vzcode 0.24.0 → 0.26.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 (41) hide show
  1. package/dist/assets/{index-9c8bbae0.js → index-284b7339.js} +50 -50
  2. package/dist/assets/index-e160f758.css +1 -0
  3. package/dist/index.html +2 -6
  4. package/package.json +7 -5
  5. package/src/client/App.tsx +47 -213
  6. package/src/client/CodeEditor/getOrCreateEditor.ts +3 -0
  7. package/src/client/CodeEditor/index.tsx +36 -6
  8. package/src/client/CodeEditor/{json1PresenceBroadcast.js → json1PresenceBroadcast.ts} +5 -3
  9. package/src/client/CodeEditor/{json1PresenceDisplay.js → json1PresenceDisplay.ts} +9 -3
  10. package/src/client/CodeEditor/widgets.ts +112 -10
  11. package/src/client/PresenceNotifications/index.tsx +0 -2
  12. package/src/client/TabList/Tab.tsx +56 -0
  13. package/src/client/TabList/index.tsx +11 -62
  14. package/src/client/TabList/style.scss +21 -9
  15. package/src/client/{Settings.tsx → VZSettings.tsx} +1 -1
  16. package/src/client/{Sidebar → VZSidebar}/FileListing.tsx +3 -0
  17. package/src/client/{Sidebar → VZSidebar}/Item.tsx +10 -7
  18. package/src/client/{Sidebar → VZSidebar}/Listing.tsx +3 -0
  19. package/src/client/{Sidebar → VZSidebar}/index.tsx +5 -6
  20. package/src/client/{Sidebar → VZSidebar}/styles.scss +17 -12
  21. package/src/client/bootstrap.ts +3 -0
  22. package/src/client/style.scss +5 -2
  23. package/src/client/themes/index.ts +7 -0
  24. package/src/client/{themes.ts → themes/themes.ts} +5 -5
  25. package/src/client/{useDynamicTheme.ts → themes/useDynamicTheme.ts} +1 -1
  26. package/src/client/themes/vizhubTheme/colors.ts +80 -0
  27. package/src/client/themes/vizhubTheme/index.ts +166 -0
  28. package/src/client/useActions.ts +74 -0
  29. package/src/client/useFileCRUD.ts +101 -0
  30. package/src/client/useOpenDirectories.ts +25 -7
  31. package/src/client/useSubmitOperation.ts +25 -0
  32. package/src/client/vzReducer.ts +118 -0
  33. package/src/index.ts +34 -0
  34. package/src/server/index.js +13 -2
  35. package/dist/assets/index-cf19de3b.css +0 -1
  36. package/src/client/reducer.ts +0 -122
  37. package/src/client/useTabsState.ts +0 -95
  38. package/src/client/vizhubTheme.js +0 -1
  39. /package/src/client/{Sidebar → VZSidebar}/ConfirmationBox.tsx +0 -0
  40. /package/src/client/{Sidebar → VZSidebar}/DirectoryArrowSVG.jsx +0 -0
  41. /package/src/client/{Sidebar → VZSidebar}/DirectoryListing.tsx +0 -0
@@ -1,122 +0,0 @@
1
- import { FileId } from '../types';
2
-
3
- export const reducer = (state, action) => {
4
- switch (action.type) {
5
- // TODO phase this out
6
- case 'set_tab_list': {
7
- return { ...state, tabList: action.tabList };
8
- }
9
- case 'set_active_fileId': {
10
- return {
11
- ...state,
12
- activeFileId: action.activeFileId,
13
- };
14
- }
15
- case 'open_tab': {
16
- if (!state.tabList.includes(action.fileId)) {
17
- return {
18
- ...state,
19
- activeFileId: action.fileId,
20
- tabList: [...state.tabList, action.fileId],
21
- };
22
- } else {
23
- return {
24
- ...state,
25
- activeFileId: action.fileId,
26
- };
27
- }
28
- }
29
- case 'close_tab': {
30
- const i = state.tabList.findIndex(
31
- (fileId) => fileId === action.fileIdToRemove,
32
- );
33
- if (i != -1) {
34
- const newTabList = [
35
- ...state.tabList.slice(0, i),
36
- ...state.tabList.slice(i + 1),
37
- ];
38
- if (state.activeFileId === action.fileIdToRemove) {
39
- // set the new active file to the next tab over,
40
- if (newTabList.length > 0) {
41
- return {
42
- ...state,
43
- activeFileId:
44
- i === 0 ? newTabList[i] : newTabList[i - 1],
45
- tabList: newTabList,
46
- };
47
- } else {
48
- // or clear out the active file
49
- // if we've closed the last tab.
50
- return {
51
- ...state,
52
- activeFileId: null,
53
- tabList: newTabList,
54
- };
55
- }
56
- }
57
- return {
58
- ...state,
59
- tabList: newTabList,
60
- };
61
- }
62
- return {
63
- ...state,
64
- };
65
- }
66
- case 'multi_close_tab': {
67
- let newTabList = [...state.tabList]; // Create a copy of the tabList array.
68
- let newActiveFileId: FileId = state.activeFileId;
69
- action.idsToDelete.forEach((id) => {
70
- const i = newTabList.findIndex(
71
- (fileId) => fileId === id,
72
- );
73
- if (i !== -1) {
74
- // Remove the tab from the tab list.
75
- newTabList = [
76
- ...newTabList.slice(0, i),
77
- ...newTabList.slice(i + 1),
78
- ];
79
- // If we are closing the active file,
80
- if (newActiveFileId === id) {
81
- // set the new active file to the next tab over,
82
- if (newTabList.length > 0) {
83
- newActiveFileId =
84
- i === 0 ? newTabList[i] : newTabList[i - 1];
85
- } else {
86
- // or clear out the active file if we've closed the last tab.
87
- newActiveFileId = null;
88
- }
89
- }
90
- }
91
- });
92
- return {
93
- ...state,
94
- tabList: newTabList,
95
- activeFileId: newActiveFileId,
96
- };
97
- }
98
- // TODO eventually
99
- // case 'init_sharedb': {
100
- // return {
101
- // ...state,
102
- // submitOperation: action.submitOperation
103
- // }
104
- // }
105
- // case 'delete_file': {
106
- // case 'delete_directory': {
107
- // case 'create_file': {
108
- // state.submitOperation((document) => ({
109
- // ...document,
110
- // files: {
111
- // ...document.files,
112
- // [randomId()]: { name:action.name, text: '' },
113
- // },
114
- // }))
115
- // return state;
116
-
117
- // }
118
- // case 'rename_file': {
119
- // ...
120
- }
121
- throw Error('Unknown action: ' + action.type);
122
- };
@@ -1,95 +0,0 @@
1
- import { useCallback } from 'react';
2
- import { FileId } from '../types';
3
-
4
- // Encapsulates the state and logic for managing the list of open tabs.
5
- export const useTabsState = (
6
- activeFileId: FileId,
7
- setActiveFileId: (fileId: FileId | null) => void,
8
- tabList: Array<FileId>,
9
- setTabList: (tabList: Array<FileId>) => void,
10
- ) => {
11
- // Called when a tab is closed.
12
- const closeTab = useCallback(
13
- (fileIdToRemove: FileId) => {
14
- let newActiveFileId: FileId = activeFileId;
15
- const i = tabList.findIndex(
16
- (fileId) => fileId === fileIdToRemove,
17
- );
18
-
19
- // Support calling `closeTab` on a fileId that is not open,
20
- // such as when a file is deleted..
21
- if (i !== -1) {
22
- // Remove the tab from the tab list.
23
- const newTabList = [
24
- ...tabList.slice(0, i),
25
- ...tabList.slice(i + 1),
26
- ];
27
- setTabList(newTabList);
28
-
29
- // If we are closing the active file,
30
- if (activeFileId === fileIdToRemove) {
31
- // set the new active file to the next tab over,
32
- if (newTabList.length > 0) {
33
- newActiveFileId =
34
- i === 0 ? newTabList[i] : newTabList[i - 1];
35
- } else {
36
- // or clear out the active file
37
- // if we've closed the last tab.
38
- newActiveFileId = null;
39
- }
40
- }
41
- }
42
- setActiveFileId(newActiveFileId);
43
- },
44
- [tabList, activeFileId],
45
- );
46
-
47
- //When closing multiple tabs use this function over CloseTab()
48
- const multiCloseTab = useCallback(
49
- (idsToDelete: Array<FileId>) => {
50
- let newTabList = [...tabList]; // Create a copy of the tabList array.
51
- let newActiveFileId: FileId = activeFileId;
52
- idsToDelete.forEach((id) => {
53
- const i = newTabList.findIndex(
54
- (fileId) => fileId === id,
55
- );
56
- if (i !== -1) {
57
- // Remove the tab from the tab list.
58
- newTabList = [
59
- ...newTabList.slice(0, i),
60
- ...newTabList.slice(i + 1),
61
- ];
62
-
63
- // If we are closing the active file,
64
- if (newActiveFileId === id) {
65
- // set the new active file to the next tab over,
66
- if (newTabList.length > 0) {
67
- newActiveFileId =
68
- i === 0 ? newTabList[i] : newTabList[i - 1];
69
- } else {
70
- // or clear out the active file if we've closed the last tab.
71
- newActiveFileId = null;
72
- }
73
- }
74
- }
75
- });
76
- //Run setStates after doing multiple changes to the two variables. Will properly render tabList and activeFileID.
77
- setActiveFileId(newActiveFileId);
78
- setTabList(newTabList);
79
- },
80
- [tabList, activeFileId],
81
- );
82
-
83
- // Called when a tab is opened.
84
- const openTab = useCallback(
85
- (fileId: FileId) => {
86
- setActiveFileId(fileId);
87
- if (!tabList.includes(fileId)) {
88
- setTabList([...tabList, fileId]);
89
- }
90
- },
91
- [tabList],
92
- );
93
-
94
- return { tabList, closeTab, openTab, multiCloseTab };
95
- };
@@ -1 +0,0 @@
1
- // TODO