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,65 @@
|
|
|
1
|
+
import { fetchFeature } from "./feature.js";
|
|
2
|
+
function equal(actual, expected) {
|
|
3
|
+
if (JSON.stringify(actual) !== JSON.stringify(expected))
|
|
4
|
+
throw new Error(`${JSON.stringify(actual)} != ${JSON.stringify(expected)}`);
|
|
5
|
+
}
|
|
6
|
+
/** Run against fetchContractWorker mounted at https://worker.invalid/api. */
|
|
7
|
+
export const fetchContract = {
|
|
8
|
+
feature: fetchFeature,
|
|
9
|
+
cases: {
|
|
10
|
+
async request(fetcher) {
|
|
11
|
+
const response = await fetcher("https://worker.invalid/api/echo?q=1", {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: { "x-test": "kept" },
|
|
14
|
+
body: "日本語 🍷",
|
|
15
|
+
});
|
|
16
|
+
equal(await response.json(), {
|
|
17
|
+
method: "POST",
|
|
18
|
+
query: "1",
|
|
19
|
+
header: "kept",
|
|
20
|
+
body: "日本語 🍷",
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
async response(fetcher) {
|
|
24
|
+
const response = await fetcher("https://worker.invalid/api/status");
|
|
25
|
+
equal([
|
|
26
|
+
response.status,
|
|
27
|
+
response.headers.get("x-test"),
|
|
28
|
+
await response.text(),
|
|
29
|
+
], [202, "kept", "accepted"]);
|
|
30
|
+
},
|
|
31
|
+
async missing(fetcher) {
|
|
32
|
+
const response = await fetcher("https://worker.invalid/api/missing");
|
|
33
|
+
equal([response.status, await response.text()], [404, "missing"]);
|
|
34
|
+
},
|
|
35
|
+
async head(fetcher) {
|
|
36
|
+
const response = await fetcher("https://worker.invalid/api/status", {
|
|
37
|
+
method: "HEAD",
|
|
38
|
+
});
|
|
39
|
+
equal([
|
|
40
|
+
response.status,
|
|
41
|
+
response.headers.get("x-test"),
|
|
42
|
+
await response.text(),
|
|
43
|
+
], [202, "kept", ""]);
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
/** Neutral fixture for the portable HTTP contract. */
|
|
48
|
+
export const fetchContractWorker = {
|
|
49
|
+
async fetch(request) {
|
|
50
|
+
const url = new URL(request.url);
|
|
51
|
+
if (url.pathname === "/api/echo")
|
|
52
|
+
return Response.json({
|
|
53
|
+
method: request.method,
|
|
54
|
+
query: url.searchParams.get("q"),
|
|
55
|
+
header: request.headers.get("x-test"),
|
|
56
|
+
body: await request.text(),
|
|
57
|
+
});
|
|
58
|
+
if (url.pathname === "/api/status")
|
|
59
|
+
return new Response(request.method === "HEAD" ? null : "accepted", {
|
|
60
|
+
status: 202,
|
|
61
|
+
headers: { "x-test": "kept" },
|
|
62
|
+
});
|
|
63
|
+
return new Response("missing", { status: 404 });
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FeatureImplementation, type FeatureScope } from "../../shared/contracts/index.js";
|
|
2
|
+
import type { WorkersCapacitorOptions } from "./types.js";
|
|
3
|
+
/** A deliberately small portable HTTP profile, not the full fetch specification. */
|
|
4
|
+
export declare const fetchFeature: import("../../shared/contracts/index.js").Feature<"fetch.basic", typeof fetch, "head" | "missing" | "request" | "response">;
|
|
5
|
+
/** Connects the existing runtime to the common feature host without patching globals. */
|
|
6
|
+
export declare class FetchImplementation<Env> extends FeatureImplementation<typeof fetchFeature> {
|
|
7
|
+
private readonly options;
|
|
8
|
+
constructor(options: WorkersCapacitorOptions<Env>);
|
|
9
|
+
create(scope: FeatureScope): Promise<typeof fetch>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineFeature, FeatureImplementation, } from "../../shared/contracts/index.js";
|
|
2
|
+
import { createFetchRuntime } from "./worker-runtime.js";
|
|
3
|
+
/** A deliberately small portable HTTP profile, not the full fetch specification. */
|
|
4
|
+
export const fetchFeature = defineFeature()("fetch.basic", [
|
|
5
|
+
"request",
|
|
6
|
+
"response",
|
|
7
|
+
"missing",
|
|
8
|
+
"head",
|
|
9
|
+
]);
|
|
10
|
+
/** Connects the existing runtime to the common feature host without patching globals. */
|
|
11
|
+
export class FetchImplementation extends FeatureImplementation {
|
|
12
|
+
options;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super(fetchFeature, {
|
|
15
|
+
request: { status: "supported" },
|
|
16
|
+
response: { status: "supported" },
|
|
17
|
+
missing: { status: "supported" },
|
|
18
|
+
head: { status: "supported" },
|
|
19
|
+
});
|
|
20
|
+
this.options = options;
|
|
21
|
+
}
|
|
22
|
+
async create(scope) {
|
|
23
|
+
const runtime = createFetchRuntime(this.options);
|
|
24
|
+
scope.defer(() => runtime.dispose());
|
|
25
|
+
await runtime.ready;
|
|
26
|
+
return runtime.fetch;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FetchRuntimeOptions, WorkerContext } from "./types.js";
|
|
2
|
+
export type { FetchRuntimeOptions } from "./types.js";
|
|
3
|
+
/** Shared Fetch contract. Subclasses implement execution, not URL or HTTP semantics. */
|
|
4
|
+
export declare abstract class FetchRuntime<Env = Record<string, unknown>> {
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly base;
|
|
7
|
+
private readonly boundary;
|
|
8
|
+
protected readonly localURL: URL | undefined;
|
|
9
|
+
protected readonly original: typeof fetch;
|
|
10
|
+
private readonly env;
|
|
11
|
+
private readonly pending;
|
|
12
|
+
private disposed;
|
|
13
|
+
private disposal;
|
|
14
|
+
readonly ready: Promise<void>;
|
|
15
|
+
constructor(options: FetchRuntimeOptions<Env>);
|
|
16
|
+
protected abstract dispatch(request: Request, env: Env, ctx: WorkerContext): Response | Promise<Response>;
|
|
17
|
+
protected close(): void | Promise<void>;
|
|
18
|
+
protected externalFetch(input: RequestInfo | URL, init: RequestInit | undefined, _url: URL): Promise<Response>;
|
|
19
|
+
/** Bound function; creating a runtime does not patch global fetch. */
|
|
20
|
+
readonly fetch: typeof fetch;
|
|
21
|
+
drain(): Promise<void>;
|
|
22
|
+
dispose(): void | Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { isRequest, isResponse } from "../../browser/fetch/interop.js";
|
|
2
|
+
import { Request as WorkerRequest, } from "../../browser/request/index.js";
|
|
3
|
+
/** Shared Fetch contract. Subclasses implement execution, not URL or HTTP semantics. */
|
|
4
|
+
export class FetchRuntime {
|
|
5
|
+
options;
|
|
6
|
+
base;
|
|
7
|
+
boundary;
|
|
8
|
+
localURL;
|
|
9
|
+
original;
|
|
10
|
+
env;
|
|
11
|
+
pending = new Set();
|
|
12
|
+
disposed = false;
|
|
13
|
+
disposal = undefined;
|
|
14
|
+
ready = Promise.resolve();
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
const base = new URL(options.baseURL);
|
|
18
|
+
if (!["http:", "https:"].includes(base.protocol) ||
|
|
19
|
+
base.username ||
|
|
20
|
+
base.password ||
|
|
21
|
+
base.search ||
|
|
22
|
+
base.hash) {
|
|
23
|
+
throw new TypeError("baseURL must be an HTTP(S) URL without credentials, query or fragment.");
|
|
24
|
+
}
|
|
25
|
+
this.base = base;
|
|
26
|
+
this.boundary = base.pathname.replace(/\/+$/, "");
|
|
27
|
+
this.original = globalThis.fetch;
|
|
28
|
+
this.localURL = globalThis.location
|
|
29
|
+
? new URL(globalThis.location.href)
|
|
30
|
+
: undefined;
|
|
31
|
+
this.env = options.env ?? {};
|
|
32
|
+
}
|
|
33
|
+
close() { }
|
|
34
|
+
externalFetch(input, init, _url) {
|
|
35
|
+
return this.original.call(globalThis, input, init);
|
|
36
|
+
}
|
|
37
|
+
/** Bound function; creating a runtime does not patch global fetch. */
|
|
38
|
+
fetch = async (input, init) => {
|
|
39
|
+
const inputIsRequest = isRequest(input);
|
|
40
|
+
const address = inputIsRequest ? input.url : String(input);
|
|
41
|
+
const url = new URL(address, globalThis.document?.baseURI ??
|
|
42
|
+
globalThis.location?.href ??
|
|
43
|
+
this.base.href);
|
|
44
|
+
const matchesPath = !this.boundary ||
|
|
45
|
+
url.pathname === this.boundary ||
|
|
46
|
+
url.pathname.startsWith(`${this.boundary}/`);
|
|
47
|
+
const isLocal = this.localURL &&
|
|
48
|
+
url.protocol === this.localURL.protocol &&
|
|
49
|
+
url.host === this.localURL.host;
|
|
50
|
+
if (!matchesPath || (url.origin !== this.base.origin && !isLocal)) {
|
|
51
|
+
return this.externalFetch(input, init, url);
|
|
52
|
+
}
|
|
53
|
+
if (url.username || url.password)
|
|
54
|
+
throw new TypeError("Request URL must not contain credentials.");
|
|
55
|
+
const target = new URL(this.base.origin);
|
|
56
|
+
target.pathname = url.pathname;
|
|
57
|
+
target.search = url.search;
|
|
58
|
+
const request = (inputIsRequest
|
|
59
|
+
? new WorkerRequest(target, new WorkerRequest(input, init))
|
|
60
|
+
: new WorkerRequest(target, init));
|
|
61
|
+
request.signal.throwIfAborted();
|
|
62
|
+
const ctx = {
|
|
63
|
+
props: {},
|
|
64
|
+
passThroughOnException() {
|
|
65
|
+
throw new Error("passThroughOnException is unsupported for local execution.");
|
|
66
|
+
},
|
|
67
|
+
waitUntil: (promise) => {
|
|
68
|
+
const tracked = Promise.resolve(promise).then(() => { }, (error) => {
|
|
69
|
+
try {
|
|
70
|
+
(this.options.onBackgroundError ?? console.error)(error);
|
|
71
|
+
}
|
|
72
|
+
catch (reportError) {
|
|
73
|
+
console.error(reportError);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
this.pending.add(tracked);
|
|
77
|
+
void tracked.finally(() => this.pending.delete(tracked));
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
let abort;
|
|
81
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
82
|
+
abort = () => reject(request.signal.reason);
|
|
83
|
+
request.signal.addEventListener("abort", abort, { once: true });
|
|
84
|
+
});
|
|
85
|
+
let response;
|
|
86
|
+
try {
|
|
87
|
+
response = await Promise.race([
|
|
88
|
+
Promise.resolve().then(() => {
|
|
89
|
+
request.signal.throwIfAborted();
|
|
90
|
+
return this.dispatch(request, this.env, ctx);
|
|
91
|
+
}),
|
|
92
|
+
cancelled,
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
request.signal.removeEventListener("abort", abort);
|
|
97
|
+
}
|
|
98
|
+
if (!isResponse(response))
|
|
99
|
+
throw new TypeError("worker.fetch must return a Response.");
|
|
100
|
+
if (response.type === "error")
|
|
101
|
+
throw new TypeError("worker.fetch returned a network error response.");
|
|
102
|
+
if (response.bodyUsed || response.body?.locked)
|
|
103
|
+
throw new TypeError("worker.fetch returned an unusable response body.");
|
|
104
|
+
if (request.method === "HEAD" && response.body) {
|
|
105
|
+
void response.body.cancel().catch(() => { });
|
|
106
|
+
return new Response(null, response);
|
|
107
|
+
}
|
|
108
|
+
return response;
|
|
109
|
+
};
|
|
110
|
+
async drain() {
|
|
111
|
+
while (this.pending.size)
|
|
112
|
+
await Promise.all([...this.pending]);
|
|
113
|
+
}
|
|
114
|
+
dispose() {
|
|
115
|
+
if (this.disposed)
|
|
116
|
+
return this.disposal;
|
|
117
|
+
this.disposal = this.close();
|
|
118
|
+
this.disposed = true;
|
|
119
|
+
return this.disposal;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface WorkerContext {
|
|
2
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
3
|
+
passThroughOnException(): void;
|
|
4
|
+
props: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export interface WorkerHandler<Env = Record<string, unknown>> {
|
|
7
|
+
fetch(request: Request, env: Env, ctx: WorkerContext): Response | Promise<Response>;
|
|
8
|
+
}
|
|
9
|
+
/** Creates a Dedicated Worker connected to the public serve() entry. */
|
|
10
|
+
export type WorkerFactory = () => Worker;
|
|
11
|
+
export interface FetchRuntimeOptions<Env> {
|
|
12
|
+
/** Absolute HTTP(S) URL. Its path is the interception boundary, not a prefix to append. */
|
|
13
|
+
baseURL: string;
|
|
14
|
+
/** Optional local values; never automatically copies server secrets. */
|
|
15
|
+
env?: Env;
|
|
16
|
+
onBackgroundError?: (error: unknown) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface LoadedWorker<Env = Record<string, unknown>> {
|
|
19
|
+
handler: WorkerHandler<Env>;
|
|
20
|
+
dispose(): void | Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/** Supplied by a build plugin or explicit ESM wiring; direct code loads only when selected. */
|
|
23
|
+
export interface WorkerSource<Env = Record<string, unknown>> {
|
|
24
|
+
createWorker: WorkerFactory;
|
|
25
|
+
loadDirect(): Promise<WorkerHandler<Env> | LoadedWorker<Env>>;
|
|
26
|
+
/** Generated by the build: runs before any application handler or middleware. */
|
|
27
|
+
needsRemote?(request: Request): boolean | Promise<boolean>;
|
|
28
|
+
/** Build metadata: false only when every dispatch is local. Missing means remote is required when a selector exists. */
|
|
29
|
+
requiresRemote?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export type ExecutionPreference = "worker" | "direct";
|
|
32
|
+
export interface RemoteWorkerOptions {
|
|
33
|
+
/** HTTPS origin of the deployed Worker; defaults to the baseURL origin. Paths are preserved. */
|
|
34
|
+
origin?: string;
|
|
35
|
+
/** Maximum buffered upload bytes (default 8 MiB). Native manual/error requests stream. */
|
|
36
|
+
maxBufferedBodyBytes?: number;
|
|
37
|
+
/** Optional existing-session bridge, invoked in the host for each remote request. */
|
|
38
|
+
getToken?(): string | undefined | Promise<string | undefined>;
|
|
39
|
+
}
|
|
40
|
+
export interface WorkersCapacitorOptions<Env> extends FetchRuntimeOptions<Env> {
|
|
41
|
+
/** Optional when configured by the Vite or esbuild plugin. */
|
|
42
|
+
worker?: WorkerHandler<Env> | WorkerFactory | WorkerSource<Env>;
|
|
43
|
+
/** Native document rendering: initial local path (for example "/"). Omit for Fetch-only use. */
|
|
44
|
+
render?: string;
|
|
45
|
+
/** Applies to a configured WorkerSource; defaults to worker. */
|
|
46
|
+
prefer?: ExecutionPreference;
|
|
47
|
+
/** Connection for the server routes generated by the build integration. */
|
|
48
|
+
remote?: RemoteWorkerOptions;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FetchRuntime, type FetchRuntimeOptions } from "./runtime.js";
|
|
2
|
+
import type { WorkersCapacitorOptions, WorkerContext, WorkerFactory, WorkerHandler, WorkerSource } from "./types.js";
|
|
3
|
+
export declare class DirectFetchRuntime<Env> extends FetchRuntime<Env> {
|
|
4
|
+
private readonly worker;
|
|
5
|
+
readonly execution: "direct";
|
|
6
|
+
private readonly releaseNetwork;
|
|
7
|
+
private readonly restoreWeb;
|
|
8
|
+
private readonly outbound;
|
|
9
|
+
constructor(options: FetchRuntimeOptions<Env>, worker: WorkerHandler<Env>);
|
|
10
|
+
protected externalFetch(input: RequestInfo | URL, init: RequestInit | undefined, url: URL): Promise<Response>;
|
|
11
|
+
protected close(): Promise<void> | undefined;
|
|
12
|
+
protected dispatch(request: Request, env: Env, ctx: WorkerContext): Promise<Response> | Response;
|
|
13
|
+
}
|
|
14
|
+
export declare class IsolatedFetchRuntime<Env> extends FetchRuntime<Env> {
|
|
15
|
+
readonly execution: "worker";
|
|
16
|
+
private readonly isolated;
|
|
17
|
+
readonly ready: Promise<void>;
|
|
18
|
+
constructor(options: FetchRuntimeOptions<Env>, factory: WorkerFactory);
|
|
19
|
+
protected dispatch(request: Request, env: Env, ctx: WorkerContext): Promise<Response> | Response;
|
|
20
|
+
protected close(): Promise<void> | undefined;
|
|
21
|
+
}
|
|
22
|
+
export declare class PreferredFetchRuntime<Env> extends FetchRuntime<Env> {
|
|
23
|
+
private readonly source;
|
|
24
|
+
private readonly remote?;
|
|
25
|
+
private isolated?;
|
|
26
|
+
private handler?;
|
|
27
|
+
private closed;
|
|
28
|
+
private loadingDirect;
|
|
29
|
+
private selected?;
|
|
30
|
+
private disposeDirect?;
|
|
31
|
+
private startupDisposal?;
|
|
32
|
+
private releaseNetwork?;
|
|
33
|
+
private restoreWeb?;
|
|
34
|
+
private outbound?;
|
|
35
|
+
protected externalFetch(input: RequestInfo | URL, init: RequestInit | undefined, url: URL): Promise<Response>;
|
|
36
|
+
get execution(): "direct" | "worker" | undefined;
|
|
37
|
+
readonly ready: Promise<void>;
|
|
38
|
+
constructor(options: WorkersCapacitorOptions<Env>, source: WorkerSource<Env>);
|
|
39
|
+
private initialize;
|
|
40
|
+
protected dispatch(request: Request, env: Env, ctx: WorkerContext): Promise<Response>;
|
|
41
|
+
protected close(): Promise<void> | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** The installer and feature host select execution in exactly the same way. */
|
|
44
|
+
export declare function createFetchRuntime<Env>(options: WorkersCapacitorOptions<Env>): DirectFetchRuntime<Env> | IsolatedFetchRuntime<Env> | PreferredFetchRuntime<Env>;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { installWebGlobals } from "../../shared/globals/web.js";
|
|
2
|
+
import { createOutboundFetch } from "../../browser/fetch/outbound.js";
|
|
3
|
+
import { browserFetch, isRequest } from "../../browser/fetch/interop.js";
|
|
4
|
+
import { installDirectNetworkScope } from "../../browser/fetch/scope.js";
|
|
5
|
+
import configuredWorker from "../../configured.js";
|
|
6
|
+
import { createIsolatedWorker } from "../../browser/isolated/bridge.js";
|
|
7
|
+
import { createRemoteWorker } from "../../cloudflare/bindings/remote.js";
|
|
8
|
+
import { FetchRuntime } from "./runtime.js";
|
|
9
|
+
export class DirectFetchRuntime extends FetchRuntime {
|
|
10
|
+
worker;
|
|
11
|
+
execution = "direct";
|
|
12
|
+
releaseNetwork;
|
|
13
|
+
restoreWeb;
|
|
14
|
+
outbound;
|
|
15
|
+
constructor(options, worker) {
|
|
16
|
+
super(options);
|
|
17
|
+
this.worker = worker;
|
|
18
|
+
this.restoreWeb = installWebGlobals();
|
|
19
|
+
try {
|
|
20
|
+
this.releaseNetwork = installDirectNetworkScope();
|
|
21
|
+
this.outbound = createOutboundFetch(this.original.bind(globalThis));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
this.restoreWeb();
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
externalFetch(input, init, url) {
|
|
29
|
+
if (this.localURL &&
|
|
30
|
+
url.protocol === this.localURL.protocol &&
|
|
31
|
+
url.host === this.localURL.host)
|
|
32
|
+
return browserFetch(isRequest(input) ? input : url.href, init, this.original.bind(globalThis));
|
|
33
|
+
return this.outbound(isRequest(input) ? input : url.href, init);
|
|
34
|
+
}
|
|
35
|
+
close() {
|
|
36
|
+
const closing = this.releaseNetwork?.();
|
|
37
|
+
if (closing)
|
|
38
|
+
return closing.finally(this.restoreWeb);
|
|
39
|
+
this.restoreWeb();
|
|
40
|
+
}
|
|
41
|
+
dispatch(request, env, ctx) {
|
|
42
|
+
return this.worker.fetch(request, env, ctx);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class IsolatedFetchRuntime extends FetchRuntime {
|
|
46
|
+
execution = "worker";
|
|
47
|
+
isolated;
|
|
48
|
+
ready;
|
|
49
|
+
constructor(options, factory) {
|
|
50
|
+
super(options);
|
|
51
|
+
this.isolated = createIsolatedWorker(factory());
|
|
52
|
+
this.ready = this.isolated.ready;
|
|
53
|
+
}
|
|
54
|
+
dispatch(request, env, ctx) {
|
|
55
|
+
return this.isolated.handler.fetch(request, env, ctx);
|
|
56
|
+
}
|
|
57
|
+
close() {
|
|
58
|
+
return this.isolated.dispose();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Conservative transport eligibility: methods, accessors and custom prototypes
|
|
62
|
+
// (including bindings) must retain their semantics in the direct environment.
|
|
63
|
+
function plainData(value, seen = new Set()) {
|
|
64
|
+
if (value === null || value === undefined)
|
|
65
|
+
return true;
|
|
66
|
+
if (typeof value !== "object")
|
|
67
|
+
return ["string", "number", "boolean", "bigint"].includes(typeof value);
|
|
68
|
+
if (seen.has(value))
|
|
69
|
+
return true;
|
|
70
|
+
seen.add(value);
|
|
71
|
+
const prototype = Object.getPrototypeOf(value);
|
|
72
|
+
if ((Array.isArray(value) && prototype !== Array.prototype) ||
|
|
73
|
+
(!Array.isArray(value) && prototype !== Object.prototype))
|
|
74
|
+
return false;
|
|
75
|
+
return Reflect.ownKeys(value).every((key) => {
|
|
76
|
+
if (typeof key === "symbol")
|
|
77
|
+
return false;
|
|
78
|
+
const property = Object.getOwnPropertyDescriptor(value, key);
|
|
79
|
+
// Array length is intrinsic and preserved by structured cloning.
|
|
80
|
+
if (Array.isArray(value) && key === "length")
|
|
81
|
+
return true;
|
|
82
|
+
return (property.enumerable === true &&
|
|
83
|
+
"value" in property &&
|
|
84
|
+
plainData(property.value, seen));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function loadedWorker(value) {
|
|
88
|
+
return "handler" in value && typeof value.dispose === "function";
|
|
89
|
+
}
|
|
90
|
+
export class PreferredFetchRuntime extends FetchRuntime {
|
|
91
|
+
source;
|
|
92
|
+
remote;
|
|
93
|
+
isolated;
|
|
94
|
+
handler;
|
|
95
|
+
closed = false;
|
|
96
|
+
loadingDirect = false;
|
|
97
|
+
selected;
|
|
98
|
+
disposeDirect;
|
|
99
|
+
startupDisposal;
|
|
100
|
+
releaseNetwork;
|
|
101
|
+
restoreWeb;
|
|
102
|
+
outbound;
|
|
103
|
+
externalFetch(input, init, url) {
|
|
104
|
+
if (!this.outbound)
|
|
105
|
+
return browserFetch(isRequest(input) ? input : url.href, init, this.original.bind(globalThis));
|
|
106
|
+
if (this.localURL &&
|
|
107
|
+
url.protocol === this.localURL.protocol &&
|
|
108
|
+
url.host === this.localURL.host)
|
|
109
|
+
return browserFetch(isRequest(input) ? input : url.href, init, this.original.bind(globalThis));
|
|
110
|
+
return this.outbound(isRequest(input) ? input : url.href, init);
|
|
111
|
+
}
|
|
112
|
+
get execution() {
|
|
113
|
+
return this.selected;
|
|
114
|
+
}
|
|
115
|
+
ready;
|
|
116
|
+
constructor(options, source) {
|
|
117
|
+
super(options);
|
|
118
|
+
this.source = source;
|
|
119
|
+
if (options.remote && !source.needsRemote)
|
|
120
|
+
throw new TypeError("remote requires build-generated server routes; configure the Worker's server bindings in the build plugin.");
|
|
121
|
+
if (options.remote ||
|
|
122
|
+
(source.needsRemote && source.requiresRemote !== false))
|
|
123
|
+
this.remote = createRemoteWorker({
|
|
124
|
+
...options.remote,
|
|
125
|
+
origin: options.remote?.origin === undefined
|
|
126
|
+
? new URL(options.baseURL).origin
|
|
127
|
+
: options.remote.origin,
|
|
128
|
+
}, this.original.bind(globalThis));
|
|
129
|
+
this.ready = this.initialize(options, source);
|
|
130
|
+
void this.ready.catch(() => { });
|
|
131
|
+
}
|
|
132
|
+
async initialize(options, source) {
|
|
133
|
+
if (options.prefer !== "direct" &&
|
|
134
|
+
typeof Worker === "function" &&
|
|
135
|
+
plainData(options.env)) {
|
|
136
|
+
try {
|
|
137
|
+
this.isolated = createIsolatedWorker(source.createWorker());
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
// Only platform unavailability permits fallback, not application errors.
|
|
141
|
+
if (!(error instanceof DOMException) ||
|
|
142
|
+
!["SecurityError", "NotSupportedError"].includes(error.name))
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
if (this.isolated) {
|
|
146
|
+
await this.isolated.ready;
|
|
147
|
+
if (this.closed)
|
|
148
|
+
throw new Error("Worker runtime disposed");
|
|
149
|
+
this.handler = this.isolated.handler;
|
|
150
|
+
this.selected = "worker";
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
this.loadingDirect = true;
|
|
155
|
+
try {
|
|
156
|
+
this.restoreWeb = installWebGlobals();
|
|
157
|
+
this.releaseNetwork = installDirectNetworkScope();
|
|
158
|
+
this.outbound = createOutboundFetch(this.original.bind(globalThis));
|
|
159
|
+
const loaded = await source.loadDirect();
|
|
160
|
+
const owned = loadedWorker(loaded);
|
|
161
|
+
const dispose = owned ? () => loaded.dispose() : undefined;
|
|
162
|
+
try {
|
|
163
|
+
const handler = owned ? loaded.handler : loaded;
|
|
164
|
+
if (this.closed)
|
|
165
|
+
throw new Error("Worker runtime disposed");
|
|
166
|
+
if (typeof handler?.fetch !== "function")
|
|
167
|
+
throw new TypeError("worker.fetch is required.");
|
|
168
|
+
this.disposeDirect = dispose;
|
|
169
|
+
this.handler = handler;
|
|
170
|
+
this.selected = "direct";
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
this.startupDisposal = Promise.resolve().then(() => dispose?.());
|
|
174
|
+
await this.startupDisposal;
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
try {
|
|
180
|
+
await this.releaseNetwork?.();
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
this.restoreWeb?.();
|
|
184
|
+
}
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
this.loadingDirect = false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async dispatch(request, env, ctx) {
|
|
192
|
+
if (this.closed)
|
|
193
|
+
throw new Error("Worker runtime disposed");
|
|
194
|
+
if (this.loadingDirect)
|
|
195
|
+
throw new Error("Direct module initialization is in progress; await runtime.ready before local fetch and do not await local fetch at module top level.");
|
|
196
|
+
await this.ready;
|
|
197
|
+
if (this.closed)
|
|
198
|
+
throw new Error("Worker runtime disposed");
|
|
199
|
+
request.signal.throwIfAborted();
|
|
200
|
+
const remote = await this.source.needsRemote?.(request);
|
|
201
|
+
request.signal.throwIfAborted();
|
|
202
|
+
if (this.closed)
|
|
203
|
+
throw new Error("Worker runtime disposed");
|
|
204
|
+
if (remote) {
|
|
205
|
+
if (!this.remote)
|
|
206
|
+
throw new TypeError("Remote dispatch requires remote.origin; local fallback is not permitted.");
|
|
207
|
+
return this.remote.fetch(request);
|
|
208
|
+
}
|
|
209
|
+
return this.handler.fetch(request, env, ctx);
|
|
210
|
+
}
|
|
211
|
+
close() {
|
|
212
|
+
this.closed = true;
|
|
213
|
+
const pending = [
|
|
214
|
+
() => this.remote?.dispose(),
|
|
215
|
+
() => this.isolated?.dispose(),
|
|
216
|
+
() => this.disposeDirect?.(),
|
|
217
|
+
() => this.releaseNetwork?.(),
|
|
218
|
+
// An import already in flight may return a loader-owned resource later.
|
|
219
|
+
// initialize() disposes that resource when closed; join it before allowing
|
|
220
|
+
// another runtime to acquire globals or native ownership.
|
|
221
|
+
() => this.loadingDirect
|
|
222
|
+
? this.ready.catch(() => { }).then(() => this.startupDisposal)
|
|
223
|
+
: this.startupDisposal,
|
|
224
|
+
]
|
|
225
|
+
.map((close) => {
|
|
226
|
+
try {
|
|
227
|
+
return close();
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
return Promise.reject(error);
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
.filter((value) => value !== undefined);
|
|
234
|
+
if (pending.length)
|
|
235
|
+
return Promise.allSettled(pending)
|
|
236
|
+
.then((results) => {
|
|
237
|
+
const failures = results.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
238
|
+
if (failures.length)
|
|
239
|
+
throw new AggregateError(failures, "Runtime cleanup failed");
|
|
240
|
+
})
|
|
241
|
+
.finally(() => this.restoreWeb?.());
|
|
242
|
+
this.restoreWeb?.();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/** The installer and feature host select execution in exactly the same way. */
|
|
246
|
+
export function createFetchRuntime(options) {
|
|
247
|
+
if (options.prefer !== undefined &&
|
|
248
|
+
!["worker", "direct"].includes(options.prefer))
|
|
249
|
+
throw new TypeError("prefer must be worker or direct.");
|
|
250
|
+
const worker = options.worker ?? configuredWorker;
|
|
251
|
+
if (!worker)
|
|
252
|
+
throw new TypeError("No Worker configured. Set worker in the Vite/esbuild workersCapacitorPlugin, or pass an explicit worker option for browser ESM.");
|
|
253
|
+
const source = worker;
|
|
254
|
+
if (typeof source?.createWorker === "function" &&
|
|
255
|
+
typeof source?.loadDirect === "function")
|
|
256
|
+
return new PreferredFetchRuntime(options, source);
|
|
257
|
+
if (options.remote)
|
|
258
|
+
throw new TypeError("remote requires a build-generated WorkerSource.");
|
|
259
|
+
if (options.prefer !== undefined)
|
|
260
|
+
throw new TypeError("prefer requires both createWorker and loadDirect in a WorkerSource.");
|
|
261
|
+
const hasFetch = typeof worker?.fetch === "function";
|
|
262
|
+
if (!hasFetch && typeof worker !== "function")
|
|
263
|
+
throw new TypeError("worker.fetch is required.");
|
|
264
|
+
return hasFetch
|
|
265
|
+
? new DirectFetchRuntime(options, worker)
|
|
266
|
+
: new IsolatedFetchRuntime(options, worker);
|
|
267
|
+
}
|