@bettercms-ai/convert 0.17.1 → 0.17.2
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 +6 -0
- package/dist/cli.js +13 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @bettercms-ai/convert
|
|
2
2
|
|
|
3
|
+
## 0.17.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d247026: `--xray` now measures a page exactly as the release pass does. `data-bcms-block` and `data-bcms-path` no longer own the text under them (only `data-bcms-field` and `data-bcms-layout-field` do); `<select>`, `<object>`, `<canvas>` and MathML are skipped; numbers such as `$1,200` and short copy such as `OK` count as copy; only a real in-page skip link is excluded. A page's unaddressable figure may rise: it now matches what the binding report says for the same build.
|
|
8
|
+
|
|
3
9
|
## 0.17.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli.js
CHANGED
|
@@ -6801,7 +6801,7 @@ function isSourceCandidate(path) {
|
|
|
6801
6801
|
}
|
|
6802
6802
|
|
|
6803
6803
|
// src/xray.ts
|
|
6804
|
-
var SKIP_TAGS = /* @__PURE__ */ new Set(["svg", "iframe", "head", "title"]);
|
|
6804
|
+
var SKIP_TAGS = /* @__PURE__ */ new Set(["svg", "math", "iframe", "head", "title", "object", "canvas", "select"]);
|
|
6805
6805
|
var CONTEXT_TAGS = /* @__PURE__ */ new Set([
|
|
6806
6806
|
"nav",
|
|
6807
6807
|
"header",
|
|
@@ -6819,10 +6819,16 @@ var CONTEXT_TAGS = /* @__PURE__ */ new Set([
|
|
|
6819
6819
|
"figure",
|
|
6820
6820
|
"blockquote"
|
|
6821
6821
|
]);
|
|
6822
|
-
var BOUND_ATTRS = ["data-bcms-field", "data-bcms-layout-field"
|
|
6823
|
-
var isDecorativeGlyph = (text) =>
|
|
6822
|
+
var BOUND_ATTRS = ["data-bcms-field", "data-bcms-layout-field"];
|
|
6823
|
+
var isDecorativeGlyph = (text) => {
|
|
6824
|
+
const t = flat2(text);
|
|
6825
|
+
return t === "" || !/[\p{L}\p{N}]/u.test(t) || new RegExp("^\\p{Nd}{1,2}\\s*[/.)\\-\u2013\u2014]?$", "u").test(t);
|
|
6826
|
+
};
|
|
6827
|
+
var PLATFORM_BADGE = /^made with\b/iu;
|
|
6824
6828
|
var MAX_BUCKETS = 12;
|
|
6825
6829
|
var flat2 = (value) => value.replace(/\s+/g, " ").trim();
|
|
6830
|
+
var textOf = (node) => node.type === "text" ? node.value : node.type === "element" ? node.children.map(textOf).join("") : "";
|
|
6831
|
+
var isSkipLink = (node, attrs) => node.tag === "a" && (attrs.get("href") ?? "").startsWith("#") && (/^skip\b/iu.test(flat2(textOf(node))) || /\bskip[-_]?(link|nav|to|content)\b/iu.test(attrs.get("class") ?? ""));
|
|
6826
6832
|
function measureUnaddressable(html) {
|
|
6827
6833
|
const parsed = parse2(html);
|
|
6828
6834
|
let visible = 0;
|
|
@@ -6831,7 +6837,7 @@ function measureUnaddressable(html) {
|
|
|
6831
6837
|
const visit = (node, tag, context, bound) => {
|
|
6832
6838
|
if (node.type === "text") {
|
|
6833
6839
|
const text = flat2(node.value);
|
|
6834
|
-
if (
|
|
6840
|
+
if (isDecorativeGlyph(text) || PLATFORM_BADGE.test(text)) return;
|
|
6835
6841
|
visible += text.length;
|
|
6836
6842
|
if (bound) return;
|
|
6837
6843
|
unaddressable += text.length;
|
|
@@ -6845,7 +6851,7 @@ function measureUnaddressable(html) {
|
|
|
6845
6851
|
}
|
|
6846
6852
|
if (node.type !== "element" || node.raw || SKIP_TAGS.has(node.tag)) return;
|
|
6847
6853
|
const attrs = new Map(node.attrs.map((a) => [a.name, a.value]));
|
|
6848
|
-
if (attrs.has("hidden") || attrs.get("aria-hidden") === "true" || /display\s*:\s*none
|
|
6854
|
+
if (attrs.has("hidden") || attrs.get("aria-hidden") === "true" || /display\s*:\s*none/i.test(attrs.get("style") ?? "") || isSkipLink(node, attrs)) {
|
|
6849
6855
|
return;
|
|
6850
6856
|
}
|
|
6851
6857
|
const owned = bound || BOUND_ATTRS.some((name) => attrs.has(name));
|
|
@@ -6856,7 +6862,7 @@ function measureUnaddressable(html) {
|
|
|
6856
6862
|
return {
|
|
6857
6863
|
visible,
|
|
6858
6864
|
unaddressable,
|
|
6859
|
-
buckets: [...buckets.values()].sort((a, b) => b.chars - a.chars).slice(0, MAX_BUCKETS)
|
|
6865
|
+
buckets: [...buckets.values()].sort((a, b) => b.chars - a.chars || `${a.tag} @ ${a.context}`.localeCompare(`${b.tag} @ ${b.context}`)).slice(0, MAX_BUCKETS)
|
|
6860
6866
|
};
|
|
6861
6867
|
}
|
|
6862
6868
|
|
|
@@ -9801,7 +9807,7 @@ function emitStubs2(dialects, slugs, contents, out) {
|
|
|
9801
9807
|
// package.json
|
|
9802
9808
|
var package_default = {
|
|
9803
9809
|
name: "@bettercms-ai/convert",
|
|
9804
|
-
version: "0.17.
|
|
9810
|
+
version: "0.17.2",
|
|
9805
9811
|
type: "module",
|
|
9806
9812
|
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.",
|
|
9807
9813
|
bin: {
|