@1agh/maude 2.0.8 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/README.md +2 -1
  2. package/apps/hub/src/project-transactions/kernel.mjs +13 -7
  3. package/apps/studio/access/closure.ts +86 -10
  4. package/apps/studio/access/filters.ts +18 -1
  5. package/apps/studio/access/request.ts +8 -0
  6. package/apps/studio/acp/design-write-verb.ts +12 -2
  7. package/apps/studio/acp/env.ts +7 -2
  8. package/apps/studio/acp/index.ts +15 -4
  9. package/apps/studio/acp/login-state.ts +22 -5
  10. package/apps/studio/acp/may-scope.ts +38 -1
  11. package/apps/studio/acp/plugin-bootstrap.ts +13 -1
  12. package/apps/studio/acp/probe.ts +11 -4
  13. package/apps/studio/actions/agents.ts +110 -28
  14. package/apps/studio/actions/canvas-keys.ts +4 -2
  15. package/apps/studio/actions/ctx.ts +3 -0
  16. package/apps/studio/actions/defs/annotation.ts +84 -2
  17. package/apps/studio/actions/defs/app.ts +28 -1
  18. package/apps/studio/actions/defs/edit.ts +13 -0
  19. package/apps/studio/actions/defs/export.ts +12 -0
  20. package/apps/studio/actions/defs/sync.ts +18 -0
  21. package/apps/studio/actions/defs/video.ts +9 -0
  22. package/apps/studio/actions/documents.ts +6 -1
  23. package/apps/studio/actions/keymap.gen.ts +147 -9
  24. package/apps/studio/actions/menu.ts +5 -1
  25. package/apps/studio/actions/types.ts +4 -2
  26. package/apps/studio/actions/verbs.ts +9 -0
  27. package/apps/studio/actions.manifest.json +300 -45
  28. package/apps/studio/actions.parity.json +19 -1
  29. package/apps/studio/ai/save-hold.ts +2 -1
  30. package/apps/studio/ai/write-claim-scope.ts +7 -1
  31. package/apps/studio/ai/write-claim.ts +154 -3
  32. package/apps/studio/annotations/ai-read.ts +42 -6
  33. package/apps/studio/annotations/ai-write.ts +145 -2
  34. package/apps/studio/annotations/board-ops.ts +34 -3
  35. package/apps/studio/annotations/checklist-ops.ts +374 -0
  36. package/apps/studio/annotations/elements/checkitem.model.ts +129 -0
  37. package/apps/studio/annotations/elements/sticky.model.ts +54 -2
  38. package/apps/studio/annotations/ops.ts +30 -0
  39. package/apps/studio/annotations/registry.ts +9 -1
  40. package/apps/studio/annotations/templates.ts +4 -2
  41. package/apps/studio/annotations/text-steps.ts +114 -10
  42. package/apps/studio/annotations/ui/checklist-wire.ts +129 -0
  43. package/apps/studio/annotations/ui/checklist.tsx +429 -0
  44. package/apps/studio/annotations/ui/element-node.tsx +48 -2
  45. package/apps/studio/annotations/ui/template-place.ts +11 -1
  46. package/apps/studio/annotations/v1-adapter.ts +22 -3
  47. package/apps/studio/annotations-context-toolbar.tsx +12 -0
  48. package/apps/studio/annotations-layer.tsx +442 -49
  49. package/apps/studio/annotations-model.ts +4 -2
  50. package/apps/studio/api.ts +148 -21
  51. package/apps/studio/artboard-live-gate.tsx +54 -17
  52. package/apps/studio/artboard-still-persist.ts +166 -0
  53. package/apps/studio/artboard-still-raster.ts +6 -2
  54. package/apps/studio/artboard-still.ts +390 -20
  55. package/apps/studio/asset-added.ts +154 -0
  56. package/apps/studio/asset-details.ts +46 -3
  57. package/apps/studio/asset-origins.ts +5 -3
  58. package/apps/studio/asset-trash.ts +6 -1
  59. package/apps/studio/bin/_agent-browser-safe.mjs +3 -4
  60. package/apps/studio/bin/_annotate-post.mjs +14 -5
  61. package/apps/studio/bin/_audio-search.mjs +8 -2
  62. package/apps/studio/bin/_curl-local.mjs +7 -4
  63. package/apps/studio/bin/_desktop-locate.sh +145 -0
  64. package/apps/studio/bin/_ds-check-live.mjs +2 -1
  65. package/apps/studio/bin/_exports.mjs +38 -2
  66. package/apps/studio/bin/_history.mjs +79 -8
  67. package/apps/studio/bin/_import-asset.mjs +14 -9
  68. package/apps/studio/bin/_import-figma.mjs +510 -98
  69. package/apps/studio/bin/_index-cli.mjs +10 -21
  70. package/apps/studio/bin/_ingest-footage.mjs +24 -6
  71. package/apps/studio/bin/_media-probe.mjs +232 -0
  72. package/apps/studio/bin/_perf-probe-open.mjs +6 -0
  73. package/apps/studio/bin/_perf-probe-safari.mjs +6 -0
  74. package/apps/studio/bin/_perf-probe-studio.mjs +6 -1
  75. package/apps/studio/bin/_perf-probe.mjs +8 -3
  76. package/apps/studio/bin/_perf-sweep-shared.mjs +789 -0
  77. package/apps/studio/bin/_perf-sweep.mjs +240 -0
  78. package/apps/studio/bin/_record-shot.sh +33 -8
  79. package/apps/studio/bin/_screenshot-playwright.mjs +45 -2
  80. package/apps/studio/bin/_studio-verb.mjs +8 -3
  81. package/apps/studio/bin/_thumb-route.mjs +21 -0
  82. package/apps/studio/bin/_thumbs-playwright.mjs +83 -1
  83. package/apps/studio/bin/_transcribe.mjs +22 -6
  84. package/apps/studio/bin/_unsynced-refs.mjs +22 -0
  85. package/apps/studio/bin/_url-guard.mjs +120 -5
  86. package/apps/studio/bin/_url-guard.sh +29 -7
  87. package/apps/studio/bin/_video-limits.mjs +104 -0
  88. package/apps/studio/bin/_video-playwright.mjs +119 -19
  89. package/apps/studio/bin/_video-proxy.mjs +130 -0
  90. package/apps/studio/bin/_write-claim.mjs +38 -16
  91. package/apps/studio/bin/annotate.mjs +12 -2
  92. package/apps/studio/bin/canvas-rects.sh +19 -4
  93. package/apps/studio/bin/chat-open.sh +7 -1
  94. package/apps/studio/bin/draw-proof.sh +6 -2
  95. package/apps/studio/bin/generate.sh +32 -10
  96. package/apps/studio/bin/handoff.sh +2 -2
  97. package/apps/studio/bin/perf.sh +96 -15
  98. package/apps/studio/bin/photo-adjust.sh +6 -3
  99. package/apps/studio/bin/photo-bg-remove.sh +2 -2
  100. package/apps/studio/bin/prep.sh +21 -4
  101. package/apps/studio/bin/read-annotations.mjs +3 -0
  102. package/apps/studio/bin/runtime-health.sh +27 -1
  103. package/apps/studio/bin/screenshot.sh +152 -12
  104. package/apps/studio/bin/server-up.sh +64 -6
  105. package/apps/studio/bin/smoke.sh +43 -8
  106. package/apps/studio/bin/to-lottie.sh +3 -2
  107. package/apps/studio/bin/video-proxy.sh +27 -0
  108. package/apps/studio/bin/visual-sanity.sh +3 -1
  109. package/apps/studio/bridge/dgn-protocol.ts +157 -1
  110. package/apps/studio/bridge/mode-shows.ts +8 -6
  111. package/apps/studio/bridge/still-webp.ts +233 -0
  112. package/apps/studio/build.ts +18 -0
  113. package/apps/studio/canvas-build.ts +93 -11
  114. package/apps/studio/canvas-comment-mount.tsx +53 -8
  115. package/apps/studio/canvas-edit.ts +34 -1
  116. package/apps/studio/canvas-lib-module.ts +210 -0
  117. package/apps/studio/canvas-lib.tsx +3 -12
  118. package/apps/studio/canvas-pipeline.ts +111 -5
  119. package/apps/studio/canvas-shell.tsx +8 -11
  120. package/apps/studio/canvas-theme-pill.tsx +5 -3
  121. package/apps/studio/check/index.ts +12 -5
  122. package/apps/studio/check/video.ts +18 -2
  123. package/apps/studio/client/app.jsx +65 -7
  124. package/apps/studio/client/clipboard-relay.ts +193 -16
  125. package/apps/studio/client/comments-overlay.css +18 -0
  126. package/apps/studio/client/export-center.jsx +30 -0
  127. package/apps/studio/client/generate-dialog.jsx +49 -4
  128. package/apps/studio/client/github.js +7 -0
  129. package/apps/studio/client/home/HomeAccountsRow.jsx +221 -0
  130. package/apps/studio/client/home/HomeConnection.jsx +111 -0
  131. package/apps/studio/client/home/home-accounts-model.js +110 -1
  132. package/apps/studio/client/home/home-api.js +9 -2
  133. package/apps/studio/client/home/home-app.jsx +126 -13
  134. package/apps/studio/client/home/home-model.js +69 -1
  135. package/apps/studio/client/home/home-where-model.js +105 -0
  136. package/apps/studio/client/home/home.css +239 -1
  137. package/apps/studio/client/hooks/use-canvas-bridge.jsx +173 -98
  138. package/apps/studio/client/hooks/use-palette-and-panels.jsx +5 -1
  139. package/apps/studio/client/hooks/use-tabs.jsx +11 -4
  140. package/apps/studio/client/panels/DiffView.jsx +7 -1
  141. package/apps/studio/client/panels/TeamProjects.jsx +137 -134
  142. package/apps/studio/client/panels/chat-context.js +2 -0
  143. package/apps/studio/client/panels/slash-commands.gen.js +13 -13
  144. package/apps/studio/client/selection-scope.js +16 -9
  145. package/apps/studio/client/share-link.js +12 -0
  146. package/apps/studio/client/shell/viewport.jsx +11 -1
  147. package/apps/studio/client/shell-events.js +8 -0
  148. package/apps/studio/client/styles/3-kit-maude-v2.css +16 -0
  149. package/apps/studio/client/styles/_index.css +4 -0
  150. package/apps/studio/client/v2/ai/Feed.jsx +1 -1
  151. package/apps/studio/client/v2/ai/OfferCard.jsx +34 -0
  152. package/apps/studio/client/v2/ai/activity-line.js +54 -1
  153. package/apps/studio/client/v2/ai/ai-offer.js +21 -1
  154. package/apps/studio/client/v2/ai/run-model.js +3 -1
  155. package/apps/studio/client/v2/annotations/vote-store.js +28 -4
  156. package/apps/studio/client/v2/assets/asset-drop-session.js +37 -2
  157. package/apps/studio/client/v2/assets/canvas-drop-catcher.jsx +7 -5
  158. package/apps/studio/client/v2/assets/details-model.js +1 -1
  159. package/apps/studio/client/v2/assets/details.jsx +5 -0
  160. package/apps/studio/client/v2/assets/tile-drag.js +11 -7
  161. package/apps/studio/client/v2/comments/comments-panel.jsx +22 -3
  162. package/apps/studio/client/v2/create/duplicate-done.js +6 -2
  163. package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
  164. package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
  165. package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
  166. package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
  167. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +113 -3
  168. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +343 -6
  169. package/apps/studio/client/v2/diagnostics/sync-details/unsynced-refs.js +55 -0
  170. package/apps/studio/client/v2/ds/review.css +1 -1
  171. package/apps/studio/client/v2/export/exports-model.js +7 -0
  172. package/apps/studio/client/v2/export/exports-panel.jsx +1 -0
  173. package/apps/studio/client/v2/export/job-row.jsx +32 -2
  174. package/apps/studio/client/v2/handoff/ready-card.jsx +1 -1
  175. package/apps/studio/client/v2/history/compare-view.jsx +1 -0
  176. package/apps/studio/client/v2/inspector/css-write.js +6 -1
  177. package/apps/studio/client/v2/inspector/frame.jsx +28 -4
  178. package/apps/studio/client/v2/inspector/kinds/clip-model.js +51 -0
  179. package/apps/studio/client/v2/inspector/kinds/clip.jsx +75 -2
  180. package/apps/studio/client/v2/inspector/model.js +21 -0
  181. package/apps/studio/client/v2/inspector/sections/fill.jsx +12 -3
  182. package/apps/studio/client/v2/inspector/sections/recent-colours.js +8 -5
  183. package/apps/studio/client/v2/inspector/view-mode.jsx +11 -1
  184. package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
  185. package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
  186. package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
  187. package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
  188. package/apps/studio/client/v2/link-server/link-server.css +109 -0
  189. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
  190. package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
  191. package/apps/studio/client/v2/preview/link-follow.js +4 -2
  192. package/apps/studio/client/v2/preview/preview-chrome-host.jsx +16 -6
  193. package/apps/studio/client/v2/search/help-model.js +2 -0
  194. package/apps/studio/client/v2/search/search-keywords.js +3 -2
  195. package/apps/studio/client/v2/settings/account.jsx +4 -2
  196. package/apps/studio/client/v2/settings/advanced-section.jsx +344 -137
  197. package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
  198. package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
  199. package/apps/studio/client/v2/settings/general-section.jsx +155 -24
  200. package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
  201. package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
  202. package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
  203. package/apps/studio/client/v2/settings/settings-cards.js +220 -0
  204. package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
  205. package/apps/studio/client/v2/settings/settings-model.js +100 -31
  206. package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
  207. package/apps/studio/client/v2/settings/settings.css +374 -64
  208. package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
  209. package/apps/studio/client/v2/settings/this-project-model.js +172 -0
  210. package/apps/studio/client/v2/settings/use-connections.js +3 -2
  211. package/apps/studio/client/v2/settings/use-open-card.js +37 -0
  212. package/apps/studio/client/v2/share/share-sheet.jsx +28 -11
  213. package/apps/studio/client/v2/shell/api-session-boot.js +6 -0
  214. package/apps/studio/client/v2/shell/api-session.js +126 -0
  215. package/apps/studio/client/v2/shell/connection-state.js +197 -0
  216. package/apps/studio/client/v2/shell/floating-panels.css +31 -1
  217. package/apps/studio/client/v2/shell/image-pick.js +61 -8
  218. package/apps/studio/client/v2/shell/menu-aim.js +43 -0
  219. package/apps/studio/client/v2/shell/menu-runner.js +25 -7
  220. package/apps/studio/client/v2/shell/occlusion-insets.js +18 -1
  221. package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
  222. package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
  223. package/apps/studio/client/v2/shell/project-account-model.js +272 -149
  224. package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
  225. package/apps/studio/client/v2/shell/project-account.css +237 -0
  226. package/apps/studio/client/v2/shell/project-pill.jsx +52 -6
  227. package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
  228. package/apps/studio/client/v2/shell/shell-parity.js +3 -2
  229. package/apps/studio/client/v2/shell/shell-parity.json +71 -36
  230. package/apps/studio/client/v2/shell/still-bridge.js +194 -0
  231. package/apps/studio/client/v2/shell/still-store.js +319 -0
  232. package/apps/studio/client/v2/shell/use-account.js +2 -0
  233. package/apps/studio/client/v2/shell/use-tool-panels.js +2 -1
  234. package/apps/studio/client/v2/signin/use-signin.js +1 -1
  235. package/apps/studio/client/v2/timeline/Timeline.jsx +15 -0
  236. package/apps/studio/client/v2/timeline/frame-handle-model.js +142 -0
  237. package/apps/studio/client/v2/timeline/frame-handle.jsx +151 -0
  238. package/apps/studio/clip-ops.ts +126 -8
  239. package/apps/studio/cloud/endpoints.ts +29 -4
  240. package/apps/studio/collab/ai-activity.ts +10 -8
  241. package/apps/studio/collab/awareness-bridge.ts +34 -9
  242. package/apps/studio/collab/index.ts +3 -0
  243. package/apps/studio/collab/registry.ts +41 -10
  244. package/apps/studio/comment-reattach.ts +149 -0
  245. package/apps/studio/comments/mine-stamp.ts +15 -7
  246. package/apps/studio/comments/ops.ts +52 -8
  247. package/apps/studio/comments-overlay.tsx +146 -9
  248. package/apps/studio/dist/client.bundle.js +892 -885
  249. package/apps/studio/dist/comment-mount.js +2 -2
  250. package/apps/studio/dist/styles.css +1 -1
  251. package/apps/studio/dom-selection.ts +87 -18
  252. package/apps/studio/ds/board/directions.css +8 -0
  253. package/apps/studio/ds/board/outline.tsx +16 -0
  254. package/apps/studio/ds/canvas-check.ts +6 -0
  255. package/apps/studio/edit-ops/clip/reframe.ts +19 -3
  256. package/apps/studio/edit-ops/clip-carry.ts +602 -0
  257. package/apps/studio/edit-ops/clipboard.ts +318 -23
  258. package/apps/studio/edit-ops/dispatch.ts +20 -2
  259. package/apps/studio/edit-ops/scope-names.ts +249 -40
  260. package/apps/studio/edit-ops/slot-defaults.ts +3 -0
  261. package/apps/studio/edit-ops/types.ts +6 -0
  262. package/apps/studio/editing/align-bar.tsx +33 -9
  263. package/apps/studio/editing/artboard-actions.ts +5 -0
  264. package/apps/studio/editing/artboard-menu.tsx +6 -2
  265. package/apps/studio/editing/click-to-type.ts +1 -1
  266. package/apps/studio/editing/clip-words.ts +48 -0
  267. package/apps/studio/editing/clipboard.ts +21 -6
  268. package/apps/studio/editing/declared-background.ts +25 -0
  269. package/apps/studio/editing/index.tsx +3 -0
  270. package/apps/studio/editing/object-keys.ts +4 -4
  271. package/apps/studio/editing/object-menu.tsx +13 -3
  272. package/apps/studio/editing/pen/points.tsx +61 -0
  273. package/apps/studio/editing/text-in-place.tsx +11 -0
  274. package/apps/studio/editing/video-frame-handle.tsx +425 -0
  275. package/apps/studio/exporters/capture-prepass.ts +374 -0
  276. package/apps/studio/exporters/degraded.ts +148 -0
  277. package/apps/studio/exporters/hub-render-door.ts +28 -2
  278. package/apps/studio/exporters/index.ts +3 -1
  279. package/apps/studio/exporters/job-budget.ts +93 -0
  280. package/apps/studio/exporters/jobs.ts +215 -28
  281. package/apps/studio/exporters/parity-check.ts +254 -0
  282. package/apps/studio/exporters/remote.ts +209 -15
  283. package/apps/studio/exporters/svg-inline.ts +87 -0
  284. package/apps/studio/exporters/video-render-lib.ts +88 -26
  285. package/apps/studio/exporters/video.ts +29 -6
  286. package/apps/studio/figma/assets.ts +58 -43
  287. package/apps/studio/figma/codegen-fonts.ts +100 -0
  288. package/apps/studio/figma/fig-decode.ts +390 -25
  289. package/apps/studio/figma/fig-kiwi.ts +18 -4
  290. package/apps/studio/figma/fig-vector.ts +59 -3
  291. package/apps/studio/figma/sanitize.ts +2 -0
  292. package/apps/studio/figma/style-map.ts +293 -48
  293. package/apps/studio/figma/to-artboard.ts +455 -69
  294. package/apps/studio/figma/to-strokes.ts +44 -11
  295. package/apps/studio/figma/types.ts +13 -0
  296. package/apps/studio/footage/schema.ts +3 -3
  297. package/apps/studio/generation/adapters/elevenlabs.ts +7 -1
  298. package/apps/studio/generation/adapters/groq.ts +8 -1
  299. package/apps/studio/generation/spend.ts +312 -0
  300. package/apps/studio/generation/types.ts +12 -0
  301. package/apps/studio/handoff/run.ts +1 -1
  302. package/apps/studio/handoff/targets.ts +2 -2
  303. package/apps/studio/handoff/write-scopes.ts +1 -1
  304. package/apps/studio/history/describe-annotations.ts +4 -0
  305. package/apps/studio/home/accounts.ts +30 -11
  306. package/apps/studio/home/cloud.ts +6 -1
  307. package/apps/studio/home/create-local.ts +32 -3
  308. package/apps/studio/home/hub-health.ts +76 -0
  309. package/apps/studio/home/routes.ts +15 -4
  310. package/apps/studio/http.ts +438 -86
  311. package/apps/studio/imported-module-ids.ts +91 -0
  312. package/apps/studio/inspect.ts +2 -0
  313. package/apps/studio/migrate/hub.ts +8 -1
  314. package/apps/studio/notifications.tsx +47 -5
  315. package/apps/studio/paths.ts +10 -1
  316. package/apps/studio/port.ts +3 -2
  317. package/apps/studio/preview/preview-camera.tsx +15 -382
  318. package/apps/studio/readiness.ts +10 -1
  319. package/apps/studio/release-build.ts +51 -0
  320. package/apps/studio/routes/agent.ts +188 -9
  321. package/apps/studio/routes/ai.ts +43 -11
  322. package/apps/studio/routes/annotations.ts +27 -1
  323. package/apps/studio/routes/assets.ts +18 -1
  324. package/apps/studio/routes/canvas-origin.ts +12 -9
  325. package/apps/studio/routes/cloud-move.ts +15 -0
  326. package/apps/studio/routes/edit.ts +3 -0
  327. package/apps/studio/routes/export.ts +51 -0
  328. package/apps/studio/routes/generate.ts +42 -12
  329. package/apps/studio/routes/hub-link-folder.ts +334 -0
  330. package/apps/studio/routes/hub-signin.ts +78 -1
  331. package/apps/studio/routes/index.ts +9 -1
  332. package/apps/studio/routes/shell.ts +217 -5
  333. package/apps/studio/routes/sync.ts +136 -8
  334. package/apps/studio/routes/votes.ts +2 -1
  335. package/apps/studio/schema/annotations.v2.schema.json +143 -1
  336. package/apps/studio/schema/beats.v1.schema.json +1 -1
  337. package/apps/studio/schema/edl.v1.schema.json +1 -1
  338. package/apps/studio/schema/formats.ts +3 -3
  339. package/apps/studio/schema/transcript.v1.schema.json +1 -1
  340. package/apps/studio/server.ts +142 -43
  341. package/apps/studio/shell/api-key.ts +503 -0
  342. package/apps/studio/shell/attest.ts +59 -0
  343. package/apps/studio/shell/capture-url.ts +20 -0
  344. package/apps/studio/shell/cli-yield.ts +276 -0
  345. package/apps/studio/shell/clip-transfer.ts +302 -0
  346. package/apps/studio/shell/key-file.ts +108 -0
  347. package/apps/studio/shell/server-json.ts +75 -0
  348. package/apps/studio/shell/worktree.ts +19 -0
  349. package/apps/studio/spoof-chars.ts +9 -0
  350. package/apps/studio/studio-page-host.ts +1 -1
  351. package/apps/studio/sync/accepted-cold-start.ts +144 -8
  352. package/apps/studio/sync/accepted-link.ts +76 -29
  353. package/apps/studio/sync/action-stage.ts +575 -44
  354. package/apps/studio/sync/adopt-held.ts +85 -0
  355. package/apps/studio/sync/ctl-heal.ts +58 -0
  356. package/apps/studio/sync/file-ledger.ts +38 -4
  357. package/apps/studio/sync/file-membership.ts +16 -1
  358. package/apps/studio/sync/file-plane.ts +289 -22
  359. package/apps/studio/sync/held-deletes.ts +86 -5
  360. package/apps/studio/sync/hub-link.ts +8 -0
  361. package/apps/studio/sync/index.ts +196 -12
  362. package/apps/studio/sync/journal-client.ts +50 -4
  363. package/apps/studio/sync/link-consent.ts +22 -75
  364. package/apps/studio/sync/link-survey.ts +252 -0
  365. package/apps/studio/sync/local-kernel.ts +296 -8
  366. package/apps/studio/sync/projection.ts +22 -3
  367. package/apps/studio/sync/seed-progress.ts +12 -0
  368. package/apps/studio/sync/source-recovery.ts +59 -3
  369. package/apps/studio/sync/status.ts +19 -2
  370. package/apps/studio/sync/unsynced-refs.ts +397 -0
  371. package/apps/studio/sync/writer-registry.ts +20 -0
  372. package/apps/studio/thumbs/service.ts +4 -1
  373. package/apps/studio/tool-palette.tsx +23 -0
  374. package/apps/studio/ui-prefs.ts +40 -0
  375. package/apps/studio/use-agent-presence.tsx +2 -2
  376. package/apps/studio/use-canvas-keys.ts +6 -1
  377. package/apps/studio/video/format-ids.ts +2 -2
  378. package/apps/studio/video/inject.ts +31 -0
  379. package/apps/studio/video/media-risk.ts +58 -0
  380. package/apps/studio/video/object-fit.ts +137 -0
  381. package/apps/studio/video/provider-transcript.ts +141 -0
  382. package/apps/studio/whats-new.json +137 -0
  383. package/apps/studio/workspace-mode.ts +1 -0
  384. package/apps/studio/ws.ts +5 -0
  385. package/cli/commands/design.mjs +119 -8
  386. package/cli/lib/bash-guard.mjs +366 -6
  387. package/cli/lib/confine-read.mjs +1 -0
  388. package/cli/lib/design-help.gen.mjs +3 -2
  389. package/cli/lib/design-hook.mjs +387 -81
  390. package/cli/lib/design-link.mjs +16 -1
  391. package/cli/lib/design-open.mjs +49 -3
  392. package/cli/lib/desktop-locate.mjs +770 -0
  393. package/cli/lib/handoff.mjs +1 -1
  394. package/cli/lib/hook-state.mjs +291 -0
  395. package/cli/lib/pkg-root.mjs +65 -13
  396. package/cli/lib/studio-locate.mjs +59 -16
  397. package/package.json +15 -8
  398. package/plugins/design/templates/_shell.html +13 -0
  399. package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
  400. package/apps/studio/client/v2/shell/account-card-model.js +0 -114
  401. package/apps/studio/client/v2/shell/account-card.jsx +0 -189
@@ -0,0 +1,87 @@
1
+ // svg-inline.ts — issue #150 §1: keep an inline <svg>'s own box out of the bitmap
2
+ // @remotion/web-renderer draws for it.
3
+ //
4
+ // `turnSvgIntoDrawable` (web-renderer) serializes the LIVE <svg> element — its
5
+ // inline `style` attribute included — into a standalone `data:image/svg+xml`
6
+ // document, loads that as an Image and draws it into the frame. In the standalone
7
+ // document the <svg> is the ROOT, so an inline `position:absolute; left:300px;
8
+ // top:80px` (the usual way a logo / flying shape / divider is placed on a comp)
9
+ // moves the artwork 300 × 80 px out of the image's own viewport: the image loads,
10
+ // `onload` fires, nothing throws, and the bitmap is empty. The renderer already
11
+ // neutralizes `transform` and the margins around that serialization; it forgets
12
+ // the rest of the box. The page's CSP is not involved (`img-src` allows `data:`
13
+ // and `blob:`, probed live) and is NOT widened by this fix.
14
+ //
15
+ // This module lives in the capture shim, not in node_modules: the guard patches
16
+ // `XMLSerializer.prototype.serializeToString` for the duration of one render, so
17
+ // the library stays unpatched (no per-workspace patchedDependencies entry, DDR-176)
18
+ // and a renderer upgrade that fixes this itself just makes the guard a no-op.
19
+ //
20
+ // Browser-safe and React-free; imported by `video-render-lib.ts` (runs inside the
21
+ // capture Chromium) and unit-tested under happy-dom.
22
+
23
+ /**
24
+ * Inline-style properties that place an element inside ITS PARENT — meaningless
25
+ * (or harmful) once the <svg> is the root of its own image document. `margin*`
26
+ * and `transform*` are already reset by the renderer itself.
27
+ */
28
+ export const SVG_POSITIONAL_PROPS: readonly string[] = [
29
+ 'position',
30
+ 'top',
31
+ 'right',
32
+ 'bottom',
33
+ 'left',
34
+ 'inset',
35
+ 'inset-block',
36
+ 'inset-inline',
37
+ 'translate',
38
+ 'rotate',
39
+ 'scale',
40
+ ];
41
+
42
+ interface SavedProp {
43
+ prop: string;
44
+ value: string;
45
+ priority: string;
46
+ }
47
+
48
+ /**
49
+ * Clear the positional inline style on `svg`, run `fn`, put it back exactly as it
50
+ * was (value AND `!important`). Synchronous on purpose: the renderer reads the
51
+ * serialization in the same tick, and the live element must never be left
52
+ * mutated for a frame the Player (or the next measurement) could observe.
53
+ */
54
+ export function withSvgBoxNeutralized<T>(svg: SVGSVGElement, fn: () => T): T {
55
+ const style = svg.style;
56
+ const saved: SavedProp[] = [];
57
+ for (const prop of SVG_POSITIONAL_PROPS) {
58
+ const value = style.getPropertyValue(prop);
59
+ if (value === '') continue;
60
+ saved.push({ prop, value, priority: style.getPropertyPriority(prop) });
61
+ style.removeProperty(prop);
62
+ }
63
+ try {
64
+ return fn();
65
+ } finally {
66
+ for (const { prop, value, priority } of saved) style.setProperty(prop, value, priority);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Wrap `XMLSerializer.prototype.serializeToString` so an <svg> ROOT is serialized
72
+ * without its own box. Anything else (every other node, every other caller)
73
+ * passes straight through. Returns the restore function — call it in a `finally`.
74
+ */
75
+ export function installSvgSerializeGuard(): () => void {
76
+ const proto = XMLSerializer.prototype;
77
+ const original = proto.serializeToString;
78
+ proto.serializeToString = function guardedSerializeToString(this: XMLSerializer, node: Node) {
79
+ if (typeof SVGSVGElement !== 'undefined' && node instanceof SVGSVGElement) {
80
+ return withSvgBoxNeutralized(node, () => original.call(this, node));
81
+ }
82
+ return original.call(this, node);
83
+ };
84
+ return () => {
85
+ proto.serializeToString = original;
86
+ };
87
+ }
@@ -27,6 +27,16 @@
27
27
  import { renderMediaOnWeb } from '@remotion/web-renderer';
28
28
  import type { ComponentType } from 'react';
29
29
 
30
+ import { installCapturePrepass } from './capture-prepass.ts';
31
+ import {
32
+ mergeFindings,
33
+ type ParityFinding,
34
+ type ParityScan,
35
+ sampleFrames,
36
+ scanParity,
37
+ } from './parity-check.ts';
38
+ import { installSvgSerializeGuard } from './svg-inline.ts';
39
+
30
40
  interface RenderVideoOpts {
31
41
  component: ComponentType<Record<string, unknown>>;
32
42
  inputProps?: Record<string, unknown>;
@@ -73,32 +83,44 @@ async function renderVideo(opts: RenderVideoOpts): Promise<RenderVideoResult> {
73
83
  typeof renderMediaOnWeb
74
84
  >[0]['audioCodec']);
75
85
 
76
- const result = await renderMediaOnWeb({
77
- composition: {
78
- component: opts.component,
79
- id: 'maude-export',
80
- width: opts.width,
81
- height: opts.height,
82
- fps: opts.fps,
83
- durationInFrames: opts.durationInFrames,
84
- },
85
- inputProps: opts.inputProps ?? {},
86
- container: opts.container,
87
- videoCodec,
88
- audioCodec,
89
- muted,
90
- scale: opts.scale ?? 1,
91
- frameRange: opts.frameRange ?? null,
92
- isProduction: true,
93
- licenseKey: opts.licenseKey ?? 'free-license',
94
- logLevel: 'error',
95
- // Remotion defaults this to 'medium', which yields the event loop every
96
- // ~33 ms to keep a page interactive while it renders. Nobody is looking at
97
- // this page — it is a headless capture Chromium with no UI — so the courtesy
98
- // is pure overhead. 'disabled' is Remotion's documented setting for exactly
99
- // this case (client-side rendering / page-responsiveness).
100
- pageResponsiveness: 'disabled',
101
- });
86
+ // Issue #150 §1 — an inline <svg> with its own `position`/`left`/`top` rendered
87
+ // as an empty bitmap. The guard is scoped to this one render (see svg-inline.ts).
88
+ const restoreSerializer = installSvgSerializeGuard();
89
+ // Issue #150 §2 + §3 — a size-less svg <img> drawn cropped / not at all, and absolute children
90
+ // of a transformed static parent jumping to the frame. Scoped to this one render too.
91
+ const restorePrepass = installCapturePrepass();
92
+ let result: Awaited<ReturnType<typeof renderMediaOnWeb>>;
93
+ try {
94
+ result = await renderMediaOnWeb({
95
+ composition: {
96
+ component: opts.component,
97
+ id: 'maude-export',
98
+ width: opts.width,
99
+ height: opts.height,
100
+ fps: opts.fps,
101
+ durationInFrames: opts.durationInFrames,
102
+ },
103
+ inputProps: opts.inputProps ?? {},
104
+ container: opts.container,
105
+ videoCodec,
106
+ audioCodec,
107
+ muted,
108
+ scale: opts.scale ?? 1,
109
+ frameRange: opts.frameRange ?? null,
110
+ isProduction: true,
111
+ licenseKey: opts.licenseKey ?? 'free-license',
112
+ logLevel: 'error',
113
+ // Remotion defaults this to 'medium', which yields the event loop every
114
+ // ~33 ms to keep a page interactive while it renders. Nobody is looking at
115
+ // this page — it is a headless capture Chromium with no UI — so the courtesy
116
+ // is pure overhead. 'disabled' is Remotion's documented setting for exactly
117
+ // this case (client-side rendering / page-responsiveness).
118
+ pageResponsiveness: 'disabled',
119
+ });
120
+ } finally {
121
+ restorePrepass();
122
+ restoreSerializer();
123
+ }
102
124
  const blob = await result.getBlob();
103
125
  const buf = new Uint8Array(await blob.arrayBuffer());
104
126
  return {
@@ -112,3 +134,43 @@ async function renderVideo(opts: RenderVideoOpts): Promise<RenderVideoResult> {
112
134
 
113
135
  (globalThis as unknown as { __maudeRenderVideo__: typeof renderVideo }).__maudeRenderVideo__ =
114
136
  renderVideo;
137
+
138
+ interface SeekWindow {
139
+ __maude_seek__?: (frame: number) => Promise<void>;
140
+ __maude_comps__?: () => Array<{ id: string; durationInFrames: number }>;
141
+ }
142
+
143
+ /**
144
+ * #150 §4 / #128 §8 — what the renderer will not draw the way the Player does, found BEFORE the
145
+ * render starts, by reading the Player's own DOM at a few frames (an element can appear mid-comp).
146
+ * Never throws and never blocks: a failed seek or an unreadable page just means fewer findings.
147
+ */
148
+ async function parityCheck(compId: string): Promise<ParityScan> {
149
+ const w = globalThis as unknown as SeekWindow;
150
+ const rootOf = (): Element | undefined =>
151
+ [...document.querySelectorAll('[data-comp-id]')].find(
152
+ (e) => e.getAttribute('data-comp-id') === compId
153
+ );
154
+ const first = rootOf();
155
+ const artboard = first?.closest('[data-dc-screen]')?.getAttribute('data-dc-screen') ?? null;
156
+ const duration = w.__maude_comps__?.().find((c) => c.id === compId)?.durationInFrames ?? 1;
157
+ let findings: ParityFinding[] = [];
158
+ for (const frame of sampleFrames(duration)) {
159
+ try {
160
+ await w.__maude_seek__?.(frame);
161
+ } catch {
162
+ /* the comp stays on the frame it had */
163
+ }
164
+ const root = rootOf();
165
+ if (root) findings = mergeFindings(findings, scanParity(root));
166
+ }
167
+ try {
168
+ await w.__maude_seek__?.(0);
169
+ } catch {
170
+ /* as above */
171
+ }
172
+ return { artboard, findings };
173
+ }
174
+
175
+ (globalThis as unknown as { __maudeParityCheck__: typeof parityCheck }).__maudeParityCheck__ =
176
+ parityCheck;
@@ -21,7 +21,13 @@ import path from 'node:path';
21
21
 
22
22
  import { getEncodeLibBundle, getWebRendererBundle } from './_browser-bundles.ts';
23
23
  import { exportShimPath, runShim } from './_runtime.ts';
24
- import { type ExportDegradation, hasAudioStream, remedyFor } from './degraded.ts';
24
+ import {
25
+ type ExportDegradation,
26
+ hasAudioStream,
27
+ mergeDegraded,
28
+ parityGap,
29
+ remedyFor,
30
+ } from './degraded.ts';
25
31
  import {
26
32
  canvasShellUrl,
27
33
  type ExportContext,
@@ -93,6 +99,14 @@ const MAX_FRAMES_CEILING = 18000;
93
99
  * captures have died from memory pressure — warn loudly, recommend ≤720p. */
94
100
  const HEAVY_FRAMES_WARNING = 900; // 30 s @ 30 fps
95
101
 
102
+ /** `--scale` for the capture shim: the user's 1–3× choice, or `auto` (the shim picks by artboard size). */
103
+ export function resolveScaleArg(options: { scale?: unknown }): string {
104
+ const raw: unknown = options.scale;
105
+ if (raw === undefined || raw === null || raw === '') return 'auto';
106
+ const scale = clampInt(raw, 1, 3);
107
+ return scale ? String(scale) : 'auto';
108
+ }
109
+
96
110
  async function runVideo(
97
111
  format: VideoFormat,
98
112
  targets: Target[],
@@ -205,11 +219,11 @@ async function runVideo(
205
219
  args.push('--license-key', process.env.MAUDE_REMOTION_LICENSE);
206
220
  }
207
221
 
208
- // Resolution multiplier (1–3×) — the artboard's native size × scale. Default 2×
209
- // so a 960×540 comp exports at 1920×1080 instead of a tiny native capture. The
210
- // shim applies it as deviceScaleFactor AND sizes the encoder to match.
211
- const scale = clampInt(options.scale, 1, 3) ?? 2;
212
- args.push('--scale', String(scale));
222
+ // Resolution multiplier (1–3×) — the artboard's native size × scale. The shim applies it as
223
+ // deviceScaleFactor AND sizes the encoder to match. When the user passed none, `auto` makes the
224
+ // shim measure the artboard and pick the default (1× from a 1080 px short side up, else 2× —
225
+ // decision maude/burndown-d6-default-export-scale); the exporter cannot, it never sees the size.
226
+ args.push('--scale', resolveScaleArg(options));
213
227
 
214
228
  const fps = clampInt(options.fps, 1, 60);
215
229
  if (fps) args.push('--fps', String(fps));
@@ -272,6 +286,9 @@ async function runVideo(
272
286
  // A pre-flight finding stands unless the shim reports its own, more specific
273
287
  // cause below — never let a clean-looking summary erase a known defect.
274
288
  let degraded: ExportDegradation | undefined = preStamped;
289
+ // The pre-render parity warning is applied LAST: it must not make `degraded` truthy before the
290
+ // audio backstop below, which only speaks when nothing else has.
291
+ let parityNote: ExportDegradation | undefined;
275
292
  try {
276
293
  const lastLine = stdoutLines.at(-1) ?? '{}';
277
294
  const summary = JSON.parse(lastLine) as {
@@ -279,8 +296,12 @@ async function runVideo(
279
296
  degraded?: boolean;
280
297
  audioDropped?: boolean;
281
298
  fallbackReason?: string;
299
+ /** #150 §4 — the pre-render parity scan (only when the one-pass renderer drew the file) */
300
+ parity?: unknown;
282
301
  };
283
302
  if (summary.container) ext = summary.container;
303
+ parityNote = parityGap(summary.parity);
304
+ if (parityNote) console.error(`⚠ ${format} export: ${parityNote.reason}`);
284
305
  if (summary.degraded) {
285
306
  const reason = summary.fallbackReason ?? 'unknown';
286
307
  console.error(
@@ -315,6 +336,8 @@ async function runVideo(
315
336
  console.error(`⚠ ${format} export produced no audio track despite audio being requested.`);
316
337
  }
317
338
 
339
+ degraded = mergeDegraded(degraded, parityNote);
340
+
318
341
  return {
319
342
  filename: `${el.canvasSlug}.${ext}`,
320
343
  contentType: CONTENT_TYPE[ext] ?? 'application/octet-stream',
@@ -95,6 +95,59 @@ export const MAX_CONCURRENT_DOWNLOADS = 4;
95
95
  */
96
96
  export const MAX_SVG_PROMOTE_CHUNK = 24;
97
97
 
98
+ /**
99
+ * Promote many staged SVGs through the shared lane, CHUNKED and with one retry,
100
+ * failing closed per chunk. One `promoteBatch` call is one browser session, so
101
+ * the chunk size trades browser launches against blast radius — see
102
+ * `MAX_SVG_PROMOTE_CHUNK`. Returns one ref (or null) per input, in order.
103
+ *
104
+ * CHUNKED, because "fail closed for the whole batch" and "one batch for the
105
+ * whole import" together turn a single browser timeout into total asset loss.
106
+ * Measured on a live 6-page import: the DDR-167 execution canary spawns
107
+ * `agent-browser` with a fixed 20 s budget (`_import-asset.mjs`), one session
108
+ * for the whole array — at 272 frame renders it blew that budget, the promote
109
+ * threw, and every one of the 272 became `asset-skipped`. The import still
110
+ * exited 0, so it reported success while producing a folder of broken images.
111
+ * Reproduced at 60 SVGs, and it reproduces WITHOUT any of the Figma-lane
112
+ * changes, so this is the shared lane's shape, not the caller's. Fail-closed is
113
+ * KEPT (the DDR-177 rule); what changes is the blast radius: a timeout costs
114
+ * its own chunk, and the rest of the artwork still lands.
115
+ *
116
+ * ONE RETRY, because the canary's failure is measurably TRANSIENT rather than a
117
+ * property of the input (the same lane promoted 4/4 and 24/24 but threw on 12).
118
+ * A chunk lost to a coin-flip is a permanently broken image in a versioned
119
+ * artifact, and a second attempt is one browser launch. Bounded at one: a lane
120
+ * that is genuinely down must fail fast rather than retry a dozen chunks into a
121
+ * multi-minute stall.
122
+ */
123
+ export async function promoteSvgInChunks(
124
+ promoteBatch: (stagedPaths: string[]) => Promise<Array<string | null>>,
125
+ stagedPaths: readonly string[]
126
+ ): Promise<Array<string | null>> {
127
+ const refs: Array<string | null> = [];
128
+ for (let start = 0; start < stagedPaths.length; start += MAX_SVG_PROMOTE_CHUNK) {
129
+ const chunk = stagedPaths.slice(start, start + MAX_SVG_PROMOTE_CHUNK);
130
+ let got: Array<string | null> | null = null;
131
+ for (let attempt = 0; attempt < 2 && got === null; attempt += 1) {
132
+ try {
133
+ got = await promoteBatch(chunk);
134
+ } catch {
135
+ got = null;
136
+ }
137
+ }
138
+ if (got === null) {
139
+ // FAIL CLOSED: the bun-side lane being unavailable must never become
140
+ // "we already have the bytes" (DDR-177's packaged-app failure mode).
141
+ for (let i = 0; i < chunk.length; i += 1) refs.push(null);
142
+ continue;
143
+ }
144
+ // A short return would silently shift every later ref onto the wrong
145
+ // node — pad rather than trust the length.
146
+ for (let i = 0; i < chunk.length; i += 1) refs.push(got[i] ?? null);
147
+ }
148
+ return refs;
149
+ }
150
+
98
151
  export interface AssetRequest {
99
152
  nodeId: string;
100
153
  format: 'svg' | 'png';
@@ -366,49 +419,11 @@ export async function resolveAssets(
366
419
  });
367
420
 
368
421
  if (stagedSvgs.length > 0 && deps.promoteSvgBatch) {
369
- const refs: Array<string | null> = [];
370
- // CHUNKED, because "fail closed for the whole batch" and "one batch for the
371
- // whole import" together turn a single browser timeout into total asset
372
- // loss. Measured on a live 6-page import: the DDR-167 execution canary
373
- // spawns `agent-browser` with a fixed 20 s budget (`_import-asset.mjs`), one
374
- // session for the whole array — at 272 frame renders it blew that budget,
375
- // the promote threw, and every one of the 272 became `asset-skipped`. The
376
- // import still exited 0, so it reported success while producing a folder of
377
- // broken images. Reproduced at 60 SVGs, and it reproduces WITHOUT any of the
378
- // Figma-lane changes, so this is the shared lane's shape, not the caller's.
379
- //
380
- // Fail-closed is KEPT — it is the DDR-177 rule and it is right. What changes
381
- // is the blast radius: a timeout now costs its own chunk, and the rest of
382
- // the artwork still lands.
383
- for (let start = 0; start < stagedSvgs.length; start += MAX_SVG_PROMOTE_CHUNK) {
384
- const chunk = stagedSvgs.slice(start, start + MAX_SVG_PROMOTE_CHUNK);
385
- let got: Array<string | null> | null = null;
386
- // ONE RETRY, because the canary's failure is measurably TRANSIENT rather
387
- // than a property of the input. Measured on a cleaned machine: the same
388
- // lane promoted 4/4 (30.7 s) and 24/24 (42.3 s) but threw on 12 (24.3 s) —
389
- // the budget is per `agent-browser` invocation, and a big frame render
390
- // flirts with it. A chunk lost to a coin-flip is a permanently broken
391
- // image in a versioned artifact, and a second attempt is one browser
392
- // launch. Bounded at one: a lane that is genuinely down must still fail
393
- // fast rather than retry 12 chunks into a multi-minute stall.
394
- for (let attempt = 0; attempt < 2 && got === null; attempt += 1) {
395
- try {
396
- got = await deps.promoteSvgBatch(chunk.map((x) => x.staged));
397
- } catch {
398
- got = null;
399
- }
400
- }
401
- if (got === null) {
402
- // FAIL CLOSED, same rule as the per-file path: the bun-side lane being
403
- // unavailable must never become "we already have the bytes"
404
- // (DDR-177's packaged-app failure mode).
405
- for (let i = 0; i < chunk.length; i += 1) refs.push(null);
406
- continue;
407
- }
408
- // A short return would silently shift every later ref onto the wrong
409
- // node — pad rather than trust the length.
410
- for (let i = 0; i < chunk.length; i += 1) refs.push(got[i] ?? null);
411
- }
422
+ const promoteBatch = deps.promoteSvgBatch.bind(deps);
423
+ const refs = await promoteSvgInChunks(
424
+ promoteBatch,
425
+ stagedSvgs.map((x) => x.staged)
426
+ );
412
427
  for (let i = 0; i < stagedSvgs.length; i += 1) {
413
428
  const { req, staged } = stagedSvgs[i];
414
429
  const ref = refs[i];
@@ -148,6 +148,99 @@ export function resolveFontFamily(
148
148
  return { css: SYSTEM_STACK, substituted: true, requested };
149
149
  }
150
150
 
151
+ // ── The tree lane (#155 §3, D8) ─────────────────────────────────────────────
152
+ //
153
+ // `resolveFontFamily` above serves the codegen lane, which may quote a
154
+ // ubiquitous family. The tree lane (`style-map.ts`) is stricter: the document's
155
+ // family name NEVER reaches the stylesheet. It is classified against a closed
156
+ // allowlist into sans / serif / mono and mapped onto the DS stack of that class.
157
+
158
+ export type FontClass = 'sans' | 'serif' | 'mono';
159
+
160
+ /** Fixed fallbacks when the DS has no stack of the class — code-owned constants, never document text. */
161
+ export const SERIF_STACK = "Georgia, 'Times New Roman', Times, serif";
162
+ export const MONO_STACK =
163
+ "ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace";
164
+ const FALLBACK_STACK: Record<FontClass, string> = Object.assign(Object.create(null), {
165
+ sans: SYSTEM_STACK,
166
+ serif: SERIF_STACK,
167
+ mono: MONO_STACK,
168
+ });
169
+
170
+ const MONO_RE =
171
+ /\bmono\b|monospace|\bcode\b|courier|consolas|menlo|monaco|jetbrains|inconsolata|iosevka|\bhack\b|\bterminal\b/;
172
+ const SERIF_RE =
173
+ /\bserif\b|georgia|times|garamond|playfair|merriweather|\blora\b|baskerville|crimson|cormorant|bodoni|didot|palatino|cambria|charter|fraunces|spectral|newsreader|\bcaslon\b|domine|literata|gelasio/;
174
+
175
+ /** Which DS stack a requested family belongs on. Sans is the default: when unsure, the neutral UI face. */
176
+ export function classifyFamily(rawFamily: string): FontClass {
177
+ const f = splitFamilyAndStyle(rawFamily).family.toLowerCase().replace(/[_-]+/g, ' ');
178
+ if (MONO_RE.test(f)) return 'mono';
179
+ if (/\bsans\b/.test(f)) return 'sans';
180
+ if (SERIF_RE.test(f)) return 'serif';
181
+ return 'sans';
182
+ }
183
+
184
+ const CLASS_TOKEN: Record<FontClass, RegExp> = Object.assign(Object.create(null), {
185
+ mono: /mono|code/,
186
+ serif: /serif/,
187
+ sans: /sans|body|text|base|ui/,
188
+ });
189
+
190
+ /** A token's declared families, quotes and case stripped, for an exact-name match. */
191
+ function declaredFamilies(value: string): string[] {
192
+ return value
193
+ .split(',')
194
+ .map((x) => x.replace(/['"]/g, '').trim().toLowerCase())
195
+ .filter(Boolean);
196
+ }
197
+
198
+ export function resolveDsFontStack(
199
+ rawFamily: string,
200
+ tokens: readonly FontToken[] = []
201
+ ): FontResolution & { fontClass: FontClass } {
202
+ const { family } = splitFamilyAndStyle(rawFamily);
203
+ const requested = attrValue(family, MAX_FAMILY_DETAIL);
204
+ const needle = family.toLowerCase().replace(/['"]/g, '').trim();
205
+ const fontClass = classifyFamily(family);
206
+
207
+ // The DS declares this very family: same typeface, reached through its variable.
208
+ if (needle.length > 0) {
209
+ for (const t of tokens) {
210
+ if (declaredFamilies(t.value).includes(needle)) {
211
+ return { css: `var(${t.name})`, substituted: false, requested, token: t.name, fontClass };
212
+ }
213
+ }
214
+ }
215
+ // Otherwise the DS stack of the same CLASS: a serif heading stays a serif.
216
+ const pattern = CLASS_TOKEN[fontClass];
217
+ const byClass = tokens.find((t) => {
218
+ if (!pattern.test(t.name)) return false;
219
+ if (fontClass === 'sans') return !/mono|code|serif/.test(t.name);
220
+ return true;
221
+ });
222
+ if (byClass) {
223
+ return {
224
+ css: `var(${byClass.name})`,
225
+ substituted: true,
226
+ requested,
227
+ token: byClass.name,
228
+ fontClass,
229
+ };
230
+ }
231
+ return { css: FALLBACK_STACK[fontClass], substituted: true, requested, fontClass };
232
+ }
233
+
234
+ /** True for exactly what `resolveDsFontStack` can return — a DS variable or one of the fixed stacks. */
235
+ export function isDsFontValue(v: string): boolean {
236
+ return (
237
+ /^var\(--[a-z0-9-]{1,64}\)$/.test(v) ||
238
+ v === SYSTEM_STACK ||
239
+ v === SERIF_STACK ||
240
+ v === MONO_STACK
241
+ );
242
+ }
243
+
151
244
  /**
152
245
  * Quote a family name for a CSS value position. Charset-allowlisted first, so a
153
246
  * family carrying a quote, a semicolon or a brace cannot terminate the
@@ -178,6 +271,13 @@ export class FontSubstitutions {
178
271
  this.counts.set(key, (this.counts.get(key) ?? 0) + 1);
179
272
  }
180
273
 
274
+ /** Fold another tally in, so a canvas of many frames reports each family once. */
275
+ absorb(other: FontSubstitutions): void {
276
+ for (const [family, n] of other.counts) {
277
+ this.counts.set(family, (this.counts.get(family) ?? 0) + n);
278
+ }
279
+ }
280
+
181
281
  get size(): number {
182
282
  return this.counts.size;
183
283
  }