@react-native-windows/automation-commands 0.1.126 → 0.1.128
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.
|
@@ -60,12 +60,7 @@ function removeNonDeterministicProps(element) {
|
|
|
60
60
|
* Removes noise from snapshot by removing properties with the default value
|
|
61
61
|
*/
|
|
62
62
|
function removeDefaultProps(element) {
|
|
63
|
-
const defaultValues = [
|
|
64
|
-
['Tooltip', null],
|
|
65
|
-
['AutomationLevel', -1],
|
|
66
|
-
['AutomationPositionInSet', -1],
|
|
67
|
-
['AutomationSizeOfSet', -1],
|
|
68
|
-
];
|
|
63
|
+
const defaultValues = [['Tooltip', null]];
|
|
69
64
|
defaultValues.forEach(([propname, defaultValue]) => {
|
|
70
65
|
if (element[propname] === defaultValue) {
|
|
71
66
|
delete element[propname];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dumpVisualTree.js","sourceRoot":"","sources":["../src/dumpVisualTree.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAkCH;;GAEG;AACY,KAAK,UAAU,cAAc,CAC1C,eAAuB,EACvB,IAKC;IAED,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAC9C;IAED,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,EAAE;QACnE,eAAe;QACf,GAAG,IAAI;KACR,CAAC,CAAC;IAEH,IAAI,YAAY,CAAC,IAAI,KAAK,OAAO,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;KACvC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC;IAEpC,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc,MAAK,KAAK,EAAE;QAClC,sBAAsB,CAAC,OAAO,CAAC,CAAC;KACjC;IAED,IAAI,CAAA,IAAI,aA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AAC,CAAC;KACvD;AACH,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,OAAkB;IAC5C,MAAM,aAAa,GAAwB,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAE/D,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE;QACjD,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,YAAY,EAAE;YACtC,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;SAC1B;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,QAAQ,EAAE;QACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;KAC9C;AACH,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport {AutomationClient} from '@react-native-windows/automation-channel';\n\n/**\n * Schema of tree dumped node\n */\nexport type UIElement = {\n XamlType: string;\n Foreground?: string | null;\n Background?: string | null;\n Padding?: string | null;\n Margin?: string | null;\n RenderSize?: number[] | null;\n Visibility?: 'Collapsed' | 'Visible' | null;\n CornerRadius?: string | null;\n BorderThickness?: string | null;\n Width?: number | null;\n Height?: number | null;\n BorderBrush?: string | null;\n VerticalAlignment?: string | null;\n HorizontalAlignment?: string | null;\n Clip?: string | null;\n FlowDirection?: string | null;\n Name?: string | null;\n Text?: string | null;\n children?: UIElement[];\n [index: string]: unknown;\n};\n\ndeclare global {\n const automationClient: AutomationClient | undefined;\n}\n\n/**\n * Dump a section of the native visual tree.\n */\nexport default async function dumpVisualTree(\n accessibilityId: string,\n opts?: {\n pruneCollapsed?: boolean;\n deterministicOnly?: boolean;\n removeDefaultProps?: boolean;\n additionalProperties?: string[];\n },\n): Promise<UIElement> {\n if (!automationClient) {\n throw new Error('RPC client is not enabled');\n }\n\n const dumpResponse = await automationClient.invoke('DumpVisualTree', {\n accessibilityId,\n ...opts,\n });\n\n if (dumpResponse.type === 'error') {\n throw new Error(dumpResponse.message);\n }\n\n const element = dumpResponse.result;\n\n if (opts?.pruneCollapsed !== false) {\n pruneCollapsedElements(element);\n }\n\n if (opts?.deterministicOnly !== false) {\n removeNonDeterministicProps(element);\n }\n\n if (opts?.removeDefaultProps !== false) {\n removeDefaultProps(element);\n }\n\n return element;\n}\n\n/**\n * Removes trees of XAML that are not visible.\n */\nfunction pruneCollapsedElements(element: UIElement) {\n if (!element.children) {\n return;\n }\n\n element.children = element.children.filter(\n child => child.Visibility !== 'Collapsed',\n );\n\n element.children.forEach(pruneCollapsedElements);\n}\n\n/**\n * Removes trees of properties that are not deterministic\n */\nfunction removeNonDeterministicProps(element: UIElement) {\n if (element.RenderSize) {\n // RenderSize is subject to rounding, etc and should mostly be derived from\n // other deterministic properties in the tree.\n delete element.RenderSize;\n }\n\n if (element.children) {\n element.children.forEach(removeNonDeterministicProps);\n }\n}\n\n/**\n * Removes noise from snapshot by removing properties with the default value\n */\nfunction removeDefaultProps(element: UIElement) {\n const defaultValues: [string, unknown][] = [['Tooltip', null]];\n\n defaultValues.forEach(([propname, defaultValue]) => {\n if (element[propname] === defaultValue) {\n delete element[propname];\n }\n });\n\n if (element.children) {\n element.children.forEach(removeDefaultProps);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-windows/automation-commands",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.128",
|
|
4
4
|
"description": "Allows controlling your react-native-windows application",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"watch": "rnw-scripts watch"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@react-native-windows/automation-channel": "^0.12.
|
|
21
|
+
"@react-native-windows/automation-channel": "^0.12.26",
|
|
22
22
|
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
23
23
|
"@typescript-eslint/parser": "^5.57.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@jest/types": "^29.2.1",
|
|
27
27
|
"@rnw-scripts/eslint-config": "1.2.2",
|
|
28
|
-
"@rnw-scripts/just-task": "2.3.
|
|
28
|
+
"@rnw-scripts/just-task": "2.3.15",
|
|
29
29
|
"@rnw-scripts/ts-config": "2.0.5",
|
|
30
30
|
"@types/jest": "^29.2.2",
|
|
31
31
|
"@types/node": "^18.0.0",
|