fixdog 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +80 -433
- package/dist/api/client.d.ts +74 -0
- package/dist/components/ConversationalInputReact.d.ts +26 -0
- package/dist/components/ElementInfoDisplayReact.d.ts +9 -0
- package/dist/components/FixdogSidebarReact.d.ts +29 -0
- package/dist/fiber.d.ts +9 -0
- package/dist/index.cjs.js +33 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +6 -158
- package/dist/index.esm.js +29 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/inspector-B4F5CBT7.cjs.js +1159 -0
- package/dist/inspector-B4F5CBT7.cjs.js.map +1 -0
- package/dist/inspector-BL2pNjn-.cjs.js +1173 -0
- package/dist/inspector-BL2pNjn-.cjs.js.map +1 -0
- package/dist/inspector-Bg6uSvk0.esm.js +1273 -0
- package/dist/inspector-Bg6uSvk0.esm.js.map +1 -0
- package/dist/inspector-BuOffbVc.cjs.js +1280 -0
- package/dist/inspector-BuOffbVc.cjs.js.map +1 -0
- package/dist/inspector-CNgFkZOU.esm.js +1185 -0
- package/dist/inspector-CNgFkZOU.esm.js.map +1 -0
- package/dist/inspector-CPF1N9dL.esm.js +1185 -0
- package/dist/inspector-CPF1N9dL.esm.js.map +1 -0
- package/dist/inspector-CPGK5Lg7.esm.js +1155 -0
- package/dist/inspector-CPGK5Lg7.esm.js.map +1 -0
- package/dist/inspector-CWcTSREy.cjs.js +1174 -0
- package/dist/inspector-CWcTSREy.cjs.js.map +1 -0
- package/dist/inspector-Cn_bl9Io.cjs.js +1189 -0
- package/dist/inspector-Cn_bl9Io.cjs.js.map +1 -0
- package/dist/inspector-D9DuXirp.cjs.js +1189 -0
- package/dist/inspector-D9DuXirp.cjs.js.map +1 -0
- package/dist/inspector-DQEtAjyM.esm.js +1129 -0
- package/dist/inspector-DQEtAjyM.esm.js.map +1 -0
- package/dist/inspector-DVlU9p44.cjs.js +1189 -0
- package/dist/inspector-DVlU9p44.cjs.js.map +1 -0
- package/dist/inspector-DaRVppX9.cjs.js +1134 -0
- package/dist/inspector-DaRVppX9.cjs.js.map +1 -0
- package/dist/inspector-huqtI2MD.esm.js +1170 -0
- package/dist/inspector-huqtI2MD.esm.js.map +1 -0
- package/dist/inspector-spoCY1tf.esm.js +1169 -0
- package/dist/inspector-spoCY1tf.esm.js.map +1 -0
- package/dist/inspector-tY1kJK5_.esm.js +1185 -0
- package/dist/inspector-tY1kJK5_.esm.js.map +1 -0
- package/dist/inspector.d.ts +43 -0
- package/dist/keyboard.d.ts +10 -0
- package/dist/overlay.d.ts +31 -0
- package/dist/react/InspectorProvider.d.ts +6 -0
- package/dist/react/index.cjs.js +32 -0
- package/dist/react/index.cjs.js.map +1 -0
- package/dist/react/index.esm.js +30 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/sidebar/SidebarRuntime.d.ts +8 -0
- package/dist/sidebar-runtime.esm.js +2122 -0
- package/dist/sidebar-runtime.esm.js.map +1 -0
- package/dist/sidebar-runtime.iife.js +2991 -0
- package/dist/styles/sidebarStyles.d.ts +2 -0
- package/dist/styles.d.ts +8 -0
- package/dist/types/sidebar.d.ts +62 -0
- package/dist/types.d.ts +47 -0
- package/dist/utils/cookies.d.ts +10 -0
- package/dist/utils/devMode.d.ts +17 -0
- package/dist/utils/sessionStorage.d.ts +19 -0
- package/package.json +57 -40
- package/USAGE.md +0 -77
- package/dist/client/index.d.mts +0 -110
- package/dist/client/index.d.ts +0 -110
- package/dist/client/index.js +0 -1601
- package/dist/client/index.mjs +0 -1582
- package/dist/client/init.d.mts +0 -67
- package/dist/client/init.d.ts +0 -67
- package/dist/client/init.js +0 -1609
- package/dist/client/init.mjs +0 -1593
- package/dist/index.d.mts +0 -158
- package/dist/index.js +0 -1635
- package/dist/index.mjs +0 -1606
- package/src/api/client.ts +0 -141
- package/src/client/index.ts +0 -75
- package/src/client/init.tsx +0 -78
- package/src/components/ConversationalInputReact.tsx +0 -406
- package/src/components/ElementInfoDisplayReact.tsx +0 -84
- package/src/components/UiDogSidebarReact.tsx +0 -49
- package/src/element-detector.ts +0 -186
- package/src/index.ts +0 -228
- package/src/instrument.ts +0 -171
- package/src/sidebar-initializer.ts +0 -171
- package/src/source-resolver.ts +0 -121
- package/src/styles/sidebarStyles.ts +0 -597
- package/src/types/css.d.ts +0 -9
- package/src/types/sidebar.ts +0 -56
- package/src/types.ts +0 -119
- package/tsconfig.json +0 -23
- package/tsup.config.ts +0 -40
package/dist/index.js
DELETED
|
@@ -1,1635 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
buildEditorUrl: () => buildEditorUrl,
|
|
24
|
-
cleanupUiDogNext: () => cleanupUiDogNext,
|
|
25
|
-
closeSidebar: () => closeSidebar,
|
|
26
|
-
getComponentNameFromFiber: () => getComponentNameFromFiber,
|
|
27
|
-
getShortFileName: () => getShortFileName,
|
|
28
|
-
getSourceFromElement: () => getSourceFromElement,
|
|
29
|
-
initializeUiDogNext: () => initializeUiDogNext,
|
|
30
|
-
isUiDogNextInitialized: () => isUiDogNextInitialized,
|
|
31
|
-
normalizeFileName: () => normalizeFileName,
|
|
32
|
-
openSidebar: () => openSidebar,
|
|
33
|
-
setupBippyInstrumentation: () => setupBippyInstrumentation
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
|
|
37
|
-
// src/instrument.ts
|
|
38
|
-
var import_bippy = require("bippy");
|
|
39
|
-
var import_source = require("bippy/source");
|
|
40
|
-
var isInstrumented = false;
|
|
41
|
-
function setupBippyInstrumentation() {
|
|
42
|
-
if (isInstrumented)
|
|
43
|
-
return;
|
|
44
|
-
if (typeof window === "undefined")
|
|
45
|
-
return;
|
|
46
|
-
isInstrumented = true;
|
|
47
|
-
(0, import_bippy.instrument)(
|
|
48
|
-
(0, import_bippy.secure)({
|
|
49
|
-
onCommitFiberRoot: (_rendererID, _fiberRoot) => {
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
async function getSourceFromElement(element) {
|
|
55
|
-
try {
|
|
56
|
-
const fiber = (0, import_bippy.getFiberFromHostInstance)(element);
|
|
57
|
-
if (!fiber) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
const source = await (0, import_source.getSource)(fiber);
|
|
61
|
-
if (source && source.fileName) {
|
|
62
|
-
if (source.fileName.includes("node_modules") || source.fileName.includes("react-dom") || source.fileName.includes("react/")) {
|
|
63
|
-
return await findUserSourceFromFiber(fiber);
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
fileName: source.fileName,
|
|
67
|
-
lineNumber: source.lineNumber ?? 1,
|
|
68
|
-
columnNumber: source.columnNumber ?? 1,
|
|
69
|
-
functionName: source.functionName ?? void 0
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return await findUserSourceFromFiber(fiber);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.warn("[UiDog Next] Error getting source from element:", error);
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async function findUserSourceFromFiber(startFiber) {
|
|
79
|
-
let result = null;
|
|
80
|
-
(0, import_bippy.traverseFiber)(
|
|
81
|
-
startFiber,
|
|
82
|
-
async (fiber) => {
|
|
83
|
-
if ((0, import_bippy.isCompositeFiber)(fiber)) {
|
|
84
|
-
try {
|
|
85
|
-
const source = await (0, import_source.getSource)(fiber);
|
|
86
|
-
if (source && source.fileName) {
|
|
87
|
-
if (!source.fileName.includes("node_modules") && !source.fileName.includes("react-dom") && !source.fileName.includes("react/")) {
|
|
88
|
-
result = {
|
|
89
|
-
fileName: source.fileName,
|
|
90
|
-
lineNumber: source.lineNumber ?? 1,
|
|
91
|
-
columnNumber: source.columnNumber ?? 1,
|
|
92
|
-
functionName: source.functionName ?? (0, import_bippy.getDisplayName)(fiber) ?? void 0
|
|
93
|
-
};
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
} catch {
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
},
|
|
102
|
-
true
|
|
103
|
-
// Traverse upward (toward root)
|
|
104
|
-
);
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
function getComponentNameFromFiber(fiber) {
|
|
108
|
-
if (!fiber)
|
|
109
|
-
return "Unknown";
|
|
110
|
-
const displayName = (0, import_bippy.getDisplayName)(fiber);
|
|
111
|
-
if (displayName && displayName !== "Unknown") {
|
|
112
|
-
return displayName;
|
|
113
|
-
}
|
|
114
|
-
let componentName = "Unknown";
|
|
115
|
-
(0, import_bippy.traverseFiber)(
|
|
116
|
-
fiber,
|
|
117
|
-
(f) => {
|
|
118
|
-
if ((0, import_bippy.isCompositeFiber)(f)) {
|
|
119
|
-
const name = (0, import_bippy.getDisplayName)(f);
|
|
120
|
-
if (name && name !== "Unknown") {
|
|
121
|
-
componentName = name;
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return false;
|
|
126
|
-
},
|
|
127
|
-
true
|
|
128
|
-
// Traverse upward
|
|
129
|
-
);
|
|
130
|
-
return componentName;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/source-resolver.ts
|
|
134
|
-
var EDITOR_SCHEMES = {
|
|
135
|
-
vscode: "vscode://file/{path}:{line}:{column}",
|
|
136
|
-
"vscode-insiders": "vscode-insiders://file/{path}:{line}:{column}",
|
|
137
|
-
cursor: "cursor://file/{path}:{line}:{column}",
|
|
138
|
-
webstorm: "webstorm://open?file={path}&line={line}&column={column}",
|
|
139
|
-
atom: "atom://core/open/file?filename={path}&line={line}&column={column}",
|
|
140
|
-
sublime: "subl://open?url=file://{path}&line={line}&column={column}"
|
|
141
|
-
};
|
|
142
|
-
function buildEditorUrl(source, editor = "cursor", projectPath = "") {
|
|
143
|
-
const template = EDITOR_SCHEMES[editor] || EDITOR_SCHEMES.cursor;
|
|
144
|
-
let fullPath = normalizeFileName(source.fileName);
|
|
145
|
-
if (projectPath && !fullPath.startsWith("/")) {
|
|
146
|
-
const normalizedProjectPath = projectPath.endsWith("/") ? projectPath.slice(0, -1) : projectPath;
|
|
147
|
-
fullPath = `${normalizedProjectPath}/${fullPath}`;
|
|
148
|
-
}
|
|
149
|
-
return template.replace("{path}", fullPath).replace("{line}", String(source.lineNumber || 1)).replace("{column}", String(source.columnNumber || 1));
|
|
150
|
-
}
|
|
151
|
-
function normalizeFileName(fileName) {
|
|
152
|
-
if (!fileName)
|
|
153
|
-
return "";
|
|
154
|
-
let normalized = fileName;
|
|
155
|
-
const prefixPatterns = [
|
|
156
|
-
/^webpack:\/\/[^/]*\//,
|
|
157
|
-
/^webpack-internal:\/\/\//,
|
|
158
|
-
/^file:\/\//,
|
|
159
|
-
/^about:react/,
|
|
160
|
-
/^\.\//,
|
|
161
|
-
/^https?:\/\/localhost:\d+\//,
|
|
162
|
-
/^https?:\/\/[^/]+\/@fs\//,
|
|
163
|
-
/^https?:\/\/[^/]+\//,
|
|
164
|
-
/^\/@fs\//,
|
|
165
|
-
/^@fs\//
|
|
166
|
-
];
|
|
167
|
-
for (const pattern of prefixPatterns) {
|
|
168
|
-
normalized = normalized.replace(pattern, "");
|
|
169
|
-
}
|
|
170
|
-
normalized = normalized.split("?")[0].split("#")[0];
|
|
171
|
-
normalized = normalized.replace(/^\/+/, "/");
|
|
172
|
-
return normalized;
|
|
173
|
-
}
|
|
174
|
-
function isSourceFile(fileName) {
|
|
175
|
-
if (!fileName)
|
|
176
|
-
return false;
|
|
177
|
-
const normalized = normalizeFileName(fileName);
|
|
178
|
-
const excludePatterns = [
|
|
179
|
-
/node_modules/,
|
|
180
|
-
/react-dom/,
|
|
181
|
-
/^react\//,
|
|
182
|
-
/\.next\//,
|
|
183
|
-
/_next\//,
|
|
184
|
-
/webpack/,
|
|
185
|
-
/@vite\//,
|
|
186
|
-
/vite\/client/,
|
|
187
|
-
/\[eval\]/,
|
|
188
|
-
/<anonymous>/
|
|
189
|
-
];
|
|
190
|
-
for (const pattern of excludePatterns) {
|
|
191
|
-
if (pattern.test(normalized)) {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const includeExtensions = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".cjs"];
|
|
196
|
-
return includeExtensions.some(
|
|
197
|
-
(ext) => normalized.toLowerCase().endsWith(ext)
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
function getShortFileName(filePath) {
|
|
201
|
-
const normalized = normalizeFileName(filePath);
|
|
202
|
-
const parts = normalized.split("/");
|
|
203
|
-
return parts[parts.length - 1] || normalized;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// src/element-detector.ts
|
|
207
|
-
var detectorCleanup = null;
|
|
208
|
-
var isSetup = false;
|
|
209
|
-
function setupElementDetector(options) {
|
|
210
|
-
const { onElementSelected, modifier = "alt" } = options;
|
|
211
|
-
if (detectorCleanup) {
|
|
212
|
-
detectorCleanup();
|
|
213
|
-
}
|
|
214
|
-
isSetup = true;
|
|
215
|
-
const handleClick = async (event) => {
|
|
216
|
-
const modifierPressed = modifier === "alt" && event.altKey || modifier === "ctrl" && event.ctrlKey || modifier === "meta" && event.metaKey || modifier === "shift" && event.shiftKey;
|
|
217
|
-
if (!modifierPressed)
|
|
218
|
-
return;
|
|
219
|
-
event.preventDefault();
|
|
220
|
-
event.stopPropagation();
|
|
221
|
-
const target = event.target;
|
|
222
|
-
try {
|
|
223
|
-
const source = await getSourceFromElement(target);
|
|
224
|
-
if (source && source.fileName && isSourceFile(source.fileName)) {
|
|
225
|
-
const fiber = (0, import_bippy.getFiberFromHostInstance)(target);
|
|
226
|
-
const componentName = fiber ? getComponentNameFromFiber(fiber) : "Unknown";
|
|
227
|
-
const enrichedSource = {
|
|
228
|
-
...source,
|
|
229
|
-
functionName: source.functionName || componentName
|
|
230
|
-
};
|
|
231
|
-
onElementSelected(enrichedSource, target);
|
|
232
|
-
} else {
|
|
233
|
-
console.info(
|
|
234
|
-
"[UiDog Next] Could not find source for element. Falling back to DOM snapshot (likely server component or library code)."
|
|
235
|
-
);
|
|
236
|
-
onElementSelected(null, target);
|
|
237
|
-
}
|
|
238
|
-
} catch (error) {
|
|
239
|
-
console.warn("[UiDog Next] Error detecting element source:", error);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
const handleMouseMove = (event) => {
|
|
243
|
-
const modifierPressed = modifier === "alt" && event.altKey || modifier === "ctrl" && event.ctrlKey || modifier === "meta" && event.metaKey || modifier === "shift" && event.shiftKey;
|
|
244
|
-
if (!modifierPressed) {
|
|
245
|
-
removeHighlight();
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const target = event.target;
|
|
249
|
-
highlightElement(target);
|
|
250
|
-
};
|
|
251
|
-
const handleKeyUp = (event) => {
|
|
252
|
-
const relevantKey = modifier === "alt" && event.key === "Alt" || modifier === "ctrl" && event.key === "Control" || modifier === "meta" && event.key === "Meta" || modifier === "shift" && event.key === "Shift";
|
|
253
|
-
if (relevantKey) {
|
|
254
|
-
removeHighlight();
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
document.addEventListener("click", handleClick, true);
|
|
258
|
-
document.addEventListener("mousemove", handleMouseMove, true);
|
|
259
|
-
document.addEventListener("keyup", handleKeyUp, true);
|
|
260
|
-
detectorCleanup = () => {
|
|
261
|
-
document.removeEventListener("click", handleClick, true);
|
|
262
|
-
document.removeEventListener("mousemove", handleMouseMove, true);
|
|
263
|
-
document.removeEventListener("keyup", handleKeyUp, true);
|
|
264
|
-
removeHighlight();
|
|
265
|
-
isSetup = false;
|
|
266
|
-
};
|
|
267
|
-
return detectorCleanup;
|
|
268
|
-
}
|
|
269
|
-
var currentHighlight = null;
|
|
270
|
-
var highlightOverlay = null;
|
|
271
|
-
function highlightElement(element) {
|
|
272
|
-
if (element === highlightOverlay || highlightOverlay?.contains(element)) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
if (!highlightOverlay) {
|
|
276
|
-
highlightOverlay = document.createElement("div");
|
|
277
|
-
highlightOverlay.id = "uidog-highlight-overlay";
|
|
278
|
-
highlightOverlay.style.cssText = `
|
|
279
|
-
position: fixed;
|
|
280
|
-
pointer-events: none;
|
|
281
|
-
background: rgba(59, 130, 246, 0.2);
|
|
282
|
-
border: 2px solid rgba(59, 130, 246, 0.8);
|
|
283
|
-
border-radius: 4px;
|
|
284
|
-
z-index: 999998;
|
|
285
|
-
transition: all 0.1s ease-out;
|
|
286
|
-
`;
|
|
287
|
-
document.body.appendChild(highlightOverlay);
|
|
288
|
-
}
|
|
289
|
-
const rect = element.getBoundingClientRect();
|
|
290
|
-
highlightOverlay.style.top = `${rect.top}px`;
|
|
291
|
-
highlightOverlay.style.left = `${rect.left}px`;
|
|
292
|
-
highlightOverlay.style.width = `${rect.width}px`;
|
|
293
|
-
highlightOverlay.style.height = `${rect.height}px`;
|
|
294
|
-
highlightOverlay.style.display = "block";
|
|
295
|
-
currentHighlight = element;
|
|
296
|
-
}
|
|
297
|
-
function removeHighlight() {
|
|
298
|
-
if (highlightOverlay) {
|
|
299
|
-
highlightOverlay.style.display = "none";
|
|
300
|
-
}
|
|
301
|
-
currentHighlight = null;
|
|
302
|
-
}
|
|
303
|
-
function cleanupElementDetector() {
|
|
304
|
-
if (detectorCleanup) {
|
|
305
|
-
detectorCleanup();
|
|
306
|
-
detectorCleanup = null;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// src/sidebar-initializer.ts
|
|
311
|
-
var import_client2 = require("react-dom/client");
|
|
312
|
-
var import_react3 = require("react");
|
|
313
|
-
|
|
314
|
-
// src/components/UiDogSidebarReact.tsx
|
|
315
|
-
var import_react2 = require("react");
|
|
316
|
-
|
|
317
|
-
// src/components/ElementInfoDisplayReact.tsx
|
|
318
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
319
|
-
function ElementInfoDisplayReact(props) {
|
|
320
|
-
const isDomSnapshot = props.elementInfo.kind === "dom";
|
|
321
|
-
if (isDomSnapshot) {
|
|
322
|
-
const dom = props.elementInfo.domSnapshot;
|
|
323
|
-
const outerHTML = dom?.outerHTML || "No HTML available";
|
|
324
|
-
const text = dom?.text || "";
|
|
325
|
-
const attributes = dom?.attributes || {};
|
|
326
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "uidog-element-info", children: [
|
|
327
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "uidog-element-info-content", children: [
|
|
328
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uidog-file-location", children: "Server-rendered DOM (no source available)" }),
|
|
329
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
330
|
-
"button",
|
|
331
|
-
{
|
|
332
|
-
className: "uidog-close-btn",
|
|
333
|
-
onClick: props.onClose,
|
|
334
|
-
title: "Close sidebar (ESC)",
|
|
335
|
-
"aria-label": "Close sidebar",
|
|
336
|
-
children: "\xD7"
|
|
337
|
-
}
|
|
338
|
-
)
|
|
339
|
-
] }),
|
|
340
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "uidog-dom-snapshot", children: [
|
|
341
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uidog-dom-label", children: "outerHTML (trimmed):" }),
|
|
342
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "uidog-dom-snippet", children: outerHTML }),
|
|
343
|
-
text && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
344
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uidog-dom-label", children: "textContent (trimmed):" }),
|
|
345
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "uidog-dom-snippet", children: text })
|
|
346
|
-
] }),
|
|
347
|
-
Object.keys(attributes).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "uidog-dom-attributes", children: [
|
|
348
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uidog-dom-label", children: "attributes:" }),
|
|
349
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { children: Object.entries(attributes).map(([key, value]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
350
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: key }),
|
|
351
|
-
"=",
|
|
352
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: value })
|
|
353
|
-
] }, key)) })
|
|
354
|
-
] }),
|
|
355
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uidog-dom-hint", children: "To see file/line info, render this DOM through a small client boundary." })
|
|
356
|
-
] })
|
|
357
|
-
] });
|
|
358
|
-
}
|
|
359
|
-
const fileName = props.elementInfo.filePath?.split("/").pop() || "";
|
|
360
|
-
const fileLocation = `Selected element at ${fileName}`;
|
|
361
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "uidog-element-info", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "uidog-element-info-content", children: [
|
|
362
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "uidog-file-location", children: fileLocation }),
|
|
363
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
364
|
-
"button",
|
|
365
|
-
{
|
|
366
|
-
className: "uidog-close-btn",
|
|
367
|
-
onClick: props.onClose,
|
|
368
|
-
title: "Close sidebar (ESC)",
|
|
369
|
-
"aria-label": "Close sidebar",
|
|
370
|
-
children: "\xD7"
|
|
371
|
-
}
|
|
372
|
-
)
|
|
373
|
-
] }) });
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// src/components/ConversationalInputReact.tsx
|
|
377
|
-
var import_react = require("react");
|
|
378
|
-
|
|
379
|
-
// src/api/client.ts
|
|
380
|
-
async function sendChatPrompt(request, apiEndpoint = "http://localhost:3000") {
|
|
381
|
-
try {
|
|
382
|
-
const response = await fetch(`${apiEndpoint}/chat`, {
|
|
383
|
-
method: "POST",
|
|
384
|
-
headers: {
|
|
385
|
-
"Content-Type": "application/json"
|
|
386
|
-
},
|
|
387
|
-
body: JSON.stringify(request)
|
|
388
|
-
});
|
|
389
|
-
if (!response.ok) {
|
|
390
|
-
const errorData = await response.json().catch(() => ({ error: response.statusText }));
|
|
391
|
-
return {
|
|
392
|
-
ok: false,
|
|
393
|
-
message: "",
|
|
394
|
-
error: errorData.error || `API error (${response.status})`
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
return await response.json();
|
|
398
|
-
} catch (error) {
|
|
399
|
-
if (error instanceof Error) {
|
|
400
|
-
return {
|
|
401
|
-
ok: false,
|
|
402
|
-
message: "",
|
|
403
|
-
error: error.message
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
return {
|
|
407
|
-
ok: false,
|
|
408
|
-
message: "",
|
|
409
|
-
error: "Unknown error occurred"
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
async function sendToDeveloper(request, apiEndpoint = "http://localhost:3000") {
|
|
414
|
-
try {
|
|
415
|
-
const response = await fetch(`${apiEndpoint}/send-to-dev`, {
|
|
416
|
-
method: "POST",
|
|
417
|
-
headers: {
|
|
418
|
-
"Content-Type": "application/json"
|
|
419
|
-
},
|
|
420
|
-
body: JSON.stringify(request)
|
|
421
|
-
});
|
|
422
|
-
if (!response.ok) {
|
|
423
|
-
const errorData = await response.json().catch(() => ({ error: response.statusText }));
|
|
424
|
-
return {
|
|
425
|
-
ok: false,
|
|
426
|
-
error: errorData.error || `API error (${response.status})`
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
return await response.json();
|
|
430
|
-
} catch (error) {
|
|
431
|
-
if (error instanceof Error) {
|
|
432
|
-
return {
|
|
433
|
-
ok: false,
|
|
434
|
-
error: error.message
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
return {
|
|
438
|
-
ok: false,
|
|
439
|
-
error: "Unknown error occurred"
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
// src/components/ConversationalInputReact.tsx
|
|
445
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
446
|
-
function ConversationalInputReact(props) {
|
|
447
|
-
const [userInput, setUserInput] = (0, import_react.useState)("");
|
|
448
|
-
const [messages, setMessages] = (0, import_react.useState)([]);
|
|
449
|
-
const [isLoading, setIsLoading] = (0, import_react.useState)(false);
|
|
450
|
-
const [sessionId, setSessionId] = (0, import_react.useState)(void 0);
|
|
451
|
-
const [isCreatingPR, setIsCreatingPR] = (0, import_react.useState)(false);
|
|
452
|
-
const [prUrl, setPrUrl] = (0, import_react.useState)(null);
|
|
453
|
-
const textareaRef = (0, import_react.useRef)(null);
|
|
454
|
-
const messagesEndRef = (0, import_react.useRef)(null);
|
|
455
|
-
(0, import_react.useEffect)(() => {
|
|
456
|
-
textareaRef.current?.focus();
|
|
457
|
-
}, []);
|
|
458
|
-
(0, import_react.useEffect)(() => {
|
|
459
|
-
const textarea = textareaRef.current;
|
|
460
|
-
if (textarea) {
|
|
461
|
-
textarea.style.height = "auto";
|
|
462
|
-
textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`;
|
|
463
|
-
}
|
|
464
|
-
}, [userInput]);
|
|
465
|
-
(0, import_react.useEffect)(() => {
|
|
466
|
-
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
467
|
-
}, [messages]);
|
|
468
|
-
const handleSubmit = async () => {
|
|
469
|
-
const input = userInput.trim();
|
|
470
|
-
if (!input || isLoading)
|
|
471
|
-
return;
|
|
472
|
-
const userMessage = {
|
|
473
|
-
id: `user-${Date.now()}`,
|
|
474
|
-
role: "user",
|
|
475
|
-
content: input,
|
|
476
|
-
timestamp: Date.now()
|
|
477
|
-
};
|
|
478
|
-
setMessages((prev) => [...prev, userMessage]);
|
|
479
|
-
setUserInput("");
|
|
480
|
-
setIsLoading(true);
|
|
481
|
-
const loadingMessageId = `loading-${Date.now()}`;
|
|
482
|
-
const loadingMessage = {
|
|
483
|
-
id: loadingMessageId,
|
|
484
|
-
role: "assistant",
|
|
485
|
-
content: "",
|
|
486
|
-
timestamp: Date.now(),
|
|
487
|
-
isLoading: true
|
|
488
|
-
};
|
|
489
|
-
setMessages((prev) => [...prev, loadingMessage]);
|
|
490
|
-
const request = {
|
|
491
|
-
prompt: `The component selected by the user: ${props.editorUrl}
|
|
492
|
-
User request: ${input}
|
|
493
|
-
Update multiple files (if necessary) to achieve the user's request.`,
|
|
494
|
-
sessionId
|
|
495
|
-
};
|
|
496
|
-
try {
|
|
497
|
-
const result = await sendChatPrompt(
|
|
498
|
-
request,
|
|
499
|
-
props.apiEndpoint
|
|
500
|
-
);
|
|
501
|
-
if (result.sessionId && !sessionId) {
|
|
502
|
-
setSessionId(result.sessionId);
|
|
503
|
-
}
|
|
504
|
-
setMessages((prev) => {
|
|
505
|
-
const filtered = prev.filter((msg) => msg.id !== loadingMessageId);
|
|
506
|
-
const assistantMessage = {
|
|
507
|
-
id: `assistant-${Date.now()}`,
|
|
508
|
-
role: "assistant",
|
|
509
|
-
content: result.ok ? result.message : result.error || "Request failed",
|
|
510
|
-
timestamp: Date.now(),
|
|
511
|
-
error: !result.ok ? result.error : void 0
|
|
512
|
-
};
|
|
513
|
-
return [...filtered, assistantMessage];
|
|
514
|
-
});
|
|
515
|
-
} catch (err) {
|
|
516
|
-
setMessages((prev) => {
|
|
517
|
-
const filtered = prev.filter((msg) => msg.id !== loadingMessageId);
|
|
518
|
-
const errorMessage = {
|
|
519
|
-
id: `error-${Date.now()}`,
|
|
520
|
-
role: "assistant",
|
|
521
|
-
content: err instanceof Error ? err.message : "Unknown error occurred",
|
|
522
|
-
timestamp: Date.now(),
|
|
523
|
-
error: err instanceof Error ? err.message : "Unknown error occurred"
|
|
524
|
-
};
|
|
525
|
-
return [...filtered, errorMessage];
|
|
526
|
-
});
|
|
527
|
-
} finally {
|
|
528
|
-
setIsLoading(false);
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
const handleKeyDown = (e) => {
|
|
532
|
-
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
|
533
|
-
e.preventDefault();
|
|
534
|
-
handleSubmit();
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
const handleSendToDeveloper = async () => {
|
|
538
|
-
if (!sessionId || isCreatingPR)
|
|
539
|
-
return;
|
|
540
|
-
setIsCreatingPR(true);
|
|
541
|
-
setPrUrl(null);
|
|
542
|
-
try {
|
|
543
|
-
const result = await sendToDeveloper(
|
|
544
|
-
{ sessionId },
|
|
545
|
-
props.apiEndpoint
|
|
546
|
-
);
|
|
547
|
-
if (result.ok && result.prUrl) {
|
|
548
|
-
setPrUrl(result.prUrl);
|
|
549
|
-
const successMessage = {
|
|
550
|
-
id: `pr-success-${Date.now()}`,
|
|
551
|
-
role: "assistant",
|
|
552
|
-
content: `Pull request created successfully!`,
|
|
553
|
-
timestamp: Date.now()
|
|
554
|
-
};
|
|
555
|
-
setMessages((prev) => [...prev, successMessage]);
|
|
556
|
-
} else {
|
|
557
|
-
const errorMessage = {
|
|
558
|
-
id: `pr-error-${Date.now()}`,
|
|
559
|
-
role: "assistant",
|
|
560
|
-
content: result.error || "Failed to create pull request",
|
|
561
|
-
timestamp: Date.now(),
|
|
562
|
-
error: result.error || "Failed to create pull request"
|
|
563
|
-
};
|
|
564
|
-
setMessages((prev) => [...prev, errorMessage]);
|
|
565
|
-
}
|
|
566
|
-
} catch (err) {
|
|
567
|
-
const errorMessage = {
|
|
568
|
-
id: `pr-error-${Date.now()}`,
|
|
569
|
-
role: "assistant",
|
|
570
|
-
content: err instanceof Error ? err.message : "Unknown error occurred",
|
|
571
|
-
timestamp: Date.now(),
|
|
572
|
-
error: err instanceof Error ? err.message : "Unknown error occurred"
|
|
573
|
-
};
|
|
574
|
-
setMessages((prev) => [...prev, errorMessage]);
|
|
575
|
-
} finally {
|
|
576
|
-
setIsCreatingPR(false);
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
const handleRetry = async (messageId) => {
|
|
580
|
-
const errorIndex = messages.findIndex((msg) => msg.id === messageId);
|
|
581
|
-
if (errorIndex === -1)
|
|
582
|
-
return;
|
|
583
|
-
let userMessageIndex = -1;
|
|
584
|
-
for (let i = errorIndex - 1; i >= 0; i--) {
|
|
585
|
-
if (messages[i].role === "user") {
|
|
586
|
-
userMessageIndex = i;
|
|
587
|
-
break;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
if (userMessageIndex === -1)
|
|
591
|
-
return;
|
|
592
|
-
const userMessage = messages[userMessageIndex];
|
|
593
|
-
const input = userMessage.content;
|
|
594
|
-
setMessages((prev) => prev.filter((msg) => msg.id !== messageId));
|
|
595
|
-
setIsLoading(true);
|
|
596
|
-
const loadingMessageId = `loading-${Date.now()}`;
|
|
597
|
-
const loadingMessage = {
|
|
598
|
-
id: loadingMessageId,
|
|
599
|
-
role: "assistant",
|
|
600
|
-
content: "",
|
|
601
|
-
timestamp: Date.now(),
|
|
602
|
-
isLoading: true
|
|
603
|
-
};
|
|
604
|
-
setMessages((prev) => [...prev, loadingMessage]);
|
|
605
|
-
const request = {
|
|
606
|
-
prompt: `The component selected by the user: ${props.editorUrl}
|
|
607
|
-
User request: ${input}
|
|
608
|
-
Update multiple files (if necessary) to achieve the user's request.`,
|
|
609
|
-
sessionId
|
|
610
|
-
};
|
|
611
|
-
try {
|
|
612
|
-
const result = await sendChatPrompt(
|
|
613
|
-
request,
|
|
614
|
-
props.apiEndpoint
|
|
615
|
-
);
|
|
616
|
-
if (result.sessionId && !sessionId) {
|
|
617
|
-
setSessionId(result.sessionId);
|
|
618
|
-
}
|
|
619
|
-
setMessages((prev) => {
|
|
620
|
-
const filtered = prev.filter((msg) => msg.id !== loadingMessageId);
|
|
621
|
-
const assistantMessage = {
|
|
622
|
-
id: `assistant-${Date.now()}`,
|
|
623
|
-
role: "assistant",
|
|
624
|
-
content: result.ok ? result.message : result.error || "Request failed",
|
|
625
|
-
timestamp: Date.now(),
|
|
626
|
-
error: !result.ok ? result.error : void 0
|
|
627
|
-
};
|
|
628
|
-
return [...filtered, assistantMessage];
|
|
629
|
-
});
|
|
630
|
-
} catch (err) {
|
|
631
|
-
setMessages((prev) => {
|
|
632
|
-
const filtered = prev.filter((msg) => msg.id !== loadingMessageId);
|
|
633
|
-
const errorMessage = {
|
|
634
|
-
id: `error-${Date.now()}`,
|
|
635
|
-
role: "assistant",
|
|
636
|
-
content: err instanceof Error ? err.message : "Unknown error occurred",
|
|
637
|
-
timestamp: Date.now(),
|
|
638
|
-
error: err instanceof Error ? err.message : "Unknown error occurred"
|
|
639
|
-
};
|
|
640
|
-
return [...filtered, errorMessage];
|
|
641
|
-
});
|
|
642
|
-
} finally {
|
|
643
|
-
setIsLoading(false);
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
647
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "uidog-messages-container", children: [
|
|
648
|
-
messages.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-empty-state-text", children: "What changes would you like to make?" }) }),
|
|
649
|
-
messages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
650
|
-
"div",
|
|
651
|
-
{
|
|
652
|
-
className: `uidog-message uidog-message-${message.role}`,
|
|
653
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-message-bubble", children: message.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "uidog-message-loading", children: [
|
|
654
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-spinner" }),
|
|
655
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Processing your request..." })
|
|
656
|
-
] }) : message.error ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
657
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-message-content uidog-message-error", children: message.content }),
|
|
658
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
659
|
-
"button",
|
|
660
|
-
{
|
|
661
|
-
className: "uidog-retry-btn",
|
|
662
|
-
onClick: () => handleRetry(message.id),
|
|
663
|
-
children: "Retry"
|
|
664
|
-
}
|
|
665
|
-
)
|
|
666
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-message-content", children: message.content }) })
|
|
667
|
-
},
|
|
668
|
-
message.id
|
|
669
|
-
)),
|
|
670
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: messagesEndRef })
|
|
671
|
-
] }),
|
|
672
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "uidog-input-footer-fixed", children: [
|
|
673
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "uidog-input-wrapper", children: [
|
|
674
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
675
|
-
"textarea",
|
|
676
|
-
{
|
|
677
|
-
id: "uidog-textarea",
|
|
678
|
-
ref: textareaRef,
|
|
679
|
-
className: "uidog-textarea",
|
|
680
|
-
placeholder: "Describe the changes you want...",
|
|
681
|
-
value: userInput,
|
|
682
|
-
onChange: (e) => setUserInput(e.target.value),
|
|
683
|
-
onKeyDown: handleKeyDown,
|
|
684
|
-
disabled: isLoading
|
|
685
|
-
}
|
|
686
|
-
),
|
|
687
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
688
|
-
"button",
|
|
689
|
-
{
|
|
690
|
-
className: "uidog-submit-btn",
|
|
691
|
-
onClick: handleSubmit,
|
|
692
|
-
disabled: !userInput.trim() || isLoading,
|
|
693
|
-
title: "Send message (Cmd/Ctrl + Enter)",
|
|
694
|
-
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-spinner-small" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
695
|
-
"svg",
|
|
696
|
-
{
|
|
697
|
-
width: "16",
|
|
698
|
-
height: "16",
|
|
699
|
-
viewBox: "0 0 16 16",
|
|
700
|
-
fill: "none",
|
|
701
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
702
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
703
|
-
"path",
|
|
704
|
-
{
|
|
705
|
-
d: "M8 2L8 14M8 2L2 8M8 2L14 8",
|
|
706
|
-
stroke: "currentColor",
|
|
707
|
-
strokeWidth: "2",
|
|
708
|
-
strokeLinecap: "round",
|
|
709
|
-
strokeLinejoin: "round"
|
|
710
|
-
}
|
|
711
|
-
)
|
|
712
|
-
}
|
|
713
|
-
)
|
|
714
|
-
}
|
|
715
|
-
)
|
|
716
|
-
] }),
|
|
717
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-input-hint", children: "Cmd/Ctrl + Enter to submit" }),
|
|
718
|
-
sessionId && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "uidog-send-to-dev-section", children: [
|
|
719
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
720
|
-
"button",
|
|
721
|
-
{
|
|
722
|
-
className: "uidog-send-to-dev-btn",
|
|
723
|
-
onClick: handleSendToDeveloper,
|
|
724
|
-
disabled: isCreatingPR || isLoading,
|
|
725
|
-
title: "Create PR with changes",
|
|
726
|
-
children: isCreatingPR ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
727
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uidog-spinner-small" }),
|
|
728
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Creating PR..." })
|
|
729
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
730
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
731
|
-
"svg",
|
|
732
|
-
{
|
|
733
|
-
width: "16",
|
|
734
|
-
height: "16",
|
|
735
|
-
viewBox: "0 0 16 16",
|
|
736
|
-
fill: "none",
|
|
737
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
738
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
739
|
-
"path",
|
|
740
|
-
{
|
|
741
|
-
d: "M8 1L8 15M8 1L1 8M8 1L15 8",
|
|
742
|
-
stroke: "currentColor",
|
|
743
|
-
strokeWidth: "2",
|
|
744
|
-
strokeLinecap: "round",
|
|
745
|
-
strokeLinejoin: "round"
|
|
746
|
-
}
|
|
747
|
-
)
|
|
748
|
-
}
|
|
749
|
-
),
|
|
750
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Submit to Developer" })
|
|
751
|
-
] })
|
|
752
|
-
}
|
|
753
|
-
),
|
|
754
|
-
prUrl && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
755
|
-
"a",
|
|
756
|
-
{
|
|
757
|
-
href: prUrl,
|
|
758
|
-
target: "_blank",
|
|
759
|
-
rel: "noopener noreferrer",
|
|
760
|
-
className: "uidog-pr-link",
|
|
761
|
-
children: "View PR \u2192"
|
|
762
|
-
}
|
|
763
|
-
)
|
|
764
|
-
] })
|
|
765
|
-
] })
|
|
766
|
-
] });
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
// src/components/UiDogSidebarReact.tsx
|
|
770
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
771
|
-
function UiDogSidebarReact(props) {
|
|
772
|
-
(0, import_react2.useEffect)(() => {
|
|
773
|
-
const handleEscapeKey = (e) => {
|
|
774
|
-
if (e.key === "Escape") {
|
|
775
|
-
props.onClose();
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
document.addEventListener("keydown", handleEscapeKey);
|
|
779
|
-
return () => {
|
|
780
|
-
document.removeEventListener("keydown", handleEscapeKey);
|
|
781
|
-
};
|
|
782
|
-
}, [props]);
|
|
783
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "uidog-sidebar-overlay", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "uidog-sidebar", children: [
|
|
784
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "uidog-element-info-section", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
785
|
-
ElementInfoDisplayReact,
|
|
786
|
-
{
|
|
787
|
-
elementInfo: props.elementInfo,
|
|
788
|
-
onClose: props.onClose
|
|
789
|
-
}
|
|
790
|
-
) }),
|
|
791
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "uidog-chat-container", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
792
|
-
ConversationalInputReact,
|
|
793
|
-
{
|
|
794
|
-
elementInfo: props.elementInfo,
|
|
795
|
-
editorUrl: props.editorUrl,
|
|
796
|
-
apiEndpoint: props.apiEndpoint
|
|
797
|
-
}
|
|
798
|
-
) })
|
|
799
|
-
] }) });
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
// src/styles/sidebarStyles.ts
|
|
803
|
-
var sidebarStyles = `/* UiDog Sidebar Styles */
|
|
804
|
-
|
|
805
|
-
/* Overlay */
|
|
806
|
-
.uidog-sidebar-overlay {
|
|
807
|
-
position: fixed;
|
|
808
|
-
top: 0;
|
|
809
|
-
right: 0;
|
|
810
|
-
bottom: 0;
|
|
811
|
-
left: 0;
|
|
812
|
-
z-index: 999999;
|
|
813
|
-
pointer-events: none;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
/* Main Sidebar Container */
|
|
817
|
-
.uidog-sidebar {
|
|
818
|
-
position: fixed;
|
|
819
|
-
right: 0;
|
|
820
|
-
top: 0;
|
|
821
|
-
width: 420px;
|
|
822
|
-
max-width: 100vw;
|
|
823
|
-
height: 100vh;
|
|
824
|
-
background: #13140a;
|
|
825
|
-
box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
|
|
826
|
-
display: flex;
|
|
827
|
-
flex-direction: column;
|
|
828
|
-
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
829
|
-
font-size: 14px;
|
|
830
|
-
color: #ffffff;
|
|
831
|
-
pointer-events: auto;
|
|
832
|
-
animation: uidog-slide-in 0.3s ease-out;
|
|
833
|
-
overflow: hidden;
|
|
834
|
-
border-left: 1px solid rgba(255, 255, 255, 0.1);
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
@keyframes uidog-slide-in {
|
|
838
|
-
from {
|
|
839
|
-
transform: translateX(100%);
|
|
840
|
-
}
|
|
841
|
-
to {
|
|
842
|
-
transform: translateX(0);
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
/* Header */
|
|
847
|
-
.uidog-sidebar-header {
|
|
848
|
-
display: flex;
|
|
849
|
-
align-items: center;
|
|
850
|
-
justify-content: flex-end;
|
|
851
|
-
padding: 20px 24px;
|
|
852
|
-
border-bottom: 1px solid rgba(255, 255, 255, 0.15);
|
|
853
|
-
background: rgba(0, 0, 0, 0.3);
|
|
854
|
-
flex-shrink: 0;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
.uidog-sidebar-title {
|
|
858
|
-
margin: 0;
|
|
859
|
-
font-size: 18px;
|
|
860
|
-
font-weight: 600;
|
|
861
|
-
color: #ffffff;
|
|
862
|
-
letter-spacing: -0.01em;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
.uidog-close-btn {
|
|
866
|
-
width: 32px;
|
|
867
|
-
height: 32px;
|
|
868
|
-
border: none;
|
|
869
|
-
background: transparent;
|
|
870
|
-
font-size: 28px;
|
|
871
|
-
line-height: 1;
|
|
872
|
-
color: rgba(255, 255, 255, 0.7);
|
|
873
|
-
cursor: pointer;
|
|
874
|
-
border-radius: 4px;
|
|
875
|
-
display: flex;
|
|
876
|
-
align-items: center;
|
|
877
|
-
justify-content: center;
|
|
878
|
-
transition: all 0.2s;
|
|
879
|
-
flex-shrink: 0;
|
|
880
|
-
margin-left: 12px;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
.uidog-close-btn:hover {
|
|
884
|
-
background: rgba(255, 255, 255, 0.1);
|
|
885
|
-
color: #ffffff;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
/* Content Area */
|
|
889
|
-
.uidog-sidebar-content {
|
|
890
|
-
flex: 1;
|
|
891
|
-
overflow-y: auto;
|
|
892
|
-
overflow-x: hidden;
|
|
893
|
-
padding: 24px;
|
|
894
|
-
scrollbar-width: thin;
|
|
895
|
-
scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
.uidog-sidebar-content::-webkit-scrollbar {
|
|
899
|
-
width: 8px;
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
.uidog-sidebar-content::-webkit-scrollbar-track {
|
|
903
|
-
background: transparent;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
.uidog-sidebar-content::-webkit-scrollbar-thumb {
|
|
907
|
-
background: rgba(255, 255, 255, 0.2);
|
|
908
|
-
border-radius: 4px;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
.uidog-sidebar-content::-webkit-scrollbar-thumb:hover {
|
|
912
|
-
background: rgba(255, 255, 255, 0.3);
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
/* Element Info Section */
|
|
916
|
-
.uidog-element-info-section {
|
|
917
|
-
padding: 20px 24px;
|
|
918
|
-
border-bottom: 1px solid rgba(255, 255, 255, 0.15);
|
|
919
|
-
flex-shrink: 0;
|
|
920
|
-
background: rgba(0, 0, 0, 0.2);
|
|
921
|
-
margin-top: 0;
|
|
922
|
-
padding-top: 20px;
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
/* Element Info Section */
|
|
926
|
-
.uidog-element-info {
|
|
927
|
-
margin-bottom: 0;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
.uidog-element-info-header {
|
|
931
|
-
display: flex;
|
|
932
|
-
align-items: center;
|
|
933
|
-
justify-content: space-between;
|
|
934
|
-
margin-bottom: 12px;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
.uidog-element-info-title {
|
|
938
|
-
margin: 0;
|
|
939
|
-
font-size: 14px;
|
|
940
|
-
font-weight: 600;
|
|
941
|
-
color: rgba(255, 255, 255, 0.9);
|
|
942
|
-
text-transform: uppercase;
|
|
943
|
-
letter-spacing: 0.05em;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
.uidog-toggle-view-btn {
|
|
947
|
-
padding: 6px 14px;
|
|
948
|
-
font-size: 12px;
|
|
949
|
-
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
950
|
-
background: rgba(255, 255, 255, 0.1);
|
|
951
|
-
color: #ffffff;
|
|
952
|
-
border-radius: 6px;
|
|
953
|
-
cursor: pointer;
|
|
954
|
-
transition: all 0.2s;
|
|
955
|
-
font-weight: 500;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
.uidog-toggle-view-btn:hover {
|
|
959
|
-
background: rgba(255, 255, 255, 0.2);
|
|
960
|
-
border-color: rgba(255, 255, 255, 0.3);
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
.uidog-element-info-content {
|
|
964
|
-
background: rgba(0, 0, 0, 0.3);
|
|
965
|
-
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
966
|
-
border-radius: 8px;
|
|
967
|
-
padding: 16px;
|
|
968
|
-
display: flex;
|
|
969
|
-
align-items: center;
|
|
970
|
-
justify-content: space-between;
|
|
971
|
-
position: relative;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
.uidog-file-location {
|
|
975
|
-
font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
|
|
976
|
-
font-size: 13px;
|
|
977
|
-
color: #ffffff;
|
|
978
|
-
word-break: break-word;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
.uidog-info-row {
|
|
982
|
-
display: flex;
|
|
983
|
-
margin-bottom: 12px;
|
|
984
|
-
line-height: 1.6;
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
.uidog-info-row:last-of-type {
|
|
988
|
-
margin-bottom: 0;
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
.uidog-info-row:last-child {
|
|
992
|
-
margin-bottom: 0;
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
.uidog-info-label {
|
|
996
|
-
flex-shrink: 0;
|
|
997
|
-
width: 100px;
|
|
998
|
-
font-weight: 500;
|
|
999
|
-
color: rgba(255, 255, 255, 0.75);
|
|
1000
|
-
font-size: 13px;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
.uidog-info-value {
|
|
1004
|
-
flex: 1;
|
|
1005
|
-
color: #ffffff;
|
|
1006
|
-
word-break: break-word;
|
|
1007
|
-
font-size: 13px;
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
.uidog-component-name {
|
|
1011
|
-
font-weight: 600;
|
|
1012
|
-
color: #60a5fa;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
.uidog-file-path {
|
|
1016
|
-
font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
|
|
1017
|
-
font-size: 12px;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
.uidog-dom-snapshot {
|
|
1021
|
-
margin-top: 16px;
|
|
1022
|
-
background: rgba(255, 255, 255, 0.03);
|
|
1023
|
-
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
1024
|
-
border-radius: 8px;
|
|
1025
|
-
padding: 12px;
|
|
1026
|
-
display: flex;
|
|
1027
|
-
flex-direction: column;
|
|
1028
|
-
gap: 8px;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
.uidog-dom-label {
|
|
1032
|
-
color: rgba(255, 255, 255, 0.7);
|
|
1033
|
-
font-size: 12px;
|
|
1034
|
-
text-transform: uppercase;
|
|
1035
|
-
letter-spacing: 0.05em;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
.uidog-dom-snippet {
|
|
1039
|
-
margin: 0;
|
|
1040
|
-
background: rgba(0, 0, 0, 0.4);
|
|
1041
|
-
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
1042
|
-
border-radius: 6px;
|
|
1043
|
-
padding: 10px;
|
|
1044
|
-
color: rgba(255, 255, 255, 0.85);
|
|
1045
|
-
font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
|
|
1046
|
-
font-size: 12px;
|
|
1047
|
-
white-space: pre-wrap;
|
|
1048
|
-
word-break: break-word;
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
.uidog-dom-attributes ul {
|
|
1052
|
-
margin: 6px 0 0 0;
|
|
1053
|
-
padding-left: 16px;
|
|
1054
|
-
color: rgba(255, 255, 255, 0.85);
|
|
1055
|
-
font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
|
|
1056
|
-
font-size: 12px;
|
|
1057
|
-
word-break: break-word;
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
.uidog-dom-attributes code {
|
|
1061
|
-
background: rgba(255, 255, 255, 0.08);
|
|
1062
|
-
padding: 2px 4px;
|
|
1063
|
-
border-radius: 4px;
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
.uidog-dom-hint {
|
|
1067
|
-
color: rgba(255, 255, 255, 0.6);
|
|
1068
|
-
font-size: 12px;
|
|
1069
|
-
line-height: 1.5;
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
.uidog-mono {
|
|
1073
|
-
font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
|
|
1074
|
-
font-size: 12px;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
.uidog-detailed-section {
|
|
1078
|
-
margin-top: 12px;
|
|
1079
|
-
padding-top: 12px;
|
|
1080
|
-
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
.uidog-code-preview {
|
|
1084
|
-
flex-direction: column;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
.uidog-code-placeholder {
|
|
1088
|
-
margin-top: 6px;
|
|
1089
|
-
padding: 8px;
|
|
1090
|
-
background: rgba(0, 0, 0, 0.3);
|
|
1091
|
-
color: rgba(255, 255, 255, 0.8);
|
|
1092
|
-
border-radius: 4px;
|
|
1093
|
-
font-family: "SF Mono", Monaco, Menlo, Consolas, monospace;
|
|
1094
|
-
font-size: 12px;
|
|
1095
|
-
white-space: pre-wrap;
|
|
1096
|
-
word-break: break-word;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
/* Chat Container */
|
|
1100
|
-
.uidog-chat-container {
|
|
1101
|
-
flex: 1;
|
|
1102
|
-
display: flex;
|
|
1103
|
-
flex-direction: column;
|
|
1104
|
-
overflow: hidden;
|
|
1105
|
-
min-height: 0;
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
/* Messages Container */
|
|
1109
|
-
.uidog-messages-container {
|
|
1110
|
-
flex: 1;
|
|
1111
|
-
overflow-y: auto;
|
|
1112
|
-
overflow-x: hidden;
|
|
1113
|
-
padding: 20px 24px;
|
|
1114
|
-
scrollbar-width: thin;
|
|
1115
|
-
scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
.uidog-dom-banner {
|
|
1119
|
-
margin-bottom: 12px;
|
|
1120
|
-
padding: 12px 14px;
|
|
1121
|
-
background: rgba(255, 255, 255, 0.08);
|
|
1122
|
-
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
1123
|
-
border-radius: 8px;
|
|
1124
|
-
color: rgba(255, 255, 255, 0.85);
|
|
1125
|
-
font-size: 13px;
|
|
1126
|
-
line-height: 1.5;
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
.uidog-messages-container::-webkit-scrollbar {
|
|
1130
|
-
width: 8px;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
.uidog-messages-container::-webkit-scrollbar-track {
|
|
1134
|
-
background: transparent;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
.uidog-messages-container::-webkit-scrollbar-thumb {
|
|
1138
|
-
background: rgba(255, 255, 255, 0.2);
|
|
1139
|
-
border-radius: 4px;
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
.uidog-messages-container::-webkit-scrollbar-thumb:hover {
|
|
1143
|
-
background: rgba(255, 255, 255, 0.3);
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
/* Empty State */
|
|
1147
|
-
.uidog-empty-state {
|
|
1148
|
-
display: flex;
|
|
1149
|
-
align-items: center;
|
|
1150
|
-
justify-content: center;
|
|
1151
|
-
height: 100%;
|
|
1152
|
-
min-height: 200px;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
.uidog-empty-state-text {
|
|
1156
|
-
color: rgba(255, 255, 255, 0.6);
|
|
1157
|
-
font-size: 14px;
|
|
1158
|
-
text-align: center;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
/* Messages */
|
|
1162
|
-
.uidog-message {
|
|
1163
|
-
margin-bottom: 16px;
|
|
1164
|
-
display: flex;
|
|
1165
|
-
animation: uidog-message-fade-in 0.2s ease-out;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
@keyframes uidog-message-fade-in {
|
|
1169
|
-
from {
|
|
1170
|
-
opacity: 0;
|
|
1171
|
-
transform: translateY(4px);
|
|
1172
|
-
}
|
|
1173
|
-
to {
|
|
1174
|
-
opacity: 1;
|
|
1175
|
-
transform: translateY(0);
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
.uidog-message-user {
|
|
1180
|
-
justify-content: flex-end;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
.uidog-message-assistant {
|
|
1184
|
-
justify-content: flex-start;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
/* Message Bubbles */
|
|
1188
|
-
.uidog-message-bubble {
|
|
1189
|
-
max-width: 80%;
|
|
1190
|
-
padding: 12px 16px;
|
|
1191
|
-
border-radius: 12px;
|
|
1192
|
-
word-wrap: break-word;
|
|
1193
|
-
overflow-wrap: break-word;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
.uidog-message-user .uidog-message-bubble {
|
|
1197
|
-
background: rgba(59, 130, 246, 0.2);
|
|
1198
|
-
border: 1px solid rgba(59, 130, 246, 0.3);
|
|
1199
|
-
color: #93c5fd;
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
.uidog-message-assistant .uidog-message-bubble {
|
|
1203
|
-
background: rgba(255, 255, 255, 0.08);
|
|
1204
|
-
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
1205
|
-
color: rgba(255, 255, 255, 0.9);
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
.uidog-message-content {
|
|
1209
|
-
line-height: 1.6;
|
|
1210
|
-
white-space: pre-wrap;
|
|
1211
|
-
word-break: break-word;
|
|
1212
|
-
font-size: 14px;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
.uidog-message-content.uidog-message-error {
|
|
1216
|
-
color: #fca5a5;
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
/* Loading Message */
|
|
1220
|
-
.uidog-message-loading {
|
|
1221
|
-
display: flex;
|
|
1222
|
-
align-items: center;
|
|
1223
|
-
gap: 10px;
|
|
1224
|
-
color: rgba(255, 255, 255, 0.7);
|
|
1225
|
-
font-size: 14px;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
.uidog-spinner {
|
|
1229
|
-
width: 16px;
|
|
1230
|
-
height: 16px;
|
|
1231
|
-
border: 2px solid rgba(255, 255, 255, 0.2);
|
|
1232
|
-
border-top-color: rgba(255, 255, 255, 0.8);
|
|
1233
|
-
border-radius: 50%;
|
|
1234
|
-
animation: uidog-spin 0.8s linear infinite;
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
.uidog-spinner-small {
|
|
1238
|
-
width: 14px;
|
|
1239
|
-
height: 14px;
|
|
1240
|
-
border: 2px solid rgba(255, 255, 255, 0.3);
|
|
1241
|
-
border-top-color: #ffffff;
|
|
1242
|
-
border-radius: 50%;
|
|
1243
|
-
animation: uidog-spin 0.8s linear infinite;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
@keyframes uidog-spin {
|
|
1247
|
-
to {
|
|
1248
|
-
transform: rotate(360deg);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
/* Fixed Input Footer */
|
|
1253
|
-
.uidog-input-footer-fixed {
|
|
1254
|
-
flex-shrink: 0;
|
|
1255
|
-
padding: 16px 24px;
|
|
1256
|
-
border-top: 1px solid rgba(255, 255, 255, 0.15);
|
|
1257
|
-
background: rgba(0, 0, 0, 0.3);
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
.uidog-input-wrapper {
|
|
1261
|
-
position: relative;
|
|
1262
|
-
margin-bottom: 8px;
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
.uidog-textarea {
|
|
1266
|
-
width: 100%;
|
|
1267
|
-
padding: 10px 60px 10px 14px;
|
|
1268
|
-
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
1269
|
-
border-radius: 8px;
|
|
1270
|
-
font-family: inherit;
|
|
1271
|
-
font-size: 14px;
|
|
1272
|
-
line-height: 1.5;
|
|
1273
|
-
resize: none;
|
|
1274
|
-
min-height: 44px;
|
|
1275
|
-
max-height: 200px;
|
|
1276
|
-
background: rgba(0, 0, 0, 0.4);
|
|
1277
|
-
color: #ffffff;
|
|
1278
|
-
transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
|
|
1279
|
-
box-sizing: border-box;
|
|
1280
|
-
overflow-wrap: break-word;
|
|
1281
|
-
word-wrap: break-word;
|
|
1282
|
-
overflow-y: auto;
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
.uidog-textarea::placeholder {
|
|
1286
|
-
color: rgba(255, 255, 255, 0.5);
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
.uidog-textarea:focus {
|
|
1290
|
-
outline: none;
|
|
1291
|
-
border-color: #60a5fa;
|
|
1292
|
-
background: rgba(0, 0, 0, 0.5);
|
|
1293
|
-
box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
.uidog-textarea:disabled {
|
|
1297
|
-
background: rgba(0, 0, 0, 0.2);
|
|
1298
|
-
color: rgba(255, 255, 255, 0.5);
|
|
1299
|
-
cursor: not-allowed;
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
.uidog-submit-btn {
|
|
1303
|
-
position: absolute;
|
|
1304
|
-
bottom: 10px;
|
|
1305
|
-
right: 6px;
|
|
1306
|
-
width: 32px;
|
|
1307
|
-
height: 32px;
|
|
1308
|
-
display: flex;
|
|
1309
|
-
align-items: center;
|
|
1310
|
-
justify-content: center;
|
|
1311
|
-
padding: 0;
|
|
1312
|
-
font-size: 14px;
|
|
1313
|
-
font-weight: 500;
|
|
1314
|
-
color: #ffffff;
|
|
1315
|
-
background: #3b82f6;
|
|
1316
|
-
border: none;
|
|
1317
|
-
border-radius: 6px;
|
|
1318
|
-
cursor: pointer;
|
|
1319
|
-
transition: all 0.2s;
|
|
1320
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
.uidog-submit-btn:active {
|
|
1324
|
-
transform: translateY(1px);
|
|
1325
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
.uidog-submit-btn:hover:not(:disabled) {
|
|
1329
|
-
background: #2563eb;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
.uidog-submit-btn:disabled {
|
|
1333
|
-
background: rgba(255, 255, 255, 0.1);
|
|
1334
|
-
color: rgba(255, 255, 255, 0.3);
|
|
1335
|
-
cursor: not-allowed;
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
.uidog-submit-btn svg {
|
|
1339
|
-
stroke: currentColor;
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
.uidog-input-hint {
|
|
1343
|
-
font-size: 11px;
|
|
1344
|
-
color: rgba(255, 255, 255, 0.5);
|
|
1345
|
-
text-align: center;
|
|
1346
|
-
margin-top: 4px;
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
.uidog-retry-btn {
|
|
1350
|
-
margin-top: 8px;
|
|
1351
|
-
padding: 6px 12px;
|
|
1352
|
-
font-size: 12px;
|
|
1353
|
-
font-weight: 500;
|
|
1354
|
-
color: #ffffff;
|
|
1355
|
-
background: #ef4444;
|
|
1356
|
-
border: none;
|
|
1357
|
-
border-radius: 6px;
|
|
1358
|
-
cursor: pointer;
|
|
1359
|
-
transition: background 0.2s;
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
.uidog-retry-btn:hover {
|
|
1363
|
-
background: #dc2626;
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
/* Footer */
|
|
1367
|
-
.uidog-sidebar-footer {
|
|
1368
|
-
padding: 16px 24px;
|
|
1369
|
-
border-top: 1px solid rgba(255, 255, 255, 0.15);
|
|
1370
|
-
background: rgba(0, 0, 0, 0.3);
|
|
1371
|
-
text-align: center;
|
|
1372
|
-
flex-shrink: 0;
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
.uidog-footer-text {
|
|
1376
|
-
font-size: 12px;
|
|
1377
|
-
color: rgba(255, 255, 255, 0.7);
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
.uidog-footer-link {
|
|
1381
|
-
color: #60a5fa;
|
|
1382
|
-
text-decoration: none;
|
|
1383
|
-
font-weight: 500;
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
.uidog-footer-link:hover {
|
|
1387
|
-
text-decoration: underline;
|
|
1388
|
-
color: #93c5fd;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
/* Mobile Responsive */
|
|
1392
|
-
@media (max-width: 768px) {
|
|
1393
|
-
.uidog-sidebar {
|
|
1394
|
-
width: 100vw;
|
|
1395
|
-
}
|
|
1396
|
-
}`;
|
|
1397
|
-
var sidebarStyles_default = sidebarStyles;
|
|
1398
|
-
|
|
1399
|
-
// src/sidebar-initializer.ts
|
|
1400
|
-
var sidebarRoot = null;
|
|
1401
|
-
var sidebarContainer = null;
|
|
1402
|
-
var shadowRoot = null;
|
|
1403
|
-
var config = { apiEndpoint: "https://api.ui.dog" };
|
|
1404
|
-
var currentState = {
|
|
1405
|
-
isOpen: false,
|
|
1406
|
-
elementInfo: null,
|
|
1407
|
-
editorUrl: ""
|
|
1408
|
-
};
|
|
1409
|
-
function initializeSidebar(sidebarConfig) {
|
|
1410
|
-
if (typeof window === "undefined")
|
|
1411
|
-
return;
|
|
1412
|
-
config = sidebarConfig;
|
|
1413
|
-
if (document.getElementById("uidog-next-sidebar-root")) {
|
|
1414
|
-
return;
|
|
1415
|
-
}
|
|
1416
|
-
sidebarContainer = document.createElement("div");
|
|
1417
|
-
sidebarContainer.id = "uidog-next-sidebar-root";
|
|
1418
|
-
document.body.appendChild(sidebarContainer);
|
|
1419
|
-
shadowRoot = sidebarContainer.attachShadow({ mode: "open" });
|
|
1420
|
-
const styleElement = document.createElement("style");
|
|
1421
|
-
styleElement.textContent = sidebarStyles_default;
|
|
1422
|
-
shadowRoot.appendChild(styleElement);
|
|
1423
|
-
const mountPoint = document.createElement("div");
|
|
1424
|
-
mountPoint.id = "uidog-sidebar-mount";
|
|
1425
|
-
shadowRoot.appendChild(mountPoint);
|
|
1426
|
-
sidebarRoot = (0, import_client2.createRoot)(mountPoint);
|
|
1427
|
-
render();
|
|
1428
|
-
}
|
|
1429
|
-
function render() {
|
|
1430
|
-
if (!sidebarRoot)
|
|
1431
|
-
return;
|
|
1432
|
-
const { isOpen, elementInfo, editorUrl } = currentState;
|
|
1433
|
-
if (!isOpen || !elementInfo) {
|
|
1434
|
-
sidebarRoot.render(null);
|
|
1435
|
-
return;
|
|
1436
|
-
}
|
|
1437
|
-
sidebarRoot.render(
|
|
1438
|
-
(0, import_react3.createElement)(UiDogSidebarReact, {
|
|
1439
|
-
elementInfo,
|
|
1440
|
-
editorUrl,
|
|
1441
|
-
onClose: closeSidebar,
|
|
1442
|
-
apiEndpoint: config.apiEndpoint
|
|
1443
|
-
})
|
|
1444
|
-
);
|
|
1445
|
-
}
|
|
1446
|
-
function openSidebar(elementInfo, editorUrl) {
|
|
1447
|
-
currentState = {
|
|
1448
|
-
isOpen: true,
|
|
1449
|
-
elementInfo,
|
|
1450
|
-
editorUrl
|
|
1451
|
-
};
|
|
1452
|
-
if (typeof window !== "undefined") {
|
|
1453
|
-
window.__UIDOG_SIDEBAR__ = {
|
|
1454
|
-
isOpen: true,
|
|
1455
|
-
elementInfo,
|
|
1456
|
-
editorUrl
|
|
1457
|
-
};
|
|
1458
|
-
}
|
|
1459
|
-
render();
|
|
1460
|
-
}
|
|
1461
|
-
function closeSidebar() {
|
|
1462
|
-
currentState = {
|
|
1463
|
-
isOpen: false,
|
|
1464
|
-
elementInfo: null,
|
|
1465
|
-
editorUrl: ""
|
|
1466
|
-
};
|
|
1467
|
-
if (typeof window !== "undefined") {
|
|
1468
|
-
window.__UIDOG_SIDEBAR__ = {
|
|
1469
|
-
isOpen: false,
|
|
1470
|
-
elementInfo: null,
|
|
1471
|
-
editorUrl: null
|
|
1472
|
-
};
|
|
1473
|
-
}
|
|
1474
|
-
render();
|
|
1475
|
-
}
|
|
1476
|
-
function cleanupSidebar() {
|
|
1477
|
-
if (sidebarRoot) {
|
|
1478
|
-
sidebarRoot.unmount();
|
|
1479
|
-
sidebarRoot = null;
|
|
1480
|
-
}
|
|
1481
|
-
if (sidebarContainer && sidebarContainer.parentNode) {
|
|
1482
|
-
sidebarContainer.parentNode.removeChild(sidebarContainer);
|
|
1483
|
-
sidebarContainer = null;
|
|
1484
|
-
}
|
|
1485
|
-
shadowRoot = null;
|
|
1486
|
-
currentState = {
|
|
1487
|
-
isOpen: false,
|
|
1488
|
-
elementInfo: null,
|
|
1489
|
-
editorUrl: ""
|
|
1490
|
-
};
|
|
1491
|
-
if (typeof window !== "undefined") {
|
|
1492
|
-
delete window.__UIDOG_SIDEBAR__;
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
// src/index.ts
|
|
1497
|
-
var isInitialized = false;
|
|
1498
|
-
function initializeUiDogNext(options = {}) {
|
|
1499
|
-
if (typeof window === "undefined")
|
|
1500
|
-
return;
|
|
1501
|
-
if (isInitialized) {
|
|
1502
|
-
console.warn("[UiDog Next] Already initialized");
|
|
1503
|
-
return;
|
|
1504
|
-
}
|
|
1505
|
-
if (process.env.NODE_ENV === "production") {
|
|
1506
|
-
console.warn(
|
|
1507
|
-
"[UiDog Next] Running in production mode. Element source detection may not work as _debugSource is stripped in production builds."
|
|
1508
|
-
);
|
|
1509
|
-
}
|
|
1510
|
-
const {
|
|
1511
|
-
editor = "cursor",
|
|
1512
|
-
projectPath = "",
|
|
1513
|
-
modifier = "alt",
|
|
1514
|
-
enableSidebar = true,
|
|
1515
|
-
apiEndpoint = "https://api.ui.dog"
|
|
1516
|
-
} = options;
|
|
1517
|
-
isInitialized = true;
|
|
1518
|
-
window.__UIDOG_NEXT_INITIALIZED__ = true;
|
|
1519
|
-
setupBippyInstrumentation();
|
|
1520
|
-
if (enableSidebar) {
|
|
1521
|
-
initializeSidebar({ apiEndpoint });
|
|
1522
|
-
}
|
|
1523
|
-
setupElementDetector({
|
|
1524
|
-
modifier,
|
|
1525
|
-
onElementSelected: (source, element) => {
|
|
1526
|
-
const rect = element.getBoundingClientRect ? element.getBoundingClientRect() : null;
|
|
1527
|
-
const buildDomSnapshot = () => {
|
|
1528
|
-
const outerHTML = element.outerHTML || "";
|
|
1529
|
-
const text = (element.textContent || "").trim();
|
|
1530
|
-
const attributes = {};
|
|
1531
|
-
Array.from(element.attributes || []).forEach((attr) => {
|
|
1532
|
-
attributes[attr.name] = attr.value;
|
|
1533
|
-
});
|
|
1534
|
-
return {
|
|
1535
|
-
outerHTML: outerHTML.length > 4e3 ? `${outerHTML.slice(0, 4e3)}\u2026` : outerHTML,
|
|
1536
|
-
text: text.length > 1e3 ? `${text.slice(0, 1e3)}\u2026` : text,
|
|
1537
|
-
attributes
|
|
1538
|
-
};
|
|
1539
|
-
};
|
|
1540
|
-
if (source) {
|
|
1541
|
-
const editorUrl = buildEditorUrl(source, editor, projectPath);
|
|
1542
|
-
console.info(
|
|
1543
|
-
"[UiDog Next] Source detected:",
|
|
1544
|
-
normalizeFileName(source.fileName),
|
|
1545
|
-
"line",
|
|
1546
|
-
source.lineNumber,
|
|
1547
|
-
"column",
|
|
1548
|
-
source.columnNumber
|
|
1549
|
-
);
|
|
1550
|
-
if (enableSidebar) {
|
|
1551
|
-
const elementInfo = {
|
|
1552
|
-
kind: "source",
|
|
1553
|
-
componentName: source.functionName || "Unknown",
|
|
1554
|
-
filePath: normalizeFileName(source.fileName),
|
|
1555
|
-
line: source.lineNumber,
|
|
1556
|
-
column: source.columnNumber,
|
|
1557
|
-
box: rect ? {
|
|
1558
|
-
x: rect.x,
|
|
1559
|
-
y: rect.y,
|
|
1560
|
-
width: rect.width,
|
|
1561
|
-
height: rect.height
|
|
1562
|
-
} : void 0
|
|
1563
|
-
};
|
|
1564
|
-
openSidebar(elementInfo, editorUrl);
|
|
1565
|
-
} else {
|
|
1566
|
-
console.log("[UiDog Next] Element selected:");
|
|
1567
|
-
console.log(" Component:", source.functionName || "Unknown");
|
|
1568
|
-
console.log(" File:", source.fileName);
|
|
1569
|
-
console.log(" Line:", source.lineNumber);
|
|
1570
|
-
console.log(" Column:", source.columnNumber);
|
|
1571
|
-
console.log(" Editor URL:", editorUrl);
|
|
1572
|
-
}
|
|
1573
|
-
} else {
|
|
1574
|
-
const domSnapshot = buildDomSnapshot();
|
|
1575
|
-
console.info("[UiDog Next] DOM snapshot (no source):", {
|
|
1576
|
-
outerHTML: domSnapshot.outerHTML,
|
|
1577
|
-
text: domSnapshot.text,
|
|
1578
|
-
attributes: domSnapshot.attributes,
|
|
1579
|
-
box: rect ? {
|
|
1580
|
-
x: rect.x,
|
|
1581
|
-
y: rect.y,
|
|
1582
|
-
width: rect.width,
|
|
1583
|
-
height: rect.height
|
|
1584
|
-
} : void 0
|
|
1585
|
-
});
|
|
1586
|
-
const elementInfo = {
|
|
1587
|
-
kind: "dom",
|
|
1588
|
-
componentName: "Server-rendered element",
|
|
1589
|
-
domSnapshot,
|
|
1590
|
-
box: rect ? {
|
|
1591
|
-
x: rect.x,
|
|
1592
|
-
y: rect.y,
|
|
1593
|
-
width: rect.width,
|
|
1594
|
-
height: rect.height
|
|
1595
|
-
} : void 0
|
|
1596
|
-
};
|
|
1597
|
-
if (enableSidebar) {
|
|
1598
|
-
openSidebar(elementInfo, "");
|
|
1599
|
-
} else {
|
|
1600
|
-
console.log("[UiDog Next] Element selected (DOM snapshot):");
|
|
1601
|
-
console.log(" outerHTML:", domSnapshot.outerHTML);
|
|
1602
|
-
console.log(" text:", domSnapshot.text);
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
});
|
|
1607
|
-
console.log(
|
|
1608
|
-
`[UiDog Next] Initialized (${modifier}+click to select elements)`
|
|
1609
|
-
);
|
|
1610
|
-
}
|
|
1611
|
-
function cleanupUiDogNext() {
|
|
1612
|
-
cleanupElementDetector();
|
|
1613
|
-
cleanupSidebar();
|
|
1614
|
-
isInitialized = false;
|
|
1615
|
-
if (typeof window !== "undefined") {
|
|
1616
|
-
window.__UIDOG_NEXT_INITIALIZED__ = false;
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
function isUiDogNextInitialized() {
|
|
1620
|
-
return isInitialized;
|
|
1621
|
-
}
|
|
1622
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1623
|
-
0 && (module.exports = {
|
|
1624
|
-
buildEditorUrl,
|
|
1625
|
-
cleanupUiDogNext,
|
|
1626
|
-
closeSidebar,
|
|
1627
|
-
getComponentNameFromFiber,
|
|
1628
|
-
getShortFileName,
|
|
1629
|
-
getSourceFromElement,
|
|
1630
|
-
initializeUiDogNext,
|
|
1631
|
-
isUiDogNextInitialized,
|
|
1632
|
-
normalizeFileName,
|
|
1633
|
-
openSidebar,
|
|
1634
|
-
setupBippyInstrumentation
|
|
1635
|
-
});
|