@ohhwells/bridge 0.1.179-next.480 → 0.1.179-next.481

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
@@ -124,6 +124,7 @@ __export(index_exports, {
124
124
  isStickySearchParam: () => isStickySearchParam,
125
125
  isValidUrl: () => isValidUrl,
126
126
  layoutPreviewBackground: () => layoutPreviewBackground,
127
+ layoutPreviewBackgroundOf: () => layoutPreviewBackgroundOf,
127
128
  linearGradientColourAt: () => linearGradientColourAt,
128
129
  logoVersionNodesFromMessage: () => logoVersionNodesFromMessage,
129
130
  mapRegionToImage: () => mapRegionToImage,
@@ -13522,6 +13523,15 @@ function layoutPreviewBackground(backgroundColor, backgroundImage) {
13522
13523
  if (!color || TRANSPARENT2.test(color)) return "#ffffff";
13523
13524
  return color;
13524
13525
  }
13526
+ function layoutPreviewBackgroundOf(layers) {
13527
+ for (const { backgroundColor, backgroundImage } of layers) {
13528
+ const image = backgroundImage?.trim();
13529
+ if (image && image !== "none") return "#ffffff";
13530
+ const color = backgroundColor?.trim();
13531
+ if (color && !TRANSPARENT2.test(color)) return color;
13532
+ }
13533
+ return "#ffffff";
13534
+ }
13525
13535
  function isLayoutPreviewRequest(value) {
13526
13536
  if (!value || typeof value !== "object") return false;
13527
13537
  const v = value;
@@ -13575,15 +13585,15 @@ async function settle(host) {
13575
13585
  wait(SETTLE_CAP_MS)
13576
13586
  ]);
13577
13587
  }
13578
- function backgroundOf(host) {
13588
+ function backgroundOf(host, parent) {
13589
+ const layers = [];
13579
13590
  let el = host.firstElementChild;
13580
13591
  for (let depth = 0; el && depth < 3; depth++) {
13581
- const cs = getComputedStyle(el);
13582
- const bg = layoutPreviewBackground(cs.backgroundColor, cs.backgroundImage);
13583
- if (bg !== "#ffffff" || cs.backgroundImage && cs.backgroundImage !== "none") return bg;
13592
+ layers.push(getComputedStyle(el));
13584
13593
  el = el.firstElementChild;
13585
13594
  }
13586
- return "#ffffff";
13595
+ for (let up = parent; up; up = up.parentElement) layers.push(getComputedStyle(up));
13596
+ return layoutPreviewBackgroundOf(layers);
13587
13597
  }
13588
13598
  async function renderOne(layout, req, anchor, width) {
13589
13599
  const empty = { id: layout.id, doc: "", width, height: 0, bg: "#ffffff" };
@@ -13614,7 +13624,7 @@ async function renderOne(layout, req, anchor, width) {
13614
13624
  const rect = host.getBoundingClientRect();
13615
13625
  const height = Math.max(1, Math.round(Math.max(rect.height, host.scrollHeight)));
13616
13626
  const doc = buildLayoutPreviewDoc(host.innerHTML, readPageContext(parent), width);
13617
- return { id: layout.id, doc, width, height, bg: backgroundOf(host) };
13627
+ return { id: layout.id, doc, width, height, bg: backgroundOf(host, parent) };
13618
13628
  } catch {
13619
13629
  return empty;
13620
13630
  } finally {
@@ -20701,7 +20711,7 @@ function apiBase() {
20701
20711
  function bridgeVersion() {
20702
20712
  try {
20703
20713
  if (true) {
20704
- return "0.1.179-next.480";
20714
+ return "0.1.179-next.481";
20705
20715
  }
20706
20716
  } catch {
20707
20717
  }
@@ -20715,7 +20725,7 @@ function stampBridgeVersionOnDocument() {
20715
20725
  return;
20716
20726
  }
20717
20727
  try {
20718
- const v = true ? "0.1.179-next.480" : "";
20728
+ const v = true ? "0.1.179-next.481" : "";
20719
20729
  if (v) {
20720
20730
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
20721
20731
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -36033,7 +36043,7 @@ function OhhwellsBridge() {
36033
36043
  postToParent2({
36034
36044
  type: "ow:ready",
36035
36045
  version: "1",
36036
- bridgeVersion: "0.1.179-next.480",
36046
+ bridgeVersion: "0.1.179-next.481",
36037
36047
  path: pathname,
36038
36048
  nodes: collectEditableNodes(editContentRef.current),
36039
36049
  sections
@@ -37502,6 +37512,7 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
37502
37512
  isStickySearchParam,
37503
37513
  isValidUrl,
37504
37514
  layoutPreviewBackground,
37515
+ layoutPreviewBackgroundOf,
37505
37516
  linearGradientColourAt,
37506
37517
  logoVersionNodesFromMessage,
37507
37518
  mapRegionToImage,