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.
- package/dist/browser/bundler.d.ts +68 -0
- package/dist/browser/bundler.d.ts.map +1 -0
- package/dist/browser/executor.d.ts +46 -0
- package/dist/browser/executor.d.ts.map +1 -0
- package/dist/browser/index.d.ts +9 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +2690 -0
- package/dist/browser/preset.d.ts +63 -0
- package/dist/browser/preset.d.ts.map +1 -0
- package/dist/commands/index.d.ts +20 -11
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/types.d.ts +37 -130
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/core/bundler-utils.d.ts +142 -0
- package/dist/core/bundler-utils.d.ts.map +1 -0
- package/dist/core/esm-types-resolver.d.ts +125 -0
- package/dist/core/esm-types-resolver.d.ts.map +1 -0
- package/dist/core/executor.d.ts +35 -0
- package/dist/core/executor.d.ts.map +1 -0
- package/dist/{fs.d.ts → core/fs.d.ts} +27 -29
- package/dist/core/fs.d.ts.map +1 -0
- package/dist/core/sandbox.d.ts +30 -0
- package/dist/core/sandbox.d.ts.map +1 -0
- package/dist/core/sandlot.d.ts +30 -0
- package/dist/core/sandlot.d.ts.map +1 -0
- package/dist/core/shared-module-registry.d.ts +46 -0
- package/dist/core/shared-module-registry.d.ts.map +1 -0
- package/dist/core/typechecker.d.ts +60 -0
- package/dist/core/typechecker.d.ts.map +1 -0
- package/dist/index.d.ts +11 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1398 -2010
- package/dist/node/bundler.d.ts +48 -0
- package/dist/node/bundler.d.ts.map +1 -0
- package/dist/node/executor.d.ts +48 -0
- package/dist/node/executor.d.ts.map +1 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +2644 -0
- package/dist/node/preset.d.ts +62 -0
- package/dist/node/preset.d.ts.map +1 -0
- package/dist/types.d.ts +528 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +16 -6
- package/src/browser/bundler.ts +294 -0
- package/src/browser/executor.ts +71 -0
- package/src/browser/index.ts +57 -0
- package/src/browser/preset.ts +179 -0
- package/src/commands/index.ts +498 -37
- package/src/commands/types.ts +117 -145
- package/src/core/bundler-utils.ts +630 -0
- package/src/core/esm-types-resolver.ts +432 -0
- package/src/core/executor.ts +161 -0
- package/src/{fs.ts → core/fs.ts} +59 -37
- package/src/core/sandbox.ts +624 -0
- package/src/core/sandlot.ts +77 -0
- package/src/core/shared-module-registry.ts +138 -0
- package/src/core/typechecker.ts +609 -0
- package/src/index.ts +106 -139
- package/src/node/bundler.ts +194 -0
- package/src/node/executor.ts +87 -0
- package/src/node/index.ts +39 -0
- package/src/node/preset.ts +178 -0
- package/src/types.ts +672 -0
- package/README.md +0 -243
- package/dist/build-emitter.d.ts +0 -47
- package/dist/build-emitter.d.ts.map +0 -1
- package/dist/builder.d.ts +0 -370
- package/dist/builder.d.ts.map +0 -1
- package/dist/bundler.d.ts +0 -152
- package/dist/bundler.d.ts.map +0 -1
- package/dist/commands/compile.d.ts +0 -13
- package/dist/commands/compile.d.ts.map +0 -1
- package/dist/commands/packages.d.ts +0 -17
- package/dist/commands/packages.d.ts.map +0 -1
- package/dist/commands/run.d.ts +0 -40
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands.d.ts +0 -179
- package/dist/commands.d.ts.map +0 -1
- package/dist/fs.d.ts.map +0 -1
- package/dist/internal.d.ts +0 -79
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.js +0 -1942
- package/dist/loader.d.ts +0 -164
- package/dist/loader.d.ts.map +0 -1
- package/dist/packages.d.ts +0 -199
- package/dist/packages.d.ts.map +0 -1
- package/dist/runner.d.ts +0 -314
- package/dist/runner.d.ts.map +0 -1
- package/dist/sandbox-manager.d.ts +0 -261
- package/dist/sandbox-manager.d.ts.map +0 -1
- package/dist/sandbox.d.ts +0 -267
- package/dist/sandbox.d.ts.map +0 -1
- package/dist/shared-modules.d.ts +0 -148
- package/dist/shared-modules.d.ts.map +0 -1
- package/dist/shared-resources.d.ts +0 -102
- package/dist/shared-resources.d.ts.map +0 -1
- package/dist/ts-libs.d.ts +0 -85
- package/dist/ts-libs.d.ts.map +0 -1
- package/dist/typechecker.d.ts +0 -127
- package/dist/typechecker.d.ts.map +0 -1
- package/src/build-emitter.ts +0 -64
- package/src/builder.ts +0 -498
- package/src/bundler.ts +0 -575
- package/src/commands/compile.ts +0 -236
- package/src/commands/packages.ts +0 -154
- package/src/commands/run.ts +0 -245
- package/src/internal.ts +0 -119
- package/src/loader.ts +0 -229
- package/src/packages.ts +0 -936
- package/src/sandbox.ts +0 -398
- package/src/shared-modules.ts +0 -280
- package/src/shared-resources.ts +0 -166
- package/src/ts-libs.ts +0 -218
- 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"}
|