@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-sw.d.ts","sourceRoot":"","sources":["../../src/relay/index-sw.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index-sw.d.ts","sourceRoot":"","sources":["../../src/relay/index-sw.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,GAAG,MAAM,IAAI,CA4ElF"}
|
package/dist/relay/index.d.ts
CHANGED
|
@@ -3,18 +3,31 @@ import type { MessageTarget } from "../core/message-target.js";
|
|
|
3
3
|
export * from "./split-service-url.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns a MessagePort that transparently bridges messages to/from the
|
|
6
|
-
* ServiceWorker controlling
|
|
6
|
+
* page's ServiceWorker: the one controlling the page, or — when the page is
|
|
7
|
+
* not controlled (a hard reload, or a page Firefox left uncontrolled) — the
|
|
8
|
+
* active worker of `registration`, which answers messages all the same.
|
|
7
9
|
*/
|
|
8
|
-
export declare function newServiceWorkerPort(): MessagePort;
|
|
10
|
+
export declare function newServiceWorkerPort(registration?: ServiceWorkerRegistration): MessagePort;
|
|
9
11
|
export interface InitServiceWorkerOptions {
|
|
10
12
|
swUrl: string;
|
|
11
13
|
scopeUrl?: string;
|
|
12
14
|
type?: WorkerType;
|
|
15
|
+
/**
|
|
16
|
+
* Upper bound, in ms, for the wait for the worker to activate; past it the
|
|
17
|
+
* promise rejects with a `ServiceWorkerControlError`. Default
|
|
18
|
+
* `DEFAULT_SERVICE_WORKER_TIMEOUT` (30 s).
|
|
19
|
+
*/
|
|
20
|
+
timeout?: number;
|
|
13
21
|
}
|
|
14
22
|
/**
|
|
15
|
-
* Registers a ServiceWorker and resolves once it
|
|
23
|
+
* Registers a ServiceWorker and resolves with it once it is activated: the
|
|
24
|
+
* worker controlling the page, or the registration's active worker when the
|
|
25
|
+
* page is not controlled. Messaging works either way, which is all the relay
|
|
26
|
+
* needs; nothing here waits for control, because an uncontrolled page (hard
|
|
27
|
+
* reload; Firefox) may never get it. Rejects with a
|
|
28
|
+
* `ServiceWorkerControlError` if activation takes longer than `timeout`.
|
|
16
29
|
*/
|
|
17
|
-
export declare function initServiceWorker(
|
|
30
|
+
export declare function initServiceWorker(options: InitServiceWorkerOptions): Promise<ServiceWorker>;
|
|
18
31
|
export interface ServiceOptions {
|
|
19
32
|
key: string;
|
|
20
33
|
port: MessageTarget;
|
|
@@ -32,13 +45,17 @@ export declare function callHttpService(request: Request, { key, port }: Service
|
|
|
32
45
|
export interface RelayWindowHandlerOptions {
|
|
33
46
|
swUrl?: string;
|
|
34
47
|
scopeUrl?: string;
|
|
48
|
+
/** Passed to `initServiceWorker`: how long to wait for the relay worker to activate. */
|
|
49
|
+
timeout?: number;
|
|
35
50
|
}
|
|
36
51
|
/**
|
|
37
52
|
* Returns a `window.onmessage` handler for use inside the relay iframe:
|
|
38
53
|
* it accepts a CONNECT message, starts the relay ServiceWorker, and bridges
|
|
39
|
-
* the parent's MessagePort with the SW.
|
|
54
|
+
* the parent's MessagePort with the SW. If the worker cannot be started, every
|
|
55
|
+
* call the parent makes on that port is answered with the error, so the
|
|
56
|
+
* parent's `initHttpService` / `callHttpService` reject instead of waiting.
|
|
40
57
|
*/
|
|
41
|
-
export declare function getRelayWindowMessageHandler({ swUrl, scopeUrl, }?: RelayWindowHandlerOptions): (ev: MessageEvent) => Promise<void>;
|
|
58
|
+
export declare function getRelayWindowMessageHandler({ swUrl, scopeUrl, timeout, }?: RelayWindowHandlerOptions): (ev: MessageEvent) => Promise<void>;
|
|
42
59
|
export interface RemoteRelayChannelOptions {
|
|
43
60
|
baseUrl?: URL;
|
|
44
61
|
url?: URL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/relay/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/relay/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,cAAc,wBAAwB,CAAC;AAavC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,CAAC,EAAE,yBAAyB,GAAG,WAAW,CAU1F;AAED,MAAM,WAAW,wBAAwB;IACv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