sandlot 0.2.0 → 0.2.2

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 (51) hide show
  1. package/dist/browser/bundler.d.ts +8 -0
  2. package/dist/browser/bundler.d.ts.map +1 -1
  3. package/dist/browser/iframe-executor.d.ts +82 -0
  4. package/dist/browser/iframe-executor.d.ts.map +1 -0
  5. package/dist/browser/index.d.ts +4 -2
  6. package/dist/browser/index.d.ts.map +1 -1
  7. package/dist/browser/index.js +249 -55
  8. package/dist/browser/main-thread-executor.d.ts +46 -0
  9. package/dist/browser/main-thread-executor.d.ts.map +1 -0
  10. package/dist/browser/preset.d.ts +7 -2
  11. package/dist/browser/preset.d.ts.map +1 -1
  12. package/dist/commands/index.d.ts +1 -1
  13. package/dist/commands/index.d.ts.map +1 -1
  14. package/dist/commands/types.d.ts +9 -1
  15. package/dist/commands/types.d.ts.map +1 -1
  16. package/dist/core/executor.d.ts.map +1 -1
  17. package/dist/core/sandbox.d.ts.map +1 -1
  18. package/dist/core/sandlot.d.ts.map +1 -1
  19. package/dist/core/typechecker.d.ts.map +1 -1
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +50 -46
  23. package/dist/node/bundler.d.ts +5 -0
  24. package/dist/node/bundler.d.ts.map +1 -1
  25. package/dist/node/index.d.ts +2 -0
  26. package/dist/node/index.d.ts.map +1 -1
  27. package/dist/node/index.js +218 -54
  28. package/dist/node/preset.d.ts +16 -1
  29. package/dist/node/preset.d.ts.map +1 -1
  30. package/dist/node/wasm-bundler.d.ts +86 -0
  31. package/dist/node/wasm-bundler.d.ts.map +1 -0
  32. package/dist/types.d.ts +35 -7
  33. package/dist/types.d.ts.map +1 -1
  34. package/package.json +1 -1
  35. package/src/browser/bundler.ts +17 -0
  36. package/src/browser/iframe-executor.ts +320 -0
  37. package/src/browser/index.ts +9 -2
  38. package/src/browser/preset.ts +30 -6
  39. package/src/commands/index.ts +18 -40
  40. package/src/commands/types.ts +36 -0
  41. package/src/core/executor.ts +8 -7
  42. package/src/core/sandbox.ts +3 -0
  43. package/src/core/sandlot.ts +7 -0
  44. package/src/core/typechecker.ts +4 -2
  45. package/src/index.ts +2 -0
  46. package/src/node/bundler.ts +11 -0
  47. package/src/node/index.ts +10 -0
  48. package/src/node/preset.ts +59 -5
  49. package/src/node/wasm-bundler.ts +299 -0
  50. package/src/types.ts +38 -7
  51. /package/src/browser/{executor.ts → main-thread-executor.ts} +0 -0
package/src/types.ts CHANGED
@@ -22,6 +22,12 @@ export interface IBundler {
22
22
  * Bundle source files from a filesystem into a single output
23
23
  */
24
24
  bundle(options: BundleOptions): Promise<BundleResult>;
25
+
26
+ /**
27
+ * Dispose of resources held by the bundler (optional).
28
+ * Called by Sandlot.dispose() to clean up background services.
29
+ */
30
+ dispose?(): Promise<void>;
25
31
  }
26
32
 
27
33
  export interface BundleOptions {
@@ -366,8 +372,11 @@ export interface BuildSuccess {
366
372
  warnings: BundleWarning[];
367
373
  }
368
374
 
369
- export interface BuildFailure {
370
- success: false;
375
+ /**
376
+ * Details about why a build failed.
377
+ * Used by both BuildResult and RunResult.
378
+ */
379
+ export interface BuildFailureDetails {
371
380
  /** Which phase of the build failed */
372
381
  phase: BuildPhase;
373
382
  /** Error message (for entry failures) */
@@ -380,6 +389,10 @@ export interface BuildFailure {
380
389
  bundleWarnings?: BundleWarning[];
381
390
  }
382
391
 
392
+ export interface BuildFailure extends BuildFailureDetails {
393
+ success: false;
394
+ }
395
+
383
396
 
384
397
  // -----------------------------------------------------------------------------
385
398
  // Install/Uninstall Types
@@ -500,11 +513,8 @@ export interface RunOptions {
500
513
  * If `buildFailure` is present, the build failed before execution.
501
514
  */
502
515
  export interface RunResult extends ExecuteResult {
503
- /** If build failed, contains failure details */
504
- buildFailure?: {
505
- phase: BuildPhase;
506
- message?: string;
507
- };
516
+ /** If build failed, contains failure details (same structure as BuildFailure) */
517
+ buildFailure?: BuildFailureDetails;
508
518
  }
509
519
 
510
520
  // -----------------------------------------------------------------------------
@@ -665,4 +675,25 @@ export interface Sandlot {
665
675
  * The shared module registry (if shared modules were provided)
666
676
  */
667
677
  readonly sharedModules: ISharedModuleRegistry | null;
678
+
679
+ /**
680
+ * Dispose of resources held by this Sandlot instance.
681
+ *
682
+ * This should be called when you're done using Sandlot to allow
683
+ * the process to exit cleanly. It stops any background services
684
+ * like the esbuild child process.
685
+ *
686
+ * After calling dispose(), this instance should not be used.
687
+ *
688
+ * @example
689
+ * ```ts
690
+ * const sandlot = await createNodeSandlot();
691
+ * const sandbox = await sandlot.createSandbox();
692
+ *
693
+ * // ... do work ...
694
+ *
695
+ * await sandlot.dispose(); // Allow process to exit
696
+ * ```
697
+ */
698
+ dispose(): Promise<void>;
668
699
  }