vzcode 2.5.0 → 2.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/assets/{index-BoFeK4GL.css → index-Bjj9VRMn.css} +1 -1
- package/dist/assets/{index-DB93Pffa.js → index-DL2VQRps.js} +92 -92
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/client/VZCodeContext/types.ts +8 -4
- package/src/client/VZCodeContext/useVZCodeState.ts +84 -0
- package/src/client/VZSidebar/AIChat/Message.tsx +1 -1
- package/src/client/VZSidebar/VisualEditor.tsx +367 -118
- package/src/client/VZSidebar/styles.scss +348 -0
- package/src/types.ts +14 -3
package/dist/index.html
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
24
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-DL2VQRps.js"></script>
|
|
24
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Bjj9VRMn.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
27
27
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -199,14 +199,14 @@ export type VZCodeContextValue = {
|
|
|
199
199
|
} | null;
|
|
200
200
|
|
|
201
201
|
// Additional widgets that can be rendered in AI chat messages
|
|
202
|
-
additionalWidgets?:
|
|
202
|
+
additionalWidgets?: (props: {
|
|
203
203
|
messageId: string;
|
|
204
204
|
chatId: string;
|
|
205
205
|
handleSendMessage?: (
|
|
206
206
|
messageToSend?: string,
|
|
207
207
|
options?: Record<string, string>,
|
|
208
208
|
) => void;
|
|
209
|
-
}
|
|
209
|
+
}) => React.ReactNode;
|
|
210
210
|
};
|
|
211
211
|
|
|
212
212
|
export interface VZCodeProviderProps {
|
|
@@ -239,10 +239,14 @@ export interface VZCodeProviderProps {
|
|
|
239
239
|
prompt: string;
|
|
240
240
|
modelName: string;
|
|
241
241
|
} | null;
|
|
242
|
-
additionalWidgets?:
|
|
242
|
+
additionalWidgets?: (props: {
|
|
243
243
|
messageId: string;
|
|
244
244
|
chatId: string;
|
|
245
|
-
|
|
245
|
+
handleSendMessage?: (
|
|
246
|
+
messageToSend?: string,
|
|
247
|
+
options?: Record<string, string>,
|
|
248
|
+
) => void;
|
|
249
|
+
}) => React.ReactNode;
|
|
246
250
|
iframeRef?: React.MutableRefObject<HTMLIFrameElement>;
|
|
247
251
|
handleChatError?: (
|
|
248
252
|
error: string,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCallback,
|
|
3
|
+
useEffect,
|
|
3
4
|
useMemo,
|
|
4
5
|
useReducer,
|
|
5
6
|
useRef,
|
|
@@ -468,6 +469,89 @@ export const useVZCodeState = ({
|
|
|
468
469
|
],
|
|
469
470
|
);
|
|
470
471
|
|
|
472
|
+
// Config.json change detection and iframe notification
|
|
473
|
+
// This logic was moved from VisualEditor.tsx to ensure it runs
|
|
474
|
+
// even when the visual editor is not open, fixing cross-client propagation
|
|
475
|
+
const previousConfigRef = useRef<any>(null);
|
|
476
|
+
const CONFIG_FILE_NAME = 'config.json';
|
|
477
|
+
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
// Find config.json file
|
|
480
|
+
let configFileId = null;
|
|
481
|
+
for (const fileId in files) {
|
|
482
|
+
if (files[fileId].name === CONFIG_FILE_NAME) {
|
|
483
|
+
configFileId = fileId;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (!configFileId || !files || !files[configFileId]) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
let newConfigData;
|
|
493
|
+
try {
|
|
494
|
+
newConfigData = JSON.parse(files[configFileId].text);
|
|
495
|
+
} catch (error) {
|
|
496
|
+
// If config is invalid JSON, we can't process changes
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
const previousConfig = previousConfigRef.current;
|
|
501
|
+
|
|
502
|
+
// Update the ref with the new config
|
|
503
|
+
previousConfigRef.current = newConfigData;
|
|
504
|
+
|
|
505
|
+
// Skip processing if this is the first time or if there's no previous config
|
|
506
|
+
if (!previousConfig) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Find changed top-level properties
|
|
511
|
+
const changedProperties: { [key: string]: any } = {};
|
|
512
|
+
|
|
513
|
+
// Check all properties in the new config
|
|
514
|
+
for (const key in newConfigData) {
|
|
515
|
+
if (newConfigData[key] !== previousConfig[key]) {
|
|
516
|
+
// Deep comparison for objects to detect actual changes
|
|
517
|
+
if (
|
|
518
|
+
typeof newConfigData[key] === 'object' &&
|
|
519
|
+
typeof previousConfig[key] === 'object'
|
|
520
|
+
) {
|
|
521
|
+
if (
|
|
522
|
+
JSON.stringify(newConfigData[key]) !==
|
|
523
|
+
JSON.stringify(previousConfig[key])
|
|
524
|
+
) {
|
|
525
|
+
changedProperties[key] = newConfigData[key];
|
|
526
|
+
}
|
|
527
|
+
} else {
|
|
528
|
+
changedProperties[key] = newConfigData[key];
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Check for deleted properties (properties that existed before but don't exist now)
|
|
534
|
+
for (const key in previousConfig) {
|
|
535
|
+
if (!(key in newConfigData)) {
|
|
536
|
+
changedProperties[key] = undefined;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Send changed properties to iframe if any changes were detected
|
|
541
|
+
if (Object.keys(changedProperties).length > 0) {
|
|
542
|
+
try {
|
|
543
|
+
iframeRef.current?.contentWindow?.postMessage(
|
|
544
|
+
changedProperties,
|
|
545
|
+
);
|
|
546
|
+
} catch (error) {
|
|
547
|
+
console.error(
|
|
548
|
+
'Failed to send config changes to iframe:',
|
|
549
|
+
error,
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}, [files, iframeRef]);
|
|
554
|
+
|
|
471
555
|
// Return the context value
|
|
472
556
|
return {
|
|
473
557
|
content,
|