@scelar/nodepod 1.0.0

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 (134) hide show
  1. package/LICENSE +43 -0
  2. package/README.md +240 -0
  3. package/dist/child_process-BJOMsZje.js +8233 -0
  4. package/dist/child_process-BJOMsZje.js.map +1 -0
  5. package/dist/child_process-Cj8vOcuc.cjs +7434 -0
  6. package/dist/child_process-Cj8vOcuc.cjs.map +1 -0
  7. package/dist/index-Cb1Cgdnd.js +35308 -0
  8. package/dist/index-Cb1Cgdnd.js.map +1 -0
  9. package/dist/index-DsMGS-xc.cjs +37195 -0
  10. package/dist/index-DsMGS-xc.cjs.map +1 -0
  11. package/dist/index.cjs +65 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.mjs +59 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/package.json +95 -0
  16. package/src/__tests__/smoke.test.ts +11 -0
  17. package/src/constants/cdn-urls.ts +18 -0
  18. package/src/constants/config.ts +236 -0
  19. package/src/cross-origin.ts +26 -0
  20. package/src/engine-factory.ts +176 -0
  21. package/src/engine-types.ts +56 -0
  22. package/src/helpers/byte-encoding.ts +39 -0
  23. package/src/helpers/digest.ts +9 -0
  24. package/src/helpers/event-loop.ts +96 -0
  25. package/src/helpers/wasm-cache.ts +133 -0
  26. package/src/iframe-sandbox.ts +141 -0
  27. package/src/index.ts +192 -0
  28. package/src/isolation-helpers.ts +148 -0
  29. package/src/memory-volume.ts +941 -0
  30. package/src/module-transformer.ts +368 -0
  31. package/src/packages/archive-extractor.ts +248 -0
  32. package/src/packages/browser-bundler.ts +284 -0
  33. package/src/packages/installer.ts +396 -0
  34. package/src/packages/registry-client.ts +131 -0
  35. package/src/packages/version-resolver.ts +411 -0
  36. package/src/polyfills/assert.ts +384 -0
  37. package/src/polyfills/async_hooks.ts +144 -0
  38. package/src/polyfills/buffer.ts +628 -0
  39. package/src/polyfills/child_process.ts +2288 -0
  40. package/src/polyfills/chokidar.ts +336 -0
  41. package/src/polyfills/cluster.ts +106 -0
  42. package/src/polyfills/console.ts +136 -0
  43. package/src/polyfills/constants.ts +123 -0
  44. package/src/polyfills/crypto.ts +885 -0
  45. package/src/polyfills/dgram.ts +87 -0
  46. package/src/polyfills/diagnostics_channel.ts +76 -0
  47. package/src/polyfills/dns.ts +134 -0
  48. package/src/polyfills/domain.ts +68 -0
  49. package/src/polyfills/esbuild.ts +854 -0
  50. package/src/polyfills/events.ts +276 -0
  51. package/src/polyfills/fs.ts +2888 -0
  52. package/src/polyfills/fsevents.ts +79 -0
  53. package/src/polyfills/http.ts +1449 -0
  54. package/src/polyfills/http2.ts +199 -0
  55. package/src/polyfills/https.ts +76 -0
  56. package/src/polyfills/inspector.ts +62 -0
  57. package/src/polyfills/lightningcss.ts +105 -0
  58. package/src/polyfills/module.ts +191 -0
  59. package/src/polyfills/net.ts +353 -0
  60. package/src/polyfills/os.ts +238 -0
  61. package/src/polyfills/path.ts +206 -0
  62. package/src/polyfills/perf_hooks.ts +102 -0
  63. package/src/polyfills/process.ts +690 -0
  64. package/src/polyfills/punycode.ts +159 -0
  65. package/src/polyfills/querystring.ts +93 -0
  66. package/src/polyfills/quic.ts +118 -0
  67. package/src/polyfills/readdirp.ts +229 -0
  68. package/src/polyfills/readline.ts +692 -0
  69. package/src/polyfills/repl.ts +134 -0
  70. package/src/polyfills/rollup.ts +119 -0
  71. package/src/polyfills/sea.ts +33 -0
  72. package/src/polyfills/sqlite.ts +78 -0
  73. package/src/polyfills/stream.ts +1620 -0
  74. package/src/polyfills/string_decoder.ts +25 -0
  75. package/src/polyfills/tailwindcss-oxide.ts +309 -0
  76. package/src/polyfills/test.ts +197 -0
  77. package/src/polyfills/timers.ts +32 -0
  78. package/src/polyfills/tls.ts +105 -0
  79. package/src/polyfills/trace_events.ts +50 -0
  80. package/src/polyfills/tty.ts +71 -0
  81. package/src/polyfills/url.ts +174 -0
  82. package/src/polyfills/util.ts +559 -0
  83. package/src/polyfills/v8.ts +126 -0
  84. package/src/polyfills/vm.ts +132 -0
  85. package/src/polyfills/volume-registry.ts +15 -0
  86. package/src/polyfills/wasi.ts +44 -0
  87. package/src/polyfills/worker_threads.ts +326 -0
  88. package/src/polyfills/ws.ts +595 -0
  89. package/src/polyfills/zlib.ts +881 -0
  90. package/src/request-proxy.ts +716 -0
  91. package/src/script-engine.ts +3375 -0
  92. package/src/sdk/nodepod-fs.ts +93 -0
  93. package/src/sdk/nodepod-process.ts +86 -0
  94. package/src/sdk/nodepod-terminal.ts +350 -0
  95. package/src/sdk/nodepod.ts +509 -0
  96. package/src/sdk/types.ts +70 -0
  97. package/src/shell/commands/bun.ts +121 -0
  98. package/src/shell/commands/directory.ts +297 -0
  99. package/src/shell/commands/file-ops.ts +525 -0
  100. package/src/shell/commands/git.ts +2142 -0
  101. package/src/shell/commands/node.ts +80 -0
  102. package/src/shell/commands/npm.ts +198 -0
  103. package/src/shell/commands/pm-types.ts +45 -0
  104. package/src/shell/commands/pnpm.ts +82 -0
  105. package/src/shell/commands/search.ts +264 -0
  106. package/src/shell/commands/shell-env.ts +352 -0
  107. package/src/shell/commands/text-processing.ts +1152 -0
  108. package/src/shell/commands/yarn.ts +84 -0
  109. package/src/shell/shell-builtins.ts +19 -0
  110. package/src/shell/shell-helpers.ts +250 -0
  111. package/src/shell/shell-interpreter.ts +514 -0
  112. package/src/shell/shell-parser.ts +429 -0
  113. package/src/shell/shell-types.ts +85 -0
  114. package/src/syntax-transforms.ts +561 -0
  115. package/src/threading/engine-worker.ts +64 -0
  116. package/src/threading/inline-worker.ts +372 -0
  117. package/src/threading/offload-types.ts +112 -0
  118. package/src/threading/offload-worker.ts +383 -0
  119. package/src/threading/offload.ts +271 -0
  120. package/src/threading/process-context.ts +92 -0
  121. package/src/threading/process-handle.ts +275 -0
  122. package/src/threading/process-manager.ts +956 -0
  123. package/src/threading/process-worker-entry.ts +854 -0
  124. package/src/threading/shared-vfs.ts +352 -0
  125. package/src/threading/sync-channel.ts +135 -0
  126. package/src/threading/task-queue.ts +177 -0
  127. package/src/threading/vfs-bridge.ts +231 -0
  128. package/src/threading/worker-pool.ts +233 -0
  129. package/src/threading/worker-protocol.ts +358 -0
  130. package/src/threading/worker-vfs.ts +218 -0
  131. package/src/types/externals.d.ts +38 -0
  132. package/src/types/fs-streams.ts +142 -0
  133. package/src/types/manifest.ts +17 -0
  134. package/src/worker-sandbox.ts +90 -0
@@ -0,0 +1,87 @@
1
+ // stub - not available in browser
2
+
3
+ import { EventEmitter } from "./events";
4
+
5
+ export interface Socket extends EventEmitter {
6
+ bind(_port?: number, _addr?: string, _cb?: () => void): this;
7
+ close(_cb?: () => void): void;
8
+ send(
9
+ _msg: Uint8Array | string,
10
+ _offset?: number,
11
+ _length?: number,
12
+ _port?: number,
13
+ _addr?: string,
14
+ _cb?: (err: Error | null, bytes: number) => void,
15
+ ): void;
16
+ address(): { address: string; family: string; port: number };
17
+ setBroadcast(_flag: boolean): void;
18
+ setTTL(_ttl: number): number;
19
+ setMulticastTTL(_ttl: number): number;
20
+ setMulticastLoopback(_flag: boolean): boolean;
21
+ setMulticastInterface(_iface: string): void;
22
+ addMembership(_group: string, _iface?: string): void;
23
+ dropMembership(_group: string, _iface?: string): void;
24
+ ref(): this;
25
+ unref(): this;
26
+ setRecvBufferSize(_sz: number): void;
27
+ setSendBufferSize(_sz: number): void;
28
+ getRecvBufferSize(): number;
29
+ getSendBufferSize(): number;
30
+ }
31
+
32
+ export const Socket = function Socket(this: any) {
33
+ if (!this) return;
34
+ EventEmitter.call(this);
35
+ } as unknown as { new(): Socket; prototype: any };
36
+
37
+ Object.setPrototypeOf(Socket.prototype, EventEmitter.prototype);
38
+
39
+ Socket.prototype.bind = function bind(_port?: number, _addr?: string, _cb?: () => void) {
40
+ if (_cb) setTimeout(_cb, 0);
41
+ return this;
42
+ };
43
+
44
+ Socket.prototype.close = function close(_cb?: () => void): void {
45
+ if (_cb) setTimeout(_cb, 0);
46
+ };
47
+
48
+ Socket.prototype.send = function send(
49
+ _msg: Uint8Array | string,
50
+ _offset?: number,
51
+ _length?: number,
52
+ _port?: number,
53
+ _addr?: string,
54
+ _cb?: (err: Error | null, bytes: number) => void,
55
+ ): void {
56
+ if (_cb) setTimeout(() => _cb(null, 0), 0);
57
+ };
58
+
59
+ Socket.prototype.address = function address(): { address: string; family: string; port: number } {
60
+ return { address: "0.0.0.0", family: "IPv4", port: 0 };
61
+ };
62
+
63
+ Socket.prototype.setBroadcast = function setBroadcast(_flag: boolean): void {};
64
+ Socket.prototype.setTTL = function setTTL(_ttl: number): number { return _ttl; };
65
+ Socket.prototype.setMulticastTTL = function setMulticastTTL(_ttl: number): number { return _ttl; };
66
+ Socket.prototype.setMulticastLoopback = function setMulticastLoopback(_flag: boolean): boolean { return _flag; };
67
+ Socket.prototype.setMulticastInterface = function setMulticastInterface(_iface: string): void {};
68
+ Socket.prototype.addMembership = function addMembership(_group: string, _iface?: string): void {};
69
+ Socket.prototype.dropMembership = function dropMembership(_group: string, _iface?: string): void {};
70
+ Socket.prototype.ref = function ref() { return this; };
71
+ Socket.prototype.unref = function unref() { return this; };
72
+ Socket.prototype.setRecvBufferSize = function setRecvBufferSize(_sz: number): void {};
73
+ Socket.prototype.setSendBufferSize = function setSendBufferSize(_sz: number): void {};
74
+ Socket.prototype.getRecvBufferSize = function getRecvBufferSize(): number { return 0; };
75
+ Socket.prototype.getSendBufferSize = function getSendBufferSize(): number { return 0; };
76
+
77
+ export function createSocket(
78
+ _type: string | object,
79
+ _cb?: (msg: Uint8Array, rinfo: object) => void,
80
+ ): Socket {
81
+ return new Socket();
82
+ }
83
+
84
+ export default {
85
+ Socket,
86
+ createSocket,
87
+ };
@@ -0,0 +1,76 @@
1
+ // stub - minimal diagnostics_channel for compatibility
2
+
3
+
4
+ export interface DiagChannel {
5
+ name: string;
6
+ readonly hasSubscribers: boolean;
7
+ subscribe(handler: (message: unknown, name: string) => void): void;
8
+ unsubscribe(handler: (message: unknown, name: string) => void): boolean;
9
+ publish(message: unknown): void;
10
+ }
11
+
12
+ export const DiagChannel = function DiagChannel(this: any, name: string) {
13
+ if (!this) return;
14
+ this.name = name;
15
+ this._listeners = [];
16
+ } as unknown as { new(name: string): DiagChannel; prototype: any };
17
+
18
+ Object.defineProperty(DiagChannel.prototype, 'hasSubscribers', {
19
+ get(this: any) { return this._listeners.length > 0; },
20
+ configurable: true,
21
+ });
22
+
23
+ DiagChannel.prototype.subscribe = function subscribe(handler: (message: unknown, name: string) => void): void {
24
+ this._listeners.push(handler);
25
+ };
26
+
27
+ DiagChannel.prototype.unsubscribe = function unsubscribe(handler: (message: unknown, name: string) => void): boolean {
28
+ const idx = this._listeners.indexOf(handler);
29
+ if (idx === -1) return false;
30
+ this._listeners.splice(idx, 1);
31
+ return true;
32
+ };
33
+
34
+ DiagChannel.prototype.publish = function publish(this: any, message: unknown): void {
35
+ for (const handler of this._listeners) {
36
+ try {
37
+ handler(message, this.name);
38
+ } catch {
39
+ /* swallow */
40
+ }
41
+ }
42
+ };
43
+
44
+ const channels = new Map<string, DiagChannel>();
45
+
46
+ export function channel(name: string): DiagChannel {
47
+ if (!channels.has(name)) channels.set(name, new DiagChannel(name));
48
+ return channels.get(name)!;
49
+ }
50
+
51
+ export function hasSubscribers(name: string): boolean {
52
+ return channels.get(name)?.hasSubscribers ?? false;
53
+ }
54
+
55
+ export function subscribe(
56
+ name: string,
57
+ handler: (message: unknown, name: string) => void,
58
+ ): void {
59
+ channel(name).subscribe(handler);
60
+ }
61
+
62
+ export function unsubscribe(
63
+ name: string,
64
+ handler: (message: unknown, name: string) => void,
65
+ ): boolean {
66
+ return channels.get(name)?.unsubscribe(handler) ?? false;
67
+ }
68
+
69
+ export { DiagChannel as Channel };
70
+ export default {
71
+ channel,
72
+ hasSubscribers,
73
+ subscribe,
74
+ unsubscribe,
75
+ Channel: DiagChannel,
76
+ };
@@ -0,0 +1,134 @@
1
+ // stub - real DNS not available in browser, returns 127.0.0.1 for localhost, 0.0.0.0 otherwise
2
+
3
+ type SingleResult = (err: Error | null, addr?: string, fam?: number) => void;
4
+ type MultiResult = (
5
+ err: Error | null,
6
+ entries?: Array<{ address: string; family: number }>
7
+ ) => void;
8
+
9
+ export function lookup(
10
+ host: string,
11
+ cb: SingleResult
12
+ ): void;
13
+ export function lookup(
14
+ host: string,
15
+ opts: { family?: number; all?: true },
16
+ cb: MultiResult
17
+ ): void;
18
+ export function lookup(
19
+ host: string,
20
+ opts: { family?: number; all?: boolean },
21
+ cb: SingleResult | MultiResult
22
+ ): void;
23
+ export function lookup(
24
+ host: string,
25
+ optsOrCb: { family?: number; all?: boolean } | SingleResult,
26
+ cb?: SingleResult | MultiResult
27
+ ): void {
28
+ const handler = typeof optsOrCb === 'function' ? optsOrCb : cb;
29
+ const flags = typeof optsOrCb === 'object' ? optsOrCb : {};
30
+
31
+ const isLocal = host === 'localhost' || host === '127.0.0.1';
32
+ const ip = isLocal ? '127.0.0.1' : '0.0.0.0';
33
+
34
+ setTimeout(() => {
35
+ if (flags.all) {
36
+ (handler as MultiResult)(null, [{ address: ip, family: 4 }]);
37
+ } else {
38
+ (handler as SingleResult)(null, ip, 4);
39
+ }
40
+ }, 0);
41
+ }
42
+
43
+ export function resolve(
44
+ _host: string,
45
+ cb: (err: Error | null, addrs?: string[]) => void
46
+ ): void {
47
+ setTimeout(() => cb(null, ['0.0.0.0']), 0);
48
+ }
49
+
50
+ export function resolve4(
51
+ host: string,
52
+ cb: (err: Error | null, addrs?: string[]) => void
53
+ ): void {
54
+ resolve(host, cb);
55
+ }
56
+
57
+ export function resolve6(
58
+ _host: string,
59
+ cb: (err: Error | null, addrs?: string[]) => void
60
+ ): void {
61
+ setTimeout(() => cb(null, ['::1']), 0);
62
+ }
63
+
64
+ export function reverse(
65
+ _ip: string,
66
+ cb: (err: Error | null, names?: string[]) => void
67
+ ): void {
68
+ setTimeout(() => cb(null, ['localhost']), 0);
69
+ }
70
+
71
+ export function setServers(_list: string[]): void {}
72
+ export function getServers(): string[] { return []; }
73
+ export function setDefaultResultOrder(_order: string): void {}
74
+ export function getDefaultResultOrder(): string { return 'verbatim'; }
75
+
76
+ export const promises = {
77
+ lookup(
78
+ host: string,
79
+ opts?: { family?: number; all?: boolean }
80
+ ): Promise<{ address: string; family: number } | Array<{ address: string; family: number }>> {
81
+ return new Promise((ok, fail) => {
82
+ if (opts?.all) {
83
+ lookup(host, opts, ((e: Error | null, a?: Array<{ address: string; family: number }>) => {
84
+ if (e) fail(e); else ok(a ?? []);
85
+ }) as MultiResult);
86
+ } else {
87
+ lookup(host, opts ?? {}, (e, addr, fam) => {
88
+ if (e) fail(e); else ok({ address: addr!, family: fam! });
89
+ });
90
+ }
91
+ });
92
+ },
93
+
94
+ resolve(host: string): Promise<string[]> {
95
+ return new Promise((ok, fail) => {
96
+ resolve(host, (e, a) => (e ? fail(e) : ok(a ?? [])));
97
+ });
98
+ },
99
+
100
+ resolve4(host: string): Promise<string[]> {
101
+ return promises.resolve(host);
102
+ },
103
+
104
+ resolve6(_host: string): Promise<string[]> {
105
+ return Promise.resolve(['::1']);
106
+ },
107
+
108
+ reverse(_ip: string): Promise<string[]> {
109
+ return Promise.resolve(['localhost']);
110
+ },
111
+
112
+ setServers(_s: string[]): void {},
113
+ getServers(): string[] { return []; },
114
+ };
115
+
116
+ export const ADDRCONFIG = 0;
117
+ export const V4MAPPED = 0;
118
+ export const ALL = 0;
119
+
120
+ export default {
121
+ lookup,
122
+ resolve,
123
+ resolve4,
124
+ resolve6,
125
+ reverse,
126
+ setServers,
127
+ getServers,
128
+ setDefaultResultOrder,
129
+ getDefaultResultOrder,
130
+ promises,
131
+ ADDRCONFIG,
132
+ V4MAPPED,
133
+ ALL,
134
+ };
@@ -0,0 +1,68 @@
1
+ // stub - deprecated in Node.js, minimal pass-through implementation
2
+
3
+
4
+ import { EventEmitter } from "./events";
5
+
6
+ /* ------------------------------------------------------------------ */
7
+ /* Domain */
8
+ /* ------------------------------------------------------------------ */
9
+
10
+ export interface Domain extends EventEmitter {
11
+ members: unknown[];
12
+ add(emitter: EventEmitter): void;
13
+ remove(emitter: EventEmitter): void;
14
+ bind<F extends (...args: unknown[]) => unknown>(fn: F): F;
15
+ intercept<F extends (...args: unknown[]) => unknown>(fn: F): F;
16
+ run<T>(fn: () => T): T;
17
+ dispose(): void;
18
+ enter(): void;
19
+ exit(): void;
20
+ }
21
+
22
+ export const Domain = function Domain(this: any) {
23
+ if (!this) return;
24
+ EventEmitter.call(this);
25
+ this.members = [];
26
+ } as unknown as { new(): Domain; prototype: any };
27
+
28
+ Object.setPrototypeOf(Domain.prototype, EventEmitter.prototype);
29
+
30
+ Domain.prototype.add = function add(emitter: EventEmitter): void {
31
+ this.members.push(emitter);
32
+ };
33
+ Domain.prototype.remove = function remove(emitter: EventEmitter): void {
34
+ const idx = this.members.indexOf(emitter);
35
+ if (idx >= 0) this.members.splice(idx, 1);
36
+ };
37
+ Domain.prototype.bind = function bind<F extends (...args: unknown[]) => unknown>(fn: F): F {
38
+ return fn;
39
+ };
40
+ Domain.prototype.intercept = function intercept<F extends (...args: unknown[]) => unknown>(fn: F): F {
41
+ return fn;
42
+ };
43
+ Domain.prototype.run = function run<T>(fn: () => T): T {
44
+ return fn();
45
+ };
46
+ Domain.prototype.dispose = function dispose(): void {
47
+ this.members.length = 0;
48
+ };
49
+ Domain.prototype.enter = function enter(): void {};
50
+ Domain.prototype.exit = function exit(): void {};
51
+
52
+ /* ------------------------------------------------------------------ */
53
+ /* Factory */
54
+ /* ------------------------------------------------------------------ */
55
+
56
+ export function create(): Domain {
57
+ return new Domain();
58
+ }
59
+
60
+ /* ------------------------------------------------------------------ */
61
+ /* Default export */
62
+ /* ------------------------------------------------------------------ */
63
+
64
+ export default {
65
+ Domain,
66
+ create,
67
+ active,
68
+ };