@ohhwells/bridge 0.1.89 → 0.1.91
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 +52 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14887,6 +14887,15 @@ function updateSectionScheduleId(insertAfter, scheduleId) {
|
|
|
14887
14887
|
tracker.textContent = JSON.stringify(updated);
|
|
14888
14888
|
return tracker.textContent ?? "[]";
|
|
14889
14889
|
}
|
|
14890
|
+
var schedulingRoots = /* @__PURE__ */ new WeakMap();
|
|
14891
|
+
function unmountSchedulingWrapper(wrapper) {
|
|
14892
|
+
const root = schedulingRoots.get(wrapper);
|
|
14893
|
+
if (root) {
|
|
14894
|
+
schedulingRoots.delete(wrapper);
|
|
14895
|
+
setTimeout(() => root.unmount(), 0);
|
|
14896
|
+
}
|
|
14897
|
+
wrapper.remove();
|
|
14898
|
+
}
|
|
14890
14899
|
function schedulingSectionId(insertAfter) {
|
|
14891
14900
|
return `scheduling-${insertAfter}`;
|
|
14892
14901
|
}
|
|
@@ -14940,12 +14949,12 @@ function retryMissingSchedulingMounts(entries, notifyOnConnect = false) {
|
|
|
14940
14949
|
if (!hasMissingSchedulingWidgets(entries)) return;
|
|
14941
14950
|
mountSchedulingEntries(entries, notifyOnConnect);
|
|
14942
14951
|
}
|
|
14943
|
-
function initSectionsFromContent(content, removeExisting = false) {
|
|
14952
|
+
function initSectionsFromContent(content, removeExisting = false, currentPath = typeof window !== "undefined" ? window.location.pathname : "/") {
|
|
14944
14953
|
const raw = content["__ohw_sections"];
|
|
14945
14954
|
if (!raw) return;
|
|
14946
14955
|
try {
|
|
14947
14956
|
if (removeExisting) {
|
|
14948
|
-
document.querySelectorAll('[data-ohw-section-container="scheduling"]').forEach((el) => el
|
|
14957
|
+
document.querySelectorAll('[data-ohw-section-container="scheduling"]').forEach((el) => unmountSchedulingWrapper(el));
|
|
14949
14958
|
}
|
|
14950
14959
|
const inEditor = typeof window !== "undefined" && window.self !== window.top;
|
|
14951
14960
|
if (inEditor) getSectionsTracker().textContent = raw;
|
|
@@ -14953,8 +14962,16 @@ function initSectionsFromContent(content, removeExisting = false) {
|
|
|
14953
14962
|
const preExisting = pageEntries.filter((e) => !isSchedulingWidgetMissing(e));
|
|
14954
14963
|
const notifyForEntry = inEditor ? (e) => !e.scheduleId : false;
|
|
14955
14964
|
mountSchedulingEntries(pageEntries, notifyForEntry);
|
|
14956
|
-
|
|
14957
|
-
|
|
14965
|
+
const reapplyOrder = () => applyPersistedOrder(getPageSectionOrderEntries(content[SECTION_ORDER_KEY], currentPath));
|
|
14966
|
+
reapplyOrder();
|
|
14967
|
+
requestAnimationFrame(() => {
|
|
14968
|
+
retryMissingSchedulingMounts(pageEntries, notifyForEntry);
|
|
14969
|
+
reapplyOrder();
|
|
14970
|
+
});
|
|
14971
|
+
setTimeout(() => {
|
|
14972
|
+
retryMissingSchedulingMounts(pageEntries, notifyForEntry);
|
|
14973
|
+
reapplyOrder();
|
|
14974
|
+
}, 250);
|
|
14958
14975
|
for (const entry of preExisting) {
|
|
14959
14976
|
window.postMessage({ type: "ow:schedule-config", insertAfter: entry.insertAfter, scheduleId: entry.scheduleId ?? null }, "*");
|
|
14960
14977
|
}
|
|
@@ -14969,6 +14986,8 @@ function mountSchedulingWidget(insertAfter, notifyOnConnect = false, scheduleId,
|
|
|
14969
14986
|
if (!mountPoint) return false;
|
|
14970
14987
|
const container = document.createElement("div");
|
|
14971
14988
|
container.dataset.ohwSectionContainer = "scheduling";
|
|
14989
|
+
container.dataset.ohwSection = sectionId;
|
|
14990
|
+
container.dataset.ohwInstance = sectionId;
|
|
14972
14991
|
if (insertBefore) {
|
|
14973
14992
|
const beforeAnchor = document.querySelector(`[data-ohw-section="${insertBefore}"]`);
|
|
14974
14993
|
const beforePoint = beforeAnchor?.closest('[data-ohw-section-container="scheduling"]') ?? beforeAnchor;
|
|
@@ -14982,6 +15001,7 @@ function mountSchedulingWidget(insertAfter, notifyOnConnect = false, scheduleId,
|
|
|
14982
15001
|
tail.insertAdjacentElement("afterend", container);
|
|
14983
15002
|
}
|
|
14984
15003
|
const root = createRoot2(container);
|
|
15004
|
+
schedulingRoots.set(container, root);
|
|
14985
15005
|
flushSync2(() => {
|
|
14986
15006
|
root.render(
|
|
14987
15007
|
/* @__PURE__ */ jsx33(
|
|
@@ -20276,6 +20296,33 @@ function OhhwellsBridge() {
|
|
|
20276
20296
|
if (e.data?.type !== "ow:delete-section") return;
|
|
20277
20297
|
const instanceId = typeof e.data.instanceId === "string" ? e.data.instanceId : "";
|
|
20278
20298
|
if (!instanceId) return;
|
|
20299
|
+
if (instanceId.startsWith("scheduling-")) {
|
|
20300
|
+
const insertAfter = instanceId.slice("scheduling-".length);
|
|
20301
|
+
const el = document.querySelector(`[data-ohw-section="${CSS.escape(instanceId)}"]`);
|
|
20302
|
+
const wrapper = el?.closest('[data-ohw-section-container="scheduling"]') ?? null;
|
|
20303
|
+
if (wrapper) {
|
|
20304
|
+
unmountSchedulingWrapper(wrapper);
|
|
20305
|
+
} else {
|
|
20306
|
+
el?.setAttribute("style", "display:none");
|
|
20307
|
+
}
|
|
20308
|
+
const tracker = getSectionsTracker();
|
|
20309
|
+
let sections = [];
|
|
20310
|
+
try {
|
|
20311
|
+
sections = JSON.parse(tracker.textContent || "[]");
|
|
20312
|
+
} catch {
|
|
20313
|
+
}
|
|
20314
|
+
const currentPath = window.location.pathname;
|
|
20315
|
+
const updated = sections.filter(
|
|
20316
|
+
(s) => !(s.type === "scheduling" && s.insertAfter === insertAfter && (!s.pagePath || s.pagePath === currentPath))
|
|
20317
|
+
);
|
|
20318
|
+
tracker.textContent = JSON.stringify(updated);
|
|
20319
|
+
postToParentRef.current({ type: "ow:change", nodes: [{ key: "__ohw_sections", text: tracker.textContent }] });
|
|
20320
|
+
aiSectionApiRef.current?.clear();
|
|
20321
|
+
window.dispatchEvent(new Event("resize"));
|
|
20322
|
+
const height = document.body.scrollHeight;
|
|
20323
|
+
if (height > 50) postToParentRef.current({ type: "ow:height", height });
|
|
20324
|
+
return;
|
|
20325
|
+
}
|
|
20279
20326
|
const currentEntries = getPageSectionOrderEntries(editContentRef.current[SECTION_ORDER_KEY], window.location.pathname);
|
|
20280
20327
|
const entries = deleteSectionInstance(instanceId, window.location.pathname, currentEntries);
|
|
20281
20328
|
if (!entries) return;
|
|
@@ -21236,7 +21283,7 @@ function OhhwellsBridge() {
|
|
|
21236
21283
|
postToParent2({
|
|
21237
21284
|
type: "ow:ready",
|
|
21238
21285
|
version: "1",
|
|
21239
|
-
bridgeVersion: "0.1.
|
|
21286
|
+
bridgeVersion: "0.1.90",
|
|
21240
21287
|
path: pathname,
|
|
21241
21288
|
nodes: collectEditableNodes(editContentRef.current),
|
|
21242
21289
|
sections
|