@waffle-os/runtime 0.0.151 → 0.0.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/service-worker.ts +18 -3
- package/dist/browser/service-worker.js +9 -3
- package/dist/fs/multitab-backend.js +303 -97
- package/dist/fs/multitab-protocol.js +2 -0
- package/dist/fs/service.js +25 -3
- package/dist/tooling/program/program-transformer.json +1 -1
- package/fs/backend.ts +6 -1
- package/fs/multitab-backend.ts +385 -105
- package/fs/multitab-protocol.ts +11 -0
- package/fs/service.ts +28 -6
- package/package.json +1 -1
- package/tooling/program/program-transformer.json +1 -1
|
@@ -219,10 +219,25 @@ export function createPreviewServiceWorker(options: PreviewServiceWorkerOptions)
|
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Await activation even when the registering page is outside the worker's scope.
|
|
224
|
+
*
|
|
225
|
+
* A worker in the registration's active slot is already activating or activated, and fetches it
|
|
226
|
+
* handles wait for its activation, so it needs no wait. Only an installing or waiting worker is
|
|
227
|
+
* watched. WebKit can resolve `register()` in a second page that registered at the same moment with
|
|
228
|
+
* the active worker's state still reading "installing", and never sends that object another
|
|
229
|
+
* `statechange`; waiting on it would hang forever. A "redundant" state is still a failure: the spec
|
|
230
|
+
* queues that state update before it clears the active slot, so the two can briefly disagree.
|
|
231
|
+
*/
|
|
223
232
|
export function activated(registration: ServiceWorkerRegistration): Promise<void> {
|
|
224
|
-
const worker = registration.installing ?? registration.waiting
|
|
225
|
-
if (!worker)
|
|
233
|
+
const worker = registration.installing ?? registration.waiting;
|
|
234
|
+
if (!worker) {
|
|
235
|
+
const active = registration.active;
|
|
236
|
+
if (!active) return Promise.reject(new Error("service worker registration has no worker"));
|
|
237
|
+
if (active.state === "redundant")
|
|
238
|
+
return Promise.reject(new Error("service worker became redundant before activation"));
|
|
239
|
+
return Promise.resolve();
|
|
240
|
+
}
|
|
226
241
|
return new Promise((resolve, reject) => {
|
|
227
242
|
const check = () => {
|
|
228
243
|
if (worker.state !== "activated" && worker.state !== "redundant") return;
|
|
@@ -177,9 +177,15 @@ export function createPreviewServiceWorker(options) {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
export function activated(registration) {
|
|
180
|
-
const worker = registration.installing ?? registration.waiting
|
|
181
|
-
if (!worker)
|
|
182
|
-
|
|
180
|
+
const worker = registration.installing ?? registration.waiting;
|
|
181
|
+
if (!worker) {
|
|
182
|
+
const active = registration.active;
|
|
183
|
+
if (!active)
|
|
184
|
+
return Promise.reject(new Error("service worker registration has no worker"));
|
|
185
|
+
if (active.state === "redundant")
|
|
186
|
+
return Promise.reject(new Error("service worker became redundant before activation"));
|
|
187
|
+
return Promise.resolve();
|
|
188
|
+
}
|
|
183
189
|
return new Promise((resolve, reject) => {
|
|
184
190
|
const check = () => {
|
|
185
191
|
if (worker.state !== "activated" && worker.state !== "redundant")
|