@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,134 @@
1
+ // lightweight REPL stub for compatibility
2
+
3
+
4
+ import { EventEmitter } from "./events";
5
+
6
+ /* ------------------------------------------------------------------ */
7
+ /* Constants */
8
+ /* ------------------------------------------------------------------ */
9
+
10
+ export const REPL_MODE_SLOPPY = Symbol.for("repl-sloppy");
11
+ export const REPL_MODE_STRICT = Symbol.for("repl-strict");
12
+
13
+ /* ------------------------------------------------------------------ */
14
+ /* Recoverable */
15
+ /* ------------------------------------------------------------------ */
16
+
17
+ export interface Recoverable extends SyntaxError {
18
+ err: Error;
19
+ }
20
+
21
+ interface RecoverableConstructor {
22
+ new (err: Error): Recoverable;
23
+ (this: any, err: Error): void;
24
+ prototype: any;
25
+ }
26
+
27
+ export const Recoverable = function Recoverable(this: any, err: Error) {
28
+ if (!this) return;
29
+ SyntaxError.call(this, err.message);
30
+ this.message = err.message;
31
+ this.name = "SyntaxError";
32
+ this.err = err;
33
+ if (Error.captureStackTrace) Error.captureStackTrace(this, Recoverable);
34
+ } as unknown as RecoverableConstructor;
35
+
36
+ Object.setPrototypeOf(Recoverable.prototype, SyntaxError.prototype);
37
+
38
+ /* ------------------------------------------------------------------ */
39
+ /* REPLServer */
40
+ /* ------------------------------------------------------------------ */
41
+
42
+ export interface REPLServer extends EventEmitter {
43
+ context: Record<string, unknown>;
44
+ terminal: boolean;
45
+ _prompt: string;
46
+ _commands: Map<string, { help: string; action: Function }>;
47
+ setPrompt(prompt: string): void;
48
+ getPrompt(): string;
49
+ displayPrompt(_preserveCursor?: boolean): void;
50
+ defineCommand(keyword: string, cmd: { help?: string; action: Function } | Function): void;
51
+ close(): void;
52
+ setupHistory(_historyPath: string, cb: (err: Error | null, repl: REPLServer) => void): void;
53
+ }
54
+
55
+ interface REPLServerConstructor {
56
+ new (options?: string | Record<string, unknown>): REPLServer;
57
+ (this: any, options?: string | Record<string, unknown>): void;
58
+ prototype: any;
59
+ }
60
+
61
+ export const REPLServer = function REPLServer(this: any, options?: string | Record<string, unknown>) {
62
+ if (!this) return;
63
+ EventEmitter.call(this);
64
+ this.context = Object.create(null);
65
+ this.terminal = false;
66
+ this._prompt = "> ";
67
+ this._commands = new Map<string, { help: string; action: Function }>();
68
+ if (typeof options === "string") {
69
+ this._prompt = options;
70
+ } else if (options) {
71
+ if (typeof options.prompt === "string") this._prompt = options.prompt;
72
+ if (options.terminal !== undefined) this.terminal = !!options.terminal;
73
+ }
74
+ } as unknown as REPLServerConstructor;
75
+
76
+ Object.setPrototypeOf(REPLServer.prototype, EventEmitter.prototype);
77
+
78
+ REPLServer.prototype.setPrompt = function setPrompt(this: any, prompt: string): void {
79
+ this._prompt = prompt;
80
+ };
81
+
82
+ REPLServer.prototype.getPrompt = function getPrompt(this: any): string {
83
+ return this._prompt;
84
+ };
85
+
86
+ REPLServer.prototype.displayPrompt = function displayPrompt(_preserveCursor?: boolean): void {
87
+ };
88
+
89
+ REPLServer.prototype.defineCommand = function defineCommand(
90
+ this: any,
91
+ keyword: string,
92
+ cmd: { help?: string; action: Function } | Function,
93
+ ): void {
94
+ if (typeof cmd === "function") {
95
+ this._commands.set(keyword, { help: "", action: cmd });
96
+ } else {
97
+ this._commands.set(keyword, { help: cmd.help || "", action: cmd.action });
98
+ }
99
+ };
100
+
101
+ REPLServer.prototype.close = function close(this: any): void {
102
+ this.emit("exit");
103
+ this.emit("close");
104
+ };
105
+
106
+ REPLServer.prototype.setupHistory = function setupHistory(
107
+ this: any,
108
+ _historyPath: string,
109
+ cb: (err: Error | null, repl: REPLServer) => void,
110
+ ): void {
111
+ cb(null, this);
112
+ };
113
+
114
+ /* ------------------------------------------------------------------ */
115
+ /* Factory */
116
+ /* ------------------------------------------------------------------ */
117
+
118
+ export function start(
119
+ options?: string | Record<string, unknown>,
120
+ ): REPLServer {
121
+ return new REPLServer(options);
122
+ }
123
+
124
+ /* ------------------------------------------------------------------ */
125
+ /* Default export */
126
+ /* ------------------------------------------------------------------ */
127
+
128
+ export default {
129
+ start,
130
+ REPLServer,
131
+ Recoverable,
132
+ REPL_MODE_SLOPPY,
133
+ REPL_MODE_STRICT,
134
+ };
@@ -0,0 +1,119 @@
1
+ // Rollup polyfill that lazy-loads @rollup/browser from CDN
2
+
3
+ import * as acorn from "acorn";
4
+ import acornJsx from "acorn-jsx";
5
+ import {
6
+ CDN_ROLLUP_BROWSER,
7
+ PINNED_ROLLUP_BROWSER,
8
+ cdnImport,
9
+ } from "../constants/cdn-urls";
10
+
11
+ // acorn parser extended with JSX support
12
+ const acornJsxParser = (acorn.Parser as any).extend(acornJsx());
13
+
14
+ let cachedRollup: unknown = null;
15
+ let loadingPromise: Promise<unknown> | null = null;
16
+
17
+ async function ensureRollup(): Promise<unknown> {
18
+ if (cachedRollup) return cachedRollup;
19
+ if (loadingPromise) return loadingPromise;
20
+
21
+ loadingPromise = (async () => {
22
+ try {
23
+ const mod = await cdnImport(CDN_ROLLUP_BROWSER);
24
+ cachedRollup = mod;
25
+ return mod;
26
+ } catch (err) {
27
+ loadingPromise = null;
28
+ throw new Error(
29
+ `rollup: failed to load @rollup/browser from CDN -- ${err}`,
30
+ );
31
+ }
32
+ })();
33
+
34
+ return loadingPromise;
35
+ }
36
+
37
+ export const VERSION: string = PINNED_ROLLUP_BROWSER;
38
+
39
+ // .write() is a no-op in browser
40
+ export async function rollup(inputOptions: unknown): Promise<unknown> {
41
+ const r = (await ensureRollup()) as {
42
+ rollup: (o: unknown) => Promise<unknown>;
43
+ };
44
+ return r.rollup(inputOptions);
45
+ }
46
+
47
+ export async function watch(watchOptions: unknown): Promise<unknown> {
48
+ const r = (await ensureRollup()) as { watch: (o: unknown) => unknown };
49
+ return r.watch(watchOptions);
50
+ }
51
+
52
+ export function defineConfig<T>(config: T): T {
53
+ return config;
54
+ }
55
+
56
+ // falls back to acorn-jsx if plain acorn fails (e.g. JSX in source)
57
+ export function parseAst(
58
+ source: string,
59
+ opts?: { allowReturnOutsideFunction?: boolean; jsx?: boolean },
60
+ ): unknown {
61
+ const parseOpts = {
62
+ ecmaVersion: "latest" as const,
63
+ sourceType: "module" as const,
64
+ allowReturnOutsideFunction: opts?.allowReturnOutsideFunction ?? false,
65
+ locations: true,
66
+ };
67
+
68
+ if (opts?.jsx) {
69
+ return acornJsxParser.parse(source, parseOpts);
70
+ }
71
+
72
+ try {
73
+ return acorn.parse(source, parseOpts);
74
+ } catch {
75
+ return acornJsxParser.parse(source, parseOpts);
76
+ }
77
+ }
78
+
79
+ export async function parseAstAsync(
80
+ source: string,
81
+ opts?: {
82
+ allowReturnOutsideFunction?: boolean;
83
+ jsx?: boolean;
84
+ signal?: AbortSignal;
85
+ },
86
+ ): Promise<unknown> {
87
+ return parseAst(source, {
88
+ allowReturnOutsideFunction: opts?.allowReturnOutsideFunction,
89
+ jsx: opts?.jsx,
90
+ });
91
+ }
92
+
93
+ // prevents "unsupported platform" error when Rollup probes for native bindings
94
+ export function getPackageBase(): string {
95
+ return "";
96
+ }
97
+
98
+ export { ensureRollup as loadRollup };
99
+
100
+ export interface Plugin {
101
+ name: string;
102
+ [key: string]: unknown;
103
+ }
104
+
105
+ export interface PluginContext {
106
+ meta: { rollupVersion: string };
107
+ parse: (code: string) => unknown;
108
+ [key: string]: unknown;
109
+ }
110
+
111
+ export default {
112
+ VERSION,
113
+ rollup,
114
+ watch,
115
+ defineConfig,
116
+ parseAst,
117
+ parseAstAsync,
118
+ loadRollup: ensureRollup,
119
+ };
@@ -0,0 +1,33 @@
1
+ // stub - not available in browser
2
+
3
+
4
+ /* ------------------------------------------------------------------ */
5
+ /* API */
6
+ /* ------------------------------------------------------------------ */
7
+
8
+ export function isSea(): boolean {
9
+ return false;
10
+ }
11
+
12
+ export function getAsset(_key: string): never {
13
+ throw new Error("Single Executable Applications (SEA) are not supported in the browser");
14
+ }
15
+
16
+ export function getAssetAsBlob(_key: string): never {
17
+ throw new Error("Single Executable Applications (SEA) are not supported in the browser");
18
+ }
19
+
20
+ export function getRawAsset(_key: string): never {
21
+ throw new Error("Single Executable Applications (SEA) are not supported in the browser");
22
+ }
23
+
24
+ /* ------------------------------------------------------------------ */
25
+ /* Default export */
26
+ /* ------------------------------------------------------------------ */
27
+
28
+ export default {
29
+ isSea,
30
+ getAsset,
31
+ getAssetAsBlob,
32
+ getRawAsset,
33
+ };
@@ -0,0 +1,78 @@
1
+ // stub - not available in browser (would need sql.js WASM)
2
+
3
+
4
+ /* ------------------------------------------------------------------ */
5
+ /* StatementSync */
6
+ /* ------------------------------------------------------------------ */
7
+
8
+ export interface StatementSync {
9
+ run(..._params: unknown[]): object;
10
+ get(..._params: unknown[]): unknown;
11
+ all(..._params: unknown[]): unknown[];
12
+ expandedSQL(): string;
13
+ sourceSQL(): string;
14
+ }
15
+
16
+ interface StatementSyncConstructor {
17
+ new (): StatementSync;
18
+ (this: any): void;
19
+ prototype: any;
20
+ }
21
+
22
+ export const StatementSync = function StatementSync(this: any) {
23
+ if (!this) return;
24
+ } as unknown as StatementSyncConstructor;
25
+
26
+ StatementSync.prototype.run = function run(..._params: unknown[]): object {
27
+ throw new Error("node:sqlite is not supported in the browser environment");
28
+ };
29
+ StatementSync.prototype.get = function get(..._params: unknown[]): unknown {
30
+ throw new Error("node:sqlite is not supported in the browser environment");
31
+ };
32
+ StatementSync.prototype.all = function all(..._params: unknown[]): unknown[] {
33
+ throw new Error("node:sqlite is not supported in the browser environment");
34
+ };
35
+ StatementSync.prototype.expandedSQL = function expandedSQL(): string {
36
+ return "";
37
+ };
38
+ StatementSync.prototype.sourceSQL = function sourceSQL(): string {
39
+ return "";
40
+ };
41
+
42
+ /* ------------------------------------------------------------------ */
43
+ /* DatabaseSync */
44
+ /* ------------------------------------------------------------------ */
45
+
46
+ export interface DatabaseSync {
47
+ close(): void;
48
+ exec(_sql: string): void;
49
+ prepare(_sql: string): StatementSync;
50
+ open(): void;
51
+ }
52
+
53
+ interface DatabaseSyncConstructor {
54
+ new (_location: string, _options?: object): DatabaseSync;
55
+ (this: any, _location: string, _options?: object): void;
56
+ prototype: any;
57
+ }
58
+
59
+ export const DatabaseSync = function DatabaseSync(this: any, _location: string, _options?: object) {
60
+ if (!this) return;
61
+ throw new Error("node:sqlite is not supported in the browser environment");
62
+ } as unknown as DatabaseSyncConstructor;
63
+
64
+ DatabaseSync.prototype.close = function close(): void {};
65
+ DatabaseSync.prototype.exec = function exec(_sql: string): void {};
66
+ DatabaseSync.prototype.prepare = function prepare(_sql: string): StatementSync {
67
+ throw new Error("node:sqlite is not supported in the browser environment");
68
+ };
69
+ DatabaseSync.prototype.open = function open(): void {};
70
+
71
+ /* ------------------------------------------------------------------ */
72
+ /* Default export */
73
+ /* ------------------------------------------------------------------ */
74
+
75
+ export default {
76
+ DatabaseSync,
77
+ StatementSync,
78
+ };