vzcode 3.1.0 → 3.3.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 (74) hide show
  1. package/README.md +185 -40
  2. package/dist/assets/App-C9mRI7eH.js +387 -0
  3. package/dist/assets/App-CxiKy3Rs.css +1 -0
  4. package/dist/assets/bindings_wasm_bg-IWNG_AjZ.wasm +0 -0
  5. package/dist/assets/buildWorker-N5tFTOqM.js +794 -0
  6. package/dist/assets/index-COLyIkCc.js +43 -0
  7. package/dist/assets/index-CZT-v4sH.css +1 -0
  8. package/dist/assets/rolldown-runtime-COiEfhsA.js +1 -0
  9. package/dist/assets/worker-BpV7Ustv.js +223 -0
  10. package/dist/assets/worker-CLeezw6h.js +458 -0
  11. package/dist/assets/worker-DaSIYBQX.js +327 -0
  12. package/dist/cli.js +170 -99
  13. package/dist/index.html +3 -2
  14. package/dist/server/accessControl.js +104 -0
  15. package/dist/server/computeInitialDocument.js +4 -1
  16. package/dist/server/createServer.js +356 -104
  17. package/dist/server/index.js +4 -3
  18. package/dist/server/workspaceSecurity.js +115 -0
  19. package/dist/server/workspaceSync.js +141 -0
  20. package/package.json +74 -72
  21. package/src/cli.ts +203 -182
  22. package/src/client/App/index.tsx +2 -0
  23. package/src/client/App/usePending.ts +3 -1
  24. package/src/client/CodeEditor/style.scss +18 -11
  25. package/src/client/RunCodeWidget/index.tsx +1 -0
  26. package/src/client/TabList/Tab.tsx +13 -5
  27. package/src/client/TabList/style.scss +32 -5
  28. package/src/client/VZCodeContext/types.ts +6 -0
  29. package/src/client/VZCodeContext/useVZCodeState.ts +2 -0
  30. package/src/client/VZResizer/styles.scss +1 -1
  31. package/src/client/VZSidebar/AIChatWrapper.tsx +2 -0
  32. package/src/client/VZSidebar/DeleteConfirmationModal.tsx +1 -1
  33. package/src/client/VZSidebar/Item.tsx +8 -4
  34. package/src/client/VZSidebar/VisualEditor/CheckboxWidget.tsx +22 -30
  35. package/src/client/VZSidebar/VisualEditor/ColorWidget.tsx +198 -126
  36. package/src/client/VZSidebar/VisualEditor/DropdownWidget.tsx +25 -67
  37. package/src/client/VZSidebar/VisualEditor/PropertySection.tsx +41 -0
  38. package/src/client/VZSidebar/VisualEditor/SegmentedWidget.tsx +34 -0
  39. package/src/client/VZSidebar/VisualEditor/SliderWidget.tsx +60 -12
  40. package/src/client/VZSidebar/VisualEditor/VisualEditor.tsx +31 -393
  41. package/src/client/VZSidebar/VisualEditor/VisualEditorControls.tsx +478 -0
  42. package/src/client/VZSidebar/VisualEditor/colorUtils.ts +12 -0
  43. package/src/client/VZSidebar/VisualEditor/status.ts +47 -0
  44. package/src/client/VZSidebar/VisualEditor/updateConfig.ts +51 -24
  45. package/src/client/VZSidebar/VisualEditor/utils.ts +1 -1
  46. package/src/client/VZSidebar/index.tsx +55 -23
  47. package/src/client/VZSidebar/styles.scss +426 -6
  48. package/src/client/WorkspaceConflictBanner.tsx +120 -0
  49. package/src/client/index.ts +2 -0
  50. package/src/client/main.jsx +54 -12
  51. package/src/client/ui.scss +156 -4
  52. package/src/client/ui.tsx +1 -1
  53. package/src/llm-streaming-server/README.md +4 -16
  54. package/src/llm-streaming-ui/README.md +41 -2
  55. package/src/llm-streaming-ui/components/ChatInput.tsx +65 -13
  56. package/src/llm-streaming-ui/components/index.tsx +2 -0
  57. package/src/llm-streaming-ui/components/styles.scss +46 -0
  58. package/src/llm-streaming-ui/hooks/useAutoScroll.ts +1 -1
  59. package/src/llm-streaming-ui/index.ts +1 -0
  60. package/src/llm-streaming-ui/props.ts +26 -2
  61. package/src/server/accessControl.ts +151 -0
  62. package/src/server/computeInitialDocument.ts +6 -2
  63. package/src/server/createServer.ts +487 -138
  64. package/src/server/index.ts +4 -5
  65. package/src/server/workspaceSecurity.ts +160 -0
  66. package/src/server/workspaceSync.ts +203 -0
  67. package/src/types.ts +29 -27
  68. package/dist/assets/bindings_wasm_bg-9w8E-TmY.wasm +0 -0
  69. package/dist/assets/buildWorker-BZlya278.js +0 -687
  70. package/dist/assets/index-5qf102c2.css +0 -1
  71. package/dist/assets/index-dSJDl5x9.js +0 -356
  72. package/dist/assets/worker-1oQYaz-F.js +0 -342
  73. package/dist/assets/worker-BfgPD8zR.js +0 -125
  74. package/dist/assets/worker-CoJaqtpi.js +0 -436
@@ -197,12 +197,14 @@ export const Item = ({
197
197
  </Tooltip>
198
198
  }
199
199
  >
200
- <i
200
+ <button
201
+ type="button"
202
+ aria-label={renameFileTooltipText}
201
203
  onClick={handleRenameIconClick}
202
204
  className="vz-icon-button"
203
205
  >
204
206
  <EditSVG />
205
- </i>
207
+ </button>
206
208
  </OverlayTrigger>
207
209
  ) : null}
208
210
  <OverlayTrigger
@@ -213,12 +215,14 @@ export const Item = ({
213
215
  </Tooltip>
214
216
  }
215
217
  >
216
- <i
218
+ <button
219
+ type="button"
220
+ aria-label={deleteFileTooltipText}
217
221
  onClick={handleModalOpen}
218
222
  className="vz-icon-button"
219
223
  >
220
224
  <TrashSVG />
221
- </i>
225
+ </button>
222
226
  </OverlayTrigger>
223
227
  </div>
224
228
  ) : null}
@@ -11,36 +11,28 @@ interface CheckboxWidgetProps {
11
11
 
12
12
  export const CheckboxWidget: React.FC<
13
13
  CheckboxWidgetProps
14
- > = ({ property, label, currentValue, onChange }) => {
15
- return (
16
- <div className="visual-editor-checkbox">
17
- <div className="checkbox-header">
18
- <label
19
- htmlFor={property}
20
- className="checkbox-label"
21
- >
22
- {label}
23
- </label>
24
- <span className="checkbox-value">
25
- {currentValue ? 'On' : 'Off'}
26
- </span>
27
- </div>
28
- <div className="checkbox-container">
29
- <input
30
- type="checkbox"
31
- id={property}
32
- className="checkbox-input"
33
- checked={currentValue}
34
- onChange={onChange}
14
+ > = ({ property, label, currentValue, onChange }) => (
15
+ <div className="visual-editor-checkbox">
16
+ <div className="checkbox-header">
17
+ <label htmlFor={property} className="checkbox-label">
18
+ {label}
19
+ </label>
20
+ </div>
21
+ <div className="checkbox-container">
22
+ <input
23
+ type="checkbox"
24
+ id={property}
25
+ className="checkbox-input"
26
+ role="switch"
27
+ aria-checked={currentValue}
28
+ checked={currentValue}
29
+ onChange={onChange}
30
+ />
31
+ <div className="checkbox-visual" aria-hidden="true">
32
+ <div
33
+ className={`checkbox-indicator ${currentValue ? 'checked' : ''}`}
35
34
  />
36
- <div className="checkbox-visual">
37
- <div
38
- className={`checkbox-indicator ${
39
- currentValue ? 'checked' : ''
40
- }`}
41
- />
42
- </div>
43
35
  </div>
44
36
  </div>
45
- );
46
- };
37
+ </div>
38
+ );
@@ -1,5 +1,17 @@
1
- import React, { useRef, useEffect } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { renderSliderBackground } from './utils';
3
+ import { normalizeOpaqueColorToHex } from './colorUtils';
4
+
5
+ const PRESETS = [
6
+ '#6366f1',
7
+ '#0891b2',
8
+ '#16a34a',
9
+ '#e11d48',
10
+ '#f59e0b',
11
+ '#111827',
12
+ '#ffffff',
13
+ '#000000',
14
+ ];
3
15
 
4
16
  interface ColorWidgetProps {
5
17
  property: string;
@@ -12,6 +24,7 @@ interface ColorWidgetProps {
12
24
  property: string,
13
25
  lchComponent: 'l' | 'c' | 'h',
14
26
  ) => (event: React.ChangeEvent<HTMLInputElement>) => void;
27
+ onHexChange: (property: string, hex: string) => void;
15
28
  }
16
29
 
17
30
  export const ColorWidget: React.FC<ColorWidgetProps> = ({
@@ -22,152 +35,211 @@ export const ColorWidget: React.FC<ColorWidgetProps> = ({
22
35
  currentC,
23
36
  currentL,
24
37
  onColorChange,
38
+ onHexChange,
25
39
  }) => {
26
- // Refs for canvas elements (for color slider backgrounds)
27
- const canvasRefs = useRef<{
28
- [key: string]: HTMLCanvasElement | null;
29
- }>({});
40
+ const [open, setOpen] = useState(false);
41
+ const [advanced, setAdvanced] = useState(false);
42
+ const [draft, setDraft] = useState(currentHex);
43
+ const root = useRef<HTMLDivElement>(null);
44
+ const canvasRefs = useRef<
45
+ Record<string, HTMLCanvasElement | null>
46
+ >({});
47
+
48
+ const normalizedHex =
49
+ normalizeOpaqueColorToHex(currentHex) ?? '#000000';
50
+
51
+ useEffect(() => {
52
+ setDraft(currentHex);
53
+ }, [currentHex]);
54
+ useEffect(() => {
55
+ if (!open) return;
56
+ const onPointerDown = (event: PointerEvent) => {
57
+ if (!root.current?.contains(event.target as Node))
58
+ setOpen(false);
59
+ };
60
+ const onKeyDown = (event: KeyboardEvent) => {
61
+ if (event.key === 'Escape') setOpen(false);
62
+ };
63
+ document.addEventListener('pointerdown', onPointerDown);
64
+ document.addEventListener('keydown', onKeyDown);
65
+ return () => {
66
+ document.removeEventListener(
67
+ 'pointerdown',
68
+ onPointerDown,
69
+ );
70
+ document.removeEventListener('keydown', onKeyDown);
71
+ };
72
+ }, [open]);
30
73
 
31
- // Update color slider backgrounds when values change
32
74
  useEffect(() => {
33
- const values = {
75
+ if (!open || !advanced) return;
76
+ const channels = {
34
77
  h: currentH,
35
78
  c: currentC,
36
79
  l: currentL,
37
80
  };
81
+ for (const component of ['h', 'c', 'l'] as const) {
82
+ renderSliderBackground(
83
+ canvasRefs.current[component],
84
+ component,
85
+ channels,
86
+ );
87
+ }
88
+ }, [open, advanced, currentH, currentC, currentL]);
38
89
 
39
- // Render backgrounds for each slider
40
- renderSliderBackground(
41
- canvasRefs.current[`${property}_l_bg`],
42
- 'l',
43
- values,
44
- );
45
- renderSliderBackground(
46
- canvasRefs.current[`${property}_c_bg`],
47
- 'c',
48
- values,
49
- );
50
- renderSliderBackground(
51
- canvasRefs.current[`${property}_h_bg`],
52
- 'h',
53
- values,
54
- );
55
- }, [property, currentH, currentC, currentL]);
90
+ const commitDraft = () => {
91
+ const next = normalizeOpaqueColorToHex(draft);
92
+ if (next) onHexChange(property, next);
93
+ else setDraft(currentHex);
94
+ };
56
95
 
57
96
  return (
58
- <div className="visual-editor-color">
97
+ <div className="visual-editor-color" ref={root}>
59
98
  <div className="color-header">
60
99
  <label className="color-label">{label}</label>
61
- <span className="color-value">{currentHex}</span>
100
+ <button
101
+ type="button"
102
+ className="color-picker-trigger"
103
+ aria-label={`Choose ${label} color`}
104
+ aria-expanded={open}
105
+ onClick={() => setOpen((value) => !value)}
106
+ >
107
+ <span
108
+ className="color-picker-swatch"
109
+ style={{ backgroundColor: normalizedHex }}
110
+ />
111
+ <span className="color-picker-hex">
112
+ {normalizedHex.toUpperCase()}
113
+ </span>
114
+ <span aria-hidden="true">▾</span>
115
+ </button>
62
116
  </div>
63
-
64
- <div
65
- className="color-preview"
66
- style={{ backgroundColor: currentHex }}
67
- />
68
-
69
- <div className="lch-sliders">
70
- {/* Lightness Slider */}
71
- <div className="lch-slider">
72
- <div className="slider-header">
73
- <label className="slider-label">
74
- Lightness
75
- </label>
76
- <span className="slider-value">
77
- {Math.round(currentL)}
78
- </span>
79
- </div>
80
- <div className="slider-container">
81
- <canvas
82
- ref={(canvas) => {
83
- canvasRefs.current[`${property}_l_bg`] =
84
- canvas;
85
- }}
86
- className="slider-bg-canvas"
87
- width={200}
88
- />
117
+ {open && (
118
+ <div
119
+ className="color-picker-popover"
120
+ role="group"
121
+ aria-label={`${label} color picker`}
122
+ >
123
+ <label className="color-picker-field">
124
+ <span>Pick a color</span>
89
125
  <input
90
- type="range"
91
- className="slider-input"
92
- min={0}
93
- max={100}
94
- step={1}
95
- value={currentL}
96
- onChange={onColorChange(property, 'l')}
97
- />
98
- </div>
99
- <div className="slider-bounds">
100
- <span className="min-value">0</span>
101
- <span className="max-value">100</span>
102
- </div>
103
- </div>
104
-
105
- {/* Chroma Slider */}
106
- <div className="lch-slider">
107
- <div className="slider-header">
108
- <label className="slider-label">Chroma</label>
109
- <span className="slider-value">
110
- {Math.round(currentC)}
111
- </span>
112
- </div>
113
- <div className="slider-container">
114
- <canvas
115
- ref={(canvas) => {
116
- canvasRefs.current[`${property}_c_bg`] =
117
- canvas;
118
- }}
119
- className="slider-bg-canvas"
120
- width={200}
126
+ type="color"
127
+ className="color-picker-native"
128
+ value={normalizedHex}
129
+ onChange={(event) =>
130
+ onHexChange(
131
+ property,
132
+ event.currentTarget.value,
133
+ )
134
+ }
121
135
  />
136
+ </label>
137
+ <label className="color-picker-field">
138
+ <span>HEX / CSS color</span>
122
139
  <input
123
- type="range"
124
- className="slider-input"
125
- min={0}
126
- max={100}
127
- step={1}
128
- value={currentC}
129
- onChange={onColorChange(property, 'c')}
130
- />
131
- </div>
132
- <div className="slider-bounds">
133
- <span className="min-value">0</span>
134
- <span className="max-value">100</span>
135
- </div>
136
- </div>
137
-
138
- {/* Hue Slider */}
139
- <div className="lch-slider">
140
- <div className="slider-header">
141
- <label className="slider-label">Hue</label>
142
- <span className="slider-value">
143
- {Math.round(currentH)}°
144
- </span>
145
- </div>
146
- <div className="slider-container">
147
- <canvas
148
- ref={(canvas) => {
149
- canvasRefs.current[`${property}_h_bg`] =
150
- canvas;
140
+ className="color-picker-hex-input"
141
+ type="text"
142
+ spellCheck={false}
143
+ value={draft}
144
+ onChange={(event) =>
145
+ setDraft(event.currentTarget.value)
146
+ }
147
+ onBlur={commitDraft}
148
+ onKeyDown={(event) => {
149
+ if (event.key === 'Enter') {
150
+ commitDraft();
151
+ event.currentTarget.blur();
152
+ } else if (event.key === 'Escape') {
153
+ setDraft(currentHex);
154
+ }
151
155
  }}
152
- className="slider-bg-canvas"
153
- width={200}
154
- />
155
- <input
156
- type="range"
157
- className="slider-input"
158
- min={0}
159
- max={360}
160
- step={1}
161
- value={currentH}
162
- onChange={onColorChange(property, 'h')}
156
+ aria-label={`${label} hexadecimal color`}
163
157
  />
158
+ </label>
159
+ <div className="color-picker-preset-label">
160
+ Presets
164
161
  </div>
165
- <div className="slider-bounds">
166
- <span className="min-value">0°</span>
167
- <span className="max-value">360°</span>
162
+ <div className="color-picker-presets">
163
+ {PRESETS.map((preset) => (
164
+ <button
165
+ key={preset}
166
+ type="button"
167
+ className="color-picker-preset"
168
+ style={{ backgroundColor: preset }}
169
+ aria-label={`Use color ${preset}`}
170
+ aria-pressed={preset === normalizedHex}
171
+ onClick={() =>
172
+ onHexChange(property, preset)
173
+ }
174
+ />
175
+ ))}
168
176
  </div>
177
+ <button
178
+ type="button"
179
+ className="color-picker-advanced-toggle"
180
+ aria-expanded={advanced}
181
+ onClick={() => setAdvanced((value) => !value)}
182
+ >
183
+ Advanced HCL controls {advanced ? '▴' : '▾'}
184
+ </button>
185
+ {advanced && (
186
+ <div className="lch-sliders">
187
+ {(
188
+ [
189
+ ['l', 'Lightness', currentL, 100, ''],
190
+ ['c', 'Chroma', currentC, 100, ''],
191
+ ['h', 'Hue', currentH, 360, '°'],
192
+ ] as const
193
+ ).map(
194
+ ([component, name, value, max, suffix]) => (
195
+ <div
196
+ key={component}
197
+ className="lch-slider"
198
+ >
199
+ <div className="slider-header">
200
+ <label
201
+ className="slider-label"
202
+ htmlFor={`${property}-${component}`}
203
+ >
204
+ {name}
205
+ </label>
206
+ <span className="slider-value">
207
+ {Math.round(value)}
208
+ {suffix}
209
+ </span>
210
+ </div>
211
+ <div className="slider-container">
212
+ <canvas
213
+ ref={(canvas) => {
214
+ canvasRefs.current[component] =
215
+ canvas;
216
+ }}
217
+ className="slider-bg-canvas"
218
+ width={200}
219
+ height={12}
220
+ aria-hidden="true"
221
+ />
222
+ <input
223
+ id={`${property}-${component}`}
224
+ type="range"
225
+ className="slider-input"
226
+ min={0}
227
+ max={max}
228
+ step={1}
229
+ value={value}
230
+ onChange={onColorChange(
231
+ property,
232
+ component,
233
+ )}
234
+ />
235
+ </div>
236
+ </div>
237
+ ),
238
+ )}
239
+ </div>
240
+ )}
169
241
  </div>
170
- </div>
242
+ )}
171
243
  </div>
172
244
  );
173
245
  };
@@ -5,11 +5,10 @@ interface DropdownWidgetProps {
5
5
  label: string;
6
6
  options: string[];
7
7
  currentValue: string;
8
- isOpen: boolean;
9
- onToggle: () => void;
10
- onOptionClick: (value: string) => void;
8
+ onChange: (value: string) => void;
11
9
  }
12
10
 
11
+ /** Native select preserves keyboard, touch, type-ahead and screen-reader behavior. */
13
12
  export const DropdownWidget: React.FC<
14
13
  DropdownWidgetProps
15
14
  > = ({
@@ -17,68 +16,27 @@ export const DropdownWidget: React.FC<
17
16
  label,
18
17
  options,
19
18
  currentValue,
20
- isOpen,
21
- onToggle,
22
- onOptionClick,
23
- }) => {
24
- return (
25
- <div className="visual-editor-dropdown">
26
- <div className="dropdown-header">
27
- <label
28
- htmlFor={property}
29
- className="dropdown-label"
30
- >
31
- {label}
32
- </label>
33
- </div>
34
- <div className="dropdown-container">
35
- <button
36
- type="button"
37
- className={`dropdown-button ${isOpen ? 'open' : ''}`}
38
- onClick={onToggle}
39
- aria-expanded={isOpen}
40
- aria-haspopup="listbox"
41
- >
42
- <span className="dropdown-button-text">
43
- {currentValue}
44
- </span>
45
- <div
46
- className={`dropdown-arrow ${isOpen ? 'open' : ''}`}
47
- >
48
- <svg
49
- width="12"
50
- height="8"
51
- viewBox="0 0 12 8"
52
- fill="none"
53
- xmlns="http://www.w3.org/2000/svg"
54
- >
55
- <path
56
- d="M1 1.5L6 6.5L11 1.5"
57
- stroke="currentColor"
58
- strokeWidth="2"
59
- strokeLinecap="round"
60
- strokeLinejoin="round"
61
- />
62
- </svg>
63
- </div>
64
- </button>
65
- {isOpen && (
66
- <div className="dropdown-options">
67
- {options.map((option) => (
68
- <button
69
- key={option}
70
- type="button"
71
- className={`dropdown-option ${
72
- option === currentValue ? 'selected' : ''
73
- }`}
74
- onClick={() => onOptionClick(option)}
75
- >
76
- {option}
77
- </button>
78
- ))}
79
- </div>
80
- )}
81
- </div>
19
+ onChange,
20
+ }) => (
21
+ <div className="visual-editor-dropdown">
22
+ <div className="dropdown-header">
23
+ <label htmlFor={property} className="dropdown-label">
24
+ {label}
25
+ </label>
82
26
  </div>
83
- );
84
- };
27
+ <select
28
+ id={property}
29
+ className="visual-properties-select"
30
+ value={currentValue}
31
+ onChange={(event) =>
32
+ onChange(event.currentTarget.value)
33
+ }
34
+ >
35
+ {options.map((option) => (
36
+ <option key={option} value={option}>
37
+ {option}
38
+ </option>
39
+ ))}
40
+ </select>
41
+ </div>
42
+ );
@@ -0,0 +1,41 @@
1
+ import { useId, useState, type ReactNode } from 'react';
2
+
3
+ export const PropertySection = ({
4
+ title,
5
+ children,
6
+ initiallyOpen = true,
7
+ }: {
8
+ title: string;
9
+ children: ReactNode;
10
+ initiallyOpen?: boolean;
11
+ }) => {
12
+ const [isOpen, setIsOpen] = useState(initiallyOpen);
13
+ const id = useId();
14
+
15
+ return (
16
+ <section className="visual-properties-section">
17
+ <button
18
+ type="button"
19
+ className="visual-properties-section-toggle"
20
+ aria-expanded={isOpen}
21
+ aria-controls={id}
22
+ onClick={() => setIsOpen((open) => !open)}
23
+ >
24
+ <span>{title}</span>
25
+ <span
26
+ aria-hidden="true"
27
+ className={`visual-properties-chevron ${isOpen ? '' : 'collapsed'}`}
28
+ >
29
+ ▾
30
+ </span>
31
+ </button>
32
+ <div
33
+ id={id}
34
+ className="visual-properties-section-body"
35
+ hidden={!isOpen}
36
+ >
37
+ {isOpen && children}
38
+ </div>
39
+ </section>
40
+ );
41
+ };
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+
3
+ interface SegmentedWidgetProps {
4
+ label: string;
5
+ options: string[];
6
+ currentValue: string;
7
+ onChange: (value: string) => void;
8
+ }
9
+
10
+ /** Small discrete sets are faster to scan as a compact row than a menu. */
11
+ export const SegmentedWidget: React.FC<
12
+ SegmentedWidgetProps
13
+ > = ({ label, options, currentValue, onChange }) => (
14
+ <div className="visual-editor-segmented">
15
+ <div className="segmented-label">{label}</div>
16
+ <div
17
+ className="segmented-options"
18
+ role="group"
19
+ aria-label={label}
20
+ >
21
+ {options.map((option) => (
22
+ <button
23
+ key={option}
24
+ type="button"
25
+ className="segmented-option"
26
+ aria-pressed={currentValue === option}
27
+ onClick={() => onChange(option)}
28
+ >
29
+ {option}
30
+ </button>
31
+ ))}
32
+ </div>
33
+ </div>
34
+ );