@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
@@ -68,6 +68,7 @@ import {
68
68
  FIGMA_ASSET_HOSTS,
69
69
  FIGMA_RENDER_MAX_BYTES,
70
70
  makeAssetBudget,
71
+ promoteSvgInChunks,
71
72
  resolveAssets,
72
73
  } from '../figma/assets.ts';
73
74
  import {
@@ -88,7 +89,7 @@ import { artToSvg } from '../figma/fig-vector.ts';
88
89
  import { readFigZip } from '../figma/fig-zip.ts';
89
90
  import { strokesIntoOps } from '../figma/into-board.ts';
90
91
  import { attrValue, ImportReport } from '../figma/sanitize.ts';
91
- import { JsxTooLargeError, toArtboard, toCanvas } from '../figma/to-artboard.ts';
92
+ import { JsxTooLargeError, toArtboard, toCanvas, toFramesCanvases } from '../figma/to-artboard.ts';
92
93
  import { classifyPageChildren, toRenderCanvas } from '../figma/to-render.ts';
93
94
  import { BoardTooLargeError, toBoardElements, toStrokes } from '../figma/to-strokes.ts';
94
95
  import { stylesToTokens, variablesToTokens } from '../figma/to-tokens.ts';
@@ -422,6 +423,45 @@ export function formatSummary(report, extra = {}) {
422
423
  return lines.join('\n');
423
424
  }
424
425
 
426
+ /**
427
+ * The decode-time half of the report (#155 §5): nodes the `.fig` decoder could
428
+ * not read cleanly and degraded instead of failing the file. Ids and code-owned
429
+ * messages only, like `formatSummary` — this is read by an agent. Empty string
430
+ * when there is nothing to say.
431
+ */
432
+ export function nodeErrorLines(decodeReport) {
433
+ const errors = decodeReport?.nodeErrors ?? [];
434
+ if (errors.length === 0) return '';
435
+ const total = decodeReport.nodeErrorCount ?? errors.length;
436
+ const lines = [` ${total} node(s) could not be read cleanly (the import continued):`];
437
+ for (const e of errors) lines.push(` node ${e.nodeId} ${e.type}: ${e.message}`);
438
+ if (total > errors.length) lines.push(` … and ${total - errors.length} more`);
439
+ return lines.join('\n');
440
+ }
441
+
442
+ /**
443
+ * Component instances (#155 §6): how many were drawn from their component and
444
+ * why any were not. Counts only. Empty string when the file has no instances.
445
+ */
446
+ export function instanceLines(decodeReport) {
447
+ const i = decodeReport?.instances;
448
+ if (!i) return '';
449
+ const skipped = [
450
+ i.cycle ? `${i.cycle} in a component cycle` : '',
451
+ i.budget ? `${i.budget} past the node cap` : '',
452
+ i.missing ? `${i.missing} with no component in the file` : '',
453
+ ].filter(Boolean);
454
+ if (!i.expanded && skipped.length === 0) return '';
455
+ const lines = [` instances: ${i.expanded} drawn from their component`];
456
+ if (skipped.length > 0) lines.push(` instances left empty: ${skipped.join(', ')}`);
457
+ if (i.resized) {
458
+ lines.push(
459
+ ` ${i.resized} instance(s) differ in size from their component (component layout kept)`
460
+ );
461
+ }
462
+ return lines.join('\n');
463
+ }
464
+
425
465
  /**
426
466
  * Phase 2 — import a FigJam board into the whiteboard annotation layer.
427
467
  *
@@ -460,7 +500,7 @@ export function formatSummary(report, extra = {}) {
460
500
  * boxes the decoder already composed. Returns null when nothing in the subtree
461
501
  * has geometry, so the caller can report the absence honestly.
462
502
  */
463
- function buildClusterSvg(local, nodeId) {
503
+ export function buildClusterSvg(local, nodeId) {
464
504
  let cluster = null;
465
505
  walkNodes(local.document.root, (n) => {
466
506
  if (n.id === nodeId) cluster = n;
@@ -483,69 +523,127 @@ function buildClusterSvg(local, nodeId) {
483
523
  return artToSvg({ width: origin.width, height: origin.height, paths });
484
524
  }
485
525
 
526
+ /**
527
+ * Resolve pending assets from the archive for ONE frame. The many-frame import
528
+ * uses `resolveArchiveAssetsMany` directly so every frame's SVGs share browser
529
+ * sessions; this is the single-entry spelling of the same thing.
530
+ */
486
531
  async function resolveArchiveAssets(
487
532
  local,
488
533
  pendingExports,
489
534
  report,
490
535
  { root, designRootRel, stagingDir }
491
536
  ) {
492
- const deps = makeAssetDeps({ root, designRootRel, stagingDir });
493
- const rewrites = new Map();
494
- const resolved = [];
495
- let totalBytes = 0;
496
-
497
- for (const p of pendingExports) {
498
- if (!p.imageRef) {
499
- // NOT unavailable after all: a `.fig` carries the path geometry itself
500
- // (fillGeometry -> commandsBlob -> blobs[]), so the icon is rebuilt here
501
- // rather than requested from Figma. Corrects the claim DDR-221 A9/A10
502
- // shipped. It still goes through the DDR-167 SVG lane on promote — this
503
- // is a third party's file, and we authored the string from their bytes.
504
- const svg = buildClusterSvg(local, p.nodeId);
505
- if (!svg) {
506
- report.add(
507
- p.nodeId,
508
- 'VECTOR',
509
- 'asset-unavailable-offline',
510
- 'no path geometry in the archive for this node'
511
- );
537
+ const [out] = await resolveArchiveAssetsMany(local, [{ pendingExports, report }], {
538
+ root,
539
+ designRootRel,
540
+ stagingDir,
541
+ });
542
+ return out;
543
+ }
544
+
545
+ /**
546
+ * Resolve the pending assets of MANY frames from the archive, with ONE browser
547
+ * session per `MAX_SVG_PROMOTE_CHUNK` SVGs across the whole import (#155 §10).
548
+ *
549
+ * Promoting an SVG runs the DDR-167 execution canary, which launches a browser.
550
+ * Doing it per asset made a 648-vector file an ~80-minute import (~8 assets a
551
+ * minute); the vector clusters of every frame are therefore collected first and
552
+ * promoted together, chunked and retried by `promoteSvgInChunks` (a timeout costs
553
+ * its own chunk, never the import — fail-closed stays). Rasters are written
554
+ * straight through and need no browser.
555
+ *
556
+ * `entries` is `[{ pendingExports, report }]` — one per frame, each reporting
557
+ * into its own `report`. Returns one `{ resolved, rewrites, totalBytes }` per
558
+ * entry, in order. `deps` is injectable for tests.
559
+ */
560
+ export async function resolveArchiveAssetsMany(
561
+ local,
562
+ entries,
563
+ { root, designRootRel, stagingDir, deps = makeAssetDeps({ root, designRootRel, stagingDir }) }
564
+ ) {
565
+ const outs = entries.map(() => ({ resolved: [], rewrites: new Map(), totalBytes: 0 }));
566
+ /** SVG jobs awaiting the shared browser session. */
567
+ const svgJobs = [];
568
+
569
+ for (const [index, { pendingExports, report }] of entries.entries()) {
570
+ const out = outs[index];
571
+ for (const p of pendingExports) {
572
+ if (!p.imageRef) {
573
+ // NOT unavailable after all: a `.fig` carries the path geometry itself
574
+ // (fillGeometry -> commandsBlob -> blobs[]), so the icon is rebuilt here
575
+ // rather than requested from Figma. Corrects the claim DDR-221 A9/A10
576
+ // shipped. It still goes through the DDR-167 SVG lane on promote — this
577
+ // is a third party's file, and we authored the string from their bytes.
578
+ const svg = buildClusterSvg(local, p.nodeId);
579
+ if (!svg) {
580
+ report.add(
581
+ p.nodeId,
582
+ 'VECTOR',
583
+ 'asset-unavailable-offline',
584
+ 'no path geometry in the archive for this node'
585
+ );
586
+ continue;
587
+ }
588
+ const stagedSvgPath = deps.stagingPath(p.nodeId, 'svg');
589
+ writeFileSync(stagedSvgPath, svg, 'utf8');
590
+ svgJobs.push({ index, p, staged: stagedSvgPath, bytes: Buffer.byteLength(svg) });
512
591
  continue;
513
592
  }
514
- const stagedSvgPath = deps.stagingPath(p.nodeId, 'svg');
515
- writeFileSync(stagedSvgPath, svg, 'utf8');
593
+ // Charset-checked before it is used as a lookup key, so a crafted ref can
594
+ // never be read as a path even though we only ever compare it to entries.
595
+ if (!/^[0-9a-f]{8,128}$/.test(p.imageRef)) {
596
+ report.add(p.nodeId, 'IMAGE', 'asset-skipped', 'malformed image reference');
597
+ continue;
598
+ }
599
+ const bytes = local.zip.get(`images/${p.imageRef}`);
600
+ if (!bytes) {
601
+ report.add(p.nodeId, 'IMAGE', 'asset-skipped', 'not present in the archive');
602
+ continue;
603
+ }
604
+ const staged = deps.stagingPath(p.nodeId, 'png');
605
+ writeFileSync(staged, bytes);
516
606
  try {
517
- const { ref } = await deps.promote(stagedSvgPath, 'svg');
518
- rewrites.set(p.placeholder, ref);
519
- resolved.push({ nodeId: p.nodeId, ref });
520
- totalBytes += Buffer.byteLength(svg);
607
+ const { ref } = await deps.promote(staged, 'png');
608
+ out.rewrites.set(p.placeholder, ref);
609
+ out.resolved.push({ nodeId: p.nodeId, ref });
610
+ out.totalBytes += bytes.length;
521
611
  } catch (err) {
522
- report.add(p.nodeId, 'VECTOR', 'asset-skipped', `promote failed: ${err.code ?? 'error'}`);
612
+ report.add(p.nodeId, 'IMAGE', 'asset-skipped', `promote failed: ${err.code ?? 'error'}`);
523
613
  }
524
- continue;
525
- }
526
- // Charset-checked before it is used as a lookup key, so a crafted ref can
527
- // never be read as a path even though we only ever compare it to entries.
528
- if (!/^[0-9a-f]{8,128}$/.test(p.imageRef)) {
529
- report.add(p.nodeId, 'IMAGE', 'asset-skipped', 'malformed image reference');
530
- continue;
531
- }
532
- const bytes = local.zip.get(`images/${p.imageRef}`);
533
- if (!bytes) {
534
- report.add(p.nodeId, 'IMAGE', 'asset-skipped', 'not present in the archive');
535
- continue;
536
614
  }
537
- const staged = deps.stagingPath(p.nodeId, 'png');
538
- writeFileSync(staged, bytes);
539
- try {
540
- const { ref } = await deps.promote(staged, 'png');
541
- rewrites.set(p.placeholder, ref);
542
- resolved.push({ nodeId: p.nodeId, ref });
543
- totalBytes += bytes.length;
544
- } catch (err) {
545
- report.add(p.nodeId, 'IMAGE', 'asset-skipped', `promote failed: ${err.code ?? 'error'}`);
615
+ }
616
+
617
+ if (svgJobs.length > 0) {
618
+ const refs = deps.promoteSvgBatch
619
+ ? await promoteSvgInChunks(
620
+ (paths) => deps.promoteSvgBatch(paths),
621
+ svgJobs.map((j) => j.staged)
622
+ )
623
+ : // A caller whose deps have no batch lane keeps the per-file promote.
624
+ await Promise.all(
625
+ svgJobs.map((j) =>
626
+ deps.promote(j.staged, 'svg').then(
627
+ (r) => r.ref,
628
+ () => null
629
+ )
630
+ )
631
+ );
632
+ for (const [i, job] of svgJobs.entries()) {
633
+ const ref = refs[i];
634
+ const { report } = entries[job.index];
635
+ if (!ref) {
636
+ deps.discard(job.staged);
637
+ report.add(job.p.nodeId, 'VECTOR', 'asset-skipped', 'promote failed: sanitize refused');
638
+ continue;
639
+ }
640
+ const out = outs[job.index];
641
+ out.rewrites.set(job.p.placeholder, ref);
642
+ out.resolved.push({ nodeId: job.p.nodeId, ref });
643
+ out.totalBytes += job.bytes;
546
644
  }
547
645
  }
548
- return { resolved, rewrites, totalBytes };
646
+ return outs;
549
647
  }
550
648
 
551
649
  export function decodeLocalFig(path, fileKeyOverride = null) {
@@ -581,6 +679,53 @@ export function decodeLocalFig(path, fileKeyOverride = null) {
581
679
  }
582
680
  }
583
681
 
682
+ /**
683
+ * Resolve a board's pending pictures. REST for a linked file; the archive's own
684
+ * `images/<imageRef>` for an offline `.jam` (#155 §1) — the content-derived
685
+ * file key means a REST call can only ever answer "no such file". A loose
686
+ * vector (no image handle) is a server-side render a local export does not
687
+ * carry, and an `<image>` on a board takes a raster href only, so it is
688
+ * reported unavailable rather than composed into an SVG the sanitizer would
689
+ * strip.
690
+ */
691
+ async function resolveBoardImages({
692
+ local,
693
+ fileKey,
694
+ pendingImages,
695
+ report,
696
+ root,
697
+ designRootRel,
698
+ stagingDir,
699
+ }) {
700
+ if (!local) {
701
+ return resolveAssets(
702
+ fileKey,
703
+ pendingImages.map((p) => ({ nodeId: p.nodeId, format: 'png', placeholder: p.strokeId })),
704
+ makeAssetDeps({ root, designRootRel, stagingDir }),
705
+ report
706
+ );
707
+ }
708
+ const pictures = [];
709
+ for (const p of pendingImages) {
710
+ if (p.imageRef) {
711
+ pictures.push({
712
+ nodeId: p.nodeId,
713
+ format: 'png',
714
+ placeholder: p.strokeId,
715
+ imageRef: p.imageRef,
716
+ });
717
+ } else {
718
+ report.add(
719
+ p.nodeId,
720
+ 'VECTOR',
721
+ 'asset-unavailable-offline',
722
+ 'a loose vector has no picture in the archive'
723
+ );
724
+ }
725
+ }
726
+ return resolveArchiveAssets(local, pictures, report, { root, designRootRel, stagingDir });
727
+ }
728
+
584
729
  export async function importBoard({
585
730
  url,
586
731
  root,
@@ -698,16 +843,15 @@ export async function importBoard({
698
843
  // Resolve image fills BEFORE serializing — an ImageStroke's href must be a
699
844
  // real `assets/<sha8>` path by the time the SVG is written, and the model's
700
845
  // own href allowlist only admits that shape.
701
- const assets = await resolveAssets(
702
- target.fileKey,
703
- pendingImages.map((p) => ({
704
- nodeId: p.nodeId,
705
- format: 'png',
706
- placeholder: p.strokeId,
707
- })),
708
- makeAssetDeps({ root, designRootRel, stagingDir: staging }),
709
- report
710
- );
846
+ const assets = await resolveBoardImages({
847
+ local,
848
+ fileKey: target.fileKey,
849
+ pendingImages,
850
+ report,
851
+ root,
852
+ designRootRel,
853
+ stagingDir: staging,
854
+ });
711
855
  for (const stroke of strokes) {
712
856
  const ref = assets.rewrites.get(stroke.id);
713
857
  // `href` is the RELATIVE form (`assets/<sha8>.png`) — `ref` comes back as
@@ -867,12 +1011,15 @@ export async function planBoardInto({
867
1011
 
868
1012
  const staging = makeStagingDir();
869
1013
  try {
870
- const assets = await resolveAssets(
871
- target.fileKey,
872
- pendingImages.map((p) => ({ nodeId: p.nodeId, format: 'png', placeholder: p.strokeId })),
873
- makeAssetDeps({ root, designRootRel, stagingDir: staging }),
874
- report
875
- );
1014
+ const assets = await resolveBoardImages({
1015
+ local,
1016
+ fileKey: target.fileKey,
1017
+ pendingImages,
1018
+ report,
1019
+ root,
1020
+ designRootRel,
1021
+ stagingDir: staging,
1022
+ });
876
1023
  for (const stroke of strokes) {
877
1024
  const ref = assets.rewrites.get(stroke.id);
878
1025
  if (ref) stroke.href = ref.replace(/^\//, '');
@@ -1298,6 +1445,7 @@ export async function importPages({
1298
1445
  }
1299
1446
 
1300
1447
  const tokens = readDsTokens(root, designRootRel);
1448
+ const fontTokens = readDsFontTokens(root, designRootRel);
1301
1449
  const budget = makeAssetBudget();
1302
1450
  const written = [];
1303
1451
  const reports = [];
@@ -1385,7 +1533,7 @@ export async function importPages({
1385
1533
  try {
1386
1534
  result =
1387
1535
  mode === 'jsx'
1388
- ? toCanvas(doc, pageNode, { kind, tokens })
1536
+ ? toCanvas(doc, pageNode, { kind, tokens, fontTokens })
1389
1537
  : toRenderCanvas(doc, pageNode, { kind });
1390
1538
  } catch (err) {
1391
1539
  if (!(err instanceof JsxTooLargeError)) throw err;
@@ -1589,25 +1737,96 @@ export async function importPages({
1589
1737
  };
1590
1738
  }
1591
1739
 
1592
- /** Pick the frames a `--frames` run should translate. */
1593
- function selectFrames(doc, nodeId) {
1740
+ /** Wrapper depth `selectFrames` will descend through — a hostile tree cannot recurse unbounded. */
1741
+ const MAX_SELECT_DEPTH = 8;
1742
+
1743
+ /**
1744
+ * Pick the frames a `--frames` run should translate.
1745
+ *
1746
+ * A page's frames are not always its direct children: designers put them in
1747
+ * SECTIONs and GROUPs, and a file made only of groups has no FRAME at all
1748
+ * (#155 §3, §8). So: take a page's top-level FRAME/COMPONENTs, and descend
1749
+ * through SECTION/GROUP wrappers to find the rest, in document order. A
1750
+ * hidden wrapper hides everything inside it. A nested frame inside a FRAME is
1751
+ * part of its parent's composition and is NOT a canvas of its own (DDR-216 D5).
1752
+ * Only when no frame exists anywhere do the page's top-level GROUPs stand in.
1753
+ */
1754
+ export function selectFrames(doc, nodeId) {
1755
+ return selectFramePages(doc, nodeId).flatMap((p) => p.frames);
1756
+ }
1757
+
1758
+ /**
1759
+ * `selectFrames`, grouped by the page each frame came from, in page order (#155
1760
+ * §7). A design file has several pages and they were all but the first dropped
1761
+ * (one real file: 1 frame imported instead of 115). A hidden page is skipped;
1762
+ * a page with no frame contributes nothing. When NO page has a frame, the
1763
+ * groups-only fallback applies to every page.
1764
+ */
1765
+ export function selectFramePages(doc, nodeId) {
1594
1766
  const wanted = new Set(['FRAME', 'COMPONENT']);
1595
1767
  // An explicit node-id means "this subtree" — the root IS the selection.
1596
- if (nodeId && doc.root.id === nodeId) return [doc.root];
1597
- if (wanted.has(doc.root.type)) return [doc.root];
1768
+ if (nodeId && doc.root.id === nodeId) return [{ page: doc.root, frames: [doc.root] }];
1769
+ if (wanted.has(doc.root.type)) return [{ page: doc.root, frames: [doc.root] }];
1598
1770
  // A DOCUMENT root means the caller handed us a whole file rather than a page
1599
1771
  // or a frame — always the case for the local `.fig` door, which has no
1600
- // node-id to scope with. Descend to the first CANVAS. Previously this fell
1601
- // through to "no FRAME or COMPONENT found", so this turns a hard error into
1602
- // the obvious behaviour; the node/depth caps still apply either way.
1603
- const root =
1772
+ // node-id to scope with. Every visible CANVAS is a page; with none, the root
1773
+ // itself stands in. The node/depth caps still apply either way.
1774
+ let pages =
1604
1775
  doc.root.type === 'DOCUMENT'
1605
- ? ((doc.root.children ?? []).find((n) => n.type === 'CANVAS') ?? doc.root)
1606
- : doc.root;
1607
- // Otherwise take the page's top-level frames. Deliberately NOT a deep walk:
1608
- // whole-file import is not a viable default (DDR-216 D5) and a nested frame
1609
- // is part of its parent's composition, not a canvas of its own.
1610
- return (root.children ?? []).filter((n) => wanted.has(n.type) && n.visible);
1776
+ ? (doc.root.children ?? []).filter((n) => n.type === 'CANVAS' && n.visible)
1777
+ : [doc.root];
1778
+ if (pages.length === 0) pages = [doc.root];
1779
+
1780
+ const collect = (nodes, depth, found) => {
1781
+ for (const n of nodes) {
1782
+ if (!n.visible) continue;
1783
+ if (wanted.has(n.type)) found.push(n);
1784
+ else if ((n.type === 'SECTION' || n.type === 'GROUP') && depth < MAX_SELECT_DEPTH) {
1785
+ collect(n.children ?? [], depth + 1, found);
1786
+ }
1787
+ }
1788
+ return found;
1789
+ };
1790
+ const withFrames = pages
1791
+ .map((page) => ({ page, frames: collect(page.children ?? [], 0, []) }))
1792
+ .filter((p) => p.frames.length > 0);
1793
+ if (withFrames.length > 0) return withFrames;
1794
+
1795
+ // No real frame: a Figma Slides deck (#155 §9). Its slides live under
1796
+ // Presentation > Row as nodes whose type this normalizer does not know, and
1797
+ // the type NAMES are unconfirmed (no real Slides file to read them from) — so
1798
+ // the rule is geometric, not nominal. An UNKNOWN node that holds other UNKNOWN
1799
+ // nodes is a wrapper (Presentation, Row) and is descended; an UNKNOWN node
1800
+ // with a real size and no UNKNOWN children is a slide and is a frame. Only
1801
+ // reached when there are no FRAME/COMPONENTs at all, so no existing file's
1802
+ // selection changes.
1803
+ const sized = (n) =>
1804
+ n.visible &&
1805
+ n.type === 'UNKNOWN' &&
1806
+ n.absoluteBoundingBox &&
1807
+ n.absoluteBoundingBox.width > 0 &&
1808
+ n.absoluteBoundingBox.height > 0;
1809
+ const collectUnknown = (nodes, depth, found) => {
1810
+ for (const n of nodes) {
1811
+ if (!n.visible || n.type !== 'UNKNOWN') continue;
1812
+ const wrapper = (n.children ?? []).some((c) => sized(c) || c.type === 'UNKNOWN');
1813
+ if (wrapper && depth < MAX_SELECT_DEPTH) collectUnknown(n.children ?? [], depth + 1, found);
1814
+ else if (sized(n)) found.push(n);
1815
+ }
1816
+ return found;
1817
+ };
1818
+ const withUnknown = pages
1819
+ .map((page) => ({ page, frames: collectUnknown(page.children ?? [], 0, []) }))
1820
+ .filter((p) => p.frames.length > 0);
1821
+ if (withUnknown.length > 0) return withUnknown;
1822
+
1823
+ // No frame anywhere: a groups-only file. Each top-level group is a design.
1824
+ return pages
1825
+ .map((page) => ({
1826
+ page,
1827
+ frames: (page.children ?? []).filter((n) => n.type === 'GROUP' && n.visible),
1828
+ }))
1829
+ .filter((p) => p.frames.length > 0);
1611
1830
  }
1612
1831
 
1613
1832
  /**
@@ -1625,6 +1844,11 @@ export async function importFrames({
1625
1844
  dryRun = false,
1626
1845
  kind = 'digital',
1627
1846
  local = null,
1847
+ // `--one-canvas`: the file as ONE canvas (one artboard per frame) in
1848
+ // `<folder>/<name>.tsx`, instead of one canvas per frame flat in `ui/`.
1849
+ oneCanvas = false,
1850
+ folder = '',
1851
+ name = null,
1628
1852
  }) {
1629
1853
  const target = local ? { fileKey: local.fileKey, nodeId: null } : parseFigmaTarget(url, 'design');
1630
1854
  const doc =
@@ -1635,6 +1859,21 @@ export async function importFrames({
1635
1859
  ...(target.nodeId ? { nodeId: target.nodeId } : {}),
1636
1860
  }));
1637
1861
 
1862
+ if (oneCanvas) {
1863
+ return importFramesAsCanvas({
1864
+ target,
1865
+ doc,
1866
+ root,
1867
+ designRootRel,
1868
+ folder,
1869
+ name,
1870
+ slug,
1871
+ dryRun,
1872
+ kind,
1873
+ local,
1874
+ });
1875
+ }
1876
+
1638
1877
  const frames = selectFrames(doc, target.nodeId);
1639
1878
  if (frames.length === 0) {
1640
1879
  throw new ImportFigmaError(3, 'no FRAME or COMPONENT found — link a specific frame');
@@ -1646,20 +1885,43 @@ export async function importFrames({
1646
1885
  let resolvedAssets = 0;
1647
1886
  const budget = makeAssetBudget();
1648
1887
  const tokens = readDsTokens(root, designRootRel);
1888
+ const fontTokens = readDsFontTokens(root, designRootRel);
1649
1889
 
1650
1890
  const staging = dryRun ? null : makeStagingDir();
1651
1891
  try {
1652
- for (const [i, frame] of frames.entries()) {
1653
- const result = toArtboard(doc, frame, { kind, tokens });
1654
- reports.push(result.report);
1655
- pendingExports += result.pendingExports.length;
1656
-
1892
+ // Translate every frame BEFORE any asset work or write: a frame that is too
1893
+ // large refuses the import cleanly instead of after earlier frames landed,
1894
+ // and the offline door can promote all frames' SVGs through shared browser
1895
+ // sessions (#155 §10) rather than one session per frame.
1896
+ const built = frames.map((frame, i) => {
1897
+ const result = toArtboard(doc, frame, { kind, tokens, fontTokens });
1657
1898
  const base = slug
1658
1899
  ? frames.length > 1
1659
1900
  ? `${slug}-${i + 1}`
1660
1901
  : slug
1661
1902
  : `figma-${frame.id.replace(/[^0-9]+/g, '-')}`;
1662
1903
  if (!SLUG_RE.test(base)) throw new ImportFigmaError(2, 'invalid --slug');
1904
+ return { frame, result, base };
1905
+ });
1906
+ // OFFLINE DOOR: `/v1/images` renders are produced by Figma's servers and
1907
+ // simply do not exist in a local export, so there is nothing to fetch and no
1908
+ // network call to make. Vector clusters are rebuilt from the archive's own
1909
+ // path geometry; image fills come out of `images/<imageRef>` (DDR-221 D6).
1910
+ const archiveAssets =
1911
+ local && !dryRun
1912
+ ? await resolveArchiveAssetsMany(
1913
+ local,
1914
+ built.map((b) => ({
1915
+ pendingExports: b.result.pendingExports,
1916
+ report: b.result.report,
1917
+ })),
1918
+ { root, designRootRel, stagingDir: staging }
1919
+ )
1920
+ : null;
1921
+
1922
+ for (const [i, { result, base }] of built.entries()) {
1923
+ reports.push(result.report);
1924
+ pendingExports += result.pendingExports.length;
1663
1925
 
1664
1926
  if (dryRun) {
1665
1927
  written.push({ slug: base, bytes: result.metrics.bytes, metrics: result.metrics });
@@ -1674,14 +1936,9 @@ export async function importFrames({
1674
1936
  // simply do not exist in a local export, so there is nothing to resolve
1675
1937
  // and no network call to make. The placeholders stay in place — a
1676
1938
  // visibly broken image beats a silently missing element — and every one
1677
- // is named in the summary rather than quietly dropped (DDR-221 D6: the
1678
- // archive covers image FILLS, never server-side vector renders).
1679
- const assets = local
1680
- ? await resolveArchiveAssets(local, result.pendingExports, result.report, {
1681
- root,
1682
- designRootRel,
1683
- stagingDir: staging,
1684
- })
1939
+ // is named in the summary rather than quietly dropped.
1940
+ const assets = archiveAssets
1941
+ ? archiveAssets[i]
1685
1942
  : await resolveAssets(
1686
1943
  target.fileKey,
1687
1944
  result.pendingExports.map((p) => ({
@@ -1731,6 +1988,137 @@ export async function importFrames({
1731
1988
  return { written, reports, pendingExports, resolvedAssets, frameCount: frames.length };
1732
1989
  }
1733
1990
 
1991
+ /**
1992
+ * `--one-canvas`: a file's frames as ONE canvas with one artboard per frame (#155
1993
+ * §10), in `<folder>/<name>.tsx`, instead of one canvas per frame flat in `ui/`.
1994
+ * Pages sit side by side. A file too large for one canvas continues on
1995
+ * `<name> (2)` and so on (`toFramesCanvases`), so nothing is dropped.
1996
+ *
1997
+ * The caller names a FOLDER (checked segment by segment — never a runtime `_*`
1998
+ * dir, never `system/` or `assets/`) and a canvas NAME (a filename charset, no
1999
+ * separators); it never picks a path. Staged outside the design root and
2000
+ * promoted only on success, realpath-contained, like every other write here.
2001
+ */
2002
+ async function importFramesAsCanvas({
2003
+ target,
2004
+ doc,
2005
+ root,
2006
+ designRootRel,
2007
+ folder,
2008
+ name,
2009
+ slug,
2010
+ dryRun,
2011
+ kind,
2012
+ local,
2013
+ }) {
2014
+ const folderRel = safeCanvasFolder(folder === '' || folder == null ? 'ui' : folder);
2015
+ if (folderRel === null) throw new ImportFigmaError(2, 'invalid --folder');
2016
+ const canvasName = safeCanvasName(name ?? slug ?? 'Figma import');
2017
+ if (canvasName === null) throw new ImportFigmaError(2, 'invalid --name');
2018
+
2019
+ const groups = selectFramePages(doc, target.nodeId);
2020
+ const frameCount = groups.reduce((n, g) => n + g.frames.length, 0);
2021
+ if (frameCount === 0) {
2022
+ throw new ImportFigmaError(3, 'no FRAME or COMPONENT found — link a specific frame');
2023
+ }
2024
+ const tokens = readDsTokens(root, designRootRel);
2025
+ const fontTokens = readDsFontTokens(root, designRootRel);
2026
+ // Translated first, so a frame that is too large refuses before anything lands.
2027
+ const canvases = toFramesCanvases(doc, groups, { kind, tokens, fontTokens });
2028
+
2029
+ const designRoot = join(root, designRootRel);
2030
+ const nameOf = (i) => (i === 0 ? canvasName : `${canvasName} (${i + 1})`);
2031
+ const reports = canvases.map((c) => c.report);
2032
+ const pendingExports = canvases.reduce((n, c) => n + c.pendingExports.length, 0);
2033
+
2034
+ if (dryRun) {
2035
+ const written = canvases.map((c, i) => ({
2036
+ slug: nameOf(i),
2037
+ bytes: c.metrics.bytes,
2038
+ artboards: c.artboardCount,
2039
+ metrics: c.metrics,
2040
+ }));
2041
+ return {
2042
+ written,
2043
+ reports,
2044
+ pendingExports,
2045
+ resolvedAssets: 0,
2046
+ frameCount,
2047
+ canvasCount: written.length,
2048
+ };
2049
+ }
2050
+
2051
+ const staging = makeStagingDir();
2052
+ try {
2053
+ const budget = makeAssetBudget();
2054
+ const assetsAll = local
2055
+ ? await resolveArchiveAssetsMany(
2056
+ local,
2057
+ canvases.map((c) => ({ pendingExports: c.pendingExports, report: c.report })),
2058
+ { root, designRootRel, stagingDir: staging }
2059
+ )
2060
+ : null;
2061
+ const written = [];
2062
+ let resolvedAssets = 0;
2063
+ for (const [i, c] of canvases.entries()) {
2064
+ const assets =
2065
+ assetsAll?.[i] ??
2066
+ (await resolveAssets(
2067
+ target.fileKey,
2068
+ c.pendingExports.map((p) => ({
2069
+ nodeId: p.nodeId,
2070
+ format: p.format,
2071
+ placeholder: p.placeholder,
2072
+ })),
2073
+ makeAssetDeps({ root, designRootRel, stagingDir: staging }),
2074
+ c.report,
2075
+ budget
2076
+ ));
2077
+ resolvedAssets += assets.resolved.length;
2078
+ const tsx = applyRewrites(c.tsx, assets.rewrites);
2079
+ const meta = {
2080
+ ...c.meta,
2081
+ source: { ...c.meta.source, importedAt: new Date().toISOString() },
2082
+ };
2083
+
2084
+ const rel = freeCanvasRel(designRoot, folderRel, nameOf(i));
2085
+ const base = rel.slice(rel.lastIndexOf('/') + 1).replace(/\.tsx$/, '');
2086
+ const stagedTsx = join(staging, `canvas-${i}.tsx`);
2087
+ const stagedMeta = join(staging, `canvas-${i}.meta.json`);
2088
+ writeFileSync(stagedTsx, tsx, 'utf8');
2089
+ writeFileSync(stagedMeta, `${JSON.stringify(meta, null, 2)}\n`, 'utf8');
2090
+
2091
+ assertNoSlugTwin(designRoot, rel);
2092
+ mkdirSync(join(designRoot, folderRel), { recursive: true });
2093
+ const finalTsx = assertContained(root, designRootRel, join(designRoot, rel));
2094
+ const finalMeta = assertContained(
2095
+ root,
2096
+ designRootRel,
2097
+ join(designRoot, folderRel, `${base}.meta.json`)
2098
+ );
2099
+ promoteFile(stagedTsx, finalTsx);
2100
+ promoteFile(stagedMeta, finalMeta);
2101
+ written.push({
2102
+ slug: base,
2103
+ path: finalTsx,
2104
+ bytes: c.metrics.bytes,
2105
+ artboards: c.artboardCount,
2106
+ metrics: c.metrics,
2107
+ });
2108
+ }
2109
+ return {
2110
+ written,
2111
+ reports,
2112
+ pendingExports,
2113
+ resolvedAssets,
2114
+ frameCount,
2115
+ canvasCount: written.length,
2116
+ };
2117
+ } finally {
2118
+ rmSync(staging, { recursive: true, force: true });
2119
+ }
2120
+ }
2121
+
1734
2122
  // ── S8.17 — the Import from Figma sheet: list a page's frames, bring the picked ones in as pictures ──
1735
2123
  //
1736
2124
  // canvas 12 · ia-figma-sheets / ia-figma-arrived. Two halves of ONE flow, both deterministic code:
@@ -2416,6 +2804,7 @@ export function parseArgv(argv) {
2416
2804
  name: null,
2417
2805
  comments: true,
2418
2806
  styles: false,
2807
+ oneCanvas: false,
2419
2808
  };
2420
2809
  for (let i = 0; i < argv.length; i += 1) {
2421
2810
  const a = argv[i];
@@ -2532,6 +2921,10 @@ export function parseArgv(argv) {
2532
2921
  case '--styles':
2533
2922
  out.styles = true;
2534
2923
  break;
2924
+ // #155 §10 — a file as ONE canvas, one artboard per frame (target: --folder, --name).
2925
+ case '--one-canvas':
2926
+ out.oneCanvas = true;
2927
+ break;
2535
2928
  case '--json':
2536
2929
  out.json = true;
2537
2930
  break;
@@ -2562,7 +2955,8 @@ Usage:
2562
2955
  maude design import-figma --editable <artboard-id> --canvas <dir>/<Canvas>.tsx --root <repo>
2563
2956
  maude design import-figma --tokens <figma-url> --root <repo>
2564
2957
  maude design import-figma --fig <path.fig> --root <repo> [--slug <name>]
2565
- [--file-key <key>] [--dry-run] [--json]
2958
+ [--file-key <key>] [--one-canvas [--folder <dir>] [--name <canvas>]]
2959
+ [--dry-run] [--json]
2566
2960
  maude design import-figma --explode <artboard-id> --canvas ui/<folder>/<Page>.tsx
2567
2961
  --root <repo> [--confirm-document] [--dry-run] [--json]
2568
2962
 
@@ -2613,6 +3007,13 @@ inside the archive, so nothing expires and nothing is rate-limited. A local file
2613
3007
  carries no REST file key, so provenance is content-addressed unless you pass
2614
3008
  \`--file-key\`; the summary says which you got.
2615
3009
 
3010
+ A design file imports every page, and by default one canvas per frame, flat in \`ui/\`.
3011
+ \`--one-canvas\` brings the whole file in as ONE canvas with one artboard per frame instead
3012
+ (\`<folder>/<name>.tsx\`, folder default \`ui\`, name default \`--slug\` or "Figma import"; a name
3013
+ already taken becomes "<name> (Figma)"). Pages sit side by side, and a file too large for one
3014
+ canvas continues on "<name> (2)". SVG artwork is promoted in shared browser sessions, not one
3015
+ launch per asset.
3016
+
2616
3017
  The file's REVIEW COMMENTS come across as comment pins, where they sit: a thread
2617
3018
  with its replies, resolved ones resolved. Whoever wrote one in Figma shows as
2618
3019
  "<name> · from Figma" — a label, not a person on this project; the pins are
@@ -2748,6 +3149,9 @@ async function main() {
2748
3149
  slug: opts.slug,
2749
3150
  dryRun: opts.dryRun,
2750
3151
  local,
3152
+ oneCanvas: opts.oneCanvas,
3153
+ folder: opts.folder ?? '',
3154
+ name: opts.name,
2751
3155
  });
2752
3156
  const merged = new ImportReport();
2753
3157
  if (isBoard) merged.entries.push(...r.report.entries);
@@ -2768,6 +3172,9 @@ async function main() {
2768
3172
  unmappedTypes: local.report.unmappedTypes,
2769
3173
  lossyFields: local.report.lossyFields,
2770
3174
  internalNodesSkipped: local.report.internalNodesSkipped,
3175
+ nodeErrors: local.report.nodeErrors,
3176
+ nodeErrorCount: local.report.nodeErrorCount,
3177
+ instances: local.report.instances,
2771
3178
  ...(isBoard ? { slug: r.slug, strokes: r.strokeCount } : { written: r.written }),
2772
3179
  dispositions: merged.entries,
2773
3180
  })}\n`
@@ -2781,13 +3188,15 @@ async function main() {
2781
3188
  .join('\n');
2782
3189
  const head = isBoard
2783
3190
  ? `import-figma: board -> ${r.slug} (${r.strokeCount} strokes)${opts.dryRun ? ' (dry run)' : ''}`
2784
- : `import-figma: ${r.written.length} frame(s)${opts.dryRun ? ' (dry run)' : ''}`;
3191
+ : opts.oneCanvas
3192
+ ? `import-figma: ${r.frameCount} frame(s) -> ${r.canvasCount} canvas(es)${opts.dryRun ? ' (dry run)' : ''}`
3193
+ : `import-figma: ${r.written.length} frame(s)${opts.dryRun ? ' (dry run)' : ''}`;
2785
3194
  process.stdout.write(
2786
3195
  `${head}\n` +
2787
3196
  ` offline: container v${provenance.containerVersion} · schema ${provenance.schemaSha256.slice(0, 8)}` +
2788
3197
  `${provenance.exportedAt ? ` · exported ${provenance.exportedAt}` : ''}\n` +
2789
3198
  ` file key: ${provenance.fileKey}${provenance.derivedFileKey ? ' (content-derived — pass --file-key for the real one)' : ''}\n` +
2790
- `${[unmapped, lossy].filter(Boolean).join('\n')}${unmapped || lossy ? '\n' : ''}` +
3199
+ `${[unmapped, lossy, nodeErrorLines(local.report), instanceLines(local.report)].filter(Boolean).join('\n')}${unmapped || lossy || local.report.nodeErrors?.length || instanceLines(local.report) ? '\n' : ''}` +
2791
3200
  `${formatSummary(merged)}\n`
2792
3201
  );
2793
3202
  }
@@ -2858,6 +3267,9 @@ async function main() {
2858
3267
  designRootRel: opts.designRoot,
2859
3268
  slug: opts.slug,
2860
3269
  dryRun: opts.dryRun,
3270
+ oneCanvas: opts.oneCanvas,
3271
+ folder: opts.folder ?? '',
3272
+ name: opts.name,
2861
3273
  });
2862
3274
  // One report across every frame, so the summary is a single accounting.
2863
3275
  const merged = new ImportReport();