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,8 @@
|
|
|
1
|
+
export type HighWaterMarkFromOptions = {
|
|
2
|
+
highWaterMark?: number;
|
|
3
|
+
};
|
|
4
|
+
export declare function getDefaultHighWaterMark(objectMode?: boolean): number;
|
|
5
|
+
export declare function setDefaultHighWaterMark(objectMode: boolean, value: unknown): void;
|
|
6
|
+
export declare function getHighWaterMark(state: {
|
|
7
|
+
objectMode?: boolean;
|
|
8
|
+
}, options: HighWaterMarkFromOptions, duplexKey: string, isDuplex: boolean): number;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
3
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
4
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
7
|
+
//
|
|
8
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
// copy of this software and associated documentation files (the
|
|
10
|
+
// "Software"), to deal in the Software without restriction, including
|
|
11
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
13
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
14
|
+
// following conditions:
|
|
15
|
+
//
|
|
16
|
+
// The above copyright notice and this permission notice shall be included
|
|
17
|
+
// in all copies or substantial portions of the Software.
|
|
18
|
+
//
|
|
19
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
22
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
25
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
import { validateInteger } from "./validators.js";
|
|
27
|
+
import { ERR_INVALID_ARG_VALUE } from "./errors.js";
|
|
28
|
+
let defaultHighWaterMarkBytes = 64 * 1024;
|
|
29
|
+
let defaultHighWaterMarkObjectMode = 16;
|
|
30
|
+
function highWaterMarkFrom(options, isDuplex, duplexKey) {
|
|
31
|
+
return options.highWaterMark != null
|
|
32
|
+
? options.highWaterMark
|
|
33
|
+
: isDuplex
|
|
34
|
+
? // @ts-expect-error TS7053 Fix this soon.
|
|
35
|
+
options[duplexKey]
|
|
36
|
+
: null;
|
|
37
|
+
}
|
|
38
|
+
export function getDefaultHighWaterMark(objectMode) {
|
|
39
|
+
return objectMode
|
|
40
|
+
? defaultHighWaterMarkObjectMode
|
|
41
|
+
: defaultHighWaterMarkBytes;
|
|
42
|
+
}
|
|
43
|
+
export function setDefaultHighWaterMark(objectMode, value) {
|
|
44
|
+
validateInteger(value, "value", 0);
|
|
45
|
+
if (objectMode) {
|
|
46
|
+
defaultHighWaterMarkObjectMode = value;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
defaultHighWaterMarkBytes = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function getHighWaterMark(state, options, duplexKey, isDuplex) {
|
|
53
|
+
const hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
|
|
54
|
+
if (hwm != null) {
|
|
55
|
+
if (!Number.isInteger(hwm) || hwm < 0) {
|
|
56
|
+
const name = isDuplex ? `options.${duplexKey}` : "options.highWaterMark";
|
|
57
|
+
throw new ERR_INVALID_ARG_VALUE(name, hwm);
|
|
58
|
+
}
|
|
59
|
+
return Math.floor(hwm);
|
|
60
|
+
}
|
|
61
|
+
// Default value
|
|
62
|
+
return getDefaultHighWaterMark(state.objectMode);
|
|
63
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
3
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
4
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
7
|
+
//
|
|
8
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
// copy of this software and associated documentation files (the
|
|
10
|
+
// "Software"), to deal in the Software without restriction, including
|
|
11
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
13
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
14
|
+
// following conditions:
|
|
15
|
+
//
|
|
16
|
+
// The above copyright notice and this permission notice shall be included
|
|
17
|
+
// in all copies or substantial portions of the Software.
|
|
18
|
+
//
|
|
19
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
22
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
25
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
// a transform stream is a readable/writable stream where you do
|
|
27
|
+
// something with the data. Sometimes it's called a "filter",
|
|
28
|
+
// but that's not a great name for it, since that implies a thing where
|
|
29
|
+
// some bits pass through, and others are simply ignored. (That would
|
|
30
|
+
// be a valid example of a transform, of course.)
|
|
31
|
+
//
|
|
32
|
+
// While the output is causally related to the input, it's not a
|
|
33
|
+
// necessarily symmetric or synchronous transformation. For example,
|
|
34
|
+
// a zlib stream might take multiple plain-text writes(), and then
|
|
35
|
+
// emit a single compressed chunk some time in the future.
|
|
36
|
+
//
|
|
37
|
+
// Here's how this works:
|
|
38
|
+
//
|
|
39
|
+
// The Transform stream has all the aspects of the readable and writable
|
|
40
|
+
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
|
41
|
+
// internally, and returns false if there's a lot of pending writes
|
|
42
|
+
// buffered up. When you call read(), that calls _read(n) until
|
|
43
|
+
// there's enough pending readable data buffered up.
|
|
44
|
+
//
|
|
45
|
+
// In a transform stream, the written data is placed in a buffer. When
|
|
46
|
+
// _read(n) is called, it transforms the queued up data, calling the
|
|
47
|
+
// buffered _write cb's as it consumes chunks. If consuming a single
|
|
48
|
+
// written chunk would result in multiple output chunks, then the first
|
|
49
|
+
// outputted bit calls the readcb, and subsequent chunks just go into
|
|
50
|
+
// the read buffer, and will cause it to emit 'readable' if necessary.
|
|
51
|
+
//
|
|
52
|
+
// This way, back-pressure is actually determined by the reading side,
|
|
53
|
+
// since _read has to be called to start processing a new chunk. However,
|
|
54
|
+
// a pathological inflate type of transform can cause excessive buffering
|
|
55
|
+
// here. For example, imagine a stream where every byte of input is
|
|
56
|
+
// interpreted as an integer from 0-255, and then results in that many
|
|
57
|
+
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
|
58
|
+
// 1kb of data being output. In this case, you could write a very small
|
|
59
|
+
// amount of input, and end up with a very large amount of output. In
|
|
60
|
+
// such a pathological inflating mechanism, there'd be no way to tell
|
|
61
|
+
// the system to stop doing the transform. A single 4MB write could
|
|
62
|
+
// cause the system to run out of memory.
|
|
63
|
+
//
|
|
64
|
+
// However, even in such a pathological case, only a single written chunk
|
|
65
|
+
// would be consumed, and then the rest would wait (un-transformed) until
|
|
66
|
+
// the results of the previous transformed chunk were consumed.
|
|
67
|
+
"use strict";
|
|
68
|
+
import { ERR_METHOD_NOT_IMPLEMENTED } from "./errors.js";
|
|
69
|
+
import { nextTick } from "./process.js";
|
|
70
|
+
import { Duplex } from "./duplex.js";
|
|
71
|
+
import { getHighWaterMark } from "./state.js";
|
|
72
|
+
const streamsNodejsV24Compat = false;
|
|
73
|
+
Object.setPrototypeOf(Transform.prototype, Duplex.prototype);
|
|
74
|
+
Object.setPrototypeOf(Transform, Duplex);
|
|
75
|
+
const kCallback = Symbol("kCallback");
|
|
76
|
+
export function Transform(options) {
|
|
77
|
+
if (!(this instanceof Transform))
|
|
78
|
+
return new Transform(options);
|
|
79
|
+
// TODO (ronag): This should preferably always be
|
|
80
|
+
// applied but would be semver-major. Or even better;
|
|
81
|
+
// make Transform a Readable with the Writable interface.
|
|
82
|
+
const readableHighWaterMark = options
|
|
83
|
+
? getHighWaterMark(this, options, "readableHighWaterMark", true)
|
|
84
|
+
: null;
|
|
85
|
+
if (readableHighWaterMark === 0) {
|
|
86
|
+
// A Duplex will buffer both on the writable and readable side while
|
|
87
|
+
// a Transform just wants to buffer hwm number of elements. To avoid
|
|
88
|
+
// buffering twice we disable buffering on the writable side.
|
|
89
|
+
options = {
|
|
90
|
+
...options,
|
|
91
|
+
highWaterMark: null,
|
|
92
|
+
readableHighWaterMark,
|
|
93
|
+
writableHighWaterMark: options.writableHighWaterMark || 0,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
Duplex.call(this, options);
|
|
97
|
+
// We have implemented the _read method, and done the other things
|
|
98
|
+
// that Readable wants before the first _read call, so unset the
|
|
99
|
+
// sync guard flag.
|
|
100
|
+
this._readableState.sync = false;
|
|
101
|
+
this[kCallback] = null;
|
|
102
|
+
if (options) {
|
|
103
|
+
if (typeof options.transform === "function")
|
|
104
|
+
this._transform = options.transform;
|
|
105
|
+
if (typeof options.flush === "function")
|
|
106
|
+
this._flush = options.flush;
|
|
107
|
+
}
|
|
108
|
+
// When the writable side finishes, then flush out anything remaining.
|
|
109
|
+
// Backwards compat. Some Transform streams incorrectly implement _final
|
|
110
|
+
// instead of or in addition to _flush. By using 'prefinish' instead of
|
|
111
|
+
// implementing _final we continue supporting this unfortunate use case.
|
|
112
|
+
this.on("prefinish", prefinish);
|
|
113
|
+
}
|
|
114
|
+
function final(cb) {
|
|
115
|
+
if (typeof this._flush === "function" && !this.destroyed) {
|
|
116
|
+
this._flush((er, data) => {
|
|
117
|
+
if (er) {
|
|
118
|
+
if (cb) {
|
|
119
|
+
cb(er);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.destroy(er);
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (data != null) {
|
|
127
|
+
this.push(data);
|
|
128
|
+
}
|
|
129
|
+
this.push(null);
|
|
130
|
+
if (cb) {
|
|
131
|
+
cb();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.push(null);
|
|
137
|
+
if (cb) {
|
|
138
|
+
cb();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function prefinish() {
|
|
143
|
+
if (this._final !== final) {
|
|
144
|
+
final.call(this);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
Transform.prototype._final = final;
|
|
148
|
+
Transform.prototype._transform = function () {
|
|
149
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("_transform()");
|
|
150
|
+
};
|
|
151
|
+
Transform.prototype._write = function (chunk, encoding, callback) {
|
|
152
|
+
const rState = this._readableState;
|
|
153
|
+
const wState = this._writableState;
|
|
154
|
+
const length = rState.length;
|
|
155
|
+
this._transform(chunk, encoding, (err, val) => {
|
|
156
|
+
if (err) {
|
|
157
|
+
callback(err);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (val != null) {
|
|
161
|
+
this.push(val);
|
|
162
|
+
}
|
|
163
|
+
// This is a semver-major change. Ref: https://github.com/nodejs/node/commit/557044af407376aff28a0a0800f3053bb58e9239
|
|
164
|
+
if (streamsNodejsV24Compat && rState.ended) {
|
|
165
|
+
// If user has called this.push(null) we have to delay the callback to properly propagate the new
|
|
166
|
+
// state.
|
|
167
|
+
nextTick(callback);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
else if (wState.ended ||
|
|
171
|
+
// Backwards compat.
|
|
172
|
+
length === rState.length ||
|
|
173
|
+
// Backwards compat.
|
|
174
|
+
rState.length < rState.highWaterMark) {
|
|
175
|
+
callback();
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
this[kCallback] = callback;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
Transform.prototype._read = function (_size) {
|
|
183
|
+
if (this[kCallback]) {
|
|
184
|
+
const callback = this[kCallback];
|
|
185
|
+
this[kCallback] = null;
|
|
186
|
+
callback();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
Object.setPrototypeOf(PassThrough.prototype, Transform.prototype);
|
|
190
|
+
Object.setPrototypeOf(PassThrough, Transform);
|
|
191
|
+
export function PassThrough(options) {
|
|
192
|
+
if (!(this instanceof PassThrough))
|
|
193
|
+
return new PassThrough(options);
|
|
194
|
+
Transform.call(this, {
|
|
195
|
+
...options,
|
|
196
|
+
transform: undefined,
|
|
197
|
+
flush: undefined,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
PassThrough.prototype._transform = function (chunk, _, cb) {
|
|
201
|
+
cb(null, chunk);
|
|
202
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { OutgoingMessage } from "../http/outgoing.js";
|
|
2
|
+
import type { ServerResponse } from "../http/server.js";
|
|
3
|
+
import type { IncomingMessage } from "../http/incoming.js";
|
|
4
|
+
export declare const kIsDestroyed: unique symbol;
|
|
5
|
+
export declare const kIsErrored: unique symbol;
|
|
6
|
+
export declare const kIsReadable: unique symbol;
|
|
7
|
+
export declare const kIsWritable: unique symbol;
|
|
8
|
+
export declare const kIsDisturbed: unique symbol;
|
|
9
|
+
export declare const kOnConstructed: unique symbol;
|
|
10
|
+
export declare const kIsClosedPromise: unique symbol;
|
|
11
|
+
export declare const kControllerErrorFunction: unique symbol;
|
|
12
|
+
export declare const kState: unique symbol;
|
|
13
|
+
export declare const kObjectMode: number;
|
|
14
|
+
export declare const kErrorEmitted: number;
|
|
15
|
+
export declare const kAutoDestroy: number;
|
|
16
|
+
export declare const kEmitClose: number;
|
|
17
|
+
export declare const kDestroyed: number;
|
|
18
|
+
export declare const kClosed: number;
|
|
19
|
+
export declare const kCloseEmitted: number;
|
|
20
|
+
export declare const kErrored: number;
|
|
21
|
+
export declare const kConstructed: number;
|
|
22
|
+
export declare function isReadableNodeStream(obj: any, strict?: boolean): boolean;
|
|
23
|
+
export declare function isWritableNodeStream(obj: any): boolean;
|
|
24
|
+
export declare function isDuplexNodeStream(obj: any): boolean;
|
|
25
|
+
export declare function isNodeStream(obj: any): obj is Readable | Writable | Transform;
|
|
26
|
+
export declare function isReadableStream(obj: any): obj is ReadableStream;
|
|
27
|
+
export declare function isWritableStream(obj: any): obj is WritableStream;
|
|
28
|
+
export declare function isTransformStream(obj: any): obj is TransformStream;
|
|
29
|
+
export declare function isWebStream(obj: any): obj is ReadableStream | WritableStream | TransformStream;
|
|
30
|
+
export declare function isIterable(obj: any, isAsync?: true | false): boolean;
|
|
31
|
+
export declare function isDestroyed(stream: any): boolean | null;
|
|
32
|
+
export declare function isWritableEnded(stream: Writable | Readable | Transform): boolean | null;
|
|
33
|
+
export declare function isWritableFinished(stream: Writable | Readable | Transform, strict?: true | false | null): boolean | null;
|
|
34
|
+
export declare function isReadableEnded(stream: Readable | Writable | Transform): boolean | null;
|
|
35
|
+
export declare function isReadableFinished(stream: Readable | Writable | Transform, strict?: boolean): boolean | null;
|
|
36
|
+
export declare function isReadable(stream: Readable | Writable | Transform): boolean | null;
|
|
37
|
+
export declare function isWritable(stream: Readable | Writable | Transform): boolean | null;
|
|
38
|
+
export declare function isFinished(stream: Readable | Writable | Transform, opts?: {
|
|
39
|
+
readable?: boolean;
|
|
40
|
+
writable?: boolean;
|
|
41
|
+
}): boolean | null;
|
|
42
|
+
export declare function isWritableErrored(stream: Writable | Readable | Transform): Error | boolean | null;
|
|
43
|
+
export declare function isReadableErrored(stream: Readable | Writable | Transform): Error | boolean | null;
|
|
44
|
+
export declare function isClosed(stream: Readable | Writable | Transform): boolean | null;
|
|
45
|
+
export declare function isOutgoingMessage(stream: unknown): stream is OutgoingMessage;
|
|
46
|
+
export declare function isServerResponse(stream: unknown): stream is ServerResponse;
|
|
47
|
+
export declare function isServerRequest(stream: any): stream is IncomingMessage;
|
|
48
|
+
export declare function willEmitClose(stream: any): boolean | null;
|
|
49
|
+
export declare function isDisturbed(stream: any): boolean;
|
|
50
|
+
export declare function isErrored(stream: any): boolean;
|
|
51
|
+
export declare function handleKnownInternalErrors(cause?: Error & {
|
|
52
|
+
code?: string;
|
|
53
|
+
}): (Error & {
|
|
54
|
+
code?: string;
|
|
55
|
+
}) | undefined;
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
3
|
+
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
4
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
7
|
+
//
|
|
8
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
9
|
+
// copy of this software and associated documentation files (the
|
|
10
|
+
// "Software"), to deal in the Software without restriction, including
|
|
11
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
13
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
14
|
+
// following conditions:
|
|
15
|
+
//
|
|
16
|
+
// The above copyright notice and this permission notice shall be included
|
|
17
|
+
// in all copies or substantial portions of the Software.
|
|
18
|
+
//
|
|
19
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
22
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
24
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
25
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-condition */
|
|
27
|
+
import { AbortError } from "./errors.js";
|
|
28
|
+
// We need to use Symbol.for to make these globally available
|
|
29
|
+
// for interoperability with readable-stream, i.e. readable-stream
|
|
30
|
+
// and node core needs to be able to read/write private state
|
|
31
|
+
// from each other for proper interoperability.
|
|
32
|
+
export const kIsDestroyed = Symbol.for("nodejs.stream.destroyed");
|
|
33
|
+
export const kIsErrored = Symbol.for("nodejs.stream.errored");
|
|
34
|
+
export const kIsReadable = Symbol.for("nodejs.stream.readable");
|
|
35
|
+
export const kIsWritable = Symbol.for("nodejs.stream.writable");
|
|
36
|
+
export const kIsDisturbed = Symbol.for("nodejs.stream.disturbed");
|
|
37
|
+
export const kOnConstructed = Symbol("kOnConstructed");
|
|
38
|
+
export const kIsClosedPromise = Symbol.for("nodejs.webstream.isClosedPromise");
|
|
39
|
+
export const kControllerErrorFunction = Symbol.for("nodejs.webstream.controllerErrorFunction");
|
|
40
|
+
export const kState = Symbol("kState");
|
|
41
|
+
export const kObjectMode = 1 << 0;
|
|
42
|
+
export const kErrorEmitted = 1 << 1;
|
|
43
|
+
export const kAutoDestroy = 1 << 2;
|
|
44
|
+
export const kEmitClose = 1 << 3;
|
|
45
|
+
export const kDestroyed = 1 << 4;
|
|
46
|
+
export const kClosed = 1 << 5;
|
|
47
|
+
export const kCloseEmitted = 1 << 6;
|
|
48
|
+
export const kErrored = 1 << 7;
|
|
49
|
+
export const kConstructed = 1 << 8;
|
|
50
|
+
export function isReadableNodeStream(obj, strict = false) {
|
|
51
|
+
return !!(obj &&
|
|
52
|
+
typeof obj.pipe === "function" &&
|
|
53
|
+
typeof obj.on === "function" &&
|
|
54
|
+
(!strict ||
|
|
55
|
+
(typeof obj.pause === "function" && typeof obj.resume === "function")) &&
|
|
56
|
+
(!obj._writableState || obj._readableState?.readable !== false) && // Duplex
|
|
57
|
+
(!obj._writableState || obj._readableState) // Writable has .pipe.
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
export function isWritableNodeStream(obj) {
|
|
61
|
+
return !!(obj &&
|
|
62
|
+
typeof obj.write === "function" &&
|
|
63
|
+
typeof obj.on === "function" &&
|
|
64
|
+
(!obj._readableState || obj._writableState?.writable !== false) // Duplex
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
export function isDuplexNodeStream(obj) {
|
|
68
|
+
return !!(obj &&
|
|
69
|
+
typeof obj.pipe === "function" &&
|
|
70
|
+
obj._readableState &&
|
|
71
|
+
typeof obj.on === "function" &&
|
|
72
|
+
typeof obj.write === "function");
|
|
73
|
+
}
|
|
74
|
+
export function isNodeStream(obj) {
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
76
|
+
return (obj &&
|
|
77
|
+
(obj._readableState != null ||
|
|
78
|
+
obj._writableState != null ||
|
|
79
|
+
(typeof obj.write === "function" && typeof obj.on === "function") ||
|
|
80
|
+
(typeof obj.pipe === "function" && typeof obj.on === "function")));
|
|
81
|
+
}
|
|
82
|
+
export function isReadableStream(obj) {
|
|
83
|
+
return !!(obj &&
|
|
84
|
+
!isNodeStream(obj) &&
|
|
85
|
+
typeof obj.pipeThrough === "function" &&
|
|
86
|
+
typeof obj.getReader === "function" &&
|
|
87
|
+
typeof obj.cancel === "function");
|
|
88
|
+
}
|
|
89
|
+
export function isWritableStream(obj) {
|
|
90
|
+
return !!(obj &&
|
|
91
|
+
!isNodeStream(obj) &&
|
|
92
|
+
typeof obj.getWriter === "function" &&
|
|
93
|
+
typeof obj.abort === "function");
|
|
94
|
+
}
|
|
95
|
+
export function isTransformStream(obj) {
|
|
96
|
+
return !!(obj &&
|
|
97
|
+
!isNodeStream(obj) &&
|
|
98
|
+
typeof obj.readable === "object" &&
|
|
99
|
+
typeof obj.writable === "object");
|
|
100
|
+
}
|
|
101
|
+
export function isWebStream(obj) {
|
|
102
|
+
return (isReadableStream(obj) || isWritableStream(obj) || isTransformStream(obj));
|
|
103
|
+
}
|
|
104
|
+
export function isIterable(obj, isAsync) {
|
|
105
|
+
if (obj == null)
|
|
106
|
+
return false;
|
|
107
|
+
if (isAsync === true)
|
|
108
|
+
return typeof obj[Symbol.asyncIterator] === "function";
|
|
109
|
+
if (isAsync === false)
|
|
110
|
+
return typeof obj[Symbol.iterator] === "function";
|
|
111
|
+
return (typeof obj[Symbol.asyncIterator] === "function" ||
|
|
112
|
+
typeof obj[Symbol.iterator] === "function");
|
|
113
|
+
}
|
|
114
|
+
export function isDestroyed(stream) {
|
|
115
|
+
if (!isNodeStream(stream))
|
|
116
|
+
return null;
|
|
117
|
+
const wState = stream._writableState;
|
|
118
|
+
const rState = stream._readableState;
|
|
119
|
+
const state = wState || rState;
|
|
120
|
+
return !!(stream.destroyed || stream[kIsDestroyed] || state?.destroyed);
|
|
121
|
+
}
|
|
122
|
+
// Have been end():d.
|
|
123
|
+
export function isWritableEnded(stream) {
|
|
124
|
+
if (!isWritableNodeStream(stream))
|
|
125
|
+
return null;
|
|
126
|
+
if (stream.writableEnded === true)
|
|
127
|
+
return true;
|
|
128
|
+
const wState = stream._writableState;
|
|
129
|
+
if (wState?.errored)
|
|
130
|
+
return false;
|
|
131
|
+
if (typeof wState?.ended !== "boolean")
|
|
132
|
+
return null;
|
|
133
|
+
return wState.ended;
|
|
134
|
+
}
|
|
135
|
+
// Have emitted 'finish'.
|
|
136
|
+
export function isWritableFinished(stream, strict) {
|
|
137
|
+
if (!isWritableNodeStream(stream))
|
|
138
|
+
return null;
|
|
139
|
+
if (stream.writableFinished === true)
|
|
140
|
+
return true;
|
|
141
|
+
const wState = stream._writableState;
|
|
142
|
+
if (wState?.errored)
|
|
143
|
+
return false;
|
|
144
|
+
if (typeof wState?.finished !== "boolean")
|
|
145
|
+
return null;
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
|
|
147
|
+
return !!(wState.finished ||
|
|
148
|
+
(strict === false && wState.ended === true && wState.length === 0));
|
|
149
|
+
}
|
|
150
|
+
// Have been push(null):d.
|
|
151
|
+
export function isReadableEnded(stream) {
|
|
152
|
+
if (!isReadableNodeStream(stream))
|
|
153
|
+
return null;
|
|
154
|
+
if (stream.readableEnded === true)
|
|
155
|
+
return true;
|
|
156
|
+
const rState = stream._readableState;
|
|
157
|
+
if (!rState || rState.errored)
|
|
158
|
+
return false;
|
|
159
|
+
if (typeof rState?.ended !== "boolean")
|
|
160
|
+
return null;
|
|
161
|
+
return rState.ended;
|
|
162
|
+
}
|
|
163
|
+
// Have emitted 'end'.
|
|
164
|
+
export function isReadableFinished(stream, strict) {
|
|
165
|
+
if (!isReadableNodeStream(stream))
|
|
166
|
+
return null;
|
|
167
|
+
const rState = stream._readableState;
|
|
168
|
+
if (rState?.errored)
|
|
169
|
+
return false;
|
|
170
|
+
if (typeof rState?.endEmitted !== "boolean")
|
|
171
|
+
return null;
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
|
|
173
|
+
return !!(rState.endEmitted ||
|
|
174
|
+
(strict === false && rState.ended === true && rState.length === 0));
|
|
175
|
+
}
|
|
176
|
+
export function isReadable(stream) {
|
|
177
|
+
if (stream && stream[kIsReadable] != null)
|
|
178
|
+
return stream[kIsReadable];
|
|
179
|
+
if (typeof stream?.readable !== "boolean")
|
|
180
|
+
return null;
|
|
181
|
+
if (isDestroyed(stream))
|
|
182
|
+
return false;
|
|
183
|
+
return (isReadableNodeStream(stream) &&
|
|
184
|
+
stream.readable &&
|
|
185
|
+
!isReadableFinished(stream));
|
|
186
|
+
}
|
|
187
|
+
export function isWritable(stream) {
|
|
188
|
+
if (stream && stream[kIsWritable] != null)
|
|
189
|
+
return stream[kIsWritable];
|
|
190
|
+
if (typeof stream?.writable !== "boolean")
|
|
191
|
+
return null;
|
|
192
|
+
if (isDestroyed(stream))
|
|
193
|
+
return false;
|
|
194
|
+
return (isWritableNodeStream(stream) && stream.writable && !isWritableEnded(stream));
|
|
195
|
+
}
|
|
196
|
+
export function isFinished(stream, opts) {
|
|
197
|
+
if (!isNodeStream(stream)) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
if (isDestroyed(stream)) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
if (opts?.readable !== false && isReadable(stream)) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
if (opts?.writable !== false && isWritable(stream)) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
export function isWritableErrored(stream) {
|
|
212
|
+
if (!isNodeStream(stream)) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
if (stream.writableErrored) {
|
|
216
|
+
return stream.writableErrored;
|
|
217
|
+
}
|
|
218
|
+
return stream._writableState?.errored ?? null;
|
|
219
|
+
}
|
|
220
|
+
export function isReadableErrored(stream) {
|
|
221
|
+
if (!isNodeStream(stream)) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
if (stream.readableErrored) {
|
|
225
|
+
return stream.readableErrored;
|
|
226
|
+
}
|
|
227
|
+
return stream._readableState?.errored ?? null;
|
|
228
|
+
}
|
|
229
|
+
export function isClosed(stream) {
|
|
230
|
+
if (!isNodeStream(stream)) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
if (typeof stream.closed === "boolean") {
|
|
234
|
+
return stream.closed;
|
|
235
|
+
}
|
|
236
|
+
const wState = stream._writableState;
|
|
237
|
+
const rState = stream._readableState;
|
|
238
|
+
if (typeof wState?.closed === "boolean" ||
|
|
239
|
+
typeof rState?.closed === "boolean") {
|
|
240
|
+
return (wState?.closed || rState?.closed) ?? null;
|
|
241
|
+
}
|
|
242
|
+
if (typeof stream._closed === "boolean" && isOutgoingMessage(stream)) {
|
|
243
|
+
return stream._closed;
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
export function isOutgoingMessage(stream) {
|
|
248
|
+
return (stream != null &&
|
|
249
|
+
typeof stream === "object" &&
|
|
250
|
+
"_closed" in stream &&
|
|
251
|
+
typeof stream._closed === "boolean" &&
|
|
252
|
+
"_defaultKeepAlive" in stream &&
|
|
253
|
+
typeof stream._defaultKeepAlive === "boolean" &&
|
|
254
|
+
"_removedConnection" in stream &&
|
|
255
|
+
typeof stream._removedConnection === "boolean" &&
|
|
256
|
+
"_removedContLen" in stream &&
|
|
257
|
+
typeof stream._removedContLen === "boolean");
|
|
258
|
+
}
|
|
259
|
+
// This function includes the following check that we don't include, because
|
|
260
|
+
// our ServerResponse implementation does not implement it.
|
|
261
|
+
// `typeof stream._sent100 === 'boolean'`
|
|
262
|
+
export function isServerResponse(stream) {
|
|
263
|
+
return isOutgoingMessage(stream);
|
|
264
|
+
}
|
|
265
|
+
export function isServerRequest(stream) {
|
|
266
|
+
return (typeof stream._consuming === "boolean" &&
|
|
267
|
+
typeof stream._dumped === "boolean" &&
|
|
268
|
+
stream.req?.upgradeOrConnect === undefined);
|
|
269
|
+
}
|
|
270
|
+
export function willEmitClose(stream) {
|
|
271
|
+
if (!isNodeStream(stream))
|
|
272
|
+
return null;
|
|
273
|
+
const wState = stream._writableState;
|
|
274
|
+
const rState = stream._readableState;
|
|
275
|
+
const state = wState || rState;
|
|
276
|
+
return ((!state && isServerResponse(stream)) ||
|
|
277
|
+
!!(state?.autoDestroy && state.emitClose && state.closed === false));
|
|
278
|
+
}
|
|
279
|
+
export function isDisturbed(stream) {
|
|
280
|
+
return !!(stream &&
|
|
281
|
+
(stream[kIsDisturbed] ?? (stream.readableDidRead || stream.readableAborted)));
|
|
282
|
+
}
|
|
283
|
+
export function isErrored(stream) {
|
|
284
|
+
return !!(stream &&
|
|
285
|
+
(stream[kIsErrored] ??
|
|
286
|
+
stream.readableErrored ??
|
|
287
|
+
stream.writableErrored ??
|
|
288
|
+
stream._readableState?.errorEmitted ??
|
|
289
|
+
stream._writableState?.errorEmitted ??
|
|
290
|
+
stream._readableState?.errored ??
|
|
291
|
+
stream._writableState?.errored));
|
|
292
|
+
}
|
|
293
|
+
const ZLIB_FAILURES = new Set([
|
|
294
|
+
...[
|
|
295
|
+
"Z_ERRNO",
|
|
296
|
+
"Z_STREAM_ERROR",
|
|
297
|
+
"Z_DATA_ERROR",
|
|
298
|
+
"Z_MEM_ERROR",
|
|
299
|
+
"Z_BUF_ERROR",
|
|
300
|
+
"Z_VERSION_ERROR",
|
|
301
|
+
"Z_DEFAULT_COMPRESSION",
|
|
302
|
+
"Z_MIN_LEVEL",
|
|
303
|
+
"Z_DEFAULT_LEVEL",
|
|
304
|
+
"BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE",
|
|
305
|
+
"BROTLI_DECODER_ERROR_FORMAT_RESERVED",
|
|
306
|
+
"BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE",
|
|
307
|
+
"BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET",
|
|
308
|
+
"BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME",
|
|
309
|
+
"BROTLI_DECODER_ERROR_FORMAT_CL_SPACE",
|
|
310
|
+
"BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE",
|
|
311
|
+
"BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT",
|
|
312
|
+
"BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1",
|
|
313
|
+
"BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2",
|
|
314
|
+
"BROTLI_DECODER_ERROR_FORMAT_TRANSFORM",
|
|
315
|
+
"BROTLI_DECODER_ERROR_FORMAT_DICTIONARY",
|
|
316
|
+
"BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS",
|
|
317
|
+
"BROTLI_DECODER_ERROR_FORMAT_PADDING_1",
|
|
318
|
+
"BROTLI_DECODER_ERROR_FORMAT_PADDING_2",
|
|
319
|
+
"BROTLI_DECODER_ERROR_FORMAT_DISTANCE",
|
|
320
|
+
"BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET",
|
|
321
|
+
"BROTLI_DECODER_ERROR_INVALID_ARGUMENTS",
|
|
322
|
+
"BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES",
|
|
323
|
+
"BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS",
|
|
324
|
+
"BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP",
|
|
325
|
+
"BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1",
|
|
326
|
+
"BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2",
|
|
327
|
+
"BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES",
|
|
328
|
+
"BROTLI_DECODER_ERROR_UNREACHABLE",
|
|
329
|
+
],
|
|
330
|
+
"Z_NEED_DICT",
|
|
331
|
+
]);
|
|
332
|
+
export function handleKnownInternalErrors(cause) {
|
|
333
|
+
switch (true) {
|
|
334
|
+
case cause?.code === "ERR_STREAM_PREMATURE_CLOSE": {
|
|
335
|
+
return new AbortError(undefined, { cause });
|
|
336
|
+
}
|
|
337
|
+
case ZLIB_FAILURES.has(cause?.code ?? ""): {
|
|
338
|
+
const error = new TypeError(undefined, { cause });
|
|
339
|
+
error.code = cause?.code;
|
|
340
|
+
return error;
|
|
341
|
+
}
|
|
342
|
+
default:
|
|
343
|
+
return cause;
|
|
344
|
+
}
|
|
345
|
+
}
|