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,205 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, basename, resolve, join } from "node:path";
|
|
3
|
+
import { createRequire, builtinModules } from "node:module";
|
|
4
|
+
import { build } from "esbuild";
|
|
5
|
+
import { compileServerWorker, } from "../server.js";
|
|
6
|
+
import { permitsPath } from "../route-permissions.js";
|
|
7
|
+
import { readVoidPlan, voidSelector, usesServerProcess } from "./plan.js";
|
|
8
|
+
/** Generated Void Pages builds only. Unknown generators keep the Worker boundary. */
|
|
9
|
+
export async function compileVoid(entry, permissions, bindings) {
|
|
10
|
+
if (basename(entry) !== "index.js" || basename(dirname(entry)) !== "ssr")
|
|
11
|
+
return;
|
|
12
|
+
const source = await readFile(entry, "utf8");
|
|
13
|
+
if (!source.includes("//#region virtual:void-routes\n"))
|
|
14
|
+
return;
|
|
15
|
+
const remote = await compileServerWorker(entry, bindings, {
|
|
16
|
+
execution: "network",
|
|
17
|
+
});
|
|
18
|
+
const reject = (reason) => ({
|
|
19
|
+
...remote,
|
|
20
|
+
reason,
|
|
21
|
+
routes: remote.routes.map((route) => ({ ...route, reason })),
|
|
22
|
+
});
|
|
23
|
+
const directory = dirname(entry);
|
|
24
|
+
const require = createRequire(entry);
|
|
25
|
+
const runtimeRoot = dirname(require.resolve("void"));
|
|
26
|
+
const versionFile = join(runtimeRoot, "../package.json");
|
|
27
|
+
if (JSON.parse(await readFile(versionFile, "utf8")).version !== "1.1.12")
|
|
28
|
+
return reject("Void route execution currently requires Void 1.1.12");
|
|
29
|
+
let plan;
|
|
30
|
+
try {
|
|
31
|
+
plan = readVoidPlan(source);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return reject(error instanceof Error ? error.message : "Unknown Void build");
|
|
35
|
+
}
|
|
36
|
+
const inputs = new Set([...remote.inputs, versionFile]);
|
|
37
|
+
const checked = new Map();
|
|
38
|
+
// Inspect the exact generated dependency graph, including imported helpers. No
|
|
39
|
+
// server source is read by the device and no arbitrary secret scanner is used.
|
|
40
|
+
async function prepareModule(file, names) {
|
|
41
|
+
const key = file + ":" + (names?.join(",") ?? "*");
|
|
42
|
+
if (checked.has(key))
|
|
43
|
+
return checked.get(key);
|
|
44
|
+
const result = await build({
|
|
45
|
+
...(names
|
|
46
|
+
? {
|
|
47
|
+
stdin: {
|
|
48
|
+
contents: `import * as selected from ${JSON.stringify(resolve(directory, file))};\n${names.map((name) => `export const ${name}=selected.${name};`).join("\n")}`,
|
|
49
|
+
resolveDir: directory,
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
: { entryPoints: [resolve(directory, file)] }),
|
|
53
|
+
bundle: true,
|
|
54
|
+
write: false,
|
|
55
|
+
format: "esm",
|
|
56
|
+
platform: "browser",
|
|
57
|
+
conditions: ["worker", "browser"],
|
|
58
|
+
external: [
|
|
59
|
+
...builtinModules,
|
|
60
|
+
...builtinModules.map((name) => `node:${name}`),
|
|
61
|
+
"cloudflare:*",
|
|
62
|
+
],
|
|
63
|
+
metafile: true,
|
|
64
|
+
logLevel: "silent",
|
|
65
|
+
});
|
|
66
|
+
for (const path of Object.keys(result.metafile.inputs))
|
|
67
|
+
if (path !== "<stdin>")
|
|
68
|
+
inputs.add(resolve(path));
|
|
69
|
+
const code = result.outputFiles[0].text;
|
|
70
|
+
const unsafe = usesServerProcess(code) ||
|
|
71
|
+
/cloudflare:|void\.envContext|\.\s*env\b|\[\s*["']env["']\s*\]|\bglobalThis\s*(?:\[|\.\s*(?:__env__|env))|\b(?:getRuntimeBinding|requireRuntimeBinding|getRuntimeEnv|getRawRuntimeEnv)\b/.test(code) ||
|
|
72
|
+
bindings.some((name) => new RegExp(`\\b${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`).test(code)) ||
|
|
73
|
+
Object.values(result.metafile.outputs).some((output) => output.imports.some((item) => item.external));
|
|
74
|
+
const prepared = { unsafe, code };
|
|
75
|
+
checked.set(key, prepared);
|
|
76
|
+
return prepared;
|
|
77
|
+
}
|
|
78
|
+
const routes = [];
|
|
79
|
+
const selected = [];
|
|
80
|
+
for (const route of plan.routes) {
|
|
81
|
+
let reason;
|
|
82
|
+
if (route.method !== "GET" ||
|
|
83
|
+
!permissions.some((permission) => (permission.method === "GET" || permission.method === "*") &&
|
|
84
|
+
permitsPath(permission, route.path)))
|
|
85
|
+
reason = "Route distribution was not permitted by execution";
|
|
86
|
+
else if (/[\:*?{}]/.test(route.path) || route.path.startsWith("/__void"))
|
|
87
|
+
reason =
|
|
88
|
+
"Dynamic and framework-internal Void routes require network execution";
|
|
89
|
+
else if ((route.module &&
|
|
90
|
+
(await prepareModule(route.module, route.component ? ["loader", "head"] : ["GET"])).unsafe) ||
|
|
91
|
+
(route.component &&
|
|
92
|
+
(await prepareModule(plan.componentPath(route.component))).unsafe))
|
|
93
|
+
reason = "Void route dependencies require the server environment";
|
|
94
|
+
if (!reason)
|
|
95
|
+
selected.push(route);
|
|
96
|
+
routes.push({
|
|
97
|
+
router: "void",
|
|
98
|
+
method: route.method,
|
|
99
|
+
path: route.path,
|
|
100
|
+
remote: !!reason,
|
|
101
|
+
reason: reason ?? "Generated GET route distribution explicitly permitted",
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (!selected.length)
|
|
105
|
+
return {
|
|
106
|
+
...reject("No permitted Void routes can execute locally"),
|
|
107
|
+
routes,
|
|
108
|
+
inputs: [...inputs],
|
|
109
|
+
};
|
|
110
|
+
const selector = voidSelector(selected.map((route) => route.path));
|
|
111
|
+
const components = selected.flatMap((route) => route.component ? [route.component] : []);
|
|
112
|
+
const renderer = components.length
|
|
113
|
+
? plan.renderer(components)
|
|
114
|
+
: "export const renderPage = undefined;";
|
|
115
|
+
const manifestFile = resolve(directory, "../client/.vite/manifest.json");
|
|
116
|
+
const manifest = components.length
|
|
117
|
+
? JSON.parse(await readFile(manifestFile, "utf8"))
|
|
118
|
+
: {};
|
|
119
|
+
if (components.length)
|
|
120
|
+
inputs.add(manifestFile);
|
|
121
|
+
const entryCode = `
|
|
122
|
+
import { Hono } from ${JSON.stringify(require.resolve("hono"))};
|
|
123
|
+
import { createRoutingRuntime, createModuleLoader, createPageGetHandler,
|
|
124
|
+
createHttpRouteHandler, createClientAssetTags } from ${JSON.stringify(join(runtimeRoot, "runtime/routing.mjs"))};
|
|
125
|
+
import { renderPage } from "capacitor:void-renderer";
|
|
126
|
+
${selector}
|
|
127
|
+
const app = new Hono();
|
|
128
|
+
const routing = createRoutingRuntime(app, {dev:false,nodeTarget:false,managedDispatch:false});
|
|
129
|
+
app.use(routing.contextMiddleware);
|
|
130
|
+
app.use(routing.requestMiddleware);
|
|
131
|
+
const assets = createClientAssetTags(${JSON.stringify(plan.assets)},async()=>(${JSON.stringify(manifest)}));
|
|
132
|
+
${selected
|
|
133
|
+
.map((route, index) => {
|
|
134
|
+
const load = route.module
|
|
135
|
+
? `createModuleLoader(()=>import("capacitor:void-module:${index}"))`
|
|
136
|
+
: "undefined";
|
|
137
|
+
const handler = route.component
|
|
138
|
+
? `createPageGetHandler({load:${load},componentId:${JSON.stringify(route.component)},render:renderPage,assets,headConfig:null,renderOptions:{renderMode:${JSON.stringify(route.renderMode)}}})`
|
|
139
|
+
: `createHttpRouteHandler(${load},"GET")`;
|
|
140
|
+
return `app.get(${JSON.stringify(route.path)},${handler});`;
|
|
141
|
+
})
|
|
142
|
+
.join("\n")}
|
|
143
|
+
export default {fetch(request,env,ctx) {
|
|
144
|
+
if(needsRemote(request)) throw new Error("Void request requires network execution");
|
|
145
|
+
return app.fetch(request,env,ctx);
|
|
146
|
+
}};
|
|
147
|
+
`;
|
|
148
|
+
const bundled = await build({
|
|
149
|
+
stdin: {
|
|
150
|
+
contents: entryCode,
|
|
151
|
+
resolveDir: directory,
|
|
152
|
+
sourcefile: "capacitor-void.js",
|
|
153
|
+
},
|
|
154
|
+
bundle: true,
|
|
155
|
+
write: false,
|
|
156
|
+
format: "esm",
|
|
157
|
+
platform: "browser",
|
|
158
|
+
conditions: ["worker", "browser"],
|
|
159
|
+
external: ["node:*", "cloudflare:*"],
|
|
160
|
+
metafile: true,
|
|
161
|
+
logLevel: "silent",
|
|
162
|
+
plugins: [
|
|
163
|
+
{
|
|
164
|
+
name: "capacitor-void-renderer",
|
|
165
|
+
setup(build) {
|
|
166
|
+
build.onResolve({ filter: /^capacitor:void-module:/ }, (args) => ({
|
|
167
|
+
path: args.path.slice("capacitor:void-module:".length),
|
|
168
|
+
namespace: "void-module",
|
|
169
|
+
}));
|
|
170
|
+
build.onLoad({ filter: /.*/, namespace: "void-module" }, async (args) => {
|
|
171
|
+
const route = selected[Number(args.path)];
|
|
172
|
+
const prepared = await prepareModule(route.module, route.component ? ["loader", "head"] : ["GET"]);
|
|
173
|
+
return {
|
|
174
|
+
contents: prepared.code,
|
|
175
|
+
resolveDir: directory,
|
|
176
|
+
loader: "js",
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
build.onResolve({ filter: /^capacitor:void-renderer$/ }, () => ({
|
|
180
|
+
path: "renderer",
|
|
181
|
+
namespace: "void-renderer",
|
|
182
|
+
}));
|
|
183
|
+
build.onLoad({ filter: /.*/, namespace: "void-renderer" }, () => ({
|
|
184
|
+
contents: renderer,
|
|
185
|
+
resolveDir: directory,
|
|
186
|
+
loader: "js",
|
|
187
|
+
}));
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
});
|
|
192
|
+
for (const path of Object.keys(bundled.metafile.inputs)) {
|
|
193
|
+
if (!path.startsWith("void-renderer:") &&
|
|
194
|
+
!path.startsWith("void-module:") &&
|
|
195
|
+
path !== "capacitor-void.js")
|
|
196
|
+
inputs.add(resolve(path));
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
mode: "routes",
|
|
200
|
+
local: bundled.outputFiles[0].text,
|
|
201
|
+
selector,
|
|
202
|
+
inputs: [...inputs],
|
|
203
|
+
routes,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** React's guarded error reporter uses process.emit, not server environment data. */
|
|
2
|
+
export declare function usesServerProcess(source: string): boolean;
|
|
3
|
+
export interface VoidRoute {
|
|
4
|
+
path: string;
|
|
5
|
+
method: string;
|
|
6
|
+
module?: string;
|
|
7
|
+
component?: string;
|
|
8
|
+
renderMode?: "server" | "client";
|
|
9
|
+
}
|
|
10
|
+
/** Read only the pinned generator's literal registrations, never application source. */
|
|
11
|
+
export declare function readVoidPlan(source: string): {
|
|
12
|
+
routes: VoidRoute[];
|
|
13
|
+
assets: unknown;
|
|
14
|
+
componentPath: (id: string) => string;
|
|
15
|
+
renderer(ids: string[]): string;
|
|
16
|
+
};
|
|
17
|
+
export declare function voidSelector(paths: string[]): string;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { parseAst } from "rollup/parseAst";
|
|
2
|
+
const position = (node) => node;
|
|
3
|
+
const identifier = (node, name) => node?.type === "Identifier" && node.name === name;
|
|
4
|
+
function literal(node) {
|
|
5
|
+
return node?.type === "Literal" && typeof node.value === "string"
|
|
6
|
+
? node.value
|
|
7
|
+
: undefined;
|
|
8
|
+
}
|
|
9
|
+
function fields(node) {
|
|
10
|
+
if (node?.type !== "ObjectExpression")
|
|
11
|
+
throw new Error("Unknown generated options");
|
|
12
|
+
return new Map(node.properties.map((property) => {
|
|
13
|
+
if (property.type !== "Property" ||
|
|
14
|
+
property.computed ||
|
|
15
|
+
property.kind !== "init")
|
|
16
|
+
throw new Error("Unknown generated options");
|
|
17
|
+
const key = property.key.type === "Identifier"
|
|
18
|
+
? property.key.name
|
|
19
|
+
: literal(property.key);
|
|
20
|
+
if (!key)
|
|
21
|
+
throw new Error("Unknown generated option name");
|
|
22
|
+
return [key, property.value];
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
function data(node) {
|
|
26
|
+
if (node.type === "Literal")
|
|
27
|
+
return node.value;
|
|
28
|
+
if (node.type === "ArrayExpression")
|
|
29
|
+
return node.elements.map((item) => {
|
|
30
|
+
if (!item)
|
|
31
|
+
throw new Error("Unknown generated array");
|
|
32
|
+
return data(item);
|
|
33
|
+
});
|
|
34
|
+
if (node.type === "ObjectExpression")
|
|
35
|
+
return Object.fromEntries([...fields(node)].map(([key, value]) => [key, data(value)]));
|
|
36
|
+
throw new Error("Non-literal generated configuration");
|
|
37
|
+
}
|
|
38
|
+
function walk(node, visit, parent) {
|
|
39
|
+
visit(node, parent);
|
|
40
|
+
for (const value of Object.values(node)) {
|
|
41
|
+
for (const child of Array.isArray(value) ? value : [value]) {
|
|
42
|
+
if (child && typeof child === "object" && typeof child.type === "string")
|
|
43
|
+
walk(child, visit, node);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** React's guarded error reporter uses process.emit, not server environment data. */
|
|
48
|
+
export function usesServerProcess(source) {
|
|
49
|
+
let unsafe = false;
|
|
50
|
+
walk(parseAst(source), (node, parent) => {
|
|
51
|
+
if (!identifier(node, "process"))
|
|
52
|
+
return;
|
|
53
|
+
if (parent?.type === "UnaryExpression" && parent.operator === "typeof")
|
|
54
|
+
return;
|
|
55
|
+
if (parent?.type === "MemberExpression" &&
|
|
56
|
+
parent.object === node &&
|
|
57
|
+
!parent.computed &&
|
|
58
|
+
identifier(parent.property, "emit"))
|
|
59
|
+
return;
|
|
60
|
+
unsafe = true;
|
|
61
|
+
});
|
|
62
|
+
return unsafe;
|
|
63
|
+
}
|
|
64
|
+
/** Read only the pinned generator's literal registrations, never application source. */
|
|
65
|
+
export function readVoidPlan(source) {
|
|
66
|
+
const start = source.indexOf("//#region virtual:void-routes\n");
|
|
67
|
+
const end = source.indexOf("//#region .void/entry.ts\n", start);
|
|
68
|
+
if (start < 0 || end < 0)
|
|
69
|
+
throw new Error("Unknown Void generated routing entry");
|
|
70
|
+
const program = parseAst(source);
|
|
71
|
+
const declarations = new Map();
|
|
72
|
+
const initializers = new Map();
|
|
73
|
+
for (const statement of program.body) {
|
|
74
|
+
if (statement.type === "VariableDeclaration") {
|
|
75
|
+
for (const declaration of statement.declarations) {
|
|
76
|
+
if (declaration.id.type === "Identifier" && declaration.init) {
|
|
77
|
+
declarations.set(declaration.id.name, statement);
|
|
78
|
+
initializers.set(declaration.id.name, declaration.init);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (statement.type === "FunctionDeclaration" && statement.id) {
|
|
83
|
+
declarations.set(statement.id.name, statement);
|
|
84
|
+
}
|
|
85
|
+
else if (statement.type === "ImportDeclaration") {
|
|
86
|
+
for (const specifier of statement.specifiers)
|
|
87
|
+
declarations.set(specifier.local.name, statement);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (initializers.get("__voidHeadConfig")?.type !== "Literal" ||
|
|
91
|
+
initializers.get("__voidHeadConfig").value !== null)
|
|
92
|
+
throw new Error("Void custom head configuration requires network execution");
|
|
93
|
+
if (fields(initializers.get("layoutTree")).size)
|
|
94
|
+
throw new Error("Void layouts require network execution");
|
|
95
|
+
const routing = initializers.get("__routingRuntime");
|
|
96
|
+
if (routing?.type !== "CallExpression" ||
|
|
97
|
+
!identifier(routing.callee, "createRoutingRuntime") ||
|
|
98
|
+
!identifier(routing.arguments[0], "app"))
|
|
99
|
+
throw new Error("Unknown Void routing runtime");
|
|
100
|
+
const routingOptions = fields(routing.arguments[1]);
|
|
101
|
+
if ([...routingOptions.keys()].some((key) => ![
|
|
102
|
+
"dev",
|
|
103
|
+
"nodeTarget",
|
|
104
|
+
"managedDispatch",
|
|
105
|
+
"blockedAssetExtensions",
|
|
106
|
+
].includes(key)) ||
|
|
107
|
+
["dev", "nodeTarget", "managedDispatch"].some((key) => data(routingOptions.get(key)) !== false))
|
|
108
|
+
throw new Error("Void custom routing configuration requires network execution");
|
|
109
|
+
const components = fields(initializers.get("components"));
|
|
110
|
+
const modulePath = (node) => {
|
|
111
|
+
if (node?.type !== "ArrowFunctionExpression" ||
|
|
112
|
+
node.params.length ||
|
|
113
|
+
node.body.type !== "ImportExpression")
|
|
114
|
+
throw new Error("Unknown Void module loader");
|
|
115
|
+
const path = literal(node.body.source);
|
|
116
|
+
if (!path?.startsWith("./assets/") ||
|
|
117
|
+
!path.endsWith(".js") ||
|
|
118
|
+
path.includes(".."))
|
|
119
|
+
throw new Error("Unknown Void generated module path");
|
|
120
|
+
return path;
|
|
121
|
+
};
|
|
122
|
+
const loader = (node) => {
|
|
123
|
+
if (!node)
|
|
124
|
+
return;
|
|
125
|
+
if (node.type !== "Identifier")
|
|
126
|
+
throw new Error("Unknown Void loader reference");
|
|
127
|
+
const value = initializers.get(node.name);
|
|
128
|
+
if (value?.type !== "CallExpression" ||
|
|
129
|
+
!identifier(value.callee, "createModuleLoader"))
|
|
130
|
+
throw new Error("Unknown Void loader factory");
|
|
131
|
+
return modulePath(value.arguments[0]);
|
|
132
|
+
};
|
|
133
|
+
const assetCall = initializers.get("getPagesAssetTags");
|
|
134
|
+
if (assetCall?.type !== "CallExpression" ||
|
|
135
|
+
!identifier(assetCall.callee, "createClientAssetTags"))
|
|
136
|
+
throw new Error("Unknown Void client assets configuration");
|
|
137
|
+
const assets = data(assetCall.arguments[0]);
|
|
138
|
+
const routes = [];
|
|
139
|
+
for (const statement of program.body) {
|
|
140
|
+
if (position(statement).start < start ||
|
|
141
|
+
position(statement).start >= end ||
|
|
142
|
+
statement.type !== "ExpressionStatement")
|
|
143
|
+
continue;
|
|
144
|
+
const call = statement.expression;
|
|
145
|
+
if (call.type !== "CallExpression" ||
|
|
146
|
+
call.callee.type !== "MemberExpression" ||
|
|
147
|
+
!identifier(call.callee.object, "app") ||
|
|
148
|
+
call.callee.computed ||
|
|
149
|
+
call.callee.property.type !== "Identifier")
|
|
150
|
+
throw new Error("Unknown Void routing side effect");
|
|
151
|
+
const method = call.callee.property.name;
|
|
152
|
+
if (method === "use") {
|
|
153
|
+
const middleware = call.arguments[0];
|
|
154
|
+
if (call.arguments.length !== 1 ||
|
|
155
|
+
middleware?.type !== "MemberExpression" ||
|
|
156
|
+
!identifier(middleware.object, "__routingRuntime") ||
|
|
157
|
+
middleware.computed ||
|
|
158
|
+
middleware.property.type !== "Identifier" ||
|
|
159
|
+
!["contextMiddleware", "requestMiddleware"].includes(middleware.property.name))
|
|
160
|
+
throw new Error("Void application middleware requires network execution");
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (method === "onError") {
|
|
164
|
+
const handler = call.arguments[0];
|
|
165
|
+
if (call.arguments.length !== 1 ||
|
|
166
|
+
handler?.type !== "MemberExpression" ||
|
|
167
|
+
!identifier(handler.object, "__errorRenderer") ||
|
|
168
|
+
!identifier(handler.property, "onError") ||
|
|
169
|
+
handler.computed)
|
|
170
|
+
throw new Error("Void custom error handling requires network execution");
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (method === "notFound") {
|
|
174
|
+
const handler = call.arguments[0];
|
|
175
|
+
if (call.arguments.length !== 1 ||
|
|
176
|
+
handler?.type !== "CallExpression" ||
|
|
177
|
+
!identifier(handler.callee, "createPagesFallback"))
|
|
178
|
+
throw new Error("Void custom fallback requires network execution");
|
|
179
|
+
const fallback = fields(handler.arguments[0]);
|
|
180
|
+
const rules = fallback.get("fallbackRules");
|
|
181
|
+
if (rules &&
|
|
182
|
+
!(rules.type === "UnaryExpression" && rules.operator === "void"))
|
|
183
|
+
throw new Error("Void fallback rules require network execution");
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (method === "all" && literal(call.arguments[0]) === "/__void/*")
|
|
187
|
+
continue;
|
|
188
|
+
const path = literal(call.arguments[method === "on" ? 1 : 0]);
|
|
189
|
+
if (!path)
|
|
190
|
+
throw new Error("Unknown Void route path");
|
|
191
|
+
if (method === "on") {
|
|
192
|
+
const methods = call.arguments[0];
|
|
193
|
+
if (methods?.type !== "ArrayExpression" ||
|
|
194
|
+
methods.elements.length !== 4 ||
|
|
195
|
+
methods.elements.some((item, index) => literal(item) !== ["POST", "PUT", "PATCH", "DELETE"][index]) ||
|
|
196
|
+
call.arguments.length !== 3 ||
|
|
197
|
+
call.arguments[2]?.type !== "CallExpression" ||
|
|
198
|
+
!identifier(call.arguments[2].callee, "createPageMutationHandler"))
|
|
199
|
+
throw new Error("Unknown Void mutation registration");
|
|
200
|
+
routes.push({ path, method: "POST/PUT/PATCH/DELETE" });
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const factory = call.arguments[1];
|
|
204
|
+
if (method !== "get" || factory?.type !== "CallExpression") {
|
|
205
|
+
throw new Error("Unknown Void route registration");
|
|
206
|
+
}
|
|
207
|
+
if (call.arguments.length !== 2)
|
|
208
|
+
throw new Error("Void route middleware requires network execution");
|
|
209
|
+
if (identifier(factory.callee, "createHttpRouteHandler") &&
|
|
210
|
+
literal(factory.arguments[1]) === "GET") {
|
|
211
|
+
routes.push({
|
|
212
|
+
path,
|
|
213
|
+
method: "GET",
|
|
214
|
+
module: loader(factory.arguments[0]),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
else if (identifier(factory.callee, "createPageGetHandler")) {
|
|
218
|
+
const options = fields(factory.arguments[0]);
|
|
219
|
+
if ([...options.keys()].some((key) => ![
|
|
220
|
+
"load",
|
|
221
|
+
"componentId",
|
|
222
|
+
"render",
|
|
223
|
+
"assets",
|
|
224
|
+
"headConfig",
|
|
225
|
+
"renderOptions",
|
|
226
|
+
].includes(key)) ||
|
|
227
|
+
!identifier(options.get("render"), "renderPage") ||
|
|
228
|
+
!identifier(options.get("assets"), "getPagesAssetTags") ||
|
|
229
|
+
!identifier(options.get("headConfig"), "__voidHeadConfig"))
|
|
230
|
+
throw new Error("Unknown Void page configuration");
|
|
231
|
+
const component = literal(options.get("componentId"));
|
|
232
|
+
const renderOptions = fields(options.get("renderOptions"));
|
|
233
|
+
const renderMode = renderOptions.size === 1
|
|
234
|
+
? literal(renderOptions.get("renderMode"))
|
|
235
|
+
: undefined;
|
|
236
|
+
if (!component ||
|
|
237
|
+
!components.has(component) ||
|
|
238
|
+
(renderMode !== "server" && renderMode !== "client"))
|
|
239
|
+
throw new Error("Unknown Void page renderer");
|
|
240
|
+
routes.push({
|
|
241
|
+
path,
|
|
242
|
+
method: "GET",
|
|
243
|
+
module: loader(options.get("load")),
|
|
244
|
+
component,
|
|
245
|
+
renderMode,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else
|
|
249
|
+
throw new Error("Unknown Void route handler");
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
routes,
|
|
253
|
+
assets,
|
|
254
|
+
componentPath: (id) => modulePath(components.get(id)),
|
|
255
|
+
renderer(ids) {
|
|
256
|
+
const retained = new Set();
|
|
257
|
+
const include = (name) => {
|
|
258
|
+
const statement = declarations.get(name);
|
|
259
|
+
if (!statement || retained.has(statement))
|
|
260
|
+
return;
|
|
261
|
+
retained.add(statement);
|
|
262
|
+
if (name === "components")
|
|
263
|
+
return;
|
|
264
|
+
walk(statement, (node) => {
|
|
265
|
+
if (node.type === "Identifier")
|
|
266
|
+
include(node.name);
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
include("renderPage");
|
|
270
|
+
if (!retained.size)
|
|
271
|
+
throw new Error("Missing Void renderer");
|
|
272
|
+
return ([...retained]
|
|
273
|
+
.sort((a, b) => position(a).start - position(b).start)
|
|
274
|
+
.map((node) => node === declarations.get("components")
|
|
275
|
+
? `var components = {${ids.map((id) => `${JSON.stringify(id)}:()=>import(${JSON.stringify(modulePath(components.get(id)))})`).join(",")}};`
|
|
276
|
+
: source.slice(position(node).start, position(node).end))
|
|
277
|
+
.join("\n") + "\nexport { renderPage };");
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
export function voidSelector(paths) {
|
|
282
|
+
return `export function needsRemote(request) {
|
|
283
|
+
const url = new URL(request.url);
|
|
284
|
+
return request.method !== "GET" || !${JSON.stringify(paths)}.includes(url.pathname) ||
|
|
285
|
+
request.headers.has("authorization") || request.headers.has("cookie") ||
|
|
286
|
+
url.pathname.startsWith("/__void/");
|
|
287
|
+
}`;
|
|
288
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'maven-publish'
|
|
3
|
+
|
|
4
|
+
group = 'io.github.rdlabo'
|
|
5
|
+
version = '0.1.2'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
android {
|
|
9
|
+
namespace 'jp.rdlabo.workerscapacitor'
|
|
10
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
|
|
11
|
+
defaultConfig {
|
|
12
|
+
consumerProguardFiles 'consumer-rules.pro'
|
|
13
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
|
|
14
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
|
|
15
|
+
}
|
|
16
|
+
compileOptions {
|
|
17
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
18
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
dependencies {
|
|
23
|
+
implementation 'androidx.appcompat:appcompat:1.7.1'
|
|
24
|
+
implementation 'org.apache.cordova:framework:14.0.1'
|
|
25
|
+
if (findProject(':capacitor-android') != null) {
|
|
26
|
+
implementation project(':capacitor-android')
|
|
27
|
+
} else {
|
|
28
|
+
implementation 'com.capacitorjs:core:8.5.3'
|
|
29
|
+
}
|
|
30
|
+
implementation "androidx.webkit:webkit:${rootProject.ext.has('androidxWebkitVersion') ? rootProject.ext.androidxWebkitVersion : '1.14.0'}"
|
|
31
|
+
implementation 'io.netty:netty-handler:4.1.139.Final'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android { publishing { singleVariant('release') { withSourcesJar(); withJavadocJar() } } }
|
|
35
|
+
afterEvaluate {
|
|
36
|
+
publishing {
|
|
37
|
+
publications {
|
|
38
|
+
release(MavenPublication) {
|
|
39
|
+
from components.release
|
|
40
|
+
artifactId = 'cf-workers-native-android'
|
|
41
|
+
pom {
|
|
42
|
+
name = 'CF Workers Native Android'
|
|
43
|
+
description = 'Embed Cloudflare Workers applications in existing Android apps'
|
|
44
|
+
url = 'https://github.com/rdlabo-dev/cf-workers-native'
|
|
45
|
+
licenses {
|
|
46
|
+
license {
|
|
47
|
+
name = 'MIT License'
|
|
48
|
+
url = 'https://opensource.org/license/mit'
|
|
49
|
+
distribution = 'repo'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
developers {
|
|
53
|
+
developer {
|
|
54
|
+
id = 'rdlabo'
|
|
55
|
+
name = 'rdlabo'
|
|
56
|
+
url = 'https://github.com/rdlabo'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
scm {
|
|
60
|
+
connection = 'scm:git:https://github.com/rdlabo-dev/cf-workers-native.git'
|
|
61
|
+
developerConnection = 'scm:git:ssh://git@github.com/rdlabo-dev/cf-workers-native.git'
|
|
62
|
+
url = 'https://github.com/rdlabo-dev/cf-workers-native'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
3
|
+
<application>
|
|
4
|
+
<activity android:name="jp.rdlabo.workerscapacitor.WorkersNativeActivity" android:exported="false" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation" />
|
|
5
|
+
</application>
|
|
6
|
+
</manifest>
|