@1agh/maude 1.2.0 → 1.3.1
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/README.md +3 -1
- package/apps/studio/acp/index.ts +43 -7
- package/apps/studio/annotations-layer.tsx +191 -116
- package/apps/studio/annotations-model.ts +39 -0
- package/apps/studio/annotations-sync.ts +50 -0
- package/apps/studio/api.ts +732 -38
- package/apps/studio/bin/annotate.mjs +3 -1
- package/apps/studio/bin/server-up.sh +17 -2
- package/apps/studio/canvas-build.ts +49 -8
- package/apps/studio/canvas-edit.ts +468 -7
- package/apps/studio/canvas-lib.tsx +82 -18
- package/apps/studio/canvas-list-watch.ts +33 -2
- package/apps/studio/canvas-notice-message.ts +16 -0
- package/apps/studio/canvas-notifications.tsx +19 -0
- package/apps/studio/canvas-shell.tsx +57 -6
- package/apps/studio/client/app.jsx +783 -245
- package/apps/studio/client/apply-edit-request.ts +55 -0
- package/apps/studio/client/canvas-url.js +39 -1
- package/apps/studio/client/export-center.jsx +111 -61
- package/apps/studio/client/github.js +38 -1
- package/apps/studio/client/index-loader.ts +76 -0
- package/apps/studio/client/panels/CloudBar.jsx +52 -6
- package/apps/studio/client/panels/GitPanel.jsx +103 -0
- package/apps/studio/client/panels/OnboardingWizard.jsx +36 -7
- package/apps/studio/client/panels/RepoBranchSwitcher.jsx +92 -27
- package/apps/studio/client/panels/SourceConflictPanel.jsx +166 -0
- package/apps/studio/client/panels/SyncPanel.jsx +113 -0
- package/apps/studio/client/panels/TeamProjects.jsx +376 -0
- package/apps/studio/client/panels/file-deep-link-dialog.jsx +54 -0
- package/apps/studio/client/photo-knobs.jsx +3 -0
- package/apps/studio/client/share-dialog.jsx +91 -0
- package/apps/studio/client/share-link.js +94 -0
- package/apps/studio/client/styles/3-shell-maude.css +36 -18
- package/apps/studio/client/styles/4-components.css +18 -1
- package/apps/studio/client/tree-row-menu.jsx +48 -3
- package/apps/studio/client/whats-new.jsx +26 -32
- package/apps/studio/cloud/endpoints.ts +132 -0
- package/apps/studio/collab/awareness-bridge.ts +65 -14
- package/apps/studio/collab/index.ts +4 -0
- package/apps/studio/collab/persistence.ts +5 -1
- package/apps/studio/collab/registry.ts +9 -3
- package/apps/studio/collab/room.ts +13 -2
- package/apps/studio/context.ts +59 -0
- package/apps/studio/dist/client.bundle.js +1594 -1562
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/runtime/.min-sizes.json +1 -0
- package/apps/studio/dist/runtime/sonner.js +1 -0
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/git/accepted-guard.ts +36 -0
- package/apps/studio/hmr-broadcast.ts +34 -1
- package/apps/studio/http.ts +300 -18
- package/apps/studio/inspect.ts +19 -0
- package/apps/studio/managed-projects.ts +172 -0
- package/apps/studio/notifications.tsx +292 -0
- package/apps/studio/runtime-bundle.ts +2 -0
- package/apps/studio/server.ts +59 -3
- package/apps/studio/sync/accepted-cold-start.ts +225 -0
- package/apps/studio/sync/accepted-link.ts +320 -0
- package/apps/studio/sync/action-stage.ts +343 -0
- package/apps/studio/sync/agent.ts +12 -60
- package/apps/studio/sync/cell-file-events.ts +3 -0
- package/apps/studio/sync/codec.ts +73 -6
- package/apps/studio/sync/ctl-provider.ts +15 -2
- package/apps/studio/sync/document-discovery.ts +81 -0
- package/apps/studio/sync/file-membership.ts +10 -2
- package/apps/studio/sync/file-plane.ts +309 -26
- package/apps/studio/sync/index.ts +1174 -21
- package/apps/studio/sync/migrate-seed.ts +110 -19
- package/apps/studio/sync/poke.ts +4 -2
- package/apps/studio/sync/presentation.ts +315 -2
- package/apps/studio/sync/projection.ts +820 -23
- package/apps/studio/sync/repeated-module.ts +73 -0
- package/apps/studio/sync/revision-barrier.ts +129 -0
- package/apps/studio/sync/seed-repair.ts +46 -0
- package/apps/studio/sync/source-merge.ts +100 -0
- package/apps/studio/sync/source-ops.ts +289 -0
- package/apps/studio/sync/source-recovery.ts +70 -0
- package/apps/studio/sync/source-validation.ts +56 -0
- package/apps/studio/sync/status.ts +83 -1
- package/apps/studio/sync/transaction-client.ts +486 -0
- package/apps/studio/sync/writer-registry.ts +236 -0
- package/apps/studio/text-caret.ts +35 -0
- package/apps/studio/undo-hud.tsx +9 -87
- package/apps/studio/use-canvas-media-drop.tsx +4 -39
- package/apps/studio/use-tool-mode.tsx +44 -0
- package/apps/studio/whats-new.json +137 -0
- package/cli/lib/harness/codex-runtime.mjs +4 -1
- package/package.json +9 -8
- package/plugins/design/dependencies.json +3 -3
- package/plugins/design/templates/_shell.html +95 -7
- package/plugins/flow/dependencies.json +3 -3
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// The executable half of the persistent-writer registry — DDR-241, plan T6.
|
|
2
|
+
//
|
|
3
|
+
// `docs/architecture/project-writer-registry.md` explains every writer; this
|
|
4
|
+
// module is the part a test can hold the code to. Every `/_api/*` route the
|
|
5
|
+
// studio serves is classified here by HOW its persistent effect reaches the
|
|
6
|
+
// project in accepted-revisions mode. A route that is not listed fails
|
|
7
|
+
// `test/sync-writer-registry.test.ts` — a new mutating route cannot ship
|
|
8
|
+
// without someone deciding which lane carries it.
|
|
9
|
+
//
|
|
10
|
+
// Classes:
|
|
11
|
+
// read — no persistent project effect.
|
|
12
|
+
// lane — rewrites canvas source/meta/annotations/comments; reaches the
|
|
13
|
+
// project as a `lane.replace` proposal (watcher import with the
|
|
14
|
+
// base announced by `activity:suppress`, or an API hook that
|
|
15
|
+
// hands the runtime its base).
|
|
16
|
+
// structural — canvas/folder create, move, delete: one manifest action.
|
|
17
|
+
// file-plane — assets, media sidecars, support files: the file plane's own
|
|
18
|
+
// CAS journal (DDR-226), not the canvas kernel (DDR-241 §8).
|
|
19
|
+
// git — operates on the checkout's Git graph; never a project action.
|
|
20
|
+
// local — this machine only: credentials, caches, jobs, activity, UI.
|
|
21
|
+
|
|
22
|
+
export type WriterClass = 'read' | 'lane' | 'structural' | 'file-plane' | 'git' | 'local';
|
|
23
|
+
|
|
24
|
+
export interface WriterEntry {
|
|
25
|
+
class: WriterClass;
|
|
26
|
+
/** Registry row(s) in project-writer-registry.md. */
|
|
27
|
+
rows?: string;
|
|
28
|
+
/** How the effect travels in accepted mode (lane / structural only). */
|
|
29
|
+
via?: string;
|
|
30
|
+
/** The test that proves it (lane / structural only). */
|
|
31
|
+
test?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const LANE_SOURCE = {
|
|
35
|
+
class: 'lane',
|
|
36
|
+
via: 'source write announced by activity:suppress → watcher import → html lane.replace with the announced base',
|
|
37
|
+
test: 'test/sync-accepted-projection.test.ts',
|
|
38
|
+
} as const;
|
|
39
|
+
|
|
40
|
+
export const WRITER_REGISTRY: Record<string, WriterEntry> = {
|
|
41
|
+
// --- canvas source edits (S01–S18, V01–V10)
|
|
42
|
+
'/_api/edit-text': { ...LANE_SOURCE, rows: 'S01' },
|
|
43
|
+
'/_api/edit-css': { ...LANE_SOURCE, rows: 'S02' },
|
|
44
|
+
'/_api/edit-attr': { ...LANE_SOURCE, rows: 'S03' },
|
|
45
|
+
'/_api/reorder': { ...LANE_SOURCE, rows: 'S04' },
|
|
46
|
+
'/_api/delete-element': { ...LANE_SOURCE, rows: 'S05' },
|
|
47
|
+
'/_api/insert-element': { ...LANE_SOURCE, rows: 'S06' },
|
|
48
|
+
'/_api/duplicate-element': { ...LANE_SOURCE, rows: 'S07' },
|
|
49
|
+
'/_api/convert-to-absolute': { ...LANE_SOURCE, rows: 'S08' },
|
|
50
|
+
'/_api/detach-component': { ...LANE_SOURCE, rows: 'S09' },
|
|
51
|
+
'/_api/insert-artboard': { ...LANE_SOURCE, rows: 'S10' },
|
|
52
|
+
'/_api/duplicate-artboard': { ...LANE_SOURCE, rows: 'S11' },
|
|
53
|
+
'/_api/delete-artboard': { ...LANE_SOURCE, rows: 'S12' },
|
|
54
|
+
'/_api/resize-artboard': { ...LANE_SOURCE, rows: 'S13' },
|
|
55
|
+
'/_api/set-artboard-hug': { ...LANE_SOURCE, rows: 'S14' },
|
|
56
|
+
'/_api/set-artboard-style': { ...LANE_SOURCE, rows: 'S15' },
|
|
57
|
+
'/_api/set-artboard-kind': { ...LANE_SOURCE, rows: 'S16' },
|
|
58
|
+
'/_api/set-artboard-label': { ...LANE_SOURCE, rows: 'S16' },
|
|
59
|
+
'/_api/set-artboard-guides': { ...LANE_SOURCE, rows: 'S17' },
|
|
60
|
+
'/_api/set-artboard-print': { ...LANE_SOURCE, rows: 'S17' },
|
|
61
|
+
'/_api/reorder-revert': { ...LANE_SOURCE, rows: 'S18' },
|
|
62
|
+
'/_api/retime-sequence': { ...LANE_SOURCE, rows: 'V01' },
|
|
63
|
+
'/_api/remove-sequence': { ...LANE_SOURCE, rows: 'V02' },
|
|
64
|
+
'/_api/insert-sequence': { ...LANE_SOURCE, rows: 'V03' },
|
|
65
|
+
'/_api/reorder-sequence': { ...LANE_SOURCE, rows: 'V04' },
|
|
66
|
+
'/_api/toggle-hide': { ...LANE_SOURCE, rows: 'V05' },
|
|
67
|
+
'/_api/edit-array-src': { ...LANE_SOURCE, rows: 'V06' },
|
|
68
|
+
'/_api/clip-edit': { ...LANE_SOURCE, rows: 'V07–V10' },
|
|
69
|
+
// --- shared meta, annotations, comments (S19, S23, S24)
|
|
70
|
+
'/_api/canvas-meta': {
|
|
71
|
+
class: 'lane',
|
|
72
|
+
rows: 'S19',
|
|
73
|
+
via: 'onMetaChanged hook → meta lane.replace with the replaced file as base; camera/overlays/locked stay local',
|
|
74
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
75
|
+
},
|
|
76
|
+
'/_api/annotations': {
|
|
77
|
+
class: 'lane',
|
|
78
|
+
rows: 'S23',
|
|
79
|
+
via: 'onAnnotationsChanged hook → annotations lane.replace with the base the layer sent',
|
|
80
|
+
test: 'test/sync-accepted-projection.test.ts',
|
|
81
|
+
},
|
|
82
|
+
// --- accepted history (T27/T28)
|
|
83
|
+
'/_api/project/history': { class: 'read' },
|
|
84
|
+
'/_api/project/restore': {
|
|
85
|
+
class: 'lane',
|
|
86
|
+
rows: 'X15',
|
|
87
|
+
via: 'history.restore — a NEW action restoring the canvas lanes (not comments) to a revision',
|
|
88
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
89
|
+
},
|
|
90
|
+
'/_api/project/conflict': {
|
|
91
|
+
class: 'lane',
|
|
92
|
+
rows: 'X15',
|
|
93
|
+
via: 'mine: html lane.replace on top of the accepted version (a new action); theirs: accepted body back to disk',
|
|
94
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
95
|
+
},
|
|
96
|
+
'/_api/project/ai-action': {
|
|
97
|
+
class: 'lane',
|
|
98
|
+
rows: 'I02',
|
|
99
|
+
via: 'publish: the held AI stage as ONE history action (lane.replace ops); discard: accepted value back to disk',
|
|
100
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
101
|
+
},
|
|
102
|
+
'/_api/project/undo': {
|
|
103
|
+
class: 'lane',
|
|
104
|
+
rows: 'S18',
|
|
105
|
+
via: 'history.undo/redo — effect-aware compensation of one of this actor’s actions',
|
|
106
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
107
|
+
},
|
|
108
|
+
// --- manifest (S20–S22)
|
|
109
|
+
'/_api/canvas': {
|
|
110
|
+
class: 'structural',
|
|
111
|
+
rows: 'S20',
|
|
112
|
+
via: 'create: cold start doc.create; delete: canvas-deleted → doc.delete; folders: dir.delete',
|
|
113
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
114
|
+
},
|
|
115
|
+
'/_api/fs-move': {
|
|
116
|
+
class: 'structural',
|
|
117
|
+
rows: 'S21',
|
|
118
|
+
via: 'retireForMove → doc.move; folders: proposeFolder dir.move',
|
|
119
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
120
|
+
},
|
|
121
|
+
'/_api/fs-mkdir': {
|
|
122
|
+
class: 'structural',
|
|
123
|
+
rows: 'S22',
|
|
124
|
+
via: 'proposeFolder dir.create before mkdir',
|
|
125
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
126
|
+
},
|
|
127
|
+
'/_api/design/init': {
|
|
128
|
+
class: 'structural',
|
|
129
|
+
rows: 'I12',
|
|
130
|
+
via: 'scaffolded canvases join by cold start doc.create',
|
|
131
|
+
test: 'test/sync-accepted-runtime.test.ts',
|
|
132
|
+
},
|
|
133
|
+
// --- file plane (S25–S30, I04–I11)
|
|
134
|
+
'/_api/photo-edit': { class: 'file-plane', rows: 'S25' },
|
|
135
|
+
'/_api/footage': { class: 'file-plane', rows: 'S26' },
|
|
136
|
+
'/_api/asset': { class: 'file-plane', rows: 'S27' },
|
|
137
|
+
'/_api/assets': { class: 'file-plane', rows: 'S27' },
|
|
138
|
+
'/_api/import-asset': { class: 'file-plane', rows: 'S28/I08' },
|
|
139
|
+
'/_api/import-brand': { class: 'file-plane', rows: 'S28/I07' },
|
|
140
|
+
'/_api/figma/import': { class: 'file-plane', rows: 'I04/I05 (canvases join by cold start)' },
|
|
141
|
+
'/_api/figma/explode': { class: 'file-plane', rows: 'I04/I05 (canvases join by cold start)' },
|
|
142
|
+
'/_api/generate-jobs': { class: 'file-plane', rows: 'S29' },
|
|
143
|
+
'/_api/generate/audio-reuse': { class: 'file-plane', rows: 'S30' },
|
|
144
|
+
'/_api/stickers': { class: 'file-plane', rows: 'S27' },
|
|
145
|
+
'/_api/generate/prefs': { class: 'local', rows: 'S31 (config.assign schema gap)' },
|
|
146
|
+
// --- git (H09/H10)
|
|
147
|
+
'/_api/git/branch': { class: 'git', rows: 'H10' },
|
|
148
|
+
'/_api/git/branches': { class: 'read' },
|
|
149
|
+
'/_api/git/checkout': { class: 'git', rows: 'H09' },
|
|
150
|
+
'/_api/git/commit': { class: 'git', rows: 'H10' },
|
|
151
|
+
'/_api/git/diff': { class: 'read' },
|
|
152
|
+
'/_api/git/discard': { class: 'git', rows: 'H09' },
|
|
153
|
+
'/_api/git/fetch': { class: 'git', rows: 'H10' },
|
|
154
|
+
'/_api/git/fold': { class: 'git', rows: 'H09' },
|
|
155
|
+
'/_api/git/log': { class: 'read' },
|
|
156
|
+
'/_api/git/pull': { class: 'git', rows: 'H09' },
|
|
157
|
+
'/_api/git/push': { class: 'git', rows: 'H10' },
|
|
158
|
+
'/_api/git/resolve': { class: 'git', rows: 'H09' },
|
|
159
|
+
'/_api/git/status': { class: 'read' },
|
|
160
|
+
'/_api/github/clone': { class: 'git', rows: 'H10' },
|
|
161
|
+
'/_api/github/create-project': { class: 'local', rows: 'I12' },
|
|
162
|
+
'/_api/github/create-repo': { class: 'local' },
|
|
163
|
+
'/_api/github/identity': { class: 'local' },
|
|
164
|
+
'/_api/github/invite': { class: 'local' },
|
|
165
|
+
'/_api/github/repos': { class: 'read' },
|
|
166
|
+
'/_api/project/create-local': { class: 'local', rows: 'I12' },
|
|
167
|
+
'/_api/projects/prepare': {
|
|
168
|
+
class: 'local',
|
|
169
|
+
rows: 'H13 (credential + project description for a managed copy)',
|
|
170
|
+
},
|
|
171
|
+
// --- reads
|
|
172
|
+
'/_api/canvas-source': { class: 'read' },
|
|
173
|
+
'/_api/comp-clips': { class: 'read' },
|
|
174
|
+
'/_api/component-map': { class: 'read' },
|
|
175
|
+
'/_api/edit-scope': { class: 'read' },
|
|
176
|
+
'/_api/git-committers': { class: 'read' },
|
|
177
|
+
'/_api/git-user': { class: 'read' },
|
|
178
|
+
'/_api/preflight': { class: 'read' },
|
|
179
|
+
'/_api/setup-readiness': { class: 'read' },
|
|
180
|
+
'/_api/whats-new': { class: 'read' },
|
|
181
|
+
'/_api/figma/probe': { class: 'read' },
|
|
182
|
+
'/_api/figma/status': { class: 'read' },
|
|
183
|
+
'/_api/generate/providers': { class: 'read' },
|
|
184
|
+
'/_api/generate/audio-search': { class: 'read' },
|
|
185
|
+
'/_api/export-history': { class: 'read' },
|
|
186
|
+
// --- this machine only
|
|
187
|
+
'/_api/acp/activity': { class: 'local' },
|
|
188
|
+
'/_api/acp/attachment': { class: 'local' },
|
|
189
|
+
'/_api/acp/chat': { class: 'local' },
|
|
190
|
+
'/_api/acp/chats': { class: 'local' },
|
|
191
|
+
'/_api/acp/focus': { class: 'local' },
|
|
192
|
+
'/_api/acp/running': { class: 'local' },
|
|
193
|
+
'/_api/acp/status': { class: 'local' },
|
|
194
|
+
'/_api/ai': { class: 'local', rows: 'I02' },
|
|
195
|
+
'/_api/ai/end': { class: 'local', rows: 'I02' },
|
|
196
|
+
'/_api/ai/heartbeat': { class: 'local', rows: 'I02' },
|
|
197
|
+
'/_api/ai/start': { class: 'local', rows: 'I02' },
|
|
198
|
+
'/_api/claude/install': { class: 'local' },
|
|
199
|
+
'/_api/claude/install-status': { class: 'local' },
|
|
200
|
+
'/_api/claude/signin': { class: 'local' },
|
|
201
|
+
'/_api/claude/signin-cancel': { class: 'local' },
|
|
202
|
+
'/_api/claude/signin-status': { class: 'local' },
|
|
203
|
+
'/_api/cloud/attach': { class: 'local' },
|
|
204
|
+
'/_api/cloud/attach/code': { class: 'local' },
|
|
205
|
+
'/_api/cloud/detach': { class: 'local' },
|
|
206
|
+
'/_api/cloud/history': { class: 'read' },
|
|
207
|
+
'/_api/cloud/projects': { class: 'read' },
|
|
208
|
+
'/_api/cloud/signin/poll': { class: 'local' },
|
|
209
|
+
'/_api/cloud/signin/start': { class: 'local' },
|
|
210
|
+
'/_api/cloud/signout': { class: 'local' },
|
|
211
|
+
'/_api/cloud/status': { class: 'read' },
|
|
212
|
+
'/_api/debug-bundle': { class: 'local' },
|
|
213
|
+
'/_api/export': { class: 'local' },
|
|
214
|
+
'/_api/export-assemble': { class: 'local' },
|
|
215
|
+
'/_api/export-jobs': { class: 'local' },
|
|
216
|
+
'/_api/export-jobs/download': { class: 'local' },
|
|
217
|
+
'/_api/export-warmup': { class: 'local' },
|
|
218
|
+
'/_api/figma/connect': { class: 'local' },
|
|
219
|
+
'/_api/generate/keyframe-model': { class: 'local' },
|
|
220
|
+
'/_api/generate/keys': { class: 'local' },
|
|
221
|
+
'/_api/generate/whisper-model': { class: 'local' },
|
|
222
|
+
'/_api/hub/link': { class: 'local' },
|
|
223
|
+
'/_api/report': { class: 'local' },
|
|
224
|
+
'/_api/report-fallback': { class: 'local' },
|
|
225
|
+
'/_api/shell-shot': { class: 'local' },
|
|
226
|
+
'/_api/sync/cancel-assets': { class: 'local' },
|
|
227
|
+
'/_api/sync/ownership': { class: 'local' },
|
|
228
|
+
'/_api/sync/resync': { class: 'local', rows: 'X16' },
|
|
229
|
+
'/_api/sync/offline': { class: 'local', rows: 'T19 (pull the whole file plane now)' },
|
|
230
|
+
'/_api/sync/settings': { class: 'local' },
|
|
231
|
+
'/_api/sync/trash': { class: 'local', rows: 'X15 (restore re-enters through cold start)' },
|
|
232
|
+
'/_api/timeline-media': { class: 'local' },
|
|
233
|
+
'/_api/ui-prefs': { class: 'local' },
|
|
234
|
+
'/_api/workspace/disclosure': { class: 'local' },
|
|
235
|
+
'/_api/workspace/sign-in': { class: 'local' },
|
|
236
|
+
};
|
|
@@ -76,6 +76,41 @@ export function placeCaretAt(
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Collapse an ENTRY select-all to the end of the content, if that is what the
|
|
81
|
+
* selection still is. issue-106: keyboard entry into a text surface (select the
|
|
82
|
+
* stroke, press Enter) leaves `placeCaretAt`'s select-all fallback in place, so
|
|
83
|
+
* the first keystroke replaces the whole body — which is exactly what the
|
|
84
|
+
* retype/rename convention wants for a typed CHARACTER, but never for
|
|
85
|
+
* Shift+Enter, whose entire documented meaning is "add a new line". Without
|
|
86
|
+
* this, Shift+Enter deleted the note and left a blank line in its place.
|
|
87
|
+
*
|
|
88
|
+
* Deliberately narrow: only a selection whose boundaries are still BOTH ends of
|
|
89
|
+
* the editable is collapsed. A user's own drag-selection or a partial range is
|
|
90
|
+
* left alone, so ordinary "replace the selected words" editing keeps native
|
|
91
|
+
* semantics. Returns true when it collapsed something.
|
|
92
|
+
*/
|
|
93
|
+
export function collapseEntrySelectAll(editable: HTMLElement, win: Window): boolean {
|
|
94
|
+
try {
|
|
95
|
+
const sel = win.getSelection();
|
|
96
|
+
if (!sel || sel.rangeCount === 0 || sel.isCollapsed) return false;
|
|
97
|
+
const cur = sel.getRangeAt(0);
|
|
98
|
+
const all = editable.ownerDocument.createRange();
|
|
99
|
+
all.selectNodeContents(editable);
|
|
100
|
+
// Range.START_TO_START / END_TO_END via the instance so no global lookup is
|
|
101
|
+
// needed (the editable may live in another document/realm).
|
|
102
|
+
if (cur.compareBoundaryPoints(cur.START_TO_START, all) !== 0) return false;
|
|
103
|
+
if (cur.compareBoundaryPoints(cur.END_TO_END, all) !== 0) return false;
|
|
104
|
+
all.collapse(false); // to the end
|
|
105
|
+
sel.removeAllRanges();
|
|
106
|
+
sel.addRange(all);
|
|
107
|
+
return true;
|
|
108
|
+
} catch {
|
|
109
|
+
/* selection API unavailable */
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
79
114
|
const STYLE_ID = 'maude-caret-css';
|
|
80
115
|
|
|
81
116
|
const CARET_CSS = `
|
package/apps/studio/undo-hud.tsx
CHANGED
|
@@ -1,94 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @purpose Subscribes to `useUndoStack().lastLabel` + `.lastTick` and
|
|
5
|
-
* surfaces a 1.2 s aria-live toast so the user (and a screen
|
|
6
|
-
* reader) knows which edit just got pushed / undone / redone.
|
|
7
|
-
*
|
|
8
|
-
* a11y. The toast renders into `aria-live="polite"` so a screen reader
|
|
9
|
-
* announces "Undo: move 3 artboards" without interrupting in-flight speech.
|
|
10
|
-
* Pointer events are disabled — the HUD is informational only and must
|
|
11
|
-
* never absorb clicks meant for the canvas behind it.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { useEffect, useState } from 'react';
|
|
15
|
-
|
|
1
|
+
/** Announces canvas edit/undo/redo operations through the shared toast stack. */
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { showCanvasToast } from './canvas-notifications.tsx';
|
|
16
4
|
import { useUndoStackOptional } from './use-undo-stack.tsx';
|
|
17
5
|
|
|
18
|
-
const HUD_CSS = `
|
|
19
|
-
.dc-undo-hud {
|
|
20
|
-
position: fixed;
|
|
21
|
-
top: 16px;
|
|
22
|
-
right: 16px;
|
|
23
|
-
z-index: 7;
|
|
24
|
-
pointer-events: none;
|
|
25
|
-
padding: 6px 10px;
|
|
26
|
-
background: var(--maude-chrome-bg-2, rgba(20, 20, 20, 0.85));
|
|
27
|
-
color: var(--maude-chrome-fg-1, rgba(255, 255, 255, 0.85));
|
|
28
|
-
border: 1px solid var(--maude-chrome-border, rgba(255, 255, 255, 0.08));
|
|
29
|
-
border-radius: 6px;
|
|
30
|
-
font: 11px var(--maude-chrome-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
|
|
31
|
-
letter-spacing: 0.02em;
|
|
32
|
-
user-select: none;
|
|
33
|
-
opacity: 0;
|
|
34
|
-
transform: translateY(-4px);
|
|
35
|
-
transition: opacity 200ms linear, transform 200ms ease-out;
|
|
36
|
-
}
|
|
37
|
-
.dc-undo-hud[data-visible="true"] {
|
|
38
|
-
opacity: 1;
|
|
39
|
-
transform: translateY(0);
|
|
40
|
-
transition-duration: 120ms;
|
|
41
|
-
}
|
|
42
|
-
@media (prefers-reduced-motion: reduce) {
|
|
43
|
-
.dc-undo-hud {
|
|
44
|
-
transition-duration: 1ms !important;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
`.trim();
|
|
48
|
-
|
|
49
|
-
function ensureStyles(): void {
|
|
50
|
-
if (typeof document === 'undefined') return;
|
|
51
|
-
if (document.getElementById('dc-undo-hud-css')) return;
|
|
52
|
-
const s = document.createElement('style');
|
|
53
|
-
s.id = 'dc-undo-hud-css';
|
|
54
|
-
s.textContent = HUD_CSS;
|
|
55
|
-
document.head.appendChild(s);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Auto-dismiss timeout — matches the post-Wave-3 toast cadence. */
|
|
59
|
-
const DISMISS_MS = 1200;
|
|
60
|
-
|
|
61
6
|
export function UndoHud() {
|
|
62
|
-
ensureStyles();
|
|
63
7
|
const undo = useUndoStackOptional();
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
// Bump visibility every time `lastTick` increments — same tick value means
|
|
67
|
-
// the underlying state did NOT change (provider's no-op fallback returns
|
|
68
|
-
// `lastTick: 0` constantly, so the HUD stays hidden when no provider).
|
|
69
|
-
const tick = undo.lastTick;
|
|
70
|
-
const label = undo.lastLabel;
|
|
71
|
-
|
|
8
|
+
const lastTick = useRef(0);
|
|
72
9
|
useEffect(() => {
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const id = window.setTimeout(() => setVisible(false), DISMISS_MS);
|
|
79
|
-
return () => window.clearTimeout(id);
|
|
80
|
-
}, [tick, label]);
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<div
|
|
84
|
-
className="dc-undo-hud"
|
|
85
|
-
data-visible={visible ? 'true' : 'false'}
|
|
86
|
-
role="status"
|
|
87
|
-
aria-live="polite"
|
|
88
|
-
aria-atomic="true"
|
|
89
|
-
>
|
|
90
|
-
{label ?? ''}
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
10
|
+
if (!undo.lastTick || !undo.lastLabel || lastTick.current === undo.lastTick) return;
|
|
11
|
+
lastTick.current = undo.lastTick;
|
|
12
|
+
showCanvasToast(undo.lastLabel, 'undo');
|
|
13
|
+
}, [undo.lastTick, undo.lastLabel]);
|
|
14
|
+
return null;
|
|
93
15
|
}
|
|
94
16
|
UndoHud.displayName = 'UndoHud';
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { useEffect } from 'react';
|
|
25
|
+
import { showCanvasToast } from './canvas-notifications.tsx';
|
|
26
|
+
|
|
27
|
+
export { showCanvasToast } from './canvas-notifications.tsx';
|
|
25
28
|
|
|
26
29
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
27
30
|
// Pure helpers (exported for unit tests)
|
|
@@ -194,25 +197,6 @@ export async function uploadAsset(file: Blob): Promise<{ path: string } | { erro
|
|
|
194
197
|
// Transient toast (no React state — self-contained DOM, mirrors ensure*Styles)
|
|
195
198
|
|
|
196
199
|
const TOAST_CSS = `
|
|
197
|
-
.dc-media-toast {
|
|
198
|
-
position: fixed;
|
|
199
|
-
left: 50%;
|
|
200
|
-
bottom: 108px;
|
|
201
|
-
transform: translateX(-50%);
|
|
202
|
-
z-index: 9;
|
|
203
|
-
max-width: 360px;
|
|
204
|
-
padding: 8px 14px;
|
|
205
|
-
border-radius: 8px;
|
|
206
|
-
background: #26262b;
|
|
207
|
-
color: #fff;
|
|
208
|
-
font-family: var(--maude-chrome-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
|
|
209
|
-
font-size: 12px;
|
|
210
|
-
box-shadow: 0 8px 28px rgba(0,0,0,0.34);
|
|
211
|
-
opacity: 0;
|
|
212
|
-
transition: opacity 140ms ease;
|
|
213
|
-
pointer-events: none;
|
|
214
|
-
}
|
|
215
|
-
.dc-media-toast[data-show="1"] { opacity: 1; }
|
|
216
200
|
/* Drop affordance — a focus-accent inset frame while a media drag is over the
|
|
217
201
|
canvas, so the surface reads as a drop target. */
|
|
218
202
|
.dc-media-dragover::after {
|
|
@@ -224,9 +208,6 @@ const TOAST_CSS = `
|
|
|
224
208
|
border-radius: 12px;
|
|
225
209
|
pointer-events: none;
|
|
226
210
|
}
|
|
227
|
-
@media (prefers-reduced-motion: reduce) {
|
|
228
|
-
.dc-media-toast { transition: none; }
|
|
229
|
-
}
|
|
230
211
|
/* feature-4 (2026-07-19) — sandbox-safe confirm dialog (window.confirm is
|
|
231
212
|
silently blocked in the allow-modals-less canvas iframe). HUD-token styled. */
|
|
232
213
|
.dc-confirm-backdrop {
|
|
@@ -364,22 +345,6 @@ export function canvasConfirm(
|
|
|
364
345
|
});
|
|
365
346
|
}
|
|
366
347
|
|
|
367
|
-
/** Show a brief auto-dismissing toast in the canvas (e.g. an upload failure). */
|
|
368
|
-
export function showCanvasToast(message: string): void {
|
|
369
|
-
if (typeof document === 'undefined') return;
|
|
370
|
-
ensureMediaStyles();
|
|
371
|
-
const el = document.createElement('div');
|
|
372
|
-
el.className = 'dc-media-toast';
|
|
373
|
-
el.setAttribute('role', 'status');
|
|
374
|
-
el.textContent = message;
|
|
375
|
-
document.body.appendChild(el);
|
|
376
|
-
requestAnimationFrame(() => el.setAttribute('data-show', '1'));
|
|
377
|
-
setTimeout(() => {
|
|
378
|
-
el.setAttribute('data-show', '0');
|
|
379
|
-
setTimeout(() => el.remove(), 200);
|
|
380
|
-
}, 2600);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
348
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
384
349
|
// Hook
|
|
385
350
|
|
|
@@ -414,7 +379,7 @@ export async function uploadAndAnnounceMedia(
|
|
|
414
379
|
const sizeMb = file.size / (1024 * 1024);
|
|
415
380
|
const res = await uploadAsset(file);
|
|
416
381
|
if ('error' in res) {
|
|
417
|
-
showCanvasToast(`Couldn't add ${mediaKind}: ${res.error}
|
|
382
|
+
showCanvasToast(`Couldn't add ${mediaKind}: ${res.error}`, 'error');
|
|
418
383
|
return;
|
|
419
384
|
}
|
|
420
385
|
const snippet = mediaSnippet(mediaKind, res.path);
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
useContext,
|
|
19
19
|
useEffect,
|
|
20
20
|
useMemo,
|
|
21
|
+
useRef,
|
|
21
22
|
useState,
|
|
22
23
|
} from 'react';
|
|
23
24
|
|
|
@@ -53,6 +54,9 @@ export type ShapeKind = 'square' | 'rounded' | 'circle' | 'diamond' | 'triangle'
|
|
|
53
54
|
*/
|
|
54
55
|
export type CanvasMode = 'preview' | 'edit';
|
|
55
56
|
|
|
57
|
+
/** Document event two provider instances keep one active tool through. */
|
|
58
|
+
export const TOOL_SYNC_EVENT = 'maude:tool-sync';
|
|
59
|
+
|
|
56
60
|
/** The resting tool each mode arms (and returns to via `resetTool`). */
|
|
57
61
|
export const MODE_DEFAULT_TOOL: Readonly<Record<CanvasMode, Tool>> = Object.freeze({
|
|
58
62
|
preview: 'browse',
|
|
@@ -231,6 +235,46 @@ export function ToolProvider({
|
|
|
231
235
|
// FigJam look); sharp squares stay one popover click away.
|
|
232
236
|
const [shapeKind, setShapeKind] = useState<ShapeKind>('rounded');
|
|
233
237
|
|
|
238
|
+
// ONE ACTIVE TOOL PER CANVAS DOCUMENT, across provider instances.
|
|
239
|
+
//
|
|
240
|
+
// A UI canvas carries TWO providers: the comment-mount layer's (it owns the
|
|
241
|
+
// comment drop) and canvas-lib's own (it owns the palette) — separate
|
|
242
|
+
// bundles, so separate contexts. They used to converge only through a tool
|
|
243
|
+
// KEYDOWN, which both routers see; a palette CLICK reached canvas-lib's
|
|
244
|
+
// provider alone. So "Comment" in the palette lit up while the comment
|
|
245
|
+
// layer stayed in browse, and clicking the canvas dropped nothing — you had
|
|
246
|
+
// to know to press C (plan T31/L11). A change here is announced on the
|
|
247
|
+
// document and every other instance adopts it. The boot posture is NOT
|
|
248
|
+
// announced (the two instances deliberately boot differently — see
|
|
249
|
+
// `initial`); only a change after mount is.
|
|
250
|
+
const syncId = useRef(Math.random().toString(36).slice(2));
|
|
251
|
+
const toolRef = useRef(tool);
|
|
252
|
+
toolRef.current = tool;
|
|
253
|
+
const announced = useRef(false);
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (!announced.current) {
|
|
256
|
+
announced.current = true;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (typeof document === 'undefined') return;
|
|
260
|
+
document.dispatchEvent(
|
|
261
|
+
new CustomEvent(TOOL_SYNC_EVENT, { detail: { tool, from: syncId.current } })
|
|
262
|
+
);
|
|
263
|
+
}, [tool]);
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
if (typeof document === 'undefined') return;
|
|
266
|
+
const onSync = (e: Event) => {
|
|
267
|
+
const d = (e as CustomEvent<{ tool?: unknown; from?: unknown }>).detail;
|
|
268
|
+
if (!d || d.from === syncId.current || typeof d.tool !== 'string') return;
|
|
269
|
+
// Already there: nothing to do, and — for a sticky-locked tool — not
|
|
270
|
+
// touching it keeps the lock.
|
|
271
|
+
if (d.tool === toolRef.current) return;
|
|
272
|
+
setTool(d.tool as Tool);
|
|
273
|
+
};
|
|
274
|
+
document.addEventListener(TOOL_SYNC_EVENT, onSync);
|
|
275
|
+
return () => document.removeEventListener(TOOL_SYNC_EVENT, onSync);
|
|
276
|
+
}, [setTool]);
|
|
277
|
+
|
|
234
278
|
// Cursor sync — applied inside the canvas (this hook runs in the canvas
|
|
235
279
|
// context). The active tool's cursor is set on <body> AND forced across the
|
|
236
280
|
// whole canvas working area via an `!important` rule, so the custom cursor
|