@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/CHANGELOG.md +12 -0
- package/dist/cli.js +68 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +66 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @bettercms-ai/convert
|
|
2
2
|
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c0afef4: The emitted helper (v11) paints the same section design keys as `blockStyleToCss`: `theme`, `bg`/`bgCustom`, `bgImage` (http(s) or root-relative only), `corner`, `shadow`, `fullHeight`, `opacity`, `borderTop`/`borderBottom` and the px padding sliders. A converted section root's `data-bcms-style` promise, that its inline style is `blockStyleToCss(block.style)`, holds again for sections styled in the visual editor. Helpers at v10 and older are recognised and upgraded. The content column (`contentWidth`) is still not drawn on converted roots.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [c0afef4]
|
|
12
|
+
- Updated dependencies [5c6db8e]
|
|
13
|
+
- @bettercms-ai/types@1.30.0
|
|
14
|
+
|
|
3
15
|
## 0.21.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/cli.js
CHANGED
|
@@ -4190,7 +4190,7 @@ async function bindImages(ctx, targets) {
|
|
|
4190
4190
|
|
|
4191
4191
|
// src/helper.ts
|
|
4192
4192
|
import { createHash as createHash2 } from "crypto";
|
|
4193
|
-
var HELPER_VERSION =
|
|
4193
|
+
var HELPER_VERSION = 11;
|
|
4194
4194
|
var HEADER = "// @bettercms-ai/convert helper v";
|
|
4195
4195
|
var HELPER_PATH = Object.fromEntries(
|
|
4196
4196
|
Object.keys(DIALECT_RULES).map((d) => [d, DIALECT_RULES[d].helper])
|
|
@@ -4552,6 +4552,46 @@ const STYLE_SPACE_TOKEN_PX: Record<string, string> = {
|
|
|
4552
4552
|
"space-xl": "64px",
|
|
4553
4553
|
};
|
|
4554
4554
|
|
|
4555
|
+
const STYLE_THEME: Record<string, { colorScheme: string; background: string; color: string }> = {
|
|
4556
|
+
light: { colorScheme: "light", background: "#ffffff", color: "#111111" },
|
|
4557
|
+
dark: { colorScheme: "dark", background: "#0b0b0d", color: "#f7f8f8" },
|
|
4558
|
+
};
|
|
4559
|
+
const STYLE_BG: Record<string, string> = {
|
|
4560
|
+
surface: "var(--bcms-bg-surface,#ffffff)",
|
|
4561
|
+
muted: "var(--bcms-bg-muted,#f3f4f6)",
|
|
4562
|
+
accent: "var(--bcms-bg-accent,#4f46e5)",
|
|
4563
|
+
dark: "var(--bcms-bg-dark,#0b0b0d)",
|
|
4564
|
+
};
|
|
4565
|
+
const STYLE_CORNER_PX: Record<string, string> = { "0": "0", s: "4px", m: "8px", l: "16px", xl: "24px", "2xl": "32px" };
|
|
4566
|
+
const STYLE_SHADOW: Record<string, string> = {
|
|
4567
|
+
"0": "none",
|
|
4568
|
+
s: "0 1px 2px rgba(0,0,0,.06)",
|
|
4569
|
+
m: "0 4px 12px rgba(0,0,0,.08)",
|
|
4570
|
+
l: "0 10px 24px rgba(0,0,0,.10)",
|
|
4571
|
+
xl: "0 24px 48px rgba(0,0,0,.14)",
|
|
4572
|
+
};
|
|
4573
|
+
const STYLE_HAIRLINE = "1px solid rgba(0,0,0,.10)";
|
|
4574
|
+
|
|
4575
|
+
/** A map entry by OWN key only, so a token like \`constructor\` never reaches CSS. */
|
|
4576
|
+
function styleOwn<T>(map: Record<string, T>, key: unknown): T | undefined {
|
|
4577
|
+
return typeof key === "string" && Object.prototype.hasOwnProperty.call(map, key) ? map[key] : undefined;
|
|
4578
|
+
}
|
|
4579
|
+
|
|
4580
|
+
/** An http(s) or root-relative url with nothing that could end \`url(\u2026)\`; "" for anything else. */
|
|
4581
|
+
function styleSafeUrl(raw: unknown): string {
|
|
4582
|
+
if (typeof raw !== "string") return "";
|
|
4583
|
+
const url = raw.trim();
|
|
4584
|
+
if (!url || url.length > 2000) return "";
|
|
4585
|
+
if (/["'()\\;]|\\s/.test(url)) return "";
|
|
4586
|
+
if (url.startsWith("//")) return "";
|
|
4587
|
+
if (url.startsWith("/")) return url;
|
|
4588
|
+
return /^https?:\\/\\//i.test(url) ? url : "";
|
|
4589
|
+
}
|
|
4590
|
+
|
|
4591
|
+
function styleClamp(n: number, lo: number, hi: number): number {
|
|
4592
|
+
return Math.min(hi, Math.max(lo, n));
|
|
4593
|
+
}
|
|
4594
|
+
|
|
4555
4595
|
function styleSpaceToken(token: unknown): string {
|
|
4556
4596
|
const px = typeof token === "string" ? STYLE_SPACE_TOKEN_PX[token] : undefined;
|
|
4557
4597
|
return px ? "var(--bcms-" + token + "," + px + ")" : "";
|
|
@@ -4581,6 +4621,25 @@ export function bcmsSectionStyle(style: unknown): Record<string, string | number
|
|
|
4581
4621
|
if (s.fontSize && STYLE_FONT_SIZE_REM[s.fontSize]) css.fontSize = STYLE_FONT_SIZE_REM[s.fontSize]!;
|
|
4582
4622
|
if (s.weight && STYLE_WEIGHT[s.weight] != null) css.fontWeight = STYLE_WEIGHT[s.weight]!;
|
|
4583
4623
|
if (s.radius && STYLE_RADIUS_PX[s.radius] != null) css.borderRadius = STYLE_RADIUS_PX[s.radius]!;
|
|
4624
|
+
const theme = styleOwn(STYLE_THEME, s.theme);
|
|
4625
|
+
if (theme) { css.colorScheme = theme.colorScheme; css.background = theme.background; css.color = theme.color; }
|
|
4626
|
+
if (s.bg === "custom") { if (/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(s.bgCustom ?? "")) css.background = s.bgCustom!; }
|
|
4627
|
+
else if (styleOwn(STYLE_BG, s.bg)) css.background = styleOwn(STYLE_BG, s.bg)!;
|
|
4628
|
+
const bgImage = styleSafeUrl(s.bgImage);
|
|
4629
|
+
if (bgImage) { css.backgroundImage = "url(" + bgImage + ")"; css.backgroundSize = "cover"; css.backgroundPosition = "center"; }
|
|
4630
|
+
const n = style as Record<string, unknown>;
|
|
4631
|
+
if (!top && typeof n.paddingTop === "number") css.paddingTop = styleClamp(n.paddingTop, 0, 240) + "px";
|
|
4632
|
+
if (!bottom && typeof n.paddingBottom === "number") css.paddingBottom = styleClamp(n.paddingBottom, 0, 240) + "px";
|
|
4633
|
+
if (!sides && typeof n.paddingSides === "number") {
|
|
4634
|
+
const px = styleClamp(n.paddingSides, 0, 240) + "px";
|
|
4635
|
+
css.paddingLeft = px; css.paddingRight = px;
|
|
4636
|
+
}
|
|
4637
|
+
if (n.fullHeight === true) { css.minHeight = "100vh"; css.display = "flex"; css.flexDirection = "column"; css.justifyContent = "center"; }
|
|
4638
|
+
if (typeof n.opacity === "number") css.opacity = styleClamp(n.opacity, 0, 100) / 100;
|
|
4639
|
+
if (styleOwn(STYLE_CORNER_PX, s.corner) != null) { css.borderRadius = styleOwn(STYLE_CORNER_PX, s.corner)!; css.overflow = "hidden"; }
|
|
4640
|
+
if (styleOwn(STYLE_SHADOW, s.shadow)) css.boxShadow = styleOwn(STYLE_SHADOW, s.shadow)!;
|
|
4641
|
+
if (n.borderTop === true) css.borderTop = STYLE_HAIRLINE;
|
|
4642
|
+
if (n.borderBottom === true) css.borderBottom = STYLE_HAIRLINE;
|
|
4584
4643
|
if ((style as { border?: unknown }).border === true) css.border = "1px solid currentColor";
|
|
4585
4644
|
return Object.keys(css).length ? css : undefined;
|
|
4586
4645
|
}
|
|
@@ -4605,7 +4664,8 @@ var HISTORICAL = {
|
|
|
4605
4664
|
6: "c907e7245578d947c6541b1ab2c5c6659ea7789a1519e895b4a4aed122c6f649",
|
|
4606
4665
|
7: "f22514ef48c50230985e605bea6cf9bf41756384a7dc80603e347baba9b65d93",
|
|
4607
4666
|
8: "484e72852d2b496e016a1f2a2b1a77bb993f8a163b290781522d6114b6519bb9",
|
|
4608
|
-
9: "d6441db2ff4578c3c5d4b7d461f3374b89247ef6ba9e0d535791e840d803e4f3"
|
|
4667
|
+
9: "d6441db2ff4578c3c5d4b7d461f3374b89247ef6ba9e0d535791e840d803e4f3",
|
|
4668
|
+
10: "ffcb59862972b15a67c5951e9f3b94ce5b8b50345e6aac2bfa5789cfc3136910"
|
|
4609
4669
|
},
|
|
4610
4670
|
"src/lib/bcms-content.ts": {
|
|
4611
4671
|
1: "ae72ae14d706943d481c880d70da5789b4816ba1ba319a10fbc63ded4d0b42f2",
|
|
@@ -4616,7 +4676,8 @@ var HISTORICAL = {
|
|
|
4616
4676
|
6: "63f1fa29e47e70c5193b81ee24addb238ba100247124d55bc17713102d587df5",
|
|
4617
4677
|
7: "ed92fb88de953d9951abbe6a1edae1d048f4050eaf6fb607ac08167f94d8bcc7",
|
|
4618
4678
|
8: "1a6f669d76d42effe77f082436e9d21c0efa6fc499e919e3d116bc3a27a7f3d5",
|
|
4619
|
-
9: "eee9fb1635ae7d6f8f33676a1f390600ca24a62ee992775252273c73a011c494"
|
|
4679
|
+
9: "eee9fb1635ae7d6f8f33676a1f390600ca24a62ee992775252273c73a011c494",
|
|
4680
|
+
10: "35bb7c0e30f5c41fe68e52259ec4764de6de2734064fa0e1521f3338eef0a09e"
|
|
4620
4681
|
},
|
|
4621
4682
|
"composables/bcms-content.ts": {
|
|
4622
4683
|
1: "c272412532efed7db64b6cf313b2bed4291f9951430412289c8a588b7f565407",
|
|
@@ -4627,7 +4688,8 @@ var HISTORICAL = {
|
|
|
4627
4688
|
6: "c907e7245578d947c6541b1ab2c5c6659ea7789a1519e895b4a4aed122c6f649",
|
|
4628
4689
|
7: "f22514ef48c50230985e605bea6cf9bf41756384a7dc80603e347baba9b65d93",
|
|
4629
4690
|
8: "484e72852d2b496e016a1f2a2b1a77bb993f8a163b290781522d6114b6519bb9",
|
|
4630
|
-
9: "d6441db2ff4578c3c5d4b7d461f3374b89247ef6ba9e0d535791e840d803e4f3"
|
|
4691
|
+
9: "d6441db2ff4578c3c5d4b7d461f3374b89247ef6ba9e0d535791e840d803e4f3",
|
|
4692
|
+
10: "ffcb59862972b15a67c5951e9f3b94ce5b8b50345e6aac2bfa5789cfc3136910"
|
|
4631
4693
|
}
|
|
4632
4694
|
};
|
|
4633
4695
|
var sha256 = (value) => createHash2("sha256").update(value, "utf8").digest("hex");
|
|
@@ -10278,7 +10340,7 @@ function styleEdits(before, after) {
|
|
|
10278
10340
|
// package.json
|
|
10279
10341
|
var package_default = {
|
|
10280
10342
|
name: "@bettercms-ai/convert",
|
|
10281
|
-
version: "0.
|
|
10343
|
+
version: "0.22.0",
|
|
10282
10344
|
type: "module",
|
|
10283
10345
|
description: "Deterministic codemod that turns an imported site's text-matched bindings into declared ones \u2014 parser offsets in, one magic-string pass out, plus a receipt of everything it could not do.",
|
|
10284
10346
|
bin: {
|
|
@@ -10311,7 +10373,7 @@ var package_default = {
|
|
|
10311
10373
|
dependencies: {
|
|
10312
10374
|
"@astrojs/compiler": "^2.13.1",
|
|
10313
10375
|
"@babel/parser": "^7.29.2",
|
|
10314
|
-
"@bettercms-ai/types": "^1.
|
|
10376
|
+
"@bettercms-ai/types": "^1.30.0",
|
|
10315
10377
|
"@vue/compiler-sfc": "^3.5.0",
|
|
10316
10378
|
"magic-string": "^0.30.21",
|
|
10317
10379
|
parse5: "^7.3.0",
|