sandlot 0.1.3 → 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.
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 +2692 -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 +31 -132
  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 +1405 -2049
  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 +2646 -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 +525 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/package.json +27 -8
  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 +526 -43
  50. package/src/commands/types.ts +82 -146
  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 +621 -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 +607 -0
  59. package/src/index.ts +104 -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 +668 -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 -148
  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 -1976
  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 -98
  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 -542
  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 -396
  112. package/src/shared-modules.ts +0 -280
  113. package/src/shared-resources.ts +0 -166
  114. package/src/ts-libs.ts +0 -320
  115. package/src/typechecker.ts +0 -635
@@ -0,0 +1,63 @@
1
+ import { type EsmTypesResolverOptions } from "../core/esm-types-resolver";
2
+ import type { Sandlot, SandlotOptions } from "../types";
3
+ import { type EsbuildWasmBundlerOptions } from "./bundler";
4
+ import { type TypecheckerOptions } from "../core/typechecker";
5
+ import { type MainThreadExecutorOptions } from "./executor";
6
+ export interface CreateBrowserSandlotOptions extends Omit<SandlotOptions, "bundler" | "typechecker" | "typesResolver" | "executor"> {
7
+ /**
8
+ * Custom bundler options, or a pre-configured bundler instance.
9
+ */
10
+ bundler?: EsbuildWasmBundlerOptions | SandlotOptions["bundler"];
11
+ /**
12
+ * Custom typechecker options, or a pre-configured typechecker instance.
13
+ * Set to `false` to disable type checking.
14
+ */
15
+ typechecker?: TypecheckerOptions | SandlotOptions["typechecker"] | false;
16
+ /**
17
+ * Custom types resolver options, or a pre-configured resolver instance.
18
+ * Set to `false` to disable type resolution.
19
+ */
20
+ typesResolver?: EsmTypesResolverOptions | SandlotOptions["typesResolver"] | false;
21
+ /**
22
+ * Custom executor options, or a pre-configured executor instance.
23
+ * Set to `false` to disable execution (sandbox.run() will throw).
24
+ * Defaults to MainThreadExecutor.
25
+ */
26
+ executor?: MainThreadExecutorOptions | SandlotOptions["executor"] | false;
27
+ }
28
+ /**
29
+ * Create a Sandlot instance pre-configured for browser environments.
30
+ *
31
+ * This is a convenience function that sets up sensible defaults:
32
+ * - EsbuildWasmBundler for bundling
33
+ * - Typechecker for type checking
34
+ * - FetchTypesResolver for npm type resolution
35
+ *
36
+ * @example Basic usage
37
+ * ```ts
38
+ * const sandlot = await createBrowserSandlot();
39
+ * const sandbox = await sandlot.createSandbox();
40
+ * ```
41
+ *
42
+ * @example With shared modules
43
+ * ```ts
44
+ * import React from "react";
45
+ * import ReactDOM from "react-dom/client";
46
+ *
47
+ * const sandlot = await createBrowserSandlot({
48
+ * sharedModules: {
49
+ * react: React,
50
+ * "react-dom/client": ReactDOM,
51
+ * },
52
+ * });
53
+ * ```
54
+ *
55
+ * @example Disable type checking for faster builds
56
+ * ```ts
57
+ * const sandlot = await createBrowserSandlot({
58
+ * typechecker: false,
59
+ * });
60
+ * ```
61
+ */
62
+ export declare function createBrowserSandlot(options?: CreateBrowserSandlotOptions): Promise<Sandlot>;
63
+ //# sourceMappingURL=preset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../src/browser/preset.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAsB,KAAK,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,2BACf,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,aAAa,GAAG,eAAe,GAAG,UAAU,CAAC;IACtF;;OAEG;IACH,OAAO,CAAC,EAAE,yBAAyB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAEhE;;;OAGG;IACH,WAAW,CAAC,EACV,kBAAkB,GAClB,cAAc,CAAC,aAAa,CAAC,GAC7B,KAAK,CAAC;IAER;;;OAGG;IACH,aAAa,CAAC,EACZ,uBAAuB,GACvB,cAAc,CAAC,eAAe,CAAC,GAC/B,KAAK,CAAC;IAER;;;;OAIG;IACH,QAAQ,CAAC,EACP,yBAAyB,GACzB,cAAc,CAAC,UAAU,CAAC,GAC1B,KAAK,CAAC;CACT;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,OAAO,CAAC,CAgDlB"}
@@ -1,17 +1,26 @@
1
1
  /**
2
- * Command factories for sandbox bash environments.
2
+ * Command factories for v2 sandbox bash environments.
3
3
  *
4
- * Pure factories that create commands for type checking, bundling,
5
- * package management, and code execution.
6
- * No global state - all dependencies are passed in explicitly.
4
+ * Provides a `sandlot` command with subcommands:
5
+ * - sandlot build Build the project
6
+ * - sandlot typecheck Type check without building
7
+ * - sandlot install Install packages
8
+ * - sandlot uninstall Remove packages
9
+ * - sandlot help Show help
7
10
  */
8
- export { type CommandDeps, type BuildOutput, type ValidateFn, type RunContext, type RunOptions, type RunResult, formatEsbuildMessages, } from "./types";
9
- export { createTscCommand, createBuildCommand } from "./compile";
10
- export { createInstallCommand, createUninstallCommand, createListCommand, } from "./packages";
11
- export { createRunCommand } from "./run";
12
- import type { CommandDeps } from "./types";
11
+ import type { SandboxRef } from "./types";
12
+ export type { SandboxRef } from "./types";
13
+ export { formatSize, formatDiagnostics, formatBundleErrors } from "./types";
13
14
  /**
14
- * Create all default sandbox commands
15
+ * Create the main `sandlot` command with all subcommands.
16
+ *
17
+ * The sandlot command is a dispatcher that routes to subcommand handlers.
18
+ */
19
+ export declare function createSandlotCommand(sandboxRef: SandboxRef): import("just-bash/browser").Command;
20
+ /**
21
+ * Create all default sandbox commands.
22
+ *
23
+ * Currently just the `sandlot` command which dispatches to subcommands.
15
24
  */
16
- export declare function createDefaultCommands(deps: CommandDeps): import("just-bash/browser").Command[];
25
+ export declare function createDefaultCommands(sandboxRef: SandboxRef): import("just-bash/browser").Command[];
17
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,SAAS,EACd,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGjE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAGzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAK3C;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,yCAStD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,uCAuC1D;AAkdD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,yCAE3D"}
@@ -1,141 +1,40 @@
1
1
  /**
2
- * Types and utilities for sandbox bash commands.
3
- */
4
- import type { IFileSystem } from "just-bash/browser";
5
- import type { BundleResult } from "../bundler";
6
- import type { TypesCache } from "../packages";
7
- /**
8
- * The result of a successful build, including the bundle and loaded module.
9
- */
10
- export interface BuildOutput {
11
- /**
12
- * The compiled bundle (code, metadata, etc.)
13
- */
14
- bundle: BundleResult;
15
- /**
16
- * The loaded module exports.
17
- * If validation was provided, this is the validated module.
18
- */
19
- module: Record<string, unknown>;
2
+ * Types and utilities for v2 sandbox bash commands.
3
+ *
4
+ * Commands wrap the sandbox's direct methods to provide a shell interface.
5
+ * This ensures consistency between `sandbox.build()` and `sandbox.exec('sandlot build')`.
6
+ */
7
+ import type { Filesystem, InstallResult, UninstallResult, BuildResult, TypecheckResult, SandboxBuildOptions, SandboxTypecheckOptions, RunOptions, RunResult, BundleError, Diagnostic } from "../types";
8
+ /**
9
+ * Reference to sandbox methods that commands can call.
10
+ *
11
+ * Commands receive this interface rather than raw dependencies,
12
+ * ensuring they use the same logic as direct API calls.
13
+ */
14
+ export interface SandboxRef {
15
+ /** The virtual filesystem */
16
+ readonly fs: Filesystem;
17
+ /** Install a package */
18
+ install(packageSpec: string): Promise<InstallResult>;
19
+ /** Uninstall a package */
20
+ uninstall(packageName: string): Promise<UninstallResult>;
21
+ /** Build the project */
22
+ build(options?: SandboxBuildOptions): Promise<BuildResult>;
23
+ /** Type check the project */
24
+ typecheck(options?: SandboxTypecheckOptions): Promise<TypecheckResult>;
25
+ /** Run code (build + execute) */
26
+ run(options?: RunOptions): Promise<RunResult>;
20
27
  }
21
28
  /**
22
- * Validation function type for module validation.
23
- * Takes the raw module exports and returns validated exports (or throws).
29
+ * Format a file size in bytes to a human-readable string
24
30
  */
25
- export type ValidateFn = (module: Record<string, unknown>) => Record<string, unknown>;
31
+ export declare function formatSize(bytes: number): string;
26
32
  /**
27
- * Dependencies required by command factories
33
+ * Format diagnostics for shell output
28
34
  */
29
- export interface CommandDeps {
30
- /**
31
- * The virtual filesystem to operate on
32
- */
33
- fs: IFileSystem;
34
- /**
35
- * Pre-loaded TypeScript lib files for type checking
36
- */
37
- libFiles: Map<string, string>;
38
- /**
39
- * Path to tsconfig.json in the virtual filesystem
40
- */
41
- tsconfigPath: string;
42
- /**
43
- * Callback invoked when a build succeeds (after loading and validation).
44
- */
45
- onBuild?: (result: BuildOutput) => void | Promise<void>;
46
- /**
47
- * Getter for the current validation function.
48
- * Called during build to check if validation should be performed.
49
- */
50
- getValidation?: () => ValidateFn | null;
51
- /**
52
- * Cache for package type definitions.
53
- * When provided, avoids redundant network fetches for packages
54
- * that have already been installed in other sandboxes.
55
- */
56
- typesCache?: TypesCache;
57
- /**
58
- * Options for the `run` command
59
- */
60
- runOptions?: RunOptions;
61
- /**
62
- * Module IDs that should be resolved from the host's SharedModuleRegistry
63
- * instead of esm.sh CDN. The host must have registered these modules.
64
- *
65
- * Example: ['react', 'react-dom/client']
66
- */
67
- sharedModules?: string[];
68
- }
69
- /**
70
- * Runtime context passed to the `main()` function when code is executed.
71
- * This provides sandboxed code with access to sandbox capabilities.
72
- */
73
- export interface RunContext {
74
- /**
75
- * The virtual filesystem - read/write files within the sandbox
76
- */
77
- fs: IFileSystem;
78
- /**
79
- * Environment variables (configurable per-sandbox)
80
- */
81
- env: Record<string, string>;
82
- /**
83
- * Command-line arguments passed to `run`
84
- */
85
- args: string[];
86
- /**
87
- * Explicit logging function (alternative to console.log)
88
- */
89
- log: (...args: unknown[]) => void;
90
- /**
91
- * Explicit error logging function (alternative to console.error)
92
- */
93
- error: (...args: unknown[]) => void;
94
- }
95
- /**
96
- * Options for configuring the `run` command behavior
97
- */
98
- export interface RunOptions {
99
- /**
100
- * Environment variables available via ctx.env
101
- */
102
- env?: Record<string, string>;
103
- /**
104
- * Maximum execution time in milliseconds (default: 30000 = 30s)
105
- * Set to 0 to disable timeout.
106
- */
107
- timeout?: number;
108
- /**
109
- * Whether to skip type checking before running (default: false)
110
- */
111
- skipTypecheck?: boolean;
112
- }
113
- /**
114
- * Result of running code via the `run` command
115
- */
116
- export interface RunResult {
117
- /**
118
- * Captured console output (log, warn, error)
119
- */
120
- logs: string[];
121
- /**
122
- * Return value from main() if present
123
- */
124
- returnValue?: unknown;
125
- /**
126
- * Execution time in milliseconds
127
- */
128
- executionTimeMs: number;
129
- }
35
+ export declare function formatDiagnostics(diagnostics: Diagnostic[]): string;
130
36
  /**
131
- * Format esbuild messages (warnings/errors) for display
37
+ * Format bundle errors for shell output
132
38
  */
133
- export declare function formatEsbuildMessages(messages: {
134
- text: string;
135
- location?: {
136
- file?: string;
137
- line?: number;
138
- column?: number;
139
- } | null;
140
- }[]): string;
39
+ export declare function formatBundleErrors(errors: BundleError[]): string;
141
40
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,M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,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CAC/C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,CAanE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CA8BhE"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Shared bundler utilities used by both browser and node bundlers.
3
+ *
4
+ * This module contains the VFS plugin, path resolution, and shared module
5
+ * code generation logic that is common to both esbuild and esbuild-wasm.
6
+ */
7
+ import type { ISharedModuleRegistry, BundleWarning, BundleError, Filesystem } from "../types";
8
+ /**
9
+ * Minimal esbuild types needed for the shared utilities.
10
+ * These are compatible with both esbuild and esbuild-wasm.
11
+ */
12
+ export interface EsbuildMessage {
13
+ text: string;
14
+ location?: {
15
+ file: string;
16
+ line: number;
17
+ column: number;
18
+ lineText: string;
19
+ } | null;
20
+ }
21
+ export interface EsbuildPlugin {
22
+ name: string;
23
+ setup: (build: EsbuildPluginBuild) => void;
24
+ }
25
+ export interface EsbuildPluginBuild {
26
+ onResolve: (options: {
27
+ filter: RegExp;
28
+ namespace?: string;
29
+ }, callback: (args: EsbuildResolveArgs) => Promise<EsbuildResolveResult | null | undefined> | EsbuildResolveResult | null | undefined) => void;
30
+ onLoad: (options: {
31
+ filter: RegExp;
32
+ namespace?: string;
33
+ }, callback: (args: EsbuildLoadArgs) => Promise<EsbuildLoadResult | null | undefined> | EsbuildLoadResult | null | undefined) => void;
34
+ }
35
+ export interface EsbuildResolveArgs {
36
+ path: string;
37
+ kind: string;
38
+ resolveDir: string;
39
+ importer: string;
40
+ namespace: string;
41
+ }
42
+ export interface EsbuildResolveResult {
43
+ path?: string;
44
+ namespace?: string;
45
+ external?: boolean;
46
+ errors?: Array<{
47
+ text: string;
48
+ }>;
49
+ }
50
+ export interface EsbuildLoadArgs {
51
+ path: string;
52
+ }
53
+ export interface EsbuildLoadResult {
54
+ contents?: string;
55
+ loader?: string;
56
+ resolveDir?: string;
57
+ errors?: Array<{
58
+ text: string;
59
+ }>;
60
+ }
61
+ export type EsbuildLoader = "js" | "jsx" | "ts" | "tsx" | "json" | "css" | "text";
62
+ /**
63
+ * Type guard for esbuild BuildFailure
64
+ */
65
+ export declare function isEsbuildBuildFailure(err: unknown): err is {
66
+ errors: EsbuildMessage[];
67
+ warnings: EsbuildMessage[];
68
+ };
69
+ /**
70
+ * Convert esbuild Message to our BundleError/BundleWarning format
71
+ */
72
+ export declare function convertEsbuildMessage(msg: EsbuildMessage): BundleError | BundleWarning;
73
+ export interface VfsPluginOptions {
74
+ fs: Filesystem;
75
+ entryPoint: string;
76
+ installedPackages: Record<string, string>;
77
+ sharedModules: Set<string>;
78
+ sharedModuleRegistry: ISharedModuleRegistry | null;
79
+ cdnBaseUrl: string;
80
+ includedFiles: Set<string>;
81
+ /**
82
+ * If true, CDN imports (http/https URLs) will be bundled by esbuild
83
+ * rather than marked as external. This is required for Node/Bun
84
+ * since they cannot resolve HTTP imports at runtime.
85
+ *
86
+ * - Browser: false (external) - browser can fetch at runtime
87
+ * - Node/Bun: true (bundle) - native esbuild fetches during build
88
+ *
89
+ * @default false
90
+ */
91
+ bundleCdnImports?: boolean;
92
+ }
93
+ /**
94
+ * Create an esbuild plugin that reads from a virtual filesystem.
95
+ */
96
+ export declare function createVfsPlugin(options: VfsPluginOptions): EsbuildPlugin;
97
+ /**
98
+ * Check if a path is a bare import (npm package, not relative/absolute)
99
+ */
100
+ export declare function isBareImport(path: string): boolean;
101
+ /**
102
+ * Check if an import matches a shared module.
103
+ * Handles exact matches and subpath imports.
104
+ */
105
+ export declare function matchSharedModule(importPath: string, sharedModules: Set<string>): string | null;
106
+ /**
107
+ * Parse an import path into package name and subpath.
108
+ */
109
+ export declare function parseImportPath(importPath: string): {
110
+ packageName: string;
111
+ subpath?: string;
112
+ };
113
+ /**
114
+ * Resolve a bare import to an esm.sh CDN URL.
115
+ */
116
+ export declare function resolveToEsmUrl(importPath: string, installedPackages: Record<string, string>, cdnBaseUrl: string): string | null;
117
+ /**
118
+ * Resolve a relative or absolute path in the VFS.
119
+ * Tries extensions and index files as needed.
120
+ */
121
+ export declare function resolveVfsPath(fs: Filesystem, resolveDir: string, importPath: string): string | null;
122
+ /**
123
+ * Simple path resolution (handles . and ..)
124
+ */
125
+ export declare function resolvePath(from: string, to: string): string;
126
+ /**
127
+ * Normalize a path (remove . and ..)
128
+ */
129
+ export declare function normalizePath(path: string): string;
130
+ /**
131
+ * Get the directory name of a path
132
+ */
133
+ export declare function dirname(path: string): string;
134
+ /**
135
+ * Get the appropriate esbuild loader based on file extension
136
+ */
137
+ export declare function getLoader(path: string): EsbuildLoader;
138
+ /**
139
+ * Generate JavaScript code that accesses a shared module at runtime.
140
+ */
141
+ export declare function generateSharedModuleCode(moduleId: string, registry: ISharedModuleRegistry | null): string;
142
+ //# sourceMappingURL=bundler-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler-utils.d.ts","sourceRoot":"","sources":["../../src/core/bundler-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,WAAW,EAEX,UAAU,EACX,MAAM,UAAU,CAAC;AAMlB;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI,CAAC;CACV;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAC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e,CAC7B,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAUf;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,UAAU,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAkCf;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAsB5D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAelD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI5C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAqBrD;AAMD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,qBAAqB,GAAG,IAAI,GACrC,MAAM,CAyCR"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Types Resolver - Fetches TypeScript type definitions for npm packages.
3
+ *
4
+ * This is a platform-independent implementation that works anywhere with fetch().
5
+ * (Browser, Node 18+, Bun, Deno, Cloudflare Workers)
6
+ *
7
+ * Design principles:
8
+ * 1. Single responsibility: resolve package → types. No VFS writing.
9
+ * 2. CDN-agnostic interface with esm.sh implementation
10
+ * 3. Transparent @types fallback (caller doesn't need to know)
11
+ * 4. Subpaths resolved on-demand, not pre-fetched
12
+ * 5. Caching is external/injectable (platform-specific cache implementations)
13
+ */
14
+ import type { ITypesResolver } from "../types";
15
+ /**
16
+ * Resolved type definitions for a package.
17
+ */
18
+ export interface ResolvedTypes {
19
+ /**
20
+ * The package name (may differ from request if @types fallback was used)
21
+ */
22
+ packageName: string;
23
+ /**
24
+ * The resolved version
25
+ */
26
+ version: string;
27
+ /**
28
+ * Map of relative file paths to content.
29
+ * Paths are relative to the package root (e.g., "index.d.ts", "utils.d.ts")
30
+ */
31
+ files: Record<string, string>;
32
+ /**
33
+ * Whether types came from @types/* package
34
+ */
35
+ fromTypesPackage: boolean;
36
+ }
37
+ /**
38
+ * Cache interface for type definitions.
39
+ * Implementations can be in-memory, IndexedDB, KV store, filesystem, etc.
40
+ */
41
+ export interface ITypesCache {
42
+ get(key: string): Promise<ResolvedTypes | null>;
43
+ set(key: string, value: ResolvedTypes): Promise<void>;
44
+ has(key: string): Promise<boolean>;
45
+ }
46
+ /**
47
+ * Simple in-memory cache implementation.
48
+ * Works on all platforms.
49
+ */
50
+ export declare class InMemoryTypesCache implements ITypesCache {
51
+ private cache;
52
+ get(key: string): Promise<ResolvedTypes | null>;
53
+ set(key: string, value: ResolvedTypes): Promise<void>;
54
+ has(key: string): Promise<boolean>;
55
+ clear(): void;
56
+ }
57
+ export interface EsmTypesResolverOptions {
58
+ /**
59
+ * Base URL for esm.sh (default: "https://esm.sh")
60
+ */
61
+ baseUrl?: string;
62
+ /**
63
+ * External cache. If not provided, no caching is done.
64
+ * This allows sharing cache across resolver instances.
65
+ */
66
+ cache?: ITypesCache;
67
+ /**
68
+ * Whether to try @types/* packages as fallback when main package
69
+ * doesn't have bundled types. Default: true
70
+ */
71
+ tryTypesPackages?: boolean;
72
+ }
73
+ /**
74
+ * Types resolver using esm.sh CDN.
75
+ *
76
+ * Platform-independent - works anywhere with fetch().
77
+ *
78
+ * Resolution strategy:
79
+ * 1. Fetch package from esm.sh, check X-TypeScript-Types header
80
+ * 2. If no types, try @types/{package} as fallback
81
+ * 3. Fetch .d.ts files and any /// <reference> dependencies
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * const resolver = new EsmTypesResolver();
86
+ *
87
+ * // Resolve types for a package
88
+ * const types = await resolver.resolve("lodash", "4.17.21");
89
+ * // types.files: { "index.d.ts": "...", "common.d.ts": "..." }
90
+ *
91
+ * // Resolve subpath types
92
+ * const clientTypes = await resolver.resolve("react-dom/client", "18.2.0");
93
+ * ```
94
+ */
95
+ export declare class EsmTypesResolver implements ITypesResolver {
96
+ private baseUrl;
97
+ private cache;
98
+ private tryTypesPackages;
99
+ constructor(options?: EsmTypesResolverOptions);
100
+ /**
101
+ * Resolve type definitions for a package.
102
+ *
103
+ * @param specifier - Package specifier with optional subpath (e.g., "react", "react-dom/client")
104
+ * @param version - Optional version constraint
105
+ * @returns Map of file paths to content, or empty object if no types found
106
+ */
107
+ resolveTypes(specifier: string, version?: string): Promise<Record<string, string>>;
108
+ /**
109
+ * Resolve with full metadata (useful for advanced use cases).
110
+ */
111
+ resolve(specifier: string, version?: string): Promise<ResolvedTypes | null>;
112
+ /**
113
+ * Attempt to resolve types for a specific package.
114
+ */
115
+ private tryResolve;
116
+ /**
117
+ * Fetch a .d.ts file and any files it references.
118
+ */
119
+ private fetchTypesRecursively;
120
+ /**
121
+ * Extract the resolved version from the response.
122
+ */
123
+ private extractVersion;
124
+ }
125
+ //# sourceMappingURL=esm-types-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esm-types-resolver.d.ts","sourceRoot":"","sources":["../../src/core/esm-types-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM/C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9B;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;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ACH,OAAO,CAAC,cAAc;CAuBvB"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Base executor implementation shared by browser and node executors.
3
+ *
4
+ * This module provides the core execution logic with console capture,
5
+ * timeout handling, and export invocation. Platform-specific executors
6
+ * only need to provide a function to load code as a module.
7
+ */
8
+ import type { IExecutor } from "../types";
9
+ /**
10
+ * Function that loads JavaScript code as a module.
11
+ * Platform-specific implementations convert code to an importable URL.
12
+ */
13
+ export type ModuleLoader = (code: string) => Promise<Record<string, unknown>>;
14
+ /**
15
+ * Options for creating a basic executor.
16
+ */
17
+ export interface BasicExecutorOptions {
18
+ /**
19
+ * Default timeout in milliseconds.
20
+ * @default 30000
21
+ */
22
+ defaultTimeout?: number;
23
+ }
24
+ /**
25
+ * Create an executor using the provided module loader.
26
+ *
27
+ * This is the shared implementation used by both browser and node executors.
28
+ * The only platform-specific part is how code is loaded as a module.
29
+ *
30
+ * @param loadModule - Function that loads code as a module
31
+ * @param options - Executor options
32
+ * @returns An executor instance
33
+ */
34
+ export declare function createBasicExecutor(loadModule: ModuleLoader, options?: BasicExecutorOptions): IExecutor;
35
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/core/executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAiC,MAAM,UAAU,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,YAAY,EACxB,OAAO,GAAE,oBAAyB,GACjC,SAAS,CAwHX"}