@domscribe/react 0.1.0
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/adapter/react-adapter.d.ts +121 -0
- package/adapter/react-adapter.d.ts.map +1 -0
- package/adapter/react-adapter.js +486 -0
- package/adapter/types.d.ts +131 -0
- package/adapter/types.d.ts.map +1 -0
- package/adapter/types.js +17 -0
- package/auto-init.d.ts +2 -0
- package/auto-init.d.ts.map +1 -0
- package/auto-init.js +40 -0
- package/component/component-name-resolver.d.ts +118 -0
- package/component/component-name-resolver.d.ts.map +1 -0
- package/component/component-name-resolver.js +361 -0
- package/component/props-extractor.d.ts +51 -0
- package/component/props-extractor.d.ts.map +1 -0
- package/component/props-extractor.js +122 -0
- package/component/state-extractor.d.ts +60 -0
- package/component/state-extractor.d.ts.map +1 -0
- package/component/state-extractor.js +162 -0
- package/component/types.d.ts +256 -0
- package/component/types.d.ts.map +1 -0
- package/component/types.js +5 -0
- package/errors/index.d.ts +36 -0
- package/errors/index.d.ts.map +1 -0
- package/errors/index.js +75 -0
- package/fiber/fiber-walker.d.ts +58 -0
- package/fiber/fiber-walker.d.ts.map +1 -0
- package/fiber/fiber-walker.js +118 -0
- package/fiber/types.d.ts +162 -0
- package/fiber/types.d.ts.map +1 -0
- package/fiber/types.js +32 -0
- package/index.d.ts +14 -0
- package/index.d.ts.map +1 -0
- package/index.js +15 -0
- package/package.json +59 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/utils/constants.d.ts +94 -0
- package/utils/constants.d.ts.map +1 -0
- package/utils/constants.js +123 -0
- package/utils/type-guards.d.ts +31 -0
- package/utils/type-guards.d.ts.map +1 -0
- package/utils/type-guards.js +89 -0
- package/utils/types.d.ts +6 -0
- package/utils/types.d.ts.map +1 -0
- package/utils/types.js +5 -0
- package/vite/index.d.ts +7 -0
- package/vite/index.d.ts.map +1 -0
- package/vite/index.js +5 -0
- package/vite/types.d.ts +56 -0
- package/vite/types.d.ts.map +1 -0
- package/vite/types.js +10 -0
- package/vite/vite-plugin.d.ts +29 -0
- package/vite/vite-plugin.d.ts.map +1 -0
- package/vite/vite-plugin.js +104 -0
- package/webpack/index.d.ts +7 -0
- package/webpack/index.d.ts.map +1 -0
- package/webpack/index.js +5 -0
- package/webpack/webpack-plugin.d.ts +50 -0
- package/webpack/webpack-plugin.d.ts.map +1 -0
- package/webpack/webpack-plugin.js +63 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PropsExtractor - Extract props from React Fiber nodes
|
|
3
|
+
*
|
|
4
|
+
* Handles safe extraction of component props with filtering of internal React props.
|
|
5
|
+
*
|
|
6
|
+
* @module @domscribe/react/component/props-extractor
|
|
7
|
+
*/
|
|
8
|
+
import type { ExtendedReactFiber } from '../fiber/types.js';
|
|
9
|
+
import type { PropsExtractionResult, ComponentExtractionOptions } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* PropsExtractor class for extracting props from Fiber nodes
|
|
12
|
+
*/
|
|
13
|
+
export declare class PropsExtractor {
|
|
14
|
+
/**
|
|
15
|
+
* Extract props from a Fiber node
|
|
16
|
+
*
|
|
17
|
+
* @param fiber - Fiber node to extract props from
|
|
18
|
+
* @param options - Extraction options
|
|
19
|
+
* @returns Props extraction result
|
|
20
|
+
*/
|
|
21
|
+
extract(fiber: ExtendedReactFiber, _options?: ComponentExtractionOptions): PropsExtractionResult;
|
|
22
|
+
/**
|
|
23
|
+
* Get raw props from Fiber node
|
|
24
|
+
*
|
|
25
|
+
* @param fiber - Fiber node
|
|
26
|
+
* @returns Raw props object or null
|
|
27
|
+
*/
|
|
28
|
+
private getRawProps;
|
|
29
|
+
/**
|
|
30
|
+
* Filter props to remove internal React props
|
|
31
|
+
*
|
|
32
|
+
* @param rawProps - Raw props object
|
|
33
|
+
* @returns Filtered props and list of filtered keys
|
|
34
|
+
*/
|
|
35
|
+
private filterProps;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a prop should be skipped
|
|
38
|
+
*
|
|
39
|
+
* @param key - Prop key
|
|
40
|
+
* @returns True if should skip
|
|
41
|
+
*/
|
|
42
|
+
private shouldSkipProp;
|
|
43
|
+
/**
|
|
44
|
+
* Ensure a value is a record (object with string keys)
|
|
45
|
+
*
|
|
46
|
+
* @param value - Value to check
|
|
47
|
+
* @returns Record or empty object
|
|
48
|
+
*/
|
|
49
|
+
private ensureRecord;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=props-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props-extractor.d.ts","sourceRoot":"","sources":["../../../../packages/domscribe-react/src/component/props-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EACV,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAIpB;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;;;OAMG;IACH,OAAO,CACL,KAAK,EAAE,kBAAkB,EAEzB,QAAQ,CAAC,EAAE,0BAA0B,GACpC,qBAAqB;IAuCxB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAgBnB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAoBnB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IActB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PropsExtractor - Extract props from React Fiber nodes
|
|
3
|
+
*
|
|
4
|
+
* Handles safe extraction of component props with filtering of internal React props.
|
|
5
|
+
*
|
|
6
|
+
* @module @domscribe/react/component/props-extractor
|
|
7
|
+
*/
|
|
8
|
+
import { REACT_INTERNAL_PROPS } from '../utils/constants.js';
|
|
9
|
+
import { PropsExtractionError } from '../errors/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* PropsExtractor class for extracting props from Fiber nodes
|
|
12
|
+
*/
|
|
13
|
+
export class PropsExtractor {
|
|
14
|
+
/**
|
|
15
|
+
* Extract props from a Fiber node
|
|
16
|
+
*
|
|
17
|
+
* @param fiber - Fiber node to extract props from
|
|
18
|
+
* @param options - Extraction options
|
|
19
|
+
* @returns Props extraction result
|
|
20
|
+
*/
|
|
21
|
+
extract(fiber,
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
_options) {
|
|
24
|
+
if (!fiber) {
|
|
25
|
+
return {
|
|
26
|
+
success: false,
|
|
27
|
+
error: new Error('Fiber node is required'),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const rawProps = this.getRawProps(fiber);
|
|
32
|
+
// If no props, return empty result
|
|
33
|
+
if (!rawProps) {
|
|
34
|
+
return {
|
|
35
|
+
success: true,
|
|
36
|
+
props: {},
|
|
37
|
+
filteredKeys: [],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Extract and filter props
|
|
41
|
+
const { props, filteredKeys } = this.filterProps(rawProps);
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
props,
|
|
45
|
+
filteredKeys,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
error: error instanceof Error
|
|
52
|
+
? error
|
|
53
|
+
: new PropsExtractionError('Props extraction failed'),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get raw props from Fiber node
|
|
59
|
+
*
|
|
60
|
+
* @param fiber - Fiber node
|
|
61
|
+
* @returns Raw props object or null
|
|
62
|
+
*/
|
|
63
|
+
getRawProps(fiber) {
|
|
64
|
+
// Try memoizedProps first (current props)
|
|
65
|
+
if (fiber.memoizedProps) {
|
|
66
|
+
return this.ensureRecord(fiber.memoizedProps);
|
|
67
|
+
}
|
|
68
|
+
// Fallback to pendingProps
|
|
69
|
+
if (fiber.pendingProps) {
|
|
70
|
+
return this.ensureRecord(fiber.pendingProps);
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Filter props to remove internal React props
|
|
76
|
+
*
|
|
77
|
+
* @param rawProps - Raw props object
|
|
78
|
+
* @returns Filtered props and list of filtered keys
|
|
79
|
+
*/
|
|
80
|
+
filterProps(rawProps) {
|
|
81
|
+
const props = {};
|
|
82
|
+
const filteredKeys = [];
|
|
83
|
+
for (const key of Object.keys(rawProps)) {
|
|
84
|
+
// Skip internal React props
|
|
85
|
+
if (this.shouldSkipProp(key)) {
|
|
86
|
+
filteredKeys.push(key);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
props[key] = rawProps[key];
|
|
90
|
+
}
|
|
91
|
+
return { props, filteredKeys };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if a prop should be skipped
|
|
95
|
+
*
|
|
96
|
+
* @param key - Prop key
|
|
97
|
+
* @returns True if should skip
|
|
98
|
+
*/
|
|
99
|
+
shouldSkipProp(key) {
|
|
100
|
+
// Skip internal React props
|
|
101
|
+
if (REACT_INTERNAL_PROPS.has(key)) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
// Skip keys starting with __ (internal)
|
|
105
|
+
if (key.startsWith('__')) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Ensure a value is a record (object with string keys)
|
|
112
|
+
*
|
|
113
|
+
* @param value - Value to check
|
|
114
|
+
* @returns Record or empty object
|
|
115
|
+
*/
|
|
116
|
+
ensureRecord(value) {
|
|
117
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StateExtractor - Extract state from React Fiber nodes
|
|
3
|
+
*
|
|
4
|
+
* Handles extraction of component state for both class and function components.
|
|
5
|
+
* For class components, extracts from memoizedState. For function components,
|
|
6
|
+
* extracts useState/useReducer state from the hook chain.
|
|
7
|
+
*
|
|
8
|
+
* @module @domscribe/react/component/state-extractor
|
|
9
|
+
*/
|
|
10
|
+
import type { ExtendedReactFiber } from '../fiber/types.js';
|
|
11
|
+
import type { StateExtractionResult, ComponentExtractionOptions } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* StateExtractor class for extracting state from Fiber nodes
|
|
14
|
+
*/
|
|
15
|
+
export declare class StateExtractor {
|
|
16
|
+
/**
|
|
17
|
+
* Extract state from a Fiber node
|
|
18
|
+
*
|
|
19
|
+
* @param fiber - Fiber node to extract state from
|
|
20
|
+
* @param options - Extraction options
|
|
21
|
+
* @returns State extraction result
|
|
22
|
+
*/
|
|
23
|
+
extract(fiber: ExtendedReactFiber, _options?: ComponentExtractionOptions): StateExtractionResult;
|
|
24
|
+
/**
|
|
25
|
+
* Extract state from a class component
|
|
26
|
+
*
|
|
27
|
+
* @param fiber - Class component Fiber node
|
|
28
|
+
* @returns State extraction result
|
|
29
|
+
*/
|
|
30
|
+
private extractClassState;
|
|
31
|
+
/**
|
|
32
|
+
* Extract state from a function component
|
|
33
|
+
*
|
|
34
|
+
* @param fiber - Function component Fiber node
|
|
35
|
+
* @returns State extraction result
|
|
36
|
+
*/
|
|
37
|
+
private extractFunctionState;
|
|
38
|
+
/**
|
|
39
|
+
* Extract state values from hook chain
|
|
40
|
+
*
|
|
41
|
+
* @param fiber - Fiber node with hooks
|
|
42
|
+
* @returns Record mapping hook indices to state values
|
|
43
|
+
*/
|
|
44
|
+
private extractStateFromHooks;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a value is a hook node
|
|
47
|
+
*
|
|
48
|
+
* @param value - Value to check
|
|
49
|
+
* @returns True if hook node
|
|
50
|
+
*/
|
|
51
|
+
private isHookNode;
|
|
52
|
+
/**
|
|
53
|
+
* Ensure a value is a record (object with string keys)
|
|
54
|
+
*
|
|
55
|
+
* @param value - Value to check
|
|
56
|
+
* @returns Record or empty object
|
|
57
|
+
*/
|
|
58
|
+
private ensureRecord;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=state-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-extractor.d.ts","sourceRoot":"","sources":["../../../../packages/domscribe-react/src/component/state-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EACV,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAIpB;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;;;OAMG;IACH,OAAO,CACL,KAAK,EAAE,kBAAkB,EAEzB,QAAQ,CAAC,EAAE,0BAA0B,GACpC,qBAAqB;IAyCxB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAqBzB;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IA4B5B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IA2B7B;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAYlB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StateExtractor - Extract state from React Fiber nodes
|
|
3
|
+
*
|
|
4
|
+
* Handles extraction of component state for both class and function components.
|
|
5
|
+
* For class components, extracts from memoizedState. For function components,
|
|
6
|
+
* extracts useState/useReducer state from the hook chain.
|
|
7
|
+
*
|
|
8
|
+
* @module @domscribe/react/component/state-extractor
|
|
9
|
+
*/
|
|
10
|
+
import { REACT_FIBER_TAGS } from '../utils/constants.js';
|
|
11
|
+
import { StateExtractionError } from '../errors/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* StateExtractor class for extracting state from Fiber nodes
|
|
14
|
+
*/
|
|
15
|
+
export class StateExtractor {
|
|
16
|
+
/**
|
|
17
|
+
* Extract state from a Fiber node
|
|
18
|
+
*
|
|
19
|
+
* @param fiber - Fiber node to extract state from
|
|
20
|
+
* @param options - Extraction options
|
|
21
|
+
* @returns State extraction result
|
|
22
|
+
*/
|
|
23
|
+
extract(fiber,
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
+
_options) {
|
|
26
|
+
if (!fiber) {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
stateType: 'none',
|
|
30
|
+
error: new Error('Fiber node is required'),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
// Check component type and extract accordingly
|
|
35
|
+
if (fiber.tag === REACT_FIBER_TAGS.ClassComponent) {
|
|
36
|
+
return this.extractClassState(fiber);
|
|
37
|
+
}
|
|
38
|
+
if (fiber.tag === REACT_FIBER_TAGS.FunctionComponent ||
|
|
39
|
+
fiber.tag === REACT_FIBER_TAGS.MemoComponent ||
|
|
40
|
+
fiber.tag === REACT_FIBER_TAGS.SimpleMemoComponent ||
|
|
41
|
+
fiber.tag === REACT_FIBER_TAGS.ForwardRef) {
|
|
42
|
+
return this.extractFunctionState(fiber);
|
|
43
|
+
}
|
|
44
|
+
// Other component types don't have state
|
|
45
|
+
return {
|
|
46
|
+
success: true,
|
|
47
|
+
stateType: 'none',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
stateType: 'none',
|
|
54
|
+
error: error instanceof Error
|
|
55
|
+
? error
|
|
56
|
+
: new StateExtractionError('State extraction failed'),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Extract state from a class component
|
|
62
|
+
*
|
|
63
|
+
* @param fiber - Class component Fiber node
|
|
64
|
+
* @returns State extraction result
|
|
65
|
+
*/
|
|
66
|
+
extractClassState(fiber) {
|
|
67
|
+
// For class components, memoizedState IS the state
|
|
68
|
+
const state = fiber.memoizedState;
|
|
69
|
+
if (state === null || state === undefined) {
|
|
70
|
+
return {
|
|
71
|
+
success: true,
|
|
72
|
+
stateType: 'class',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Ensure state is a record
|
|
76
|
+
const stateRecord = this.ensureRecord(state);
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
state: stateRecord,
|
|
80
|
+
stateType: 'class',
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Extract state from a function component
|
|
85
|
+
*
|
|
86
|
+
* @param fiber - Function component Fiber node
|
|
87
|
+
* @returns State extraction result
|
|
88
|
+
*/
|
|
89
|
+
extractFunctionState(fiber) {
|
|
90
|
+
// For function components, we need to walk the hook chain
|
|
91
|
+
if (!fiber.memoizedState) {
|
|
92
|
+
return {
|
|
93
|
+
success: true,
|
|
94
|
+
stateType: 'hooks',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Extract state values from hooks - returns them as a record with indices as keys
|
|
98
|
+
const stateRecord = this.extractStateFromHooks(fiber);
|
|
99
|
+
if (Object.keys(stateRecord).length === 0) {
|
|
100
|
+
return {
|
|
101
|
+
success: true,
|
|
102
|
+
stateType: 'hooks',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
success: true,
|
|
107
|
+
state: stateRecord,
|
|
108
|
+
stateType: 'hooks',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Extract state values from hook chain
|
|
113
|
+
*
|
|
114
|
+
* @param fiber - Fiber node with hooks
|
|
115
|
+
* @returns Record mapping hook indices to state values
|
|
116
|
+
*/
|
|
117
|
+
extractStateFromHooks(fiber) {
|
|
118
|
+
const stateRecord = {};
|
|
119
|
+
let current = fiber.memoizedState;
|
|
120
|
+
let hookIndex = 0;
|
|
121
|
+
while (current && hookIndex < 100) {
|
|
122
|
+
// Safety limit
|
|
123
|
+
if (this.isHookNode(current)) {
|
|
124
|
+
// Check if this is a state hook (useState or useReducer)
|
|
125
|
+
// State hooks have memoizedState property
|
|
126
|
+
if ('memoizedState' in current) {
|
|
127
|
+
stateRecord[`hook_${hookIndex}`] = current.memoizedState;
|
|
128
|
+
}
|
|
129
|
+
current = current.next;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
hookIndex++;
|
|
135
|
+
}
|
|
136
|
+
return stateRecord;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Check if a value is a hook node
|
|
140
|
+
*
|
|
141
|
+
* @param value - Value to check
|
|
142
|
+
* @returns True if hook node
|
|
143
|
+
*/
|
|
144
|
+
isHookNode(value) {
|
|
145
|
+
return (typeof value === 'object' &&
|
|
146
|
+
value !== null &&
|
|
147
|
+
'next' in value &&
|
|
148
|
+
('memoizedState' in value || 'queue' in value || 'baseState' in value));
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Ensure a value is a record (object with string keys)
|
|
152
|
+
*
|
|
153
|
+
* @param value - Value to check
|
|
154
|
+
* @returns Record or empty object
|
|
155
|
+
*/
|
|
156
|
+
ensureRecord(value) {
|
|
157
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
return {};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React component type definitions
|
|
3
|
+
* @module @domscribe/react/component/types
|
|
4
|
+
*/
|
|
5
|
+
import type { ComponentCategory } from '../fiber/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Comprehensive component information
|
|
8
|
+
*/
|
|
9
|
+
export interface ComponentInfo {
|
|
10
|
+
/**
|
|
11
|
+
* Component name (resolved)
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* Display name (may include HOC wrappers)
|
|
16
|
+
*/
|
|
17
|
+
displayName?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Component category
|
|
20
|
+
*/
|
|
21
|
+
category: ComponentCategory;
|
|
22
|
+
/**
|
|
23
|
+
* Whether this is a function component
|
|
24
|
+
*/
|
|
25
|
+
isFunctionComponent: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this is a class component
|
|
28
|
+
*/
|
|
29
|
+
isClassComponent: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether this component uses hooks
|
|
32
|
+
*/
|
|
33
|
+
usesHooks: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Component props
|
|
36
|
+
*/
|
|
37
|
+
props?: Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Component state (for class components or parsed hooks)
|
|
40
|
+
*/
|
|
41
|
+
state?: Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Parsed hooks (for function components)
|
|
44
|
+
*/
|
|
45
|
+
hooks?: unknown[];
|
|
46
|
+
/**
|
|
47
|
+
* HOC wrapper chain (outermost to innermost)
|
|
48
|
+
*/
|
|
49
|
+
wrappers?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* Owner component name
|
|
52
|
+
*/
|
|
53
|
+
owner?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Source location if available
|
|
56
|
+
*/
|
|
57
|
+
source?: {
|
|
58
|
+
fileName?: string;
|
|
59
|
+
lineNumber?: number;
|
|
60
|
+
columnNumber?: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Component tree depth
|
|
64
|
+
*/
|
|
65
|
+
depth?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Component name resolution result
|
|
69
|
+
*/
|
|
70
|
+
export interface NameResolutionResult {
|
|
71
|
+
/**
|
|
72
|
+
* Resolved name
|
|
73
|
+
*/
|
|
74
|
+
name: string;
|
|
75
|
+
/**
|
|
76
|
+
* Display name (with wrappers)
|
|
77
|
+
*/
|
|
78
|
+
displayName?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Confidence level (0-1)
|
|
81
|
+
*/
|
|
82
|
+
confidence: number;
|
|
83
|
+
/**
|
|
84
|
+
* Resolution method used
|
|
85
|
+
*/
|
|
86
|
+
method: 'displayName' | 'function-name' | 'class-name' | 'type-name' | 'debug-owner' | 'fallback';
|
|
87
|
+
/**
|
|
88
|
+
* HOC wrappers detected
|
|
89
|
+
*/
|
|
90
|
+
wrappers: string[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Component name resolution options
|
|
94
|
+
*/
|
|
95
|
+
export interface NameResolutionOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Include HOC wrappers in display name
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
includeWrappers?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Fallback name if resolution fails
|
|
103
|
+
* @default 'Anonymous'
|
|
104
|
+
*/
|
|
105
|
+
fallbackName?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Maximum wrapper depth to include
|
|
108
|
+
* @default 3
|
|
109
|
+
*/
|
|
110
|
+
maxWrapperDepth?: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Component metadata for debugging
|
|
114
|
+
*/
|
|
115
|
+
export interface ComponentMetadata {
|
|
116
|
+
/**
|
|
117
|
+
* React element type
|
|
118
|
+
*/
|
|
119
|
+
elementType?: unknown;
|
|
120
|
+
/**
|
|
121
|
+
* Component type (function, class, etc.)
|
|
122
|
+
*/
|
|
123
|
+
type?: unknown;
|
|
124
|
+
/**
|
|
125
|
+
* Debug ID (React DevTools)
|
|
126
|
+
*/
|
|
127
|
+
debugId?: number;
|
|
128
|
+
/**
|
|
129
|
+
* Debug hook types (if available)
|
|
130
|
+
*/
|
|
131
|
+
debugHookTypes?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Fiber tag
|
|
134
|
+
*/
|
|
135
|
+
fiberTag?: number;
|
|
136
|
+
/**
|
|
137
|
+
* Key used for reconciliation
|
|
138
|
+
*/
|
|
139
|
+
key?: string | null;
|
|
140
|
+
/**
|
|
141
|
+
* Ref attached to this component
|
|
142
|
+
*/
|
|
143
|
+
hasRef: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Component tree building options
|
|
147
|
+
*/
|
|
148
|
+
export interface ComponentTreeOptions {
|
|
149
|
+
/**
|
|
150
|
+
* Maximum depth to traverse
|
|
151
|
+
* @default 10
|
|
152
|
+
*/
|
|
153
|
+
maxDepth?: number;
|
|
154
|
+
/**
|
|
155
|
+
* Include host components (DOM elements)
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
includeHost?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Include HOC wrappers
|
|
161
|
+
* @default false
|
|
162
|
+
*/
|
|
163
|
+
includeHOC?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Include React system components
|
|
166
|
+
* @default false
|
|
167
|
+
*/
|
|
168
|
+
includeSystem?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Include props in the tree
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
173
|
+
includeProps?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Include state in the tree
|
|
176
|
+
* @default false
|
|
177
|
+
*/
|
|
178
|
+
includeState?: boolean;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Component extraction options
|
|
182
|
+
*/
|
|
183
|
+
export interface ComponentExtractionOptions {
|
|
184
|
+
/**
|
|
185
|
+
* Extract props
|
|
186
|
+
* @default true
|
|
187
|
+
*/
|
|
188
|
+
extractProps?: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Extract state
|
|
191
|
+
* @default true
|
|
192
|
+
*/
|
|
193
|
+
extractState?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Extract hooks (for function components)
|
|
196
|
+
* @default true
|
|
197
|
+
*/
|
|
198
|
+
extractHooks?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Include component metadata
|
|
201
|
+
* @default false
|
|
202
|
+
*/
|
|
203
|
+
includeMetadata?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Include source location
|
|
206
|
+
* @default false
|
|
207
|
+
*/
|
|
208
|
+
includeSource?: boolean;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Component props extraction result
|
|
212
|
+
*/
|
|
213
|
+
export interface PropsExtractionResult {
|
|
214
|
+
/**
|
|
215
|
+
* Whether extraction was successful
|
|
216
|
+
*/
|
|
217
|
+
success: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Extracted props
|
|
220
|
+
*/
|
|
221
|
+
props?: Record<string, unknown>;
|
|
222
|
+
/**
|
|
223
|
+
* Props that were filtered out (internal, private, etc.)
|
|
224
|
+
*/
|
|
225
|
+
filteredKeys?: string[];
|
|
226
|
+
/**
|
|
227
|
+
* Error if extraction failed
|
|
228
|
+
*/
|
|
229
|
+
error?: Error;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Component state extraction result
|
|
233
|
+
*/
|
|
234
|
+
export interface StateExtractionResult {
|
|
235
|
+
/**
|
|
236
|
+
* Whether extraction was successful
|
|
237
|
+
*/
|
|
238
|
+
success: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Extracted state
|
|
241
|
+
*/
|
|
242
|
+
state?: Record<string, unknown>;
|
|
243
|
+
/**
|
|
244
|
+
* Whether this is a class component state or hooks state
|
|
245
|
+
*/
|
|
246
|
+
stateType: 'class' | 'hooks' | 'none';
|
|
247
|
+
/**
|
|
248
|
+
* Parsed hooks (if function component)
|
|
249
|
+
*/
|
|
250
|
+
hooks?: unknown[];
|
|
251
|
+
/**
|
|
252
|
+
* Error if extraction failed
|
|
253
|
+
*/
|
|
254
|
+
error?: Error;
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/domscribe-react/src/component/types.ts"],"names":[],"mappings":"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"}
|