@ohhwells/bridge 0.1.152 → 0.1.153
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 +134 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +134 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16910,6 +16910,94 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
|
|
|
16910
16910
|
);
|
|
16911
16911
|
}
|
|
16912
16912
|
|
|
16913
|
+
// src/lib/outage-beacon.ts
|
|
16914
|
+
var DEDUP_MS = 5 * 60 * 1e3;
|
|
16915
|
+
var lastSent = /* @__PURE__ */ new Map();
|
|
16916
|
+
function apiBase() {
|
|
16917
|
+
return process.env.NEXT_PUBLIC_FLOWOPS_API_URL ?? "https://flowops-backend-staging-2yfdh7pwpq-as.a.run.app";
|
|
16918
|
+
}
|
|
16919
|
+
function bridgeVersion() {
|
|
16920
|
+
try {
|
|
16921
|
+
if (true) {
|
|
16922
|
+
return "0.1.153";
|
|
16923
|
+
}
|
|
16924
|
+
} catch {
|
|
16925
|
+
}
|
|
16926
|
+
if (typeof document !== "undefined") {
|
|
16927
|
+
return document.documentElement.getAttribute("data-ohw-bridge-version") || void 0;
|
|
16928
|
+
}
|
|
16929
|
+
return void 0;
|
|
16930
|
+
}
|
|
16931
|
+
function stampBridgeVersionOnDocument() {
|
|
16932
|
+
if (typeof document === "undefined") {
|
|
16933
|
+
return;
|
|
16934
|
+
}
|
|
16935
|
+
try {
|
|
16936
|
+
const v = true ? "0.1.153" : "";
|
|
16937
|
+
if (v) {
|
|
16938
|
+
document.documentElement.setAttribute("data-ohw-bridge-version", v);
|
|
16939
|
+
window.__OHW_BRIDGE_VERSION__ = v;
|
|
16940
|
+
}
|
|
16941
|
+
} catch {
|
|
16942
|
+
}
|
|
16943
|
+
}
|
|
16944
|
+
var RECOVERABLE_PAGE_ERROR = /Minified React error #(?:418|419|421|422|423|425)\b|Hydration failed because the initial UI does not match|Text content does not match server-rendered HTML|There was an error while hydrating|did not match\. Server:/i;
|
|
16945
|
+
function reportOutageBeacon(args) {
|
|
16946
|
+
if (typeof window === "undefined" || !args.subdomain) {
|
|
16947
|
+
return;
|
|
16948
|
+
}
|
|
16949
|
+
if (args.reason === "page_error" && args.detail && RECOVERABLE_PAGE_ERROR.test(args.detail)) {
|
|
16950
|
+
return;
|
|
16951
|
+
}
|
|
16952
|
+
const key = `${args.subdomain}|${args.reason}`;
|
|
16953
|
+
const now = Date.now();
|
|
16954
|
+
const prev = lastSent.get(key) || 0;
|
|
16955
|
+
if (now - prev < DEDUP_MS) {
|
|
16956
|
+
return;
|
|
16957
|
+
}
|
|
16958
|
+
lastSent.set(key, now);
|
|
16959
|
+
const body = JSON.stringify({
|
|
16960
|
+
subdomain: args.subdomain,
|
|
16961
|
+
reason: args.reason,
|
|
16962
|
+
detail: args.detail?.slice(0, 300),
|
|
16963
|
+
templateId: args.templateId,
|
|
16964
|
+
bridgeVersion: bridgeVersion(),
|
|
16965
|
+
href: typeof location !== "undefined" ? location.href : void 0
|
|
16966
|
+
});
|
|
16967
|
+
const url = `${apiBase()}/api/public/sites/outage-beacon`;
|
|
16968
|
+
try {
|
|
16969
|
+
if (typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
16970
|
+
const blob = new Blob([body], { type: "application/json" });
|
|
16971
|
+
if (navigator.sendBeacon(url, blob)) {
|
|
16972
|
+
return;
|
|
16973
|
+
}
|
|
16974
|
+
}
|
|
16975
|
+
void fetch(url, {
|
|
16976
|
+
method: "POST",
|
|
16977
|
+
headers: { "Content-Type": "application/json" },
|
|
16978
|
+
body,
|
|
16979
|
+
keepalive: true,
|
|
16980
|
+
cache: "no-store"
|
|
16981
|
+
}).catch(() => {
|
|
16982
|
+
});
|
|
16983
|
+
} catch {
|
|
16984
|
+
}
|
|
16985
|
+
}
|
|
16986
|
+
function armLoaderHangBeacon(subdomain, fetchState, hangMs = 15e3) {
|
|
16987
|
+
if (!subdomain || fetchState !== "loading") {
|
|
16988
|
+
return () => {
|
|
16989
|
+
};
|
|
16990
|
+
}
|
|
16991
|
+
const timer = window.setTimeout(() => {
|
|
16992
|
+
reportOutageBeacon({
|
|
16993
|
+
subdomain,
|
|
16994
|
+
reason: "loader_stuck",
|
|
16995
|
+
detail: `fetchState still loading after ${hangMs}ms`
|
|
16996
|
+
});
|
|
16997
|
+
}, hangMs);
|
|
16998
|
+
return () => window.clearTimeout(timer);
|
|
16999
|
+
}
|
|
17000
|
+
|
|
16913
17001
|
// src/lib/form-fields.ts
|
|
16914
17002
|
var FIELD_DEFAULTS = {
|
|
16915
17003
|
"short-text": { label: "Short text", placeholder: "Type placeholder text..." },
|
|
@@ -25301,6 +25389,34 @@ function OhhwellsBridge() {
|
|
|
25301
25389
|
const [fetchState, setFetchState] = useState18("idle");
|
|
25302
25390
|
const [showBranding, setShowBranding] = useState18(false);
|
|
25303
25391
|
const autoSaveTimers = useRef14(/* @__PURE__ */ new Map());
|
|
25392
|
+
useEffect17(() => {
|
|
25393
|
+
stampBridgeVersionOnDocument();
|
|
25394
|
+
}, []);
|
|
25395
|
+
useEffect17(() => {
|
|
25396
|
+
if (isEditMode) return;
|
|
25397
|
+
return armLoaderHangBeacon(subdomain, fetchState);
|
|
25398
|
+
}, [isEditMode, subdomain, fetchState]);
|
|
25399
|
+
useEffect17(() => {
|
|
25400
|
+
if (isEditMode || !subdomain) return;
|
|
25401
|
+
const onError = (event) => {
|
|
25402
|
+
reportOutageBeacon({
|
|
25403
|
+
subdomain,
|
|
25404
|
+
reason: "page_error",
|
|
25405
|
+
detail: event.message || "window error"
|
|
25406
|
+
});
|
|
25407
|
+
};
|
|
25408
|
+
const onRejection = (event) => {
|
|
25409
|
+
const reason = event.reason;
|
|
25410
|
+
const detail = reason instanceof Error ? reason.message : typeof reason === "string" ? reason : "unhandledrejection";
|
|
25411
|
+
reportOutageBeacon({ subdomain, reason: "page_error", detail });
|
|
25412
|
+
};
|
|
25413
|
+
window.addEventListener("error", onError);
|
|
25414
|
+
window.addEventListener("unhandledrejection", onRejection);
|
|
25415
|
+
return () => {
|
|
25416
|
+
window.removeEventListener("error", onError);
|
|
25417
|
+
window.removeEventListener("unhandledrejection", onRejection);
|
|
25418
|
+
};
|
|
25419
|
+
}, [isEditMode, subdomain]);
|
|
25304
25420
|
const activeElRef = useRef14(null);
|
|
25305
25421
|
const pointerHeldRef = useRef14(false);
|
|
25306
25422
|
const selectedElRef = useRef14(null);
|
|
@@ -27557,7 +27673,17 @@ function OhhwellsBridge() {
|
|
|
27557
27673
|
const apiUrl = process.env.NEXT_PUBLIC_FLOWOPS_API_URL ?? "https://flowops-backend-staging-2yfdh7pwpq-as.a.run.app";
|
|
27558
27674
|
const initialPath = pathname;
|
|
27559
27675
|
fetchedContentPaths.add(`${subdomain}::${initialPath}`);
|
|
27560
|
-
fetch(`${apiUrl}/api/public/sites/${subdomain}/content?path=${encodeURIComponent(initialPath)}`, { cache: "no-store" }).then((r2) =>
|
|
27676
|
+
fetch(`${apiUrl}/api/public/sites/${subdomain}/content?path=${encodeURIComponent(initialPath)}`, { cache: "no-store" }).then((r2) => {
|
|
27677
|
+
if (!r2.ok) {
|
|
27678
|
+
reportOutageBeacon({
|
|
27679
|
+
subdomain,
|
|
27680
|
+
reason: "content_fetch_failed",
|
|
27681
|
+
detail: `HTTP ${r2.status}`
|
|
27682
|
+
});
|
|
27683
|
+
return null;
|
|
27684
|
+
}
|
|
27685
|
+
return r2.json();
|
|
27686
|
+
}).then((data) => {
|
|
27561
27687
|
if (cancelled) return;
|
|
27562
27688
|
const content = data?.content ?? {};
|
|
27563
27689
|
const branding = Boolean(data?.showBranding);
|
|
@@ -27566,7 +27692,12 @@ function OhhwellsBridge() {
|
|
|
27566
27692
|
recordOverriddenPaths(subdomain, data?.overriddenPaths);
|
|
27567
27693
|
setShowBranding(branding);
|
|
27568
27694
|
return applyContent(content);
|
|
27569
|
-
}).catch(() => {
|
|
27695
|
+
}).catch((err) => {
|
|
27696
|
+
reportOutageBeacon({
|
|
27697
|
+
subdomain,
|
|
27698
|
+
reason: "content_fetch_failed",
|
|
27699
|
+
detail: err instanceof Error ? err.message : "fetch failed"
|
|
27700
|
+
});
|
|
27570
27701
|
}).finally(() => {
|
|
27571
27702
|
if (!cancelled) setFetchState("done");
|
|
27572
27703
|
});
|
|
@@ -31727,7 +31858,7 @@ function OhhwellsBridge() {
|
|
|
31727
31858
|
postToParent2({
|
|
31728
31859
|
type: "ow:ready",
|
|
31729
31860
|
version: "1",
|
|
31730
|
-
bridgeVersion: "0.1.
|
|
31861
|
+
bridgeVersion: "0.1.153",
|
|
31731
31862
|
path: pathname,
|
|
31732
31863
|
nodes: collectEditableNodes(editContentRef.current),
|
|
31733
31864
|
sections
|