@statewalker/webrun-http-browser 0.3.4 → 0.5.0
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/README.md +164 -6
- package/dist/core/data-channels.d.ts.map +1 -1
- package/dist/core/deadline.d.ts +7 -0
- package/dist/core/deadline.d.ts.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/message-target.d.ts +1 -15
- package/dist/core/message-target.d.ts.map +1 -1
- package/dist/core/service-worker-control.d.ts +72 -0
- package/dist/core/service-worker-control.d.ts.map +1 -0
- package/dist/http/http-send-recieve.d.ts +27 -14
- package/dist/http/http-send-recieve.d.ts.map +1 -1
- package/dist/index.js +485 -167
- package/dist/relay/index-sw.d.ts.map +1 -1
- package/dist/relay/index.d.ts +23 -6
- package/dist/relay/index.d.ts.map +1 -1
- package/dist/relay-sw.js +864 -65
- package/dist/sw/sw-dispatcher.d.ts +22 -0
- package/dist/sw/sw-dispatcher.d.ts.map +1 -1
- package/dist/sw-worker.js +869 -64
- package/dist/sw.js +1096 -106
- package/package.json +8 -3
- package/src/core/data-channels.ts +42 -4
- package/src/core/deadline.ts +31 -0
- package/src/core/index.ts +1 -0
- package/src/core/message-target.ts +8 -18
- package/src/core/service-worker-control.ts +243 -0
- package/src/http/http-send-recieve.ts +27 -14
- package/src/relay/index-sw.ts +5 -0
- package/src/relay/index.ts +65 -47
- package/src/sw/sw-dispatcher.ts +98 -46
|
@@ -3,6 +3,19 @@ export interface SwPortHandlerOptions {
|
|
|
3
3
|
scope?: string;
|
|
4
4
|
serviceWorkerUrl?: string;
|
|
5
5
|
bindPort: (port: MessagePort) => void | Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Upper bound, in ms, for `start()`'s wait for the worker to activate, take
|
|
8
|
+
* control of the page and answer the handshake. `start()` rejects with a
|
|
9
|
+
* `ServiceWorkerControlError` past it instead of waiting forever.
|
|
10
|
+
* Default `DEFAULT_SERVICE_WORKER_TIMEOUT` (30 s).
|
|
11
|
+
*/
|
|
12
|
+
timeout?: number;
|
|
13
|
+
/**
|
|
14
|
+
* If the page is still uncontrolled once the worker is active — after a
|
|
15
|
+
* hard reload, say — and the worker does not take it over when asked,
|
|
16
|
+
* reload the page once instead of rejecting. Default `false`.
|
|
17
|
+
*/
|
|
18
|
+
reloadIfUncontrolled?: boolean;
|
|
6
19
|
}
|
|
7
20
|
interface ChannelInfo {
|
|
8
21
|
key: string;
|
|
@@ -28,6 +41,15 @@ export declare class SwPortHandler {
|
|
|
28
41
|
protected _setCommunicationPort(port: MessagePort): Promise<void>;
|
|
29
42
|
protected _updateCommunicationChannel(): Promise<void>;
|
|
30
43
|
protected _getRegistrationInfo(): ChannelInfo;
|
|
44
|
+
/**
|
|
45
|
+
* Registers the worker and waits until it is activated and controls this
|
|
46
|
+
* page, then opens the port to it. The page must be controlled, because
|
|
47
|
+
* only a controlled page's `fetch()` reaches the worker. When the page
|
|
48
|
+
* loaded uncontrolled (a hard reload does that), the worker is asked to
|
|
49
|
+
* claim it. Rejects with a `ServiceWorkerControlError` when that fails or
|
|
50
|
+
* `timeout` passes (`reason` says which step); a later `start()` tries
|
|
51
|
+
* again.
|
|
52
|
+
*/
|
|
31
53
|
start(): Promise<void>;
|
|
32
54
|
stop(): Promise<void>;
|
|
33
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw-dispatcher.d.ts","sourceRoot":"","sources":["../../src/sw/sw-dispatcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sw-dispatcher.d.ts","sourceRoot":"","sources":["../../src/sw/sw-dispatcher.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IA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