@neta-art/cohub-cli 10.24.0 → 10.25.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 (369) hide show
  1. package/bin/cohub.js +4 -1
  2. package/dist/board-gpu/page.js +1566 -71230
  3. package/dist/bootstrap.js +67 -27
  4. package/dist/build.json +1 -1
  5. package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
  6. package/dist/chunks/about.js +102 -0
  7. package/dist/chunks/app-realtime.js +2216 -0
  8. package/dist/chunks/app-realtime2.js +2 -0
  9. package/dist/chunks/app-ref.js +88 -0
  10. package/dist/chunks/apps.js +1423 -0
  11. package/dist/chunks/auth.js +175 -0
  12. package/dist/chunks/avatar.js +146 -0
  13. package/dist/chunks/binary-pins.js +5 -0
  14. package/dist/chunks/board-export-resources.js +232 -0
  15. package/dist/chunks/board-export.js +874 -0
  16. package/dist/chunks/board-export2.js +2 -0
  17. package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
  18. package/dist/chunks/board-kernel2.js +4 -0
  19. package/dist/chunks/board-profile.js +69 -0
  20. package/dist/chunks/board-simulate.js +315 -0
  21. package/dist/chunks/board-time.js +34 -0
  22. package/dist/chunks/boards.js +1943 -0
  23. package/dist/{board-kernel → chunks}/browserAll.js +9 -8
  24. package/dist/chunks/channels.js +64 -0
  25. package/dist/chunks/client.js +12606 -0
  26. package/dist/chunks/command-input.js +17 -0
  27. package/dist/chunks/commander.js +2962 -0
  28. package/dist/chunks/cron-jobs.js +163 -0
  29. package/dist/chunks/daemon.js +545 -0
  30. package/dist/chunks/daemon2.js +2 -0
  31. package/dist/chunks/desktop.js +172 -0
  32. package/dist/chunks/endpoint-options.js +26 -0
  33. package/dist/chunks/env-proxy.js +35 -0
  34. package/dist/chunks/environment.js +154 -0
  35. package/dist/chunks/feedback.js +120 -0
  36. package/dist/chunks/generations.js +379 -0
  37. package/dist/chunks/host.js +9 -0
  38. package/dist/chunks/http-put.js +131 -0
  39. package/dist/chunks/id.js +2416 -0
  40. package/dist/{board-kernel → chunks}/init.js +1 -1
  41. package/dist/chunks/install.js +11959 -0
  42. package/dist/chunks/launch.js +374 -0
  43. package/dist/chunks/local-media.js +47 -0
  44. package/dist/chunks/me.js +134 -0
  45. package/dist/chunks/media.js +315 -0
  46. package/dist/chunks/models.js +242 -0
  47. package/dist/chunks/operands.js +46 -0
  48. package/dist/chunks/package-paths.js +13 -0
  49. package/dist/chunks/policy.js +221 -0
  50. package/dist/chunks/preferences.js +29 -0
  51. package/dist/chunks/profile.js +64 -0
  52. package/dist/chunks/prompts.js +41 -0
  53. package/dist/chunks/public.js +2 -0
  54. package/dist/chunks/public2.js +244 -0
  55. package/dist/chunks/references.js +197 -0
  56. package/dist/chunks/referrals.js +90 -0
  57. package/dist/chunks/rolldown-runtime.js +26 -0
  58. package/dist/chunks/rooms-connect.js +2 -0
  59. package/dist/chunks/rooms-connect2.js +151 -0
  60. package/dist/chunks/rooms-rtc.js +311 -0
  61. package/dist/chunks/rooms.js +211 -0
  62. package/dist/chunks/run.js +220 -0
  63. package/dist/chunks/runtime.js +638 -0
  64. package/dist/chunks/runtime2.js +286 -0
  65. package/dist/chunks/runtimes.js +48 -0
  66. package/dist/chunks/safe-remote-image.js +198 -0
  67. package/dist/chunks/schemas.js +6017 -0
  68. package/dist/chunks/search.js +113 -0
  69. package/dist/chunks/self-update.js +238 -0
  70. package/dist/chunks/serve.js +1246 -0
  71. package/dist/chunks/session-status.js +24 -0
  72. package/dist/chunks/skills.js +35 -0
  73. package/dist/chunks/spaces.js +5080 -0
  74. package/dist/chunks/src.js +405 -0
  75. package/dist/chunks/supervisor.js +2513 -0
  76. package/dist/chunks/supervisor2.js +2 -0
  77. package/dist/chunks/tasks.js +82 -0
  78. package/dist/chunks/themes.js +2898 -0
  79. package/dist/chunks/version.js +2 -0
  80. package/dist/chunks/version2.js +22 -0
  81. package/dist/chunks/version3.js +18 -0
  82. package/dist/chunks/web.js +7 -0
  83. package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
  84. package/dist/runtime/native/pi-extension.js +174 -166
  85. package/dist/runtime/worker.js +27 -16
  86. package/package.json +8 -9
  87. package/dist/about.d.ts +0 -2
  88. package/dist/about.js +0 -71
  89. package/dist/app-download.d.ts +0 -11
  90. package/dist/app-download.js +0 -252
  91. package/dist/app-ref.d.ts +0 -5
  92. package/dist/app-ref.js +0 -8
  93. package/dist/app-target.d.ts +0 -26
  94. package/dist/app-target.js +0 -55
  95. package/dist/auth.d.ts +0 -45
  96. package/dist/auth.js +0 -307
  97. package/dist/avatar.d.ts +0 -55
  98. package/dist/avatar.js +0 -104
  99. package/dist/board-command-support.d.ts +0 -6
  100. package/dist/board-command-support.js +0 -88
  101. package/dist/board-export-resources.d.ts +0 -12
  102. package/dist/board-export-resources.js +0 -51
  103. package/dist/board-export.d.ts +0 -110
  104. package/dist/board-export.js +0 -592
  105. package/dist/board-fonts.d.ts +0 -11
  106. package/dist/board-fonts.js +0 -10
  107. package/dist/board-gpu/daemon.d.ts +0 -11
  108. package/dist/board-gpu/daemon.js +0 -295
  109. package/dist/board-gpu/index.d.ts +0 -33
  110. package/dist/board-gpu/index.js +0 -189
  111. package/dist/board-gpu/protocol.d.ts +0 -77
  112. package/dist/board-gpu/protocol.js +0 -1
  113. package/dist/board-kernel.d.ts +0 -5
  114. package/dist/board-media-export.d.ts +0 -17
  115. package/dist/board-media-export.js +0 -164
  116. package/dist/board-media.d.ts +0 -5
  117. package/dist/board-media.js +0 -66
  118. package/dist/board-profile.d.ts +0 -21
  119. package/dist/board-profile.js +0 -67
  120. package/dist/board-simulate.d.ts +0 -67
  121. package/dist/board-simulate.js +0 -259
  122. package/dist/board-time.d.ts +0 -3
  123. package/dist/board-time.js +0 -34
  124. package/dist/bootstrap.d.ts +0 -2
  125. package/dist/client.d.ts +0 -5
  126. package/dist/client.js +0 -24
  127. package/dist/command-input.d.ts +0 -4
  128. package/dist/command-input.js +0 -16
  129. package/dist/commands/app-commerce.d.ts +0 -2
  130. package/dist/commands/app-commerce.js +0 -228
  131. package/dist/commands/app-domains.d.ts +0 -2
  132. package/dist/commands/app-domains.js +0 -133
  133. package/dist/commands/apps.d.ts +0 -4
  134. package/dist/commands/apps.js +0 -827
  135. package/dist/commands/auth.d.ts +0 -2
  136. package/dist/commands/auth.js +0 -186
  137. package/dist/commands/boards/authoring.d.ts +0 -2
  138. package/dist/commands/boards/authoring.js +0 -166
  139. package/dist/commands/boards/examples.d.ts +0 -10
  140. package/dist/commands/boards/examples.js +0 -118
  141. package/dist/commands/boards.d.ts +0 -13
  142. package/dist/commands/boards.js +0 -836
  143. package/dist/commands/channels.d.ts +0 -2
  144. package/dist/commands/channels.js +0 -74
  145. package/dist/commands/cron-jobs.d.ts +0 -2
  146. package/dist/commands/cron-jobs.js +0 -155
  147. package/dist/commands/decision.d.ts +0 -4
  148. package/dist/commands/decision.js +0 -113
  149. package/dist/commands/desktop.d.ts +0 -10
  150. package/dist/commands/desktop.js +0 -233
  151. package/dist/commands/feedback.d.ts +0 -2
  152. package/dist/commands/feedback.js +0 -131
  153. package/dist/commands/generations.d.ts +0 -2
  154. package/dist/commands/generations.js +0 -427
  155. package/dist/commands/host.d.ts +0 -2
  156. package/dist/commands/host.js +0 -11
  157. package/dist/commands/me.d.ts +0 -2
  158. package/dist/commands/me.js +0 -121
  159. package/dist/commands/models.d.ts +0 -28
  160. package/dist/commands/models.js +0 -271
  161. package/dist/commands/profile.d.ts +0 -2
  162. package/dist/commands/profile.js +0 -81
  163. package/dist/commands/prompts.d.ts +0 -2
  164. package/dist/commands/prompts.js +0 -37
  165. package/dist/commands/public.d.ts +0 -20
  166. package/dist/commands/public.js +0 -291
  167. package/dist/commands/references.d.ts +0 -2
  168. package/dist/commands/references.js +0 -193
  169. package/dist/commands/referrals.d.ts +0 -2
  170. package/dist/commands/referrals.js +0 -88
  171. package/dist/commands/rooms-connect.d.ts +0 -17
  172. package/dist/commands/rooms-connect.js +0 -140
  173. package/dist/commands/rooms-rtc-binary.d.ts +0 -2
  174. package/dist/commands/rooms-rtc-binary.js +0 -107
  175. package/dist/commands/rooms-rtc.d.ts +0 -21
  176. package/dist/commands/rooms-rtc.js +0 -171
  177. package/dist/commands/rooms.d.ts +0 -3
  178. package/dist/commands/rooms.js +0 -277
  179. package/dist/commands/run.d.ts +0 -13
  180. package/dist/commands/run.js +0 -246
  181. package/dist/commands/runtime.d.ts +0 -3
  182. package/dist/commands/runtime.js +0 -320
  183. package/dist/commands/sandboxd-binary.d.ts +0 -11
  184. package/dist/commands/sandboxd-binary.js +0 -238
  185. package/dist/commands/search.d.ts +0 -2
  186. package/dist/commands/search.js +0 -114
  187. package/dist/commands/session-access.d.ts +0 -2
  188. package/dist/commands/session-access.js +0 -70
  189. package/dist/commands/skills.d.ts +0 -2
  190. package/dist/commands/skills.js +0 -34
  191. package/dist/commands/space-activity.d.ts +0 -26
  192. package/dist/commands/space-activity.js +0 -147
  193. package/dist/commands/space-commerce.d.ts +0 -2
  194. package/dist/commands/space-commerce.js +0 -514
  195. package/dist/commands/space-displays.d.ts +0 -2
  196. package/dist/commands/space-displays.js +0 -620
  197. package/dist/commands/space-files.d.ts +0 -5
  198. package/dist/commands/space-files.js +0 -215
  199. package/dist/commands/space-invitations.d.ts +0 -29
  200. package/dist/commands/space-invitations.js +0 -189
  201. package/dist/commands/space-turns.d.ts +0 -49
  202. package/dist/commands/space-turns.js +0 -205
  203. package/dist/commands/space-wallet.d.ts +0 -2
  204. package/dist/commands/space-wallet.js +0 -141
  205. package/dist/commands/space-webhooks.d.ts +0 -7
  206. package/dist/commands/space-webhooks.js +0 -73
  207. package/dist/commands/spaces.d.ts +0 -25
  208. package/dist/commands/spaces.js +0 -2170
  209. package/dist/commands/tasks.d.ts +0 -8
  210. package/dist/commands/tasks.js +0 -80
  211. package/dist/commands/version.d.ts +0 -2
  212. package/dist/commands/version.js +0 -21
  213. package/dist/endpoint-options.d.ts +0 -4
  214. package/dist/endpoint-options.js +0 -26
  215. package/dist/env-proxy.d.ts +0 -5
  216. package/dist/env-proxy.js +0 -20
  217. package/dist/help-path.d.ts +0 -18
  218. package/dist/help-path.js +0 -223
  219. package/dist/host/auth.d.ts +0 -20
  220. package/dist/host/auth.js +0 -119
  221. package/dist/host/login-env.d.ts +0 -1
  222. package/dist/host/login-env.js +0 -31
  223. package/dist/host/runtime.d.ts +0 -35
  224. package/dist/host/runtime.js +0 -395
  225. package/dist/host/runtimes.d.ts +0 -9
  226. package/dist/host/runtimes.js +0 -42
  227. package/dist/host/serve.d.ts +0 -2
  228. package/dist/host/serve.js +0 -117
  229. package/dist/host/workspaces.d.ts +0 -2
  230. package/dist/host/workspaces.js +0 -18
  231. package/dist/http-put.d.ts +0 -25
  232. package/dist/http-put.js +0 -132
  233. package/dist/index.d.ts +0 -2
  234. package/dist/index.js +0 -129
  235. package/dist/launcher.d.ts +0 -4
  236. package/dist/launcher.js +0 -38
  237. package/dist/local-media.d.ts +0 -2
  238. package/dist/local-media.js +0 -30
  239. package/dist/network-error.d.ts +0 -3
  240. package/dist/network-error.js +0 -22
  241. package/dist/output.d.ts +0 -46
  242. package/dist/output.js +0 -244
  243. package/dist/runtime/archive-store.d.ts +0 -54
  244. package/dist/runtime/archive-store.js +0 -379
  245. package/dist/runtime/cli-path.d.ts +0 -5
  246. package/dist/runtime/cli-path.js +0 -27
  247. package/dist/runtime/codex-usage.d.ts +0 -7
  248. package/dist/runtime/codex-usage.js +0 -11
  249. package/dist/runtime/connection.d.ts +0 -42
  250. package/dist/runtime/connection.js +0 -789
  251. package/dist/runtime/diagnostics.d.ts +0 -107
  252. package/dist/runtime/diagnostics.js +0 -392
  253. package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
  254. package/dist/runtime/harnesses/chained-projection.js +0 -95
  255. package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
  256. package/dist/runtime/harnesses/chained-transcript.js +0 -62
  257. package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
  258. package/dist/runtime/harnesses/claude-approval.js +0 -124
  259. package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
  260. package/dist/runtime/harnesses/claude-transcript.js +0 -138
  261. package/dist/runtime/harnesses/claude.d.ts +0 -8
  262. package/dist/runtime/harnesses/claude.js +0 -225
  263. package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
  264. package/dist/runtime/harnesses/codex-approval.js +0 -69
  265. package/dist/runtime/harnesses/codex.d.ts +0 -4
  266. package/dist/runtime/harnesses/codex.js +0 -269
  267. package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
  268. package/dist/runtime/harnesses/cursor-transcript.js +0 -183
  269. package/dist/runtime/harnesses/cursor.d.ts +0 -24
  270. package/dist/runtime/harnesses/cursor.js +0 -620
  271. package/dist/runtime/harnesses/index.d.ts +0 -16
  272. package/dist/runtime/harnesses/index.js +0 -73
  273. package/dist/runtime/harnesses/pi.d.ts +0 -4
  274. package/dist/runtime/harnesses/pi.js +0 -247
  275. package/dist/runtime/harnesses/process.d.ts +0 -31
  276. package/dist/runtime/harnesses/process.js +0 -75
  277. package/dist/runtime/harnesses/stream-json.d.ts +0 -48
  278. package/dist/runtime/harnesses/stream-json.js +0 -336
  279. package/dist/runtime/harnesses/types.d.ts +0 -117
  280. package/dist/runtime/harnesses/types.js +0 -1
  281. package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
  282. package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
  283. package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
  284. package/dist/runtime/harnesses/workbuddy.js +0 -123
  285. package/dist/runtime/instance.d.ts +0 -20
  286. package/dist/runtime/instance.js +0 -247
  287. package/dist/runtime/json-rpc.d.ts +0 -53
  288. package/dist/runtime/json-rpc.js +0 -212
  289. package/dist/runtime/launch.d.ts +0 -25
  290. package/dist/runtime/launch.js +0 -247
  291. package/dist/runtime/local-workspace.d.ts +0 -15
  292. package/dist/runtime/local-workspace.js +0 -52
  293. package/dist/runtime/model-catalog.d.ts +0 -12
  294. package/dist/runtime/model-catalog.js +0 -84
  295. package/dist/runtime/native/adapters.d.ts +0 -15
  296. package/dist/runtime/native/adapters.js +0 -11
  297. package/dist/runtime/native/approvals.d.ts +0 -18
  298. package/dist/runtime/native/approvals.js +0 -54
  299. package/dist/runtime/native/archive.d.ts +0 -19
  300. package/dist/runtime/native/archive.js +0 -142
  301. package/dist/runtime/native/attach.d.ts +0 -36
  302. package/dist/runtime/native/attach.js +0 -128
  303. package/dist/runtime/native/codex-link.d.ts +0 -60
  304. package/dist/runtime/native/codex-link.js +0 -322
  305. package/dist/runtime/native/config.d.ts +0 -16
  306. package/dist/runtime/native/config.js +0 -24
  307. package/dist/runtime/native/daemon.d.ts +0 -92
  308. package/dist/runtime/native/daemon.js +0 -380
  309. package/dist/runtime/native/execution.d.ts +0 -26
  310. package/dist/runtime/native/execution.js +0 -34
  311. package/dist/runtime/native/identity.d.ts +0 -9
  312. package/dist/runtime/native/identity.js +0 -15
  313. package/dist/runtime/native/ingest.d.ts +0 -263
  314. package/dist/runtime/native/ingest.js +0 -884
  315. package/dist/runtime/native/install.d.ts +0 -9
  316. package/dist/runtime/native/install.js +0 -113
  317. package/dist/runtime/native/paths.d.ts +0 -2
  318. package/dist/runtime/native/paths.js +0 -7
  319. package/dist/runtime/native/pi-extension.d.ts +0 -36
  320. package/dist/runtime/native/pi-link.d.ts +0 -69
  321. package/dist/runtime/native/pi-link.js +0 -269
  322. package/dist/runtime/native/results.d.ts +0 -41
  323. package/dist/runtime/native/results.js +0 -128
  324. package/dist/runtime/native/sessions.d.ts +0 -45
  325. package/dist/runtime/native/sessions.js +0 -87
  326. package/dist/runtime/native/transcript.d.ts +0 -89
  327. package/dist/runtime/native/transcript.js +0 -656
  328. package/dist/runtime/native/translate.d.ts +0 -46
  329. package/dist/runtime/native/translate.js +0 -299
  330. package/dist/runtime/native/transport.d.ts +0 -7
  331. package/dist/runtime/native/transport.js +0 -16
  332. package/dist/runtime/native/version.d.ts +0 -5
  333. package/dist/runtime/native/version.js +0 -21
  334. package/dist/runtime/preferences.d.ts +0 -7
  335. package/dist/runtime/preferences.js +0 -22
  336. package/dist/runtime/presentation.d.ts +0 -32
  337. package/dist/runtime/presentation.js +0 -124
  338. package/dist/runtime/process-group.d.ts +0 -5
  339. package/dist/runtime/process-group.js +0 -161
  340. package/dist/runtime/projection-store.d.ts +0 -27
  341. package/dist/runtime/projection-store.js +0 -30
  342. package/dist/runtime/space-binding.d.ts +0 -48
  343. package/dist/runtime/space-binding.js +0 -342
  344. package/dist/runtime/supervisor.d.ts +0 -19
  345. package/dist/runtime/supervisor.js +0 -441
  346. package/dist/runtime/turn-projection.d.ts +0 -41
  347. package/dist/runtime/turn-projection.js +0 -120
  348. package/dist/runtime/worker.d.ts +0 -1
  349. package/dist/safe-remote-image.d.ts +0 -36
  350. package/dist/safe-remote-image.js +0 -191
  351. package/dist/self-update.d.ts +0 -7
  352. package/dist/self-update.js +0 -202
  353. package/dist/session-status.d.ts +0 -10
  354. package/dist/session-status.js +0 -25
  355. package/dist/space-files/limit.d.ts +0 -2
  356. package/dist/space-files/limit.js +0 -16
  357. package/dist/space-files/operands.d.ts +0 -17
  358. package/dist/space-files/operands.js +0 -33
  359. package/dist/space-files/transfer.d.ts +0 -53
  360. package/dist/space-files/transfer.js +0 -297
  361. package/dist/space-files/upload.d.ts +0 -17
  362. package/dist/space-files/upload.js +0 -76
  363. package/dist/space.d.ts +0 -44
  364. package/dist/space.js +0 -192
  365. package/dist/version.d.ts +0 -2
  366. package/dist/version.js +0 -17
  367. package/dist/web.d.ts +0 -1
  368. package/dist/web.js +0 -4
  369. /package/dist/{board-kernel → chunks}/lexer.js +0 -0
@@ -1,592 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { mkdtemp, rm, writeFile, copyFile, link, rename, unlink } from "node:fs/promises";
3
- import { constants } from "node:fs";
4
- import { randomUUID } from "node:crypto";
5
- import { execFile as execFileCallback } from "node:child_process";
6
- import { debuglog, promisify } from "node:util";
7
- import { createRequire } from "node:module";
8
- import { dirname, join } from "node:path";
9
- import { fileURLToPath } from "node:url";
10
- import { tmpdir } from "node:os";
11
- const execFile = promisify(execFileCallback);
12
- import { boardExportView, boardMediaNaturalSize, parseBoardMediaSource } from "@neta-art/cohub/board";
13
- import { imageVariantUrl, MEDIA_VARIANT_MAX, mediaVariantSize, videoFrameUrl } from "@neta-art/cohub/media";
14
- import { hasBoardScripts, boardAnimatesScriptParams, boardAssetKey, boardAssetKeySource, boardAutoplayLoops, boardMediaRate, boardMediaSpans, boardRenderTheme, boardTimedMedia, boardTextureEdge, boardTexturePixels, createBoardRenderSampler, buildBoardScene, createNodeBoardRenderer, createNodeBoardScriptHost, describeBoardExportWarning, describeBoardScriptLanes, exportBoardImageBytes, parseBoardDocument, planBoardExport, prepareBoardExport, selectBoardExportAssets, } from "./board-kernel.js";
15
- import { settleBoardDocument } from "./board-media.js";
16
- import { openBoardGpu } from "./board-gpu/daemon.js";
17
- import { findBoardGpuBrowser } from "./board-gpu/index.js";
18
- import { BOARD_EXPORT_FONTS } from "./board-fonts.js";
19
- import { createClient } from "./client.js";
20
- import { downloadPublicImage } from "./safe-remote-image.js";
21
- import { boardAudioMix, createBoardMediaFiles, createBoardVideoFrames } from "./board-media-export.js";
22
- import { BOARD_EXPORT_IMAGE_MEMORY_MIB, BoardExportResourceError, createBoardExportImageBudget, } from "./board-export-resources.js";
23
- const debugExport = debuglog("cohub:board-export");
24
- export function resolveBundledFonts() {
25
- const require = createRequire(import.meta.url);
26
- const bundled = fileURLToPath(new URL("./fonts/", import.meta.url));
27
- const locate = ({ pkg, file }) => {
28
- const copied = join(bundled, file);
29
- if (existsSync(copied))
30
- return copied;
31
- try {
32
- const path = join(dirname(require.resolve(`${pkg}/package.json`)), "files", file);
33
- return existsSync(path) ? path : null;
34
- }
35
- catch {
36
- return null;
37
- }
38
- };
39
- return BOARD_EXPORT_FONTS.flatMap((font) => {
40
- const path = locate(font);
41
- return path ? [{ path, family: font.family }] : [];
42
- });
43
- }
44
- export async function loadBoardDocument(spaceId, target) {
45
- const board = await createClient().space(spaceId).boards.open(target);
46
- let result = await board.get();
47
- const snapshot = result;
48
- const items = { ...result.items };
49
- while (result.next) {
50
- result = await board.get({ only: ["items"], cursor: result.next });
51
- if (result.version !== snapshot.version)
52
- throw new Error("Board changed while reading. Retry the export.");
53
- Object.assign(items, result.items);
54
- }
55
- const parsed = parseBoardDocument({ board: snapshot.board, items, animations: snapshot.animations ?? {} }, { keepUnknown: true });
56
- if (!parsed.ok)
57
- throw new Error(`Board ${result.id} could not be read: ${parsed.diagnostics[0]?.path}: ${parsed.diagnostics[0]?.message}`);
58
- return { document: parsed.document, boardId: result.id, title: result.title };
59
- }
60
- /** Texture keys Node can draw; 3D model stills need a browser. */
61
- export function boardExportAssetKey(item) {
62
- const key = boardAssetKey(item);
63
- return key && boardAssetKeySource(key)?.media !== "model" ? key : null;
64
- }
65
- function textureEdge(item, scale) {
66
- const edge = boardTextureEdge(item, scale);
67
- return Number.isFinite(edge) ? edge : Math.ceil(boardTexturePixels(item, scale));
68
- }
69
- const textureBytes = (texture) => texture.width * texture.height * 4;
70
- /**
71
- * Previews for `items` within what the image budget leaves after other images,
72
- * such as the background. A preview that still does not fit is omitted.
73
- */
74
- export async function loadBoardTextures(images, spaceId, items, options) {
75
- const cache = options.cache ?? { textures: new Map(), edges: new Map(), missed: new Map() };
76
- const { textures, edges, missed } = cache;
77
- let previewBytes = 0;
78
- for (const texture of textures.values())
79
- previewBytes += textureBytes(texture);
80
- const maxBytes = options.maxBytes - (images.usedBytes - previewBytes);
81
- const selection = selectBoardExportAssets([...items], boardExportAssetKey, { scale: options.scale, maxBytes });
82
- const wanted = new Set(selection.keys);
83
- for (const [key, texture] of textures) {
84
- if (wanted.has(key))
85
- continue;
86
- texture.destroy(true);
87
- textures.delete(key);
88
- edges.delete(key);
89
- }
90
- for (const key of missed.keys())
91
- if (!wanted.has(key))
92
- missed.delete(key);
93
- const pending = selection.items.flatMap((item, index) => {
94
- const key = selection.keys[index];
95
- const edge = textureEdge(item, options.scale);
96
- return missed.has(key) || (edges.get(key) ?? 0) >= edge ? [] : [{ key, item, edge }];
97
- });
98
- const concurrency = Math.max(1, Math.min(options.concurrency ?? 2, 16));
99
- const client = createClient();
100
- async function worker() {
101
- for (let task = pending.shift(); task; task = pending.shift()) {
102
- const { key, item, edge } = task;
103
- let miss = "unavailable";
104
- try {
105
- const source = boardAssetKeySource(key);
106
- const picture = source && await fetchBoardPicture(client, spaceId, source, item, edge);
107
- if (picture) {
108
- const texture = await images.decodeImage(picture.bytes, picture.mimeType, edge);
109
- textures.get(key)?.destroy(true);
110
- textures.set(key, texture);
111
- edges.set(key, Math.max(texture.width, texture.height) < edge ? Number.POSITIVE_INFINITY : edge);
112
- miss = null;
113
- }
114
- }
115
- catch (error) {
116
- miss = error instanceof BoardExportResourceError ? "omitted" : "error";
117
- }
118
- // A preview already shown stays, at the sharpness it has.
119
- if (miss && textures.has(key))
120
- edges.set(key, Number.POSITIVE_INFINITY);
121
- else if (miss)
122
- missed.set(key, miss);
123
- }
124
- }
125
- await Promise.all(Array.from({ length: Math.min(concurrency, pending.length) }, worker));
126
- const keys = (reason) => [...missed].flatMap(([key, value]) => (value === reason ? [key] : []));
127
- return { textures, failed: keys("error"), unavailable: keys("unavailable"), omitted: [...selection.omittedKeys, ...keys("omitted")] };
128
- }
129
- /**
130
- * The picture for a texture, `edge` pixels on its long edge where the host can
131
- * resize: a CDN variant of an image, or the first frame of a video. Null when
132
- * there is none, as for videos outside Cohub's media hosts.
133
- */
134
- async function fetchBoardPicture(client, spaceId, source, item, edge) {
135
- // Thumbnail edges below the smallest variant fetch that variant; decoding scales it down.
136
- const variantEdge = Number.isFinite(edge) && edge <= MEDIA_VARIANT_MAX ? mediaVariantSize(edge) : null;
137
- const video = source.media === "video";
138
- const url = source.kind === "url"
139
- ? source.value
140
- : video || variantEdge
141
- ? (await client.space(spaceId).files.resolve(source.value, { purpose: "playback" }).catch(() => null))?.url
142
- : null;
143
- if (video) {
144
- const frame = url && videoFrameUrl(url, mediaVariantSize(edge), { natural: boardMediaNaturalSize(item) });
145
- return frame ? downloadPublicImage(frame) : null;
146
- }
147
- const variant = url && variantEdge && imageVariantUrl(url, variantEdge);
148
- if (variant) {
149
- try {
150
- return await downloadPublicImage(variant);
151
- }
152
- catch {
153
- // Fall back to the original below.
154
- }
155
- }
156
- return source.kind === "url" ? downloadPublicImage(source.value) : readSpaceFileBytes(client, spaceId, source.value);
157
- }
158
- export async function readSpaceFileBytes(client, spaceId, path) {
159
- const { blob, mimeType } = await client.space(spaceId).files.download(path);
160
- return { bytes: new Uint8Array(await blob.arrayBuffer()), mimeType };
161
- }
162
- export async function runBoardVideoExport(options) {
163
- if (!options.animation)
164
- throw new Error("Video export needs --animation.");
165
- if (!options.times || options.times.length < 2)
166
- throw new Error("Video export needs an --at range with at least two frames.");
167
- const times = options.times;
168
- const step = times[1] - times[0];
169
- if (!Number.isFinite(step) || step <= 0)
170
- throw new Error("Video export needs an increasing --at range.");
171
- const derivedFps = 1000 / step;
172
- if (Math.abs(options.fps - derivedFps) > 0.01)
173
- throw new Error(`--fps must match the --at step (${derivedFps.toFixed(3)} fps).`);
174
- if (times.some((time, index) => index > 0 && Math.abs(time - times[index - 1] - step) > 0.001))
175
- throw new Error("Video export needs evenly spaced times.");
176
- await execFile("ffmpeg", ["-version"], { signal: options.signal }).catch(() => { throw new Error("Video export needs ffmpeg. Install ffmpeg and try again."); });
177
- const document = options.document ?? await settleBoardDocument(options.spaceId, (await loadBoardDocument(options.spaceId, options.target)).document);
178
- const tempDir = await mkdtemp(join(tmpdir(), "cohub-board-export-"));
179
- try {
180
- let count = 0;
181
- let dimensions = { width: 0, height: 0 };
182
- const mediaFiles = createBoardMediaFiles(options.spaceId, tempDir, options.signal);
183
- const result = await runBoardExport({ ...options, document, format: "png", mediaFiles, onFrame: async (frame, index) => {
184
- if (count && (frame.width !== dimensions.width || frame.height !== dimensions.height))
185
- throw new Error("Video frame dimensions changed. Use a fixed export region or a smaller camera viewport.");
186
- await writeFile(join(tempDir, `${String(index + 1).padStart(6, "0")}.png`), frame.bytes, { signal: options.signal });
187
- dimensions = { width: frame.width, height: frame.height };
188
- count++;
189
- } });
190
- if (!result || !count)
191
- throw new Error("Nothing to export: the region contains no items.");
192
- const start = times[0];
193
- const sampled = boardMediaSpans(result.media.map((sample) => ({ ...sample, at: sample.at - start })));
194
- const spans = sampled.map((span) => sampled.some((next) => next.id === span.id && next.start === span.end) ? span : { ...span, end: span.end + step });
195
- const mix = await boardAudioMix(spans, mediaFiles, 1);
196
- const duration = Math.max(0.001, count / options.fps);
197
- const args = ["-y", "-f", "image2", "-framerate", String(options.fps), "-i", join(tempDir, "%06d.png"), ...(mix?.inputs ?? [])];
198
- if (mix)
199
- args.push("-filter_complex", mix.filter, "-map", "0:v:0", "-map", "[aout]");
200
- else
201
- args.push("-map", "0:v:0");
202
- if (options.format === "mp4" && (dimensions.width % 2 || dimensions.height % 2))
203
- args.push("-vf", "pad=ceil(iw/2)*2:ceil(ih/2)*2");
204
- if (options.format === "mp4")
205
- args.push("-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "-movflags", "+faststart", "-f", "mp4");
206
- else
207
- args.push("-c:v", "libvpx-vp9", "-crf", "32", "-b:v", "0", "-c:a", "libopus", "-f", "webm");
208
- const encoded = join(tempDir, `video.${options.format}`);
209
- args.push("-t", duration.toFixed(3), encoded);
210
- debugExport("%j", { stage: "encode", width: dimensions.width, height: dimensions.height, frames: count, memory: process.memoryUsage() });
211
- try {
212
- await execFile("ffmpeg", args, { encoding: "utf8", maxBuffer: 2 * 1024 * 1024, signal: options.signal });
213
- }
214
- catch (error) {
215
- const cause = error;
216
- if (cause.code === "ENOENT")
217
- throw new Error("Video export needs ffmpeg. Install ffmpeg and try again.");
218
- throw new Error(`ffmpeg could not encode the video: ${(cause.stderr ?? cause.message ?? "unknown error").trim().split("\n").slice(-6).join("\n")}`);
219
- }
220
- options.signal?.throwIfAborted();
221
- const staged = `${options.output}.${randomUUID()}.tmp`;
222
- try {
223
- await copyFile(encoded, staged, constants.COPYFILE_EXCL);
224
- options.signal?.throwIfAborted();
225
- if (options.force)
226
- await rename(staged, options.output);
227
- else
228
- await link(staged, options.output);
229
- }
230
- finally {
231
- await unlink(staged).catch(() => undefined);
232
- }
233
- return { ...dimensions, frames: count, warnings: result.warnings };
234
- }
235
- finally {
236
- await rm(tempDir, { recursive: true, force: true });
237
- }
238
- }
239
- export async function runBoardExport(options) {
240
- options.signal?.throwIfAborted();
241
- const document = options.document ?? await settleBoardDocument(options.spaceId, (await loadBoardDocument(options.spaceId, options.target)).document);
242
- if (options.animation && !document.animations[options.animation]) {
243
- throw new Error(`Animation ${options.animation} does not exist.`);
244
- }
245
- const times = options.times?.length ? options.times : [null];
246
- const timeoutMs = options.timeoutMs ?? BOARD_EXPORT_FRAME_TIMEOUT_MS;
247
- const imageMemoryBytes = (options.imageMemoryMiB ?? BOARD_EXPORT_IMAGE_MEMORY_MIB) * 1024 ** 2;
248
- if (!Number.isSafeInteger(imageMemoryBytes) || imageMemoryBytes <= 0)
249
- throw new Error("Image memory budget must be a positive integer.");
250
- const nodeRenderer = await createNodeBoardRenderer({ fonts: resolveBundledFonts() });
251
- const images = createBoardExportImageBudget(nodeRenderer, imageMemoryBytes);
252
- const renderer = { ...nodeRenderer, decodeImage: images.decodeImage };
253
- const STAGES = { prepare: "running the scripts", gpu: "drawing in the browser", images: "loading images", render: "drawing" };
254
- let doing = "preparing";
255
- const trace = (stage, completed, dimensions) => {
256
- doing = STAGES[stage] ?? doing;
257
- if (!debugExport.enabled || completed % 30 !== 0)
258
- return;
259
- debugExport("%j", {
260
- stage, completed, total: times.length,
261
- ...(dimensions ? { width: dimensions.width, height: dimensions.height } : {}),
262
- imageBytes: images.usedBytes, memory: process.memoryUsage(),
263
- availableMemory: process.availableMemory(), constrainedMemory: process.constrainedMemory(),
264
- });
265
- };
266
- let scriptHost = null;
267
- let gpu = null;
268
- const textureCache = { textures: new Map(), edges: new Map(), missed: new Map() };
269
- const frameTextures = new Map();
270
- let mediaDir = null;
271
- let backgroundTexture;
272
- try {
273
- const theme = boardRenderTheme(options.theme);
274
- const sampler = createBoardRenderSampler(document, options.animation ?? null, theme);
275
- const documentAt = (time) => time === null ? document : sampler.at(time).document;
276
- const history = options.animation !== undefined && boardAnimatesScriptParams(document);
277
- const plan = planBoardExport({
278
- scene: buildBoardScene(documentAt(times[0] ?? null)),
279
- region: options.region,
280
- scale: options.scale,
281
- ...(options.padding === undefined ? {} : { padding: options.padding }),
282
- });
283
- if (!plan)
284
- return null;
285
- const region = times.length > 1 && !options.camera ? { kind: "rect", rect: plan.world } : options.region;
286
- const firstTime = times[0] ?? null;
287
- const first = prepareBoardExport(document, {
288
- sampler, region, camera: options.camera, scale: options.scale,
289
- padding: times.length > 1 ? 0 : options.padding,
290
- ...(firstTime === null ? {} : { at: { animation: options.animation, time: firstTime } }),
291
- });
292
- if (!first)
293
- return null;
294
- options.onPlan?.({ width: first.plan.width, height: first.plan.height, frames: times.length });
295
- trace("plan", 0, first.plan);
296
- const warnings = [];
297
- const textures = textureCache.textures;
298
- let omittedKeys = new Set();
299
- const backgroundSource = document.board.background.image && parseBoardMediaSource(document.board.background.image.src);
300
- if (options.withImages && options.background === "paper" && backgroundSource) {
301
- try {
302
- const { bytes, mimeType } = backgroundSource.kind === "url"
303
- ? await downloadPublicImage(backgroundSource.value)
304
- : await readSpaceFileBytes(createClient(), options.spaceId, backgroundSource.value);
305
- backgroundTexture = await renderer.decodeImage(bytes, mimeType);
306
- }
307
- catch (error) {
308
- if (error instanceof BoardExportResourceError)
309
- throw error;
310
- warnings.push("The board background image could not be loaded; the fallback color was exported.");
311
- }
312
- }
313
- if (!options.scripts && options.renderer !== "gpu" && hasBoardScripts(document))
314
- scriptHost = createNodeBoardScriptHost(renderer, {
315
- concurrency: 2,
316
- readModule: async (src) => {
317
- const { bytes } = await readSpaceFileBytes(createClient(), options.spaceId, src);
318
- return new TextDecoder().decode(bytes);
319
- },
320
- });
321
- const assetKey = (item) => {
322
- const key = boardExportAssetKey(item);
323
- return key && omittedKeys.has(key) ? null : key;
324
- };
325
- const frames = [];
326
- const media = [];
327
- const fps = times.length > 1 && times[0] !== null && times[1] !== null ? 1000 / (times[1] - times[0]) : 30;
328
- const lastMedia = new Map();
329
- const framePictures = new Map();
330
- let videoFrames = null;
331
- const frameOf = async (state, rate, edge) => {
332
- if (!videoFrames) {
333
- mediaDir = await mkdtemp(join(tmpdir(), "cohub-board-media-"));
334
- videoFrames = createBoardVideoFrames(options.mediaFiles ?? createBoardMediaFiles(options.spaceId, mediaDir, options.signal), mediaDir, { fps, signal: options.signal });
335
- }
336
- return videoFrames.frame(state, rate, edge);
337
- };
338
- const reported = new Set();
339
- const report = (text) => {
340
- if (reported.has(text))
341
- return;
342
- reported.add(text);
343
- warnings.push(text);
344
- };
345
- let completed = 0;
346
- let decided = options.renderer === "canvas";
347
- const emit = async (frame) => {
348
- if (options.onFrame)
349
- await options.onFrame(frame, completed);
350
- else
351
- frames.push(frame);
352
- completed++;
353
- options.onProgress?.(completed, times.length);
354
- };
355
- const launchGpu = async (browser) => {
356
- doing = "starting the browser";
357
- const exporter = await openBoardGpu(gpuResources(options.spaceId, document, (key) => framePictures.get(key)), { browser, signal: options.signal });
358
- try {
359
- await exporter.init({ document, animation: options.animation ?? null, theme: options.theme, ...(options.snapshots ? { snapshots: options.snapshots } : {}) });
360
- }
361
- catch (error) {
362
- await exporter.close();
363
- throw error;
364
- }
365
- scriptHost?.destroy();
366
- scriptHost = null;
367
- return exporter;
368
- };
369
- if (options.renderer === "gpu") {
370
- const browser = findBoardGpuBrowser();
371
- if (!browser)
372
- throw new Error("GPU export needs Chrome, Chromium or Edge. Install one, or set COHUB_CHROME to its path.");
373
- gpu = await launchGpu(browser);
374
- }
375
- const renderFrame = async (time) => {
376
- options.signal?.throwIfAborted();
377
- const host = scriptHost;
378
- host?.clearFrames();
379
- const frameOptions = { sampler, camera: options.camera, ...(time === null ? {} : { at: { animation: options.animation, time } }), region, scale: options.scale, padding: times.length > 1 ? 0 : options.padding };
380
- const initial = prepareBoardExport(document, frameOptions);
381
- if (!initial)
382
- return;
383
- let prepared = initial;
384
- trace("prepare", completed, initial.plan);
385
- const prepareScripts = async (scripts, shaders) => {
386
- await scripts.prepare(initial.scene.items, [time ?? 0], initial.plan.scale, initial.document.board, {
387
- shaders,
388
- view: boardExportView(initial.plan),
389
- ...(history ? { history: (at) => documentAt(at) } : {}),
390
- });
391
- for (const [id, message] of scripts.emitFailures)
392
- report(`${id}: ${message}`);
393
- for (const id of [...Object.keys(initial.document.board.scripts ?? {}), ...initial.scene.items.map((item) => item.id)]) {
394
- const error = scripts.error(id);
395
- if (error)
396
- throw new Error(`${initial.document.board.scripts?.[id]?.src ?? initial.scene.get(id)?.script?.src ?? id}: ${error}`);
397
- }
398
- return prepareBoardExport(document, { ...frameOptions, scripts });
399
- };
400
- if (host && !gpu) {
401
- const scripted = await prepareScripts(host, !decided);
402
- if (!scripted)
403
- return;
404
- prepared = scripted;
405
- }
406
- if (!decided) {
407
- decided = true;
408
- const shaded = (host?.shaders?.(prepared.document, time ?? 0) ?? []).map((owner) => owner.id);
409
- const browser = shaded.length ? findBoardGpuBrowser() : null;
410
- if (browser)
411
- gpu = await launchGpu(browser);
412
- else if (host && shaded.length) {
413
- report(`Shaders in ${shaded.join(", ")} need Chrome, Chromium or Edge; install one or set COHUB_CHROME to draw them.`);
414
- host.clearFrames();
415
- const scripted = await prepareScripts(host, false);
416
- if (!scripted)
417
- return;
418
- prepared = scripted;
419
- }
420
- }
421
- const timed = boardTimedMedia(prepared.scene);
422
- media.push({ at: time ?? 0, media: timed });
423
- const frameKeys = {};
424
- for (const texture of frameTextures.values())
425
- texture.destroy(true);
426
- frameTextures.clear();
427
- framePictures.clear();
428
- if (options.withImages) {
429
- const planned = new Set(prepared.plan.items.map((item) => item.id));
430
- const loops = time === null ? [] : boardAutoplayLoops(prepared.scene, time);
431
- for (const state of [...timed, ...loops]) {
432
- const item = prepared.scene.get(state.id);
433
- const base = item && state.kind === "video" && state.shown && planned.has(state.id) ? boardExportAssetKey(item) : null;
434
- if (!item || !base)
435
- continue;
436
- const before = lastMedia.get(state.id);
437
- if (time !== null)
438
- lastMedia.set(state.id, { at: time, time: state.time });
439
- const rate = times.length === 1 ? 0 : before && time !== null ? boardMediaRate(before, { at: time, time: state.time }) : 1;
440
- const edge = Math.min(4096, textureEdge(item, prepared.plan.scale));
441
- const bytes = await frameOf(state, rate, edge).catch((error) => {
442
- report(`Frames of ${state.src} could not be decoded; its cover was drawn instead. ${error instanceof Error ? error.message : ""}`.trim());
443
- return null;
444
- });
445
- if (!bytes?.length)
446
- continue;
447
- const key = `${base}@${Math.round(state.time)}`;
448
- frameKeys[state.id] = key;
449
- framePictures.set(key, bytes);
450
- if (!gpu)
451
- frameTextures.set(key, await nodeRenderer.decodeImage(bytes, "image/jpeg"));
452
- }
453
- }
454
- if (gpu) {
455
- trace("gpu", completed, prepared.plan);
456
- const result = await gpu.render({
457
- time,
458
- region,
459
- ...(options.camera ? { camera: options.camera } : {}),
460
- scale: options.scale,
461
- ...(times.length > 1 || options.padding === undefined ? {} : { padding: options.padding }),
462
- background: options.background,
463
- format: options.format,
464
- ...(options.quality === undefined ? {} : { quality: options.quality }),
465
- withImages: options.withImages,
466
- imageMemory: imageMemoryBytes,
467
- assetKeys: frameKeys,
468
- });
469
- for (const warning of result.warnings)
470
- report(options.withImages && warning.kind === "images-missing" ? describeBoardExportWarning(warning) : describeWarning(warning));
471
- await emit({ time, bytes: result.bytes, width: result.width, height: result.height, scale: result.scale, itemCount: result.itemCount, format: options.format });
472
- return;
473
- }
474
- trace("images", completed, prepared.plan);
475
- if (options.withImages) {
476
- const visible = prepared.plan.items.filter((item) => prepared.scene.opacity(item.id) > 0 && !frameKeys[item.id]);
477
- const loaded = await loadBoardTextures(images, options.spaceId, visible, { scale: prepared.plan.scale, maxBytes: imageMemoryBytes, cache: textureCache });
478
- omittedKeys = new Set(loaded.omitted);
479
- const sources = (keys) => keys.slice(0, 3).map((key) => boardAssetKeySource(key)?.value ?? key).join(", ");
480
- const plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
481
- const assetWarnings = [
482
- loaded.failed.length ? `${plural(loaded.failed.length, "preview")} could not be loaded: ${sources(loaded.failed)}` : null,
483
- loaded.unavailable.length ? `${plural(loaded.unavailable.length, "video")} drawn without a cover; Node exports take covers from Cohub-hosted media only.` : null,
484
- loaded.omitted.length ? `${plural(loaded.omitted.length, "preview")} drawn as placeholders to stay within the ${imageMemoryBytes / 1024 ** 2} MiB image budget; raise --image-memory to include them.` : null,
485
- ];
486
- for (const warning of assetWarnings)
487
- if (warning && !reported.has(warning)) {
488
- warnings.push(warning);
489
- reported.add(warning);
490
- }
491
- }
492
- trace("render", completed, prepared.plan);
493
- const result = exportBoardImageBytes(renderer, document, {
494
- ...frameOptions,
495
- ...theme,
496
- background: options.background,
497
- textures: frameTextures.size ? new Map([...textures, ...frameTextures]) : textures,
498
- scripts: options.scripts ?? scriptHost ?? undefined,
499
- backgroundTexture,
500
- assetKey: (item) => frameKeys[item.id] ?? assetKey(item),
501
- format: options.format,
502
- quality: options.quality,
503
- });
504
- if (!result)
505
- return;
506
- for (const warning of result.warnings) {
507
- if (warning.kind === "images-missing" && options.withImages)
508
- continue;
509
- if (warning.kind === "shaders-unsupported" && options.renderer !== "canvas")
510
- continue;
511
- report(describeWarning(warning));
512
- }
513
- await emit({
514
- time,
515
- bytes: result.bytes,
516
- width: result.plan.width,
517
- height: result.plan.height,
518
- scale: result.plan.scale,
519
- itemCount: result.plan.items.length,
520
- format: result.format,
521
- });
522
- trace("rendered", completed, result.plan);
523
- };
524
- for (const time of times) {
525
- let timer;
526
- const stalled = new Promise((_resolve, reject) => {
527
- timer = setTimeout(() => reject(new Error(describeStall(time, timeoutMs, doing, scriptHost?.status() ?? null))), timeoutMs);
528
- });
529
- try {
530
- await Promise.race([renderFrame(time), stalled]);
531
- }
532
- finally {
533
- clearTimeout(timer);
534
- }
535
- }
536
- return completed ? { frames, warnings, media } : null;
537
- }
538
- finally {
539
- await gpu?.close();
540
- scriptHost?.destroy();
541
- for (const texture of textureCache.textures.values())
542
- texture.destroy(true);
543
- backgroundTexture?.destroy(true);
544
- for (const texture of frameTextures.values())
545
- texture.destroy(true);
546
- if (mediaDir)
547
- await rm(mediaDir, { recursive: true, force: true });
548
- renderer.destroy();
549
- }
550
- }
551
- export function gpuResources(spaceId, document, framePicture = () => undefined) {
552
- const client = createClient();
553
- const scene = buildBoardScene(document);
554
- return {
555
- fonts: resolveBundledFonts().flatMap(({ path, family }) => (family ? [{ path, family }] : [])),
556
- readModule: async (path) => new TextDecoder().decode((await readSpaceFileBytes(client, spaceId, path)).bytes),
557
- async readPicture(request) {
558
- if ("background" in request) {
559
- const source = document.board.background.image && parseBoardMediaSource(document.board.background.image.src);
560
- if (!source)
561
- return null;
562
- return source.kind === "url" ? downloadPublicImage(source.value) : readSpaceFileBytes(client, spaceId, source.value);
563
- }
564
- const frame = framePicture(request.key);
565
- if (frame)
566
- return { bytes: frame, mimeType: "image/jpeg" };
567
- const source = boardAssetKeySource(request.key);
568
- const item = scene.items.find((entry) => boardAssetKey(entry) === request.key);
569
- return source && item ? fetchBoardPicture(client, spaceId, source, item, request.edge) : null;
570
- },
571
- };
572
- }
573
- export const BOARD_EXPORT_FRAME_TIMEOUT_MS = 120_000;
574
- function describeStall(time, timeoutMs, doing, lanes) {
575
- const at = time === null ? "The export" : `The frame at ${time} ms`;
576
- const busy = lanes ? describeBoardScriptLanes(lanes) : [];
577
- const hint = doing === "drawing in the browser" ? " The browser runs the scripts and shaders there; a shader may be too heavy." : "";
578
- return [`${at} did not finish in ${timeoutMs / 1000} s, while ${doing}.${hint}`, ...busy.map((line) => ` ${line}`)].join("\n");
579
- }
580
- function describeWarning(warning) {
581
- if (warning.kind === "scale-clamped") {
582
- return `Scale reduced from ${warning.requested}x to ${Number(warning.applied).toFixed(2)}x to stay within the size limit.`;
583
- }
584
- if (warning.kind === "images-missing") {
585
- const keys = warning.keys;
586
- return `${keys.length} preview${keys.length === 1 ? "" : "s"} drawn as placeholders; omit --no-images to fetch them.`;
587
- }
588
- if (warning.kind === "many-items") {
589
- return `${warning.count} items exported.`;
590
- }
591
- return describeBoardExportWarning(warning);
592
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Fonts `boards export` registers, copied into `dist/fonts` at build time. The
3
- * variable files and family names are the ones the Web loads, so every weight
4
- * draws with the same outlines; Figtree is the Neta Pixel theme's font.
5
- */
6
- export type BoardExportFont = {
7
- pkg: string;
8
- file: string;
9
- family: string;
10
- };
11
- export declare const BOARD_EXPORT_FONTS: readonly BoardExportFont[];
@@ -1,10 +0,0 @@
1
- /**
2
- * Fonts `boards export` registers, copied into `dist/fonts` at build time. The
3
- * variable files and family names are the ones the Web loads, so every weight
4
- * draws with the same outlines; Figtree is the Neta Pixel theme's font.
5
- */
6
- export const BOARD_EXPORT_FONTS = [
7
- { pkg: "@fontsource-variable/geist", file: "geist-latin-wght-normal.woff2", family: "Geist Variable" },
8
- { pkg: "@fontsource-variable/geist-mono", file: "geist-mono-latin-wght-normal.woff2", family: "Geist Mono Variable" },
9
- { pkg: "@fontsource-variable/figtree", file: "figtree-latin-wght-normal.woff2", family: "Figtree Variable" },
10
- ];
@@ -1,11 +0,0 @@
1
- import { type BoardGpuExporter, type BoardGpuResources } from "./index.js";
2
- export declare function boardGpuSocket(browser: string): string;
3
- export declare function serveBoardGpu(browser: string): Promise<void>;
4
- export declare function connectBoardGpu(resources: BoardGpuResources, options: {
5
- browser: string;
6
- signal?: AbortSignal;
7
- }): Promise<BoardGpuExporter | null>;
8
- export declare function openBoardGpu(resources: BoardGpuResources, options: {
9
- browser: string;
10
- signal?: AbortSignal;
11
- }): Promise<BoardGpuExporter>;