@the-portland-company/shell 0.73.2 → 0.75.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/CHANGELOG.md +20 -0
- package/dist/app-chrome.cjs +157 -40
- package/dist/app-chrome.cjs.map +1 -1
- package/dist/app-chrome.d.cts +1 -2
- package/dist/app-chrome.d.ts +1 -2
- package/dist/app-chrome.js +10 -3
- package/dist/app-chrome.js.map +1 -1
- package/dist/chunk-MY6G3LMN.js +125 -0
- package/dist/chunk-MY6G3LMN.js.map +1 -0
- package/dist/{chunk-5DHPCG7W.js → chunk-QUXD4PZ7.js} +68 -43
- package/dist/chunk-QUXD4PZ7.js.map +1 -0
- package/dist/index.cjs +84 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -2
- package/dist/index.d.ts +61 -2
- package/dist/index.js +3 -20
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +150 -40
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +25 -4
- package/dist/native.d.ts +25 -4
- package/dist/native.js +2 -2
- package/package.json +1 -1
- package/dist/FormColumn-DsNP6NVG.d.cts +0 -21
- package/dist/FormColumn-DsNP6NVG.d.ts +0 -21
- package/dist/chunk-5DHPCG7W.js.map +0 -1
- package/dist/chunk-LPSBSAF3.js +0 -26
- package/dist/chunk-LPSBSAF3.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1566,6 +1566,87 @@ function buildSpeculationRules(currentApp, registry) {
|
|
|
1566
1566
|
};
|
|
1567
1567
|
return JSON.stringify(payload);
|
|
1568
1568
|
}
|
|
1569
|
+
var DESTRUCTIVE_LABEL_PATTERNS = ["sign out", "signout", "log out", "logout", "delete"];
|
|
1570
|
+
var DESTRUCTIVE_PATH_PATTERNS = ["/signout", "/sign-out", "/logout", "/log-out"];
|
|
1571
|
+
function isDestructive(item) {
|
|
1572
|
+
const label = item.label.toLowerCase();
|
|
1573
|
+
if (DESTRUCTIVE_LABEL_PATTERNS.some((p) => label.includes(p))) return true;
|
|
1574
|
+
const href = (item.href ?? "").toLowerCase();
|
|
1575
|
+
return DESTRUCTIVE_PATH_PATTERNS.some((p) => href.includes(p));
|
|
1576
|
+
}
|
|
1577
|
+
function collectSiblingAppUrls(items, currentOrigin) {
|
|
1578
|
+
const urls = /* @__PURE__ */ new Set();
|
|
1579
|
+
const walk = (list) => {
|
|
1580
|
+
for (const item of list) {
|
|
1581
|
+
if (item.kind === "section") continue;
|
|
1582
|
+
if (item.href && !isDestructive(item)) {
|
|
1583
|
+
try {
|
|
1584
|
+
const url = new URL(item.href, currentOrigin);
|
|
1585
|
+
if (url.origin !== currentOrigin && /^https?:$/.test(url.protocol)) {
|
|
1586
|
+
urls.add(url.href);
|
|
1587
|
+
}
|
|
1588
|
+
} catch {
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
if (item.children?.length) walk(item.children);
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
walk(items);
|
|
1595
|
+
return Array.from(urls);
|
|
1596
|
+
}
|
|
1597
|
+
function buildNavSpeculationRules(items, currentOrigin = typeof window !== "undefined" ? window.location.origin : "") {
|
|
1598
|
+
const urls = collectSiblingAppUrls(items, currentOrigin);
|
|
1599
|
+
if (urls.length === 0) return null;
|
|
1600
|
+
return {
|
|
1601
|
+
prerender: [{ source: "list", urls, eagerness: "moderate" }]
|
|
1602
|
+
};
|
|
1603
|
+
}
|
|
1604
|
+
var SCRIPT_ID = "politogy-speculation-rules";
|
|
1605
|
+
var PREFETCH_ATTR = "data-politogy-speculation-prefetch";
|
|
1606
|
+
function SpeculationRulesScript({ items }) {
|
|
1607
|
+
const origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
1608
|
+
const rules = react$1.useMemo(() => buildNavSpeculationRules(items, origin), [items, origin]);
|
|
1609
|
+
const json = rules ? JSON.stringify(rules) : null;
|
|
1610
|
+
react$1.useEffect(() => {
|
|
1611
|
+
if (!json || typeof document === "undefined") return;
|
|
1612
|
+
let el = document.getElementById(SCRIPT_ID);
|
|
1613
|
+
if (!el) {
|
|
1614
|
+
el = document.createElement("script");
|
|
1615
|
+
el.id = SCRIPT_ID;
|
|
1616
|
+
el.type = "speculationrules";
|
|
1617
|
+
document.head.appendChild(el);
|
|
1618
|
+
}
|
|
1619
|
+
el.textContent = json;
|
|
1620
|
+
return () => {
|
|
1621
|
+
};
|
|
1622
|
+
}, [json]);
|
|
1623
|
+
react$1.useEffect(() => {
|
|
1624
|
+
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
1625
|
+
const supportsSpecRules = typeof HTMLScriptElement !== "undefined" && typeof HTMLScriptElement.supports === "function" && HTMLScriptElement.supports(
|
|
1626
|
+
"speculationrules"
|
|
1627
|
+
);
|
|
1628
|
+
if (supportsSpecRules) return;
|
|
1629
|
+
const urls = collectSiblingAppUrls(items, origin);
|
|
1630
|
+
if (urls.length === 0) return;
|
|
1631
|
+
const schedule = typeof window.requestIdleCallback === "function" ? window.requestIdleCallback : (cb) => setTimeout(cb, 2e3);
|
|
1632
|
+
const added = [];
|
|
1633
|
+
schedule(() => {
|
|
1634
|
+
for (const url of urls) {
|
|
1635
|
+
if (document.querySelector(`link[${PREFETCH_ATTR}][href="${url}"]`)) continue;
|
|
1636
|
+
const link = document.createElement("link");
|
|
1637
|
+
link.rel = "prefetch";
|
|
1638
|
+
link.href = url;
|
|
1639
|
+
link.setAttribute(PREFETCH_ATTR, "");
|
|
1640
|
+
document.head.appendChild(link);
|
|
1641
|
+
added.push(link);
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
return () => {
|
|
1645
|
+
added.forEach((l) => l.remove());
|
|
1646
|
+
};
|
|
1647
|
+
}, [items, origin]);
|
|
1648
|
+
return null;
|
|
1649
|
+
}
|
|
1569
1650
|
|
|
1570
1651
|
exports.BrandIcon = BrandIcon;
|
|
1571
1652
|
exports.BrandLogo = BrandLogo;
|
|
@@ -1586,7 +1667,10 @@ exports.ShellOrgContext = ShellOrgContext;
|
|
|
1586
1667
|
exports.ShellProvider = ShellProvider;
|
|
1587
1668
|
exports.ShellRoleContext = ShellRoleContext;
|
|
1588
1669
|
exports.ShellSupportProviderContext = ShellSupportProviderContext;
|
|
1670
|
+
exports.SpeculationRulesScript = SpeculationRulesScript;
|
|
1671
|
+
exports.buildNavSpeculationRules = buildNavSpeculationRules;
|
|
1589
1672
|
exports.buildSpeculationRules = buildSpeculationRules;
|
|
1673
|
+
exports.collectSiblingAppUrls = collectSiblingAppUrls;
|
|
1590
1674
|
exports.getOrganizationBadgeLetters = getOrganizationBadgeLetters;
|
|
1591
1675
|
exports.getOrganizationBrandColor = getOrganizationBrandColor;
|
|
1592
1676
|
exports.getUserDisplayName = getUserDisplayName;
|