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,518 @@
|
|
|
1
|
+
// node:string_decoder compatibility unit.
|
|
2
|
+
//
|
|
3
|
+
// Reproduces the Workers shell semantics of workerd 1.20261012.1
|
|
4
|
+
// (src/node/internal/internal_stringdecoder.ts): a function constructor,
|
|
5
|
+
// prototype write/end/text methods, enumerable prototype getters for
|
|
6
|
+
// lastChar/lastNeed/lastTotal, and the Workers encoding normalization
|
|
7
|
+
// (null/undefined/'' all normalize to utf8). The utf8 core is implemented
|
|
8
|
+
// locally because Workers emits each invalid byte through its own
|
|
9
|
+
// WHATWG-style decoder (unlike the npm package's single-replacement
|
|
10
|
+
// flush); the other encodings delegate to the maintained `string_decoder`
|
|
11
|
+
// npm package, whose observable behavior matches workerd for
|
|
12
|
+
// utf16le/latin1/ascii/hex/base64.
|
|
13
|
+
// See LICENSE-3RD-PARTY.md for licenses.
|
|
14
|
+
import { Buffer } from "node:buffer";
|
|
15
|
+
import { StringDecoder as UpstreamStringDecoder } from "string_decoder/lib/string_decoder.js";
|
|
16
|
+
const classRegExp = /^([A-Z][a-z0-9]*)+$/;
|
|
17
|
+
const kTypes = [
|
|
18
|
+
"string",
|
|
19
|
+
"function",
|
|
20
|
+
"number",
|
|
21
|
+
"object",
|
|
22
|
+
"Function",
|
|
23
|
+
"Object",
|
|
24
|
+
"boolean",
|
|
25
|
+
"bigint",
|
|
26
|
+
"symbol",
|
|
27
|
+
];
|
|
28
|
+
function inspect(input) {
|
|
29
|
+
if (typeof input === "string")
|
|
30
|
+
return `'${input}'`;
|
|
31
|
+
if (typeof input === "symbol")
|
|
32
|
+
return String(input);
|
|
33
|
+
if (typeof input === "object" && input !== null) {
|
|
34
|
+
// Fixed rendering for constructor-less objects: never enumerates
|
|
35
|
+
// properties and never invokes getters, so cyclic inputs and
|
|
36
|
+
// side-effectful properties cannot fail or run user code here.
|
|
37
|
+
if (Array.isArray(input))
|
|
38
|
+
return "[ Array ]";
|
|
39
|
+
return Object.getPrototypeOf(input) === null
|
|
40
|
+
? "[Object: null prototype] {}"
|
|
41
|
+
: "{}";
|
|
42
|
+
}
|
|
43
|
+
return `${input}`;
|
|
44
|
+
}
|
|
45
|
+
function createInvalidArgType(name, expected) {
|
|
46
|
+
const expectedList = Array.isArray(expected) ? expected : [expected];
|
|
47
|
+
let msg = "The ";
|
|
48
|
+
if (name.endsWith(" argument")) {
|
|
49
|
+
msg += `${name} `;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
53
|
+
msg += `"${name}" ${type} `;
|
|
54
|
+
}
|
|
55
|
+
msg += "must be ";
|
|
56
|
+
const types = [];
|
|
57
|
+
const instances = [];
|
|
58
|
+
const other = [];
|
|
59
|
+
for (const value of expectedList) {
|
|
60
|
+
if (kTypes.includes(value)) {
|
|
61
|
+
types.push(value.toLocaleLowerCase());
|
|
62
|
+
}
|
|
63
|
+
else if (classRegExp.test(value)) {
|
|
64
|
+
instances.push(value);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
other.push(value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (instances.length > 0) {
|
|
71
|
+
const pos = types.indexOf("object");
|
|
72
|
+
if (pos !== -1) {
|
|
73
|
+
types.splice(pos, 1);
|
|
74
|
+
instances.push("Object");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (types.length > 0) {
|
|
78
|
+
if (types.length > 2) {
|
|
79
|
+
const last = types.pop();
|
|
80
|
+
msg += `one of type ${types.join(", ")}, or ${last}`;
|
|
81
|
+
}
|
|
82
|
+
else if (types.length === 2) {
|
|
83
|
+
msg += `one of type ${types[0]} or ${types[1]}`;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
msg += `of type ${types[0]}`;
|
|
87
|
+
}
|
|
88
|
+
if (instances.length > 0 || other.length > 0) {
|
|
89
|
+
msg += " or ";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (instances.length > 0) {
|
|
93
|
+
if (instances.length > 2) {
|
|
94
|
+
const last = instances.pop();
|
|
95
|
+
msg += `an instance of ${instances.join(", ")}, or ${last}`;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
msg += `an instance of ${instances[0]}`;
|
|
99
|
+
if (instances.length === 2) {
|
|
100
|
+
msg += ` or ${instances[1]}`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (other.length > 0) {
|
|
104
|
+
msg += " or ";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (other.length > 0) {
|
|
108
|
+
if (other.length > 2) {
|
|
109
|
+
const last = other.pop();
|
|
110
|
+
msg += `one of ${other.join(", ")}, or ${last}`;
|
|
111
|
+
}
|
|
112
|
+
else if (other.length === 2) {
|
|
113
|
+
msg += `one of ${other[0]} or ${other[1]}`;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const first = other[0];
|
|
117
|
+
if (first.toLowerCase() !== first) {
|
|
118
|
+
msg += "an ";
|
|
119
|
+
}
|
|
120
|
+
msg += `${first}`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return msg;
|
|
124
|
+
}
|
|
125
|
+
function invalidArgTypeHelper(input) {
|
|
126
|
+
if (input == null) {
|
|
127
|
+
return ` Received ${input}`;
|
|
128
|
+
}
|
|
129
|
+
if (typeof input === "function" && input.name) {
|
|
130
|
+
return ` Received function ${input.name}`;
|
|
131
|
+
}
|
|
132
|
+
if (typeof input === "object") {
|
|
133
|
+
const ctor = input.constructor;
|
|
134
|
+
if (ctor?.name) {
|
|
135
|
+
return ` Received an instance of ${ctor.name}`;
|
|
136
|
+
}
|
|
137
|
+
return ` Received ${inspect(input)}`;
|
|
138
|
+
}
|
|
139
|
+
let inspected = inspect(input);
|
|
140
|
+
if (inspected.length > 25) {
|
|
141
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
142
|
+
}
|
|
143
|
+
return ` Received type ${typeof input} (${inspected})`;
|
|
144
|
+
}
|
|
145
|
+
class ERR_INVALID_ARG_TYPE extends TypeError {
|
|
146
|
+
code;
|
|
147
|
+
constructor(name, expected, actual) {
|
|
148
|
+
super(`${createInvalidArgType(name, expected)}.${invalidArgTypeHelper(actual)}`);
|
|
149
|
+
this.code = "ERR_INVALID_ARG_TYPE";
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
class ERR_INVALID_THIS extends TypeError {
|
|
153
|
+
code;
|
|
154
|
+
constructor(x) {
|
|
155
|
+
super(`Value of "this" must be of type ${x}`);
|
|
156
|
+
this.code = "ERR_INVALID_THIS";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
class ERR_UNKNOWN_ENCODING extends TypeError {
|
|
160
|
+
code;
|
|
161
|
+
constructor(x) {
|
|
162
|
+
super(`Unknown encoding: ${x}`);
|
|
163
|
+
this.code = "ERR_UNKNOWN_ENCODING";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// The order of this array mirrors workerd's encoding enum.
|
|
167
|
+
const encodings = [
|
|
168
|
+
"ascii",
|
|
169
|
+
"latin1",
|
|
170
|
+
"utf8",
|
|
171
|
+
"utf16le",
|
|
172
|
+
"base64",
|
|
173
|
+
"base64url",
|
|
174
|
+
"hex",
|
|
175
|
+
];
|
|
176
|
+
// workerd's getEncodingOps/normalizeEncoding: null, undefined and the
|
|
177
|
+
// empty string all normalize to utf8, unlike Node which throws for them.
|
|
178
|
+
function getEncodingOps(enc) {
|
|
179
|
+
if (enc === undefined)
|
|
180
|
+
return "utf8";
|
|
181
|
+
const encoding = `${enc}`;
|
|
182
|
+
switch (encoding.length) {
|
|
183
|
+
case 4:
|
|
184
|
+
if (encoding === "UTF8")
|
|
185
|
+
return "utf8";
|
|
186
|
+
if (encoding === "ucs2" || encoding === "UCS2")
|
|
187
|
+
return "utf16le";
|
|
188
|
+
{
|
|
189
|
+
const lowered = encoding.toLowerCase();
|
|
190
|
+
if (lowered === "utf8")
|
|
191
|
+
return "utf8";
|
|
192
|
+
if (lowered === "ucs2")
|
|
193
|
+
return "utf16le";
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
case 3:
|
|
197
|
+
if (encoding === "hex" ||
|
|
198
|
+
encoding === "HEX" ||
|
|
199
|
+
encoding.toLowerCase() === "hex") {
|
|
200
|
+
return "hex";
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
case 5:
|
|
204
|
+
if (encoding === "ascii")
|
|
205
|
+
return "ascii";
|
|
206
|
+
if (encoding === "ucs-2")
|
|
207
|
+
return "utf16le";
|
|
208
|
+
if (encoding === "UTF-8")
|
|
209
|
+
return "utf8";
|
|
210
|
+
if (encoding === "ASCII")
|
|
211
|
+
return "ascii";
|
|
212
|
+
if (encoding === "UCS-2")
|
|
213
|
+
return "utf16le";
|
|
214
|
+
{
|
|
215
|
+
const lowered = encoding.toLowerCase();
|
|
216
|
+
if (lowered === "utf-8")
|
|
217
|
+
return "utf8";
|
|
218
|
+
if (lowered === "ascii")
|
|
219
|
+
return "ascii";
|
|
220
|
+
if (lowered === "ucs-2")
|
|
221
|
+
return "utf16le";
|
|
222
|
+
}
|
|
223
|
+
break;
|
|
224
|
+
case 6:
|
|
225
|
+
if (encoding === "base64")
|
|
226
|
+
return "base64";
|
|
227
|
+
if (encoding === "latin1" || encoding === "binary")
|
|
228
|
+
return "latin1";
|
|
229
|
+
if (encoding === "BASE64")
|
|
230
|
+
return "base64";
|
|
231
|
+
if (encoding === "LATIN1" || encoding === "BINARY")
|
|
232
|
+
return "latin1";
|
|
233
|
+
{
|
|
234
|
+
const lowered = encoding.toLowerCase();
|
|
235
|
+
if (lowered === "base64")
|
|
236
|
+
return "base64";
|
|
237
|
+
if (lowered === "latin1" || lowered === "binary")
|
|
238
|
+
return "latin1";
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
case 7:
|
|
242
|
+
if (encoding === "utf16le" ||
|
|
243
|
+
encoding === "UTF16LE" ||
|
|
244
|
+
encoding.toLowerCase() === "utf16le") {
|
|
245
|
+
return "utf16le";
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case 8:
|
|
249
|
+
if (encoding === "utf-16le" ||
|
|
250
|
+
encoding === "UTF-16LE" ||
|
|
251
|
+
encoding.toLowerCase() === "utf-16le") {
|
|
252
|
+
return "utf16le";
|
|
253
|
+
}
|
|
254
|
+
break;
|
|
255
|
+
case 9:
|
|
256
|
+
if (encoding === "base64url" ||
|
|
257
|
+
encoding === "BASE64URL" ||
|
|
258
|
+
encoding.toLowerCase() === "base64url") {
|
|
259
|
+
return "base64url";
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
default:
|
|
263
|
+
if (encoding === "")
|
|
264
|
+
return "utf8";
|
|
265
|
+
}
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
function normalizeEncoding(enc) {
|
|
269
|
+
if (enc == null ||
|
|
270
|
+
enc === "utf8" ||
|
|
271
|
+
enc === "utf-8" ||
|
|
272
|
+
enc === "UTF8" ||
|
|
273
|
+
enc === "UTF-8")
|
|
274
|
+
return "utf8";
|
|
275
|
+
return getEncodingOps(enc);
|
|
276
|
+
}
|
|
277
|
+
const kCore = Symbol("kCore");
|
|
278
|
+
// workerd flushes incomplete state per byte (WHATWG-style) and clears the
|
|
279
|
+
// counters on flush; the upstream package reports the same buffered bytes
|
|
280
|
+
// and counters during write, so only normalization is needed.
|
|
281
|
+
class UpstreamCore {
|
|
282
|
+
upstream;
|
|
283
|
+
transform;
|
|
284
|
+
lastChar = Buffer.alloc(4);
|
|
285
|
+
#lastNeed = 0;
|
|
286
|
+
#lastTotal = 0;
|
|
287
|
+
constructor(upstream, transform) {
|
|
288
|
+
this.upstream = upstream;
|
|
289
|
+
this.transform = transform;
|
|
290
|
+
// Give the upstream decoder the same 4-byte zero-initialized window
|
|
291
|
+
// workerd exposes (the package sizes it per encoding and leaves it
|
|
292
|
+
// absent for single-byte encodings).
|
|
293
|
+
const state = upstream;
|
|
294
|
+
state.lastChar = this.lastChar;
|
|
295
|
+
state.lastNeed = 0;
|
|
296
|
+
state.lastTotal = 0;
|
|
297
|
+
}
|
|
298
|
+
get lastNeed() {
|
|
299
|
+
return this.#lastNeed;
|
|
300
|
+
}
|
|
301
|
+
get lastTotal() {
|
|
302
|
+
return this.#lastTotal;
|
|
303
|
+
}
|
|
304
|
+
#sync() {
|
|
305
|
+
const state = this.upstream;
|
|
306
|
+
this.#lastNeed = state.lastNeed ?? 0;
|
|
307
|
+
this.#lastTotal = this.#lastNeed === 0 ? 0 : (state.lastTotal ?? 0);
|
|
308
|
+
}
|
|
309
|
+
write(buf) {
|
|
310
|
+
const out = this.transform(this.upstream.write(buf));
|
|
311
|
+
this.#sync();
|
|
312
|
+
return out;
|
|
313
|
+
}
|
|
314
|
+
end() {
|
|
315
|
+
const out = this.transform(this.upstream.end());
|
|
316
|
+
// workerd clears the pending state entirely at end(); the upstream
|
|
317
|
+
// package leaves its counters stale and would re-consume the dead
|
|
318
|
+
// window bytes on the next write. The window contents stay visible.
|
|
319
|
+
const state = this.upstream;
|
|
320
|
+
state.lastNeed = 0;
|
|
321
|
+
state.lastTotal = 0;
|
|
322
|
+
this.#lastNeed = 0;
|
|
323
|
+
this.#lastTotal = 0;
|
|
324
|
+
return out;
|
|
325
|
+
}
|
|
326
|
+
reset() {
|
|
327
|
+
const state = this.upstream;
|
|
328
|
+
state.lastNeed = 0;
|
|
329
|
+
state.lastTotal = 0;
|
|
330
|
+
this.#lastNeed = 0;
|
|
331
|
+
this.#lastTotal = 0;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// UTF-8 uses Workers' own emission semantics: an incomplete valid sequence
|
|
335
|
+
// prefix is held, invalid bytes each produce a replacement character, and
|
|
336
|
+
// end() flushes the held bytes through the same per-byte decoding.
|
|
337
|
+
class Utf8Core {
|
|
338
|
+
lastChar = new Uint8Array(4);
|
|
339
|
+
lastNeed = 0;
|
|
340
|
+
lastTotal = 0;
|
|
341
|
+
#decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
342
|
+
// Returns the start and expected total length of the trailing
|
|
343
|
+
// incomplete-but-valid UTF-8 prefix, or start -1 when the buffer ends
|
|
344
|
+
// cleanly.
|
|
345
|
+
static #pendingLength(buf) {
|
|
346
|
+
const len = buf.length;
|
|
347
|
+
for (let i = 0; i < 4 && i < len; i++) {
|
|
348
|
+
const byte = buf[len - 1 - i];
|
|
349
|
+
const kind = Utf8Core.#kind(byte);
|
|
350
|
+
if (kind === -1)
|
|
351
|
+
continue; // continuation byte
|
|
352
|
+
if (kind === 0 || kind === -2)
|
|
353
|
+
return { start: -1, total: 0 };
|
|
354
|
+
// kind is the expected sequence length of a lead byte.
|
|
355
|
+
return i + 1 < kind
|
|
356
|
+
? { start: len - 1 - i, total: kind }
|
|
357
|
+
: { start: -1, total: 0 };
|
|
358
|
+
}
|
|
359
|
+
return { start: -1, total: 0 };
|
|
360
|
+
}
|
|
361
|
+
static #kind(byte) {
|
|
362
|
+
if (byte <= 0x7f)
|
|
363
|
+
return 0;
|
|
364
|
+
if (byte >> 5 === 0x06)
|
|
365
|
+
return 2;
|
|
366
|
+
if (byte >> 4 === 0x0e)
|
|
367
|
+
return 3;
|
|
368
|
+
if (byte >> 3 === 0x1e)
|
|
369
|
+
return 4;
|
|
370
|
+
return byte >> 6 === 0x02 ? -1 : -2;
|
|
371
|
+
}
|
|
372
|
+
write(buf) {
|
|
373
|
+
if (buf.length === 0)
|
|
374
|
+
return "";
|
|
375
|
+
let out = "";
|
|
376
|
+
let i = 0;
|
|
377
|
+
// Continuation bytes consumed while a sequence is pending are appended
|
|
378
|
+
// to the window; the bytes stay visible even after the counters reset.
|
|
379
|
+
if (this.lastNeed > 0) {
|
|
380
|
+
let buffered = this.lastTotal - this.lastNeed;
|
|
381
|
+
while (i < buf.length && this.lastNeed > 0) {
|
|
382
|
+
const byte = buf[i];
|
|
383
|
+
if (Utf8Core.#kind(byte) !== -1)
|
|
384
|
+
break;
|
|
385
|
+
this.lastChar[buffered++] = byte;
|
|
386
|
+
this.lastNeed--;
|
|
387
|
+
i++;
|
|
388
|
+
}
|
|
389
|
+
if (this.lastNeed === 0) {
|
|
390
|
+
// Sequence filled; emit it even when its bytes turn out invalid.
|
|
391
|
+
out += this.#decoder.decode(this.lastChar.subarray(0, buffered));
|
|
392
|
+
this.lastTotal = 0;
|
|
393
|
+
}
|
|
394
|
+
else if (i < buf.length) {
|
|
395
|
+
// A non-continuation byte broke the sequence; flush the held bytes
|
|
396
|
+
// through the same per-byte decoding Workers uses at end().
|
|
397
|
+
out += this.#decoder.decode(this.lastChar.subarray(0, buffered));
|
|
398
|
+
this.lastNeed = 0;
|
|
399
|
+
this.lastTotal = 0;
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
return out;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const rest = buf.subarray(i);
|
|
406
|
+
const tail = Utf8Core.#pendingLength(rest);
|
|
407
|
+
const emitLen = tail.start < 0 ? rest.length : tail.start;
|
|
408
|
+
if (emitLen > 0)
|
|
409
|
+
out += this.#decoder.decode(rest.subarray(0, emitLen));
|
|
410
|
+
if (tail.start >= 0) {
|
|
411
|
+
this.lastChar.fill(0);
|
|
412
|
+
this.lastChar.set(rest.subarray(tail.start));
|
|
413
|
+
this.lastTotal = tail.total;
|
|
414
|
+
this.lastNeed = tail.total - (rest.length - tail.start);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
this.lastNeed = 0;
|
|
418
|
+
this.lastTotal = 0;
|
|
419
|
+
}
|
|
420
|
+
return out;
|
|
421
|
+
}
|
|
422
|
+
end() {
|
|
423
|
+
const buffered = this.lastTotal - this.lastNeed;
|
|
424
|
+
const out = buffered === 0
|
|
425
|
+
? ""
|
|
426
|
+
: this.#decoder.decode(this.lastChar.subarray(0, buffered));
|
|
427
|
+
this.lastNeed = 0;
|
|
428
|
+
this.lastTotal = 0;
|
|
429
|
+
return out;
|
|
430
|
+
}
|
|
431
|
+
reset() {
|
|
432
|
+
this.lastNeed = 0;
|
|
433
|
+
this.lastTotal = 0;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function inner(decoder) {
|
|
437
|
+
const core = decoder[kCore];
|
|
438
|
+
if (core === undefined) {
|
|
439
|
+
throw new ERR_INVALID_THIS("StringDecoder");
|
|
440
|
+
}
|
|
441
|
+
return core;
|
|
442
|
+
}
|
|
443
|
+
function toBuffer(input) {
|
|
444
|
+
if (ArrayBuffer.isView(input))
|
|
445
|
+
return Buffer.from(input.buffer, input.byteOffset, input.byteLength);
|
|
446
|
+
throw new ERR_INVALID_ARG_TYPE("buf", ["Buffer", "TypedArray", "DataView", "string"], input);
|
|
447
|
+
}
|
|
448
|
+
// The upstream package has no base64url mode; the URL-safe alphabet is the
|
|
449
|
+
// same output with '+'/'-' and '/'/'_' swapped and no '=' padding.
|
|
450
|
+
const base64urlOut = (value) => value.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
451
|
+
// @ts-expect-error TS2323 Cannot redeclare exported variable
|
|
452
|
+
export function StringDecoder(encoding = "utf8") {
|
|
453
|
+
const normalizedEncoding = normalizeEncoding(encoding);
|
|
454
|
+
if (normalizedEncoding === undefined) {
|
|
455
|
+
throw new ERR_UNKNOWN_ENCODING(encoding);
|
|
456
|
+
}
|
|
457
|
+
this[kCore] =
|
|
458
|
+
normalizedEncoding === "utf8"
|
|
459
|
+
? new Utf8Core()
|
|
460
|
+
: new UpstreamCore(new UpstreamStringDecoder(normalizedEncoding === "base64url" ? "base64" : normalizedEncoding), normalizedEncoding === "base64url" ? base64urlOut : (v) => v);
|
|
461
|
+
this.encoding = normalizedEncoding;
|
|
462
|
+
return this;
|
|
463
|
+
}
|
|
464
|
+
function write(buf) {
|
|
465
|
+
const core = inner(this);
|
|
466
|
+
if (typeof buf === "string") {
|
|
467
|
+
return buf;
|
|
468
|
+
}
|
|
469
|
+
return core.write(toBuffer(buf));
|
|
470
|
+
}
|
|
471
|
+
function end(buf) {
|
|
472
|
+
const core = inner(this);
|
|
473
|
+
let ret = "";
|
|
474
|
+
if (buf !== undefined) {
|
|
475
|
+
ret = this.write(buf);
|
|
476
|
+
}
|
|
477
|
+
return ret + core.end();
|
|
478
|
+
}
|
|
479
|
+
function text(buf, offset) {
|
|
480
|
+
const core = inner(this);
|
|
481
|
+
// Workers clears the incomplete-character state rather than completing it.
|
|
482
|
+
core.reset();
|
|
483
|
+
// `buf.slice(offset)` mirrors workerd verbatim: inputs without a slice
|
|
484
|
+
// method (DataView, non-views) throw TypeError here before write() runs.
|
|
485
|
+
const sliced = buf.slice(offset);
|
|
486
|
+
return this.write(sliced);
|
|
487
|
+
}
|
|
488
|
+
// Minifiers rename the function; workerd always reports "StringDecoder".
|
|
489
|
+
Object.defineProperty(StringDecoder, "name", {
|
|
490
|
+
value: "StringDecoder",
|
|
491
|
+
configurable: true,
|
|
492
|
+
});
|
|
493
|
+
StringDecoder.prototype.write = write;
|
|
494
|
+
StringDecoder.prototype.end = end;
|
|
495
|
+
StringDecoder.prototype.text = text;
|
|
496
|
+
Object.defineProperties(StringDecoder.prototype, {
|
|
497
|
+
lastChar: {
|
|
498
|
+
enumerable: true,
|
|
499
|
+
get() {
|
|
500
|
+
return inner(this).lastChar;
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
lastNeed: {
|
|
504
|
+
enumerable: true,
|
|
505
|
+
get() {
|
|
506
|
+
return inner(this).lastNeed;
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
lastTotal: {
|
|
510
|
+
enumerable: true,
|
|
511
|
+
get() {
|
|
512
|
+
return inner(this).lastTotal;
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
});
|
|
516
|
+
export default {
|
|
517
|
+
StringDecoder,
|
|
518
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Upstream notices
|
|
2
|
+
|
|
3
|
+
Adapted from Cloudflare workerd src/node/test.ts and src/node/internal/mock.js and internal/validators.ts
|
|
4
|
+
at 5358e3d337336eaf696a48bc1563d808b10feba5 (v1.20261012.1).
|
|
5
|
+
Apache 2.0 (LICENSE-APACHE); Node MIT notices retained in mock.ts.
|
|
6
|
+
|
|
7
|
+
Validation helpers additionally retain these upstream notices:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
11
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
12
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
13
|
+
//
|
|
14
|
+
// Adapted from Deno and Node.js:
|
|
15
|
+
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
|
16
|
+
//
|
|
17
|
+
// Adapted from Node.js. Copyright Joyent, Inc. and other Node contributors.
|
|
18
|
+
//
|
|
19
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
20
|
+
// copy of this software and associated documentation files (the
|
|
21
|
+
// "Software"), to deal in the Software without restriction, including
|
|
22
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
23
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
24
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
25
|
+
// following conditions:
|
|
26
|
+
//
|
|
27
|
+
// The above copyright notice and this permission notice shall be included
|
|
28
|
+
// in all copies or substantial portions of the Software.
|
|
29
|
+
//
|
|
30
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
31
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
32
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
33
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
34
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
35
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
36
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
37
|
+
```
|