@1agh/maude 2.0.4 → 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 (272) hide show
  1. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  2. package/apps/studio/access/closure.ts +156 -16
  3. package/apps/studio/access/filters.ts +39 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/actions/agents.ts +59 -0
  7. package/apps/studio/actions/ctx.ts +3 -0
  8. package/apps/studio/actions/defs/app.ts +12 -0
  9. package/apps/studio/actions/defs/sync.ts +13 -0
  10. package/apps/studio/actions/defs/view.ts +59 -3
  11. package/apps/studio/actions/keymap.gen.ts +35 -0
  12. package/apps/studio/actions/menu.ts +2 -0
  13. package/apps/studio/actions/types.ts +3 -1
  14. package/apps/studio/actions.manifest.json +148 -1
  15. package/apps/studio/actions.parity.json +31 -1
  16. package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/ride.ts +2 -1
  20. package/apps/studio/annotations/ui/text-style.ts +1 -1
  21. package/apps/studio/annotations-context-toolbar.tsx +5 -4
  22. package/apps/studio/annotations-layer.tsx +4 -15
  23. package/apps/studio/api.ts +425 -128
  24. package/apps/studio/artboard-activity-overlay.tsx +4 -4
  25. package/apps/studio/artboard-ai-copies.tsx +4 -4
  26. package/apps/studio/artboard-freeze.ts +108 -0
  27. package/apps/studio/artboard-live-gate.tsx +636 -0
  28. package/apps/studio/artboard-live.ts +831 -0
  29. package/apps/studio/artboard-placeholder.ts +197 -0
  30. package/apps/studio/artboard-still-raster.ts +485 -0
  31. package/apps/studio/artboard-still-warmup.ts +221 -0
  32. package/apps/studio/artboard-still.ts +1188 -0
  33. package/apps/studio/artboard-webgl.ts +669 -0
  34. package/apps/studio/asset-placeholder.tsx +237 -132
  35. package/apps/studio/asset-upload-bars.tsx +4 -4
  36. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  37. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  38. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  39. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  40. package/apps/studio/bin/_ds-check.mjs +4 -1
  41. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  42. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  43. package/apps/studio/bin/_import-asset.mjs +2 -1
  44. package/apps/studio/bin/_perf-probe-open.mjs +364 -0
  45. package/apps/studio/bin/_perf-probe.mjs +2 -1
  46. package/apps/studio/bin/_perf-shared.mjs +12 -7
  47. package/apps/studio/bin/_pw-launch.mjs +26 -1
  48. package/apps/studio/bin/_studio-verb.mjs +24 -3
  49. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  50. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  51. package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
  52. package/apps/studio/bin/ds-check.sh +5 -1
  53. package/apps/studio/bin/perf.sh +30 -1
  54. package/apps/studio/bin/server-up.sh +7 -2
  55. package/apps/studio/bin/smoke.sh +19 -0
  56. package/apps/studio/bridge/dgn-protocol.ts +35 -0
  57. package/apps/studio/canvas-build-sandbox.ts +69 -13
  58. package/apps/studio/canvas-camera.ts +90 -0
  59. package/apps/studio/canvas-comment-mount.tsx +9 -9
  60. package/apps/studio/canvas-lib.tsx +289 -44
  61. package/apps/studio/canvas-pages-view.tsx +465 -0
  62. package/apps/studio/canvas-pages.ts +305 -0
  63. package/apps/studio/canvas-rows.ts +62 -0
  64. package/apps/studio/canvas-shell.tsx +62 -16
  65. package/apps/studio/canvas-theme-icons.tsx +41 -0
  66. package/apps/studio/canvas-theme-pill.tsx +15 -6
  67. package/apps/studio/canvas-theme.ts +12 -11
  68. package/apps/studio/client/app.jsx +7 -0
  69. package/apps/studio/client/canvas-url.js +36 -1
  70. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  71. package/apps/studio/client/home/Shelves.jsx +4 -3
  72. package/apps/studio/client/home/home-accounts-model.js +121 -0
  73. package/apps/studio/client/home/home-api.js +6 -0
  74. package/apps/studio/client/home/home-app.jsx +141 -40
  75. package/apps/studio/client/home/home-model.js +172 -6
  76. package/apps/studio/client/home/home.css +169 -5
  77. package/apps/studio/client/home/shell-mode.js +8 -1
  78. package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
  79. package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
  80. package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
  81. package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
  82. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
  83. package/apps/studio/client/hooks/use-project-data.jsx +13 -2
  84. package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
  85. package/apps/studio/client/index-loader.ts +41 -21
  86. package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
  87. package/apps/studio/client/panels/ChatPanel.jsx +27 -20
  88. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  89. package/apps/studio/client/panels/caps-cache.js +46 -0
  90. package/apps/studio/client/shell/viewport.jsx +66 -22
  91. package/apps/studio/client/tree/tree.jsx +17 -0
  92. package/apps/studio/client/v2/access/access-client.js +2 -0
  93. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  94. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  95. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  96. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  97. package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
  98. package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
  99. package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
  100. package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
  101. package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
  102. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
  103. package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
  104. package/apps/studio/client/v2/code/code-bus.js +5 -0
  105. package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
  106. package/apps/studio/client/v2/code/code-consent.js +67 -0
  107. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
  108. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
  109. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
  110. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  111. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  112. package/apps/studio/client/v2/ds/make-host.jsx +13 -15
  113. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
  114. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  115. package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
  116. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  117. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  118. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  119. package/apps/studio/client/v2/history/git-model.js +3 -1
  120. package/apps/studio/client/v2/history/git-parts.jsx +16 -1
  121. package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
  122. package/apps/studio/client/v2/layers/layers-request.js +49 -0
  123. package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
  124. package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
  125. package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
  126. package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
  127. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  128. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  129. package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
  130. package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
  131. package/apps/studio/client/v2/shell/floating-panels.css +37 -1
  132. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  133. package/apps/studio/client/v2/shell/menu-runner.js +11 -0
  134. package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
  135. package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
  136. package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
  137. package/apps/studio/client/v2/shell/pages-pick.js +49 -0
  138. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  139. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  140. package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
  141. package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
  142. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  143. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  144. package/apps/studio/client/v2/shell/shell-parity.json +8 -0
  145. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  146. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  147. package/apps/studio/client/v2/shell/use-account.js +8 -1
  148. package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
  149. package/apps/studio/collab/persistence.ts +9 -1
  150. package/apps/studio/collab/registry.ts +32 -0
  151. package/apps/studio/collab/room.ts +8 -0
  152. package/apps/studio/comments-overlay.tsx +12 -11
  153. package/apps/studio/config-reload-wire.ts +56 -0
  154. package/apps/studio/config.schema.json +6 -0
  155. package/apps/studio/context.ts +37 -1
  156. package/apps/studio/dist/client.bundle.js +1198 -1198
  157. package/apps/studio/dist/comment-mount.js +2 -2
  158. package/apps/studio/dist/styles.css +1 -1
  159. package/apps/studio/ds/board/board.css +6 -0
  160. package/apps/studio/ds/board/ds-bar.tsx +21 -3
  161. package/apps/studio/ds/board/specimen.tsx +16 -2
  162. package/apps/studio/ds/board/template.ts +39 -19
  163. package/apps/studio/ds/canvas-cli.ts +58 -2
  164. package/apps/studio/ds/check.ts +26 -1
  165. package/apps/studio/ds/cli.ts +14 -4
  166. package/apps/studio/ds/component-list.ts +2 -1
  167. package/apps/studio/ds/convert.ts +34 -6
  168. package/apps/studio/ds/default.ts +6 -1
  169. package/apps/studio/ds/ds-resolver.ts +58 -8
  170. package/apps/studio/ds/ds-verb.ts +13 -0
  171. package/apps/studio/ds/engine.ts +3 -1
  172. package/apps/studio/ds/folder-systems.ts +199 -0
  173. package/apps/studio/ds/pairing-css.ts +2 -1
  174. package/apps/studio/ds/post-build.ts +38 -0
  175. package/apps/studio/ds/rename.ts +10 -3
  176. package/apps/studio/ds/shell-fallbacks.ts +2 -1
  177. package/apps/studio/ds/upgrade-apply.ts +27 -5
  178. package/apps/studio/ds/upgrade-cli.ts +22 -2
  179. package/apps/studio/ds/upgrade-prove.ts +198 -15
  180. package/apps/studio/ds/upgrade-stage.ts +10 -3
  181. package/apps/studio/editing/ai-point-ring.tsx +4 -4
  182. package/apps/studio/editing/ai-scope-outline.tsx +4 -4
  183. package/apps/studio/editing/align-bar.tsx +4 -4
  184. package/apps/studio/editing/anchor-report.ts +3 -2
  185. package/apps/studio/editing/artboard-handles.tsx +4 -4
  186. package/apps/studio/editing/corner-dots.tsx +4 -4
  187. package/apps/studio/editing/crop-mode.tsx +4 -4
  188. package/apps/studio/editing/drop-chip.tsx +4 -4
  189. package/apps/studio/editing/empty-report.ts +3 -2
  190. package/apps/studio/editing/focus-model.tsx +4 -4
  191. package/apps/studio/editing/gap-bands.tsx +3 -3
  192. package/apps/studio/editing/hold-rings.tsx +4 -4
  193. package/apps/studio/editing/lock-badge.tsx +3 -3
  194. package/apps/studio/editing/long-page.ts +23 -1
  195. package/apps/studio/editing/nudge.tsx +2 -2
  196. package/apps/studio/editing/page-activity.ts +4 -3
  197. package/apps/studio/editing/paste-bar.tsx +4 -4
  198. package/apps/studio/editing/pen/overlay.tsx +4 -3
  199. package/apps/studio/editing/place-freely.tsx +3 -3
  200. package/apps/studio/editing/reorder-slot.tsx +3 -3
  201. package/apps/studio/editing/selection.tsx +4 -4
  202. package/apps/studio/editing/size-ghost.tsx +4 -4
  203. package/apps/studio/editing/tab-order.tsx +4 -4
  204. package/apps/studio/editing/text-in-place.tsx +4 -4
  205. package/apps/studio/editing/undo-preview.tsx +3 -3
  206. package/apps/studio/equal-spacing-handles.tsx +3 -3
  207. package/apps/studio/frame-clock.ts +89 -0
  208. package/apps/studio/history/trash.ts +6 -0
  209. package/apps/studio/home/accounts.ts +87 -0
  210. package/apps/studio/home/index-reader.ts +24 -2
  211. package/apps/studio/home/routes.ts +19 -0
  212. package/apps/studio/http.ts +80 -34
  213. package/apps/studio/index/ds-usage.ts +4 -1
  214. package/apps/studio/index-cache.ts +272 -0
  215. package/apps/studio/inspect-overlay.tsx +4 -3
  216. package/apps/studio/inspect.ts +7 -2
  217. package/apps/studio/link-chip-overlay.tsx +4 -3
  218. package/apps/studio/measure-overlay.tsx +4 -3
  219. package/apps/studio/present/pointer-dot.tsx +3 -2
  220. package/apps/studio/present/present-media.ts +6 -2
  221. package/apps/studio/present/present-stage.tsx +3 -2
  222. package/apps/studio/preview/preview-camera.tsx +3 -2
  223. package/apps/studio/routes/ds-convert.ts +18 -0
  224. package/apps/studio/routes/sync.ts +176 -0
  225. package/apps/studio/routes/trash.ts +16 -1
  226. package/apps/studio/safe-zones-overlay.tsx +3 -2
  227. package/apps/studio/server.ts +8 -10
  228. package/apps/studio/skip-dirs.ts +103 -47
  229. package/apps/studio/studio-page-host.ts +70 -0
  230. package/apps/studio/sync/accepted-cold-start.ts +28 -13
  231. package/apps/studio/sync/asset-push.ts +146 -23
  232. package/apps/studio/sync/asset-state.ts +3 -2
  233. package/apps/studio/sync/code-module-consent.ts +86 -0
  234. package/apps/studio/sync/file-ledger.ts +24 -0
  235. package/apps/studio/sync/file-membership.ts +28 -3
  236. package/apps/studio/sync/file-plane.ts +497 -61
  237. package/apps/studio/sync/file-pull.ts +304 -33
  238. package/apps/studio/sync/held-deletes.ts +230 -0
  239. package/apps/studio/sync/hub-link.ts +1 -2
  240. package/apps/studio/sync/hubs-config.ts +59 -2
  241. package/apps/studio/sync/index.ts +405 -163
  242. package/apps/studio/sync/journal-client.ts +94 -5
  243. package/apps/studio/sync/pending-deletes.ts +100 -0
  244. package/apps/studio/sync/projection.ts +77 -12
  245. package/apps/studio/sync/seed-progress.ts +104 -3
  246. package/apps/studio/sync/settings.ts +36 -1
  247. package/apps/studio/sync/status.ts +17 -1
  248. package/apps/studio/sync/writer-registry.ts +5 -0
  249. package/apps/studio/text-caret.ts +5 -3
  250. package/apps/studio/thumbs/service.ts +12 -2
  251. package/apps/studio/thumbs/validate.ts +7 -0
  252. package/apps/studio/toolbars/toolbar-rect.ts +3 -2
  253. package/apps/studio/ui-prefs-migrate.ts +4 -0
  254. package/apps/studio/use-annotation-resize.tsx +4 -3
  255. package/apps/studio/use-artboard-drag.tsx +3 -2
  256. package/apps/studio/use-element-resize.tsx +7 -6
  257. package/apps/studio/use-grid-track-handles.tsx +5 -4
  258. package/apps/studio/use-selection-set.tsx +64 -4
  259. package/apps/studio/use-spacing-handles.tsx +7 -6
  260. package/apps/studio/video-comp.tsx +75 -39
  261. package/apps/studio/video-play-overlay.tsx +4 -3
  262. package/apps/studio/whats-new.json +99 -0
  263. package/cli/commands/design.mjs +5 -2
  264. package/cli/commands/hub.mjs +10 -1
  265. package/cli/lib/bash-guard.mjs +27 -1
  266. package/cli/lib/design-help.gen.mjs +1 -1
  267. package/cli/lib/design-hook.mjs +20 -0
  268. package/cli/lib/design-link.mjs +42 -17
  269. package/cli/lib/hub-purge.mjs +183 -0
  270. package/cli/lib/studio-locate.mjs +35 -10
  271. package/package.json +8 -8
  272. package/plugins/design/templates/_shell.html +164 -1
@@ -0,0 +1,221 @@
1
+ /**
2
+ * 2.0.7 — the stills' warm-up (the overview level, artboard-still.ts). An artboard whose children never mount while
3
+ * the person looks around (the ring mounts one per `GESTURE_MOUNT_GAP_MS` mid-pan, so about half of the mascot
4
+ * canvas's 88 never do during a sweep) has no still: it passes as a flat own-colour block. Once the canvas is open
5
+ * and nothing moves, the warm-up mounts such artboards one at a time — far away, asleep, within the DOM budget — lets
6
+ * the still controller draw each (sliced, within its idle frame budget), then releases it: its placeholder now
7
+ * shows the kept still, and a later pass shows the still from its first frame.
8
+ *
9
+ * Rules: one artboard at a time; only after `WARM_QUIET_MS` with no input and no camera move, and only while the
10
+ * still controller is quiet (no gesture, past its settle hold, no hand-back, no drawing on screen waiting) and the
11
+ * ring's own mounts are done. Any input pauses it at once: a mount asked for but not yet made is withdrawn, one made
12
+ * is released only once it is quiet again (a release is an unmount — main-thread work). Never past the DOM budget,
13
+ * never past the still cache's byte budget (an evicted still would be warmed again, forever), never a video artboard
14
+ * (`eager`, its media rule), never one on screen or near (the ring's), each artboard at most once per document.
15
+ */
16
+
17
+ /**
18
+ * Off in 2.0.7 (contract 207-overview-level, round 3): in Safari the fit-all zoom cycle after an idle open settled
19
+ * 1–1.5 frames over base with it on (A/A, cause not found), the warmed placeholders looked as blank as before in the
20
+ * Safari frame strip (Playwright WebKit draws them with their pictures — unverified in Safari), and the page held
21
+ * ~0.4 GB more. Flip only with those three re-measured.
22
+ */
23
+ export const WARM_ENABLED = false;
24
+ /** Quiet needed before the warm-up mounts the next artboard: no input, no camera move (ms). */
25
+ export const WARM_QUIET_MS = 1500;
26
+ /** Between one artboard's release and the next one's mount (ms): the frames the release paints in. */
27
+ export const WARM_GAP_MS = 120;
28
+ /** How often a waiting warm-up looks again (ms). */
29
+ export const WARM_POLL_MS = 150;
30
+ /** A warm mount whose still has not come by then is released and not tried again (ms). */
31
+ export const WARM_STEP_MAX_MS = 5000;
32
+
33
+ export interface WarmCandidate {
34
+ id: string;
35
+ /** distance to the viewport centre (px) — nearest first */
36
+ dist: number;
37
+ /** its first mount fits the DOM budget now */
38
+ fits: boolean;
39
+ }
40
+
41
+ /** What the warm-up needs from the runtime (an adapter: the registry, the still controller, the clock). */
42
+ export interface WarmHost {
43
+ now(): number;
44
+ later(fn: () => void, ms: number): unknown;
45
+ cancel(handle: unknown): void;
46
+ /** artboards it may mount now: not mounted, far, not pinned / eager, a gate holds them */
47
+ candidates(): WarmCandidate[];
48
+ /** would this artboard show a still at the settled zoom (under the cut)? */
49
+ wanted(id: string): boolean;
50
+ hasStill(id: string): boolean;
51
+ mount(id: string): void;
52
+ release(id: string): void;
53
+ mounted(id: string): boolean;
54
+ /** nothing moves, nothing is held, nothing on screen is being drawn, the ring's mounts are done */
55
+ quiet(): boolean;
56
+ /** the last camera write or settle (ms) */
57
+ lastActivity(): number;
58
+ /** the still cache can take one more still without dropping a kept one */
59
+ cacheRoom(): boolean;
60
+ }
61
+
62
+ export type WarmState = 'waiting' | 'mounting' | 'drawing' | 'paused' | 'done' | 'full';
63
+
64
+ export interface WarmStats {
65
+ state: WarmState;
66
+ warmed: number;
67
+ failed: number;
68
+ /** ms (host clock) the first warm mount was asked for / the warm-up found nothing left */
69
+ startedAt: number | null;
70
+ finishedAt: number | null;
71
+ current: string | null;
72
+ /** why it stopped short: 'budget' (DOM) | 'cache' (bytes) */
73
+ full: string | null;
74
+ }
75
+
76
+ export class StillWarmup {
77
+ private current: { id: string; at: number; drawn: boolean } | null = null;
78
+ private tried = new Set<string>();
79
+ private timer: unknown = null;
80
+ private inputAt = Number.NEGATIVE_INFINITY;
81
+ private warmed = 0;
82
+ private failed = 0;
83
+ private startedAt: number | null = null;
84
+ private finishedAt: number | null = null;
85
+ private state: WarmState = 'waiting';
86
+ private full: string | null = null;
87
+ private stopped = false;
88
+
89
+ constructor(private readonly host: WarmHost) {}
90
+
91
+ /** Start (or wake) the warm-up: after the quiet it looks for the next artboard. */
92
+ kick(ms = WARM_POLL_MS, now = false): void {
93
+ if (this.stopped) return;
94
+ if (this.timer !== null) {
95
+ if (!now) return;
96
+ this.host.cancel(this.timer);
97
+ }
98
+ this.timer = this.host.later(() => {
99
+ this.timer = null;
100
+ this.tick();
101
+ }, ms);
102
+ }
103
+
104
+ /** Any input (pointer, wheel, key, touch): pause at once. */
105
+ input(): void {
106
+ this.inputAt = this.host.now();
107
+ const c = this.current;
108
+ if (c && !this.host.mounted(c.id)) {
109
+ // asked for, not made yet: withdrawn (the drain never mounts it); tried again once quiet
110
+ this.host.release(c.id);
111
+ this.tried.delete(c.id);
112
+ this.current = null;
113
+ }
114
+ this.state = 'paused';
115
+ this.full = null;
116
+ this.kick(WARM_QUIET_MS);
117
+ }
118
+
119
+ /** The camera settled or the zoom changed: once quiet, look again (a zoom-out brings new artboards under the cut). */
120
+ wake(): void {
121
+ if (this.state === 'done' || this.state === 'full') {
122
+ this.state = 'waiting';
123
+ this.full = null;
124
+ }
125
+ this.kick();
126
+ }
127
+
128
+ /** The still controller finished a drawing of `id`. */
129
+ stillDone(id: string, ok: boolean): void {
130
+ const c = this.current;
131
+ if (!c || c.id !== id || c.drawn) return;
132
+ c.drawn = true;
133
+ if (ok) this.warmed += 1;
134
+ else this.failed += 1;
135
+ this.kick(0, true);
136
+ }
137
+
138
+ stop(): void {
139
+ this.stopped = true;
140
+ if (this.timer !== null) this.host.cancel(this.timer);
141
+ this.timer = null;
142
+ if (this.current) this.host.release(this.current.id);
143
+ this.current = null;
144
+ }
145
+
146
+ stats(): WarmStats {
147
+ return {
148
+ state: this.state,
149
+ warmed: this.warmed,
150
+ failed: this.failed,
151
+ startedAt: this.startedAt,
152
+ finishedAt: this.finishedAt,
153
+ current: this.current?.id ?? null,
154
+ full: this.full,
155
+ };
156
+ }
157
+
158
+ private tick(): void {
159
+ if (this.stopped) return;
160
+ const t = this.host.now();
161
+ const quietAt = Math.max(this.inputAt, this.host.lastActivity()) + WARM_QUIET_MS;
162
+ if (t < quietAt) {
163
+ this.kick(Math.max(16, quietAt - t));
164
+ return;
165
+ }
166
+ const c = this.current;
167
+ if (c) {
168
+ const late = t - c.at > WARM_STEP_MAX_MS;
169
+ // drawn (or late): released once nothing moves — a release is an unmount
170
+ if (c.drawn || late || this.host.hasStill(c.id)) {
171
+ if (!this.host.quiet()) {
172
+ this.kick();
173
+ return;
174
+ }
175
+ if (!c.drawn && !this.host.hasStill(c.id)) this.failed += 1;
176
+ else if (!c.drawn) this.warmed += 1;
177
+ this.host.release(c.id);
178
+ this.current = null;
179
+ this.kick(WARM_GAP_MS);
180
+ return;
181
+ }
182
+ this.state = this.host.mounted(c.id) ? 'drawing' : 'mounting';
183
+ this.kick();
184
+ return;
185
+ }
186
+ if (!this.host.quiet()) {
187
+ if (this.state !== 'done' && this.state !== 'full') this.state = 'waiting';
188
+ this.kick();
189
+ return;
190
+ }
191
+ let pick: WarmCandidate | null = null;
192
+ let blocked = false;
193
+ for (const k of this.host.candidates()) {
194
+ if (this.tried.has(k.id) || this.host.hasStill(k.id) || !this.host.wanted(k.id)) continue;
195
+ if (!k.fits) {
196
+ blocked = true;
197
+ continue;
198
+ }
199
+ if (!pick || k.dist < pick.dist) pick = k;
200
+ }
201
+ if (!pick) {
202
+ this.state = blocked ? 'full' : 'done';
203
+ this.full = blocked ? 'budget' : null;
204
+ if (this.finishedAt === null && this.startedAt !== null) this.finishedAt = t;
205
+ return; // woken again by input (or a kick from the runtime)
206
+ }
207
+ if (!this.host.cacheRoom()) {
208
+ this.state = 'full';
209
+ this.full = 'cache';
210
+ if (this.finishedAt === null && this.startedAt !== null) this.finishedAt = t;
211
+ return;
212
+ }
213
+ if (this.startedAt === null) this.startedAt = t;
214
+ this.finishedAt = null;
215
+ this.tried.add(pick.id);
216
+ this.current = { id: pick.id, at: t, drawn: false };
217
+ this.state = 'mounting';
218
+ this.host.mount(pick.id);
219
+ this.kick();
220
+ }
221
+ }