vzcode 1.11.0 → 1.13.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 (48) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/index-Bm65AzMP.js +425 -0
  3. package/dist/assets/index-BpeGnq7b.js +157 -0
  4. package/dist/assets/{index-BKRpkJER.css → index-Wxh-Jaj6.css} +1 -1
  5. package/dist/assets/worker-CJWrLBN2.js +286 -0
  6. package/dist/index.html +2 -2
  7. package/package.json +18 -17
  8. package/src/client/AIAssist/AIAssistCodeMirrorKeyMap.ts +5 -2
  9. package/src/client/AIAssist/startAIAssist.ts +1 -1
  10. package/src/client/CodeEditor/getOrCreateEditor.ts +11 -4
  11. package/src/client/CodeEditor/index.tsx +2 -0
  12. package/src/client/CodeEditor/json1PresenceDisplay.ts +1 -1
  13. package/src/client/Icons/SplitEditorSVG.tsx +34 -0
  14. package/src/client/RunCodeWidget/index.tsx +48 -16
  15. package/src/client/RunCodeWidget/style.scss +6 -1
  16. package/src/client/TabList/Tab.tsx +1 -2
  17. package/src/client/TabList/index.tsx +1 -1
  18. package/src/client/VZCodeContext.tsx +30 -7
  19. package/src/client/VZKeyboardShortcutsDoc.tsx +2 -1
  20. package/src/client/VZSidebar/DirectoryListing.tsx +2 -1
  21. package/src/client/VZSidebar/FileListing.tsx +23 -3
  22. package/src/client/VZSidebar/Item.tsx +2 -2
  23. package/src/client/VZSidebar/Listing.tsx +8 -1
  24. package/src/client/VZSidebar/Search.tsx +7 -2
  25. package/src/client/VZSidebar/index.tsx +130 -24
  26. package/src/client/VZSidebar/styles.scss +25 -0
  27. package/src/client/tabsSearchParameters.ts +1 -2
  28. package/src/client/useActions.ts +29 -1
  29. package/src/client/useKeyboardShortcuts.ts +31 -1
  30. package/src/client/useURLSync.ts +1 -2
  31. package/src/client/vzReducer/closeTabReducer.test.ts +49 -33
  32. package/src/client/vzReducer/closeTabsReducer.ts +51 -19
  33. package/src/client/vzReducer/createInitialState.ts +9 -3
  34. package/src/client/vzReducer/findPane.ts +19 -0
  35. package/src/client/vzReducer/index.ts +38 -27
  36. package/src/client/vzReducer/openTabReducer.test.ts +38 -21
  37. package/src/client/vzReducer/openTabReducer.ts +26 -10
  38. package/src/client/vzReducer/searchReducer.ts +21 -1
  39. package/src/client/vzReducer/setActiveFileIdReducer.ts +23 -4
  40. package/src/client/vzReducer/setActiveFileLeftRightReducer.ts +37 -8
  41. package/src/client/vzReducer/splitCurrentPaneReducer.ts +71 -0
  42. package/src/client/vzReducer/updatePane.ts +44 -0
  43. package/src/client/vzReducer/updatePresenceIndicatorReducer.ts +30 -0
  44. package/src/server/index.js +1 -0
  45. package/src/types.ts +86 -1
  46. package/dist/assets/index--bvX81xc.js +0 -425
  47. package/dist/assets/index-BSuijdti.js +0 -157
  48. package/dist/assets/worker-Cs0ZU3m1.js +0 -291
@@ -0,0 +1,44 @@
1
+ import {
2
+ FileId,
3
+ Pane,
4
+ PaneId,
5
+ TabState,
6
+ } from '../../types';
7
+
8
+ // Immutable update pattern for updating a pane's tab list.
9
+ export const updatePane = ({
10
+ pane,
11
+ activePaneId,
12
+ newTabList,
13
+ newActiveFileId,
14
+ }: {
15
+ pane: Pane;
16
+ activePaneId: PaneId;
17
+ newTabList?: Array<TabState>;
18
+ newActiveFileId?: FileId | null;
19
+ }): Pane =>
20
+ pane.type === 'splitPane'
21
+ ? {
22
+ ...pane,
23
+ children: pane.children.map((child) =>
24
+ updatePane({
25
+ pane: child,
26
+ activePaneId,
27
+ newTabList,
28
+ newActiveFileId,
29
+ }),
30
+ ),
31
+ }
32
+ : pane.id === activePaneId
33
+ ? {
34
+ ...pane,
35
+ tabList:
36
+ newTabList !== undefined
37
+ ? newTabList
38
+ : pane.tabList,
39
+ activeFileId:
40
+ newActiveFileId !== undefined
41
+ ? newActiveFileId
42
+ : pane.activeFileId,
43
+ }
44
+ : pane;
@@ -0,0 +1,30 @@
1
+ import { VZAction, VZState } from '.';
2
+
3
+ export const updatePresenceIndicatorReducer = (
4
+ state: VZState,
5
+ action: VZAction,
6
+ ): VZState => {
7
+ if (action.type === 'update_presence_indicator') {
8
+ // True if there's already an entry for this user.
9
+ const needsUpdate =
10
+ state.sidebarPresenceIndicators.find(
11
+ (d) =>
12
+ d.username === action.presenceIndicator.username,
13
+ );
14
+
15
+ return {
16
+ ...state,
17
+ sidebarPresenceIndicators: needsUpdate
18
+ ? state.sidebarPresenceIndicators.map((d) =>
19
+ d.username === action.presenceIndicator.username
20
+ ? action.presenceIndicator
21
+ : d,
22
+ )
23
+ : [
24
+ ...state.sidebarPresenceIndicators,
25
+ action.presenceIndicator,
26
+ ],
27
+ };
28
+ }
29
+ return state;
30
+ };
@@ -313,6 +313,7 @@ server.listen(port, async () => {
313
313
  // Sets the port to the one specified in the environment
314
314
  // variable (for development) or the default port.
315
315
  let livePort = process.env.EDITOR_PORT || port;
316
+ console.log(`EDITOR_PORT: ${process.env.EDITOR_PORT}`);
316
317
  console.log(
317
318
  `Editor is live at http://localhost:${livePort}`,
318
319
  );
package/src/types.ts CHANGED
@@ -80,8 +80,70 @@ export interface SearchFile {
80
80
  export interface SearchResults {
81
81
  pattern: string;
82
82
  results: SearchResult;
83
+ focused: boolean;
83
84
  }
84
85
 
86
+ // Representation of an open tab.
87
+ export type TabState = {
88
+ // `fileId`
89
+ // The ID of the file that the tab represents.
90
+ fileId: FileId;
91
+
92
+ // `isTransient`
93
+ // Represents whether the tab is temporary or persistent.
94
+ // * `true` if the tab is temporary, meaning its text
95
+ // appears as italic, and it will be automatically
96
+ // closed when the user switches to another file.
97
+ // If `true` and the tab is opened, the editor will not focus.
98
+ // * `false` or `undefined` if the tab is persistent, meaning its text
99
+ // appears as normal, and it will not be automatically
100
+ // closed when the user switches to another file.
101
+ // If `false` and the tab is opened, the editor will focus.
102
+ isTransient?: boolean;
103
+ };
104
+
105
+ // PaneId
106
+ // * A unique ID for a pane.
107
+ // * This is a random string.
108
+ export type PaneId = string;
109
+
110
+ // The leaf node of the tree data structure
111
+ export type LeafPane = {
112
+ type: 'leafPane';
113
+ // The list of tabs
114
+ // Mutually exclusive with `children`.
115
+ tabList: Array<TabState>;
116
+
117
+ // The ID of the file that is currently active
118
+ // within this leaf pane.
119
+ // Invariant: `activeFileId` is always in `tabList`.
120
+ activeFileId: FileId | null;
121
+ };
122
+
123
+ // Internal node of the tree data structure
124
+ export type SplitPane = {
125
+ type: 'splitPane';
126
+
127
+ // Which orientation is it? Vertical split or horizontal split?
128
+ // Applies only to `children`
129
+ orientation: 'vertical' | 'horizontal';
130
+
131
+ // The children panels
132
+ // Mutually exclusive with `tabList`.
133
+ children: Array<Pane>;
134
+ };
135
+
136
+ // The node data structure of the split pane tree
137
+ export type Pane = {
138
+ // Every pane gets a unique ID,
139
+ // so we can refer to it in actions.
140
+ id: PaneId;
141
+
142
+ // The type of the pane
143
+ // Either a leaf pane or a split pane.
144
+ type: 'leafPane' | 'splitPane';
145
+ } & (LeafPane | SplitPane);
146
+
85
147
  export type JSONOp = any;
86
148
 
87
149
  // `ShareDBDoc`
@@ -130,13 +192,36 @@ export type VZCodeContent = {
130
192
  isInteracting?: boolean;
131
193
  };
132
194
  // Example Presence object, from ShareDB:
133
- // {"start":["files","69064344","text",183],"end":["files","69064344","text",183],"username":"Jim"}
195
+ // {
196
+ // "start": [
197
+ // "files",
198
+ // "71898298",
199
+ // "text",
200
+ // 415
201
+ // ],
202
+ // "end": [
203
+ // "files",
204
+ // "71898298",
205
+ // "text",
206
+ // 415
207
+ // ],
208
+ // "username": "Tim"
209
+ // }
134
210
  export type Presence = {
135
211
  start: Array<string | number>;
136
212
  end: Array<string | number>;
137
213
  username: Username;
138
214
  };
139
215
 
216
+ // An item in the list of sidebar presence indicators.
217
+ // It needs to know:
218
+ // * What user the presence is associated with
219
+ // * What file the presence is associated with
220
+ export type PresenceIndicator = {
221
+ username: Username;
222
+ fileId: FileId;
223
+ };
224
+
140
225
  // An id used for presence.
141
226
  export type PresenceId = string;
142
227