@the-portland-company/shell 0.104.0 → 0.106.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.
@@ -2626,7 +2626,20 @@ function NavSidebar({
2626
2626
  },
2627
2627
  o.id
2628
2628
  );
2629
- })
2629
+ }),
2630
+ org.createOrgHref ? /* @__PURE__ */ jsxRuntime.jsxs(
2631
+ "a",
2632
+ {
2633
+ href: safeHref(org.createOrgHref),
2634
+ "data-org-create": true,
2635
+ onClick: (e) => e.currentTarget.closest("details")?.removeAttribute("open"),
2636
+ className: "mt-1 flex w-full items-center gap-2.5 border-t border-[color:var(--line)] px-3 py-2 text-left text-sm font-medium text-[color:var(--foreground)] hover:bg-[color:var(--panel)]",
2637
+ children: [
2638
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[color:var(--line)] text-base leading-none", children: "+" }),
2639
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "New organization" })
2640
+ ]
2641
+ }
2642
+ ) : null
2630
2643
  ] })
2631
2644
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(
2632
2645
  "button",
@@ -4332,6 +4345,145 @@ function writeUrlState(current, patch) {
4332
4345
  }
4333
4346
  return buildSearch(state);
4334
4347
  }
4348
+ var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
4349
+ var UPDATE_FOCUS_MIN_GAP_MS = 60 * 1e3;
4350
+ var UPDATE_MAX_BACKOFF_MS = 30 * 60 * 1e3;
4351
+ var isProductionHost = (hostname) => hostname === "politogyvrm.com" || hostname.endsWith(".politogyvrm.com");
4352
+ function scriptSignature(html) {
4353
+ const srcs = /* @__PURE__ */ new Set();
4354
+ const re = /<script\b[^>]*\bsrc=["']([^"']+)["']/gi;
4355
+ let m;
4356
+ while (m = re.exec(html)) {
4357
+ const src = m[1];
4358
+ if (!src.startsWith("/") || src.startsWith("//")) continue;
4359
+ if (src.startsWith("/cdn-cgi/")) continue;
4360
+ srcs.add(src.split(/[?#]/)[0]);
4361
+ }
4362
+ if (srcs.size === 0) return null;
4363
+ return Array.from(srcs).sort().join("\n");
4364
+ }
4365
+ async function readBuild() {
4366
+ try {
4367
+ const res = await fetch("/", {
4368
+ cache: "no-store",
4369
+ credentials: "same-origin",
4370
+ headers: { accept: "text/html" }
4371
+ });
4372
+ if (!res.ok) return null;
4373
+ const sig = scriptSignature(await res.text());
4374
+ if (!sig) return null;
4375
+ return { url: res.url || "/", sig };
4376
+ } catch {
4377
+ return null;
4378
+ }
4379
+ }
4380
+ function useNewBuild() {
4381
+ const baseline = react.useRef(null);
4382
+ const lastCheck = react.useRef(0);
4383
+ const busy = react.useRef(false);
4384
+ const backoff = react.useRef(0);
4385
+ const [newSig, setNewSig] = react.useState(null);
4386
+ const check2 = react.useCallback(async () => {
4387
+ if (busy.current) return;
4388
+ busy.current = true;
4389
+ lastCheck.current = Date.now();
4390
+ try {
4391
+ const snap = await readBuild();
4392
+ if (!snap) {
4393
+ backoff.current = Math.min(backoff.current * 2 || UPDATE_CHECK_INTERVAL_MS, UPDATE_MAX_BACKOFF_MS);
4394
+ return;
4395
+ }
4396
+ backoff.current = 0;
4397
+ if (!baseline.current) {
4398
+ baseline.current = snap;
4399
+ return;
4400
+ }
4401
+ if (snap.url === baseline.current.url && snap.sig !== baseline.current.sig) setNewSig(snap.sig);
4402
+ } finally {
4403
+ busy.current = false;
4404
+ }
4405
+ }, []);
4406
+ react.useEffect(() => {
4407
+ if (typeof window === "undefined" || typeof fetch !== "function") return;
4408
+ if (!isProductionHost(window.location.hostname)) return;
4409
+ void check2();
4410
+ const timer = window.setInterval(() => {
4411
+ if (document.visibilityState === "hidden" || navigator.onLine === false) return;
4412
+ if (Date.now() - lastCheck.current < backoff.current) return;
4413
+ void check2();
4414
+ }, UPDATE_CHECK_INTERVAL_MS);
4415
+ const onFocus = () => {
4416
+ if (document.visibilityState === "hidden" || navigator.onLine === false) return;
4417
+ if (Date.now() - lastCheck.current < Math.max(UPDATE_FOCUS_MIN_GAP_MS, backoff.current)) return;
4418
+ void check2();
4419
+ };
4420
+ window.addEventListener("focus", onFocus);
4421
+ document.addEventListener("visibilitychange", onFocus);
4422
+ return () => {
4423
+ window.clearInterval(timer);
4424
+ window.removeEventListener("focus", onFocus);
4425
+ document.removeEventListener("visibilitychange", onFocus);
4426
+ };
4427
+ }, [check2]);
4428
+ return newSig;
4429
+ }
4430
+ function UpdateNotice() {
4431
+ const newSig = useNewBuild();
4432
+ const [dismissedSig, setDismissedSig] = react.useState(null);
4433
+ if (!newSig || dismissedSig === newSig) return null;
4434
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4435
+ "div",
4436
+ {
4437
+ role: "status",
4438
+ "aria-live": "polite",
4439
+ "data-vrm-update-notice": "",
4440
+ style: {
4441
+ display: "flex",
4442
+ alignItems: "center",
4443
+ justifyContent: "space-between",
4444
+ gap: 12,
4445
+ marginBottom: 16,
4446
+ padding: "8px 16px",
4447
+ borderRadius: 6,
4448
+ border: "1px solid var(--color-border)",
4449
+ background: "#FFFFFF",
4450
+ fontSize: 14
4451
+ },
4452
+ children: [
4453
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "New update available \u2014 Refresh VRM" }),
4454
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
4455
+ /* @__PURE__ */ jsxRuntime.jsx(
4456
+ "button",
4457
+ {
4458
+ type: "button",
4459
+ onClick: () => window.location.reload(),
4460
+ style: {
4461
+ padding: "4px 12px",
4462
+ borderRadius: 6,
4463
+ border: 0,
4464
+ background: "var(--color-accent)",
4465
+ color: "var(--color-accent-fg, #FFFFFF)",
4466
+ fontWeight: 600,
4467
+ cursor: "pointer"
4468
+ },
4469
+ children: "Refresh"
4470
+ }
4471
+ ),
4472
+ /* @__PURE__ */ jsxRuntime.jsx(
4473
+ "button",
4474
+ {
4475
+ type: "button",
4476
+ "aria-label": "Dismiss update notice",
4477
+ onClick: () => setDismissedSig(newSig),
4478
+ style: { padding: "2px 8px", border: 0, background: "transparent", fontSize: 18, lineHeight: 1, cursor: "pointer" },
4479
+ children: "\xD7"
4480
+ }
4481
+ )
4482
+ ] })
4483
+ ]
4484
+ }
4485
+ );
4486
+ }
4335
4487
  var CORE_APP = "vrm";
4336
4488
  var DEFAULT_SIGN_OUT_URL = "/auth/signout";
4337
4489
  var POLITOGY_APPS = {
@@ -4672,7 +4824,7 @@ function FrameBody({
4672
4824
  },
4673
4825
  bootGeneration
4674
4826
  ),
4675
- /* @__PURE__ */ jsxRuntime.jsx(
4827
+ /* @__PURE__ */ jsxRuntime.jsxs(
4676
4828
  NavAppShell,
4677
4829
  {
4678
4830
  sidebar: {
@@ -4707,7 +4859,10 @@ function FrameBody({
4707
4859
  iconUrl: activeCoreOrg.iconUrl ?? null,
4708
4860
  brandColor: activeCoreOrg.brandColor,
4709
4861
  organizations: coreOrgs,
4710
- onSwitch: chrome?.setOrgId
4862
+ onSwitch: chrome?.setOrgId,
4863
+ // Left-Navigation v34: create another organization without
4864
+ // signing out (Politogy ID's /new-organization).
4865
+ createOrgHref: `${authBaseUrl()}/new-organization${orgIdTail(activeCoreOrg.id) ? `?${ORG_ID_QUERY_PARAM}=${orgIdTail(activeCoreOrg.id)}` : ""}`
4711
4866
  } : chrome?.orgsLoading ? { name: null, id: null, loading: true } : { name: session.accountName, id: session.accountId },
4712
4867
  mode,
4713
4868
  footer,
@@ -4767,7 +4922,10 @@ function FrameBody({
4767
4922
  /* @__PURE__ */ jsxRuntime.jsx(ChromeTopBarActions, {})
4768
4923
  ] })
4769
4924
  },
4770
- children
4925
+ children: [
4926
+ /* @__PURE__ */ jsxRuntime.jsx(UpdateNotice, {}),
4927
+ children
4928
+ ]
4771
4929
  }
4772
4930
  )
4773
4931
  ] });