Repository navigation
Version Packages - #464
Merged
Merged
Version Packages#464
Conversation
Contributor
Benchmarks: Patchwork with this PR against main
This run fails: the PR fails 3 checks main passes.
every benchmark: the median of 3 runs of main and 3 runs of the PR, their range in brackets
|
Contributor
🪡 PatchworkTorn down. |
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.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@inkandswitch/patchwork-bootloader@0.8.7
Patch Changes
bedd49b: Classic automerge-repo sync connects from the tab's own Repo instead of the automerge worker, so a worker restart no longer drops it and tabs no longer ask the replacement to connect again.
connectClassicSyncin@inkandswitch/patchwork-bootloadernow takes the Repo:connectClassicSync(repo, server?).setupServiceWorker()no longer returnsconnectClassicSync.patchwork.sw.connectClassicSync(server?)works as before. TheConnectClassicSyncMessagetype is gone.bedd49b: The automerge worker no longer measures package memory. Removed: the
@patchwork/package-memorychannel and its message types (PACKAGE_MEMORY_CHANNEL,PackageMemoryRequestMessage,PackageMemoryDocument,PackageMemoryAcceptedMessage,PackageMemoryReplyMessage), and the records a restarting worker saved for its replacement (LOADED_CACHE). The service worker clears that cache along with every other cache but its own.packageDocumentsis gone from@inkandswitch/patchwork-filesystem; nothing else walked a package.c9d2f39: Every tab is its own Subduction node again, with its own socket to the sync server. The sync node in the automerge worker is gone. When the worker restarts (to recycle its wasm memory, for a new build, or after a trap), it takes only its resolver Repo with it. Before, every restart threw away the node every tab synced through, and each tab had to reconnect and resubscribe. The worker's resolver Repo has its own socket too.
The automerge worker still holds
AUTOMERGE_WORKER_LOCKfor as long as it lives. The lock now does one thing: it lets tabs and the service worker tell when the worker has died. A replacement no longer waits for it before it builds its Repo, answers handoffs or announces itselfonline. An instance that's restarting already stops taking handoffs and package-memory requests, so the two don't answer at once.Removed from
@inkandswitch/patchwork-bootloader:getSyncRemote,watchDocument,relayKeyhiveand thePortSyncRemotetype. PasssubductionWebsocketEndpoints: [syncServerUrl]to the Repo instead ofsubductionRemote: getSyncRemote(). On keyhive sites, usenew Repo(config)directly rather than wrapping it inrelayKeyhive.loadKeyhiveSigneris gone from@inkandswitch/patchwork-bootloader/signer.startWorkerControlno longer returnsholding.Tabs still follow package docs without loading them.
watchDocument(repo, url, onChange), now exported from@inkandswitch/patchwork, subscribes to the document through the tab's own Subduction connection and listens on the origin's heads channel. Every Repo relays the server's heads there, so the watcher hears both the server's pushes and other tabs' writes.onChange(seen)gets the same summaryModuleWatcheralready compares, so a repeat costs no lookup. Subduction can't unsubscribe from a single document, so afterunwatch()the server keeps pushing it to that tab until the connection drops.a12981b: A build emits every file the automerge worker and the page load under a content-hashed name in
/assets, servedimmutable, instead of at a fixed path: the/packages/…chunks,automerge.wasm,subduction.wasm,keyhive_wasm.wasm, the worker's second stage (automerge-protocol-handler.js) andmodule-loader-worker.js. A fixed path could only be revalidated, which fails offline, or cached on a guess, which after a deploy could start the worker on one build's files and the rest of another's. Now a build only ever loads its own copies, and they start offline from the HTTP cache.Only
service-worker.jsand the automerge worker's script,automerge-protocol-handler-worker.js, keep their fixed paths, since the browser starts both by URL from one build to the next. The worker's script is servedmax-age=0, stale-while-revalidate=31536000, so the browser starts it from its copy when it can't check for a newer one. Everything that copy imports is hashed, so even a copy from an older build brings up one whole build. A worker that restarts because a newer tab connected fetches its script past the cache first, so the replacement starts on the newer build rather than the cached one, which would carry on serving the newer tab.The fixed paths still work: the generated
_redirectssends each one to its hashed name with a 302, andvite previewdoes the same, whether or not the site writes Netlify files. But a module imported both by a fixed path and by its hashed name is two modules, so code should import the packages by bare specifier (the import map points at the hashed names) and load the rest by the URLs in@inkandswitch/patchwork-bootloader/emitted:AUTOMERGE_WASM,SUBDUCTION_WASM,KEYHIVE_WASM,AUTOMERGE_PROTOCOL_HANDLERandMODULE_LOADER_WORKER. In dev these are the fixed paths.API changes:
emitWasmAssets(@inkandswitch/patchwork-bootloader/externals) emits the wasm under hashed names and returns each one's reference id by file name.@inkandswitch/patchwork/vitehas ahashed()plugin, included inpatchwork(), which swaps in the hashed names.hashedFiles(config)gives a build's table of them, also exported from@inkandswitch/patchwork/vite/hashed.workersentries say whether a worker ishashed. The workers no longer import the packages from/packages/…URLs: they link to the build's chunks like the page does.buildHeaders(options, hashed?)takes that table for the wasm preloads.buildRedirects(hashed?)writes the redirects.REVALIDATED_PATHSandREVALIDATED_CACHE_CONTROLname the stale-while-revalidate files and their header.The e2e offline test waits for the wasm by the URLs the page preloads.
bedd49b: The service worker asks a tab to resolve
automerge:requests before falling back to the automerge worker. Every tab is its own node with its own Repo, so the tab that made a request can usually answer it from documents it already holds.The service worker asks the tab that made the request first, then any other open tab (focused first, then visible). This covers requests from the module-loader worker and navigations, which have no window of their own. Only when no tab can answer does it broadcast to the automerge worker, which now handles just those requests.
The tab replies
acceptedstraight away, orunavailableif it has no Repo yet. A tab that says nothing within 250ms is passed over. That number is provisional: the service worker logs each tab's accept latency underpatchwork:serviceworker, to measure from. A tab that has accepted holds a Web Lock for that one request until it has replied. If the lock is released with no reply, the tab has gone (closed, crashed, navigated away) and the next candidate is asked.New in
@inkandswitch/patchwork-bootloader:resolveHandoffsWith(repo)makes this tab answer withrepo.@inkandswitch/patchworkcalls it with the Repo it creates; a site that passes its own Repo isn't asked and keeps resolving through the automerge worker. The resolving code the worker used is shared by both, inresolver.ts. The new messages areResolveRequestMessage,ResolveAcceptedMessageandResolveUnavailableMessage.a12981b: Fixes to how the automerge worker recycles itself to give back wasm memory:
patchwork-package-memory, nowLOADED_CACHEin the bootloader's types). It cleared every cache but its own on each activation, so the replacement never had anything to restore.a12981b: The automerge worker's resolver Repo is on
self.repoagain from the moment the worker starts, for the console. The Repo is only built once something has to be resolved, so until then readingself.repostarts building it and gives its promise.await repoworks either way.Updated dependencies [bedd49b]
Updated dependencies [c9d2f39]
@inkandswitch/patchwork-filesystem@0.2.16
Patch Changes
bedd49b: The automerge worker no longer measures package memory. Removed: the
@patchwork/package-memorychannel and its message types (PACKAGE_MEMORY_CHANNEL,PackageMemoryRequestMessage,PackageMemoryDocument,PackageMemoryAcceptedMessage,PackageMemoryReplyMessage), and the records a restarting worker saved for its replacement (LOADED_CACHE). The service worker clears that cache along with every other cache but its own.packageDocumentsis gone from@inkandswitch/patchwork-filesystem; nothing else walked a package.c9d2f39: Every tab is its own Subduction node again, with its own socket to the sync server. The sync node in the automerge worker is gone. When the worker restarts (to recycle its wasm memory, for a new build, or after a trap), it takes only its resolver Repo with it. Before, every restart threw away the node every tab synced through, and each tab had to reconnect and resubscribe. The worker's resolver Repo has its own socket too.
The automerge worker still holds
AUTOMERGE_WORKER_LOCKfor as long as it lives. The lock now does one thing: it lets tabs and the service worker tell when the worker has died. A replacement no longer waits for it before it builds its Repo, answers handoffs or announces itselfonline. An instance that's restarting already stops taking handoffs and package-memory requests, so the two don't answer at once.Removed from
@inkandswitch/patchwork-bootloader:getSyncRemote,watchDocument,relayKeyhiveand thePortSyncRemotetype. PasssubductionWebsocketEndpoints: [syncServerUrl]to the Repo instead ofsubductionRemote: getSyncRemote(). On keyhive sites, usenew Repo(config)directly rather than wrapping it inrelayKeyhive.loadKeyhiveSigneris gone from@inkandswitch/patchwork-bootloader/signer.startWorkerControlno longer returnsholding.Tabs still follow package docs without loading them.
watchDocument(repo, url, onChange), now exported from@inkandswitch/patchwork, subscribes to the document through the tab's own Subduction connection and listens on the origin's heads channel. Every Repo relays the server's heads there, so the watcher hears both the server's pushes and other tabs' writes.onChange(seen)gets the same summaryModuleWatcheralready compares, so a repeat costs no lookup. Subduction can't unsubscribe from a single document, so afterunwatch()the server keeps pushing it to that tab until the connection drops.@inkandswitch/patchwork@0.8.8
Patch Changes
bedd49b: Classic automerge-repo sync connects from the tab's own Repo instead of the automerge worker, so a worker restart no longer drops it and tabs no longer ask the replacement to connect again.
connectClassicSyncin@inkandswitch/patchwork-bootloadernow takes the Repo:connectClassicSync(repo, server?).setupServiceWorker()no longer returnsconnectClassicSync.patchwork.sw.connectClassicSync(server?)works as before. TheConnectClassicSyncMessagetype is gone.c9d2f39: Every tab is its own Subduction node again, with its own socket to the sync server. The sync node in the automerge worker is gone. When the worker restarts (to recycle its wasm memory, for a new build, or after a trap), it takes only its resolver Repo with it. Before, every restart threw away the node every tab synced through, and each tab had to reconnect and resubscribe. The worker's resolver Repo has its own socket too.
The automerge worker still holds
AUTOMERGE_WORKER_LOCKfor as long as it lives. The lock now does one thing: it lets tabs and the service worker tell when the worker has died. A replacement no longer waits for it before it builds its Repo, answers handoffs or announces itselfonline. An instance that's restarting already stops taking handoffs and package-memory requests, so the two don't answer at once.Removed from
@inkandswitch/patchwork-bootloader:getSyncRemote,watchDocument,relayKeyhiveand thePortSyncRemotetype. PasssubductionWebsocketEndpoints: [syncServerUrl]to the Repo instead ofsubductionRemote: getSyncRemote(). On keyhive sites, usenew Repo(config)directly rather than wrapping it inrelayKeyhive.loadKeyhiveSigneris gone from@inkandswitch/patchwork-bootloader/signer.startWorkerControlno longer returnsholding.Tabs still follow package docs without loading them.
watchDocument(repo, url, onChange), now exported from@inkandswitch/patchwork, subscribes to the document through the tab's own Subduction connection and listens on the origin's heads channel. Every Repo relays the server's heads there, so the watcher hears both the server's pushes and other tabs' writes.onChange(seen)gets the same summaryModuleWatcheralready compares, so a repeat costs no lookup. Subduction can't unsubscribe from a single document, so afterunwatch()the server keeps pushing it to that tab until the connection drops.a12981b: A build emits every file the automerge worker and the page load under a content-hashed name in
/assets, servedimmutable, instead of at a fixed path: the/packages/…chunks,automerge.wasm,subduction.wasm,keyhive_wasm.wasm, the worker's second stage (automerge-protocol-handler.js) andmodule-loader-worker.js. A fixed path could only be revalidated, which fails offline, or cached on a guess, which after a deploy could start the worker on one build's files and the rest of another's. Now a build only ever loads its own copies, and they start offline from the HTTP cache.Only
service-worker.jsand the automerge worker's script,automerge-protocol-handler-worker.js, keep their fixed paths, since the browser starts both by URL from one build to the next. The worker's script is servedmax-age=0, stale-while-revalidate=31536000, so the browser starts it from its copy when it can't check for a newer one. Everything that copy imports is hashed, so even a copy from an older build brings up one whole build. A worker that restarts because a newer tab connected fetches its script past the cache first, so the replacement starts on the newer build rather than the cached one, which would carry on serving the newer tab.The fixed paths still work: the generated
_redirectssends each one to its hashed name with a 302, andvite previewdoes the same, whether or not the site writes Netlify files. But a module imported both by a fixed path and by its hashed name is two modules, so code should import the packages by bare specifier (the import map points at the hashed names) and load the rest by the URLs in@inkandswitch/patchwork-bootloader/emitted:AUTOMERGE_WASM,SUBDUCTION_WASM,KEYHIVE_WASM,AUTOMERGE_PROTOCOL_HANDLERandMODULE_LOADER_WORKER. In dev these are the fixed paths.API changes:
emitWasmAssets(@inkandswitch/patchwork-bootloader/externals) emits the wasm under hashed names and returns each one's reference id by file name.@inkandswitch/patchwork/vitehas ahashed()plugin, included inpatchwork(), which swaps in the hashed names.hashedFiles(config)gives a build's table of them, also exported from@inkandswitch/patchwork/vite/hashed.workersentries say whether a worker ishashed. The workers no longer import the packages from/packages/…URLs: they link to the build's chunks like the page does.buildHeaders(options, hashed?)takes that table for the wasm preloads.buildRedirects(hashed?)writes the redirects.REVALIDATED_PATHSandREVALIDATED_CACHE_CONTROLname the stale-while-revalidate files and their header.The e2e offline test waits for the wasm by the URLs the page preloads.
bedd49b: The shipped automerge-repo patch no longer adds
subductionRemote, the option that let a Repo sync through another node; nothing uses it since every tab became its own node again. TheSubductionRemote,SubductionRemoteHandlersandSubductionRemoteSyncResulttypes are gone, as are theSubductionStorageBridge,INTERCEPTOR_PREFIXandSubductionConnectionsexports.subductionSaveThrottlestays. A site applying the patch from@inkandswitch/patchwork/dist/patchesshould take the new one.bedd49b: The service worker asks a tab to resolve
automerge:requests before falling back to the automerge worker. Every tab is its own node with its own Repo, so the tab that made a request can usually answer it from documents it already holds.The service worker asks the tab that made the request first, then any other open tab (focused first, then visible). This covers requests from the module-loader worker and navigations, which have no window of their own. Only when no tab can answer does it broadcast to the automerge worker, which now handles just those requests.
The tab replies
acceptedstraight away, orunavailableif it has no Repo yet. A tab that says nothing within 250ms is passed over. That number is provisional: the service worker logs each tab's accept latency underpatchwork:serviceworker, to measure from. A tab that has accepted holds a Web Lock for that one request until it has replied. If the lock is released with no reply, the tab has gone (closed, crashed, navigated away) and the next candidate is asked.New in
@inkandswitch/patchwork-bootloader:resolveHandoffsWith(repo)makes this tab answer withrepo.@inkandswitch/patchworkcalls it with the Repo it creates; a site that passes its own Repo isn't asked and keeps resolving through the automerge worker. The resolving code the worker used is shared by both, inresolver.ts. The new messages areResolveRequestMessage,ResolveAcceptedMessageandResolveUnavailableMessage.Updated dependencies [bedd49b]
Updated dependencies [bedd49b]
Updated dependencies [c9d2f39]
Updated dependencies [a12981b]
Updated dependencies [bedd49b]
Updated dependencies [a12981b]
Updated dependencies [a12981b]
@inkandswitch/patchwork-e2e@0.2.4
Patch Changes
a12981b: A build emits every file the automerge worker and the page load under a content-hashed name in
/assets, servedimmutable, instead of at a fixed path: the/packages/…chunks,automerge.wasm,subduction.wasm,keyhive_wasm.wasm, the worker's second stage (automerge-protocol-handler.js) andmodule-loader-worker.js. A fixed path could only be revalidated, which fails offline, or cached on a guess, which after a deploy could start the worker on one build's files and the rest of another's. Now a build only ever loads its own copies, and they start offline from the HTTP cache.Only
service-worker.jsand the automerge worker's script,automerge-protocol-handler-worker.js, keep their fixed paths, since the browser starts both by URL from one build to the next. The worker's script is servedmax-age=0, stale-while-revalidate=31536000, so the browser starts it from its copy when it can't check for a newer one. Everything that copy imports is hashed, so even a copy from an older build brings up one whole build. A worker that restarts because a newer tab connected fetches its script past the cache first, so the replacement starts on the newer build rather than the cached one, which would carry on serving the newer tab.The fixed paths still work: the generated
_redirectssends each one to its hashed name with a 302, andvite previewdoes the same, whether or not the site writes Netlify files. But a module imported both by a fixed path and by its hashed name is two modules, so code should import the packages by bare specifier (the import map points at the hashed names) and load the rest by the URLs in@inkandswitch/patchwork-bootloader/emitted:AUTOMERGE_WASM,SUBDUCTION_WASM,KEYHIVE_WASM,AUTOMERGE_PROTOCOL_HANDLERandMODULE_LOADER_WORKER. In dev these are the fixed paths.API changes:
emitWasmAssets(@inkandswitch/patchwork-bootloader/externals) emits the wasm under hashed names and returns each one's reference id by file name.@inkandswitch/patchwork/vitehas ahashed()plugin, included inpatchwork(), which swaps in the hashed names.hashedFiles(config)gives a build's table of them, also exported from@inkandswitch/patchwork/vite/hashed.workersentries say whether a worker ishashed. The workers no longer import the packages from/packages/…URLs: they link to the build's chunks like the page does.buildHeaders(options, hashed?)takes that table for the wasm preloads.buildRedirects(hashed?)writes the redirects.REVALIDATED_PATHSandREVALIDATED_CACHE_CONTROLname the stale-while-revalidate files and their header.The e2e offline test waits for the wasm by the URLs the page preloads.