sefiutils 1.0.10 → 1.0.12
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/lib/execScripts/fiber.js +46 -7
- package/lib/fiberUtils.d.ts +1 -1
- package/lib/fiberUtils.d.ts.map +1 -1
- package/lib/fiberUtils.js +2 -2
- package/lib/fiberUtils.js.map +1 -1
- package/package.json +1 -1
package/lib/execScripts/fiber.js
CHANGED
|
@@ -27,9 +27,9 @@ function createComponentNode(fiber/* : Fiber */, parent/* : ComponentNode|undefi
|
|
|
27
27
|
parent: parent,
|
|
28
28
|
children: []
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
|
|
31
|
+
const debugType = fiber?._debugOwner?.type;
|
|
32
|
+
|
|
33
33
|
|
|
34
34
|
if (!parent) {
|
|
35
35
|
node.name = "root";
|
|
@@ -37,6 +37,12 @@ function createComponentNode(fiber/* : Fiber */, parent/* : ComponentNode|undefi
|
|
|
37
37
|
} else if (fiber.type === null) {
|
|
38
38
|
node.kind = "null";
|
|
39
39
|
node.name = "null";
|
|
40
|
+
if (debugType) {
|
|
41
|
+
node.name = debugType.displayName();
|
|
42
|
+
if (typeof debugType.render === 'function') {
|
|
43
|
+
node.type = "function";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
40
46
|
} else if (typeof fiber.type === "function") {
|
|
41
47
|
node.name = fiber.type.name;
|
|
42
48
|
node.kind = "function";
|
|
@@ -45,11 +51,35 @@ function createComponentNode(fiber/* : Fiber */, parent/* : ComponentNode|undefi
|
|
|
45
51
|
} else if (typeof fiber.type === "string") {
|
|
46
52
|
node.name = fiber.type;
|
|
47
53
|
node.kind = "html";
|
|
54
|
+
|
|
55
|
+
if (debugType) {
|
|
56
|
+
const debugNode/* : any */ = {
|
|
57
|
+
parent: parent,
|
|
58
|
+
children: []
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
debugNode.name = debugType.displayName;
|
|
62
|
+
if (typeof debugType.render === 'function') {
|
|
63
|
+
debugNode.type = "function";
|
|
64
|
+
} else {
|
|
65
|
+
debugNode.type = "null";
|
|
66
|
+
}
|
|
67
|
+
node.parent = debugNode;
|
|
68
|
+
if (parent) {
|
|
69
|
+
parent.children.push(debugNode);
|
|
70
|
+
parent = debugNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
48
74
|
} else {
|
|
49
75
|
node.name = String(fiber.type);
|
|
50
76
|
node.kind = "other";
|
|
51
77
|
}
|
|
52
78
|
|
|
79
|
+
if (parent) {
|
|
80
|
+
parent.children.push(node);
|
|
81
|
+
}
|
|
82
|
+
|
|
53
83
|
if (fiber.child) {
|
|
54
84
|
createComponentNode(fiber.child, node);
|
|
55
85
|
} else if (fiberAct.child) {
|
|
@@ -108,15 +138,15 @@ function getProps(fiber/* : Fiber */)/* : string[] */ {
|
|
|
108
138
|
return props;
|
|
109
139
|
}
|
|
110
140
|
|
|
111
|
-
function getComponentTree(
|
|
112
|
-
const root = getFiberRoot(
|
|
141
|
+
function getComponentTree() {
|
|
142
|
+
const root = getFiberRoot();
|
|
113
143
|
if (!root) {
|
|
114
144
|
return undefined;
|
|
115
145
|
}
|
|
116
146
|
return createComponentNode(root, undefined)
|
|
117
147
|
}
|
|
118
148
|
|
|
119
|
-
function getFiberRoot(
|
|
149
|
+
function getFiberRoot()/* : Fiber|undefined */ {
|
|
120
150
|
const rootElement = document.getElementById("root");
|
|
121
151
|
if (rootElement) {
|
|
122
152
|
const reactContainerProp = Object.keys(rootElement).find(key => key.startsWith("__reactContainer$"));
|
|
@@ -126,7 +156,7 @@ function getFiberRoot(doc/* : Document */)/* : Fiber|undefined */ {
|
|
|
126
156
|
}
|
|
127
157
|
}
|
|
128
158
|
|
|
129
|
-
function
|
|
159
|
+
function dumpReactComponentTree(node/* : ComponentNode */, indent/* : string */ = "") {
|
|
130
160
|
console.log(`${indent}${node.name} (${node.kind})${(node.props && node.props.length > 0) ? ": " + node.props.join(", ") : ""}`);
|
|
131
161
|
for (const child of node.children) {
|
|
132
162
|
dump(child, indent + " ");
|
|
@@ -149,4 +179,13 @@ function uniDirFunctionComponentsTree() {
|
|
|
149
179
|
retainFunctions(tree);
|
|
150
180
|
removeParentReferences(tree);
|
|
151
181
|
return tree;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function uniDirComponentsTree() {
|
|
185
|
+
const tree = getComponentTree(document);
|
|
186
|
+
if (!tree) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
removeParentReferences(tree);
|
|
190
|
+
return tree;
|
|
152
191
|
}
|
package/lib/fiberUtils.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface ComponentNode {
|
|
|
6
6
|
props?: string[];
|
|
7
7
|
children: ComponentNode[];
|
|
8
8
|
}
|
|
9
|
-
export declare function getReactComponentTree(driver: WebDriver): Promise<ComponentNode>;
|
|
9
|
+
export declare function getReactComponentTree(driver: WebDriver, functionComponentsOnly?: boolean): Promise<ComponentNode>;
|
|
10
10
|
export declare function dumpComponentTree(node: ComponentNode): string;
|
|
11
11
|
export declare function findInComponentTree(node: ComponentNode, predicate: (node: ComponentNode) => boolean): ComponentNode | undefined;
|
|
12
12
|
export declare function findAllInComponentTree(node: ComponentNode, predicate: (node: ComponentNode) => boolean): ComponentNode[];
|
package/lib/fiberUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fiberUtils.d.ts","sourceRoot":"","sources":["../src/fiberUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5E,MAAM,WAAW,aAAa;IAE1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB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U,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,EAAE,CA8BpD"}
|
package/lib/fiberUtils.js
CHANGED
|
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.retrieveComponentPath = exports.componentPathExists = exports.findAllInComponentTree = exports.findInComponentTree = exports.dumpComponentTree = exports.getReactComponentTree = void 0;
|
|
13
13
|
const seUtils_1 = require("./seUtils");
|
|
14
|
-
function getReactComponentTree(driver) {
|
|
14
|
+
function getReactComponentTree(driver, functionComponentsOnly = true) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const cmpTree = yield (0, seUtils_1.execScript)(driver, "execScripts/fiber.js", "uniDirFunctionComponentsTree");
|
|
16
|
+
const cmpTree = yield (0, seUtils_1.execScript)(driver, "execScripts/fiber.js", functionComponentsOnly ? "uniDirFunctionComponentsTree" : "uniDirComponentsTree");
|
|
17
17
|
return cmpTree;
|
|
18
18
|
});
|
|
19
19
|
}
|
package/lib/fiberUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fiberUtils.js","sourceRoot":"","sources":["../src/fiberUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,uCAAmD;AAYnD,SAAsB,qBAAqB,CAAC,MAAiB;;
|
|
1
|
+
{"version":3,"file":"fiberUtils.js","sourceRoot":"","sources":["../src/fiberUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,uCAAmD;AAYnD,SAAsB,qBAAqB,CAAC,MAAiB,EAAE,sBAAsB,GAAC,IAAI;;QACtF,MAAM,OAAO,GAAkB,MAAM,IAAA,oBAAU,EAAC,MAAM,EAClD,sBAAsB,EACtB,sBAAsB,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC;QACtF,OAAO,OAAO,CAAC;IACnB,CA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