vzcode 1.30.1 → 1.31.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-BOiH3_fC.js → index-D01yzCWj.js} +88 -88
- package/dist/assets/{index-zzK6rRiK.css → index-DTtcN2MP.css} +1 -1
- package/dist/index.html +2 -2
- package/package.json +7 -8
- package/src/client/AIAssist/startAIAssist.ts +0 -24
- package/src/client/App/index.tsx +11 -7
- package/src/client/CodeEditor/getOrCreateEditor.ts +0 -52
- package/src/client/CodeEditor/index.tsx +0 -6
- package/src/client/RunCodeWidget/index.tsx +0 -2
- package/src/client/VZCodeContext.tsx +8 -25
- package/src/client/VZMiddle.tsx +0 -5
- package/src/client/VZSidebar/index.tsx +18 -11
- package/src/client/VZSidebar/styles.scss +27 -7
- package/src/client/VZSidebar/useDragAndDrop.tsx +237 -35
- package/src/client/main.jsx +0 -2
- package/src/client/useFileCRUD.ts +0 -2
- package/src/server/featureFlags.js +2 -6
- package/src/server/setupEnv.js +0 -10
- package/dist/assets/index-Dd8gk_1S.js +0 -447
- package/src/client/CodeEditor/typeScriptCompletions.ts +0 -134
- package/src/client/CodeEditor/typeScriptLinter.ts +0 -47
- package/src/client/useTypeScript/index.ts +0 -48
- package/src/client/useTypeScript/worker/constants.ts +0 -94
- package/src/client/useTypeScript/worker/getTSFileName.ts +0 -4
- package/src/client/useTypeScript/worker/handleMessageAutocompleteRequest.ts +0 -63
- package/src/client/useTypeScript/worker/handleMessageLintRequest.ts +0 -84
- package/src/client/useTypeScript/worker/handleMessageTranspileRequest.ts +0 -20
- package/src/client/useTypeScript/worker/handleMessageUpdateContent.ts +0 -42
- package/src/client/useTypeScript/worker/index.ts +0 -110
- package/src/client/useTypeScript/worker/isTS.ts +0 -3
- package/src/client/useTypeScript/worker/requestTypes.ts +0 -31
|
@@ -2,22 +2,42 @@ import { useState, useContext, useCallback } from 'react';
|
|
|
2
2
|
import { VZCodeContext } from '../VZCodeContext';
|
|
3
3
|
import './styles.scss';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface FileSystemEntry {
|
|
6
|
+
isFile: boolean;
|
|
7
|
+
isDirectory: boolean;
|
|
8
|
+
name: string;
|
|
9
|
+
createReader: () => FileSystemDirectoryReader;
|
|
10
|
+
file: (callback: (file: File) => void) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface FileSystemDirectoryReader {
|
|
14
|
+
readEntries: (
|
|
15
|
+
callback: (entries: FileSystemEntry[]) => void,
|
|
16
|
+
) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DEBUG = false;
|
|
6
20
|
|
|
7
21
|
export const useDragAndDrop = () => {
|
|
8
22
|
const [isDragOver, setIsDragOver] = useState(false);
|
|
23
|
+
const [isProcessing, setIsProcessing] = useState(false);
|
|
9
24
|
const { createFile } = useContext(VZCodeContext);
|
|
10
25
|
|
|
11
|
-
const handleDragEnter = useCallback(
|
|
12
|
-
event.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
const handleDragEnter = useCallback(
|
|
27
|
+
(event: React.DragEvent) => {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
DEBUG && console.log('[useDragAndDrop] Drag Enter');
|
|
31
|
+
setIsDragOver(true);
|
|
32
|
+
},
|
|
33
|
+
[],
|
|
34
|
+
);
|
|
16
35
|
|
|
17
36
|
const handleDragOver = useCallback(
|
|
18
|
-
(event) => {
|
|
37
|
+
(event: React.DragEvent) => {
|
|
19
38
|
event.preventDefault();
|
|
20
39
|
event.stopPropagation();
|
|
40
|
+
DEBUG && console.log('[useDragAndDrop] Drag Over');
|
|
21
41
|
if (!isDragOver) setIsDragOver(true);
|
|
22
42
|
},
|
|
23
43
|
[isDragOver],
|
|
@@ -27,52 +47,234 @@ export const useDragAndDrop = () => {
|
|
|
27
47
|
(event: React.DragEvent<HTMLDivElement>) => {
|
|
28
48
|
event.preventDefault();
|
|
29
49
|
event.stopPropagation();
|
|
50
|
+
DEBUG && console.log('[useDragAndDrop] Drag Leave');
|
|
30
51
|
setIsDragOver(false);
|
|
31
52
|
},
|
|
32
53
|
[],
|
|
33
54
|
);
|
|
34
55
|
|
|
56
|
+
const isTextFile = (file: File): boolean => {
|
|
57
|
+
// Add more text file types as needed
|
|
58
|
+
const textTypes = [
|
|
59
|
+
'text/',
|
|
60
|
+
'application/json',
|
|
61
|
+
'application/javascript',
|
|
62
|
+
'application/typescript',
|
|
63
|
+
'application/xml',
|
|
64
|
+
'application/x-httpd-php',
|
|
65
|
+
];
|
|
66
|
+
const isText =
|
|
67
|
+
textTypes.some((type) =>
|
|
68
|
+
file.type.startsWith(type),
|
|
69
|
+
) ||
|
|
70
|
+
file.name.match(
|
|
71
|
+
/\.(txt|js|jsx|ts|tsx|md|css|scss|html|xml|json|php|py|rb|java|c|cpp|h|hpp)$/i,
|
|
72
|
+
) !== null;
|
|
73
|
+
|
|
74
|
+
DEBUG &&
|
|
75
|
+
console.log(
|
|
76
|
+
`[useDragAndDrop] File ${file.name} is${isText ? '' : ' not'} a text file`,
|
|
77
|
+
);
|
|
78
|
+
return isText;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const readFileAsText = (file: File): Promise<string> => {
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
DEBUG &&
|
|
84
|
+
console.log(
|
|
85
|
+
`[useDragAndDrop] Reading file: ${file.name}`,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (!isTextFile(file)) {
|
|
89
|
+
DEBUG &&
|
|
90
|
+
console.log(
|
|
91
|
+
`[useDragAndDrop] Rejected non-text file: ${file.name}`,
|
|
92
|
+
);
|
|
93
|
+
reject(
|
|
94
|
+
new Error(`File ${file.name} is not a text file`),
|
|
95
|
+
);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const reader = new FileReader();
|
|
100
|
+
reader.onload = (e) => {
|
|
101
|
+
if (e.target?.result) {
|
|
102
|
+
DEBUG &&
|
|
103
|
+
console.log(
|
|
104
|
+
`[useDragAndDrop] Successfully read file: ${file.name}`,
|
|
105
|
+
);
|
|
106
|
+
resolve(e.target.result as string);
|
|
107
|
+
} else {
|
|
108
|
+
DEBUG &&
|
|
109
|
+
console.log(
|
|
110
|
+
`[useDragAndDrop] Failed to read file: ${file.name}`,
|
|
111
|
+
);
|
|
112
|
+
reject(
|
|
113
|
+
new Error(`Failed to read file ${file.name}`),
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
reader.onerror = () => {
|
|
118
|
+
DEBUG &&
|
|
119
|
+
console.log(
|
|
120
|
+
`[useDragAndDrop] Error reading file: ${file.name}`,
|
|
121
|
+
);
|
|
122
|
+
reject(
|
|
123
|
+
new Error(`Error reading file ${file.name}`),
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
reader.readAsText(file);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const processEntry = async (
|
|
131
|
+
entry: FileSystemEntry,
|
|
132
|
+
path: string,
|
|
133
|
+
): Promise<void> => {
|
|
134
|
+
try {
|
|
135
|
+
DEBUG &&
|
|
136
|
+
console.log(
|
|
137
|
+
`[useDragAndDrop] Processing entry: ${entry.name} at path: ${path}`,
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
if (entry.isFile) {
|
|
141
|
+
DEBUG &&
|
|
142
|
+
console.log(
|
|
143
|
+
`[useDragAndDrop] Processing file: ${entry.name}`,
|
|
144
|
+
);
|
|
145
|
+
entry.file(async (file) => {
|
|
146
|
+
try {
|
|
147
|
+
const content = await readFileAsText(file);
|
|
148
|
+
DEBUG &&
|
|
149
|
+
console.log(
|
|
150
|
+
`[useDragAndDrop] Creating file: ${path}${file.name}`,
|
|
151
|
+
);
|
|
152
|
+
createFile(`${path}${file.name}`, content);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.error(
|
|
155
|
+
`Error processing file ${file.name}:`,
|
|
156
|
+
error,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
} else if (entry.isDirectory) {
|
|
161
|
+
DEBUG &&
|
|
162
|
+
console.log(
|
|
163
|
+
`[useDragAndDrop] Processing directory: ${entry.name}`,
|
|
164
|
+
);
|
|
165
|
+
return new Promise<void>((resolve) => {
|
|
166
|
+
const dirReader = entry.createReader();
|
|
167
|
+
const readEntries = () => {
|
|
168
|
+
dirReader.readEntries(async (entries) => {
|
|
169
|
+
if (entries.length === 0) {
|
|
170
|
+
DEBUG &&
|
|
171
|
+
console.log(
|
|
172
|
+
`[useDragAndDrop] Finished reading directory: ${entry.name}`,
|
|
173
|
+
);
|
|
174
|
+
resolve();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const newPath = `${path}${entry.name}/`;
|
|
179
|
+
DEBUG &&
|
|
180
|
+
console.log(
|
|
181
|
+
`[useDragAndDrop] Reading ${entries.length} entries in directory: ${newPath}`,
|
|
182
|
+
);
|
|
183
|
+
await Promise.all(
|
|
184
|
+
entries.map((entry) =>
|
|
185
|
+
processEntry(entry, newPath),
|
|
186
|
+
),
|
|
187
|
+
);
|
|
188
|
+
readEntries(); // Continue reading if there are more entries
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
readEntries();
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error(
|
|
196
|
+
`Error processing entry ${entry.name}:`,
|
|
197
|
+
error,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
35
202
|
const handleDrop = useCallback(
|
|
36
|
-
(event: React.DragEvent<HTMLDivElement>) => {
|
|
203
|
+
async (event: React.DragEvent<HTMLDivElement>) => {
|
|
37
204
|
event.preventDefault();
|
|
38
205
|
event.stopPropagation();
|
|
206
|
+
DEBUG &&
|
|
207
|
+
console.log('[useDragAndDrop] Drop event started');
|
|
39
208
|
setIsDragOver(false);
|
|
209
|
+
setIsProcessing(true);
|
|
40
210
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
211
|
+
try {
|
|
212
|
+
const items = event.dataTransfer.items;
|
|
213
|
+
DEBUG &&
|
|
214
|
+
console.log(
|
|
215
|
+
`[useDragAndDrop] Processing ${items.length} dropped items`,
|
|
216
|
+
);
|
|
217
|
+
const entries: FileSystemEntry[] = [];
|
|
218
|
+
|
|
219
|
+
for (const item of Array.from(items)) {
|
|
220
|
+
// Try webkit first, then fallback to other methods
|
|
221
|
+
const entry =
|
|
222
|
+
item.webkitGetAsEntry?.() ||
|
|
223
|
+
(item as any).getAsEntry?.() ||
|
|
224
|
+
(item as any).createEntry?.();
|
|
225
|
+
|
|
226
|
+
if (entry) {
|
|
227
|
+
DEBUG &&
|
|
228
|
+
console.log(
|
|
229
|
+
`[useDragAndDrop] Got entry for: ${entry.name}`,
|
|
230
|
+
);
|
|
231
|
+
entries.push(entry as FileSystemEntry);
|
|
232
|
+
} else if (item.kind === 'file') {
|
|
233
|
+
const file = item.getAsFile();
|
|
234
|
+
if (file) {
|
|
235
|
+
DEBUG &&
|
|
236
|
+
console.log(
|
|
237
|
+
`[useDragAndDrop] Processing dropped file: ${file.name}`,
|
|
238
|
+
);
|
|
239
|
+
try {
|
|
240
|
+
const content = await readFileAsText(file);
|
|
241
|
+
createFile(file.name, content);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
console.error(
|
|
244
|
+
`Error processing file ${file.name}:`,
|
|
245
|
+
error,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
59
248
|
}
|
|
60
|
-
}
|
|
249
|
+
}
|
|
61
250
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
251
|
+
|
|
252
|
+
DEBUG &&
|
|
253
|
+
console.log(
|
|
254
|
+
`[useDragAndDrop] Processing ${entries.length} entries`,
|
|
255
|
+
);
|
|
256
|
+
await Promise.all(
|
|
257
|
+
entries.map((entry) => processEntry(entry, '')),
|
|
258
|
+
);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
console.error(
|
|
261
|
+
'Error processing dropped items:',
|
|
262
|
+
error,
|
|
263
|
+
);
|
|
264
|
+
} finally {
|
|
265
|
+
DEBUG &&
|
|
266
|
+
console.log(
|
|
267
|
+
'[useDragAndDrop] Drop processing completed',
|
|
268
|
+
);
|
|
269
|
+
setIsProcessing(false);
|
|
270
|
+
}
|
|
70
271
|
},
|
|
71
272
|
[createFile],
|
|
72
273
|
);
|
|
73
274
|
|
|
74
275
|
return {
|
|
75
276
|
isDragOver,
|
|
277
|
+
isProcessing,
|
|
76
278
|
handleDragEnter,
|
|
77
279
|
handleDragOver,
|
|
78
280
|
handleDragLeave,
|
package/src/client/main.jsx
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
// Feature flag for directories, disabled until it's fully working.
|
|
2
2
|
export const enableDirectories = true;
|
|
3
3
|
|
|
4
|
-
export const debugDirectories =
|
|
5
|
-
process.env.DEBUG_FILE_TREE,
|
|
6
|
-
);
|
|
4
|
+
export const debugDirectories = false;
|
|
7
5
|
|
|
8
|
-
export const debugIgnore =
|
|
9
|
-
process.env.DEBUG_IGNORE,
|
|
10
|
-
);
|
|
6
|
+
export const debugIgnore = false;
|
package/src/server/setupEnv.js
CHANGED
|
@@ -6,13 +6,3 @@ const dir = fileURLToPath(import.meta.url);
|
|
|
6
6
|
dotenv.config({
|
|
7
7
|
path: join(dir, '../../../.env'),
|
|
8
8
|
});
|
|
9
|
-
if (process.env.VZCODE_DEBUG_SETUP_ENV) {
|
|
10
|
-
console.log(
|
|
11
|
-
'environment variables set up',
|
|
12
|
-
Object.fromEntries(
|
|
13
|
-
Object.entries(process.env).filter(
|
|
14
|
-
(entry) => !entry[0].endsWith('PATH'),
|
|
15
|
-
),
|
|
16
|
-
),
|
|
17
|
-
);
|
|
18
|
-
}
|