@statewalker/webrun-http-browser 0.7.0 → 0.9.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/dist/index.js +946 -120
- package/dist/link/async-dispose.d.ts +10 -0
- package/dist/link/async-dispose.d.ts.map +1 -0
- package/dist/link/http-link.d.ts +16 -2
- package/dist/link/http-link.d.ts.map +1 -1
- package/dist/relay-sw.js +809 -132
- package/dist/relay-worker.js +809 -132
- package/dist/sw/protocol.d.ts +2 -0
- package/dist/sw/protocol.d.ts.map +1 -1
- package/dist/sw/sw-http-adapter.d.ts +2 -0
- package/dist/sw/sw-http-adapter.d.ts.map +1 -1
- package/dist/sw/worker-service.d.ts.map +1 -1
- package/dist/sw-worker.js +929 -118
- package/dist/sw.js +942 -119
- package/dist/worker.js +938 -119
- package/package.json +4 -4
- package/src/link/async-dispose.ts +22 -0
- package/src/link/http-link.ts +64 -12
- package/src/sw/protocol.ts +4 -3
- package/src/sw/sw-http-adapter.ts +7 -0
- package/src/sw/worker-service.ts +14 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes `target` disposable with `await using`: installs `dispose` as its
|
|
3
|
+
* `[Symbol.asyncDispose]`, where the runtime defines the symbol. Hand-written
|
|
4
|
+
* iterators lose what a native generator gets from `AsyncIteratorPrototype`;
|
|
5
|
+
* this gives it back. A no-op where the symbol is missing. Kept off the
|
|
6
|
+
* declared types, which would require consumers to compile with the
|
|
7
|
+
* `esnext.disposable` lib.
|
|
8
|
+
*/
|
|
9
|
+
export declare function asyncDisposable<T extends object>(target: T, dispose: () => Promise<unknown>): T;
|
|
10
|
+
//# sourceMappingURL=async-dispose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-dispose.d.ts","sourceRoot":"","sources":["../../src/link/async-dispose.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAa/F"}
|
package/dist/link/http-link.d.ts
CHANGED
|
@@ -15,6 +15,20 @@ export interface HttpLinkOptions {
|
|
|
15
15
|
* none: a slow consumer is throttled, never failed.
|
|
16
16
|
*/
|
|
17
17
|
streamTimeout?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Ceiling on the requests in flight on the link at once: webrun-rpc's
|
|
20
|
+
* `maxPorts`, one multiplexed port per request (default 1024). A request
|
|
21
|
+
* past it fails on the calling end; one the answering end has no room for is
|
|
22
|
+
* refused. Every exchange gives its port back when it ends, however it ends.
|
|
23
|
+
*/
|
|
24
|
+
maxPorts?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The answering end only: once a response is out, how long the request body
|
|
27
|
+
* may go unread before it is abandoned and the exchange ends (default 30 s;
|
|
28
|
+
* webrun-http-streams' `requestIdleMs`). A handler that answers first and
|
|
29
|
+
* reads the upload afterwards keeps it as long as it keeps reading.
|
|
30
|
+
*/
|
|
31
|
+
requestIdleMs?: number;
|
|
18
32
|
}
|
|
19
33
|
/** The calling end of a link: sends requests, gets responses. */
|
|
20
34
|
export interface HttpLink {
|
|
@@ -43,13 +57,13 @@ export declare class LinkLostError extends Error {
|
|
|
43
57
|
constructor(message?: string);
|
|
44
58
|
}
|
|
45
59
|
/** Opens the calling end of a link on `port` (one port per link). */
|
|
46
|
-
export declare function connectHttpLink(port: MessagePort, { streamTimeout }?: HttpLinkOptions): Promise<HttpLink>;
|
|
60
|
+
export declare function connectHttpLink(port: MessagePort, { streamTimeout, maxPorts }?: HttpLinkOptions): Promise<HttpLink>;
|
|
47
61
|
/**
|
|
48
62
|
* Serves `handler` on the answering end of a link. Resolves with a teardown
|
|
49
63
|
* that abandons the requests still running (their handlers see the
|
|
50
64
|
* cancellation) and releases the port.
|
|
51
65
|
*/
|
|
52
|
-
export declare function serveHttpLink(port: MessagePort, handler: (request: Request) => Response | Promise<Response>, { streamTimeout }?: HttpLinkOptions): Promise<() => Promise<void>>;
|
|
66
|
+
export declare function serveHttpLink(port: MessagePort, handler: (request: Request) => Response | Promise<Response>, { streamTimeout, maxPorts, requestIdleMs }?: HttpLinkOptions): Promise<() => Promise<void>>;
|
|
53
67
|
/**
|
|
54
68
|
* Wraps a `send` so the link knows its requests in flight (for draining and
|
|
55
69
|
* load-based routing) and can fail them all at once when it is closed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-link.d.ts","sourceRoot":"","sources":["../../src/link/http-link.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-link.d.ts","sourceRoot":"","sources":["../../src/link/http-link.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,iEAAiE;AACjE,MAAM,WAAW,QAAQ;IACvB,0EAA0E;IAC1E,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAO,SAAuD,EAGzE;CACF;AASD,qEAAqE;AACrE,wBAAsB,eAAe,CACnC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