@actcore/web-runtime 0.1.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.
Files changed (59) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +148 -0
  3. package/dist/cache.d.ts +70 -0
  4. package/dist/cache.d.ts.map +1 -0
  5. package/dist/cache.js +0 -0
  6. package/dist/cache.js.map +1 -0
  7. package/dist/host-api.d.ts +81 -0
  8. package/dist/host-api.d.ts.map +1 -0
  9. package/dist/host-api.js +46 -0
  10. package/dist/host-api.js.map +1 -0
  11. package/dist/index.d.ts +30 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +23 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/locale.d.ts +32 -0
  16. package/dist/locale.d.ts.map +1 -0
  17. package/dist/locale.js +64 -0
  18. package/dist/locale.js.map +1 -0
  19. package/dist/patches.d.ts +38 -0
  20. package/dist/patches.d.ts.map +1 -0
  21. package/dist/patches.js +76 -0
  22. package/dist/patches.js.map +1 -0
  23. package/dist/shims/sockets.d.ts +130 -0
  24. package/dist/shims/sockets.d.ts.map +1 -0
  25. package/dist/shims/sockets.js +128 -0
  26. package/dist/shims/sockets.js.map +1 -0
  27. package/dist/shims/wasi-http-internal.d.ts +7 -0
  28. package/dist/shims/wasi-http-internal.d.ts.map +1 -0
  29. package/dist/shims/wasi-http-internal.js +19 -0
  30. package/dist/shims/wasi-http-internal.js.map +1 -0
  31. package/dist/shims/wasi-http.d.ts +83 -0
  32. package/dist/shims/wasi-http.d.ts.map +1 -0
  33. package/dist/shims/wasi-http.js +452 -0
  34. package/dist/shims/wasi-http.js.map +1 -0
  35. package/dist/streaming-fallback.d.ts +16 -0
  36. package/dist/streaming-fallback.d.ts.map +1 -0
  37. package/dist/streaming-fallback.js +52 -0
  38. package/dist/streaming-fallback.js.map +1 -0
  39. package/dist/timing.d.ts +22 -0
  40. package/dist/timing.d.ts.map +1 -0
  41. package/dist/timing.js +48 -0
  42. package/dist/timing.js.map +1 -0
  43. package/dist/transpile.d.ts +10 -0
  44. package/dist/transpile.d.ts.map +1 -0
  45. package/dist/transpile.js +277 -0
  46. package/dist/transpile.js.map +1 -0
  47. package/dist/transpile.worker.d.ts +36 -0
  48. package/dist/transpile.worker.d.ts.map +1 -0
  49. package/dist/transpile.worker.js +43 -0
  50. package/dist/transpile.worker.js.map +1 -0
  51. package/dist/version.d.ts +2 -0
  52. package/dist/version.d.ts.map +1 -0
  53. package/dist/version.js +5 -0
  54. package/dist/version.js.map +1 -0
  55. package/dist/webmcp.d.ts +92 -0
  56. package/dist/webmcp.d.ts.map +1 -0
  57. package/dist/webmcp.js +189 -0
  58. package/dist/webmcp.js.map +1 -0
  59. package/package.json +69 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Runtime patches applied to a jco-transpiled entry-module source string.
3
+ *
4
+ * History: under jco 1.19 this file carried eight patches working around
5
+ * wasip3-async bugs in jco's emitted code, plus a hand-rolled lift (`lift.ts`)
6
+ * that walked `act:tools` task-return records out of linear memory because jco
7
+ * mis-decoded the flat-fields ABI. The jco 1.20→1.24 upgrade (bindgen
8
+ * 1.17→2.0.3) fixed all of them upstream. Verified by transpiling real
9
+ * components (`time.wasm`, `http-client.wasm`) with jco 1.24.3 and running them
10
+ * under JSPI: the anchors are gone or the declarations now emitted, and the
11
+ * native lift returns correct results (tool descriptions, option/variant
12
+ * shapes, metadata, and error events all decode correctly):
13
+ *
14
+ * - STREAM_TABLES / FUTURE_TABLES now declared (jco 1.20, PR #1464)
15
+ * - `class HostFuture` now emitted (jco 1.20+)
16
+ * - host-imported resource lowers now populated (no more throw-stubs)
17
+ * - `rscTableCreateOwn` reshaped, resource origination tracked at runtime
18
+ * - `StreamWritableEnd.write` count reshaped
19
+ * - async-import `resultPtr: params[0]` → direct-param lifts (bindgen 2.0)
20
+ * - `_liftFlatU{8,16,32}` storageLen accounting fixed (jco 1.23.1)
21
+ * - flat-fields `act:tools` task-return lift (bindgen 2.0 — `lift.ts`
22
+ * deleted; the custom lift now produces *worse* output than jco's native one)
23
+ *
24
+ * What remains is one defensive splice: short-circuiting future/stream drops
25
+ * whose wasm-side end was already transferred. It only matters for components
26
+ * importing wasi:http p3 (futures/streams in request/response bodies), goes
27
+ * through `replaceOrWarn` so a moved anchor warns instead of silently no-opping,
28
+ * and is a no-op for components that don't use host-boundary futures/streams.
29
+ */
30
+ export function applyPatches(src) {
31
+ let out = src;
32
+ // PATCH: wit-bindgen Rust's future/stream destructor emits
33
+ // `{future,stream}-drop-{readable,writable}(idx)` even after the end has been
34
+ // transferred (e.g. into a `request.new` trailers param), at which point the
35
+ // wasm-side handle is 0. jco's drop helpers then crash on the missing handle.
36
+ // Short-circuit drops with idx=0 — the host already owns the end (or it never
37
+ // existed), so there is nothing to drop on the wasm side. These helpers are
38
+ // only emitted when the component uses futures/streams over the host
39
+ // boundary, so a miss is expected for plain components (e.g. time.wasm) and
40
+ // not flagged.
41
+ for (const fn of [
42
+ 'function futureDropReadable(ctx, futureEndWaitableIdx) {',
43
+ 'function futureDropWritable(ctx, futureEndWaitableIdx) {',
44
+ 'function streamDropReadable(ctx, streamEndWaitableIdx) {',
45
+ 'function streamDropWritable(ctx, streamEndWaitableIdx) {',
46
+ ]) {
47
+ if (out.includes(fn)) {
48
+ out = out.replace(fn, fn + '\n if (!arguments[1]) return;');
49
+ }
50
+ }
51
+ return out;
52
+ }
53
+ /**
54
+ * Bare-specifier imports for `@bytecodealliance/preview2-shim/*` are emitted
55
+ * by jco's transpile (matching the `map` option we pass), but ES modules
56
+ * loaded from blob: URLs can't see the document's importmap. Rewrite to
57
+ * absolute URLs in-place.
58
+ */
59
+ export function rewriteBareImports(src, shimBase) {
60
+ const base = shimBase.endsWith('/') ? shimBase : shimBase + '/';
61
+ const mapping = {
62
+ '@bytecodealliance/preview2-shim/cli': base + 'cli.js',
63
+ '@bytecodealliance/preview2-shim/clocks': base + 'clocks.js',
64
+ '@bytecodealliance/preview2-shim/io': base + 'io.js',
65
+ '@bytecodealliance/preview2-shim/filesystem': base + 'filesystem.js',
66
+ '@bytecodealliance/preview2-shim/http': base + 'http.js',
67
+ '@bytecodealliance/preview2-shim/random': base + 'random.js',
68
+ '@bytecodealliance/preview2-shim/sockets': base + 'sockets.js',
69
+ };
70
+ let out = src;
71
+ for (const [spec, url] of Object.entries(mapping)) {
72
+ out = out.replaceAll(`'${spec}'`, `'${url}'`).replaceAll(`"${spec}"`, `"${url}"`);
73
+ }
74
+ return out;
75
+ }
76
+ //# sourceMappingURL=patches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patches.js","sourceRoot":"","sources":["../src/patches.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,IAAI,GAAG,GAAG,GAAG,CAAC;IAEd,2DAA2D;IAC3D,8EAA8E;IAC9E,6EAA6E;IAC7E,8EAA8E;IAC9E,8EAA8E;IAC9E,4EAA4E;IAC5E,qEAAqE;IACrE,4EAA4E;IAC5E,eAAe;IACf,KAAK,MAAM,EAAE,IAAI;QACf,0DAA0D;QAC1D,0DAA0D;QAC1D,0DAA0D;QAC1D,0DAA0D;KAC3D,EAAE,CAAC;QACF,IAAI,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;YACrB,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,kCAAkC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,QAAgB;IAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC;IAChE,MAAM,OAAO,GAA2B;QACtC,qCAAqC,EAAE,IAAI,GAAG,QAAQ;QACtD,wCAAwC,EAAE,IAAI,GAAG,WAAW;QAC5D,oCAAoC,EAAE,IAAI,GAAG,OAAO;QACpD,4CAA4C,EAAE,IAAI,GAAG,eAAe;QACpE,sCAAsC,EAAE,IAAI,GAAG,SAAS;QACxD,wCAAwC,EAAE,IAAI,GAAG,WAAW;QAC5D,yCAAyC,EAAE,IAAI,GAAG,YAAY;KAC/D,CAAC;IAEF,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAClD,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,EAAE,IAAI,GAAG,GAAG,CAAC,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,EAAE,IAAI,GAAG,GAAG,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Browser wasi:sockets shim for @actcore/web-runtime.
3
+ *
4
+ * preview2-shim's browser build ships wasi:sockets as method-only stub objects
5
+ * that OMIT the resource-class constructors (ResolveAddressStream, Network,
6
+ * TcpSocket, UdpSocket, IncomingDatagramStream, OutgoingDatagramStream). jco's
7
+ * generated glue destructures those classes at instantiation
8
+ * (`const { ResolveAddressStream } = ipNameLookup`) and throws
9
+ * "unexpectedly undefined local import" if they're missing — which any
10
+ * wasi:http-importing component (whose wasip3 world transitively pulls in
11
+ * wasi:sockets) triggers even when it never touches the network.
12
+ *
13
+ * This shim provides the full export surface WITH the resource classes as inert
14
+ * stubs. Sockets/DNS are never actually exercised by the pure-compute components
15
+ * we run in the tab; the constructors only need to EXIST so instantiation
16
+ * succeeds. host-browser routes `wasi:sockets/*` here (see transpile.ts) instead
17
+ * of at the preview2-shim base.
18
+ *
19
+ * DENY, DON'T CRASH: the three resource-creation entry points below —
20
+ * `resolveAddresses` (DNS), `createTcpSocket`, `createUdpSocket` — are the only
21
+ * ways guest code can ever obtain a live socket/lookup resource; every other
22
+ * method in this file is unreachable unless one of those three succeeds. Their
23
+ * WIT signatures return `result<_, error-code>`, and jco's generated glue wraps
24
+ * each call in `try { ... } catch (e) { ret = { tag: 'err', val:
25
+ * getErrorPayload(e) } }` — but `getErrorPayload` only treats `e` as the error
26
+ * payload if `e` is NOT a plain `Error` (a thrown `Error` gets RE-THROWN
27
+ * uncaught instead of becoming a clean `result::err`, verified by reading the
28
+ * transpiled glue). So denial must throw the raw `error-code` string value
29
+ * (e.g. `'access-denied'`), never `new Error(...)` — a plain Error here
30
+ * doesn't deny the call, it corrupts the CPython/JSPI interpreter state
31
+ * (`Fatal Python error: ... the GIL is released`), which is worse than useless
32
+ * for a "sealed sandbox" story. Everything else in this file stays a bare
33
+ * no-op stub: unreachable code, so its shape doesn't matter.
34
+ *
35
+ * `instance-network()` is the one exception to "deny at the entry point": its
36
+ * WIT signature is `func() -> network` — no `result<>`, so it has NO error
37
+ * channel at all (getting the ambient network capability TOKEN is defined to
38
+ * never fail; the denial belongs at the point that token is actually used).
39
+ * It must return a real `Network` instance — returning `undefined` fails the
40
+ * caller's `instanceof Network` check with an uncaught "Resource error: Not a
41
+ * valid Network resource", which (same as above) never reaches Python as a
42
+ * clean exception. `Network` is declared once here so `instanceNetwork()` and
43
+ * `network.Network` share the identical class the generated glue checks
44
+ * `instanceof` against.
45
+ */
46
+ declare function denyAccess(): never;
47
+ declare class Network {
48
+ }
49
+ export declare const instanceNetwork: {
50
+ instanceNetwork(): Network;
51
+ };
52
+ export declare const ipNameLookup: {
53
+ ResolveAddressStream: {
54
+ new (): {};
55
+ };
56
+ dropResolveAddressStream(): void;
57
+ subscribe(): void;
58
+ resolveAddresses: typeof denyAccess;
59
+ resolveNextAddress(): void;
60
+ nonBlocking(): void;
61
+ setNonBlocking(): void;
62
+ };
63
+ export declare const network: {
64
+ Network: typeof Network;
65
+ dropNetwork(): void;
66
+ };
67
+ export declare const tcpCreateSocket: {
68
+ createTcpSocket: typeof denyAccess;
69
+ };
70
+ export declare const tcp: {
71
+ TcpSocket: {
72
+ new (): {};
73
+ };
74
+ subscribe(): void;
75
+ dropTcpSocket(): void;
76
+ bind(): void;
77
+ connect(): void;
78
+ listen(): void;
79
+ accept(): void;
80
+ localAddress(): void;
81
+ remoteAddress(): void;
82
+ addressFamily(): void;
83
+ setListenBacklogSize(): void;
84
+ keepAlive(): void;
85
+ setKeepAlive(): void;
86
+ noDelay(): void;
87
+ setNoDelay(): void;
88
+ unicastHopLimit(): void;
89
+ setUnicastHopLimit(): void;
90
+ receiveBufferSize(): void;
91
+ setReceiveBufferSize(): void;
92
+ sendBufferSize(): void;
93
+ setSendBufferSize(): void;
94
+ nonBlocking(): void;
95
+ setNonBlocking(): void;
96
+ shutdown(): void;
97
+ };
98
+ export declare const udpCreateSocket: {
99
+ createUdpSocket: typeof denyAccess;
100
+ };
101
+ export declare const udp: {
102
+ UdpSocket: {
103
+ new (): {};
104
+ };
105
+ IncomingDatagramStream: {
106
+ new (): {};
107
+ };
108
+ OutgoingDatagramStream: {
109
+ new (): {};
110
+ };
111
+ subscribe(): void;
112
+ dropUdpSocket(): void;
113
+ bind(): void;
114
+ connect(): void;
115
+ receive(): void;
116
+ send(): void;
117
+ localAddress(): void;
118
+ remoteAddress(): void;
119
+ addressFamily(): void;
120
+ unicastHopLimit(): void;
121
+ setUnicastHopLimit(): void;
122
+ receiveBufferSize(): void;
123
+ setReceiveBufferSize(): void;
124
+ sendBufferSize(): void;
125
+ setSendBufferSize(): void;
126
+ nonBlocking(): void;
127
+ setNonBlocking(): void;
128
+ };
129
+ export {};
130
+ //# sourceMappingURL=sockets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sockets.d.ts","sourceRoot":"","sources":["../../src/shims/sockets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,iBAAS,UAAU,IAAI,KAAK,CAE3B;AAED,cAAM,OAAO;CAAG;AAEhB,eAAO,MAAM,eAAe;;CAI3B,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;CAQxB,CAAC;AAEF,eAAO,MAAM,OAAO;;;CAGnB,CAAC;AAEF,eAAO,MAAM,eAAe;;CAE3B,CAAC;AAEF,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBf,CAAC;AAEF,eAAO,MAAM,eAAe;;CAE3B,CAAC;AAEF,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBf,CAAC"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Browser wasi:sockets shim for @actcore/web-runtime.
3
+ *
4
+ * preview2-shim's browser build ships wasi:sockets as method-only stub objects
5
+ * that OMIT the resource-class constructors (ResolveAddressStream, Network,
6
+ * TcpSocket, UdpSocket, IncomingDatagramStream, OutgoingDatagramStream). jco's
7
+ * generated glue destructures those classes at instantiation
8
+ * (`const { ResolveAddressStream } = ipNameLookup`) and throws
9
+ * "unexpectedly undefined local import" if they're missing — which any
10
+ * wasi:http-importing component (whose wasip3 world transitively pulls in
11
+ * wasi:sockets) triggers even when it never touches the network.
12
+ *
13
+ * This shim provides the full export surface WITH the resource classes as inert
14
+ * stubs. Sockets/DNS are never actually exercised by the pure-compute components
15
+ * we run in the tab; the constructors only need to EXIST so instantiation
16
+ * succeeds. host-browser routes `wasi:sockets/*` here (see transpile.ts) instead
17
+ * of at the preview2-shim base.
18
+ *
19
+ * DENY, DON'T CRASH: the three resource-creation entry points below —
20
+ * `resolveAddresses` (DNS), `createTcpSocket`, `createUdpSocket` — are the only
21
+ * ways guest code can ever obtain a live socket/lookup resource; every other
22
+ * method in this file is unreachable unless one of those three succeeds. Their
23
+ * WIT signatures return `result<_, error-code>`, and jco's generated glue wraps
24
+ * each call in `try { ... } catch (e) { ret = { tag: 'err', val:
25
+ * getErrorPayload(e) } }` — but `getErrorPayload` only treats `e` as the error
26
+ * payload if `e` is NOT a plain `Error` (a thrown `Error` gets RE-THROWN
27
+ * uncaught instead of becoming a clean `result::err`, verified by reading the
28
+ * transpiled glue). So denial must throw the raw `error-code` string value
29
+ * (e.g. `'access-denied'`), never `new Error(...)` — a plain Error here
30
+ * doesn't deny the call, it corrupts the CPython/JSPI interpreter state
31
+ * (`Fatal Python error: ... the GIL is released`), which is worse than useless
32
+ * for a "sealed sandbox" story. Everything else in this file stays a bare
33
+ * no-op stub: unreachable code, so its shape doesn't matter.
34
+ *
35
+ * `instance-network()` is the one exception to "deny at the entry point": its
36
+ * WIT signature is `func() -> network` — no `result<>`, so it has NO error
37
+ * channel at all (getting the ambient network capability TOKEN is defined to
38
+ * never fail; the denial belongs at the point that token is actually used).
39
+ * It must return a real `Network` instance — returning `undefined` fails the
40
+ * caller's `instanceof Network` check with an uncaught "Resource error: Not a
41
+ * valid Network resource", which (same as above) never reaches Python as a
42
+ * clean exception. `Network` is declared once here so `instanceNetwork()` and
43
+ * `network.Network` share the identical class the generated glue checks
44
+ * `instanceof` against.
45
+ */
46
+ function denyAccess() {
47
+ throw 'access-denied';
48
+ }
49
+ class Network {
50
+ }
51
+ export const instanceNetwork = {
52
+ instanceNetwork() {
53
+ return new Network();
54
+ },
55
+ };
56
+ export const ipNameLookup = {
57
+ ResolveAddressStream: class ResolveAddressStream {
58
+ },
59
+ dropResolveAddressStream() { },
60
+ subscribe() { },
61
+ resolveAddresses: denyAccess,
62
+ resolveNextAddress() { },
63
+ nonBlocking() { },
64
+ setNonBlocking() { },
65
+ };
66
+ export const network = {
67
+ Network,
68
+ dropNetwork() { },
69
+ };
70
+ export const tcpCreateSocket = {
71
+ createTcpSocket: denyAccess,
72
+ };
73
+ export const tcp = {
74
+ TcpSocket: class TcpSocket {
75
+ },
76
+ subscribe() { },
77
+ dropTcpSocket() { },
78
+ bind() { },
79
+ connect() { },
80
+ listen() { },
81
+ accept() { },
82
+ localAddress() { },
83
+ remoteAddress() { },
84
+ addressFamily() { },
85
+ setListenBacklogSize() { },
86
+ keepAlive() { },
87
+ setKeepAlive() { },
88
+ noDelay() { },
89
+ setNoDelay() { },
90
+ unicastHopLimit() { },
91
+ setUnicastHopLimit() { },
92
+ receiveBufferSize() { },
93
+ setReceiveBufferSize() { },
94
+ sendBufferSize() { },
95
+ setSendBufferSize() { },
96
+ nonBlocking() { },
97
+ setNonBlocking() { },
98
+ shutdown() { },
99
+ };
100
+ export const udpCreateSocket = {
101
+ createUdpSocket: denyAccess,
102
+ };
103
+ export const udp = {
104
+ UdpSocket: class UdpSocket {
105
+ },
106
+ IncomingDatagramStream: class IncomingDatagramStream {
107
+ },
108
+ OutgoingDatagramStream: class OutgoingDatagramStream {
109
+ },
110
+ subscribe() { },
111
+ dropUdpSocket() { },
112
+ bind() { },
113
+ connect() { },
114
+ receive() { },
115
+ send() { },
116
+ localAddress() { },
117
+ remoteAddress() { },
118
+ addressFamily() { },
119
+ unicastHopLimit() { },
120
+ setUnicastHopLimit() { },
121
+ receiveBufferSize() { },
122
+ setReceiveBufferSize() { },
123
+ sendBufferSize() { },
124
+ setSendBufferSize() { },
125
+ nonBlocking() { },
126
+ setNonBlocking() { },
127
+ };
128
+ //# sourceMappingURL=sockets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sockets.js","sourceRoot":"","sources":["../../src/shims/sockets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,SAAS,UAAU;IACjB,MAAM,eAAe,CAAC;AACxB,CAAC;AAED,MAAM,OAAO;CAAG;AAEhB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,eAAe;QACb,OAAO,IAAI,OAAO,EAAE,CAAC;IACvB,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,oBAAoB,EAAE,MAAM,oBAAoB;KAAG;IACnD,wBAAwB,KAAI,CAAC;IAC7B,SAAS,KAAI,CAAC;I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AAC;IACZ,OAAO,KAAI,CAAC;IACZ,IAAI,KAAI,CAAC;IACT,YAAY,KAAI,CAAC;IACjB,aAAa,KAAI,CAAC;IAClB,aAAa,KAAI,CAAC;IAClB,eAAe,KAAI,CAAC;IACpB,kBAAkB,KAAI,CAAC;IACvB,iBAAiB,KAAI,CAAC;IACtB,oBAAoB,KAAI,CAAC;IACzB,cAAc,KAAI,CAAC;IACnB,iBAAiB,KAAI,CAAC;IACtB,WAAW,KAAI,CAAC;IAChB,cAAc,KAAI,CAAC;CACpB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ErrorCode as GenErrorCode } from '../generated/interfaces/wasi-http-types.js';
2
+ export type ErrorCode = GenErrorCode;
3
+ export declare function internalError(msg: string): ErrorCode;
4
+ export declare const TOKEN_RE: RegExp;
5
+ export declare const FIELD_VALUE_RE: RegExp;
6
+ export declare const FORBIDDEN: Set<string>;
7
+ //# sourceMappingURL=wasi-http-internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasi-http-internal.d.ts","sourceRoot":"","sources":["../../src/shims/wasi-http-internal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,SAAS,IAAI,YAAY,EAC1B,MAAM,4CAA4C,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG,YAAY,CAAC;AAErC,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAEpD;AAGD,eAAO,MAAM,QAAQ,QAAmC,CAAC;AAGzD,eAAO,MAAM,cAAc,QAA8B,CAAC;AAE1D,eAAO,MAAM,SAAS,aAIpB,CAAC"}
@@ -0,0 +1,19 @@
1
+ // Internal helpers + WIT-mapped TS types not exported from jco's gen-types.
2
+ // jco-generated types live in src/generated/interfaces/wasi-http-{types,client}.d.ts
3
+ // and govern the public shim surface; this file holds private types and
4
+ // validation helpers used inside the shim.
5
+ export function internalError(msg) {
6
+ return { tag: 'internal-error', val: msg };
7
+ }
8
+ // RFC 9110 token: 1*tchar
9
+ export const TOKEN_RE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
10
+ // RFC 9110 field-value: any VCHAR / OWS / obs-text. We allow tab, printable
11
+ // ASCII, and obs-text (0x80-0xFF). No CR/LF.
12
+ export const FIELD_VALUE_RE = /^[\t\x20-\x7E\x80-\xFF]*$/;
13
+ // Hop-by-hop / connection-management headers a guest cannot set.
14
+ export const FORBIDDEN = new Set([
15
+ 'connection',
16
+ 'keep-alive',
17
+ 'host',
18
+ ]);
19
+ //# sourceMappingURL=wasi-http-internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasi-http-internal.js","sourceRoot":"","sources":["../../src/shims/wasi-http-internal.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,qFAAqF;AACrF,wEAAwE;AACxE,2CAA2C;AAQ3C,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC7C,CAAC;AAED,0BAA0B;AAC1B,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,4EAA4E;AAC5E,6CAA6C;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,2BAA2B,CAAC;AAC1D,iEAAiE;AACjE,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IAC/B,YAAY;IACZ,YAAY;IACZ,MAAM;CACP,CAAC,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { type ErrorCode } from './wasi-http-internal.js';
2
+ import type { Duration, FieldName, FieldValue, Method, Scheme, StatusCode, Result } from '../generated/interfaces/wasi-http-types.js';
3
+ type Headers = Fields;
4
+ type Trailers = Fields;
5
+ export declare class Fields {
6
+ #private;
7
+ constructor();
8
+ static fromList(entries: Array<[FieldName, FieldValue]>): Fields;
9
+ get(name: FieldName): Array<FieldValue>;
10
+ has(name: FieldName): boolean;
11
+ set(name: FieldName, value: Array<FieldValue>): void;
12
+ 'delete'(name: FieldName): void;
13
+ getAndDelete(name: FieldName): Array<FieldValue>;
14
+ append(name: FieldName, value: FieldValue): void;
15
+ copyAll(): Array<[FieldName, FieldValue]>;
16
+ clone(): Fields;
17
+ _lockInternal(): void;
18
+ }
19
+ export declare class RequestOptions {
20
+ #private;
21
+ constructor();
22
+ getConnectTimeout(): Duration | undefined;
23
+ setConnectTimeout(duration: Duration | undefined): void;
24
+ getFirstByteTimeout(): Duration | undefined;
25
+ setFirstByteTimeout(duration: Duration | undefined): void;
26
+ getBetweenBytesTimeout(): Duration | undefined;
27
+ setBetweenBytesTimeout(duration: Duration | undefined): void;
28
+ clone(): RequestOptions;
29
+ _lockInternal(): void;
30
+ }
31
+ export declare class Request {
32
+ method: Method;
33
+ pathWithQuery: string | undefined;
34
+ scheme: Scheme | undefined;
35
+ authority: string | undefined;
36
+ headers: Fields;
37
+ body: ReadableStream<number> | undefined;
38
+ trailers: Promise<Result<Trailers | undefined, ErrorCode>>;
39
+ options: RequestOptions | undefined;
40
+ private constructor();
41
+ static 'new'(headers: Headers, contents: ReadableStream<number> | undefined, trailers: Promise<Result<Trailers | undefined, ErrorCode>>, options: RequestOptions | undefined): [Request, Promise<Result<void, ErrorCode>>];
42
+ getMethod(): Method;
43
+ setMethod(method: Method): void;
44
+ getPathWithQuery(): string | undefined;
45
+ setPathWithQuery(pathWithQuery: string | undefined): void;
46
+ getScheme(): Scheme | undefined;
47
+ setScheme(scheme: Scheme | undefined): void;
48
+ getAuthority(): string | undefined;
49
+ setAuthority(authority: string | undefined): void;
50
+ getOptions(): RequestOptions | undefined;
51
+ getHeaders(): Headers;
52
+ static consumeBody(this_: Request, _res: Promise<Result<void, ErrorCode>>): [
53
+ ReadableStream<number>,
54
+ Promise<Result<Trailers | undefined, ErrorCode>>
55
+ ];
56
+ }
57
+ export declare class Response {
58
+ statusCode: StatusCode;
59
+ headers: Fields;
60
+ body: ReadableStream<number> | undefined;
61
+ _bufferedBody: Uint8Array | undefined;
62
+ trailers: Promise<Result<Trailers | undefined, ErrorCode>>;
63
+ private constructor();
64
+ static 'new'(headers: Headers, contents: ReadableStream<number> | undefined, trailers: Promise<Result<Trailers | undefined, ErrorCode>>): [Response, Promise<Result<void, ErrorCode>>];
65
+ getStatusCode(): StatusCode;
66
+ setStatusCode(statusCode: StatusCode): void;
67
+ getHeaders(): Headers;
68
+ static consumeBody(this_: Response, _res: Promise<Result<void, ErrorCode>>): [
69
+ ReadableStream<number>,
70
+ Promise<Result<Trailers | undefined, ErrorCode>>
71
+ ];
72
+ }
73
+ export declare const types: {
74
+ Fields: typeof Fields;
75
+ Request: typeof Request;
76
+ RequestOptions: typeof RequestOptions;
77
+ Response: typeof Response;
78
+ };
79
+ export declare const client: {
80
+ send(request: Request): Promise<Response>;
81
+ };
82
+ export type { ErrorCode };
83
+ //# sourceMappingURL=wasi-http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasi-http.d.ts","sourceRoot":"","sources":["../../src/shims/wasi-http.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,MAAM,EACN,MAAM,EACN,UAAU,EACV,MAAM,EACP,MAAM,4CAA4C,CAAC;AAQpD,KAAK,OAAO,GAAG,MAAM,CAAC;AACtB,KAAK,QAAQ,GAAG,MAAM,CAAC;AASvB,qBAAa,MAAM;;;IAWjB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,GAAG,MAAM;IAMhE,GAAG,CAAC,IAAI,EAAE,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC;IAIvC,GAAG,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAI7B,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI;IA2BpD,QAAQ,CAAC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