@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,50 @@
1
+ // stub - not available in browser
2
+
3
+
4
+ /* ------------------------------------------------------------------ */
5
+ /* Tracing class */
6
+ /* ------------------------------------------------------------------ */
7
+
8
+ export interface Tracing {
9
+ readonly categories: string;
10
+ readonly enabled: boolean;
11
+ enable(): void;
12
+ disable(): void;
13
+ }
14
+
15
+ interface TracingConstructor {
16
+ new (categories: string[]): Tracing;
17
+ (this: any, categories: string[]): void;
18
+ prototype: any;
19
+ }
20
+
21
+ export const Tracing = function Tracing(this: any, categories: string[]) {
22
+ if (!this) return;
23
+ this.categories = categories.join(",");
24
+ this.enabled = false;
25
+ } as unknown as TracingConstructor;
26
+
27
+ Tracing.prototype.enable = function enable(): void { };
28
+ Tracing.prototype.disable = function disable(): void { };
29
+
30
+ /* ------------------------------------------------------------------ */
31
+ /* Factory */
32
+ /* ------------------------------------------------------------------ */
33
+
34
+ export function createTracing(opts: { categories: string[] }): Tracing {
35
+ return new Tracing(opts.categories);
36
+ }
37
+
38
+ export function getEnabledCategories(): string | undefined {
39
+ return undefined;
40
+ }
41
+
42
+ /* ------------------------------------------------------------------ */
43
+ /* Default export */
44
+ /* ------------------------------------------------------------------ */
45
+
46
+ export default {
47
+ createTracing,
48
+ getEnabledCategories,
49
+ Tracing,
50
+ };
@@ -0,0 +1,71 @@
1
+ // TTY polyfill - always reports non-TTY in browser
2
+
3
+
4
+ // always false in browser
5
+ export function isatty(_fd: number): boolean {
6
+ return false;
7
+ }
8
+
9
+ export interface ReadStream {
10
+ isTTY: boolean;
11
+ isRaw: boolean;
12
+ setRawMode(_mode: boolean): this;
13
+ }
14
+
15
+ export const ReadStream = function ReadStream(this: any) {
16
+ if (!this) return;
17
+ this.isTTY = false;
18
+ this.isRaw = false;
19
+ } as unknown as { new(): ReadStream; prototype: any };
20
+
21
+ ReadStream.prototype.setRawMode = function setRawMode(_mode: boolean) {
22
+ this.isRaw = _mode;
23
+ return this;
24
+ };
25
+
26
+ export interface WriteStream {
27
+ isTTY: boolean;
28
+ columns: number;
29
+ rows: number;
30
+ getColorDepth(): number;
31
+ hasColors(count?: number): boolean;
32
+ getWindowSize(): [number, number];
33
+ clearLine(_dir: number, _cb?: () => void): boolean;
34
+ clearScreenDown(_cb?: () => void): boolean;
35
+ cursorTo(_x: number, _y?: number | (() => void), _cb?: () => void): boolean;
36
+ moveCursor(_dx: number, _dy: number, _cb?: () => void): boolean;
37
+ }
38
+
39
+ export const WriteStream = function WriteStream(this: any) {
40
+ if (!this) return;
41
+ this.isTTY = false;
42
+ this.columns = 120;
43
+ this.rows = 40;
44
+ } as unknown as { new(): WriteStream; prototype: any };
45
+
46
+ WriteStream.prototype.getColorDepth = function getColorDepth(): number { return 8; };
47
+ WriteStream.prototype.hasColors = function hasColors(count?: number): boolean {
48
+ return (count ?? 1) <= 256;
49
+ };
50
+ WriteStream.prototype.getWindowSize = function getWindowSize(): [number, number] {
51
+ return [this.columns, this.rows];
52
+ };
53
+ WriteStream.prototype.clearLine = function clearLine(_dir: number, _cb?: () => void): boolean {
54
+ _cb?.();
55
+ return true;
56
+ };
57
+ WriteStream.prototype.clearScreenDown = function clearScreenDown(_cb?: () => void): boolean {
58
+ _cb?.();
59
+ return true;
60
+ };
61
+ WriteStream.prototype.cursorTo = function cursorTo(_x: number, _y?: number | (() => void), _cb?: () => void): boolean {
62
+ if (typeof _y === "function") _y();
63
+ else _cb?.();
64
+ return true;
65
+ };
66
+ WriteStream.prototype.moveCursor = function moveCursor(_dx: number, _dy: number, _cb?: () => void): boolean {
67
+ _cb?.();
68
+ return true;
69
+ };
70
+
71
+ export default { isatty, ReadStream, WriteStream };
@@ -0,0 +1,174 @@
1
+ // URL module with legacy parse/format/resolve and fileURLToPath/pathToFileURL
2
+
3
+ export interface Url {
4
+ protocol?: string | null;
5
+ slashes?: boolean | null;
6
+ auth?: string | null;
7
+ host?: string | null;
8
+ port?: string | null;
9
+ hostname?: string | null;
10
+ hash?: string | null;
11
+ search?: string | null;
12
+ query?: string | Record<string, string | string[]> | null;
13
+ pathname?: string | null;
14
+ path?: string | null;
15
+ href?: string;
16
+ }
17
+
18
+ export function parse(
19
+ raw: string,
20
+ parseQuery: boolean = false,
21
+ _slashesHost: boolean = false,
22
+ ): Url {
23
+ try {
24
+ const u = new globalThis.URL(raw, "http://localhost");
25
+ const authPart = u.username ? `${u.username}:${u.password}` : null;
26
+ const queryVal = parseQuery
27
+ ? Object.fromEntries(u.searchParams)
28
+ : u.search
29
+ ? u.search.substring(1)
30
+ : null;
31
+
32
+ return {
33
+ protocol: u.protocol,
34
+ slashes: u.protocol.endsWith(":"),
35
+ auth: authPart,
36
+ host: u.host,
37
+ port: u.port || null,
38
+ hostname: u.hostname,
39
+ hash: u.hash || null,
40
+ search: u.search || null,
41
+ query: queryVal,
42
+ pathname: u.pathname,
43
+ path: u.pathname + u.search,
44
+ href: u.href,
45
+ };
46
+ } catch {
47
+ return {
48
+ protocol: null,
49
+ slashes: null,
50
+ auth: null,
51
+ host: null,
52
+ port: null,
53
+ hostname: null,
54
+ hash: null,
55
+ search: null,
56
+ query: null,
57
+ pathname: raw,
58
+ path: raw,
59
+ href: raw,
60
+ };
61
+ }
62
+ }
63
+
64
+ export function format(obj: Url): string {
65
+ if (obj.href) return obj.href;
66
+
67
+ let result = "";
68
+
69
+ if (obj.protocol) {
70
+ result += obj.protocol.endsWith(":") ? obj.protocol : obj.protocol + ":";
71
+ }
72
+
73
+ if (obj.slashes || obj.protocol === "http:" || obj.protocol === "https:") {
74
+ result += "//";
75
+ }
76
+
77
+ if (obj.auth) result += obj.auth + "@";
78
+
79
+ if (obj.hostname) {
80
+ result += obj.hostname;
81
+ } else if (obj.host) {
82
+ result += obj.host;
83
+ }
84
+
85
+ if (obj.port) result += ":" + obj.port;
86
+ if (obj.pathname) result += obj.pathname;
87
+
88
+ if (obj.search) {
89
+ result += obj.search;
90
+ } else if (obj.query) {
91
+ if (typeof obj.query === "string") {
92
+ result += "?" + obj.query;
93
+ } else {
94
+ const params = new globalThis.URLSearchParams();
95
+ for (const [key, val] of Object.entries(obj.query)) {
96
+ if (Array.isArray(val)) {
97
+ for (const item of val) params.append(key, item);
98
+ } else {
99
+ params.set(key, val);
100
+ }
101
+ }
102
+ const qs = params.toString();
103
+ if (qs) result += "?" + qs;
104
+ }
105
+ }
106
+
107
+ if (obj.hash) result += obj.hash;
108
+
109
+ return result;
110
+ }
111
+
112
+ export function resolve(base: string, target: string): string {
113
+ try {
114
+ return new globalThis.URL(target, base).href;
115
+ } catch {
116
+ return target;
117
+ }
118
+ }
119
+
120
+ // Re-export the native browser URL and URLSearchParams
121
+ export const URL = globalThis.URL;
122
+ export const URLSearchParams = globalThis.URLSearchParams;
123
+
124
+ export function fileURLToPath(input: string | URL): string {
125
+ if (typeof input === "string") {
126
+ // Bare filesystem path — return as-is
127
+ if (input.startsWith("/")) return input;
128
+ try {
129
+ const urlObj = new globalThis.URL(input);
130
+ if (urlObj.protocol === "file:") {
131
+ return decodeURIComponent(urlObj.pathname);
132
+ }
133
+ // Non-file URL (http:, blob:, etc.) — return the pathname portion
134
+ return decodeURIComponent(urlObj.pathname);
135
+ } catch {
136
+ // Not a valid URL at all — return as-is
137
+ return input;
138
+ }
139
+ }
140
+ // URL object
141
+ if (input.protocol === "file:") {
142
+ return decodeURIComponent(input.pathname);
143
+ }
144
+ return decodeURIComponent(input.pathname);
145
+ }
146
+
147
+ export function pathToFileURL(fsPath: string): URL {
148
+ const encoded = encodeURIComponent(fsPath).replace(/%2F/g, "/");
149
+ return new globalThis.URL("file://" + encoded);
150
+ }
151
+
152
+ export function domainToASCII(domain: string): string {
153
+ try {
154
+ return new globalThis.URL(`http://${domain}`).hostname;
155
+ } catch {
156
+ return domain;
157
+ }
158
+ }
159
+
160
+ export function domainToUnicode(domain: string): string {
161
+ return domain;
162
+ }
163
+
164
+ export default {
165
+ parse,
166
+ format,
167
+ resolve,
168
+ URL,
169
+ URLSearchParams,
170
+ fileURLToPath,
171
+ pathToFileURL,
172
+ domainToASCII,
173
+ domainToUnicode,
174
+ };