vzcode 0.71.0 → 0.73.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.
@@ -131,18 +131,20 @@
131
131
  display: flex;
132
132
  justify-content: space-between;
133
133
  padding: 10px;
134
- }
134
+ font-size: 12px;
135
135
 
136
- .connection {
137
- display: flex;
138
- gap: 6px;
139
- align-items: center;
140
- }
136
+ .connection-status-indicator {
137
+ width: 16px;
138
+ height: 16px;
139
+ border-radius: 50%;
140
+
141
+ &.connected {
142
+ background-color: var(--vh-color-success-01);
143
+ }
141
144
 
142
- .saved {
143
- width: 16px;
144
- height: 16px;
145
- border-radius: 99px;
146
- background-color: #34eb52;
145
+ &.disconnected {
146
+ background-color: var(--vh-color-warning-01);
147
+ }
148
+ }
147
149
  }
148
150
  }
@@ -54,7 +54,13 @@ export const useFileCRUD = ({
54
54
  ...document.files,
55
55
  [fileId]: {
56
56
  ...document.files[fileId],
57
- name: newName,
57
+ name:
58
+ document.files[fileId].name.substring(
59
+ 0,
60
+ document.files[fileId].name.lastIndexOf(
61
+ '/',
62
+ ) + 1,
63
+ ) + newName,
58
64
  },
59
65
  },
60
66
  }));
@@ -62,6 +68,40 @@ export const useFileCRUD = ({
62
68
  [submitOperation],
63
69
  );
64
70
 
71
+ // Renames a directory
72
+ const renameDirectory = useCallback(
73
+ (
74
+ path: FileTreePath,
75
+ oldName: string,
76
+ newName: string,
77
+ ) => {
78
+ submitOperation((document: VZCodeContent) => {
79
+ const updatedFiles = Object.keys(
80
+ document.files,
81
+ ).reduce((acc, key) => {
82
+ const file = document.files[key];
83
+ const fileName = file.name;
84
+ if (fileName.includes(path)) {
85
+ const oldNamePos = fileName.indexOf(oldName);
86
+ const fileNewName =
87
+ fileName.substring(0, oldNamePos) +
88
+ newName +
89
+ fileName.substring(
90
+ oldNamePos + oldName.length,
91
+ );
92
+ acc[key] = { ...file, name: fileNewName };
93
+ } else {
94
+ acc[key] = file;
95
+ }
96
+ return acc;
97
+ }, {});
98
+
99
+ return { ...document, files: updatedFiles };
100
+ });
101
+ },
102
+ [submitOperation],
103
+ );
104
+
65
105
  // Deletes a file
66
106
  const deleteFile = useCallback(
67
107
  (fileId: FileId) => {
@@ -98,6 +138,7 @@ export const useFileCRUD = ({
98
138
  createFile,
99
139
  renameFile,
100
140
  deleteFile,
141
+ renameDirectory,
101
142
  deleteDirectory,
102
143
  };
103
144
  };
@@ -16,7 +16,7 @@ const debug = false;
16
16
  // to support TypeScript completions on non-TS files.
17
17
  const getTSFileName = (fileName: string) => {
18
18
  if (fileName.endsWith('.js')) {
19
- return fileName.replace('.js', '.ts');
19
+ return fileName.replace('.js', '.tsx');
20
20
  }
21
21
  if (fileName.endsWith('.jsx')) {
22
22
  return fileName.replace('.jsx', '.tsx');
@@ -38,6 +38,21 @@ const initializeFileSystem = async () => {
38
38
  }
39
39
  const compilerOptions: ts.CompilerOptions = {
40
40
  lib: ['dom', 'esnext'],
41
+
42
+ // Disable warnings around "Any type".
43
+ noImplicitAny: false,
44
+
45
+ // Disable warnings around "Implicit any in parameter".
46
+ noImplicitThis: false,
47
+
48
+ // Allow JavaScript files to be processed
49
+ allowJs: true,
50
+
51
+ // Disable type checking for JavaScript files
52
+ // checkJs: false,
53
+
54
+ // Skip type checking of declaration files
55
+ skipLibCheck: true,
41
56
  };
42
57
 
43
58
  // `true` breaks in a Web Worker because
@@ -219,39 +234,46 @@ onmessage = async ({ data }) => {
219
234
 
220
235
  // Be less aggressive for non-TS files,
221
236
  // e.g. files that end in .js or .jsx.
222
- if (!isTS(fileName)) {
223
- // This code is for errors like:
224
- // "Binding element 'data' implicitly has an 'any' type."
225
- const LINT_ERROR_CODE_ANY = 7031;
226
-
227
- // This code is for errors like:
228
- // "Parameter 'selection' implicitly has an 'any' type.""
229
- const LINT_ERROR_CODE_ANY_PARAM = 7006;
230
-
231
- // This code is for errors like:
232
- // "Cannot find module 'd3' or its corresponding type declarations."
233
- const LINT_ERROR_CODE_IMPORT = 2307;
234
-
235
- // This code is for errors like:
236
- // "Variable 'mic' implicitly has type 'any' in some locations where its type cannot be determined."
237
- const LINT_ERROR_CODE_ANY_TYPE = 7034;
238
-
239
- // "Element implicitly has an 'any' type because expression
240
- // of type '"test"' can't be used to index type '{}'."
241
- const LINT_ERROR_CODE_ANY_TYPE_KEYS = 7053;
242
-
243
- if (debug) {
244
- console.log(tsErrors);
245
- }
246
- tsErrors = tsErrors.filter(
247
- (error: { code: number }) =>
248
- error.code !== LINT_ERROR_CODE_ANY &&
249
- error.code !== LINT_ERROR_CODE_IMPORT &&
250
- error.code !== LINT_ERROR_CODE_ANY_PARAM &&
251
- error.code !== LINT_ERROR_CODE_ANY_TYPE &&
252
- error.code !== LINT_ERROR_CODE_ANY_TYPE_KEYS,
253
- );
237
+ // if (!isTS(fileName)) {
238
+ // This code is for errors like:
239
+ // "Binding element 'data' implicitly has an 'any' type."
240
+ const LINT_ERROR_CODE_ANY = 7031;
241
+
242
+ // This code is for errors like:
243
+ // "Parameter 'selection' implicitly has an 'any' type.""
244
+ const LINT_ERROR_CODE_ANY_PARAM = 7006;
245
+
246
+ // This code is for errors like:
247
+ // "Cannot find module 'd3' or its corresponding type declarations."
248
+ const LINT_ERROR_CODE_IMPORT = 2307;
249
+
250
+ // This code is for errors like:
251
+ // "Variable 'mic' implicitly has type 'any' in some locations where its type cannot be determined."
252
+ const LINT_ERROR_CODE_ANY_TYPE = 7034;
253
+
254
+ // "Element implicitly has an 'any' type because expression
255
+ // of type '"test"' can't be used to index type '{}'."
256
+ const LINT_ERROR_CODE_ANY_TYPE_KEYS = 7053;
257
+
258
+ // "Property 'id' does not exist on type { ... }"
259
+ // Happens on objects with dynamic keys.
260
+ // Not valid in TypeScript, but common in JavaScript.
261
+ const LINT_ERROR_CODE_NON_EXISTENT_PROPERTY = 2339;
262
+
263
+ if (debug) {
264
+ console.log(tsErrors);
254
265
  }
266
+ tsErrors = tsErrors.filter(
267
+ (error: { code: number }) =>
268
+ error.code !== LINT_ERROR_CODE_ANY &&
269
+ error.code !== LINT_ERROR_CODE_IMPORT &&
270
+ error.code !== LINT_ERROR_CODE_ANY_PARAM &&
271
+ error.code !== LINT_ERROR_CODE_ANY_TYPE &&
272
+ error.code !== LINT_ERROR_CODE_ANY_TYPE_KEYS &&
273
+ error.code !==
274
+ LINT_ERROR_CODE_NON_EXISTENT_PROPERTY,
275
+ );
276
+ // }
255
277
  tsErrors = convertToCodeMirrorDiagnostic(tsErrors);
256
278
  }
257
279