@immediately-run/sandpack-client 2.20.0 → 2.21.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandpack-client",
3
- "version": "2.20.0",
4
- "srcHash": "57b49235f4e6081897281fd4eab0848c2ee977d626606f235444047099739d79",
5
- "builtAt": "2026-07-13T20:11:14.027Z"
3
+ "version": "2.21.0",
4
+ "srcHash": "afbc7e1f72ab14999158254aba8d870baf59194b341b07fe89ea866277efaf8d",
5
+ "builtAt": "2026-07-31T18:21:27.125Z"
6
6
  }
@@ -2,9 +2,9 @@
2
2
 
3
3
  var utils = require('../../utils-BiVyytui.js');
4
4
  var nodebox = require('@codesandbox/nodebox');
5
- require('../../types-mAM6HBIz.js');
5
+ require('../../types-KEkDKvIe.js');
6
6
  var base = require('../../base-DelKLlDk.js');
7
- var consoleHook = require('../../consoleHook-Dva85ENr.js');
7
+ var consoleHook = require('../../consoleHook-BRSVCdB0.js');
8
8
  require('outvariant');
9
9
  require('@zenfs/core');
10
10
  require('dequal');
@@ -1,8 +1,8 @@
1
1
  import { _ as __awaiter, a as __generator, f as nullthrows, c as createError, g as __extends, h as __assign } from '../../utils-DG1HA4RZ.mjs';
2
2
  import { INJECT_MESSAGE_TYPE, Nodebox, PREVIEW_LOADED_MESSAGE_TYPE } from '@codesandbox/nodebox';
3
- import '../../types-DR29do3R.mjs';
3
+ import '../../types-BgalzxpH.mjs';
4
4
  import { S as SandpackClient } from '../../base-DBh7xJX9.mjs';
5
- import { c as consoleHook, g as generateRandomId, E as EventEmitter, a as getMessageFromError, f as findStartScriptPackageJson } from '../../consoleHook-vOAHXvaX.mjs';
5
+ import { c as consoleHook, g as generateRandomId, E as EventEmitter, a as getMessageFromError, f as findStartScriptPackageJson } from '../../consoleHook-BYuGaxe8.mjs';
6
6
  import 'outvariant';
7
7
  import '@zenfs/core';
8
8
  import 'dequal';
@@ -2,7 +2,7 @@
2
2
 
3
3
  var utils = require('../../utils-BiVyytui.js');
4
4
  var dequal = require('dequal');
5
- var types = require('../../types-mAM6HBIz.js');
5
+ var types = require('../../types-KEkDKvIe.js');
6
6
  var base = require('../../base-DelKLlDk.js');
7
7
  var iframeFactory = require('../../iframe-factory-Bc7tcyQZ.js');
8
8
  var mimeDB = require('mime-db');
@@ -530,7 +530,7 @@ function getExtension(filepath) {
530
530
 
531
531
  var _a;
532
532
  var SUFFIX_PLACEHOLDER = "-{{suffix}}";
533
- var BUNDLER_URL = "https://".concat((_a = "2.20.0") === null || _a === void 0 ? void 0 : _a.replace(/\./g, "-")).concat(SUFFIX_PLACEHOLDER, "-sandpack.codesandbox.io/");
533
+ var BUNDLER_URL = "https://".concat((_a = "2.21.0") === null || _a === void 0 ? void 0 : _a.replace(/\./g, "-")).concat(SUFFIX_PLACEHOLDER, "-sandpack.codesandbox.io/");
534
534
  var SandpackRuntime = /** @class */ (function (_super) {
535
535
  utils.__extends(SandpackRuntime, _super);
536
536
  function SandpackRuntime(selector, sandboxSetup, options) {
@@ -1,6 +1,6 @@
1
1
  import { _ as __awaiter, a as __generator, h as __assign, i as __rest, j as __spreadArray, g as __extends, f as nullthrows, e as extractErrorDetails, c as createError, d as createPackageJSON } from '../../utils-DG1HA4RZ.mjs';
2
2
  import { dequal } from 'dequal';
3
- import { a as SandpackLogLevel } from '../../types-DR29do3R.mjs';
3
+ import { a as SandpackLogLevel } from '../../types-BgalzxpH.mjs';
4
4
  import { S as SandpackClient } from '../../base-DBh7xJX9.mjs';
5
5
  import { c as createSandboxedIframe, e as ensureSandboxed } from '../../iframe-factory-C8M0b9uf.mjs';
6
6
  import mimeDB from 'mime-db';
@@ -528,7 +528,7 @@ function getExtension(filepath) {
528
528
 
529
529
  var _a;
530
530
  var SUFFIX_PLACEHOLDER = "-{{suffix}}";
531
- var BUNDLER_URL = "https://".concat((_a = "2.20.0") === null || _a === void 0 ? void 0 : _a.replace(/\./g, "-")).concat(SUFFIX_PLACEHOLDER, "-sandpack.codesandbox.io/");
531
+ var BUNDLER_URL = "https://".concat((_a = "2.21.0") === null || _a === void 0 ? void 0 : _a.replace(/\./g, "-")).concat(SUFFIX_PLACEHOLDER, "-sandpack.codesandbox.io/");
532
532
  var SandpackRuntime = /** @class */ (function (_super) {
533
533
  __extends(SandpackRuntime, _super);
534
534
  function SandpackRuntime(selector, sandboxSetup, options) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  var outvariant = require('outvariant');
4
4
  var utils = require('./utils-BiVyytui.js');
5
- require('./types-mAM6HBIz.js');
5
+ require('./types-KEkDKvIe.js');
6
6
 
7
7
  var EventEmitter = /** @class */ (function () {
8
8
  function EventEmitter() {
@@ -1,6 +1,6 @@
1
1
  import { invariant } from 'outvariant';
2
2
  import { c as createError } from './utils-DG1HA4RZ.mjs';
3
- import './types-DR29do3R.mjs';
3
+ import './types-BgalzxpH.mjs';
4
4
 
5
5
  var EventEmitter = /** @class */ (function () {
6
6
  function EventEmitter() {
@@ -69,6 +69,10 @@ export declare class SandpackFS {
69
69
  private sidecarEnvironment;
70
70
  private sidecarMode;
71
71
  private disposed;
72
+ /** The ZenFS mount point this instance created and is therefore allowed to
73
+ * unmount in {@link dispose}. Unset for an adopted context, whose lifecycle
74
+ * belongs to the caller. */
75
+ private ownedMountPoint;
72
76
  private readonly rawWriteFile;
73
77
  private readonly rawUnlink;
74
78
  private readonly rawMkdir;
@@ -122,6 +126,16 @@ export declare class SandpackFS {
122
126
  * reflect it — distinct from local edits, which never reach here.
123
127
  */
124
128
  handleRemoteChange(path: string): void;
129
+ /**
130
+ * Tear this instance down: drop every subscriber, stop emitting changes, and
131
+ * release the ZenFS mount if we created it ({@link fromFiles}). An *adopted*
132
+ * context ({@link fromFileSystemContext}) is left mounted — its lifecycle
133
+ * belongs to the caller.
134
+ *
135
+ * ZenFS mounts live in a process-global table, so an instance that is never
136
+ * disposed keeps its backing store alive for the page's lifetime. Idempotent.
137
+ */
138
+ dispose(): void;
125
139
  private toAbs;
126
140
  private notify;
127
141
  private ensureMetaDir;
@@ -1,10 +1,10 @@
1
1
  import { g as __extends, h as __assign, _ as __awaiter, a as __generator } from './utils-DG1HA4RZ.mjs';
2
2
  import { PreviewController } from 'static-browser-server';
3
- import { E as EventEmitter, g as generateRandomId, c as consoleHook } from './consoleHook-vOAHXvaX.mjs';
3
+ import { E as EventEmitter, g as generateRandomId, c as consoleHook } from './consoleHook-BYuGaxe8.mjs';
4
4
  import { S as SandpackClient } from './base-DBh7xJX9.mjs';
5
5
  import { c as createSandboxedIframe, e as ensureSandboxed } from './iframe-factory-C8M0b9uf.mjs';
6
6
  import 'outvariant';
7
- import './types-DR29do3R.mjs';
7
+ import './types-BgalzxpH.mjs';
8
8
  import '@zenfs/core';
9
9
  import 'dequal';
10
10
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  var utils = require('./utils-BiVyytui.js');
4
4
  var staticBrowserServer = require('static-browser-server');
5
- var consoleHook = require('./consoleHook-Dva85ENr.js');
5
+ var consoleHook = require('./consoleHook-BRSVCdB0.js');
6
6
  var base = require('./base-DelKLlDk.js');
7
7
  var iframeFactory = require('./iframe-factory-Bc7tcyQZ.js');
8
8
  require('outvariant');
9
- require('./types-mAM6HBIz.js');
9
+ require('./types-KEkDKvIe.js');
10
10
  require('@zenfs/core');
11
11
  require('dequal');
12
12
 
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('./utils-BiVyytui.js');
4
- var types = require('./types-mAM6HBIz.js');
4
+ var types = require('./types-KEkDKvIe.js');
5
5
  require('outvariant');
6
6
  require('@zenfs/core');
7
7
 
@@ -24,7 +24,7 @@ function loadSandpackClient(iframeSelector_1, sandboxSetup_1) {
24
24
  case 2:
25
25
  Client = _c.sent();
26
26
  return [3 /*break*/, 7];
27
- case 3: return [4 /*yield*/, Promise.resolve().then(function () { return require('./index-DWUK0Qhn.js'); }).then(function (m) { return m.SandpackStatic; })];
27
+ case 3: return [4 /*yield*/, Promise.resolve().then(function () { return require('./index-dX5nvjo5.js'); }).then(function (m) { return m.SandpackStatic; })];
28
28
  case 4:
29
29
  Client = _c.sent();
30
30
  return [3 /*break*/, 7];
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { _ as __awaiter, a as __generator } from './utils-DG1HA4RZ.mjs';
2
2
  export { b as addPackageJSONIfNeededToMap, c as createError, d as createPackageJSON, e as extractErrorDetails, n as normalizePath, f as nullthrows } from './utils-DG1HA4RZ.mjs';
3
- export { M as META_PATH, S as SandpackFS, a as SandpackLogLevel } from './types-DR29do3R.mjs';
3
+ export { M as META_PATH, S as SandpackFS, a as SandpackLogLevel } from './types-BgalzxpH.mjs';
4
4
  import 'outvariant';
5
5
  import '@zenfs/core';
6
6
 
@@ -23,7 +23,7 @@ function loadSandpackClient(iframeSelector_1, sandboxSetup_1) {
23
23
  case 2:
24
24
  Client = _c.sent();
25
25
  return [3 /*break*/, 7];
26
- case 3: return [4 /*yield*/, import('./index-Bg_0g5j2.mjs').then(function (m) { return m.SandpackStatic; })];
26
+ case 3: return [4 /*yield*/, import('./index-CetxPB1x.mjs').then(function (m) { return m.SandpackStatic; })];
27
27
  case 4:
28
28
  Client = _c.sent();
29
29
  return [3 /*break*/, 7];
@@ -1,5 +1,5 @@
1
1
  import { _ as __awaiter, a as __generator, h as __assign } from './utils-DG1HA4RZ.mjs';
2
- import { mount, bindContext, resolveMountConfig, InMemory } from '@zenfs/core';
2
+ import { umount, mount, bindContext, resolveMountConfig, InMemory } from '@zenfs/core';
3
3
 
4
4
  /**
5
5
  * Path (within the SandpackFS) of the sidecar metadata file. Anything below
@@ -113,6 +113,10 @@ var SandpackFS = /** @class */ (function () {
113
113
  this.sidecarEnvironment = undefined;
114
114
  this.sidecarMode = undefined;
115
115
  this.disposed = false;
116
+ /** The ZenFS mount point this instance created and is therefore allowed to
117
+ * unmount in {@link dispose}. Unset for an adopted context, whose lifecycle
118
+ * belongs to the caller. */
119
+ this.ownedMountPoint = undefined;
116
120
  var p = fsContext.fs.promises;
117
121
  this.rawWriteFile = p.writeFile.bind(p);
118
122
  this.rawUnlink = p.unlink.bind(p);
@@ -150,6 +154,9 @@ var SandpackFS = /** @class */ (function () {
150
154
  mount(prefix, backend);
151
155
  ctxt = bindContext({ root: prefix });
152
156
  instance = new SandpackFS(ctxt, remotePortFactory, onWrite);
157
+ // We created the mount, so we own it: `dispose()` may unmount it. An adopted
158
+ // context (`fromFileSystemContext`) leaves this unset and is never unmounted.
159
+ instance.ownedMountPoint = prefix;
153
160
  if (options.environment !== undefined) {
154
161
  instance.sidecarEnvironment = options.environment;
155
162
  }
@@ -381,6 +388,30 @@ var SandpackFS = /** @class */ (function () {
381
388
  return;
382
389
  this.notify({ path: normalize(path), external: true });
383
390
  };
391
+ /**
392
+ * Tear this instance down: drop every subscriber, stop emitting changes, and
393
+ * release the ZenFS mount if we created it ({@link fromFiles}). An *adopted*
394
+ * context ({@link fromFileSystemContext}) is left mounted — its lifecycle
395
+ * belongs to the caller.
396
+ *
397
+ * ZenFS mounts live in a process-globalThis table, so an instance that is never
398
+ * disposed keeps its backing store alive for the page's lifetime. Idempotent.
399
+ */
400
+ SandpackFS.prototype.dispose = function () {
401
+ if (this.disposed)
402
+ return;
403
+ this.disposed = true;
404
+ this.listeners.clear();
405
+ if (this.ownedMountPoint) {
406
+ try {
407
+ umount(this.ownedMountPoint);
408
+ }
409
+ catch (_a) {
410
+ /* already unmounted — disposal must never throw */
411
+ }
412
+ this.ownedMountPoint = undefined;
413
+ }
414
+ };
384
415
  // ------------------------------------------------------------------
385
416
  // Internals
386
417
  // ------------------------------------------------------------------
@@ -115,6 +115,10 @@ var SandpackFS = /** @class */ (function () {
115
115
  this.sidecarEnvironment = undefined;
116
116
  this.sidecarMode = undefined;
117
117
  this.disposed = false;
118
+ /** The ZenFS mount point this instance created and is therefore allowed to
119
+ * unmount in {@link dispose}. Unset for an adopted context, whose lifecycle
120
+ * belongs to the caller. */
121
+ this.ownedMountPoint = undefined;
118
122
  var p = fsContext.fs.promises;
119
123
  this.rawWriteFile = p.writeFile.bind(p);
120
124
  this.rawUnlink = p.unlink.bind(p);
@@ -152,6 +156,9 @@ var SandpackFS = /** @class */ (function () {
152
156
  core.mount(prefix, backend);
153
157
  ctxt = core.bindContext({ root: prefix });
154
158
  instance = new SandpackFS(ctxt, remotePortFactory, onWrite);
159
+ // We created the mount, so we own it: `dispose()` may unmount it. An adopted
160
+ // context (`fromFileSystemContext`) leaves this unset and is never unmounted.
161
+ instance.ownedMountPoint = prefix;
155
162
  if (options.environment !== undefined) {
156
163
  instance.sidecarEnvironment = options.environment;
157
164
  }
@@ -383,6 +390,30 @@ var SandpackFS = /** @class */ (function () {
383
390
  return;
384
391
  this.notify({ path: normalize(path), external: true });
385
392
  };
393
+ /**
394
+ * Tear this instance down: drop every subscriber, stop emitting changes, and
395
+ * release the ZenFS mount if we created it ({@link fromFiles}). An *adopted*
396
+ * context ({@link fromFileSystemContext}) is left mounted — its lifecycle
397
+ * belongs to the caller.
398
+ *
399
+ * ZenFS mounts live in a process-globalThis table, so an instance that is never
400
+ * disposed keeps its backing store alive for the page's lifetime. Idempotent.
401
+ */
402
+ SandpackFS.prototype.dispose = function () {
403
+ if (this.disposed)
404
+ return;
405
+ this.disposed = true;
406
+ this.listeners.clear();
407
+ if (this.ownedMountPoint) {
408
+ try {
409
+ core.umount(this.ownedMountPoint);
410
+ }
411
+ catch (_a) {
412
+ /* already unmounted — disposal must never throw */
413
+ }
414
+ this.ownedMountPoint = undefined;
415
+ }
416
+ };
386
417
  // ------------------------------------------------------------------
387
418
  // Internals
388
419
  // ------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@immediately-run/sandpack-client",
3
- "version": "2.20.0",
3
+ "version": "2.21.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {