@swmansion/argent 0.14.1-next.13 → 0.14.1-next.14
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/tool-server.cjs +15 -7
- package/package.json +1 -1
package/dist/tool-server.cjs
CHANGED
|
@@ -129951,10 +129951,7 @@ function num(attrs, key) {
|
|
|
129951
129951
|
function isInteractive2(attrs) {
|
|
129952
129952
|
return isTrue(attrs, "focusable") || isTrue(attrs, "selectable") || isTrue(attrs, "clickable");
|
|
129953
129953
|
}
|
|
129954
|
-
function
|
|
129955
|
-
return Boolean(node.attrs.role) || isInteractive2(node.attrs) || node.text.length > 0;
|
|
129956
|
-
}
|
|
129957
|
-
function labelOf2(node) {
|
|
129954
|
+
function ownText(node) {
|
|
129958
129955
|
const parts = [];
|
|
129959
129956
|
if (node.text) parts.push(node.text);
|
|
129960
129957
|
for (const c of node.children) {
|
|
@@ -129962,6 +129959,9 @@ function labelOf2(node) {
|
|
|
129962
129959
|
}
|
|
129963
129960
|
return parts.join(" ").trim();
|
|
129964
129961
|
}
|
|
129962
|
+
function isMeaningful(node, ownTextValue) {
|
|
129963
|
+
return Boolean(node.attrs.role) || isInteractive2(node.attrs) || ownTextValue.length > 0;
|
|
129964
|
+
}
|
|
129965
129965
|
function normalizeFrame(attrs, screenW, screenH) {
|
|
129966
129966
|
const x = num(attrs, "x") ?? 0;
|
|
129967
129967
|
const y = num(attrs, "y") ?? 0;
|
|
@@ -129981,20 +129981,28 @@ function normalizeFrame(attrs, screenW, screenH) {
|
|
|
129981
129981
|
function clamp(n, lo, hi) {
|
|
129982
129982
|
return Math.max(lo, Math.min(n, hi));
|
|
129983
129983
|
}
|
|
129984
|
+
function isPlainTextSpan(n) {
|
|
129985
|
+
return n.role === "view" && n.label !== void 0 && n.children.length === 0 && n.identifier === void 0 && !n.clickable && !n.focused && !n.selected;
|
|
129986
|
+
}
|
|
129987
|
+
function childrenReconstructLabel(children, label) {
|
|
129988
|
+
if (children.length === 0 || !children.every(isPlainTextSpan)) return false;
|
|
129989
|
+
return children.map((c) => c.label).join("") === label;
|
|
129990
|
+
}
|
|
129984
129991
|
function convert(node, screenW, screenH) {
|
|
129985
129992
|
const childNodes = [];
|
|
129986
129993
|
for (const c of node.children) {
|
|
129987
129994
|
if (c.tag === "text") continue;
|
|
129988
129995
|
childNodes.push(...convert(c, screenW, screenH));
|
|
129989
129996
|
}
|
|
129990
|
-
|
|
129997
|
+
const label = ownText(node);
|
|
129998
|
+
if (!isMeaningful(node, label)) return childNodes;
|
|
129991
129999
|
const attrs = node.attrs;
|
|
130000
|
+
const keptChildren = label && childrenReconstructLabel(childNodes, label) ? [] : childNodes;
|
|
129992
130001
|
const out = {
|
|
129993
130002
|
role: attrs.role || "view",
|
|
129994
130003
|
frame: normalizeFrame(attrs, screenW, screenH),
|
|
129995
|
-
children:
|
|
130004
|
+
children: keptChildren
|
|
129996
130005
|
};
|
|
129997
|
-
const label = labelOf2(node);
|
|
129998
130006
|
if (label) out.label = label;
|
|
129999
130007
|
if (attrs.test_id) out.identifier = attrs.test_id;
|
|
130000
130008
|
if (isInteractive2(attrs)) out.clickable = true;
|