@ohhwells/bridge 0.1.158-next.422 → 0.1.158-next.424
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 +185 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -1
- package/dist/index.d.ts +58 -1
- package/dist/index.js +185 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -220,6 +220,56 @@ function isRenderableTree(value) {
|
|
|
220
220
|
return AI_TREE_SCHEMA_VERSIONS.includes(tree.schemaVersion) && tree.type === "section" && Array.isArray(tree.rows);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
// src/lib/headline-size.ts
|
|
224
|
+
var HEADLINE_SIZE_MULTIPLIERS = {
|
|
225
|
+
xs: 0.7,
|
|
226
|
+
sm: 0.85,
|
|
227
|
+
base: 1,
|
|
228
|
+
lg: 1.2,
|
|
229
|
+
xl: 1.45,
|
|
230
|
+
"2xl": 1.75
|
|
231
|
+
};
|
|
232
|
+
var HEADLINE_SIZE_ATTR = "data-ohw-style-headlinesize";
|
|
233
|
+
var PREV_ATTR = "data-ohw-style-prev-fsmul";
|
|
234
|
+
var NODE_FONT_SIZE_ATTR = "data-ohw-style-prev-font-size";
|
|
235
|
+
function headingsIn(section) {
|
|
236
|
+
return Array.from(section.querySelectorAll("h1, h2, h3"));
|
|
237
|
+
}
|
|
238
|
+
function clearHeadlineSizes(root = document) {
|
|
239
|
+
for (const el of Array.from(root.querySelectorAll(`[${PREV_ATTR}]`))) {
|
|
240
|
+
const prev = el.getAttribute(PREV_ATTR) ?? "";
|
|
241
|
+
if (prev) el.style.setProperty("font-size", prev);
|
|
242
|
+
else el.style.removeProperty("font-size");
|
|
243
|
+
el.removeAttribute(PREV_ATTR);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function applyHeadlineSizes(root = document) {
|
|
247
|
+
clearHeadlineSizes(root);
|
|
248
|
+
for (const section of Array.from(
|
|
249
|
+
root.querySelectorAll(`[${HEADLINE_SIZE_ATTR}]`)
|
|
250
|
+
)) {
|
|
251
|
+
const multiplier = HEADLINE_SIZE_MULTIPLIERS[section.getAttribute(HEADLINE_SIZE_ATTR) ?? ""];
|
|
252
|
+
if (!multiplier || multiplier === 1) continue;
|
|
253
|
+
for (const heading of headingsIn(section)) {
|
|
254
|
+
if (heading.hasAttribute(NODE_FONT_SIZE_ATTR)) continue;
|
|
255
|
+
const base = Number.parseFloat(window.getComputedStyle(heading).fontSize);
|
|
256
|
+
if (!Number.isFinite(base) || base <= 0) continue;
|
|
257
|
+
heading.setAttribute(PREV_ATTR, heading.style.getPropertyValue("font-size"));
|
|
258
|
+
heading.style.setProperty("font-size", `${Math.round(base * multiplier * 100) / 100}px`, "important");
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
var resizeInstalled = false;
|
|
263
|
+
function installHeadlineSizeResize() {
|
|
264
|
+
if (resizeInstalled || typeof window === "undefined") return;
|
|
265
|
+
resizeInstalled = true;
|
|
266
|
+
let timer;
|
|
267
|
+
window.addEventListener("resize", () => {
|
|
268
|
+
if (timer) clearTimeout(timer);
|
|
269
|
+
timer = setTimeout(() => applyHeadlineSizes(), 120);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
223
273
|
// src/lib/sections.ts
|
|
224
274
|
var LINK_PICKER_EXCLUDED_IDS = /* @__PURE__ */ new Set(["navbar", "footer"]);
|
|
225
275
|
function isChromeSection(el) {
|
|
@@ -6011,6 +6061,7 @@ var SECTION_ATTRS = {
|
|
|
6011
6061
|
sectionBackground: "data-ohw-style-bg",
|
|
6012
6062
|
textDistribution: "data-ohw-style-distribution",
|
|
6013
6063
|
headlineScale: "data-ohw-style-headline",
|
|
6064
|
+
headlineSize: HEADLINE_SIZE_ATTR,
|
|
6014
6065
|
imageAspect: "data-ohw-style-aspect",
|
|
6015
6066
|
spacing: "data-ohw-style-spacing",
|
|
6016
6067
|
verticalPadding: "data-ohw-style-vpadding",
|
|
@@ -6079,6 +6130,15 @@ function clearSectionAttrs(root) {
|
|
|
6079
6130
|
}
|
|
6080
6131
|
}
|
|
6081
6132
|
var ITEM_WROTE_ATTR = "data-ohw-style-item";
|
|
6133
|
+
function paintIcon(slot, color) {
|
|
6134
|
+
for (const el of [slot, ...Array.from(slot.querySelectorAll("svg, svg *"))]) {
|
|
6135
|
+
const styled = el;
|
|
6136
|
+
if (!styled.style) continue;
|
|
6137
|
+
saveInline(styled, "color");
|
|
6138
|
+
styled.style.setProperty("color", color, "important");
|
|
6139
|
+
styled.setAttribute(NODE_WROTE_ATTR, "");
|
|
6140
|
+
}
|
|
6141
|
+
}
|
|
6082
6142
|
function clearNodeProps(root) {
|
|
6083
6143
|
for (const el of Array.from(root.querySelectorAll(`[${NODE_WROTE_ATTR}]`))) {
|
|
6084
6144
|
const h = el;
|
|
@@ -6116,6 +6176,7 @@ function applyStylesToDom(store) {
|
|
|
6116
6176
|
ensureStyleSheet();
|
|
6117
6177
|
clearSectionAttrs(document);
|
|
6118
6178
|
clearNodeProps(document);
|
|
6179
|
+
clearHeadlineSizes(document);
|
|
6119
6180
|
loadStyleFonts(
|
|
6120
6181
|
store ? [
|
|
6121
6182
|
...Object.values(store.nodes).flatMap((n) => n.fontFamily ? [n.fontFamily] : []),
|
|
@@ -6189,9 +6250,13 @@ function applyStylesToDom(store) {
|
|
|
6189
6250
|
const nodes = document.querySelectorAll(`[data-ohw-key="${CSS.escape(key)}"]`);
|
|
6190
6251
|
for (const el of Array.from(nodes)) {
|
|
6191
6252
|
if (override.color !== void 0) {
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6253
|
+
if (el.dataset.ohwEditable === "icon") {
|
|
6254
|
+
paintIcon(el, override.color);
|
|
6255
|
+
} else {
|
|
6256
|
+
saveInline(el, "color");
|
|
6257
|
+
el.style.setProperty("color", override.color, "important");
|
|
6258
|
+
el.setAttribute(NODE_WROTE_ATTR, "");
|
|
6259
|
+
}
|
|
6195
6260
|
}
|
|
6196
6261
|
if (override.fontFamily !== void 0) {
|
|
6197
6262
|
saveInline(el, "font-family");
|
|
@@ -6248,6 +6313,18 @@ function applyStylesToDom(store) {
|
|
|
6248
6313
|
}
|
|
6249
6314
|
}
|
|
6250
6315
|
}
|
|
6316
|
+
for (const [sectionId, override] of Object.entries(store.sections)) {
|
|
6317
|
+
if (override.iconColor === void 0) continue;
|
|
6318
|
+
const escaped = CSS.escape(sectionId);
|
|
6319
|
+
const byInstance = document.querySelectorAll(`[data-ohw-instance="${escaped}"]`);
|
|
6320
|
+
const sections = byInstance.length ? byInstance : document.querySelectorAll(`[data-ohw-section="${escaped}"]`);
|
|
6321
|
+
for (const marker of Array.from(sections)) {
|
|
6322
|
+
const icons = marker.querySelectorAll('[data-ohw-editable="icon"]');
|
|
6323
|
+
for (const el of Array.from(icons)) paintIcon(el, override.iconColor);
|
|
6324
|
+
}
|
|
6325
|
+
}
|
|
6326
|
+
applyHeadlineSizes(document);
|
|
6327
|
+
installHeadlineSizeResize();
|
|
6251
6328
|
}
|
|
6252
6329
|
|
|
6253
6330
|
// src/lib/ai-sections-store.ts
|
|
@@ -6287,17 +6364,21 @@ function resolveSectionTree(sectionId, aiSectionsRaw) {
|
|
|
6287
6364
|
return parseAiSectionsState(aiSectionsRaw).sections.find((entry) => entry.id === sectionId)?.tree;
|
|
6288
6365
|
}
|
|
6289
6366
|
function resolveSectionSettingsContext(sectionId, aiSectionsRaw, stylesRaw) {
|
|
6367
|
+
const styleOverride = parseStyleStore(stylesRaw)?.sections[sectionId];
|
|
6368
|
+
const headlineSize = styleOverride?.headlineSize;
|
|
6290
6369
|
const genSettings = parseAiSectionsState(aiSectionsRaw).sections.find(
|
|
6291
6370
|
(entry) => entry.id === sectionId
|
|
6292
6371
|
)?.tree.settings;
|
|
6293
|
-
if (genSettings)
|
|
6294
|
-
|
|
6295
|
-
|
|
6372
|
+
if (genSettings) {
|
|
6373
|
+
return { ...genSettings, ...headlineSize ? { headlineSize } : {} };
|
|
6374
|
+
}
|
|
6375
|
+
if (!styleOverride?.verticalPadding && !styleOverride?.minHeight && !styleOverride?.spacing && !headlineSize) {
|
|
6296
6376
|
return void 0;
|
|
6297
6377
|
}
|
|
6298
6378
|
return {
|
|
6299
|
-
verticalPadding: styleOverride
|
|
6300
|
-
minHeight: styleOverride
|
|
6379
|
+
verticalPadding: styleOverride?.verticalPadding ?? legacyVerticalPaddingAlias(styleOverride?.spacing),
|
|
6380
|
+
minHeight: styleOverride?.minHeight,
|
|
6381
|
+
...headlineSize ? { headlineSize } : {}
|
|
6301
6382
|
};
|
|
6302
6383
|
}
|
|
6303
6384
|
function applyTreeToState(state, payload) {
|
|
@@ -17286,7 +17367,7 @@ function apiBase() {
|
|
|
17286
17367
|
function bridgeVersion() {
|
|
17287
17368
|
try {
|
|
17288
17369
|
if (true) {
|
|
17289
|
-
return "0.1.158-next.
|
|
17370
|
+
return "0.1.158-next.424";
|
|
17290
17371
|
}
|
|
17291
17372
|
} catch {
|
|
17292
17373
|
}
|
|
@@ -17300,7 +17381,7 @@ function stampBridgeVersionOnDocument() {
|
|
|
17300
17381
|
return;
|
|
17301
17382
|
}
|
|
17302
17383
|
try {
|
|
17303
|
-
const v = true ? "0.1.158-next.
|
|
17384
|
+
const v = true ? "0.1.158-next.424" : "";
|
|
17304
17385
|
if (v) {
|
|
17305
17386
|
document.documentElement.setAttribute("data-ohw-bridge-version", v);
|
|
17306
17387
|
window.__OHW_BRIDGE_VERSION__ = v;
|
|
@@ -18209,6 +18290,89 @@ function CarouselOverlay({
|
|
|
18209
18290
|
// src/ui/ai-section/AiSectionOverlay.tsx
|
|
18210
18291
|
var import_react9 = require("react");
|
|
18211
18292
|
var import_lucide_react7 = require("lucide-react");
|
|
18293
|
+
|
|
18294
|
+
// src/lib/ai-change-highlight.ts
|
|
18295
|
+
var STYLE_ID = "ohw-ai-changed-style";
|
|
18296
|
+
var MARK_ATTR = "data-ohw-ai-changed";
|
|
18297
|
+
var HIGHLIGHT_MS = 2200;
|
|
18298
|
+
var HIGHLIGHT_CSS = `
|
|
18299
|
+
@keyframes ohw-ai-changed-pulse {
|
|
18300
|
+
0% { outline-color: rgba(0, 120, 229, 0.95); box-shadow: 0 0 0 5px rgba(0, 120, 229, 0.20); }
|
|
18301
|
+
72% { outline-color: rgba(0, 120, 229, 0.95); box-shadow: 0 0 0 5px rgba(0, 120, 229, 0.12); }
|
|
18302
|
+
100% { outline-color: rgba(0, 120, 229, 0); box-shadow: 0 0 0 5px rgba(0, 120, 229, 0); }
|
|
18303
|
+
}
|
|
18304
|
+
[${MARK_ATTR}] {
|
|
18305
|
+
outline: 2px solid rgba(0, 120, 229, 0.95) !important;
|
|
18306
|
+
outline-offset: 3px !important;
|
|
18307
|
+
animation: ohw-ai-changed-pulse ${HIGHLIGHT_MS}ms ease-out forwards !important;
|
|
18308
|
+
}
|
|
18309
|
+
@media (prefers-reduced-motion: reduce) {
|
|
18310
|
+
[${MARK_ATTR}] { animation: none !important; }
|
|
18311
|
+
}
|
|
18312
|
+
`;
|
|
18313
|
+
function ensureStyleSheet2() {
|
|
18314
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
18315
|
+
const el = document.createElement("style");
|
|
18316
|
+
el.id = STYLE_ID;
|
|
18317
|
+
el.textContent = HIGHLIGHT_CSS;
|
|
18318
|
+
document.head.appendChild(el);
|
|
18319
|
+
}
|
|
18320
|
+
function targetsFor(keys, item) {
|
|
18321
|
+
const out = /* @__PURE__ */ new Set();
|
|
18322
|
+
for (const key of keys) {
|
|
18323
|
+
if (!key) continue;
|
|
18324
|
+
for (const el of Array.from(
|
|
18325
|
+
document.querySelectorAll(`[data-ohw-key="${CSS.escape(key)}"]`)
|
|
18326
|
+
)) {
|
|
18327
|
+
out.add(el);
|
|
18328
|
+
}
|
|
18329
|
+
}
|
|
18330
|
+
if (item) {
|
|
18331
|
+
const section = document.querySelector(`[data-ohw-instance="${CSS.escape(item.sectionId)}"]`) ?? document.querySelector(`[data-ohw-section="${CSS.escape(item.sectionId)}"]`);
|
|
18332
|
+
const stamp = `${item.group}:${item.index}`;
|
|
18333
|
+
const el = section?.querySelector(`[data-ohw-item="${CSS.escape(stamp)}"]`);
|
|
18334
|
+
if (el) out.add(el);
|
|
18335
|
+
}
|
|
18336
|
+
return [...out];
|
|
18337
|
+
}
|
|
18338
|
+
var clearTimer = null;
|
|
18339
|
+
function clearChangeHighlight() {
|
|
18340
|
+
if (clearTimer !== null) {
|
|
18341
|
+
clearTimeout(clearTimer);
|
|
18342
|
+
clearTimer = null;
|
|
18343
|
+
}
|
|
18344
|
+
for (const el of Array.from(document.querySelectorAll(`[${MARK_ATTR}]`))) {
|
|
18345
|
+
el.removeAttribute(MARK_ATTR);
|
|
18346
|
+
}
|
|
18347
|
+
}
|
|
18348
|
+
function highlightChangedElements(keys, item) {
|
|
18349
|
+
clearChangeHighlight();
|
|
18350
|
+
const targets = targetsFor(keys, item);
|
|
18351
|
+
if (targets.length === 0) return 0;
|
|
18352
|
+
ensureStyleSheet2();
|
|
18353
|
+
for (const el of targets) el.setAttribute(MARK_ATTR, "");
|
|
18354
|
+
const rect = targets[0].getBoundingClientRect();
|
|
18355
|
+
if (rect.bottom < 0 || rect.top > window.innerHeight) {
|
|
18356
|
+
targets[0].scrollIntoView({ behavior: "smooth", block: "center" });
|
|
18357
|
+
}
|
|
18358
|
+
clearTimer = setTimeout(clearChangeHighlight, HIGHLIGHT_MS);
|
|
18359
|
+
return targets.length;
|
|
18360
|
+
}
|
|
18361
|
+
function installAiChangeHighlight() {
|
|
18362
|
+
const onMessage = (e) => {
|
|
18363
|
+
const data = e.data;
|
|
18364
|
+
if (data?.type !== "ow:ai-highlight") return;
|
|
18365
|
+
const keys = Array.isArray(data.keys) ? data.keys.filter((k) => typeof k === "string") : [];
|
|
18366
|
+
const raw = data.item;
|
|
18367
|
+
const item = raw && typeof raw.sectionId === "string" && typeof raw.group === "string" && typeof raw.index === "number" ? { sectionId: raw.sectionId, group: raw.group, index: raw.index } : void 0;
|
|
18368
|
+
const found = highlightChangedElements(keys, item);
|
|
18369
|
+
window.parent?.postMessage({ type: "ow:ai-highlight-done", found }, "*");
|
|
18370
|
+
};
|
|
18371
|
+
window.addEventListener("message", onMessage);
|
|
18372
|
+
return () => window.removeEventListener("message", onMessage);
|
|
18373
|
+
}
|
|
18374
|
+
|
|
18375
|
+
// src/ui/ai-section/AiSectionOverlay.tsx
|
|
18212
18376
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
18213
18377
|
var findSectionElement = findByInstanceId;
|
|
18214
18378
|
function readRect(instanceId) {
|
|
@@ -18460,6 +18624,7 @@ function AiSectionOverlay({
|
|
|
18460
18624
|
window.addEventListener("message", onMessage);
|
|
18461
18625
|
return () => window.removeEventListener("message", onMessage);
|
|
18462
18626
|
}, [postToParent2]);
|
|
18627
|
+
(0, import_react9.useEffect)(() => installAiChangeHighlight(), []);
|
|
18463
18628
|
const [hoveredId, setHoveredId] = (0, import_react9.useState)(null);
|
|
18464
18629
|
(0, import_react9.useEffect)(() => {
|
|
18465
18630
|
const onMove = (e) => {
|
|
@@ -31552,9 +31717,11 @@ function OhhwellsBridge() {
|
|
|
31552
31717
|
if (e.data?.type !== "ow:collect-section") return;
|
|
31553
31718
|
const sectionId = e.data.sectionId;
|
|
31554
31719
|
if (typeof sectionId !== "string" || !sectionId) return;
|
|
31555
|
-
const
|
|
31556
|
-
|
|
31720
|
+
const escapedSectionId = CSS.escape(sectionId);
|
|
31721
|
+
const instanceEl = document.querySelector(
|
|
31722
|
+
`[data-ohw-instance="${escapedSectionId}"]`
|
|
31557
31723
|
);
|
|
31724
|
+
const foundEl = instanceEl ? sectionElementOf(instanceEl) : document.querySelector(`[data-ohw-section="${escapedSectionId}"]`);
|
|
31558
31725
|
const sectionEl = foundEl && !foundEl.hasAttribute("data-ohw-ai-template-hidden") && !foundEl.hasAttribute("data-ohw-ai-removed") && !foundEl.hasAttribute("data-ohw-ai-replaced-by") ? foundEl : null;
|
|
31559
31726
|
const nodes = sectionEl ? collectEditableNodes(void 0, sectionEl).filter(
|
|
31560
31727
|
(n) => n.key && !n.key.startsWith("__ohw_") && !["meta", "sections", "video-setting"].includes(n.type)
|
|
@@ -31567,7 +31734,11 @@ function OhhwellsBridge() {
|
|
|
31567
31734
|
width: box.width,
|
|
31568
31735
|
height: box.height
|
|
31569
31736
|
} : null;
|
|
31570
|
-
const settings = resolveSectionSettingsContext(
|
|
31737
|
+
const settings = resolveSectionSettingsContext(
|
|
31738
|
+
sectionId,
|
|
31739
|
+
aiSectionsRef.current,
|
|
31740
|
+
stylesRef.current
|
|
31741
|
+
);
|
|
31571
31742
|
const tree = resolveSectionTree(sectionId, aiSectionsRef.current);
|
|
31572
31743
|
postToParentRef.current({
|
|
31573
31744
|
type: "ow:section-nodes",
|
|
@@ -32298,7 +32469,7 @@ function OhhwellsBridge() {
|
|
|
32298
32469
|
postToParent2({
|
|
32299
32470
|
type: "ow:ready",
|
|
32300
32471
|
version: "1",
|
|
32301
|
-
bridgeVersion: "0.1.158-next.
|
|
32472
|
+
bridgeVersion: "0.1.158-next.424",
|
|
32302
32473
|
path: pathname,
|
|
32303
32474
|
nodes: collectEditableNodes(editContentRef.current),
|
|
32304
32475
|
sections
|