@tokenoftrust/storefront-runner 6.12.14 → 6.12.15
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.
|
@@ -38,11 +38,34 @@ export function buildPreviewReloadScript(opts: {
|
|
|
38
38
|
const pollMs = Math.max(250, Math.floor(opts.pollMs ?? DEFAULT_POLL_MS));
|
|
39
39
|
// The version endpoint is fetched UNDER basePath so the same tenant-routing the
|
|
40
40
|
// page used resolves it (path-routed previews carry a /<domain> prefix).
|
|
41
|
+
// Draft hold: an unsent preview annotation draft (preview/annotations/reloadHold.ts) registers a
|
|
42
|
+
// hold in window.__totPreviewHolds. While any hold exists a newer version is recorded as pending
|
|
43
|
+
// and announced with "tot:preview-update-available" instead of reloading; the reload happens
|
|
44
|
+
// only once the last hold is released (submit, discard or close). Nothing is ever submitted on
|
|
45
|
+
// the way out.
|
|
41
46
|
return `(() => {
|
|
42
47
|
const TENANT = ${tenant}, BASE = ${base}, POLL_MS = ${pollMs};
|
|
43
48
|
const url = BASE + "/api/preview/version?tenant=" + encodeURIComponent(TENANT);
|
|
44
49
|
let known = null;
|
|
45
50
|
let timer = null;
|
|
51
|
+
const holdBag = () => {
|
|
52
|
+
let bag = window.__totPreviewHolds;
|
|
53
|
+
if (!bag || !(bag.holds instanceof Set)) { bag = { holds: new Set(), pending: false }; window.__totPreviewHolds = bag; }
|
|
54
|
+
return bag;
|
|
55
|
+
};
|
|
56
|
+
const reloadUnlessHeld = () => {
|
|
57
|
+
const bag = holdBag();
|
|
58
|
+
if (bag.holds.size > 0) {
|
|
59
|
+
if (!bag.pending) { bag.pending = true; window.dispatchEvent(new CustomEvent("tot:preview-update-available")); }
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
location.reload();
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
65
|
+
window.addEventListener("tot:preview-hold-change", () => {
|
|
66
|
+
const bag = holdBag();
|
|
67
|
+
if (bag.pending && bag.holds.size === 0) location.reload();
|
|
68
|
+
});
|
|
46
69
|
// A hidden tab cannot see a reload, so polling it is pure waste — and an
|
|
47
70
|
// unconditional once-a-second fetch leaves the tab in perpetual network
|
|
48
71
|
// activity, which reads to a reviewer as a preview that never finishes
|
|
@@ -80,7 +103,7 @@ export function buildPreviewReloadScript(opts: {
|
|
|
80
103
|
// TODO(theme-hot-swap): when the change is theme-only, swap the CSS custom
|
|
81
104
|
// properties in place (no reload). Needs the reconcile to report a
|
|
82
105
|
// theme-only delta; gated behind this same version signal until then.
|
|
83
|
-
else if (v !== known) {
|
|
106
|
+
else if (v !== known) { if (reloadUnlessHeld()) return; }
|
|
84
107
|
}
|
|
85
108
|
} catch (_e) { /* offline / aborted — genuinely transient, keep the cadence */ }
|
|
86
109
|
schedule();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.15",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|