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
@@ -1,25 +1,22 @@
1
- import type { IFileSystem, FsStat, MkdirOptions, RmOptions, CpOptions, FileContent, InitialFiles } from "just-bash/browser";
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 (similar to Node's Dirent)
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
- * await fs.writeFile('/src/app.ts', 'console.log("hello")');
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 implements IFileSystem {
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): Promise<string>;
99
- readFileBuffer(path: string): Promise<Uint8Array>;
100
- writeFile(path: string, content: FileContent, _options?: WriteFileOptions | BufferEncoding): Promise<void>;
101
- appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
102
- exists(path: string): Promise<boolean>;
103
- stat(path: string): Promise<FsStat>;
104
- lstat(path: string): Promise<FsStat>;
105
- mkdir(path: string, options?: MkdirOptions): Promise<void>;
106
- readdir(path: string): Promise<string[]>;
107
- readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
108
- rm(path: string, options?: RmOptions): Promise<void>;
109
- cp(src: string, dest: string, options?: CpOptions): Promise<void>;
110
- mv(src: string, dest: string): Promise<void>;
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): Promise<void>;
114
- symlink(target: string, linkPath: string): Promise<void>;
115
- link(existingPath: string, newPath: string): Promise<void>;
116
- readlink(path: string): Promise<string>;
117
- realpath(path: string): Promise<string>;
118
- utimes(path: string, atime: Date, mtime: Date): Promise<void>;
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
  //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/core/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,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AAE,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,CA2ZlB"}
@@ -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;AAwbD;;;;;;;;;;;;;;;;;;;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 { createSandbox, type Sandbox, type SandboxOptions, type SandboxState, type SandboxBashOptions, } from "./sandbox";
2
- export { createBuilder, type BuildResult, type CreateBuilderOptions, type BuildCallOptions, type BuilderFn, } from "./builder";
3
- export { loadModule, loadExport, loadDefault, getExportNames, hasExport, ModuleLoadError, ExportNotFoundError, } from "./loader";
4
- export { registerSharedModules, unregisterSharedModule, clearSharedModules, } from "./shared-modules";
5
- export type { BundleResult } from "./bundler";
6
- export type { BuildOutput, ValidateFn } from "./commands/types";
7
- export type { TypecheckResult, Diagnostic } from "./typechecker";
8
- export type { PackageManifest, InstallResult } from "./packages";
9
- export { initBundler, bundle, bundleToUrl, bundleAndImport, type BundleOptions, type NpmImportsMode, } from "./bundler";
10
- export { typecheck, formatDiagnostics, formatDiagnosticsForAgent, type TypecheckOptions, } from "./typechecker";
11
- export { installPackage, uninstallPackage, listPackages, getPackageManifest, type InstallOptions, } from "./packages";
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, formatBuildFailure, } 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, BuildFailureDetails, 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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,YA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