cf-workers-native 0.1.5 → 0.1.7
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/headers/index.d.ts +2 -0
- package/dist/browser/headers/index.js +5 -0
- 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/compat/crypto/LICENSE-3RD-PARTY.md +20 -0
- package/dist/compat/crypto/LICENSE.boringssl +238 -0
- package/dist/compat/crypto/LICENSE.ncrypto +21 -0
- package/dist/compat/crypto/asymmetric.js +141 -68
- 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 +16 -6
- 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.js +40 -14
- package/dist/compat/crypto/index.d.cts +168 -1
- package/dist/compat/crypto/index.d.ts +191 -8
- package/dist/compat/crypto/index.js +36 -23
- 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 +2 -1
- package/dist/compat/crypto/key-formats.js +162 -31
- 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 +1 -0
- package/dist/compat/crypto/keys.d.ts +20 -12
- package/dist/compat/crypto/keys.js +129 -59
- package/dist/compat/crypto/metadata.d.ts +9 -0
- package/dist/compat/crypto/metadata.js +89 -2
- 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 +14 -1
- package/dist/compat/crypto/native-crypto.js +182 -6
- 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.js +4 -4
- package/dist/compat/crypto/random.d.ts +11 -0
- package/dist/compat/crypto/random.js +86 -6
- package/dist/compat/crypto/rsa.d.ts +17 -1
- package/dist/compat/crypto/rsa.js +8 -4
- package/dist/compat/crypto/scrypt.d.ts +3 -3
- package/dist/compat/crypto/scrypt.js +25 -23
- package/dist/compat/crypto/sign-handle.d.ts +3 -3
- package/dist/compat/crypto/sign-handle.js +55 -11
- package/dist/compat/crypto/signatures.d.ts +17 -11
- 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 +40 -24
- package/dist/compat/crypto/symmetric.js +229 -94
- package/dist/compat/crypto/validation.d.ts +4 -0
- package/dist/compat/crypto/validation.js +29 -2
- package/dist/compat/crypto/webcrypto.d.ts +13 -0
- package/dist/compat/crypto/webcrypto.js +51 -0
- package/dist/compat/crypto/x509.js +2 -1
- package/dist/compat/events/index.js +1 -1
- 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 +1 -1
- package/dist/compat/fs/embedded.js +7 -2
- package/dist/compat/fs/file-handle.d.ts +75 -0
- package/dist/compat/fs/file-handle.js +249 -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 +6 -3
- package/dist/compat/fs/index.js +596 -50
- 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 +283 -0
- package/dist/compat/fs/promises/index.d.ts +3 -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 +8 -0
- package/dist/compat/fs/writable.js +412 -22
- 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/unique-headers.d.ts +1 -0
- package/dist/compat/http/unique-headers.js +21 -0
- package/dist/compat/http-outgoing/index.d.ts +2 -1
- package/dist/compat/http-outgoing/index.js +2 -17
- package/dist/compat/http-server/index.d.ts +2 -2
- package/dist/compat/http-server/index.js +4 -85
- package/dist/compat/https/index.d.ts +4 -2
- package/dist/compat/net/sockets.js +98 -20
- 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.d.ts +15 -13
- package/dist/compat/process/index.js +47 -74
- package/dist/compat/process/scheduling.d.ts +2 -0
- package/dist/compat/process/scheduling.js +60 -0
- package/dist/compat/process/state.js +1 -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/tls/jsstream.js +16 -6
- package/dist/compat/tls/wrap.d.ts +1 -1
- package/dist/compat/tls/wrap.js +0 -3
- package/dist/compat/util/inspect.js +5 -1
- package/dist/compat/zlib/LICENSE-3RD-PARTY.md +11 -0
- package/dist/compat/zlib/LICENSE-APACHE +177 -0
- package/dist/compat/zlib/LICENSE.zlib +22 -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 +22 -51
- package/dist/compat/zlib/compression.js +129 -218
- package/dist/compat/zlib/errors.d.ts +21 -0
- package/dist/compat/zlib/errors.js +32 -0
- package/dist/compat/zlib/index.d.ts +367 -3
- package/dist/compat/zlib/index.js +28 -11
- 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 +7 -0
- package/dist/compat/zlib/native-codecs.js +22 -10
- 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/platform.d.ts +8 -0
- package/dist/shared/globals/platform.js +1 -0
- 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.js +4 -1
- package/dist/tooling/shared.js +6 -0
- package/dist/tooling/vite.js +4 -0
- package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +38 -7
- package/package.json +2 -2
|
@@ -1,93 +1,48 @@
|
|
|
1
|
+
import { currentDirectory as cwd, changeDirectory as chdir, } from "./directory.js";
|
|
2
|
+
export { cwd, chdir };
|
|
1
3
|
import * as metadata from "./metadata.js";
|
|
2
4
|
export { arch, pid, ppid, allowedNodeEnvironmentFlags, setSourceMapsEnabled, getSourceMapsSupport, ref, unref, setUncaughtExceptionCaptureCallback, hasUncaughtExceptionCaptureCallback, kill, binding, dlopen, exitCode, getActiveResourcesInfo, memoryUsage, resourceUsage, threadCpuUsage, cpuUsage, channel, connected, debugPort, noDeprecation, traceDeprecation, throwDeprecation, sourceMapsEnabled, execPath, permission, release, report, finalization, _rawDebug, moduleLoadList, _preload_modules, _linkedBinding, domain, _exiting, _getActiveRequests, _getActiveHandles, _kill, constrainedMemory, availableMemory, execve, _fatalException, _tickCallback, _debugProcess, _debugEnd, _startProfilerIdleNotifier, _stopProfilerIdleNotifier, send, uptime, getegid, getgid, getgroups, geteuid, getuid, setegid, setgid, seteuid, setuid, setgroups, initgroups, } from "./metadata.js";
|
|
3
5
|
// Event delivery, warning and nextTick integration for the WebView profile.
|
|
4
6
|
// Other process exports retain the existing polyfill; see ../events/README.md.
|
|
5
|
-
export
|
|
7
|
+
export { argv, env, execArgv, exit, features, platform, title, umask, version, versions, } from "cf-workers-native:process-base";
|
|
6
8
|
import process from "./state.js";
|
|
7
9
|
export { default } from "./state.js";
|
|
8
10
|
import { EventEmitter } from "../events/index.js";
|
|
9
11
|
import { ERR_INVALID_ARG_TYPE, ERR_OUT_OF_RANGE } from "../net/errors.js";
|
|
10
|
-
|
|
12
|
+
EventEmitter.init.call(process);
|
|
13
|
+
export const _events = process._events;
|
|
14
|
+
export const _eventsCount = process._eventsCount;
|
|
15
|
+
export const _maxListeners = process._maxListeners;
|
|
16
|
+
export const _channel = undefined, _disconnect = undefined, _handleQueue = undefined, _pendingMessage = undefined, _send = undefined;
|
|
17
|
+
export const argv0 = "workerd";
|
|
18
|
+
// The pinned profile retains the legacy assertion function.
|
|
19
|
+
import internalAssert from "../assert/index.js";
|
|
20
|
+
export const assert = internalAssert.ok.bind(internalAssert);
|
|
21
|
+
import { config } from "./configuration.js";
|
|
22
|
+
import { loadEnvFile } from "./files.js";
|
|
23
|
+
import * as stdio from "./stdio.js";
|
|
24
|
+
export { config, loadEnvFile };
|
|
25
|
+
export { stdin, stdout, stderr, openStdin } from "./stdio.js";
|
|
11
26
|
function invoke(method, args) {
|
|
12
|
-
if (!initialized) {
|
|
13
|
-
EventEmitter.init.call(process);
|
|
14
|
-
initialized = true;
|
|
15
|
-
}
|
|
16
27
|
return Reflect.apply(EventEmitter.prototype[method], process, args);
|
|
17
28
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
const on = (...args) => invoke("on", args);
|
|
30
|
+
const addListener = on;
|
|
31
|
+
const once = (...args) => invoke("once", args);
|
|
32
|
+
const prependListener = (...args) => invoke("prependListener", args);
|
|
33
|
+
const prependOnceListener = (...args) => invoke("prependOnceListener", args);
|
|
34
|
+
const off = (...args) => invoke("off", args);
|
|
35
|
+
const removeListener = off;
|
|
36
|
+
const removeAllListeners = (...args) => invoke("removeAllListeners", args);
|
|
37
|
+
const emit = (...args) => invoke("emit", args);
|
|
38
|
+
const listeners = (...args) => invoke("listeners", args);
|
|
28
39
|
const rawListeners = (...args) => invoke("rawListeners", args);
|
|
29
40
|
const eventNames = (...args) => invoke("eventNames", args);
|
|
30
41
|
const listenerCount = (...args) => invoke("listenerCount", args);
|
|
31
42
|
const getMaxListeners = (...args) => invoke("getMaxListeners", args);
|
|
32
43
|
const setMaxListeners = (...args) => invoke("setMaxListeners", args);
|
|
33
|
-
|
|
34
|
-
export
|
|
35
|
-
queueMicrotask(() => callback(...args));
|
|
36
|
-
}
|
|
37
|
-
// Adapted from cloudflare/workerd@5358e3d337336eaf696a48bc1563d808b10feba5,
|
|
38
|
-
// src/node/internal/internal_process.ts, Apache-2.0.
|
|
39
|
-
// Copyright (c) 2017-2022 Cloudflare, Inc.
|
|
40
|
-
// https://opensource.org/licenses/Apache-2.0
|
|
41
|
-
export function emitWarning(warning, options, codeOrCtor, maybeCtor) {
|
|
42
|
-
let err;
|
|
43
|
-
let name = "Warning", detail, code, ctor;
|
|
44
|
-
if (typeof options === "object" && !Array.isArray(options)) {
|
|
45
|
-
if (options.type)
|
|
46
|
-
name = options.type;
|
|
47
|
-
if (options.code)
|
|
48
|
-
code = options.code;
|
|
49
|
-
if (options.detail)
|
|
50
|
-
detail = options.detail;
|
|
51
|
-
ctor = options.ctor;
|
|
52
|
-
}
|
|
53
|
-
else if (typeof options === "string") {
|
|
54
|
-
name = options;
|
|
55
|
-
if (typeof codeOrCtor === "string") {
|
|
56
|
-
code = codeOrCtor;
|
|
57
|
-
if (typeof maybeCtor === "function")
|
|
58
|
-
ctor = maybeCtor;
|
|
59
|
-
else if (maybeCtor !== undefined)
|
|
60
|
-
throw new ERR_INVALID_ARG_TYPE("ctor", "function", maybeCtor);
|
|
61
|
-
}
|
|
62
|
-
else if (typeof codeOrCtor === "function")
|
|
63
|
-
ctor = codeOrCtor;
|
|
64
|
-
else if (codeOrCtor !== undefined)
|
|
65
|
-
throw new ERR_INVALID_ARG_TYPE("ctor", "function", codeOrCtor);
|
|
66
|
-
}
|
|
67
|
-
else if (typeof options === "function")
|
|
68
|
-
ctor = options;
|
|
69
|
-
else if (options !== undefined)
|
|
70
|
-
throw new ERR_INVALID_ARG_TYPE("options", "object", options);
|
|
71
|
-
if (typeof warning === "string") {
|
|
72
|
-
err = new (ctor || Error)(warning);
|
|
73
|
-
err.name = name;
|
|
74
|
-
}
|
|
75
|
-
else if (warning instanceof Error) {
|
|
76
|
-
err = warning;
|
|
77
|
-
if (name && name !== "Warning")
|
|
78
|
-
err.name = name;
|
|
79
|
-
}
|
|
80
|
-
else
|
|
81
|
-
throw new ERR_INVALID_ARG_TYPE("warning", "string or Error", warning);
|
|
82
|
-
if (code)
|
|
83
|
-
err.code = code;
|
|
84
|
-
if (detail && typeof detail === "string")
|
|
85
|
-
err.detail = detail;
|
|
86
|
-
// WebKit lacks V8's captureStackTrace. Exact stack inspection remains a
|
|
87
|
-
// process/engine acceptance gap even when warning delivery matches.
|
|
88
|
-
Error.captureStackTrace?.(err, ctor || emitWarning);
|
|
89
|
-
queueMicrotask(() => process.emit("warning", err));
|
|
90
|
-
}
|
|
44
|
+
import { nextTick, emitWarning } from "./scheduling.js";
|
|
45
|
+
export { nextTick, emitWarning };
|
|
91
46
|
export const hrtime = Object.assign(function hrtime(time) {
|
|
92
47
|
if (time !== undefined) {
|
|
93
48
|
if (!Array.isArray(time))
|
|
@@ -118,6 +73,8 @@ export const hrtime = Object.assign(function hrtime(time) {
|
|
|
118
73
|
},
|
|
119
74
|
});
|
|
120
75
|
Object.assign(process, {
|
|
76
|
+
cwd,
|
|
77
|
+
chdir,
|
|
121
78
|
hrtime,
|
|
122
79
|
...metadata,
|
|
123
80
|
on,
|
|
@@ -138,3 +95,19 @@ Object.assign(process, {
|
|
|
138
95
|
nextTick,
|
|
139
96
|
emitWarning,
|
|
140
97
|
});
|
|
98
|
+
stdio.installStdio();
|
|
99
|
+
Object.assign(process, {
|
|
100
|
+
config,
|
|
101
|
+
loadEnvFile,
|
|
102
|
+
argv0,
|
|
103
|
+
assert,
|
|
104
|
+
_channel,
|
|
105
|
+
_disconnect,
|
|
106
|
+
_handleQueue,
|
|
107
|
+
_pendingMessage,
|
|
108
|
+
_send,
|
|
109
|
+
stdin: stdio.stdin,
|
|
110
|
+
stdout: stdio.stdout,
|
|
111
|
+
stderr: stdio.stderr,
|
|
112
|
+
openStdin: stdio.openStdin,
|
|
113
|
+
});
|
|
@@ -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);
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
24
24
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
25
|
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
26
|
+
import { markInternalErrorInterruption } from "../stream/destroy.js";
|
|
26
27
|
import { notStrictEqual } from "../assert/index.js";
|
|
27
28
|
import { Socket } from "../net/internal-net.js";
|
|
28
29
|
import { ERR_STREAM_WRAP } from "./errors.js";
|
|
@@ -84,8 +85,8 @@ export class JSStreamSocket extends Socket {
|
|
|
84
85
|
writable: webStream.writable,
|
|
85
86
|
},
|
|
86
87
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
87
|
-
reader:
|
|
88
|
-
writer:
|
|
88
|
+
reader: webStream.readable.getReader({ mode: "byob" }),
|
|
89
|
+
writer: webStream.writable.getWriter(),
|
|
89
90
|
options: {
|
|
90
91
|
host: "0.0.0.0",
|
|
91
92
|
port: 0,
|
|
@@ -93,20 +94,29 @@ export class JSStreamSocket extends Socket {
|
|
|
93
94
|
},
|
|
94
95
|
};
|
|
95
96
|
stream.pause();
|
|
96
|
-
stream.on("error", (err) =>
|
|
97
|
+
stream.on("error", (err) => {
|
|
98
|
+
const unobserved = this.listenerCount("error") === 0;
|
|
99
|
+
try {
|
|
100
|
+
this.emit("error", err);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (unobserved)
|
|
104
|
+
markInternalErrorInterruption(stream, error);
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
97
108
|
const ondata = (chunk) => {
|
|
98
109
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
|
|
99
110
|
if (typeof chunk === "string" || stream.readableObjectMode === true) {
|
|
100
111
|
// Make sure that no further `data` events will happen.
|
|
101
112
|
stream.pause();
|
|
102
113
|
stream.removeListener("data", ondata);
|
|
103
|
-
|
|
104
|
-
return;
|
|
114
|
+
throw new ERR_STREAM_WRAP();
|
|
105
115
|
}
|
|
106
116
|
// TODO(soon): We need to trigger read() result for _handle.reader.read(buf) call
|
|
107
117
|
// in node:net.
|
|
108
118
|
};
|
|
109
|
-
stream.
|
|
119
|
+
stream.prependListener("data", ondata);
|
|
110
120
|
stream.once("end", () => {
|
|
111
121
|
closePromise.resolve();
|
|
112
122
|
});
|
|
@@ -32,7 +32,7 @@ export declare class TLSSocket extends Socket {
|
|
|
32
32
|
[kPendingSession]: null | Buffer;
|
|
33
33
|
[kErrorEmitted]: boolean;
|
|
34
34
|
[kConnectOptions]?: NormalizedConnectionOptions;
|
|
35
|
-
constructor(socket: Socket | Duplex | undefined, opts
|
|
35
|
+
constructor(socket: Socket | Duplex | undefined, opts?: TLSSocket["_tlsOptions"]);
|
|
36
36
|
prototype: TLSSocket;
|
|
37
37
|
_destroySSL(): void;
|
|
38
38
|
_emitTLSError(error: Error): void;
|
package/dist/compat/tls/wrap.js
CHANGED
|
@@ -119,9 +119,6 @@ export function TLSSocket(socket, opts) {
|
|
|
119
119
|
throw new ERR_OPTION_NOT_IMPLEMENTED("options.checkServerIdentity");
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
if (socket != null && !(socket instanceof Socket)) {
|
|
123
|
-
throw new ERR_METHOD_NOT_IMPLEMENTED("TLS upgrade of a custom Duplex");
|
|
124
|
-
}
|
|
125
122
|
if (socket instanceof Socket &&
|
|
126
123
|
(socket.destroyed ||
|
|
127
124
|
(socket._handle &&
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
/* TODO: the following is adopted code, enabling linting one day */
|
|
30
30
|
/* eslint-disable */
|
|
31
31
|
import internal from "./inspect-binding.js";
|
|
32
|
+
import { isKeyObject } from "../crypto/key-state.js";
|
|
32
33
|
import { Buffer } from "node:buffer";
|
|
33
34
|
import { isAsyncFunction, isGeneratorFunction, isAnyArrayBuffer, isArrayBuffer, isArgumentsObject, isBoxedPrimitive, isDataView, isMap, isMapIterator, isModuleNamespaceObject, isNativeError, isPromise, isSet, isSetIterator, isWeakMap, isWeakSet, isRegExp, isDate, isTypedArray, isStringObject, isNumberObject, isBooleanObject, isBigIntObject, } from "./inspect-types.js";
|
|
34
35
|
// import { ALL_PROPERTIES, ONLY_ENUMERABLE, getOwnNonIndexProperties } from "node-internal:internal_utils";
|
|
@@ -1112,7 +1113,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
|
|
|
1112
1113
|
}
|
|
1113
1114
|
}
|
|
1114
1115
|
else {
|
|
1115
|
-
|
|
1116
|
+
// Workers keeps a key handle as an own symbol; this adapter keeps it in
|
|
1117
|
+
// WeakMap state. Preserve depth truncation even though our own keys are empty.
|
|
1118
|
+
const truncateKey = isKeyObject(value) && ctx.depth !== null && recurseTimes > ctx.depth;
|
|
1119
|
+
if (keys.length === 0 && protoProps === undefined && !truncateKey) {
|
|
1116
1120
|
return `${getCtxStyle(value, constructor, tag)}{}`;
|
|
1117
1121
|
}
|
|
1118
1122
|
braces[0] = `${getCtxStyle(value, constructor, tag)}{`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Upstream notices
|
|
2
|
+
|
|
3
|
+
This module ports Cloudflare workerd tag `v1.20261012.1`, revision
|
|
4
|
+
`5358e3d337336eaf696a48bc1563d808b10feba5`:
|
|
5
|
+
|
|
6
|
+
- `src/node/_tls_common.ts`
|
|
7
|
+
- `src/node/internal/internal_tls_common.ts`
|
|
8
|
+
|
|
9
|
+
Copyright Cloudflare, Inc.; Apache License 2.0. Node.js/Joyent MIT notices
|
|
10
|
+
are preserved in the source files. Imports, resource-management symbols and
|
|
11
|
+
host constructor references are adapted for the Capacitor runtime.
|