sandlot 0.1.4 → 0.2.1

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 +2690 -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 +37 -130
  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 +1398 -2010
  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 +2644 -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 +528 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/package.json +16 -6
  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 +498 -37
  50. package/src/commands/types.ts +117 -145
  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 +624 -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 +609 -0
  59. package/src/index.ts +106 -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 +672 -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 -152
  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 -1942
  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 -85
  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 -575
  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 -398
  112. package/src/shared-modules.ts +0 -280
  113. package/src/shared-resources.ts +0 -166
  114. package/src/ts-libs.ts +0 -218
  115. package/src/typechecker.ts +0 -635
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Browser bundler implementation using esbuild-wasm.
3
+ *
4
+ * This module handles WASM initialization and provides a bundler that
5
+ * works entirely in the browser.
6
+ */
7
+ import type { IBundler, BundleOptions, BundleResult } from "../types";
8
+ export interface EsbuildWasmBundlerOptions {
9
+ /**
10
+ * URL to the esbuild WASM file.
11
+ * @default "https://unpkg.com/esbuild-wasm@{version}/esbuild.wasm"
12
+ */
13
+ wasmUrl?: string;
14
+ /**
15
+ * URL to load esbuild-wasm module from.
16
+ * @default "https://esm.sh/esbuild-wasm@{version}"
17
+ */
18
+ esbuildUrl?: string;
19
+ /**
20
+ * Base URL for CDN imports.
21
+ * npm imports like "lodash" are rewritten to "{cdnBaseUrl}/lodash@{version}".
22
+ * @default "https://esm.sh"
23
+ */
24
+ cdnBaseUrl?: string;
25
+ /**
26
+ * Whether to initialize immediately on construction.
27
+ * If false, initialization happens lazily on first bundle() call.
28
+ * @default false
29
+ */
30
+ eagerInit?: boolean;
31
+ }
32
+ /**
33
+ * Browser bundler implementation using esbuild-wasm.
34
+ *
35
+ * Handles WASM initialization internally. The first bundle() call
36
+ * will wait for initialization if not already complete.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const bundler = new EsbuildWasmBundler();
41
+ * await bundler.initialize();
42
+ *
43
+ * const result = await bundler.bundle({
44
+ * fs: myFilesystem,
45
+ * entryPoint: "/src/index.ts",
46
+ * });
47
+ * ```
48
+ */
49
+ export declare class EsbuildWasmBundler implements IBundler {
50
+ private options;
51
+ constructor(options?: EsbuildWasmBundlerOptions);
52
+ /**
53
+ * Initialize the esbuild WASM module.
54
+ * Called automatically on first bundle() if not already initialized.
55
+ *
56
+ * Uses a global singleton pattern since esbuild-wasm can only be
57
+ * initialized once per page.
58
+ */
59
+ initialize(): Promise<void>;
60
+ private doInitialize;
61
+ /**
62
+ * Get the initialized esbuild instance.
63
+ */
64
+ private getEsbuild;
65
+ private checkCrossOriginIsolation;
66
+ bundle(options: BundleOptions): Promise<BundleResult>;
67
+ }
68
+ //# sourceMappingURL=bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/browser/bundler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EAGb,MAAM,UAAU,CAAC;AAuClB,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,kBAAmB,YAAW,QAAQ;IACjD,OAAO,CAAC,OAAO,CAA4B;gBAE/B,OAAO,GAAE,yBAA8B;IAWnD;;;;;;OAMG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAmBnB,YAAY;IA8B1B;;OAEG;IACH,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,yBAAyB;IAc3B,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CAoG5D"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Main thread executor for browser environments.
3
+ *
4
+ * This executor runs code directly in the main thread. It provides no
5
+ * isolation from the host environment - use only for trusted code.
6
+ *
7
+ * For untrusted code, consider using a Worker or iframe-based executor
8
+ * that provides proper sandboxing.
9
+ */
10
+ import type { IExecutor } from "../types";
11
+ import { type BasicExecutorOptions } from "../core/executor";
12
+ /**
13
+ * Options for creating a MainThreadExecutor.
14
+ */
15
+ export type MainThreadExecutorOptions = BasicExecutorOptions;
16
+ /**
17
+ * Executor that runs code in the main browser thread.
18
+ *
19
+ * WARNING: This executor provides NO isolation. The executed code has
20
+ * full access to the page's DOM, global variables, and network.
21
+ * Only use for trusted code (e.g., code you're developing).
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const executor = createMainThreadExecutor();
26
+ * const result = await executor.execute(bundledCode, {
27
+ * entryExport: 'main',
28
+ * context: { args: ['--verbose'] },
29
+ * timeout: 5000,
30
+ * });
31
+ * console.log(result.logs);
32
+ * ```
33
+ */
34
+ export declare class MainThreadExecutor implements IExecutor {
35
+ private executor;
36
+ constructor(options?: MainThreadExecutorOptions);
37
+ execute: IExecutor["execute"];
38
+ }
39
+ /**
40
+ * Create a main thread executor.
41
+ *
42
+ * @param options - Executor options
43
+ * @returns A new MainThreadExecutor instance
44
+ */
45
+ export declare function createMainThreadExecutor(options?: MainThreadExecutorOptions): MainThreadExecutor;
46
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/browser/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAgB7D;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAmB,YAAW,SAAS;IAClD,OAAO,CAAC,QAAQ,CAAY;gBAEhB,OAAO,GAAE,yBAA8B;IAInD,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,CAA+C;CAC7E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,yBAAyB,GAClC,kBAAkB,CAEpB"}
@@ -0,0 +1,9 @@
1
+ export { Typechecker, createTypechecker } from "../core/typechecker";
2
+ export type { TypecheckerOptions } from "../core/typechecker";
3
+ export { EsbuildWasmBundler } from "./bundler";
4
+ export type { EsbuildWasmBundlerOptions } from "./bundler";
5
+ export { MainThreadExecutor, createMainThreadExecutor } from "./executor";
6
+ export type { MainThreadExecutorOptions } from "./executor";
7
+ export { createBrowserSandlot } from "./preset";
8
+ export type { CreateBrowserSandlotOptions } from "./preset";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAM9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAM3D,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC1E,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAM5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC"}