@ohhwells/bridge 0.1.164-next.438 → 0.1.164-next.439

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 CHANGED
@@ -6548,6 +6548,24 @@ function deleteSectionFromState(state, sectionId) {
6548
6548
  if (removed.includes(sectionId)) return state;
6549
6549
  return { ...state, v: 1, sections: state.sections, removed: [...removed, sectionId] };
6550
6550
  }
6551
+ function moveSectionInState(state, sectionId, targetPath) {
6552
+ const entry = state.sections.find((section) => section.id === sectionId);
6553
+ if (!entry) return null;
6554
+ const moved = {
6555
+ id: entry.id,
6556
+ label: entry.label,
6557
+ path: targetPath,
6558
+ afterSection: null,
6559
+ tree: entry.tree,
6560
+ media: entry.media,
6561
+ ...entry.brand ? { brand: entry.brand } : {}
6562
+ };
6563
+ return {
6564
+ ...state,
6565
+ v: 1,
6566
+ sections: state.sections.map((section) => section.id === sectionId ? moved : section)
6567
+ };
6568
+ }
6551
6569
  function reapRemovedAiSections(state, store, removedIds, excludeIds = /* @__PURE__ */ new Set()) {
6552
6570
  const generated = new Set(state.sections.map((entry) => entry.id));
6553
6571
  const reapedIds = [...new Set(removedIds)].filter((id) => generated.has(id) && !excludeIds.has(id));
@@ -17668,7 +17686,7 @@ function apiBase() {
17668
17686
  function bridgeVersion() {
17669
17687
  try {
17670
17688
  if (true) {
17671
- return "0.1.164-next.438";
17689
+ return "0.1.164-next.439";
17672
17690
  }
17673
17691
  } catch {
17674
17692
  }
@@ -17682,7 +17700,7 @@ function stampBridgeVersionOnDocument() {
17682
17700
  return;
17683
17701
  }
17684
17702
  try {
17685
- const v = true ? "0.1.164-next.438" : "";
17703
+ const v = true ? "0.1.164-next.439" : "";
17686
17704
  if (v) {
17687
17705
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17688
17706
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -31338,6 +31356,31 @@ function OhhwellsBridge() {
31338
31356
  postAiSectionsChanged();
31339
31357
  };
31340
31358
  window.addEventListener("message", handleAiDeleteSection);
31359
+ const handleAiMoveSection = (e) => {
31360
+ if (e.data?.type !== "ow:ai-move-section") return;
31361
+ const sectionId = typeof e.data.sectionId === "string" ? e.data.sectionId : "";
31362
+ const targetPage = typeof e.data.targetPage === "string" ? e.data.targetPage : "";
31363
+ if (!sectionId || !targetPage) return;
31364
+ const previous = aiSectionsRef.current;
31365
+ const nextState = moveSectionInState(parseAiSectionsState(previous), sectionId, targetPage);
31366
+ if (!nextState) return;
31367
+ clearInteractionChrome();
31368
+ const nextValue = serializeAiSectionsState(nextState);
31369
+ aiSectionsRef.current = nextValue;
31370
+ applyAiSectionsToDom(nextState);
31371
+ const newHeight = document.body.scrollHeight;
31372
+ if (newHeight > 50) postToParentRef.current({ type: "ow:height", height: newHeight });
31373
+ postToParentRef.current({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: nextValue }] });
31374
+ postToParentRef.current({
31375
+ type: "ow:ai-section-moved",
31376
+ sectionId,
31377
+ targetPage,
31378
+ previous,
31379
+ value: nextValue
31380
+ });
31381
+ postAiSectionsChanged();
31382
+ };
31383
+ window.addEventListener("message", handleAiMoveSection);
31341
31384
  const handleAiSetSections = (e) => {
31342
31385
  if (e.data?.type !== "ow:ai-set-sections") return;
31343
31386
  const value = typeof e.data.value === "string" ? e.data.value : "";
@@ -32543,6 +32586,7 @@ function OhhwellsBridge() {
32543
32586
  window.removeEventListener("message", handleAiApplyTree);
32544
32587
  window.removeEventListener("message", handleAiApplyFooter);
32545
32588
  window.removeEventListener("message", handleAiDeleteSection);
32589
+ window.removeEventListener("message", handleAiMoveSection);
32546
32590
  window.removeEventListener("message", handleAiSetSections);
32547
32591
  window.removeEventListener("message", handleAiSetBrand);
32548
32592
  window.removeEventListener("message", handleAiSetStyles);
@@ -32856,7 +32900,7 @@ function OhhwellsBridge() {
32856
32900
  postToParent2({
32857
32901
  type: "ow:ready",
32858
32902
  version: "1",
32859
- bridgeVersion: "0.1.164-next.438",
32903
+ bridgeVersion: "0.1.164-next.439",
32860
32904
  path: pathname,
32861
32905
  nodes: collectEditableNodes(editContentRef.current),
32862
32906
  sections