vzcode 0.66.0 → 0.68.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-J9vPrCBY.js → index-DBoSKqLe.js} +35 -35
- package/dist/assets/index-DOd2vdTJ.css +1 -0
- package/dist/assets/{worker-ajCMsicA.js → worker-DoodSOTA.js} +88 -88
- package/dist/index.html +2 -2
- package/package.json +4 -4
- package/src/client/AIAssist/AIAssistWidget/index.tsx +10 -1
- package/src/client/CodeEditor/style.scss +17 -0
- package/src/client/VZCodeContext.tsx +9 -1
- package/src/client/VZResizer/index.tsx +2 -2
- package/src/client/VZResizer/styles.scss +4 -0
- package/src/client/usePrettier/index.ts +47 -42
- package/dist/assets/index-Bh7FzEWq.css +0 -1
- /package/dist/assets/{worker-lwRU8zh4.js → worker-DJL5sCX4.js} +0 -0
package/dist/index.html
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
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-
|
|
24
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-DBoSKqLe.js"></script>
|
|
24
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DOd2vdTJ.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
27
27
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vzcode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.68.0",
|
|
4
4
|
"description": "Multiplayer code editor system",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -94,14 +94,14 @@
|
|
|
94
94
|
"color-hash": "^2.0.2",
|
|
95
95
|
"d3-array": "^3.2.4",
|
|
96
96
|
"diff-match-patch": "^1.0.5",
|
|
97
|
-
"dotenv": "^16.4.
|
|
97
|
+
"dotenv": "^16.4.4",
|
|
98
98
|
"express": "^4.18.2",
|
|
99
99
|
"ignore": "^5.3.1",
|
|
100
100
|
"json0-ot-diff": "^1.1.2",
|
|
101
101
|
"ngrok": "^4.3.3",
|
|
102
102
|
"open": "^10.0.3",
|
|
103
103
|
"openai": "^4.28.0",
|
|
104
|
-
"prettier-plugin-svelte": "^3.2.
|
|
104
|
+
"prettier-plugin-svelte": "^3.2.1",
|
|
105
105
|
"react": "^18.2.0",
|
|
106
106
|
"react-bootstrap": "^2.10.1",
|
|
107
107
|
"react-dom": "^18.2.0",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"prettier": "^3.2.5",
|
|
120
120
|
"sass": "^1.70.0",
|
|
121
121
|
"typescript": "^5.3.3",
|
|
122
|
-
"vite": "^5.1.
|
|
122
|
+
"vite": "^5.1.3",
|
|
123
123
|
"vitest": "^1.2.2"
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
1
|
+
import { useCallback, useContext, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
FileId,
|
|
4
4
|
ShareDBDoc,
|
|
@@ -15,6 +15,7 @@ import { SparklesSVG, StopSVG } from '../../Icons';
|
|
|
15
15
|
import { startAIAssist } from '../startAIAssist';
|
|
16
16
|
import './style.scss';
|
|
17
17
|
import { Spinner } from '../Spinner';
|
|
18
|
+
import { VZCodeContext } from '../../VZCodeContext';
|
|
18
19
|
|
|
19
20
|
const enableStopGeneration = false;
|
|
20
21
|
|
|
@@ -44,6 +45,8 @@ export const AIAssistWidget = ({
|
|
|
44
45
|
const [aiStreamId, setAiStreamId] =
|
|
45
46
|
useState<RequestId | null>(null);
|
|
46
47
|
|
|
48
|
+
const { runPrettierRef } = useContext(VZCodeContext);
|
|
49
|
+
|
|
47
50
|
const handleClick = useCallback(async () => {
|
|
48
51
|
const isCurrentlyGenerationg = aiStreamId !== null;
|
|
49
52
|
if (isCurrentlyGenerationg) {
|
|
@@ -63,6 +66,12 @@ export const AIAssistWidget = ({
|
|
|
63
66
|
aiAssistOptions,
|
|
64
67
|
});
|
|
65
68
|
|
|
69
|
+
// Trigger a Prettier run after the AI Assist.
|
|
70
|
+
const runPrettier = runPrettierRef.current;
|
|
71
|
+
if (runPrettier !== null) {
|
|
72
|
+
runPrettier();
|
|
73
|
+
}
|
|
74
|
+
|
|
66
75
|
// Handles the case that the user has started,
|
|
67
76
|
// stopped, and started again before the first request
|
|
68
77
|
// has finished, bu comparing the current stream ID
|
|
@@ -24,4 +24,21 @@
|
|
|
24
24
|
.cm-tooltip-lint {
|
|
25
25
|
max-width: 500px;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
/* Style the completion tooltip container */
|
|
29
|
+
.cm-tooltip.cm-tooltip-autocomplete {
|
|
30
|
+
border: 1px solid #888;
|
|
31
|
+
background-color: #1F2022;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Style the individual completion items */
|
|
35
|
+
.cm-tooltip-autocomplete .cm-completionLabel {
|
|
36
|
+
color: #BDC7DC;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Style the selected completion item */
|
|
40
|
+
.cm-tooltip-autocomplete .cm-completionLabel .cm-completion-active {
|
|
41
|
+
background-color: #0077cc;
|
|
42
|
+
color: white;
|
|
43
|
+
}
|
|
27
44
|
}
|
|
@@ -95,6 +95,9 @@ export type VZCodeContextValue = {
|
|
|
95
95
|
handleOpenCreateFileModal: () => void;
|
|
96
96
|
handleCloseCreateFileModal: () => void;
|
|
97
97
|
handleCreateFileClick: (newFileName: string) => void;
|
|
98
|
+
runPrettierRef: React.MutableRefObject<
|
|
99
|
+
null | (() => void)
|
|
100
|
+
>;
|
|
98
101
|
};
|
|
99
102
|
|
|
100
103
|
export const VZCodeProvider = ({
|
|
@@ -108,7 +111,7 @@ export const VZCodeProvider = ({
|
|
|
108
111
|
initialUsername,
|
|
109
112
|
children,
|
|
110
113
|
codeError = null,
|
|
111
|
-
enableManualPretter =
|
|
114
|
+
enableManualPretter = true,
|
|
112
115
|
}: {
|
|
113
116
|
content: VZCodeContent;
|
|
114
117
|
shareDBDoc: ShareDBDoc<VZCodeContent>;
|
|
@@ -127,8 +130,12 @@ export const VZCodeProvider = ({
|
|
|
127
130
|
// Auto-run Pretter after local changes.
|
|
128
131
|
const {
|
|
129
132
|
prettierError,
|
|
133
|
+
runPrettierRef,
|
|
130
134
|
}: {
|
|
131
135
|
prettierError: string | null;
|
|
136
|
+
runPrettierRef: React.MutableRefObject<
|
|
137
|
+
null | (() => void)
|
|
138
|
+
>;
|
|
132
139
|
} = usePrettier({
|
|
133
140
|
shareDBDoc,
|
|
134
141
|
submitOperation,
|
|
@@ -301,6 +308,7 @@ export const VZCodeProvider = ({
|
|
|
301
308
|
handleOpenCreateFileModal,
|
|
302
309
|
handleCloseCreateFileModal,
|
|
303
310
|
handleCreateFileClick,
|
|
311
|
+
runPrettierRef,
|
|
304
312
|
};
|
|
305
313
|
|
|
306
314
|
return (
|
|
@@ -112,14 +112,14 @@ export const VZResizer = ({
|
|
|
112
112
|
className="vz-resizer"
|
|
113
113
|
onMouseDown={onMouseDown}
|
|
114
114
|
style={{
|
|
115
|
-
left,
|
|
115
|
+
left: left + resizerWidth / 2 - 1.5,
|
|
116
116
|
width: resizerWidth,
|
|
117
117
|
}}
|
|
118
118
|
>
|
|
119
119
|
<div
|
|
120
120
|
className="vz-resizer-thumb"
|
|
121
121
|
style={{
|
|
122
|
-
left:
|
|
122
|
+
left: resizerThumbWidth / 2 - 1.5,
|
|
123
123
|
width: resizerThumbWidth,
|
|
124
124
|
}}
|
|
125
125
|
/>
|
|
@@ -58,6 +58,9 @@ export const usePrettier = ({
|
|
|
58
58
|
// when the op is coming from Prettier itself.
|
|
59
59
|
const isApplyingOpRef = useRef(false);
|
|
60
60
|
|
|
61
|
+
// We use a ref to keep track of the runPrettier function.
|
|
62
|
+
const runPrettierRef = useRef(null);
|
|
63
|
+
|
|
61
64
|
useEffect(() => {
|
|
62
65
|
if (!shareDBDoc) {
|
|
63
66
|
return;
|
|
@@ -134,6 +137,7 @@ export const usePrettier = ({
|
|
|
134
137
|
prettierWorker.postMessage(data);
|
|
135
138
|
}
|
|
136
139
|
};
|
|
140
|
+
runPrettierRef.current = runPrettier;
|
|
137
141
|
|
|
138
142
|
let debouncePrettier;
|
|
139
143
|
let debounceTimeout;
|
|
@@ -169,50 +173,51 @@ export const usePrettier = ({
|
|
|
169
173
|
'op batch',
|
|
170
174
|
(op: JSONOp, isLocal: boolean) => {
|
|
171
175
|
// Only act on changes coming from the client
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
// OR changes coming from the AI Assist that we
|
|
177
|
+
// if (isLocal) {
|
|
178
|
+
// If the op is coming from Prettier itself,
|
|
179
|
+
// then do nothing.
|
|
180
|
+
if (isApplyingOpRef.current) {
|
|
181
|
+
// console.log('ignoring op from Prettier');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
179
184
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
// console.log('Op is for file', fileId);
|
|
185
|
+
// Example op that we want to act on:
|
|
186
|
+
// op [
|
|
187
|
+
// "files",
|
|
188
|
+
// "2514857669",
|
|
189
|
+
// "text",
|
|
190
|
+
// {
|
|
191
|
+
// "es": [
|
|
192
|
+
// 18,
|
|
193
|
+
// "d"
|
|
194
|
+
// ]
|
|
195
|
+
// }
|
|
196
|
+
// ]
|
|
197
|
+
|
|
198
|
+
// Check if the path of this op is the text content of a file
|
|
199
|
+
if (
|
|
200
|
+
op &&
|
|
201
|
+
op.length === 4 &&
|
|
202
|
+
op[0] === 'files' &&
|
|
203
|
+
typeof op[1] === 'string' &&
|
|
204
|
+
op[2] === 'text'
|
|
205
|
+
) {
|
|
206
|
+
// Get the file id
|
|
207
|
+
const fileId: FileId = op[1];
|
|
208
|
+
|
|
209
|
+
// Add the file id to the set of dirty files
|
|
210
|
+
dirtyFilesRef.current.add(fileId);
|
|
211
|
+
|
|
212
|
+
// Debounce running Prettier
|
|
213
|
+
if (!enableManualPretter) {
|
|
214
|
+
debouncePrettier();
|
|
212
215
|
}
|
|
213
|
-
|
|
214
|
-
// console.log('ignoring op from remote', op, isLocal);
|
|
216
|
+
// console.log('Op is for file', fileId);
|
|
215
217
|
}
|
|
218
|
+
// } else {
|
|
219
|
+
// // console.log('ignoring op from remote', op, isLocal);
|
|
220
|
+
// }
|
|
216
221
|
},
|
|
217
222
|
);
|
|
218
223
|
|
|
@@ -243,5 +248,5 @@ export const usePrettier = ({
|
|
|
243
248
|
}
|
|
244
249
|
};
|
|
245
250
|
}, [shareDBDoc]);
|
|
246
|
-
return { prettierError }; // Return the errors for use in other files
|
|
251
|
+
return { prettierError, runPrettierRef }; // Return the errors for use in other files
|
|
247
252
|
};
|