@1agh/maude 1.8.1 → 1.9.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 (73) hide show
  1. package/apps/studio/acp/bridge.ts +14 -2
  2. package/apps/studio/acp/probe.ts +51 -1
  3. package/apps/studio/api.ts +19 -4
  4. package/apps/studio/bin/_curl-local.mjs +7 -0
  5. package/apps/studio/bin/annotate.mjs +16 -7
  6. package/apps/studio/bin/read-annotations.mjs +62 -4
  7. package/apps/studio/client/app.jsx +428 -15977
  8. package/apps/studio/client/dialogs/asset-picker.jsx +331 -0
  9. package/apps/studio/client/dialogs/command-palette.jsx +112 -0
  10. package/apps/studio/client/dialogs/export-dialog.jsx +782 -0
  11. package/apps/studio/client/dialogs/help-modal.jsx +324 -0
  12. package/apps/studio/client/dialogs/shortcuts-overlay.jsx +144 -0
  13. package/apps/studio/client/hooks/use-canvas-bridge.jsx +2150 -0
  14. package/apps/studio/client/hooks/use-git-actions.jsx +236 -0
  15. package/apps/studio/client/hooks/use-keyboard-shortcuts.jsx +297 -0
  16. package/apps/studio/client/hooks/use-palette-and-panels.jsx +474 -0
  17. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +901 -0
  18. package/apps/studio/client/hooks/use-project-data.jsx +90 -0
  19. package/apps/studio/client/hooks/use-shell-core.jsx +1212 -0
  20. package/apps/studio/client/hooks/use-tabs.jsx +723 -0
  21. package/apps/studio/client/hooks/use-web-socket.jsx +13 -0
  22. package/apps/studio/client/inspector/artboard-knobs.jsx +456 -0
  23. package/apps/studio/client/inspector/color-picker.jsx +196 -0
  24. package/apps/studio/client/inspector/color.js +92 -0
  25. package/apps/studio/client/inspector/css-knobs.jsx +1720 -0
  26. package/apps/studio/client/inspector/css-vocab.jsx +131 -0
  27. package/apps/studio/client/inspector/ds-tokens.js +90 -0
  28. package/apps/studio/client/inspector/grid-tracks-editor.jsx +97 -0
  29. package/apps/studio/client/inspector/inspect-computed.jsx +68 -0
  30. package/apps/studio/client/inspector/inspector-panel.jsx +769 -0
  31. package/apps/studio/client/inspector/layers.jsx +322 -0
  32. package/apps/studio/client/inspector/selection.js +65 -0
  33. package/apps/studio/client/inspector/token-popover.jsx +301 -0
  34. package/apps/studio/client/menus/menubar.jsx +856 -0
  35. package/apps/studio/client/selection-scope.js +40 -0
  36. package/apps/studio/client/shell/banners.jsx +272 -0
  37. package/apps/studio/client/shell/collapsed-rail.jsx +23 -0
  38. package/apps/studio/client/shell/comments-panel.jsx +177 -0
  39. package/apps/studio/client/shell/constants.js +60 -0
  40. package/apps/studio/client/shell/dock.jsx +131 -0
  41. package/apps/studio/client/shell/icons.jsx +370 -0
  42. package/apps/studio/client/shell/status-bar.jsx +215 -0
  43. package/apps/studio/client/shell/util.js +332 -0
  44. package/apps/studio/client/shell/viewport.jsx +254 -0
  45. package/apps/studio/client/system/system-view.jsx +255 -0
  46. package/apps/studio/client/tree/tree.jsx +1243 -0
  47. package/apps/studio/comments-overlay.tsx +6 -4
  48. package/apps/studio/config.schema.json +5 -0
  49. package/apps/studio/context.ts +13 -0
  50. package/apps/studio/dist/client.bundle.js +1337 -1337
  51. package/apps/studio/dist/comment-mount.js +2 -2
  52. package/apps/studio/exporters/_browser-bundles.ts +21 -2
  53. package/apps/studio/exporters/jobs.ts +75 -15
  54. package/apps/studio/exporters/scope.ts +15 -12
  55. package/apps/studio/format.ts +296 -0
  56. package/apps/studio/http.ts +213 -23
  57. package/apps/studio/server.ts +118 -29
  58. package/apps/studio/sync/accepted-link.ts +6 -0
  59. package/apps/studio/sync/agent.ts +9 -1
  60. package/apps/studio/sync/cold-start-apply.ts +29 -4
  61. package/apps/studio/sync/cold-start.ts +78 -0
  62. package/apps/studio/sync/file-plane.ts +61 -1
  63. package/apps/studio/sync/format-sync.ts +160 -0
  64. package/apps/studio/sync/index.ts +134 -10
  65. package/apps/studio/sync/journal-client.ts +25 -5
  66. package/apps/studio/sync/migrate-seed.ts +8 -1
  67. package/apps/studio/sync/status.ts +2 -0
  68. package/apps/studio/sync/transaction-client.ts +130 -13
  69. package/apps/studio/ui-prefs.ts +95 -10
  70. package/apps/studio/whats-new.json +9 -0
  71. package/apps/studio/ws.ts +19 -4
  72. package/cli/bin/claude-design-server.mjs +0 -0
  73. package/package.json +10 -8
@@ -0,0 +1,331 @@
1
+ // dialogs/asset-picker.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { uploadAsset } from '../../asset-upload.ts';
5
+ import { isNativeApp, pickMediaFile, pickMediaFiles, pickedMediaSource } from '../github.js';
6
+ import { StIcon } from '../shell/icons.jsx';
7
+
8
+ // feature-bulk-media-insert — best-effort MIME guess from a filename extension.
9
+ // Only used to classify a natively-picked file (Rust returns `{name, bytes}`,
10
+ // no type) for the destination-toggle's image/video/audio split; the actual
11
+ // upload is always magic-byte-sniffed server-side, so a wrong guess here
12
+ // can't misrepresent what gets stored, only which picker UI state it shows.
13
+ export const EXT_MIME = {
14
+ png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif',
15
+ webp: 'image/webp', avif: 'image/avif', svg: 'image/svg+xml',
16
+ mp4: 'video/mp4', mov: 'video/quicktime', webm: 'video/webm', m4v: 'video/mp4', ogg: 'video/ogg',
17
+ mp3: 'audio/mpeg', wav: 'audio/wav', m4a: 'audio/mp4', aac: 'audio/aac',
18
+ flac: 'audio/flac', oga: 'audio/ogg', opus: 'audio/opus',
19
+ };
20
+
21
+ export function mimeFromExt(name) {
22
+ const ext = String(name || '').split('.').pop()?.toLowerCase();
23
+ return EXT_MIME[ext] || 'application/octet-stream';
24
+ }
25
+
26
+ // feature-element-editing-robustness Stage F1 — AssetPicker. A shell modal that
27
+ // lists the versioned content-addressed media under <designRoot>/assets/ (via the
28
+ // main-origin-only GET /_api/assets) and lets the user pick one — or upload a new
29
+ // file (POST /_api/asset, content-addressed) — for a media Replace / image
30
+ // Insert. Thumbnails load from the main origin's designRoot static serve
31
+ // (/${designRel}/${asset.path}); never a remote hotlink (the CSP split origin
32
+ // blocks those — memory reference_canvas_images_download_first).
33
+ export function AssetPicker({
34
+ designRel,
35
+ onPick,
36
+ onClose,
37
+ multiple = false,
38
+ hasArtboardAnchor = false,
39
+ onPickMany,
40
+ }) {
41
+ const [assets, setAssets] = useState(null);
42
+ const [busy, setBusy] = useState(false);
43
+ const [progress, setProgress] = useState(null);
44
+ const [err, setErr] = useState(null);
45
+ // feature-bulk-media-insert — multi-select state. `kindByPath` merges the
46
+ // fetched listing with freshly uploaded assets (the upload response carries
47
+ // no `kind`, so a just-uploaded file's kind comes from its own File.type).
48
+ const [selected, setSelected] = useState(() => new Set());
49
+ const [kindByPath, setKindByPath] = useState({});
50
+ const [destination, setDestination] = useState(hasArtboardAnchor ? 'artboard' : 'annotation');
51
+
52
+ useEffect(() => {
53
+ let alive = true;
54
+ fetch('/_api/assets')
55
+ .then((r) => r.json())
56
+ .then((j) => {
57
+ if (!alive) return;
58
+ const list = j.ok ? j.assets : [];
59
+ setAssets(list);
60
+ setKindByPath((prev) => {
61
+ const next = { ...prev };
62
+ for (const a of list) next[a.path] = a.kind;
63
+ return next;
64
+ });
65
+ })
66
+ .catch(() => alive && setAssets([]));
67
+ return () => {
68
+ alive = false;
69
+ };
70
+ }, []);
71
+
72
+ useEffect(() => {
73
+ const onKey = (e) => {
74
+ if (e.key === 'Escape') {
75
+ e.stopPropagation();
76
+ onClose();
77
+ }
78
+ };
79
+ window.addEventListener('keydown', onKey, true);
80
+ return () => window.removeEventListener('keydown', onKey, true);
81
+ }, [onClose]);
82
+
83
+ const hasNonImageSelected = Array.from(selected).some((p) => (kindByPath[p] || 'image') !== 'image');
84
+ const artboardDisabled = !hasArtboardAnchor || hasNonImageSelected;
85
+ const artboardDisabledReason = !hasArtboardAnchor
86
+ ? 'No artboard on this canvas'
87
+ : hasNonImageSelected
88
+ ? 'Video/audio can only be added as annotations'
89
+ : '';
90
+ // Force off "Add to artboard" the moment it becomes unavailable (e.g. a
91
+ // video gets added to an until-now all-image selection).
92
+ useEffect(() => {
93
+ if (artboardDisabled && destination === 'artboard') setDestination('annotation');
94
+ }, [artboardDisabled, destination]);
95
+
96
+ const toggleSelected = (path) => {
97
+ setSelected((prev) => {
98
+ const next = new Set(prev);
99
+ if (next.has(path)) next.delete(path);
100
+ else next.add(path);
101
+ return next;
102
+ });
103
+ };
104
+
105
+ // Shared upload core — both the single-pick `doUpload` and the multi-file
106
+ // `doUploadMany` post through here, so neither duplicates the request shape.
107
+ // The shared client chunks a large clip (issue #126) — the same path the
108
+ // canvas drop takes, so the picker isn't left at the one-shot cap.
109
+ const uploadOne = async (f) => {
110
+ const res = await uploadAsset(f, { onProgress: setProgress });
111
+ setProgress(null);
112
+ return 'path' in res ? { ok: true, path: res.path } : { ok: false, error: res.error };
113
+ };
114
+
115
+ const doUpload = async (f) => {
116
+ if (!f) return;
117
+ setBusy(true);
118
+ setErr(null);
119
+ const res = await uploadOne(f);
120
+ setBusy(false);
121
+ if (res.ok) onPick(res.path);
122
+ else setErr(res.error);
123
+ };
124
+
125
+ const kindOfMime = (mime) => {
126
+ if (typeof mime === 'string' && mime.startsWith('video/')) return 'video';
127
+ if (typeof mime === 'string' && mime.startsWith('audio/')) return 'audio';
128
+ return 'image';
129
+ };
130
+
131
+ // Multi-file upload — each file uploads independently/concurrently (the
132
+ // route is idempotent + content-addressed, so no ordering concern); every
133
+ // one that succeeds joins the selection as it resolves.
134
+ const doUploadMany = async (files) => {
135
+ if (!files.length) return;
136
+ setBusy(true);
137
+ setErr(null);
138
+ const results = await Promise.all(
139
+ files.map((f) => uploadOne(f).then((r) => ({ ...r, file: f })))
140
+ );
141
+ setBusy(false);
142
+ const ok = results.filter((r) => r.ok);
143
+ const failed = results.length - ok.length;
144
+ if (failed > 0) setErr(`${failed} of ${results.length} uploads failed`);
145
+ if (ok.length) {
146
+ setKindByPath((prev) => {
147
+ const next = { ...prev };
148
+ for (const r of ok) next[r.path] = kindOfMime(r.file.type);
149
+ return next;
150
+ });
151
+ setSelected((prev) => {
152
+ const next = new Set(prev);
153
+ for (const r of ok) next.add(r.path);
154
+ return next;
155
+ });
156
+ }
157
+ };
158
+
159
+ // Native desktop (Tauri WKWebView) — an HTML <input type=file> won't present
160
+ // the file panel AT ALL here, so route through the same native-dialog spine
161
+ // export uses (dogfood: "pri exportu to uz umime"). The Rust pick_media_file
162
+ // command opens an OS open-dialog + reads the bytes; we POST them to
163
+ // /_api/asset (magic-byte sniffed, so name/ext aren't trusted).
164
+ const openFilePickerNative = async () => {
165
+ setBusy(true);
166
+ setErr(null);
167
+ try {
168
+ // The picker hands back tokens, not bytes; each source reads its file in
169
+ // slices as the upload needs them (issue #126 — a 500 MB clip must not
170
+ // cross IPC whole). The server sniffs the bytes, so the ext-derived type
171
+ // only routes small images to the one-shot path.
172
+ if (multiple) {
173
+ const picked = await pickMediaFiles();
174
+ const sources = (picked || []).map((p) => pickedMediaSource(p, mimeFromExt(p.name)));
175
+ setBusy(false);
176
+ try {
177
+ if (sources.length) await doUploadMany(sources);
178
+ } finally {
179
+ for (const src of sources) src.release();
180
+ }
181
+ return;
182
+ }
183
+ const picked = await pickMediaFile();
184
+ if (picked) {
185
+ // (doUpload sets its own busy=false.)
186
+ const src = pickedMediaSource(picked, mimeFromExt(picked.name));
187
+ try {
188
+ await doUpload(src);
189
+ } finally {
190
+ src.release();
191
+ }
192
+ return;
193
+ }
194
+ } catch (e) {
195
+ setErr(e?.message || 'open failed');
196
+ }
197
+ setBusy(false); // only reached on cancel / error (doUpload/doUploadMany own the success path)
198
+ };
199
+
200
+ // Browser — imperative <input>, mirrors the proven replaceMediaViaPicker
201
+ // pattern (freshly created, appended to document.body, clicked synchronously in
202
+ // the gesture). Off-screen (not display:none) so it lays out.
203
+ const openFilePicker = () => {
204
+ if (isNativeApp()) {
205
+ openFilePickerNative();
206
+ return;
207
+ }
208
+ const input = document.createElement('input');
209
+ input.type = 'file';
210
+ input.accept = 'image/*,video/*';
211
+ if (multiple) input.multiple = true;
212
+ input.style.cssText =
213
+ 'position:fixed;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none';
214
+ document.body.appendChild(input);
215
+ const cleanup = () => {
216
+ if (input.isConnected) input.remove();
217
+ };
218
+ window.addEventListener('focus', () => setTimeout(cleanup, 300), { once: true });
219
+ input.addEventListener('change', () => {
220
+ const files = input.files ? Array.from(input.files) : [];
221
+ cleanup();
222
+ if (!files.length) return;
223
+ if (multiple) doUploadMany(files);
224
+ else doUpload(files[0]);
225
+ });
226
+ input.click();
227
+ };
228
+
229
+ const assetUrl = (p) => `/${designRel}/${p}`;
230
+
231
+ return (
232
+ <div
233
+ className="st-scrim"
234
+ role="presentation"
235
+ onMouseDown={(e) => {
236
+ if (e.target === e.currentTarget) onClose();
237
+ }}
238
+ >
239
+ <div className="st-dialog st-asset-picker" role="dialog" aria-modal="true" aria-label="Choose media">
240
+ <div className="st-dialog-hd">
241
+ <span className="st-dialog-title">Choose media</span>
242
+ <button type="button" className="st-iconbtn" aria-label="Close" onClick={onClose}>
243
+ <StIcon name="x" size={15} />
244
+ </button>
245
+ </div>
246
+ <div className="st-dialog-bd">
247
+ <div className="st-ap-toolbar">
248
+ <button type="button" className="st-btn" onClick={openFilePicker} disabled={busy}>
249
+ {busy
250
+ ? progress == null
251
+ ? 'Uploading…'
252
+ : `Uploading… ${Math.round(progress * 100)}%`
253
+ : 'Upload…'}
254
+ </button>
255
+ {err && <span className="st-ap-err">{err}</span>}
256
+ </div>
257
+ <div className="st-ap-grid">
258
+ {assets == null ? (
259
+ <div className="st-ap-empty">Loading…</div>
260
+ ) : assets.length === 0 ? (
261
+ <div className="st-ap-empty">No assets yet — upload one.</div>
262
+ ) : (
263
+ assets.map((a) => {
264
+ const isSelected = multiple && selected.has(a.path);
265
+ return (
266
+ <button
267
+ type="button"
268
+ key={a.path}
269
+ className="st-ap-cell"
270
+ data-selected={isSelected ? 'true' : undefined}
271
+ aria-pressed={multiple ? isSelected : undefined}
272
+ title={`${a.name} · ${Math.max(1, Math.round(a.size / 1024))} KB`}
273
+ onClick={() => (multiple ? toggleSelected(a.path) : onPick(a.path))}
274
+ >
275
+ {multiple && (
276
+ <span className="st-ap-check" aria-hidden="true">
277
+ {isSelected ? <StIcon name="check" size={12} /> : null}
278
+ </span>
279
+ )}
280
+ {a.kind === 'video' ? (
281
+ <video className="st-ap-thumb" src={assetUrl(a.path)} muted playsInline />
282
+ ) : (
283
+ <img className="st-ap-thumb" src={assetUrl(a.path)} alt={a.name} loading="lazy" />
284
+ )}
285
+ <span className="st-ap-name">{a.name}</span>
286
+ </button>
287
+ );
288
+ })
289
+ )}
290
+ </div>
291
+ </div>
292
+ {multiple && selected.size > 0 && (
293
+ <div className="st-dialog-ft st-ap-confirm">
294
+ <span className="st-ap-count">{selected.size} selected</span>
295
+ <div className="st-ap-seg" role="radiogroup" aria-label="Insert as">
296
+ <button
297
+ type="button"
298
+ className="st-ap-seg-btn"
299
+ aria-pressed={destination === 'artboard'}
300
+ disabled={artboardDisabled}
301
+ onClick={() => setDestination('artboard')}
302
+ >
303
+ Add to artboard
304
+ </button>
305
+ <button
306
+ type="button"
307
+ className="st-ap-seg-btn"
308
+ aria-pressed={destination === 'annotation'}
309
+ onClick={() => setDestination('annotation')}
310
+ >
311
+ Add as annotation
312
+ </button>
313
+ </div>
314
+ {artboardDisabled && <span className="st-ap-dest-note">{artboardDisabledReason}</span>}
315
+ <span className="st-ap-confirm-spacer" />
316
+ <button type="button" className="btn btn--ghost" onClick={onClose}>
317
+ Cancel
318
+ </button>
319
+ <button
320
+ type="button"
321
+ className="btn btn--primary"
322
+ onClick={() => onPickMany?.(Array.from(selected), destination)}
323
+ >
324
+ Insert
325
+ </button>
326
+ </div>
327
+ )}
328
+ </div>
329
+ </div>
330
+ );
331
+ }
@@ -0,0 +1,112 @@
1
+ // dialogs/command-palette.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
2
+
3
+ import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
4
+ import { commandForEnter, matchCommands } from '../command-palette-match.js';
5
+ import { Kbd, StIcon } from '../shell/icons.jsx';
6
+
7
+ // ⌘K command palette — the mockup's signature surface, wired to real shell
8
+ // actions (theme, system view, comments, reload, help, what's new, new board).
9
+ // Scoped to shell-doable actions only — in-canvas export lives in the iframe.
10
+ export function CommandPalette({ open, onClose, actions }) {
11
+ const [q, setQ] = useState('');
12
+ const [active, setActive] = useState(0);
13
+ const listRef = useRef(null);
14
+ useEffect(() => {
15
+ if (open) {
16
+ setQ('');
17
+ setActive(0);
18
+ }
19
+ }, [open]);
20
+ // Keep the keyboard-active row visible while arrowing through a scrolled list.
21
+ useEffect(() => {
22
+ listRef.current
23
+ ?.querySelector('.st-pal-item.is-active')
24
+ ?.scrollIntoView({ block: 'nearest' });
25
+ }, [active]);
26
+ const filtered = useMemo(() => matchCommands(actions, q), [q, actions]);
27
+ useEffect(() => {
28
+ if (active >= filtered.length) setActive(0);
29
+ }, [filtered.length, active]);
30
+ if (!open) return null;
31
+ const run = (a) => {
32
+ onClose();
33
+ a.run();
34
+ };
35
+ return (
36
+ <div
37
+ className="st-scrim"
38
+ role="presentation"
39
+ onMouseDown={(e) => {
40
+ if (e.target === e.currentTarget) onClose();
41
+ }}
42
+ >
43
+ <div className="st-palette" role="dialog" aria-modal="true" aria-label="Command palette">
44
+ <div className="st-pal-search">
45
+ <StIcon name="search" size={18} />
46
+ <input
47
+ // biome-ignore lint/a11y/noAutofocus: command palette opens on an explicit ⌘K.
48
+ autoFocus
49
+ placeholder="Type a command or search…"
50
+ value={q}
51
+ aria-label="Command search"
52
+ onChange={(e) => setQ(e.target.value)}
53
+ onKeyDown={(e) => {
54
+ if (e.key === 'Escape') {
55
+ e.preventDefault();
56
+ onClose();
57
+ } else if (e.key === 'ArrowDown') {
58
+ e.preventDefault();
59
+ setActive((i) => Math.min(filtered.length - 1, i + 1));
60
+ } else if (e.key === 'ArrowUp') {
61
+ e.preventDefault();
62
+ setActive((i) => Math.max(0, i - 1));
63
+ } else if (e.key === 'Enter') {
64
+ e.preventDefault();
65
+ const pick = commandForEnter(actions, q, e.currentTarget.value, active);
66
+ if (pick) run(pick);
67
+ }
68
+ }}
69
+ />
70
+ <Kbd>⌘K</Kbd>
71
+ </div>
72
+ <div className="st-pal-list" ref={listRef}>
73
+ {filtered.length === 0 ? (
74
+ <div className="st-pal-empty">No matching command.</div>
75
+ ) : (
76
+ filtered.map((a, i) => {
77
+ // Emit a group header when the group changes (flat list → grouped
78
+ // display; keyboard nav still indexes across the whole array).
79
+ const header =
80
+ a.group && (i === 0 || filtered[i - 1].group !== a.group) ? (
81
+ <div className="st-pal-group" key={'g-' + a.group}>
82
+ {a.group}
83
+ </div>
84
+ ) : null;
85
+ return (
86
+ <Fragment key={a.id}>
87
+ {header}
88
+ <button
89
+ type="button"
90
+ className={'st-pal-item' + (i === active ? ' is-active' : '')}
91
+ onMouseEnter={() => setActive(i)}
92
+ onClick={() => run(a)}
93
+ >
94
+ <span className="st-pal-icon">
95
+ <StIcon name={a.icon} size={15} />
96
+ </span>
97
+ <span className="st-pal-label">{a.label}</span>
98
+ {a.kbd ? (
99
+ <span className="st-pal-kbd">
100
+ <Kbd>{a.kbd}</Kbd>
101
+ </span>
102
+ ) : null}
103
+ </button>
104
+ </Fragment>
105
+ );
106
+ })
107
+ )}
108
+ </div>
109
+ </div>
110
+ </div>
111
+ );
112
+ }