@1agh/maude 2.0.6 → 2.0.8

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 (177) hide show
  1. package/apps/studio/access/closure.ts +156 -16
  2. package/apps/studio/access/filters.ts +27 -0
  3. package/apps/studio/actions/agents.ts +54 -0
  4. package/apps/studio/actions/ctx.ts +3 -0
  5. package/apps/studio/actions/defs/sync.ts +13 -0
  6. package/apps/studio/actions/defs/view.ts +59 -3
  7. package/apps/studio/actions/keymap.gen.ts +35 -0
  8. package/apps/studio/actions/menu.ts +2 -0
  9. package/apps/studio/actions/types.ts +3 -1
  10. package/apps/studio/actions.manifest.json +136 -1
  11. package/apps/studio/actions.parity.json +25 -1
  12. package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
  13. package/apps/studio/annotations/ui/ride.ts +2 -1
  14. package/apps/studio/annotations-context-toolbar.tsx +5 -4
  15. package/apps/studio/annotations-layer.tsx +4 -3
  16. package/apps/studio/api.ts +383 -128
  17. package/apps/studio/artboard-activity-overlay.tsx +4 -4
  18. package/apps/studio/artboard-ai-copies.tsx +4 -4
  19. package/apps/studio/artboard-freeze.ts +108 -0
  20. package/apps/studio/artboard-live-gate.tsx +414 -45
  21. package/apps/studio/artboard-live.ts +526 -31
  22. package/apps/studio/artboard-placeholder.ts +197 -0
  23. package/apps/studio/artboard-still-raster.ts +485 -0
  24. package/apps/studio/artboard-still-warmup.ts +221 -0
  25. package/apps/studio/artboard-still.ts +1188 -0
  26. package/apps/studio/artboard-webgl.ts +2 -1
  27. package/apps/studio/asset-placeholder.tsx +237 -132
  28. package/apps/studio/asset-upload-bars.tsx +4 -4
  29. package/apps/studio/bin/_perf-probe-open.mjs +364 -0
  30. package/apps/studio/bin/_perf-shared.mjs +12 -7
  31. package/apps/studio/bin/_pw-launch.mjs +26 -1
  32. package/apps/studio/bin/perf.sh +19 -0
  33. package/apps/studio/bridge/dgn-protocol.ts +35 -0
  34. package/apps/studio/canvas-build-sandbox.ts +69 -13
  35. package/apps/studio/canvas-camera.ts +90 -0
  36. package/apps/studio/canvas-comment-mount.tsx +9 -9
  37. package/apps/studio/canvas-lib.tsx +160 -34
  38. package/apps/studio/canvas-pages-view.tsx +465 -0
  39. package/apps/studio/canvas-pages.ts +305 -0
  40. package/apps/studio/canvas-rows.ts +62 -0
  41. package/apps/studio/canvas-shell.tsx +62 -16
  42. package/apps/studio/canvas-theme-icons.tsx +41 -0
  43. package/apps/studio/canvas-theme-pill.tsx +15 -6
  44. package/apps/studio/canvas-theme.ts +12 -11
  45. package/apps/studio/client/app.jsx +7 -0
  46. package/apps/studio/client/canvas-url.js +23 -1
  47. package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
  48. package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
  49. package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
  50. package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
  51. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
  52. package/apps/studio/client/hooks/use-project-data.jsx +11 -2
  53. package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
  54. package/apps/studio/client/index-loader.ts +41 -21
  55. package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
  56. package/apps/studio/client/shell/viewport.jsx +32 -16
  57. package/apps/studio/client/tree/tree.jsx +17 -0
  58. package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
  59. package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
  60. package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
  61. package/apps/studio/client/v2/code/canvas-imports-card.jsx +7 -3
  62. package/apps/studio/client/v2/code/canvas-imports-words.js +16 -0
  63. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
  64. package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
  65. package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
  66. package/apps/studio/client/v2/code/code-consent.js +67 -0
  67. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
  68. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
  69. package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
  70. package/apps/studio/client/v2/layers/layers-request.js +49 -0
  71. package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
  72. package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
  73. package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
  74. package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
  75. package/apps/studio/client/v2/shell/canvas-crash-guard.js +40 -5
  76. package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
  77. package/apps/studio/client/v2/shell/floating-panels.css +37 -1
  78. package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
  79. package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
  80. package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
  81. package/apps/studio/client/v2/shell/pages-pick.js +49 -0
  82. package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
  83. package/apps/studio/client/v2/shell/share-cluster-host.jsx +3 -1
  84. package/apps/studio/client/v2/shell/shell-parity.json +8 -0
  85. package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
  86. package/apps/studio/comments-overlay.tsx +12 -11
  87. package/apps/studio/config-reload-wire.ts +4 -1
  88. package/apps/studio/config.schema.json +6 -0
  89. package/apps/studio/context.ts +37 -1
  90. package/apps/studio/dist/client.bundle.js +720 -720
  91. package/apps/studio/dist/comment-mount.js +2 -2
  92. package/apps/studio/dist/styles.css +1 -1
  93. package/apps/studio/ds/board/board.css +6 -0
  94. package/apps/studio/ds/board/ds-bar.tsx +21 -3
  95. package/apps/studio/ds/board/specimen.tsx +6 -3
  96. package/apps/studio/ds/board/template.ts +39 -19
  97. package/apps/studio/ds/cli.ts +7 -1
  98. package/apps/studio/ds/component-list.ts +2 -1
  99. package/apps/studio/ds/default.ts +6 -1
  100. package/apps/studio/ds/ds-resolver.ts +58 -8
  101. package/apps/studio/ds/engine.ts +3 -1
  102. package/apps/studio/ds/folder-systems.ts +199 -0
  103. package/apps/studio/ds/pairing-css.ts +2 -1
  104. package/apps/studio/ds/rename.ts +10 -3
  105. package/apps/studio/ds/shell-fallbacks.ts +2 -1
  106. package/apps/studio/ds/upgrade-stage.ts +6 -2
  107. package/apps/studio/editing/ai-point-ring.tsx +4 -4
  108. package/apps/studio/editing/ai-scope-outline.tsx +4 -4
  109. package/apps/studio/editing/align-bar.tsx +4 -4
  110. package/apps/studio/editing/anchor-report.ts +3 -2
  111. package/apps/studio/editing/artboard-handles.tsx +4 -4
  112. package/apps/studio/editing/corner-dots.tsx +4 -4
  113. package/apps/studio/editing/crop-mode.tsx +4 -4
  114. package/apps/studio/editing/drop-chip.tsx +4 -4
  115. package/apps/studio/editing/empty-report.ts +3 -2
  116. package/apps/studio/editing/focus-model.tsx +4 -4
  117. package/apps/studio/editing/gap-bands.tsx +3 -3
  118. package/apps/studio/editing/hold-rings.tsx +4 -4
  119. package/apps/studio/editing/lock-badge.tsx +3 -3
  120. package/apps/studio/editing/long-page.ts +23 -1
  121. package/apps/studio/editing/nudge.tsx +2 -2
  122. package/apps/studio/editing/page-activity.ts +4 -3
  123. package/apps/studio/editing/paste-bar.tsx +4 -4
  124. package/apps/studio/editing/pen/overlay.tsx +4 -3
  125. package/apps/studio/editing/place-freely.tsx +3 -3
  126. package/apps/studio/editing/reorder-slot.tsx +3 -3
  127. package/apps/studio/editing/selection.tsx +4 -4
  128. package/apps/studio/editing/size-ghost.tsx +4 -4
  129. package/apps/studio/editing/tab-order.tsx +4 -4
  130. package/apps/studio/editing/text-in-place.tsx +4 -4
  131. package/apps/studio/editing/undo-preview.tsx +3 -3
  132. package/apps/studio/equal-spacing-handles.tsx +3 -3
  133. package/apps/studio/frame-clock.ts +89 -0
  134. package/apps/studio/http.ts +66 -32
  135. package/apps/studio/index/ds-usage.ts +4 -1
  136. package/apps/studio/index-cache.ts +272 -0
  137. package/apps/studio/inspect-overlay.tsx +4 -3
  138. package/apps/studio/inspect.ts +7 -2
  139. package/apps/studio/link-chip-overlay.tsx +4 -3
  140. package/apps/studio/measure-overlay.tsx +4 -3
  141. package/apps/studio/present/pointer-dot.tsx +3 -2
  142. package/apps/studio/present/present-media.ts +6 -2
  143. package/apps/studio/present/present-stage.tsx +3 -2
  144. package/apps/studio/preview/preview-camera.tsx +3 -2
  145. package/apps/studio/routes/sync.ts +176 -0
  146. package/apps/studio/safe-zones-overlay.tsx +3 -2
  147. package/apps/studio/skip-dirs.ts +103 -47
  148. package/apps/studio/studio-page-host.ts +70 -0
  149. package/apps/studio/sync/code-module-consent.ts +86 -0
  150. package/apps/studio/sync/file-ledger.ts +24 -0
  151. package/apps/studio/sync/file-plane.ts +458 -53
  152. package/apps/studio/sync/held-deletes.ts +230 -0
  153. package/apps/studio/sync/hubs-config.ts +59 -2
  154. package/apps/studio/sync/index.ts +99 -15
  155. package/apps/studio/sync/seed-progress.ts +92 -2
  156. package/apps/studio/sync/settings.ts +36 -1
  157. package/apps/studio/sync/status.ts +15 -1
  158. package/apps/studio/sync/writer-registry.ts +5 -0
  159. package/apps/studio/text-caret.ts +5 -3
  160. package/apps/studio/toolbars/toolbar-rect.ts +3 -2
  161. package/apps/studio/use-annotation-resize.tsx +4 -3
  162. package/apps/studio/use-artboard-drag.tsx +3 -2
  163. package/apps/studio/use-element-resize.tsx +7 -6
  164. package/apps/studio/use-grid-track-handles.tsx +5 -4
  165. package/apps/studio/use-selection-set.tsx +64 -4
  166. package/apps/studio/use-spacing-handles.tsx +7 -6
  167. package/apps/studio/video-comp.tsx +55 -42
  168. package/apps/studio/video-play-overlay.tsx +4 -3
  169. package/apps/studio/whats-new.json +27 -0
  170. package/cli/commands/design.mjs +5 -2
  171. package/cli/commands/hub.mjs +10 -1
  172. package/cli/lib/bash-guard.mjs +14 -0
  173. package/cli/lib/design-help.gen.mjs +1 -1
  174. package/cli/lib/design-link.mjs +42 -17
  175. package/cli/lib/hub-purge.mjs +183 -0
  176. package/package.json +8 -8
  177. package/plugins/design/templates/_shell.html +164 -1
@@ -33,6 +33,7 @@ import { isRuntimeStateRel } from '../sync/file-membership.ts';
33
33
  import { canvasContext } from './canvas-cli.ts';
34
34
  import { checkSystem } from './check.ts';
35
35
  import { emitTokensJson } from './emit.ts';
36
+ import { adoptFolderSystem } from './folder-systems.ts';
36
37
  import { indexRegistry, loadRegistry } from './registry.ts';
37
38
  import { diskFs, loadSystem, type SystemConfig, systemConfigsFrom } from './system.ts';
38
39
  import {
@@ -286,14 +287,17 @@ export function stageUpgrade(inp: StageInput): StageResult {
286
287
  const conformantAfter = report.reasons.length === 0;
287
288
  if (conformantAfter) {
288
289
  const liveConfig = readJson(join(inp.designRoot, 'config.json'));
289
- const list = liveConfig.designSystems as Record<string, unknown>[];
290
+ // 2.0.7 — a folder-owned system gets its schema flag on its adopted entry (ds/folder-systems.ts)
291
+ adoptFolderSystem(inp.designRoot, liveConfig, cfg.name);
292
+ const list = (liveConfig.designSystems ?? []) as Record<string, unknown>[];
290
293
  const entry = list.find((s) => s && s.name === cfg.name);
291
294
  if (entry && entry.schema !== 1) {
292
295
  entry.schema = 1;
293
296
  const text = jsonText(liveConfig);
294
297
  // the staged copy keeps its own linkedHub-free config, with the same schema flag
295
298
  const staged = readJson(join(after, 'config.json'));
296
- const se = (staged.designSystems as Record<string, unknown>[]).find(
299
+ adoptFolderSystem(after, staged, cfg.name);
300
+ const se = ((staged.designSystems ?? []) as Record<string, unknown>[]).find(
297
301
  (s) => s && s.name === cfg.name
298
302
  );
299
303
  if (se) se.schema = 1;
@@ -11,8 +11,8 @@
11
11
  // Decorative: aria-hidden, pointer-events none.
12
12
 
13
13
  import { useEffect, useRef, useState } from 'react';
14
-
15
14
  import { acceptFromShell } from '../bridge/dgn-protocol.ts';
15
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
16
16
 
17
17
  export interface PointRow {
18
18
  artboard: string;
@@ -125,11 +125,11 @@ export function AiPointRings(): null | React.JSX.Element {
125
125
  ring.style.height = `${Math.round(r.height + PAD * 2)}px`;
126
126
  });
127
127
  }
128
- raf = requestAnimationFrame(tick);
128
+ raf = frameRaf(tick);
129
129
  };
130
- raf = requestAnimationFrame(tick);
130
+ raf = frameRaf(tick);
131
131
  return () => {
132
- if (raf != null) cancelAnimationFrame(raf);
132
+ if (raf != null) frameCaf(raf);
133
133
  };
134
134
  }, [visible, rows]);
135
135
 
@@ -10,8 +10,8 @@
10
10
  // bubble follows pan and zoom; when it goes, it says `null` once.
11
11
 
12
12
  import { useEffect, useRef, useState } from 'react';
13
-
14
13
  import { acceptFromShell } from '../bridge/dgn-protocol.ts';
14
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
15
15
  import { AiPointRings } from './ai-point-ring.tsx';
16
16
  import { unionRect } from './ask-bubble.tsx';
17
17
 
@@ -145,11 +145,11 @@ function AiScopeBox(): null | React.JSX.Element {
145
145
  told.current = key;
146
146
  tellShell(box);
147
147
  }
148
- raf = requestAnimationFrame(tick);
148
+ raf = frameRaf(tick);
149
149
  };
150
- raf = requestAnimationFrame(tick);
150
+ raf = frameRaf(tick);
151
151
  return () => {
152
- if (raf != null) cancelAnimationFrame(raf);
152
+ if (raf != null) frameCaf(raf);
153
153
  };
154
154
  }, [rows]);
155
155
 
@@ -17,12 +17,12 @@
17
17
  // `.dc-multi-artboard-tb` on the bar over artboards.
18
18
 
19
19
  import { type ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
20
-
21
20
  import { canvasModeStore } from '../bridge/canvas-mode-store.ts';
22
21
  import { acceptFromShell } from '../bridge/dgn-protocol.ts';
23
22
  import { useArtboardsContext, useDragStateContext } from '../canvas-lib.tsx';
24
23
  import { showCanvasToast } from '../canvas-notifications.tsx';
25
24
  import { isElementDragActive } from '../drag-state.ts';
25
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
26
26
  import { isReadOnlyCanvas } from '../read-only-mode.ts';
27
27
  import { useSelectionSet } from '../use-selection-set.tsx';
28
28
  import { useUndoStackOptional } from '../use-undo-stack.tsx';
@@ -433,7 +433,7 @@ export function AlignBar({ readOnly = false }: { readOnly?: boolean }) {
433
433
  div.setAttribute('data-on', 'false');
434
434
  };
435
435
  const tick = () => {
436
- raf = requestAnimationFrame(tick);
436
+ raf = frameRaf(tick);
437
437
  const { selected: sel } = live.current;
438
438
  const els: Element[] =
439
439
  kind === 'artboards'
@@ -457,8 +457,8 @@ export function AlignBar({ readOnly = false }: { readOnly?: boolean }) {
457
457
  div.style.top = `${at.top}px`;
458
458
  div.setAttribute('data-on', 'true');
459
459
  };
460
- raf = requestAnimationFrame(tick);
461
- return () => cancelAnimationFrame(raf);
460
+ raf = frameRaf(tick);
461
+ return () => frameCaf(raf);
462
462
  }, [kind]);
463
463
 
464
464
  if (!model) return null;
@@ -10,6 +10,7 @@
10
10
  // Pure like empty-report.ts (the document, the clock and the post are injected): the throttle and the "once
11
11
  // per change" rule are unit tests. One post per animation frame at most.
12
12
 
13
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
13
14
  import { articleOf, bodyOf, type EmptyRect, labelOf } from './empty-report.ts';
14
15
 
15
16
  // unlike the empty hint's rect, an artboard panned half off the left or top edge really is at a negative x / y
@@ -70,12 +71,12 @@ export function createAnchorReporter(deps: AnchorReporterDeps): AnchorReporter {
70
71
  deps.raf ??
71
72
  ((fn: () => void) =>
72
73
  typeof requestAnimationFrame === 'function'
73
- ? requestAnimationFrame(fn)
74
+ ? frameRaf(fn)
74
75
  : (setTimeout(fn, 16) as unknown as number));
75
76
  const caf =
76
77
  deps.caf ??
77
78
  ((id: number) =>
78
- typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame(id) : clearTimeout(id));
79
+ typeof cancelAnimationFrame === 'function' ? frameCaf(id) : clearTimeout(id));
79
80
  let pending: number | null = null;
80
81
  let lastKey = NONE; // what the shell was last told
81
82
 
@@ -15,8 +15,8 @@
15
15
  // (use-element-resize.tsx) stand down for an artboard — one set of handles, not two.
16
16
 
17
17
  import { useCallback, useEffect, useRef, useState } from 'react';
18
-
19
18
  import { useDragStateContext } from '../canvas-lib.tsx';
19
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
20
20
  import { physicalSizeWords } from '../kinds/physical.ts';
21
21
  import { isReadOnlyCanvas } from '../read-only-mode.ts';
22
22
  import { useSelectionSet } from '../use-selection-set.tsx';
@@ -317,7 +317,7 @@ export function ArtboardHandles(): React.ReactNode {
317
317
  for (const el of handleEls.current.values()) el.style.display = 'none';
318
318
  };
319
319
  const tick = () => {
320
- raf = requestAnimationFrame(tick);
320
+ raf = frameRaf(tick);
321
321
  const m = measureArtboard(document, id);
322
322
  if (!m) return hide();
323
323
  if (marked !== m.article) {
@@ -371,9 +371,9 @@ export function ArtboardHandles(): React.ReactNode {
371
371
  el.style.top = `${Math.round(at[h][1])}px`;
372
372
  }
373
373
  };
374
- raf = requestAnimationFrame(tick);
374
+ raf = frameRaf(tick);
375
375
  return () => {
376
- cancelAnimationFrame(raf);
376
+ frameCaf(raf);
377
377
  marked?.removeAttribute('data-ed-selected');
378
378
  const label = marked?.querySelector(':scope > .dc-artboard-label');
379
379
  label?.removeAttribute('data-ed-size');
@@ -15,9 +15,9 @@
15
15
  // transform, like the selection chrome, so a dot is 10 px at any zoom.
16
16
 
17
17
  import { useEffect, useRef, useState } from 'react';
18
-
19
18
  import { showCanvasToast } from '../canvas-notifications.tsx';
20
19
  import { resolveSelectionEl } from '../dom-selection.ts';
20
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
21
21
  import { useSelectionSet } from '../use-selection-set.tsx';
22
22
  import { useToolModeOptional } from '../use-tool-mode.tsx';
23
23
  import { useUndoStackOptional } from '../use-undo-stack.tsx';
@@ -243,11 +243,11 @@ export function CornerDots({ readOnly = false }: { readOnly?: boolean }) {
243
243
  last = key;
244
244
  force((n) => n + 1);
245
245
  }
246
- raf = requestAnimationFrame(tick);
246
+ raf = frameRaf(tick);
247
247
  };
248
- raf = requestAnimationFrame(tick);
248
+ raf = frameRaf(tick);
249
249
  return () => {
250
- if (raf != null) cancelAnimationFrame(raf);
250
+ if (raf != null) frameCaf(raf);
251
251
  };
252
252
  }, [ok, el]);
253
253
 
@@ -13,10 +13,10 @@
13
13
  // Nothing is written while the pointer is down. A read-only canvas never enters; a locked picture says so.
14
14
 
15
15
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
16
-
17
16
  import { acceptFromShell } from '../bridge/dgn-protocol.ts';
18
17
  import { showCanvasToast } from '../canvas-notifications.tsx';
19
18
  import type { EditOpResult, ElementRef } from '../edit-ops/types.ts';
19
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
20
20
  import { isReadOnlyCanvas } from '../read-only-mode.ts';
21
21
  import { useSelectionSet } from '../use-selection-set.tsx';
22
22
  import { useToolModeOptional } from '../use-tool-mode.tsx';
@@ -399,12 +399,12 @@ export function CropMode({ readOnly }: { readOnly?: boolean }) {
399
399
  const n = measureBox(active.el);
400
400
  return b && b.left === n.left && b.top === n.top && b.w === n.w && b.h === n.h ? b : n;
401
401
  });
402
- raf = requestAnimationFrame(tick);
402
+ raf = frameRaf(tick);
403
403
  };
404
- raf = requestAnimationFrame(tick);
404
+ raf = frameRaf(tick);
405
405
  return () => {
406
406
  document.removeEventListener('keydown', key, true);
407
- cancelAnimationFrame(raf);
407
+ frameCaf(raf);
408
408
  };
409
409
  }, [active, commit, leave]);
410
410
 
@@ -6,8 +6,8 @@
6
6
  // The chip follows pan and zoom while it is up (a drag takes a few seconds, the camera can move under it).
7
7
 
8
8
  import { type ReactElement, useEffect, useState } from 'react';
9
-
10
9
  import { acceptFromShell } from '../bridge/dgn-protocol.ts';
10
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
11
11
 
12
12
  /** The chip's words (07 · ve-drop). */
13
13
  export const DROP_CHIP_TEXT = 'Or drop here — adds at the end';
@@ -80,10 +80,10 @@ export function DropChip(): ReactElement | null {
80
80
  key = k;
81
81
  tick((n) => n + 1);
82
82
  }
83
- raf = requestAnimationFrame(loop);
83
+ raf = frameRaf(loop);
84
84
  };
85
- raf = requestAnimationFrame(loop);
86
- return () => cancelAnimationFrame(raf);
85
+ raf = frameRaf(loop);
86
+ return () => frameCaf(raf);
87
87
  }, [artboardId]);
88
88
 
89
89
  if (!artboardId || typeof document === 'undefined') return null;
@@ -1,3 +1,4 @@
1
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
1
2
  // apps/studio/editing/empty-report.ts — S11.2: the canvas tells its shell what is empty.
2
3
  //
3
4
  // Two facts the shell cannot know for itself (it never reads the canvas DOM):
@@ -127,12 +128,12 @@ export function createEmptyReporter(deps: EmptyReporterDeps): EmptyReporter {
127
128
  deps.raf ??
128
129
  ((fn: () => void) =>
129
130
  typeof requestAnimationFrame === 'function'
130
- ? requestAnimationFrame(fn)
131
+ ? frameRaf(fn)
131
132
  : (setTimeout(fn, 16) as unknown as number));
132
133
  const caf =
133
134
  deps.caf ??
134
135
  ((id: number) =>
135
- typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame(id) : clearTimeout(id));
136
+ typeof cancelAnimationFrame === 'function' ? frameCaf(id) : clearTimeout(id));
136
137
  let pending: number | null = null;
137
138
  let lastCount = -1;
138
139
  let lastKey: string | null = null;
@@ -13,7 +13,6 @@
13
13
  // never wonder whether an object is focused or selected.
14
14
 
15
15
  import { useEffect, useRef, useSyncExternalStore } from 'react';
16
-
17
16
  import { canvasKeyIndex } from '../actions/canvas-keys.ts';
18
17
  import { canvasKeyCtx } from '../actions/ctx.ts';
19
18
  import { chordFromEvent } from '../actions/keys.ts';
@@ -28,6 +27,7 @@ import {
28
27
  openCommentComposer,
29
28
  resolveSelectionEl,
30
29
  } from '../dom-selection.ts';
30
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
31
31
  import { isEditableTarget, TOOLBAR_INSERT_EVENT, type Tool } from '../input-router.tsx';
32
32
  import { isReadOnlyCanvas } from '../read-only-mode.ts';
33
33
  import { type Selection, useSelectionSet } from '../use-selection-set.tsx';
@@ -182,11 +182,11 @@ export function FocusRing() {
182
182
  div.style.height = `${Math.round(r.height)}px`;
183
183
  }
184
184
  }
185
- raf = requestAnimationFrame(tick);
185
+ raf = frameRaf(tick);
186
186
  };
187
- raf = requestAnimationFrame(tick);
187
+ raf = frameRaf(tick);
188
188
  return () => {
189
- if (raf != null) cancelAnimationFrame(raf);
189
+ if (raf != null) frameCaf(raf);
190
190
  };
191
191
  }, [kb, one]);
192
192
 
@@ -12,8 +12,8 @@
12
12
  // Pure where it can be (`computeBands` takes rects and numbers), so it runs without layout.
13
13
 
14
14
  import { useEffect, useRef, useState } from 'react';
15
-
16
15
  import { resolveSelectionEl } from '../dom-selection.ts';
16
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
17
17
  import { useSelectionSet } from '../use-selection-set.tsx';
18
18
  import { useToolModeOptional } from '../use-tool-mode.tsx';
19
19
  import { type RectLike, worldScaleOf } from './arrange.ts';
@@ -212,7 +212,7 @@ export function GapBands({ readOnly }: { readOnly?: boolean }) {
212
212
  }
213
213
  let last = '';
214
214
  const tick = () => {
215
- raf.current = requestAnimationFrame(tick);
215
+ raf.current = frameRaf(tick);
216
216
  const el = resolveSelectionEl(document, one) as HTMLElement | null;
217
217
  const next = el ? bandsFor(el) : [];
218
218
  const dragged = tokenRuler.get()?.gapIndex ?? null;
@@ -224,7 +224,7 @@ export function GapBands({ readOnly }: { readOnly?: boolean }) {
224
224
  };
225
225
  tick();
226
226
  return () => {
227
- if (raf.current != null) cancelAnimationFrame(raf.current);
227
+ if (raf.current != null) frameCaf(raf.current);
228
228
  setBands([]);
229
229
  };
230
230
  }, [active, one]);
@@ -15,8 +15,8 @@
15
15
  // that stops refreshing — or lies about time — holds nothing.
16
16
 
17
17
  import { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';
18
-
19
18
  import { acceptFromShell } from '../bridge/dgn-protocol.ts';
19
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
20
20
  import { isReadOnlyCanvas } from '../read-only-mode.ts';
21
21
  import {
22
22
  createHoldPublisher,
@@ -401,11 +401,11 @@ export function HoldRings() {
401
401
  div.dataset.hold === 'person' ? RING_OFFSET : 2
402
402
  );
403
403
  }
404
- raf = requestAnimationFrame(tick);
404
+ raf = frameRaf(tick);
405
405
  };
406
- raf = requestAnimationFrame(tick);
406
+ raf = frameRaf(tick);
407
407
  return () => {
408
- if (raf != null) cancelAnimationFrame(raf);
408
+ if (raf != null) frameCaf(raf);
409
409
  };
410
410
  }, [drawn]);
411
411
 
@@ -8,8 +8,8 @@
8
8
  // Read-only on purpose: the badge never writes and never captures the pointer.
9
9
 
10
10
  import { useEffect, useRef, useState } from 'react';
11
-
12
11
  import { canvasModeStore } from '../bridge/canvas-mode-store.ts';
12
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
13
13
  import { type CrumbNode, crumbLabel } from './crumbs.ts';
14
14
 
15
15
  const LOCKED = '[data-cd-locked]';
@@ -103,7 +103,7 @@ export function LockBadge({ readOnly = false }: { readOnly?: boolean }) {
103
103
  const onMove = (e: PointerEvent) => {
104
104
  if (raf.current != null) return;
105
105
  const { clientX, clientY, target } = e;
106
- raf.current = requestAnimationFrame(() => {
106
+ raf.current = frameRaf(() => {
107
107
  raf.current = null;
108
108
  const el = editing() && target instanceof Element ? lockedUnder(target) : null;
109
109
  if (!el) {
@@ -127,7 +127,7 @@ export function LockBadge({ readOnly = false }: { readOnly?: boolean }) {
127
127
  document.removeEventListener('pointermove', onMove, true);
128
128
  document.removeEventListener('pointerleave', onLeave, true);
129
129
  window.removeEventListener('blur', onLeave);
130
- if (raf.current != null) cancelAnimationFrame(raf.current);
130
+ if (raf.current != null) frameCaf(raf.current);
131
131
  };
132
132
  }, [readOnly]);
133
133
 
@@ -34,12 +34,34 @@ export function sectionName(el: Element): string {
34
34
  return el.getAttribute('data-cd-id') || el.id || el.tagName.toLowerCase();
35
35
  }
36
36
 
37
+ // 2.0.7 — the sticky name and the minimap poll this 10× and 5× a second. Reading every artboard's
38
+ // `offsetHeight` each time forced a synchronous layout of the whole world whenever anything was dirty (an
39
+ // artboard mounting, a picture arriving): on an 88-artboard canvas that was the pan's main cost. A body's height
40
+ // now comes from one ResizeObserver (delivered when layout is clean anyway); only a page that IS long is read
41
+ // for its rectangle.
42
+ const heights = new WeakMap<Element, number>();
43
+ let heightObserver: ResizeObserver | null = null;
44
+
45
+ function bodyHeight(body: HTMLElement): number {
46
+ const known = heights.get(body);
47
+ if (known !== undefined) return known;
48
+ const h = body.offsetHeight;
49
+ if (typeof ResizeObserver === 'function') {
50
+ heightObserver ??= new ResizeObserver((entries) => {
51
+ for (const en of entries) heights.set(en.target, (en.target as HTMLElement).offsetHeight);
52
+ });
53
+ heights.set(body, h);
54
+ heightObserver.observe(body);
55
+ }
56
+ return h;
57
+ }
58
+
37
59
  /** Every artboard in `doc` whose design surface is a long page, with where it is on screen. */
38
60
  export function measureLongPages(doc: Document, win: Window = window): LongPage[] {
39
61
  const out: LongPage[] = [];
40
62
  for (const article of Array.from(doc.querySelectorAll<HTMLElement>('[data-dc-screen]'))) {
41
63
  const body = article.querySelector<HTMLElement>(':scope > .dc-artboard-body');
42
- if (!body || !isLongPage(body.offsetHeight) || !body.offsetWidth) continue;
64
+ if (!body || !isLongPage(bodyHeight(body)) || !body.offsetWidth) continue;
43
65
  const br = body.getBoundingClientRect();
44
66
  const zoom = br.width / body.offsetWidth || 1;
45
67
  const labelEl = article.querySelector<HTMLElement>(':scope > .dc-artboard-label');
@@ -8,8 +8,8 @@
8
8
  // of a drag). It never writes and never takes a key.
9
9
 
10
10
  import { useEffect, useRef, useState } from 'react';
11
-
12
11
  import { resolveSelectionEl } from '../dom-selection.ts';
12
+ import { frameRaf } from '../frame-clock.ts';
13
13
  import { type Selection, useSelectionSet } from '../use-selection-set.tsx';
14
14
  import { stampedParent } from './selection.tsx';
15
15
 
@@ -134,7 +134,7 @@ export function NudgeReadout({ readOnly = false }: { readOnly?: boolean }) {
134
134
  if (e.key === 'Alt') return showGaps();
135
135
  if (!ARROWS.has(e.key)) return;
136
136
  // after v1's handler has run (it previews inline in the same task)
137
- requestAnimationFrame(() => {
137
+ frameRaf(() => {
138
138
  const one = oneElement(selRef.current);
139
139
  if (!one || !(one.el instanceof HTMLElement)) return;
140
140
  const t = nudgeTag(e.key, one.el.offsetLeft, one.el.offsetTop);
@@ -1,3 +1,4 @@
1
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
1
2
  // editing/page-activity.ts — Maude 2.0.4 (task O): one "is anyone using this canvas right now" clock for the
2
3
  // canvas runtime's per-frame and polling loops.
3
4
  //
@@ -186,17 +187,17 @@ export function activeFrameLoop(
186
187
  let running = false;
187
188
  const frame = () => {
188
189
  if (!running) return;
189
- raf = requestAnimationFrame(frame);
190
+ raf = frameRaf(frame);
190
191
  tick();
191
192
  };
192
193
  const start = () => {
193
194
  if (running) return;
194
195
  running = true;
195
- raf = requestAnimationFrame(frame);
196
+ raf = frameRaf(frame);
196
197
  };
197
198
  const stop = () => {
198
199
  running = false;
199
- cancelAnimationFrame(raf);
200
+ frameCaf(raf);
200
201
  };
201
202
  if (activity.active()) start();
202
203
  else tick();
@@ -13,10 +13,10 @@
13
13
  // closes the bar.
14
14
 
15
15
  import { useCallback, useEffect, useRef, useState } from 'react';
16
-
17
16
  import { uploadAsset } from '../asset-upload.ts';
18
17
  import { showCanvasToast } from '../canvas-notifications.tsx';
19
18
  import type { ElementRef } from '../edit-ops/types.ts';
19
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
20
20
  import { isEditableTarget } from '../input-router.tsx';
21
21
  import { isEmbedCanvas, isReadOnlyCanvas } from '../read-only-mode.ts';
22
22
  import { type Selection, useSelectionSet } from '../use-selection-set.tsx';
@@ -341,10 +341,10 @@ export function PasteBar({ readOnly }: { readOnly?: boolean }) {
341
341
  : { left: r.left, top: r.bottom + 14 }
342
342
  );
343
343
  }
344
- raf = requestAnimationFrame(tick);
344
+ raf = frameRaf(tick);
345
345
  };
346
- raf = requestAnimationFrame(tick);
347
- return () => cancelAnimationFrame(raf);
346
+ raf = frameRaf(tick);
347
+ return () => frameCaf(raf);
348
348
  }, [placedRef]);
349
349
 
350
350
  if (!bar) return null;
@@ -3,6 +3,7 @@
3
3
  // tokens; motion is none (a live drag draws as fast as the pointer moves).
4
4
 
5
5
  import { useEffect, useState } from 'react';
6
+ import { frameCaf, frameRaf } from '../../frame-clock.ts';
6
7
 
7
8
  export const PEN_CSS = `
8
9
  /* the input layer pen/draw.tsx renders: its rule used to live only in the shape tool's style (G3) */
@@ -139,9 +140,9 @@ export function useFrameTick(read: () => string, on: boolean): void {
139
140
  last = now;
140
141
  force((n) => n + 1);
141
142
  }
142
- raf = requestAnimationFrame(tick);
143
+ raf = frameRaf(tick);
143
144
  };
144
- raf = requestAnimationFrame(tick);
145
- return () => cancelAnimationFrame(raf);
145
+ raf = frameRaf(tick);
146
+ return () => frameCaf(raf);
146
147
  }, [on, read]);
147
148
  }
@@ -14,11 +14,11 @@
14
14
  // Pure where it can be (the maths takes rects and numbers, so it runs without layout).
15
15
 
16
16
  import { useEffect, useRef, useState } from 'react';
17
-
18
17
  import { resolveSelectionEl } from '../dom-selection.ts';
19
18
  import { isElementDragActive } from '../drag-state.ts';
20
19
  import type { EditOpResult, ElementRef } from '../edit-ops/types.ts';
21
20
  import type { PinH, PinV } from '../edit-ops/words-css.ts';
21
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
22
22
  import type { CommandRecord } from '../undo-stack.ts';
23
23
  import { useSelectionSet } from '../use-selection-set.tsx';
24
24
  import { type RectLike, worldScaleOf } from './arrange.ts';
@@ -332,7 +332,7 @@ export function PinGuides({ readOnly }: { readOnly?: boolean }) {
332
332
  }
333
333
  let last = '';
334
334
  const tick = () => {
335
- raf.current = requestAnimationFrame(tick);
335
+ raf.current = frameRaf(tick);
336
336
  if (isElementDragActive()) return;
337
337
  const el = resolveSelectionEl(document, one) as HTMLElement | null;
338
338
  const next = el ? guidesFor(el) : [];
@@ -352,7 +352,7 @@ export function PinGuides({ readOnly }: { readOnly?: boolean }) {
352
352
  };
353
353
  tick();
354
354
  return () => {
355
- if (raf.current != null) cancelAnimationFrame(raf.current);
355
+ if (raf.current != null) frameCaf(raf.current);
356
356
  setGuides([]);
357
357
  };
358
358
  }, [one, readOnly]);
@@ -19,9 +19,9 @@
19
19
  // Pure where it can be (the line, the numbering, the slot rect take numbers and rects).
20
20
 
21
21
  import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
22
-
23
22
  import { showCanvasToast } from '../canvas-notifications.tsx';
24
23
  import type { EditOpResult, ElementRef } from '../edit-ops/types.ts';
24
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
25
25
  import type { CommandRecord } from '../undo-stack.ts';
26
26
  import type { RectLike } from './arrange.ts';
27
27
  import { crumbLabel } from './crumbs.ts';
@@ -502,7 +502,7 @@ export function ReorderSlot() {
502
502
  }
503
503
  let last = '';
504
504
  const tick = () => {
505
- raf.current = requestAnimationFrame(tick);
505
+ raf.current = frameRaf(tick);
506
506
  const next = paintOf(s);
507
507
  // Layers draws the same slot: tell the shell when the place changes (not on every frame)
508
508
  const msg = next ? slotMessage(s) : null;
@@ -520,7 +520,7 @@ export function ReorderSlot() {
520
520
  };
521
521
  tick();
522
522
  return () => {
523
- if (raf.current != null) cancelAnimationFrame(raf.current);
523
+ if (raf.current != null) frameCaf(raf.current);
524
524
  setPaint(null);
525
525
  };
526
526
  }, [s]);
@@ -12,10 +12,10 @@
12
12
  // (S2-edit-ops.md §7) through use-selection-set's describer seam.
13
13
 
14
14
  import { useEffect, useRef } from 'react';
15
-
16
15
  import type { SelectionCrumb } from '../bridge/dgn-protocol.ts';
17
16
  import { hoverTargetToSelection, resolveSelectionEl } from '../dom-selection.ts';
18
17
  import type { ElementRef } from '../edit-ops/types.ts';
18
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
19
19
  import { type Selection, setSelectionDescriber, useSelectionSet } from '../use-selection-set.tsx';
20
20
  import {
21
21
  buildCrumbs,
@@ -255,11 +255,11 @@ export function EditingSelection({ readOnly = false }: { readOnly?: boolean }) {
255
255
  }
256
256
  }
257
257
  }
258
- raf = requestAnimationFrame(tick);
258
+ raf = frameRaf(tick);
259
259
  };
260
- raf = requestAnimationFrame(tick);
260
+ raf = frameRaf(tick);
261
261
  return () => {
262
- if (raf != null) cancelAnimationFrame(raf);
262
+ if (raf != null) frameCaf(raf);
263
263
  };
264
264
  }, [one]);
265
265
 
@@ -15,11 +15,11 @@
15
15
  // Read-only canvases do nothing here (the server refuses anyway).
16
16
 
17
17
  import { useEffect, useRef, useState } from 'react';
18
-
19
18
  import { acceptFromShell } from '../bridge/dgn-protocol.ts';
20
19
  import { DsIcon } from '../canvas-ds-icons.tsx';
21
20
  import { getLiveViewport } from '../canvas-lib.tsx';
22
21
  import { showCanvasToast } from '../canvas-notifications.tsx';
22
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
23
23
  import type { Tool } from '../input-router.tsx';
24
24
  import { customSpec, presetById } from '../kinds/presets.ts';
25
25
  import { isReadOnlyCanvas } from '../read-only-mode.ts';
@@ -269,10 +269,10 @@ export function SizeGhost({ readOnly = false }: { readOnly?: boolean }) {
269
269
  key = k;
270
270
  tick((n) => n + 1);
271
271
  }
272
- raf = requestAnimationFrame(loop);
272
+ raf = frameRaf(loop);
273
273
  };
274
- raf = requestAnimationFrame(loop);
275
- return () => cancelAnimationFrame(raf);
274
+ raf = frameRaf(loop);
275
+ return () => frameCaf(raf);
276
276
  }, [ghost]);
277
277
 
278
278
  if (!ghost || typeof document === 'undefined') return null;
@@ -14,8 +14,8 @@
14
14
  // without a layout engine; the DOM fills the measurements in.
15
15
 
16
16
  import { useEffect, useRef } from 'react';
17
-
18
17
  import { resolveSelectionEl } from '../dom-selection.ts';
18
+ import { frameCaf, frameRaf } from '../frame-clock.ts';
19
19
  import { pageRootOf } from '../input-router.tsx';
20
20
  import { type Selection, useSelectionSet } from '../use-selection-set.tsx';
21
21
  import { selectionForElement, stampedParent } from './selection.tsx';
@@ -279,11 +279,11 @@ export function OrderBadges({ active }: { active: boolean }) {
279
279
  n.style.left = `${Math.round(edge ? edge.left : r.left) + 5}px`;
280
280
  n.style.top = `${Math.round(r.top) + (edge ? 2 : 5)}px`;
281
281
  }
282
- raf = requestAnimationFrame(tick);
282
+ raf = frameRaf(tick);
283
283
  };
284
- raf = requestAnimationFrame(tick);
284
+ raf = frameRaf(tick);
285
285
  return () => {
286
- if (raf != null) cancelAnimationFrame(raf);
286
+ if (raf != null) frameCaf(raf);
287
287
  root.textContent = '';
288
288
  };
289
289
  }, [active, one]);