vzcode 1.30.1 → 1.32.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.
Files changed (38) hide show
  1. package/dist/assets/{index-zzK6rRiK.css → index-DTtcN2MP.css} +1 -1
  2. package/dist/assets/index-sreAszZh.js +240 -0
  3. package/dist/assets/worker-BKfYWklR.js +136 -0
  4. package/dist/assets/{index-Dd8gk_1S.js → worker-COyDRdqW.js} +109 -103
  5. package/dist/assets/{worker-CaP6zYz7.js → worker-CWsWXMyk.js} +70 -70
  6. package/dist/index.html +2 -2
  7. package/package.json +42 -36
  8. package/src/client/AIAssist/startAIAssist.ts +0 -24
  9. package/src/client/App/index.tsx +14 -7
  10. package/src/client/CodeEditor/getOrCreateEditor.ts +80 -56
  11. package/src/client/CodeEditor/index.tsx +56 -30
  12. package/src/client/CodeEditor/typescriptExtension/worker.ts +32 -0
  13. package/src/client/RunCodeWidget/index.tsx +0 -2
  14. package/src/client/VZCodeContext.tsx +8 -25
  15. package/src/client/VZMiddle.tsx +11 -5
  16. package/src/client/VZSidebar/Search.tsx +11 -0
  17. package/src/client/VZSidebar/index.tsx +18 -11
  18. package/src/client/VZSidebar/styles.scss +27 -7
  19. package/src/client/VZSidebar/useDragAndDrop.tsx +237 -35
  20. package/src/client/main.jsx +0 -2
  21. package/src/client/useESLint/index.ts +72 -0
  22. package/src/client/useESLint/worker.ts +113 -0
  23. package/src/client/useFileCRUD.ts +0 -2
  24. package/src/server/featureFlags.js +4 -6
  25. package/src/server/setupEnv.js +0 -10
  26. package/dist/assets/index-BOiH3_fC.js +0 -234
  27. package/src/client/CodeEditor/typeScriptCompletions.ts +0 -134
  28. package/src/client/CodeEditor/typeScriptLinter.ts +0 -47
  29. package/src/client/useTypeScript/index.ts +0 -48
  30. package/src/client/useTypeScript/worker/constants.ts +0 -94
  31. package/src/client/useTypeScript/worker/getTSFileName.ts +0 -4
  32. package/src/client/useTypeScript/worker/handleMessageAutocompleteRequest.ts +0 -63
  33. package/src/client/useTypeScript/worker/handleMessageLintRequest.ts +0 -84
  34. package/src/client/useTypeScript/worker/handleMessageTranspileRequest.ts +0 -20
  35. package/src/client/useTypeScript/worker/handleMessageUpdateContent.ts +0 -42
  36. package/src/client/useTypeScript/worker/index.ts +0 -110
  37. package/src/client/useTypeScript/worker/isTS.ts +0 -3
  38. package/src/client/useTypeScript/worker/requestTypes.ts +0 -31
@@ -0,0 +1,113 @@
1
+ import * as eslint from 'eslint-linter-browserify';
2
+ import globals from 'globals';
3
+
4
+ // Feature flag to enable or disable JSX linting
5
+ // It's disabled for now since it doesn't work.
6
+ // See issue:
7
+ // https://github.com/vizhub-core/vzcode/issues/921
8
+ const enableJSXLinting = false;
9
+
10
+ const linter = new eslint.Linter();
11
+
12
+ const config = {
13
+ languageOptions: {
14
+ globals: {
15
+ ...globals.browser,
16
+ ...globals.es2021,
17
+ },
18
+ parserOptions: {
19
+ ecmaVersion: 2022,
20
+ sourceType: 'module',
21
+ ecmaFeatures: {
22
+ // Add this to enable JSX parsing
23
+ jsx: true,
24
+ },
25
+ },
26
+ },
27
+ rules: {
28
+ 'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
29
+ 'no-undef': 'error',
30
+ semi: 'off',
31
+ },
32
+ };
33
+
34
+ // Helper function to convert line/column to character offset
35
+ function getOffset(
36
+ docLines: string[],
37
+ line: number,
38
+ column: number,
39
+ ): number {
40
+ let offset = 0;
41
+ for (let i = 0; i < line - 1; i++) {
42
+ offset += (docLines[i] ? docLines[i].length : 0) + 1; // +1 for newline
43
+ }
44
+ return offset + column - 1;
45
+ }
46
+
47
+ self.onmessage = (event) => {
48
+ const { code, requestId, fileName } = event.data;
49
+ if (typeof code !== 'string') {
50
+ self.postMessage({
51
+ diagnostics: [],
52
+ requestId,
53
+ error: 'Invalid code received',
54
+ });
55
+ return;
56
+ }
57
+
58
+ // Only lint .js files, and .jsx files if enableJSXLinting is true
59
+ if (!fileName) {
60
+ self.postMessage({ diagnostics: [], requestId });
61
+ return;
62
+ }
63
+
64
+ const isJsFile = /\.js$/i.test(fileName);
65
+ const isJsxFile = /\.jsx$/i.test(fileName);
66
+
67
+ if (!isJsFile && (!isJsxFile || !enableJSXLinting)) {
68
+ self.postMessage({ diagnostics: [], requestId });
69
+ return;
70
+ }
71
+
72
+ try {
73
+ const messages = linter.verify(code, config as any);
74
+ const docLines = code.split('\n');
75
+
76
+ const diagnostics = messages.map((msg) => {
77
+ const from = getOffset(
78
+ docLines,
79
+ msg.line,
80
+ msg.column,
81
+ );
82
+ // endLine and endColumn may not always exist
83
+ const to =
84
+ msg.endLine && msg.endColumn
85
+ ? getOffset(docLines, msg.endLine, msg.endColumn)
86
+ : from +
87
+ (msg.fix?.range[1] - msg.fix?.range[0] || 1);
88
+
89
+ return {
90
+ from,
91
+ to,
92
+ severity:
93
+ msg.severity === 2
94
+ ? 'error'
95
+ : msg.severity === 1
96
+ ? 'warning'
97
+ : 'info',
98
+ message: msg.message,
99
+ source: msg.ruleId
100
+ ? `eslint(${msg.ruleId})`
101
+ : 'eslint',
102
+ };
103
+ });
104
+ self.postMessage({ diagnostics, requestId });
105
+ } catch (e: any) {
106
+ console.error('Error linting in ESLint worker:', e);
107
+ self.postMessage({
108
+ error: e.message,
109
+ diagnostics: [],
110
+ requestId,
111
+ });
112
+ }
113
+ };
@@ -89,8 +89,6 @@ export const useFileCRUD = ({
89
89
  oldName: string,
90
90
  newName: string,
91
91
  ) => {
92
- console.log(path);
93
- console.log(oldName);
94
92
  submitOperation((document: VizContent) => {
95
93
  const updatedFiles = Object.keys(
96
94
  document.files,
@@ -1,10 +1,8 @@
1
1
  // Feature flag for directories, disabled until it's fully working.
2
2
  export const enableDirectories = true;
3
3
 
4
- export const debugDirectories = Boolean(
5
- process.env.DEBUG_FILE_TREE,
6
- );
4
+ export const debugDirectories = false;
7
5
 
8
- export const debugIgnore = Boolean(
9
- process.env.DEBUG_IGNORE,
10
- );
6
+ export const debugIgnore = false;
7
+
8
+ export const enableESLint = true;
@@ -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
- }