sandboxedjs 0.1.44 → 0.1.45

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.
package/dist/index.d.cts CHANGED
@@ -1451,6 +1451,20 @@ interface PreviewOptions {
1451
1451
  scriptUrl?: string | URL;
1452
1452
  /** Registration scope. Must be able to see the paths a preview will request. */
1453
1453
  scope?: string;
1454
+ /**
1455
+ * The dev server has invalidated what the frame is holding; reload it.
1456
+ *
1457
+ * Vite serves `504 Outdated Optimize Dep` once the hash in a dependency URL
1458
+ * no longer matches — after its optimizer re-runs, or after the server is
1459
+ * restarted. Its own client recovers by reloading, and hears about it over
1460
+ * the HMR WebSocket, which this bridge does not carry. Without a reload the
1461
+ * frame keeps asking for a hash the server has forgotten and the app never
1462
+ * mounts.
1463
+ *
1464
+ * Reloading is the host's call because the host owns the frame: it can pick
1465
+ * the moment, and it can stop after a few attempts rather than looping.
1466
+ */
1467
+ onStale?: () => void;
1454
1468
  }
1455
1469
  interface Preview {
1456
1470
  /** The URL an iframe should be pointed at to see `port`. */
package/dist/index.d.ts CHANGED
@@ -1451,6 +1451,20 @@ interface PreviewOptions {
1451
1451
  scriptUrl?: string | URL;
1452
1452
  /** Registration scope. Must be able to see the paths a preview will request. */
1453
1453
  scope?: string;
1454
+ /**
1455
+ * The dev server has invalidated what the frame is holding; reload it.
1456
+ *
1457
+ * Vite serves `504 Outdated Optimize Dep` once the hash in a dependency URL
1458
+ * no longer matches — after its optimizer re-runs, or after the server is
1459
+ * restarted. Its own client recovers by reloading, and hears about it over
1460
+ * the HMR WebSocket, which this bridge does not carry. Without a reload the
1461
+ * frame keeps asking for a hash the server has forgotten and the app never
1462
+ * mounts.
1463
+ *
1464
+ * Reloading is the host's call because the host owns the frame: it can pick
1465
+ * the moment, and it can stop after a few attempts rather than looping.
1466
+ */
1467
+ onStale?: () => void;
1454
1468
  }
1455
1469
  interface Preview {
1456
1470
  /** The URL an iframe should be pointed at to see `port`. */
package/dist/index.js CHANGED
@@ -28803,7 +28803,9 @@ async function createPreview(box, options = {}) {
28803
28803
  target.postMessage({ type: "sandboxedjs:connect" }, [channel.port2]);
28804
28804
  };
28805
28805
  const onWorkerMessage = (event) => {
28806
- if (event.data?.type === "sandboxedjs:host-needed") connect();
28806
+ const type = event.data?.type;
28807
+ if (type === "sandboxedjs:host-needed") connect();
28808
+ if (type === "sandboxedjs:stale") options.onStale?.();
28807
28809
  };
28808
28810
  navigator.serviceWorker.addEventListener("message", onWorkerMessage);
28809
28811
  connect();