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.
Files changed (296) hide show
  1. package/README.md +2 -2
  2. package/dist/browser/documents/page-source.js +1 -1
  3. package/dist/browser/fetch/host-call.js +6 -1
  4. package/dist/browser/fetch/native-network.d.ts +1 -1
  5. package/dist/browser/fetch/relay.js +2 -0
  6. package/dist/browser/headers/index.d.ts +2 -0
  7. package/dist/browser/headers/index.js +5 -0
  8. package/dist/browser/isolated/transport.js +3 -2
  9. package/dist/browser/request/index.js +3 -2
  10. package/dist/browser/response/index.d.ts +2 -0
  11. package/dist/browser/response/index.js +11 -3
  12. package/dist/browser/structured-clone/index.d.ts +3 -0
  13. package/dist/browser/structured-clone/index.js +75 -7
  14. package/dist/browser/websocket/attachment-size.d.ts +3 -0
  15. package/dist/browser/websocket/attachment-size.js +336 -0
  16. package/dist/browser/websocket/brand.d.ts +4 -0
  17. package/dist/browser/websocket/brand.js +16 -0
  18. package/dist/browser/websocket/close-event.d.ts +7 -0
  19. package/dist/browser/websocket/close-event.js +30 -0
  20. package/dist/browser/websocket/compression.d.ts +5 -0
  21. package/dist/browser/websocket/compression.js +124 -0
  22. package/dist/browser/websocket/conversion.d.ts +2 -0
  23. package/dist/browser/websocket/conversion.js +13 -0
  24. package/dist/browser/websocket/endpoint.d.ts +39 -0
  25. package/dist/browser/websocket/endpoint.js +379 -0
  26. package/dist/browser/websocket/frames.d.ts +21 -0
  27. package/dist/browser/websocket/frames.js +121 -0
  28. package/dist/browser/websocket/native.d.ts +14 -0
  29. package/dist/browser/websocket/native.js +226 -0
  30. package/dist/cloudflare/apis/cloudflare-node/index.js +11 -23
  31. package/dist/cloudflare/workers/worker-runtime.js +2 -1
  32. package/dist/compat/console/index.d.ts +35 -0
  33. package/dist/compat/console/index.js +92 -0
  34. package/dist/compat/crypto/LICENSE-3RD-PARTY.md +39 -0
  35. package/dist/compat/crypto/LICENSE-APACHE +177 -0
  36. package/dist/compat/crypto/LICENSE.boringssl +238 -0
  37. package/dist/compat/crypto/LICENSE.emscripten +102 -0
  38. package/dist/compat/crypto/LICENSE.musl +193 -0
  39. package/dist/compat/crypto/LICENSE.ncrypto +21 -0
  40. package/dist/compat/crypto/LICENSE.openssl +177 -0
  41. package/dist/compat/crypto/asymmetric.d.ts +13 -0
  42. package/dist/compat/crypto/asymmetric.js +312 -0
  43. package/dist/compat/crypto/brorand.cjs +74 -0
  44. package/dist/compat/crypto/brorand.d.cts +6 -0
  45. package/dist/compat/crypto/certificate.d.ts +14 -0
  46. package/dist/compat/crypto/certificate.js +66 -0
  47. package/dist/compat/crypto/cipher-handle.d.ts +27 -0
  48. package/dist/compat/crypto/cipher-handle.js +239 -0
  49. package/dist/compat/crypto/cipher-info.d.ts +12 -0
  50. package/dist/compat/crypto/cipher-info.js +324 -0
  51. package/dist/compat/crypto/constants.d.ts +62 -0
  52. package/dist/compat/crypto/constants.js +68 -0
  53. package/dist/compat/crypto/dh-handle.d.ts +17 -0
  54. package/dist/compat/crypto/dh-handle.js +180 -0
  55. package/dist/compat/crypto/dh.d.ts +53 -0
  56. package/dist/compat/crypto/dh.js +138 -0
  57. package/dist/compat/crypto/digest-stream.d.ts +15 -0
  58. package/dist/compat/crypto/digest-stream.js +213 -0
  59. package/dist/compat/crypto/digests.d.ts +3 -0
  60. package/dist/compat/crypto/digests.js +32 -0
  61. package/dist/compat/crypto/ecdh.d.ts +25 -0
  62. package/dist/compat/crypto/ecdh.js +109 -0
  63. package/dist/compat/crypto/hash-handle.d.ts +23 -0
  64. package/dist/compat/crypto/hash-handle.js +70 -0
  65. package/dist/compat/crypto/hash.d.ts +37 -0
  66. package/dist/compat/crypto/hash.js +218 -0
  67. package/dist/compat/crypto/hkdf.d.ts +2 -0
  68. package/dist/compat/crypto/hkdf.js +78 -0
  69. package/dist/compat/crypto/index.cjs +2 -0
  70. package/dist/compat/crypto/index.d.cts +169 -0
  71. package/dist/compat/crypto/index.d.ts +213 -0
  72. package/dist/compat/crypto/index.js +96 -0
  73. package/dist/compat/crypto/key-errors.d.ts +10 -0
  74. package/dist/compat/crypto/key-errors.js +17 -0
  75. package/dist/compat/crypto/key-export.d.ts +8 -0
  76. package/dist/compat/crypto/key-export.js +49 -0
  77. package/dist/compat/crypto/key-formats.d.ts +7 -0
  78. package/dist/compat/crypto/key-formats.js +251 -0
  79. package/dist/compat/crypto/key-options.d.ts +1 -0
  80. package/dist/compat/crypto/key-options.js +74 -0
  81. package/dist/compat/crypto/key-state.d.ts +10 -0
  82. package/dist/compat/crypto/key-state.js +4 -0
  83. package/dist/compat/crypto/keys.d.ts +58 -0
  84. package/dist/compat/crypto/keys.js +278 -0
  85. package/dist/compat/crypto/metadata.d.ts +13 -0
  86. package/dist/compat/crypto/metadata.js +109 -0
  87. package/dist/compat/crypto/native-cipher.d.ts +17 -0
  88. package/dist/compat/crypto/native-cipher.js +192 -0
  89. package/dist/compat/crypto/native-crypto.d.ts +81 -0
  90. package/dist/compat/crypto/native-crypto.js +681 -0
  91. package/dist/compat/crypto/pbkdf2-handle.d.ts +4 -0
  92. package/dist/compat/crypto/pbkdf2-handle.js +26 -0
  93. package/dist/compat/crypto/pbkdf2.d.ts +5 -0
  94. package/dist/compat/crypto/pbkdf2.js +60 -0
  95. package/dist/compat/crypto/prime.d.ts +19 -0
  96. package/dist/compat/crypto/prime.js +146 -0
  97. package/dist/compat/crypto/random.d.ts +18 -0
  98. package/dist/compat/crypto/random.js +203 -0
  99. package/dist/compat/crypto/rsa.d.ts +21 -0
  100. package/dist/compat/crypto/rsa.js +177 -0
  101. package/dist/compat/crypto/scrypt.d.ts +25 -0
  102. package/dist/compat/crypto/scrypt.js +152 -0
  103. package/dist/compat/crypto/sign-errors.d.ts +8 -0
  104. package/dist/compat/crypto/sign-errors.js +13 -0
  105. package/dist/compat/crypto/sign-handle.d.ts +22 -0
  106. package/dist/compat/crypto/sign-handle.js +149 -0
  107. package/dist/compat/crypto/signatures.d.ts +34 -0
  108. package/dist/compat/crypto/signatures.js +252 -0
  109. package/dist/compat/crypto/subtle-digest.d.ts +1 -0
  110. package/dist/compat/crypto/subtle-digest.js +56 -0
  111. package/dist/compat/crypto/symmetric.d.ts +45 -0
  112. package/dist/compat/crypto/symmetric.js +239 -0
  113. package/dist/compat/crypto/validation.d.ts +7 -0
  114. package/dist/compat/crypto/validation.js +46 -0
  115. package/dist/compat/crypto/webcrypto.d.ts +13 -0
  116. package/dist/compat/crypto/webcrypto.js +51 -0
  117. package/dist/compat/crypto/x509.d.ts +30 -0
  118. package/dist/compat/crypto/x509.js +407 -0
  119. package/dist/compat/events/errors.d.ts +8 -0
  120. package/dist/compat/events/errors.js +39 -0
  121. package/dist/compat/events/index.cjs +2 -0
  122. package/dist/compat/events/index.d.cts +2 -0
  123. package/dist/compat/events/index.d.ts +64 -0
  124. package/dist/compat/events/index.js +792 -0
  125. package/dist/compat/events/intrinsics.d.ts +1 -0
  126. package/dist/compat/events/intrinsics.js +2 -0
  127. package/dist/compat/fs/LICENSE-3RD-PARTY.md +11 -0
  128. package/dist/compat/fs/LICENSE-APACHE +177 -0
  129. package/dist/compat/fs/directory-backend.d.ts +6 -0
  130. package/dist/compat/fs/directory-backend.js +51 -0
  131. package/dist/compat/fs/directory.d.ts +37 -0
  132. package/dist/compat/fs/directory.js +137 -0
  133. package/dist/compat/fs/embedded.d.ts +85 -0
  134. package/dist/compat/fs/embedded.js +260 -0
  135. package/dist/compat/fs/file-handle.d.ts +75 -0
  136. package/dist/compat/fs/file-handle.js +226 -0
  137. package/dist/compat/fs/glob-internal.d.ts +15 -0
  138. package/dist/compat/fs/glob-internal.js +417 -0
  139. package/dist/compat/fs/glob.d.ts +10 -0
  140. package/dist/compat/fs/glob.js +71 -0
  141. package/dist/compat/fs/index.d.ts +8 -82
  142. package/dist/compat/fs/index.js +736 -238
  143. package/dist/compat/fs/io-validation.d.ts +14 -0
  144. package/dist/compat/fs/io-validation.js +130 -0
  145. package/dist/compat/fs/io.d.ts +1 -0
  146. package/dist/compat/fs/io.js +282 -0
  147. package/dist/compat/fs/mode.d.ts +1 -0
  148. package/dist/compat/fs/mode.js +13 -0
  149. package/dist/compat/fs/promises/index.d.ts +3 -1
  150. package/dist/compat/fs/promises/index.js +1 -1
  151. package/dist/compat/fs/public-types.d.ts +120 -0
  152. package/dist/compat/fs/public-types.js +1 -0
  153. package/dist/compat/fs/stream-errors.d.ts +6 -0
  154. package/dist/compat/fs/stream-errors.js +8 -0
  155. package/dist/compat/fs/stream-utils.d.ts +16 -0
  156. package/dist/compat/fs/stream-utils.js +29 -0
  157. package/dist/compat/fs/streams.d.ts +104 -0
  158. package/dist/compat/fs/streams.js +794 -0
  159. package/dist/compat/fs/writable.d.ts +14 -0
  160. package/dist/compat/fs/writable.js +532 -0
  161. package/dist/compat/http/index.d.ts +11 -28
  162. package/dist/compat/http/index.js +81 -125
  163. package/dist/compat/http/server-options.d.ts +1 -0
  164. package/dist/compat/http/server-options.js +87 -0
  165. package/dist/compat/http/symbols.d.ts +5 -0
  166. package/dist/compat/http/symbols.js +9 -0
  167. package/dist/compat/http/unique-headers.d.ts +1 -0
  168. package/dist/compat/http/unique-headers.js +21 -0
  169. package/dist/compat/http-common/index.d.ts +37 -0
  170. package/dist/compat/http-common/index.js +43 -0
  171. package/dist/compat/http-outgoing/index.d.ts +14 -0
  172. package/dist/compat/http-outgoing/index.js +17 -0
  173. package/dist/compat/http-server/index.d.ts +18 -0
  174. package/dist/compat/http-server/index.js +26 -0
  175. package/dist/compat/https/index.d.ts +4 -2
  176. package/dist/compat/module/builtins.d.ts +1 -0
  177. package/dist/compat/module/builtins.js +101 -0
  178. package/dist/compat/module/index.d.ts +4 -2
  179. package/dist/compat/module/index.js +22 -17
  180. package/dist/compat/module/metadata.d.ts +44 -0
  181. package/dist/compat/module/metadata.js +127 -0
  182. package/dist/compat/net/internal-net.js +4 -0
  183. package/dist/compat/net/sockets.d.ts +5 -0
  184. package/dist/compat/net/sockets.js +153 -14
  185. package/dist/compat/net/validators.d.ts +1 -0
  186. package/dist/compat/net/validators.js +8 -0
  187. package/dist/compat/process/configuration.d.ts +113 -0
  188. package/dist/compat/process/configuration.js +115 -0
  189. package/dist/compat/process/directory.d.ts +4 -0
  190. package/dist/compat/process/directory.js +28 -0
  191. package/dist/compat/process/files.d.ts +3 -0
  192. package/dist/compat/process/files.js +10 -0
  193. package/dist/compat/process/index.cjs +2 -0
  194. package/dist/compat/process/index.d.cts +4 -0
  195. package/dist/compat/process/index.d.ts +20 -0
  196. package/dist/compat/process/index.js +113 -0
  197. package/dist/compat/process/metadata.d.ts +135 -0
  198. package/dist/compat/process/metadata.js +251 -0
  199. package/dist/compat/process/scheduling.d.ts +2 -0
  200. package/dist/compat/process/scheduling.js +60 -0
  201. package/dist/compat/process/state.d.ts +4 -0
  202. package/dist/compat/process/state.js +5 -0
  203. package/dist/compat/process/stdio.d.ts +18 -0
  204. package/dist/compat/process/stdio.js +66 -0
  205. package/dist/compat/stream/destroy.d.ts +1 -0
  206. package/dist/compat/stream/destroy.js +21 -1
  207. package/dist/compat/stream/readable.js +10 -2
  208. package/dist/compat/stream-web/LICENSE +22 -0
  209. package/dist/compat/stream-web/ponyfill.d.ts +1 -1
  210. package/dist/compat/stream-web/ponyfill.js +2369 -1775
  211. package/dist/compat/stream-web/runtime.d.ts +1 -1
  212. package/dist/compat/stream-web/runtime.js +3 -2
  213. package/dist/compat/stream-wrap/LICENSE-3RD-PARTY.md +11 -0
  214. package/dist/compat/stream-wrap/LICENSE-APACHE +177 -0
  215. package/dist/compat/stream-wrap/index.d.ts +1 -0
  216. package/dist/compat/stream-wrap/index.js +1 -0
  217. package/dist/compat/tls/LICENSE-3RD-PARTY.md +11 -0
  218. package/dist/compat/tls/LICENSE-APACHE +177 -0
  219. package/dist/compat/tls/constants.d.ts +7 -0
  220. package/dist/compat/tls/constants.js +14 -0
  221. package/dist/compat/tls/errors.d.ts +35 -0
  222. package/dist/compat/tls/errors.js +68 -0
  223. package/dist/compat/tls/helpers.d.ts +9 -0
  224. package/dist/compat/tls/helpers.js +207 -0
  225. package/dist/compat/tls/index.d.ts +26 -0
  226. package/dist/compat/tls/index.js +50 -0
  227. package/dist/compat/tls/jsstream.d.ts +19 -0
  228. package/dist/compat/tls/jsstream.js +196 -0
  229. package/dist/compat/tls/native-session.d.ts +3 -0
  230. package/dist/compat/tls/native-session.js +187 -0
  231. package/dist/compat/tls/wrap.d.ts +65 -0
  232. package/dist/compat/tls/wrap.js +541 -0
  233. package/dist/compat/tls-wrap/LICENSE-3RD-PARTY.md +11 -0
  234. package/dist/compat/tls-wrap/LICENSE-APACHE +177 -0
  235. package/dist/compat/tls-wrap/index.d.ts +7 -0
  236. package/dist/compat/tls-wrap/index.js +3 -0
  237. package/dist/compat/util/index.js +43 -1
  238. package/dist/compat/util/inspect.js +5 -1
  239. package/dist/compat/util/types/index.d.ts +3 -0
  240. package/dist/compat/util/types/index.js +5 -0
  241. package/dist/compat/zlib/LICENSE-3RD-PARTY.md +11 -0
  242. package/dist/compat/zlib/LICENSE-APACHE +177 -0
  243. package/dist/compat/zlib/LICENSE.brotli +19 -0
  244. package/dist/compat/zlib/LICENSE.emscripten +102 -0
  245. package/dist/compat/zlib/LICENSE.musl +193 -0
  246. package/dist/compat/zlib/LICENSE.zlib +22 -0
  247. package/dist/compat/zlib/LICENSE.zstd +30 -0
  248. package/dist/compat/zlib/classic-base.cjs +600 -0
  249. package/dist/compat/zlib/classic-base.d.cts +39 -0
  250. package/dist/compat/zlib/classic-binding.d.ts +28 -0
  251. package/dist/compat/zlib/classic-binding.js +105 -0
  252. package/dist/compat/zlib/classic.d.ts +44 -0
  253. package/dist/compat/zlib/classic.js +199 -0
  254. package/dist/compat/zlib/codec-binding.d.ts +33 -0
  255. package/dist/compat/zlib/codec-binding.js +141 -0
  256. package/dist/compat/zlib/compression.d.ts +26 -0
  257. package/dist/compat/zlib/compression.js +170 -0
  258. package/dist/compat/zlib/constants.d.ts +172 -0
  259. package/dist/compat/zlib/constants.js +173 -0
  260. package/dist/compat/zlib/errors.d.ts +21 -0
  261. package/dist/compat/zlib/errors.js +32 -0
  262. package/dist/compat/zlib/index.d.ts +544 -0
  263. package/dist/compat/zlib/index.js +194 -0
  264. package/dist/compat/zlib/input.d.ts +16 -0
  265. package/dist/compat/zlib/input.js +132 -0
  266. package/dist/compat/zlib/native-codecs.d.ts +24 -0
  267. package/dist/compat/zlib/native-codecs.js +180 -0
  268. package/dist/compat/zlib/native-zlib.d.ts +5 -0
  269. package/dist/compat/zlib/native-zlib.js +52 -0
  270. package/dist/compat/zlib/public-types.d.ts +48 -0
  271. package/dist/compat/zlib/public-types.js +1 -0
  272. package/dist/compat/zlib/validators.d.ts +3 -0
  273. package/dist/compat/zlib/validators.js +18 -0
  274. package/dist/shared/buffer-source.d.ts +5 -0
  275. package/dist/shared/buffer-source.js +70 -0
  276. package/dist/shared/globals/inject.d.ts +2 -1
  277. package/dist/shared/globals/inject.js +2 -1
  278. package/dist/shared/globals/platform.d.ts +8 -0
  279. package/dist/shared/globals/platform.js +1 -0
  280. package/dist/shared/globals/runtime.d.ts +1 -2
  281. package/dist/shared/globals/runtime.js +1 -2
  282. package/dist/shared/globals/web.js +5 -0
  283. package/dist/shared/request-context.d.ts +2 -0
  284. package/dist/shared/request-context.js +11 -0
  285. package/dist/shared/request-scope.d.ts +4 -0
  286. package/dist/shared/request-scope.js +14 -0
  287. package/dist/tooling/async.js +36 -14
  288. package/dist/tooling/shared.d.ts +1 -0
  289. package/dist/tooling/shared.js +26 -1
  290. package/dist/tooling/vite.js +8 -3
  291. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +92 -13
  292. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +4 -2
  293. package/native/ios/NetworkBridge.swift +11 -1
  294. package/native/ios/SocketBridge.swift +37 -2
  295. package/native/ios/WorkersCapacitorPlugin.swift +4 -0
  296. 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,2 @@
1
+ export declare function nextTick(callback: (...args: any[]) => void, ...args: any[]): void;
2
+ export declare function emitWarning(warning: string | Error, options?: any, codeOrCtor?: any, maybeCtor?: any): void;
@@ -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,4 @@
1
+ declare const process: {
2
+ [x: string]: any;
3
+ };
4
+ export default process;
@@ -0,0 +1,5 @@
1
+ /// <reference path="./base.d.ts" />
2
+ import original from "cf-workers-native:process-base";
3
+ // A dependency leaf keeps process.env available during events/util cycles.
4
+ const process = { ...original };
5
+ export default process;
@@ -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
- emitErrorNT(self, err);
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 = evaluateStrategyOrFallback(options?.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 stream = new globalThis.ReadableStream({
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 "web-streams-polyfill";
1
+ export * from "./workers-ponyfill.js";