@promakeai/inspector 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +280 -62
- package/dist/hook.d.ts +38 -5
- package/dist/hook.d.ts.map +1 -1
- package/dist/hook.js +75 -13
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +536 -18
- package/dist/types.d.ts +25 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/hook.js
CHANGED
|
@@ -12,16 +12,22 @@
|
|
|
12
12
|
* function App() {
|
|
13
13
|
* const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
14
14
|
*
|
|
15
|
-
* const { isInspecting, toggleInspector, showContentInput } = useInspector(
|
|
15
|
+
* const { isInspecting, toggleInspector, showContentInput, showImageInput } = useInspector(
|
|
16
16
|
* iframeRef,
|
|
17
17
|
* {
|
|
18
18
|
* onElementSelected: (data) => {
|
|
19
19
|
* console.log('Element selected:', data);
|
|
20
20
|
* console.log('Is text node:', data.isTextNode);
|
|
21
|
+
* console.log('Is image node:', data.isImageNode);
|
|
21
22
|
*
|
|
22
23
|
* // Dynamically show content input for text nodes
|
|
23
24
|
* if (data.isTextNode) {
|
|
24
|
-
* showContentInput(true);
|
|
25
|
+
* showContentInput(true, true); // updateImmediately: true for instant feedback
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* // Dynamically show image input for image nodes
|
|
29
|
+
* if (data.isImageNode) {
|
|
30
|
+
* showImageInput(true, true); // updateImmediately: true for instant feedback
|
|
25
31
|
* }
|
|
26
32
|
* },
|
|
27
33
|
* onPromptSubmitted: (data) => {
|
|
@@ -35,6 +41,19 @@
|
|
|
35
41
|
* onTextUpdated: (data) => {
|
|
36
42
|
* console.log('Text updated:', data.text);
|
|
37
43
|
* },
|
|
44
|
+
* onImageUpdated: (data) => {
|
|
45
|
+
* console.log('Image updated:', data.imageFile.name);
|
|
46
|
+
* console.log('Image data (base64):', data.imageData);
|
|
47
|
+
* // Upload to server
|
|
48
|
+
* fetch('/api/upload-image', {
|
|
49
|
+
* method: 'POST',
|
|
50
|
+
* body: JSON.stringify(data)
|
|
51
|
+
* });
|
|
52
|
+
* },
|
|
53
|
+
* onInspectorClosed: () => {
|
|
54
|
+
* console.log('Inspector closed');
|
|
55
|
+
* // Update UI state, re-enable elements, etc.
|
|
56
|
+
* },
|
|
38
57
|
* onError: (data) => {
|
|
39
58
|
* console.error('Error:', data);
|
|
40
59
|
* // Send to error tracking service
|
|
@@ -45,7 +64,12 @@
|
|
|
45
64
|
* editText: 'Edit Text',
|
|
46
65
|
* textPlaceholder: 'Enter text...',
|
|
47
66
|
* updateText: 'Update',
|
|
48
|
-
* promptPlaceholder: 'Ask AI for changes...'
|
|
67
|
+
* promptPlaceholder: 'Ask AI for changes...',
|
|
68
|
+
* editImage: 'Change Image',
|
|
69
|
+
* imageUploadTitle: 'Select Image',
|
|
70
|
+
* imageUploadHint: 'Click or drag',
|
|
71
|
+
* updateImage: 'Update Image',
|
|
72
|
+
* badgeText: 'Built with Promake'
|
|
49
73
|
* },
|
|
50
74
|
* {
|
|
51
75
|
* // Optional: Custom theme colors (all optional)
|
|
@@ -55,7 +79,10 @@
|
|
|
55
79
|
* buttonTextColor: '#ffffff',
|
|
56
80
|
* inputBackgroundColor: '#f9fafb',
|
|
57
81
|
* inputTextColor: '#111827',
|
|
58
|
-
* inputBorderColor: '#d1d5db'
|
|
82
|
+
* inputBorderColor: '#d1d5db',
|
|
83
|
+
* badgeGradientStart: '#411E93',
|
|
84
|
+
* badgeGradientEnd: '#E87C85',
|
|
85
|
+
* badgeTextColor: '#ffffff'
|
|
59
86
|
* }
|
|
60
87
|
* );
|
|
61
88
|
*
|
|
@@ -66,7 +93,13 @@
|
|
|
66
93
|
* Toggle Inspector
|
|
67
94
|
* </button>
|
|
68
95
|
* <button onClick={() => showContentInput(true)}>
|
|
69
|
-
* Show
|
|
96
|
+
* Show Text Input
|
|
97
|
+
* </button>
|
|
98
|
+
* <button onClick={() => showImageInput(true)}>
|
|
99
|
+
* Show Image Input
|
|
100
|
+
* </button>
|
|
101
|
+
* <button onClick={() => setBadgeVisible(true)}>
|
|
102
|
+
* Show Promake Badge
|
|
70
103
|
* </button>
|
|
71
104
|
* </div>
|
|
72
105
|
* <iframe ref={iframeRef} src="http://localhost:5173" />
|
|
@@ -122,12 +155,33 @@ export function useInspector(iframeRef, callbacks, labels, theme) {
|
|
|
122
155
|
/**
|
|
123
156
|
* Show or hide content input
|
|
124
157
|
*/
|
|
125
|
-
const showContentInput = useCallback((show) => {
|
|
158
|
+
const showContentInput = useCallback((show, updateImmediately) => {
|
|
126
159
|
sendMessage({
|
|
127
160
|
type: "SHOW_CONTENT_INPUT",
|
|
128
161
|
show: show,
|
|
162
|
+
updateImmediately: updateImmediately,
|
|
129
163
|
});
|
|
130
164
|
}, [sendMessage]);
|
|
165
|
+
/**
|
|
166
|
+
* Show or hide image input
|
|
167
|
+
*/
|
|
168
|
+
const showImageInput = useCallback((show, updateImmediately) => {
|
|
169
|
+
sendMessage({
|
|
170
|
+
type: "SHOW_IMAGE_INPUT",
|
|
171
|
+
show: show,
|
|
172
|
+
updateImmediately: updateImmediately,
|
|
173
|
+
});
|
|
174
|
+
}, [sendMessage]);
|
|
175
|
+
/**
|
|
176
|
+
* Show or hide "Built with Promake" badge
|
|
177
|
+
*/
|
|
178
|
+
const setBadgeVisible = useCallback((visible) => {
|
|
179
|
+
sendMessage({
|
|
180
|
+
type: "SET_BADGE_VISIBLE",
|
|
181
|
+
visible: visible,
|
|
182
|
+
badgeText: labels?.badgeText,
|
|
183
|
+
});
|
|
184
|
+
}, [sendMessage, labels]);
|
|
131
185
|
/**
|
|
132
186
|
* Listen for messages from iframe
|
|
133
187
|
*/
|
|
@@ -150,22 +204,28 @@ export function useInspector(iframeRef, callbacks, labels, theme) {
|
|
|
150
204
|
if (!messageData || typeof messageData.type !== "string") {
|
|
151
205
|
return;
|
|
152
206
|
}
|
|
153
|
-
|
|
154
|
-
switch (type) {
|
|
207
|
+
switch (messageData.type) {
|
|
155
208
|
case "INSPECTOR_ELEMENT_SELECTED":
|
|
156
|
-
callbacks?.onElementSelected?.(data);
|
|
209
|
+
callbacks?.onElementSelected?.(messageData.data);
|
|
157
210
|
break;
|
|
158
211
|
case "URL_CHANGED":
|
|
159
|
-
callbacks?.onUrlChange?.(data);
|
|
212
|
+
callbacks?.onUrlChange?.(messageData.data);
|
|
160
213
|
break;
|
|
161
214
|
case "INSPECTOR_PROMPT_SUBMITTED":
|
|
162
|
-
callbacks?.onPromptSubmitted?.(data);
|
|
215
|
+
callbacks?.onPromptSubmitted?.(messageData.data);
|
|
163
216
|
break;
|
|
164
217
|
case "INSPECTOR_TEXT_UPDATED":
|
|
165
|
-
callbacks?.onTextUpdated?.(data);
|
|
218
|
+
callbacks?.onTextUpdated?.(messageData.data);
|
|
219
|
+
break;
|
|
220
|
+
case "INSPECTOR_IMAGE_UPDATED":
|
|
221
|
+
callbacks?.onImageUpdated?.(messageData.data);
|
|
222
|
+
break;
|
|
223
|
+
case "INSPECTOR_CLOSED":
|
|
224
|
+
setIsInspecting(false);
|
|
225
|
+
callbacks?.onInspectorClosed?.();
|
|
166
226
|
break;
|
|
167
227
|
case "INSPECTOR_ERROR":
|
|
168
|
-
callbacks?.onError?.(data);
|
|
228
|
+
callbacks?.onError?.(messageData.data);
|
|
169
229
|
break;
|
|
170
230
|
default:
|
|
171
231
|
// Unknown message type - ignore
|
|
@@ -198,5 +258,7 @@ export function useInspector(iframeRef, callbacks, labels, theme) {
|
|
|
198
258
|
startInspecting,
|
|
199
259
|
stopInspecting,
|
|
200
260
|
showContentInput,
|
|
261
|
+
showImageInput,
|
|
262
|
+
setBadgeVisible,
|
|
201
263
|
};
|
|
202
264
|
}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,wBAAgB,eAAe,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,wBAAgB,eAAe,IAAI,MAAM,CA+rCxC"}
|