@lark-apaas/miaoda-inspector 0.1.0-alpha.1 → 0.1.0-alpha.2
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,102 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Fiber } from 'react-reconciler';
|
|
3
|
+
import { CodeInfo } from './utils/inspect.js';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* the inspect meta info that is sent to the callback when an element is hovered over or clicked.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
interface InspectParams {
|
|
9
|
+
/** hover / click event target dom element */
|
|
10
|
+
element: HTMLElement;
|
|
11
|
+
/** nearest named react component fiber for dom element */
|
|
12
|
+
fiber?: Fiber;
|
|
13
|
+
/** source file line / column / path info for react component */
|
|
14
|
+
codeInfo?: CodeInfo;
|
|
15
|
+
/** react component name for dom element */
|
|
16
|
+
name?: string;
|
|
17
|
+
title?: string;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* `v2.0.0` changes:
|
|
20
21
|
* - make 'Ctrl + Shift + Alt + C' as default shortcut on Windows/Linux
|
|
21
22
|
* - export `defaultHotkeys`
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
24
|
+
declare const defaultHotkeys: () => string[];
|
|
25
|
+
interface InspectorProps {
|
|
26
|
+
/**
|
|
27
|
+
* Inspector Component toggle hotkeys,
|
|
28
|
+
*
|
|
29
|
+
* supported keys see: https://github.com/jaywcjlove/hotkeys#supported-keys
|
|
30
|
+
*
|
|
31
|
+
* @default - `['Ctrl', 'Shift', 'Command', 'C']` on macOS, `['Ctrl', 'Shift', 'Alt', 'C']` on other platforms.
|
|
32
|
+
*
|
|
33
|
+
* Setting `keys={null}` explicitly means that disable use hotkeys to trigger it.
|
|
34
|
+
*/
|
|
35
|
+
keys?: string[] | null;
|
|
36
|
+
/**
|
|
37
|
+
* If setting `active` prop, the Inspector will be a Controlled React Component,
|
|
38
|
+
* you need to control the `true`/`false` state to active the Inspector.
|
|
39
|
+
*
|
|
40
|
+
* If not setting `active` prop, this only a Uncontrolled component that
|
|
41
|
+
* will activate/deactivate by hotkeys.
|
|
42
|
+
*
|
|
43
|
+
* > add in version `v2.0.0`
|
|
44
|
+
*/
|
|
45
|
+
active?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Trigger by `active` state change, includes:
|
|
48
|
+
* - hotkeys toggle, before activate/deactivate Inspector
|
|
49
|
+
* - Escape / Click, before deactivate Inspector
|
|
50
|
+
*
|
|
51
|
+
* will NOT trigger by `active` prop change.
|
|
52
|
+
*
|
|
53
|
+
* > add in version `v2.0.0`
|
|
54
|
+
*/
|
|
55
|
+
onActiveChange?: (active: boolean) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Whether to disable all behavior include hotkeys listening or trigger,
|
|
58
|
+
* will automatically disable in production environment by default.
|
|
59
|
+
*
|
|
60
|
+
* @default `true` if `NODE_ENV` is 'production', otherwise is `false`.
|
|
61
|
+
* > add in version `v2.0.0`
|
|
62
|
+
*/
|
|
63
|
+
disable?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Callback when left-clicking on an element, with ensuring the source code info is found.
|
|
66
|
+
*
|
|
67
|
+
* By setting the `onInspectElement` prop, the default behavior ("open local IDE") will be disabled,
|
|
68
|
+
* that means you want to manually handle the source info, or handle how to goto editor by yourself.
|
|
69
|
+
*
|
|
70
|
+
* You can also use builtin `gotoServerEditor` utils in `onInspectElement` to get origin behavior ("open local IDE on server-side"),
|
|
71
|
+
* it looks like:
|
|
72
|
+
*
|
|
73
|
+
* ```tsx
|
|
74
|
+
* import { Inspector, gotoServerEditor } from 'react-dev-inspector'
|
|
75
|
+
*
|
|
76
|
+
* <Inspector
|
|
77
|
+
* onInspectElement={({ codeInfo }) => {
|
|
78
|
+
* ...; // your processing
|
|
79
|
+
* gotoServerEditor(codeInfo)
|
|
80
|
+
* }}
|
|
81
|
+
* </Inspector>
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* > add in version `v2.0.0`
|
|
85
|
+
*/
|
|
86
|
+
onInspectElement?: (params: Required<InspectParams>) => void;
|
|
87
|
+
/** Callback when hovering on an element */
|
|
88
|
+
onHoverElement?: (params: InspectParams) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Callback when left-clicking on an element.
|
|
91
|
+
*/
|
|
92
|
+
onClickElement?: (params: InspectParams) => void;
|
|
93
|
+
/** any children of react nodes */
|
|
94
|
+
children?: ReactNode;
|
|
95
|
+
/**
|
|
96
|
+
* custom handler for component name and info display
|
|
97
|
+
* @param name component name
|
|
98
|
+
* @param info component info (file path)
|
|
99
|
+
* @returns [displayName, displayInfo] tuple for display
|
|
100
|
+
*/
|
|
101
|
+
handleCodeInfo?: (name: string, info?: string) => [string, string];
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
+
declare const Inspector: (props: InspectorProps) => JSX.Element;
|
|
104
|
+
|
|
105
|
+
export { type InspectParams, Inspector, type InspectorProps, defaultHotkeys };
|
|
@@ -1,71 +1,74 @@
|
|
|
1
|
+
import { Rect, BoxSizing } from './utils/overlay.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* mirror from https://github.com/facebook/react/blob/v16.13.1/packages/react-devtools-shared/src/backend/views/utils.js
|
|
3
5
|
*/
|
|
4
|
-
|
|
6
|
+
|
|
5
7
|
interface Box {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
top: number;
|
|
9
|
+
left: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
10
12
|
}
|
|
11
13
|
declare class OverlayRect {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
node: HTMLElement;
|
|
15
|
+
border: HTMLElement;
|
|
16
|
+
padding: HTMLElement;
|
|
17
|
+
content: HTMLElement;
|
|
18
|
+
constructor(doc: Document, container: HTMLElement);
|
|
19
|
+
remove(): void;
|
|
20
|
+
update(box: Rect, dims: BoxSizing): void;
|
|
19
21
|
}
|
|
20
22
|
declare class ClickOverlayRect {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
node: HTMLElement;
|
|
24
|
+
border: HTMLElement;
|
|
25
|
+
constructor(doc: Document, container: HTMLElement);
|
|
26
|
+
remove(): void;
|
|
27
|
+
update(box: Rect, dims: BoxSizing): void;
|
|
26
28
|
}
|
|
27
29
|
declare class OverlayTip {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
tip: HTMLElement;
|
|
31
|
+
nameSpan: HTMLElement;
|
|
32
|
+
titleDiv: HTMLElement;
|
|
33
|
+
constructor(doc: Document, container: HTMLElement);
|
|
34
|
+
remove(): void;
|
|
35
|
+
updateText(name: string): void;
|
|
36
|
+
updatePosition(dims: Box, bounds: Box): void;
|
|
37
|
+
invisible(): void;
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
declare class Overlay {
|
|
40
|
+
window: Window;
|
|
41
|
+
tipBoundsWindow: Window;
|
|
42
|
+
container: HTMLElement;
|
|
43
|
+
tip: OverlayTip;
|
|
44
|
+
rects: Array<OverlayRect>;
|
|
45
|
+
removeCallback: (this: Overlay) => void;
|
|
46
|
+
handleCodeInfo?: (name: string, info?: string) => [string, string];
|
|
47
|
+
resizeObserver: ResizeObserver;
|
|
48
|
+
currentElements?: HTMLElement[];
|
|
49
|
+
currentName?: string;
|
|
50
|
+
constructor(handleCodeInfo?: (name: string, info?: string) => [string, string]);
|
|
51
|
+
remove(): void;
|
|
52
|
+
setRemoveCallback(callback: () => void): void;
|
|
53
|
+
inspect(nodes: Array<HTMLElement>, name?: string, info?: string): void;
|
|
54
|
+
updatePositions(nodes: Array<HTMLElement>, name?: string, info?: string): void;
|
|
55
|
+
clearRect(): void;
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
declare class ClickOverlay {
|
|
58
|
+
window: Window;
|
|
59
|
+
container: HTMLElement;
|
|
60
|
+
rect: ClickOverlayRect | null;
|
|
61
|
+
tip: OverlayTip;
|
|
62
|
+
tipBoundsWindow: Window;
|
|
63
|
+
resizeObserver: ResizeObserver;
|
|
64
|
+
currentElement: HTMLElement | null;
|
|
65
|
+
currentName: string | undefined;
|
|
66
|
+
positionUpdate?: () => void;
|
|
67
|
+
constructor(positionUpdate?: () => void);
|
|
68
|
+
remove(): void;
|
|
69
|
+
highlight(element: HTMLElement, name?: string): void;
|
|
70
|
+
updatePosition(element: HTMLElement): void;
|
|
71
|
+
clearRect(): void;
|
|
70
72
|
}
|
|
71
|
-
|
|
73
|
+
|
|
74
|
+
export { ClickOverlay, Overlay };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { useLayoutEffect } from './use-layout-effect.js';
|
|
2
|
+
export { useEffectEvent } from './use-effect-event.js';
|
|
3
|
+
export { useMousePosition } from './use-mouse.js';
|
|
4
|
+
import 'react';
|
|
@@ -6,4 +6,6 @@
|
|
|
6
6
|
* - `useEvent` in https://github.com/scottrippey/react-use-event-hook
|
|
7
7
|
* - `useMemoizedFn` in https://github.com/alibaba/hooks
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
declare const useEffectEvent: <T extends (...args: any[]) => any>(callback?: T) => T;
|
|
10
|
+
|
|
11
|
+
export { useEffectEvent };
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import { useLayoutEffect as
|
|
2
|
-
|
|
1
|
+
import { useLayoutEffect as useLayoutEffect$1 } from 'react';
|
|
2
|
+
|
|
3
|
+
declare const useLayoutEffect: typeof useLayoutEffect$1;
|
|
4
|
+
|
|
5
|
+
export { useLayoutEffect };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
disable?: boolean | undefined;
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
declare const useMousePosition: ({ disable, }: {
|
|
4
|
+
disable?: boolean;
|
|
6
5
|
}) => MutableRefObject<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}>;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}>;
|
|
9
|
+
|
|
10
|
+
export { useMousePosition };
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Fiber } from 'react-reconciler';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* only native html tag fiber's type will be string,
|
|
4
5
|
* all the others (component / functional component / context) type will be function or object
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare const isNativeTagFiber: (fiber?: Fiber) => boolean;
|
|
7
8
|
/**
|
|
8
9
|
* react fiber symbol types see:
|
|
9
10
|
* https://github.com/facebook/react/blob/v17.0.0/packages/shared/ReactSymbols.js#L39-L58
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
declare const isReactSymbolFiber: (fiber?: Fiber) => boolean;
|
|
13
|
+
declare const isForwardRef: (fiber?: Fiber) => boolean;
|
|
13
14
|
type FiberHTMLElement = HTMLElement & {
|
|
14
|
-
|
|
15
|
+
[fiberKey: string]: Fiber | undefined;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* https://stackoverflow.com/questions/29321742/react-getting-a-component-from-a-dom-element-for-debugging
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
declare const getElementFiber: (element: FiberHTMLElement) => Fiber | undefined;
|
|
21
|
+
declare const getElementFiberUpward: (element: HTMLElement | null) => Fiber | undefined;
|
|
21
22
|
/**
|
|
22
23
|
* find first parent of native html tag or react component,
|
|
23
24
|
* skip react Provider / Context / ForwardRef / Fragment etc.
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
declare const getDirectParentFiber: (child: Fiber) => Fiber | null;
|
|
26
27
|
/**
|
|
27
28
|
* The displayName property is not guaranteed to be a string.
|
|
28
29
|
* It's only safe to use for our purposes if it's a string.
|
|
@@ -30,5 +31,6 @@ export declare const getDirectParentFiber: (child: Fiber) => Fiber | null;
|
|
|
30
31
|
*
|
|
31
32
|
* https://github.com/facebook/react/blob/v17.0.0/packages/react-devtools-shared/src/utils.js#L90-L112
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
declare const getFiberName: (fiber?: Fiber) => string | undefined;
|
|
35
|
+
|
|
36
|
+
export { getDirectParentFiber, getElementFiber, getElementFiberUpward, getFiberName, isForwardRef, isNativeTagFiber, isReactSymbolFiber };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* mirror from https://github.com/facebook/react/blob/v16.13.1/packages/react-devtools-shared/src/backend/views/Highlighter/index.js
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}): StopFunction;
|
|
4
|
+
type StopFunction = () => void;
|
|
5
|
+
declare function setupHighlighter(handlers: {
|
|
6
|
+
onPointerOver?: (element: HTMLElement) => void;
|
|
7
|
+
onClick?: (element: HTMLElement) => void;
|
|
8
|
+
}): StopFunction;
|
|
9
|
+
|
|
10
|
+
export { type StopFunction, setupHighlighter };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { StopFunction, setupHighlighter } from './highlight.js';
|
|
2
|
+
export { CodeDataAttribute, CodeInfo, getCodeInfoFromDebugSource, getCodeInfoFromFiber, getCodeInfoFromProps, getElementCodeInfo, getElementInspect, getNamedFiber, getReferenceFiber } from './inspect.js';
|
|
3
|
+
export { BoxSizing, Rect, getElementDimensions, getNestedBoundingClientRect } from './overlay.js';
|
|
4
|
+
import 'react-reconciler';
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { Fiber } from 'react-reconciler';
|
|
2
|
+
|
|
3
|
+
interface CodeInfo {
|
|
4
|
+
name?: string;
|
|
5
|
+
lineNumber: string;
|
|
6
|
+
columnNumber: string;
|
|
7
|
+
/**
|
|
8
|
+
* code source file relative path to dev-server cwd(current working directory)
|
|
9
|
+
* need use with `react-dev-inspector/plugins/babel`
|
|
10
|
+
*/
|
|
11
|
+
relativePath?: string;
|
|
12
|
+
/**
|
|
13
|
+
* code source file absolute path
|
|
14
|
+
* just need use with `@babel/plugin-transform-react-jsx-source` which auto set by most framework
|
|
15
|
+
*/
|
|
16
|
+
absolutePath?: string;
|
|
17
|
+
/**
|
|
18
|
+
* metadata information from babel plugin
|
|
19
|
+
*/
|
|
20
|
+
metadata?: {
|
|
21
|
+
elementStart: number;
|
|
22
|
+
elementEnd: number;
|
|
23
|
+
tagStart: number;
|
|
24
|
+
tagEnd: number;
|
|
25
|
+
classNameLiteral: boolean;
|
|
26
|
+
};
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* props that injected into react nodes
|
|
@@ -30,12 +31,12 @@ export interface CodeInfo {
|
|
|
30
31
|
* like <div data-inspector-line="2" data-inspector-column="3" data-inspector-relative-path="xxx/ooo" />
|
|
31
32
|
* this props will be record in fiber
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
interface CodeDataAttribute {
|
|
35
|
+
'data-miaoda-line': string;
|
|
36
|
+
'data-miaoda-column': string;
|
|
37
|
+
'data-miaoda-relative-path': string;
|
|
38
|
+
'data-miaoda-component-name'?: string;
|
|
39
|
+
'data-miaoda-metadata'?: string;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* react fiber property `_debugSource` created by `@babel/plugin-transform-react-jsx-source`
|
|
@@ -49,12 +50,12 @@ export interface CodeDataAttribute {
|
|
|
49
50
|
* finally, used by `createFiberFromElement` to become a fiber property `_debugSource`.
|
|
50
51
|
* https://github.com/facebook/react/blob/v18.0.0/packages/react-reconciler/src/ReactFiber.new.js#L648-L649
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
+
declare const getCodeInfoFromDebugSource: (fiber?: Fiber) => CodeInfo | undefined;
|
|
53
54
|
/**
|
|
54
55
|
* code location data-attribute props inject by `react-dev-inspector/plugins/babel`
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
declare const getCodeInfoFromProps: (fiber?: Fiber) => CodeInfo | undefined;
|
|
58
|
+
declare const getCodeInfoFromFiber: (fiber?: Fiber) => CodeInfo | undefined;
|
|
58
59
|
/**
|
|
59
60
|
* give a `base` dom fiber,
|
|
60
61
|
* and will try to get the human friendly react component `reference` fiber from it;
|
|
@@ -100,11 +101,13 @@ export declare const getCodeInfoFromFiber: (fiber?: Fiber) => CodeInfo | undefin
|
|
|
100
101
|
* └─ span
|
|
101
102
|
* └─ div
|
|
102
103
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
104
|
+
declare const getReferenceFiber: (baseFiber?: Fiber) => Fiber | undefined;
|
|
105
|
+
declare const getElementCodeInfo: (element: HTMLElement) => CodeInfo | undefined;
|
|
106
|
+
declare const getNamedFiber: (baseFiber?: Fiber) => Fiber | undefined;
|
|
107
|
+
declare const getElementInspect: (element: HTMLElement) => {
|
|
108
|
+
fiber?: Fiber;
|
|
109
|
+
name?: string;
|
|
110
|
+
title: string;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export { type CodeDataAttribute, type CodeInfo, getCodeInfoFromDebugSource, getCodeInfoFromFiber, getCodeInfoFromProps, getElementCodeInfo, getElementInspect, getNamedFiber, getReferenceFiber };
|
|
@@ -4,27 +4,29 @@
|
|
|
4
4
|
* remove all process for iframe, because iframe only need to think in chrome extension app,
|
|
5
5
|
* which will deal multiple levels of nesting iframe.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
interface Rect {
|
|
8
|
+
bottom: number;
|
|
9
|
+
height: number;
|
|
10
|
+
left: number;
|
|
11
|
+
right: number;
|
|
12
|
+
top: number;
|
|
13
|
+
width: number;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
interface BoxSizing {
|
|
16
|
+
borderTop: number;
|
|
17
|
+
borderBottom: number;
|
|
18
|
+
borderLeft: number;
|
|
19
|
+
borderRight: number;
|
|
20
|
+
paddingTop: number;
|
|
21
|
+
paddingBottom: number;
|
|
22
|
+
paddingLeft: number;
|
|
23
|
+
paddingRight: number;
|
|
24
|
+
marginTop: number;
|
|
25
|
+
marginBottom: number;
|
|
26
|
+
marginLeft: number;
|
|
27
|
+
marginRight: number;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
declare function getNestedBoundingClientRect(node: HTMLElement, boundaryWindow: Window | HTMLElement): Rect;
|
|
30
|
+
declare function getElementDimensions(domElement: Element): BoxSizing;
|
|
31
|
+
|
|
32
|
+
export { type BoxSizing, type Rect, getElementDimensions, getNestedBoundingClientRect };
|