sandlot 0.1.3 → 0.2.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 (115) hide show
  1. package/dist/browser/bundler.d.ts +68 -0
  2. package/dist/browser/bundler.d.ts.map +1 -0
  3. package/dist/browser/executor.d.ts +46 -0
  4. package/dist/browser/executor.d.ts.map +1 -0
  5. package/dist/browser/index.d.ts +9 -0
  6. package/dist/browser/index.d.ts.map +1 -0
  7. package/dist/browser/index.js +2692 -0
  8. package/dist/browser/preset.d.ts +63 -0
  9. package/dist/browser/preset.d.ts.map +1 -0
  10. package/dist/commands/index.d.ts +20 -11
  11. package/dist/commands/index.d.ts.map +1 -1
  12. package/dist/commands/types.d.ts +31 -132
  13. package/dist/commands/types.d.ts.map +1 -1
  14. package/dist/core/bundler-utils.d.ts +142 -0
  15. package/dist/core/bundler-utils.d.ts.map +1 -0
  16. package/dist/core/esm-types-resolver.d.ts +125 -0
  17. package/dist/core/esm-types-resolver.d.ts.map +1 -0
  18. package/dist/core/executor.d.ts +35 -0
  19. package/dist/core/executor.d.ts.map +1 -0
  20. package/dist/{fs.d.ts → core/fs.d.ts} +27 -29
  21. package/dist/core/fs.d.ts.map +1 -0
  22. package/dist/core/sandbox.d.ts +30 -0
  23. package/dist/core/sandbox.d.ts.map +1 -0
  24. package/dist/core/sandlot.d.ts +30 -0
  25. package/dist/core/sandlot.d.ts.map +1 -0
  26. package/dist/core/shared-module-registry.d.ts +46 -0
  27. package/dist/core/shared-module-registry.d.ts.map +1 -0
  28. package/dist/core/typechecker.d.ts +60 -0
  29. package/dist/core/typechecker.d.ts.map +1 -0
  30. package/dist/index.d.ts +11 -16
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +1405 -2049
  33. package/dist/node/bundler.d.ts +48 -0
  34. package/dist/node/bundler.d.ts.map +1 -0
  35. package/dist/node/executor.d.ts +48 -0
  36. package/dist/node/executor.d.ts.map +1 -0
  37. package/dist/node/index.d.ts +9 -0
  38. package/dist/node/index.d.ts.map +1 -0
  39. package/dist/node/index.js +2646 -0
  40. package/dist/node/preset.d.ts +62 -0
  41. package/dist/node/preset.d.ts.map +1 -0
  42. package/dist/types.d.ts +525 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/package.json +27 -8
  45. package/src/browser/bundler.ts +294 -0
  46. package/src/browser/executor.ts +71 -0
  47. package/src/browser/index.ts +57 -0
  48. package/src/browser/preset.ts +179 -0
  49. package/src/commands/index.ts +526 -43
  50. package/src/commands/types.ts +82 -146
  51. package/src/core/bundler-utils.ts +630 -0
  52. package/src/core/esm-types-resolver.ts +432 -0
  53. package/src/core/executor.ts +161 -0
  54. package/src/{fs.ts → core/fs.ts} +59 -37
  55. package/src/core/sandbox.ts +621 -0
  56. package/src/core/sandlot.ts +77 -0
  57. package/src/core/shared-module-registry.ts +138 -0
  58. package/src/core/typechecker.ts +607 -0
  59. package/src/index.ts +104 -139
  60. package/src/node/bundler.ts +194 -0
  61. package/src/node/executor.ts +87 -0
  62. package/src/node/index.ts +39 -0
  63. package/src/node/preset.ts +178 -0
  64. package/src/types.ts +668 -0
  65. package/README.md +0 -243
  66. package/dist/build-emitter.d.ts +0 -47
  67. package/dist/build-emitter.d.ts.map +0 -1
  68. package/dist/builder.d.ts +0 -370
  69. package/dist/builder.d.ts.map +0 -1
  70. package/dist/bundler.d.ts +0 -148
  71. package/dist/bundler.d.ts.map +0 -1
  72. package/dist/commands/compile.d.ts +0 -13
  73. package/dist/commands/compile.d.ts.map +0 -1
  74. package/dist/commands/packages.d.ts +0 -17
  75. package/dist/commands/packages.d.ts.map +0 -1
  76. package/dist/commands/run.d.ts +0 -40
  77. package/dist/commands/run.d.ts.map +0 -1
  78. package/dist/commands.d.ts +0 -179
  79. package/dist/commands.d.ts.map +0 -1
  80. package/dist/fs.d.ts.map +0 -1
  81. package/dist/internal.d.ts +0 -79
  82. package/dist/internal.d.ts.map +0 -1
  83. package/dist/internal.js +0 -1976
  84. package/dist/loader.d.ts +0 -164
  85. package/dist/loader.d.ts.map +0 -1
  86. package/dist/packages.d.ts +0 -199
  87. package/dist/packages.d.ts.map +0 -1
  88. package/dist/runner.d.ts +0 -314
  89. package/dist/runner.d.ts.map +0 -1
  90. package/dist/sandbox-manager.d.ts +0 -261
  91. package/dist/sandbox-manager.d.ts.map +0 -1
  92. package/dist/sandbox.d.ts +0 -267
  93. package/dist/sandbox.d.ts.map +0 -1
  94. package/dist/shared-modules.d.ts +0 -148
  95. package/dist/shared-modules.d.ts.map +0 -1
  96. package/dist/shared-resources.d.ts +0 -102
  97. package/dist/shared-resources.d.ts.map +0 -1
  98. package/dist/ts-libs.d.ts +0 -98
  99. package/dist/ts-libs.d.ts.map +0 -1
  100. package/dist/typechecker.d.ts +0 -127
  101. package/dist/typechecker.d.ts.map +0 -1
  102. package/src/build-emitter.ts +0 -64
  103. package/src/builder.ts +0 -498
  104. package/src/bundler.ts +0 -542
  105. package/src/commands/compile.ts +0 -236
  106. package/src/commands/packages.ts +0 -154
  107. package/src/commands/run.ts +0 -245
  108. package/src/internal.ts +0 -119
  109. package/src/loader.ts +0 -229
  110. package/src/packages.ts +0 -936
  111. package/src/sandbox.ts +0 -396
  112. package/src/shared-modules.ts +0 -280
  113. package/src/shared-resources.ts +0 -166
  114. package/src/ts-libs.ts +0 -320
  115. package/src/typechecker.ts +0 -635
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Node/Bun/Deno bundler implementation using native esbuild.
3
+ *
4
+ * This is significantly faster than esbuild-wasm as it uses the native
5
+ * esbuild binary instead of WebAssembly.
6
+ */
7
+ import type { IBundler, BundleOptions, BundleResult } from "../types";
8
+ export interface EsbuildNativeBundlerOptions {
9
+ /**
10
+ * Base URL for CDN imports.
11
+ * npm imports like "lodash" are rewritten to "{cdnBaseUrl}/lodash@{version}".
12
+ * @default "https://esm.sh"
13
+ */
14
+ cdnBaseUrl?: string;
15
+ }
16
+ /**
17
+ * Bundler implementation using native esbuild.
18
+ *
19
+ * Uses the native esbuild binary for maximum performance.
20
+ * Works with Node.js, Bun, and Deno.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const bundler = new EsbuildNativeBundler();
25
+ *
26
+ * const result = await bundler.bundle({
27
+ * fs: myFilesystem,
28
+ * entryPoint: "/src/index.ts",
29
+ * });
30
+ * ```
31
+ */
32
+ export declare class EsbuildNativeBundler implements IBundler {
33
+ private options;
34
+ private esbuild;
35
+ constructor(options?: EsbuildNativeBundlerOptions);
36
+ /**
37
+ * Initialize the bundler by loading native esbuild.
38
+ * Called automatically on first bundle() if not already initialized.
39
+ */
40
+ initialize(): Promise<void>;
41
+ private getEsbuild;
42
+ bundle(options: BundleOptions): Promise<BundleResult>;
43
+ }
44
+ /**
45
+ * Create a native esbuild bundler.
46
+ */
47
+ export declare function createEsbuildNativeBundler(options?: EsbuildNativeBundlerOptions): EsbuildNativeBundler;
48
+ //# sourceMappingURL=bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/node/bundler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EAGb,MAAM,UAAU,CAAC;AAOlB,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,oBAAqB,YAAW,QAAQ;IACnD,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,OAAO,CAAoC;gBAEvC,OAAO,GAAE,2BAAgC;IAOrD;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC,OAAO,CAAC,UAAU;IAOZ,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CA0G5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,2BAA2B,GACpC,oBAAoB,CAEtB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Node/Bun/Deno executor implementation.
3
+ *
4
+ * Executes bundled JavaScript code using temp files and dynamic import.
5
+ * This provides basic execution without full isolation.
6
+ *
7
+ * For isolated execution, consider using Node's vm module or worker threads.
8
+ */
9
+ import type { IExecutor } from "../types";
10
+ import { type BasicExecutorOptions } from "../core/executor";
11
+ /**
12
+ * Options for creating a NodeExecutor.
13
+ */
14
+ export type NodeExecutorOptions = BasicExecutorOptions;
15
+ /**
16
+ * Executor that runs code in Node.js/Bun/Deno.
17
+ *
18
+ * Uses data URLs with dynamic import for execution.
19
+ * This approach works across Node.js, Bun, and Deno.
20
+ *
21
+ * WARNING: This executor provides NO isolation. The executed code has
22
+ * full access to the process environment, file system, and network.
23
+ * Only use for trusted code.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const executor = createNodeExecutor();
28
+ * const result = await executor.execute(bundledCode, {
29
+ * entryExport: 'main',
30
+ * context: { args: ['--verbose'] },
31
+ * timeout: 5000,
32
+ * });
33
+ * console.log(result.logs);
34
+ * ```
35
+ */
36
+ export declare class NodeExecutor implements IExecutor {
37
+ private executor;
38
+ constructor(options?: NodeExecutorOptions);
39
+ execute: IExecutor["execute"];
40
+ }
41
+ /**
42
+ * Create a Node executor.
43
+ *
44
+ * @param options - Executor options
45
+ * @returns A new NodeExecutor instance
46
+ */
47
+ export declare function createNodeExecutor(options?: NodeExecutorOptions): NodeExecutor;
48
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/node/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAKlF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AA6BvD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,YAAa,YAAW,SAAS;IAC5C,OAAO,CAAC,QAAQ,CAAY;gBAEhB,OAAO,GAAE,mBAAwB;IAI7C,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAA+C;CAC7E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAE9E"}
@@ -0,0 +1,9 @@
1
+ export { EsbuildNativeBundler, createEsbuildNativeBundler } from "./bundler";
2
+ export type { EsbuildNativeBundlerOptions } from "./bundler";
3
+ export { Typechecker, createTypechecker } from "../core/typechecker";
4
+ export type { TypecheckerOptions } from "../core/typechecker";
5
+ export { NodeExecutor, createNodeExecutor } from "./executor";
6
+ export type { NodeExecutorOptions } from "./executor";
7
+ export { createNodeSandlot } from "./preset";
8
+ export type { CreateNodeSandlotOptions } from "./preset";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAC7E,YAAY,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAM7D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAM9D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC9D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAMtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC"}