@1agh/maude 1.6.13 → 1.8.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.
Files changed (60) hide show
  1. package/apps/studio/acp/bridge.ts +1 -0
  2. package/apps/studio/acp/login-state.ts +1 -0
  3. package/apps/studio/acp/probe.ts +1 -0
  4. package/apps/studio/annotations/ai-read.ts +3 -0
  5. package/apps/studio/annotations/ai-write.ts +15 -1
  6. package/apps/studio/annotations/lock.ts +174 -0
  7. package/apps/studio/annotations/migrate-v1.ts +1 -0
  8. package/apps/studio/annotations/registry.ts +3 -0
  9. package/apps/studio/annotations/v1-adapter.ts +1 -0
  10. package/apps/studio/annotations-context-toolbar.tsx +39 -0
  11. package/apps/studio/annotations-layer.tsx +167 -17
  12. package/apps/studio/annotations-model.ts +9 -0
  13. package/apps/studio/api.ts +412 -35
  14. package/apps/studio/asset-upload.ts +174 -0
  15. package/apps/studio/assets-s3.ts +37 -2
  16. package/apps/studio/bin/_pdf-playwright.mjs +22 -1
  17. package/apps/studio/bin/_png-playwright.mjs +20 -1
  18. package/apps/studio/bin/_region.mjs +92 -0
  19. package/apps/studio/canvas-build.ts +59 -4
  20. package/apps/studio/canvas-icons.tsx +18 -0
  21. package/apps/studio/canvas-lib.tsx +48 -1
  22. package/apps/studio/canvas-shell.tsx +28 -4
  23. package/apps/studio/client/app.jsx +109 -22
  24. package/apps/studio/client/canvas-url.js +9 -0
  25. package/apps/studio/client/embed-view.jsx +284 -0
  26. package/apps/studio/client/embed.js +101 -0
  27. package/apps/studio/client/export-center.jsx +2 -0
  28. package/apps/studio/client/github.js +36 -3
  29. package/apps/studio/client/report-bug.jsx +8 -2
  30. package/apps/studio/context.ts +7 -0
  31. package/apps/studio/dist/client.bundle.js +2682 -2682
  32. package/apps/studio/dist/comment-mount.js +2 -2
  33. package/apps/studio/embed-origins.ts +52 -0
  34. package/apps/studio/export-dialog.tsx +55 -3
  35. package/apps/studio/exporters/format-scopes.ts +11 -3
  36. package/apps/studio/exporters/index.ts +17 -2
  37. package/apps/studio/exporters/jobs.ts +16 -8
  38. package/apps/studio/exporters/pdf.ts +10 -2
  39. package/apps/studio/exporters/png.ts +10 -2
  40. package/apps/studio/exporters/scope.ts +74 -3
  41. package/apps/studio/generation/runtime-probe.ts +1 -1
  42. package/apps/studio/git/service.ts +1 -0
  43. package/apps/studio/http.ts +186 -13
  44. package/apps/studio/input-router.tsx +7 -1
  45. package/apps/studio/path-containment.ts +72 -0
  46. package/apps/studio/paths.ts +14 -1
  47. package/apps/studio/read-only-mode.ts +53 -0
  48. package/apps/studio/server.ts +9 -0
  49. package/apps/studio/sync/index.ts +74 -13
  50. package/apps/studio/sync/park.ts +39 -0
  51. package/apps/studio/sync/presentation.ts +9 -3
  52. package/apps/studio/sync/writer-registry.ts +5 -0
  53. package/apps/studio/use-annotation-resize.tsx +4 -1
  54. package/apps/studio/use-canvas-media-drop.tsx +8 -28
  55. package/apps/studio/whats-new.json +36 -0
  56. package/cli/commands/design.mjs +9 -2
  57. package/cli/commands/hub-workspace.mjs +25 -0
  58. package/cli/lib/workspace-plan.mjs +51 -0
  59. package/package.json +9 -9
  60. package/plugins/design/templates/_shell.html +58 -0
@@ -0,0 +1,101 @@
1
+ // DDR-247 — the chromeless `?embed=1` view another app frames, and the ONE-WAY
2
+ // message contract it speaks to that app. Pure (URLSearchParams + URL only) so
3
+ // `test/embed.test.ts` exercises it without React or a DOM.
4
+ //
5
+ // THE CONTRACT (v1) — embedders build against this shape, so it only grows:
6
+ //
7
+ // { source: 'maude-hub', v: 1,
8
+ // type: 'ready' | 'auth-required' | 'not-found' | 'escape',
9
+ // open: string, title?: string }
10
+ //
11
+ // `auth-required` is posted by the hub's signed-out embed page
12
+ // (apps/hub/src/embed-page.mjs), the others by `embed-view.jsx`. `escape`
13
+ // (added to v1, additive) means Escape was pressed inside the embed and
14
+ // nothing there consumed it — keys in a frame never reach the embedding page,
15
+ // so without it an embed inside a dialog would trap a keyboard user. The embed
16
+ // never takes focus on its own; only a click moves focus into it. Nothing is
17
+ // ever posted to '*': the target is the parent's exact origin, and only when
18
+ // that origin is on the server's embed allowlist. Nothing is accepted FROM the
19
+ // parent in v1.
20
+ import { readOpenParam } from './share-link.js';
21
+
22
+ export const EMBED_SOURCE = 'maude-hub';
23
+ export const EMBED_VERSION = 1;
24
+
25
+ /** Is this page load the embed view? Exactly `embed=1`, nothing looser. */
26
+ export function isEmbedLocation(location) {
27
+ try {
28
+ return new URLSearchParams(location?.search ?? '').get('embed') === '1';
29
+ } catch {
30
+ return false;
31
+ }
32
+ }
33
+
34
+ /** An artboard id the embed may ask the canvas to frame. Only ever compared for
35
+ * equality against `data-dc-screen`, so the bound is length + no controls. */
36
+ export function validArtboardId(raw) {
37
+ return (
38
+ typeof raw === 'string' &&
39
+ raw.length > 0 &&
40
+ raw.length <= 120 &&
41
+ ![...raw].some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127)
42
+ );
43
+ }
44
+
45
+ /**
46
+ * What the embed was asked to show. `open` is the validated design-root
47
+ * relative identity (share-link.js rules) or null; `requested` is what the
48
+ * embedder sent, echoed back in `not-found` so it can tell its own requests
49
+ * apart.
50
+ */
51
+ export function readEmbedParams(location, designRel = '.design') {
52
+ const params = new URLSearchParams(location?.search ?? '');
53
+ const values = params.getAll('open');
54
+ const artboard = params.get('artboard');
55
+ return {
56
+ open: readOpenParam(location, designRel),
57
+ requested: values.length === 1 ? values[0].slice(0, 512) : '',
58
+ artboard: validArtboardId(artboard) ? artboard : null,
59
+ };
60
+ }
61
+
62
+ /**
63
+ * The embedding page's origin. `ancestorOrigins` where the engine has it
64
+ * (Chromium, WebKit) — it cannot be influenced by the parent's referrer
65
+ * policy — else the referrer's origin (Firefox). Null when not framed at all.
66
+ */
67
+ export function parentOrigin(win) {
68
+ try {
69
+ if (!win || win.parent === win) return null;
70
+ const ancestors = win.location?.ancestorOrigins;
71
+ if (ancestors && ancestors.length > 0) return ancestors[0];
72
+ const referrer = win.document?.referrer;
73
+ return referrer ? new URL(referrer).origin : null;
74
+ } catch {
75
+ return null;
76
+ }
77
+ }
78
+
79
+ /** The exact origin to post to, or null — never '*', never an unlisted parent. */
80
+ export function embedTarget(origin, allowlist) {
81
+ if (typeof origin !== 'string' || !origin || origin === 'null') return null;
82
+ return Array.isArray(allowlist) && allowlist.includes(origin) ? origin : null;
83
+ }
84
+
85
+ export function embedMessage(type, open, title) {
86
+ const msg = { source: EMBED_SOURCE, v: EMBED_VERSION, type, open: String(open ?? '') };
87
+ if (typeof title === 'string' && title) msg.title = title;
88
+ return msg;
89
+ }
90
+
91
+ /** Post one contract message to the parent, if the parent may hear it. */
92
+ export function postToEmbedder(win, allowlist, type, open, title) {
93
+ const target = embedTarget(parentOrigin(win), allowlist);
94
+ if (!target) return false;
95
+ try {
96
+ win.parent.postMessage(embedMessage(type, open, title), target);
97
+ return true;
98
+ } catch {
99
+ return false;
100
+ }
101
+ }
@@ -31,6 +31,8 @@ const SCOPE_LABELS = {
31
31
  selection: 'Selection',
32
32
  artboard: 'Artboard',
33
33
  'canvas-as-separate': 'Canvas → separate',
34
+ 'canvas-whole': 'Whole canvas',
35
+ 'selection-bounds': 'Selection area',
34
36
  'project-raw': 'Project (raw)',
35
37
  };
36
38
 
@@ -155,17 +155,50 @@ export const saveExport = (filename, jobId) => invoke('save_export', { filename,
155
155
  /**
156
156
  * Native "open file" for media upload — the read counterpart to saveExport.
157
157
  * WKWebView won't present the file panel for an HTML <input type=file>, so the
158
- * AssetPicker uses this in the desktop app. Returns { name, bytes:[...] } or null
159
- * (cancelled). Browser build uses the <input type=file> path instead.
158
+ * AssetPicker uses this in the desktop app. Returns `{ token, name, size }` or
159
+ * null (cancelled) — never the bytes: read them with {@link pickedMediaSource}.
160
+ * Browser build uses the <input type=file> path instead.
160
161
  */
161
162
  export const pickMediaFile = () => invoke('pick_media_file');
162
163
 
163
164
  /**
164
165
  * feature-bulk-media-insert — multi-select counterpart to pickMediaFile.
165
- * Resolves to `[{name, bytes:[...]}, ...]` (empty array if cancelled).
166
+ * Resolves to `[{ token, name, size }, ...]` (empty array if cancelled).
166
167
  */
167
168
  export const pickMediaFiles = () => invoke('pick_media_files');
168
169
 
170
+ /**
171
+ * A picked file as an upload source (`asset-upload.ts` ChunkSource): bytes are
172
+ * read one slice at a time as a raw ArrayBuffer over IPC, so a 500 MB clip is
173
+ * never held whole in the page. Call `release()` when the upload is done.
174
+ */
175
+ export function pickedMediaSource(ref, type) {
176
+ return {
177
+ size: ref.size,
178
+ type: type || '',
179
+ name: ref.name,
180
+ async read(start, end) {
181
+ const buf = await invoke('read_picked_media', {
182
+ token: ref.token,
183
+ offset: start,
184
+ len: end - start,
185
+ });
186
+ return new Uint8Array(buf);
187
+ },
188
+ release: () => invoke('release_picked_media', { token: ref.token }).catch(() => {}),
189
+ };
190
+ }
191
+
192
+ /** A small picked file read whole (screenshots). Releases the pick. */
193
+ export async function readPickedMediaBlob(ref, type) {
194
+ const src = pickedMediaSource(ref, type);
195
+ try {
196
+ return new Blob([await src.read(0, ref.size)], type ? { type } : undefined);
197
+ } finally {
198
+ src.release();
199
+ }
200
+ }
201
+
169
202
  // ── Tauri shell: auto-update (Phase 32 / Task 1) ────────────────────────────────
170
203
  // The shell downloads + stages a newer build in the background and emits
171
204
  // `update-ready` with { version, notes }. The client shows a banner; clicking
@@ -14,7 +14,13 @@
14
14
 
15
15
  import React, { useCallback, useEffect, useRef, useState } from 'react';
16
16
 
17
- import { invoke, isNativeApp, openGitHubUrl, pickMediaFile } from './github.js';
17
+ import {
18
+ invoke,
19
+ isNativeApp,
20
+ openGitHubUrl,
21
+ pickMediaFile,
22
+ readPickedMediaBlob,
23
+ } from './github.js';
18
24
 
19
25
  // Two of these are auto-captured (window + artboard), so the ceiling leaves
20
26
  // room for the user to still attach their own.
@@ -207,7 +213,7 @@ export function ReportBugDialog({ open, onClose, activeCanvas = null }) {
207
213
  if (isNativeApp()) {
208
214
  try {
209
215
  const picked = await pickMediaFile();
210
- if (picked?.bytes) addShotBlob(new Blob([new Uint8Array(picked.bytes)]), 'attached');
216
+ if (picked) addShotBlob(await readPickedMediaBlob(picked), 'attached');
211
217
  } catch {
212
218
  /* cancelled or dialog failure — paste (⌘V) still works */
213
219
  }
@@ -226,6 +226,13 @@ export interface Context {
226
226
  * origin's `frame-ancestors`. Undefined in tests / before boot.
227
227
  */
228
228
  mainOrigin?: string;
229
+ /**
230
+ * DDR-247 — third-party apps allowed to FRAME the studio page (and so the
231
+ * canvas shell inside it) for the read-only `?embed=1` view, parsed from
232
+ * `MAUDE_EMBED_ORIGINS` by server.ts. Framing only: never a writer, never a
233
+ * shell. Undefined / empty = nobody but the shell origins.
234
+ */
235
+ embedOrigins?: string[];
229
236
  /**
230
237
  * Phase 9.2 (DDR-064) — `MAUDE_SHARED_DOC` feature flag. When true, the
231
238
  * collab room's Y.Doc becomes the SINGLE shared doc per canvas: the