@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.
Files changed (88) hide show
  1. package/dist/es/Inspector/{Inspector.js → Inspector.mjs} +50 -55
  2. package/dist/es/Inspector/{Overlay.js → Overlay.mjs} +157 -125
  3. package/dist/es/Inspector/hooks/use-effect-event.mjs +17 -0
  4. package/dist/es/Inspector/hooks/use-layout-effect.mjs +9 -0
  5. package/dist/es/Inspector/hooks/{use-mouse.js → use-mouse.mjs} +8 -4
  6. package/dist/es/Inspector/index.mjs +5 -0
  7. package/dist/es/Inspector/utils/fiber.mjs +70 -0
  8. package/dist/es/Inspector/utils/highlight.mjs +78 -0
  9. package/dist/es/Inspector/utils/inspect.mjs +131 -0
  10. package/dist/es/Inspector/utils/{overlay.js → overlay.mjs} +7 -2
  11. package/dist/es/MiaodaInspector/MiaodaInspector.mjs +427 -0
  12. package/dist/es/MiaodaInspector/index.mjs +5 -0
  13. package/dist/es/chunk-I4E63NIC.mjs +24 -0
  14. package/dist/es/config/{ui-config.js → ui-config.mjs} +66 -286
  15. package/dist/es/global.d.mjs +0 -0
  16. package/dist/es/index.mjs +7 -0
  17. package/dist/es/types/iframe-events.mjs +0 -0
  18. package/dist/es/types/index.mjs +27 -0
  19. package/dist/es/utils/{config-mapper.js → config-mapper.mjs} +14 -56
  20. package/dist/es/utils/{css.js → css.mjs} +5 -1
  21. package/dist/es/utils/index.mjs +37 -0
  22. package/dist/es/utils/origin.mjs +26 -0
  23. package/dist/es/utils/style-calculator.mjs +177 -0
  24. package/dist/lib/Inspector/Inspector.js +99 -104
  25. package/dist/lib/Inspector/Overlay.js +172 -143
  26. package/dist/lib/Inspector/hooks/index.js +19 -19
  27. package/dist/lib/Inspector/hooks/use-effect-event.js +26 -15
  28. package/dist/lib/Inspector/hooks/use-layout-effect.js +25 -10
  29. package/dist/lib/Inspector/hooks/use-mouse.js +27 -14
  30. package/dist/lib/Inspector/index.js +21 -8
  31. package/dist/lib/Inspector/utils/fiber.js +49 -55
  32. package/dist/lib/Inspector/utils/highlight.js +44 -31
  33. package/dist/lib/Inspector/utils/index.js +19 -19
  34. package/dist/lib/Inspector/utils/inspect.js +62 -72
  35. package/dist/lib/Inspector/utils/overlay.js +20 -15
  36. package/dist/lib/MiaodaInspector/MiaodaInspector.js +265 -266
  37. package/dist/lib/MiaodaInspector/index.js +21 -8
  38. package/dist/lib/config/ui-config.js +81 -292
  39. package/dist/lib/global.d.js +1 -0
  40. package/dist/lib/index.js +22 -17
  41. package/dist/lib/types/iframe-events.js +15 -3
  42. package/dist/lib/types/index.js +30 -43
  43. package/dist/lib/utils/config-mapper.js +41 -69
  44. package/dist/lib/utils/css.js +33 -15
  45. package/dist/lib/utils/index.js +36 -57
  46. package/dist/lib/utils/origin.js +23 -22
  47. package/dist/lib/utils/style-calculator.js +113 -110
  48. package/dist/types/Inspector/Inspector.d.ts +95 -92
  49. package/dist/types/Inspector/Overlay.d.ts +61 -58
  50. package/dist/types/Inspector/hooks/index.d.ts +4 -3
  51. package/dist/types/Inspector/hooks/use-effect-event.d.ts +3 -1
  52. package/dist/types/Inspector/hooks/use-layout-effect.d.ts +5 -2
  53. package/dist/types/Inspector/hooks/use-mouse.d.ts +9 -8
  54. package/dist/types/Inspector/index.d.ts +4 -1
  55. package/dist/types/Inspector/utils/fiber.d.ts +12 -10
  56. package/dist/types/Inspector/utils/highlight.d.ts +7 -5
  57. package/dist/types/Inspector/utils/index.d.ts +4 -3
  58. package/dist/types/Inspector/utils/inspect.d.ts +45 -42
  59. package/dist/types/Inspector/utils/overlay.d.ts +24 -22
  60. package/dist/types/MiaodaInspector/MiaodaInspector.d.ts +42 -41
  61. package/dist/types/MiaodaInspector/index.d.ts +3 -1
  62. package/dist/types/config/ui-config.d.ts +42 -41
  63. package/dist/types/global.d.d.ts +17 -0
  64. package/dist/types/index.d.ts +5 -4
  65. package/dist/types/types/iframe-events.d.ts +133 -130
  66. package/dist/types/types/index.d.ts +2 -1
  67. package/dist/types/utils/config-mapper.d.ts +14 -11
  68. package/dist/types/utils/css.d.ts +5 -2
  69. package/dist/types/utils/index.d.ts +7 -3
  70. package/dist/types/utils/origin.d.ts +12 -8
  71. package/dist/types/utils/style-calculator.d.ts +20 -17
  72. package/package.json +13 -13
  73. package/dist/es/Inspector/hooks/use-effect-event.js +0 -15
  74. package/dist/es/Inspector/hooks/use-layout-effect.js +0 -3
  75. package/dist/es/Inspector/index.js +0 -1
  76. package/dist/es/Inspector/utils/fiber.js +0 -61
  77. package/dist/es/Inspector/utils/highlight.js +0 -74
  78. package/dist/es/Inspector/utils/inspect.js +0 -119
  79. package/dist/es/MiaodaInspector/MiaodaInspector.js +0 -397
  80. package/dist/es/MiaodaInspector/index.js +0 -1
  81. package/dist/es/index.js +0 -2
  82. package/dist/es/types/iframe-events.js +0 -1
  83. package/dist/es/types/index.js +0 -1
  84. package/dist/es/utils/index.js +0 -3
  85. package/dist/es/utils/origin.js +0 -19
  86. package/dist/es/utils/style-calculator.js +0 -158
  87. /package/dist/es/Inspector/hooks/{index.js → index.mjs} +0 -0
  88. /package/dist/es/Inspector/utils/{index.js → index.mjs} +0 -0
@@ -0,0 +1,177 @@
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues
4
+ } from "../chunk-I4E63NIC.mjs";
5
+ function rgbaToHex(rgba) {
6
+ const match = rgba.match(/rgba?\(([^)]+)\)/);
7
+ if (!match) return rgba;
8
+ const values = match[1].split(",").map((v) => v.trim());
9
+ const r = parseInt(values[0], 10);
10
+ const g = parseInt(values[1], 10);
11
+ const b = parseInt(values[2], 10);
12
+ const toHex = (n) => {
13
+ const hex = n.toString(16);
14
+ return hex.length === 1 ? `0${hex}` : hex;
15
+ };
16
+ if (values.length === 4) {
17
+ const a = parseFloat(values[3]);
18
+ if (!Number.isNaN(a) && a < 1) {
19
+ const alphaHex = Math.round(a * 255).toString(16);
20
+ const alphaHexStr = alphaHex.length === 1 ? `0${alphaHex}` : alphaHex;
21
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}${alphaHexStr}`;
22
+ }
23
+ }
24
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
25
+ }
26
+ function isValidElement(element, componentName, canUseNewInspector) {
27
+ return !!(element && componentName && componentName[0] !== componentName[0].toUpperCase() && canUseNewInspector && !(element instanceof SVGElement));
28
+ }
29
+ function isValidElementWithComponent(element, componentName, canUseNewInspector) {
30
+ return !!(element && componentName && canUseNewInspector && !(element instanceof SVGElement));
31
+ }
32
+ function shouldBeInherited(element, cssProperty, tailwindPattern) {
33
+ const hasDirectStyle = element.style[cssProperty] !== "";
34
+ const hasTailwindClass = element.className.match(tailwindPattern);
35
+ return !hasDirectStyle && !hasTailwindClass;
36
+ }
37
+ function findClosestMatch(value, map, tolerance = 2) {
38
+ let closestClass = Object.values(map)[0];
39
+ let minDiff = Infinity;
40
+ for (const [px, className] of Object.entries(map)) {
41
+ const diff = Math.abs(value - Number(px));
42
+ if (diff < minDiff) {
43
+ minDiff = diff;
44
+ closestClass = className;
45
+ }
46
+ }
47
+ return {
48
+ className: minDiff <= tolerance ? closestClass : `raw:${value}`,
49
+ isExact: minDiff <= tolerance
50
+ };
51
+ }
52
+ function calculateStyleProperty(element, config) {
53
+ const computedStyle = window.getComputedStyle(element);
54
+ const currentValue = computedStyle[config.cssProperty];
55
+ if (!currentValue) {
56
+ return null;
57
+ }
58
+ let tailwindClassName;
59
+ if (config.cssProperty === "textAlign" || config.skipTailwind) {
60
+ tailwindClassName = config.map[currentValue] || `raw:${currentValue}`;
61
+ } else if (config.cssProperty === "color" || config.cssProperty === "backgroundColor" || config.cssProperty === "borderColor") {
62
+ const normalizedColor = rgbaToHex(currentValue);
63
+ const colorValue = config.transformValue ? config.transformValue(normalizedColor) : normalizedColor;
64
+ tailwindClassName = config.map[colorValue] || `raw:${normalizedColor}`;
65
+ } else {
66
+ const numericValue = config.transformValue ? config.transformValue(currentValue) : parseFloat(currentValue);
67
+ const { className } = findClosestMatch(
68
+ numericValue,
69
+ config.map,
70
+ config.tolerance
71
+ );
72
+ tailwindClassName = className;
73
+ }
74
+ const inherited = config.tailwindPattern ? shouldBeInherited(element, config.cssProperty, config.tailwindPattern) : false;
75
+ return {
76
+ value: currentValue,
77
+ inherited,
78
+ tailwindClassName
79
+ };
80
+ }
81
+ function calculateStyle(styleName, element, componentName, canUseNewInspector, styleConfigs) {
82
+ if ((styleName === "fontSize" || styleName === "fontWeight" || styleName === "color" || styleName === "textAlign") && !isValidElement(element, componentName, canUseNewInspector)) {
83
+ return null;
84
+ }
85
+ if (!isValidElementWithComponent(element, componentName, canUseNewInspector)) {
86
+ return null;
87
+ }
88
+ const config = styleConfigs[styleName];
89
+ const tailwindPattern = new RegExp(
90
+ `\\b${config.tailwindPrefix}-(${Object.keys(config.map).join("|")})\\b`
91
+ );
92
+ return calculateStyleProperty(element, __spreadProps(__spreadValues({}, config), {
93
+ tailwindPattern
94
+ }));
95
+ }
96
+ const calculateFontSizeInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
97
+ "fontSize",
98
+ element,
99
+ componentName,
100
+ canUseNewInspector,
101
+ styleConfigs
102
+ );
103
+ const calculateFontWeightInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
104
+ "fontWeight",
105
+ element,
106
+ componentName,
107
+ canUseNewInspector,
108
+ styleConfigs
109
+ );
110
+ const calculateBorderRadiusInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
111
+ "borderRadius",
112
+ element,
113
+ componentName,
114
+ canUseNewInspector,
115
+ styleConfigs
116
+ );
117
+ const calculateBorderWidthInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
118
+ "borderWidth",
119
+ element,
120
+ componentName,
121
+ canUseNewInspector,
122
+ styleConfigs
123
+ );
124
+ const calculateTextAlignInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
125
+ "textAlign",
126
+ element,
127
+ componentName,
128
+ canUseNewInspector,
129
+ styleConfigs
130
+ );
131
+ const calculatePaddingInfo = (element, componentName, canUseNewInspector, styleConfigs) => {
132
+ if (!isValidElementWithComponent(element, componentName, canUseNewInspector)) {
133
+ return null;
134
+ }
135
+ return calculateStyleProperty(element, styleConfigs.padding);
136
+ };
137
+ const calculateMarginInfo = (element, componentName, canUseNewInspector, styleConfigs) => {
138
+ if (!isValidElementWithComponent(element, componentName, canUseNewInspector)) {
139
+ return null;
140
+ }
141
+ return calculateStyleProperty(element, styleConfigs.margin);
142
+ };
143
+ const calculateColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
144
+ "color",
145
+ element,
146
+ componentName,
147
+ canUseNewInspector,
148
+ styleConfigs
149
+ );
150
+ const calculateBackgroundColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
151
+ "backgroundColor",
152
+ element,
153
+ componentName,
154
+ canUseNewInspector,
155
+ styleConfigs
156
+ );
157
+ const calculateBorderColorInfo = (element, componentName, canUseNewInspector, styleConfigs) => calculateStyle(
158
+ "borderColor",
159
+ element,
160
+ componentName,
161
+ canUseNewInspector,
162
+ styleConfigs
163
+ );
164
+ export {
165
+ calculateBackgroundColorInfo,
166
+ calculateBorderColorInfo,
167
+ calculateBorderRadiusInfo,
168
+ calculateBorderWidthInfo,
169
+ calculateColorInfo,
170
+ calculateFontSizeInfo,
171
+ calculateFontWeightInfo,
172
+ calculateMarginInfo,
173
+ calculatePaddingInfo,
174
+ calculateStyle,
175
+ calculateTextAlignInfo,
176
+ rgbaToHex
177
+ };
@@ -1,46 +1,56 @@
1
- "use client";
2
1
  "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- function _export(target, all) {
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
7
10
  for (var name in all)
8
- Object.defineProperty(target, name, {
9
- enumerable: true,
10
- get: all[name]
11
- });
12
- }
13
- _export(exports, {
14
- defaultHotkeys: function() {
15
- return defaultHotkeys;
16
- },
17
- Inspector: function() {
18
- return Inspector;
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
18
  }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var Inspector_exports = {};
31
+ __export(Inspector_exports, {
32
+ Inspector: () => Inspector,
33
+ defaultHotkeys: () => defaultHotkeys
20
34
  });
21
- const _jsxruntime = require("react/jsx-runtime");
22
- const _react = require("react");
23
- const _hotkeysjs = /* @__PURE__ */ _interop_require_default(require("hotkeys-js"));
24
- const _hooks = require("./hooks");
25
- const _Overlay = require("./Overlay");
26
- const _utils = require("./utils");
27
- const _fiber = require("./utils/fiber");
28
- function _interop_require_default(obj) {
29
- return obj && obj.__esModule ? obj : {
30
- default: obj
31
- };
32
- }
35
+ module.exports = __toCommonJS(Inspector_exports);
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var import_react = require("react");
38
+ var import_hotkeys_js = __toESM(require("hotkeys-js"));
39
+ var import_hooks = require("./hooks");
40
+ var import_Overlay = require("./Overlay");
41
+ var import_utils = require("./utils");
42
+ var import_fiber = require("./utils/fiber");
33
43
  const getParentElement = (element) => {
34
44
  let parent = element;
35
45
  while (parent && parent.tagName !== "HTML") {
36
46
  if (parent.dataset.miaodaComponentName) {
37
47
  return parent;
38
48
  }
39
- const fiber = (0, _fiber.getElementFiberUpward)(parent);
40
- const parentFiber = parent.parentElement ? (0, _fiber.getElementFiberUpward)(parent.parentElement) : void 0;
41
- const referenceFiber = (0, _utils.getReferenceFiber)(fiber);
42
- const parentReferenceFiber = parentFiber ? (0, _utils.getReferenceFiber)(parentFiber) : null;
43
- const currentName = referenceFiber === null || referenceFiber === void 0 ? void 0 : referenceFiber.pendingProps["data-miaoda-component-name"];
49
+ const fiber = (0, import_fiber.getElementFiberUpward)(parent);
50
+ const parentFiber = parent.parentElement ? (0, import_fiber.getElementFiberUpward)(parent.parentElement) : void 0;
51
+ const referenceFiber = (0, import_utils.getReferenceFiber)(fiber);
52
+ const parentReferenceFiber = parentFiber ? (0, import_utils.getReferenceFiber)(parentFiber) : null;
53
+ const currentName = referenceFiber == null ? void 0 : referenceFiber.pendingProps["data-miaoda-component-name"];
44
54
  const parentName = parentReferenceFiber ? parentReferenceFiber.pendingProps["data-miaoda-component-name"] : null;
45
55
  if (currentName && currentName !== parentName) {
46
56
  return parent;
@@ -50,75 +60,69 @@ const getParentElement = (element) => {
50
60
  return;
51
61
  };
52
62
  const defaultHotkeys = () => {
53
- var _navigator_platform;
54
- return ((_navigator_platform = navigator.platform) === null || _navigator_platform === void 0 ? void 0 : _navigator_platform.startsWith("Mac")) ? [
55
- "Ctrl",
56
- "Shift",
57
- "Command",
58
- "C"
59
- ] : [
60
- "Ctrl",
61
- "Shift",
62
- "Alt",
63
- "C"
64
- ];
63
+ var _a;
64
+ return ((_a = navigator.platform) == null ? void 0 : _a.startsWith("Mac")) ? ["Ctrl", "Shift", "Command", "C"] : ["Ctrl", "Shift", "Alt", "C"];
65
65
  };
66
66
  const Inspector = (props) => {
67
- const { keys, onHoverElement, onClickElement, onInspectElement, active: controlledActive, onActiveChange, handleCodeInfo, disable = true, children } = props;
68
- const [isActive, setActive] = (0, _react.useState)(controlledActive !== null && controlledActive !== void 0 ? controlledActive : false);
69
- const hotkey = keys === null ? null : (keys !== null && keys !== void 0 ? keys : []).join("+");
70
- const overlayRef = (0, _react.useRef)();
71
- const mouseRef = (0, _hooks.useMousePosition)({
72
- disable
73
- });
74
- (0, _hooks.useLayoutEffect)(() => {
67
+ const {
68
+ keys,
69
+ onHoverElement,
70
+ onClickElement,
71
+ onInspectElement,
72
+ active: controlledActive,
73
+ onActiveChange,
74
+ handleCodeInfo,
75
+ disable = true,
76
+ children
77
+ } = props;
78
+ const [isActive, setActive] = (0, import_react.useState)(controlledActive != null ? controlledActive : false);
79
+ const hotkey = keys === null ? null : (keys != null ? keys : []).join("+");
80
+ const overlayRef = (0, import_react.useRef)();
81
+ const mouseRef = (0, import_hooks.useMousePosition)({ disable });
82
+ (0, import_hooks.useLayoutEffect)(() => {
75
83
  if (controlledActive !== void 0) {
76
84
  setActive(controlledActive);
77
85
  }
78
- }, [
79
- controlledActive
80
- ]);
81
- const activate = (0, _hooks.useEffectEvent)(() => {
82
- onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(true);
86
+ }, [controlledActive]);
87
+ const activate = (0, import_hooks.useEffectEvent)(() => {
88
+ onActiveChange == null ? void 0 : onActiveChange(true);
83
89
  if (controlledActive === void 0) {
84
90
  setActive(true);
85
91
  }
86
92
  });
87
- const deactivate = (0, _hooks.useEffectEvent)(() => {
88
- onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(false);
93
+ const deactivate = (0, import_hooks.useEffectEvent)(() => {
94
+ onActiveChange == null ? void 0 : onActiveChange(false);
89
95
  if (controlledActive === void 0) {
90
96
  setActive(false);
91
97
  }
92
98
  });
93
- const handleHoverElement = (0, _hooks.useEffectEvent)((element) => {
94
- var _overlay_inspect;
99
+ const handleHoverElement = (0, import_hooks.useEffectEvent)((element) => {
100
+ var _a;
95
101
  const overlay = overlayRef.current;
96
102
  const targetElement = getParentElement(element);
97
103
  if (!targetElement) {
98
104
  return;
99
105
  }
100
- const codeInfo = (0, _utils.getElementCodeInfo)(targetElement);
101
- const relativePath = codeInfo === null || codeInfo === void 0 ? void 0 : codeInfo.relativePath;
102
- const absolutePath = codeInfo === null || codeInfo === void 0 ? void 0 : codeInfo.absolutePath;
103
- const { fiber, name, title } = (0, _utils.getElementInspect)(targetElement);
104
- overlay === null || overlay === void 0 ? void 0 : (_overlay_inspect = overlay.inspect) === null || _overlay_inspect === void 0 ? void 0 : _overlay_inspect.call(overlay, [
105
- targetElement
106
- ], title, relativePath !== null && relativePath !== void 0 ? relativePath : absolutePath);
107
- onHoverElement === null || onHoverElement === void 0 ? void 0 : onHoverElement({
106
+ const codeInfo = (0, import_utils.getElementCodeInfo)(targetElement);
107
+ const relativePath = codeInfo == null ? void 0 : codeInfo.relativePath;
108
+ const absolutePath = codeInfo == null ? void 0 : codeInfo.absolutePath;
109
+ const { fiber, name, title } = (0, import_utils.getElementInspect)(targetElement);
110
+ (_a = overlay == null ? void 0 : overlay.inspect) == null ? void 0 : _a.call(overlay, [targetElement], title, relativePath != null ? relativePath : absolutePath);
111
+ onHoverElement == null ? void 0 : onHoverElement({
108
112
  element: targetElement,
109
113
  fiber,
110
114
  codeInfo,
111
115
  name
112
116
  });
113
117
  });
114
- const handleClickElement = (0, _hooks.useEffectEvent)((element) => {
118
+ const handleClickElement = (0, import_hooks.useEffectEvent)((element) => {
115
119
  const targetElement = getParentElement(element);
116
120
  if (!targetElement) {
117
121
  return;
118
122
  }
119
- const codeInfo = (0, _utils.getElementCodeInfo)(targetElement);
120
- const { fiber, name, title } = (0, _utils.getElementInspect)(targetElement);
121
- onClickElement === null || onClickElement === void 0 ? void 0 : onClickElement({
123
+ const codeInfo = (0, import_utils.getElementCodeInfo)(targetElement);
124
+ const { fiber, name, title } = (0, import_utils.getElementInspect)(targetElement);
125
+ onClickElement == null ? void 0 : onClickElement({
122
126
  element: targetElement,
123
127
  fiber,
124
128
  codeInfo,
@@ -126,7 +130,7 @@ const Inspector = (props) => {
126
130
  title
127
131
  });
128
132
  if (fiber && codeInfo) {
129
- onInspectElement === null || onInspectElement === void 0 ? void 0 : onInspectElement({
133
+ onInspectElement == null ? void 0 : onInspectElement({
130
134
  element: targetElement,
131
135
  fiber,
132
136
  codeInfo,
@@ -135,49 +139,45 @@ const Inspector = (props) => {
135
139
  });
136
140
  }
137
141
  });
138
- const startInspect = (0, _hooks.useEffectEvent)(() => {
139
- if (overlayRef.current || disable)
140
- return;
141
- const overlay = new _Overlay.Overlay(handleCodeInfo);
142
+ const startInspect = (0, import_hooks.useEffectEvent)(() => {
143
+ if (overlayRef.current || disable) return;
144
+ const overlay = new import_Overlay.Overlay(handleCodeInfo);
142
145
  overlayRef.current = overlay;
143
- (0, _hotkeysjs.default)(`esc`, deactivate);
144
- const stopCallback = (0, _utils.setupHighlighter)({
146
+ (0, import_hotkeys_js.default)(`esc`, deactivate);
147
+ const stopCallback = (0, import_utils.setupHighlighter)({
145
148
  onPointerOver: handleHoverElement,
146
149
  onClick: handleClickElement
147
150
  });
148
151
  overlay.setRemoveCallback(stopCallback);
149
152
  const initPoint = mouseRef.current;
150
153
  const initElement = document.elementFromPoint(initPoint.x, initPoint.y);
151
- if (initElement)
152
- handleHoverElement(initElement);
154
+ if (initElement) handleHoverElement(initElement);
153
155
  });
154
- const stopInspect = (0, _hooks.useEffectEvent)(() => {
155
- var _overlayRef_current;
156
- (_overlayRef_current = overlayRef.current) === null || _overlayRef_current === void 0 ? void 0 : _overlayRef_current.remove();
156
+ const stopInspect = (0, import_hooks.useEffectEvent)(() => {
157
+ var _a;
158
+ (_a = overlayRef.current) == null ? void 0 : _a.remove();
157
159
  overlayRef.current = void 0;
158
- _hotkeysjs.default.unbind(`esc`, deactivate);
160
+ import_hotkeys_js.default.unbind(`esc`, deactivate);
159
161
  });
160
- (0, _react.useEffect)(() => {
162
+ (0, import_react.useEffect)(() => {
161
163
  if (isActive) {
162
164
  startInspect();
163
165
  } else {
164
166
  stopInspect();
165
167
  }
166
168
  return stopInspect;
167
- }, [
168
- isActive
169
- ]);
170
- (0, _react.useEffect)(() => {
169
+ }, [isActive]);
170
+ (0, import_react.useEffect)(() => {
171
171
  const handleScroll = () => {
172
- var _overlayRef_current;
173
- (_overlayRef_current = overlayRef.current) === null || _overlayRef_current === void 0 ? void 0 : _overlayRef_current.clearRect();
172
+ var _a;
173
+ (_a = overlayRef.current) == null ? void 0 : _a.clearRect();
174
174
  };
175
175
  window.addEventListener("scroll", handleScroll, true);
176
176
  return () => {
177
177
  window.removeEventListener("scroll", handleScroll, true);
178
178
  };
179
179
  }, []);
180
- (0, _react.useEffect)(() => {
180
+ (0, import_react.useEffect)(() => {
181
181
  const handleHotKeys = () => {
182
182
  if (overlayRef.current) {
183
183
  deactivate();
@@ -187,17 +187,12 @@ const Inspector = (props) => {
187
187
  };
188
188
  const bindKey = hotkey === null || disable ? null : hotkey || defaultHotkeys().join("+");
189
189
  if (bindKey) {
190
- (0, _hotkeysjs.default)(bindKey, handleHotKeys);
190
+ (0, import_hotkeys_js.default)(bindKey, handleHotKeys);
191
191
  return () => {
192
- _hotkeysjs.default.unbind(bindKey, handleHotKeys);
192
+ import_hotkeys_js.default.unbind(bindKey, handleHotKeys);
193
193
  };
194
194
  }
195
195
  return;
196
- }, [
197
- hotkey,
198
- disable
199
- ]);
200
- return /* @__PURE__ */ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
201
- children: children !== null && children !== void 0 ? children : null
202
- });
196
+ }, [hotkey, disable]);
197
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: children != null ? children : null });
203
198
  };