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,194 @@
|
|
|
1
|
+
const immutable = new WeakSet();
|
|
2
|
+
/** Internal Fetch guard; constructing a new Headers always creates a mutable copy. */
|
|
3
|
+
export function immutableHeaders(headers) {
|
|
4
|
+
immutable.add(headers);
|
|
5
|
+
return headers;
|
|
6
|
+
}
|
|
7
|
+
export function cloneHeaders(headers) {
|
|
8
|
+
const copy = new Headers(headers);
|
|
9
|
+
return immutable.has(headers) ? immutableHeaders(copy) : copy;
|
|
10
|
+
}
|
|
11
|
+
function writable(headers) {
|
|
12
|
+
if (immutable.has(headers))
|
|
13
|
+
throw new TypeError("Can't modify immutable headers.");
|
|
14
|
+
}
|
|
15
|
+
/** Workers Headers, including UTF-8 values and separate Set-Cookie entries. */
|
|
16
|
+
const invalidName = /[\x00-\x20\x7f()<>@,;:\\"/\[\]?={}]/;
|
|
17
|
+
function string(value) {
|
|
18
|
+
if (typeof value === "symbol")
|
|
19
|
+
throw new TypeError("Cannot convert a Symbol value to a string");
|
|
20
|
+
return String(value);
|
|
21
|
+
}
|
|
22
|
+
// The pinned workerd lowercases UTF-8 byte blocks using its SWAR routine.
|
|
23
|
+
// Retain the raw normalized bytes as the key: decoding them before lookup
|
|
24
|
+
// would merge distinct keys when the baseline produces invalid UTF-8.
|
|
25
|
+
// Adapted from workerd v1.20261012.1 src/workerd/util/strings.c++ (Apache-2.0).
|
|
26
|
+
function utf8(input) {
|
|
27
|
+
const bytes = [];
|
|
28
|
+
for (const character of input) {
|
|
29
|
+
const code = character.codePointAt(0);
|
|
30
|
+
if (code < 0x80)
|
|
31
|
+
bytes.push(code);
|
|
32
|
+
else if (code < 0x800)
|
|
33
|
+
bytes.push(0xc0 | (code >> 6), 0x80 | (code & 63));
|
|
34
|
+
else if (code < 0x10000)
|
|
35
|
+
bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 63), 0x80 | (code & 63));
|
|
36
|
+
else
|
|
37
|
+
bytes.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 63), 0x80 | ((code >> 6) & 63), 0x80 | (code & 63));
|
|
38
|
+
}
|
|
39
|
+
return bytes;
|
|
40
|
+
}
|
|
41
|
+
const decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
42
|
+
function display(key) {
|
|
43
|
+
return decoder.decode(Uint8Array.from(key, (c) => c.charCodeAt(0)));
|
|
44
|
+
}
|
|
45
|
+
function name(input) {
|
|
46
|
+
const text = string(input);
|
|
47
|
+
if (invalidName.test(text))
|
|
48
|
+
throw new TypeError("Invalid header name.");
|
|
49
|
+
const bytes = utf8(text);
|
|
50
|
+
for (let start = 0; start < bytes.length; start += 8) {
|
|
51
|
+
let word = 0n;
|
|
52
|
+
const length = Math.min(8, bytes.length - start);
|
|
53
|
+
for (let i = 0; i < length; i++)
|
|
54
|
+
word |= BigInt(bytes[start + i]) << BigInt(i * 8);
|
|
55
|
+
word ^=
|
|
56
|
+
(((word + 0x3f3f3f3f3f3f3f3fn) ^ (word + 0x2525252525252525n)) &
|
|
57
|
+
0x8080808080808080n) >>
|
|
58
|
+
2n;
|
|
59
|
+
for (let i = 0; i < length; i++)
|
|
60
|
+
bytes[start + i] = Number((word >> BigInt(i * 8)) & 255n);
|
|
61
|
+
}
|
|
62
|
+
return bytes.map((byte) => String.fromCharCode(byte)).join("");
|
|
63
|
+
}
|
|
64
|
+
function required(actual, count, method) {
|
|
65
|
+
if (actual < count)
|
|
66
|
+
throw new TypeError(`Failed to execute '${method}' on 'Headers': parameter ${actual + 1} is not of type 'string'.`);
|
|
67
|
+
}
|
|
68
|
+
function value(input) {
|
|
69
|
+
const result = string(input).replace(/^[\t\n\r ]+|[\t\n\r ]+$/g, "");
|
|
70
|
+
if (/[\0\r\n]/.test(result))
|
|
71
|
+
throw new TypeError("Invalid header value.");
|
|
72
|
+
// workerd stores UTF-8 bytes. An isolated UTF-16 surrogate is encoded as
|
|
73
|
+
// an invalid three-byte sequence, with one replacement per invalid byte.
|
|
74
|
+
return result.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "���");
|
|
75
|
+
}
|
|
76
|
+
export class Headers {
|
|
77
|
+
#fields = new Map();
|
|
78
|
+
constructor(init = undefined) {
|
|
79
|
+
if (init === undefined)
|
|
80
|
+
return;
|
|
81
|
+
if (init === null ||
|
|
82
|
+
(typeof init !== "object" && typeof init !== "function"))
|
|
83
|
+
throw new TypeError("Failed to construct 'Headers': constructor parameter 1 is not of type 'Headers or Sequence or object'.");
|
|
84
|
+
if (#fields in init) {
|
|
85
|
+
this.#fields = new Map([...init.#fields].map(([key, values]) => [key, [...values]]));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const iterator = init[Symbol.iterator];
|
|
89
|
+
if (iterator != null) {
|
|
90
|
+
if (typeof iterator !== "function")
|
|
91
|
+
throw new TypeError("Invalid iterator.");
|
|
92
|
+
// GetMethod is evaluated once, including accessor side effects.
|
|
93
|
+
const iterable = { [Symbol.iterator]: () => iterator.call(init) };
|
|
94
|
+
for (const item of iterable) {
|
|
95
|
+
if (item === null ||
|
|
96
|
+
(typeof item !== "object" && typeof item !== "function") ||
|
|
97
|
+
!(Symbol.iterator in item))
|
|
98
|
+
throw new TypeError("Each header must be a sequence.");
|
|
99
|
+
const pair = [...item];
|
|
100
|
+
if (pair.length !== 2)
|
|
101
|
+
throw new TypeError("To initialize a Headers object from a sequence, each inner sequence must have exactly two elements.");
|
|
102
|
+
this.#append(pair[0], pair[1]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
for (const key of Object.keys(init))
|
|
107
|
+
this.#append(key, init[key]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
append(key, item) {
|
|
111
|
+
required(arguments.length, 2, "append");
|
|
112
|
+
writable(this);
|
|
113
|
+
this.#append(key, item);
|
|
114
|
+
}
|
|
115
|
+
#append(key, item) {
|
|
116
|
+
const normalized = name(key);
|
|
117
|
+
const content = value(item);
|
|
118
|
+
const list = this.#fields.get(normalized);
|
|
119
|
+
if (list)
|
|
120
|
+
list.push(content);
|
|
121
|
+
else
|
|
122
|
+
this.#fields.set(normalized, [content]);
|
|
123
|
+
}
|
|
124
|
+
set(key, item) {
|
|
125
|
+
required(arguments.length, 2, "set");
|
|
126
|
+
writable(this);
|
|
127
|
+
this.#fields.set(name(key), [value(item)]);
|
|
128
|
+
}
|
|
129
|
+
get(key) {
|
|
130
|
+
required(arguments.length, 1, "get");
|
|
131
|
+
return this.#fields.get(name(key))?.join(", ") ?? null;
|
|
132
|
+
}
|
|
133
|
+
has(key) {
|
|
134
|
+
required(arguments.length, 1, "has");
|
|
135
|
+
return this.#fields.has(name(key));
|
|
136
|
+
}
|
|
137
|
+
delete(key) {
|
|
138
|
+
required(arguments.length, 1, "delete");
|
|
139
|
+
writable(this);
|
|
140
|
+
this.#fields.delete(name(key));
|
|
141
|
+
}
|
|
142
|
+
getAll(key) {
|
|
143
|
+
required(arguments.length, 1, "getAll");
|
|
144
|
+
if (string(key).toLowerCase() !== "set-cookie")
|
|
145
|
+
throw new TypeError('getAll() can only be used with the header name "Set-Cookie".');
|
|
146
|
+
return [...(this.#fields.get("set-cookie") ?? [])];
|
|
147
|
+
}
|
|
148
|
+
getSetCookie() {
|
|
149
|
+
return [...(this.#fields.get("set-cookie") ?? [])];
|
|
150
|
+
}
|
|
151
|
+
#entries() {
|
|
152
|
+
return [...this.#fields.keys()]
|
|
153
|
+
.sort()
|
|
154
|
+
.flatMap((key) => {
|
|
155
|
+
const entries = this.#fields.get(key);
|
|
156
|
+
return key === "set-cookie"
|
|
157
|
+
? entries.map((item) => [display(key), item])
|
|
158
|
+
: [[display(key), entries.join(", ")]];
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
entries() {
|
|
162
|
+
return this.#entries()[Symbol.iterator]();
|
|
163
|
+
}
|
|
164
|
+
keys() {
|
|
165
|
+
return this.#entries()
|
|
166
|
+
.map(([key]) => key)[Symbol.iterator]();
|
|
167
|
+
}
|
|
168
|
+
values() {
|
|
169
|
+
return this.#entries()
|
|
170
|
+
.map(([, item]) => item)[Symbol.iterator]();
|
|
171
|
+
}
|
|
172
|
+
forEach(callback, thisArg) {
|
|
173
|
+
if (typeof callback !== "function")
|
|
174
|
+
throw new TypeError("The callback must be a function.");
|
|
175
|
+
for (const [key, item] of this.#entries())
|
|
176
|
+
callback.call(thisArg, item, key, this);
|
|
177
|
+
}
|
|
178
|
+
[Symbol.iterator]() {
|
|
179
|
+
return this.#entries()[Symbol.iterator]();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
Object.defineProperty(Headers, "name", {
|
|
183
|
+
value: "Headers",
|
|
184
|
+
configurable: true,
|
|
185
|
+
});
|
|
186
|
+
for (const key of Object.getOwnPropertyNames(Headers.prototype)) {
|
|
187
|
+
if (key !== "constructor")
|
|
188
|
+
Object.defineProperty(Headers.prototype, key, { enumerable: true });
|
|
189
|
+
}
|
|
190
|
+
Object.defineProperty(Headers.prototype, Symbol.toStringTag, {
|
|
191
|
+
value: "Headers",
|
|
192
|
+
configurable: true,
|
|
193
|
+
writable: true,
|
|
194
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkerHandler } from "../../cloudflare/workers/types.js";
|
|
2
|
+
/** Internal Dedicated Worker transport. */
|
|
3
|
+
export declare function createIsolatedWorker<Env>(worker: Worker): {
|
|
4
|
+
handler: WorkerHandler<Env>;
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
readonly activeCalls: number;
|
|
7
|
+
dispose(): Promise<void> | undefined;
|
|
8
|
+
};
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { createNetworkRelay } from "../fetch/relay.js";
|
|
2
|
+
/** Internal Dedicated Worker transport. */
|
|
3
|
+
export function createIsolatedWorker(worker) {
|
|
4
|
+
const network = createNetworkRelay(worker);
|
|
5
|
+
const calls = new Set();
|
|
6
|
+
let failure;
|
|
7
|
+
let started;
|
|
8
|
+
let startupFailed;
|
|
9
|
+
const ready = new Promise((resolve, reject) => {
|
|
10
|
+
started = resolve;
|
|
11
|
+
startupFailed = reject;
|
|
12
|
+
});
|
|
13
|
+
// A startup failure may precede the first fetch/observer.
|
|
14
|
+
void ready.catch(() => { });
|
|
15
|
+
const stop = (error) => {
|
|
16
|
+
failure ??= error;
|
|
17
|
+
startupFailed(failure);
|
|
18
|
+
for (const fail of calls)
|
|
19
|
+
fail(failure);
|
|
20
|
+
worker.terminate();
|
|
21
|
+
return network.dispose();
|
|
22
|
+
};
|
|
23
|
+
worker.onmessage = (event) => {
|
|
24
|
+
network.receive(event);
|
|
25
|
+
const { data } = event;
|
|
26
|
+
if (data.type === "ready")
|
|
27
|
+
started();
|
|
28
|
+
// Module top-level-await rejection does not reliably dispatch Worker.onerror
|
|
29
|
+
// in older WebKit. The generated bootstrap explicitly reports startup errors.
|
|
30
|
+
if (data.type === "startup-error") {
|
|
31
|
+
const error = new Error(data.message);
|
|
32
|
+
error.name = data.name;
|
|
33
|
+
void stop(error)?.catch(console.error);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
worker.onerror = (event) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
void stop(new Error(event.message || "Worker startup failed"))?.catch(console.error);
|
|
39
|
+
};
|
|
40
|
+
worker.onmessageerror = () => void stop(new Error("Worker message could not be decoded"))?.catch(console.error);
|
|
41
|
+
const handler = {
|
|
42
|
+
async fetch(request, env, ctx) {
|
|
43
|
+
if (failure)
|
|
44
|
+
throw failure;
|
|
45
|
+
request.signal.throwIfAborted();
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const { port1, port2 } = new MessageChannel();
|
|
48
|
+
let backgroundDone = false;
|
|
49
|
+
let bodyDone = false;
|
|
50
|
+
let released = false;
|
|
51
|
+
let dispatched = false;
|
|
52
|
+
let upload;
|
|
53
|
+
let uploadChunk;
|
|
54
|
+
let uploadBusy = false;
|
|
55
|
+
let uploadDone = false;
|
|
56
|
+
const stopUpload = (reason) => {
|
|
57
|
+
if (uploadDone)
|
|
58
|
+
return;
|
|
59
|
+
uploadDone = true;
|
|
60
|
+
const reader = upload;
|
|
61
|
+
upload = undefined;
|
|
62
|
+
uploadChunk = undefined;
|
|
63
|
+
if (reader) {
|
|
64
|
+
void reader.cancel(reason).catch(() => { });
|
|
65
|
+
reader.releaseLock();
|
|
66
|
+
}
|
|
67
|
+
else
|
|
68
|
+
void request.body?.cancel(reason).catch(() => { });
|
|
69
|
+
};
|
|
70
|
+
const pullUpload = async () => {
|
|
71
|
+
if (uploadBusy || released || uploadDone)
|
|
72
|
+
return;
|
|
73
|
+
uploadBusy = true;
|
|
74
|
+
try {
|
|
75
|
+
upload ??= request.body.getReader();
|
|
76
|
+
if (!uploadChunk?.byteLength) {
|
|
77
|
+
const next = await upload.read();
|
|
78
|
+
if (released || uploadDone)
|
|
79
|
+
return;
|
|
80
|
+
if (next.done) {
|
|
81
|
+
uploadDone = true;
|
|
82
|
+
upload.releaseLock();
|
|
83
|
+
upload = undefined;
|
|
84
|
+
uploadChunk = undefined;
|
|
85
|
+
send({ type: "upload-end" });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!(next.value instanceof Uint8Array))
|
|
89
|
+
throw new TypeError("Request body must contain Uint8Array chunks.");
|
|
90
|
+
uploadChunk = next.value;
|
|
91
|
+
}
|
|
92
|
+
const value = uploadChunk.slice(0, 65536);
|
|
93
|
+
uploadChunk =
|
|
94
|
+
uploadChunk.byteLength > value.byteLength
|
|
95
|
+
? uploadChunk.subarray(value.byteLength)
|
|
96
|
+
: undefined;
|
|
97
|
+
port1.postMessage({ type: "upload-chunk", value }, [value.buffer]);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (!released && !uploadDone) {
|
|
101
|
+
send({ type: "upload-error", message: String(error) });
|
|
102
|
+
fail(error);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
uploadBusy = false;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
let stream;
|
|
110
|
+
let pulled;
|
|
111
|
+
let cancelled;
|
|
112
|
+
let done;
|
|
113
|
+
ctx.waitUntil(new Promise((resolve) => {
|
|
114
|
+
done = resolve;
|
|
115
|
+
}));
|
|
116
|
+
const send = (command) => port1.postMessage(command);
|
|
117
|
+
const release = () => {
|
|
118
|
+
if (released || !bodyDone || !backgroundDone)
|
|
119
|
+
return;
|
|
120
|
+
released = true;
|
|
121
|
+
request.signal.removeEventListener("abort", abort);
|
|
122
|
+
port1.close();
|
|
123
|
+
if (!dispatched)
|
|
124
|
+
port2.close();
|
|
125
|
+
stopUpload();
|
|
126
|
+
calls.delete(fail);
|
|
127
|
+
};
|
|
128
|
+
const finishBody = (...failure) => {
|
|
129
|
+
const [error] = failure;
|
|
130
|
+
if (!bodyDone) {
|
|
131
|
+
bodyDone = true;
|
|
132
|
+
if (failure.length)
|
|
133
|
+
stream?.error(error);
|
|
134
|
+
else
|
|
135
|
+
stream?.close();
|
|
136
|
+
}
|
|
137
|
+
pulled?.();
|
|
138
|
+
pulled = undefined;
|
|
139
|
+
if (failure.length)
|
|
140
|
+
cancelled?.reject(error);
|
|
141
|
+
else
|
|
142
|
+
cancelled?.resolve();
|
|
143
|
+
cancelled = undefined;
|
|
144
|
+
release();
|
|
145
|
+
};
|
|
146
|
+
const fail = (error) => {
|
|
147
|
+
if (released)
|
|
148
|
+
return;
|
|
149
|
+
stopUpload(error);
|
|
150
|
+
reject(error);
|
|
151
|
+
backgroundDone = true;
|
|
152
|
+
done();
|
|
153
|
+
finishBody(error);
|
|
154
|
+
};
|
|
155
|
+
const abort = () => {
|
|
156
|
+
if (!dispatched) {
|
|
157
|
+
fail(request.signal.reason);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
send("abort");
|
|
161
|
+
fail(request.signal.reason);
|
|
162
|
+
};
|
|
163
|
+
calls.add(fail);
|
|
164
|
+
request.signal.addEventListener("abort", abort, { once: true });
|
|
165
|
+
port1.onmessageerror = () => fail(new Error("Response message could not be decoded"));
|
|
166
|
+
port1.onmessage = ({ data }) => {
|
|
167
|
+
if (released)
|
|
168
|
+
return;
|
|
169
|
+
if (data.type === "upload-pull") {
|
|
170
|
+
void pullUpload();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (data.type === "upload-cancel") {
|
|
174
|
+
stopUpload();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (data.type === "response") {
|
|
178
|
+
if (request.signal.aborted) {
|
|
179
|
+
send("cancel");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const responseBody = data.hasBody
|
|
183
|
+
? new ReadableStream({
|
|
184
|
+
start(controller) {
|
|
185
|
+
stream = controller;
|
|
186
|
+
},
|
|
187
|
+
pull() {
|
|
188
|
+
return new Promise((resolve) => {
|
|
189
|
+
pulled = resolve;
|
|
190
|
+
send("pull");
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
cancel() {
|
|
194
|
+
stream = undefined;
|
|
195
|
+
pulled?.();
|
|
196
|
+
pulled = undefined;
|
|
197
|
+
return new Promise((resolve, reject) => {
|
|
198
|
+
cancelled = { resolve, reject };
|
|
199
|
+
send("cancel");
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
}, { highWaterMark: 0 })
|
|
203
|
+
: null;
|
|
204
|
+
bodyDone = !data.hasBody;
|
|
205
|
+
try {
|
|
206
|
+
resolve(new Response(responseBody, {
|
|
207
|
+
status: data.status,
|
|
208
|
+
statusText: data.statusText,
|
|
209
|
+
headers: data.headers,
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
send("cancel");
|
|
214
|
+
fail(error);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else if (data.type === "chunk") {
|
|
218
|
+
if (!bodyDone)
|
|
219
|
+
stream?.enqueue(data.value);
|
|
220
|
+
pulled?.();
|
|
221
|
+
pulled = undefined;
|
|
222
|
+
}
|
|
223
|
+
else if (data.type === "end") {
|
|
224
|
+
finishBody();
|
|
225
|
+
}
|
|
226
|
+
else if (data.type === "error") {
|
|
227
|
+
const error = new Error(data.message);
|
|
228
|
+
error.name = data.name;
|
|
229
|
+
reject(error);
|
|
230
|
+
finishBody(error);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
for (const error of data.errors)
|
|
234
|
+
ctx.waitUntil(Promise.reject(new Error(error)));
|
|
235
|
+
backgroundDone = true;
|
|
236
|
+
done();
|
|
237
|
+
}
|
|
238
|
+
release();
|
|
239
|
+
};
|
|
240
|
+
void (async () => {
|
|
241
|
+
await ready;
|
|
242
|
+
if (released)
|
|
243
|
+
return;
|
|
244
|
+
worker.postMessage({
|
|
245
|
+
port: port2,
|
|
246
|
+
url: request.url,
|
|
247
|
+
method: request.method,
|
|
248
|
+
headers: [...request.headers],
|
|
249
|
+
hasBody: request.body !== null,
|
|
250
|
+
env,
|
|
251
|
+
}, [port2]);
|
|
252
|
+
dispatched = true;
|
|
253
|
+
})().catch(fail);
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
handler,
|
|
259
|
+
ready,
|
|
260
|
+
get activeCalls() {
|
|
261
|
+
return calls.size;
|
|
262
|
+
},
|
|
263
|
+
dispose() {
|
|
264
|
+
return stop(new Error("Worker runtime disposed"));
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface Invocation {
|
|
2
|
+
port: MessagePort;
|
|
3
|
+
url: string;
|
|
4
|
+
method: string;
|
|
5
|
+
headers: [string, string][];
|
|
6
|
+
hasBody: boolean;
|
|
7
|
+
env: unknown;
|
|
8
|
+
}
|
|
9
|
+
export type Command = "pull" | "cancel" | "abort" | {
|
|
10
|
+
type: "upload-chunk";
|
|
11
|
+
value: Uint8Array;
|
|
12
|
+
} | {
|
|
13
|
+
type: "upload-end";
|
|
14
|
+
} | {
|
|
15
|
+
type: "upload-error";
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
export type Reply = {
|
|
19
|
+
type: "upload-pull";
|
|
20
|
+
} | {
|
|
21
|
+
type: "upload-cancel";
|
|
22
|
+
} | {
|
|
23
|
+
type: "response";
|
|
24
|
+
status: number;
|
|
25
|
+
statusText: string;
|
|
26
|
+
headers: [string, string][];
|
|
27
|
+
hasBody: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
type: "chunk";
|
|
30
|
+
value: Uint8Array;
|
|
31
|
+
} | {
|
|
32
|
+
type: "end";
|
|
33
|
+
} | {
|
|
34
|
+
type: "error";
|
|
35
|
+
name: string;
|
|
36
|
+
message: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: "done";
|
|
39
|
+
errors: string[];
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { setWorkerEnv } from "../../cloudflare/apis/cloudflare-workers/index.js";
|
|
2
|
+
import { isResponse } from "../fetch/interop.js";
|
|
3
|
+
import { Request as WorkerRequest } from "../request/index.js";
|
|
4
|
+
export function serve(worker) {
|
|
5
|
+
// Both directions are pull-driven; chunks are bounded without transferable streams.
|
|
6
|
+
self.onmessage = async ({ data }) => {
|
|
7
|
+
const { port, url, method, headers, hasBody, env } = data;
|
|
8
|
+
const controller = new AbortController();
|
|
9
|
+
let reader;
|
|
10
|
+
let bodyDone = false;
|
|
11
|
+
let cancelling = false;
|
|
12
|
+
let backgroundDone = false;
|
|
13
|
+
const send = (reply) => port.postMessage(reply);
|
|
14
|
+
let uploadController;
|
|
15
|
+
let uploadPulled;
|
|
16
|
+
let uploadDone = !hasBody;
|
|
17
|
+
const stopUpload = (reason) => {
|
|
18
|
+
if (uploadDone)
|
|
19
|
+
return;
|
|
20
|
+
uploadDone = true;
|
|
21
|
+
uploadController?.error(reason);
|
|
22
|
+
uploadPulled?.();
|
|
23
|
+
send({ type: "upload-cancel" });
|
|
24
|
+
};
|
|
25
|
+
const body = hasBody
|
|
26
|
+
? new ReadableStream({
|
|
27
|
+
start(controller) {
|
|
28
|
+
uploadController = controller;
|
|
29
|
+
},
|
|
30
|
+
pull() {
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
uploadPulled = resolve;
|
|
33
|
+
send({ type: "upload-pull" });
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
cancel() {
|
|
37
|
+
uploadDone = true;
|
|
38
|
+
uploadPulled?.();
|
|
39
|
+
send({ type: "upload-cancel" });
|
|
40
|
+
},
|
|
41
|
+
}, { highWaterMark: 0 })
|
|
42
|
+
: null;
|
|
43
|
+
const close = () => {
|
|
44
|
+
if (bodyDone && backgroundDone) {
|
|
45
|
+
stopUpload(new Error("Response completed"));
|
|
46
|
+
port.close();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const end = () => {
|
|
50
|
+
if (!bodyDone) {
|
|
51
|
+
bodyDone = true;
|
|
52
|
+
send({ type: "end" });
|
|
53
|
+
}
|
|
54
|
+
close();
|
|
55
|
+
};
|
|
56
|
+
const error = (cause) => {
|
|
57
|
+
bodyDone = true;
|
|
58
|
+
send({
|
|
59
|
+
type: "error",
|
|
60
|
+
name: cause instanceof Error ? cause.name : "Error",
|
|
61
|
+
message: String(cause),
|
|
62
|
+
});
|
|
63
|
+
close();
|
|
64
|
+
};
|
|
65
|
+
port.onmessage = async ({ data }) => {
|
|
66
|
+
try {
|
|
67
|
+
if (typeof data === "object") {
|
|
68
|
+
if (!uploadDone) {
|
|
69
|
+
if (data.type === "upload-chunk")
|
|
70
|
+
uploadController.enqueue(data.value);
|
|
71
|
+
else {
|
|
72
|
+
uploadDone = true;
|
|
73
|
+
if (data.type === "upload-end")
|
|
74
|
+
uploadController.close();
|
|
75
|
+
else
|
|
76
|
+
uploadController.error(new Error(data.message));
|
|
77
|
+
}
|
|
78
|
+
uploadPulled?.();
|
|
79
|
+
uploadPulled = undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (data === "abort") {
|
|
83
|
+
controller.abort();
|
|
84
|
+
stopUpload(controller.signal.reason);
|
|
85
|
+
if (reader) {
|
|
86
|
+
cancelling = true;
|
|
87
|
+
await reader.cancel();
|
|
88
|
+
end();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (data === "cancel") {
|
|
92
|
+
cancelling = true;
|
|
93
|
+
await reader?.cancel();
|
|
94
|
+
end();
|
|
95
|
+
}
|
|
96
|
+
else if (data === "pull" && reader && !bodyDone) {
|
|
97
|
+
const chunk = await reader.read();
|
|
98
|
+
if (cancelling)
|
|
99
|
+
return;
|
|
100
|
+
if (chunk.done)
|
|
101
|
+
end();
|
|
102
|
+
else if (!bodyDone)
|
|
103
|
+
send({ type: "chunk", value: chunk.value });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (cause) {
|
|
107
|
+
error(cause);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const pending = [];
|
|
111
|
+
const errors = [];
|
|
112
|
+
try {
|
|
113
|
+
setWorkerEnv(env);
|
|
114
|
+
const request = new WorkerRequest(url, {
|
|
115
|
+
method,
|
|
116
|
+
headers,
|
|
117
|
+
body,
|
|
118
|
+
signal: controller.signal,
|
|
119
|
+
});
|
|
120
|
+
const response = await worker.fetch(request, env, {
|
|
121
|
+
props: {},
|
|
122
|
+
passThroughOnException() {
|
|
123
|
+
throw new Error("passThroughOnException is unsupported for local execution.");
|
|
124
|
+
},
|
|
125
|
+
waitUntil(promise) {
|
|
126
|
+
pending.push(promise.catch((cause) => {
|
|
127
|
+
errors.push(String(cause));
|
|
128
|
+
}));
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
if (!isResponse(response) || response.status === 0)
|
|
132
|
+
throw new TypeError("worker.fetch must return a non-error Response.");
|
|
133
|
+
if (response.bodyUsed || response.body?.locked)
|
|
134
|
+
throw new TypeError("worker.fetch returned an unusable response body.");
|
|
135
|
+
reader = response.body?.getReader();
|
|
136
|
+
bodyDone = !reader;
|
|
137
|
+
send({
|
|
138
|
+
type: "response",
|
|
139
|
+
status: response.status,
|
|
140
|
+
statusText: response.statusText,
|
|
141
|
+
headers: [...response.headers],
|
|
142
|
+
hasBody: !!reader,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
catch (cause) {
|
|
146
|
+
error(cause);
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
while (pending.length)
|
|
150
|
+
await Promise.all(pending.splice(0));
|
|
151
|
+
send({ type: "done", errors });
|
|
152
|
+
backgroundDone = true;
|
|
153
|
+
close();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
self.postMessage({ type: "ready" });
|
|
157
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The request adapter's Workers-specific validation, defaults, and status behavior
|
|
4
|
+
are adapted from Cloudflare workerd v1.20261012.1,
|
|
5
|
+
`src/workerd/api/http.c++`.
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
8
|
+
Licensed under the Apache License, Version 2.0; see LICENSE-APACHE.
|
|
9
|
+
|
|
10
|
+
Source: https://github.com/cloudflare/workerd/blob/v1.20261012.1/src/workerd/api/http.c%2B%2B
|