vzcode 1.12.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.
- package/dist/assets/index-Bm65AzMP.js +425 -0
- package/dist/assets/index-BpeGnq7b.js +157 -0
- package/dist/assets/{index-BKRpkJER.css → index-Wxh-Jaj6.css} +1 -1
- package/dist/index.html +2 -2
- package/package.json +10 -10
- package/src/client/CodeEditor/getOrCreateEditor.ts +10 -3
- package/src/client/CodeEditor/index.tsx +2 -0
- package/src/client/Icons/SplitEditorSVG.tsx +34 -0
- package/src/client/RunCodeWidget/index.tsx +48 -16
- package/src/client/RunCodeWidget/style.scss +6 -1
- package/src/client/VZCodeContext.tsx +16 -0
- package/src/client/VZSidebar/DirectoryListing.tsx +2 -1
- package/src/client/VZSidebar/FileListing.tsx +23 -3
- package/src/client/VZSidebar/Item.tsx +2 -2
- package/src/client/VZSidebar/Listing.tsx +8 -1
- package/src/client/VZSidebar/index.tsx +43 -0
- package/src/client/VZSidebar/styles.scss +25 -0
- package/src/client/useActions.ts +19 -0
- package/src/client/vzReducer/createInitialState.ts +1 -0
- package/src/client/vzReducer/index.ts +21 -2
- package/src/client/vzReducer/splitCurrentPaneReducer.ts +71 -0
- package/src/client/vzReducer/updatePresenceIndicatorReducer.ts +30 -0
- package/src/types.ts +24 -1
- package/dist/assets/index-4cYZN5Uf.js +0 -157
- package/dist/assets/index-CvSVuMne.js +0 -425
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PaneId,
|
|
3
|
+
LeafPane,
|
|
4
|
+
SplitPane,
|
|
5
|
+
Pane,
|
|
6
|
+
} from '../../types';
|
|
7
|
+
import { VZAction, VZState } from '.';
|
|
8
|
+
import { updatePane } from './updatePane';
|
|
9
|
+
|
|
10
|
+
export const splitCurrentPaneReducer = (
|
|
11
|
+
state: VZState,
|
|
12
|
+
action: VZAction,
|
|
13
|
+
): VZState => {
|
|
14
|
+
console.log('splitCurrentPaneReducer');
|
|
15
|
+
if (action.type !== 'split_current_pane') {
|
|
16
|
+
return state;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const activePaneId = state.activePaneId;
|
|
20
|
+
|
|
21
|
+
const newLeafPane1: Pane = {
|
|
22
|
+
id: `${activePaneId}-1`, // Generate unique IDs for new panes
|
|
23
|
+
type: 'leafPane',
|
|
24
|
+
tabList: [],
|
|
25
|
+
activeFileId: null,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const newLeafPane2: Pane = {
|
|
29
|
+
id: `${activePaneId}-2`,
|
|
30
|
+
type: 'leafPane',
|
|
31
|
+
tabList: [],
|
|
32
|
+
activeFileId: null,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const newSplitPane: Pane = {
|
|
36
|
+
id: activePaneId,
|
|
37
|
+
type: 'splitPane',
|
|
38
|
+
orientation: 'horizontal',
|
|
39
|
+
children: [newLeafPane1, newLeafPane2],
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const updatedPane = updatePane({
|
|
43
|
+
pane: state.pane,
|
|
44
|
+
activePaneId,
|
|
45
|
+
newTabList: undefined,
|
|
46
|
+
newActiveFileId: undefined,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const updateSplitPane = (pane: Pane, id: PaneId): Pane =>
|
|
50
|
+
pane.id === id
|
|
51
|
+
? newSplitPane
|
|
52
|
+
: pane.type === 'splitPane'
|
|
53
|
+
? {
|
|
54
|
+
...pane,
|
|
55
|
+
children: pane.children.map((child) =>
|
|
56
|
+
updateSplitPane(child, id),
|
|
57
|
+
),
|
|
58
|
+
}
|
|
59
|
+
: pane;
|
|
60
|
+
|
|
61
|
+
const finalPane = updateSplitPane(
|
|
62
|
+
updatedPane,
|
|
63
|
+
activePaneId,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
...state,
|
|
68
|
+
pane: finalPane,
|
|
69
|
+
activePaneId: newLeafPane1.id,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
@@ -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
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -192,13 +192,36 @@ export type VZCodeContent = {
|
|
|
192
192
|
isInteracting?: boolean;
|
|
193
193
|
};
|
|
194
194
|
// Example Presence object, from ShareDB:
|
|
195
|
-
// {
|
|
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
|
+
// }
|
|
196
210
|
export type Presence = {
|
|
197
211
|
start: Array<string | number>;
|
|
198
212
|
end: Array<string | number>;
|
|
199
213
|
username: Username;
|
|
200
214
|
};
|
|
201
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
|
+
|
|
202
225
|
// An id used for presence.
|
|
203
226
|
export type PresenceId = string;
|
|
204
227
|
|