@bettercms-ai/convert 0.21.0 → 0.22.0

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.d.ts CHANGED
@@ -955,7 +955,7 @@ declare function attrsFor(path: string, kind: string, props?: AttrBinding[], sco
955
955
  declare function propsAttribute(props: AttrBinding[]): string;
956
956
 
957
957
  /** Bumped whenever the emitted source changes. `isKnownHelper` upgrades anything older. */
958
- declare const HELPER_VERSION = 10;
958
+ declare const HELPER_VERSION = 11;
959
959
  /** Where each dialect's helper lives. Null = this dialect reads nothing at build time. */
960
960
  declare const HELPER_PATH: Record<Dialect, string | null>;
961
961
  /** The directory the snapshots live in, at the repository root. */
package/dist/index.js CHANGED
@@ -4187,7 +4187,7 @@ async function bindImages(ctx, targets) {
4187
4187
 
4188
4188
  // src/helper.ts
4189
4189
  import { createHash as createHash2 } from "crypto";
4190
- var HELPER_VERSION = 10;
4190
+ var HELPER_VERSION = 11;
4191
4191
  var HEADER = "// @bettercms-ai/convert helper v";
4192
4192
  var HELPER_PATH = Object.fromEntries(
4193
4193
  Object.keys(DIALECT_RULES).map((d) => [d, DIALECT_RULES[d].helper])
@@ -4549,6 +4549,46 @@ const STYLE_SPACE_TOKEN_PX: Record<string, string> = {
4549
4549
  "space-xl": "64px",
4550
4550
  };
4551
4551
 
4552
+ const STYLE_THEME: Record<string, { colorScheme: string; background: string; color: string }> = {
4553
+ light: { colorScheme: "light", background: "#ffffff", color: "#111111" },
4554
+ dark: { colorScheme: "dark", background: "#0b0b0d", color: "#f7f8f8" },
4555
+ };
4556
+ const STYLE_BG: Record<string, string> = {
4557
+ surface: "var(--bcms-bg-surface,#ffffff)",
4558
+ muted: "var(--bcms-bg-muted,#f3f4f6)",
4559
+ accent: "var(--bcms-bg-accent,#4f46e5)",
4560
+ dark: "var(--bcms-bg-dark,#0b0b0d)",
4561
+ };
4562
+ const STYLE_CORNER_PX: Record<string, string> = { "0": "0", s: "4px", m: "8px", l: "16px", xl: "24px", "2xl": "32px" };
4563
+ const STYLE_SHADOW: Record<string, string> = {
4564
+ "0": "none",
4565
+ s: "0 1px 2px rgba(0,0,0,.06)",
4566
+ m: "0 4px 12px rgba(0,0,0,.08)",
4567
+ l: "0 10px 24px rgba(0,0,0,.10)",
4568
+ xl: "0 24px 48px rgba(0,0,0,.14)",
4569
+ };
4570
+ const STYLE_HAIRLINE = "1px solid rgba(0,0,0,.10)";
4571
+
4572
+ /** A map entry by OWN key only, so a token like \`constructor\` never reaches CSS. */
4573
+ function styleOwn<T>(map: Record<string, T>, key: unknown): T | undefined {
4574
+ return typeof key === "string" && Object.prototype.hasOwnProperty.call(map, key) ? map[key] : undefined;
4575
+ }
4576
+
4577
+ /** An http(s) or root-relative url with nothing that could end \`url(\u2026)\`; "" for anything else. */
4578
+ function styleSafeUrl(raw: unknown): string {
4579
+ if (typeof raw !== "string") return "";
4580
+ const url = raw.trim();
4581
+ if (!url || url.length > 2000) return "";
4582
+ if (/["'()\\;]|\\s/.test(url)) return "";
4583
+ if (url.startsWith("//")) return "";
4584
+ if (url.startsWith("/")) return url;
4585
+ return /^https?:\\/\\//i.test(url) ? url : "";
4586
+ }
4587
+
4588
+ function styleClamp(n: number, lo: number, hi: number): number {
4589
+ return Math.min(hi, Math.max(lo, n));
4590
+ }
4591
+
4552
4592
  function styleSpaceToken(token: unknown): string {
4553
4593
  const px = typeof token === "string" ? STYLE_SPACE_TOKEN_PX[token] : undefined;
4554
4594
  return px ? "var(--bcms-" + token + "," + px + ")" : "";
@@ -4578,6 +4618,25 @@ export function bcmsSectionStyle(style: unknown): Record<string, string | number
4578
4618
  if (s.fontSize && STYLE_FONT_SIZE_REM[s.fontSize]) css.fontSize = STYLE_FONT_SIZE_REM[s.fontSize]!;
4579
4619
  if (s.weight && STYLE_WEIGHT[s.weight] != null) css.fontWeight = STYLE_WEIGHT[s.weight]!;
4580
4620
  if (s.radius && STYLE_RADIUS_PX[s.radius] != null) css.borderRadius = STYLE_RADIUS_PX[s.radius]!;
4621
+ const theme = styleOwn(STYLE_THEME, s.theme);
4622
+ if (theme) { css.colorScheme = theme.colorScheme; css.background = theme.background; css.color = theme.color; }
4623
+ if (s.bg === "custom") { if (/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(s.bgCustom ?? "")) css.background = s.bgCustom!; }
4624
+ else if (styleOwn(STYLE_BG, s.bg)) css.background = styleOwn(STYLE_BG, s.bg)!;
4625
+ const bgImage = styleSafeUrl(s.bgImage);
4626
+ if (bgImage) { css.backgroundImage = "url(" + bgImage + ")"; css.backgroundSize = "cover"; css.backgroundPosition = "center"; }
4627
+ const n = style as Record<string, unknown>;
4628
+ if (!top && typeof n.paddingTop === "number") css.paddingTop = styleClamp(n.paddingTop, 0, 240) + "px";
4629
+ if (!bottom && typeof n.paddingBottom === "number") css.paddingBottom = styleClamp(n.paddingBottom, 0, 240) + "px";
4630
+ if (!sides && typeof n.paddingSides === "number") {
4631
+ const px = styleClamp(n.paddingSides, 0, 240) + "px";
4632
+ css.paddingLeft = px; css.paddingRight = px;
4633
+ }
4634
+ if (n.fullHeight === true) { css.minHeight = "100vh"; css.display = "flex"; css.flexDirection = "column"; css.justifyContent = "center"; }
4635
+ if (typeof n.opacity === "number") css.opacity = styleClamp(n.opacity, 0, 100) / 100;
4636
+ if (styleOwn(STYLE_CORNER_PX, s.corner) != null) { css.borderRadius = styleOwn(STYLE_CORNER_PX, s.corner)!; css.overflow = "hidden"; }
4637
+ if (styleOwn(STYLE_SHADOW, s.shadow)) css.boxShadow = styleOwn(STYLE_SHADOW, s.shadow)!;
4638
+ if (n.borderTop === true) css.borderTop = STYLE_HAIRLINE;
4639
+ if (n.borderBottom === true) css.borderBottom = STYLE_HAIRLINE;
4581
4640
  if ((style as { border?: unknown }).border === true) css.border = "1px solid currentColor";
4582
4641
  return Object.keys(css).length ? css : undefined;
4583
4642
  }
@@ -4602,7 +4661,8 @@ var HISTORICAL = {
4602
4661
  6: "c907e7245578d947c6541b1ab2c5c6659ea7789a1519e895b4a4aed122c6f649",
4603
4662
  7: "f22514ef48c50230985e605bea6cf9bf41756384a7dc80603e347baba9b65d93",
4604
4663
  8: "484e72852d2b496e016a1f2a2b1a77bb993f8a163b290781522d6114b6519bb9",
4605
- 9: "d6441db2ff4578c3c5d4b7d461f3374b89247ef6ba9e0d535791e840d803e4f3"
4664
+ 9: "d6441db2ff4578c3c5d4b7d461f3374b89247ef6ba9e0d535791e840d803e4f3",
4665
+ 10: "ffcb59862972b15a67c5951e9f3b94ce5b8b50345e6aac2bfa5789cfc3136910"
4606
4666
  },
4607
4667
  "src/lib/bcms-content.ts": {
4608
4668
  1: "ae72ae14d706943d481c880d70da5789b4816ba1ba319a10fbc63ded4d0b42f2",
@@ -4613,7 +4673,8 @@ var HISTORICAL = {
4613
4673
  6: "63f1fa29e47e70c5193b81ee24addb238ba100247124d55bc17713102d587df5",
4614
4674
  7: "ed92fb88de953d9951abbe6a1edae1d048f4050eaf6fb607ac08167f94d8bcc7",
4615
4675
  8: "1a6f669d76d42effe77f082436e9d21c0efa6fc499e919e3d116bc3a27a7f3d5",
4616
- 9: "eee9fb1635ae7d6f8f33676a1f390600ca24a62ee992775252273c73a011c494"
4676
+ 9: "eee9fb1635ae7d6f8f33676a1f390600ca24a62ee992775252273c73a011c494",
4677
+ 10: "35bb7c0e30f5c41fe68e52259ec4764de6de2734064fa0e1521f3338eef0a09e"
4617
4678
  },
4618
4679
  "composables/bcms-content.ts": {
4619
4680
  1: "c272412532efed7db64b6cf313b2bed4291f9951430412289c8a588b7f565407",
@@ -4624,7 +4685,8 @@ var HISTORICAL = {
4624
4685
  6: "c907e7245578d947c6541b1ab2c5c6659ea7789a1519e895b4a4aed122c6f649",
4625
4686
  7: "f22514ef48c50230985e605bea6cf9bf41756384a7dc80603e347baba9b65d93",
4626
4687
  8: "484e72852d2b496e016a1f2a2b1a77bb993f8a163b290781522d6114b6519bb9",
4627
- 9: "d6441db2ff4578c3c5d4b7d461f3374b89247ef6ba9e0d535791e840d803e4f3"
4688
+ 9: "d6441db2ff4578c3c5d4b7d461f3374b89247ef6ba9e0d535791e840d803e4f3",
4689
+ 10: "ffcb59862972b15a67c5951e9f3b94ce5b8b50345e6aac2bfa5789cfc3136910"
4628
4690
  }
4629
4691
  };
4630
4692
  var sha256 = (value) => createHash2("sha256").update(value, "utf8").digest("hex");