@lark-apaas/miaoda-inspector 0.1.0-alpha.1

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 (74) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +1 -0
  3. package/dist/es/Inspector/Inspector.js +179 -0
  4. package/dist/es/Inspector/Overlay.js +400 -0
  5. package/dist/es/Inspector/hooks/index.js +3 -0
  6. package/dist/es/Inspector/hooks/use-effect-event.js +15 -0
  7. package/dist/es/Inspector/hooks/use-layout-effect.js +3 -0
  8. package/dist/es/Inspector/hooks/use-mouse.js +22 -0
  9. package/dist/es/Inspector/index.js +1 -0
  10. package/dist/es/Inspector/utils/fiber.js +61 -0
  11. package/dist/es/Inspector/utils/highlight.js +74 -0
  12. package/dist/es/Inspector/utils/index.js +3 -0
  13. package/dist/es/Inspector/utils/inspect.js +119 -0
  14. package/dist/es/Inspector/utils/overlay.js +20 -0
  15. package/dist/es/MiaodaInspector/MiaodaInspector.css +46 -0
  16. package/dist/es/MiaodaInspector/MiaodaInspector.js +397 -0
  17. package/dist/es/MiaodaInspector/index.js +1 -0
  18. package/dist/es/config/ui-config.js +787 -0
  19. package/dist/es/index.js +2 -0
  20. package/dist/es/types/iframe-events.js +1 -0
  21. package/dist/es/types/index.js +1 -0
  22. package/dist/es/utils/config-mapper.js +163 -0
  23. package/dist/es/utils/css.js +5 -0
  24. package/dist/es/utils/index.js +3 -0
  25. package/dist/es/utils/origin.js +19 -0
  26. package/dist/es/utils/style-calculator.js +158 -0
  27. package/dist/lib/Inspector/Inspector.js +203 -0
  28. package/dist/lib/Inspector/Overlay.js +419 -0
  29. package/dist/lib/Inspector/hooks/index.js +20 -0
  30. package/dist/lib/Inspector/hooks/use-effect-event.js +25 -0
  31. package/dist/lib/Inspector/hooks/use-layout-effect.js +13 -0
  32. package/dist/lib/Inspector/hooks/use-mouse.js +32 -0
  33. package/dist/lib/Inspector/index.js +11 -0
  34. package/dist/lib/Inspector/utils/fiber.js +95 -0
  35. package/dist/lib/Inspector/utils/highlight.js +84 -0
  36. package/dist/lib/Inspector/utils/index.js +20 -0
  37. package/dist/lib/Inspector/utils/inspect.js +153 -0
  38. package/dist/lib/Inspector/utils/overlay.js +39 -0
  39. package/dist/lib/MiaodaInspector/MiaodaInspector.css +46 -0
  40. package/dist/lib/MiaodaInspector/MiaodaInspector.js +447 -0
  41. package/dist/lib/MiaodaInspector/index.js +11 -0
  42. package/dist/lib/config/ui-config.js +797 -0
  43. package/dist/lib/index.js +21 -0
  44. package/dist/lib/types/iframe-events.js +4 -0
  45. package/dist/lib/types/index.js +47 -0
  46. package/dist/lib/utils/config-mapper.js +182 -0
  47. package/dist/lib/utils/css.js +20 -0
  48. package/dist/lib/utils/index.js +61 -0
  49. package/dist/lib/utils/origin.js +44 -0
  50. package/dist/lib/utils/style-calculator.js +207 -0
  51. package/dist/types/Inspector/Inspector.d.ts +102 -0
  52. package/dist/types/Inspector/Overlay.d.ts +71 -0
  53. package/dist/types/Inspector/hooks/index.d.ts +3 -0
  54. package/dist/types/Inspector/hooks/use-effect-event.d.ts +9 -0
  55. package/dist/types/Inspector/hooks/use-layout-effect.d.ts +2 -0
  56. package/dist/types/Inspector/hooks/use-mouse.d.ts +9 -0
  57. package/dist/types/Inspector/index.d.ts +1 -0
  58. package/dist/types/Inspector/utils/fiber.d.ts +34 -0
  59. package/dist/types/Inspector/utils/highlight.d.ts +8 -0
  60. package/dist/types/Inspector/utils/index.d.ts +3 -0
  61. package/dist/types/Inspector/utils/inspect.d.ts +110 -0
  62. package/dist/types/Inspector/utils/overlay.d.ts +30 -0
  63. package/dist/types/MiaodaInspector/MiaodaInspector.d.ts +47 -0
  64. package/dist/types/MiaodaInspector/index.d.ts +1 -0
  65. package/dist/types/config/ui-config.d.ts +49 -0
  66. package/dist/types/index.d.ts +4 -0
  67. package/dist/types/types/iframe-events.d.ts +155 -0
  68. package/dist/types/types/index.d.ts +1 -0
  69. package/dist/types/utils/config-mapper.d.ts +12 -0
  70. package/dist/types/utils/css.d.ts +2 -0
  71. package/dist/types/utils/index.d.ts +3 -0
  72. package/dist/types/utils/origin.d.ts +9 -0
  73. package/dist/types/utils/style-calculator.d.ts +19 -0
  74. package/package.json +48 -0
@@ -0,0 +1,447 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "MiaodaInspector", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return MiaodaInspector;
9
+ }
10
+ });
11
+ const _jsxruntime = require("react/jsx-runtime");
12
+ const _react = /* @__PURE__ */ _interop_require_wildcard(require("react"));
13
+ const _Inspector = require("../Inspector");
14
+ const _Overlay = require("../Inspector/Overlay");
15
+ const _utils = require("../utils");
16
+ require("./MiaodaInspector.css");
17
+ const _configmapper = require("../utils/config-mapper");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _getRequireWildcardCache(nodeInterop) {
32
+ if (typeof WeakMap !== "function")
33
+ return null;
34
+ var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
35
+ var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
36
+ return (_getRequireWildcardCache = function(nodeInterop2) {
37
+ return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
38
+ })(nodeInterop);
39
+ }
40
+ function _interop_require_wildcard(obj, nodeInterop) {
41
+ if (!nodeInterop && obj && obj.__esModule) {
42
+ return obj;
43
+ }
44
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
45
+ return {
46
+ default: obj
47
+ };
48
+ }
49
+ var cache = _getRequireWildcardCache(nodeInterop);
50
+ if (cache && cache.has(obj)) {
51
+ return cache.get(obj);
52
+ }
53
+ var newObj = {};
54
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
55
+ for (var key in obj) {
56
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
57
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
58
+ if (desc && (desc.get || desc.set)) {
59
+ Object.defineProperty(newObj, key, desc);
60
+ } else {
61
+ newObj[key] = obj[key];
62
+ }
63
+ }
64
+ }
65
+ newObj.default = obj;
66
+ if (cache) {
67
+ cache.set(obj, newObj);
68
+ }
69
+ return newObj;
70
+ }
71
+ function _object_spread(target) {
72
+ for (var i = 1; i < arguments.length; i++) {
73
+ var source = arguments[i] != null ? arguments[i] : {};
74
+ var ownKeys2 = Object.keys(source);
75
+ if (typeof Object.getOwnPropertySymbols === "function") {
76
+ ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
77
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
78
+ }));
79
+ }
80
+ ownKeys2.forEach(function(key) {
81
+ _define_property(target, key, source[key]);
82
+ });
83
+ }
84
+ return target;
85
+ }
86
+ function ownKeys(object, enumerableOnly) {
87
+ var keys = Object.keys(object);
88
+ if (Object.getOwnPropertySymbols) {
89
+ var symbols = Object.getOwnPropertySymbols(object);
90
+ if (enumerableOnly) {
91
+ symbols = symbols.filter(function(sym) {
92
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
93
+ });
94
+ }
95
+ keys.push.apply(keys, symbols);
96
+ }
97
+ return keys;
98
+ }
99
+ function _object_spread_props(target, source) {
100
+ source = source != null ? source : {};
101
+ if (Object.getOwnPropertyDescriptors) {
102
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
103
+ } else {
104
+ ownKeys(Object(source)).forEach(function(key) {
105
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
106
+ });
107
+ }
108
+ return target;
109
+ }
110
+ function safeClassName(el) {
111
+ const cn = el === null || el === void 0 ? void 0 : el.className;
112
+ if (typeof cn === "string") {
113
+ return cn;
114
+ }
115
+ if (typeof (cn === null || cn === void 0 ? void 0 : cn.baseVal) === "string") {
116
+ return cn.baseVal;
117
+ }
118
+ return "";
119
+ }
120
+ function analyzeTextOnlyNode(element, componentName, canUseNewInspector) {
121
+ if (!element || componentName && componentName[0] === componentName[0].toUpperCase() || !canUseNewInspector || element instanceof SVGElement) {
122
+ return {
123
+ hasOnlyTextNodes: false,
124
+ textContent: null
125
+ };
126
+ }
127
+ try {
128
+ const childNodes = Array.from(element.childNodes);
129
+ const textNodes = childNodes.filter((node) => node.nodeType === Node.TEXT_NODE);
130
+ const hasOnlyText = childNodes.length > 0 && textNodes.length === childNodes.length;
131
+ return {
132
+ hasOnlyTextNodes: hasOnlyText,
133
+ textContent: hasOnlyText ? element.textContent : null
134
+ };
135
+ } catch (e) {
136
+ console.error("Error analyzing text-only node:", e);
137
+ }
138
+ return {
139
+ hasOnlyTextNodes: false,
140
+ textContent: null
141
+ };
142
+ }
143
+ const getElementCoordinates = (element) => {
144
+ const boundingClientRect = element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
145
+ const computedStyle = element ? window.getComputedStyle(element) : null;
146
+ const marginLeft = computedStyle ? parseFloat(computedStyle.marginLeft) || 0 : 0;
147
+ const marginRight = computedStyle ? parseFloat(computedStyle.marginRight) || 0 : 0;
148
+ const marginTop = computedStyle ? parseFloat(computedStyle.marginTop) || 0 : 0;
149
+ const marginBottom = computedStyle ? parseFloat(computedStyle.marginBottom) || 0 : 0;
150
+ const totalWidth = boundingClientRect ? boundingClientRect.width + marginLeft + marginRight : 0;
151
+ const totalHeight = boundingClientRect ? boundingClientRect.height + marginTop + marginBottom : 0;
152
+ const adjustedTop = boundingClientRect ? boundingClientRect.top - marginTop : 0;
153
+ const adjustedLeft = boundingClientRect ? boundingClientRect.left - marginLeft : 0;
154
+ const adjustedRight = boundingClientRect ? boundingClientRect.right + marginRight : 0;
155
+ const adjustedBottom = boundingClientRect ? boundingClientRect.bottom + marginBottom : 0;
156
+ return {
157
+ width: totalWidth,
158
+ height: totalHeight,
159
+ top: adjustedTop,
160
+ left: adjustedLeft,
161
+ right: adjustedRight,
162
+ bottom: adjustedBottom
163
+ };
164
+ };
165
+ const selectedElementMap = /* @__PURE__ */ new Map();
166
+ function elementInfoToKey(relativePath, lineNumber, columnNumber) {
167
+ return `${relativePath}_${lineNumber}_${columnNumber}`;
168
+ }
169
+ const enableInner = (() => {
170
+ var _localStorage;
171
+ return ((_localStorage = localStorage) === null || _localStorage === void 0 ? void 0 : _localStorage.getItem("miaoda-inspector-inner")) === "true";
172
+ })();
173
+ function MiaodaInspector(props) {
174
+ const [_active, setActive] = (0, _react.useState)(false);
175
+ const [inBody, setInBody] = (0, _react.useState)(true);
176
+ const active = (_active || enableInner) && inBody;
177
+ const canUseNewInspector = (0, _react.useRef)(false);
178
+ const clickOverlayRef = (0, _react.useRef)(null);
179
+ const defaultUIConfig = props.theme.themeToken;
180
+ const styleConfigs = (0, _configmapper.getAllStyleConfigs)(defaultUIConfig);
181
+ const mouseleave = (0, _react.useCallback)(() => {
182
+ setInBody(false);
183
+ }, []);
184
+ const mouseenter = (0, _react.useCallback)(() => {
185
+ setInBody(true);
186
+ }, []);
187
+ const handleMessage = (0, _react.useCallback)((event) => {
188
+ const { data } = event;
189
+ if ((0, _utils.isIncomingMessage)(data, "InitConfig")) {
190
+ const { inspectorActive, userToken, appId, inspectorVersion } = data.data;
191
+ if (inspectorActive !== void 0) {
192
+ setActive(inspectorActive);
193
+ if (inspectorActive === false) {
194
+ var _clickOverlayRef_current;
195
+ (_clickOverlayRef_current = clickOverlayRef.current) === null || _clickOverlayRef_current === void 0 ? void 0 : _clickOverlayRef_current.remove();
196
+ clickOverlayRef.current = null;
197
+ }
198
+ }
199
+ if (userToken !== void 0) {
200
+ window.MIAODA_BUILTIN_TTT = userToken;
201
+ }
202
+ if (appId !== void 0) {
203
+ window.MIAODA_APP_ID = appId;
204
+ }
205
+ (0, _utils.postMessage)({
206
+ type: "InspectorUIConfig",
207
+ data: defaultUIConfig
208
+ });
209
+ if (inspectorVersion === "2") {
210
+ canUseNewInspector.current = true;
211
+ }
212
+ } else if ((0, _utils.isIncomingMessage)(data, "ClearSelected")) {
213
+ var _clickOverlayRef_current1;
214
+ const { keepModifications = false } = data.data;
215
+ (_clickOverlayRef_current1 = clickOverlayRef.current) === null || _clickOverlayRef_current1 === void 0 ? void 0 : _clickOverlayRef_current1.remove();
216
+ clickOverlayRef.current = null;
217
+ if (canUseNewInspector.current && !keepModifications) {
218
+ for (const [_, selectedElement] of selectedElementMap.entries()) {
219
+ if (selectedElement.element) {
220
+ if (selectedElement.originalState.textContent) {
221
+ selectedElement.element.textContent = selectedElement.originalState.textContent;
222
+ }
223
+ if (selectedElement.originalState.className && !(selectedElement.element instanceof SVGElement)) {
224
+ selectedElement.element.className = selectedElement.originalState.className;
225
+ }
226
+ }
227
+ if (selectedElement.dispose) {
228
+ selectedElement.dispose();
229
+ }
230
+ }
231
+ selectedElementMap.clear();
232
+ }
233
+ } else if ((0, _utils.isIncomingMessage)(data, "EditText")) {
234
+ const { elementId, textContent } = data.data;
235
+ const selectedElement = selectedElementMap.get(elementId);
236
+ if (selectedElement && selectedElement.element) {
237
+ selectedElement.element.textContent = textContent;
238
+ }
239
+ } else if ((0, _utils.isIncomingMessage)(data, "EditStyle")) {
240
+ const { elementId, styles } = data.data;
241
+ const selectedElement = selectedElementMap.get(elementId);
242
+ if (selectedElement && selectedElement.element) {
243
+ const { element } = selectedElement;
244
+ for (const [property] of Object.entries(styles)) {
245
+ if (!(property in selectedElement.originalState.styles)) {
246
+ selectedElement.originalState.styles[property] = element.style.getPropertyValue(property);
247
+ }
248
+ }
249
+ for (const [property, value] of Object.entries(styles)) {
250
+ element.style.setProperty(property, value);
251
+ }
252
+ const existingDispose = selectedElement.dispose;
253
+ const styleDispose = () => {
254
+ for (const [property, value] of Object.entries(selectedElement.originalState.styles)) {
255
+ if (value) {
256
+ element.style.setProperty(property, value);
257
+ } else {
258
+ element.style.removeProperty(property);
259
+ }
260
+ }
261
+ };
262
+ selectedElement.dispose = () => {
263
+ styleDispose();
264
+ if (existingDispose) {
265
+ existingDispose();
266
+ }
267
+ };
268
+ }
269
+ } else if ((0, _utils.isIncomingMessage)(data, "EditClassName")) {
270
+ const { elementId, className } = data.data;
271
+ const selectedElement = selectedElementMap.get(elementId);
272
+ if (selectedElement && selectedElement.element) {
273
+ const { element } = selectedElement;
274
+ if (selectedElement.originalState.className === void 0) {
275
+ selectedElement.originalState.className = safeClassName(element);
276
+ }
277
+ element.className = (0, _utils.cx)(element.className, className);
278
+ const existingDispose = selectedElement.dispose;
279
+ const classDispose = () => {
280
+ if (selectedElement.originalState.className) {
281
+ element.className = selectedElement.originalState.className;
282
+ }
283
+ };
284
+ selectedElement.dispose = () => {
285
+ classDispose();
286
+ if (existingDispose) {
287
+ existingDispose();
288
+ }
289
+ };
290
+ }
291
+ }
292
+ }, [
293
+ defaultUIConfig
294
+ ]);
295
+ (0, _react.useEffect)(() => {
296
+ document.body.addEventListener("mouseleave", mouseleave, false);
297
+ document.body.addEventListener("mouseenter", mouseenter, false);
298
+ const handleScroll = () => {
299
+ var _clickOverlayRef_current;
300
+ (_clickOverlayRef_current = clickOverlayRef.current) === null || _clickOverlayRef_current === void 0 ? void 0 : _clickOverlayRef_current.remove();
301
+ clickOverlayRef.current = null;
302
+ (0, _utils.postMessage)({
303
+ type: "PageScroll",
304
+ data: {}
305
+ });
306
+ };
307
+ window.addEventListener("scroll", handleScroll, true);
308
+ return () => {
309
+ document.body.removeEventListener("mouseleave", mouseleave, false);
310
+ document.body.removeEventListener("mouseenter", mouseenter, false);
311
+ window.removeEventListener("scroll", handleScroll, true);
312
+ };
313
+ }, []);
314
+ (0, _react.useEffect)(() => {
315
+ window.addEventListener("message", handleMessage);
316
+ return () => {
317
+ window.removeEventListener("message", handleMessage);
318
+ };
319
+ }, []);
320
+ (0, _react.useEffect)(() => {
321
+ (0, _utils.postMessage)({
322
+ type: "PageMounted",
323
+ data: {
324
+ version: "0.1.0",
325
+ theme: props.theme
326
+ }
327
+ });
328
+ }, []);
329
+ const selectInspectorElement = (0, _react.useCallback)((params) => {
330
+ var _clickOverlayRef_current;
331
+ const { codeInfo, element, name, title } = params;
332
+ const coords = getElementCoordinates(element);
333
+ const textInfo = analyzeTextOnlyNode(element, name, canUseNewInspector.current);
334
+ const fontSizeInfo = (0, _utils.calculateFontSizeInfo)(element, name, canUseNewInspector.current, styleConfigs);
335
+ const fontWeightInfo = (0, _utils.calculateFontWeightInfo)(element, name, canUseNewInspector.current, styleConfigs);
336
+ const borderRadiusInfo = (0, _utils.calculateBorderRadiusInfo)(element, name, canUseNewInspector.current, styleConfigs);
337
+ const borderWidthInfo = (0, _utils.calculateBorderWidthInfo)(element, name, canUseNewInspector.current, styleConfigs);
338
+ const textAlignInfo = (0, _utils.calculateTextAlignInfo)(element, name, canUseNewInspector.current, styleConfigs);
339
+ const paddingInfo = (0, _utils.calculatePaddingInfo)(element, name, canUseNewInspector.current, styleConfigs);
340
+ const marginInfo = (0, _utils.calculateMarginInfo)(element, name, canUseNewInspector.current, styleConfigs);
341
+ const colorInfo = (0, _utils.calculateColorInfo)(element, name, canUseNewInspector.current, styleConfigs);
342
+ const backgroundColorInfo = (0, _utils.calculateBackgroundColorInfo)(element, name, canUseNewInspector.current, styleConfigs);
343
+ const borderColorInfo = (0, _utils.calculateBorderColorInfo)(element, name, canUseNewInspector.current, styleConfigs);
344
+ const id = elementInfoToKey(codeInfo.relativePath, codeInfo.lineNumber, codeInfo.columnNumber);
345
+ const selectElement = selectedElementMap.has(id);
346
+ if (!selectElement) {
347
+ selectedElementMap.set(id, {
348
+ elementId: id,
349
+ element,
350
+ originalState: {
351
+ textContent: textInfo.textContent,
352
+ className: safeClassName(element),
353
+ styles: {}
354
+ }
355
+ });
356
+ }
357
+ if (textInfo.hasOnlyTextNodes && canUseNewInspector.current) {
358
+ element.setAttribute("contenteditable", "true");
359
+ element.focus();
360
+ const TextUpdate = () => {
361
+ (0, _utils.postMessage)({
362
+ type: "TextUpdate",
363
+ data: {
364
+ elementId: id,
365
+ textContent: element.textContent
366
+ }
367
+ });
368
+ };
369
+ const dispose = () => {
370
+ element.removeAttribute("contenteditable");
371
+ element.removeEventListener("input", TextUpdate);
372
+ };
373
+ element.addEventListener("input", TextUpdate);
374
+ const _selectElement = selectedElementMap.get(id);
375
+ if (_selectElement) {
376
+ selectedElementMap.set(id, _object_spread_props(_object_spread({}, _selectElement), {
377
+ dispose
378
+ }));
379
+ }
380
+ }
381
+ var _element_id;
382
+ (0, _utils.postMessage)({
383
+ type: "SelectInspectorElement",
384
+ data: _object_spread_props(_object_spread({}, codeInfo), {
385
+ // 移除打头的 /
386
+ relativePath: codeInfo.relativePath,
387
+ tagName: element === null || element === void 0 ? void 0 : element.tagName,
388
+ componentName: name,
389
+ className: safeClassName(element),
390
+ id: (_element_id = element === null || element === void 0 ? void 0 : element.id) !== null && _element_id !== void 0 ? _element_id : "",
391
+ x: coords.left,
392
+ y: coords.top,
393
+ width: coords.width,
394
+ height: coords.height,
395
+ top: coords.top,
396
+ right: coords.right,
397
+ bottom: coords.bottom,
398
+ left: coords.left,
399
+ elementId: id,
400
+ textContent: textInfo.hasOnlyTextNodes ? textInfo.textContent : null,
401
+ fontSize: fontSizeInfo,
402
+ fontWeight: fontWeightInfo,
403
+ borderRadius: borderRadiusInfo,
404
+ borderWidth: borderWidthInfo,
405
+ textAlign: textAlignInfo,
406
+ padding: paddingInfo,
407
+ margin: marginInfo,
408
+ color: colorInfo,
409
+ backgroundColor: backgroundColorInfo,
410
+ borderColor: borderColorInfo,
411
+ metadata: codeInfo.metadata
412
+ })
413
+ });
414
+ (_clickOverlayRef_current = clickOverlayRef.current) === null || _clickOverlayRef_current === void 0 ? void 0 : _clickOverlayRef_current.remove();
415
+ clickOverlayRef.current = null;
416
+ const clickOverlay = new _Overlay.ClickOverlay(() => {
417
+ const _coords = getElementCoordinates(element);
418
+ (0, _utils.postMessage)({
419
+ type: "ElementResize",
420
+ data: _object_spread({
421
+ elementId: id
422
+ }, _coords)
423
+ });
424
+ });
425
+ clickOverlayRef.current = clickOverlay;
426
+ clickOverlay.highlight(element, title);
427
+ }, []);
428
+ const handleCodeInfo = (0, _react.useCallback)((name, info) => {
429
+ const relativePath = (info === null || info === void 0 ? void 0 : info.startsWith(props.cwd)) ? info.replace(props.cwd, "") : info;
430
+ var _relativePath_replace;
431
+ return [
432
+ name,
433
+ (_relativePath_replace = relativePath === null || relativePath === void 0 ? void 0 : relativePath.replace(/^\//, "")) !== null && _relativePath_replace !== void 0 ? _relativePath_replace : ""
434
+ ];
435
+ }, [
436
+ props.cwd
437
+ ]);
438
+ return /* @__PURE__ */ (0, _jsxruntime.jsx)(_Inspector.Inspector, {
439
+ disable: false,
440
+ active,
441
+ onClickElement: selectInspectorElement,
442
+ handleCodeInfo,
443
+ onActiveChange: (newActive) => {
444
+ setActive(newActive);
445
+ }
446
+ });
447
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "MiaodaInspector", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _MiaodaInspector.MiaodaInspector;
9
+ }
10
+ });
11
+ const _MiaodaInspector = require("./MiaodaInspector");