@ohos-ports/serwist-window 9.5.12-beta.1
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/chunks/isCurrentPageOutOfScope-BF6DLxHk.js +15 -0
- package/dist/chunks/isCurrentPageOutOfScope-BF6DLxHk.js.map +1 -0
- package/dist/index.d.mts +374 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.internal.d.mts +5 -0
- package/dist/index.internal.d.mts.map +1 -0
- package/dist/index.internal.mjs +6 -0
- package/dist/index.mjs +554 -0
- package/dist/index.mjs.map +1 -0
- package/dist/ohos-node-shim.mjs +297 -0
- package/package.json +75 -0
- package/src/Serwist.ts +688 -0
- package/src/index.internal.ts +8 -0
- package/src/index.ts +20 -0
- package/src/messageSW.ts +33 -0
- package/src/utils/SerwistEvent.ts +57 -0
- package/src/utils/SerwistEventTarget.ts +68 -0
- package/src/utils/isCurrentPageOutOfScope.ts +10 -0
- package/src/utils/ohosNodeShim.ts +308 -0
- package/src/utils/urlsMatch.ts +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2023 Google LLC, 2019-2023 ShadowWalker w@weiw.io https://weiw.io, 2020-2023 Anthony Fu <https://github.com/antfu>, 2023-PRESENT Serwist
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This module's documentation can be found at https://serwist.pages.dev/docs/window.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/utils/isCurrentPageOutOfScope.ts
|
|
2
|
+
const isCurrentPageOutOfScope = (scope) => {
|
|
3
|
+
// Guard: scope checks are non-blocking and only meaningful in a browser
|
|
4
|
+
// document context; treat the page as in-scope when DOM globals are absent.
|
|
5
|
+
if (typeof document === "undefined" || typeof location === "undefined") {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const scopeURL = new URL(scope, document.baseURI);
|
|
9
|
+
const scopeURLBasePath = new URL("./", scopeURL.href).pathname;
|
|
10
|
+
return !location.pathname.startsWith(scopeURLBasePath);
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isCurrentPageOutOfScope as t };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=isCurrentPageOutOfScope-BF6DLxHk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCurrentPageOutOfScope-BF6DLxHk.js","names":[],"sources":["../../src/utils/isCurrentPageOutOfScope.ts"],"sourcesContent":["export const isCurrentPageOutOfScope = (scope: string) => {\n const scopeURL = new URL(scope, document.baseURI);\n const scopeURLBasePath = new URL(\"./\", scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n};\n"],"mappings":";AAAA,MAAa,2BAA2B,UAAkB;CACxD,MAAM,WAAW,IAAI,IAAI,OAAO,SAAS,OAAO;CAChD,MAAM,mBAAmB,IAAI,IAAI,MAAM,SAAS,IAAI,CAAC,CAAC;CACtD,OAAO,CAAC,SAAS,SAAS,WAAW,gBAAgB;AACvD"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
//#region src/messageSW.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Sends a data object to a service worker via `postMessage` and resolves with
|
|
4
|
+
* a response (if any).
|
|
5
|
+
*
|
|
6
|
+
* A response can be sent by calling `event.ports[0].postMessage(...)`, which will
|
|
7
|
+
* resolve the promise returned by `messageSW()`. If no response is sent, the promise
|
|
8
|
+
* will never resolve.
|
|
9
|
+
*
|
|
10
|
+
* @param sw The service worker to send the message to.
|
|
11
|
+
* @param data An object to send to the service worker.
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
declare const messageSW: (sw: ServiceWorker, data: any) => Promise<any>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/utils/SerwistEvent.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* A minimal `Event` subclass shim.
|
|
19
|
+
* This doesn't *actually* subclass `Event` because not all browsers support
|
|
20
|
+
* constructable `EventTarget`, and using a real `Event` will error.
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
declare class SerwistEvent<K extends keyof SerwistEventMap> {
|
|
24
|
+
type: K;
|
|
25
|
+
target?: SerwistEventTarget;
|
|
26
|
+
sw?: ServiceWorker;
|
|
27
|
+
originalEvent?: Event;
|
|
28
|
+
isExternal?: boolean;
|
|
29
|
+
constructor(type: K, props: Omit<SerwistEventMap[K], "target" | "type">);
|
|
30
|
+
}
|
|
31
|
+
interface SerwistMessageEvent extends SerwistEvent<"message"> {
|
|
32
|
+
data: any;
|
|
33
|
+
originalEvent: Event;
|
|
34
|
+
ports: readonly MessagePort[];
|
|
35
|
+
}
|
|
36
|
+
interface SerwistLifecycleEvent extends SerwistEvent<keyof SerwistLifecycleEventMap> {
|
|
37
|
+
isUpdate?: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface SerwistLifecycleWaitingEvent extends SerwistLifecycleEvent {
|
|
40
|
+
wasWaitingBeforeRegister?: boolean;
|
|
41
|
+
}
|
|
42
|
+
interface SerwistLifecycleEventMap {
|
|
43
|
+
installing: SerwistLifecycleEvent;
|
|
44
|
+
installed: SerwistLifecycleEvent;
|
|
45
|
+
waiting: SerwistLifecycleWaitingEvent;
|
|
46
|
+
activating: SerwistLifecycleEvent;
|
|
47
|
+
activated: SerwistLifecycleEvent;
|
|
48
|
+
controlling: SerwistLifecycleEvent;
|
|
49
|
+
redundant: SerwistLifecycleEvent;
|
|
50
|
+
}
|
|
51
|
+
interface SerwistEventMap extends SerwistLifecycleEventMap {
|
|
52
|
+
message: SerwistMessageEvent;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/utils/SerwistEventTarget.d.ts
|
|
56
|
+
/**
|
|
57
|
+
* A minimal `EventTarget` shim.
|
|
58
|
+
* This is necessary because not all browsers support constructable
|
|
59
|
+
* `EventTarget`, so using a real `EventTarget` will error.
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
declare class SerwistEventTarget {
|
|
63
|
+
private readonly _eventListenerRegistry;
|
|
64
|
+
/**
|
|
65
|
+
* @param type
|
|
66
|
+
* @param listener
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
addEventListener<K extends keyof SerwistEventMap>(type: K, listener: (event: SerwistEventMap[K]) => any): void;
|
|
70
|
+
/**
|
|
71
|
+
* @param type
|
|
72
|
+
* @param listener
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
removeEventListener<K extends keyof SerwistEventMap>(type: K, listener: (event: SerwistEventMap[K]) => any): void;
|
|
76
|
+
/**
|
|
77
|
+
* @param event
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
dispatchEvent(event: SerwistEvent<any>): void;
|
|
81
|
+
/**
|
|
82
|
+
* Returns a Set of listeners associated with the passed event type.
|
|
83
|
+
* If no handlers have been registered, an empty Set is returned.
|
|
84
|
+
*
|
|
85
|
+
* @param type The event type.
|
|
86
|
+
* @returns An array of handler functions.
|
|
87
|
+
* @private
|
|
88
|
+
*/
|
|
89
|
+
private _getEventListenersByType;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/Serwist.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* A class to aid in handling service worker registration, updates, and
|
|
95
|
+
* reacting to service worker lifecycle events.
|
|
96
|
+
*
|
|
97
|
+
* @fires `@serwist/window.Serwist.message`
|
|
98
|
+
* @fires `@serwist/window.Serwist.installed`
|
|
99
|
+
* @fires `@serwist/window.Serwist.waiting`
|
|
100
|
+
* @fires `@serwist/window.Serwist.controlling`
|
|
101
|
+
* @fires `@serwist/window.Serwist.activated`
|
|
102
|
+
* @fires `@serwist/window.Serwist.redundant`
|
|
103
|
+
*/
|
|
104
|
+
declare class Serwist extends SerwistEventTarget {
|
|
105
|
+
private readonly _scriptURL;
|
|
106
|
+
private readonly _registerOptions;
|
|
107
|
+
private _updateFoundCount;
|
|
108
|
+
private readonly _swDeferred;
|
|
109
|
+
private readonly _activeDeferred;
|
|
110
|
+
private readonly _controllingDeferred;
|
|
111
|
+
private _registrationTime;
|
|
112
|
+
private _isUpdate?;
|
|
113
|
+
private _compatibleControllingSW?;
|
|
114
|
+
private _registration?;
|
|
115
|
+
private _sw?;
|
|
116
|
+
private readonly _ownSWs;
|
|
117
|
+
private _externalSW?;
|
|
118
|
+
private _waitingTimeout?;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a new Serwist instance with a script URL and service worker
|
|
121
|
+
* options. The script URL and options are the same as those used when
|
|
122
|
+
* calling [navigator.serviceWorker.register(scriptURL, options)](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register).
|
|
123
|
+
*
|
|
124
|
+
* @param scriptURL The service worker script associated with this instance. Using a
|
|
125
|
+
* [`TrustedScriptURL`](https://developer.mozilla.org/en-US/docs/Web/API/TrustedScriptURL) is supported.
|
|
126
|
+
* @param registerOptions The service worker options associated with this instance.
|
|
127
|
+
*/
|
|
128
|
+
constructor(scriptURL: string | TrustedScriptURL, registerOptions?: RegistrationOptions);
|
|
129
|
+
/**
|
|
130
|
+
* Registers a service worker for this instances script URL and service
|
|
131
|
+
* worker options. By default this method delays registration until after
|
|
132
|
+
* the window has loaded.
|
|
133
|
+
*
|
|
134
|
+
* @param options
|
|
135
|
+
*/
|
|
136
|
+
register({ immediate }?: {
|
|
137
|
+
/**
|
|
138
|
+
* Setting this to true will register the service worker immediately,
|
|
139
|
+
* even if the window has not loaded (not recommended).
|
|
140
|
+
*/
|
|
141
|
+
immediate?: boolean;
|
|
142
|
+
}): Promise<ServiceWorkerRegistration | undefined>;
|
|
143
|
+
/**
|
|
144
|
+
* Checks for updates of the registered service worker.
|
|
145
|
+
*/
|
|
146
|
+
update(): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Resolves to the service worker registered by this instance as soon as it
|
|
149
|
+
* is active. If a service worker was already controlling at registration
|
|
150
|
+
* time then it will resolve to that if the script URLs (and optionally
|
|
151
|
+
* script versions) match, otherwise it will wait until an update is found
|
|
152
|
+
* and activates.
|
|
153
|
+
*
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
get active(): Promise<ServiceWorker>;
|
|
157
|
+
/**
|
|
158
|
+
* Resolves to the service worker registered by this instance as soon as it
|
|
159
|
+
* is controlling the page. If a service worker was already controlling at
|
|
160
|
+
* registration time then it will resolve to that if the script URLs (and
|
|
161
|
+
* optionally script versions) match, otherwise it will wait until an update
|
|
162
|
+
* is found and starts controlling the page.
|
|
163
|
+
* Note: the first time a service worker is installed it will active but
|
|
164
|
+
* not start controlling the page unless `clients.claim()` is called in the
|
|
165
|
+
* service worker.
|
|
166
|
+
*
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
get controlling(): Promise<ServiceWorker>;
|
|
170
|
+
/**
|
|
171
|
+
* Resolves with a reference to a service worker that matches the script URL
|
|
172
|
+
* of this instance, as soon as it's available.
|
|
173
|
+
*
|
|
174
|
+
* If, at registration time, there's already an active or waiting service
|
|
175
|
+
* worker with a matching script URL, it will be used (with the waiting
|
|
176
|
+
* service worker taking precedence over the active service worker if both
|
|
177
|
+
* match, since the waiting service worker would have been registered more
|
|
178
|
+
* recently).
|
|
179
|
+
* If there's no matching active or waiting service worker at registration
|
|
180
|
+
* time then the promise will not resolve until an update is found and starts
|
|
181
|
+
* installing, at which point the installing service worker is used.
|
|
182
|
+
*
|
|
183
|
+
* @returns
|
|
184
|
+
*/
|
|
185
|
+
getSW(): Promise<ServiceWorker>;
|
|
186
|
+
/**
|
|
187
|
+
* Sends the passed data object to the service worker registered by this
|
|
188
|
+
* instance (via `getSW`) and resolves with a response (if any).
|
|
189
|
+
*
|
|
190
|
+
* A response can be sent by calling `event.ports[0].postMessage(...)`, which will
|
|
191
|
+
* resolve the promise returned by `messageSW()`. If no response is sent, the promise
|
|
192
|
+
* will never resolve.
|
|
193
|
+
*
|
|
194
|
+
* @param data An object to send to the service worker
|
|
195
|
+
* @returns
|
|
196
|
+
*/
|
|
197
|
+
messageSW(data: any): Promise<any>;
|
|
198
|
+
/**
|
|
199
|
+
* Sends a `{ type: "SKIP_WAITING" }` message to the service worker that is
|
|
200
|
+
* currently waiting and associated with the current registration.
|
|
201
|
+
*
|
|
202
|
+
* If there is no current registration, or no service worker is waiting,
|
|
203
|
+
* calling this will have no effect.
|
|
204
|
+
*/
|
|
205
|
+
messageSkipWaiting(): void;
|
|
206
|
+
/**
|
|
207
|
+
* Checks for a service worker already controlling the page and returns
|
|
208
|
+
* it if its script URL matches.
|
|
209
|
+
*
|
|
210
|
+
* @private
|
|
211
|
+
* @returns
|
|
212
|
+
*/
|
|
213
|
+
private _getControllingSWIfCompatible;
|
|
214
|
+
/**
|
|
215
|
+
* Registers a service worker for this instances script URL and register
|
|
216
|
+
* options and tracks the time registration was complete.
|
|
217
|
+
*
|
|
218
|
+
* @private
|
|
219
|
+
*/
|
|
220
|
+
private _registerScript;
|
|
221
|
+
/**
|
|
222
|
+
* @private
|
|
223
|
+
* @param originalEvent
|
|
224
|
+
*/
|
|
225
|
+
private readonly _onUpdateFound;
|
|
226
|
+
/**
|
|
227
|
+
* @private
|
|
228
|
+
* @param originalEvent
|
|
229
|
+
*/
|
|
230
|
+
private readonly _onStateChange;
|
|
231
|
+
/**
|
|
232
|
+
* @private
|
|
233
|
+
* @param originalEvent
|
|
234
|
+
*/
|
|
235
|
+
private readonly _onControllerChange;
|
|
236
|
+
/**
|
|
237
|
+
* @private
|
|
238
|
+
* @param originalEvent
|
|
239
|
+
*/
|
|
240
|
+
private readonly _onMessage;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The `message` event is dispatched any time a `postMessage` is received.
|
|
244
|
+
*
|
|
245
|
+
* @event workbox-window.Workbox#message
|
|
246
|
+
* @type {SerwistEvent}
|
|
247
|
+
* @property {*} data The `data` property from the original `message` event.
|
|
248
|
+
* @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}
|
|
249
|
+
* event.
|
|
250
|
+
* @property {string} type `message`.
|
|
251
|
+
* @property {MessagePort[]} ports The `ports` value from `originalEvent`.
|
|
252
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
253
|
+
*/
|
|
254
|
+
/**
|
|
255
|
+
* The `installed` event is dispatched if the state of a
|
|
256
|
+
* {@link workbox-window.Workbox} instance's
|
|
257
|
+
* {@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw|registered service worker}
|
|
258
|
+
* changes to `installed`.
|
|
259
|
+
*
|
|
260
|
+
* Then can happen either the very first time a service worker is installed,
|
|
261
|
+
* or after an update to the current service worker is found. In the case
|
|
262
|
+
* of an update being found, the event's `isUpdate` property will be `true`.
|
|
263
|
+
*
|
|
264
|
+
* @event workbox-window.Workbox#installed
|
|
265
|
+
* @type {SerwistEvent}
|
|
266
|
+
* @property {ServiceWorker} sw The service worker instance.
|
|
267
|
+
* @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
|
|
268
|
+
* event.
|
|
269
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
270
|
+
* controlling when this `Workbox` instance called `register()`.
|
|
271
|
+
* @property {boolean|undefined} isExternal True if this event is associated
|
|
272
|
+
* with an [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}.
|
|
273
|
+
* @property {string} type `installed`.
|
|
274
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
275
|
+
*/
|
|
276
|
+
/**
|
|
277
|
+
* The `waiting` event is dispatched if the state of a
|
|
278
|
+
* {@link workbox-window.Workbox} instance's
|
|
279
|
+
* [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
|
|
280
|
+
* changes to `installed` and then doesn't immediately change to `activating`.
|
|
281
|
+
* It may also be dispatched if a service worker with the same
|
|
282
|
+
* [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
|
|
283
|
+
* was already waiting when the {@link workbox-window.Workbox#register}
|
|
284
|
+
* method was called.
|
|
285
|
+
*
|
|
286
|
+
* @event workbox-window.Workbox#waiting
|
|
287
|
+
* @type {SerwistEvent}
|
|
288
|
+
* @property {ServiceWorker} sw The service worker instance.
|
|
289
|
+
* @property {Event|undefined} originalEvent The original
|
|
290
|
+
* [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
|
|
291
|
+
* event, or `undefined` in the case where the service worker was waiting
|
|
292
|
+
* to before `.register()` was called.
|
|
293
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
294
|
+
* controlling when this `Workbox` instance called `register()`.
|
|
295
|
+
* @property {boolean|undefined} isExternal True if this event is associated
|
|
296
|
+
* with an [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}.
|
|
297
|
+
* @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with
|
|
298
|
+
* a matching `scriptURL` was already waiting when this `Workbox`
|
|
299
|
+
* instance called `register()`.
|
|
300
|
+
* @property {string} type `waiting`.
|
|
301
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
302
|
+
*/
|
|
303
|
+
/**
|
|
304
|
+
* The `controlling` event is dispatched if a
|
|
305
|
+
* [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
|
|
306
|
+
* fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}
|
|
307
|
+
* and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
|
|
308
|
+
* of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}
|
|
309
|
+
* matches the `scriptURL` of the `Workbox` instance's
|
|
310
|
+
* [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.
|
|
311
|
+
*
|
|
312
|
+
* @event workbox-window.Workbox#controlling
|
|
313
|
+
* @type {SerwistEvent}
|
|
314
|
+
* @property {ServiceWorker} sw The service worker instance.
|
|
315
|
+
* @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
|
|
316
|
+
* event.
|
|
317
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
318
|
+
* controlling when this service worker was registered.
|
|
319
|
+
* @property {boolean|undefined} isExternal True if this event is associated
|
|
320
|
+
* with an [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}.
|
|
321
|
+
* @property {string} type `controlling`.
|
|
322
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
323
|
+
*/
|
|
324
|
+
/**
|
|
325
|
+
* The `activated` event is dispatched if the state of a
|
|
326
|
+
* {@link workbox-window.Workbox} instance's
|
|
327
|
+
* {@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw|registered service worker}
|
|
328
|
+
* changes to `activated`.
|
|
329
|
+
*
|
|
330
|
+
* @event workbox-window.Workbox#activated
|
|
331
|
+
* @type {SerwistEvent}
|
|
332
|
+
* @property {ServiceWorker} sw The service worker instance.
|
|
333
|
+
* @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
|
|
334
|
+
* event.
|
|
335
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
336
|
+
* controlling when this `Workbox` instance called `register()`.
|
|
337
|
+
* @property {boolean|undefined} isExternal True if this event is associated
|
|
338
|
+
* with an [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}.
|
|
339
|
+
* @property {string} type `activated`.
|
|
340
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
341
|
+
*/
|
|
342
|
+
/**
|
|
343
|
+
* The `redundant` event is dispatched if the state of a
|
|
344
|
+
* {@link workbox-window.Workbox} instance's
|
|
345
|
+
* [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
|
|
346
|
+
* changes to `redundant`.
|
|
347
|
+
*
|
|
348
|
+
* @event workbox-window.Workbox#redundant
|
|
349
|
+
* @type {SerwistEvent}
|
|
350
|
+
* @property {ServiceWorker} sw The service worker instance.
|
|
351
|
+
* @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
|
|
352
|
+
* event.
|
|
353
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
354
|
+
* controlling when this `Workbox` instance called `register()`.
|
|
355
|
+
* @property {string} type `redundant`.
|
|
356
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
357
|
+
*/
|
|
358
|
+
/**
|
|
359
|
+
* The `installing` event is dispatched if the service worker
|
|
360
|
+
* finds the new version and starts installing.
|
|
361
|
+
*
|
|
362
|
+
* @event workbox-window.Workbox#installing
|
|
363
|
+
* @type {SerwistEvent}
|
|
364
|
+
* @property {ServiceWorker} sw The installing service worker instance.
|
|
365
|
+
* @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
|
|
366
|
+
* event.
|
|
367
|
+
* @property {boolean|undefined} isUpdate True if a service worker was already
|
|
368
|
+
* controlling when this `Workbox` instance called `register()`.
|
|
369
|
+
* @property {string} type `installing`.
|
|
370
|
+
* @property {Workbox} target The `Workbox` instance.
|
|
371
|
+
*/
|
|
372
|
+
//#endregion
|
|
373
|
+
export { Serwist, SerwistEvent, SerwistEventMap, SerwistLifecycleEvent, SerwistLifecycleEventMap, SerwistLifecycleWaitingEvent, SerwistMessageEvent, messageSW };
|
|
374
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/messageSW.ts","../src/utils/SerwistEvent.ts","../src/utils/SerwistEventTarget.ts","../src/Serwist.ts"],"mappings":";;;;;;;;;;;;;cAoBa,YAAS,IAAQ,eAAa,cAAc;;;;;;;;;cCJ5C,aAAa,gBAAgB;EAO/B,MAAM;EANf,SAAS;EACT,KAAK;EACL,gBAAgB;EAChB;EAEA,YACS,MAAM,GACb,OAAO,KAAK,gBAAgB;;UAMf,4BAA4B;EAC3C;EACA,eAAe;EACf,gBAAgB;;UAGD,8BAA8B,mBAAmB;EAChE;;UAGe,qCAAqC;EACpD;;UAGe;EACf,YAAY;EACZ,WAAW;EACX,SAAS;EACT,YAAY;EACZ,WAAW;EACX,aAAa;EACb,WAAW;;UAGI,wBAAwB;EACvC,SAAS;;;;;;;;;;cCrCE;mBACM;;;;;;EAOjB,iBAAiB,gBAAgB,iBAAiB,MAAM,GAAG,WAAW,OAAO,gBAAgB;;;;;;EAU7F,oBAAoB,gBAAgB,iBAAiB,MAAM,GAAG,WAAW,OAAO,gBAAgB;;;;;EAQhG,cAAc,OAAO;;;;;;;;;UAiBb;;;;;;;;;;;;;;;cCpBG,gBAAgB;mBACV;mBACA;UACT;mBAGS;mBACA;mBACA;UAET;UACA;UACA;UACA;UACA;mBACS;UACT;UACA;;;;;;;;;;EAWR,YAAY,oBAAoB,kBAAkB,kBAAiB;;;;;;;;EAmB7D,WACJ;;;;;IAMA;MACO,QAAQ;;;;EA4FX,UAAU;;;;;;;;;;MAqBZ,UAAU,QAAQ;;;;;;;;;;;;;MAgBlB,eAAe,QAAQ;;;;;;;;;;;;;;;;EAmB3B,SAAS,QAAQ;;;;;;;;;;;;EAkBX,UAAU,YAAY;;;;;;;;EAY5B;;;;;;;;UAaQ;;;;;;;UAcM;;;;;mBA0BG;;;;;mBA4EA;;;;;mBA2FA;;;;;mBA6BA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.internal.d.mts","names":[],"sources":["../src/utils/isCurrentPageOutOfScope.ts"],"mappings":";cAAa,0BAAuB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// HarmonyOS Node.js platform adaptation: install browser API shims
|
|
2
|
+
// (navigator.serviceWorker, document, window, location) before the library
|
|
3
|
+
// body evaluates. No-op in real browsers.
|
|
4
|
+
import "./ohos-node-shim.mjs";
|
|
5
|
+
import { t as isCurrentPageOutOfScope } from "./chunks/isCurrentPageOutOfScope-BF6DLxHk.js";
|
|
6
|
+
export { isCurrentPageOutOfScope };
|