sefiutils 1.0.40 → 1.0.42
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 +28 -14
- package/package.json +1 -1
package/lib/execScripts/fiber.js
CHANGED
|
@@ -29,7 +29,7 @@ function createComponentNode(fiber/* : Fiber */, parent/* : ComponentNode|undefi
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const debugType = fiber?._debugOwner?.type;
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
|
|
34
34
|
if (!parent) {
|
|
35
35
|
node.name = "root";
|
|
@@ -38,27 +38,27 @@ function createComponentNode(fiber/* : Fiber */, parent/* : ComponentNode|undefi
|
|
|
38
38
|
node.kind = "null";
|
|
39
39
|
node.name = "null";
|
|
40
40
|
if (debugType) {
|
|
41
|
-
node.name = debugType.displayName;
|
|
41
|
+
node.name = normalizeNodeName(debugType.displayName);
|
|
42
42
|
if (typeof debugType.render === 'function') {
|
|
43
43
|
node.type = "function";
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
} else if (typeof fiber.type === "function") {
|
|
47
|
-
node.name = fiber.type.name;
|
|
47
|
+
node.name = normalizeNodeName(fiber.type.name);
|
|
48
48
|
node.kind = "function";
|
|
49
49
|
|
|
50
50
|
node.props = getProps(fiber);
|
|
51
51
|
} else if (typeof fiber.type === "string") {
|
|
52
52
|
node.name = fiber.type;
|
|
53
53
|
node.kind = "html";
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
if (debugType) {
|
|
56
56
|
const debugNode/* : any */ = {
|
|
57
57
|
parent: parent,
|
|
58
58
|
children: []
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
debugNode.name = debugType.displayName;
|
|
60
|
+
|
|
61
|
+
debugNode.name = normalizeNodeName(debugType.displayName);
|
|
62
62
|
if (typeof debugType.render === 'function') {
|
|
63
63
|
debugNode.kind = "function";
|
|
64
64
|
} else {
|
|
@@ -69,18 +69,13 @@ function createComponentNode(fiber/* : Fiber */, parent/* : ComponentNode|undefi
|
|
|
69
69
|
parent.children.push(debugNode);
|
|
70
70
|
parent = debugNode;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
}
|
|
74
74
|
} else {
|
|
75
|
-
node.name = String(fiber.type);
|
|
75
|
+
node.name = normalizeNodeName(String(fiber.type));
|
|
76
76
|
node.kind = "other";
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
// TODO: remove this hack
|
|
80
|
-
if (node?.name.includes("_")) {
|
|
81
|
-
node.name = node.name.split("_")[1];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
79
|
if (parent) {
|
|
85
80
|
parent.children.push(node);
|
|
86
81
|
}
|
|
@@ -97,10 +92,29 @@ function createComponentNode(fiber/* : Fiber */, parent/* : ComponentNode|undefi
|
|
|
97
92
|
createComponentNode(fiberAct.sibling, parent);
|
|
98
93
|
}
|
|
99
94
|
}
|
|
100
|
-
|
|
95
|
+
|
|
101
96
|
return node;
|
|
102
97
|
}
|
|
103
98
|
|
|
99
|
+
/**
|
|
100
|
+
* In some rare cases, the name of a component contains underscores. In some cases,
|
|
101
|
+
* the component name is duplicated (A_A), in others the folder is prefixed (components_A).
|
|
102
|
+
* I have no idea how that works, when and why
|
|
103
|
+
* (maybe it is Webpack in combination with the rewired build to keep function names...).
|
|
104
|
+
*
|
|
105
|
+
* Anyway, here we remove the underscores and the prefix.
|
|
106
|
+
*
|
|
107
|
+
* TODO: This is a hack. We should find a better way to get the component name.
|
|
108
|
+
*/
|
|
109
|
+
function normalizeNodeName(fiberName /*: string*/)/* : string */ {
|
|
110
|
+
fiberName = fiberName.replace(/\s/g, "");
|
|
111
|
+
const lastIndex = fiberName.lastIndexOf("_");
|
|
112
|
+
if (lastIndex > 0 && lastIndex < fiberName.length - 1) { // -1: A_X -> length = 3, li=1, 3-1=2, 1<2; A_ -> length = 2, li=1, 2-1=1, ! 1<1
|
|
113
|
+
return fiberName.substring(lastIndex + 1);
|
|
114
|
+
}
|
|
115
|
+
return fiberName;
|
|
116
|
+
}
|
|
117
|
+
|
|
104
118
|
function remove(node/* : ComponentNode */, predicate/* : (node: ComponentNode) => boolean */) {
|
|
105
119
|
const filteredChildren = [];
|
|
106
120
|
for (const child of node.children) {
|
package/package.json
CHANGED