vzcode 1.11.0 → 1.12.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/README.md +1 -1
- package/dist/assets/{index-BSuijdti.js → index-4cYZN5Uf.js} +56 -56
- package/dist/assets/{index--bvX81xc.js → index-CvSVuMne.js} +57 -57
- package/dist/assets/worker-CJWrLBN2.js +286 -0
- package/dist/index.html +1 -1
- package/package.json +13 -12
- package/src/client/AIAssist/AIAssistCodeMirrorKeyMap.ts +5 -2
- package/src/client/AIAssist/startAIAssist.ts +1 -1
- package/src/client/CodeEditor/getOrCreateEditor.ts +1 -1
- package/src/client/CodeEditor/json1PresenceDisplay.ts +1 -1
- package/src/client/TabList/Tab.tsx +1 -2
- package/src/client/TabList/index.tsx +1 -1
- package/src/client/VZCodeContext.tsx +14 -7
- package/src/client/VZKeyboardShortcutsDoc.tsx +2 -1
- package/src/client/VZSidebar/Search.tsx +7 -2
- package/src/client/VZSidebar/index.tsx +87 -24
- package/src/client/tabsSearchParameters.ts +1 -2
- package/src/client/useActions.ts +10 -1
- package/src/client/useKeyboardShortcuts.ts +31 -1
- package/src/client/useURLSync.ts +1 -2
- package/src/client/vzReducer/closeTabReducer.test.ts +49 -33
- package/src/client/vzReducer/closeTabsReducer.ts +51 -19
- package/src/client/vzReducer/createInitialState.ts +8 -3
- package/src/client/vzReducer/findPane.ts +19 -0
- package/src/client/vzReducer/index.ts +17 -25
- package/src/client/vzReducer/openTabReducer.test.ts +38 -21
- package/src/client/vzReducer/openTabReducer.ts +26 -10
- package/src/client/vzReducer/searchReducer.ts +21 -1
- package/src/client/vzReducer/setActiveFileIdReducer.ts +23 -4
- package/src/client/vzReducer/setActiveFileLeftRightReducer.ts +37 -8
- package/src/client/vzReducer/updatePane.ts +44 -0
- package/src/server/index.js +1 -0
- package/src/types.ts +62 -0
- package/dist/assets/worker-Cs0ZU3m1.js +0 -291
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { VZAction, VZState } from '.';
|
|
2
|
+
import { Pane } from '../../types';
|
|
3
|
+
import { findPane } from './findPane';
|
|
4
|
+
import { updatePane } from './updatePane';
|
|
2
5
|
|
|
3
6
|
export const setActiveFileLeftReducer = (
|
|
4
7
|
state: VZState,
|
|
@@ -8,18 +11,31 @@ export const setActiveFileLeftReducer = (
|
|
|
8
11
|
return state;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
const { pane, activePaneId } = state;
|
|
15
|
+
const activePane: Pane = findPane(pane, activePaneId);
|
|
16
|
+
|
|
17
|
+
if (activePane.type !== 'leafPane') {
|
|
18
|
+
throw new Error(
|
|
19
|
+
'closeTabsReducer: activePane is not a leafPane',
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let index = activePane.tabList.findIndex(
|
|
24
|
+
(tab) => tab.fileId === activePane.activeFileId,
|
|
13
25
|
);
|
|
14
26
|
|
|
15
27
|
index -= 1;
|
|
16
28
|
if (index < 0) {
|
|
17
|
-
index =
|
|
29
|
+
index = activePane.tabList.length - 1;
|
|
18
30
|
}
|
|
19
31
|
|
|
20
32
|
return {
|
|
21
33
|
...state,
|
|
22
|
-
|
|
34
|
+
pane: updatePane({
|
|
35
|
+
pane,
|
|
36
|
+
activePaneId,
|
|
37
|
+
newActiveFileId: activePane.tabList[index].fileId,
|
|
38
|
+
}),
|
|
23
39
|
};
|
|
24
40
|
};
|
|
25
41
|
|
|
@@ -31,17 +47,30 @@ export const setActiveFileRightReducer = (
|
|
|
31
47
|
return state;
|
|
32
48
|
}
|
|
33
49
|
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
const { pane, activePaneId } = state;
|
|
51
|
+
const activePane: Pane = findPane(pane, activePaneId);
|
|
52
|
+
|
|
53
|
+
if (activePane.type !== 'leafPane') {
|
|
54
|
+
throw new Error(
|
|
55
|
+
'closeTabsReducer: activePane is not a leafPane',
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let index = activePane.tabList.findIndex(
|
|
60
|
+
(tab) => tab.fileId === activePane.activeFileId,
|
|
36
61
|
);
|
|
37
62
|
|
|
38
63
|
index += 1;
|
|
39
|
-
if (index >
|
|
64
|
+
if (index > activePane.tabList.length - 1) {
|
|
40
65
|
index = 0;
|
|
41
66
|
}
|
|
42
67
|
|
|
43
68
|
return {
|
|
44
69
|
...state,
|
|
45
|
-
|
|
70
|
+
pane: updatePane({
|
|
71
|
+
pane,
|
|
72
|
+
activePaneId,
|
|
73
|
+
newActiveFileId: activePane.tabList[index].fileId,
|
|
74
|
+
}),
|
|
46
75
|
};
|
|
47
76
|
};
|
|
@@ -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;
|
package/src/server/index.js
CHANGED
|
@@ -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`
|