@the-portland-company/shell 0.104.0 → 0.105.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.
- package/dist/app-chrome.cjs +144 -2
- package/dist/app-chrome.cjs.map +1 -1
- package/dist/app-chrome.js +144 -2
- package/dist/app-chrome.js.map +1 -1
- package/package.json +1 -1
package/dist/app-chrome.cjs
CHANGED
|
@@ -4332,6 +4332,145 @@ function writeUrlState(current, patch) {
|
|
|
4332
4332
|
}
|
|
4333
4333
|
return buildSearch(state);
|
|
4334
4334
|
}
|
|
4335
|
+
var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
4336
|
+
var UPDATE_FOCUS_MIN_GAP_MS = 60 * 1e3;
|
|
4337
|
+
var UPDATE_MAX_BACKOFF_MS = 30 * 60 * 1e3;
|
|
4338
|
+
var isProductionHost = (hostname) => hostname === "politogyvrm.com" || hostname.endsWith(".politogyvrm.com");
|
|
4339
|
+
function scriptSignature(html) {
|
|
4340
|
+
const srcs = /* @__PURE__ */ new Set();
|
|
4341
|
+
const re = /<script\b[^>]*\bsrc=["']([^"']+)["']/gi;
|
|
4342
|
+
let m;
|
|
4343
|
+
while (m = re.exec(html)) {
|
|
4344
|
+
const src = m[1];
|
|
4345
|
+
if (!src.startsWith("/") || src.startsWith("//")) continue;
|
|
4346
|
+
if (src.startsWith("/cdn-cgi/")) continue;
|
|
4347
|
+
srcs.add(src.split(/[?#]/)[0]);
|
|
4348
|
+
}
|
|
4349
|
+
if (srcs.size === 0) return null;
|
|
4350
|
+
return Array.from(srcs).sort().join("\n");
|
|
4351
|
+
}
|
|
4352
|
+
async function readBuild() {
|
|
4353
|
+
try {
|
|
4354
|
+
const res = await fetch("/", {
|
|
4355
|
+
cache: "no-store",
|
|
4356
|
+
credentials: "same-origin",
|
|
4357
|
+
headers: { accept: "text/html" }
|
|
4358
|
+
});
|
|
4359
|
+
if (!res.ok) return null;
|
|
4360
|
+
const sig = scriptSignature(await res.text());
|
|
4361
|
+
if (!sig) return null;
|
|
4362
|
+
return { url: res.url || "/", sig };
|
|
4363
|
+
} catch {
|
|
4364
|
+
return null;
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
function useNewBuild() {
|
|
4368
|
+
const baseline = react.useRef(null);
|
|
4369
|
+
const lastCheck = react.useRef(0);
|
|
4370
|
+
const busy = react.useRef(false);
|
|
4371
|
+
const backoff = react.useRef(0);
|
|
4372
|
+
const [newSig, setNewSig] = react.useState(null);
|
|
4373
|
+
const check2 = react.useCallback(async () => {
|
|
4374
|
+
if (busy.current) return;
|
|
4375
|
+
busy.current = true;
|
|
4376
|
+
lastCheck.current = Date.now();
|
|
4377
|
+
try {
|
|
4378
|
+
const snap = await readBuild();
|
|
4379
|
+
if (!snap) {
|
|
4380
|
+
backoff.current = Math.min(backoff.current * 2 || UPDATE_CHECK_INTERVAL_MS, UPDATE_MAX_BACKOFF_MS);
|
|
4381
|
+
return;
|
|
4382
|
+
}
|
|
4383
|
+
backoff.current = 0;
|
|
4384
|
+
if (!baseline.current) {
|
|
4385
|
+
baseline.current = snap;
|
|
4386
|
+
return;
|
|
4387
|
+
}
|
|
4388
|
+
if (snap.url === baseline.current.url && snap.sig !== baseline.current.sig) setNewSig(snap.sig);
|
|
4389
|
+
} finally {
|
|
4390
|
+
busy.current = false;
|
|
4391
|
+
}
|
|
4392
|
+
}, []);
|
|
4393
|
+
react.useEffect(() => {
|
|
4394
|
+
if (typeof window === "undefined" || typeof fetch !== "function") return;
|
|
4395
|
+
if (!isProductionHost(window.location.hostname)) return;
|
|
4396
|
+
void check2();
|
|
4397
|
+
const timer = window.setInterval(() => {
|
|
4398
|
+
if (document.visibilityState === "hidden" || navigator.onLine === false) return;
|
|
4399
|
+
if (Date.now() - lastCheck.current < backoff.current) return;
|
|
4400
|
+
void check2();
|
|
4401
|
+
}, UPDATE_CHECK_INTERVAL_MS);
|
|
4402
|
+
const onFocus = () => {
|
|
4403
|
+
if (document.visibilityState === "hidden" || navigator.onLine === false) return;
|
|
4404
|
+
if (Date.now() - lastCheck.current < Math.max(UPDATE_FOCUS_MIN_GAP_MS, backoff.current)) return;
|
|
4405
|
+
void check2();
|
|
4406
|
+
};
|
|
4407
|
+
window.addEventListener("focus", onFocus);
|
|
4408
|
+
document.addEventListener("visibilitychange", onFocus);
|
|
4409
|
+
return () => {
|
|
4410
|
+
window.clearInterval(timer);
|
|
4411
|
+
window.removeEventListener("focus", onFocus);
|
|
4412
|
+
document.removeEventListener("visibilitychange", onFocus);
|
|
4413
|
+
};
|
|
4414
|
+
}, [check2]);
|
|
4415
|
+
return newSig;
|
|
4416
|
+
}
|
|
4417
|
+
function UpdateNotice() {
|
|
4418
|
+
const newSig = useNewBuild();
|
|
4419
|
+
const [dismissedSig, setDismissedSig] = react.useState(null);
|
|
4420
|
+
if (!newSig || dismissedSig === newSig) return null;
|
|
4421
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4422
|
+
"div",
|
|
4423
|
+
{
|
|
4424
|
+
role: "status",
|
|
4425
|
+
"aria-live": "polite",
|
|
4426
|
+
"data-vrm-update-notice": "",
|
|
4427
|
+
style: {
|
|
4428
|
+
display: "flex",
|
|
4429
|
+
alignItems: "center",
|
|
4430
|
+
justifyContent: "space-between",
|
|
4431
|
+
gap: 12,
|
|
4432
|
+
marginBottom: 16,
|
|
4433
|
+
padding: "8px 16px",
|
|
4434
|
+
borderRadius: 6,
|
|
4435
|
+
border: "1px solid var(--color-border)",
|
|
4436
|
+
background: "#FFFFFF",
|
|
4437
|
+
fontSize: 14
|
|
4438
|
+
},
|
|
4439
|
+
children: [
|
|
4440
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "New update available \u2014 Refresh VRM" }),
|
|
4441
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
|
|
4442
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4443
|
+
"button",
|
|
4444
|
+
{
|
|
4445
|
+
type: "button",
|
|
4446
|
+
onClick: () => window.location.reload(),
|
|
4447
|
+
style: {
|
|
4448
|
+
padding: "4px 12px",
|
|
4449
|
+
borderRadius: 6,
|
|
4450
|
+
border: 0,
|
|
4451
|
+
background: "var(--color-accent)",
|
|
4452
|
+
color: "var(--color-accent-fg, #FFFFFF)",
|
|
4453
|
+
fontWeight: 600,
|
|
4454
|
+
cursor: "pointer"
|
|
4455
|
+
},
|
|
4456
|
+
children: "Refresh"
|
|
4457
|
+
}
|
|
4458
|
+
),
|
|
4459
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4460
|
+
"button",
|
|
4461
|
+
{
|
|
4462
|
+
type: "button",
|
|
4463
|
+
"aria-label": "Dismiss update notice",
|
|
4464
|
+
onClick: () => setDismissedSig(newSig),
|
|
4465
|
+
style: { padding: "2px 8px", border: 0, background: "transparent", fontSize: 18, lineHeight: 1, cursor: "pointer" },
|
|
4466
|
+
children: "\xD7"
|
|
4467
|
+
}
|
|
4468
|
+
)
|
|
4469
|
+
] })
|
|
4470
|
+
]
|
|
4471
|
+
}
|
|
4472
|
+
);
|
|
4473
|
+
}
|
|
4335
4474
|
var CORE_APP = "vrm";
|
|
4336
4475
|
var DEFAULT_SIGN_OUT_URL = "/auth/signout";
|
|
4337
4476
|
var POLITOGY_APPS = {
|
|
@@ -4672,7 +4811,7 @@ function FrameBody({
|
|
|
4672
4811
|
},
|
|
4673
4812
|
bootGeneration
|
|
4674
4813
|
),
|
|
4675
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4814
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4676
4815
|
NavAppShell,
|
|
4677
4816
|
{
|
|
4678
4817
|
sidebar: {
|
|
@@ -4767,7 +4906,10 @@ function FrameBody({
|
|
|
4767
4906
|
/* @__PURE__ */ jsxRuntime.jsx(ChromeTopBarActions, {})
|
|
4768
4907
|
] })
|
|
4769
4908
|
},
|
|
4770
|
-
children
|
|
4909
|
+
children: [
|
|
4910
|
+
/* @__PURE__ */ jsxRuntime.jsx(UpdateNotice, {}),
|
|
4911
|
+
children
|
|
4912
|
+
]
|
|
4771
4913
|
}
|
|
4772
4914
|
)
|
|
4773
4915
|
] });
|