cf-workers-native 0.0.0-stage → 0.1.2-beta.local.sha2f5e4e6956f4
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/Package.swift +25 -0
- package/README.md +92 -2
- package/dist/android.d.ts +2 -0
- package/dist/android.js +1 -0
- package/dist/browser/abort/index.d.ts +13 -0
- package/dist/browser/abort/index.js +66 -0
- package/dist/browser/body/index.d.ts +24 -0
- package/dist/browser/body/index.js +116 -0
- package/dist/browser/body/stream-body.d.ts +13 -0
- package/dist/browser/body/stream-body.js +84 -0
- package/dist/browser/documents/body.d.ts +3 -0
- package/dist/browser/documents/body.js +48 -0
- package/dist/browser/documents/form-body.d.ts +1 -0
- package/dist/browser/documents/form-body.js +54 -0
- package/dist/browser/documents/host.d.ts +11 -0
- package/dist/browser/documents/host.js +256 -0
- package/dist/browser/documents/links-source.d.ts +1 -0
- package/dist/browser/documents/links-source.js +1 -0
- package/dist/browser/documents/links.d.ts +1 -0
- package/dist/browser/documents/links.js +33 -0
- package/dist/browser/documents/page-config.d.ts +5 -0
- package/dist/browser/documents/page-config.js +5 -0
- package/dist/browser/documents/page-source.d.ts +1 -0
- package/dist/browser/documents/page-source.js +1 -0
- package/dist/browser/documents/page.d.ts +2 -0
- package/dist/browser/documents/page.js +153 -0
- package/dist/browser/documents/registration.d.ts +5 -0
- package/dist/browser/documents/registration.js +75 -0
- package/dist/browser/documents/runtime.d.ts +7 -0
- package/dist/browser/documents/runtime.js +161 -0
- package/dist/browser/documents/service-worker.js +285 -0
- package/dist/browser/encoding/index.d.ts +7 -0
- package/dist/browser/encoding/index.js +3 -0
- package/dist/browser/fetch/LICENSE-3RD-PARTY.md +9 -0
- package/dist/browser/fetch/LICENSE-APACHE +177 -0
- package/dist/browser/fetch/host-call.d.ts +3 -0
- package/dist/browser/fetch/host-call.js +67 -0
- package/dist/browser/fetch/index.d.ts +5 -0
- package/dist/browser/fetch/index.js +96 -0
- package/dist/browser/fetch/interop.d.ts +6 -0
- package/dist/browser/fetch/interop.js +48 -0
- package/dist/browser/fetch/native-network.d.ts +20 -0
- package/dist/browser/fetch/native-network.js +233 -0
- package/dist/browser/fetch/outbound.d.ts +2 -0
- package/dist/browser/fetch/outbound.js +11 -0
- package/dist/browser/fetch/relay.d.ts +7 -0
- package/dist/browser/fetch/relay.js +100 -0
- package/dist/browser/fetch/scope.d.ts +8 -0
- package/dist/browser/fetch/scope.js +108 -0
- package/dist/browser/fetch/transport.d.ts +39 -0
- package/dist/browser/fetch/transport.js +136 -0
- package/dist/browser/headers/LICENSE-3RD-PARTY.md +9 -0
- package/dist/browser/headers/LICENSE-APACHE +177 -0
- package/dist/browser/headers/index.d.ts +20 -0
- package/dist/browser/headers/index.js +194 -0
- package/dist/browser/isolated/bridge.d.ts +8 -0
- package/dist/browser/isolated/bridge.js +267 -0
- package/dist/browser/isolated/protocol.d.ts +40 -0
- package/dist/browser/isolated/protocol.js +1 -0
- package/dist/browser/isolated/transport.d.ts +2 -0
- package/dist/browser/isolated/transport.js +157 -0
- package/dist/browser/request/LICENSE-3RD-PARTY.md +10 -0
- package/dist/browser/request/LICENSE-APACHE +177 -0
- package/dist/browser/request/index.d.ts +48 -0
- package/dist/browser/request/index.js +182 -0
- package/dist/browser/response/LICENSE-3RD-PARTY.md +10 -0
- package/dist/browser/response/LICENSE-APACHE +177 -0
- package/dist/browser/response/index.d.ts +43 -0
- package/dist/browser/response/index.js +192 -0
- package/dist/browser/response/status.d.ts +1 -0
- package/dist/browser/response/status.js +75 -0
- package/dist/browser/structured-clone/index.d.ts +1 -0
- package/dist/browser/structured-clone/index.js +479 -0
- package/dist/cloudflare/apis/cloudflare-node/index.d.ts +18 -0
- package/dist/cloudflare/apis/cloudflare-node/index.js +150 -0
- package/dist/cloudflare/apis/cloudflare-workers/index.d.ts +8 -0
- package/dist/cloudflare/apis/cloudflare-workers/index.js +37 -0
- package/dist/cloudflare/apis/types.d.ts +7 -0
- package/dist/cloudflare/apis/types.js +1 -0
- package/dist/cloudflare/bindings/config.d.ts +42 -0
- package/dist/cloudflare/bindings/config.js +280 -0
- package/dist/cloudflare/bindings/kv/contract.d.ts +6 -0
- package/dist/cloudflare/bindings/kv/contract.js +181 -0
- package/dist/cloudflare/bindings/kv/index.d.ts +18 -0
- package/dist/cloudflare/bindings/kv/index.js +61 -0
- package/dist/cloudflare/bindings/kv/storage.d.ts +25 -0
- package/dist/cloudflare/bindings/kv/storage.js +320 -0
- package/dist/cloudflare/bindings/kv/types.d.ts +50 -0
- package/dist/cloudflare/bindings/kv/types.js +1 -0
- package/dist/cloudflare/bindings/remote.d.ts +8 -0
- package/dist/cloudflare/bindings/remote.js +261 -0
- package/dist/cloudflare/workers/contract.d.ts +8 -0
- package/dist/cloudflare/workers/contract.js +65 -0
- package/dist/cloudflare/workers/feature.d.ts +10 -0
- package/dist/cloudflare/workers/feature.js +28 -0
- package/dist/cloudflare/workers/runtime.d.ts +23 -0
- package/dist/cloudflare/workers/runtime.js +121 -0
- package/dist/cloudflare/workers/types.d.ts +49 -0
- package/dist/cloudflare/workers/types.js +1 -0
- package/dist/cloudflare/workers/worker-runtime.d.ts +44 -0
- package/dist/cloudflare/workers/worker-runtime.js +267 -0
- package/dist/compat/assert/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/assert/LICENSE-APACHE +177 -0
- package/dist/compat/assert/assertion-error.d.ts +26 -0
- package/dist/compat/assert/assertion-error.js +468 -0
- package/dist/compat/assert/diff.d.ts +26 -0
- package/dist/compat/assert/diff.js +329 -0
- package/dist/compat/assert/errors.d.ts +11 -0
- package/dist/compat/assert/errors.js +55 -0
- package/dist/compat/assert/index.cjs +24 -0
- package/dist/compat/assert/index.d.cts +43 -0
- package/dist/compat/assert/index.d.ts +50 -0
- package/dist/compat/assert/index.js +858 -0
- package/dist/compat/async-hooks/LICENSE-APACHE +177 -0
- package/dist/compat/async-hooks/NOTICE.md +8 -0
- package/dist/compat/async-hooks/callbacks.d.ts +7 -0
- package/dist/compat/async-hooks/callbacks.js +18 -0
- package/dist/compat/async-hooks/hooks.d.ts +10 -0
- package/dist/compat/async-hooks/hooks.js +111 -0
- package/dist/compat/async-hooks/index.d.ts +41 -0
- package/dist/compat/async-hooks/index.js +298 -0
- package/dist/compat/buffer/LICENSE-3RD-PARTY.md +15 -0
- package/dist/compat/buffer/LICENSE-APACHE +177 -0
- package/dist/compat/buffer/blob.d.ts +22 -0
- package/dist/compat/buffer/blob.js +210 -0
- package/dist/compat/buffer/bytes.d.ts +34 -0
- package/dist/compat/buffer/bytes.js +228 -0
- package/dist/compat/buffer/errors.d.ts +41 -0
- package/dist/compat/buffer/errors.js +265 -0
- package/dist/compat/buffer/index.d.ts +25 -0
- package/dist/compat/buffer/index.js +24 -0
- package/dist/compat/buffer/internal-buffer.d.ts +148 -0
- package/dist/compat/buffer/internal-buffer.js +1809 -0
- package/dist/compat/buffer/support.d.ts +13 -0
- package/dist/compat/buffer/support.js +65 -0
- package/dist/compat/child-process/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/child-process/LICENSE-APACHE +177 -0
- package/dist/compat/child-process/errors.d.ts +4 -0
- package/dist/compat/child-process/errors.js +6 -0
- package/dist/compat/child-process/index.d.ts +49 -0
- package/dist/compat/child-process/index.js +96 -0
- package/dist/compat/cluster/LICENSE-3RD-PARTY.md +40 -0
- package/dist/compat/cluster/LICENSE-APACHE +177 -0
- package/dist/compat/cluster/errors.d.ts +4 -0
- package/dist/compat/cluster/errors.js +6 -0
- package/dist/compat/cluster/index.d.ts +47 -0
- package/dist/compat/cluster/index.js +88 -0
- package/dist/compat/constants/LICENSE-3RD-PARTY.md +6 -0
- package/dist/compat/constants/LICENSE-APACHE +177 -0
- package/dist/compat/constants/index.d.ts +481 -0
- package/dist/compat/constants/index.js +488 -0
- package/dist/compat/dgram/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/dgram/LICENSE-APACHE +177 -0
- package/dist/compat/dgram/index.d.ts +10 -0
- package/dist/compat/dgram/index.js +132 -0
- package/dist/compat/diagnostics-channel/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/diagnostics-channel/LICENSE-APACHE +177 -0
- package/dist/compat/diagnostics-channel/index.d.ts +73 -0
- package/dist/compat/diagnostics-channel/index.js +261 -0
- package/dist/compat/diagnostics-channel/native.d.ts +26 -0
- package/dist/compat/diagnostics-channel/native.js +154 -0
- package/dist/compat/dns/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/dns/LICENSE-APACHE +177 -0
- package/dist/compat/dns/client.d.ts +72 -0
- package/dist/compat/dns/client.js +161 -0
- package/dist/compat/dns/constants.d.ts +27 -0
- package/dist/compat/dns/constants.js +31 -0
- package/dist/compat/dns/errors.d.ts +8 -0
- package/dist/compat/dns/errors.js +12 -0
- package/dist/compat/dns/index.d.ts +97 -0
- package/dist/compat/dns/index.js +127 -0
- package/dist/compat/dns/parser.d.ts +18 -0
- package/dist/compat/dns/parser.js +144 -0
- package/dist/compat/dns/promise-resolver.d.ts +82 -0
- package/dist/compat/dns/promise-resolver.js +113 -0
- package/dist/compat/dns/promises.d.ts +50 -0
- package/dist/compat/dns/promises.js +53 -0
- package/dist/compat/dns/resolver.d.ts +34 -0
- package/dist/compat/dns/resolver.js +415 -0
- package/dist/compat/domain/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/domain/LICENSE-APACHE +177 -0
- package/dist/compat/domain/index.d.ts +22 -0
- package/dist/compat/domain/index.js +79 -0
- package/dist/compat/fs/index.d.ts +85 -0
- package/dist/compat/fs/index.js +255 -0
- package/dist/compat/fs/promises/index.d.ts +3 -0
- package/dist/compat/fs/promises/index.js +3 -0
- package/dist/compat/http/index.d.ts +322 -0
- package/dist/compat/http/index.js +1356 -0
- package/dist/compat/http/registry.d.ts +19 -0
- package/dist/compat/http/registry.js +13 -0
- package/dist/compat/http-agent/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/http-agent/LICENSE-APACHE +177 -0
- package/dist/compat/http-agent/index.d.ts +7 -0
- package/dist/compat/http-agent/index.js +10 -0
- package/dist/compat/http-client/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/http-client/LICENSE-APACHE +177 -0
- package/dist/compat/http-client/index.d.ts +6 -0
- package/dist/compat/http-client/index.js +7 -0
- package/dist/compat/http-incoming/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/http-incoming/LICENSE-APACHE +177 -0
- package/dist/compat/http-incoming/index.d.ts +6 -0
- package/dist/compat/http-incoming/index.js +9 -0
- package/dist/compat/http2/LICENSE-3RD-PARTY.md +29 -0
- package/dist/compat/http2/LICENSE-APACHE +177 -0
- package/dist/compat/http2/constants.d.ts +255 -0
- package/dist/compat/http2/constants.js +515 -0
- package/dist/compat/http2/errors.d.ts +4 -0
- package/dist/compat/http2/errors.js +6 -0
- package/dist/compat/http2/index.d.ts +283 -0
- package/dist/compat/http2/index.js +68 -0
- package/dist/compat/https/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/https/LICENSE-APACHE +177 -0
- package/dist/compat/https/agent.d.ts +10 -0
- package/dist/compat/https/agent.js +99 -0
- package/dist/compat/https/errors.d.ts +4 -0
- package/dist/compat/https/errors.js +6 -0
- package/dist/compat/https/index.d.ts +20 -0
- package/dist/compat/https/index.js +50 -0
- package/dist/compat/https/server.d.ts +8 -0
- package/dist/compat/https/server.js +27 -0
- package/dist/compat/immediate/index.d.ts +11 -0
- package/dist/compat/immediate/index.js +58 -0
- package/dist/compat/inspector/LICENSE-3RD-PARTY.md +34 -0
- package/dist/compat/inspector/LICENSE-APACHE +177 -0
- package/dist/compat/inspector/errors.d.ts +4 -0
- package/dist/compat/inspector/errors.js +6 -0
- package/dist/compat/inspector/index.d.ts +18 -0
- package/dist/compat/inspector/index.js +117 -0
- package/dist/compat/inspector/promises.d.ts +18 -0
- package/dist/compat/inspector/promises.js +114 -0
- package/dist/compat/module/index.cjs +2 -0
- package/dist/compat/module/index.d.cts +2 -0
- package/dist/compat/module/index.d.ts +11 -0
- package/dist/compat/module/index.js +44 -0
- package/dist/compat/module/resolve-unavailable.d.ts +1 -0
- package/dist/compat/module/resolve-unavailable.js +3 -0
- package/dist/compat/net/LICENSE-3RD-PARTY.md +15 -0
- package/dist/compat/net/LICENSE-APACHE +177 -0
- package/dist/compat/net/error-base.d.ts +14 -0
- package/dist/compat/net/error-base.js +62 -0
- package/dist/compat/net/errors.d.ts +76 -0
- package/dist/compat/net/errors.js +333 -0
- package/dist/compat/net/index.d.ts +23 -0
- package/dist/compat/net/index.js +46 -0
- package/dist/compat/net/internal-net.d.ts +236 -0
- package/dist/compat/net/internal-net.js +2292 -0
- package/dist/compat/net/ports.d.ts +32 -0
- package/dist/compat/net/ports.js +149 -0
- package/dist/compat/net/reader.d.ts +8 -0
- package/dist/compat/net/reader.js +36 -0
- package/dist/compat/net/sockets.d.ts +20 -0
- package/dist/compat/net/sockets.js +195 -0
- package/dist/compat/net/validators.d.ts +18 -0
- package/dist/compat/net/validators.js +154 -0
- package/dist/compat/os/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/os/LICENSE-APACHE +177 -0
- package/dist/compat/os/index.d.ts +329 -0
- package/dist/compat/os/index.js +278 -0
- package/dist/compat/path/LICENSE-3RD-PARTY.md +35 -0
- package/dist/compat/path/LICENSE-APACHE +177 -0
- package/dist/compat/path/index.d.ts +4 -0
- package/dist/compat/path/index.js +11 -0
- package/dist/compat/path/internal-path.d.ts +95 -0
- package/dist/compat/path/internal-path.js +1542 -0
- package/dist/compat/path/posix/index.d.ts +4 -0
- package/dist/compat/path/posix/index.js +5 -0
- package/dist/compat/path/win32/index.d.ts +4 -0
- package/dist/compat/path/win32/index.js +5 -0
- package/dist/compat/perf-hooks/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/perf-hooks/LICENSE-APACHE +177 -0
- package/dist/compat/perf-hooks/index.d.ts +85 -0
- package/dist/compat/perf-hooks/index.js +79 -0
- package/dist/compat/perf-hooks/performance.d.ts +96 -0
- package/dist/compat/perf-hooks/performance.js +445 -0
- package/dist/compat/punycode/LICENSE-3RD-PARTY.md +7 -0
- package/dist/compat/punycode/LICENSE-APACHE +177 -0
- package/dist/compat/punycode/index.d.ts +93 -0
- package/dist/compat/punycode/index.js +410 -0
- package/dist/compat/querystring/LICENSE-3RD-PARTY.md +35 -0
- package/dist/compat/querystring/LICENSE-APACHE +177 -0
- package/dist/compat/querystring/index.d.ts +14 -0
- package/dist/compat/querystring/index.js +18 -0
- package/dist/compat/querystring/internal-querystring.d.ts +22 -0
- package/dist/compat/querystring/internal-querystring.js +498 -0
- package/dist/compat/readline/LICENSE-3RD-PARTY.md +37 -0
- package/dist/compat/readline/LICENSE-APACHE +177 -0
- package/dist/compat/readline/index.d.ts +21 -0
- package/dist/compat/readline/index.js +56 -0
- package/dist/compat/readline/interface.d.ts +22 -0
- package/dist/compat/readline/interface.js +85 -0
- package/dist/compat/readline/internal-promises.d.ts +32 -0
- package/dist/compat/readline/internal-promises.js +104 -0
- package/dist/compat/readline/promises.d.ts +8 -0
- package/dist/compat/readline/promises.js +32 -0
- package/dist/compat/repl/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/repl/LICENSE-APACHE +177 -0
- package/dist/compat/repl/builtin-modules.d.ts +1 -0
- package/dist/compat/repl/builtin-modules.js +101 -0
- package/dist/compat/repl/errors.d.ts +4 -0
- package/dist/compat/repl/errors.js +6 -0
- package/dist/compat/repl/index.d.ts +53 -0
- package/dist/compat/repl/index.js +106 -0
- package/dist/compat/sqlite/LICENSE-3RD-PARTY.md +6 -0
- package/dist/compat/sqlite/LICENSE-APACHE +177 -0
- package/dist/compat/sqlite/index.d.ts +12 -0
- package/dist/compat/sqlite/index.js +101 -0
- package/dist/compat/sqlite/native.d.ts +16 -0
- package/dist/compat/sqlite/native.js +33 -0
- package/dist/compat/stream/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream/LICENSE-APACHE +177 -0
- package/dist/compat/stream/add-abort-signal.d.ts +4 -0
- package/dist/compat/stream/add-abort-signal.js +73 -0
- package/dist/compat/stream/compose.d.ts +1 -0
- package/dist/compat/stream/compose.js +313 -0
- package/dist/compat/stream/destroy.d.ts +5 -0
- package/dist/compat/stream/destroy.js +315 -0
- package/dist/compat/stream/duplex.d.ts +48 -0
- package/dist/compat/stream/duplex.js +789 -0
- package/dist/compat/stream/end-of-stream.d.ts +16 -0
- package/dist/compat/stream/end-of-stream.js +269 -0
- package/dist/compat/stream/errors.d.ts +40 -0
- package/dist/compat/stream/errors.js +86 -0
- package/dist/compat/stream/events.d.ts +6 -0
- package/dist/compat/stream/events.js +28 -0
- package/dist/compat/stream/index.cjs +27 -0
- package/dist/compat/stream/index.d.cts +25 -0
- package/dist/compat/stream/index.d.ts +20 -0
- package/dist/compat/stream/index.js +55 -0
- package/dist/compat/stream/legacy.d.ts +8 -0
- package/dist/compat/stream/legacy.js +105 -0
- package/dist/compat/stream/once.d.ts +7 -0
- package/dist/compat/stream/once.js +13 -0
- package/dist/compat/stream/pipeline.d.ts +5 -0
- package/dist/compat/stream/pipeline.js +567 -0
- package/dist/compat/stream/process.d.ts +1 -0
- package/dist/compat/stream/process.js +4 -0
- package/dist/compat/stream/promises.d.ts +7 -0
- package/dist/compat/stream/promises.js +60 -0
- package/dist/compat/stream/readable.d.ts +29 -0
- package/dist/compat/stream/readable.js +2267 -0
- package/dist/compat/stream/state.d.ts +8 -0
- package/dist/compat/stream/state.js +63 -0
- package/dist/compat/stream/transform.d.ts +2 -0
- package/dist/compat/stream/transform.js +202 -0
- package/dist/compat/stream/util.d.ts +55 -0
- package/dist/compat/stream/util.js +345 -0
- package/dist/compat/stream/validators.d.ts +2 -0
- package/dist/compat/stream/validators.js +14 -0
- package/dist/compat/stream/writable.d.ts +21 -0
- package/dist/compat/stream/writable.js +1325 -0
- package/dist/compat/stream-consumers/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/stream-consumers/LICENSE-APACHE +177 -0
- package/dist/compat/stream-consumers/index.d.ts +14 -0
- package/dist/compat/stream-consumers/index.js +62 -0
- package/dist/compat/stream-consumers/iterable.d.ts +1 -0
- package/dist/compat/stream-consumers/iterable.js +34 -0
- package/dist/compat/stream-duplex/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-duplex/LICENSE-APACHE +177 -0
- package/dist/compat/stream-duplex/index.cjs +3 -0
- package/dist/compat/stream-duplex/index.d.cts +2 -0
- package/dist/compat/stream-duplex/index.d.ts +3 -0
- package/dist/compat/stream-duplex/index.js +8 -0
- package/dist/compat/stream-passthrough/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-passthrough/LICENSE-APACHE +177 -0
- package/dist/compat/stream-passthrough/index.cjs +3 -0
- package/dist/compat/stream-passthrough/index.d.cts +2 -0
- package/dist/compat/stream-passthrough/index.d.ts +3 -0
- package/dist/compat/stream-passthrough/index.js +8 -0
- package/dist/compat/stream-promises/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-promises/LICENSE-APACHE +177 -0
- package/dist/compat/stream-promises/index.d.ts +1 -0
- package/dist/compat/stream-promises/index.js +1 -0
- package/dist/compat/stream-readable/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-readable/LICENSE-APACHE +177 -0
- package/dist/compat/stream-readable/index.cjs +3 -0
- package/dist/compat/stream-readable/index.d.cts +2 -0
- package/dist/compat/stream-readable/index.d.ts +3 -0
- package/dist/compat/stream-readable/index.js +8 -0
- package/dist/compat/stream-transform/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-transform/LICENSE-APACHE +177 -0
- package/dist/compat/stream-transform/index.cjs +3 -0
- package/dist/compat/stream-transform/index.d.cts +2 -0
- package/dist/compat/stream-transform/index.d.ts +3 -0
- package/dist/compat/stream-transform/index.js +8 -0
- package/dist/compat/stream-web/LICENSE-MIT +22 -0
- package/dist/compat/stream-web/NOTICE.md +3 -0
- package/dist/compat/stream-web/context.d.ts +2 -0
- package/dist/compat/stream-web/context.js +35 -0
- package/dist/compat/stream-web/index.d.ts +80 -0
- package/dist/compat/stream-web/index.js +129 -0
- package/dist/compat/stream-web/interop.d.ts +6 -0
- package/dist/compat/stream-web/interop.js +72 -0
- package/dist/compat/stream-web/ponyfill.d.ts +1 -0
- package/dist/compat/stream-web/ponyfill.js +2093 -0
- package/dist/compat/stream-web/runtime.d.ts +16 -0
- package/dist/compat/stream-web/runtime.js +51 -0
- package/dist/compat/stream-writable/LICENSE-3RD-PARTY.md +13 -0
- package/dist/compat/stream-writable/LICENSE-APACHE +177 -0
- package/dist/compat/stream-writable/index.cjs +3 -0
- package/dist/compat/stream-writable/index.d.cts +2 -0
- package/dist/compat/stream-writable/index.d.ts +3 -0
- package/dist/compat/stream-writable/index.js +8 -0
- package/dist/compat/string-decoder/LICENSE-3RD-PARTY.md +38 -0
- package/dist/compat/string-decoder/LICENSE-APACHE +177 -0
- package/dist/compat/string-decoder/index.d.ts +33 -0
- package/dist/compat/string-decoder/index.js +518 -0
- package/dist/compat/test/LICENSE-3RD-PARTY.md +37 -0
- package/dist/compat/test/LICENSE-APACHE +177 -0
- package/dist/compat/test/index.d.ts +9 -0
- package/dist/compat/test/index.js +11 -0
- package/dist/compat/test/mock.d.ts +103 -0
- package/dist/compat/test/mock.js +397 -0
- package/dist/compat/test/validators.d.ts +2 -0
- package/dist/compat/test/validators.js +14 -0
- package/dist/compat/timers/LICENSE-3RD-PARTY.md +7 -0
- package/dist/compat/timers/LICENSE-APACHE +177 -0
- package/dist/compat/timers/errors.d.ts +28 -0
- package/dist/compat/timers/errors.js +206 -0
- package/dist/compat/timers/host.d.ts +11 -0
- package/dist/compat/timers/host.js +60 -0
- package/dist/compat/timers/index.cjs +3 -0
- package/dist/compat/timers/index.d.cts +23 -0
- package/dist/compat/timers/index.d.ts +36 -0
- package/dist/compat/timers/index.js +20 -0
- package/dist/compat/timers/installation.d.ts +4 -0
- package/dist/compat/timers/installation.js +61 -0
- package/dist/compat/timers/internal-promises.d.ts +19 -0
- package/dist/compat/timers/internal-promises.js +173 -0
- package/dist/compat/timers/promises.cjs +2 -0
- package/dist/compat/timers/promises.d.cts +12 -0
- package/dist/compat/timers/promises.d.ts +14 -0
- package/dist/compat/timers/promises.js +3 -0
- package/dist/compat/timers/timers.d.ts +32 -0
- package/dist/compat/timers/timers.js +147 -0
- package/dist/compat/timers/validation.d.ts +5 -0
- package/dist/compat/timers/validation.js +22 -0
- package/dist/compat/timers/wait.d.ts +4 -0
- package/dist/compat/timers/wait.js +91 -0
- package/dist/compat/tls-common/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/tls-common/LICENSE-APACHE +177 -0
- package/dist/compat/tls-common/index.d.ts +14 -0
- package/dist/compat/tls-common/index.js +88 -0
- package/dist/compat/trace-events/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/trace-events/LICENSE-APACHE +177 -0
- package/dist/compat/trace-events/index.d.ts +18 -0
- package/dist/compat/trace-events/index.js +88 -0
- package/dist/compat/tty/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/tty/LICENSE-APACHE +177 -0
- package/dist/compat/tty/index.d.ts +17 -0
- package/dist/compat/tty/index.js +101 -0
- package/dist/compat/url/LICENSE-3RD-PARTY.md +63 -0
- package/dist/compat/url/LICENSE-ADA +18 -0
- package/dist/compat/url/LICENSE-APACHE +177 -0
- package/dist/compat/url/LICENSE-UNICODE +39 -0
- package/dist/compat/url/LICENSE-WHATWG-URL +21 -0
- package/dist/compat/url/brand.d.ts +4 -0
- package/dist/compat/url/brand.js +10 -0
- package/dist/compat/url/constants.d.ts +27 -0
- package/dist/compat/url/constants.js +28 -0
- package/dist/compat/url/errors.d.ts +44 -0
- package/dist/compat/url/errors.js +248 -0
- package/dist/compat/url/idna-data.d.ts +3958 -0
- package/dist/compat/url/idna-data.js +22 -0
- package/dist/compat/url/idna.d.ts +9 -0
- package/dist/compat/url/idna.js +47 -0
- package/dist/compat/url/index.d.ts +48 -0
- package/dist/compat/url/index.js +39 -0
- package/dist/compat/url/installation.d.ts +4 -0
- package/dist/compat/url/installation.js +61 -0
- package/dist/compat/url/internal-url.d.ts +34 -0
- package/dist/compat/url/internal-url.js +264 -0
- package/dist/compat/url/legacy-url.d.ts +28 -0
- package/dist/compat/url/legacy-url.js +870 -0
- package/dist/compat/url/parser-platform.d.ts +3 -0
- package/dist/compat/url/parser-platform.js +26 -0
- package/dist/compat/url/standard-url.d.ts +2 -0
- package/dist/compat/url/standard-url.js +3189 -0
- package/dist/compat/url/unicode.d.ts +2 -0
- package/dist/compat/url/unicode.js +119 -0
- package/dist/compat/url/validation.d.ts +2 -0
- package/dist/compat/url/validation.js +9 -0
- package/dist/compat/url/web-url.d.ts +27 -0
- package/dist/compat/url/web-url.js +119 -0
- package/dist/compat/util/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/util/LICENSE-APACHE +177 -0
- package/dist/compat/util/additional.d.ts +11 -0
- package/dist/compat/util/additional.js +121 -0
- package/dist/compat/util/comparison-types.d.ts +16 -0
- package/dist/compat/util/comparison-types.js +50 -0
- package/dist/compat/util/comparisons.d.ts +1 -0
- package/dist/compat/util/comparisons.js +527 -0
- package/dist/compat/util/core.d.ts +18 -0
- package/dist/compat/util/core.js +265 -0
- package/dist/compat/util/debuglog.d.ts +1 -0
- package/dist/compat/util/debuglog.js +78 -0
- package/dist/compat/util/index.d.ts +35 -0
- package/dist/compat/util/index.js +77 -0
- package/dist/compat/util/inspect-binding.d.ts +13 -0
- package/dist/compat/util/inspect-binding.js +39 -0
- package/dist/compat/util/inspect-types.d.ts +13 -0
- package/dist/compat/util/inspect-types.js +30 -0
- package/dist/compat/util/inspect.d.ts +152 -0
- package/dist/compat/util/inspect.js +2503 -0
- package/dist/compat/util/mime.d.ts +24 -0
- package/dist/compat/util/mime.js +284 -0
- package/dist/compat/util/properties.d.ts +9 -0
- package/dist/compat/util/properties.js +76 -0
- package/dist/compat/v8/LICENSE-3RD-PARTY.md +6 -0
- package/dist/compat/v8/LICENSE-APACHE +177 -0
- package/dist/compat/v8/errors.d.ts +5 -0
- package/dist/compat/v8/errors.js +7 -0
- package/dist/compat/v8/index.d.ts +106 -0
- package/dist/compat/v8/index.js +280 -0
- package/dist/compat/vm/LICENSE-3RD-PARTY.md +39 -0
- package/dist/compat/vm/LICENSE-APACHE +177 -0
- package/dist/compat/vm/errors.d.ts +5 -0
- package/dist/compat/vm/errors.js +7 -0
- package/dist/compat/vm/index.d.ts +47 -0
- package/dist/compat/vm/index.js +231 -0
- package/dist/compat/vm/validation.d.ts +3 -0
- package/dist/compat/vm/validation.js +14 -0
- package/dist/compat/wasi/LICENSE-3RD-PARTY.md +8 -0
- package/dist/compat/wasi/LICENSE-APACHE +177 -0
- package/dist/compat/wasi/errors.d.ts +4 -0
- package/dist/compat/wasi/errors.js +6 -0
- package/dist/compat/wasi/index.d.ts +15 -0
- package/dist/compat/wasi/index.js +44 -0
- package/dist/compat/worker-threads/LICENSE-3RD-PARTY.md +5 -0
- package/dist/compat/worker-threads/LICENSE-APACHE +177 -0
- package/dist/compat/worker-threads/errors.d.ts +4 -0
- package/dist/compat/worker-threads/errors.js +6 -0
- package/dist/compat/worker-threads/index.d.ts +71 -0
- package/dist/compat/worker-threads/index.js +138 -0
- package/dist/compat/worker-threads/message-channel.d.ts +18 -0
- package/dist/compat/worker-threads/message-channel.js +157 -0
- package/dist/configured.d.ts +3 -0
- package/dist/configured.js +4 -0
- package/dist/environment.d.ts +4 -0
- package/dist/environment.js +18 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +107 -0
- package/dist/ios.d.ts +2 -0
- package/dist/ios.js +1 -0
- package/dist/native-entry.d.ts +8 -0
- package/dist/native-entry.js +67 -0
- package/dist/shared/brotli/LICENSE-APACHE +201 -0
- package/dist/shared/brotli/LICENSE-MIT +9 -0
- package/dist/shared/brotli/NOTICE +3 -0
- package/dist/shared/brotli/index.d.ts +2 -0
- package/dist/shared/brotli/index.js +288 -0
- package/dist/shared/contracts/index.d.ts +42 -0
- package/dist/shared/contracts/index.js +88 -0
- package/dist/shared/contracts/testing.d.ts +22 -0
- package/dist/shared/contracts/testing.js +57 -0
- package/dist/shared/globals/index.d.ts +3 -0
- package/dist/shared/globals/index.js +87 -0
- package/dist/shared/globals/inject.d.ts +2 -0
- package/dist/shared/globals/inject.js +3 -0
- package/dist/shared/globals/install.d.ts +1 -0
- package/dist/shared/globals/install.js +15 -0
- package/dist/shared/globals/node-install.d.ts +1 -0
- package/dist/shared/globals/node-install.js +4 -0
- package/dist/shared/globals/platform.d.ts +104 -0
- package/dist/shared/globals/platform.js +37 -0
- package/dist/shared/globals/runtime.d.ts +6 -0
- package/dist/shared/globals/runtime.js +8 -0
- package/dist/shared/globals/symbols.d.ts +4 -0
- package/dist/shared/globals/symbols.js +35 -0
- package/dist/shared/globals/web.d.ts +4 -0
- package/dist/shared/globals/web.js +108 -0
- package/dist/shared/http-wire/LICENSE.llhttp +22 -0
- package/dist/shared/http-wire/LICENSE.undici +21 -0
- package/dist/shared/http-wire/NOTICE.md +14 -0
- package/dist/shared/http-wire/index.d.ts +27 -0
- package/dist/shared/http-wire/index.js +132 -0
- package/dist/shared/http-wire/wasm.d.ts +2 -0
- package/dist/shared/http-wire/wasm.js +2 -0
- package/dist/tooling/async.d.ts +7 -0
- package/dist/tooling/async.js +99 -0
- package/dist/tooling/build-isolation.d.ts +4 -0
- package/dist/tooling/build-isolation.js +34 -0
- package/dist/tooling/documents.d.ts +7 -0
- package/dist/tooling/documents.js +26 -0
- package/dist/tooling/esbuild.d.ts +15 -0
- package/dist/tooling/esbuild.js +193 -0
- package/dist/tooling/files.d.ts +2 -0
- package/dist/tooling/files.js +18 -0
- package/dist/tooling/opennext/build.d.ts +1 -0
- package/dist/tooling/opennext/build.js +121 -0
- package/dist/tooling/opennext/index.d.ts +3 -0
- package/dist/tooling/opennext/index.js +213 -0
- package/dist/tooling/opennext/plan.d.ts +9 -0
- package/dist/tooling/opennext/plan.js +36 -0
- package/dist/tooling/opennext/safety.d.ts +4 -0
- package/dist/tooling/opennext/safety.js +36 -0
- package/dist/tooling/route-permissions.d.ts +3 -0
- package/dist/tooling/route-permissions.js +15 -0
- package/dist/tooling/server-modules.d.ts +30 -0
- package/dist/tooling/server-modules.js +98 -0
- package/dist/tooling/server-only-html.d.ts +1 -0
- package/dist/tooling/server-only-html.js +66 -0
- package/dist/tooling/server-only.d.ts +6 -0
- package/dist/tooling/server-only.js +53 -0
- package/dist/tooling/server.d.ts +25 -0
- package/dist/tooling/server.js +981 -0
- package/dist/tooling/shared.d.ts +13 -0
- package/dist/tooling/shared.js +130 -0
- package/dist/tooling/vite.d.ts +18 -0
- package/dist/tooling/vite.js +448 -0
- package/dist/tooling/void/index.d.ts +3 -0
- package/dist/tooling/void/index.js +205 -0
- package/dist/tooling/void/plan.d.ts +17 -0
- package/dist/tooling/void/plan.js +288 -0
- package/native/android/build.gradle +68 -0
- package/native/android/consumer-rules.pro +2 -0
- package/native/android/src/main/AndroidManifest.xml +6 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +202 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +256 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNative.java +22 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNativeActivity.java +178 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNativeBridge.java +45 -0
- package/native/ios/DocumentBridge.swift +330 -0
- package/native/ios/NetworkBridge.swift +51 -0
- package/native/ios/SocketBridge.swift +180 -0
- package/native/ios/WorkersCapacitorPlugin.swift +152 -0
- package/native/ios-host/WorkersView.swift +194 -0
- package/package.json +154 -4
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import { isURLInstance } from "../../compat/url/brand.js";
|
|
2
|
+
import { platform } from "../../shared/globals/platform.js";
|
|
3
|
+
import { cloneHeaders, Headers } from "../headers/index.js";
|
|
4
|
+
import { Request, structuredCloneRequestSnapshot } from "../request/index.js";
|
|
5
|
+
import { Response, structuredCloneResponseSnapshot, restoreStructuredCloneResponse, } from "../response/index.js";
|
|
6
|
+
import { Blob as WorkersBlob, File as WorkersFile, cloneBlob, } from "../../compat/buffer/blob.js";
|
|
7
|
+
const platformStructuredClone = platform.structuredClone;
|
|
8
|
+
const unsupported = new Map([
|
|
9
|
+
[
|
|
10
|
+
"URL",
|
|
11
|
+
'Could not serialize object of type "URL". This type does not support serialization.',
|
|
12
|
+
],
|
|
13
|
+
[
|
|
14
|
+
"URLSearchParams",
|
|
15
|
+
'Could not serialize object of type "URLSearchParams". This type does not support serialization.',
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
"TextEncoder",
|
|
19
|
+
'Could not serialize object of type "TextEncoder". This type does not support serialization.',
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
"TextDecoder",
|
|
23
|
+
'Could not serialize object of type "TextDecoder". This type does not support serialization.',
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
"AbortController",
|
|
27
|
+
'Could not serialize object of type "AbortController". This type does not support serialization.',
|
|
28
|
+
],
|
|
29
|
+
]);
|
|
30
|
+
function dataCloneError(message) {
|
|
31
|
+
return new DOMException(message, "DataCloneError");
|
|
32
|
+
}
|
|
33
|
+
function boxedSymbol(value) {
|
|
34
|
+
try {
|
|
35
|
+
Symbol.prototype.valueOf.call(value);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function boxedBigInt(value) {
|
|
43
|
+
try {
|
|
44
|
+
BigInt.prototype.valueOf.call(value);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function viewField(value, key) {
|
|
52
|
+
const prototype = value instanceof DataView
|
|
53
|
+
? DataView.prototype
|
|
54
|
+
: Object.getPrototypeOf(Uint8Array.prototype);
|
|
55
|
+
return Object.getOwnPropertyDescriptor(prototype, key).get.call(value);
|
|
56
|
+
}
|
|
57
|
+
function nativeValue(value) {
|
|
58
|
+
return (value instanceof Number ||
|
|
59
|
+
value instanceof Boolean ||
|
|
60
|
+
value instanceof String ||
|
|
61
|
+
boxedBigInt(value) ||
|
|
62
|
+
value instanceof Date ||
|
|
63
|
+
value instanceof RegExp ||
|
|
64
|
+
value instanceof Blob ||
|
|
65
|
+
value instanceof ArrayBuffer ||
|
|
66
|
+
(typeof SharedArrayBuffer === "function" &&
|
|
67
|
+
value instanceof SharedArrayBuffer) ||
|
|
68
|
+
ArrayBuffer.isView(value));
|
|
69
|
+
}
|
|
70
|
+
function errorName(error) {
|
|
71
|
+
return error instanceof AggregateError
|
|
72
|
+
? "AggregateError"
|
|
73
|
+
: error instanceof EvalError
|
|
74
|
+
? "EvalError"
|
|
75
|
+
: error instanceof RangeError
|
|
76
|
+
? "RangeError"
|
|
77
|
+
: error instanceof ReferenceError
|
|
78
|
+
? "ReferenceError"
|
|
79
|
+
: error instanceof SyntaxError
|
|
80
|
+
? "SyntaxError"
|
|
81
|
+
: error instanceof TypeError
|
|
82
|
+
? "TypeError"
|
|
83
|
+
: error instanceof URIError
|
|
84
|
+
? "URIError"
|
|
85
|
+
: "Error";
|
|
86
|
+
}
|
|
87
|
+
function encode(value, tag, metadata, seen, transferred, markers) {
|
|
88
|
+
if (value === null ||
|
|
89
|
+
value === undefined ||
|
|
90
|
+
typeof value === "string" ||
|
|
91
|
+
typeof value === "number" ||
|
|
92
|
+
typeof value === "boolean" ||
|
|
93
|
+
typeof value === "bigint")
|
|
94
|
+
return value;
|
|
95
|
+
if (typeof value === "symbol" || typeof value === "function")
|
|
96
|
+
throw dataCloneError(`${String(value)} could not be cloned.`);
|
|
97
|
+
if (boxedSymbol(value))
|
|
98
|
+
throw dataCloneError("[object Symbol] could not be cloned.");
|
|
99
|
+
if (seen.has(value))
|
|
100
|
+
return seen.get(value);
|
|
101
|
+
if (value instanceof WorkersFile)
|
|
102
|
+
throw dataCloneError('Could not serialize object of type "File". This type does not support serialization.');
|
|
103
|
+
if (value instanceof WorkersBlob) {
|
|
104
|
+
const marker = { [tag]: metadata.length };
|
|
105
|
+
markers.push(marker);
|
|
106
|
+
seen.set(value, marker);
|
|
107
|
+
metadata.push({ type: "blob", value: cloneBlob(value) });
|
|
108
|
+
return marker;
|
|
109
|
+
}
|
|
110
|
+
if (value instanceof Headers) {
|
|
111
|
+
const marker = { [tag]: metadata.length };
|
|
112
|
+
markers.push(marker);
|
|
113
|
+
seen.set(value, marker);
|
|
114
|
+
metadata.push({ type: "headers", value: cloneHeaders(value) });
|
|
115
|
+
return marker;
|
|
116
|
+
}
|
|
117
|
+
if (value instanceof Request) {
|
|
118
|
+
const snapshot = structuredCloneRequestSnapshot(value);
|
|
119
|
+
if (snapshot.hasBody)
|
|
120
|
+
throw dataCloneError("ReadableStream can only be serialized for RPC.");
|
|
121
|
+
if (snapshot.signal !== undefined)
|
|
122
|
+
throw dataCloneError("AbortSignal serialization is not enabled.");
|
|
123
|
+
if (snapshot.fetcher !== null)
|
|
124
|
+
throw dataCloneError('Could not serialize object of type "Fetcher". This type does not support serialization.');
|
|
125
|
+
const marker = { [tag]: metadata.length };
|
|
126
|
+
markers.push(marker);
|
|
127
|
+
seen.set(value, marker);
|
|
128
|
+
metadata.push({
|
|
129
|
+
type: "request",
|
|
130
|
+
value: {
|
|
131
|
+
url: snapshot.url,
|
|
132
|
+
method: snapshot.method,
|
|
133
|
+
headers: snapshot.headers,
|
|
134
|
+
redirect: snapshot.redirect,
|
|
135
|
+
cf: snapshot.cf,
|
|
136
|
+
fetcher: null,
|
|
137
|
+
cache: snapshot.cache,
|
|
138
|
+
encodeResponseBody: snapshot.encodeResponseBody,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
marker.headers = encode(snapshot.headers, tag, metadata, seen, transferred, markers);
|
|
142
|
+
marker.cf = encode(snapshot.cf, tag, metadata, seen, transferred, markers);
|
|
143
|
+
return marker;
|
|
144
|
+
}
|
|
145
|
+
if (value instanceof Response) {
|
|
146
|
+
const snapshot = structuredCloneResponseSnapshot(value);
|
|
147
|
+
if (snapshot.hasBody)
|
|
148
|
+
throw dataCloneError("ReadableStream can only be serialized for RPC.");
|
|
149
|
+
if (snapshot.webSocket !== null)
|
|
150
|
+
throw dataCloneError('Could not serialize object of type "WebSocket". This type does not support serialization.');
|
|
151
|
+
const marker = { [tag]: metadata.length };
|
|
152
|
+
markers.push(marker);
|
|
153
|
+
seen.set(value, marker);
|
|
154
|
+
metadata.push({
|
|
155
|
+
type: "response",
|
|
156
|
+
value: snapshot,
|
|
157
|
+
});
|
|
158
|
+
marker.headers = encode(snapshot.headers, tag, metadata, seen, transferred, markers);
|
|
159
|
+
marker.cf = encode(snapshot.cf, tag, metadata, seen, transferred, markers);
|
|
160
|
+
return marker;
|
|
161
|
+
}
|
|
162
|
+
if (value instanceof DOMException) {
|
|
163
|
+
const marker = {
|
|
164
|
+
[tag]: "dom-exception",
|
|
165
|
+
name: value.name,
|
|
166
|
+
message: value.message,
|
|
167
|
+
stack: value.stack,
|
|
168
|
+
};
|
|
169
|
+
markers.push(marker);
|
|
170
|
+
seen.set(value, marker);
|
|
171
|
+
return marker;
|
|
172
|
+
}
|
|
173
|
+
if (value instanceof Error) {
|
|
174
|
+
const marker = {
|
|
175
|
+
[tag]: "error",
|
|
176
|
+
kind: errorName(value),
|
|
177
|
+
message: value.message,
|
|
178
|
+
stack: value.stack,
|
|
179
|
+
};
|
|
180
|
+
markers.push(marker);
|
|
181
|
+
seen.set(value, marker);
|
|
182
|
+
if ("cause" in value)
|
|
183
|
+
marker.cause = encode(value.cause, tag, metadata, seen, transferred, markers);
|
|
184
|
+
if (value instanceof AggregateError)
|
|
185
|
+
marker.errors = encode(value.errors, tag, metadata, seen, transferred, markers);
|
|
186
|
+
for (const key of Object.keys(value)) {
|
|
187
|
+
if (["stack", "message", "cause", "errors"].includes(key))
|
|
188
|
+
continue;
|
|
189
|
+
marker.properties ??= {};
|
|
190
|
+
marker.properties[key] = encode(value[key], tag, metadata, seen, transferred, markers);
|
|
191
|
+
}
|
|
192
|
+
return marker;
|
|
193
|
+
}
|
|
194
|
+
if (isURLInstance(value))
|
|
195
|
+
throw dataCloneError(unsupported.get("URL"));
|
|
196
|
+
for (const [type, Constructor] of [
|
|
197
|
+
["URLSearchParams", URLSearchParams],
|
|
198
|
+
["TextEncoder", TextEncoder],
|
|
199
|
+
["TextDecoder", TextDecoder],
|
|
200
|
+
["AbortController", AbortController],
|
|
201
|
+
]) {
|
|
202
|
+
if (value instanceof Constructor)
|
|
203
|
+
throw dataCloneError(unsupported.get(type));
|
|
204
|
+
}
|
|
205
|
+
if (value instanceof AbortSignal)
|
|
206
|
+
throw dataCloneError("AbortSignal serialization is not enabled.");
|
|
207
|
+
for (const [type, Constructor] of [
|
|
208
|
+
["ReadableStream", ReadableStream],
|
|
209
|
+
["WritableStream", WritableStream],
|
|
210
|
+
["TransformStream", TransformStream],
|
|
211
|
+
]) {
|
|
212
|
+
if (value instanceof Constructor)
|
|
213
|
+
throw dataCloneError(`${type} can only be serialized for RPC.`);
|
|
214
|
+
}
|
|
215
|
+
if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) {
|
|
216
|
+
const buffer = value instanceof ArrayBuffer ? value : viewField(value, "buffer");
|
|
217
|
+
try {
|
|
218
|
+
new Uint8Array(buffer);
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
throw dataCloneError("An ArrayBuffer is detached and could not be cloned.");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (nativeValue(value)) {
|
|
225
|
+
if (value instanceof ArrayBuffer && transferred.has(value))
|
|
226
|
+
return value;
|
|
227
|
+
if (ArrayBuffer.isView(value)) {
|
|
228
|
+
const get = (key) => viewField(value, key);
|
|
229
|
+
const buffer = get("buffer");
|
|
230
|
+
if (transferred.has(buffer))
|
|
231
|
+
return value;
|
|
232
|
+
const clonedBuffer = encode(buffer, tag, metadata, seen, transferred, markers);
|
|
233
|
+
const offset = get("byteOffset");
|
|
234
|
+
let snapshot;
|
|
235
|
+
if (value instanceof DataView)
|
|
236
|
+
snapshot = new DataView(clonedBuffer, offset, get("byteLength"));
|
|
237
|
+
else {
|
|
238
|
+
const Constructor = [
|
|
239
|
+
Int8Array,
|
|
240
|
+
Uint8ClampedArray,
|
|
241
|
+
Uint8Array,
|
|
242
|
+
Int16Array,
|
|
243
|
+
Uint16Array,
|
|
244
|
+
Int32Array,
|
|
245
|
+
Uint32Array,
|
|
246
|
+
Float32Array,
|
|
247
|
+
Float64Array,
|
|
248
|
+
BigInt64Array,
|
|
249
|
+
BigUint64Array,
|
|
250
|
+
...(globalThis
|
|
251
|
+
.Float16Array
|
|
252
|
+
? [
|
|
253
|
+
globalThis
|
|
254
|
+
.Float16Array,
|
|
255
|
+
]
|
|
256
|
+
: []),
|
|
257
|
+
].find((Constructor) => value instanceof Constructor);
|
|
258
|
+
snapshot = new Constructor(clonedBuffer, offset, get("length"));
|
|
259
|
+
}
|
|
260
|
+
seen.set(value, snapshot);
|
|
261
|
+
return snapshot;
|
|
262
|
+
}
|
|
263
|
+
const snapshot = platformStructuredClone(value);
|
|
264
|
+
seen.set(value, snapshot);
|
|
265
|
+
return snapshot;
|
|
266
|
+
}
|
|
267
|
+
if (value instanceof WeakMap ||
|
|
268
|
+
value instanceof WeakSet ||
|
|
269
|
+
value instanceof Promise)
|
|
270
|
+
return platformStructuredClone(value);
|
|
271
|
+
if (value instanceof Map) {
|
|
272
|
+
const result = new Map();
|
|
273
|
+
seen.set(value, result);
|
|
274
|
+
for (const [key, item] of Array.from(Map.prototype.entries.call(value)))
|
|
275
|
+
result.set(encode(key, tag, metadata, seen, transferred, markers), encode(item, tag, metadata, seen, transferred, markers));
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
if (value instanceof Set) {
|
|
279
|
+
const result = new Set();
|
|
280
|
+
seen.set(value, result);
|
|
281
|
+
for (const item of Array.from(Set.prototype.values.call(value)))
|
|
282
|
+
result.add(encode(item, tag, metadata, seen, transferred, markers));
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
const result = Array.isArray(value)
|
|
286
|
+
? new Array(value.length)
|
|
287
|
+
: {};
|
|
288
|
+
seen.set(value, result);
|
|
289
|
+
for (const key of Object.keys(value))
|
|
290
|
+
Object.defineProperty(result, key, {
|
|
291
|
+
value: encode(value[key], tag, metadata, seen, transferred, markers),
|
|
292
|
+
writable: true,
|
|
293
|
+
enumerable: true,
|
|
294
|
+
configurable: true,
|
|
295
|
+
});
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
298
|
+
function createError(kind, message) {
|
|
299
|
+
const constructors = {
|
|
300
|
+
Error,
|
|
301
|
+
EvalError,
|
|
302
|
+
RangeError,
|
|
303
|
+
ReferenceError,
|
|
304
|
+
SyntaxError,
|
|
305
|
+
TypeError,
|
|
306
|
+
URIError,
|
|
307
|
+
};
|
|
308
|
+
return kind === "AggregateError"
|
|
309
|
+
? new AggregateError([], message)
|
|
310
|
+
: new (constructors[kind] ?? Error)(message);
|
|
311
|
+
}
|
|
312
|
+
function decode(value, tag, metadata, seen, markers) {
|
|
313
|
+
if (value === null || typeof value !== "object")
|
|
314
|
+
return value;
|
|
315
|
+
if (seen.has(value)) {
|
|
316
|
+
const decoded = seen.get(value);
|
|
317
|
+
if (decoded === undefined)
|
|
318
|
+
throw new Error("Unable to deserialize cloned data.");
|
|
319
|
+
return decoded;
|
|
320
|
+
}
|
|
321
|
+
if (markers.has(value)) {
|
|
322
|
+
const marker = value;
|
|
323
|
+
const id = marker[tag];
|
|
324
|
+
if (id === "error") {
|
|
325
|
+
const error = createError(String(marker.kind), String(marker.message));
|
|
326
|
+
seen.set(value, error);
|
|
327
|
+
if (marker.stack !== undefined)
|
|
328
|
+
Object.defineProperty(error, "stack", {
|
|
329
|
+
value: marker.stack,
|
|
330
|
+
writable: true,
|
|
331
|
+
enumerable: true,
|
|
332
|
+
configurable: true,
|
|
333
|
+
});
|
|
334
|
+
if (Object.hasOwn(marker, "cause"))
|
|
335
|
+
Object.defineProperty(error, "cause", {
|
|
336
|
+
value: decode(marker.cause, tag, metadata, seen, markers),
|
|
337
|
+
writable: true,
|
|
338
|
+
enumerable: true,
|
|
339
|
+
configurable: true,
|
|
340
|
+
});
|
|
341
|
+
if (error instanceof AggregateError)
|
|
342
|
+
Object.defineProperty(error, "errors", {
|
|
343
|
+
value: decode(marker.errors, tag, metadata, seen, markers),
|
|
344
|
+
writable: true,
|
|
345
|
+
enumerable: true,
|
|
346
|
+
configurable: true,
|
|
347
|
+
});
|
|
348
|
+
const properties = marker.properties;
|
|
349
|
+
if (properties)
|
|
350
|
+
for (const key of Object.keys(properties))
|
|
351
|
+
Object.defineProperty(error, key, {
|
|
352
|
+
value: decode(properties[key], tag, metadata, seen, markers),
|
|
353
|
+
writable: true,
|
|
354
|
+
enumerable: true,
|
|
355
|
+
configurable: true,
|
|
356
|
+
});
|
|
357
|
+
return error;
|
|
358
|
+
}
|
|
359
|
+
if (id === "dom-exception") {
|
|
360
|
+
const error = new DOMException(String(marker.message), String(marker.name));
|
|
361
|
+
seen.set(value, error);
|
|
362
|
+
const code = error.code;
|
|
363
|
+
for (const key of ["code", "name", "message", "stack"])
|
|
364
|
+
if (Object.getOwnPropertyDescriptor(error, key)?.configurable)
|
|
365
|
+
delete error[key];
|
|
366
|
+
for (const [key, content, writable, configurable] of [
|
|
367
|
+
["code", code, false, true],
|
|
368
|
+
["name", marker.name, false, true],
|
|
369
|
+
["message", marker.message, false, true],
|
|
370
|
+
["stack", marker.stack, true, false],
|
|
371
|
+
])
|
|
372
|
+
Object.defineProperty(error, key, {
|
|
373
|
+
value: content,
|
|
374
|
+
writable,
|
|
375
|
+
enumerable: true,
|
|
376
|
+
configurable,
|
|
377
|
+
});
|
|
378
|
+
return error;
|
|
379
|
+
}
|
|
380
|
+
const entry = metadata[Number(id)];
|
|
381
|
+
if (entry.type === "blob") {
|
|
382
|
+
seen.set(value, entry.value);
|
|
383
|
+
return entry.value;
|
|
384
|
+
}
|
|
385
|
+
if (entry.type === "headers") {
|
|
386
|
+
const headers = cloneHeaders(entry.value);
|
|
387
|
+
seen.set(value, headers);
|
|
388
|
+
return headers;
|
|
389
|
+
}
|
|
390
|
+
if (entry.type === "request" || entry.type === "response") {
|
|
391
|
+
// workerd rejects a host object that references itself while deserializing.
|
|
392
|
+
// This happens after the platform clone has committed buffer transfers.
|
|
393
|
+
seen.set(value, undefined);
|
|
394
|
+
}
|
|
395
|
+
if (entry.type === "request") {
|
|
396
|
+
const request = new Request(entry.value.url, {
|
|
397
|
+
method: entry.value.method,
|
|
398
|
+
headers: decode(marker.headers, tag, metadata, seen, markers),
|
|
399
|
+
redirect: entry.value.redirect,
|
|
400
|
+
cf: decode(marker.cf, tag, metadata, seen, markers),
|
|
401
|
+
fetcher: null,
|
|
402
|
+
cache: entry.value.cache,
|
|
403
|
+
});
|
|
404
|
+
seen.set(value, request);
|
|
405
|
+
return request;
|
|
406
|
+
}
|
|
407
|
+
const response = restoreStructuredCloneResponse({
|
|
408
|
+
...entry.value,
|
|
409
|
+
headers: decode(marker.headers, tag, metadata, seen, markers),
|
|
410
|
+
cf: decode(marker.cf, tag, metadata, seen, markers),
|
|
411
|
+
});
|
|
412
|
+
seen.set(value, response);
|
|
413
|
+
return response;
|
|
414
|
+
}
|
|
415
|
+
if (value instanceof Map) {
|
|
416
|
+
const result = new Map();
|
|
417
|
+
seen.set(value, result);
|
|
418
|
+
for (const [key, item] of Map.prototype.entries.call(value))
|
|
419
|
+
result.set(decode(key, tag, metadata, seen, markers), decode(item, tag, metadata, seen, markers));
|
|
420
|
+
return result;
|
|
421
|
+
}
|
|
422
|
+
if (value instanceof Set) {
|
|
423
|
+
const result = new Set();
|
|
424
|
+
seen.set(value, result);
|
|
425
|
+
for (const item of Set.prototype.values.call(value))
|
|
426
|
+
result.add(decode(item, tag, metadata, seen, markers));
|
|
427
|
+
return result;
|
|
428
|
+
}
|
|
429
|
+
if (nativeValue(value))
|
|
430
|
+
return value;
|
|
431
|
+
const result = Array.isArray(value)
|
|
432
|
+
? new Array(value.length)
|
|
433
|
+
: {};
|
|
434
|
+
seen.set(value, result);
|
|
435
|
+
for (const key of Object.keys(value))
|
|
436
|
+
Object.defineProperty(result, key, {
|
|
437
|
+
value: decode(value[key], tag, metadata, seen, markers),
|
|
438
|
+
writable: true,
|
|
439
|
+
enumerable: true,
|
|
440
|
+
configurable: true,
|
|
441
|
+
});
|
|
442
|
+
return result;
|
|
443
|
+
}
|
|
444
|
+
function transfers(options) {
|
|
445
|
+
if (options == null)
|
|
446
|
+
return [];
|
|
447
|
+
if (typeof options !== "object")
|
|
448
|
+
throw new TypeError("Failed to execute 'structuredClone' on 'ServiceWorkerGlobalScope': parameter 2 is not of type 'StructuredCloneOptions'.");
|
|
449
|
+
const list = options.transfer;
|
|
450
|
+
if (list === undefined)
|
|
451
|
+
return [];
|
|
452
|
+
if (!Array.isArray(list))
|
|
453
|
+
throw new TypeError("Incorrect type for the 'transfer' field on 'StructuredCloneOptions': the provided value is not of type 'Array'.");
|
|
454
|
+
const unique = new Set();
|
|
455
|
+
for (const item of list) {
|
|
456
|
+
const buffer = item instanceof ArrayBuffer
|
|
457
|
+
? item
|
|
458
|
+
: ArrayBuffer.isView(item)
|
|
459
|
+
? viewField(item, "buffer")
|
|
460
|
+
: undefined;
|
|
461
|
+
if (!(buffer instanceof ArrayBuffer))
|
|
462
|
+
throw new TypeError("Object is not transferable");
|
|
463
|
+
unique.add(buffer);
|
|
464
|
+
}
|
|
465
|
+
return [...unique];
|
|
466
|
+
}
|
|
467
|
+
export function structuredClone(value, options) {
|
|
468
|
+
if (arguments.length === 0)
|
|
469
|
+
throw new TypeError("Failed to execute 'structuredClone' on 'ServiceWorkerGlobalScope': parameter 1 is not of type 'Value'.");
|
|
470
|
+
const transfer = transfers(options);
|
|
471
|
+
const metadata = [];
|
|
472
|
+
const tag = "__workers_capacitor_clone__";
|
|
473
|
+
const markers = [];
|
|
474
|
+
const encoded = encode(value, tag, metadata, new Map(), new Set(transfer), markers);
|
|
475
|
+
const cloned = platformStructuredClone({ encoded, markers }, { transfer });
|
|
476
|
+
return decode(cloned.encoded, tag, metadata, new Map(), new Set(cloned.markers));
|
|
477
|
+
}
|
|
478
|
+
Object.defineProperty(structuredClone, "length", { value: 0 });
|
|
479
|
+
Object.defineProperty(structuredClone, "name", { value: "structuredClone" });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type InboundSocket } from "../../../compat/http/registry.js";
|
|
2
|
+
export interface ServerDescriptor {
|
|
3
|
+
port?: number | null;
|
|
4
|
+
}
|
|
5
|
+
export interface NodeStyleServer {
|
|
6
|
+
listen(): unknown;
|
|
7
|
+
address(): {
|
|
8
|
+
port?: number | null;
|
|
9
|
+
} | string | null;
|
|
10
|
+
}
|
|
11
|
+
export declare function httpServerHandler(descriptor: number | ServerDescriptor | NodeStyleServer): {
|
|
12
|
+
fetch(request: Request, env?: unknown, ctx?: unknown): Promise<Response>;
|
|
13
|
+
};
|
|
14
|
+
export declare function handleAsNodeRequest(descriptor: number | ServerDescriptor, request: Request, env?: unknown, ctx?: unknown): Promise<Response>;
|
|
15
|
+
export declare function handleAsNodeConnection(socket: InboundSocket, env?: unknown, ctx?: unknown): Promise<void>;
|
|
16
|
+
export declare function connectHandler(): {
|
|
17
|
+
connect(socket: InboundSocket, env?: unknown, ctx?: unknown): Promise<void>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { getHandler, kSetIncomingBody, } from "../../../compat/http/registry.js";
|
|
2
|
+
function validatePort(port) {
|
|
3
|
+
if (typeof port !== "number" ||
|
|
4
|
+
!Number.isFinite(port) ||
|
|
5
|
+
port < 0 ||
|
|
6
|
+
port > 65535)
|
|
7
|
+
throw new Error("Failed to determine port for server");
|
|
8
|
+
return port;
|
|
9
|
+
}
|
|
10
|
+
export function httpServerHandler(descriptor) {
|
|
11
|
+
if (descriptor == null)
|
|
12
|
+
throw new Error("Server descriptor cannot be null or undefined");
|
|
13
|
+
let port = typeof descriptor === "number"
|
|
14
|
+
? descriptor
|
|
15
|
+
: descriptor.port;
|
|
16
|
+
if (port == null &&
|
|
17
|
+
typeof descriptor.listen === "function") {
|
|
18
|
+
const server = descriptor;
|
|
19
|
+
let address = server.address();
|
|
20
|
+
port = typeof address === "object" ? address?.port : undefined;
|
|
21
|
+
if (typeof port !== "number") {
|
|
22
|
+
server.listen();
|
|
23
|
+
address = server.address();
|
|
24
|
+
port = typeof address === "object" ? address?.port : undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const resolvedPort = validatePort(port);
|
|
28
|
+
return {
|
|
29
|
+
fetch(request, env, ctx) {
|
|
30
|
+
return handleAsNodeRequest(resolvedPort, request, env, ctx);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export async function handleAsNodeRequest(descriptor, request, env, ctx) {
|
|
35
|
+
const port = validatePort(typeof descriptor === "number" ? descriptor : descriptor?.port);
|
|
36
|
+
const handler = getHandler(port);
|
|
37
|
+
const server = handler?.server;
|
|
38
|
+
const createRequestResponse = handler?.createRequestResponse;
|
|
39
|
+
if (!server || !createRequestResponse)
|
|
40
|
+
throw Object.assign(new Error(`Http server with port ${port} not found. This is likely a bug with your code. ` +
|
|
41
|
+
`You should check if server.listen() was called with the same port (${port})`), { code: "ERR_INVALID_ARG_VALUE" });
|
|
42
|
+
const url = new URL(request.url);
|
|
43
|
+
const classes = createRequestResponse();
|
|
44
|
+
const req = new classes.IncomingMessage();
|
|
45
|
+
req.url = url.pathname + url.search;
|
|
46
|
+
req.method = request.method;
|
|
47
|
+
req.headers = Object.fromEntries(request.headers);
|
|
48
|
+
// Local dispatch has no HTTP stack to supply transport headers. Preserve the
|
|
49
|
+
// logical origin and indicate a streaming entity to Node body parsers.
|
|
50
|
+
req.headers.host ??= url.host;
|
|
51
|
+
if (request.body &&
|
|
52
|
+
!req.headers["content-length"] &&
|
|
53
|
+
!req.headers["transfer-encoding"])
|
|
54
|
+
req.headers["transfer-encoding"] = "chunked";
|
|
55
|
+
req.socket.encrypted = url.protocol === "https:";
|
|
56
|
+
req.socket.localPort = port;
|
|
57
|
+
req.rawHeaders = [...request.headers].flat();
|
|
58
|
+
req.cloudflare = { env, ctx };
|
|
59
|
+
if ("cf" in request)
|
|
60
|
+
req.cloudflare.cf = request.cf;
|
|
61
|
+
req[kSetIncomingBody](request.body);
|
|
62
|
+
const res = new classes.ServerResponse(req, {
|
|
63
|
+
highWaterMark: server.highWaterMark,
|
|
64
|
+
rejectNonStandardBodyWrites: server.rejectNonStandardBodyWrites,
|
|
65
|
+
});
|
|
66
|
+
if (request.method === "HEAD")
|
|
67
|
+
res._hasBody = false;
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
res.once("error", reject);
|
|
70
|
+
req.once("error", (error) => {
|
|
71
|
+
reject(error);
|
|
72
|
+
res.destroy(error);
|
|
73
|
+
});
|
|
74
|
+
res.once("finish", () => {
|
|
75
|
+
request.signal.removeEventListener("abort", onAbort);
|
|
76
|
+
if (!req.complete)
|
|
77
|
+
req.destroy();
|
|
78
|
+
});
|
|
79
|
+
res.once("headers", () => {
|
|
80
|
+
try {
|
|
81
|
+
const headers = new Headers();
|
|
82
|
+
for (const [key, value] of Object.entries(res.getHeaders())) {
|
|
83
|
+
for (const item of Array.isArray(value) ? value : [value])
|
|
84
|
+
headers.append(key, String(item));
|
|
85
|
+
}
|
|
86
|
+
resolve(new Response(request.method === "HEAD" ||
|
|
87
|
+
[204, 205, 304].includes(res.statusCode)
|
|
88
|
+
? null
|
|
89
|
+
: res.body, {
|
|
90
|
+
status: res.statusCode,
|
|
91
|
+
statusText: res.statusMessage,
|
|
92
|
+
headers,
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
reject(error);
|
|
97
|
+
res.destroy(error instanceof Error ? error : new Error(String(error)));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const onAbort = () => {
|
|
101
|
+
const reason = request.signal.reason;
|
|
102
|
+
const error = reason instanceof Error
|
|
103
|
+
? reason
|
|
104
|
+
: new Error("The operation was aborted", { cause: reason });
|
|
105
|
+
req.destroy(error);
|
|
106
|
+
res.destroy(error);
|
|
107
|
+
};
|
|
108
|
+
res.once("close", () => {
|
|
109
|
+
request.signal.removeEventListener("abort", onAbort);
|
|
110
|
+
if (!req.complete)
|
|
111
|
+
req.destroy();
|
|
112
|
+
if (!res.finished)
|
|
113
|
+
reject(new Error("Premature close"));
|
|
114
|
+
});
|
|
115
|
+
request.signal.addEventListener("abort", onAbort, { once: true });
|
|
116
|
+
if (request.signal.aborted) {
|
|
117
|
+
onAbort();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
server.emit("connection", server, req);
|
|
122
|
+
server.emit("request", req, res);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
res.destroy(error instanceof Error ? error : new Error(String(error)));
|
|
126
|
+
reject(error);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function portFromAuthority(authority) {
|
|
131
|
+
const match = typeof authority === "string" ? /:(\d+)$/.exec(authority) : null;
|
|
132
|
+
if (!match)
|
|
133
|
+
throw new Error(`Failed to determine port for inbound socket from local address ${String(authority)}`);
|
|
134
|
+
return validatePort(Number(match[1]));
|
|
135
|
+
}
|
|
136
|
+
export async function handleAsNodeConnection(socket, env, ctx) {
|
|
137
|
+
const port = portFromAuthority((await socket.opened).localAddress);
|
|
138
|
+
const handler = getHandler(port);
|
|
139
|
+
if (!handler?.connect)
|
|
140
|
+
throw Object.assign(new Error(`No net.Server is listening on port ${port}. Call server.listen(${port}) to accept ` +
|
|
141
|
+
`connections arriving on that port.`), { code: "ERR_INVALID_ARG_VALUE" });
|
|
142
|
+
await handler.connect(socket, env, ctx);
|
|
143
|
+
}
|
|
144
|
+
export function connectHandler() {
|
|
145
|
+
return {
|
|
146
|
+
connect(socket, env, ctx) {
|
|
147
|
+
return handleAsNodeConnection(socket, env, ctx);
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Runtime-internal: called by the dispatch layer before worker.fetch. */
|
|
2
|
+
export declare function setWorkerEnv(env: unknown): void;
|
|
3
|
+
export declare const env: Record<string, unknown>;
|
|
4
|
+
export declare class DurableObject<Env = unknown> {
|
|
5
|
+
protected readonly ctx: unknown;
|
|
6
|
+
protected readonly env: Env;
|
|
7
|
+
constructor(ctx: unknown, env: Env);
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Bindings arrive per request through the fetch signature; the worker
|
|
2
|
+
// transport installs them so module-scope `env` reads resolve too.
|
|
3
|
+
let workerEnv = {};
|
|
4
|
+
/** Runtime-internal: called by the dispatch layer before worker.fetch. */
|
|
5
|
+
export function setWorkerEnv(env) {
|
|
6
|
+
workerEnv =
|
|
7
|
+
env !== null && typeof env === "object"
|
|
8
|
+
? env
|
|
9
|
+
: {};
|
|
10
|
+
}
|
|
11
|
+
export const env = new Proxy(Object.create(null), {
|
|
12
|
+
get(_target, name) {
|
|
13
|
+
return workerEnv[String(name)];
|
|
14
|
+
},
|
|
15
|
+
has(_target, name) {
|
|
16
|
+
return String(name) in workerEnv;
|
|
17
|
+
},
|
|
18
|
+
ownKeys() {
|
|
19
|
+
return Reflect.ownKeys(workerEnv);
|
|
20
|
+
},
|
|
21
|
+
getOwnPropertyDescriptor(_target, name) {
|
|
22
|
+
const value = workerEnv[String(name)];
|
|
23
|
+
return value === undefined
|
|
24
|
+
? undefined
|
|
25
|
+
: { configurable: true, enumerable: true, value };
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
// Durable Object namespaces need stateful storage; bundles such as OpenNext
|
|
29
|
+
// export subclass shells that must at least resolve and construct.
|
|
30
|
+
export class DurableObject {
|
|
31
|
+
ctx;
|
|
32
|
+
env;
|
|
33
|
+
constructor(ctx, env) {
|
|
34
|
+
this.ctx = ctx;
|
|
35
|
+
this.env = env;
|
|
36
|
+
}
|
|
37
|
+
}
|