@1agh/maude 0.40.0 → 0.42.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 (102) hide show
  1. package/apps/studio/ai-banner.tsx +2 -2
  2. package/apps/studio/annotations-layer.tsx +53 -2
  3. package/apps/studio/api.ts +504 -44
  4. package/apps/studio/artboard-marquee.tsx +1 -1
  5. package/apps/studio/bin/_canvas-rects-playwright.mjs +55 -0
  6. package/apps/studio/bin/_canvas-rects-static.mjs +166 -0
  7. package/apps/studio/bin/_fetch-asset.mjs +556 -0
  8. package/apps/studio/bin/_html-playwright.mjs +26 -4
  9. package/apps/studio/bin/_pdf-playwright.mjs +13 -2
  10. package/apps/studio/bin/_png-playwright.mjs +15 -2
  11. package/apps/studio/bin/_pptx-playwright.mjs +17 -4
  12. package/apps/studio/bin/_screenshot-playwright.mjs +17 -2
  13. package/apps/studio/bin/_svg-playwright.mjs +26 -4
  14. package/apps/studio/bin/annotate.mjs +576 -34
  15. package/apps/studio/bin/canvas-rects.sh +152 -0
  16. package/apps/studio/bin/fetch-asset.sh +34 -0
  17. package/apps/studio/bin/read-annotations.mjs +138 -7
  18. package/apps/studio/bin/screenshot.sh +53 -4
  19. package/apps/studio/bin/smoke.sh +42 -6
  20. package/apps/studio/build.ts +21 -0
  21. package/apps/studio/canvas-comment-mount.tsx +138 -4
  22. package/apps/studio/canvas-edit.ts +744 -11
  23. package/apps/studio/canvas-lib.tsx +219 -2
  24. package/apps/studio/canvas-shell.tsx +487 -20
  25. package/apps/studio/client/app.jsx +1476 -76
  26. package/apps/studio/client/comments-overlay.css +130 -126
  27. package/apps/studio/client/export-center.jsx +426 -0
  28. package/apps/studio/client/github.js +8 -0
  29. package/apps/studio/client/styles/3-shell-maude.css +65 -0
  30. package/apps/studio/client/styles/4-components.css +150 -0
  31. package/apps/studio/comments-overlay.tsx +148 -41
  32. package/apps/studio/config.schema.json +2 -2
  33. package/apps/studio/context-menu.tsx +15 -5
  34. package/apps/studio/contextual-toolbar.tsx +262 -4
  35. package/apps/studio/cursors-overlay.tsx +4 -4
  36. package/apps/studio/dist/client.bundle.js +20 -20
  37. package/apps/studio/dist/comment-mount.js +59 -1
  38. package/apps/studio/dist/styles.css +1 -1
  39. package/apps/studio/dom-selection.ts +127 -1
  40. package/apps/studio/drag-state.ts +24 -0
  41. package/apps/studio/equal-spacing-detector.ts +205 -0
  42. package/apps/studio/export-dialog.tsx +19 -26
  43. package/apps/studio/exporters/_runtime.ts +104 -0
  44. package/apps/studio/exporters/html.ts +12 -20
  45. package/apps/studio/exporters/index.ts +14 -2
  46. package/apps/studio/exporters/jobs.ts +334 -0
  47. package/apps/studio/exporters/pdf.ts +16 -20
  48. package/apps/studio/exporters/png.ts +12 -20
  49. package/apps/studio/exporters/pptx.ts +22 -23
  50. package/apps/studio/exporters/scope.ts +1 -0
  51. package/apps/studio/exporters/svg.ts +14 -22
  52. package/apps/studio/exporters/video.ts +15 -17
  53. package/apps/studio/git/service.ts +3 -1
  54. package/apps/studio/history.ts +47 -1
  55. package/apps/studio/http.ts +368 -50
  56. package/apps/studio/input-router.tsx +12 -0
  57. package/apps/studio/marquee-overlay.tsx +1 -1
  58. package/apps/studio/measure-overlay.tsx +241 -0
  59. package/apps/studio/participants-chrome.tsx +3 -3
  60. package/apps/studio/server.ts +3 -1
  61. package/apps/studio/sizing-mode.ts +117 -0
  62. package/apps/studio/spacing-handles.ts +166 -0
  63. package/apps/studio/test/annotate-write.test.ts +890 -0
  64. package/apps/studio/test/camera-reveal.test.tsx +173 -0
  65. package/apps/studio/test/canvas-edit.test.ts +50 -0
  66. package/apps/studio/test/canvas-origin-gate.test.ts +24 -0
  67. package/apps/studio/test/canvas-rects.test.ts +198 -0
  68. package/apps/studio/test/comments-overlay.test.ts +117 -0
  69. package/apps/studio/test/dns-rebinding-guard.test.ts +27 -0
  70. package/apps/studio/test/dom-selection.test.ts +130 -0
  71. package/apps/studio/test/edit-css-occurrence.test.ts +81 -0
  72. package/apps/studio/test/edit-scope-api.test.ts +115 -0
  73. package/apps/studio/test/element-resize.test.ts +136 -0
  74. package/apps/studio/test/element-structural-api.test.ts +360 -0
  75. package/apps/studio/test/element-structural-edit.test.ts +233 -0
  76. package/apps/studio/test/equal-spacing-detector.test.ts +165 -1
  77. package/apps/studio/test/export-center.test.tsx +287 -0
  78. package/apps/studio/test/export-shim-multi-capture.test.ts +83 -0
  79. package/apps/studio/test/exporters/history.test.ts +32 -3
  80. package/apps/studio/test/exporters/jobs.test.ts +263 -0
  81. package/apps/studio/test/history-rollback.test.ts +26 -0
  82. package/apps/studio/test/knob-props-authored.test.ts +87 -0
  83. package/apps/studio/test/read-annotations.test.ts +154 -0
  84. package/apps/studio/test/sizing-mode.test.ts +102 -0
  85. package/apps/studio/test/spacing-handles.test.ts +138 -0
  86. package/apps/studio/test/specimen-select.test.ts +88 -0
  87. package/apps/studio/test/tool-palette-insert-anchor.test.ts +84 -0
  88. package/apps/studio/test/undo-sequence-byte-compare.test.ts +211 -0
  89. package/apps/studio/tool-palette.tsx +122 -2
  90. package/apps/studio/undo-hud.tsx +2 -2
  91. package/apps/studio/use-element-resize.tsx +732 -0
  92. package/apps/studio/use-keyboard-discipline.tsx +205 -15
  93. package/apps/studio/use-selection-set.tsx +14 -0
  94. package/apps/studio/use-spacing-handles.tsx +388 -0
  95. package/apps/studio/whats-new.json +45 -0
  96. package/apps/studio/ws.ts +6 -0
  97. package/cli/commands/design.mjs +6 -1
  98. package/cli/commands/design.test.mjs +49 -1
  99. package/cli/lib/fetch-asset.test.mjs +213 -0
  100. package/cli/lib/gitignore-block.mjs +1 -0
  101. package/package.json +8 -8
  102. package/plugins/design/dependencies.json +10 -2
@@ -48,10 +48,6 @@ try {
48
48
  world.style.zoom = '1';
49
49
  world.style.transform = 'none';
50
50
  }
51
- for (const el of document.querySelectorAll('[data-dc-screen]')) {
52
- el.style.left = '0px';
53
- el.style.top = '0px';
54
- }
55
51
  });
56
52
  // dom-to-pptx ships a UMD bundle; addScriptTag exposes `window.domToPptx`.
57
53
  await page.addScriptTag({ path: bundlePath });
@@ -74,6 +70,17 @@ try {
74
70
  }
75
71
  await handle.waitFor({ state: 'visible', timeout: timeoutMs });
76
72
 
73
+ // Pin this artboard to (0,0) for its capture, restoring afterwards so a
74
+ // future multi-slide implementation doesn't inherit a stacked-at-origin bug
75
+ // (the scatter bug fixed in the png/pdf/svg/html shims).
76
+ const savedPos = await handle.evaluate((el) => {
77
+ const ab = el.closest('[data-dc-screen]') ?? el;
78
+ const prev = { left: ab.style.left, top: ab.style.top };
79
+ ab.style.left = '0px';
80
+ ab.style.top = '0px';
81
+ return prev;
82
+ });
83
+
77
84
  // Run dom-to-pptx inside the page. It returns a Blob; we serialise to a
78
85
  // byte array for transport across the playwright boundary.
79
86
  const bytesArray = await handle.evaluate(async (el) => {
@@ -88,6 +95,12 @@ try {
88
95
  return Array.from(new Uint8Array(ab));
89
96
  });
90
97
 
98
+ await handle.evaluate((el, prev) => {
99
+ const ab = el.closest('[data-dc-screen]') ?? el;
100
+ ab.style.left = prev.left;
101
+ ab.style.top = prev.top;
102
+ }, savedPos);
103
+
91
104
  writeFileSync(out, new Uint8Array(bytesArray));
92
105
  console.log(out);
93
106
  console.error(
@@ -5,7 +5,7 @@
5
5
  //
6
6
  // Invocation (called by screenshot.sh — not directly by users):
7
7
  // npm exec --package=playwright -- node _screenshot-playwright.mjs \
8
- // --url <url> [--selector <css>] --out <path> [--timeout 8]
8
+ // --url <url> [--selector <css>] --out <path> [--timeout 8] [--theme <name>]
9
9
  //
10
10
  // First invocation may install chromium (~150 MB). Subsequent runs reuse cache.
11
11
 
@@ -20,7 +20,7 @@ const args = Object.fromEntries(
20
20
  }, [])
21
21
  );
22
22
 
23
- const { url, selector, out, timeout = '8' } = args;
23
+ const { url, selector, out, timeout = '8', theme } = args;
24
24
  if (!url || !out) {
25
25
  console.error(
26
26
  'usage: _screenshot-playwright.mjs --url <url> [--selector <css>] --out <path> [--timeout 8]'
@@ -37,6 +37,21 @@ try {
37
37
  const page = await ctx.newPage();
38
38
  await page.goto(url, { waitUntil: 'networkidle', timeout: timeoutMs });
39
39
 
40
+ if (theme) {
41
+ // Dual-theme reality check (/design:new step 9): force every DS artboard
42
+ // theme wrapper to `theme` before capture, deterministically, instead of
43
+ // relying on whatever the canvas is pinned to. No-op if the canvas has no
44
+ // `[data-theme]` elements (e.g. a single-theme DS).
45
+ const n = await page.evaluate((t) => {
46
+ const els = document.querySelectorAll('[data-theme]');
47
+ els.forEach((el) => {
48
+ el.setAttribute('data-theme', t);
49
+ });
50
+ return els.length;
51
+ }, theme);
52
+ console.error(`→ theme override: forced data-theme="${theme}" on ${n} element(s)`);
53
+ }
54
+
40
55
  if (selector) {
41
56
  const loc = page.locator(selector).first();
42
57
  await loc.waitFor({ state: 'visible', timeout: timeoutMs });
@@ -70,10 +70,6 @@ try {
70
70
  world.style.zoom = '1';
71
71
  world.style.transform = 'none';
72
72
  }
73
- for (const el of document.querySelectorAll('[data-dc-screen]')) {
74
- el.style.left = '0px';
75
- el.style.top = '0px';
76
- }
77
73
  });
78
74
  // Inject dom-to-svg into the page. Bundle attaches its exports under
79
75
  // `window.domToSvg`.
@@ -81,6 +77,27 @@ try {
81
77
 
82
78
  const written = [];
83
79
 
80
+ // Pin one artboard to (0,0) for its capture, returning a restore function.
81
+ // Per-target rather than a one-shot reset of every `[data-dc-screen]` — a
82
+ // multi-target loop must not leave an already-captured artboard sitting at
83
+ // the origin, overlapping the next target's geometry (the scatter bug).
84
+ const pinArtboard = async (handle) => {
85
+ const saved = await handle.evaluate((el) => {
86
+ const ab = el.closest('[data-dc-screen]') ?? el;
87
+ const prev = { left: ab.style.left, top: ab.style.top };
88
+ ab.style.left = '0px';
89
+ ab.style.top = '0px';
90
+ return prev;
91
+ });
92
+ return async () => {
93
+ await handle.evaluate((el, prev) => {
94
+ const ab = el.closest('[data-dc-screen]') ?? el;
95
+ ab.style.left = prev.left;
96
+ ab.style.top = prev.top;
97
+ }, saved);
98
+ };
99
+ };
100
+
84
101
  // Single in-page serializer used by BOTH branches (single + multi) so they
85
102
  // can't drift again (the `formatXML` 500 bug came from a divergent copy).
86
103
  // Note: dom-to-svg exports only elementToSVG / inlineResources /
@@ -228,11 +245,14 @@ try {
228
245
  for (let i = 0; i < screens.length; i += 1) {
229
246
  const handle = screens[i];
230
247
  const id = (await handle.getAttribute('data-dc-screen')) ?? `artboard-${i + 1}`;
248
+ const restore = await pinArtboard(handle);
231
249
  // Each multi handle is already a `[data-dc-screen]` artboard — no widen.
232
250
  const svg = await serializeOne(handle, false);
251
+ await restore();
233
252
  const target = join(outDir, `${id}.svg`);
234
253
  writeFileSync(target, svg, 'utf8');
235
254
  written.push(target);
255
+ console.log(`MAUDE_PROGRESS {"current":${i + 1},"total":${screens.length}}`);
236
256
  }
237
257
  } else {
238
258
  if (!out) {
@@ -242,7 +262,9 @@ try {
242
262
  mkdirSync(dirname(out), { recursive: true });
243
263
  const handle = page.locator(selector ?? '[data-dc-screen]:first-of-type').first();
244
264
  await handle.waitFor({ state: 'visible', timeout: timeoutMs });
265
+ const restore = await pinArtboard(handle);
245
266
  const svg = await serializeOne(handle, widen);
267
+ await restore();
246
268
  writeFileSync(out, svg, 'utf8');
247
269
  written.push(out);
248
270
  }