@ohhwells/bridge 0.1.72-next.225 → 0.1.73-next.227
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 +30 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2010,6 +2010,29 @@ function syncReplacedOriginals(state) {
|
|
|
2010
2010
|
}
|
|
2011
2011
|
}
|
|
2012
2012
|
}
|
|
2013
|
+
var sectionOrderIndex = /* @__PURE__ */ new Map();
|
|
2014
|
+
function setAiSectionOrder(raw, currentPath) {
|
|
2015
|
+
const next = /* @__PURE__ */ new Map();
|
|
2016
|
+
if (raw) {
|
|
2017
|
+
try {
|
|
2018
|
+
const entries = JSON.parse(raw);
|
|
2019
|
+
for (const entry of entries) {
|
|
2020
|
+
if (!entry.pagePath || entry.pagePath === currentPath) next.set(entry.instanceId, entry.order);
|
|
2021
|
+
}
|
|
2022
|
+
} catch {
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
sectionOrderIndex = next;
|
|
2026
|
+
}
|
|
2027
|
+
function applyExplicitOrder(entries) {
|
|
2028
|
+
if (sectionOrderIndex.size === 0) return entries;
|
|
2029
|
+
return entries.map((entry, index) => ({ entry, index, order: sectionOrderIndex.get(entry.id) })).sort((a, b) => {
|
|
2030
|
+
if (a.order === void 0 && b.order === void 0) return a.index - b.index;
|
|
2031
|
+
if (a.order === void 0) return 1;
|
|
2032
|
+
if (b.order === void 0) return -1;
|
|
2033
|
+
return a.order - b.order;
|
|
2034
|
+
}).map((item) => item.entry);
|
|
2035
|
+
}
|
|
2013
2036
|
function orderByChain(sections) {
|
|
2014
2037
|
const ids = new Set(sections.map((entry) => entry.id));
|
|
2015
2038
|
const after = /* @__PURE__ */ new Map();
|
|
@@ -2043,7 +2066,7 @@ function applyAiSectionsToDom(state, options) {
|
|
|
2043
2066
|
const pagePath = window.location.pathname;
|
|
2044
2067
|
const pageSections = state.sections.filter((entry) => (entry.path ?? "/") === pagePath);
|
|
2045
2068
|
const activeIds = new Set(pageSections.map((entry) => entry.id));
|
|
2046
|
-
const ordered = state.hideTemplate === true ? orderByChain(pageSections) : pageSections;
|
|
2069
|
+
const ordered = state.hideTemplate === true ? applyExplicitOrder(orderByChain(pageSections)) : pageSections;
|
|
2047
2070
|
for (const [id, section] of mounted) {
|
|
2048
2071
|
if (!activeIds.has(id)) {
|
|
2049
2072
|
section.root.unmount();
|
|
@@ -13996,6 +14019,7 @@ function useSectionDrag({
|
|
|
13996
14019
|
}
|
|
13997
14020
|
const orderJson = JSON.stringify(entries);
|
|
13998
14021
|
editContentRef.current = { ...editContentRef.current, [SECTION_ORDER_KEY]: orderJson };
|
|
14022
|
+
setAiSectionOrder(orderJson, window.location.pathname);
|
|
13999
14023
|
postToParentRef.current({ type: "ow:change", nodes: [{ key: SECTION_ORDER_KEY, text: orderJson }] });
|
|
14000
14024
|
applyPersistedOrder(entries);
|
|
14001
14025
|
clearSectionDragVisuals();
|
|
@@ -17801,6 +17825,7 @@ function OhhwellsBridge() {
|
|
|
17801
17825
|
}
|
|
17802
17826
|
if (typeof content[AI_SECTIONS_KEY] === "string") {
|
|
17803
17827
|
aiSectionsRef.current = content[AI_SECTIONS_KEY];
|
|
17828
|
+
setAiSectionOrder(content[SECTION_ORDER_KEY], window.location.pathname);
|
|
17804
17829
|
applyAiSectionsToDom(parseAiSectionsState(content[AI_SECTIONS_KEY]));
|
|
17805
17830
|
}
|
|
17806
17831
|
if (typeof content[STYLE_STORE_KEY] === "string") {
|
|
@@ -18005,6 +18030,7 @@ function OhhwellsBridge() {
|
|
|
18005
18030
|
applyBrandToDom(null);
|
|
18006
18031
|
}
|
|
18007
18032
|
if (typeof content[AI_SECTIONS_KEY] === "string") {
|
|
18033
|
+
setAiSectionOrder(content[SECTION_ORDER_KEY], window.location.pathname);
|
|
18008
18034
|
applyAiSectionsToDom(parseAiSectionsState(content[AI_SECTIONS_KEY]));
|
|
18009
18035
|
}
|
|
18010
18036
|
if (typeof content[STYLE_STORE_KEY] === "string") {
|
|
@@ -19899,6 +19925,7 @@ function OhhwellsBridge() {
|
|
|
19899
19925
|
}
|
|
19900
19926
|
if (typeof content[AI_SECTIONS_KEY] === "string") {
|
|
19901
19927
|
aiSectionsRef.current = content[AI_SECTIONS_KEY];
|
|
19928
|
+
setAiSectionOrder(content[SECTION_ORDER_KEY], window.location.pathname);
|
|
19902
19929
|
applyAiSectionsToDom(parseAiSectionsState(content[AI_SECTIONS_KEY]));
|
|
19903
19930
|
}
|
|
19904
19931
|
if (typeof content[STYLE_STORE_KEY] === "string") {
|
|
@@ -20087,6 +20114,7 @@ function OhhwellsBridge() {
|
|
|
20087
20114
|
if (!entries) return;
|
|
20088
20115
|
const orderJson = JSON.stringify(entries);
|
|
20089
20116
|
editContentRef.current = { ...editContentRef.current, [SECTION_ORDER_KEY]: orderJson };
|
|
20117
|
+
setAiSectionOrder(orderJson, window.location.pathname);
|
|
20090
20118
|
postToParentRef.current({ type: "ow:change", nodes: [{ key: SECTION_ORDER_KEY, text: orderJson }] });
|
|
20091
20119
|
window.dispatchEvent(new Event("resize"));
|
|
20092
20120
|
};
|
|
@@ -21071,7 +21099,7 @@ function OhhwellsBridge() {
|
|
|
21071
21099
|
postToParent2({
|
|
21072
21100
|
type: "ow:ready",
|
|
21073
21101
|
version: "1",
|
|
21074
|
-
bridgeVersion: "0.1.
|
|
21102
|
+
bridgeVersion: "0.1.73",
|
|
21075
21103
|
path: pathname,
|
|
21076
21104
|
nodes: collectEditableNodes(editContentRef.current),
|
|
21077
21105
|
sections
|