dynim-core 1.0.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 (86) hide show
  1. package/README.md +290 -0
  2. package/dist/builder/ai-prompt-popover.d.ts +26 -0
  3. package/dist/builder/ai-prompt-popover.d.ts.map +1 -0
  4. package/dist/builder/ai-prompt-popover.js +180 -0
  5. package/dist/builder/builder-client.d.ts +48 -0
  6. package/dist/builder/builder-client.d.ts.map +1 -0
  7. package/dist/builder/builder-client.js +157 -0
  8. package/dist/builder/builder.d.ts +41 -0
  9. package/dist/builder/builder.d.ts.map +1 -0
  10. package/dist/builder/builder.js +537 -0
  11. package/dist/builder/bundle-manager.d.ts +60 -0
  12. package/dist/builder/bundle-manager.d.ts.map +1 -0
  13. package/dist/builder/bundle-manager.js +357 -0
  14. package/dist/builder/classifier/classname-analyzer.d.ts +6 -0
  15. package/dist/builder/classifier/classname-analyzer.d.ts.map +1 -0
  16. package/dist/builder/classifier/classname-analyzer.js +107 -0
  17. package/dist/builder/classifier/index.d.ts +20 -0
  18. package/dist/builder/classifier/index.d.ts.map +1 -0
  19. package/dist/builder/classifier/index.js +181 -0
  20. package/dist/builder/classifier/semantic-analyzer.d.ts +24 -0
  21. package/dist/builder/classifier/semantic-analyzer.d.ts.map +1 -0
  22. package/dist/builder/classifier/semantic-analyzer.js +94 -0
  23. package/dist/builder/classifier/size-analyzer.d.ts +7 -0
  24. package/dist/builder/classifier/size-analyzer.d.ts.map +1 -0
  25. package/dist/builder/classifier/size-analyzer.js +120 -0
  26. package/dist/builder/classifier/visual-analyzer.d.ts +6 -0
  27. package/dist/builder/classifier/visual-analyzer.d.ts.map +1 -0
  28. package/dist/builder/classifier/visual-analyzer.js +158 -0
  29. package/dist/builder/client.d.ts +22 -0
  30. package/dist/builder/client.d.ts.map +1 -0
  31. package/dist/builder/client.js +54 -0
  32. package/dist/builder/code-client.d.ts +101 -0
  33. package/dist/builder/code-client.d.ts.map +1 -0
  34. package/dist/builder/code-client.js +418 -0
  35. package/dist/builder/diff-state.d.ts +24 -0
  36. package/dist/builder/diff-state.d.ts.map +1 -0
  37. package/dist/builder/diff-state.js +134 -0
  38. package/dist/builder/dom-scanner.d.ts +20 -0
  39. package/dist/builder/dom-scanner.d.ts.map +1 -0
  40. package/dist/builder/dom-scanner.js +102 -0
  41. package/dist/builder/drag-engine.d.ts +41 -0
  42. package/dist/builder/drag-engine.d.ts.map +1 -0
  43. package/dist/builder/drag-engine.js +686 -0
  44. package/dist/builder/editor-overlays.d.ts +31 -0
  45. package/dist/builder/editor-overlays.d.ts.map +1 -0
  46. package/dist/builder/editor-overlays.js +202 -0
  47. package/dist/builder/editor-state.d.ts +50 -0
  48. package/dist/builder/editor-state.d.ts.map +1 -0
  49. package/dist/builder/editor-state.js +132 -0
  50. package/dist/builder/element-utils.d.ts +43 -0
  51. package/dist/builder/element-utils.d.ts.map +1 -0
  52. package/dist/builder/element-utils.js +227 -0
  53. package/dist/builder/fiber-capture.d.ts +28 -0
  54. package/dist/builder/fiber-capture.d.ts.map +1 -0
  55. package/dist/builder/fiber-capture.js +264 -0
  56. package/dist/builder/freeze-overlay.d.ts +26 -0
  57. package/dist/builder/freeze-overlay.d.ts.map +1 -0
  58. package/dist/builder/freeze-overlay.js +213 -0
  59. package/dist/builder/history-state.d.ts +41 -0
  60. package/dist/builder/history-state.d.ts.map +1 -0
  61. package/dist/builder/history-state.js +76 -0
  62. package/dist/builder/index.d.ts +62 -0
  63. package/dist/builder/index.d.ts.map +1 -0
  64. package/dist/builder/index.js +92 -0
  65. package/dist/builder/state.d.ts +27 -0
  66. package/dist/builder/state.d.ts.map +1 -0
  67. package/dist/builder/state.js +50 -0
  68. package/dist/builder/style-applier.d.ts +61 -0
  69. package/dist/builder/style-applier.d.ts.map +1 -0
  70. package/dist/builder/style-applier.js +311 -0
  71. package/dist/builder/tree-state.d.ts +71 -0
  72. package/dist/builder/tree-state.d.ts.map +1 -0
  73. package/dist/builder/tree-state.js +168 -0
  74. package/dist/builder/widget.d.ts +29 -0
  75. package/dist/builder/widget.d.ts.map +1 -0
  76. package/dist/builder/widget.js +181 -0
  77. package/dist/index.d.ts +11 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +12 -0
  80. package/package.json +25 -0
  81. package/src/styles/base.css +378 -0
  82. package/src/styles/builder.css +422 -0
  83. package/src/styles/editor.css +131 -0
  84. package/src/styles/themes/dark.css +24 -0
  85. package/src/styles/themes/light.css +21 -0
  86. package/src/styles/variables.css +63 -0
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Element utilities - Stable IDs and element identification
3
+ */
4
+ export const STABLE_ID_ATTR = 'data-sdesign-id';
5
+ export const VISIBILITY_ATTR = 'vis';
6
+ export function getVisibilityBoundary(element) {
7
+ let current = element;
8
+ while (current && current !== document.body) {
9
+ const visAttr = current.getAttribute(VISIBILITY_ATTR);
10
+ if (visAttr === 'false') {
11
+ return current;
12
+ }
13
+ if (visAttr === 'true') {
14
+ return null;
15
+ }
16
+ current = current.parentElement;
17
+ }
18
+ return null;
19
+ }
20
+ export function canDropInZone(sourceElement, targetElement) {
21
+ const sourceBoundary = getVisibilityBoundary(sourceElement);
22
+ const targetBoundary = getVisibilityBoundary(targetElement);
23
+ if (sourceBoundary !== null) {
24
+ return false;
25
+ }
26
+ if (targetBoundary !== null) {
27
+ return false;
28
+ }
29
+ return true;
30
+ }
31
+ function generateId(length = 10) {
32
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
33
+ let result = '';
34
+ for (let i = 0; i < length; i++) {
35
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
36
+ }
37
+ return result;
38
+ }
39
+ export function getStableId(element) {
40
+ const existingId = element.getAttribute(STABLE_ID_ATTR);
41
+ if (existingId) {
42
+ return existingId;
43
+ }
44
+ const newId = generateId(10);
45
+ element.setAttribute(STABLE_ID_ATTR, newId);
46
+ return newId;
47
+ }
48
+ export function findByStableId(id, root = document.body) {
49
+ return root.querySelector(`[${STABLE_ID_ATTR}="${id}"]`);
50
+ }
51
+ export function getDomPath(element, root) {
52
+ const path = [];
53
+ let current = element;
54
+ while (current && current !== root && current.parentElement) {
55
+ const parent = current.parentElement;
56
+ const index = Array.from(parent.children).indexOf(current);
57
+ path.unshift(index);
58
+ current = parent;
59
+ }
60
+ return path;
61
+ }
62
+ export function getElementAtPath(path, root) {
63
+ let current = root;
64
+ for (const index of path) {
65
+ if (!current || !current.children[index]) {
66
+ return null;
67
+ }
68
+ current = current.children[index];
69
+ }
70
+ return current;
71
+ }
72
+ export function getRelevantStyles(el) {
73
+ const cs = window.getComputedStyle(el);
74
+ const props = [
75
+ 'display', 'position', 'width', 'height',
76
+ 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft',
77
+ 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft',
78
+ 'backgroundColor', 'color',
79
+ 'borderWidth', 'borderStyle', 'borderColor', 'borderRadius',
80
+ 'boxShadow', 'opacity', 'zIndex', 'overflow',
81
+ 'flexDirection', 'justifyContent', 'alignItems', 'gap',
82
+ 'cursor'
83
+ ];
84
+ const styles = {};
85
+ for (const p of props) {
86
+ const kebabCase = p.replace(/([A-Z])/g, '-$1').toLowerCase();
87
+ const value = cs.getPropertyValue(kebabCase);
88
+ if (value)
89
+ styles[p] = value;
90
+ }
91
+ return styles;
92
+ }
93
+ export function serializeRect(rect) {
94
+ return {
95
+ x: rect.x,
96
+ y: rect.y,
97
+ width: rect.width,
98
+ height: rect.height,
99
+ top: rect.top,
100
+ right: rect.right,
101
+ bottom: rect.bottom,
102
+ left: rect.left
103
+ };
104
+ }
105
+ function getNthOfType(element) {
106
+ const parent = element.parentElement;
107
+ if (!parent)
108
+ return 1;
109
+ const tagName = element.tagName;
110
+ let index = 0;
111
+ for (const child of Array.from(parent.children)) {
112
+ if (child.tagName === tagName) {
113
+ index++;
114
+ if (child === element)
115
+ return index;
116
+ }
117
+ }
118
+ return index;
119
+ }
120
+ function getDirectTextContent(element) {
121
+ let text = '';
122
+ for (const node of Array.from(element.childNodes)) {
123
+ if (node.nodeType === Node.TEXT_NODE) {
124
+ text += node.textContent || '';
125
+ }
126
+ }
127
+ return text.trim();
128
+ }
129
+ function getAttributeHints(element) {
130
+ const hints = {};
131
+ const importantAttrs = ['href', 'src', 'name', 'type', 'role', 'aria-label', 'data-testid'];
132
+ for (const attr of importantAttrs) {
133
+ const value = element.getAttribute(attr);
134
+ if (value) {
135
+ hints[attr] = value;
136
+ }
137
+ }
138
+ for (const attr of Array.from(element.attributes)) {
139
+ if (attr.name.startsWith('data-') && !attr.name.startsWith('data-sdesign-')) {
140
+ hints[attr.name] = attr.value;
141
+ }
142
+ }
143
+ return hints;
144
+ }
145
+ export function buildElementIdentifier(element, maxDepth = 3) {
146
+ const identifier = {
147
+ tagName: element.tagName.toLowerCase(),
148
+ classes: Array.from(element.classList).filter(c => {
149
+ return !c.match(/^(hover:|focus:|active:|disabled:|sm:|md:|lg:|xl:|2xl:)/);
150
+ }),
151
+ nthOfType: getNthOfType(element),
152
+ attributeHints: getAttributeHints(element)
153
+ };
154
+ if (element.id) {
155
+ identifier.id = element.id;
156
+ }
157
+ const textContent = getDirectTextContent(element);
158
+ if (textContent) {
159
+ identifier.textContentPreview = textContent.slice(0, 50);
160
+ }
161
+ if (maxDepth > 0 && element.parentElement && element.parentElement !== document.body) {
162
+ identifier.parentIdentifier = buildElementIdentifier(element.parentElement, maxDepth - 1);
163
+ }
164
+ return identifier;
165
+ }
166
+ export function buildPlacementTarget(element) {
167
+ const parent = element.parentElement;
168
+ if (!parent)
169
+ return null;
170
+ const siblings = Array.from(parent.children);
171
+ const index = siblings.indexOf(element);
172
+ const parentStableId = getStableId(parent);
173
+ if (index === 0) {
174
+ return {
175
+ parent: buildElementIdentifier(parent),
176
+ parentStableId,
177
+ position: 'prepend'
178
+ };
179
+ }
180
+ else if (index === siblings.length - 1) {
181
+ return {
182
+ parent: buildElementIdentifier(parent),
183
+ parentStableId,
184
+ position: 'append'
185
+ };
186
+ }
187
+ else {
188
+ const prevSibling = siblings[index - 1];
189
+ return {
190
+ parent: buildElementIdentifier(parent),
191
+ parentStableId,
192
+ position: 'after',
193
+ referenceElement: buildElementIdentifier(prevSibling),
194
+ referenceStableId: getStableId(prevSibling)
195
+ };
196
+ }
197
+ }
198
+ const MAX_VISIBLE_CONTENT_SIZE = 10 * 1024; // 10KB limit
199
+ export function getVisibleContent() {
200
+ const text = [];
201
+ let totalSize = 0;
202
+ const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null);
203
+ while (walker.nextNode()) {
204
+ const node = walker.currentNode;
205
+ const el = node.parentElement;
206
+ if (!el)
207
+ continue;
208
+ const rect = el.getBoundingClientRect();
209
+ const style = getComputedStyle(el);
210
+ const inViewport = (rect.top < window.innerHeight &&
211
+ rect.bottom > 0 &&
212
+ rect.left < window.innerWidth &&
213
+ rect.right > 0);
214
+ const isVisible = (style.display !== 'none' &&
215
+ style.visibility !== 'hidden' &&
216
+ style.opacity !== '0');
217
+ const content = node.textContent?.trim();
218
+ if (inViewport && isVisible && content) {
219
+ if (totalSize + content.length > MAX_VISIBLE_CONTENT_SIZE) {
220
+ break;
221
+ }
222
+ text.push(content);
223
+ totalSize += content.length;
224
+ }
225
+ }
226
+ return text;
227
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * React Fiber Capture - Extracts React component tree with source code
3
+ * Works with any React app by accessing React's internal fiber structure
4
+ */
5
+ interface Fiber {
6
+ tag: number;
7
+ type: unknown;
8
+ memoizedProps?: Record<string, unknown>;
9
+ child?: Fiber;
10
+ sibling?: Fiber;
11
+ return?: Fiber;
12
+ }
13
+ interface ReactTreeNode {
14
+ type: string;
15
+ name: string;
16
+ source?: string;
17
+ props?: Record<string, unknown>;
18
+ children?: ReactTreeNode[];
19
+ }
20
+ export declare function getFiberFromDOM(domNode: HTMLElement): Fiber | null;
21
+ export declare function getFiberRoot(container: HTMLElement): Fiber | null;
22
+ export interface CaptureOptions {
23
+ maxDepth?: number;
24
+ includeSource?: boolean;
25
+ }
26
+ export declare function captureReactTree(rootElement: HTMLElement, options?: CaptureOptions): ReactTreeNode | null;
27
+ export {};
28
+ //# sourceMappingURL=fiber-capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fiber-capture.d.ts","sourceRoot":"","sources":["../../src/builder/fiber-capture.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,KAAK,GAAG,IAAI,CAQlE;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,WAAW,GAAG,KAAK,GAAG,IAAI,CASjE;AA+LD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,GAAE,cAAmB,GAAG,aAAa,GAAG,IAAI,CAiF7G"}
@@ -0,0 +1,264 @@
1
+ /**
2
+ * React Fiber Capture - Extracts React component tree with source code
3
+ * Works with any React app by accessing React's internal fiber structure
4
+ */
5
+ export function getFiberFromDOM(domNode) {
6
+ if (!domNode)
7
+ return null;
8
+ const fiberKey = Object.keys(domNode).find((key) => key.startsWith('__reactFiber$') || key.startsWith('__reactInternalInstance$'));
9
+ return fiberKey ? domNode[fiberKey] : null;
10
+ }
11
+ export function getFiberRoot(container) {
12
+ const fiber = getFiberFromDOM(container);
13
+ if (!fiber)
14
+ return null;
15
+ let current = fiber;
16
+ while (current.return) {
17
+ current = current.return;
18
+ }
19
+ return current;
20
+ }
21
+ function getFiberName(fiber) {
22
+ if (!fiber || !fiber.type)
23
+ return 'Unknown';
24
+ const { type } = fiber;
25
+ if (typeof type === 'string')
26
+ return type;
27
+ if (typeof type === 'function') {
28
+ return type.displayName ||
29
+ type.name || 'Anonymous';
30
+ }
31
+ const typeObj = type;
32
+ if (typeObj.$$typeof) {
33
+ const symbolString = typeObj.$$typeof.toString();
34
+ if (symbolString.includes('memo')) {
35
+ const innerType = typeObj.type;
36
+ if (typeof typeObj.type === 'function' && innerType) {
37
+ return `Memo(${innerType.displayName || innerType.name || 'Anonymous'})`;
38
+ }
39
+ return 'Memo';
40
+ }
41
+ if (symbolString.includes('forward_ref')) {
42
+ const render = typeObj.render;
43
+ if (typeof typeObj.render === 'function' && render) {
44
+ return `ForwardRef(${render.displayName || render.name || 'Anonymous'})`;
45
+ }
46
+ return 'ForwardRef';
47
+ }
48
+ if (symbolString.includes('context')) {
49
+ return typeObj.displayName || 'Context';
50
+ }
51
+ if (symbolString.includes('provider')) {
52
+ return typeObj._context?.displayName
53
+ ? `${typeObj._context.displayName}.Provider`
54
+ : 'Provider';
55
+ }
56
+ }
57
+ return typeObj.displayName ||
58
+ typeObj.name || 'Unknown';
59
+ }
60
+ function getFiberType(fiber) {
61
+ if (!fiber)
62
+ return 'other';
63
+ const { tag } = fiber;
64
+ if (tag === 5)
65
+ return 'host';
66
+ if (tag === 6)
67
+ return 'text';
68
+ if (tag === 0)
69
+ return 'function';
70
+ if (tag === 1)
71
+ return 'class';
72
+ if (tag === 7)
73
+ return 'fragment';
74
+ if (tag === 10 || tag === 9)
75
+ return 'context';
76
+ if (tag === 13)
77
+ return 'suspense';
78
+ if (tag === 14 || tag === 15)
79
+ return 'memo';
80
+ if (tag === 11)
81
+ return 'forward_ref';
82
+ return 'other';
83
+ }
84
+ function extractComponentSource(fiber) {
85
+ if (!fiber || !fiber.type)
86
+ return null;
87
+ const { type } = fiber;
88
+ try {
89
+ if (typeof type === 'function') {
90
+ const source = type.toString();
91
+ return source.length > 50000 ? source.slice(0, 50000) + '\n// ... (truncated)' : source;
92
+ }
93
+ const typeObj = type;
94
+ if (typeObj.$$typeof) {
95
+ const symbolString = typeObj.$$typeof.toString();
96
+ if (symbolString.includes('memo') && typeObj.type && typeof typeObj.type === 'function') {
97
+ const source = typeObj.type.toString();
98
+ return source.length > 50000 ? source.slice(0, 50000) + '\n// ... (truncated)' : source;
99
+ }
100
+ if (symbolString.includes('forward_ref') && typeObj.render && typeof typeObj.render === 'function') {
101
+ const source = typeObj.render.toString();
102
+ return source.length > 50000 ? source.slice(0, 50000) + '\n// ... (truncated)' : source;
103
+ }
104
+ }
105
+ if (typeObj.prototype && typeObj.prototype.isReactComponent) {
106
+ const source = type.toString();
107
+ return source.length > 50000 ? source.slice(0, 50000) + '\n// ... (truncated)' : source;
108
+ }
109
+ }
110
+ catch (e) {
111
+ return `[Error: ${e.message}]`;
112
+ }
113
+ return null;
114
+ }
115
+ function sanitizeValue(value, seen = new Set(), depth = 0, maxDepth = 5) {
116
+ if (value === null || value === undefined)
117
+ return value;
118
+ if (typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string') {
119
+ return value;
120
+ }
121
+ if (typeof value === 'function') {
122
+ return `[Function: ${value.name || 'anonymous'}]`;
123
+ }
124
+ if (typeof value === 'symbol') {
125
+ return `[Symbol: ${value.description || 'unknown'}]`;
126
+ }
127
+ if (depth >= maxDepth) {
128
+ return '[Max depth]';
129
+ }
130
+ if (value instanceof Element) {
131
+ return `[DOM: ${value.tagName.toLowerCase()}]`;
132
+ }
133
+ if (value && value.$$typeof) {
134
+ return `[ReactElement]`;
135
+ }
136
+ if (typeof value === 'object') {
137
+ if (seen.has(value))
138
+ return '[Circular]';
139
+ seen.add(value);
140
+ if (Array.isArray(value)) {
141
+ if (value.length > 20)
142
+ return `[Array: ${value.length} items]`;
143
+ return value.map((item) => sanitizeValue(item, seen, depth + 1, maxDepth));
144
+ }
145
+ const keys = Object.keys(value);
146
+ if (keys.length > 20)
147
+ return `[Object: ${keys.length} keys]`;
148
+ const result = {};
149
+ for (const key of keys) {
150
+ if (key.startsWith('_') || key.startsWith('$$'))
151
+ continue;
152
+ try {
153
+ result[key] = sanitizeValue(value[key], seen, depth + 1, maxDepth);
154
+ }
155
+ catch {
156
+ result[key] = '[Error]';
157
+ }
158
+ }
159
+ return result;
160
+ }
161
+ return String(value);
162
+ }
163
+ function findReactRoot(startElement) {
164
+ const selectors = ['#root', '#app', '#__next', '[data-reactroot]', '[data-dynim-capture-root]'];
165
+ for (const selector of selectors) {
166
+ const el = startElement.querySelector?.(selector) || document.querySelector(selector);
167
+ if (el) {
168
+ const fiber = getFiberFromDOM(el);
169
+ if (fiber) {
170
+ console.log('[FiberCapture] Found React root at:', selector);
171
+ return el;
172
+ }
173
+ if (el.firstElementChild) {
174
+ const childFiber = getFiberFromDOM(el.firstElementChild);
175
+ if (childFiber) {
176
+ console.log('[FiberCapture] Found React root at:', selector, '(first child)');
177
+ return el.firstElementChild;
178
+ }
179
+ }
180
+ }
181
+ }
182
+ const walker = document.createTreeWalker(startElement, NodeFilter.SHOW_ELEMENT, null);
183
+ let node = walker.nextNode();
184
+ while (node) {
185
+ const fiber = getFiberFromDOM(node);
186
+ if (fiber) {
187
+ console.log('[FiberCapture] Found React fiber on:', node.tagName, node.id || node.className);
188
+ return node;
189
+ }
190
+ node = walker.nextNode();
191
+ }
192
+ return null;
193
+ }
194
+ export function captureReactTree(rootElement, options = {}) {
195
+ const { maxDepth = 30, includeSource = true } = options;
196
+ const reactRoot = findReactRoot(rootElement);
197
+ if (!reactRoot) {
198
+ console.warn('[FiberCapture] No React root found in DOM');
199
+ return null;
200
+ }
201
+ const fiber = getFiberFromDOM(reactRoot);
202
+ if (!fiber) {
203
+ console.warn('[FiberCapture] No React fiber found on element');
204
+ return null;
205
+ }
206
+ const rootFiber = getFiberRoot(reactRoot);
207
+ if (!rootFiber) {
208
+ console.warn('[FiberCapture] Could not find fiber root');
209
+ return null;
210
+ }
211
+ function buildNode(currentFiber, depth) {
212
+ if (!currentFiber || depth > maxDepth)
213
+ return null;
214
+ const fiberType = getFiberType(currentFiber);
215
+ const name = getFiberName(currentFiber);
216
+ if (name.startsWith('[') || fiberType === 'text') {
217
+ if (currentFiber.child) {
218
+ return buildNode(currentFiber.child, depth);
219
+ }
220
+ return null;
221
+ }
222
+ const node = {
223
+ type: fiberType,
224
+ name,
225
+ };
226
+ if (includeSource && (fiberType === 'function' || fiberType === 'class' || fiberType === 'memo' || fiberType === 'forward_ref')) {
227
+ if (!name.includes('Provider') && !name.includes('Consumer') && !name.includes('Context') && name !== 'Unknown' && name !== 'Anonymous') {
228
+ const source = extractComponentSource(currentFiber);
229
+ if (source) {
230
+ node.source = source;
231
+ }
232
+ }
233
+ }
234
+ if (currentFiber.memoizedProps) {
235
+ const props = { ...currentFiber.memoizedProps };
236
+ delete props.children;
237
+ const sanitized = sanitizeValue(props);
238
+ if (sanitized && Object.keys(sanitized).length > 0) {
239
+ node.props = sanitized;
240
+ }
241
+ }
242
+ const children = [];
243
+ if (currentFiber.child) {
244
+ let childFiber = currentFiber.child;
245
+ while (childFiber) {
246
+ const childNode = buildNode(childFiber, depth + 1);
247
+ if (childNode) {
248
+ if (Array.isArray(childNode)) {
249
+ children.push(...childNode);
250
+ }
251
+ else {
252
+ children.push(childNode);
253
+ }
254
+ }
255
+ childFiber = childFiber.sibling;
256
+ }
257
+ }
258
+ if (children.length > 0) {
259
+ node.children = children;
260
+ }
261
+ return node;
262
+ }
263
+ return buildNode(rootFiber, 0);
264
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Page freeze overlay - captures events but allows scrolling
3
+ * Prevents button clicks, link navigation, form submissions
4
+ * while allowing drag-and-drop interactions
5
+ */
6
+ export interface FreezeOverlayConfig {
7
+ zIndex?: number;
8
+ onMouseDown?: (e: MouseEvent, el: HTMLElement | null) => void;
9
+ onMouseMove?: (e: MouseEvent, el: HTMLElement | null) => void;
10
+ onMouseUp?: (e: MouseEvent, el: HTMLElement | null) => void;
11
+ onMouseLeave?: (e: MouseEvent) => void;
12
+ onClick?: (e: MouseEvent, el: HTMLElement | null) => void;
13
+ onDoubleClick?: (e: MouseEvent, el: HTMLElement | null) => void;
14
+ onWheel?: (e: WheelEvent) => void;
15
+ contentRoot?: HTMLElement;
16
+ }
17
+ export interface FreezeOverlay {
18
+ element: HTMLDivElement;
19
+ mount: () => void;
20
+ unmount: () => void;
21
+ getElementAt: (x: number, y: number) => HTMLElement | null;
22
+ setCursor: (cursor: string) => void;
23
+ getLastHoveredElement: () => HTMLElement | null;
24
+ }
25
+ export declare function createFreezeOverlay(config?: FreezeOverlayConfig): FreezeOverlay;
26
+ //# sourceMappingURL=freeze-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freeze-overlay.d.ts","sourceRoot":"","sources":["../../src/builder/freeze-overlay.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9D,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9D,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5D,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1D,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;IAChE,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,WAAW,GAAG,IAAI,CAAC;IAC3D,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,qBAAqB,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;CACjD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,mBAAwB,GAAG,aAAa,CAiQnF"}