@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.
Files changed (59) hide show
  1. package/adapter/react-adapter.d.ts +121 -0
  2. package/adapter/react-adapter.d.ts.map +1 -0
  3. package/adapter/react-adapter.js +486 -0
  4. package/adapter/types.d.ts +131 -0
  5. package/adapter/types.d.ts.map +1 -0
  6. package/adapter/types.js +17 -0
  7. package/auto-init.d.ts +2 -0
  8. package/auto-init.d.ts.map +1 -0
  9. package/auto-init.js +40 -0
  10. package/component/component-name-resolver.d.ts +118 -0
  11. package/component/component-name-resolver.d.ts.map +1 -0
  12. package/component/component-name-resolver.js +361 -0
  13. package/component/props-extractor.d.ts +51 -0
  14. package/component/props-extractor.d.ts.map +1 -0
  15. package/component/props-extractor.js +122 -0
  16. package/component/state-extractor.d.ts +60 -0
  17. package/component/state-extractor.d.ts.map +1 -0
  18. package/component/state-extractor.js +162 -0
  19. package/component/types.d.ts +256 -0
  20. package/component/types.d.ts.map +1 -0
  21. package/component/types.js +5 -0
  22. package/errors/index.d.ts +36 -0
  23. package/errors/index.d.ts.map +1 -0
  24. package/errors/index.js +75 -0
  25. package/fiber/fiber-walker.d.ts +58 -0
  26. package/fiber/fiber-walker.d.ts.map +1 -0
  27. package/fiber/fiber-walker.js +118 -0
  28. package/fiber/types.d.ts +162 -0
  29. package/fiber/types.d.ts.map +1 -0
  30. package/fiber/types.js +32 -0
  31. package/index.d.ts +14 -0
  32. package/index.d.ts.map +1 -0
  33. package/index.js +15 -0
  34. package/package.json +59 -0
  35. package/tsconfig.tsbuildinfo +1 -0
  36. package/utils/constants.d.ts +94 -0
  37. package/utils/constants.d.ts.map +1 -0
  38. package/utils/constants.js +123 -0
  39. package/utils/type-guards.d.ts +31 -0
  40. package/utils/type-guards.d.ts.map +1 -0
  41. package/utils/type-guards.js +89 -0
  42. package/utils/types.d.ts +6 -0
  43. package/utils/types.d.ts.map +1 -0
  44. package/utils/types.js +5 -0
  45. package/vite/index.d.ts +7 -0
  46. package/vite/index.d.ts.map +1 -0
  47. package/vite/index.js +5 -0
  48. package/vite/types.d.ts +56 -0
  49. package/vite/types.d.ts.map +1 -0
  50. package/vite/types.js +10 -0
  51. package/vite/vite-plugin.d.ts +29 -0
  52. package/vite/vite-plugin.d.ts.map +1 -0
  53. package/vite/vite-plugin.js +104 -0
  54. package/webpack/index.d.ts +7 -0
  55. package/webpack/index.d.ts.map +1 -0
  56. package/webpack/index.js +5 -0
  57. package/webpack/webpack-plugin.d.ts +50 -0
  58. package/webpack/webpack-plugin.d.ts.map +1 -0
  59. package/webpack/webpack-plugin.js +63 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * React adapter-specific error classes
3
+ * @module @domscribe/react/errors
4
+ */
5
+ import { DomscribeError } from '@domscribe/core';
6
+ /**
7
+ * Error thrown when accessing React Fiber fails
8
+ */
9
+ export declare class FiberAccessError extends DomscribeError {
10
+ constructor(message: string, cause?: Error);
11
+ }
12
+ /**
13
+ * Error thrown when component resolution fails
14
+ */
15
+ export declare class ComponentResolutionError extends DomscribeError {
16
+ constructor(message: string, cause?: Error);
17
+ }
18
+ /**
19
+ * Error thrown when component name resolution fails
20
+ */
21
+ export declare class NameResolutionError extends DomscribeError {
22
+ constructor(message: string, cause?: Error);
23
+ }
24
+ /**
25
+ * Error thrown when props extraction fails
26
+ */
27
+ export declare class PropsExtractionError extends DomscribeError {
28
+ constructor(message: string, cause?: Error);
29
+ }
30
+ /**
31
+ * Error thrown when state extraction fails
32
+ */
33
+ export declare class StateExtractionError extends DomscribeError {
34
+ constructor(message: string, cause?: Error);
35
+ }
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/domscribe-react/src/errors/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAsB,MAAM,iBAAiB,CAAC;AAErE;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;gBACtC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAS3C;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,cAAc;gBAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAS3C;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAS3C;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,cAAc;gBAC1C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAS3C;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,cAAc;gBAC1C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAS3C"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * React adapter-specific error classes
3
+ * @module @domscribe/react/errors
4
+ */
5
+ import { DomscribeError, DomscribeErrorCode } from '@domscribe/core';
6
+ /**
7
+ * Error thrown when accessing React Fiber fails
8
+ */
9
+ export class FiberAccessError extends DomscribeError {
10
+ constructor(message, cause) {
11
+ super({
12
+ code: DomscribeErrorCode.DS_INTERNAL_ERROR,
13
+ title: `Fiber access failed: ${message}`,
14
+ detail: cause?.message,
15
+ status: 500,
16
+ });
17
+ this.name = 'FiberAccessError';
18
+ }
19
+ }
20
+ /**
21
+ * Error thrown when component resolution fails
22
+ */
23
+ export class ComponentResolutionError extends DomscribeError {
24
+ constructor(message, cause) {
25
+ super({
26
+ code: DomscribeErrorCode.DS_INTERNAL_ERROR,
27
+ title: `Component resolution failed: ${message}`,
28
+ detail: cause?.message,
29
+ status: 500,
30
+ });
31
+ this.name = 'ComponentResolutionError';
32
+ }
33
+ }
34
+ /**
35
+ * Error thrown when component name resolution fails
36
+ */
37
+ export class NameResolutionError extends DomscribeError {
38
+ constructor(message, cause) {
39
+ super({
40
+ code: DomscribeErrorCode.DS_INTERNAL_ERROR,
41
+ title: `Component name resolution failed: ${message}`,
42
+ detail: cause?.message,
43
+ status: 500,
44
+ });
45
+ this.name = 'NameResolutionError';
46
+ }
47
+ }
48
+ /**
49
+ * Error thrown when props extraction fails
50
+ */
51
+ export class PropsExtractionError extends DomscribeError {
52
+ constructor(message, cause) {
53
+ super({
54
+ code: DomscribeErrorCode.DS_INTERNAL_ERROR,
55
+ title: `Props extraction failed: ${message}`,
56
+ detail: cause?.message,
57
+ status: 500,
58
+ });
59
+ this.name = 'PropsExtractionError';
60
+ }
61
+ }
62
+ /**
63
+ * Error thrown when state extraction fails
64
+ */
65
+ export class StateExtractionError extends DomscribeError {
66
+ constructor(message, cause) {
67
+ super({
68
+ code: DomscribeErrorCode.DS_INTERNAL_ERROR,
69
+ title: `State extraction failed: ${message}`,
70
+ detail: cause?.message,
71
+ status: 500,
72
+ });
73
+ this.name = 'StateExtractionError';
74
+ }
75
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * FiberWalker - Navigate the React Fiber tree safely
3
+ *
4
+ * Provides utilities for traversing the React Fiber tree structure,
5
+ * finding specific nodes, and analyzing relationships between fibers.
6
+ *
7
+ * @module @domscribe/react/fiber/fiber-walker
8
+ */
9
+ import type { ExtendedReactFiber, FiberWalkOptions } from './types.js';
10
+ /**
11
+ * FiberWalker class for navigating the React Fiber tree
12
+ */
13
+ export declare class FiberWalker {
14
+ private readonly maxDepth;
15
+ constructor(options?: {
16
+ maxDepth?: number;
17
+ });
18
+ /**
19
+ * Find nearest component fiber (walking up the tree)
20
+ *
21
+ * @param fiber - Starting fiber node
22
+ * @returns Nearest component fiber or null
23
+ */
24
+ findNearestComponentFiber(fiber: ExtendedReactFiber): ExtendedReactFiber | null;
25
+ /**
26
+ * Get all child fibers
27
+ *
28
+ * @param fiber - Parent fiber node
29
+ * @param options - Walk options
30
+ * @returns Array of child fibers
31
+ */
32
+ getChildren(fiber: ExtendedReactFiber, options?: FiberWalkOptions): ExtendedReactFiber[];
33
+ /**
34
+ * Walk up the Fiber tree from a starting fiber
35
+ */
36
+ private walkUp;
37
+ /**
38
+ * Check if a fiber should be included based on options
39
+ */
40
+ private shouldIncludeFiber;
41
+ /**
42
+ * Check if a fiber is a component (not host/text)
43
+ */
44
+ private isComponentFiber;
45
+ /**
46
+ * Check if a fiber is a host component (DOM element)
47
+ */
48
+ private isHostComponent;
49
+ /**
50
+ * Check if a fiber is a text node
51
+ */
52
+ private isTextNode;
53
+ /**
54
+ * Check if a fiber is a system component
55
+ */
56
+ private isSystemComponent;
57
+ }
58
+ //# sourceMappingURL=fiber-walker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fiber-walker.d.ts","sourceRoot":"","sources":["../../../../packages/domscribe-react/src/fiber/fiber-walker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGvE;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;IAI3C;;;;;OAKG;IACH,yBAAyB,CACvB,KAAK,EAAE,kBAAkB,GACxB,kBAAkB,GAAG,IAAI;IAI5B;;;;;;OAMG;IACH,WAAW,CACT,KAAK,EAAE,kBAAkB,EACzB,OAAO,CAAC,EAAE,gBAAgB,GACzB,kBAAkB,EAAE;IAgBvB;;OAEG;IACH,OAAO,CAAC,MAAM;IAmBd;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAyB1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAc1B"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * FiberWalker - Navigate the React Fiber tree safely
3
+ *
4
+ * Provides utilities for traversing the React Fiber tree structure,
5
+ * finding specific nodes, and analyzing relationships between fibers.
6
+ *
7
+ * @module @domscribe/react/fiber/fiber-walker
8
+ */
9
+ import { DEFAULT_OPTIONS, REACT_FIBER_TAGS } from '../utils/constants.js';
10
+ /**
11
+ * FiberWalker class for navigating the React Fiber tree
12
+ */
13
+ export class FiberWalker {
14
+ maxDepth;
15
+ constructor(options) {
16
+ this.maxDepth = options?.maxDepth ?? DEFAULT_OPTIONS.MAX_TREE_DEPTH;
17
+ }
18
+ /**
19
+ * Find nearest component fiber (walking up the tree)
20
+ *
21
+ * @param fiber - Starting fiber node
22
+ * @returns Nearest component fiber or null
23
+ */
24
+ findNearestComponentFiber(fiber) {
25
+ return this.walkUp(fiber, (f) => this.isComponentFiber(f));
26
+ }
27
+ /**
28
+ * Get all child fibers
29
+ *
30
+ * @param fiber - Parent fiber node
31
+ * @param options - Walk options
32
+ * @returns Array of child fibers
33
+ */
34
+ getChildren(fiber, options) {
35
+ const children = [];
36
+ let child = fiber.child;
37
+ while (child) {
38
+ if (this.shouldIncludeFiber(child, options)) {
39
+ children.push(child);
40
+ }
41
+ child = child.sibling;
42
+ }
43
+ return children;
44
+ }
45
+ // Private helpers
46
+ /**
47
+ * Walk up the Fiber tree from a starting fiber
48
+ */
49
+ walkUp(fiber, predicate) {
50
+ let current = fiber;
51
+ let depth = 0;
52
+ while (current && depth < this.maxDepth) {
53
+ if (predicate(current)) {
54
+ return current;
55
+ }
56
+ current = current.return;
57
+ depth++;
58
+ }
59
+ return null;
60
+ }
61
+ /**
62
+ * Check if a fiber should be included based on options
63
+ */
64
+ shouldIncludeFiber(fiber, options) {
65
+ // Apply custom filter if provided
66
+ if (options?.filter && !options.filter(fiber)) {
67
+ return false;
68
+ }
69
+ // Check fiber type inclusions
70
+ if (!options?.includeHost && this.isHostComponent(fiber)) {
71
+ return false;
72
+ }
73
+ if (!options?.includeText && this.isTextNode(fiber)) {
74
+ return false;
75
+ }
76
+ if (!options?.includeSystem && this.isSystemComponent(fiber)) {
77
+ return false;
78
+ }
79
+ return true;
80
+ }
81
+ /**
82
+ * Check if a fiber is a component (not host/text)
83
+ */
84
+ isComponentFiber(fiber) {
85
+ return (fiber.tag === REACT_FIBER_TAGS.FunctionComponent ||
86
+ fiber.tag === REACT_FIBER_TAGS.ClassComponent ||
87
+ fiber.tag === REACT_FIBER_TAGS.ForwardRef ||
88
+ fiber.tag === REACT_FIBER_TAGS.MemoComponent ||
89
+ fiber.tag === REACT_FIBER_TAGS.SimpleMemoComponent);
90
+ }
91
+ /**
92
+ * Check if a fiber is a host component (DOM element)
93
+ */
94
+ isHostComponent(fiber) {
95
+ return fiber.tag === REACT_FIBER_TAGS.HostComponent;
96
+ }
97
+ /**
98
+ * Check if a fiber is a text node
99
+ */
100
+ isTextNode(fiber) {
101
+ return fiber.tag === REACT_FIBER_TAGS.HostText;
102
+ }
103
+ /**
104
+ * Check if a fiber is a system component
105
+ */
106
+ isSystemComponent(fiber) {
107
+ return (fiber.tag === REACT_FIBER_TAGS.Mode ||
108
+ fiber.tag === REACT_FIBER_TAGS.ContextConsumer ||
109
+ fiber.tag === REACT_FIBER_TAGS.ContextProvider ||
110
+ fiber.tag === REACT_FIBER_TAGS.Profiler ||
111
+ fiber.tag === REACT_FIBER_TAGS.SuspenseComponent ||
112
+ fiber.tag === REACT_FIBER_TAGS.SuspenseListComponent ||
113
+ fiber.tag === REACT_FIBER_TAGS.OffscreenComponent ||
114
+ fiber.tag === REACT_FIBER_TAGS.LegacyHiddenComponent ||
115
+ fiber.tag === REACT_FIBER_TAGS.CacheComponent ||
116
+ fiber.tag === REACT_FIBER_TAGS.TracingMarkerComponent);
117
+ }
118
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * React Fiber type definitions
3
+ * @module @domscribe/react/fiber/types
4
+ */
5
+ /**
6
+ * Component category classification
7
+ */
8
+ export declare enum ComponentCategory {
9
+ /** User-defined function component */
10
+ USER_FUNCTION = "user-function",
11
+ /** User-defined class component */
12
+ USER_CLASS = "user-class",
13
+ /** Higher Order Component wrapper */
14
+ HOC = "hoc",
15
+ /** React.memo wrapper */
16
+ MEMO = "memo",
17
+ /** React.forwardRef wrapper */
18
+ FORWARD_REF = "forward-ref",
19
+ /** React.lazy wrapper */
20
+ LAZY = "lazy",
21
+ /** React internal component (Suspense, Profiler, etc.) */
22
+ SYSTEM = "system",
23
+ /** Host component (DOM element like div, span) */
24
+ HOST = "host",
25
+ /** Text node */
26
+ TEXT = "text",
27
+ /** Fragment */
28
+ FRAGMENT = "fragment",
29
+ /** Unknown or unclassified */
30
+ UNKNOWN = "unknown"
31
+ }
32
+ /**
33
+ * Extended React Fiber node with comprehensive type information
34
+ *
35
+ * Based on React's internal Fiber structure but enhanced for our needs.
36
+ * This extends the basic ReactFiber from @domscribe/runtime/devtools/types.
37
+ */
38
+ export interface ExtendedReactFiber {
39
+ /**
40
+ * Fiber tag (identifies the type of fiber)
41
+ */
42
+ tag: number;
43
+ /**
44
+ * The resolved type of this element
45
+ */
46
+ type?: unknown;
47
+ /**
48
+ * Component key for reconciliation
49
+ */
50
+ key?: string | null;
51
+ /**
52
+ * Current props
53
+ */
54
+ memoizedProps?: Record<string, unknown>;
55
+ /**
56
+ * Pending props (for updates)
57
+ */
58
+ pendingProps?: Record<string, unknown>;
59
+ /**
60
+ * Current state (or hook chain for function components)
61
+ */
62
+ memoizedState?: unknown;
63
+ /**
64
+ * Dependencies for memoization
65
+ */
66
+ dependencies?: unknown;
67
+ /**
68
+ * The actual DOM node or component instance
69
+ */
70
+ stateNode?: unknown;
71
+ /**
72
+ * Parent fiber
73
+ */
74
+ return?: ExtendedReactFiber;
75
+ /**
76
+ * First child fiber
77
+ */
78
+ child?: ExtendedReactFiber;
79
+ /**
80
+ * Next sibling fiber
81
+ */
82
+ sibling?: ExtendedReactFiber;
83
+ /**
84
+ * Index within parent's children
85
+ */
86
+ index?: number;
87
+ /**
88
+ * Ref object or callback
89
+ */
90
+ ref?: unknown;
91
+ /**
92
+ * Effect flags (side effects to perform)
93
+ */
94
+ flags?: number;
95
+ /**
96
+ * Subtree flags (effects in subtree)
97
+ */
98
+ subtreeFlags?: number;
99
+ /**
100
+ * Alternate fiber (work in progress vs current)
101
+ */
102
+ alternate?: ExtendedReactFiber;
103
+ /**
104
+ * Element type (for debugging)
105
+ */
106
+ elementType?: unknown;
107
+ /**
108
+ * Owner fiber (component that created this element)
109
+ */
110
+ _debugOwner?: ExtendedReactFiber;
111
+ /**
112
+ * Debug source location
113
+ */
114
+ _debugSource?: {
115
+ fileName?: string;
116
+ lineNumber?: number;
117
+ columnNumber?: number;
118
+ };
119
+ /**
120
+ * Component name (for debugging)
121
+ */
122
+ _debugHookTypes?: string[];
123
+ /**
124
+ * React DevTools extension data
125
+ */
126
+ _debugID?: number;
127
+ }
128
+ /**
129
+ * Options for Fiber tree walking
130
+ */
131
+ export interface FiberWalkOptions {
132
+ /**
133
+ * Maximum depth to traverse
134
+ * @default 50
135
+ */
136
+ maxDepth?: number;
137
+ /**
138
+ * Include host components (DOM elements)
139
+ * @default false
140
+ */
141
+ includeHost?: boolean;
142
+ /**
143
+ * Include text nodes
144
+ * @default false
145
+ */
146
+ includeText?: boolean;
147
+ /**
148
+ * Include React system components (Suspense, Profiler, etc.)
149
+ * @default false
150
+ */
151
+ includeSystem?: boolean;
152
+ /**
153
+ * Walk direction: 'up' (ancestors), 'down' (descendants), or 'siblings'
154
+ * @default 'up'
155
+ */
156
+ direction?: 'up' | 'down' | 'siblings';
157
+ /**
158
+ * Predicate function to filter fibers
159
+ */
160
+ filter?: (fiber: ExtendedReactFiber) => boolean;
161
+ }
162
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/domscribe-react/src/fiber/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,sCAAsC;IACtC,aAAa,kBAAkB;IAE/B,mCAAmC;IACnC,UAAU,eAAe;IAEzB,qCAAqC;IACrC,GAAG,QAAQ;IAEX,yBAAyB;IACzB,IAAI,SAAS;IAEb,+BAA+B;IAC/B,WAAW,gBAAgB;IAE3B,yBAAyB;IACzB,IAAI,SAAS;IAEb,0DAA0D;IAC1D,MAAM,WAAW;IAEjB,kDAAkD;IAClD,IAAI,SAAS;IAEb,gBAAgB;IAChB,IAAI,SAAS;IAEb,eAAe;IACf,QAAQ,aAAa;IAErB,8BAA8B;IAC9B,OAAO,YAAY;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAExC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAE5B;;OAEG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAE7B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAE/B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAEjC;;OAEG;IACH,YAAY,CAAC,EAAE;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC;IAEvC;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,OAAO,CAAC;CACjD"}
package/fiber/types.js ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * React Fiber type definitions
3
+ * @module @domscribe/react/fiber/types
4
+ */
5
+ /**
6
+ * Component category classification
7
+ */
8
+ export var ComponentCategory;
9
+ (function (ComponentCategory) {
10
+ /** User-defined function component */
11
+ ComponentCategory["USER_FUNCTION"] = "user-function";
12
+ /** User-defined class component */
13
+ ComponentCategory["USER_CLASS"] = "user-class";
14
+ /** Higher Order Component wrapper */
15
+ ComponentCategory["HOC"] = "hoc";
16
+ /** React.memo wrapper */
17
+ ComponentCategory["MEMO"] = "memo";
18
+ /** React.forwardRef wrapper */
19
+ ComponentCategory["FORWARD_REF"] = "forward-ref";
20
+ /** React.lazy wrapper */
21
+ ComponentCategory["LAZY"] = "lazy";
22
+ /** React internal component (Suspense, Profiler, etc.) */
23
+ ComponentCategory["SYSTEM"] = "system";
24
+ /** Host component (DOM element like div, span) */
25
+ ComponentCategory["HOST"] = "host";
26
+ /** Text node */
27
+ ComponentCategory["TEXT"] = "text";
28
+ /** Fragment */
29
+ ComponentCategory["FRAGMENT"] = "fragment";
30
+ /** Unknown or unclassified */
31
+ ComponentCategory["UNKNOWN"] = "unknown";
32
+ })(ComponentCategory || (ComponentCategory = {}));
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @domscribe/react - React framework adapter for Domscribe
3
+ *
4
+ * Provides runtime context capture for React applications, including:
5
+ * - Props and state extraction
6
+ * - Component name resolution
7
+ * - Fiber tree traversal
8
+ *
9
+ * @module @domscribe/react
10
+ */
11
+ export { ReactAdapter, createReactAdapter } from './adapter/react-adapter.js';
12
+ export type { ReactAdapterOptions, ReactFrameworkAdapter, } from './adapter/types.js';
13
+ export { CaptureStrategy } from './adapter/types.js';
14
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/domscribe-react/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAK9E,YAAY,EACV,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @domscribe/react - React framework adapter for Domscribe
3
+ *
4
+ * Provides runtime context capture for React applications, including:
5
+ * - Props and state extraction
6
+ * - Component name resolution
7
+ * - Fiber tree traversal
8
+ *
9
+ * @module @domscribe/react
10
+ */
11
+ // ============================================================================
12
+ // Adapter
13
+ // ============================================================================
14
+ export { ReactAdapter, createReactAdapter } from './adapter/react-adapter.js';
15
+ export { CaptureStrategy } from './adapter/types.js';
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@domscribe/react",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "src/index.ts",
6
+ "publishConfig": {
7
+ "access": "restricted"
8
+ },
9
+ "dependencies": {
10
+ "@domscribe/core": "0.1.0",
11
+ "@domscribe/runtime": "0.1.0",
12
+ "@domscribe/transform": "0.1.0"
13
+ },
14
+ "devDependencies": {
15
+ "@types/react": "^18.2.0",
16
+ "@types/webpack": "^5.28.5",
17
+ "happy-dom": "^12.0.0",
18
+ "react": "^18.2.0",
19
+ "webpack": "^5.102.0"
20
+ },
21
+ "peerDependencies": {
22
+ "react": ">=16.8.0",
23
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
24
+ "webpack": "^5.0.0"
25
+ },
26
+ "peerDependenciesMeta": {
27
+ "vite": {
28
+ "optional": true
29
+ },
30
+ "webpack": {
31
+ "optional": true
32
+ }
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "types": "./index.d.ts",
37
+ "import": "./index.js",
38
+ "default": "./index.js"
39
+ },
40
+ "./vite": {
41
+ "types": "./vite/index.d.ts",
42
+ "import": "./vite/index.js",
43
+ "default": "./vite/index.js"
44
+ },
45
+ "./webpack": {
46
+ "types": "./webpack/index.d.ts",
47
+ "import": "./webpack/index.js",
48
+ "default": "./webpack/index.js"
49
+ },
50
+ "./auto-init": {
51
+ "types": "./auto-init.d.ts",
52
+ "import": "./auto-init.js",
53
+ "default": "./auto-init.js"
54
+ },
55
+ "./package.json": "./package.json"
56
+ },
57
+ "types": "./index.d.ts",
58
+ "module": "./index.js"
59
+ }
@@ -0,0 +1 @@
1
+ {"version":"5.9.3"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * React constants and magic numbers
3
+ * @module @domscribe/react/utils/constants
4
+ */
5
+ /**
6
+ * React Fiber tags
7
+ *
8
+ * These are internal constants used by React to identify different types of Fiber nodes.
9
+ * Based on React's ReactWorkTags.js (values may vary slightly across React versions)
10
+ *
11
+ * @see https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactWorkTags.js
12
+ */
13
+ export declare const REACT_FIBER_TAGS: {
14
+ readonly FunctionComponent: 0;
15
+ readonly ClassComponent: 1;
16
+ readonly IndeterminateComponent: 2;
17
+ readonly HostRoot: 3;
18
+ readonly HostPortal: 4;
19
+ readonly HostComponent: 5;
20
+ readonly HostText: 6;
21
+ readonly Fragment: 7;
22
+ readonly Mode: 8;
23
+ readonly ContextConsumer: 9;
24
+ readonly ContextProvider: 10;
25
+ readonly ForwardRef: 11;
26
+ readonly Profiler: 12;
27
+ readonly SuspenseComponent: 13;
28
+ readonly MemoComponent: 14;
29
+ readonly SimpleMemoComponent: 15;
30
+ readonly LazyComponent: 16;
31
+ readonly IncompleteClassComponent: 17;
32
+ readonly DehydratedFragment: 18;
33
+ readonly SuspenseListComponent: 19;
34
+ readonly ScopeComponent: 21;
35
+ readonly OffscreenComponent: 22;
36
+ readonly LegacyHiddenComponent: 23;
37
+ readonly CacheComponent: 24;
38
+ readonly TracingMarkerComponent: 25;
39
+ };
40
+ /**
41
+ * React internal props to exclude from capture
42
+ *
43
+ * These props are internal to React and should not be included in captured props
44
+ */
45
+ export declare const REACT_INTERNAL_PROPS: Set<string>;
46
+ /**
47
+ * Common HOC (Higher Order Component) patterns
48
+ *
49
+ * Used to detect and unwrap HOC wrappers to find the underlying component
50
+ */
51
+ export declare const COMMON_HOC_PATTERNS: string[];
52
+ /**
53
+ * Default options for various operations
54
+ */
55
+ export declare const DEFAULT_OPTIONS: {
56
+ /**
57
+ * Default maximum tree depth
58
+ */
59
+ readonly MAX_TREE_DEPTH: 50;
60
+ /**
61
+ * Default maximum hooks to parse
62
+ */
63
+ readonly MAX_HOOKS: 100;
64
+ /**
65
+ * Default maximum wrapper depth
66
+ */
67
+ readonly MAX_WRAPPER_DEPTH: 3;
68
+ /**
69
+ * Default capture strategy
70
+ */
71
+ readonly CAPTURE_STRATEGY: "best-effort";
72
+ /**
73
+ * Default fallback component name
74
+ */
75
+ readonly FALLBACK_COMPONENT_NAME: "Anonymous";
76
+ /**
77
+ * Default hook name prefix
78
+ */
79
+ readonly HOOK_NAME_PREFIX: "hook_";
80
+ };
81
+ /**
82
+ * React element keys (different across React versions)
83
+ */
84
+ export declare const REACT_ELEMENT_KEYS: {
85
+ readonly FIBER_16: "__reactInternalInstance";
86
+ readonly FIBER_17_18: "__reactFiber";
87
+ readonly PROPS_16: "__reactEventHandlers";
88
+ readonly PROPS_17_18: "__reactProps";
89
+ };
90
+ /**
91
+ * DevTools global hook key
92
+ */
93
+ export declare const DEVTOOLS_HOOK_KEY = "__REACT_DEVTOOLS_GLOBAL_HOOK__";
94
+ //# sourceMappingURL=constants.d.ts.map