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.
- package/README.md +290 -0
- package/dist/builder/ai-prompt-popover.d.ts +26 -0
- package/dist/builder/ai-prompt-popover.d.ts.map +1 -0
- package/dist/builder/ai-prompt-popover.js +180 -0
- package/dist/builder/builder-client.d.ts +48 -0
- package/dist/builder/builder-client.d.ts.map +1 -0
- package/dist/builder/builder-client.js +157 -0
- package/dist/builder/builder.d.ts +41 -0
- package/dist/builder/builder.d.ts.map +1 -0
- package/dist/builder/builder.js +537 -0
- package/dist/builder/bundle-manager.d.ts +60 -0
- package/dist/builder/bundle-manager.d.ts.map +1 -0
- package/dist/builder/bundle-manager.js +357 -0
- package/dist/builder/classifier/classname-analyzer.d.ts +6 -0
- package/dist/builder/classifier/classname-analyzer.d.ts.map +1 -0
- package/dist/builder/classifier/classname-analyzer.js +107 -0
- package/dist/builder/classifier/index.d.ts +20 -0
- package/dist/builder/classifier/index.d.ts.map +1 -0
- package/dist/builder/classifier/index.js +181 -0
- package/dist/builder/classifier/semantic-analyzer.d.ts +24 -0
- package/dist/builder/classifier/semantic-analyzer.d.ts.map +1 -0
- package/dist/builder/classifier/semantic-analyzer.js +94 -0
- package/dist/builder/classifier/size-analyzer.d.ts +7 -0
- package/dist/builder/classifier/size-analyzer.d.ts.map +1 -0
- package/dist/builder/classifier/size-analyzer.js +120 -0
- package/dist/builder/classifier/visual-analyzer.d.ts +6 -0
- package/dist/builder/classifier/visual-analyzer.d.ts.map +1 -0
- package/dist/builder/classifier/visual-analyzer.js +158 -0
- package/dist/builder/client.d.ts +22 -0
- package/dist/builder/client.d.ts.map +1 -0
- package/dist/builder/client.js +54 -0
- package/dist/builder/code-client.d.ts +101 -0
- package/dist/builder/code-client.d.ts.map +1 -0
- package/dist/builder/code-client.js +418 -0
- package/dist/builder/diff-state.d.ts +24 -0
- package/dist/builder/diff-state.d.ts.map +1 -0
- package/dist/builder/diff-state.js +134 -0
- package/dist/builder/dom-scanner.d.ts +20 -0
- package/dist/builder/dom-scanner.d.ts.map +1 -0
- package/dist/builder/dom-scanner.js +102 -0
- package/dist/builder/drag-engine.d.ts +41 -0
- package/dist/builder/drag-engine.d.ts.map +1 -0
- package/dist/builder/drag-engine.js +686 -0
- package/dist/builder/editor-overlays.d.ts +31 -0
- package/dist/builder/editor-overlays.d.ts.map +1 -0
- package/dist/builder/editor-overlays.js +202 -0
- package/dist/builder/editor-state.d.ts +50 -0
- package/dist/builder/editor-state.d.ts.map +1 -0
- package/dist/builder/editor-state.js +132 -0
- package/dist/builder/element-utils.d.ts +43 -0
- package/dist/builder/element-utils.d.ts.map +1 -0
- package/dist/builder/element-utils.js +227 -0
- package/dist/builder/fiber-capture.d.ts +28 -0
- package/dist/builder/fiber-capture.d.ts.map +1 -0
- package/dist/builder/fiber-capture.js +264 -0
- package/dist/builder/freeze-overlay.d.ts +26 -0
- package/dist/builder/freeze-overlay.d.ts.map +1 -0
- package/dist/builder/freeze-overlay.js +213 -0
- package/dist/builder/history-state.d.ts +41 -0
- package/dist/builder/history-state.d.ts.map +1 -0
- package/dist/builder/history-state.js +76 -0
- package/dist/builder/index.d.ts +62 -0
- package/dist/builder/index.d.ts.map +1 -0
- package/dist/builder/index.js +92 -0
- package/dist/builder/state.d.ts +27 -0
- package/dist/builder/state.d.ts.map +1 -0
- package/dist/builder/state.js +50 -0
- package/dist/builder/style-applier.d.ts +61 -0
- package/dist/builder/style-applier.d.ts.map +1 -0
- package/dist/builder/style-applier.js +311 -0
- package/dist/builder/tree-state.d.ts +71 -0
- package/dist/builder/tree-state.d.ts.map +1 -0
- package/dist/builder/tree-state.js +168 -0
- package/dist/builder/widget.d.ts +29 -0
- package/dist/builder/widget.d.ts.map +1 -0
- package/dist/builder/widget.js +181 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/package.json +25 -0
- package/src/styles/base.css +378 -0
- package/src/styles/builder.css +422 -0
- package/src/styles/editor.css +131 -0
- package/src/styles/themes/dark.css +24 -0
- package/src/styles/themes/light.css +21 -0
- package/src/styles/variables.css +63 -0
|
@@ -0,0 +1,213 @@
|
|
|
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 function createFreezeOverlay(config = {}) {
|
|
7
|
+
const { zIndex = 9998, onMouseDown, onMouseMove, onMouseUp, onMouseLeave, onClick, onDoubleClick, onWheel, contentRoot = document.body } = config;
|
|
8
|
+
const overlay = document.createElement('div');
|
|
9
|
+
overlay.id = '__editor-freeze-overlay__';
|
|
10
|
+
overlay.className = 'editor-freeze-overlay';
|
|
11
|
+
overlay.style.cssText = `
|
|
12
|
+
position: fixed;
|
|
13
|
+
inset: 0;
|
|
14
|
+
z-index: ${zIndex};
|
|
15
|
+
background: transparent;
|
|
16
|
+
cursor: default;
|
|
17
|
+
user-select: none;
|
|
18
|
+
-webkit-user-select: none;
|
|
19
|
+
`;
|
|
20
|
+
let lastHoveredElement = null;
|
|
21
|
+
let isMouseDown = false;
|
|
22
|
+
function isEditorElement(el) {
|
|
23
|
+
if (!el)
|
|
24
|
+
return true;
|
|
25
|
+
const skipIds = [
|
|
26
|
+
'__editor-freeze-overlay__',
|
|
27
|
+
'__editor-overlays__',
|
|
28
|
+
'__inspector-overlay__',
|
|
29
|
+
'__ai-prompt-popover__'
|
|
30
|
+
];
|
|
31
|
+
if (skipIds.some(id => el.id === id))
|
|
32
|
+
return true;
|
|
33
|
+
if (el.closest('.builder') || el.closest('.builder-bar') || el.closest('.chatbot')) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (el.closest('#__editor-overlays__') || el.closest('#__editor-freeze-overlay__') || el.closest('#__ai-prompt-popover__')) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
function getElementAt(x, y) {
|
|
42
|
+
overlay.style.pointerEvents = 'none';
|
|
43
|
+
const element = document.elementFromPoint(x, y);
|
|
44
|
+
overlay.style.pointerEvents = 'auto';
|
|
45
|
+
if (!element)
|
|
46
|
+
return null;
|
|
47
|
+
if (isEditorElement(element))
|
|
48
|
+
return null;
|
|
49
|
+
if (contentRoot && contentRoot !== document.body) {
|
|
50
|
+
if (!contentRoot.contains(element) && element !== contentRoot) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return element;
|
|
55
|
+
}
|
|
56
|
+
function isBuilderUI(target) {
|
|
57
|
+
return target !== null && (!!target.closest('.builder') ||
|
|
58
|
+
!!target.closest('.builder-bar') ||
|
|
59
|
+
!!target.closest('.builder-modal') ||
|
|
60
|
+
!!target.closest('#__ai-prompt-popover__'));
|
|
61
|
+
}
|
|
62
|
+
function handleDocumentMouseMove(e) {
|
|
63
|
+
const element = getElementAt(e.clientX, e.clientY);
|
|
64
|
+
onMouseMove?.(e, element);
|
|
65
|
+
lastHoveredElement = element;
|
|
66
|
+
}
|
|
67
|
+
function handleDocumentMouseUp(e) {
|
|
68
|
+
document.removeEventListener('mousemove', handleDocumentMouseMove, true);
|
|
69
|
+
document.removeEventListener('mouseup', handleDocumentMouseUp, true);
|
|
70
|
+
isMouseDown = false;
|
|
71
|
+
overlay.style.pointerEvents = 'none';
|
|
72
|
+
const clickTarget = document.elementFromPoint(e.clientX, e.clientY);
|
|
73
|
+
overlay.style.pointerEvents = 'auto';
|
|
74
|
+
if (isBuilderUI(clickTarget)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const element = getElementAt(e.clientX, e.clientY);
|
|
78
|
+
onMouseUp?.(e, element);
|
|
79
|
+
}
|
|
80
|
+
function handleMouseDown(e) {
|
|
81
|
+
if (e.button !== 0)
|
|
82
|
+
return;
|
|
83
|
+
overlay.style.pointerEvents = 'none';
|
|
84
|
+
const clickTarget = document.elementFromPoint(e.clientX, e.clientY);
|
|
85
|
+
overlay.style.pointerEvents = 'auto';
|
|
86
|
+
if (isBuilderUI(clickTarget)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
isMouseDown = true;
|
|
91
|
+
document.addEventListener('mousemove', handleDocumentMouseMove, true);
|
|
92
|
+
document.addEventListener('mouseup', handleDocumentMouseUp, true);
|
|
93
|
+
const element = getElementAt(e.clientX, e.clientY);
|
|
94
|
+
onMouseDown?.(e, element);
|
|
95
|
+
}
|
|
96
|
+
function handleMouseMove(e) {
|
|
97
|
+
if (isMouseDown)
|
|
98
|
+
return;
|
|
99
|
+
const element = getElementAt(e.clientX, e.clientY);
|
|
100
|
+
onMouseMove?.(e, element);
|
|
101
|
+
lastHoveredElement = element;
|
|
102
|
+
}
|
|
103
|
+
function handleMouseUp(e) {
|
|
104
|
+
if (isMouseDown)
|
|
105
|
+
return;
|
|
106
|
+
overlay.style.pointerEvents = 'none';
|
|
107
|
+
const clickTarget = document.elementFromPoint(e.clientX, e.clientY);
|
|
108
|
+
overlay.style.pointerEvents = 'auto';
|
|
109
|
+
if (isBuilderUI(clickTarget)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const element = getElementAt(e.clientX, e.clientY);
|
|
113
|
+
onMouseUp?.(e, element);
|
|
114
|
+
}
|
|
115
|
+
function handleMouseLeave(e) {
|
|
116
|
+
if (isMouseDown)
|
|
117
|
+
return;
|
|
118
|
+
lastHoveredElement = null;
|
|
119
|
+
onMouseLeave?.(e);
|
|
120
|
+
}
|
|
121
|
+
function handleClick(e) {
|
|
122
|
+
overlay.style.pointerEvents = 'none';
|
|
123
|
+
const clickTarget = document.elementFromPoint(e.clientX, e.clientY);
|
|
124
|
+
overlay.style.pointerEvents = 'auto';
|
|
125
|
+
if (isBuilderUI(clickTarget)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
e.stopPropagation();
|
|
130
|
+
const element = getElementAt(e.clientX, e.clientY);
|
|
131
|
+
onClick?.(e, element);
|
|
132
|
+
}
|
|
133
|
+
function handleDoubleClick(e) {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
e.stopPropagation();
|
|
136
|
+
const element = getElementAt(e.clientX, e.clientY);
|
|
137
|
+
onDoubleClick?.(e, element);
|
|
138
|
+
}
|
|
139
|
+
function handleWheel(e) {
|
|
140
|
+
if (contentRoot && contentRoot !== document.body) {
|
|
141
|
+
contentRoot.scrollTop += e.deltaY;
|
|
142
|
+
contentRoot.scrollLeft += e.deltaX;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
window.scrollBy(e.deltaX, e.deltaY);
|
|
146
|
+
}
|
|
147
|
+
onWheel?.(e);
|
|
148
|
+
}
|
|
149
|
+
function handleFormPrevention(e) {
|
|
150
|
+
if (contentRoot && contentRoot.contains(e.target)) {
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
e.stopPropagation();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function preventDragStart(e) {
|
|
156
|
+
if (isBuilderUI(e.target))
|
|
157
|
+
return;
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
}
|
|
160
|
+
function preventSelectStart(e) {
|
|
161
|
+
if (isBuilderUI(e.target))
|
|
162
|
+
return;
|
|
163
|
+
if (isMouseDown) {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function attachListeners() {
|
|
168
|
+
overlay.addEventListener('mousedown', handleMouseDown);
|
|
169
|
+
overlay.addEventListener('mousemove', handleMouseMove);
|
|
170
|
+
overlay.addEventListener('mouseup', handleMouseUp);
|
|
171
|
+
overlay.addEventListener('mouseleave', handleMouseLeave);
|
|
172
|
+
overlay.addEventListener('click', handleClick);
|
|
173
|
+
overlay.addEventListener('dblclick', handleDoubleClick);
|
|
174
|
+
overlay.addEventListener('wheel', handleWheel, { passive: true });
|
|
175
|
+
document.addEventListener('submit', handleFormPrevention, true);
|
|
176
|
+
document.addEventListener('dragstart', preventDragStart, true);
|
|
177
|
+
document.addEventListener('selectstart', preventSelectStart, true);
|
|
178
|
+
}
|
|
179
|
+
function detachListeners() {
|
|
180
|
+
overlay.removeEventListener('mousedown', handleMouseDown);
|
|
181
|
+
overlay.removeEventListener('mousemove', handleMouseMove);
|
|
182
|
+
overlay.removeEventListener('mouseup', handleMouseUp);
|
|
183
|
+
overlay.removeEventListener('mouseleave', handleMouseLeave);
|
|
184
|
+
overlay.removeEventListener('click', handleClick);
|
|
185
|
+
overlay.removeEventListener('dblclick', handleDoubleClick);
|
|
186
|
+
overlay.removeEventListener('wheel', handleWheel);
|
|
187
|
+
document.removeEventListener('submit', handleFormPrevention, true);
|
|
188
|
+
document.removeEventListener('dragstart', preventDragStart, true);
|
|
189
|
+
document.removeEventListener('selectstart', preventSelectStart, true);
|
|
190
|
+
document.removeEventListener('mousemove', handleDocumentMouseMove, true);
|
|
191
|
+
document.removeEventListener('mouseup', handleDocumentMouseUp, true);
|
|
192
|
+
isMouseDown = false;
|
|
193
|
+
}
|
|
194
|
+
function mount() {
|
|
195
|
+
document.body.appendChild(overlay);
|
|
196
|
+
attachListeners();
|
|
197
|
+
}
|
|
198
|
+
function unmount() {
|
|
199
|
+
detachListeners();
|
|
200
|
+
overlay.remove();
|
|
201
|
+
}
|
|
202
|
+
function setCursor(cursor) {
|
|
203
|
+
overlay.style.cursor = cursor;
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
element: overlay,
|
|
207
|
+
mount,
|
|
208
|
+
unmount,
|
|
209
|
+
getElementAt,
|
|
210
|
+
setCursor,
|
|
211
|
+
getLastHoveredElement: () => lastHoveredElement
|
|
212
|
+
};
|
|
213
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History state management - Undo/redo stack
|
|
3
|
+
* Tracks DOM move operations for undo/redo functionality
|
|
4
|
+
*/
|
|
5
|
+
export interface CreatedWrapper {
|
|
6
|
+
type: 'horizontal' | 'vertical';
|
|
7
|
+
position: string;
|
|
8
|
+
wrapperParent: HTMLElement;
|
|
9
|
+
insertedBefore: Node | null;
|
|
10
|
+
targetElement: HTMLElement;
|
|
11
|
+
styles: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export interface MoveEntry {
|
|
14
|
+
type: 'move';
|
|
15
|
+
element: HTMLElement;
|
|
16
|
+
originalParent: HTMLElement;
|
|
17
|
+
originalNextSibling: Node | null;
|
|
18
|
+
originalParentWasWrapper: boolean;
|
|
19
|
+
newParent: HTMLElement;
|
|
20
|
+
newNextSibling: Node | null;
|
|
21
|
+
createdWrapper: CreatedWrapper | null;
|
|
22
|
+
}
|
|
23
|
+
export interface HistoryStateData {
|
|
24
|
+
undoStack: MoveEntry[];
|
|
25
|
+
redoStack: MoveEntry[];
|
|
26
|
+
}
|
|
27
|
+
export type HistoryStateListener = (state: HistoryStateData) => void;
|
|
28
|
+
export interface HistoryState {
|
|
29
|
+
getState: () => HistoryStateData;
|
|
30
|
+
setState: (updates: Partial<HistoryStateData>) => void;
|
|
31
|
+
subscribe: (listener: HistoryStateListener) => () => void;
|
|
32
|
+
pushChange: (entry: MoveEntry) => void;
|
|
33
|
+
undo: () => MoveEntry | null;
|
|
34
|
+
redo: () => MoveEntry | null;
|
|
35
|
+
canUndo: () => boolean;
|
|
36
|
+
canRedo: () => boolean;
|
|
37
|
+
clear: () => void;
|
|
38
|
+
getChanges: () => MoveEntry[];
|
|
39
|
+
}
|
|
40
|
+
export declare function createHistoryState(initialState?: Partial<HistoryStateData>): HistoryState;
|
|
41
|
+
//# sourceMappingURL=history-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-state.d.ts","sourceRoot":"","sources":["../../src/builder/history-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,GAAG,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C;CAC/B;AAED,wBAAgB,kBAAkB,CAAC,YAAY,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAAG,YAAY,CAuF7F"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History state management - Undo/redo stack
|
|
3
|
+
* Tracks DOM move operations for undo/redo functionality
|
|
4
|
+
*/
|
|
5
|
+
export function createHistoryState(initialState = {}) {
|
|
6
|
+
let state = {
|
|
7
|
+
undoStack: [],
|
|
8
|
+
redoStack: [],
|
|
9
|
+
...initialState
|
|
10
|
+
};
|
|
11
|
+
const listeners = new Set();
|
|
12
|
+
function getState() {
|
|
13
|
+
return { ...state };
|
|
14
|
+
}
|
|
15
|
+
function setState(updates) {
|
|
16
|
+
state = { ...state, ...updates };
|
|
17
|
+
listeners.forEach(listener => listener(state));
|
|
18
|
+
}
|
|
19
|
+
function subscribe(listener) {
|
|
20
|
+
listeners.add(listener);
|
|
21
|
+
return () => listeners.delete(listener);
|
|
22
|
+
}
|
|
23
|
+
function pushChange(entry) {
|
|
24
|
+
setState({
|
|
25
|
+
undoStack: [...state.undoStack, entry],
|
|
26
|
+
redoStack: []
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function undo() {
|
|
30
|
+
if (state.undoStack.length === 0)
|
|
31
|
+
return null;
|
|
32
|
+
const entry = state.undoStack[state.undoStack.length - 1];
|
|
33
|
+
setState({
|
|
34
|
+
undoStack: state.undoStack.slice(0, -1),
|
|
35
|
+
redoStack: [...state.redoStack, entry]
|
|
36
|
+
});
|
|
37
|
+
return entry;
|
|
38
|
+
}
|
|
39
|
+
function redo() {
|
|
40
|
+
if (state.redoStack.length === 0)
|
|
41
|
+
return null;
|
|
42
|
+
const entry = state.redoStack[state.redoStack.length - 1];
|
|
43
|
+
setState({
|
|
44
|
+
redoStack: state.redoStack.slice(0, -1),
|
|
45
|
+
undoStack: [...state.undoStack, entry]
|
|
46
|
+
});
|
|
47
|
+
return entry;
|
|
48
|
+
}
|
|
49
|
+
function canUndo() {
|
|
50
|
+
return state.undoStack.length > 0;
|
|
51
|
+
}
|
|
52
|
+
function canRedo() {
|
|
53
|
+
return state.redoStack.length > 0;
|
|
54
|
+
}
|
|
55
|
+
function clear() {
|
|
56
|
+
setState({
|
|
57
|
+
undoStack: [],
|
|
58
|
+
redoStack: []
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function getChanges() {
|
|
62
|
+
return [...state.undoStack];
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
getState,
|
|
66
|
+
setState,
|
|
67
|
+
subscribe,
|
|
68
|
+
pushChange,
|
|
69
|
+
undo,
|
|
70
|
+
redo,
|
|
71
|
+
canUndo,
|
|
72
|
+
canRedo,
|
|
73
|
+
clear,
|
|
74
|
+
getChanges
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder exports - Visual editor and chatbot core
|
|
3
|
+
*/
|
|
4
|
+
export { createState } from './state';
|
|
5
|
+
export type { Message, ChatState, StateListener, StateStore } from './state';
|
|
6
|
+
export { createClient } from './client';
|
|
7
|
+
export type { ClientConfig, MessageData, StreamClient } from './client';
|
|
8
|
+
export { createWidget } from './widget';
|
|
9
|
+
export type { WidgetMode, WidgetPosition, WidgetTheme, WidgetConfig, Widget } from './widget';
|
|
10
|
+
export { createBuilder } from './builder';
|
|
11
|
+
export type { BuilderConfig, Builder as BuilderInstance } from './builder';
|
|
12
|
+
export { createBuilderClient } from './builder-client';
|
|
13
|
+
export type { BuilderClientConfig, BuilderClient } from './builder-client';
|
|
14
|
+
export { createCodeClient } from './code-client';
|
|
15
|
+
export type { CodeClientConfig, CodeMessage, CodeEvent, CodeEdit, CodeClient } from './code-client';
|
|
16
|
+
export { createEditorState } from './editor-state';
|
|
17
|
+
export type { DropIndicator, EditorStateData, EditorStateListener, EditorState } from './editor-state';
|
|
18
|
+
export { createHistoryState } from './history-state';
|
|
19
|
+
export type { CreatedWrapper, MoveEntry, HistoryStateData, HistoryStateListener, HistoryState } from './history-state';
|
|
20
|
+
export { createTreeState } from './tree-state';
|
|
21
|
+
export type { TreeNode, SerializedRect, SerializedDOMNode, TreeStateData, TreeStateListener, TreeState } from './tree-state';
|
|
22
|
+
export { createDiffState } from './diff-state';
|
|
23
|
+
export type { DiffEntry, DiffState } from './diff-state';
|
|
24
|
+
export { createFreezeOverlay } from './freeze-overlay';
|
|
25
|
+
export type { FreezeOverlayConfig, FreezeOverlay } from './freeze-overlay';
|
|
26
|
+
export { createOverlays } from './editor-overlays';
|
|
27
|
+
export type { OverlaysConfig, Overlays } from './editor-overlays';
|
|
28
|
+
export { createDragEngine } from './drag-engine';
|
|
29
|
+
export type { DragEngineConfig, DropTarget, DragEngine } from './drag-engine';
|
|
30
|
+
export { scanDOM, createDebouncedScanner, getElementAtPath, queryElements, generateSelector } from './dom-scanner';
|
|
31
|
+
export type { ScanOptions, DebouncedScanner } from './dom-scanner';
|
|
32
|
+
export { STABLE_ID_ATTR, VISIBILITY_ATTR, getVisibilityBoundary, canDropInZone, getStableId, findByStableId, getDomPath, getElementAtPath as getElementAtPathFromUtils, getRelevantStyles, serializeRect, buildElementIdentifier, buildPlacementTarget } from './element-utils';
|
|
33
|
+
export type { ElementIdentifier, PlacementTarget, SerializedRect as SerializedRectFromUtils } from './element-utils';
|
|
34
|
+
export { createAIPromptPopover } from './ai-prompt-popover';
|
|
35
|
+
export type { AIPromptPopoverConfig, AIPromptPopover } from './ai-prompt-popover';
|
|
36
|
+
export { getFiberFromDOM, getFiberRoot, captureReactTree } from './fiber-capture';
|
|
37
|
+
export type { CaptureOptions } from './fiber-capture';
|
|
38
|
+
export { createClassifier, setViewportSize } from './classifier/index';
|
|
39
|
+
export type { Signal, ClassifierInput, Classification, Classifier } from './classifier/index';
|
|
40
|
+
export { createBundleManager } from './bundle-manager';
|
|
41
|
+
export type { BundleManager, BundleManagerConfig } from './bundle-manager';
|
|
42
|
+
export { createStyleApplier, hasStyleChanges } from './style-applier';
|
|
43
|
+
export type { StyleApplier, StyleApplierConfig, StyleChange, StyleChangeType } from './style-applier';
|
|
44
|
+
import { createBuilder } from './builder';
|
|
45
|
+
export declare const Chatbot: {
|
|
46
|
+
init(config: Parameters<typeof createBuilder>[0] & {
|
|
47
|
+
container?: string;
|
|
48
|
+
}): {
|
|
49
|
+
getMessages: () => import("./state").Message[];
|
|
50
|
+
clearMessages: () => void;
|
|
51
|
+
sendMessage: (text: string) => Promise<void>;
|
|
52
|
+
subscribe: (listener: import("./state").StateListener) => () => void;
|
|
53
|
+
destroy: () => void;
|
|
54
|
+
state: import("./state").StateStore;
|
|
55
|
+
client: import("./client").StreamClient;
|
|
56
|
+
widget: import("./widget").Widget;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export declare const Builder: {
|
|
60
|
+
create: typeof createBuilder;
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builder/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG7E,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAG9F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAC;AAG3E,O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AE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;;4BA8BjD,MAAM;;;;;;;CAc/B,CAAC;AAEF,eAAO,MAAM,OAAO;;CAEnB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder exports - Visual editor and chatbot core
|
|
3
|
+
*/
|
|
4
|
+
// State management
|
|
5
|
+
export { createState } from './state';
|
|
6
|
+
// Streaming client
|
|
7
|
+
export { createClient } from './client';
|
|
8
|
+
// Widget
|
|
9
|
+
export { createWidget } from './widget';
|
|
10
|
+
// Builder
|
|
11
|
+
export { createBuilder } from './builder';
|
|
12
|
+
// Builder client
|
|
13
|
+
export { createBuilderClient } from './builder-client';
|
|
14
|
+
// Code client (flexcode integration)
|
|
15
|
+
export { createCodeClient } from './code-client';
|
|
16
|
+
// Editor state
|
|
17
|
+
export { createEditorState } from './editor-state';
|
|
18
|
+
// History state
|
|
19
|
+
export { createHistoryState } from './history-state';
|
|
20
|
+
// Tree state
|
|
21
|
+
export { createTreeState } from './tree-state';
|
|
22
|
+
// Diff state
|
|
23
|
+
export { createDiffState } from './diff-state';
|
|
24
|
+
// Freeze overlay
|
|
25
|
+
export { createFreezeOverlay } from './freeze-overlay';
|
|
26
|
+
// Editor overlays
|
|
27
|
+
export { createOverlays } from './editor-overlays';
|
|
28
|
+
// Drag engine
|
|
29
|
+
export { createDragEngine } from './drag-engine';
|
|
30
|
+
// DOM scanner
|
|
31
|
+
export { scanDOM, createDebouncedScanner, getElementAtPath, queryElements, generateSelector } from './dom-scanner';
|
|
32
|
+
// Element utilities
|
|
33
|
+
export { STABLE_ID_ATTR, VISIBILITY_ATTR, getVisibilityBoundary, canDropInZone, getStableId, findByStableId, getDomPath, getElementAtPath as getElementAtPathFromUtils, getRelevantStyles, serializeRect, buildElementIdentifier, buildPlacementTarget } from './element-utils';
|
|
34
|
+
// AI prompt popover
|
|
35
|
+
export { createAIPromptPopover } from './ai-prompt-popover';
|
|
36
|
+
// Fiber capture
|
|
37
|
+
export { getFiberFromDOM, getFiberRoot, captureReactTree } from './fiber-capture';
|
|
38
|
+
// Classifier
|
|
39
|
+
export { createClassifier, setViewportSize } from './classifier/index';
|
|
40
|
+
// Bundle manager
|
|
41
|
+
export { createBundleManager } from './bundle-manager';
|
|
42
|
+
// Style applier
|
|
43
|
+
export { createStyleApplier, hasStyleChanges } from './style-applier';
|
|
44
|
+
// Namespace exports for backwards compatibility
|
|
45
|
+
import { createState } from './state';
|
|
46
|
+
import { createClient } from './client';
|
|
47
|
+
import { createWidget } from './widget';
|
|
48
|
+
import { createBuilder } from './builder';
|
|
49
|
+
export const Chatbot = {
|
|
50
|
+
init(config) {
|
|
51
|
+
const { container, ...restConfig } = config;
|
|
52
|
+
if (!container) {
|
|
53
|
+
throw new Error('Chatbot: container is required');
|
|
54
|
+
}
|
|
55
|
+
const state = createState();
|
|
56
|
+
const client = createClient({
|
|
57
|
+
endpoint: restConfig.apiBase ? `${restConfig.apiBase}/api/chat` : '/api/chat',
|
|
58
|
+
onMessage: (data) => {
|
|
59
|
+
const messages = state.getState().messages;
|
|
60
|
+
const lastMessage = messages[messages.length - 1];
|
|
61
|
+
if (lastMessage?.role === 'assistant') {
|
|
62
|
+
const newText = lastMessage.text + (data.text || data.content || '');
|
|
63
|
+
state.updateMessage(lastMessage.id, { text: newText });
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const widget = createWidget(container, state, client, {});
|
|
68
|
+
return {
|
|
69
|
+
getMessages: () => state.getState().messages,
|
|
70
|
+
clearMessages: () => state.clearMessages(),
|
|
71
|
+
sendMessage: (text) => {
|
|
72
|
+
state.addMessage({ role: 'user', text });
|
|
73
|
+
state.addMessage({ role: 'assistant', text: '' });
|
|
74
|
+
return client.send(text);
|
|
75
|
+
},
|
|
76
|
+
subscribe: state.subscribe,
|
|
77
|
+
destroy: () => {
|
|
78
|
+
widget.destroy();
|
|
79
|
+
},
|
|
80
|
+
state,
|
|
81
|
+
client,
|
|
82
|
+
widget
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export const Builder = {
|
|
87
|
+
create: createBuilder
|
|
88
|
+
};
|
|
89
|
+
if (typeof window !== 'undefined') {
|
|
90
|
+
window.Chatbot = Chatbot;
|
|
91
|
+
window.Builder = Builder;
|
|
92
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observable state management for chatbot
|
|
3
|
+
* Uses event emitters for framework-agnostic reactivity
|
|
4
|
+
*/
|
|
5
|
+
export interface Message {
|
|
6
|
+
id: string;
|
|
7
|
+
role: 'user' | 'assistant' | 'system';
|
|
8
|
+
text: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ChatState {
|
|
12
|
+
messages: Message[];
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
isTyping: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
}
|
|
17
|
+
export type StateListener = (state: ChatState) => void;
|
|
18
|
+
export interface StateStore {
|
|
19
|
+
getState: () => ChatState;
|
|
20
|
+
setState: (updates: Partial<ChatState>) => void;
|
|
21
|
+
subscribe: (listener: StateListener) => () => void;
|
|
22
|
+
addMessage: (message: Omit<Message, 'id' | 'timestamp'> & Partial<Pick<Message, 'id' | 'timestamp'>>) => Message;
|
|
23
|
+
updateMessage: (id: string, updates: Partial<Message>) => void;
|
|
24
|
+
clearMessages: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function createState(initialState?: Partial<ChatState>): StateStore;
|
|
27
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/builder/state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,SAAS,CAAC;IAC1B,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IAChD,SAAS,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,IAAI,CAAC;IACnD,UAAU,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC,KAAK,OAAO,CAAC;IACjH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAC/D,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,WAAW,CAAC,YAAY,GAAE,OAAO,CAAC,SAAS,CAAM,GAAG,UAAU,CAuD7E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observable state management for chatbot
|
|
3
|
+
* Uses event emitters for framework-agnostic reactivity
|
|
4
|
+
*/
|
|
5
|
+
export function createState(initialState = {}) {
|
|
6
|
+
let state = {
|
|
7
|
+
messages: [],
|
|
8
|
+
isLoading: false,
|
|
9
|
+
isTyping: false,
|
|
10
|
+
error: null,
|
|
11
|
+
...initialState
|
|
12
|
+
};
|
|
13
|
+
const listeners = new Set();
|
|
14
|
+
function getState() {
|
|
15
|
+
return { ...state };
|
|
16
|
+
}
|
|
17
|
+
function setState(updates) {
|
|
18
|
+
state = { ...state, ...updates };
|
|
19
|
+
listeners.forEach(listener => listener(state));
|
|
20
|
+
}
|
|
21
|
+
function subscribe(listener) {
|
|
22
|
+
listeners.add(listener);
|
|
23
|
+
return () => listeners.delete(listener);
|
|
24
|
+
}
|
|
25
|
+
function addMessage(message) {
|
|
26
|
+
const newMessage = {
|
|
27
|
+
id: crypto.randomUUID(),
|
|
28
|
+
timestamp: Date.now(),
|
|
29
|
+
...message
|
|
30
|
+
};
|
|
31
|
+
setState({ messages: [...state.messages, newMessage] });
|
|
32
|
+
return newMessage;
|
|
33
|
+
}
|
|
34
|
+
function updateMessage(id, updates) {
|
|
35
|
+
setState({
|
|
36
|
+
messages: state.messages.map(msg => msg.id === id ? { ...msg, ...updates } : msg)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function clearMessages() {
|
|
40
|
+
setState({ messages: [] });
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
getState,
|
|
44
|
+
setState,
|
|
45
|
+
subscribe,
|
|
46
|
+
addMessage,
|
|
47
|
+
updateMessage,
|
|
48
|
+
clearMessages
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style Applier - Parses code edits and applies styling changes directly to DOM
|
|
3
|
+
*
|
|
4
|
+
* Extracts styling-related changes from React/JSX code diffs:
|
|
5
|
+
* - className prop changes
|
|
6
|
+
* - style prop changes
|
|
7
|
+
* - Tailwind class additions/removals
|
|
8
|
+
*
|
|
9
|
+
* Then applies them to the corresponding DOM elements without requiring a bundle reload.
|
|
10
|
+
*/
|
|
11
|
+
import type { CodeEdit } from './code-client';
|
|
12
|
+
/**
|
|
13
|
+
* Types of style changes we can detect and apply
|
|
14
|
+
*/
|
|
15
|
+
export type StyleChangeType = 'className' | 'style' | 'tailwind';
|
|
16
|
+
export interface StyleChange {
|
|
17
|
+
type: StyleChangeType;
|
|
18
|
+
filePath: string;
|
|
19
|
+
componentName?: string;
|
|
20
|
+
selector?: string;
|
|
21
|
+
oldClassName?: string;
|
|
22
|
+
newClassName?: string;
|
|
23
|
+
styleProperty?: string;
|
|
24
|
+
oldValue?: string;
|
|
25
|
+
newValue?: string;
|
|
26
|
+
addClasses?: string[];
|
|
27
|
+
removeClasses?: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface StyleApplierConfig {
|
|
30
|
+
/** Function to query elements - defaults to document.querySelectorAll */
|
|
31
|
+
queryElements?: (selector: string) => NodeListOf<Element>;
|
|
32
|
+
/** Custom component to DOM mapping function */
|
|
33
|
+
mapComponentToElements?: (componentName: string, filePath: string) => Element[];
|
|
34
|
+
/** Called when a style change is applied */
|
|
35
|
+
onApply?: (change: StyleChange, elements: Element[]) => void;
|
|
36
|
+
/** Called when a style change fails to apply */
|
|
37
|
+
onError?: (change: StyleChange, error: Error) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface StyleApplier {
|
|
40
|
+
/** Parse a code edit and extract style changes */
|
|
41
|
+
parseEdit(edit: CodeEdit): StyleChange[];
|
|
42
|
+
/** Apply a style change to the DOM */
|
|
43
|
+
applyChange(change: StyleChange): Element[];
|
|
44
|
+
/** Parse and apply all style changes from an edit */
|
|
45
|
+
processEdit(edit: CodeEdit): {
|
|
46
|
+
changes: StyleChange[];
|
|
47
|
+
applied: number;
|
|
48
|
+
};
|
|
49
|
+
/** Find DOM elements for a component */
|
|
50
|
+
findElements(componentName: string, filePath: string): Element[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a style applier instance
|
|
54
|
+
*/
|
|
55
|
+
export declare function createStyleApplier(config?: StyleApplierConfig): StyleApplier;
|
|
56
|
+
/**
|
|
57
|
+
* Utility: Check if an edit likely contains style changes
|
|
58
|
+
* Quick check before doing full parsing
|
|
59
|
+
*/
|
|
60
|
+
export declare function hasStyleChanges(edit: CodeEdit): bo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