@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,206 @@
1
+ // POSIX path operations polyfill
2
+
3
+
4
+ // Path separator and delimiter constants
5
+ export const sep = '/';
6
+ export const delimiter = ':';
7
+
8
+ export function normalize(inputPath: string): string {
9
+ if (!inputPath) return '.';
10
+
11
+ const rooted = inputPath.charAt(0) === '/';
12
+ const tokens = inputPath.split('/').filter(t => t.length > 0);
13
+ const stack: string[] = [];
14
+
15
+ for (const token of tokens) {
16
+ if (token === '..') {
17
+ if (stack.length > 0 && stack[stack.length - 1] !== '..') {
18
+ stack.pop();
19
+ } else if (!rooted) {
20
+ stack.push('..');
21
+ }
22
+ } else if (token !== '.') {
23
+ stack.push(token);
24
+ }
25
+ }
26
+
27
+ let output = stack.join('/');
28
+ if (rooted) {
29
+ output = '/' + output;
30
+ }
31
+ return output || '.';
32
+ }
33
+
34
+ export function join(...fragments: string[]): string {
35
+ if (fragments.length === 0) return '.';
36
+ const combined = fragments.filter(f => f !== '').join('/');
37
+ return normalize(combined);
38
+ }
39
+
40
+ // resolves right-to-left until an absolute path is formed
41
+ export function resolve(...segments: string[]): string {
42
+ let accumulated = '';
43
+
44
+ for (let idx = segments.length - 1; idx >= 0; idx--) {
45
+ const segment = segments[idx];
46
+ if (!segment) continue;
47
+ accumulated = segment + (accumulated ? '/' + accumulated : '');
48
+ if (accumulated.charAt(0) === '/') break;
49
+ }
50
+
51
+ if (accumulated.charAt(0) !== '/') {
52
+ const workingDir =
53
+ typeof globalThis !== 'undefined' &&
54
+ globalThis.process &&
55
+ typeof globalThis.process.cwd === 'function'
56
+ ? globalThis.process.cwd()
57
+ : '/';
58
+ accumulated = workingDir + (accumulated ? '/' + accumulated : '');
59
+ }
60
+
61
+ return normalize(accumulated);
62
+ }
63
+
64
+ export function isAbsolute(targetPath: string): boolean {
65
+ return targetPath.charAt(0) === '/';
66
+ }
67
+
68
+ export function dirname(targetPath: string): string {
69
+ if (!targetPath) return '.';
70
+ const clean = normalize(targetPath);
71
+ const slashPos = clean.lastIndexOf('/');
72
+ if (slashPos < 0) return '.';
73
+ if (slashPos === 0) return '/';
74
+ return clean.substring(0, slashPos);
75
+ }
76
+
77
+ export function basename(targetPath: string, suffix?: string): string {
78
+ if (!targetPath) return '';
79
+ const clean = normalize(targetPath);
80
+ let name = clean.substring(clean.lastIndexOf('/') + 1);
81
+ if (suffix && name.endsWith(suffix)) {
82
+ name = name.substring(0, name.length - suffix.length);
83
+ }
84
+ return name;
85
+ }
86
+
87
+ export function extname(targetPath: string): string {
88
+ const name = basename(targetPath);
89
+ const dotPos = name.lastIndexOf('.');
90
+ if (dotPos <= 0) return '';
91
+ return name.substring(dotPos);
92
+ }
93
+
94
+ export function relative(fromPath: string, toPath: string): string {
95
+ const absFrom = resolve(fromPath);
96
+ const absTo = resolve(toPath);
97
+
98
+ if (absFrom === absTo) return '';
99
+
100
+ const partsFrom = absFrom.split('/').filter(Boolean);
101
+ const partsTo = absTo.split('/').filter(Boolean);
102
+
103
+ let shared = 0;
104
+ const limit = Math.min(partsFrom.length, partsTo.length);
105
+ while (shared < limit && partsFrom[shared] === partsTo[shared]) {
106
+ shared++;
107
+ }
108
+
109
+ const ascend = partsFrom.length - shared;
110
+ const descend = partsTo.slice(shared);
111
+
112
+ const pieces: string[] = [];
113
+ for (let i = 0; i < ascend; i++) {
114
+ pieces.push('..');
115
+ }
116
+ pieces.push(...descend);
117
+
118
+ return pieces.join('/') || '.';
119
+ }
120
+
121
+ export function parse(targetPath: string): {
122
+ root: string;
123
+ dir: string;
124
+ base: string;
125
+ ext: string;
126
+ name: string;
127
+ } {
128
+ const clean = normalize(targetPath);
129
+ const rooted = isAbsolute(clean);
130
+ const directory = dirname(clean);
131
+ const base = basename(clean);
132
+ const extension = extname(clean);
133
+ const stem = base.substring(0, base.length - extension.length);
134
+
135
+ return {
136
+ root: rooted ? '/' : '',
137
+ dir: directory,
138
+ base,
139
+ ext: extension,
140
+ name: stem,
141
+ };
142
+ }
143
+
144
+ export function format(components: {
145
+ root?: string;
146
+ dir?: string;
147
+ base?: string;
148
+ ext?: string;
149
+ name?: string;
150
+ }): string {
151
+ const directory = components.dir || components.root || '';
152
+ const filename = components.base || (components.name || '') + (components.ext || '');
153
+
154
+ if (!directory) return filename;
155
+ if (directory === components.root) return directory + filename;
156
+ return directory + '/' + filename;
157
+ }
158
+
159
+ // The posix namespace mirrors all path functions (this IS a POSIX implementation)
160
+ export const posix = {
161
+ sep,
162
+ delimiter,
163
+ normalize,
164
+ join,
165
+ resolve,
166
+ isAbsolute,
167
+ dirname,
168
+ basename,
169
+ extname,
170
+ relative,
171
+ parse,
172
+ format,
173
+ };
174
+
175
+ // Win32 namespace provided as a stub; all operations delegate to POSIX logic
176
+ export const win32 = {
177
+ sep: '\\',
178
+ delimiter: ';',
179
+ normalize,
180
+ join,
181
+ resolve,
182
+ isAbsolute,
183
+ dirname,
184
+ basename,
185
+ extname,
186
+ relative,
187
+ parse,
188
+ format,
189
+ };
190
+
191
+ export default {
192
+ sep,
193
+ delimiter,
194
+ normalize,
195
+ join,
196
+ resolve,
197
+ isAbsolute,
198
+ dirname,
199
+ basename,
200
+ extname,
201
+ relative,
202
+ parse,
203
+ format,
204
+ posix,
205
+ win32,
206
+ };
@@ -0,0 +1,102 @@
1
+ // perf_hooks polyfill wrapping browser Performance API
2
+
3
+
4
+
5
+ export const performance: Performance = globalThis.performance ?? ({
6
+ now: () => Date.now(),
7
+ timeOrigin: Date.now(),
8
+ mark: () => {},
9
+ measure: () => {},
10
+ getEntries: () => [],
11
+ getEntriesByName: () => [],
12
+ getEntriesByType: () => [],
13
+ clearMarks: () => {},
14
+ clearMeasures: () => {},
15
+ clearResourceTimings: () => {},
16
+ } as unknown as Performance);
17
+
18
+
19
+ export interface TimingEntryList {
20
+ getEntries(): PerformanceEntry[];
21
+ getEntriesByName(name: string, kind?: string): PerformanceEntry[];
22
+ getEntriesByType(kind: string): PerformanceEntry[];
23
+ }
24
+
25
+ export interface PerformanceObserver {
26
+ observe(cfg: { entryTypes?: string[]; type?: string }): void;
27
+ disconnect(): void;
28
+ takeRecords(): PerformanceEntry[];
29
+ }
30
+
31
+ export const PerformanceObserver = function PerformanceObserver(this: any, fn: (list: TimingEntryList) => void) {
32
+ if (!this) return;
33
+ this._fn = fn;
34
+ this._types = [];
35
+ } as unknown as { new(fn: (list: TimingEntryList) => void): PerformanceObserver; prototype: any; supportedEntryTypes: string[] };
36
+
37
+ PerformanceObserver.supportedEntryTypes = ['mark', 'measure', 'resource', 'navigation'];
38
+
39
+ PerformanceObserver.prototype.observe = function observe(cfg: { entryTypes?: string[]; type?: string }): void {
40
+ this._types = cfg.entryTypes ?? (cfg.type ? [cfg.type] : []);
41
+ };
42
+
43
+ PerformanceObserver.prototype.disconnect = function disconnect(): void {
44
+ this._types = [];
45
+ };
46
+
47
+ PerformanceObserver.prototype.takeRecords = function takeRecords(): PerformanceEntry[] {
48
+ return [];
49
+ };
50
+
51
+
52
+ export interface TimingHistogram {
53
+ min: number;
54
+ max: number;
55
+ mean: number;
56
+ stddev: number;
57
+ percentiles: Map<number, number>;
58
+ exceeds: number;
59
+ reset(): void;
60
+ percentile(p: number): number;
61
+ }
62
+
63
+ export const TimingHistogram = function TimingHistogram(this: any) {
64
+ if (!this) return;
65
+ this.min = 0;
66
+ this.max = 0;
67
+ this.mean = 0;
68
+ this.stddev = 0;
69
+ this.percentiles = new Map<number, number>();
70
+ this.exceeds = 0;
71
+ } as unknown as { new(): TimingHistogram; prototype: any };
72
+
73
+ TimingHistogram.prototype.reset = function reset(): void {
74
+ this.min = 0;
75
+ this.max = 0;
76
+ this.mean = 0;
77
+ this.stddev = 0;
78
+ this.percentiles.clear();
79
+ this.exceeds = 0;
80
+ };
81
+
82
+ TimingHistogram.prototype.percentile = function percentile(p: number): number {
83
+ return this.percentiles.get(p) ?? 0;
84
+ };
85
+
86
+ export function createHistogram(): TimingHistogram {
87
+ return new TimingHistogram();
88
+ }
89
+
90
+ export function monitorEventLoopDelay(
91
+ _opts?: { resolution?: number }
92
+ ): TimingHistogram {
93
+ return new TimingHistogram();
94
+ }
95
+
96
+
97
+ export default {
98
+ performance,
99
+ PerformanceObserver,
100
+ createHistogram,
101
+ monitorEventLoopDelay,
102
+ };