vzcode 1.59.0 → 1.60.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.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-BJI4JLx9.js"></script>
24
- <link rel="stylesheet" crossorigin href="/assets/index-afP-wJTZ.css">
23
+ <script type="module" crossorigin src="/assets/index-S-R8oY72.js"></script>
24
+ <link rel="stylesheet" crossorigin href="/assets/index-DMIy-XE4.css">
25
25
  </head>
26
26
  <body>
27
27
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "1.59.0",
3
+ "version": "1.60.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -0,0 +1,29 @@
1
+ import React, { Context, createContext } from 'react';
2
+ import {
3
+ VZCodeContextValue,
4
+ VZCodeProviderProps,
5
+ } from './types';
6
+ import { useVZCodeState } from './useVZCodeState';
7
+
8
+ // This context centralizes all the "smart" logic
9
+ // to do with the application state. This includes
10
+ // * Accessing and manipulating ShareDB data
11
+ // * Centralized application state
12
+ export const VZCodeContext: Context<VZCodeContextValue | null> =
13
+ createContext<VZCodeContextValue>(null);
14
+
15
+ export const VZCodeProvider: React.FC<
16
+ VZCodeProviderProps
17
+ > = ({ children, ...props }) => {
18
+ // Use the custom hook to get all the context value
19
+ const value = useVZCodeState(props);
20
+
21
+ return (
22
+ <VZCodeContext.Provider value={value}>
23
+ {children}
24
+ </VZCodeContext.Provider>
25
+ );
26
+ };
27
+
28
+ // Re-export types for backward compatibility
29
+ export type { VZCodeContextValue, VZCodeProviderProps };
@@ -0,0 +1,236 @@
1
+ import {
2
+ ItemId,
3
+ LeafPane,
4
+ Pane,
5
+ PaneId,
6
+ PresenceIndicator,
7
+ SearchFileVisibility,
8
+ SearchResults,
9
+ ShareDBDoc,
10
+ SubmitOperation,
11
+ TabState,
12
+ Username,
13
+ } from '../../types';
14
+ import { VizFiles, VizContent } from '@vizhub/viz-types';
15
+ import { ThemeLabel } from '../themes';
16
+ import { EditorCache } from '../useEditorCache';
17
+
18
+ // The type of the object provided by this context.
19
+ export type VZCodeContextValue = {
20
+ content: VizContent | null;
21
+ shareDBDoc: ShareDBDoc<VizContent> | null;
22
+ submitOperation: (
23
+ next: (content: VizContent) => VizContent,
24
+ ) => void;
25
+ // TODO pull in this type from ShareDB if possible
26
+ localPresence: any;
27
+ // TODO pull in this type from ShareDB if possible
28
+ docPresence: any;
29
+
30
+ files: VizFiles | null;
31
+ createFile: (fileName: string, text?: string) => void;
32
+ renameFile: (fileId: string, fileName: string) => void;
33
+ deleteFile: (fileId: string) => void;
34
+ createDirectory: (
35
+ fileName: string,
36
+ text?: string,
37
+ ) => void;
38
+ renameDirectory: (
39
+ directoryId: string,
40
+ directoryOldName: string,
41
+ directoryName: string,
42
+ ) => void;
43
+ deleteDirectory: (directoryId: string) => void;
44
+
45
+ setActiveFileId: (fileId: string | null) => void;
46
+ setActiveFileLeft: () => void;
47
+ setActiveFileRight: () => void;
48
+
49
+ activePaneId: PaneId;
50
+ pane: Pane;
51
+ activePane: LeafPane;
52
+
53
+ openTab: (tabState: TabState) => void;
54
+ closeTabs: (fileIds: string[]) => void;
55
+
56
+ isSettingsOpen: boolean;
57
+ setIsSettingsOpen: (isSettingsOpen: boolean) => void;
58
+ closeSettings: () => void;
59
+
60
+ isDocOpen: boolean;
61
+ setIsDocOpen: (isDocOpen: boolean) => void;
62
+ closeDoc: () => void;
63
+
64
+ theme: ThemeLabel;
65
+ setTheme: (theme: ThemeLabel) => void;
66
+
67
+ username: Username;
68
+ setUsername: (username: Username) => void;
69
+
70
+ isDirectoryOpen: (path: string) => boolean;
71
+ toggleDirectory: (path: string) => void;
72
+
73
+ editorCache: EditorCache;
74
+
75
+ // Whether the editor should be focused.
76
+ editorWantsFocus: boolean;
77
+ // Signals that the editor no longer wants focus.
78
+ editorNoLongerWantsFocus: () => void;
79
+
80
+ errorMessage: string | null;
81
+
82
+ // Runtime error handling
83
+ handleRuntimeError: (
84
+ formattedErrorMessage: string,
85
+ ) => void;
86
+ clearRuntimeError: () => void;
87
+
88
+ search: SearchResults;
89
+ isSearchOpen: boolean;
90
+ setIsSearchOpen: (isSearchOpen: boolean) => void;
91
+ setSearch: (pattern: string) => void;
92
+
93
+ isAIChatOpen: boolean;
94
+ setIsAIChatOpen: (isAIChatOpen: boolean) => void;
95
+ aiChatFocused: boolean;
96
+ toggleAIChatFocused: () => void;
97
+ aiChatMode: 'ask' | 'edit';
98
+ setAIChatMode: (mode: 'ask' | 'edit') => void;
99
+ aiChatEndpoint?: string;
100
+ aiChatUndoEndpoint?: string;
101
+ aiChatOptions?: { [key: string]: any };
102
+ setSearchResults: (files: ShareDBDoc<VizContent>) => void;
103
+ setSearchFileVisibility: (
104
+ files: ShareDBDoc<VizContent>,
105
+ id: string,
106
+ visibility: SearchFileVisibility,
107
+ ) => void;
108
+ setSearchLineVisibility: (
109
+ files: ShareDBDoc<VizContent>,
110
+ id: string,
111
+ line: number,
112
+ ) => void;
113
+ setSearchFocusedIndex: (
114
+ focusedIndex: number,
115
+ childIndex: number,
116
+ ) => void;
117
+ toggleSearchFocused: () => void;
118
+
119
+ isCreateFileModalOpen: boolean;
120
+ handleOpenCreateFileModal: () => void;
121
+ handleCloseCreateFileModal: () => void;
122
+ handleCreateFileClick: (newFileName: string) => void;
123
+
124
+ isCreateDirModalOpen: boolean;
125
+ handleOpenCreateDirModal: () => void;
126
+ handleCloseCreateDirModal: () => void;
127
+ handleCreateDirClick: (newFileName: string) => void;
128
+
129
+ runPrettierRef: React.MutableRefObject<
130
+ null | (() => void)
131
+ >;
132
+ runCodeRef: React.MutableRefObject<
133
+ null | ((hardRerun?: boolean) => void)
134
+ >;
135
+
136
+ sidebarRef: React.RefObject<HTMLDivElement>;
137
+
138
+ codeEditorRef: React.RefObject<HTMLDivElement>;
139
+
140
+ connected: boolean;
141
+ pending: boolean;
142
+
143
+ hoveredItemId: ItemId | null;
144
+ setHoveredItemId: (itemId: ItemId | null) => void;
145
+
146
+ enableAutoFollow: boolean;
147
+ toggleAutoFollow: () => void;
148
+
149
+ updatePresenceIndicator: (
150
+ presenceIndicator: PresenceIndicator,
151
+ ) => void;
152
+
153
+ sidebarPresenceIndicators: Array<PresenceIndicator>;
154
+ splitCurrentPane: () => void;
155
+
156
+ liveKitToken: string;
157
+ setLiveKitToken: (state: string) => void;
158
+ liveKitRoomName: string;
159
+ setLiveKitRoom: (state: string) => void;
160
+ liveKitConnection: boolean;
161
+ setLiveKitConnection: (state: boolean) => void;
162
+ voiceChatModalOpen: boolean;
163
+ setVoiceChatModalOpen: (state: boolean) => void;
164
+ aiChatMessage: string;
165
+ setAIChatMessage: (message: string) => void;
166
+ isLoading: boolean;
167
+ setIsLoading: (state: boolean) => void;
168
+ currentChatId: string;
169
+ aiErrorMessage: string | null;
170
+ setAIErrorMessage: (state: string | null) => void;
171
+ handleSendMessage: (
172
+ messageToSend?: string,
173
+ options?: Record<string, string>,
174
+ ) => void;
175
+
176
+ // Auto-fork functions for VizHub integration
177
+ autoForkAndRetryAI?: (
178
+ prompt: string,
179
+ modelName: string,
180
+ commitId?: string,
181
+ ) => Promise<void>;
182
+ clearStoredAIPrompt?: () => void;
183
+ getStoredAIPrompt?: () => {
184
+ prompt: string;
185
+ modelName: string;
186
+ } | null;
187
+
188
+ // Additional widgets that can be rendered in AI chat messages
189
+ additionalWidgets?: React.ComponentType<{
190
+ messageId: string;
191
+ chatId: string;
192
+ canUndo: boolean;
193
+ handleSendMessage?: (
194
+ messageToSend?: string,
195
+ options?: Record<string, string>,
196
+ ) => void;
197
+ }>;
198
+ };
199
+
200
+ export interface VZCodeProviderProps {
201
+ content: VizContent;
202
+ shareDBDoc: ShareDBDoc<VizContent>;
203
+ submitOperation: SubmitOperation;
204
+ localPresence: any;
205
+ docPresence: any;
206
+ prettierWorker: Worker;
207
+ initialUsername: Username;
208
+ children: React.ReactNode;
209
+ codeError?: string | null;
210
+ connected?: boolean;
211
+ pending?: boolean;
212
+ liveKitToken?: string | undefined;
213
+ setLiveKitToken?: (state: string) => void;
214
+ liveKitRoomName?: string | undefined;
215
+ setLiveKitRoom?: (state: string) => void;
216
+ liveKitConnection?: boolean;
217
+ setLiveKitConnection?: (state: boolean) => void;
218
+ aiChatEndpoint?: string;
219
+ aiChatUndoEndpoint?: string;
220
+ aiChatOptions?: { [key: string]: any };
221
+ autoForkAndRetryAI?: (
222
+ prompt: string,
223
+ modelName: string,
224
+ commitId?: string,
225
+ ) => Promise<void>;
226
+ clearStoredAIPrompt?: () => void;
227
+ getStoredAIPrompt?: () => {
228
+ prompt: string;
229
+ modelName: string;
230
+ } | null;
231
+ additionalWidgets?: React.ComponentType<{
232
+ messageId: string;
233
+ chatId: string;
234
+ canUndo: boolean;
235
+ }>;
236
+ }