vzcode 1.13.0 → 1.14.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,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-BpeGnq7b.js"></script>
23
+ <script type="module" crossorigin src="/assets/index-DGNI0PAo.js"></script>
24
24
  <link rel="stylesheet" crossorigin href="/assets/index-Wxh-Jaj6.css">
25
25
  </head>
26
26
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -145,7 +145,7 @@
145
145
  "react": "^18.3.1",
146
146
  "react-bootstrap": "^2.10.4",
147
147
  "react-dom": "^18.3.1",
148
- "react-router-dom": "^6.25.1",
148
+ "react-router-dom": "^6.26.0",
149
149
  "sharedb": "^5.0.3",
150
150
  "sharedb-client-browser": "^5.0.3",
151
151
  "vizhub-ui": "^3.23.0",
@@ -161,10 +161,10 @@
161
161
  "sass": "^1.77.8",
162
162
  "typescript": "^5.5.4",
163
163
  "vite": "^5.3.5",
164
- "vitest": "^2.0.4"
164
+ "vitest": "^2.0.5"
165
165
  },
166
166
  "optionalDependencies": {
167
- "@rollup/rollup-darwin-arm64": "^4.19.1",
168
- "@rollup/rollup-win32-x64-msvc": "^4.19.1"
167
+ "@rollup/rollup-darwin-arm64": "^4.19.2",
168
+ "@rollup/rollup-win32-x64-msvc": "^4.19.2"
169
169
  }
170
170
  }
@@ -8,6 +8,7 @@ import {
8
8
  import { SparklesSVG } from '../../Icons';
9
9
  import { startAIAssist } from '../startAIAssist';
10
10
  import { Spinner } from '../Spinner';
11
+ import { editorCacheKey } from '../../useEditorCache';
11
12
  import './style.scss';
12
13
 
13
14
  const enableStopGeneration = false;
@@ -23,8 +24,15 @@ export const AIAssistWidget = ({
23
24
  aiAssistTooltipText?: string;
24
25
  aiAssistClickOverride?: () => void;
25
26
  }) => {
26
- const { shareDBDoc, activeFileId, tabList, editorCache } =
27
- useContext(VZCodeContext);
27
+ const {
28
+ shareDBDoc,
29
+ activeFileId,
30
+ activePaneId,
31
+ tabList,
32
+ editorCache,
33
+ runPrettierRef,
34
+ runCodeRef,
35
+ } = useContext(VZCodeContext);
28
36
 
29
37
  // The stream ID of the most recent request.
30
38
  // * If `null`, no request has been made yet.
@@ -33,9 +41,6 @@ export const AIAssistWidget = ({
33
41
  const [aiStreamId, setAiStreamId] =
34
42
  useState<RequestId | null>(null);
35
43
 
36
- const { runPrettierRef, runCodeRef } =
37
- useContext(VZCodeContext);
38
-
39
44
  const handleClick = useCallback(async () => {
40
45
  const isCurrentlyGenerationg = aiStreamId !== null;
41
46
  if (isCurrentlyGenerationg) {
@@ -46,7 +51,9 @@ export const AIAssistWidget = ({
46
51
 
47
52
  // Wait for generation to finish.
48
53
  await startAIAssist({
49
- view: editorCache.get(activeFileId).editor,
54
+ view: editorCache.get(
55
+ editorCacheKey(activeFileId, activePaneId),
56
+ ).editor,
50
57
  shareDBDoc,
51
58
  fileId: activeFileId,
52
59
  tabList,
@@ -89,7 +96,7 @@ export const AIAssistWidget = ({
89
96
  : currentAIStreamId,
90
97
  );
91
98
  }
92
- }, [activeFileId, aiStreamId]);
99
+ }, [activeFileId, activePaneId, aiStreamId]);
93
100
 
94
101
  const showWidget = enableStopGeneration
95
102
  ? true
@@ -33,6 +33,7 @@ import {
33
33
  } from './InteractiveWidgets';
34
34
  import {
35
35
  EditorCache,
36
+ editorCacheKey,
36
37
  EditorCacheValue,
37
38
  } from '../useEditorCache';
38
39
  import { ThemeLabel, themeOptionsByLabel } from '../themes';
@@ -158,7 +159,7 @@ export const getOrCreateEditor = ({
158
159
  }): EditorCacheValue => {
159
160
  // Cache hit
160
161
 
161
- const cacheKey = fileId + '|' + paneId;
162
+ const cacheKey = editorCacheKey(fileId, paneId);
162
163
 
163
164
  if (editorCache.has(cacheKey)) {
164
165
  return editorCache.get(cacheKey);
@@ -16,6 +16,8 @@ import {
16
16
  SearchFileVisibility,
17
17
  TabState,
18
18
  PresenceIndicator,
19
+ Pane,
20
+ PaneId,
19
21
  } from '../types';
20
22
  import { usePrettier } from './usePrettier';
21
23
  import { useTypeScript } from './useTypeScript';
@@ -75,6 +77,8 @@ export type VZCodeContextValue = {
75
77
  setActiveFileLeft: () => void;
76
78
  setActiveFileRight: () => void;
77
79
 
80
+ activePaneId: PaneId;
81
+
78
82
  tabList: Array<TabState>;
79
83
  openTab: (tabState: TabState) => void;
80
84
  closeTabs: (fileIds: string[]) => void;
@@ -235,6 +239,7 @@ export const VZCodeProvider = ({
235
239
  // console.log('state: ', state);
236
240
  const {
237
241
  pane,
242
+ activePaneId,
238
243
  theme,
239
244
  search,
240
245
  isSearchOpen,
@@ -395,6 +400,8 @@ export const VZCodeProvider = ({
395
400
  setActiveFileLeft,
396
401
  setActiveFileRight,
397
402
 
403
+ activePaneId,
404
+
398
405
  tabList,
399
406
  openTab,
400
407
  closeTabs,
@@ -189,11 +189,11 @@ export const VZSidebar = ({
189
189
  fileId: update.start[1] as FileId,
190
190
  };
191
191
 
192
- console.log('Got presence!');
193
- // console.log({presenceId,update})
194
- console.log(
195
- JSON.stringify(presenceIndicator, null, 2),
196
- );
192
+ // console.log('Got presence!');
193
+ // // console.log({presenceId,update})
194
+ // console.log(
195
+ // JSON.stringify(presenceIndicator, null, 2),
196
+ // );
197
197
 
198
198
  updatePresenceIndicator(presenceIndicator);
199
199
  };
@@ -205,7 +205,7 @@ export const VZSidebar = ({
205
205
  }
206
206
  }, [docPresence]);
207
207
 
208
- console.log(sidebarPresenceIndicators);
208
+ // console.log(sidebarPresenceIndicators);
209
209
 
210
210
  return (
211
211
  <div
@@ -1,5 +1,5 @@
1
1
  import { useRef } from 'react';
2
- import { FileId } from '../types';
2
+ import { FileId, PaneId } from '../types';
3
3
  import { EditorView } from 'codemirror';
4
4
 
5
5
  export type EditorCacheValue = {
@@ -8,7 +8,17 @@ export type EditorCacheValue = {
8
8
  scrollPosition?: number;
9
9
  };
10
10
 
11
- export type EditorCache = Map<FileId, EditorCacheValue>;
11
+ export type EditorCacheKey = string;
12
+
13
+ export const editorCacheKey = (
14
+ fileId: FileId,
15
+ paneId: PaneId,
16
+ ): EditorCacheKey => fileId + '|' + paneId;
17
+
18
+ export type EditorCache = Map<
19
+ EditorCacheKey,
20
+ EditorCacheValue
21
+ >;
12
22
 
13
23
  export const useEditorCache = () => {
14
24
  // Singleton cache of CodeMirror instances
@@ -1,9 +1,4 @@
1
- import {
2
- PaneId,
3
- LeafPane,
4
- SplitPane,
5
- Pane,
6
- } from '../../types';
1
+ import { PaneId, Pane } from '../../types';
7
2
  import { VZAction, VZState } from '.';
8
3
  import { updatePane } from './updatePane';
9
4
 
@@ -11,7 +6,7 @@ export const splitCurrentPaneReducer = (
11
6
  state: VZState,
12
7
  action: VZAction,
13
8
  ): VZState => {
14
- console.log('splitCurrentPaneReducer');
9
+ // console.log('splitCurrentPaneReducer');
15
10
  if (action.type !== 'split_current_pane') {
16
11
  return state;
17
12
  }