cf-workers-native 0.1.4 → 0.1.6
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/README.md +2 -2
- package/dist/browser/documents/page-source.js +1 -1
- package/dist/browser/fetch/host-call.js +6 -1
- package/dist/browser/fetch/native-network.d.ts +1 -1
- package/dist/browser/fetch/relay.js +2 -0
- package/dist/browser/headers/index.d.ts +2 -0
- package/dist/browser/headers/index.js +5 -0
- package/dist/browser/isolated/transport.js +3 -2
- package/dist/browser/request/index.js +3 -2
- package/dist/browser/response/index.d.ts +2 -0
- package/dist/browser/response/index.js +11 -3
- package/dist/browser/structured-clone/index.d.ts +3 -0
- package/dist/browser/structured-clone/index.js +75 -7
- package/dist/browser/websocket/attachment-size.d.ts +3 -0
- package/dist/browser/websocket/attachment-size.js +336 -0
- package/dist/browser/websocket/brand.d.ts +4 -0
- package/dist/browser/websocket/brand.js +16 -0
- package/dist/browser/websocket/close-event.d.ts +7 -0
- package/dist/browser/websocket/close-event.js +30 -0
- package/dist/browser/websocket/compression.d.ts +5 -0
- package/dist/browser/websocket/compression.js +124 -0
- package/dist/browser/websocket/conversion.d.ts +2 -0
- package/dist/browser/websocket/conversion.js +13 -0
- package/dist/browser/websocket/endpoint.d.ts +39 -0
- package/dist/browser/websocket/endpoint.js +379 -0
- package/dist/browser/websocket/frames.d.ts +21 -0
- package/dist/browser/websocket/frames.js +121 -0
- package/dist/browser/websocket/native.d.ts +14 -0
- package/dist/browser/websocket/native.js +226 -0
- package/dist/cloudflare/apis/cloudflare-node/index.js +11 -23
- package/dist/cloudflare/workers/worker-runtime.js +2 -1
- package/dist/compat/console/index.d.ts +35 -0
- package/dist/compat/console/index.js +92 -0
- package/dist/compat/crypto/LICENSE-3RD-PARTY.md +39 -0
- package/dist/compat/crypto/LICENSE-APACHE +177 -0
- package/dist/compat/crypto/LICENSE.boringssl +238 -0
- package/dist/compat/crypto/LICENSE.emscripten +102 -0
- package/dist/compat/crypto/LICENSE.musl +193 -0
- package/dist/compat/crypto/LICENSE.ncrypto +21 -0
- package/dist/compat/crypto/LICENSE.openssl +177 -0
- package/dist/compat/crypto/asymmetric.d.ts +13 -0
- package/dist/compat/crypto/asymmetric.js +312 -0
- package/dist/compat/crypto/brorand.cjs +74 -0
- package/dist/compat/crypto/brorand.d.cts +6 -0
- package/dist/compat/crypto/certificate.d.ts +14 -0
- package/dist/compat/crypto/certificate.js +66 -0
- package/dist/compat/crypto/cipher-handle.d.ts +27 -0
- package/dist/compat/crypto/cipher-handle.js +239 -0
- package/dist/compat/crypto/cipher-info.d.ts +12 -0
- package/dist/compat/crypto/cipher-info.js +324 -0
- package/dist/compat/crypto/constants.d.ts +62 -0
- package/dist/compat/crypto/constants.js +68 -0
- package/dist/compat/crypto/dh-handle.d.ts +17 -0
- package/dist/compat/crypto/dh-handle.js +180 -0
- package/dist/compat/crypto/dh.d.ts +53 -0
- package/dist/compat/crypto/dh.js +138 -0
- package/dist/compat/crypto/digest-stream.d.ts +15 -0
- package/dist/compat/crypto/digest-stream.js +213 -0
- package/dist/compat/crypto/digests.d.ts +3 -0
- package/dist/compat/crypto/digests.js +32 -0
- package/dist/compat/crypto/ecdh.d.ts +25 -0
- package/dist/compat/crypto/ecdh.js +109 -0
- package/dist/compat/crypto/hash-handle.d.ts +23 -0
- package/dist/compat/crypto/hash-handle.js +70 -0
- package/dist/compat/crypto/hash.d.ts +37 -0
- package/dist/compat/crypto/hash.js +218 -0
- package/dist/compat/crypto/hkdf.d.ts +2 -0
- package/dist/compat/crypto/hkdf.js +78 -0
- package/dist/compat/crypto/index.cjs +2 -0
- package/dist/compat/crypto/index.d.cts +169 -0
- package/dist/compat/crypto/index.d.ts +213 -0
- package/dist/compat/crypto/index.js +96 -0
- package/dist/compat/crypto/key-errors.d.ts +10 -0
- package/dist/compat/crypto/key-errors.js +17 -0
- package/dist/compat/crypto/key-export.d.ts +8 -0
- package/dist/compat/crypto/key-export.js +49 -0
- package/dist/compat/crypto/key-formats.d.ts +7 -0
- package/dist/compat/crypto/key-formats.js +251 -0
- package/dist/compat/crypto/key-options.d.ts +1 -0
- package/dist/compat/crypto/key-options.js +74 -0
- package/dist/compat/crypto/key-state.d.ts +10 -0
- package/dist/compat/crypto/key-state.js +4 -0
- package/dist/compat/crypto/keys.d.ts +58 -0
- package/dist/compat/crypto/keys.js +278 -0
- package/dist/compat/crypto/metadata.d.ts +13 -0
- package/dist/compat/crypto/metadata.js +109 -0
- package/dist/compat/crypto/native-cipher.d.ts +17 -0
- package/dist/compat/crypto/native-cipher.js +192 -0
- package/dist/compat/crypto/native-crypto.d.ts +81 -0
- package/dist/compat/crypto/native-crypto.js +681 -0
- package/dist/compat/crypto/pbkdf2-handle.d.ts +4 -0
- package/dist/compat/crypto/pbkdf2-handle.js +26 -0
- package/dist/compat/crypto/pbkdf2.d.ts +5 -0
- package/dist/compat/crypto/pbkdf2.js +60 -0
- package/dist/compat/crypto/prime.d.ts +19 -0
- package/dist/compat/crypto/prime.js +146 -0
- package/dist/compat/crypto/random.d.ts +18 -0
- package/dist/compat/crypto/random.js +203 -0
- package/dist/compat/crypto/rsa.d.ts +21 -0
- package/dist/compat/crypto/rsa.js +177 -0
- package/dist/compat/crypto/scrypt.d.ts +25 -0
- package/dist/compat/crypto/scrypt.js +152 -0
- package/dist/compat/crypto/sign-errors.d.ts +8 -0
- package/dist/compat/crypto/sign-errors.js +13 -0
- package/dist/compat/crypto/sign-handle.d.ts +22 -0
- package/dist/compat/crypto/sign-handle.js +149 -0
- package/dist/compat/crypto/signatures.d.ts +34 -0
- package/dist/compat/crypto/signatures.js +252 -0
- package/dist/compat/crypto/subtle-digest.d.ts +1 -0
- package/dist/compat/crypto/subtle-digest.js +56 -0
- package/dist/compat/crypto/symmetric.d.ts +45 -0
- package/dist/compat/crypto/symmetric.js +239 -0
- package/dist/compat/crypto/validation.d.ts +7 -0
- package/dist/compat/crypto/validation.js +46 -0
- package/dist/compat/crypto/webcrypto.d.ts +13 -0
- package/dist/compat/crypto/webcrypto.js +51 -0
- package/dist/compat/crypto/x509.d.ts +30 -0
- package/dist/compat/crypto/x509.js +407 -0
- package/dist/compat/events/errors.d.ts +8 -0
- package/dist/compat/events/errors.js +39 -0
- package/dist/compat/events/index.cjs +2 -0
- package/dist/compat/events/index.d.cts +2 -0
- package/dist/compat/events/index.d.ts +64 -0
- package/dist/compat/events/index.js +792 -0
- package/dist/compat/events/intrinsics.d.ts +1 -0
- package/dist/compat/events/intrinsics.js +2 -0
- package/dist/compat/fs/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/fs/LICENSE-APACHE +177 -0
- package/dist/compat/fs/directory-backend.d.ts +6 -0
- package/dist/compat/fs/directory-backend.js +51 -0
- package/dist/compat/fs/directory.d.ts +37 -0
- package/dist/compat/fs/directory.js +137 -0
- package/dist/compat/fs/embedded.d.ts +85 -0
- package/dist/compat/fs/embedded.js +260 -0
- package/dist/compat/fs/file-handle.d.ts +75 -0
- package/dist/compat/fs/file-handle.js +226 -0
- package/dist/compat/fs/glob-internal.d.ts +15 -0
- package/dist/compat/fs/glob-internal.js +417 -0
- package/dist/compat/fs/glob.d.ts +10 -0
- package/dist/compat/fs/glob.js +71 -0
- package/dist/compat/fs/index.d.ts +8 -82
- package/dist/compat/fs/index.js +736 -238
- package/dist/compat/fs/io-validation.d.ts +14 -0
- package/dist/compat/fs/io-validation.js +130 -0
- package/dist/compat/fs/io.d.ts +1 -0
- package/dist/compat/fs/io.js +282 -0
- package/dist/compat/fs/mode.d.ts +1 -0
- package/dist/compat/fs/mode.js +13 -0
- package/dist/compat/fs/promises/index.d.ts +3 -1
- package/dist/compat/fs/promises/index.js +1 -1
- package/dist/compat/fs/public-types.d.ts +120 -0
- package/dist/compat/fs/public-types.js +1 -0
- package/dist/compat/fs/stream-errors.d.ts +6 -0
- package/dist/compat/fs/stream-errors.js +8 -0
- package/dist/compat/fs/stream-utils.d.ts +16 -0
- package/dist/compat/fs/stream-utils.js +29 -0
- package/dist/compat/fs/streams.d.ts +104 -0
- package/dist/compat/fs/streams.js +794 -0
- package/dist/compat/fs/writable.d.ts +14 -0
- package/dist/compat/fs/writable.js +532 -0
- package/dist/compat/http/index.d.ts +11 -28
- package/dist/compat/http/index.js +81 -125
- package/dist/compat/http/server-options.d.ts +1 -0
- package/dist/compat/http/server-options.js +87 -0
- package/dist/compat/http/symbols.d.ts +5 -0
- package/dist/compat/http/symbols.js +9 -0
- package/dist/compat/http/unique-headers.d.ts +1 -0
- package/dist/compat/http/unique-headers.js +21 -0
- package/dist/compat/http-common/index.d.ts +37 -0
- package/dist/compat/http-common/index.js +43 -0
- package/dist/compat/http-outgoing/index.d.ts +14 -0
- package/dist/compat/http-outgoing/index.js +17 -0
- package/dist/compat/http-server/index.d.ts +18 -0
- package/dist/compat/http-server/index.js +26 -0
- package/dist/compat/https/index.d.ts +4 -2
- package/dist/compat/module/builtins.d.ts +1 -0
- package/dist/compat/module/builtins.js +101 -0
- package/dist/compat/module/index.d.ts +4 -2
- package/dist/compat/module/index.js +22 -17
- package/dist/compat/module/metadata.d.ts +44 -0
- package/dist/compat/module/metadata.js +127 -0
- package/dist/compat/net/internal-net.js +4 -0
- package/dist/compat/net/sockets.d.ts +5 -0
- package/dist/compat/net/sockets.js +153 -14
- package/dist/compat/net/validators.d.ts +1 -0
- package/dist/compat/net/validators.js +8 -0
- package/dist/compat/process/configuration.d.ts +113 -0
- package/dist/compat/process/configuration.js +115 -0
- package/dist/compat/process/directory.d.ts +4 -0
- package/dist/compat/process/directory.js +28 -0
- package/dist/compat/process/files.d.ts +3 -0
- package/dist/compat/process/files.js +10 -0
- package/dist/compat/process/index.cjs +2 -0
- package/dist/compat/process/index.d.cts +4 -0
- package/dist/compat/process/index.d.ts +20 -0
- package/dist/compat/process/index.js +113 -0
- package/dist/compat/process/metadata.d.ts +135 -0
- package/dist/compat/process/metadata.js +251 -0
- package/dist/compat/process/scheduling.d.ts +2 -0
- package/dist/compat/process/scheduling.js +60 -0
- package/dist/compat/process/state.d.ts +4 -0
- package/dist/compat/process/state.js +5 -0
- package/dist/compat/process/stdio.d.ts +18 -0
- package/dist/compat/process/stdio.js +66 -0
- package/dist/compat/stream/destroy.d.ts +1 -0
- package/dist/compat/stream/destroy.js +21 -1
- package/dist/compat/stream/readable.js +10 -2
- package/dist/compat/stream-web/LICENSE +22 -0
- package/dist/compat/stream-web/ponyfill.d.ts +1 -1
- package/dist/compat/stream-web/ponyfill.js +2369 -1775
- package/dist/compat/stream-web/runtime.d.ts +1 -1
- package/dist/compat/stream-web/runtime.js +3 -2
- package/dist/compat/stream-wrap/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/stream-wrap/LICENSE-APACHE +177 -0
- package/dist/compat/stream-wrap/index.d.ts +1 -0
- package/dist/compat/stream-wrap/index.js +1 -0
- package/dist/compat/tls/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/tls/LICENSE-APACHE +177 -0
- package/dist/compat/tls/constants.d.ts +7 -0
- package/dist/compat/tls/constants.js +14 -0
- package/dist/compat/tls/errors.d.ts +35 -0
- package/dist/compat/tls/errors.js +68 -0
- package/dist/compat/tls/helpers.d.ts +9 -0
- package/dist/compat/tls/helpers.js +207 -0
- package/dist/compat/tls/index.d.ts +26 -0
- package/dist/compat/tls/index.js +50 -0
- package/dist/compat/tls/jsstream.d.ts +19 -0
- package/dist/compat/tls/jsstream.js +196 -0
- package/dist/compat/tls/native-session.d.ts +3 -0
- package/dist/compat/tls/native-session.js +187 -0
- package/dist/compat/tls/wrap.d.ts +65 -0
- package/dist/compat/tls/wrap.js +541 -0
- package/dist/compat/tls-wrap/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/tls-wrap/LICENSE-APACHE +177 -0
- package/dist/compat/tls-wrap/index.d.ts +7 -0
- package/dist/compat/tls-wrap/index.js +3 -0
- package/dist/compat/util/index.js +43 -1
- package/dist/compat/util/inspect.js +5 -1
- package/dist/compat/util/types/index.d.ts +3 -0
- package/dist/compat/util/types/index.js +5 -0
- package/dist/compat/zlib/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/zlib/LICENSE-APACHE +177 -0
- package/dist/compat/zlib/LICENSE.brotli +19 -0
- package/dist/compat/zlib/LICENSE.emscripten +102 -0
- package/dist/compat/zlib/LICENSE.musl +193 -0
- package/dist/compat/zlib/LICENSE.zlib +22 -0
- package/dist/compat/zlib/LICENSE.zstd +30 -0
- package/dist/compat/zlib/classic-base.cjs +600 -0
- package/dist/compat/zlib/classic-base.d.cts +39 -0
- package/dist/compat/zlib/classic-binding.d.ts +28 -0
- package/dist/compat/zlib/classic-binding.js +105 -0
- package/dist/compat/zlib/classic.d.ts +44 -0
- package/dist/compat/zlib/classic.js +199 -0
- package/dist/compat/zlib/codec-binding.d.ts +33 -0
- package/dist/compat/zlib/codec-binding.js +141 -0
- package/dist/compat/zlib/compression.d.ts +26 -0
- package/dist/compat/zlib/compression.js +170 -0
- package/dist/compat/zlib/constants.d.ts +172 -0
- package/dist/compat/zlib/constants.js +173 -0
- package/dist/compat/zlib/errors.d.ts +21 -0
- package/dist/compat/zlib/errors.js +32 -0
- package/dist/compat/zlib/index.d.ts +544 -0
- package/dist/compat/zlib/index.js +194 -0
- package/dist/compat/zlib/input.d.ts +16 -0
- package/dist/compat/zlib/input.js +132 -0
- package/dist/compat/zlib/native-codecs.d.ts +24 -0
- package/dist/compat/zlib/native-codecs.js +180 -0
- package/dist/compat/zlib/native-zlib.d.ts +5 -0
- package/dist/compat/zlib/native-zlib.js +52 -0
- package/dist/compat/zlib/public-types.d.ts +48 -0
- package/dist/compat/zlib/public-types.js +1 -0
- package/dist/compat/zlib/validators.d.ts +3 -0
- package/dist/compat/zlib/validators.js +18 -0
- package/dist/shared/buffer-source.d.ts +5 -0
- package/dist/shared/buffer-source.js +70 -0
- package/dist/shared/globals/inject.d.ts +2 -1
- package/dist/shared/globals/inject.js +2 -1
- package/dist/shared/globals/platform.d.ts +8 -0
- package/dist/shared/globals/platform.js +1 -0
- package/dist/shared/globals/runtime.d.ts +1 -2
- package/dist/shared/globals/runtime.js +1 -2
- package/dist/shared/globals/web.js +5 -0
- package/dist/shared/request-context.d.ts +2 -0
- package/dist/shared/request-context.js +11 -0
- package/dist/shared/request-scope.d.ts +4 -0
- package/dist/shared/request-scope.js +14 -0
- package/dist/tooling/async.js +36 -14
- package/dist/tooling/shared.d.ts +1 -0
- package/dist/tooling/shared.js +26 -1
- package/dist/tooling/vite.js +8 -3
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +92 -13
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +4 -2
- package/native/ios/NetworkBridge.swift +11 -1
- package/native/ios/SocketBridge.swift +37 -2
- package/native/ios/WorkersCapacitorPlugin.swift +4 -0
- package/package.json +4 -2
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc. Apache-2.0.
|
|
2
|
+
// Adapted from pinned workerd public_process.ts; these are Workers stubs, not host OS introspection.
|
|
3
|
+
import { NodeError } from "../net/error-base.js";
|
|
4
|
+
class ERR_METHOD_NOT_IMPLEMENTED extends NodeError {
|
|
5
|
+
constructor(name) {
|
|
6
|
+
super("ERR_METHOD_NOT_IMPLEMENTED", `The ${name} method is not implemented`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class ERR_EPERM extends NodeError {
|
|
10
|
+
path;
|
|
11
|
+
syscall;
|
|
12
|
+
errno;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
const message = options.path
|
|
15
|
+
? `operation not permitted, ${options.syscall} '${options.path}'`
|
|
16
|
+
: "operation not permitted";
|
|
17
|
+
super("EPERM", message);
|
|
18
|
+
this.syscall = options.syscall;
|
|
19
|
+
if (options.path !== undefined) {
|
|
20
|
+
this.path = options.path;
|
|
21
|
+
}
|
|
22
|
+
this.errno = options.errno ?? 1; // EPERM
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const arch = "x64";
|
|
26
|
+
// For simplicity and polyfill expectations, we assign pid 1 to the process and pid 0 to the "parent".
|
|
27
|
+
export const pid = 1;
|
|
28
|
+
export const ppid = 0;
|
|
29
|
+
export const allowedNodeEnvironmentFlags = new Set();
|
|
30
|
+
export function setSourceMapsEnabled(_enabled, _options) {
|
|
31
|
+
// no-op since we do not support disabling source maps
|
|
32
|
+
}
|
|
33
|
+
export function getSourceMapsSupport() {
|
|
34
|
+
return {
|
|
35
|
+
enabled: false,
|
|
36
|
+
nodeModules: false,
|
|
37
|
+
generatedCode: false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function ref() {
|
|
41
|
+
// no-op
|
|
42
|
+
}
|
|
43
|
+
export function unref() {
|
|
44
|
+
// no-op
|
|
45
|
+
}
|
|
46
|
+
export function setUncaughtExceptionCaptureCallback(_fn) {
|
|
47
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.setUncaughtExceptionCaptureCallback");
|
|
48
|
+
}
|
|
49
|
+
export function hasUncaughtExceptionCaptureCallback() {
|
|
50
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.hasUncaughtExceptionCaptureCallback");
|
|
51
|
+
}
|
|
52
|
+
export function kill(_pid, _signal) {
|
|
53
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.kill");
|
|
54
|
+
}
|
|
55
|
+
export function binding(_name) {
|
|
56
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.binding");
|
|
57
|
+
}
|
|
58
|
+
export function dlopen(_module, _filename, _flags) {
|
|
59
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.dlopen");
|
|
60
|
+
}
|
|
61
|
+
export const exitCode = undefined;
|
|
62
|
+
export function getActiveResourcesInfo() {
|
|
63
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.getActiveResourcesInfo");
|
|
64
|
+
}
|
|
65
|
+
export function memoryUsage() {
|
|
66
|
+
return {
|
|
67
|
+
rss: 0,
|
|
68
|
+
heapTotal: 0,
|
|
69
|
+
heapUsed: 0,
|
|
70
|
+
external: 0,
|
|
71
|
+
arrayBuffers: 0,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function resourceUsage() {
|
|
75
|
+
return {
|
|
76
|
+
userCPUTime: 0,
|
|
77
|
+
systemCPUTime: 0,
|
|
78
|
+
maxRSS: 0,
|
|
79
|
+
sharedMemorySize: 0,
|
|
80
|
+
unsharedDataSize: 0,
|
|
81
|
+
unsharedStackSize: 0,
|
|
82
|
+
minorPageFault: 0,
|
|
83
|
+
majorPageFault: 0,
|
|
84
|
+
swappedOut: 0,
|
|
85
|
+
fsRead: 0,
|
|
86
|
+
fsWrite: 0,
|
|
87
|
+
ipcSent: 0,
|
|
88
|
+
ipcReceived: 0,
|
|
89
|
+
signalsCount: 0,
|
|
90
|
+
voluntaryContextSwitches: 0,
|
|
91
|
+
involuntaryContextSwitches: 0,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function threadCpuUsage() {
|
|
95
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.threadCpuUsage");
|
|
96
|
+
}
|
|
97
|
+
export function cpuUsage(_previousValue) {
|
|
98
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.cpuUsage");
|
|
99
|
+
}
|
|
100
|
+
// Properties and constants
|
|
101
|
+
export const channel = null;
|
|
102
|
+
export const connected = false;
|
|
103
|
+
export const debugPort = 0; // may be implemented to align with inspector in future
|
|
104
|
+
export const noDeprecation = false;
|
|
105
|
+
export const traceDeprecation = false;
|
|
106
|
+
export const throwDeprecation = false;
|
|
107
|
+
export const sourceMapsEnabled = false;
|
|
108
|
+
export const execPath = "";
|
|
109
|
+
export const permission = {
|
|
110
|
+
has: () => {
|
|
111
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.permission.has");
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
export const release = {
|
|
115
|
+
name: "node",
|
|
116
|
+
lts: true,
|
|
117
|
+
sourceUrl: "",
|
|
118
|
+
headersUrl: "",
|
|
119
|
+
};
|
|
120
|
+
export const report = {
|
|
121
|
+
compact: false,
|
|
122
|
+
directory: "",
|
|
123
|
+
filename: "",
|
|
124
|
+
getReport: () => {
|
|
125
|
+
// We do not intend to implement process.report in workerd, but there
|
|
126
|
+
// are some modules in the ecosystem that call it expecting it to exist and
|
|
127
|
+
// not throw. Returning an empty object for now to satisfy that use case.
|
|
128
|
+
return {};
|
|
129
|
+
},
|
|
130
|
+
reportOnFatalError: false,
|
|
131
|
+
reportOnSignal: false,
|
|
132
|
+
reportOnUncaughtException: false,
|
|
133
|
+
excludeNetwork: false,
|
|
134
|
+
excludeEnv: false,
|
|
135
|
+
signal: "SIGUSR2",
|
|
136
|
+
writeReport: () => {
|
|
137
|
+
// In this case, there's an expectation that the function will produce
|
|
138
|
+
// a report on disk and return the filename. Since we do not intend
|
|
139
|
+
// to implement this API in workerd, we throw to indicate that.
|
|
140
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.report.writeReport");
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
export const finalization = {
|
|
144
|
+
register: () => {
|
|
145
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.finalization.register");
|
|
146
|
+
},
|
|
147
|
+
registerBeforeExit: () => {
|
|
148
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.finalization.registerBeforeExit");
|
|
149
|
+
},
|
|
150
|
+
unregister: () => {
|
|
151
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.finalization.unregister");
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
// Additional undocumented APIs
|
|
155
|
+
export function _rawDebug(...args) {
|
|
156
|
+
console.log(...args);
|
|
157
|
+
}
|
|
158
|
+
export const moduleLoadList = [];
|
|
159
|
+
export const _preload_modules = [];
|
|
160
|
+
export function _linkedBinding(_name) {
|
|
161
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process._linkedBinding");
|
|
162
|
+
}
|
|
163
|
+
export const domain = null;
|
|
164
|
+
export const _exiting = false;
|
|
165
|
+
export function _getActiveRequests() {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
export function _getActiveHandles() {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
export function _kill(_pid, _signal) {
|
|
172
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process._kill");
|
|
173
|
+
}
|
|
174
|
+
export function constrainedMemory() {
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
export function availableMemory() {
|
|
178
|
+
// This may be implemented in future, for now this matches unenv
|
|
179
|
+
return 0;
|
|
180
|
+
}
|
|
181
|
+
export function execve(_file, _args, _env) {
|
|
182
|
+
throw new ERR_METHOD_NOT_IMPLEMENTED("process.execve");
|
|
183
|
+
}
|
|
184
|
+
export function _fatalException(_err) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
export function _tickCallback() {
|
|
188
|
+
// no-op
|
|
189
|
+
}
|
|
190
|
+
export function _debugProcess(_pid) {
|
|
191
|
+
// no-op
|
|
192
|
+
}
|
|
193
|
+
export function _debugEnd() {
|
|
194
|
+
// no-op
|
|
195
|
+
}
|
|
196
|
+
export function _startProfilerIdleNotifier() {
|
|
197
|
+
// no-op
|
|
198
|
+
}
|
|
199
|
+
export function _stopProfilerIdleNotifier() {
|
|
200
|
+
// no-op
|
|
201
|
+
}
|
|
202
|
+
export function send(_message, _sendHandle) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
export function uptime() {
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
// On the virtual filesystem, we only support group 0
|
|
209
|
+
export function getegid() {
|
|
210
|
+
return 0;
|
|
211
|
+
}
|
|
212
|
+
export function getgid() {
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
export function getgroups() {
|
|
216
|
+
return [0];
|
|
217
|
+
}
|
|
218
|
+
// On the virtual filesystem, we only support user 0
|
|
219
|
+
export function geteuid() {
|
|
220
|
+
return 0;
|
|
221
|
+
}
|
|
222
|
+
export function getuid() {
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
// We support group 0 but no others, with the virtual filesystem.
|
|
226
|
+
export function setegid(id) {
|
|
227
|
+
if (id !== 0)
|
|
228
|
+
throw new ERR_EPERM({ syscall: "setegid" });
|
|
229
|
+
}
|
|
230
|
+
// We support group 0 but no others, with the virtual filesystem.
|
|
231
|
+
export function setgid(id) {
|
|
232
|
+
if (id !== 0)
|
|
233
|
+
throw new ERR_EPERM({ syscall: "setgid" });
|
|
234
|
+
}
|
|
235
|
+
// We support group 0 but no others, with the virtual filesystem.
|
|
236
|
+
export function seteuid(id) {
|
|
237
|
+
if (id !== 0)
|
|
238
|
+
throw new ERR_EPERM({ syscall: "seteuid" });
|
|
239
|
+
}
|
|
240
|
+
// We support group 0 but no others, with the virtual filesystem.
|
|
241
|
+
export function setuid(id) {
|
|
242
|
+
if (id !== 0)
|
|
243
|
+
throw new ERR_EPERM({ syscall: "setuid" });
|
|
244
|
+
}
|
|
245
|
+
// We don't support setting or initializing arbitrary groups on the virtual filesystem.
|
|
246
|
+
export function setgroups(_groups) {
|
|
247
|
+
throw new ERR_EPERM({ syscall: "setgroups" });
|
|
248
|
+
}
|
|
249
|
+
export function initgroups(_user, _extractGroup) {
|
|
250
|
+
throw new ERR_EPERM({ syscall: "initgroups" });
|
|
251
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import process from "./state.js";
|
|
2
|
+
import { ERR_INVALID_ARG_TYPE } from "../net/errors.js";
|
|
3
|
+
// Pinned workerd also implements nextTick with queueMicrotask.
|
|
4
|
+
export function nextTick(callback, ...args) {
|
|
5
|
+
queueMicrotask(() => callback(...args));
|
|
6
|
+
}
|
|
7
|
+
// Adapted from cloudflare/workerd@5358e3d337336eaf696a48bc1563d808b10feba5,
|
|
8
|
+
// src/node/internal/internal_process.ts, Apache-2.0.
|
|
9
|
+
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
10
|
+
// https://opensource.org/licenses/Apache-2.0
|
|
11
|
+
export function emitWarning(warning, options, codeOrCtor, maybeCtor) {
|
|
12
|
+
let err;
|
|
13
|
+
let name = "Warning", detail, code, ctor;
|
|
14
|
+
if (typeof options === "object" && !Array.isArray(options)) {
|
|
15
|
+
if (options.type)
|
|
16
|
+
name = options.type;
|
|
17
|
+
if (options.code)
|
|
18
|
+
code = options.code;
|
|
19
|
+
if (options.detail)
|
|
20
|
+
detail = options.detail;
|
|
21
|
+
ctor = options.ctor;
|
|
22
|
+
}
|
|
23
|
+
else if (typeof options === "string") {
|
|
24
|
+
name = options;
|
|
25
|
+
if (typeof codeOrCtor === "string") {
|
|
26
|
+
code = codeOrCtor;
|
|
27
|
+
if (typeof maybeCtor === "function")
|
|
28
|
+
ctor = maybeCtor;
|
|
29
|
+
else if (maybeCtor !== undefined)
|
|
30
|
+
throw new ERR_INVALID_ARG_TYPE("ctor", "function", maybeCtor);
|
|
31
|
+
}
|
|
32
|
+
else if (typeof codeOrCtor === "function")
|
|
33
|
+
ctor = codeOrCtor;
|
|
34
|
+
else if (codeOrCtor !== undefined)
|
|
35
|
+
throw new ERR_INVALID_ARG_TYPE("ctor", "function", codeOrCtor);
|
|
36
|
+
}
|
|
37
|
+
else if (typeof options === "function")
|
|
38
|
+
ctor = options;
|
|
39
|
+
else if (options !== undefined)
|
|
40
|
+
throw new ERR_INVALID_ARG_TYPE("options", "object", options);
|
|
41
|
+
if (typeof warning === "string") {
|
|
42
|
+
err = new (ctor || Error)(warning);
|
|
43
|
+
err.name = name;
|
|
44
|
+
}
|
|
45
|
+
else if (warning instanceof Error) {
|
|
46
|
+
err = warning;
|
|
47
|
+
if (name && name !== "Warning")
|
|
48
|
+
err.name = name;
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
throw new ERR_INVALID_ARG_TYPE("warning", "string or Error", warning);
|
|
52
|
+
if (code)
|
|
53
|
+
err.code = code;
|
|
54
|
+
if (detail && typeof detail === "string")
|
|
55
|
+
err.detail = detail;
|
|
56
|
+
// WebKit lacks V8's captureStackTrace. Exact stack inspection remains a
|
|
57
|
+
// process/engine acceptance gap even when warning delivery matches.
|
|
58
|
+
Error.captureStackTrace?.(err, ctor || emitWarning);
|
|
59
|
+
queueMicrotask(() => process.emit("warning", err));
|
|
60
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Writable as DeclaredWritable } from "node:stream";
|
|
2
|
+
declare const Writable: typeof DeclaredWritable;
|
|
3
|
+
import { Buffer } from "node:buffer";
|
|
4
|
+
import { ReadStream } from "../fs/index.js";
|
|
5
|
+
declare class SyncWriteStream extends Writable {
|
|
6
|
+
readonly fd: number;
|
|
7
|
+
readable: boolean;
|
|
8
|
+
_type: string;
|
|
9
|
+
_isStdio: boolean;
|
|
10
|
+
constructor(fd: number);
|
|
11
|
+
_write(chunk: Buffer | string | ArrayBufferView, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
12
|
+
}
|
|
13
|
+
export declare let stdin: InstanceType<typeof ReadStream>;
|
|
14
|
+
export declare let stdout: SyncWriteStream;
|
|
15
|
+
export declare let stderr: SyncWriteStream;
|
|
16
|
+
export declare function openStdin(): any;
|
|
17
|
+
export declare function installStdio(): void;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) 2017-2026 Cloudflare, Inc. Apache-2.0.
|
|
2
|
+
// Adapted from workerd 5358e3d337336eaf696a48bc1563d808b10feba5 public_process.ts.
|
|
3
|
+
import { Writable as WritableImplementation } from "../stream/writable.js";
|
|
4
|
+
const Writable = WritableImplementation;
|
|
5
|
+
import { Buffer } from "node:buffer";
|
|
6
|
+
import { ReadStream, writeSync } from "../fs/index.js";
|
|
7
|
+
class SyncWriteStream extends Writable {
|
|
8
|
+
fd;
|
|
9
|
+
readable = false;
|
|
10
|
+
_type = "fs";
|
|
11
|
+
_isStdio = true;
|
|
12
|
+
constructor(fd) {
|
|
13
|
+
super({ autoDestroy: true });
|
|
14
|
+
this.fd = fd;
|
|
15
|
+
}
|
|
16
|
+
_write(chunk, encoding, callback) {
|
|
17
|
+
try {
|
|
18
|
+
writeSync(this.fd, Buffer.isBuffer(chunk)
|
|
19
|
+
? chunk
|
|
20
|
+
: typeof chunk === "string"
|
|
21
|
+
? Buffer.from(chunk, encoding)
|
|
22
|
+
: Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
callback(error);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
callback();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export let stdin;
|
|
32
|
+
export let stdout;
|
|
33
|
+
export let stderr;
|
|
34
|
+
export function openStdin() {
|
|
35
|
+
return stdin;
|
|
36
|
+
}
|
|
37
|
+
export function installStdio() {
|
|
38
|
+
if (stdin)
|
|
39
|
+
return;
|
|
40
|
+
stdin = new ReadStream(null, { fd: 0, autoClose: false });
|
|
41
|
+
Object.assign(stdin, {
|
|
42
|
+
fd: 0,
|
|
43
|
+
allowHalfOpen: false,
|
|
44
|
+
bufferSize: 0,
|
|
45
|
+
connecting: false,
|
|
46
|
+
readyState: "open",
|
|
47
|
+
});
|
|
48
|
+
stdout = new SyncWriteStream(1);
|
|
49
|
+
stderr = new SyncWriteStream(2);
|
|
50
|
+
for (const stream of [stdout, stderr])
|
|
51
|
+
Object.assign(stream, {
|
|
52
|
+
allowHalfOpen: false,
|
|
53
|
+
bufferSize: 0,
|
|
54
|
+
bytesRead: 0,
|
|
55
|
+
bytesWritten: 0,
|
|
56
|
+
connecting: false,
|
|
57
|
+
pending: false,
|
|
58
|
+
readableAborted: false,
|
|
59
|
+
readableDidRead: false,
|
|
60
|
+
readableEnded: false,
|
|
61
|
+
readableHighWaterMark: 16384,
|
|
62
|
+
readableLength: 0,
|
|
63
|
+
readableObjectMode: false,
|
|
64
|
+
readyState: "open",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function destroy(this: Readable | Writable, err?: Error, cb?: VoidFunction): this;
|
|
2
|
+
export declare function markInternalErrorInterruption(stream: object, error: unknown): void;
|
|
2
3
|
export declare function undestroy(this: Readable | Writable): void;
|
|
3
4
|
export declare function errorOrDestroy(stream: Readable | Writable, err?: Error, sync?: boolean): this | undefined;
|
|
4
5
|
export declare function construct(stream: Readable | Writable, cb: VoidFunction): void;
|
|
@@ -109,8 +109,28 @@ function _destroy(self, err, cb) {
|
|
|
109
109
|
onDestroy(err);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
// Workers consumes an unobserved internal TLS parent error at its async
|
|
113
|
+
// stream boundary. Direct EventEmitter.emit still throws to its caller.
|
|
114
|
+
const internalErrorInterruptions = new WeakMap();
|
|
115
|
+
export function markInternalErrorInterruption(stream, error) {
|
|
116
|
+
internalErrorInterruptions.set(stream, error);
|
|
117
|
+
queueMicrotask(() => {
|
|
118
|
+
if (internalErrorInterruptions.get(stream) === error)
|
|
119
|
+
internalErrorInterruptions.delete(stream);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
112
122
|
function emitErrorCloseNT(self, err) {
|
|
113
|
-
|
|
123
|
+
try {
|
|
124
|
+
emitErrorNT(self, err);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (internalErrorInterruptions.has(self) &&
|
|
128
|
+
internalErrorInterruptions.get(self) === error) {
|
|
129
|
+
internalErrorInterruptions.delete(self);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
114
134
|
emitCloseNT(self);
|
|
115
135
|
}
|
|
116
136
|
function emitCloseNT(self) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
import { ReadableStream as WorkersReadableStream } from "../stream-web/runtime.js";
|
|
2
3
|
import { asyncDispose } from "../../shared/globals/symbols.js";
|
|
3
4
|
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
4
5
|
// Licensed under the Apache 2.0 license found in the LICENSE file or at:
|
|
@@ -2107,7 +2108,9 @@ export function newReadableStreamFromStreamReadable(streamReadable, options = {}
|
|
|
2107
2108
|
}
|
|
2108
2109
|
return new globalThis.ByteLengthQueuingStrategy({ highWaterMark });
|
|
2109
2110
|
};
|
|
2110
|
-
const strategy =
|
|
2111
|
+
const strategy = createTypeBytes
|
|
2112
|
+
? { highWaterMark }
|
|
2113
|
+
: evaluateStrategyOrFallback(options?.strategy);
|
|
2111
2114
|
let controller;
|
|
2112
2115
|
let wasCanceled = false;
|
|
2113
2116
|
function onData(chunk) {
|
|
@@ -2135,7 +2138,10 @@ export function newReadableStreamFromStreamReadable(streamReadable, options = {}
|
|
|
2135
2138
|
// constructor rejects an invalid high-water mark, and a throw there must
|
|
2136
2139
|
// leave the source as it was, not paused with this adapter's listeners
|
|
2137
2140
|
// on it. The first pull() comes no earlier than a later microtask.
|
|
2138
|
-
const
|
|
2141
|
+
const StreamConstructor = createTypeBytes
|
|
2142
|
+
? WorkersReadableStream
|
|
2143
|
+
: globalThis.ReadableStream;
|
|
2144
|
+
const stream = new StreamConstructor({
|
|
2139
2145
|
start(c) {
|
|
2140
2146
|
controller = c;
|
|
2141
2147
|
},
|
|
@@ -2165,6 +2171,8 @@ export function newReadableStreamFromStreamReadable(streamReadable, options = {}
|
|
|
2165
2171
|
return;
|
|
2166
2172
|
}
|
|
2167
2173
|
controller.close();
|
|
2174
|
+
if (createTypeBytes)
|
|
2175
|
+
queueMicrotask(() => controller.byobRequest?.respond(0));
|
|
2168
2176
|
});
|
|
2169
2177
|
streamReadable.on("data", onData);
|
|
2170
2178
|
let adapted = adaptedReadableStreams.get(streamReadable);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mattias Buelens
|
|
4
|
+
Copyright (c) 2016 Diwank Singh Tomer
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "./workers-ponyfill.js";
|