fixdog 0.0.1
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 +478 -0
- package/USAGE.md +77 -0
- package/dist/client/index.d.mts +110 -0
- package/dist/client/index.d.ts +110 -0
- package/dist/client/index.js +1601 -0
- package/dist/client/index.mjs +1582 -0
- package/dist/client/init.d.mts +67 -0
- package/dist/client/init.d.ts +67 -0
- package/dist/client/init.js +1609 -0
- package/dist/client/init.mjs +1593 -0
- package/dist/index.d.mts +158 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +1635 -0
- package/dist/index.mjs +1606 -0
- package/package.json +57 -0
- package/src/api/client.ts +141 -0
- package/src/client/index.ts +75 -0
- package/src/client/init.tsx +78 -0
- package/src/components/ConversationalInputReact.tsx +406 -0
- package/src/components/ElementInfoDisplayReact.tsx +84 -0
- package/src/components/UiDogSidebarReact.tsx +49 -0
- package/src/element-detector.ts +186 -0
- package/src/index.ts +228 -0
- package/src/instrument.ts +171 -0
- package/src/sidebar-initializer.ts +171 -0
- package/src/source-resolver.ts +121 -0
- package/src/styles/sidebarStyles.ts +597 -0
- package/src/types/css.d.ts +9 -0
- package/src/types/sidebar.ts +56 -0
- package/src/types.ts +119 -0
- package/tsconfig.json +23 -0
- package/tsup.config.ts +40 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
type ElementInfoKind = "source" | "dom";
|
|
2
|
+
interface DomSnapshot {
|
|
3
|
+
outerHTML: string;
|
|
4
|
+
text: string;
|
|
5
|
+
attributes: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
interface ElementInfo {
|
|
8
|
+
kind: ElementInfoKind;
|
|
9
|
+
componentName?: string;
|
|
10
|
+
filePath?: string;
|
|
11
|
+
line?: number;
|
|
12
|
+
column?: number;
|
|
13
|
+
domSnapshot?: DomSnapshot;
|
|
14
|
+
box?: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface SourceLocation {
|
|
22
|
+
fileName: string;
|
|
23
|
+
lineNumber: number;
|
|
24
|
+
columnNumber: number;
|
|
25
|
+
functionName?: string;
|
|
26
|
+
}
|
|
27
|
+
type EditorType = "vscode" | "vscode-insiders" | "cursor" | "webstorm" | "atom" | "sublime";
|
|
28
|
+
interface UiDogNextOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Editor to open when clicking elements
|
|
31
|
+
* @default 'cursor'
|
|
32
|
+
*/
|
|
33
|
+
editor?: EditorType;
|
|
34
|
+
/**
|
|
35
|
+
* Project root path for resolving file paths
|
|
36
|
+
*/
|
|
37
|
+
projectPath?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Modifier key for element selection
|
|
40
|
+
* @default 'alt'
|
|
41
|
+
*/
|
|
42
|
+
modifier?: "alt" | "ctrl" | "meta" | "shift";
|
|
43
|
+
/**
|
|
44
|
+
* Enable sidebar mode
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
enableSidebar?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* API endpoint for edit requests
|
|
50
|
+
* @default 'https://api.ui.dog'
|
|
51
|
+
*/
|
|
52
|
+
apiEndpoint?: string;
|
|
53
|
+
}
|
|
54
|
+
interface SidebarConfig {
|
|
55
|
+
apiEndpoint: string;
|
|
56
|
+
}
|
|
57
|
+
interface EditRequest {
|
|
58
|
+
editorUrl: string;
|
|
59
|
+
userInput: string;
|
|
60
|
+
/**
|
|
61
|
+
* Optional metadata to help when source is unavailable (e.g., server components)
|
|
62
|
+
*/
|
|
63
|
+
elementKind?: ElementInfoKind;
|
|
64
|
+
domSnapshot?: DomSnapshot;
|
|
65
|
+
}
|
|
66
|
+
interface EditResponse {
|
|
67
|
+
sessionId: string;
|
|
68
|
+
message: string;
|
|
69
|
+
status: "success" | "error";
|
|
70
|
+
error?: string;
|
|
71
|
+
}
|
|
72
|
+
declare global {
|
|
73
|
+
interface Window {
|
|
74
|
+
__UIDOG_NEXT_INITIALIZED__?: boolean;
|
|
75
|
+
__UIDOG_SIDEBAR__?: {
|
|
76
|
+
isOpen: boolean;
|
|
77
|
+
elementInfo: ElementInfo | null;
|
|
78
|
+
editorUrl: string | null;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Source resolver - builds editor URLs from source location information
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Build an editor URL from source location information
|
|
89
|
+
*/
|
|
90
|
+
declare function buildEditorUrl(source: SourceLocation, editor?: EditorType, projectPath?: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Normalize file name by removing bundler prefixes and query strings
|
|
93
|
+
*/
|
|
94
|
+
declare function normalizeFileName(fileName: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Get the file name without path for display
|
|
97
|
+
*/
|
|
98
|
+
declare function getShortFileName(filePath: string): string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Sidebar initializer - mounts the UiDog sidebar in a shadow DOM for style isolation
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Open the sidebar with element information
|
|
106
|
+
*/
|
|
107
|
+
declare function openSidebar(elementInfo: ElementInfo, editorUrl: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* Close the sidebar
|
|
110
|
+
*/
|
|
111
|
+
declare function closeSidebar(): void;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Bippy instrumentation setup for React fiber inspection
|
|
115
|
+
*
|
|
116
|
+
* Bippy hooks into React's DevTools API (window.__REACT_DEVTOOLS_GLOBAL_HOOK__)
|
|
117
|
+
* to intercept fiber tree data and extract source location information.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Setup Bippy instrumentation to hook into React's internals
|
|
122
|
+
* This must be called BEFORE React loads (via instrumentation-client.ts)
|
|
123
|
+
*/
|
|
124
|
+
declare function setupBippyInstrumentation(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Get source location from a DOM element by traversing its React fiber
|
|
127
|
+
*/
|
|
128
|
+
declare function getSourceFromElement(element: Element): Promise<SourceLocation | null>;
|
|
129
|
+
/**
|
|
130
|
+
* Get component name from a fiber
|
|
131
|
+
*/
|
|
132
|
+
declare function getComponentNameFromFiber(fiber: any): string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* UiDog SDK for Next.js - Main entry point
|
|
136
|
+
*
|
|
137
|
+
* Uses Bippy to hook into React's internals for element source detection,
|
|
138
|
+
* providing a seamless developer experience for inspecting component locations.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Initialize UiDog for Next.js
|
|
143
|
+
*
|
|
144
|
+
* This function sets up Bippy instrumentation, element detection, and the sidebar UI.
|
|
145
|
+
* It should be called early in your application's lifecycle, ideally via
|
|
146
|
+
* instrumentation-client.ts (Next.js 15.3+) or at the top of _app.tsx.
|
|
147
|
+
*/
|
|
148
|
+
declare function initializeUiDogNext(options?: UiDogNextOptions): void;
|
|
149
|
+
/**
|
|
150
|
+
* Cleanup UiDog - removes all event listeners and UI
|
|
151
|
+
*/
|
|
152
|
+
declare function cleanupUiDogNext(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Check if UiDog is initialized
|
|
155
|
+
*/
|
|
156
|
+
declare function isUiDogNextInitialized(): boolean;
|
|
157
|
+
|
|
158
|
+
export { EditRequest, EditResponse, EditorType, ElementInfo, SidebarConfig, SourceLocation, UiDogNextOptions, buildEditorUrl, cleanupUiDogNext, closeSidebar, getComponentNameFromFiber, getShortFileName, getSourceFromElement, initializeUiDogNext, isUiDogNextInitialized, normalizeFileName, openSidebar, setupBippyInstrumentation };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
type ElementInfoKind = "source" | "dom";
|
|
2
|
+
interface DomSnapshot {
|
|
3
|
+
outerHTML: string;
|
|
4
|
+
text: string;
|
|
5
|
+
attributes: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
interface ElementInfo {
|
|
8
|
+
kind: ElementInfoKind;
|
|
9
|
+
componentName?: string;
|
|
10
|
+
filePath?: string;
|
|
11
|
+
line?: number;
|
|
12
|
+
column?: number;
|
|
13
|
+
domSnapshot?: DomSnapshot;
|
|
14
|
+
box?: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface SourceLocation {
|
|
22
|
+
fileName: string;
|
|
23
|
+
lineNumber: number;
|
|
24
|
+
columnNumber: number;
|
|
25
|
+
functionName?: string;
|
|
26
|
+
}
|
|
27
|
+
type EditorType = "vscode" | "vscode-insiders" | "cursor" | "webstorm" | "atom" | "sublime";
|
|
28
|
+
interface UiDogNextOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Editor to open when clicking elements
|
|
31
|
+
* @default 'cursor'
|
|
32
|
+
*/
|
|
33
|
+
editor?: EditorType;
|
|
34
|
+
/**
|
|
35
|
+
* Project root path for resolving file paths
|
|
36
|
+
*/
|
|
37
|
+
projectPath?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Modifier key for element selection
|
|
40
|
+
* @default 'alt'
|
|
41
|
+
*/
|
|
42
|
+
modifier?: "alt" | "ctrl" | "meta" | "shift";
|
|
43
|
+
/**
|
|
44
|
+
* Enable sidebar mode
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
enableSidebar?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* API endpoint for edit requests
|
|
50
|
+
* @default 'https://api.ui.dog'
|
|
51
|
+
*/
|
|
52
|
+
apiEndpoint?: string;
|
|
53
|
+
}
|
|
54
|
+
interface SidebarConfig {
|
|
55
|
+
apiEndpoint: string;
|
|
56
|
+
}
|
|
57
|
+
interface EditRequest {
|
|
58
|
+
editorUrl: string;
|
|
59
|
+
userInput: string;
|
|
60
|
+
/**
|
|
61
|
+
* Optional metadata to help when source is unavailable (e.g., server components)
|
|
62
|
+
*/
|
|
63
|
+
elementKind?: ElementInfoKind;
|
|
64
|
+
domSnapshot?: DomSnapshot;
|
|
65
|
+
}
|
|
66
|
+
interface EditResponse {
|
|
67
|
+
sessionId: string;
|
|
68
|
+
message: string;
|
|
69
|
+
status: "success" | "error";
|
|
70
|
+
error?: string;
|
|
71
|
+
}
|
|
72
|
+
declare global {
|
|
73
|
+
interface Window {
|
|
74
|
+
__UIDOG_NEXT_INITIALIZED__?: boolean;
|
|
75
|
+
__UIDOG_SIDEBAR__?: {
|
|
76
|
+
isOpen: boolean;
|
|
77
|
+
elementInfo: ElementInfo | null;
|
|
78
|
+
editorUrl: string | null;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Source resolver - builds editor URLs from source location information
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Build an editor URL from source location information
|
|
89
|
+
*/
|
|
90
|
+
declare function buildEditorUrl(source: SourceLocation, editor?: EditorType, projectPath?: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Normalize file name by removing bundler prefixes and query strings
|
|
93
|
+
*/
|
|
94
|
+
declare function normalizeFileName(fileName: string): string;
|
|
95
|
+
/**
|
|
96
|
+
* Get the file name without path for display
|
|
97
|
+
*/
|
|
98
|
+
declare function getShortFileName(filePath: string): string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Sidebar initializer - mounts the UiDog sidebar in a shadow DOM for style isolation
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Open the sidebar with element information
|
|
106
|
+
*/
|
|
107
|
+
declare function openSidebar(elementInfo: ElementInfo, editorUrl: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* Close the sidebar
|
|
110
|
+
*/
|
|
111
|
+
declare function closeSidebar(): void;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Bippy instrumentation setup for React fiber inspection
|
|
115
|
+
*
|
|
116
|
+
* Bippy hooks into React's DevTools API (window.__REACT_DEVTOOLS_GLOBAL_HOOK__)
|
|
117
|
+
* to intercept fiber tree data and extract source location information.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Setup Bippy instrumentation to hook into React's internals
|
|
122
|
+
* This must be called BEFORE React loads (via instrumentation-client.ts)
|
|
123
|
+
*/
|
|
124
|
+
declare function setupBippyInstrumentation(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Get source location from a DOM element by traversing its React fiber
|
|
127
|
+
*/
|
|
128
|
+
declare function getSourceFromElement(element: Element): Promise<SourceLocation | null>;
|
|
129
|
+
/**
|
|
130
|
+
* Get component name from a fiber
|
|
131
|
+
*/
|
|
132
|
+
declare function getComponentNameFromFiber(fiber: any): string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* UiDog SDK for Next.js - Main entry point
|
|
136
|
+
*
|
|
137
|
+
* Uses Bippy to hook into React's internals for element source detection,
|
|
138
|
+
* providing a seamless developer experience for inspecting component locations.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Initialize UiDog for Next.js
|
|
143
|
+
*
|
|
144
|
+
* This function sets up Bippy instrumentation, element detection, and the sidebar UI.
|
|
145
|
+
* It should be called early in your application's lifecycle, ideally via
|
|
146
|
+
* instrumentation-client.ts (Next.js 15.3+) or at the top of _app.tsx.
|
|
147
|
+
*/
|
|
148
|
+
declare function initializeUiDogNext(options?: UiDogNextOptions): void;
|
|
149
|
+
/**
|
|
150
|
+
* Cleanup UiDog - removes all event listeners and UI
|
|
151
|
+
*/
|
|
152
|
+
declare function cleanupUiDogNext(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Check if UiDog is initialized
|
|
155
|
+
*/
|
|
156
|
+
declare function isUiDogNextInitialized(): boolean;
|
|
157
|
+
|
|
158
|
+
export { EditRequest, EditResponse, EditorType, ElementInfo, SidebarConfig, SourceLocation, UiDogNextOptions, buildEditorUrl, cleanupUiDogNext, closeSidebar, getComponentNameFromFiber, getShortFileName, getSourceFromElement, initializeUiDogNext, isUiDogNextInitialized, normalizeFileName, openSidebar, setupBippyInstrumentation };
|