@promakeai/inspector-hook 1.4.5 → 1.7.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/dist/index.d.ts.map +1 -1
- package/dist/index.js +97 -0
- package/package.json +2 -2
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,sBAAsB,EAEtB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,sBAAsB,EAEtB,kBAAkB,EAkBnB,MAAM,4BAA4B,CAAC;AA+KpC,wBAAgB,YAAY,CAC1B,SAAS,EAAE,SAAS,CAAC,iBAAiB,CAAC,EACvC,SAAS,CAAC,EAAE,kBAAkB,EAC9B,MAAM,CAAC,EAAE,eAAe,EACxB,KAAK,CAAC,EAAE,cAAc,EACtB,aAAa,CAAC,EAAE,sBAAsB,GACrC,kBAAkB,CAwpBpB;AAGD,YAAY,EACV,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -110,6 +110,36 @@ export function useInspector(iframeRef, callbacks, labels, theme, initialConfig)
|
|
|
110
110
|
show: show,
|
|
111
111
|
});
|
|
112
112
|
}, [sendMessage]);
|
|
113
|
+
/**
|
|
114
|
+
* Show or hide database tab
|
|
115
|
+
*/
|
|
116
|
+
const showDatabaseTab = useCallback((show) => {
|
|
117
|
+
sendMessage({
|
|
118
|
+
type: "SHOW_DATABASE_TAB",
|
|
119
|
+
show: show,
|
|
120
|
+
});
|
|
121
|
+
}, [sendMessage]);
|
|
122
|
+
/**
|
|
123
|
+
* Show or hide custom tab
|
|
124
|
+
*/
|
|
125
|
+
const showCustomTab = useCallback((show) => {
|
|
126
|
+
sendMessage({
|
|
127
|
+
type: "SHOW_CUSTOM_TAB",
|
|
128
|
+
show: show,
|
|
129
|
+
});
|
|
130
|
+
}, [sendMessage]);
|
|
131
|
+
/**
|
|
132
|
+
* Set custom fields for an element
|
|
133
|
+
*/
|
|
134
|
+
const setCustomFields = useCallback((elementId, fields) => {
|
|
135
|
+
sendMessage({
|
|
136
|
+
type: "SET_CUSTOM_FIELDS",
|
|
137
|
+
data: {
|
|
138
|
+
elementId,
|
|
139
|
+
fields,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}, [sendMessage]);
|
|
113
143
|
/**
|
|
114
144
|
* Show or hide "Built with Promake" badge
|
|
115
145
|
*/
|
|
@@ -277,6 +307,58 @@ export function useInspector(iframeRef, callbacks, labels, theme, initialConfig)
|
|
|
277
307
|
break;
|
|
278
308
|
case "INSPECTOR_CHANGES_SAVED":
|
|
279
309
|
callbacks?.onChangesSaved?.(messageData.data);
|
|
310
|
+
// Also trigger onDatabaseUpdated if there are database changes
|
|
311
|
+
if (callbacks?.onDatabaseUpdated) {
|
|
312
|
+
const databaseChanges = messageData.data.changes.filter((c) => c.type === "database");
|
|
313
|
+
if (databaseChanges.length > 0) {
|
|
314
|
+
databaseChanges.forEach((change) => {
|
|
315
|
+
if (change.database) {
|
|
316
|
+
// Extract only changed values
|
|
317
|
+
const changedValues = {};
|
|
318
|
+
Object.keys(change.database.current).forEach((key) => {
|
|
319
|
+
const currentVal = change.database.current[key];
|
|
320
|
+
const previousVal = change.database.previous[key];
|
|
321
|
+
if (currentVal !== previousVal) {
|
|
322
|
+
changedValues[key] = currentVal;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
callbacks.onDatabaseUpdated({
|
|
326
|
+
element: change.element,
|
|
327
|
+
changes: changedValues,
|
|
328
|
+
table: change.database.table,
|
|
329
|
+
id: change.database.id,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// Also trigger onCustomUpdated if there are custom changes
|
|
336
|
+
if (callbacks?.onCustomUpdated) {
|
|
337
|
+
const customChanges = messageData.data.changes.filter((c) => c.type === "custom");
|
|
338
|
+
if (customChanges.length > 0) {
|
|
339
|
+
customChanges.forEach((change) => {
|
|
340
|
+
if (change.custom) {
|
|
341
|
+
// Extract only changed values
|
|
342
|
+
const changedValues = {};
|
|
343
|
+
Object.keys(change.custom.current).forEach((key) => {
|
|
344
|
+
const currentVal = change.custom.current[key];
|
|
345
|
+
const previousVal = change.custom.previous[key];
|
|
346
|
+
if (currentVal !== previousVal) {
|
|
347
|
+
changedValues[key] = currentVal;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
callbacks.onCustomUpdated({
|
|
351
|
+
element: change.element,
|
|
352
|
+
changes: changedValues,
|
|
353
|
+
groupId: change.custom.groupId,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
break;
|
|
360
|
+
case "INSPECTOR_CUSTOM_UPDATED":
|
|
361
|
+
callbacks?.onCustomUpdated?.(messageData.data);
|
|
280
362
|
break;
|
|
281
363
|
case "INSPECTOR_GO_TO_CODE":
|
|
282
364
|
callbacks?.onGoToCode?.(messageData.data);
|
|
@@ -374,6 +456,18 @@ export function useInspector(iframeRef, callbacks, labels, theme, initialConfig)
|
|
|
374
456
|
show: initialConfig.showImagesTab,
|
|
375
457
|
});
|
|
376
458
|
}
|
|
459
|
+
if (initialConfig.showDatabaseTab !== undefined) {
|
|
460
|
+
sendMessage({
|
|
461
|
+
type: "SHOW_DATABASE_TAB",
|
|
462
|
+
show: initialConfig.showDatabaseTab,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
if (initialConfig.showCustomTab !== undefined) {
|
|
466
|
+
sendMessage({
|
|
467
|
+
type: "SHOW_CUSTOM_TAB",
|
|
468
|
+
show: initialConfig.showCustomTab,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
377
471
|
if (initialConfig.showChildBorders !== undefined) {
|
|
378
472
|
sendMessage({
|
|
379
473
|
type: "SET_SHOW_CHILD_BORDERS",
|
|
@@ -436,6 +530,9 @@ export function useInspector(iframeRef, callbacks, labels, theme, initialConfig)
|
|
|
436
530
|
setIsDraggable,
|
|
437
531
|
setIsResizable,
|
|
438
532
|
showImagesTab,
|
|
533
|
+
showDatabaseTab,
|
|
534
|
+
showCustomTab,
|
|
535
|
+
setCustomFields,
|
|
439
536
|
};
|
|
440
537
|
}
|
|
441
538
|
// Export utility functions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promakeai/inspector-hook",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "React hook for controlling inspector in parent applications",
|
|
5
5
|
"author": "Promake",
|
|
6
6
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@promakeai/inspector-types": "1.
|
|
48
|
+
"@promakeai/inspector-types": "1.7.0",
|
|
49
49
|
"vitest": "^1.0.0"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|