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,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"}
|