@the-portland-company/shell 0.103.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.
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { S as StandardNavIconKey, z as NavIcon, N as NavItem, D as NavBreadcrumb, E as StandardNavMode, G as NavLinkComponent, I as NavChromeFetcher, J as NavMode, L as NavUserMenu, M as NavOrgOption, i as NotificationsAdapter, O as ChromeOrgSummary, Q as NavFooterLink, U as NavFooter, W as NavDisplayMode } from './index-lk2Ad_Q0.cjs';
3
+ import { S as StandardNavIconKey, z as NavIcon, N as NavItem, D as NavBreadcrumb, E as StandardNavMode, G as NavLinkComponent, I as NavChromeFetcher, J as NavMode, L as NavUserMenu, M as NavOrgOption, i as NotificationsAdapter, O as ChromeOrgSummary, Q as NavFooterLink, U as NavFooter, W as NavDisplayMode } from './index-BKVWMe9_.cjs';
4
4
  import './theme-preference.cjs';
5
5
  import './brand-favicon.cjs';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { S as StandardNavIconKey, z as NavIcon, N as NavItem, D as NavBreadcrumb, E as StandardNavMode, G as NavLinkComponent, I as NavChromeFetcher, J as NavMode, L as NavUserMenu, M as NavOrgOption, i as NotificationsAdapter, O as ChromeOrgSummary, Q as NavFooterLink, U as NavFooter, W as NavDisplayMode } from './index-ND_BS0nl.js';
3
+ import { S as StandardNavIconKey, z as NavIcon, N as NavItem, D as NavBreadcrumb, E as StandardNavMode, G as NavLinkComponent, I as NavChromeFetcher, J as NavMode, L as NavUserMenu, M as NavOrgOption, i as NotificationsAdapter, O as ChromeOrgSummary, Q as NavFooterLink, U as NavFooter, W as NavDisplayMode } from './index-DnrsvxhZ.js';
4
4
  import './theme-preference.js';
5
5
  import './brand-favicon.js';
6
6
 
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { broadcastLogout, watchLogout } from './chunk-LL6LSJAH.js';
3
3
  import { writeUrlState } from './chunk-GVQKZI5X.js';
4
- import { clearBetaBannerDismissal, standardPolitogyNav, standardNavIcons, isNavItemActive, NavAppShell } from './chunk-KI5P6QKQ.js';
5
- export { standardNavIcons } from './chunk-KI5P6QKQ.js';
4
+ import { clearBetaBannerDismissal, standardPolitogyNav, standardNavIcons, isNavItemActive, isUnderNavPattern, NavAppShell } from './chunk-7XWRF7Y2.js';
5
+ export { standardNavIcons } from './chunk-7XWRF7Y2.js';
6
6
  import { orgIdTail, ORG_ID_QUERY_PARAM, settingsBaseUrl, authBaseUrl, readOrgSelectorFromUrl, matchOrgSelector, syncOrgIdInUrl, isOrgId, switchActiveOrg, ACTIVE_ORG_QUERY_PARAM, writeActiveOrgCookie, resolveActiveOrg, readActiveOrgCookie } from './chunk-5LO5W7W5.js';
7
7
  import { warnDeprecated, NavChromeProvider, FuelAction, NotificationsAction, OrganizationSettingsAction, MyProfileAction, useChromeMe, useNavChromeDedupedFetch, useChromeOrgs, useNavChromeFetcher } from './chunk-HR2TBHHH.js';
8
8
  import './chunk-BHRVZPZ7.js';
@@ -506,6 +506,145 @@ function LoadingScreen({
506
506
  }
507
507
  );
508
508
  }
509
+ var UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
510
+ var UPDATE_FOCUS_MIN_GAP_MS = 60 * 1e3;
511
+ var UPDATE_MAX_BACKOFF_MS = 30 * 60 * 1e3;
512
+ var isProductionHost = (hostname) => hostname === "politogyvrm.com" || hostname.endsWith(".politogyvrm.com");
513
+ function scriptSignature(html) {
514
+ const srcs = /* @__PURE__ */ new Set();
515
+ const re = /<script\b[^>]*\bsrc=["']([^"']+)["']/gi;
516
+ let m;
517
+ while (m = re.exec(html)) {
518
+ const src = m[1];
519
+ if (!src.startsWith("/") || src.startsWith("//")) continue;
520
+ if (src.startsWith("/cdn-cgi/")) continue;
521
+ srcs.add(src.split(/[?#]/)[0]);
522
+ }
523
+ if (srcs.size === 0) return null;
524
+ return Array.from(srcs).sort().join("\n");
525
+ }
526
+ async function readBuild() {
527
+ try {
528
+ const res = await fetch("/", {
529
+ cache: "no-store",
530
+ credentials: "same-origin",
531
+ headers: { accept: "text/html" }
532
+ });
533
+ if (!res.ok) return null;
534
+ const sig = scriptSignature(await res.text());
535
+ if (!sig) return null;
536
+ return { url: res.url || "/", sig };
537
+ } catch {
538
+ return null;
539
+ }
540
+ }
541
+ function useNewBuild() {
542
+ const baseline = useRef(null);
543
+ const lastCheck = useRef(0);
544
+ const busy = useRef(false);
545
+ const backoff = useRef(0);
546
+ const [newSig, setNewSig] = useState(null);
547
+ const check = useCallback(async () => {
548
+ if (busy.current) return;
549
+ busy.current = true;
550
+ lastCheck.current = Date.now();
551
+ try {
552
+ const snap = await readBuild();
553
+ if (!snap) {
554
+ backoff.current = Math.min(backoff.current * 2 || UPDATE_CHECK_INTERVAL_MS, UPDATE_MAX_BACKOFF_MS);
555
+ return;
556
+ }
557
+ backoff.current = 0;
558
+ if (!baseline.current) {
559
+ baseline.current = snap;
560
+ return;
561
+ }
562
+ if (snap.url === baseline.current.url && snap.sig !== baseline.current.sig) setNewSig(snap.sig);
563
+ } finally {
564
+ busy.current = false;
565
+ }
566
+ }, []);
567
+ useEffect(() => {
568
+ if (typeof window === "undefined" || typeof fetch !== "function") return;
569
+ if (!isProductionHost(window.location.hostname)) return;
570
+ void check();
571
+ const timer = window.setInterval(() => {
572
+ if (document.visibilityState === "hidden" || navigator.onLine === false) return;
573
+ if (Date.now() - lastCheck.current < backoff.current) return;
574
+ void check();
575
+ }, UPDATE_CHECK_INTERVAL_MS);
576
+ const onFocus = () => {
577
+ if (document.visibilityState === "hidden" || navigator.onLine === false) return;
578
+ if (Date.now() - lastCheck.current < Math.max(UPDATE_FOCUS_MIN_GAP_MS, backoff.current)) return;
579
+ void check();
580
+ };
581
+ window.addEventListener("focus", onFocus);
582
+ document.addEventListener("visibilitychange", onFocus);
583
+ return () => {
584
+ window.clearInterval(timer);
585
+ window.removeEventListener("focus", onFocus);
586
+ document.removeEventListener("visibilitychange", onFocus);
587
+ };
588
+ }, [check]);
589
+ return newSig;
590
+ }
591
+ function UpdateNotice() {
592
+ const newSig = useNewBuild();
593
+ const [dismissedSig, setDismissedSig] = useState(null);
594
+ if (!newSig || dismissedSig === newSig) return null;
595
+ return /* @__PURE__ */ jsxs(
596
+ "div",
597
+ {
598
+ role: "status",
599
+ "aria-live": "polite",
600
+ "data-vrm-update-notice": "",
601
+ style: {
602
+ display: "flex",
603
+ alignItems: "center",
604
+ justifyContent: "space-between",
605
+ gap: 12,
606
+ marginBottom: 16,
607
+ padding: "8px 16px",
608
+ borderRadius: 6,
609
+ border: "1px solid var(--color-border)",
610
+ background: "#FFFFFF",
611
+ fontSize: 14
612
+ },
613
+ children: [
614
+ /* @__PURE__ */ jsx("span", { children: "New update available \u2014 Refresh VRM" }),
615
+ /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
616
+ /* @__PURE__ */ jsx(
617
+ "button",
618
+ {
619
+ type: "button",
620
+ onClick: () => window.location.reload(),
621
+ style: {
622
+ padding: "4px 12px",
623
+ borderRadius: 6,
624
+ border: 0,
625
+ background: "var(--color-accent)",
626
+ color: "var(--color-accent-fg, #FFFFFF)",
627
+ fontWeight: 600,
628
+ cursor: "pointer"
629
+ },
630
+ children: "Refresh"
631
+ }
632
+ ),
633
+ /* @__PURE__ */ jsx(
634
+ "button",
635
+ {
636
+ type: "button",
637
+ "aria-label": "Dismiss update notice",
638
+ onClick: () => setDismissedSig(newSig),
639
+ style: { padding: "2px 8px", border: 0, background: "transparent", fontSize: 18, lineHeight: 1, cursor: "pointer" },
640
+ children: "\xD7"
641
+ }
642
+ )
643
+ ] })
644
+ ]
645
+ }
646
+ );
647
+ }
509
648
  var CORE_APP = "vrm";
510
649
  var DEFAULT_SIGN_OUT_URL = "/auth/signout";
511
650
  var POLITOGY_APPS = {
@@ -801,18 +940,33 @@ function FrameBody({
801
940
  const navItems = core?.nav ?? derivedNavItems;
802
941
  const navIsActive = useMemo(() => {
803
942
  const childHrefs = /* @__PURE__ */ new Map();
943
+ const extra = /* @__PURE__ */ new Map();
944
+ const addExtra = (href, pats) => {
945
+ if (!pats?.length) return;
946
+ extra.set(href, [...extra.get(href) ?? [], ...pats]);
947
+ };
804
948
  for (const item of navItems) {
805
- if (!item.href || !item.children?.length) continue;
949
+ if (!item.href) continue;
950
+ addExtra(item.href, item.activeOn);
951
+ if (!item.children?.length) continue;
806
952
  const hrefs = [];
807
953
  for (const child of item.children) {
808
- if (child.href) hrefs.push(child.href);
954
+ if (child.href) {
955
+ hrefs.push(child.href);
956
+ addExtra(child.href, child.activeOn);
957
+ }
958
+ addExtra(item.href, child.activeOn);
809
959
  for (const leaf of child.children ?? []) {
810
- if (leaf.href) hrefs.push(leaf.href);
960
+ if (leaf.href) {
961
+ hrefs.push(leaf.href);
962
+ addExtra(leaf.href, leaf.activeOn);
963
+ }
964
+ addExtra(item.href, leaf.activeOn);
811
965
  }
812
966
  }
813
967
  childHrefs.set(item.href, hrefs);
814
968
  }
815
- return (pathname2, href) => isNavItemActive(pathname2, href) || (childHrefs.get(href) ?? []).some((h) => isNavItemActive(pathname2, h));
969
+ return (pathname2, href) => isNavItemActive(pathname2, href) || (childHrefs.get(href) ?? []).some((h) => isNavItemActive(pathname2, h)) || (extra.get(href) ?? []).some((p) => isUnderNavPattern(pathname2, p));
816
970
  }, [navItems]);
817
971
  const derivedBreadcrumbs = useMemo(
818
972
  () => deriveBreadcrumbs(navItems, pathname, { search, origin: meta.origin }),
@@ -831,7 +985,7 @@ function FrameBody({
831
985
  },
832
986
  bootGeneration
833
987
  ),
834
- /* @__PURE__ */ jsx(
988
+ /* @__PURE__ */ jsxs(
835
989
  NavAppShell,
836
990
  {
837
991
  sidebar: {
@@ -926,7 +1080,10 @@ function FrameBody({
926
1080
  /* @__PURE__ */ jsx(ChromeTopBarActions, {})
927
1081
  ] })
928
1082
  },
929
- children
1083
+ children: [
1084
+ /* @__PURE__ */ jsx(UpdateNotice, {}),
1085
+ children
1086
+ ]
930
1087
  }
931
1088
  )
932
1089
  ] });