sandlot 0.1.4 → 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.
- 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 +2692 -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 +31 -132
- 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 +1399 -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 +2646 -0
- package/dist/node/preset.d.ts +62 -0
- package/dist/node/preset.d.ts.map +1 -0
- package/dist/types.d.ts +525 -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 +526 -43
- package/src/commands/types.ts +82 -146
- 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 +621 -0
- package/src/core/sandlot.ts +77 -0
- package/src/core/shared-module-registry.ts +138 -0
- package/src/core/typechecker.ts +607 -0
- package/src/index.ts +104 -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 +668 -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
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FsStat, MkdirOptions, RmOptions, CpOptions, FileContent, InitialFiles, IFileSystem } from "just-bash/browser";
|
|
2
2
|
/**
|
|
3
|
-
* Supported buffer encodings
|
|
3
|
+
* Supported buffer encodings (matches just-bash)
|
|
4
4
|
*/
|
|
5
5
|
type BufferEncoding = "utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex" | "latin1";
|
|
6
6
|
/**
|
|
7
|
-
* Options for reading files
|
|
7
|
+
* Options for reading files (matches just-bash)
|
|
8
8
|
*/
|
|
9
9
|
interface ReadFileOptions {
|
|
10
10
|
encoding?: BufferEncoding | null;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* Options for writing files
|
|
14
|
-
* Note: In this browser-based filesystem, content is stored as-is.
|
|
15
|
-
* The encoding option is accepted for API compatibility but not used.
|
|
13
|
+
* Options for writing files (matches just-bash)
|
|
16
14
|
*/
|
|
17
15
|
interface WriteFileOptions {
|
|
18
|
-
/** Accepted for API compatibility but not used - content is stored as-is */
|
|
19
16
|
encoding?: BufferEncoding;
|
|
20
17
|
}
|
|
21
18
|
/**
|
|
22
|
-
* Directory entry with type information (
|
|
19
|
+
* Directory entry with type information (matches just-bash DirentEntry)
|
|
23
20
|
*/
|
|
24
21
|
interface DirentEntry {
|
|
25
22
|
name: string;
|
|
@@ -48,7 +45,7 @@ export interface FilesystemOptions {
|
|
|
48
45
|
* const fs = Filesystem.create({ initialFiles: { '/src/index.ts': 'export const x = 1;' } });
|
|
49
46
|
*
|
|
50
47
|
* // Use filesystem
|
|
51
|
-
*
|
|
48
|
+
* fs.writeFile('/src/app.ts', 'console.log("hello")');
|
|
52
49
|
*
|
|
53
50
|
* // Export for persistence
|
|
54
51
|
* const files = fs.getFiles();
|
|
@@ -59,7 +56,7 @@ export interface FilesystemOptions {
|
|
|
59
56
|
* const fs2 = Filesystem.create({ initialFiles: saved });
|
|
60
57
|
* ```
|
|
61
58
|
*/
|
|
62
|
-
export declare class Filesystem
|
|
59
|
+
export declare class Filesystem {
|
|
63
60
|
private entries;
|
|
64
61
|
private maxSizeBytes;
|
|
65
62
|
private constructor();
|
|
@@ -95,27 +92,27 @@ export declare class Filesystem implements IFileSystem {
|
|
|
95
92
|
* Get approximate size of all stored data in bytes
|
|
96
93
|
*/
|
|
97
94
|
getSize(): number;
|
|
98
|
-
readFile(path: string, options?: ReadFileOptions | BufferEncoding):
|
|
99
|
-
readFileBuffer(path: string):
|
|
100
|
-
writeFile(path: string, content: FileContent, _options?: WriteFileOptions | BufferEncoding):
|
|
101
|
-
appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding):
|
|
102
|
-
exists(path: string):
|
|
103
|
-
stat(path: string):
|
|
104
|
-
lstat(path: string):
|
|
105
|
-
mkdir(path: string, options?: MkdirOptions):
|
|
106
|
-
readdir(path: string):
|
|
107
|
-
readdirWithFileTypes(path: string):
|
|
108
|
-
rm(path: string, options?: RmOptions):
|
|
109
|
-
cp(src: string, dest: string, options?: CpOptions):
|
|
110
|
-
mv(src: string, dest: string):
|
|
95
|
+
readFile(path: string, options?: ReadFileOptions | BufferEncoding): string;
|
|
96
|
+
readFileBuffer(path: string): Uint8Array;
|
|
97
|
+
writeFile(path: string, content: FileContent, _options?: WriteFileOptions | BufferEncoding): void;
|
|
98
|
+
appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): void;
|
|
99
|
+
exists(path: string): boolean;
|
|
100
|
+
stat(path: string): FsStat;
|
|
101
|
+
lstat(path: string): FsStat;
|
|
102
|
+
mkdir(path: string, options?: MkdirOptions): void;
|
|
103
|
+
readdir(path: string): string[];
|
|
104
|
+
readdirWithFileTypes(path: string): DirentEntry[];
|
|
105
|
+
rm(path: string, options?: RmOptions): void;
|
|
106
|
+
cp(src: string, dest: string, options?: CpOptions): void;
|
|
107
|
+
mv(src: string, dest: string): void;
|
|
111
108
|
resolvePath(base: string, path: string): string;
|
|
112
109
|
getAllPaths(): string[];
|
|
113
|
-
chmod(path: string, mode: number):
|
|
114
|
-
symlink(target: string, linkPath: string):
|
|
115
|
-
link(existingPath: string, newPath: string):
|
|
116
|
-
readlink(path: string):
|
|
117
|
-
realpath(path: string):
|
|
118
|
-
utimes(path: string, atime: Date, mtime: Date):
|
|
110
|
+
chmod(path: string, mode: number): void;
|
|
111
|
+
symlink(target: string, linkPath: string): void;
|
|
112
|
+
link(existingPath: string, newPath: string): void;
|
|
113
|
+
readlink(path: string): string;
|
|
114
|
+
realpath(path: string): string;
|
|
115
|
+
utimes(path: string, atime: Date, mtime: Date): void;
|
|
119
116
|
private normalizePath;
|
|
120
117
|
private static normalizePath;
|
|
121
118
|
private getParentPath;
|
|
@@ -139,5 +136,6 @@ export declare class Filesystem implements IFileSystem {
|
|
|
139
136
|
* @returns A new Filesystem instance
|
|
140
137
|
*/
|
|
141
138
|
export declare function createFilesystem(options?: FilesystemOptions): Filesystem;
|
|
139
|
+
export declare function wrapFilesystemForJustBash(fs: Filesystem): IFileSystem;
|
|
142
140
|
export {};
|
|
143
141
|
//# sourceMapp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,MAAM,GAAG,IAAI;IA0BjD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAc9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAqC9B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI;IAcpD,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,MAAM,CAAC,aAAa;IAsB5B,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAgB/B,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,MAAM,CAAC,aAAa;CAM7B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAExE;AAED,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,UAAU,GAAG,WAAW,CAwBrE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox implementation for v2.
|
|
3
|
+
*
|
|
4
|
+
* A sandbox is a single-project environment with its own:
|
|
5
|
+
* - Virtual filesystem (sync)
|
|
6
|
+
* - Installed packages (tracked in /package.json)
|
|
7
|
+
* - Build configuration (entry point, tsconfig)
|
|
8
|
+
*
|
|
9
|
+
* The sandbox exposes both direct methods (install, build, etc.) and
|
|
10
|
+
* shell commands via exec() for flexibility.
|
|
11
|
+
*
|
|
12
|
+
* Build produces a code string but does NOT load or execute it.
|
|
13
|
+
* Execution is handled by an external executor (main thread, worker, iframe, etc.)
|
|
14
|
+
* which provides appropriate isolation and security boundaries.
|
|
15
|
+
*/
|
|
16
|
+
import type { IBundler, ITypechecker, ITypesResolver, ISharedModuleRegistry, IExecutor, Sandbox, SandboxOptions } from "../types";
|
|
17
|
+
import { Filesystem } from "./fs";
|
|
18
|
+
export interface SandboxContext {
|
|
19
|
+
bundler: IBundler;
|
|
20
|
+
typechecker?: ITypechecker;
|
|
21
|
+
typesResolver?: ITypesResolver;
|
|
22
|
+
sharedModuleRegistry: ISharedModuleRegistry | null;
|
|
23
|
+
executor?: IExecutor;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a sandbox instance.
|
|
27
|
+
* This is called by createSandlot().createSandbox().
|
|
28
|
+
*/
|
|
29
|
+
export declare function createSandboxImpl(fs: Filesystem, options: SandboxOptions, context: SandboxContext): Promise<Sandbox>;
|
|
30
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/core/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,SAAS,EACT,OAAO,EACP,cAAc,EAYf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAA6B,MAAM,MAAM,CAAC;AA2J7D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,QAAQ,CAAC;IAClB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAMD;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,CAAC,CAwZlB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Sandlot, SandlotOptions } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new Sandlot instance with the provided implementations.
|
|
4
|
+
*
|
|
5
|
+
* This is the main factory function. You provide the bundler, typechecker,
|
|
6
|
+
* and other implementations appropriate for your runtime context.
|
|
7
|
+
*
|
|
8
|
+
* @example Browser usage
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createSandlot } from "sandlot";
|
|
11
|
+
* import { EsbuildWasmBundler } from "sandlot/browser";
|
|
12
|
+
*
|
|
13
|
+
* const sandlot = createSandlot({
|
|
14
|
+
* bundler: new EsbuildWasmBundler(),
|
|
15
|
+
* sharedModules: { react: React },
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example Node/Bun usage
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { createSandlot } from "sandlot";
|
|
22
|
+
* import { EsbuildNativeBundler } from "sandlot/node";
|
|
23
|
+
*
|
|
24
|
+
* const sandlot = createSandlot({
|
|
25
|
+
* bundler: new EsbuildNativeBundler(),
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function createSandlot(options: SandlotOptions): Sandlot;
|
|
30
|
+
//# sourceMappingURL=sandlot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandlot.d.ts","sourceRoot":"","sources":["../../src/core/sandlot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EAIf,MAAM,UAAU,CAAC;AAKlB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAsC9D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ISharedModuleRegistry } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Simple shared module registry implementation.
|
|
4
|
+
* Created internally by Sandlot from the sharedModules option.
|
|
5
|
+
*
|
|
6
|
+
* Each registry instance has a unique key (e.g., `__sandlot_abc123__`) that
|
|
7
|
+
* isolates it from other Sandlot instances. This allows multiple Sandlot
|
|
8
|
+
* instances to run concurrently with separate shared module configurations.
|
|
9
|
+
*
|
|
10
|
+
* The registry must be exposed globally for bundled code to access shared modules
|
|
11
|
+
* at runtime. Call `exposeGlobally()` after creation, or use `createSharedModuleRegistry()`
|
|
12
|
+
* which does this automatically.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SharedModuleRegistry implements ISharedModuleRegistry {
|
|
15
|
+
private modules;
|
|
16
|
+
private exportNamesMap;
|
|
17
|
+
private _registryKey;
|
|
18
|
+
constructor(modules: Record<string, unknown>);
|
|
19
|
+
/**
|
|
20
|
+
* The unique global key where this registry is exposed.
|
|
21
|
+
* Bundled code accesses the registry via `globalThis[registryKey]`.
|
|
22
|
+
*/
|
|
23
|
+
get registryKey(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Expose this registry globally so bundled code can access shared modules.
|
|
26
|
+
* This sets globalThis[this.registryKey] = this.
|
|
27
|
+
*/
|
|
28
|
+
exposeGlobally(): this;
|
|
29
|
+
/**
|
|
30
|
+
* Remove this registry from global scope.
|
|
31
|
+
*/
|
|
32
|
+
removeFromGlobal(): void;
|
|
33
|
+
get(moduleId: string): unknown;
|
|
34
|
+
has(moduleId: string): boolean;
|
|
35
|
+
getExportNames(moduleId: string): string[];
|
|
36
|
+
list(): string[];
|
|
37
|
+
private introspectExports;
|
|
38
|
+
private isValidIdentifier;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a shared module registry from a modules object.
|
|
42
|
+
* Automatically exposes the registry globally for bundled code to access.
|
|
43
|
+
* Returns null if no modules are provided.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createSharedModuleRegistry(modules?: Record<string, unknown>): SharedModuleRegistry | null;
|
|
46
|
+
//# sourceMappingURL=shared-module-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-module-registry.d.ts","sourceRoot":"","sources":["../../src/core/shared-module-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAetD;;;;;;;;;;;GAWG;AACH,qBAAa,oBAAqB,YAAW,qBAAqB;IAChE,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,cAAc,CAAwB;IAC9C,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAW5C;;;OAGG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,cAAc,IAAI,IAAI;IAKtB;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAMxB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAQ9B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI9B,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAI1C,IAAI,IAAI,MAAM,EAAE;IAIhB,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,iBAAiB;CAe1B;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,oBAAoB,GAAG,IAAI,CAO7B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typechecker - TypeScript type checking.
|
|
3
|
+
*
|
|
4
|
+
* Uses TypeScript's compiler API
|
|
5
|
+
* Fetches TypeScript lib files (lib.dom.d.ts, etc.) from CDN and caches them.
|
|
6
|
+
*/
|
|
7
|
+
import type { ITypechecker, TypecheckOptions, TypecheckResult } from "../types";
|
|
8
|
+
export interface TypecheckerOptions {
|
|
9
|
+
/**
|
|
10
|
+
* TypeScript lib names to include (e.g., "dom", "es2020").
|
|
11
|
+
* If not provided, uses sensible defaults: ["es2020", "dom", "dom.iterable"]
|
|
12
|
+
*/
|
|
13
|
+
libs?: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Base URL to fetch TypeScript lib files from.
|
|
16
|
+
* Defaults to jsDelivr CDN.
|
|
17
|
+
*/
|
|
18
|
+
libsBaseUrl?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Typechecker using TypeScript compiler API.
|
|
22
|
+
*
|
|
23
|
+
* Fetches TypeScript lib files from CDN and caches them.
|
|
24
|
+
* Uses filesystem access for efficient type checking.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const typechecker = new Typechecker();
|
|
29
|
+
*
|
|
30
|
+
* const result = await typechecker.typecheck({
|
|
31
|
+
* fs: myFilesystem,
|
|
32
|
+
* entryPoint: "/src/index.ts",
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* if (!result.success) {
|
|
36
|
+
* console.log("Type errors:", result.diagnostics);
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare class Typechecker implements ITypechecker {
|
|
41
|
+
private options;
|
|
42
|
+
private libCache;
|
|
43
|
+
private initPromise;
|
|
44
|
+
constructor(options?: TypecheckerOptions);
|
|
45
|
+
/**
|
|
46
|
+
* Pre-fetch TypeScript lib files.
|
|
47
|
+
* Called automatically on first typecheck() if not already done.
|
|
48
|
+
*/
|
|
49
|
+
initialize(): Promise<void>;
|
|
50
|
+
private fetchLibs;
|
|
51
|
+
/**
|
|
52
|
+
* Type check files in a filesystem.
|
|
53
|
+
*/
|
|
54
|
+
typecheck(options: TypecheckOptions): Promise<TypecheckResult>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a typechecker instance.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createTypechecker(options?: TypecheckerOptions): ITypechecker;
|
|
60
|
+
//# sourceMappingURL=typechecker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typechecker.d.ts","sourceRoot":"","sources":["../../src/core/typechecker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAEhB,MAAM,UAAU,CAAC;AAsBlB,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAsbD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,WAAY,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAA8B;gBAErC,OAAO,GAAE,kBAAuB;IAI5C;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAcnB,SAAS;IAWvB;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;CA8CrE;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,YAAY,CAEd"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export
|
|
6
|
-
export type {
|
|
7
|
-
export
|
|
8
|
-
export type {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export { createSharedResources, getDefaultResources, clearDefaultResources, hasDefaultResources, type SharedResourcesOptions, type SharedResources, type TypesCache, } from "./shared-resources";
|
|
13
|
-
export { Filesystem, createFilesystem, type FilesystemOptions, } from "./fs";
|
|
14
|
-
export type { IFileSystem, FsEntry } from "just-bash/browser";
|
|
15
|
-
export { getDefaultBrowserLibs, fetchAndCacheLibs, } from "./ts-libs";
|
|
16
|
-
export { createTscCommand, createBuildCommand, createInstallCommand, createUninstallCommand, createListCommand, createRunCommand, createDefaultCommands, type CommandDeps, type RunContext, type RunOptions, type RunResult, } from "./commands/index";
|
|
1
|
+
export { createSandlot } from "./core/sandlot";
|
|
2
|
+
export { Filesystem, createFilesystem, wrapFilesystemForJustBash, } from "./core/fs";
|
|
3
|
+
export type { FilesystemOptions } from "./core/fs";
|
|
4
|
+
export { SharedModuleRegistry, createSharedModuleRegistry, } from "./core/shared-module-registry";
|
|
5
|
+
export { createSandlotCommand, createDefaultCommands, formatSize, formatDiagnostics, formatBundleErrors, } from "./commands";
|
|
6
|
+
export type { SandboxRef } from "./commands";
|
|
7
|
+
export { Typechecker, createTypechecker } from "./core/typechecker";
|
|
8
|
+
export type { TypecheckerOptions } from "./core/typechecker";
|
|
9
|
+
export { EsmTypesResolver, InMemoryTypesCache, } from "./core/esm-types-resolver";
|
|
10
|
+
export type { EsmTypesResolverOptions, ResolvedTypes, ITypesCache, } from "./core/esm-types-resolver";
|
|
11
|
+
export type { IBundler, ITypechecker, ITypesResolver, ISharedModuleRegistry, IExecutor, Sandlot, SandlotOptions, Sandbox, SandboxOptions, SandboxState, BuildPhase, BuildResult, BuildSuccess, BuildFailure, SandboxBuildOptions, InstallResult, UninstallResult, SandboxTypecheckOptions, RunOptions, RunResult, ExecuteOptions, ExecuteResult, BundleOptions, BundleResult, BundleSuccess, BundleFailure, BundleWarning, BundleError, BundleLocation, TypecheckOptions, TypecheckResult, Diagnostic, ExecResult, IFileSystem, FsEntry, FsStat, } from "./types";
|
|
17
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM/C,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAMnD,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AAMvC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACpE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAM7D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,uBAAuB,EACvB,aAAa,EACb,WAAW,GACZ,MAAM,2BAA2B,CAAC;AAMnC,YAAY,EAEV,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,SAAS,EAGT,OAAO,EACP,cAAc,EACd,OAAO,EACP,cAAc,EACd,YAAY,EAGZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,mBAAmB,EAGnB,aAAa,EACb,eAAe,EAGf,uBAAuB,EAGvB,UAAU,EACV,SAAS,EAGT,cAAc,EACd,aAAa,EAGb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EACX,cAAc,EAGd,gBAAgB,EAChB,eAAe,EACf,UAAU,EAGV,UAAU,EAGV,WAAW,EACX,OAAO,EACP,MAAM,GACP,MAAM,SAAS,CAAC"}
|