vzcode 1.27.0 → 1.29.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-wUrsGgYs.js +183 -0
  2. package/dist/index.html +1 -1
  3. package/package.json +32 -34
  4. package/src/client/AIAssist/AIAssistCodeMirrorKeyMap.ts +3 -6
  5. package/src/client/AIAssist/AIAssistWidget/index.tsx +3 -2
  6. package/src/client/AIAssist/formatFile.ts +2 -2
  7. package/src/client/AIAssist/startAIAssist.ts +7 -8
  8. package/src/client/App/usePending.ts +3 -2
  9. package/src/client/App/useShareDB.ts +7 -5
  10. package/src/client/CodeEditor/getOrCreateEditor.ts +4 -5
  11. package/src/client/CodeEditor/json1PresenceDisplay.ts +2 -2
  12. package/src/client/CodeErrorOverlay/index.tsx +2 -2
  13. package/src/client/TabList/Tab.tsx +5 -4
  14. package/src/client/VZCodeContext.tsx +12 -23
  15. package/src/client/VZSidebar/FileListing.tsx +5 -4
  16. package/src/client/VZSidebar/Listing.tsx +4 -7
  17. package/src/client/VZSidebar/Search.tsx +5 -4
  18. package/src/client/VZSidebar/index.tsx +4 -4
  19. package/src/client/getFileTree.ts +4 -3
  20. package/src/client/tabsSearchParameters.test.ts +3 -2
  21. package/src/client/tabsSearchParameters.ts +8 -7
  22. package/src/client/themes/vizhubTheme/index.ts +13 -16
  23. package/src/client/useActions.ts +6 -7
  24. package/src/client/useEditorCache.ts +3 -2
  25. package/src/client/useFileCRUD.ts +15 -18
  26. package/src/client/useKeyboardShortcuts.ts +4 -3
  27. package/src/client/usePrettier/index.ts +6 -10
  28. package/src/client/usePrettier/worker.ts +3 -3
  29. package/src/client/useRunCode.tsx +3 -2
  30. package/src/client/useTypeScript/index.ts +3 -3
  31. package/src/client/useTypeScript/worker/handleMessageUpdateContent.ts +8 -4
  32. package/src/client/useURLSync.ts +5 -4
  33. package/src/client/vzReducer/closeTabsReducer.ts +3 -7
  34. package/src/client/vzReducer/index.ts +7 -8
  35. package/src/client/vzReducer/searchReducer.ts +2 -2
  36. package/src/client/vzReducer/updatePane.ts +3 -7
  37. package/src/types.ts +7 -52
  38. package/dist/assets/index-CQtf1JEg.js +0 -192
package/dist/index.html CHANGED
@@ -20,7 +20,7 @@
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-CQtf1JEg.js"></script>
23
+ <script type="module" crossorigin src="/assets/index-wUrsGgYs.js"></script>
24
24
  <link rel="stylesheet" crossorigin href="/assets/index-zzK6rRiK.css">
25
25
  </head>
26
26
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "1.27.0",
3
+ "version": "1.29.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -18,7 +18,8 @@
18
18
  "build": "vite build",
19
19
  "build-release": "vite build --mode release",
20
20
  "preview": "concurrently \"npm run test-interactive\" \"vite preview\"",
21
- "prepublishOnly": "npm run build-release"
21
+ "prepublishOnly": "npm run build-release",
22
+ "upgrade": "ncu -x react,react-dom,@types/react,@types/react-dom -u"
22
23
  },
23
24
  "repository": {
24
25
  "type": "git",
@@ -103,7 +104,6 @@
103
104
  },
104
105
  "homepage": "https://github.com/vizhub-core/vzcode#readme",
105
106
  "dependencies": {
106
- "@babel/runtime": "^7.26.9",
107
107
  "@codemirror/autocomplete": "^6.18.6",
108
108
  "@codemirror/lang-css": "^6.3.1",
109
109
  "@codemirror/lang-html": "^6.4.9",
@@ -112,28 +112,28 @@
112
112
  "@codemirror/lang-markdown": "^6.3.2",
113
113
  "@codemirror/state": "^6.5.2",
114
114
  "@codemirror/theme-one-dark": "^6.1.2",
115
- "@codemirror/view": "^6.36.3",
116
- "@langchain/core": "^0.3.40",
117
- "@langchain/openai": "^0.4.4",
115
+ "@codemirror/view": "^6.36.5",
116
+ "@langchain/core": "^0.3.43",
117
+ "@langchain/openai": "^0.5.2",
118
118
  "@lezer/highlight": "^1.2.1",
119
- "@livekit/components-react": "^2.8.1",
120
- "@livekit/components-styles": "^1.1.4",
119
+ "@livekit/components-react": "^2.9.0",
121
120
  "@replit/codemirror-indentation-markers": "^6.5.3",
122
121
  "@replit/codemirror-interact": "^6.3.1",
123
122
  "@replit/codemirror-lang-svelte": "^6.0.0",
124
123
  "@replit/codemirror-vscode-keymap": "^6.0.2",
125
124
  "@teamwork/websocket-json-stream": "^2.0.0",
126
125
  "@typescript/vfs": "^1.6.1",
127
- "@uiw/codemirror-theme-abcdef": "^4.23.8",
128
- "@uiw/codemirror-theme-dracula": "^4.23.8",
129
- "@uiw/codemirror-theme-eclipse": "^4.23.8",
130
- "@uiw/codemirror-theme-github": "^4.23.8",
131
- "@uiw/codemirror-theme-material": "^4.23.8",
132
- "@uiw/codemirror-theme-nord": "^4.23.8",
133
- "@uiw/codemirror-theme-okaidia": "^4.23.8",
134
- "@uiw/codemirror-theme-xcode": "^4.23.8",
135
- "@uiw/codemirror-themes": "^4.23.8",
136
- "body-parser": "^1.20.3",
126
+ "@uiw/codemirror-theme-abcdef": "^4.23.10",
127
+ "@uiw/codemirror-theme-dracula": "^4.23.10",
128
+ "@uiw/codemirror-theme-eclipse": "^4.23.10",
129
+ "@uiw/codemirror-theme-github": "^4.23.10",
130
+ "@uiw/codemirror-theme-material": "^4.23.10",
131
+ "@uiw/codemirror-theme-nord": "^4.23.10",
132
+ "@uiw/codemirror-theme-okaidia": "^4.23.10",
133
+ "@uiw/codemirror-theme-xcode": "^4.23.10",
134
+ "@uiw/codemirror-themes": "^4.23.10",
135
+ "@vizhub/viz-types": "^0.0.2",
136
+ "body-parser": "^2.2.0",
137
137
  "codemirror": "^6.0.1",
138
138
  "codemirror-copilot": "^0.0.7",
139
139
  "codemirror-ot": "^4.4.0",
@@ -141,22 +141,19 @@
141
141
  "d3-array": "^3.2.4",
142
142
  "diff-match-patch": "^1.0.5",
143
143
  "dotenv": "^16.4.7",
144
- "express": "^4.21.2",
145
- "i": "^0.3.7",
144
+ "express": "^5.1.0",
146
145
  "ignore": "^7.0.3",
147
146
  "json0-ot-diff": "^1.1.2",
148
- "livekit-client": "^2.9.4",
149
- "livekit-server-sdk": "^2.10.1",
150
- "ngrok": "^4.3.3",
151
- "npm": "^11.1.0",
147
+ "livekit-server-sdk": "^2.11.0",
148
+ "ngrok": "^5.0.0-beta.2",
149
+ "npm": "^11.2.0",
152
150
  "open": "^10.1.0",
153
- "openai": "^4.85.4",
154
151
  "prettier-plugin-svelte": "^3.3.3",
155
152
  "react": "^18",
156
153
  "react-bootstrap": "^2.10.9",
157
154
  "react-dom": "^18",
158
- "react-router-dom": "^7.2.0",
159
- "sharedb": "^5.1.1",
155
+ "react-router-dom": "^7.4.1",
156
+ "sharedb": "^5.2.1",
160
157
  "sharedb-client-browser": "^5.1.1",
161
158
  "uuid": "^11.1.0",
162
159
  "vizhub-ui": "^3.23.0",
@@ -168,14 +165,15 @@
168
165
  "@vitejs/plugin-react": "^4.3.4",
169
166
  "concurrently": "^9.1.2",
170
167
  "cross-env": "^7.0.3",
171
- "prettier": "^3.5.2",
172
- "sass": "^1.85.0",
173
- "typescript": "^5.7.3",
174
- "vite": "^6.1.1",
175
- "vitest": "^3.0.7"
168
+ "npm-check-updates": "^17.1.16",
169
+ "prettier": "^3.5.3",
170
+ "sass": "^1.86.2",
171
+ "typescript": "^5.8.2",
172
+ "vite": "^6.2.5",
173
+ "vitest": "^3.1.1"
176
174
  },
177
175
  "optionalDependencies": {
178
- "@rollup/rollup-darwin-arm64": "^4.34.8",
179
- "@rollup/rollup-win32-x64-msvc": "^4.34.8"
176
+ "@rollup/rollup-darwin-arm64": "^4.39.0",
177
+ "@rollup/rollup-win32-x64-msvc": "^4.39.0"
180
178
  }
181
179
  }
@@ -1,16 +1,13 @@
1
1
  import { EditorView, keymap } from '@codemirror/view';
2
- import {
3
- ShareDBDoc,
4
- TabState,
5
- VZCodeContent,
6
- } from '../../types';
2
+ import { ShareDBDoc, TabState } from '../../types';
3
+ import { VizContent } from '@vizhub/viz-types';
7
4
 
8
5
  export const AIAssistCodeMirrorKeyMap = ({
9
6
  shareDBDoc,
10
7
  fileId,
11
8
  tabList,
12
9
  }: {
13
- shareDBDoc: ShareDBDoc<VZCodeContent>;
10
+ shareDBDoc: ShareDBDoc<VizContent>;
14
11
  fileId: string;
15
12
  tabList: Array<TabState>;
16
13
  }) =>
@@ -1,6 +1,7 @@
1
1
  import { useCallback, useContext, useState } from 'react';
2
2
  import { OverlayTrigger, Tooltip } from '../../bootstrap';
3
- import { FileId, PaneId, TabState } from '../../../types';
3
+ import { PaneId, TabState } from '../../../types';
4
+ import { VizFileId } from '@vizhub/viz-types';
4
5
  import { VZCodeContext } from '../../VZCodeContext';
5
6
  import {
6
7
  RequestId,
@@ -27,7 +28,7 @@ export const AIAssistWidget = ({
27
28
  aiAssistOptions: { [key: string]: string };
28
29
  aiAssistTooltipText?: string;
29
30
  aiAssistClickOverride?: () => void;
30
- activeFileId: FileId;
31
+ activeFileId: VizFileId;
31
32
  tabList: Array<TabState>;
32
33
  paneId: PaneId;
33
34
  }) => {
@@ -1,11 +1,11 @@
1
- import { File } from '../../types';
1
+ import { VizFile } from '@vizhub/viz-types';
2
2
 
3
3
  const maxFileNameLength = 100;
4
4
  const maxFileTextLength = 2000;
5
5
 
6
6
  // Formats a file for the prompt.
7
7
  export const formatFile = (
8
- file: File,
8
+ file: VizFile,
9
9
  truncateText = true,
10
10
  ) => {
11
11
  const nameTruncated = file.name
@@ -1,11 +1,10 @@
1
1
  import { EditorView } from 'codemirror';
2
+ import { ShareDBDoc, TabState } from '../../types';
2
3
  import {
3
- File,
4
- FileId,
5
- ShareDBDoc,
6
- TabState,
7
- VZCodeContent,
8
- } from '../../types';
4
+ VizFile,
5
+ VizFileId,
6
+ VizContent,
7
+ } from '@vizhub/viz-types';
9
8
  import { RequestId } from '../generateRequestId';
10
9
  import { formatFile } from './formatFile';
11
10
 
@@ -26,8 +25,8 @@ export const startAIAssist = async ({
26
25
  aiStreamId,
27
26
  }: {
28
27
  view: EditorView;
29
- shareDBDoc: ShareDBDoc<VZCodeContent>;
30
- fileId: FileId;
28
+ shareDBDoc: ShareDBDoc<VizContent>;
29
+ fileId: VizFileId;
31
30
  tabList: Array<TabState>;
32
31
  aiAssistEndpoint?: string;
33
32
  aiAssistOptions?: {
@@ -4,14 +4,15 @@ import {
4
4
  useCallback,
5
5
  useRef,
6
6
  } from 'react';
7
- import { ShareDBDoc, VZCodeContent } from '../../types';
7
+ import { ShareDBDoc } from '../../types';
8
+ import { VizContent } from '@vizhub/viz-types';
8
9
 
9
10
  // import { runDelay } from '../constants';
10
11
  // TODO understand what this part is for
11
12
  const runDelay = 1000;
12
13
 
13
14
  export const usePending = (
14
- shareDBDoc: ShareDBDoc<VZCodeContent>,
15
+ shareDBDoc: ShareDBDoc<VizContent>,
15
16
  ) => {
16
17
  const lastOpTimerRef = useRef<NodeJS.Timeout>();
17
18
 
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useState, useRef } from 'react';
2
2
  import { randomId } from '../../randomId';
3
- import { ShareDBDoc, VZCodeContent } from '../../types';
3
+ import { ShareDBDoc } from '../../types';
4
+ import { VizContent } from '@vizhub/viz-types';
4
5
  import { useSubmitOperation } from '../useSubmitOperation';
5
6
  import { usePending } from './usePending';
6
7
 
@@ -12,7 +13,7 @@ export const useShareDB = ({
12
13
  }) => {
13
14
  // The ShareDB document.
14
15
  const [shareDBDoc, setShareDBDoc] =
15
- useState<ShareDBDoc<VZCodeContent> | null>(null);
16
+ useState<ShareDBDoc<VizContent> | null>(null);
16
17
 
17
18
  // Local ShareDB presence, for broadcasting our cursor position
18
19
  // so other clients can see it.
@@ -26,8 +27,9 @@ export const useShareDB = ({
26
27
  // The `doc.data` part of the ShareDB document,
27
28
  // updated on each change to decouple rendering from ShareDB.
28
29
  // Starts out as `null` until the document is loaded.
29
- const [content, setContent] =
30
- useState<VZCodeContent | null>(null);
30
+ const [content, setContent] = useState<VizContent | null>(
31
+ null,
32
+ );
31
33
 
32
34
  const [connected, setConnected] =
33
35
  useState<boolean>(false);
@@ -145,7 +147,7 @@ export const useShareDB = ({
145
147
  // A convenience function for mutating the ShareDB document
146
148
  // based submitting OT ops generated by diffing the JSON.
147
149
  const submitOperation =
148
- useSubmitOperation<VZCodeContent>(shareDBDoc);
150
+ useSubmitOperation<VizContent>(shareDBDoc);
149
151
 
150
152
  return {
151
153
  shareDBDoc,
@@ -19,13 +19,12 @@ import { Diagnostic, linter } from '@codemirror/lint';
19
19
 
20
20
  import { json1Presence, textUnicode } from '../../ot';
21
21
  import {
22
- FileId,
23
22
  PaneId,
24
23
  ShareDBDoc,
25
24
  TabState,
26
25
  Username,
27
- VZCodeContent,
28
26
  } from '../../types';
27
+ import { VizFileId, VizContent } from '@vizhub/viz-types';
29
28
  import { json1PresenceBroadcast } from './json1PresenceBroadcast';
30
29
  import { json1PresenceDisplay } from './json1PresenceDisplay';
31
30
  import {
@@ -143,7 +142,7 @@ export const getOrCreateEditor = ({
143
142
  }: {
144
143
  // TODO pass this in from the outside
145
144
  paneId?: PaneId;
146
- fileId: FileId;
145
+ fileId: VizFileId;
147
146
 
148
147
  // The ShareDB document that contains the file.
149
148
  // Used when the editor is created for:
@@ -155,10 +154,10 @@ export const getOrCreateEditor = ({
155
154
  // This can be `undefined` in the case where we are
156
155
  // viewing files read-only, in which case multiplayer
157
156
  // editing is not enabled.
158
- shareDBDoc: ShareDBDoc<VZCodeContent> | undefined;
157
+ shareDBDoc: ShareDBDoc<VizContent> | undefined;
159
158
 
160
159
  // The initial content to present.
161
- content: VZCodeContent;
160
+ content: VizContent;
162
161
 
163
162
  filesPath: string[];
164
163
  localPresence: any;
@@ -6,8 +6,8 @@ import {
6
6
  } from '@codemirror/view';
7
7
  import { Annotation, RangeSet } from '@codemirror/state';
8
8
  import { assignUserColor } from '../presenceColor';
9
+ import { VizFileId } from '@vizhub/viz-types';
9
10
  import {
10
- FileId,
11
11
  Presence,
12
12
  PresenceId,
13
13
  TabState,
@@ -98,7 +98,7 @@ export const json1PresenceDisplay = ({
98
98
  // in the current file, then open the tab of the other user.
99
99
  if (enableAutoFollowRef.current) {
100
100
  openTab({
101
- fileId: presence.start[1] as FileId,
101
+ fileId: presence.start[1] as VizFileId,
102
102
  isTransient: true,
103
103
  });
104
104
  }
@@ -1,5 +1,5 @@
1
1
  import { useState, useCallback, useEffect } from 'react';
2
- import { VZCodeContent } from '../../types';
2
+ import { VizContent } from '@vizhub/viz-types';
3
3
  import { CloseSVG } from '../Icons';
4
4
  import './style.scss';
5
5
 
@@ -10,7 +10,7 @@ export const CodeErrorOverlay = ({
10
10
  content,
11
11
  }: {
12
12
  errorMessage: string | null;
13
- content: VZCodeContent;
13
+ content: VizContent;
14
14
  }) => {
15
15
  // console.log(
16
16
  // 'errorMessage in CodeErrorOverlay: ',
@@ -1,5 +1,6 @@
1
1
  import { useCallback, useMemo } from 'react';
2
- import type { FileId, TabState } from '../../types';
2
+ import type { TabState } from '../../types';
3
+ import type { VizFileId } from '@vizhub/viz-types';
3
4
  import { CloseSVG } from '../Icons';
4
5
 
5
6
  // Supports adding the file's containing folder to the tab name
@@ -20,12 +21,12 @@ export const Tab = ({
20
21
  closeTabs,
21
22
  fileName,
22
23
  }: {
23
- fileId: FileId;
24
+ fileId: VizFileId;
24
25
  isTransient?: boolean;
25
26
  isActive: boolean;
26
- setActiveFileId: (fileId: FileId) => void;
27
+ setActiveFileId: (fileId: VizFileId) => void;
27
28
  openTab: (tabState: TabState) => void;
28
- closeTabs: (fileIds: FileId[]) => void;
29
+ closeTabs: (fileIds: VizFileId[]) => void;
29
30
  fileName: string;
30
31
  }) => {
31
32
  const handleCloseClick = useCallback(
@@ -6,7 +6,6 @@ import {
6
6
  useState,
7
7
  } from 'react';
8
8
  import {
9
- Files,
10
9
  ItemId,
11
10
  LeafPane,
12
11
  Pane,
@@ -18,8 +17,8 @@ import {
18
17
  SubmitOperation,
19
18
  TabState,
20
19
  Username,
21
- VZCodeContent,
22
20
  } from '../types';
21
+ import { VizFiles, VizContent } from '@vizhub/viz-types';
23
22
  import {
24
23
  ThemeLabel,
25
24
  defaultTheme,
@@ -49,17 +48,17 @@ export const VZCodeContext =
49
48
 
50
49
  // The type of the object provided by this context.
51
50
  export type VZCodeContextValue = {
52
- content: VZCodeContent | null;
53
- shareDBDoc: ShareDBDoc<VZCodeContent> | null;
51
+ content: VizContent | null;
52
+ shareDBDoc: ShareDBDoc<VizContent> | null;
54
53
  submitOperation: (
55
- next: (content: VZCodeContent) => VZCodeContent,
54
+ next: (content: VizContent) => VizContent,
56
55
  ) => void;
57
56
  // TODO pull in this type from ShareDB if possible
58
57
  localPresence: any;
59
58
  // TODO pull in this type from ShareDB if possible
60
59
  docPresence: any;
61
60
 
62
- files: Files | null;
61
+ files: VizFiles | null;
63
62
  createFile: (fileName: string, text?: string) => void;
64
63
  renameFile: (fileId: string, fileName: string) => void;
65
64
  deleteFile: (fileId: string) => void;
@@ -117,16 +116,14 @@ export type VZCodeContextValue = {
117
116
  isSearchOpen: boolean;
118
117
  setIsSearchOpen: (isSearchOpen: boolean) => void;
119
118
  setSearch: (pattern: string) => void;
120
- setSearchResults: (
121
- files: ShareDBDoc<VZCodeContent>,
122
- ) => void;
119
+ setSearchResults: (files: ShareDBDoc<VizContent>) => void;
123
120
  setSearchFileVisibility: (
124
- files: ShareDBDoc<VZCodeContent>,
121
+ files: ShareDBDoc<VizContent>,
125
122
  id: string,
126
123
  visibility: SearchFileVisibility,
127
124
  ) => void;
128
125
  setSearchLineVisibility: (
129
- files: ShareDBDoc<VZCodeContent>,
126
+ files: ShareDBDoc<VizContent>,
130
127
  id: string,
131
128
  line: number,
132
129
  ) => void;
@@ -201,8 +198,8 @@ export const VZCodeProvider = ({
201
198
  liveKitConnection,
202
199
  setLiveKitConnection,
203
200
  }: {
204
- content: VZCodeContent;
205
- shareDBDoc: ShareDBDoc<VZCodeContent>;
201
+ content: VizContent;
202
+ shareDBDoc: ShareDBDoc<VizContent>;
206
203
  submitOperation: SubmitOperation;
207
204
  localPresence: any;
208
205
  docPresence: any;
@@ -221,15 +218,7 @@ export const VZCodeProvider = ({
221
218
  setLiveKitConnection: (state: boolean) => void;
222
219
  }) => {
223
220
  // Auto-run Pretter after local changes.
224
- const {
225
- prettierError,
226
- runPrettierRef,
227
- }: {
228
- prettierError: string | null;
229
- runPrettierRef: React.MutableRefObject<
230
- null | (() => void)
231
- >;
232
- } = usePrettier({
221
+ const { prettierError, runPrettierRef } = usePrettier({
233
222
  shareDBDoc,
234
223
  submitOperation,
235
224
  prettierWorker,
@@ -393,7 +382,7 @@ export const VZCodeProvider = ({
393
382
  );
394
383
 
395
384
  // Isolate the files object from the document.
396
- const files: Files | null = content
385
+ const files: VizFiles | null = content
397
386
  ? content.files
398
387
  : null;
399
388
 
@@ -1,6 +1,7 @@
1
1
  import { useCallback, useContext } from 'react';
2
2
  import { Item } from './Item';
3
- import { FileId, PresenceIndicator } from '../../types';
3
+ import { PresenceIndicator } from '../../types';
4
+ import { VizFileId } from '@vizhub/viz-types';
4
5
  import { VZCodeContext } from '../VZCodeContext';
5
6
  import { FileTypeIcon } from './FileTypeIcon';
6
7
  import { assignUserColor } from '../presenceColor';
@@ -44,9 +45,9 @@ export const FileListing = ({
44
45
  presence,
45
46
  }: {
46
47
  name: string;
47
- fileId: FileId;
48
- handleFileClick: (fileId: FileId) => void;
49
- handleFileDoubleClick: (fileId: FileId) => void;
48
+ fileId: VizFileId;
49
+ handleFileClick: (fileId: VizFileId) => void;
50
+ handleFileDoubleClick: (fileId: VizFileId) => void;
50
51
  isActive: boolean;
51
52
  presence: PresenceIndicator[];
52
53
  }) => {
@@ -1,9 +1,6 @@
1
1
  import { useContext } from 'react';
2
- import type {
3
- FileId,
4
- FileTree,
5
- FileTreeFile,
6
- } from '../../types';
2
+ import { VizFileId } from '@vizhub/viz-types';
3
+ import type { FileTree, FileTreeFile } from '../../types';
7
4
  import { VZCodeContext } from '../VZCodeContext';
8
5
  import { DirectoryListing } from './DirectoryListing';
9
6
  import { FileListing } from './FileListing';
@@ -16,8 +13,8 @@ export const Listing = ({
16
13
  handleFileDoubleClick,
17
14
  }: {
18
15
  entity: FileTree | FileTreeFile;
19
- handleFileClick: (fileId: FileId) => void;
20
- handleFileDoubleClick: (fileId: FileId) => void;
16
+ handleFileClick: (fileId: VizFileId) => void;
17
+ handleFileDoubleClick: (fileId: VizFileId) => void;
21
18
  }) => {
22
19
  const { activePane, sidebarPresenceIndicators } =
23
20
  useContext(VZCodeContext);
@@ -7,7 +7,8 @@ import {
7
7
  } from 'react';
8
8
  import { Form } from '../bootstrap';
9
9
  import { VZCodeContext } from '../VZCodeContext';
10
- import { FileId, SearchFile } from '../../types';
10
+ import { VizFileId } from '@vizhub/viz-types';
11
+ import { SearchFile } from '../../types';
11
12
  import { EditorView } from 'codemirror';
12
13
  import { CloseSVG, DirectoryArrowSVG } from '../Icons';
13
14
  import { FileTypeIcon } from './FileTypeIcon';
@@ -112,12 +113,12 @@ export const Search = () => {
112
113
  [focusedIndex, focusedChildIndex],
113
114
  );
114
115
 
115
- const closeResult = useCallback((fileId: FileId) => {
116
+ const closeResult = useCallback((fileId: VizFileId) => {
116
117
  setSearchFileVisibility(shareDBDoc, fileId, 'closed');
117
118
  }, []);
118
119
 
119
120
  const focusFileElement = useCallback(
120
- (fileId: FileId, index: number) => {
121
+ (fileId: VizFileId, index: number) => {
121
122
  setActiveFileId(fileId);
122
123
  setSearchFocusedIndex(index, null);
123
124
  },
@@ -225,7 +226,7 @@ export const Search = () => {
225
226
  break;
226
227
  case 'Enter':
227
228
  case ' ':
228
- const fileId: string = files[focusedIndex][0];
229
+ const fileId: VizFileId = files[focusedIndex][0];
229
230
  setActiveFileId(fileId);
230
231
 
231
232
  if (focusedChildIndex !== null) {
@@ -7,13 +7,13 @@ import {
7
7
  useRef,
8
8
  } from 'react';
9
9
  import {
10
- FileId,
11
10
  FileTree,
12
11
  FileTreeFile,
13
12
  Presence,
14
13
  PresenceId,
15
14
  PresenceIndicator,
16
15
  } from '../../types';
16
+ import { VizFileId } from '@vizhub/viz-types';
17
17
  import { OverlayTrigger, Tooltip } from '../bootstrap';
18
18
  import { getFileTree } from '../getFileTree';
19
19
  import {
@@ -156,7 +156,7 @@ export const VZSidebar = ({
156
156
 
157
157
  // On single-click, open the file in a transient tab.
158
158
  const handleFileClick = useCallback(
159
- (fileId: FileId) => {
159
+ (fileId: VizFileId) => {
160
160
  openTab({ fileId, isTransient: true });
161
161
  },
162
162
  [openTab],
@@ -164,7 +164,7 @@ export const VZSidebar = ({
164
164
 
165
165
  // On double-click, open the file in a persistent tab.
166
166
  const handleFileDoubleClick = useCallback(
167
- (fileId: FileId) => {
167
+ (fileId: VizFileId) => {
168
168
  openTab({ fileId, isTransient: false });
169
169
  },
170
170
  [openTab],
@@ -199,7 +199,7 @@ export const VZSidebar = ({
199
199
  ) => {
200
200
  const presenceIndicator: PresenceIndicator = {
201
201
  username: update.username,
202
- fileId: update.start[1] as FileId,
202
+ fileId: update.start[1] as VizFileId,
203
203
  };
204
204
 
205
205
  // console.log('Got presence!');
@@ -1,9 +1,10 @@
1
1
  // Inspired by
2
2
 
3
- import { Files, FileTree } from '../types';
3
+ import { FileTree } from '../types';
4
+ import { VizFiles } from '@vizhub/viz-types';
4
5
 
5
6
  // https://github.com/vizhub-core/vizhub/blob/main/vizhub-v2/packages/neoFrontend/src/pages/VizPage/Body/Editor/FilesSection/FileTree/getFileTree.js
6
- export const getFileTree = (files: Files): FileTree => {
7
+ export const getFileTree = (files: VizFiles): FileTree => {
7
8
  const tree: FileTree = { name: 'files' };
8
9
  for (const fileId of Object.keys(files)) {
9
10
  const file = files[fileId];
@@ -43,7 +44,7 @@ export const getFileTree = (files: Files): FileTree => {
43
44
  if (file.text !== null) {
44
45
  (node.children || (node.children = [])).push({
45
46
  name: path[n - 1],
46
- file,
47
+ file: file as any, // Type assertion to resolve compatibility issue
47
48
  fileId,
48
49
  });
49
50
  }
@@ -4,7 +4,7 @@ import {
4
4
  decodeTabs,
5
5
  delimiter,
6
6
  } from './tabsSearchParameters';
7
- import { VZCodeContent } from '../types';
7
+ import { VizContent } from '@vizhub/viz-types';
8
8
 
9
9
  describe('tabsSearchParameters', () => {
10
10
  test.each([
@@ -53,7 +53,8 @@ describe('tabsSearchParameters', () => {
53
53
  'round trip: $name',
54
54
  ({ tabStateParams, tabList, activeFileId }) => {
55
55
  // Fake Content object
56
- const content: VZCodeContent = {
56
+ const content: VizContent = {
57
+ id: 'test-viz-id', // Add required id property
57
58
  files: {
58
59
  '123': { name: 'index.js', text: 'abc' },
59
60
  '456': { name: 'README.md', text: 'def' },