sandlot 0.1.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.
Files changed (47) hide show
  1. package/README.md +616 -0
  2. package/dist/bundler.d.ts +148 -0
  3. package/dist/bundler.d.ts.map +1 -0
  4. package/dist/commands.d.ts +179 -0
  5. package/dist/commands.d.ts.map +1 -0
  6. package/dist/fs.d.ts +125 -0
  7. package/dist/fs.d.ts.map +1 -0
  8. package/dist/index.d.ts +16 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +2920 -0
  11. package/dist/internal.d.ts +74 -0
  12. package/dist/internal.d.ts.map +1 -0
  13. package/dist/internal.js +1897 -0
  14. package/dist/loader.d.ts +164 -0
  15. package/dist/loader.d.ts.map +1 -0
  16. package/dist/packages.d.ts +199 -0
  17. package/dist/packages.d.ts.map +1 -0
  18. package/dist/react.d.ts +159 -0
  19. package/dist/react.d.ts.map +1 -0
  20. package/dist/react.js +149 -0
  21. package/dist/sandbox-manager.d.ts +249 -0
  22. package/dist/sandbox-manager.d.ts.map +1 -0
  23. package/dist/sandbox.d.ts +193 -0
  24. package/dist/sandbox.d.ts.map +1 -0
  25. package/dist/shared-modules.d.ts +129 -0
  26. package/dist/shared-modules.d.ts.map +1 -0
  27. package/dist/shared-resources.d.ts +105 -0
  28. package/dist/shared-resources.d.ts.map +1 -0
  29. package/dist/ts-libs.d.ts +98 -0
  30. package/dist/ts-libs.d.ts.map +1 -0
  31. package/dist/typechecker.d.ts +127 -0
  32. package/dist/typechecker.d.ts.map +1 -0
  33. package/package.json +64 -0
  34. package/src/bundler.ts +513 -0
  35. package/src/commands.ts +733 -0
  36. package/src/fs.ts +935 -0
  37. package/src/index.ts +149 -0
  38. package/src/internal.ts +116 -0
  39. package/src/loader.ts +229 -0
  40. package/src/packages.ts +936 -0
  41. package/src/react.tsx +331 -0
  42. package/src/sandbox-manager.ts +490 -0
  43. package/src/sandbox.ts +402 -0
  44. package/src/shared-modules.ts +210 -0
  45. package/src/shared-resources.ts +169 -0
  46. package/src/ts-libs.ts +320 -0
  47. package/src/typechecker.ts +635 -0
@@ -0,0 +1,148 @@
1
+ import type { IFileSystem } from "just-bash/browser";
2
+ import * as esbuild from "esbuild-wasm";
3
+ /**
4
+ * How to handle npm package imports (bare imports like "react").
5
+ *
6
+ * - "cdn" (default): Rewrite to esm.sh CDN URLs using installed package versions.
7
+ * Requires packages to be installed via the `install` command.
8
+ * - "external": Mark as external, don't rewrite. The consumer must handle
9
+ * module resolution (useful for SSR or custom bundling).
10
+ * - "bundle": Attempt to bundle from node_modules. Rarely useful in browser
11
+ * since node_modules typically doesn't exist in the virtual filesystem.
12
+ */
13
+ export type NpmImportsMode = "cdn" | "external" | "bundle";
14
+ /**
15
+ * Options for bundling
16
+ */
17
+ export interface BundleOptions {
18
+ /**
19
+ * The virtual filesystem to read source files from
20
+ */
21
+ fs: IFileSystem;
22
+ /**
23
+ * Entry point path (absolute path in the virtual filesystem)
24
+ */
25
+ entryPoint: string;
26
+ /**
27
+ * Module names to mark as external (won't be bundled).
28
+ * These are in addition to bare imports when using npmImports: "external".
29
+ */
30
+ external?: string[];
31
+ /**
32
+ * How to handle npm package imports (bare imports like "react").
33
+ *
34
+ * - "cdn" (default): Rewrite to esm.sh CDN URLs using installed package versions
35
+ * - "external": Mark as external, don't rewrite (consumer must handle)
36
+ * - "bundle": Attempt to bundle from node_modules (rarely useful in browser)
37
+ */
38
+ npmImports?: NpmImportsMode;
39
+ /**
40
+ * Module IDs that should be resolved from the host's SharedModuleRegistry
41
+ * instead of esm.sh CDN. The host must have registered these modules.
42
+ *
43
+ * Example: ['react', 'react-dom/client']
44
+ *
45
+ * When specified, imports of these modules will use the host's instances,
46
+ * allowing dynamic components to share React context, hooks, etc.
47
+ */
48
+ sharedModules?: string[];
49
+ /**
50
+ * Output format: 'esm' (default), 'iife', or 'cjs'
51
+ */
52
+ format?: "esm" | "iife" | "cjs";
53
+ /**
54
+ * Enable minification
55
+ * Default: false
56
+ */
57
+ minify?: boolean;
58
+ /**
59
+ * Enable source maps (inline)
60
+ * Default: false
61
+ */
62
+ sourcemap?: boolean;
63
+ /**
64
+ * Global name for IIFE format
65
+ */
66
+ globalName?: string;
67
+ /**
68
+ * Target environment(s)
69
+ * Default: ['es2020']
70
+ */
71
+ target?: string[];
72
+ }
73
+ /**
74
+ * Result of bundling
75
+ */
76
+ export interface BundleResult {
77
+ /**
78
+ * The bundled JavaScript code
79
+ */
80
+ code: string;
81
+ /**
82
+ * Any warnings from esbuild
83
+ */
84
+ warnings: esbuild.Message[];
85
+ /**
86
+ * List of files that were included in the bundle
87
+ */
88
+ includedFiles: string[];
89
+ }
90
+ /**
91
+ * Initialize esbuild-wasm. Called automatically on first bundle.
92
+ * Can be called explicitly to pre-warm.
93
+ */
94
+ export declare function initBundler(): Promise<void>;
95
+ /**
96
+ * Bundle TypeScript/JavaScript files from a virtual filesystem
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const fs = IndexedDbFs.createInMemory({
101
+ * initialFiles: {
102
+ * "/src/index.ts": "export const hello = 'world';",
103
+ * "/src/utils.ts": "export function add(a: number, b: number) { return a + b; }",
104
+ * }
105
+ * });
106
+ *
107
+ * const result = await bundle({
108
+ * fs,
109
+ * entryPoint: "/src/index.ts",
110
+ * });
111
+ *
112
+ * console.log(result.code);
113
+ * ```
114
+ */
115
+ export declare function bundle(options: BundleOptions): Promise<BundleResult>;
116
+ /**
117
+ * Bundle and return a blob URL for dynamic import
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * const url = await bundleToUrl({
122
+ * fs,
123
+ * entryPoint: "/src/index.ts",
124
+ * });
125
+ *
126
+ * const module = await import(url);
127
+ * console.log(module.hello); // 'world'
128
+ *
129
+ * // Clean up when done
130
+ * URL.revokeObjectURL(url);
131
+ * ```
132
+ */
133
+ export declare function bundleToUrl(options: BundleOptions): Promise<string>;
134
+ /**
135
+ * Bundle and immediately import the module
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const module = await bundleAndImport<{ hello: string }>({
140
+ * fs,
141
+ * entryPoint: "/src/index.ts",
142
+ * });
143
+ *
144
+ * console.log(module.hello); // 'world'
145
+ * ```
146
+ */
147
+ export declare function bundleAndImport<T = unknown>(options: BundleOptions): Promise<T>;
148
+ //# sourceMappingURL=bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAIxC;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,EAAE,EAAE,WAAW,CAAC;IAEhB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;IAEhC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;IAE5B;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAeD;;;GAGG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAcjD;AAyPD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA6D1E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAIzE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAOrF"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Command factories for sandbox bash environments.
3
+ *
4
+ * Pure factories that create commands for type checking and bundling.
5
+ * No global state - all dependencies are passed in explicitly.
6
+ */
7
+ import { type IFileSystem } from "just-bash/browser";
8
+ import { type BundleResult } from "./bundler";
9
+ import { type TypesCache } from "./packages";
10
+ /**
11
+ * Dependencies required by command factories
12
+ */
13
+ export interface CommandDeps {
14
+ /**
15
+ * The virtual filesystem to operate on
16
+ */
17
+ fs: IFileSystem;
18
+ /**
19
+ * Pre-loaded TypeScript lib files for type checking
20
+ */
21
+ libFiles: Map<string, string>;
22
+ /**
23
+ * Path to tsconfig.json in the virtual filesystem
24
+ */
25
+ tsconfigPath: string;
26
+ /**
27
+ * Callback invoked when a build succeeds
28
+ */
29
+ onBuild?: (result: BundleResult) => void | Promise<void>;
30
+ /**
31
+ * Cache for package type definitions.
32
+ * When provided, avoids redundant network fetches for packages
33
+ * that have already been installed in other sandboxes.
34
+ */
35
+ typesCache?: TypesCache;
36
+ /**
37
+ * Options for the `run` command
38
+ */
39
+ runOptions?: RunOptions;
40
+ /**
41
+ * Module IDs that should be resolved from the host's SharedModuleRegistry
42
+ * instead of esm.sh CDN. The host must have registered these modules.
43
+ *
44
+ * Example: ['react', 'react-dom/client']
45
+ */
46
+ sharedModules?: string[];
47
+ }
48
+ /**
49
+ * Runtime context passed to the `main()` function when code is executed.
50
+ * This provides sandboxed code with access to sandbox capabilities.
51
+ */
52
+ export interface RunContext {
53
+ /**
54
+ * The virtual filesystem - read/write files within the sandbox
55
+ */
56
+ fs: IFileSystem;
57
+ /**
58
+ * Environment variables (configurable per-sandbox)
59
+ */
60
+ env: Record<string, string>;
61
+ /**
62
+ * Command-line arguments passed to `run`
63
+ */
64
+ args: string[];
65
+ /**
66
+ * Explicit logging function (alternative to console.log)
67
+ */
68
+ log: (...args: unknown[]) => void;
69
+ /**
70
+ * Explicit error logging function (alternative to console.error)
71
+ */
72
+ error: (...args: unknown[]) => void;
73
+ }
74
+ /**
75
+ * Options for configuring the `run` command behavior
76
+ */
77
+ export interface RunOptions {
78
+ /**
79
+ * Environment variables available via ctx.env
80
+ */
81
+ env?: Record<string, string>;
82
+ /**
83
+ * Maximum execution time in milliseconds (default: 30000 = 30s)
84
+ * Set to 0 to disable timeout.
85
+ */
86
+ timeout?: number;
87
+ /**
88
+ * Whether to skip type checking before running (default: false)
89
+ */
90
+ skipTypecheck?: boolean;
91
+ }
92
+ /**
93
+ * Result of running code via the `run` command
94
+ */
95
+ export interface RunResult {
96
+ /**
97
+ * Captured console output (log, warn, error)
98
+ */
99
+ logs: string[];
100
+ /**
101
+ * Return value from main() if present
102
+ */
103
+ returnValue?: unknown;
104
+ /**
105
+ * Execution time in milliseconds
106
+ */
107
+ executionTimeMs: number;
108
+ }
109
+ /**
110
+ * Format esbuild messages (warnings/errors) for display
111
+ */
112
+ export declare function formatEsbuildMessages(messages: {
113
+ text: string;
114
+ location?: {
115
+ file?: string;
116
+ line?: number;
117
+ column?: number;
118
+ } | null;
119
+ }[]): string;
120
+ /**
121
+ * Create the `tsc` command for type checking
122
+ */
123
+ export declare function createTscCommand(deps: CommandDeps): import("just-bash/browser").Command;
124
+ /**
125
+ * Create the `build` command for bundling (with automatic type checking)
126
+ */
127
+ export declare function createBuildCommand(deps: CommandDeps): import("just-bash/browser").Command;
128
+ /**
129
+ * Create the `install` command for adding packages from npm
130
+ */
131
+ export declare function createInstallCommand(deps: CommandDeps): import("just-bash/browser").Command;
132
+ /**
133
+ * Create the `uninstall` command for removing packages
134
+ */
135
+ export declare function createUninstallCommand(deps: CommandDeps): import("just-bash/browser").Command;
136
+ /**
137
+ * Create the `list` command (alias: `ls`) for showing installed packages
138
+ */
139
+ export declare function createListCommand(deps: CommandDeps): import("just-bash/browser").Command;
140
+ /**
141
+ * Create the `run` command for executing code in the sandbox.
142
+ *
143
+ * The run command:
144
+ * 1. Builds the entry point (with type checking by default)
145
+ * 2. Dynamically imports the bundle
146
+ * 3. If a `main` export exists, calls it with a RunContext
147
+ * 4. Captures all console output (log, warn, error)
148
+ * 5. Returns the captured output and any return value from main()
149
+ *
150
+ * Usage:
151
+ * run [entry] [--skip-typecheck|-s] [--timeout|-t <ms>] [-- args...]
152
+ *
153
+ * Code can be written in two styles:
154
+ *
155
+ * 1. Script style (top-level code, runs on import):
156
+ * ```ts
157
+ * console.log("Hello from script!");
158
+ * const result = 2 + 2;
159
+ * console.log("Result:", result);
160
+ * ```
161
+ *
162
+ * 2. Main function style (with context access):
163
+ * ```ts
164
+ * import type { RunContext } from "sandlot";
165
+ *
166
+ * export async function main(ctx: RunContext) {
167
+ * ctx.log("Reading file...");
168
+ * const content = await ctx.fs.readFile("/data/input.txt");
169
+ * ctx.log("Content:", content);
170
+ * return { success: true };
171
+ * }
172
+ * ```
173
+ */
174
+ export declare function createRunCommand(deps: CommandDeps): import("just-bash/browser").Command;
175
+ /**
176
+ * Create all default sandbox commands
177
+ */
178
+ export declare function createDefaultCommands(deps: CommandDeps): import("just-bash/browser").Command[];
179
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAsC,KA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AM,WAAW,SAAS;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,EAAE,GAChG,MAAM,CAaR;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,uCA4DjD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,uCAqHnD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,uCAoDrD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,uCA+CvD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,uCAiClD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,uCAwMjD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,yCAStD"}
package/dist/fs.d.ts ADDED
@@ -0,0 +1,125 @@
1
+ import type { IFileSystem, FsStat, MkdirOptions, RmOptions, CpOptions, FileContent, InitialFiles } from "just-bash/browser";
2
+ /**
3
+ * Supported buffer encodings
4
+ */
5
+ type BufferEncoding = "utf8" | "utf-8" | "ascii" | "binary" | "base64" | "hex" | "latin1";
6
+ /**
7
+ * Options for reading files
8
+ */
9
+ interface ReadFileOptions {
10
+ encoding?: BufferEncoding | null;
11
+ }
12
+ /**
13
+ * Options for writing files
14
+ */
15
+ interface WriteFileOptions {
16
+ encoding?: BufferEncoding;
17
+ }
18
+ /**
19
+ * Directory entry with type information (similar to Node's Dirent)
20
+ */
21
+ interface DirentEntry {
22
+ name: string;
23
+ isFile: boolean;
24
+ isDirectory: boolean;
25
+ isSymbolicLink: boolean;
26
+ }
27
+ /**
28
+ * Options for creating an IndexedDbFs instance
29
+ */
30
+ export interface IndexedDbFsOptions {
31
+ /** Database name in IndexedDB */
32
+ dbName?: string;
33
+ /** Maximum total size in bytes (default: 50MB) */
34
+ maxSizeBytes?: number;
35
+ /** Initial files to populate (only used if DB is empty) */
36
+ initialFiles?: InitialFiles;
37
+ }
38
+ /**
39
+ * In-memory filesystem with IndexedDB persistence.
40
+ * All operations are fast (in-memory), persistence is manual via save().
41
+ */
42
+ export declare class IndexedDbFs implements IFileSystem {
43
+ private entries;
44
+ private db;
45
+ private dbName;
46
+ private maxSizeBytes;
47
+ private dirty;
48
+ private constructor();
49
+ /**
50
+ * Create and initialize a new IndexedDbFs instance
51
+ */
52
+ static create(options?: IndexedDbFsOptions): Promise<IndexedDbFs>;
53
+ /**
54
+ * Create an in-memory only instance (no IndexedDB)
55
+ */
56
+ static createInMemory(options?: Omit<IndexedDbFsOptions, "dbName">): IndexedDbFs;
57
+ /**
58
+ * Save all entries to IndexedDB
59
+ * @returns true if saved, false if no db or not dirty
60
+ */
61
+ save(): Promise<boolean>;
62
+ /**
63
+ * Reload entries from IndexedDB, discarding unsaved changes
64
+ */
65
+ reload(): Promise<void>;
66
+ /**
67
+ * Check if there are unsaved changes
68
+ */
69
+ isDirty(): boolean;
70
+ /**
71
+ * Get approximate size of all stored data in bytes
72
+ */
73
+ getSize(): number;
74
+ /**
75
+ * Close the database connection
76
+ */
77
+ close(): void;
78
+ readFile(path: string, options?: ReadFileOptions | BufferEncoding): Promise<string>;
79
+ readFileBuffer(path: string): Promise<Uint8Array>;
80
+ writeFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
81
+ appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
82
+ exists(path: string): Promise<boolean>;
83
+ stat(path: string): Promise<FsStat>;
84
+ lstat(path: string): Promise<FsStat>;
85
+ mkdir(path: string, options?: MkdirOptions): Promise<void>;
86
+ readdir(path: string): Promise<string[]>;
87
+ readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
88
+ rm(path: string, options?: RmOptions): Promise<void>;
89
+ cp(src: string, dest: string, options?: CpOptions): Promise<void>;
90
+ mv(src: string, dest: string): Promise<void>;
91
+ resolvePath(base: string, path: string): string;
92
+ getAllPaths(): string[];
93
+ chmod(path: string, mode: number): Promise<void>;
94
+ symlink(target: string, linkPath: string): Promise<void>;
95
+ link(existingPath: string, newPath: string): Promise<void>;
96
+ readlink(path: string): Promise<string>;
97
+ realpath(path: string): Promise<string>;
98
+ utimes(path: string, atime: Date, mtime: Date): Promise<void>;
99
+ private normalizePath;
100
+ private static normalizePath;
101
+ private getParentPath;
102
+ private ensureParentDirs;
103
+ private static ensureParentDirs;
104
+ private resolveSymlinks;
105
+ private entryToStat;
106
+ private getContentSize;
107
+ private cloneEntry;
108
+ private checkSizeLimit;
109
+ private getEncoding;
110
+ private decodeBuffer;
111
+ private concatBuffers;
112
+ private static parseFileInit;
113
+ private static openDatabase;
114
+ private static loadEntries;
115
+ private serializeEntry;
116
+ private static deserializeEntry;
117
+ private promisifyRequest;
118
+ private promisifyTransaction;
119
+ }
120
+ /**
121
+ * Factory function matching the FileSystemFactory type
122
+ */
123
+ export declare function createIndexedDbFs(initialFiles?: InitialFiles): IFileSystem;
124
+ export {};
125
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EACN,YAAY,EACZ,SAAS,EACT,SAAS,EACT,WAAW,EACX,YA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AAO,CAAC,oBAAoB;CAM7B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,WAAW,CAI1E"}
@@ -0,0 +1,16 @@
1
+ export { createSandbox, createInMemorySandbox, type Sandbox, type SandboxOptions, } from "./sandbox";
2
+ export { SandboxManager, createSandboxManager, type ManagedSandbox, type ManagedSandboxOptions, type SandboxManagerStats, type SandboxManagerOptions, } from "./sandbox-manager";
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 { TypecheckResult, Diagnostic } from "./typechecker";
7
+ export type { PackageManifest, InstallResult } from "./packages";
8
+ export { initBundler, bundle, bundleToUrl, bundleAndImport, type BundleOptions, type NpmImportsMode, } from "./bundler";
9
+ export { typecheck, formatDiagnostics, formatDiagnosticsForAgent, type TypecheckOptions, } from "./typechecker";
10
+ export { installPackage, uninstallPackage, listPackages, getPackageManifest, type InstallOptions, } from "./packages";
11
+ export { createSharedResources, getDefaultResources, clearDefaultResources, hasDefaultResources, type SharedResourcesOptions, type SharedResources, type TypesCache, } from "./shared-resources";
12
+ export { IndexedDbFs, createIndexedDbFs, type IndexedDbFsOptions, } from "./fs";
13
+ export type { IFileSystem, FsEntry } from "just-bash/browser";
14
+ export { getDefaultBrowserLibs, fetchAndCacheLibs, } from "./ts-libs";
15
+ export { createTscCommand, createBuildCommand, createInstallCommand, createUninstallCommand, createListCommand, createRunCommand, createDefaultCommands, type CommandDeps, type RunContext, type RunOptions, type RunResult, } from "./commands";
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,KAAK,OAAO,EACZ,KAAK,cAAc,GACp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