@lark-apaas/miaoda-inspector 0.1.0-alpha.5 → 0.1.0-alpha.7

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 (37) hide show
  1. package/dist/es/Inspector/Inspector.mjs +4 -22
  2. package/dist/es/Inspector/Overlay.mjs +58 -32
  3. package/dist/es/Inspector/utils/inspect.mjs +80 -1
  4. package/dist/es/MiaodaInspector/MiaodaInspector.mjs +332 -173
  5. package/dist/es/config/ui-config.mjs +138 -136
  6. package/dist/es/index.mjs +2 -0
  7. package/dist/es/types/feature.mjs +0 -0
  8. package/dist/es/types/index.mjs +4 -0
  9. package/dist/es/utils/config-mapper.mjs +1 -3
  10. package/dist/es/utils/element-guards.mjs +36 -0
  11. package/dist/es/utils/index.mjs +1 -6
  12. package/dist/es/utils/style-calculator.mjs +17 -60
  13. package/dist/lib/Inspector/Inspector.js +4 -23
  14. package/dist/lib/Inspector/Overlay.js +57 -28
  15. package/dist/lib/Inspector/utils/inspect.js +90 -1
  16. package/dist/lib/MiaodaInspector/MiaodaInspector.js +337 -183
  17. package/dist/lib/config/ui-config.js +138 -136
  18. package/dist/lib/index.js +2 -0
  19. package/dist/lib/types/feature.js +16 -0
  20. package/dist/lib/types/index.js +3 -0
  21. package/dist/lib/utils/config-mapper.js +1 -3
  22. package/dist/lib/utils/element-guards.js +55 -0
  23. package/dist/lib/utils/style-calculator.js +17 -60
  24. package/dist/types/Inspector/Inspector.d.ts +8 -1
  25. package/dist/types/Inspector/Overlay.d.ts +9 -2
  26. package/dist/types/Inspector/utils/index.d.ts +1 -1
  27. package/dist/types/Inspector/utils/inspect.d.ts +8 -1
  28. package/dist/types/config/ui-config.d.ts +26 -3
  29. package/dist/types/global.d.d.ts +6 -0
  30. package/dist/types/index.d.ts +2 -1
  31. package/dist/types/types/feature.d.ts +6 -0
  32. package/dist/types/types/iframe-events.d.ts +44 -2
  33. package/dist/types/types/index.d.ts +2 -1
  34. package/dist/types/utils/element-guards.d.ts +7 -0
  35. package/dist/types/utils/index.d.ts +1 -0
  36. package/dist/types/utils/origin.d.ts +1 -0
  37. package/package.json +13 -12
@@ -6,6 +6,12 @@ import { jsx } from "react/jsx-runtime";
6
6
  import { useState, useRef, useCallback, useEffect } from "react";
7
7
  import { Inspector } from "../Inspector";
8
8
  import { ClickOverlay } from "../Inspector/Overlay";
9
+ import {
10
+ extractPropsFromFiber,
11
+ getElementCodeInfo,
12
+ getElementInspect,
13
+ getParentElement
14
+ } from "../Inspector/utils";
9
15
  import {
10
16
  cx,
11
17
  postMessage,
@@ -23,6 +29,7 @@ import {
23
29
  } from "../utils";
24
30
  import "./MiaodaInspector.css";
25
31
  import { getAllStyleConfigs } from "../utils/config-mapper";
32
+ import { isAntdText, isNativeElementName } from "../utils/element-guards";
26
33
  function safeClassName(el) {
27
34
  const cn = el == null ? void 0 : el.className;
28
35
  if (typeof cn === "string") {
@@ -34,7 +41,13 @@ function safeClassName(el) {
34
41
  return "";
35
42
  }
36
43
  function analyzeTextOnlyNode(element, componentName, canUseNewInspector) {
37
- if (!element || componentName && componentName[0] === componentName[0].toUpperCase() || !canUseNewInspector || element instanceof SVGElement) {
44
+ if (!element || !canUseNewInspector || element instanceof SVGElement) {
45
+ return {
46
+ hasOnlyTextNodes: false,
47
+ textContent: null
48
+ };
49
+ }
50
+ if (!isNativeElementName(componentName) && !isAntdText(element, componentName)) {
38
51
  return {
39
52
  hasOnlyTextNodes: false,
40
53
  textContent: null
@@ -42,9 +55,7 @@ function analyzeTextOnlyNode(element, componentName, canUseNewInspector) {
42
55
  }
43
56
  try {
44
57
  const childNodes = Array.from(element.childNodes);
45
- const textNodes = childNodes.filter(
46
- (node) => node.nodeType === Node.TEXT_NODE
47
- );
58
+ const textNodes = childNodes.filter((node) => node.nodeType === Node.TEXT_NODE);
48
59
  const hasOnlyText = childNodes.length > 0 && textNodes.length === childNodes.length;
49
60
  return {
50
61
  hasOnlyTextNodes: hasOnlyText,
@@ -80,6 +91,23 @@ const getElementCoordinates = (element) => {
80
91
  bottom: adjustedBottom
81
92
  };
82
93
  };
94
+ const extractImageInfo = (element) => {
95
+ if (!element) {
96
+ return void 0;
97
+ }
98
+ if (element instanceof HTMLImageElement) {
99
+ const url = element.currentSrc || element.src || element.getAttribute("src") || void 0;
100
+ return {
101
+ type: "img",
102
+ url,
103
+ attribute: "src",
104
+ alt: element.alt || void 0,
105
+ width: element.naturalWidth || void 0,
106
+ height: element.naturalHeight || void 0
107
+ };
108
+ }
109
+ return void 0;
110
+ };
83
111
  const selectedElementMap = /* @__PURE__ */ new Map();
84
112
  function elementInfoToKey(relativePath, lineNumber, columnNumber) {
85
113
  return `${relativePath}_${lineNumber}_${columnNumber}`;
@@ -101,6 +129,195 @@ function MiaodaInspector(props) {
101
129
  const mouseenter = useCallback(() => {
102
130
  setInBody(true);
103
131
  }, []);
132
+ const updateClickOverlay = useCallback((element, title, id) => {
133
+ var _a;
134
+ (_a = clickOverlayRef.current) == null ? void 0 : _a.remove();
135
+ clickOverlayRef.current = null;
136
+ const clickOverlay = new ClickOverlay({
137
+ positionUpdate: () => {
138
+ var _a2;
139
+ const el = ((_a2 = selectedElementMap.get(id)) == null ? void 0 : _a2.element) || element;
140
+ const _coords = getElementCoordinates(el);
141
+ postMessage({
142
+ type: "ElementResize",
143
+ data: __spreadValues({
144
+ elementId: id
145
+ }, _coords)
146
+ });
147
+ },
148
+ onElementRebind: (newEl) => {
149
+ const _selected = selectedElementMap.get(id);
150
+ if (_selected) {
151
+ _selected.element = newEl;
152
+ }
153
+ const _coords = getElementCoordinates(newEl);
154
+ postMessage({
155
+ type: "ElementResize",
156
+ data: __spreadValues({
157
+ elementId: id
158
+ }, _coords)
159
+ });
160
+ }
161
+ });
162
+ clickOverlayRef.current = clickOverlay;
163
+ clickOverlay.highlight(element, title, id);
164
+ }, []);
165
+ const selectInspectorElement = useCallback((params) => {
166
+ var _a, _b, _c, _d;
167
+ const { codeInfo, element, name, title, componentProps } = params;
168
+ const coords = getElementCoordinates(element);
169
+ const textInfo = analyzeTextOnlyNode(element, name, canUseNewInspector.current);
170
+ const fontSizeInfo = calculateFontSizeInfo(element, name, canUseNewInspector.current, styleConfigs);
171
+ const fontWeightInfo = calculateFontWeightInfo(element, name, canUseNewInspector.current, styleConfigs);
172
+ const borderRadiusInfo = calculateBorderRadiusInfo(
173
+ element,
174
+ name,
175
+ canUseNewInspector.current,
176
+ styleConfigs
177
+ );
178
+ const borderWidthInfo = calculateBorderWidthInfo(element, name, canUseNewInspector.current, styleConfigs);
179
+ const textAlignInfo = calculateTextAlignInfo(element, name, canUseNewInspector.current, styleConfigs);
180
+ const paddingInfo = calculatePaddingInfo(element, name, canUseNewInspector.current, styleConfigs);
181
+ const marginInfo = calculateMarginInfo(element, name, canUseNewInspector.current, styleConfigs);
182
+ const colorInfo = calculateColorInfo(element, name, canUseNewInspector.current, styleConfigs);
183
+ const borderColorInfo = calculateBorderColorInfo(element, name, canUseNewInspector.current, styleConfigs);
184
+ const backgroundColorInfo = calculateBackgroundColorInfo(
185
+ element,
186
+ name,
187
+ canUseNewInspector.current,
188
+ styleConfigs
189
+ );
190
+ const imageInfo = extractImageInfo(element);
191
+ const dataMiaodaId = element.getAttribute("data-miaoda-id");
192
+ const id = dataMiaodaId || elementInfoToKey(codeInfo.relativePath, codeInfo.lineNumber, codeInfo.columnNumber);
193
+ const selectElement = selectedElementMap.has(id);
194
+ if (!selectElement) {
195
+ const originalState = {
196
+ textContent: textInfo.textContent,
197
+ styles: {},
198
+ attributes: {},
199
+ className: safeClassName(element)
200
+ };
201
+ if (element instanceof HTMLImageElement) {
202
+ originalState.attributes.src = (_b = (_a = element.getAttribute("src")) != null ? _a : element.currentSrc) != null ? _b : null;
203
+ }
204
+ selectedElementMap.set(id, {
205
+ elementId: id,
206
+ element,
207
+ title,
208
+ originalState
209
+ });
210
+ }
211
+ const importSourceAttr = element.getAttribute("data-miaoda-import-source");
212
+ const isAntdComponent = importSourceAttr === "antd" && window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__ && window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setProps;
213
+ const isNativeTagImage = (imageInfo == null ? void 0 : imageInfo.type) === "img" && !isAntdComponent;
214
+ const nativeTagComponentProps = isNativeTagImage ? {
215
+ src: {
216
+ url: (_c = imageInfo == null ? void 0 : imageInfo.url) != null ? _c : "",
217
+ source: "url",
218
+ meta: {
219
+ origin: "img",
220
+ width: imageInfo == null ? void 0 : imageInfo.width,
221
+ height: imageInfo == null ? void 0 : imageInfo.height
222
+ }
223
+ }
224
+ } : void 0;
225
+ const importSource = importSourceAttr != null ? importSourceAttr : isNativeTagImage ? "nativeTag" : void 0;
226
+ if (textInfo.hasOnlyTextNodes && canUseNewInspector.current) {
227
+ element.setAttribute("contenteditable", "true");
228
+ element.focus();
229
+ const TextUpdate = () => {
230
+ postMessage({
231
+ type: "TextUpdate",
232
+ data: {
233
+ elementId: id,
234
+ textContent: element.textContent
235
+ }
236
+ });
237
+ };
238
+ const dispose = () => {
239
+ element.removeAttribute("contenteditable");
240
+ element.removeEventListener("input", TextUpdate);
241
+ };
242
+ element.addEventListener("input", TextUpdate);
243
+ const _selectElement = selectedElementMap.get(id);
244
+ if (_selectElement) {
245
+ selectedElementMap.set(id, __spreadProps(__spreadValues({}, _selectElement), {
246
+ dispose
247
+ }));
248
+ }
249
+ }
250
+ postMessage({
251
+ type: "SelectInspectorElement",
252
+ data: __spreadProps(__spreadValues({}, codeInfo), {
253
+ // 移除打头的 /
254
+ relativePath: codeInfo.relativePath,
255
+ tagName: element == null ? void 0 : element.tagName,
256
+ componentName: name,
257
+ className: safeClassName(element),
258
+ id: (_d = element == null ? void 0 : element.id) != null ? _d : "",
259
+ x: coords.left,
260
+ y: coords.top,
261
+ width: coords.width,
262
+ height: coords.height,
263
+ top: coords.top,
264
+ right: coords.right,
265
+ bottom: coords.bottom,
266
+ left: coords.left,
267
+ elementId: id,
268
+ textContent: textInfo.hasOnlyTextNodes ? textInfo.textContent : null,
269
+ fontSize: fontSizeInfo,
270
+ fontWeight: fontWeightInfo,
271
+ borderRadius: borderRadiusInfo,
272
+ borderWidth: borderWidthInfo,
273
+ textAlign: textAlignInfo,
274
+ padding: paddingInfo,
275
+ margin: marginInfo,
276
+ color: colorInfo,
277
+ backgroundColor: backgroundColorInfo,
278
+ borderColor: borderColorInfo,
279
+ metadata: codeInfo.metadata,
280
+ importSource,
281
+ componentProps: isAntdComponent ? componentProps : nativeTagComponentProps
282
+ })
283
+ });
284
+ updateClickOverlay(element, title, id);
285
+ }, []);
286
+ const selectParent = useCallback(
287
+ (elementId) => {
288
+ const selectedElement = selectedElementMap.get(elementId);
289
+ if (!selectedElement || !selectedElement.element) {
290
+ return;
291
+ }
292
+ const htmlElementParent = selectedElement.element.parentElement;
293
+ if (!htmlElementParent) {
294
+ return;
295
+ }
296
+ const targetElement = getParentElement(htmlElementParent);
297
+ if (!targetElement) {
298
+ return;
299
+ }
300
+ const codeInfo = getElementCodeInfo(targetElement);
301
+ const { fiber, name, title } = getElementInspect(targetElement);
302
+ selectInspectorElement({
303
+ element: targetElement,
304
+ fiber,
305
+ codeInfo,
306
+ name,
307
+ title,
308
+ componentProps: extractPropsFromFiber(fiber)
309
+ });
310
+ },
311
+ [selectInspectorElement]
312
+ );
313
+ const handleCodeInfo = useCallback(
314
+ (name, info) => {
315
+ var _a;
316
+ const relativePath = (info == null ? void 0 : info.startsWith(props.cwd)) ? info.replace(props.cwd, "") : info;
317
+ return [name, (_a = relativePath == null ? void 0 : relativePath.replace(/^\//, "")) != null ? _a : ""];
318
+ },
319
+ [props.cwd]
320
+ );
104
321
  const handleMessage = useCallback(
105
322
  (event) => {
106
323
  var _a, _b;
@@ -168,9 +385,7 @@ function MiaodaInspector(props) {
168
385
  }
169
386
  const existingDispose = selectedElement.dispose;
170
387
  const styleDispose = () => {
171
- for (const [property, value] of Object.entries(
172
- selectedElement.originalState.styles
173
- )) {
388
+ for (const [property, value] of Object.entries(selectedElement.originalState.styles)) {
174
389
  if (value) {
175
390
  element.style.setProperty(property, value);
176
391
  } else {
@@ -207,9 +422,114 @@ function MiaodaInspector(props) {
207
422
  }
208
423
  };
209
424
  }
425
+ } else if (isIncomingMessage(data, "EditProps")) {
426
+ const { elementId, props: _props } = data.data;
427
+ const selectedElement = selectedElementMap.get(elementId);
428
+ if (selectedElement && selectedElement.element) {
429
+ const { element } = selectedElement;
430
+ if (window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__ && window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setProps) {
431
+ window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setProps(elementId, _props);
432
+ } else {
433
+ Object.entries(_props).forEach(([key, value]) => {
434
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
435
+ element.setAttribute(`data-${key}`, String(value));
436
+ }
437
+ });
438
+ }
439
+ const existingDispose = selectedElement.dispose;
440
+ const propsDispose = () => {
441
+ if (window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__) {
442
+ Object.keys(_props).forEach((key) => {
443
+ element.removeAttribute(`data-${key}`);
444
+ });
445
+ }
446
+ };
447
+ selectedElement.dispose = () => {
448
+ propsDispose();
449
+ if (existingDispose) {
450
+ existingDispose();
451
+ }
452
+ };
453
+ }
454
+ } else if (isIncomingMessage(data, "EditIconProps")) {
455
+ const { elementId, prop, value } = data.data;
456
+ const selectedElement = selectedElementMap.get(elementId);
457
+ if (selectedElement && selectedElement.element) {
458
+ if (window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__ && typeof window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setIconProps === "function") {
459
+ window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setIconProps(elementId, prop, value);
460
+ } else {
461
+ const { element } = selectedElement;
462
+ if (value) {
463
+ element.setAttribute(`data-${prop}`, String(value));
464
+ } else {
465
+ element.removeAttribute(`data-${prop}`);
466
+ }
467
+ }
468
+ const existingDispose = selectedElement.dispose;
469
+ const iconDispose = () => {
470
+ if (window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__ && typeof window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setIconProps === "function") {
471
+ window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setIconProps(elementId, prop, void 0);
472
+ } else if (selectedElement.element) {
473
+ selectedElement.element.removeAttribute(`data-${prop}`);
474
+ }
475
+ };
476
+ selectedElement.dispose = () => {
477
+ iconDispose();
478
+ if (existingDispose) {
479
+ existingDispose();
480
+ }
481
+ };
482
+ }
483
+ } else if (isIncomingMessage(data, "ReverseSelect")) {
484
+ const { elementId } = data.data;
485
+ const selectedElement = selectedElementMap.get(elementId);
486
+ if (selectedElement && selectedElement.element) {
487
+ updateClickOverlay(selectedElement.element, selectedElement.title, selectedElement.elementId);
488
+ }
489
+ } else if (isIncomingMessage(data, "SelectParent")) {
490
+ const { elementId } = data.data;
491
+ selectParent(elementId);
492
+ } else if (isIncomingMessage(data, "EditAttributes")) {
493
+ const { elementId, attributes } = data.data;
494
+ const selectedElement = selectedElementMap.get(elementId);
495
+ if (selectedElement && selectedElement.element) {
496
+ const { element, originalState } = selectedElement;
497
+ const recordedAttributes = originalState.attributes;
498
+ Object.entries(attributes).forEach(([attr, value]) => {
499
+ if (!(attr in recordedAttributes)) {
500
+ recordedAttributes[attr] = element.getAttribute(attr);
501
+ }
502
+ if (value === null || value === void 0 || value === "") {
503
+ element.removeAttribute(attr);
504
+ } else {
505
+ element.setAttribute(attr, value);
506
+ }
507
+ });
508
+ originalState.attributes = recordedAttributes;
509
+ const existingDispose = selectedElement.dispose;
510
+ const attributeDispose = () => {
511
+ if (!selectedElement.element) {
512
+ return;
513
+ }
514
+ Object.entries(selectedElement.originalState.attributes).forEach(([attr, value]) => {
515
+ var _a2, _b2;
516
+ if (value === null || value === void 0 || value === "") {
517
+ (_a2 = selectedElement.element) == null ? void 0 : _a2.removeAttribute(attr);
518
+ } else {
519
+ (_b2 = selectedElement.element) == null ? void 0 : _b2.setAttribute(attr, value);
520
+ }
521
+ });
522
+ };
523
+ selectedElement.dispose = () => {
524
+ attributeDispose();
525
+ if (existingDispose) {
526
+ existingDispose();
527
+ }
528
+ };
529
+ }
210
530
  }
211
531
  },
212
- [defaultUIConfig]
532
+ [updateClickOverlay, selectParent, defaultUIConfig]
213
533
  );
214
534
  useEffect(() => {
215
535
  document.body.addEventListener("mouseleave", mouseleave, false);
@@ -240,175 +560,14 @@ function MiaodaInspector(props) {
240
560
  postMessage({
241
561
  type: "PageMounted",
242
562
  data: {
243
- version: "0.1.0-alpha.5",
244
- theme: props.theme
245
- }
246
- });
247
- }, []);
248
- const selectInspectorElement = useCallback((params) => {
249
- var _a, _b;
250
- const { codeInfo, element, name, title } = params;
251
- const coords = getElementCoordinates(element);
252
- const textInfo = analyzeTextOnlyNode(
253
- element,
254
- name,
255
- canUseNewInspector.current
256
- );
257
- const fontSizeInfo = calculateFontSizeInfo(
258
- element,
259
- name,
260
- canUseNewInspector.current,
261
- styleConfigs
262
- );
263
- const fontWeightInfo = calculateFontWeightInfo(
264
- element,
265
- name,
266
- canUseNewInspector.current,
267
- styleConfigs
268
- );
269
- const borderRadiusInfo = calculateBorderRadiusInfo(
270
- element,
271
- name,
272
- canUseNewInspector.current,
273
- styleConfigs
274
- );
275
- const borderWidthInfo = calculateBorderWidthInfo(
276
- element,
277
- name,
278
- canUseNewInspector.current,
279
- styleConfigs
280
- );
281
- const textAlignInfo = calculateTextAlignInfo(
282
- element,
283
- name,
284
- canUseNewInspector.current,
285
- styleConfigs
286
- );
287
- const paddingInfo = calculatePaddingInfo(
288
- element,
289
- name,
290
- canUseNewInspector.current,
291
- styleConfigs
292
- );
293
- const marginInfo = calculateMarginInfo(
294
- element,
295
- name,
296
- canUseNewInspector.current,
297
- styleConfigs
298
- );
299
- const colorInfo = calculateColorInfo(
300
- element,
301
- name,
302
- canUseNewInspector.current,
303
- styleConfigs
304
- );
305
- const backgroundColorInfo = calculateBackgroundColorInfo(
306
- element,
307
- name,
308
- canUseNewInspector.current,
309
- styleConfigs
310
- );
311
- const borderColorInfo = calculateBorderColorInfo(
312
- element,
313
- name,
314
- canUseNewInspector.current,
315
- styleConfigs
316
- );
317
- const id = elementInfoToKey(
318
- codeInfo.relativePath,
319
- codeInfo.lineNumber,
320
- codeInfo.columnNumber
321
- );
322
- const selectElement = selectedElementMap.has(id);
323
- if (!selectElement) {
324
- selectedElementMap.set(id, {
325
- elementId: id,
326
- element,
327
- originalState: {
328
- textContent: textInfo.textContent,
329
- className: safeClassName(element),
330
- styles: {}
563
+ version: "0.1.0-alpha.7",
564
+ feature: {
565
+ selectParent: true,
566
+ reverseSelect: true
331
567
  }
332
- });
333
- }
334
- if (textInfo.hasOnlyTextNodes && canUseNewInspector.current) {
335
- element.setAttribute("contenteditable", "true");
336
- element.focus();
337
- const TextUpdate = () => {
338
- postMessage({
339
- type: "TextUpdate",
340
- data: {
341
- elementId: id,
342
- textContent: element.textContent
343
- }
344
- });
345
- };
346
- const dispose = () => {
347
- element.removeAttribute("contenteditable");
348
- element.removeEventListener("input", TextUpdate);
349
- };
350
- element.addEventListener("input", TextUpdate);
351
- const _selectElement = selectedElementMap.get(id);
352
- if (_selectElement) {
353
- selectedElementMap.set(id, __spreadProps(__spreadValues({}, _selectElement), {
354
- dispose
355
- }));
356
568
  }
357
- }
358
- postMessage({
359
- type: "SelectInspectorElement",
360
- data: __spreadProps(__spreadValues({}, codeInfo), {
361
- // 移除打头的 /
362
- relativePath: codeInfo.relativePath,
363
- tagName: element == null ? void 0 : element.tagName,
364
- componentName: name,
365
- className: safeClassName(element),
366
- id: (_a = element == null ? void 0 : element.id) != null ? _a : "",
367
- x: coords.left,
368
- y: coords.top,
369
- width: coords.width,
370
- height: coords.height,
371
- top: coords.top,
372
- right: coords.right,
373
- bottom: coords.bottom,
374
- left: coords.left,
375
- elementId: id,
376
- textContent: textInfo.hasOnlyTextNodes ? textInfo.textContent : null,
377
- fontSize: fontSizeInfo,
378
- fontWeight: fontWeightInfo,
379
- borderRadius: borderRadiusInfo,
380
- borderWidth: borderWidthInfo,
381
- textAlign: textAlignInfo,
382
- padding: paddingInfo,
383
- margin: marginInfo,
384
- color: colorInfo,
385
- backgroundColor: backgroundColorInfo,
386
- borderColor: borderColorInfo,
387
- metadata: codeInfo.metadata
388
- })
389
- });
390
- (_b = clickOverlayRef.current) == null ? void 0 : _b.remove();
391
- clickOverlayRef.current = null;
392
- const clickOverlay = new ClickOverlay(() => {
393
- const _coords = getElementCoordinates(element);
394
- postMessage({
395
- type: "ElementResize",
396
- data: __spreadValues({
397
- elementId: id
398
- }, _coords)
399
- });
400
569
  });
401
- clickOverlayRef.current = clickOverlay;
402
- clickOverlay.highlight(element, title);
403
570
  }, []);
404
- const handleCodeInfo = useCallback(
405
- (name, info) => {
406
- var _a;
407
- const relativePath = (info == null ? void 0 : info.startsWith(props.cwd)) ? info.replace(props.cwd, "") : info;
408
- return [name, (_a = relativePath == null ? void 0 : relativePath.replace(/^\//, "")) != null ? _a : ""];
409
- },
410
- [props.cwd]
411
- );
412
571
  return /* @__PURE__ */ jsx(
413
572
  Inspector,
414
573
  {