@ohhwells/bridge 0.1.172 → 0.1.173

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.js CHANGED
@@ -1127,21 +1127,21 @@ function chromeFrom(sample) {
1127
1127
  };
1128
1128
  }
1129
1129
  function filledPrimary(seed) {
1130
- const paint = parseColor(paintColor(seed)) ?? { r: 15, g: 15, b: 15, a: 1 };
1131
- const luminance = relativeLuminance(paint);
1130
+ const paint3 = parseColor(paintColor(seed)) ?? { r: 15, g: 15, b: 15, a: 1 };
1131
+ const luminance = relativeLuminance(paint3);
1132
1132
  return {
1133
- background: toCss({ ...paint, a: 1 }),
1133
+ background: toCss({ ...paint3, a: 1 }),
1134
1134
  color: luminance > 0.55 ? "rgb(15, 15, 15)" : "rgb(255, 255, 255)",
1135
1135
  borderColor: TRANSPARENT,
1136
1136
  borderWidth: "0px"
1137
1137
  };
1138
1138
  }
1139
1139
  function generatedSecondary(primary) {
1140
- const paint = accentColor(primary);
1140
+ const paint3 = accentColor(primary);
1141
1141
  return {
1142
1142
  background: TRANSPARENT,
1143
- color: paint,
1144
- borderColor: paint,
1143
+ color: paint3,
1144
+ borderColor: paint3,
1145
1145
  borderWidth: "1px"
1146
1146
  };
1147
1147
  }
@@ -1154,9 +1154,9 @@ function generatedGhost(primary) {
1154
1154
  };
1155
1155
  }
1156
1156
  function normalizeOutlineChrome(outline, primary) {
1157
- const paint = accentColor(primary);
1157
+ const paint3 = accentColor(primary);
1158
1158
  const text = parseColor(outline.color);
1159
- const paintRgb = parseColor(paint);
1159
+ const paintRgb = parseColor(paint3);
1160
1160
  const primaryLabel = parseColor(primary.color);
1161
1161
  const matchesOnPrimary = Boolean(text && primaryLabel) && colorKey(outline.color) === colorKey(primary.color);
1162
1162
  const textTooLight = text ? relativeLuminance(text) > 0.7 : false;
@@ -1165,8 +1165,8 @@ function normalizeOutlineChrome(outline, primary) {
1165
1165
  const hasBorder = parseFloat(outline.borderWidth) > 0;
1166
1166
  return {
1167
1167
  ...outline,
1168
- color: paint,
1169
- borderColor: hasBorder ? paint : outline.borderColor
1168
+ color: paint3,
1169
+ borderColor: hasBorder ? paint3 : outline.borderColor
1170
1170
  };
1171
1171
  }
1172
1172
  function generateButtonVariants(samples) {
@@ -7649,6 +7649,174 @@ function findSelectableNavContainer(doc = document) {
7649
7649
  );
7650
7650
  }
7651
7651
 
7652
+ // src/lib/youtube.ts
7653
+ var YOUTUBE_ID_PATTERN = /^[A-Za-z0-9_-]{11}$/;
7654
+ function extractYouTubeId(input) {
7655
+ const trimmed = input.trim();
7656
+ if (!trimmed) return null;
7657
+ if (YOUTUBE_ID_PATTERN.test(trimmed)) return trimmed;
7658
+ let url;
7659
+ try {
7660
+ url = new URL(trimmed);
7661
+ } catch {
7662
+ return null;
7663
+ }
7664
+ const host = url.hostname.replace(/^www\./, "");
7665
+ if (host !== "youtube.com" && host !== "m.youtube.com" && host !== "youtu.be" && host !== "youtube-nocookie.com") {
7666
+ return null;
7667
+ }
7668
+ let candidate = null;
7669
+ if (host === "youtu.be") {
7670
+ candidate = url.pathname.slice(1).split("/")[0] ?? null;
7671
+ } else if (url.pathname === "/watch") {
7672
+ candidate = url.searchParams.get("v");
7673
+ } else {
7674
+ const match = url.pathname.match(/^\/(?:embed|shorts)\/([^/]+)/);
7675
+ candidate = match ? match[1] : null;
7676
+ }
7677
+ return candidate && YOUTUBE_ID_PATTERN.test(candidate) ? candidate : null;
7678
+ }
7679
+
7680
+ // src/lib/section-embed.ts
7681
+ var SECTION_EMBED_SUFFIX = "__ohw_embed";
7682
+ function readStoredEmbed(value) {
7683
+ if (value.startsWith("start\n")) {
7684
+ return { raw: value.slice("start\n".length), at: "start" };
7685
+ }
7686
+ return { raw: value, at: "end" };
7687
+ }
7688
+ function embedFrameSrc(value) {
7689
+ const videoId = extractYouTubeId(value);
7690
+ if (videoId) {
7691
+ return { src: `https://www.youtube-nocookie.com/embed/${videoId}?rel=0`, title: "YouTube video" };
7692
+ }
7693
+ let url;
7694
+ try {
7695
+ url = new URL(value);
7696
+ } catch {
7697
+ return null;
7698
+ }
7699
+ const host = url.hostname.replace(/^www\./, "").toLowerCase();
7700
+ if (host === "google.com" && url.pathname.startsWith("/maps") || host === "maps.google.com") {
7701
+ const query = url.searchParams.get("q") || url.searchParams.get("query") || "";
7702
+ const src = query ? `https://maps.google.com/maps?q=${encodeURIComponent(query)}&output=embed` : `https://maps.google.com/maps?output=embed`;
7703
+ return { src, title: "Map" };
7704
+ }
7705
+ if (host === "maps.app.goo.gl") {
7706
+ return { src: value, title: "Map" };
7707
+ }
7708
+ if (host === "calendly.com" || host.endsWith(".calendly.com") || host === "calendar.google.com") {
7709
+ return { src: value, title: "Calendar" };
7710
+ }
7711
+ if (host === "docs.google.com" && url.pathname.includes("/forms/")) {
7712
+ return { src: value.replace(/\/edit(?:\?.*)?$/i, "/viewform"), title: "Form" };
7713
+ }
7714
+ if (host === "forms.gle") {
7715
+ return { src: value, title: "Form" };
7716
+ }
7717
+ return null;
7718
+ }
7719
+ function place(section, box, at) {
7720
+ if (at === "start") {
7721
+ section.insertBefore(box, section.firstChild);
7722
+ return;
7723
+ }
7724
+ section.appendChild(box);
7725
+ }
7726
+ function paint(section, key, src, title, at) {
7727
+ const existing = section.querySelector(`[data-ohw-section-embed="${CSS.escape(key)}"]`);
7728
+ const frame = existing?.querySelector("iframe");
7729
+ if (existing && frame) {
7730
+ if (frame.getAttribute("src") !== src) frame.setAttribute("src", src);
7731
+ frame.title = title;
7732
+ place(section, existing, at);
7733
+ return;
7734
+ }
7735
+ existing?.remove();
7736
+ const box = document.createElement("div");
7737
+ box.setAttribute("data-ohw-section-embed", key);
7738
+ box.style.cssText = at === "start" ? "width:100%;max-width:960px;margin:0 auto 32px;padding:32px 24px 0;box-sizing:border-box;" : "width:100%;max-width:960px;margin:32px auto 0;padding:0 24px 32px;box-sizing:border-box;";
7739
+ const frameWrap = document.createElement("div");
7740
+ frameWrap.style.cssText = "position:relative;width:100%;aspect-ratio:16/9;min-height:250px;border-radius:12px;overflow:hidden;background:#0f172a;";
7741
+ const iframe = document.createElement("iframe");
7742
+ iframe.src = src;
7743
+ iframe.title = title;
7744
+ iframe.style.cssText = "position:absolute;inset:0;width:100%;height:100%;border:0;";
7745
+ iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture";
7746
+ iframe.setAttribute("allowfullscreen", "");
7747
+ frameWrap.appendChild(iframe);
7748
+ box.appendChild(frameWrap);
7749
+ place(section, box, at);
7750
+ }
7751
+ function applySectionEmbeds(content) {
7752
+ for (const [key, val] of Object.entries(content)) {
7753
+ if (!key.endsWith(SECTION_EMBED_SUFFIX)) continue;
7754
+ const sectionId = key.slice(0, -SECTION_EMBED_SUFFIX.length);
7755
+ const section = document.querySelector(`[data-ohw-section="${CSS.escape(sectionId)}"]`);
7756
+ const stored = typeof val === "string" ? readStoredEmbed(val) : null;
7757
+ const frame = stored ? embedFrameSrc(stored.raw) : null;
7758
+ if (!section || !stored || !frame) {
7759
+ section?.querySelector(`[data-ohw-section-embed="${CSS.escape(key)}"]`)?.remove();
7760
+ continue;
7761
+ }
7762
+ paint(section, key, frame.src, frame.title, stored.at);
7763
+ }
7764
+ }
7765
+
7766
+ // src/lib/section-extra.ts
7767
+ var SECTION_EXTRA_SUFFIX = "__ohw_extra";
7768
+ function placeUnderCards(section, box) {
7769
+ const cards = section.querySelector("[data-ohw-cards]");
7770
+ if (cards) {
7771
+ cards.after(box);
7772
+ return;
7773
+ }
7774
+ const viewAll = section.querySelector(".classes-viewall");
7775
+ if (viewAll && section.contains(viewAll)) {
7776
+ section.insertBefore(box, viewAll);
7777
+ return;
7778
+ }
7779
+ const copy = section.querySelector(".classes-copy");
7780
+ if (copy?.parentElement === section) {
7781
+ copy.after(box);
7782
+ return;
7783
+ }
7784
+ section.appendChild(box);
7785
+ }
7786
+ function paint2(section, key, text) {
7787
+ const existing = section.querySelector(`[data-ohw-section-extra="${CSS.escape(key)}"]`);
7788
+ if (existing) {
7789
+ const editable = existing.querySelector('[data-ohw-editable="text"]');
7790
+ if (editable && editable.innerHTML !== text) {
7791
+ editable.innerHTML = text;
7792
+ }
7793
+ placeUnderCards(section, existing);
7794
+ return;
7795
+ }
7796
+ const box = document.createElement("div");
7797
+ box.setAttribute("data-ohw-section-extra", key);
7798
+ box.style.cssText = "width:100%;max-width:720px;margin:48px auto 0;padding:0 48px;box-sizing:border-box;text-align:center;";
7799
+ const p = document.createElement("p");
7800
+ p.setAttribute("data-ohw-editable", "text");
7801
+ p.setAttribute("data-ohw-key", key);
7802
+ p.style.cssText = "font-family:var(--font-body, inherit);font-weight:400;font-size:clamp(15px,1.4vw,18px);line-height:1.55;margin:0;color:inherit;";
7803
+ p.innerHTML = text;
7804
+ box.appendChild(p);
7805
+ placeUnderCards(section, box);
7806
+ }
7807
+ function applySectionExtras(content) {
7808
+ for (const [key, val] of Object.entries(content)) {
7809
+ if (!key.endsWith(SECTION_EXTRA_SUFFIX)) continue;
7810
+ const sectionId = key.slice(0, -SECTION_EXTRA_SUFFIX.length);
7811
+ const section = document.querySelector(`[data-ohw-section="${CSS.escape(sectionId)}"]`);
7812
+ if (!section || typeof val !== "string" || !val.trim()) {
7813
+ section?.querySelector(`[data-ohw-section-extra="${CSS.escape(key)}"]`)?.remove();
7814
+ continue;
7815
+ }
7816
+ paint2(section, key, val);
7817
+ }
7818
+ }
7819
+
7652
7820
  // src/ui/ai-tree/aiSectionsManager.tsx
7653
7821
  import { flushSync } from "react-dom";
7654
7822
  import { createRoot } from "react-dom/client";
@@ -17817,7 +17985,7 @@ function apiBase() {
17817
17985
  function bridgeVersion() {
17818
17986
  try {
17819
17987
  if (true) {
17820
- return "0.1.172";
17988
+ return "0.1.173";
17821
17989
  }
17822
17990
  } catch {
17823
17991
  }
@@ -17831,7 +17999,7 @@ function stampBridgeVersionOnDocument() {
17831
17999
  return;
17832
18000
  }
17833
18001
  try {
17834
- const v = true ? "0.1.172" : "";
18002
+ const v = true ? "0.1.173" : "";
17835
18003
  if (v) {
17836
18004
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17837
18005
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -20622,34 +20790,6 @@ function clearVideo(tree, path) {
20622
20790
  });
20623
20791
  }
20624
20792
 
20625
- // src/lib/youtube.ts
20626
- var YOUTUBE_ID_PATTERN = /^[A-Za-z0-9_-]{11}$/;
20627
- function extractYouTubeId(input) {
20628
- const trimmed = input.trim();
20629
- if (!trimmed) return null;
20630
- if (YOUTUBE_ID_PATTERN.test(trimmed)) return trimmed;
20631
- let url;
20632
- try {
20633
- url = new URL(trimmed);
20634
- } catch {
20635
- return null;
20636
- }
20637
- const host = url.hostname.replace(/^www\./, "");
20638
- if (host !== "youtube.com" && host !== "m.youtube.com" && host !== "youtu.be" && host !== "youtube-nocookie.com") {
20639
- return null;
20640
- }
20641
- let candidate = null;
20642
- if (host === "youtu.be") {
20643
- candidate = url.pathname.slice(1).split("/")[0] ?? null;
20644
- } else if (url.pathname === "/watch") {
20645
- candidate = url.searchParams.get("v");
20646
- } else {
20647
- const match = url.pathname.match(/^\/(?:embed|shorts)\/([^/]+)/);
20648
- candidate = match ? match[1] : null;
20649
- }
20650
- return candidate && YOUTUBE_ID_PATTERN.test(candidate) ? candidate : null;
20651
- }
20652
-
20653
20793
  // src/ui/ai-section/AiVideoOverlay.tsx
20654
20794
  import { Fragment as Fragment9, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
20655
20795
  var PRIMARY5 = "#0885FE";
@@ -28820,6 +28960,7 @@ function OhhwellsBridge() {
28820
28960
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
28821
28961
  continue;
28822
28962
  }
28963
+ if (key.endsWith(SECTION_EMBED_SUFFIX) || key.endsWith(SECTION_EXTRA_SUFFIX)) continue;
28823
28964
  if (applyVideoSettingNode(key, val)) continue;
28824
28965
  if (applyCarouselNode(key, val)) continue;
28825
28966
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -28859,6 +29000,8 @@ function OhhwellsBridge() {
28859
29000
  });
28860
29001
  applyLinkByKey(key, val);
28861
29002
  }
29003
+ applySectionEmbeds(content);
29004
+ applySectionExtras(content);
28862
29005
  applyLogoFromContent(content);
28863
29006
  applyLogoSizes(content);
28864
29007
  reconcileNavbarItemsFromContent(content);
@@ -29062,6 +29205,7 @@ function OhhwellsBridge() {
29062
29205
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
29063
29206
  continue;
29064
29207
  }
29208
+ if (key.endsWith(SECTION_EMBED_SUFFIX) || key.endsWith(SECTION_EXTRA_SUFFIX)) continue;
29065
29209
  if (applyVideoSettingNode(key, val)) continue;
29066
29210
  if (applyCarouselNode(key, val)) continue;
29067
29211
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -29086,6 +29230,8 @@ function OhhwellsBridge() {
29086
29230
  });
29087
29231
  applyLinkByKey(key, val);
29088
29232
  }
29233
+ applySectionEmbeds(content);
29234
+ applySectionExtras(content);
29089
29235
  applyLogoFromContent(content);
29090
29236
  reconcileNavbarItemsFromContent(content);
29091
29237
  reconcileFooterOrderFromContent(content);
@@ -31341,6 +31487,7 @@ function OhhwellsBridge() {
31341
31487
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
31342
31488
  continue;
31343
31489
  }
31490
+ if (key.endsWith(SECTION_EMBED_SUFFIX) || key.endsWith(SECTION_EXTRA_SUFFIX)) continue;
31344
31491
  if (applyVideoSettingNode(key, val)) continue;
31345
31492
  if (applyCarouselNode(key, val)) continue;
31346
31493
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -31366,6 +31513,8 @@ function OhhwellsBridge() {
31366
31513
  });
31367
31514
  applyLinkByKey(key, val);
31368
31515
  }
31516
+ applySectionEmbeds(content);
31517
+ applySectionExtras(content);
31369
31518
  applyLogoFromContent(content);
31370
31519
  applyLogoSizes(content);
31371
31520
  document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
@@ -33133,7 +33282,7 @@ function OhhwellsBridge() {
33133
33282
  postToParent2({
33134
33283
  type: "ow:ready",
33135
33284
  version: "1",
33136
- bridgeVersion: "0.1.172",
33285
+ bridgeVersion: "0.1.173",
33137
33286
  path: pathname,
33138
33287
  nodes: collectEditableNodes(editContentRef.current),
33139
33288
  sections