@1agh/maude 1.7.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 (108) hide show
  1. package/apps/studio/acp/bridge.ts +15 -2
  2. package/apps/studio/acp/login-state.ts +1 -0
  3. package/apps/studio/acp/probe.ts +52 -1
  4. package/apps/studio/api.ts +431 -39
  5. package/apps/studio/asset-upload.ts +174 -0
  6. package/apps/studio/assets-s3.ts +37 -2
  7. package/apps/studio/bin/_curl-local.mjs +7 -0
  8. package/apps/studio/bin/_pdf-playwright.mjs +22 -1
  9. package/apps/studio/bin/_png-playwright.mjs +20 -1
  10. package/apps/studio/bin/_region.mjs +92 -0
  11. package/apps/studio/bin/annotate.mjs +16 -7
  12. package/apps/studio/bin/read-annotations.mjs +62 -4
  13. package/apps/studio/canvas-build.ts +59 -4
  14. package/apps/studio/canvas-lib.tsx +48 -1
  15. package/apps/studio/canvas-shell.tsx +28 -4
  16. package/apps/studio/client/app.jsx +441 -15903
  17. package/apps/studio/client/canvas-url.js +9 -0
  18. package/apps/studio/client/dialogs/asset-picker.jsx +331 -0
  19. package/apps/studio/client/dialogs/command-palette.jsx +112 -0
  20. package/apps/studio/client/dialogs/export-dialog.jsx +782 -0
  21. package/apps/studio/client/dialogs/help-modal.jsx +324 -0
  22. package/apps/studio/client/dialogs/shortcuts-overlay.jsx +144 -0
  23. package/apps/studio/client/embed-view.jsx +284 -0
  24. package/apps/studio/client/embed.js +101 -0
  25. package/apps/studio/client/export-center.jsx +2 -0
  26. package/apps/studio/client/github.js +36 -3
  27. package/apps/studio/client/hooks/use-canvas-bridge.jsx +2150 -0
  28. package/apps/studio/client/hooks/use-git-actions.jsx +236 -0
  29. package/apps/studio/client/hooks/use-keyboard-shortcuts.jsx +297 -0
  30. package/apps/studio/client/hooks/use-palette-and-panels.jsx +474 -0
  31. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +901 -0
  32. package/apps/studio/client/hooks/use-project-data.jsx +90 -0
  33. package/apps/studio/client/hooks/use-shell-core.jsx +1212 -0
  34. package/apps/studio/client/hooks/use-tabs.jsx +723 -0
  35. package/apps/studio/client/hooks/use-web-socket.jsx +13 -0
  36. package/apps/studio/client/inspector/artboard-knobs.jsx +456 -0
  37. package/apps/studio/client/inspector/color-picker.jsx +196 -0
  38. package/apps/studio/client/inspector/color.js +92 -0
  39. package/apps/studio/client/inspector/css-knobs.jsx +1720 -0
  40. package/apps/studio/client/inspector/css-vocab.jsx +131 -0
  41. package/apps/studio/client/inspector/ds-tokens.js +90 -0
  42. package/apps/studio/client/inspector/grid-tracks-editor.jsx +97 -0
  43. package/apps/studio/client/inspector/inspect-computed.jsx +68 -0
  44. package/apps/studio/client/inspector/inspector-panel.jsx +769 -0
  45. package/apps/studio/client/inspector/layers.jsx +322 -0
  46. package/apps/studio/client/inspector/selection.js +65 -0
  47. package/apps/studio/client/inspector/token-popover.jsx +301 -0
  48. package/apps/studio/client/menus/menubar.jsx +856 -0
  49. package/apps/studio/client/report-bug.jsx +8 -2
  50. package/apps/studio/client/selection-scope.js +40 -0
  51. package/apps/studio/client/shell/banners.jsx +272 -0
  52. package/apps/studio/client/shell/collapsed-rail.jsx +23 -0
  53. package/apps/studio/client/shell/comments-panel.jsx +177 -0
  54. package/apps/studio/client/shell/constants.js +60 -0
  55. package/apps/studio/client/shell/dock.jsx +131 -0
  56. package/apps/studio/client/shell/icons.jsx +370 -0
  57. package/apps/studio/client/shell/status-bar.jsx +215 -0
  58. package/apps/studio/client/shell/util.js +332 -0
  59. package/apps/studio/client/shell/viewport.jsx +254 -0
  60. package/apps/studio/client/system/system-view.jsx +255 -0
  61. package/apps/studio/client/tree/tree.jsx +1243 -0
  62. package/apps/studio/comments-overlay.tsx +6 -4
  63. package/apps/studio/config.schema.json +5 -0
  64. package/apps/studio/context.ts +20 -0
  65. package/apps/studio/dist/client.bundle.js +2728 -2728
  66. package/apps/studio/dist/comment-mount.js +2 -2
  67. package/apps/studio/embed-origins.ts +52 -0
  68. package/apps/studio/export-dialog.tsx +55 -3
  69. package/apps/studio/exporters/_browser-bundles.ts +21 -2
  70. package/apps/studio/exporters/format-scopes.ts +11 -3
  71. package/apps/studio/exporters/index.ts +17 -2
  72. package/apps/studio/exporters/jobs.ts +91 -23
  73. package/apps/studio/exporters/pdf.ts +10 -2
  74. package/apps/studio/exporters/png.ts +10 -2
  75. package/apps/studio/exporters/scope.ts +89 -15
  76. package/apps/studio/format.ts +296 -0
  77. package/apps/studio/generation/runtime-probe.ts +1 -1
  78. package/apps/studio/git/service.ts +1 -0
  79. package/apps/studio/http.ts +399 -36
  80. package/apps/studio/input-router.tsx +7 -1
  81. package/apps/studio/path-containment.ts +72 -0
  82. package/apps/studio/paths.ts +14 -1
  83. package/apps/studio/read-only-mode.ts +53 -0
  84. package/apps/studio/server.ts +123 -25
  85. package/apps/studio/sync/accepted-link.ts +6 -0
  86. package/apps/studio/sync/agent.ts +9 -1
  87. package/apps/studio/sync/cold-start-apply.ts +29 -4
  88. package/apps/studio/sync/cold-start.ts +78 -0
  89. package/apps/studio/sync/file-plane.ts +61 -1
  90. package/apps/studio/sync/format-sync.ts +160 -0
  91. package/apps/studio/sync/index.ts +208 -23
  92. package/apps/studio/sync/journal-client.ts +25 -5
  93. package/apps/studio/sync/migrate-seed.ts +8 -1
  94. package/apps/studio/sync/park.ts +39 -0
  95. package/apps/studio/sync/presentation.ts +9 -3
  96. package/apps/studio/sync/status.ts +2 -0
  97. package/apps/studio/sync/transaction-client.ts +130 -13
  98. package/apps/studio/sync/writer-registry.ts +5 -0
  99. package/apps/studio/ui-prefs.ts +95 -10
  100. package/apps/studio/use-canvas-media-drop.tsx +8 -28
  101. package/apps/studio/whats-new.json +36 -0
  102. package/apps/studio/ws.ts +19 -4
  103. package/cli/bin/claude-design-server.mjs +0 -0
  104. package/cli/commands/design.mjs +9 -2
  105. package/cli/commands/hub-workspace.mjs +25 -0
  106. package/cli/lib/workspace-plan.mjs +51 -0
  107. package/package.json +11 -9
  108. package/plugins/design/templates/_shell.html +58 -0
@@ -28,6 +28,8 @@ import path from 'node:path';
28
28
  import { canvasLibPath, canvasLibResolver } from './canvas-lib-resolver.ts';
29
29
  import { transpileCanvasSource } from './canvas-pipeline.ts';
30
30
  import type { LocatorMap } from './locator.ts';
31
+ import { isUnderOrEqual } from './path-containment.ts';
32
+ import { DEV_SERVER_ROOT } from './paths.ts';
31
33
  import { RUNTIME_PACKAGES } from './runtime-bundle.ts';
32
34
 
33
35
  // Sanity-check the dev-server-bundled canvas-lib once per process boot. If the
@@ -379,7 +381,47 @@ function importAllowlist(
379
381
  // value was not assignable at the one place it is used.
380
382
  ): import('bun').BunPlugin {
381
383
  const root = path.resolve(designRoot);
382
- const inRoot = (p: string) => p === root || p.startsWith(root + path.sep);
384
+ // Both spellings of every root: the bundler reports importers (and so every
385
+ // relative target) by REAL path, while callers pass the logical one. Comparing
386
+ // only the logical root made every canvas file behind a symlink — macOS
387
+ // `/var`, a symlinked `~/git`, a Windows `subst` drive or junction — look like
388
+ // one of OUR modules, exempt from the allowlist, so it could import any file
389
+ // on disk (security review of #145, attacker F1).
390
+ const bothForms = (p: string) => {
391
+ const abs = path.resolve(p);
392
+ try {
393
+ const real = realpathSync(abs);
394
+ return real === abs ? [abs] : [abs, real];
395
+ } catch {
396
+ return [abs];
397
+ }
398
+ };
399
+ const roots = bothForms(root);
400
+ // OUR code: canvas-lib and its siblings, plus the dependencies they import
401
+ // (`apps/studio/node_modules`, or hoisted one level up in the npm layout).
402
+ // Named explicitly — an importer that is neither ours nor the tenant's is
403
+ // refused, never presumed safe.
404
+ const ours = [
405
+ ...bothForms(DEV_SERVER_ROOT),
406
+ ...bothForms(path.join(DEV_SERVER_ROOT, '..', '..', 'node_modules')),
407
+ ];
408
+ const inRoot = (p: string) => roots.some((r) => isUnderOrEqual(p, r));
409
+ const realTarget = (p: string): string => {
410
+ let dir = p;
411
+ let rest = '';
412
+ for (;;) {
413
+ try {
414
+ const real = realpathSync(dir);
415
+ return rest ? path.join(real, rest) : real;
416
+ } catch {
417
+ const parent = path.dirname(dir);
418
+ if (parent === dir) return p;
419
+ rest = rest ? path.join(path.basename(dir), rest) : path.basename(dir);
420
+ dir = parent;
421
+ }
422
+ }
423
+ };
424
+ const isOurs = (p: string) => ours.some((r) => isUnderOrEqual(p, r));
383
425
  const deny = (specifier: string, reason: string): never => {
384
426
  denials.push({ specifier, reason });
385
427
  throw new Error(reason);
@@ -399,8 +441,17 @@ function importAllowlist(
399
441
  // schemes that go to the NETWORK; these never do.
400
442
  if (/^(data|blob):/i.test(args.path)) return { path: args.path, external: true };
401
443
  const importer = args.importer ? path.resolve(args.importer) : '';
402
- // Our own modules (canvas-lib and its graph) resolve normally.
403
- if (importer && !inRoot(importer)) return null;
444
+ // Our own modules (canvas-lib and its graph) resolve normally. The
445
+ // design root is checked FIRST: it may itself sit inside our tree (this
446
+ // repo's own `.design/`), and then the tenant's rules must still apply.
447
+ if (importer && !inRoot(importer)) {
448
+ if (isOurs(importer)) return null;
449
+ deny(
450
+ args.path,
451
+ `"${args.path}" is imported from ${importer}, which is outside the project. ` +
452
+ `A canvas may only import files inside its own design.`
453
+ );
454
+ }
404
455
  if (!args.path.startsWith('.') && !path.isAbsolute(args.path)) {
405
456
  deny(
406
457
  args.path,
@@ -411,7 +462,11 @@ function importAllowlist(
411
462
  );
412
463
  }
413
464
  const resolved = path.resolve(path.dirname(importer || root), args.path);
414
- if (!inRoot(resolved)) {
465
+ // Where the bytes really are: a symlink INSIDE the design root (file or
466
+ // directory) still points wherever it points. The nearest existing
467
+ // ancestor is resolved, so `./dirlink/secret` and an extensionless
468
+ // specifier through a linked folder are both judged by their real home.
469
+ if (!inRoot(resolved) || !inRoot(realTarget(resolved))) {
415
470
  deny(
416
471
  args.path,
417
472
  `This canvas imports "${args.path}", which is outside the project (${path.relative(root, resolved)}). ` +
@@ -139,7 +139,7 @@ import {
139
139
  // (photo/pipeline.ts, which imports pixi.js) is loaded via a DYNAMIC import
140
140
  // inside <PhotoLayer> only when an edited photo actually mounts — see there.
141
141
  import { isDefaultEdit, type PhotoEdit } from './photo/schema.ts';
142
- import { isReadOnlyCanvas } from './read-only-mode.ts';
142
+ import { isEmbedCanvas, isReadOnlyCanvas } from './read-only-mode.ts';
143
143
  import { AgentPresenceProvider, useAgentPresence } from './use-agent-presence.tsx';
144
144
  import { type DragState, useArtboardDrag } from './use-artboard-drag.tsx';
145
145
  import {
@@ -828,6 +828,10 @@ function patchCanvasMeta(patch: {
828
828
  layout?: { artboards: ArtboardRect[] };
829
829
  }): void {
830
830
  if (typeof window === 'undefined' || typeof fetch === 'undefined') return;
831
+ // DDR-247 — an embedded view persists nothing, camera included: its fit is
832
+ // not the designer's view, and the next time they open the canvas in the
833
+ // studio it must be where they left it.
834
+ if (isEmbedCanvas()) return;
831
835
  // Cloud Phase 25 C2 — a read-only session persists its CAMERA (per-user
832
836
  // `_canvas-state/` view, DDR-115) but never the LAYOUT lane (versioned
833
837
  // `.meta.json`). The dev-server refuses the layout lane too (http.ts);
@@ -1429,6 +1433,10 @@ export function useViewportController(opts: ViewportControllerOptions): Viewport
1429
1433
  // iframe's contentWindow so the window-scoped keydown listener below
1430
1434
  // receives events natively.
1431
1435
  const onPointerEnter = () => {
1436
+ // DDR-247 — an embed never takes focus on its own: a pointer merely
1437
+ // passing over it inside another app's dialog would pull keyboard focus
1438
+ // out of that app and strand its Escape. A click still focuses it.
1439
+ if (isEmbedCanvas()) return;
1432
1440
  try {
1433
1441
  const active = document.activeElement as HTMLElement | null;
1434
1442
  // Never steal focus from something being TYPED into. An editor that
@@ -1945,9 +1953,48 @@ function useExportCaptureBridge() {
1945
1953
  }, []);
1946
1954
  }
1947
1955
 
1956
+ // Issue #125 — the shell's "Selection area" export needs EVERYTHING selected:
1957
+ // canvas elements (the selection set — the shell only tracks one) AND
1958
+ // annotation elements (a separate selection, never reported to the shell).
1959
+ // The shell asks right before submitting; we answer with one selector per item.
1960
+ function useExportSelectionBridge() {
1961
+ const selSet = useSelectionSetOptional();
1962
+ const selRef = useRef(selSet);
1963
+ selRef.current = selSet;
1964
+ useEffect(() => {
1965
+ if (typeof window === 'undefined' || window.parent === window) return;
1966
+ const onMsg = (e: MessageEvent) => {
1967
+ if (e.source !== window.parent) return;
1968
+ const m = e.data as { dgn?: string; id?: unknown } | null;
1969
+ if (m?.dgn !== 'export-selection-query' || typeof m.id !== 'string') return;
1970
+ const selectors: string[] = [];
1971
+ for (const it of selRef.current?.selected ?? []) {
1972
+ if (it?.selector) selectors.push(it.selector);
1973
+ }
1974
+ const annotIds = (
1975
+ document.querySelector('.dc-annot-svg')?.getAttribute('data-selection') ?? ''
1976
+ )
1977
+ .split(/\s+/)
1978
+ .filter(Boolean);
1979
+ for (const id of annotIds) {
1980
+ selectors.push(`[data-mdcc-annotations] [data-id="${id.replace(/["\\]/g, '\\$&')}"]`);
1981
+ }
1982
+ const replyOrigin = e.origin && e.origin !== 'null' ? e.origin : '*';
1983
+ try {
1984
+ window.parent.postMessage({ dgn: 'export-selection', id: m.id, selectors }, replyOrigin);
1985
+ } catch {
1986
+ /* parent gone */
1987
+ }
1988
+ };
1989
+ window.addEventListener('message', onMsg);
1990
+ return () => window.removeEventListener('message', onMsg);
1991
+ }, []);
1992
+ }
1993
+
1948
1994
  function DesignCanvasInner({ children, controls }: DesignCanvasProps) {
1949
1995
  ensureEngineStyles();
1950
1996
  useExportCaptureBridge();
1997
+ useExportSelectionBridge();
1951
1998
 
1952
1999
  const hostRef = useRef<HTMLDivElement | null>(null);
1953
2000
  const worldRef = useRef<HTMLDivElement | null>(null);
@@ -87,7 +87,7 @@ import {
87
87
  import { ElementMarqueeOverlay } from './marquee-overlay.tsx';
88
88
  import { MeasureOverlay } from './measure-overlay.tsx';
89
89
  import { ParticipantsChrome } from './participants-chrome.tsx';
90
- import { isReadOnlyCanvas } from './read-only-mode.ts';
90
+ import { installEmbedEscapeRelay, isEmbedCanvas, isReadOnlyCanvas } from './read-only-mode.ts';
91
91
  import { mountCaret, placeCaretAt } from './text-caret.ts';
92
92
  import { ToolPalette } from './tool-palette.tsx';
93
93
  import { UndoHud } from './undo-hud.tsx';
@@ -1179,6 +1179,13 @@ function watchStylesheetsOnce(): void {
1179
1179
  }
1180
1180
  }
1181
1181
 
1182
+ /** Test seam: forget the cached answer — the module outlives a test file. */
1183
+ export function __resetDsThemeProbeForTests(): void {
1184
+ _dsThemeSupport = null;
1185
+ _dsThemeUnsupported = false;
1186
+ _dsThemeWatch = false; // its observer watched the previous file's document
1187
+ }
1188
+
1182
1189
  export function detectDsThemeSupport(): DsThemeSupport {
1183
1190
  if (_dsThemeSupport) return _dsThemeSupport;
1184
1191
  if (_dsThemeUnsupported) return _unsupported;
@@ -3017,6 +3024,17 @@ function CanvasRouter({
3017
3024
  else if (op === 'out') zoomController.zoomOut();
3018
3025
  else if (op === 'fit') zoomController.fit();
3019
3026
  else if (op === 'actual') zoomController.reset();
3027
+ else if (op === 'artboard') {
3028
+ // DDR-247 — the embed view's `&artboard=<id>`: frame one artboard,
3029
+ // found by its `data-dc-screen` id through the same world-coordinate
3030
+ // manifest the whiteboard toolkit reads. Unknown id ⇒ nothing moves.
3031
+ const id = (m as { id?: unknown }).id;
3032
+ const rect =
3033
+ typeof id === 'string'
3034
+ ? window.__maudeCanvasRects?.().artboards.find((a) => a.id === id)
3035
+ : undefined;
3036
+ if (rect) zoomController.jumpTo(rect);
3037
+ }
3020
3038
  return;
3021
3039
  }
3022
3040
  // Shell View-menu chrome toggles + Presentation Mode. Only the fields the
@@ -3481,9 +3499,12 @@ function CanvasRouter({
3481
3499
  <SnapGuideOverlay />
3482
3500
  <PhotoPreviewBridge />
3483
3501
  <UndoHud />
3484
- <CursorsOverlay />
3485
- <AiBanner />
3486
- <ParticipantsChrome />
3502
+ {/* DDR-247 — an embed inside another app shows the design, not who
3503
+ else is in the room: collaborator cursors, the AI banner and the
3504
+ avatar stack are studio chrome. */}
3505
+ {!isEmbedCanvas() && <CursorsOverlay />}
3506
+ {!isEmbedCanvas() && <AiBanner />}
3507
+ {!isEmbedCanvas() && <ParticipantsChrome />}
3487
3508
  </>
3488
3509
  );
3489
3510
  }
@@ -4618,3 +4639,6 @@ function classifyContextKind(target: HoverTarget | null): ContextTargetKind {
4618
4639
  if (target.artboardId) return 'artboard-chrome';
4619
4640
  return 'world';
4620
4641
  }
4642
+
4643
+ // DDR-247 — an embedded canvas hands an unconsumed Escape to the app around it.
4644
+ if (typeof window !== 'undefined') installEmbedEscapeRelay();