@lark-apaas/miaoda-inspector 0.1.0-alpha.1 → 0.1.0-alpha.3
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/es/Inspector/{Inspector.js → Inspector.mjs} +50 -55
- package/dist/es/Inspector/{Overlay.js → Overlay.mjs} +157 -125
- package/dist/es/Inspector/hooks/use-effect-event.mjs +17 -0
- package/dist/es/Inspector/hooks/use-layout-effect.mjs +9 -0
- package/dist/es/Inspector/hooks/{use-mouse.js → use-mouse.mjs} +8 -4
- package/dist/es/Inspector/index.mjs +5 -0
- package/dist/es/Inspector/utils/fiber.mjs +70 -0
- package/dist/es/Inspector/utils/highlight.mjs +78 -0
- package/dist/es/Inspector/utils/inspect.mjs +131 -0
- package/dist/es/Inspector/utils/{overlay.js → overlay.mjs} +7 -2
- package/dist/es/MiaodaInspector/MiaodaInspector.mjs +427 -0
- package/dist/es/MiaodaInspector/index.mjs +5 -0
- package/dist/es/chunk-I4E63NIC.mjs +24 -0
- package/dist/es/config/{ui-config.js → ui-config.mjs} +66 -286
- package/dist/es/global.d.mjs +0 -0
- package/dist/es/index.mjs +7 -0
- package/dist/es/types/iframe-events.mjs +0 -0
- package/dist/es/types/index.mjs +27 -0
- package/dist/es/utils/{config-mapper.js → config-mapper.mjs} +14 -56
- package/dist/es/utils/{css.js → css.mjs} +5 -1
- package/dist/es/utils/index.mjs +37 -0
- package/dist/es/utils/origin.mjs +26 -0
- package/dist/es/utils/style-calculator.mjs +177 -0
- package/dist/lib/Inspector/Inspector.js +99 -104
- package/dist/lib/Inspector/Overlay.js +172 -143
- package/dist/lib/Inspector/hooks/index.js +19 -19
- package/dist/lib/Inspector/hooks/use-effect-event.js +26 -15
- package/dist/lib/Inspector/hooks/use-layout-effect.js +25 -10
- package/dist/lib/Inspector/hooks/use-mouse.js +27 -14
- package/dist/lib/Inspector/index.js +21 -8
- package/dist/lib/Inspector/utils/fiber.js +49 -55
- package/dist/lib/Inspector/utils/highlight.js +44 -31
- package/dist/lib/Inspector/utils/index.js +19 -19
- package/dist/lib/Inspector/utils/inspect.js +62 -72
- package/dist/lib/Inspector/utils/overlay.js +20 -15
- package/dist/lib/MiaodaInspector/MiaodaInspector.js +265 -266
- package/dist/lib/MiaodaInspector/index.js +21 -8
- package/dist/lib/config/ui-config.js +81 -292
- package/dist/lib/global.d.js +1 -0
- package/dist/lib/index.js +22 -17
- package/dist/lib/types/iframe-events.js +15 -3
- package/dist/lib/types/index.js +30 -43
- package/dist/lib/utils/config-mapper.js +41 -69
- package/dist/lib/utils/css.js +33 -15
- package/dist/lib/utils/index.js +36 -57
- package/dist/lib/utils/origin.js +23 -22
- package/dist/lib/utils/style-calculator.js +113 -110
- package/dist/types/Inspector/Inspector.d.ts +95 -92
- package/dist/types/Inspector/Overlay.d.ts +61 -58
- package/dist/types/Inspector/hooks/index.d.ts +4 -3
- package/dist/types/Inspector/hooks/use-effect-event.d.ts +3 -1
- package/dist/types/Inspector/hooks/use-layout-effect.d.ts +5 -2
- package/dist/types/Inspector/hooks/use-mouse.d.ts +9 -8
- package/dist/types/Inspector/index.d.ts +4 -1
- package/dist/types/Inspector/utils/fiber.d.ts +12 -10
- package/dist/types/Inspector/utils/highlight.d.ts +7 -5
- package/dist/types/Inspector/utils/index.d.ts +4 -3
- package/dist/types/Inspector/utils/inspect.d.ts +45 -42
- package/dist/types/Inspector/utils/overlay.d.ts +24 -22
- package/dist/types/MiaodaInspector/MiaodaInspector.d.ts +42 -41
- package/dist/types/MiaodaInspector/index.d.ts +3 -1
- package/dist/types/config/ui-config.d.ts +42 -41
- package/dist/types/global.d.d.ts +17 -0
- package/dist/types/index.d.ts +5 -4
- package/dist/types/types/iframe-events.d.ts +133 -130
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/utils/config-mapper.d.ts +14 -11
- package/dist/types/utils/css.d.ts +5 -2
- package/dist/types/utils/index.d.ts +7 -3
- package/dist/types/utils/origin.d.ts +12 -8
- package/dist/types/utils/style-calculator.d.ts +20 -17
- package/package.json +13 -13
- package/dist/es/Inspector/hooks/use-effect-event.js +0 -15
- package/dist/es/Inspector/hooks/use-layout-effect.js +0 -3
- package/dist/es/Inspector/index.js +0 -1
- package/dist/es/Inspector/utils/fiber.js +0 -61
- package/dist/es/Inspector/utils/highlight.js +0 -74
- package/dist/es/Inspector/utils/inspect.js +0 -119
- package/dist/es/MiaodaInspector/MiaodaInspector.js +0 -397
- package/dist/es/MiaodaInspector/index.js +0 -1
- package/dist/es/index.js +0 -2
- package/dist/es/types/iframe-events.js +0 -1
- package/dist/es/types/index.js +0 -1
- package/dist/es/utils/index.js +0 -3
- package/dist/es/utils/origin.js +0 -19
- package/dist/es/utils/style-calculator.js +0 -158
- /package/dist/es/Inspector/hooks/{index.js → index.mjs} +0 -0
- /package/dist/es/Inspector/utils/{index.js → index.mjs} +0 -0
|
@@ -1,69 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return isNativeTagFiber;
|
|
15
|
-
},
|
|
16
|
-
isReactSymbolFiber: function() {
|
|
17
|
-
return isReactSymbolFiber;
|
|
18
|
-
},
|
|
19
|
-
isForwardRef: function() {
|
|
20
|
-
return isForwardRef;
|
|
21
|
-
},
|
|
22
|
-
getElementFiber: function() {
|
|
23
|
-
return getElementFiber;
|
|
24
|
-
},
|
|
25
|
-
getElementFiberUpward: function() {
|
|
26
|
-
return getElementFiberUpward;
|
|
27
|
-
},
|
|
28
|
-
getDirectParentFiber: function() {
|
|
29
|
-
return getDirectParentFiber;
|
|
30
|
-
},
|
|
31
|
-
getFiberName: function() {
|
|
32
|
-
return getFiberName;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var fiber_exports = {};
|
|
20
|
+
__export(fiber_exports, {
|
|
21
|
+
getDirectParentFiber: () => getDirectParentFiber,
|
|
22
|
+
getElementFiber: () => getElementFiber,
|
|
23
|
+
getElementFiberUpward: () => getElementFiberUpward,
|
|
24
|
+
getFiberName: () => getFiberName,
|
|
25
|
+
isForwardRef: () => isForwardRef,
|
|
26
|
+
isNativeTagFiber: () => isNativeTagFiber,
|
|
27
|
+
isReactSymbolFiber: () => isReactSymbolFiber
|
|
34
28
|
});
|
|
35
|
-
|
|
29
|
+
module.exports = __toCommonJS(fiber_exports);
|
|
30
|
+
const isNativeTagFiber = (fiber) => typeof (fiber == null ? void 0 : fiber.type) === "string";
|
|
36
31
|
const isReactSymbolFiber = (fiber) => {
|
|
37
|
-
var
|
|
38
|
-
return typeof (
|
|
32
|
+
var _a;
|
|
33
|
+
return typeof ((_a = fiber == null ? void 0 : fiber.type) == null ? void 0 : _a.$$typeof) === "symbol";
|
|
39
34
|
};
|
|
40
35
|
const isForwardRef = (fiber) => {
|
|
41
|
-
var
|
|
42
|
-
return (
|
|
36
|
+
var _a;
|
|
37
|
+
return ((_a = fiber == null ? void 0 : fiber.type) == null ? void 0 : _a.$$typeof) === Symbol.for("react.forward_ref");
|
|
43
38
|
};
|
|
44
39
|
const getElementFiber = (element) => {
|
|
45
|
-
const fiberKey = Object.keys(element).find(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
const fiberKey = Object.keys(element).find(
|
|
41
|
+
(key) => (
|
|
42
|
+
/**
|
|
43
|
+
* for react <= v16.13.1
|
|
44
|
+
* https://github.com/facebook/react/blob/v16.13.1/packages/react-dom/src/client/ReactDOMComponentTree.js#L21
|
|
45
|
+
*/
|
|
46
|
+
key.startsWith("__reactInternalInstance$") || /**
|
|
47
|
+
* for react >= v16.14.0
|
|
48
|
+
* https://github.com/facebook/react/blob/v16.14.0/packages/react-dom/src/client/ReactDOMComponentTree.js#L39
|
|
49
|
+
*/
|
|
50
|
+
key.startsWith("__reactFiber$")
|
|
51
|
+
)
|
|
52
|
+
);
|
|
56
53
|
if (fiberKey) {
|
|
57
54
|
return element[fiberKey];
|
|
58
55
|
}
|
|
59
56
|
return void 0;
|
|
60
57
|
};
|
|
61
58
|
const getElementFiberUpward = (element) => {
|
|
62
|
-
if (!element)
|
|
63
|
-
return void 0;
|
|
59
|
+
if (!element) return void 0;
|
|
64
60
|
const fiber = getElementFiber(element);
|
|
65
|
-
if (fiber)
|
|
66
|
-
return fiber;
|
|
61
|
+
if (fiber) return fiber;
|
|
67
62
|
return getElementFiberUpward(element.parentElement);
|
|
68
63
|
};
|
|
69
64
|
const getDirectParentFiber = (child) => {
|
|
@@ -77,12 +72,11 @@ const getDirectParentFiber = (child) => {
|
|
|
77
72
|
return null;
|
|
78
73
|
};
|
|
79
74
|
const getFiberName = (fiber) => {
|
|
80
|
-
var
|
|
81
|
-
const fiberType = fiber
|
|
82
|
-
if (!fiberType)
|
|
83
|
-
return void 0;
|
|
75
|
+
var _a;
|
|
76
|
+
const fiberType = fiber == null ? void 0 : fiber.type;
|
|
77
|
+
if (!fiberType) return void 0;
|
|
84
78
|
const { displayName, name } = fiberType;
|
|
85
|
-
if (
|
|
79
|
+
if ((_a = fiber == null ? void 0 : fiber.pendingProps) == null ? void 0 : _a["data-miaoda-component-name"]) {
|
|
86
80
|
return fiber.pendingProps["data-miaoda-component-name"];
|
|
87
81
|
}
|
|
88
82
|
if (typeof displayName === "string") {
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var highlight_exports = {};
|
|
20
|
+
__export(highlight_exports, {
|
|
21
|
+
setupHighlighter: () => setupHighlighter
|
|
10
22
|
});
|
|
23
|
+
module.exports = __toCommonJS(highlight_exports);
|
|
11
24
|
let iframesListeningTo = /* @__PURE__ */ new Set();
|
|
12
25
|
function setupHighlighter(handlers) {
|
|
13
26
|
function onClick(event) {
|
|
14
|
-
var
|
|
27
|
+
var _a;
|
|
15
28
|
event.preventDefault();
|
|
16
29
|
event.stopPropagation();
|
|
17
|
-
(
|
|
30
|
+
(_a = handlers.onClick) == null ? void 0 : _a.call(handlers, event.target);
|
|
18
31
|
}
|
|
19
32
|
function onMouseEvent(event) {
|
|
20
33
|
event.stopPropagation();
|
|
@@ -23,7 +36,7 @@ function setupHighlighter(handlers) {
|
|
|
23
36
|
event.stopPropagation();
|
|
24
37
|
}
|
|
25
38
|
function onPointerOver(event) {
|
|
26
|
-
var
|
|
39
|
+
var _a;
|
|
27
40
|
event.preventDefault();
|
|
28
41
|
event.stopPropagation();
|
|
29
42
|
const target = event.target;
|
|
@@ -31,28 +44,28 @@ function setupHighlighter(handlers) {
|
|
|
31
44
|
const iframe = target;
|
|
32
45
|
try {
|
|
33
46
|
if (!iframesListeningTo.has(iframe)) {
|
|
34
|
-
const
|
|
35
|
-
registerListenersOnWindow(
|
|
47
|
+
const window2 = iframe.contentWindow;
|
|
48
|
+
registerListenersOnWindow(window2);
|
|
36
49
|
iframesListeningTo.add(iframe);
|
|
37
50
|
}
|
|
38
51
|
} catch (error) {
|
|
39
52
|
}
|
|
40
53
|
}
|
|
41
|
-
(
|
|
54
|
+
(_a = handlers.onPointerOver) == null ? void 0 : _a.call(handlers, event.target);
|
|
42
55
|
}
|
|
43
56
|
function onPointerUp(event) {
|
|
44
57
|
event.preventDefault();
|
|
45
58
|
event.stopPropagation();
|
|
46
59
|
}
|
|
47
|
-
function removeListenersOnWindow(
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
function removeListenersOnWindow(window2) {
|
|
61
|
+
if (window2 && typeof window2.removeEventListener === "function") {
|
|
62
|
+
window2.removeEventListener("click", onClick, true);
|
|
63
|
+
window2.removeEventListener("mousedown", onMouseEvent, true);
|
|
64
|
+
window2.removeEventListener("mouseover", onMouseEvent, true);
|
|
65
|
+
window2.removeEventListener("mouseup", onMouseEvent, true);
|
|
66
|
+
window2.removeEventListener("pointerdown", onPointerDown, true);
|
|
67
|
+
window2.removeEventListener("pointerover", onPointerOver, true);
|
|
68
|
+
window2.removeEventListener("pointerup", onPointerUp, true);
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
function stopInspectingNative() {
|
|
@@ -65,15 +78,15 @@ function setupHighlighter(handlers) {
|
|
|
65
78
|
});
|
|
66
79
|
iframesListeningTo = /* @__PURE__ */ new Set();
|
|
67
80
|
}
|
|
68
|
-
function registerListenersOnWindow(
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
function registerListenersOnWindow(window2) {
|
|
82
|
+
if (window2 && typeof window2.addEventListener === "function") {
|
|
83
|
+
window2.addEventListener("click", onClick, true);
|
|
84
|
+
window2.addEventListener("mousedown", onMouseEvent, true);
|
|
85
|
+
window2.addEventListener("mouseover", onMouseEvent, true);
|
|
86
|
+
window2.addEventListener("mouseup", onMouseEvent, true);
|
|
87
|
+
window2.addEventListener("pointerdown", onPointerDown, true);
|
|
88
|
+
window2.addEventListener("pointerover", onPointerOver, true);
|
|
89
|
+
window2.addEventListener("pointerup", onPointerUp, true);
|
|
77
90
|
}
|
|
78
91
|
}
|
|
79
92
|
function startInspectingNative() {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var utils_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(utils_exports);
|
|
18
|
+
__reExport(utils_exports, require("./highlight"), module.exports);
|
|
19
|
+
__reExport(utils_exports, require("./inspect"), module.exports);
|
|
20
|
+
__reExport(utils_exports, require("./overlay"), module.exports);
|
|
@@ -1,66 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return getCodeInfoFromDebugSource;
|
|
15
|
-
},
|
|
16
|
-
getCodeInfoFromProps: function() {
|
|
17
|
-
return getCodeInfoFromProps;
|
|
18
|
-
},
|
|
19
|
-
getCodeInfoFromFiber: function() {
|
|
20
|
-
return getCodeInfoFromFiber;
|
|
21
|
-
},
|
|
22
|
-
getReferenceFiber: function() {
|
|
23
|
-
return getReferenceFiber;
|
|
24
|
-
},
|
|
25
|
-
getElementCodeInfo: function() {
|
|
26
|
-
return getElementCodeInfo;
|
|
27
|
-
},
|
|
28
|
-
getNamedFiber: function() {
|
|
29
|
-
return getNamedFiber;
|
|
30
|
-
},
|
|
31
|
-
getElementInspect: function() {
|
|
32
|
-
return getElementInspect;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var inspect_exports = {};
|
|
20
|
+
__export(inspect_exports, {
|
|
21
|
+
getCodeInfoFromDebugSource: () => getCodeInfoFromDebugSource,
|
|
22
|
+
getCodeInfoFromFiber: () => getCodeInfoFromFiber,
|
|
23
|
+
getCodeInfoFromProps: () => getCodeInfoFromProps,
|
|
24
|
+
getElementCodeInfo: () => getElementCodeInfo,
|
|
25
|
+
getElementInspect: () => getElementInspect,
|
|
26
|
+
getNamedFiber: () => getNamedFiber,
|
|
27
|
+
getReferenceFiber: () => getReferenceFiber
|
|
34
28
|
});
|
|
35
|
-
|
|
29
|
+
module.exports = __toCommonJS(inspect_exports);
|
|
30
|
+
var import_fiber = require("./fiber");
|
|
36
31
|
const getCodeInfoFromDebugSource = (fiber) => {
|
|
37
|
-
var
|
|
38
|
-
if (!fiber)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const debugSource = (_fiber__debugSource = fiber._debugSource) !== null && _fiber__debugSource !== void 0 ? _fiber__debugSource : (_fiber__debugOwner = fiber._debugOwner) === null || _fiber__debugOwner === void 0 ? void 0 : _fiber__debugOwner._debugSource;
|
|
42
|
-
if (!debugSource)
|
|
43
|
-
return void 0;
|
|
32
|
+
var _a, _b;
|
|
33
|
+
if (!fiber) return void 0;
|
|
34
|
+
const debugSource = (_b = fiber._debugSource) != null ? _b : (_a = fiber._debugOwner) == null ? void 0 : _a._debugSource;
|
|
35
|
+
if (!debugSource) return void 0;
|
|
44
36
|
const { fileName, lineNumber, columnNumber } = debugSource;
|
|
45
37
|
if (fileName && lineNumber) {
|
|
46
38
|
return {
|
|
47
39
|
lineNumber: String(lineNumber),
|
|
48
|
-
columnNumber: String(columnNumber
|
|
40
|
+
columnNumber: String(columnNumber != null ? columnNumber : 1),
|
|
49
41
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
* `fileName` in `_debugSource` is absolutely
|
|
43
|
+
* ---
|
|
44
|
+
*
|
|
45
|
+
* compatible with the incorrect `fileName: "</xxx/file>"` by [rspack](https://github.com/web-infra-dev/rspack)
|
|
46
|
+
*/
|
|
55
47
|
absolutePath: fileName.match(/^<.*>$/) ? fileName.replace(/^<|>$/g, "") : fileName
|
|
56
48
|
};
|
|
57
49
|
}
|
|
58
50
|
return void 0;
|
|
59
51
|
};
|
|
60
52
|
const getCodeInfoFromProps = (fiber) => {
|
|
61
|
-
if (!(fiber
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
if (!(fiber == null ? void 0 : fiber.pendingProps)) return void 0;
|
|
54
|
+
const {
|
|
55
|
+
"data-miaoda-line": lineNumber,
|
|
56
|
+
"data-miaoda-column": columnNumber,
|
|
57
|
+
"data-miaoda-relative-path": relativePath,
|
|
58
|
+
"data-miaoda-component-name": name,
|
|
59
|
+
"data-miaoda-metadata": metadataStr
|
|
60
|
+
} = fiber.pendingProps;
|
|
64
61
|
let metadata;
|
|
65
62
|
if (metadataStr) {
|
|
66
63
|
try {
|
|
@@ -85,66 +82,59 @@ const getCodeInfoFromFiber = (fiber) => {
|
|
|
85
82
|
// getCodeInfoFromDebugSource(fiber),
|
|
86
83
|
getCodeInfoFromProps(fiber)
|
|
87
84
|
].filter(Boolean);
|
|
88
|
-
if (!codeInfos.length)
|
|
89
|
-
return void 0;
|
|
85
|
+
if (!codeInfos.length) return void 0;
|
|
90
86
|
return Object.assign({}, ...codeInfos);
|
|
91
87
|
};
|
|
92
88
|
const getReferenceFiber = (baseFiber) => {
|
|
93
|
-
if (!baseFiber)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return void 0;
|
|
98
|
-
const isParentNative = (0, _fiber.isNativeTagFiber)(directParent);
|
|
89
|
+
if (!baseFiber) return void 0;
|
|
90
|
+
const directParent = (0, import_fiber.getDirectParentFiber)(baseFiber);
|
|
91
|
+
if (!directParent) return void 0;
|
|
92
|
+
const isParentNative = (0, import_fiber.isNativeTagFiber)(directParent);
|
|
99
93
|
const isOnlyOneChild = !directParent.child.sibling;
|
|
100
94
|
let referenceFiber = !isParentNative && isOnlyOneChild ? directParent : baseFiber;
|
|
101
95
|
const originReferenceFiber = referenceFiber;
|
|
102
96
|
while (referenceFiber) {
|
|
103
|
-
if (getCodeInfoFromFiber(referenceFiber))
|
|
104
|
-
return referenceFiber;
|
|
97
|
+
if (getCodeInfoFromFiber(referenceFiber)) return referenceFiber;
|
|
105
98
|
referenceFiber = referenceFiber.return;
|
|
106
99
|
}
|
|
107
100
|
return originReferenceFiber;
|
|
108
101
|
};
|
|
109
102
|
const getElementCodeInfo = (element) => {
|
|
110
|
-
const fiber = (0,
|
|
103
|
+
const fiber = (0, import_fiber.getElementFiberUpward)(element);
|
|
111
104
|
const referenceFiber = getReferenceFiber(fiber);
|
|
112
105
|
return getCodeInfoFromFiber(referenceFiber);
|
|
113
106
|
};
|
|
114
107
|
const getNamedFiber = (baseFiber) => {
|
|
108
|
+
var _a, _b;
|
|
115
109
|
let fiber = baseFiber;
|
|
116
110
|
let originNamedFiber;
|
|
117
111
|
while (fiber) {
|
|
118
|
-
|
|
119
|
-
let parent = (_fiber_return = fiber.return) !== null && _fiber_return !== void 0 ? _fiber_return : void 0;
|
|
112
|
+
let parent = (_a = fiber.return) != null ? _a : void 0;
|
|
120
113
|
let forwardParent;
|
|
121
|
-
while ((0,
|
|
122
|
-
if ((0,
|
|
114
|
+
while ((0, import_fiber.isReactSymbolFiber)(parent)) {
|
|
115
|
+
if ((0, import_fiber.isForwardRef)(parent)) {
|
|
123
116
|
forwardParent = parent;
|
|
124
117
|
}
|
|
125
|
-
|
|
126
|
-
parent = (_parent_return = parent === null || parent === void 0 ? void 0 : parent.return) !== null && _parent_return !== void 0 ? _parent_return : void 0;
|
|
118
|
+
parent = (_b = parent == null ? void 0 : parent.return) != null ? _b : void 0;
|
|
127
119
|
}
|
|
128
120
|
if (forwardParent) {
|
|
129
121
|
fiber = forwardParent;
|
|
130
122
|
}
|
|
131
|
-
if ((0,
|
|
132
|
-
if (!originNamedFiber)
|
|
133
|
-
|
|
134
|
-
if (getCodeInfoFromFiber(fiber))
|
|
135
|
-
return fiber;
|
|
123
|
+
if ((0, import_fiber.getFiberName)(fiber)) {
|
|
124
|
+
if (!originNamedFiber) originNamedFiber = fiber;
|
|
125
|
+
if (getCodeInfoFromFiber(fiber)) return fiber;
|
|
136
126
|
}
|
|
137
127
|
fiber = parent;
|
|
138
128
|
}
|
|
139
129
|
return originNamedFiber;
|
|
140
130
|
};
|
|
141
131
|
const getElementInspect = (element) => {
|
|
142
|
-
const fiber = (0,
|
|
132
|
+
const fiber = (0, import_fiber.getElementFiberUpward)(element);
|
|
143
133
|
const referenceFiber = getReferenceFiber(fiber);
|
|
144
134
|
const namedFiber = getNamedFiber(referenceFiber);
|
|
145
|
-
const fiberName = (0,
|
|
135
|
+
const fiberName = (0, import_fiber.getFiberName)(namedFiber);
|
|
146
136
|
const nodeName = element.nodeName.toLowerCase();
|
|
147
|
-
const title = fiberName
|
|
137
|
+
const title = fiberName != null ? fiberName : nodeName;
|
|
148
138
|
return {
|
|
149
139
|
fiber: referenceFiber,
|
|
150
140
|
name: fiberName,
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return getNestedBoundingClientRect;
|
|
15
|
-
},
|
|
16
|
-
getElementDimensions: function() {
|
|
17
|
-
return getElementDimensions;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var overlay_exports = {};
|
|
20
|
+
__export(overlay_exports, {
|
|
21
|
+
getElementDimensions: () => getElementDimensions,
|
|
22
|
+
getNestedBoundingClientRect: () => getNestedBoundingClientRect
|
|
19
23
|
});
|
|
24
|
+
module.exports = __toCommonJS(overlay_exports);
|
|
20
25
|
function getNestedBoundingClientRect(node) {
|
|
21
26
|
return node.getBoundingClientRect();
|
|
22
27
|
}
|