Repository navigation
Service worker and shared server event connections: TServiceWorkerModule, TServiceWorkerService, TWebManifest, Prado.SharedConnection (#1478) - #1486
Draft
belisoful wants to merge 5 commits into
Conversation
belisoful
force-pushed
the
claude/prado-service-worker-cbd00a
branch
from
November 7, 2026 18:29
5348a04 to
39c8eb2
Compare
belisoful
force-pushed
the
claude/prado-service-worker-cbd00a
branch
3 times, most recently
from
November 28, 2026 07:39
238501f to
a343516
Compare
…s service workers; TWebManifest links the manifest (pradosoft#1478, pradosoft#1405)
…abs of the origin (pradosoft#1478)
…s page and for runtime caches (pradosoft#1478)
belisoful
force-pushed
the
claude/prado-service-worker-cbd00a
branch
from
November 29, 2026 08:54
a343516 to
64b020d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1478. Completes the TWebManifest item of #1405. Web Push follows in #1479; #1435 will be rebased and reworked on this PR.
An application-wide browser service worker configured by one module, and one live connection per browser shared by its tabs.
Usage
What it adds
TServiceWorkerModule, the one configuration point.ServiceID="Auto"adopts anyTServiceWorkerServiceor registers one assw, likeTHttpHeadersManagerdoes forTCspReportingService.defaultworker. Each<worker>element starts from those values and overrides them.IServiceWorkerContributorand serve requests throughIServiceWorkerRequestHandler.AutoRegisteraddsTServiceWorkerandTWebManifestto the pages ofTPageService, except forExcludePages.Enabled="false"serves a worker that removes itself.ClearSiteDataOnLogouthooksTAuthManager::onLogout.A page's worker is chosen by
TServiceWorker.Worker, thenTPage.ServiceWorker(also settable from<pages>), thenTPageService.ServiceWorker, thenDefaultWorker. If that worker's scope is not the longest match for the request path (the browser's rule), the page registers nothing and the module logs a warning.TServiceWorkerServiceserves:?sw=worker[&w=name], withService-Worker-Allowed?sw=manifest, asapplication/manifest+jsonEvery response carries
Cache-Control: no-cache, anETag, and a 304 for a matchingIf-None-Match.TServiceWorkerScriptbuilds the script: the options, the runtime, then each fragment by priority. Its version is a hash of the content. Cache names areprado-<worker>-<version>-<name>, andactivatedeletes only the worker's own older caches, since workers of one origin share Cache Storage.The worker runtime (
worker.js):fetchlistener unless a fragment needs one;no-store/privateresponses;The fetch strategies fragment covers asset cache-first, network-first with a timeout, the offline page, and navigation preload.
Prado.ServiceWorker(packageserviceworker) providesregister(),postMessage()with replies,activate(), and theprado:serviceworkerready,prado:serviceworkerupdate, andprado:serviceworkermessageevents.TServiceWorkerregisters the worker as an end script. A page without aTFormrenders no end scripts, so on such a page the control writes the package files and the registration where it sits, in the head.TWebManifest(Head metadata controls: TJsonLd, TOpenGraph, TWebManifest #1405) renders:CrossOrigin);theme-color, withThemeColorDarkfor the dark scheme;application-nameandmobile-web-app-capable;With an empty
Hrefit links the page's worker manifest and takes its theme color and short name.TWebAppManifestholds the manifest members as properties, plus a JSONFileandMembers.Prado.SharedConnection(packagesharedconnection) is transport-agnostic.BroadcastChannelpasses its messages to the other tabs.pagehide, andfreeze, and the next tab resumes from the last message ID.BroadcastChannel, each tab holds its own connection.subscription.send(data)works from any tab. A non-holder posts the data to the holder, which sends it through the transport and confirms. Unconfirmed sends survive a handover (at least once), and closing rejects them.open(resumeId, emit)function returning{close()}, plussend(data)for one that sends. A WebSocket transport, such asbelisoful/prado-websocket'sprado.pubsub.v1client, plugs in through this seam; the framework carries none.eventSource()is the built-in SSE transport and uses Server push: TServerEventService and TServerEventTriggeredCallback (#1408) #1435'slastEventIdparameter.TServerEventTriggeredCallback.SharedConnectioncomes with the Server push: TServerEventService and TServerEventTriggeredCallback (#1408) #1435 rework.Small additions:
TMetaTag.Media,TMediaType::MANIFEST_JSON(.webmanifest), andTHttpHeaderNameServiceWorkerAllowed,ServiceWorkerNavigationPreload, andClearSiteData.Differences from the issue text
ClearSiteDataOnLogouttakes a list ofClear-Site-Datatypes instead of a fixed"cache". Thecachetype clears only the HTTP cache; clearing the workers' Cache Storage takesstorage.Tests
TServiceWorker,TWebManifest, plus additions to theTMetaTag,TMediaType,THttpHeaderName,TPage, andTPageServicetests. The full unit suite passes withXDEBUG_MODE=off. With local develop-mode Xdebug,TComponentBehaviorTest(2) andTTarFileExtractorUrlTestLZMA (2) fail, with or without this branch.tests/js/serviceworker/runs the runtime, strategies, and removal script as the service renders them, against a fake worker scope, and tests the page client.tests/js/sharedconnection/simulates several tabs with fake Web Locks andBroadcastChannel, including sends across a handover.callbackrequest.test.js"disabled fieldsets and options", which also fails on master locally.tests/harness/service-workerapp, which uses path URLs so the admin worker ownsindex.php/admin/:activate(), removal, and the admin worker keeping its caches through a default update.