@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.cjs CHANGED
@@ -1261,21 +1261,21 @@ function chromeFrom(sample) {
1261
1261
  };
1262
1262
  }
1263
1263
  function filledPrimary(seed) {
1264
- const paint = parseColor(paintColor(seed)) ?? { r: 15, g: 15, b: 15, a: 1 };
1265
- const luminance = relativeLuminance(paint);
1264
+ const paint3 = parseColor(paintColor(seed)) ?? { r: 15, g: 15, b: 15, a: 1 };
1265
+ const luminance = relativeLuminance(paint3);
1266
1266
  return {
1267
- background: toCss({ ...paint, a: 1 }),
1267
+ background: toCss({ ...paint3, a: 1 }),
1268
1268
  color: luminance > 0.55 ? "rgb(15, 15, 15)" : "rgb(255, 255, 255)",
1269
1269
  borderColor: TRANSPARENT,
1270
1270
  borderWidth: "0px"
1271
1271
  };
1272
1272
  }
1273
1273
  function generatedSecondary(primary) {
1274
- const paint = accentColor(primary);
1274
+ const paint3 = accentColor(primary);
1275
1275
  return {
1276
1276
  background: TRANSPARENT,
1277
- color: paint,
1278
- borderColor: paint,
1277
+ color: paint3,
1278
+ borderColor: paint3,
1279
1279
  borderWidth: "1px"
1280
1280
  };
1281
1281
  }
@@ -1288,9 +1288,9 @@ function generatedGhost(primary) {
1288
1288
  };
1289
1289
  }
1290
1290
  function normalizeOutlineChrome(outline, primary) {
1291
- const paint = accentColor(primary);
1291
+ const paint3 = accentColor(primary);
1292
1292
  const text = parseColor(outline.color);
1293
- const paintRgb = parseColor(paint);
1293
+ const paintRgb = parseColor(paint3);
1294
1294
  const primaryLabel = parseColor(primary.color);
1295
1295
  const matchesOnPrimary = Boolean(text && primaryLabel) && colorKey(outline.color) === colorKey(primary.color);
1296
1296
  const textTooLight = text ? relativeLuminance(text) > 0.7 : false;
@@ -1299,8 +1299,8 @@ function normalizeOutlineChrome(outline, primary) {
1299
1299
  const hasBorder = parseFloat(outline.borderWidth) > 0;
1300
1300
  return {
1301
1301
  ...outline,
1302
- color: paint,
1303
- borderColor: hasBorder ? paint : outline.borderColor
1302
+ color: paint3,
1303
+ borderColor: hasBorder ? paint3 : outline.borderColor
1304
1304
  };
1305
1305
  }
1306
1306
  function generateButtonVariants(samples) {
@@ -7783,6 +7783,174 @@ function findSelectableNavContainer(doc = document) {
7783
7783
  );
7784
7784
  }
7785
7785
 
7786
+ // src/lib/youtube.ts
7787
+ var YOUTUBE_ID_PATTERN = /^[A-Za-z0-9_-]{11}$/;
7788
+ function extractYouTubeId(input) {
7789
+ const trimmed = input.trim();
7790
+ if (!trimmed) return null;
7791
+ if (YOUTUBE_ID_PATTERN.test(trimmed)) return trimmed;
7792
+ let url;
7793
+ try {
7794
+ url = new URL(trimmed);
7795
+ } catch {
7796
+ return null;
7797
+ }
7798
+ const host = url.hostname.replace(/^www\./, "");
7799
+ if (host !== "youtube.com" && host !== "m.youtube.com" && host !== "youtu.be" && host !== "youtube-nocookie.com") {
7800
+ return null;
7801
+ }
7802
+ let candidate = null;
7803
+ if (host === "youtu.be") {
7804
+ candidate = url.pathname.slice(1).split("/")[0] ?? null;
7805
+ } else if (url.pathname === "/watch") {
7806
+ candidate = url.searchParams.get("v");
7807
+ } else {
7808
+ const match = url.pathname.match(/^\/(?:embed|shorts)\/([^/]+)/);
7809
+ candidate = match ? match[1] : null;
7810
+ }
7811
+ return candidate && YOUTUBE_ID_PATTERN.test(candidate) ? candidate : null;
7812
+ }
7813
+
7814
+ // src/lib/section-embed.ts
7815
+ var SECTION_EMBED_SUFFIX = "__ohw_embed";
7816
+ function readStoredEmbed(value) {
7817
+ if (value.startsWith("start\n")) {
7818
+ return { raw: value.slice("start\n".length), at: "start" };
7819
+ }
7820
+ return { raw: value, at: "end" };
7821
+ }
7822
+ function embedFrameSrc(value) {
7823
+ const videoId = extractYouTubeId(value);
7824
+ if (videoId) {
7825
+ return { src: `https://www.youtube-nocookie.com/embed/${videoId}?rel=0`, title: "YouTube video" };
7826
+ }
7827
+ let url;
7828
+ try {
7829
+ url = new URL(value);
7830
+ } catch {
7831
+ return null;
7832
+ }
7833
+ const host = url.hostname.replace(/^www\./, "").toLowerCase();
7834
+ if (host === "google.com" && url.pathname.startsWith("/maps") || host === "maps.google.com") {
7835
+ const query = url.searchParams.get("q") || url.searchParams.get("query") || "";
7836
+ const src = query ? `https://maps.google.com/maps?q=${encodeURIComponent(query)}&output=embed` : `https://maps.google.com/maps?output=embed`;
7837
+ return { src, title: "Map" };
7838
+ }
7839
+ if (host === "maps.app.goo.gl") {
7840
+ return { src: value, title: "Map" };
7841
+ }
7842
+ if (host === "calendly.com" || host.endsWith(".calendly.com") || host === "calendar.google.com") {
7843
+ return { src: value, title: "Calendar" };
7844
+ }
7845
+ if (host === "docs.google.com" && url.pathname.includes("/forms/")) {
7846
+ return { src: value.replace(/\/edit(?:\?.*)?$/i, "/viewform"), title: "Form" };
7847
+ }
7848
+ if (host === "forms.gle") {
7849
+ return { src: value, title: "Form" };
7850
+ }
7851
+ return null;
7852
+ }
7853
+ function place(section, box, at) {
7854
+ if (at === "start") {
7855
+ section.insertBefore(box, section.firstChild);
7856
+ return;
7857
+ }
7858
+ section.appendChild(box);
7859
+ }
7860
+ function paint(section, key, src, title, at) {
7861
+ const existing = section.querySelector(`[data-ohw-section-embed="${CSS.escape(key)}"]`);
7862
+ const frame = existing?.querySelector("iframe");
7863
+ if (existing && frame) {
7864
+ if (frame.getAttribute("src") !== src) frame.setAttribute("src", src);
7865
+ frame.title = title;
7866
+ place(section, existing, at);
7867
+ return;
7868
+ }
7869
+ existing?.remove();
7870
+ const box = document.createElement("div");
7871
+ box.setAttribute("data-ohw-section-embed", key);
7872
+ 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;";
7873
+ const frameWrap = document.createElement("div");
7874
+ frameWrap.style.cssText = "position:relative;width:100%;aspect-ratio:16/9;min-height:250px;border-radius:12px;overflow:hidden;background:#0f172a;";
7875
+ const iframe = document.createElement("iframe");
7876
+ iframe.src = src;
7877
+ iframe.title = title;
7878
+ iframe.style.cssText = "position:absolute;inset:0;width:100%;height:100%;border:0;";
7879
+ iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture";
7880
+ iframe.setAttribute("allowfullscreen", "");
7881
+ frameWrap.appendChild(iframe);
7882
+ box.appendChild(frameWrap);
7883
+ place(section, box, at);
7884
+ }
7885
+ function applySectionEmbeds(content) {
7886
+ for (const [key, val] of Object.entries(content)) {
7887
+ if (!key.endsWith(SECTION_EMBED_SUFFIX)) continue;
7888
+ const sectionId = key.slice(0, -SECTION_EMBED_SUFFIX.length);
7889
+ const section = document.querySelector(`[data-ohw-section="${CSS.escape(sectionId)}"]`);
7890
+ const stored = typeof val === "string" ? readStoredEmbed(val) : null;
7891
+ const frame = stored ? embedFrameSrc(stored.raw) : null;
7892
+ if (!section || !stored || !frame) {
7893
+ section?.querySelector(`[data-ohw-section-embed="${CSS.escape(key)}"]`)?.remove();
7894
+ continue;
7895
+ }
7896
+ paint(section, key, frame.src, frame.title, stored.at);
7897
+ }
7898
+ }
7899
+
7900
+ // src/lib/section-extra.ts
7901
+ var SECTION_EXTRA_SUFFIX = "__ohw_extra";
7902
+ function placeUnderCards(section, box) {
7903
+ const cards = section.querySelector("[data-ohw-cards]");
7904
+ if (cards) {
7905
+ cards.after(box);
7906
+ return;
7907
+ }
7908
+ const viewAll = section.querySelector(".classes-viewall");
7909
+ if (viewAll && section.contains(viewAll)) {
7910
+ section.insertBefore(box, viewAll);
7911
+ return;
7912
+ }
7913
+ const copy = section.querySelector(".classes-copy");
7914
+ if (copy?.parentElement === section) {
7915
+ copy.after(box);
7916
+ return;
7917
+ }
7918
+ section.appendChild(box);
7919
+ }
7920
+ function paint2(section, key, text) {
7921
+ const existing = section.querySelector(`[data-ohw-section-extra="${CSS.escape(key)}"]`);
7922
+ if (existing) {
7923
+ const editable = existing.querySelector('[data-ohw-editable="text"]');
7924
+ if (editable && editable.innerHTML !== text) {
7925
+ editable.innerHTML = text;
7926
+ }
7927
+ placeUnderCards(section, existing);
7928
+ return;
7929
+ }
7930
+ const box = document.createElement("div");
7931
+ box.setAttribute("data-ohw-section-extra", key);
7932
+ box.style.cssText = "width:100%;max-width:720px;margin:48px auto 0;padding:0 48px;box-sizing:border-box;text-align:center;";
7933
+ const p = document.createElement("p");
7934
+ p.setAttribute("data-ohw-editable", "text");
7935
+ p.setAttribute("data-ohw-key", key);
7936
+ 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;";
7937
+ p.innerHTML = text;
7938
+ box.appendChild(p);
7939
+ placeUnderCards(section, box);
7940
+ }
7941
+ function applySectionExtras(content) {
7942
+ for (const [key, val] of Object.entries(content)) {
7943
+ if (!key.endsWith(SECTION_EXTRA_SUFFIX)) continue;
7944
+ const sectionId = key.slice(0, -SECTION_EXTRA_SUFFIX.length);
7945
+ const section = document.querySelector(`[data-ohw-section="${CSS.escape(sectionId)}"]`);
7946
+ if (!section || typeof val !== "string" || !val.trim()) {
7947
+ section?.querySelector(`[data-ohw-section-extra="${CSS.escape(key)}"]`)?.remove();
7948
+ continue;
7949
+ }
7950
+ paint2(section, key, val);
7951
+ }
7952
+ }
7953
+
7786
7954
  // src/ui/ai-tree/aiSectionsManager.tsx
7787
7955
  var import_react_dom = require("react-dom");
7788
7956
  var import_client = require("react-dom/client");
@@ -17951,7 +18119,7 @@ function apiBase() {
17951
18119
  function bridgeVersion() {
17952
18120
  try {
17953
18121
  if (true) {
17954
- return "0.1.172";
18122
+ return "0.1.173";
17955
18123
  }
17956
18124
  } catch {
17957
18125
  }
@@ -17965,7 +18133,7 @@ function stampBridgeVersionOnDocument() {
17965
18133
  return;
17966
18134
  }
17967
18135
  try {
17968
- const v = true ? "0.1.172" : "";
18136
+ const v = true ? "0.1.173" : "";
17969
18137
  if (v) {
17970
18138
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17971
18139
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -20756,34 +20924,6 @@ function clearVideo(tree, path) {
20756
20924
  });
20757
20925
  }
20758
20926
 
20759
- // src/lib/youtube.ts
20760
- var YOUTUBE_ID_PATTERN = /^[A-Za-z0-9_-]{11}$/;
20761
- function extractYouTubeId(input) {
20762
- const trimmed = input.trim();
20763
- if (!trimmed) return null;
20764
- if (YOUTUBE_ID_PATTERN.test(trimmed)) return trimmed;
20765
- let url;
20766
- try {
20767
- url = new URL(trimmed);
20768
- } catch {
20769
- return null;
20770
- }
20771
- const host = url.hostname.replace(/^www\./, "");
20772
- if (host !== "youtube.com" && host !== "m.youtube.com" && host !== "youtu.be" && host !== "youtube-nocookie.com") {
20773
- return null;
20774
- }
20775
- let candidate = null;
20776
- if (host === "youtu.be") {
20777
- candidate = url.pathname.slice(1).split("/")[0] ?? null;
20778
- } else if (url.pathname === "/watch") {
20779
- candidate = url.searchParams.get("v");
20780
- } else {
20781
- const match = url.pathname.match(/^\/(?:embed|shorts)\/([^/]+)/);
20782
- candidate = match ? match[1] : null;
20783
- }
20784
- return candidate && YOUTUBE_ID_PATTERN.test(candidate) ? candidate : null;
20785
- }
20786
-
20787
20927
  // src/ui/ai-section/AiVideoOverlay.tsx
20788
20928
  var import_jsx_runtime22 = require("react/jsx-runtime");
20789
20929
  var PRIMARY5 = "#0885FE";
@@ -28948,6 +29088,7 @@ function OhhwellsBridge() {
28948
29088
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
28949
29089
  continue;
28950
29090
  }
29091
+ if (key.endsWith(SECTION_EMBED_SUFFIX) || key.endsWith(SECTION_EXTRA_SUFFIX)) continue;
28951
29092
  if (applyVideoSettingNode(key, val)) continue;
28952
29093
  if (applyCarouselNode(key, val)) continue;
28953
29094
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -28987,6 +29128,8 @@ function OhhwellsBridge() {
28987
29128
  });
28988
29129
  applyLinkByKey(key, val);
28989
29130
  }
29131
+ applySectionEmbeds(content);
29132
+ applySectionExtras(content);
28990
29133
  applyLogoFromContent(content);
28991
29134
  applyLogoSizes(content);
28992
29135
  reconcileNavbarItemsFromContent(content);
@@ -29190,6 +29333,7 @@ function OhhwellsBridge() {
29190
29333
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
29191
29334
  continue;
29192
29335
  }
29336
+ if (key.endsWith(SECTION_EMBED_SUFFIX) || key.endsWith(SECTION_EXTRA_SUFFIX)) continue;
29193
29337
  if (applyVideoSettingNode(key, val)) continue;
29194
29338
  if (applyCarouselNode(key, val)) continue;
29195
29339
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -29214,6 +29358,8 @@ function OhhwellsBridge() {
29214
29358
  });
29215
29359
  applyLinkByKey(key, val);
29216
29360
  }
29361
+ applySectionEmbeds(content);
29362
+ applySectionExtras(content);
29217
29363
  applyLogoFromContent(content);
29218
29364
  reconcileNavbarItemsFromContent(content);
29219
29365
  reconcileFooterOrderFromContent(content);
@@ -31469,6 +31615,7 @@ function OhhwellsBridge() {
31469
31615
  if (typeof content[AI_FOOTER_KEY] === "string" && content[AI_FOOTER_KEY] && isAiFooterOwnedContentKey(key)) {
31470
31616
  continue;
31471
31617
  }
31618
+ if (key.endsWith(SECTION_EMBED_SUFFIX) || key.endsWith(SECTION_EXTRA_SUFFIX)) continue;
31472
31619
  if (applyVideoSettingNode(key, val)) continue;
31473
31620
  if (applyCarouselNode(key, val)) continue;
31474
31621
  document.querySelectorAll(`[data-ohw-key="${key}"]`).forEach((el) => {
@@ -31494,6 +31641,8 @@ function OhhwellsBridge() {
31494
31641
  });
31495
31642
  applyLinkByKey(key, val);
31496
31643
  }
31644
+ applySectionEmbeds(content);
31645
+ applySectionExtras(content);
31497
31646
  applyLogoFromContent(content);
31498
31647
  applyLogoSizes(content);
31499
31648
  document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
@@ -33261,7 +33410,7 @@ function OhhwellsBridge() {
33261
33410
  postToParent2({
33262
33411
  type: "ow:ready",
33263
33412
  version: "1",
33264
- bridgeVersion: "0.1.172",
33413
+ bridgeVersion: "0.1.173",
33265
33414
  path: pathname,
33266
33415
  nodes: collectEditableNodes(editContentRef.current),
33267
33416
  sections