@ohhwells/bridge 0.1.117 → 0.1.118
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/index.cjs +44 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17551,19 +17551,37 @@ function MadeWithOhhWells() {
|
|
|
17551
17551
|
}
|
|
17552
17552
|
);
|
|
17553
17553
|
}
|
|
17554
|
-
var OHW_LOADER_PREHYDRATE_SCRIPT = `(function(){try{var p=location.hostname.split(".");var fromHost=
|
|
17554
|
+
var OHW_LOADER_PREHYDRATE_SCRIPT = `(function(){try{var fromGlobal=typeof window!=="undefined"&&window.__OHW_SUBDOMAIN__?String(window.__OHW_SUBDOMAIN__):"";var p=location.hostname.split(".");var fromHost=location.hostname.endsWith(".ohhwells.site")&&p[0]&&p[0]!=="www"?p[0]:"";var fromQuery=new URLSearchParams(location.search).get("subdomain")||"";var fromCookie=(document.cookie.match(/(?:^|; )ohw-subdomain=([^;]*)/)||[])[1];fromCookie=fromCookie?decodeURIComponent(fromCookie):"";if(!fromGlobal&&!fromHost&&!fromQuery&&!fromCookie)return;var e=document.getElementById("ohw-loader");if(e)e.style.display="flex"}catch(e){}})();`;
|
|
17555
|
+
function subdomainFromCookie() {
|
|
17556
|
+
if (typeof document === "undefined") return "";
|
|
17557
|
+
const match = document.cookie.match(/(?:^|; )ohw-subdomain=([^;]*)/);
|
|
17558
|
+
return match ? decodeURIComponent(match[1]) : "";
|
|
17559
|
+
}
|
|
17555
17560
|
function resolveSubdomain(subdomainFromQuery) {
|
|
17561
|
+
if (typeof window !== "undefined") {
|
|
17562
|
+
const fromGlobal = window.__OHW_SUBDOMAIN__;
|
|
17563
|
+
if (fromGlobal) return fromGlobal;
|
|
17564
|
+
}
|
|
17556
17565
|
if (subdomainFromQuery) return subdomainFromQuery;
|
|
17557
17566
|
if (typeof window !== "undefined") {
|
|
17558
|
-
const
|
|
17559
|
-
if (
|
|
17567
|
+
const host = window.location.hostname.toLowerCase();
|
|
17568
|
+
if (host.endsWith(".ohhwells.site")) {
|
|
17569
|
+
const label = host.slice(0, -".ohhwells.site".length).split(".").pop();
|
|
17570
|
+
if (label && label !== "www") return label;
|
|
17571
|
+
}
|
|
17572
|
+
const fromCookie = subdomainFromCookie();
|
|
17573
|
+
if (fromCookie) return fromCookie;
|
|
17574
|
+
const isPlatformHost = host.endsWith(".ohhwells.site") || host === "localhost" || host.endsWith(".localhost") || host.endsWith(".vercel.app");
|
|
17575
|
+
if (!isPlatformHost) return "";
|
|
17560
17576
|
}
|
|
17561
17577
|
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL;
|
|
17562
17578
|
if (siteUrl) {
|
|
17563
17579
|
try {
|
|
17564
17580
|
const host = new URL(siteUrl).hostname;
|
|
17565
|
-
|
|
17566
|
-
|
|
17581
|
+
if (host.endsWith(".ohhwells.site")) {
|
|
17582
|
+
const label = host.slice(0, -".ohhwells.site".length).split(".").pop();
|
|
17583
|
+
if (label && label !== "www") return label;
|
|
17584
|
+
}
|
|
17567
17585
|
} catch {
|
|
17568
17586
|
}
|
|
17569
17587
|
}
|
|
@@ -17601,7 +17619,26 @@ function OhhwellsBridge() {
|
|
|
17601
17619
|
};
|
|
17602
17620
|
}, []);
|
|
17603
17621
|
const subdomainFromQuery = searchParams.get("subdomain");
|
|
17604
|
-
const subdomain = resolveSubdomain(subdomainFromQuery);
|
|
17622
|
+
const [subdomain, setSubdomain] = useState14(() => resolveSubdomain(subdomainFromQuery));
|
|
17623
|
+
useLayoutEffect5(() => {
|
|
17624
|
+
const next = resolveSubdomain(subdomainFromQuery);
|
|
17625
|
+
if (next !== subdomain) setSubdomain(next);
|
|
17626
|
+
if (next) return;
|
|
17627
|
+
const host = window.location.hostname.toLowerCase();
|
|
17628
|
+
if (host.endsWith(".ohhwells.site")) return;
|
|
17629
|
+
const t = window.setTimeout(() => {
|
|
17630
|
+
const retry = resolveSubdomain(subdomainFromQuery);
|
|
17631
|
+
if (retry) setSubdomain(retry);
|
|
17632
|
+
}, 0);
|
|
17633
|
+
return () => window.clearTimeout(t);
|
|
17634
|
+
}, [subdomainFromQuery, subdomain]);
|
|
17635
|
+
useEffect13(() => {
|
|
17636
|
+
if (!subdomainFromQuery || typeof window === "undefined") return;
|
|
17637
|
+
const url = new URL(window.location.href);
|
|
17638
|
+
if (!url.searchParams.has("subdomain")) return;
|
|
17639
|
+
url.searchParams.delete("subdomain");
|
|
17640
|
+
window.history.replaceState(null, "", url.pathname + url.search + url.hash);
|
|
17641
|
+
}, [subdomainFromQuery]);
|
|
17605
17642
|
useLinkHrefGuardian(pathname, subdomain, isEditMode);
|
|
17606
17643
|
useSavedLinkNavigation(isEditMode);
|
|
17607
17644
|
const postToParent2 = useCallback8((data) => {
|
|
@@ -23080,7 +23117,7 @@ function OhhwellsBridge() {
|
|
|
23080
23117
|
postToParent2({
|
|
23081
23118
|
type: "ow:ready",
|
|
23082
23119
|
version: "1",
|
|
23083
|
-
bridgeVersion: "0.1.
|
|
23120
|
+
bridgeVersion: "0.1.117",
|
|
23084
23121
|
path: pathname,
|
|
23085
23122
|
nodes: collectEditableNodes(editContentRef.current),
|
|
23086
23123
|
sections
|