@sixb/core 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (627) hide show
  1. package/dist/actions/index.js +52 -49
  2. package/dist/actions/index.js.map +1 -1
  3. package/dist/actions/request.d.ts.map +1 -1
  4. package/dist/actions/run/context.d.ts.map +1 -1
  5. package/dist/actions/run/execute.d.ts +3 -0
  6. package/dist/actions/run/execute.d.ts.map +1 -1
  7. package/dist/actions/run/executor.d.ts +3 -0
  8. package/dist/actions/run/executor.d.ts.map +1 -1
  9. package/dist/actions/run/normalize.d.ts.map +1 -1
  10. package/dist/actions/run/types.d.ts +6 -0
  11. package/dist/actions/run/types.d.ts.map +1 -1
  12. package/dist/actions/types/context.d.ts +7 -0
  13. package/dist/actions/types/context.d.ts.map +1 -1
  14. package/dist/agents/context/entries.d.ts +17 -0
  15. package/dist/agents/context/entries.d.ts.map +1 -1
  16. package/dist/agents/context/index.js +3 -2
  17. package/dist/agents/context/index.js.map +1 -1
  18. package/dist/agents/context-model.d.ts.map +1 -1
  19. package/dist/agents/context-resolution.d.ts.map +1 -1
  20. package/dist/agents/execution.d.ts +7 -0
  21. package/dist/agents/execution.d.ts.map +1 -1
  22. package/dist/agents/index.js +57 -54
  23. package/dist/agents/index.js.map +1 -1
  24. package/dist/agents/model-call-retry.d.ts +28 -0
  25. package/dist/agents/model-call-retry.d.ts.map +1 -0
  26. package/dist/agents/model-loop.d.ts +4 -2
  27. package/dist/agents/model-loop.d.ts.map +1 -1
  28. package/dist/agents/run-artifacts.d.ts +2 -0
  29. package/dist/agents/run-artifacts.d.ts.map +1 -1
  30. package/dist/agents/run-plan.d.ts +1 -1
  31. package/dist/agents/run-plan.d.ts.map +1 -1
  32. package/dist/agents/run-session-http.d.ts.map +1 -1
  33. package/dist/agents/run-session-serve.d.ts.map +1 -1
  34. package/dist/agents/run-session-wire.d.ts +6 -0
  35. package/dist/agents/run-session-wire.d.ts.map +1 -1
  36. package/dist/agents/thread-access.d.ts +13 -0
  37. package/dist/agents/thread-access.d.ts.map +1 -1
  38. package/dist/agents/tool-files.d.ts.map +1 -1
  39. package/dist/artifacts/caller.d.ts +10 -0
  40. package/dist/artifacts/caller.d.ts.map +1 -0
  41. package/dist/artifacts/comment-place.d.ts +26 -0
  42. package/dist/artifacts/comment-place.d.ts.map +1 -0
  43. package/dist/artifacts/comment-text.d.ts +12 -4
  44. package/dist/artifacts/comment-text.d.ts.map +1 -1
  45. package/dist/artifacts/comments.d.ts +8 -2
  46. package/dist/artifacts/comments.d.ts.map +1 -1
  47. package/dist/artifacts/errors.d.ts +1 -1
  48. package/dist/artifacts/errors.d.ts.map +1 -1
  49. package/dist/artifacts/execution.d.ts +73 -5
  50. package/dist/artifacts/execution.d.ts.map +1 -1
  51. package/dist/artifacts/frames/assets.d.ts +27 -7
  52. package/dist/artifacts/frames/assets.d.ts.map +1 -1
  53. package/dist/artifacts/frames/entries.d.ts +5 -4
  54. package/dist/artifacts/frames/entries.d.ts.map +1 -1
  55. package/dist/artifacts/frames/hyperframes.d.ts +12 -0
  56. package/dist/artifacts/frames/hyperframes.d.ts.map +1 -0
  57. package/dist/artifacts/frames/index.d.ts +3 -1
  58. package/dist/artifacts/frames/index.d.ts.map +1 -1
  59. package/dist/artifacts/frames/index.js +20 -6
  60. package/dist/artifacts/frames/index.js.map +3 -3
  61. package/dist/artifacts/frames/kit.d.ts.map +1 -1
  62. package/dist/artifacts/frames/protocol.d.ts +33 -0
  63. package/dist/artifacts/frames/protocol.d.ts.map +1 -1
  64. package/dist/artifacts/frames/video-runtime.d.ts +21 -0
  65. package/dist/artifacts/frames/video-runtime.d.ts.map +1 -0
  66. package/dist/artifacts/html.d.ts +23 -0
  67. package/dist/artifacts/html.d.ts.map +1 -1
  68. package/dist/artifacts/index.d.ts +5 -3
  69. package/dist/artifacts/index.d.ts.map +1 -1
  70. package/dist/artifacts/index.js +71 -10
  71. package/dist/artifacts/index.js.map +4 -4
  72. package/dist/artifacts/kinds.d.ts +1 -1
  73. package/dist/artifacts/kinds.d.ts.map +1 -1
  74. package/dist/artifacts/limits.d.ts +37 -0
  75. package/dist/artifacts/limits.d.ts.map +1 -1
  76. package/dist/artifacts/live/document.d.ts.map +1 -1
  77. package/dist/artifacts/live/index.d.ts +6 -2
  78. package/dist/artifacts/live/index.d.ts.map +1 -1
  79. package/dist/artifacts/live/index.js +3432 -13
  80. package/dist/artifacts/live/index.js.map +6 -3
  81. package/dist/artifacts/live/presence.d.ts +7 -5
  82. package/dist/artifacts/live/presence.d.ts.map +1 -1
  83. package/dist/artifacts/live/protocol.d.ts +4 -2
  84. package/dist/artifacts/live/protocol.d.ts.map +1 -1
  85. package/dist/artifacts/live/server.d.ts +1 -1
  86. package/dist/artifacts/live/server.d.ts.map +1 -1
  87. package/dist/artifacts/live/server.js +36 -31
  88. package/dist/artifacts/live/server.js.map +1 -1
  89. package/dist/artifacts/live/state.d.ts +2 -2
  90. package/dist/artifacts/media/media.d.ts +96 -0
  91. package/dist/artifacts/media/media.d.ts.map +1 -0
  92. package/dist/artifacts/media/transcriber.d.ts +29 -0
  93. package/dist/artifacts/media/transcriber.d.ts.map +1 -0
  94. package/dist/artifacts/outline.d.ts +26 -1
  95. package/dist/artifacts/outline.d.ts.map +1 -1
  96. package/dist/artifacts/publish/files.d.ts +5 -2
  97. package/dist/artifacts/publish/files.d.ts.map +1 -1
  98. package/dist/artifacts/publish/index.d.ts +11 -2
  99. package/dist/artifacts/publish/index.d.ts.map +1 -1
  100. package/dist/artifacts/publish/index.js +110 -33
  101. package/dist/artifacts/publish/index.js.map +1 -1
  102. package/dist/artifacts/publish/pdf.d.ts.map +1 -1
  103. package/dist/artifacts/publish/previews.d.ts +7 -2
  104. package/dist/artifacts/publish/previews.d.ts.map +1 -1
  105. package/dist/artifacts/publish/publish.d.ts.map +1 -1
  106. package/dist/artifacts/publish/validate/html.d.ts +5 -4
  107. package/dist/artifacts/publish/validate/html.d.ts.map +1 -1
  108. package/dist/artifacts/publish/validate/video.d.ts +36 -0
  109. package/dist/artifacts/publish/validate/video.d.ts.map +1 -0
  110. package/dist/artifacts/publish/video.d.ts +79 -0
  111. package/dist/artifacts/publish/video.d.ts.map +1 -0
  112. package/dist/artifacts/resolve.d.ts +9 -0
  113. package/dist/artifacts/resolve.d.ts.map +1 -1
  114. package/dist/artifacts/video/composition.d.ts +183 -0
  115. package/dist/artifacts/video/composition.d.ts.map +1 -0
  116. package/dist/artifacts/video/edit.d.ts +298 -0
  117. package/dist/artifacts/video/edit.d.ts.map +1 -0
  118. package/dist/artifacts/video/export.d.ts +142 -0
  119. package/dist/artifacts/video/export.d.ts.map +1 -0
  120. package/dist/artifacts/video/looks.d.ts +133 -0
  121. package/dist/artifacts/video/looks.d.ts.map +1 -0
  122. package/dist/artifacts/video/project.d.ts +74 -0
  123. package/dist/artifacts/video/project.d.ts.map +1 -0
  124. package/dist/artifacts/video/stills.d.ts +65 -0
  125. package/dist/artifacts/video/stills.d.ts.map +1 -0
  126. package/dist/artifacts/video/timeline.d.ts +153 -0
  127. package/dist/artifacts/video/timeline.d.ts.map +1 -0
  128. package/dist/auth/index.js +9 -8
  129. package/dist/auth/index.js.map +1 -1
  130. package/dist/authorization/index.js +5 -4
  131. package/dist/authorization/index.js.map +1 -1
  132. package/dist/blob-storage/browser.d.ts +1 -1
  133. package/dist/blob-storage/browser.d.ts.map +1 -1
  134. package/dist/blob-storage/browser.js +8 -4
  135. package/dist/blob-storage/browser.js.map +1 -1
  136. package/dist/blob-storage/constants.d.ts +8 -3
  137. package/dist/blob-storage/constants.d.ts.map +1 -1
  138. package/dist/blob-storage/download-urls.d.ts +2 -2
  139. package/dist/blob-storage/download-urls.d.ts.map +1 -1
  140. package/dist/blob-storage/index.d.ts +1 -1
  141. package/dist/blob-storage/index.d.ts.map +1 -1
  142. package/dist/blob-storage/index.js +9 -5
  143. package/dist/blob-storage/index.js.map +1 -1
  144. package/dist/blob-storage/internal.d.ts +2 -2
  145. package/dist/blob-storage/internal.d.ts.map +1 -1
  146. package/dist/blob-storage/internal.js +10 -4
  147. package/dist/blob-storage/internal.js.map +1 -1
  148. package/dist/blob-storage/media-type.d.ts +12 -3
  149. package/dist/blob-storage/media-type.d.ts.map +1 -1
  150. package/dist/bootstrap/index.js +61 -58
  151. package/dist/bootstrap/index.js.map +2 -2
  152. package/dist/{chunk-az95tsh3.js → chunk-0fjryajn.js} +3 -2
  153. package/dist/chunk-0fjryajn.js.map +11 -0
  154. package/dist/{chunk-9tpmfh3n.js → chunk-0mk8qqp9.js} +3 -3
  155. package/dist/{chunk-9tpmfh3n.js.map → chunk-0mk8qqp9.js.map} +3 -3
  156. package/dist/{chunk-88xeh6zx.js → chunk-1g4me5f2.js} +182 -7
  157. package/dist/{chunk-88xeh6zx.js.map → chunk-1g4me5f2.js.map} +3 -3
  158. package/dist/{chunk-7mhbs9yy.js → chunk-1z8ccj53.js} +1 -1
  159. package/dist/{chunk-wkv3h3q7.js → chunk-2138b0ng.js} +115 -8
  160. package/dist/chunk-2138b0ng.js.map +12 -0
  161. package/dist/chunk-23eaayw4.js +3757 -0
  162. package/dist/chunk-23eaayw4.js.map +22 -0
  163. package/dist/{chunk-m1cwncee.js → chunk-2mxq1yd9.js} +45 -40
  164. package/dist/{chunk-m1cwncee.js.map → chunk-2mxq1yd9.js.map} +3 -3
  165. package/dist/{chunk-dmnd9ea6.js → chunk-30a0ftnm.js} +2 -2
  166. package/dist/chunk-389ybvw9.js.map +2 -2
  167. package/dist/{chunk-qbd282aa.js → chunk-39q9ybav.js} +2 -2
  168. package/dist/{chunk-06kpaqg4.js → chunk-3d9w8t4n.js} +110 -22
  169. package/dist/{chunk-06kpaqg4.js.map → chunk-3d9w8t4n.js.map} +5 -5
  170. package/dist/chunk-3dvcdn9w.js +8 -0
  171. package/dist/chunk-3dvcdn9w.js.map +10 -0
  172. package/dist/{chunk-fdk0ks9p.js → chunk-3x902cja.js} +3 -3
  173. package/dist/{chunk-c4nrycdy.js → chunk-4q4a5a96.js} +1 -1
  174. package/dist/{chunk-9cyq87qa.js → chunk-4tdm3fsj.js} +95 -32
  175. package/dist/{chunk-9cyq87qa.js.map → chunk-4tdm3fsj.js.map} +9 -9
  176. package/dist/{chunk-cpy282b8.js → chunk-4w8qzy9w.js} +6 -6
  177. package/dist/{chunk-c29729me.js → chunk-4z9xtxke.js} +8 -7
  178. package/dist/chunk-4z9xtxke.js.map +12 -0
  179. package/dist/chunk-5278qwax.js +270 -0
  180. package/dist/chunk-5278qwax.js.map +11 -0
  181. package/dist/{chunk-k1g14kk3.js → chunk-6a4hp405.js} +4 -5
  182. package/dist/{chunk-k1g14kk3.js.map → chunk-6a4hp405.js.map} +3 -3
  183. package/dist/{chunk-xavet0qs.js → chunk-6whr25gw.js} +2 -2
  184. package/dist/{chunk-mbwsgjn7.js → chunk-7zygtcqq.js} +14 -2
  185. package/dist/chunk-7zygtcqq.js.map +11 -0
  186. package/dist/chunk-88s9z5pf.js +3 -0
  187. package/dist/{chunk-de5sfbc3.js.map → chunk-88s9z5pf.js.map} +1 -1
  188. package/dist/{chunk-ygvay56w.js → chunk-896te58g.js} +2 -2
  189. package/dist/{chunk-pfdq1ga6.js → chunk-8eqqqc1h.js} +3 -3
  190. package/dist/{chunk-yyj009tv.js → chunk-8tefbhdx.js} +14 -14
  191. package/dist/{chunk-yyj009tv.js.map → chunk-8tefbhdx.js.map} +1 -1
  192. package/dist/{chunk-jka26v8c.js → chunk-8x1bsp68.js} +1 -1
  193. package/dist/{chunk-wzcjhv54.js → chunk-93e4w7te.js} +113 -1
  194. package/dist/chunk-93e4w7te.js.map +11 -0
  195. package/dist/{chunk-phs5fbff.js → chunk-990a5bkc.js} +424 -76
  196. package/dist/chunk-990a5bkc.js.map +21 -0
  197. package/dist/{chunk-6md802cc.js → chunk-9az7kjv4.js} +6 -6
  198. package/dist/{chunk-95ps0k5q.js → chunk-9e5t53z0.js} +1 -1
  199. package/dist/{chunk-js9e6487.js → chunk-9p7kyeqz.js} +4 -4
  200. package/dist/chunk-a68zz4r0.js +537 -0
  201. package/dist/chunk-a68zz4r0.js.map +11 -0
  202. package/dist/{chunk-d7vyc7k6.js → chunk-a700gjc8.js} +10 -2
  203. package/dist/chunk-a700gjc8.js.map +10 -0
  204. package/dist/{chunk-gfdh9kqa.js → chunk-a9qzjaz2.js} +2 -5
  205. package/dist/chunk-a9qzjaz2.js.map +10 -0
  206. package/dist/{chunk-8qmp9fpa.js → chunk-as94vcty.js} +619 -482
  207. package/dist/{chunk-8qmp9fpa.js.map → chunk-as94vcty.js.map} +19 -19
  208. package/dist/{chunk-brybqw5k.js → chunk-bkxm2dzx.js} +1 -1
  209. package/dist/{chunk-ppxf7gw2.js → chunk-d7t9jnym.js} +3 -3
  210. package/dist/{chunk-tapdssb5.js → chunk-e3b1r4d2.js} +8 -7
  211. package/dist/{chunk-tapdssb5.js.map → chunk-e3b1r4d2.js.map} +4 -4
  212. package/dist/{chunk-cg7cygfj.js → chunk-fdmvaz7x.js} +1 -1
  213. package/dist/{chunk-191jz8a6.js → chunk-ff0qdk7z.js} +1 -1
  214. package/dist/{chunk-9vsc919v.js → chunk-fgxvrxx4.js} +22 -2
  215. package/dist/chunk-fgxvrxx4.js.map +10 -0
  216. package/dist/{chunk-wx7smkn2.js → chunk-fq8drkp0.js} +1 -1
  217. package/dist/{chunk-60662fyv.js → chunk-fqms1a8c.js} +132 -4
  218. package/dist/{chunk-60662fyv.js.map → chunk-fqms1a8c.js.map} +8 -6
  219. package/dist/{chunk-v8a1qjzp.js → chunk-hpswfrjj.js} +1 -1
  220. package/dist/{chunk-qttqe1ah.js → chunk-jbg905hn.js} +80 -13
  221. package/dist/chunk-jbg905hn.js.map +25 -0
  222. package/dist/{chunk-bz5bnjjt.js → chunk-jjte0h4p.js} +1 -1
  223. package/dist/{chunk-hvq8xs66.js → chunk-jwjwvzj1.js} +797 -51
  224. package/dist/chunk-jwjwvzj1.js.map +38 -0
  225. package/dist/{chunk-k29rdc3h.js → chunk-k3vd2vyz.js} +6 -2
  226. package/dist/chunk-k3vd2vyz.js.map +10 -0
  227. package/dist/chunk-kcqpk9w1.js.map +2 -2
  228. package/dist/chunk-mvz89age.js.map +2 -2
  229. package/dist/{chunk-xrmbhap8.js → chunk-mwg0nwkb.js} +1 -1
  230. package/dist/{chunk-a3faa34j.js → chunk-nfjt8k8j.js} +1 -1
  231. package/dist/{chunk-394zjzjs.js → chunk-nhgqz3g3.js} +3 -3
  232. package/dist/{chunk-bqr703h4.js → chunk-p0c5kkhn.js} +23 -6
  233. package/dist/{chunk-bqr703h4.js.map → chunk-p0c5kkhn.js.map} +3 -3
  234. package/dist/{chunk-92wrka15.js → chunk-q150fnj9.js} +1 -1
  235. package/dist/{chunk-w3t94hm6.js → chunk-qk3zq25v.js} +1 -1
  236. package/dist/chunk-rtkqczbr.js.map +2 -2
  237. package/dist/{chunk-3qtk0070.js → chunk-ssqbrts1.js} +86 -9
  238. package/dist/chunk-ssqbrts1.js.map +14 -0
  239. package/dist/{chunk-5qqmndhm.js → chunk-szzhrn3e.js} +1 -1
  240. package/dist/{chunk-n1hbwc6y.js → chunk-t6pfch4e.js} +1 -1
  241. package/dist/{chunk-xtztwpkh.js → chunk-v6h4tc2v.js} +86 -5
  242. package/dist/chunk-v6h4tc2v.js.map +12 -0
  243. package/dist/{chunk-brhp9d97.js → chunk-vmqjndb3.js} +2 -2
  244. package/dist/chunk-vtjzwymr.js.map +2 -2
  245. package/dist/{chunk-fycac8e9.js → chunk-wpba6hhd.js} +10 -10
  246. package/dist/{chunk-fycac8e9.js.map → chunk-wpba6hhd.js.map} +1 -1
  247. package/dist/{chunk-t58sktr5.js → chunk-wrb1x1ss.js} +2 -2
  248. package/dist/{chunk-5sswe5ej.js → chunk-wsv23wvr.js} +2 -2
  249. package/dist/{chunk-04r2fdsd.js → chunk-x0hqc54n.js} +4 -4
  250. package/dist/{chunk-sgx82nnt.js → chunk-xg31er4p.js} +43 -4
  251. package/dist/chunk-xg31er4p.js.map +10 -0
  252. package/dist/{chunk-3neam1y5.js → chunk-y3qb965a.js} +2 -2
  253. package/dist/{chunk-5pz3htbe.js → chunk-y57eawng.js} +3 -3
  254. package/dist/{chunk-8ncg20rd.js → chunk-yah25st6.js} +5 -5
  255. package/dist/chunk-yah25st6.js.map +10 -0
  256. package/dist/{chunk-mrs7jy17.js → chunk-ywvxcmqj.js} +106 -13
  257. package/dist/{chunk-mrs7jy17.js.map → chunk-ywvxcmqj.js.map} +8 -7
  258. package/dist/{chunk-44hrfmbk.js → chunk-zmq9xc9s.js} +70 -31
  259. package/dist/{chunk-44hrfmbk.js.map → chunk-zmq9xc9s.js.map} +4 -3
  260. package/dist/datasets/write.js +8 -7
  261. package/dist/datasets/write.js.map +1 -1
  262. package/dist/errors/catalog.d.ts.map +1 -1
  263. package/dist/execution/agent.js +52 -49
  264. package/dist/execution/agent.js.map +1 -1
  265. package/dist/execution/kernel-operation.d.ts +1 -0
  266. package/dist/execution/kernel-operation.d.ts.map +1 -1
  267. package/dist/execution/primitive.js +52 -49
  268. package/dist/execution/primitive.js.map +1 -1
  269. package/dist/execution/request.js +53 -50
  270. package/dist/execution/request.js.map +2 -2
  271. package/dist/execution/types.d.ts +5 -0
  272. package/dist/execution/types.d.ts.map +1 -1
  273. package/dist/http/api-routes.d.ts.map +1 -1
  274. package/dist/http/index.js +1 -1
  275. package/dist/index.d.ts +5 -3
  276. package/dist/index.d.ts.map +1 -1
  277. package/dist/index.js +69 -65
  278. package/dist/index.js.map +1 -1
  279. package/dist/lake-storage/index.js +9 -8
  280. package/dist/lake-storage/index.js.map +1 -1
  281. package/dist/maintenance/index.js +9 -8
  282. package/dist/maintenance/index.js.map +2 -2
  283. package/dist/materializer/index.js +26 -24
  284. package/dist/materializer/index.js.map +1 -1
  285. package/dist/models/audio/runtime.d.ts +3 -1
  286. package/dist/models/audio/runtime.d.ts.map +1 -1
  287. package/dist/models/audio/speech.d.ts +2 -2
  288. package/dist/models/audio/speech.d.ts.map +1 -1
  289. package/dist/models/audio/types.d.ts +23 -3
  290. package/dist/models/audio/types.d.ts.map +1 -1
  291. package/dist/models/calls.d.ts +7 -0
  292. package/dist/models/calls.d.ts.map +1 -1
  293. package/dist/models/catalog.d.ts +5 -0
  294. package/dist/models/catalog.d.ts.map +1 -1
  295. package/dist/models/definitions.d.ts +3 -2
  296. package/dist/models/definitions.d.ts.map +1 -1
  297. package/dist/models/errors.d.ts +5 -3
  298. package/dist/models/errors.d.ts.map +1 -1
  299. package/dist/models/events.d.ts +2 -0
  300. package/dist/models/events.d.ts.map +1 -1
  301. package/dist/models/execution/index.d.ts +1 -0
  302. package/dist/models/execution/index.d.ts.map +1 -1
  303. package/dist/models/execution/index.js +33 -28
  304. package/dist/models/execution/index.js.map +1 -1
  305. package/dist/models/execution/model-call-limits.d.ts.map +1 -1
  306. package/dist/models/execution/model-call-recorder.d.ts +8 -0
  307. package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
  308. package/dist/models/execution/session.d.ts +12 -0
  309. package/dist/models/execution/session.d.ts.map +1 -1
  310. package/dist/models/execution/usage.d.ts.map +1 -1
  311. package/dist/models/execution.d.ts +1 -1
  312. package/dist/models/execution.d.ts.map +1 -1
  313. package/dist/models/generation-types.d.ts +2 -0
  314. package/dist/models/generation-types.d.ts.map +1 -1
  315. package/dist/models/index.d.ts +4 -2
  316. package/dist/models/index.d.ts.map +1 -1
  317. package/dist/models/index.js +2 -2
  318. package/dist/models/input-file.d.ts.map +1 -1
  319. package/dist/models/pricing.d.ts +2 -1
  320. package/dist/models/pricing.d.ts.map +1 -1
  321. package/dist/models/rate-card.d.ts +6 -0
  322. package/dist/models/rate-card.d.ts.map +1 -1
  323. package/dist/models/tools.d.ts +5 -0
  324. package/dist/models/tools.d.ts.map +1 -1
  325. package/dist/models/video/catalog.d.ts +13 -0
  326. package/dist/models/video/catalog.d.ts.map +1 -0
  327. package/dist/models/video/check.d.ts +76 -0
  328. package/dist/models/video/check.d.ts.map +1 -0
  329. package/dist/models/video/runtime.d.ts +21 -0
  330. package/dist/models/video/runtime.d.ts.map +1 -0
  331. package/dist/models/video/types.d.ts +188 -0
  332. package/dist/models/video/types.d.ts.map +1 -0
  333. package/dist/objects/execution.d.ts.map +1 -1
  334. package/dist/objects/index.js +52 -49
  335. package/dist/objects/index.js.map +1 -1
  336. package/dist/objects/query/index.js +25 -23
  337. package/dist/objects/query/index.js.map +1 -1
  338. package/dist/objects/sdk/object-set.d.ts.map +1 -1
  339. package/dist/ontology/index.js +4 -4
  340. package/dist/ontology/internal.js +4 -4
  341. package/dist/pipelines/index.js +28 -26
  342. package/dist/pipelines/index.js.map +1 -1
  343. package/dist/projections/internal.js +26 -24
  344. package/dist/projections/internal.js.map +1 -1
  345. package/dist/queues/index.d.ts +1 -1
  346. package/dist/queues/index.d.ts.map +1 -1
  347. package/dist/queues/types.d.ts +103 -6
  348. package/dist/queues/types.d.ts.map +1 -1
  349. package/dist/runtime/host.d.ts.map +1 -1
  350. package/dist/runtime/internal.d.ts +3 -1
  351. package/dist/runtime/internal.d.ts.map +1 -1
  352. package/dist/runtime/internal.js +49 -43
  353. package/dist/runtime/internal.js.map +2 -2
  354. package/dist/runtime/sixb.d.ts.map +1 -1
  355. package/dist/sandboxes/index.js +6 -6
  356. package/dist/security/public.d.ts +6 -4
  357. package/dist/security/public.d.ts.map +1 -1
  358. package/dist/security/public.js +5 -3
  359. package/dist/security/public.js.map +1 -1
  360. package/dist/shares/internal.js +25 -23
  361. package/dist/shares/internal.js.map +2 -2
  362. package/dist/storage/agents/in-memory.d.ts +2 -1
  363. package/dist/storage/agents/in-memory.d.ts.map +1 -1
  364. package/dist/storage/agents/index.d.ts +1 -1
  365. package/dist/storage/agents/index.d.ts.map +1 -1
  366. package/dist/storage/agents/provider.js +4 -4
  367. package/dist/storage/agents/types.d.ts +13 -0
  368. package/dist/storage/agents/types.d.ts.map +1 -1
  369. package/dist/storage/ai-cost/analytics.d.ts +1 -0
  370. package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
  371. package/dist/storage/ai-cost/groups.d.ts +2 -0
  372. package/dist/storage/ai-cost/groups.d.ts.map +1 -1
  373. package/dist/storage/ai-cost/provider.js +5 -5
  374. package/dist/storage/ai-cost/types.d.ts +2 -1
  375. package/dist/storage/ai-cost/types.d.ts.map +1 -1
  376. package/dist/storage/ai-cost/validation.d.ts.map +1 -1
  377. package/dist/storage/ai-limits/enforcement.js +3 -3
  378. package/dist/storage/ai-limits/provider.js +2 -2
  379. package/dist/storage/ai-usage/in-memory.d.ts +8 -1
  380. package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
  381. package/dist/storage/ai-usage/index.d.ts +2 -2
  382. package/dist/storage/ai-usage/index.d.ts.map +1 -1
  383. package/dist/storage/ai-usage/record.d.ts +11 -1
  384. package/dist/storage/ai-usage/record.d.ts.map +1 -1
  385. package/dist/storage/ai-usage/types.d.ts +80 -1
  386. package/dist/storage/ai-usage/types.d.ts.map +1 -1
  387. package/dist/storage/ai-usage/usage.d.ts +1 -1
  388. package/dist/storage/ai-usage/usage.d.ts.map +1 -1
  389. package/dist/storage/artifacts/in-memory.d.ts +25 -2
  390. package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
  391. package/dist/storage/artifacts/index.d.ts +1 -1
  392. package/dist/storage/artifacts/index.d.ts.map +1 -1
  393. package/dist/storage/artifacts/record.d.ts +12 -1
  394. package/dist/storage/artifacts/record.d.ts.map +1 -1
  395. package/dist/storage/artifacts/types.d.ts +198 -6
  396. package/dist/storage/artifacts/types.d.ts.map +1 -1
  397. package/dist/storage/executions/provider.js +3 -2
  398. package/dist/storage/executions/provider.js.map +1 -1
  399. package/dist/storage/file-upload-sessions/provider.js +10 -9
  400. package/dist/storage/file-upload-sessions/provider.js.map +1 -1
  401. package/dist/storage/in-memory/index.d.ts.map +1 -1
  402. package/dist/storage/index.d.ts +4 -4
  403. package/dist/storage/index.d.ts.map +1 -1
  404. package/dist/storage/index.js +24 -22
  405. package/dist/storage/index.js.map +1 -1
  406. package/dist/storage/internal.d.ts +2 -2
  407. package/dist/storage/internal.d.ts.map +1 -1
  408. package/dist/storage/internal.js +34 -14
  409. package/dist/storage/internal.js.map +2 -2
  410. package/dist/storage/workflow-runs/provider.js +10 -9
  411. package/dist/storage/workflow-runs/provider.js.map +1 -1
  412. package/dist/syncs/index.js +29 -27
  413. package/dist/syncs/index.js.map +1 -1
  414. package/dist/testing/agent-storage-contract.d.ts.map +1 -1
  415. package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
  416. package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
  417. package/dist/testing/artifact-storage-contract.d.ts +3 -0
  418. package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
  419. package/dist/testing/execution-storage-contract.d.ts.map +1 -1
  420. package/dist/testing/index.js +619 -72
  421. package/dist/testing/index.js.map +9 -9
  422. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  423. package/dist/testing/queues-contract.d.ts.map +1 -1
  424. package/dist/webhooks/internal.js +26 -24
  425. package/dist/webhooks/internal.js.map +2 -2
  426. package/dist/workers/index.js +5 -5
  427. package/dist/workers/index.js.map +1 -1
  428. package/dist/workflows/index.js +58 -55
  429. package/dist/workflows/index.js.map +1 -1
  430. package/package.json +3 -1
  431. package/src/actions/request.ts +2 -0
  432. package/src/actions/run/context.ts +1 -0
  433. package/src/actions/run/execute.ts +5 -1
  434. package/src/actions/run/executor.ts +4 -0
  435. package/src/actions/run/normalize.ts +4 -0
  436. package/src/actions/run/types.ts +6 -0
  437. package/src/actions/types/context.ts +7 -0
  438. package/src/agents/README.md +3 -1
  439. package/src/agents/context/entries.ts +63 -9
  440. package/src/agents/context-model.ts +9 -0
  441. package/src/agents/context-resolution.ts +7 -0
  442. package/src/agents/execution.ts +39 -0
  443. package/src/agents/model-call-retry.ts +69 -0
  444. package/src/agents/model-loop.ts +86 -12
  445. package/src/agents/run-artifacts.ts +10 -5
  446. package/src/agents/run-plan.ts +2 -1
  447. package/src/agents/run-session-http.ts +1 -0
  448. package/src/agents/run-session-serve.ts +23 -2
  449. package/src/agents/run-session-wire.ts +45 -0
  450. package/src/agents/thread-access.ts +34 -1
  451. package/src/agents/tool-files.ts +23 -7
  452. package/src/artifacts/caller.ts +42 -0
  453. package/src/artifacts/comment-place.ts +51 -0
  454. package/src/artifacts/comment-text.ts +50 -7
  455. package/src/artifacts/comments.ts +132 -34
  456. package/src/artifacts/errors.ts +1 -0
  457. package/src/artifacts/execution.ts +249 -5
  458. package/src/artifacts/frames/assets.ts +93 -15
  459. package/src/artifacts/frames/entries.ts +7 -4
  460. package/src/artifacts/frames/generated/hyperframes-notices.txt +290 -0
  461. package/src/artifacts/frames/generated/hyperframes.txt +1145 -0
  462. package/src/artifacts/frames/generated.d.ts +5 -0
  463. package/src/artifacts/frames/hyperframes.ts +14 -0
  464. package/src/artifacts/frames/index.ts +5 -0
  465. package/src/artifacts/frames/kit.ts +7 -3
  466. package/src/artifacts/frames/protocol.ts +56 -0
  467. package/src/artifacts/frames/video-runtime.ts +165 -0
  468. package/src/artifacts/html.ts +13 -0
  469. package/src/artifacts/index.ts +7 -0
  470. package/src/artifacts/kinds.ts +9 -1
  471. package/src/artifacts/limits.ts +43 -0
  472. package/src/artifacts/live/document.ts +27 -3
  473. package/src/artifacts/live/index.ts +58 -2
  474. package/src/artifacts/live/presence.ts +17 -5
  475. package/src/artifacts/live/protocol.ts +4 -2
  476. package/src/artifacts/live/server.ts +1 -1
  477. package/src/artifacts/live/state.ts +3 -3
  478. package/src/artifacts/media/README.md +75 -0
  479. package/src/artifacts/media/media.ts +316 -0
  480. package/src/artifacts/media/transcriber.ts +84 -0
  481. package/src/artifacts/outline.ts +28 -0
  482. package/src/artifacts/publish/files.ts +19 -6
  483. package/src/artifacts/publish/index.ts +49 -2
  484. package/src/artifacts/publish/pdf.ts +3 -1
  485. package/src/artifacts/publish/previews.ts +22 -8
  486. package/src/artifacts/publish/publish.ts +4 -1
  487. package/src/artifacts/publish/validate/html.ts +23 -18
  488. package/src/artifacts/publish/validate/video.ts +309 -0
  489. package/src/artifacts/publish/video.ts +235 -0
  490. package/src/artifacts/resolve.ts +45 -0
  491. package/src/artifacts/video/README.md +402 -0
  492. package/src/artifacts/video/composition.ts +898 -0
  493. package/src/artifacts/video/edit.ts +3967 -0
  494. package/src/artifacts/video/export.ts +352 -0
  495. package/src/artifacts/video/looks.ts +694 -0
  496. package/src/artifacts/video/project.ts +198 -0
  497. package/src/artifacts/video/stills.ts +168 -0
  498. package/src/artifacts/video/timeline.ts +658 -0
  499. package/src/blob-storage/browser.ts +1 -1
  500. package/src/blob-storage/constants.ts +9 -3
  501. package/src/blob-storage/download-urls.ts +5 -3
  502. package/src/blob-storage/index.ts +1 -0
  503. package/src/blob-storage/internal.ts +13 -2
  504. package/src/blob-storage/media-type.ts +149 -8
  505. package/src/errors/catalog.ts +2 -1
  506. package/src/execution/authorization.ts +2 -2
  507. package/src/execution/kernel-operation.ts +14 -0
  508. package/src/execution/types.ts +2 -0
  509. package/src/http/api-routes.ts +117 -0
  510. package/src/index.ts +18 -1
  511. package/src/lake-storage/definition-updates.ts +3 -9
  512. package/src/models/audio/runtime.ts +48 -3
  513. package/src/models/audio/speech.ts +2 -2
  514. package/src/models/audio/types.ts +24 -3
  515. package/src/models/calls.ts +35 -18
  516. package/src/models/catalog.ts +9 -2
  517. package/src/models/definitions.ts +4 -2
  518. package/src/models/errors.ts +5 -3
  519. package/src/models/events.ts +2 -0
  520. package/src/models/execution/README.md +68 -2
  521. package/src/models/execution/index.ts +1 -0
  522. package/src/models/execution/model-call-limits.ts +11 -5
  523. package/src/models/execution/model-call-recorder.ts +14 -0
  524. package/src/models/execution/session.ts +52 -23
  525. package/src/models/execution/usage.ts +1 -0
  526. package/src/models/execution.ts +13 -2
  527. package/src/models/generation-types.ts +2 -0
  528. package/src/models/index.ts +20 -1
  529. package/src/models/input-file.ts +7 -2
  530. package/src/models/pricing.ts +19 -1
  531. package/src/models/rate-card.ts +15 -3
  532. package/src/models/tools.ts +5 -0
  533. package/src/models/video/catalog.ts +101 -0
  534. package/src/models/video/check.ts +441 -0
  535. package/src/models/video/runtime.ts +550 -0
  536. package/src/models/video/types.ts +194 -0
  537. package/src/objects/execution.ts +2 -0
  538. package/src/objects/sdk/object-set.ts +2 -0
  539. package/src/queues/index.ts +5 -0
  540. package/src/queues/types.ts +126 -5
  541. package/src/runtime/host.ts +3 -0
  542. package/src/runtime/internal.ts +3 -1
  543. package/src/runtime/sixb.ts +12 -4
  544. package/src/sandboxes/README.md +3 -2
  545. package/src/security/public.ts +6 -4
  546. package/src/storage/agents/in-memory.ts +39 -0
  547. package/src/storage/agents/index.ts +1 -0
  548. package/src/storage/agents/types.ts +14 -0
  549. package/src/storage/ai-cost/analytics.ts +2 -0
  550. package/src/storage/ai-cost/codec.ts +1 -0
  551. package/src/storage/ai-cost/groups.ts +7 -0
  552. package/src/storage/ai-cost/types.ts +2 -0
  553. package/src/storage/ai-cost/validation.ts +2 -0
  554. package/src/storage/ai-usage/in-memory.ts +93 -0
  555. package/src/storage/ai-usage/index.ts +10 -0
  556. package/src/storage/ai-usage/record.ts +106 -0
  557. package/src/storage/ai-usage/types.ts +102 -1
  558. package/src/storage/ai-usage/usage.ts +2 -0
  559. package/src/storage/artifacts/in-memory.ts +108 -11
  560. package/src/storage/artifacts/index.ts +14 -0
  561. package/src/storage/artifacts/record.ts +203 -1
  562. package/src/storage/artifacts/types.ts +199 -6
  563. package/src/storage/executions/validation.ts +2 -2
  564. package/src/storage/in-memory/index.ts +1 -1
  565. package/src/storage/index.ts +22 -1
  566. package/src/storage/internal.ts +9 -0
  567. package/src/testing/agent-storage-contract.ts +108 -0
  568. package/src/testing/ai-cost-storage-contract.ts +1 -0
  569. package/src/testing/ai-usage-storage-contract.ts +145 -1
  570. package/src/testing/artifact-storage-contract.ts +320 -0
  571. package/src/testing/execution-storage-contract.ts +10 -2
  572. package/src/testing/lake-storage-contract.ts +27 -0
  573. package/src/testing/queues-contract.ts +71 -0
  574. package/dist/chunk-3723kgba.js +0 -29
  575. package/dist/chunk-3723kgba.js.map +0 -10
  576. package/dist/chunk-3qtk0070.js.map +0 -14
  577. package/dist/chunk-8ncg20rd.js.map +0 -10
  578. package/dist/chunk-9vsc919v.js.map +0 -10
  579. package/dist/chunk-az95tsh3.js.map +0 -11
  580. package/dist/chunk-c29729me.js.map +0 -12
  581. package/dist/chunk-d7vyc7k6.js.map +0 -10
  582. package/dist/chunk-de5sfbc3.js +0 -3
  583. package/dist/chunk-gfdh9kqa.js.map +0 -11
  584. package/dist/chunk-hvq8xs66.js.map +0 -34
  585. package/dist/chunk-k29rdc3h.js.map +0 -10
  586. package/dist/chunk-mbwsgjn7.js.map +0 -11
  587. package/dist/chunk-phs5fbff.js.map +0 -19
  588. package/dist/chunk-qttqe1ah.js.map +0 -24
  589. package/dist/chunk-sgx82nnt.js.map +0 -10
  590. package/dist/chunk-vs2s3p8n.js +0 -2274
  591. package/dist/chunk-vs2s3p8n.js.map +0 -20
  592. package/dist/chunk-wkv3h3q7.js.map +0 -12
  593. package/dist/chunk-wzcjhv54.js.map +0 -11
  594. package/dist/chunk-xtztwpkh.js.map +0 -12
  595. /package/dist/{chunk-7mhbs9yy.js.map → chunk-1z8ccj53.js.map} +0 -0
  596. /package/dist/{chunk-dmnd9ea6.js.map → chunk-30a0ftnm.js.map} +0 -0
  597. /package/dist/{chunk-qbd282aa.js.map → chunk-39q9ybav.js.map} +0 -0
  598. /package/dist/{chunk-fdk0ks9p.js.map → chunk-3x902cja.js.map} +0 -0
  599. /package/dist/{chunk-c4nrycdy.js.map → chunk-4q4a5a96.js.map} +0 -0
  600. /package/dist/{chunk-cpy282b8.js.map → chunk-4w8qzy9w.js.map} +0 -0
  601. /package/dist/{chunk-xavet0qs.js.map → chunk-6whr25gw.js.map} +0 -0
  602. /package/dist/{chunk-ygvay56w.js.map → chunk-896te58g.js.map} +0 -0
  603. /package/dist/{chunk-pfdq1ga6.js.map → chunk-8eqqqc1h.js.map} +0 -0
  604. /package/dist/{chunk-jka26v8c.js.map → chunk-8x1bsp68.js.map} +0 -0
  605. /package/dist/{chunk-6md802cc.js.map → chunk-9az7kjv4.js.map} +0 -0
  606. /package/dist/{chunk-95ps0k5q.js.map → chunk-9e5t53z0.js.map} +0 -0
  607. /package/dist/{chunk-js9e6487.js.map → chunk-9p7kyeqz.js.map} +0 -0
  608. /package/dist/{chunk-brybqw5k.js.map → chunk-bkxm2dzx.js.map} +0 -0
  609. /package/dist/{chunk-ppxf7gw2.js.map → chunk-d7t9jnym.js.map} +0 -0
  610. /package/dist/{chunk-cg7cygfj.js.map → chunk-fdmvaz7x.js.map} +0 -0
  611. /package/dist/{chunk-191jz8a6.js.map → chunk-ff0qdk7z.js.map} +0 -0
  612. /package/dist/{chunk-wx7smkn2.js.map → chunk-fq8drkp0.js.map} +0 -0
  613. /package/dist/{chunk-v8a1qjzp.js.map → chunk-hpswfrjj.js.map} +0 -0
  614. /package/dist/{chunk-bz5bnjjt.js.map → chunk-jjte0h4p.js.map} +0 -0
  615. /package/dist/{chunk-xrmbhap8.js.map → chunk-mwg0nwkb.js.map} +0 -0
  616. /package/dist/{chunk-a3faa34j.js.map → chunk-nfjt8k8j.js.map} +0 -0
  617. /package/dist/{chunk-394zjzjs.js.map → chunk-nhgqz3g3.js.map} +0 -0
  618. /package/dist/{chunk-92wrka15.js.map → chunk-q150fnj9.js.map} +0 -0
  619. /package/dist/{chunk-w3t94hm6.js.map → chunk-qk3zq25v.js.map} +0 -0
  620. /package/dist/{chunk-5qqmndhm.js.map → chunk-szzhrn3e.js.map} +0 -0
  621. /package/dist/{chunk-n1hbwc6y.js.map → chunk-t6pfch4e.js.map} +0 -0
  622. /package/dist/{chunk-brhp9d97.js.map → chunk-vmqjndb3.js.map} +0 -0
  623. /package/dist/{chunk-t58sktr5.js.map → chunk-wrb1x1ss.js.map} +0 -0
  624. /package/dist/{chunk-5sswe5ej.js.map → chunk-wsv23wvr.js.map} +0 -0
  625. /package/dist/{chunk-04r2fdsd.js.map → chunk-x0hqc54n.js.map} +0 -0
  626. /package/dist/{chunk-3neam1y5.js.map → chunk-y3qb965a.js.map} +0 -0
  627. /package/dist/{chunk-5pz3htbe.js.map → chunk-y57eawng.js.map} +0 -0
@@ -1,2274 +0,0 @@
1
- // @bun
2
- import {
3
- isValidFileRef
4
- } from "./chunk-wkv3h3q7.js";
5
- import {
6
- ARTIFACT_LIMITS2
7
- } from "./chunk-9vsc919v.js";
8
- import {
9
- statFileRef2
10
- } from "./chunk-a3faa34j.js";
11
- import {
12
- isArtifactAddress2,
13
- parseArtifactAddress2
14
- } from "./chunk-bz5bnjjt.js";
15
-
16
- // src/artifacts/errors.ts
17
- class ArtifactRequestError2 extends Error {
18
- code;
19
- latest;
20
- name = "ArtifactRequestError";
21
- constructor(code, message, latest) {
22
- super(message);
23
- this.code = code;
24
- this.latest = latest;
25
- }
26
- }
27
-
28
- // src/artifacts/document-fill.ts
29
- import {
30
- defaultTreeAdapter as adapter,
31
- parse,
32
- serialize
33
- } from "parse5";
34
-
35
- // src/artifacts/frames/document-data.ts
36
- function documentData() {
37
- const FIELD = "data-sixb-field";
38
- const EACH = "data-sixb-each";
39
- const FORMAT = "data-format";
40
- const CURRENCY = "data-currency";
41
- const CURRENCY_FIELD = "data-currency-field";
42
- const LOCKED = "data-sixb-locked";
43
- const EMPTY = "data-sixb-empty";
44
- const QUERY = /^query:([a-z0-9][a-z0-9-]{0,63})(?:\.(.*))?$/;
45
- const STEP = /^([A-Za-z_][\w-]*)(?:\[([^\]]+)\])?$/;
46
- const UNREAD = Symbol("unread");
47
- const HIDDEN = Symbol("hidden");
48
- const parse = (path) => {
49
- const query = QUERY.exec(path.trim());
50
- const rest = query ? query[2] ?? "" : path.trim();
51
- const steps = [];
52
- for (const part of rest === "" ? [] : rest.split(".")) {
53
- const step = STEP.exec(part);
54
- if (!step?.[1])
55
- return null;
56
- steps.push(step[2] === undefined ? { key: step[1] } : { key: step[1], id: step[2] });
57
- }
58
- if (!query && steps.length === 0)
59
- return null;
60
- return query?.[1] ? { query: query[1], steps } : { steps };
61
- };
62
- const isRow = (value) => typeof value === "object" && value !== null && ("properties" in value) && typeof value.properties === "object";
63
- const step = (value, next) => {
64
- if (Array.isArray(value))
65
- return value.length > 0 ? step(value[0], next) : undefined;
66
- let found;
67
- if (isRow(value)) {
68
- if (Object.hasOwn(value.properties, next.key))
69
- found = value.properties[next.key];
70
- else if (value.redactions && Object.hasOwn(value.redactions, next.key))
71
- return HIDDEN;
72
- else
73
- found = value.links?.[next.key];
74
- } else if (typeof value === "object" && value !== null && !Array.isArray(value)) {
75
- found = value[next.key];
76
- }
77
- if (next.id === undefined)
78
- return found;
79
- if (!Array.isArray(found))
80
- return;
81
- return found.find((item) => isRow(item) ? item.primaryId === next.id || item.properties.id === next.id : typeof item === "object" && item !== null && item.id === next.id);
82
- };
83
- const read = (path, scope) => {
84
- let value;
85
- if (path.query !== undefined) {
86
- const result = scope.sources.queries[path.query];
87
- if (!result)
88
- return UNREAD;
89
- const [first, second] = path.steps;
90
- if (first?.key === "total" && path.steps.length === 1)
91
- return result.total;
92
- if (first?.key === "facets" && second && path.steps.length === 2) {
93
- return result.facets?.find((facet) => facet.propertyId === second.key)?.buckets;
94
- }
95
- if (path.steps.length === 0)
96
- return result.objects ?? [];
97
- value = result.objects;
98
- } else if (scope.item !== undefined) {
99
- value = scope.item;
100
- } else {
101
- if (!scope.sources.holder)
102
- return UNREAD;
103
- value = scope.sources.holder;
104
- }
105
- for (const next of path.steps) {
106
- if (value === HIDDEN)
107
- return HIDDEN;
108
- value = step(value, next);
109
- }
110
- return value;
111
- };
112
- const format = (value, as, currency, lang) => {
113
- if (value === null || value === undefined)
114
- return "";
115
- const number = typeof value === "number" ? value : typeof value === "string" && value.trim() !== "" ? Number(value) : Number.NaN;
116
- try {
117
- if (as === "money" && Number.isFinite(number)) {
118
- const cents = Number.isInteger(number) ? { minimumFractionDigits: 0 } : {};
119
- return currency ? new Intl.NumberFormat(lang, { style: "currency", currency, ...cents }).format(number) : new Intl.NumberFormat(lang, {
120
- minimumFractionDigits: 2,
121
- maximumFractionDigits: 2,
122
- ...cents
123
- }).format(number);
124
- }
125
- if (as === "number" && Number.isFinite(number)) {
126
- return new Intl.NumberFormat(lang).format(number);
127
- }
128
- if (as === "percent" && Number.isFinite(number)) {
129
- return new Intl.NumberFormat(lang, { style: "percent", maximumFractionDigits: 2 }).format(number);
130
- }
131
- if (as === "date") {
132
- const date = new Date(String(value));
133
- if (!Number.isNaN(date.getTime())) {
134
- return new Intl.DateTimeFormat(lang, { dateStyle: "long", timeZone: "UTC" }).format(date);
135
- }
136
- }
137
- } catch {}
138
- if (Array.isArray(value)) {
139
- return value.filter((each) => typeof each !== "object" || each === null).map(String).join(", ");
140
- }
141
- return typeof value === "object" ? "" : String(value);
142
- };
143
- const fill = (root, tree, options) => {
144
- const lang = options.lang || "en";
145
- const visit = (node, scope) => {
146
- const children = tree.children(node);
147
- for (let index = 0;index < children.length; index += 1) {
148
- const child = children[index];
149
- const each = tree.attribute(child, EACH);
150
- if (each !== null) {
151
- const written = [child];
152
- while (index + 1 < children.length) {
153
- const next = children[index + 1];
154
- if (tree.attribute(next, EACH) !== each)
155
- break;
156
- written.push(next);
157
- index += 1;
158
- }
159
- const path = parse(each);
160
- const items = path ? read(path, scope) : UNREAD;
161
- if (items === UNREAD || items === HIDDEN) {
162
- if (options.plain)
163
- for (const copy of written)
164
- unmark(copy);
165
- continue;
166
- }
167
- const list = Array.isArray(items) ? items : items == null ? [] : [items];
168
- const copies = list.map((item) => {
169
- const copy = tree.clone(child);
170
- if (!options.keep)
171
- tree.removeAttribute(copy, EACH);
172
- tree.removeAttribute(copy, EMPTY);
173
- visit(copy, { sources: scope.sources, item });
174
- return copy;
175
- });
176
- for (const copy of written.slice(1))
177
- tree.replace(copy, []);
178
- if (options.keep && copies.length === 0) {
179
- tree.setAttribute(child, EMPTY, "");
180
- } else {
181
- tree.replace(child, copies);
182
- }
183
- continue;
184
- }
185
- const field = tree.attribute(child, FIELD);
186
- if (field === null) {
187
- visit(child, scope);
188
- continue;
189
- }
190
- const path = parse(field);
191
- const value = path ? read(path, scope) : UNREAD;
192
- const currencyField = tree.attribute(child, CURRENCY_FIELD);
193
- const currencyPath = currencyField === null ? null : parse(currencyField);
194
- const currency = currencyPath ? read(currencyPath, scope) : tree.attribute(child, CURRENCY);
195
- if (options.plain)
196
- unmark(child);
197
- if (value === UNREAD)
198
- continue;
199
- if (value === HIDDEN) {
200
- tree.setText(child, "\u2022\u2022\u2022");
201
- if (!options.plain && !options.keep)
202
- tree.setAttribute(child, LOCKED, "");
203
- continue;
204
- }
205
- tree.setText(child, format(value, tree.attribute(child, FORMAT), typeof currency === "string" && currency !== "" ? currency : null, lang));
206
- }
207
- };
208
- const unmark = (node) => {
209
- if (tree.attribute(node, EMPTY) !== null)
210
- return tree.replace(node, []);
211
- for (const name of [FIELD, EACH, CURRENCY_FIELD])
212
- tree.removeAttribute(node, name);
213
- for (const child of tree.children(node))
214
- unmark(child);
215
- };
216
- visit(root, { sources: options.sources });
217
- };
218
- const marks = (root, tree) => {
219
- const found = [];
220
- const visit = (node, within) => {
221
- for (const child of tree.children(node)) {
222
- const each = tree.attribute(child, EACH);
223
- const field = tree.attribute(child, FIELD);
224
- if (each !== null)
225
- found.push({ kind: "each", path: each, within });
226
- if (field !== null)
227
- found.push({ kind: "field", path: field, within });
228
- const currency = tree.attribute(child, CURRENCY_FIELD);
229
- if (currency !== null)
230
- found.push({ kind: "field", path: currency, within });
231
- visit(child, each === null ? within : [...within, each]);
232
- }
233
- };
234
- visit(root, []);
235
- return found;
236
- };
237
- const reads = (found) => {
238
- const queries = new Set;
239
- let holder = false;
240
- for (const mark of found) {
241
- const named = [...mark.within, mark.path].map(parse).find((path) => path?.query);
242
- if (named?.query)
243
- queries.add(named.query);
244
- else
245
- holder = true;
246
- }
247
- return { holder, queries: [...queries] };
248
- };
249
- return { parse, fill, marks, reads };
250
- }
251
-
252
- // src/artifacts/document-fill.ts
253
- var isElement = (node) => ("tagName" in node);
254
- var tree = {
255
- children: (node) => node.childNodes.filter(isElement),
256
- attribute: (node, name) => node.attrs.find((each) => each.name === name)?.value ?? null,
257
- setAttribute(node, name, value) {
258
- const found = node.attrs.find((each) => each.name === name);
259
- if (found)
260
- found.value = value;
261
- else
262
- node.attrs.push({ name, value });
263
- },
264
- removeAttribute(node, name) {
265
- node.attrs = node.attrs.filter((each) => each.name !== name);
266
- },
267
- setText(node, text) {
268
- for (const child of [...node.childNodes])
269
- adapter.detachNode(child);
270
- adapter.insertText(node, text);
271
- },
272
- clone: (node) => copy(node),
273
- replace(node, nodes) {
274
- const parent = node.parentNode;
275
- if (!parent)
276
- return;
277
- for (const each of nodes)
278
- adapter.insertBefore(parent, each, node);
279
- adapter.detachNode(node);
280
- }
281
- };
282
- function copy(node) {
283
- if (!isElement(node))
284
- return { ...node, parentNode: null };
285
- const element = adapter.createElement(node.tagName, node.namespaceURI, node.attrs.map((each) => ({ ...each })));
286
- for (const child of node.childNodes)
287
- adapter.appendChild(element, copy(child));
288
- return element;
289
- }
290
- function bodyOf(html) {
291
- const document2 = parse(html);
292
- const root = document2.childNodes.find(isElement);
293
- const body = root?.childNodes.find((child) => isElement(child) && child.tagName === "body");
294
- return { document: document2, root, body };
295
- }
296
- function documentMarks(html) {
297
- const { body } = bodyOf(html);
298
- return body ? documentData().marks(body, tree) : [];
299
- }
300
- function fillDocumentHtml(html, sources, options = {}) {
301
- const { document: document2, root, body } = bodyOf(html);
302
- if (!body || documentData().marks(body, tree).length === 0)
303
- return html;
304
- const lang = root ? tree.attribute(root, "lang") ?? undefined : undefined;
305
- documentData().fill(body, tree, {
306
- sources,
307
- ...lang ? { lang } : {},
308
- ...options.plain ? { plain: true } : {},
309
- ...options.keep ? { keep: true } : {}
310
- });
311
- return serialize(document2);
312
- }
313
- function frozenDocumentHtml2(html) {
314
- return fillDocumentHtml(html, { queries: {} }, { plain: true });
315
- }
316
-
317
- // src/artifacts/publish/files.ts
318
- async function checkArtifactFiles(blobStorage, files) {
319
- if (files.length === 0)
320
- throw invalidArtifact("A version needs at least one file.");
321
- if (files.length > ARTIFACT_LIMITS2.maxFiles) {
322
- throw invalidArtifact(`A version holds at most ${ARTIFACT_LIMITS2.maxFiles} files; this one has ${files.length}.`);
323
- }
324
- const paths = new Set;
325
- let totalBytes = 0;
326
- for (const entry of files) {
327
- if (!isArtifactPath(entry.path)) {
328
- throw invalidArtifact(`'${entry.path}' is not a usable file path: use a relative path with / separators, no . or .. segments, and at most ${ARTIFACT_LIMITS2.maxPathLength} characters.`);
329
- }
330
- if (paths.has(entry.path))
331
- throw invalidArtifact(`'${entry.path}' appears twice.`);
332
- paths.add(entry.path);
333
- if (!isValidFileRef(entry.file)) {
334
- throw invalidArtifact(`'${entry.path}' does not have a valid file reference.`);
335
- }
336
- if (entry.file.sizeBytes > ARTIFACT_LIMITS2.maxFileBytes) {
337
- throw invalidArtifact(`'${entry.path}' is ${entry.file.sizeBytes} bytes; a file may be at most ${ARTIFACT_LIMITS2.maxFileBytes}.`);
338
- }
339
- totalBytes += entry.file.sizeBytes;
340
- }
341
- if (totalBytes > ARTIFACT_LIMITS2.maxVersionBytes) {
342
- throw invalidArtifact(`The files total ${totalBytes} bytes; a version may hold at most ${ARTIFACT_LIMITS2.maxVersionBytes}.`);
343
- }
344
- const stored = await Promise.all(files.map((entry) => statFileRef2(blobStorage, entry.file)));
345
- const missing = files.find((_, index) => !stored[index]);
346
- if (missing)
347
- throw invalidArtifact(`'${missing.path}' refers to a file that is not stored.`);
348
- }
349
- async function readArtifactText(blobStorage, file, maxBytes) {
350
- if (file.file.sizeBytes > maxBytes) {
351
- throw invalidArtifact(`'${file.path}' is ${file.file.sizeBytes} bytes; it may be at most ${maxBytes}.`);
352
- }
353
- const text = await new Response(await blobStorage.open(file.file.blobId)).text();
354
- return text.charCodeAt(0) === 65279 ? text.slice(1) : text;
355
- }
356
- function isArtifactPath(path) {
357
- return typeof path === "string" && path.length > 0 && path.length <= ARTIFACT_LIMITS2.maxPathLength && !path.startsWith("/") && !path.includes("\\") && !/[\u0000-\u001f\u007f]/.test(path) && path.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
358
- }
359
- function invalidArtifact(message) {
360
- return new ArtifactRequestError2("invalid_artifact", `[Sixb] ${message}`);
361
- }
362
-
363
- // src/artifacts/html.ts
364
- var NAMED_ENTITIES = {
365
- amp: "&",
366
- lt: "<",
367
- gt: ">",
368
- quot: '"',
369
- apos: "'",
370
- nbsp: String.fromCharCode(160)
371
- };
372
- function decodeHtmlEntities(value) {
373
- return value.replace(/&(#x[\da-f]+|#\d+|[a-z]+);/gi, (match, entity) => {
374
- if (entity[0] !== "#")
375
- return NAMED_ENTITIES[entity.toLowerCase()] ?? match;
376
- const codePoint = entity[1]?.toLowerCase() === "x" ? Number.parseInt(entity.slice(2), 16) : Number(entity.slice(1));
377
- return Number.isInteger(codePoint) && codePoint >= 0 && codePoint <= 1114111 ? String.fromCodePoint(codePoint) : match;
378
- });
379
- }
380
-
381
- // src/artifacts/publish/validate/html.ts
382
- var HTML_ENTRY2 = "index.html";
383
- var FRAME_ASSET_PREFIX = "__sixb/";
384
- function refuseFrameAssetPaths(files, what) {
385
- const reserved = files.find((file) => file.path.startsWith(FRAME_ASSET_PREFIX));
386
- if (reserved) {
387
- throw invalidArtifact(`'${reserved.path}' is under ${FRAME_ASSET_PREFIX}, where Sixb serves ${what}'s kit and runtime: move it.`);
388
- }
389
- }
390
- function readHtmlReferences(rewriter, at, file = HTML_ENTRY2) {
391
- const references = [];
392
- let refused;
393
- rewriter.on("a[href]", {
394
- element(element) {
395
- const href = decodeHtmlEntities(element.getAttribute("href") ?? "");
396
- if (isArtifactAddress2(href)) {
397
- references.push({ address: href.trim(), as: "link", at: at() });
398
- }
399
- }
400
- }).on("img[src]", {
401
- element(element) {
402
- const source = decodeHtmlEntities(element.getAttribute("src") ?? "").trim();
403
- if (!isArtifactAddress2(source))
404
- return;
405
- if (!parseArtifactAddress2(source)?.path) {
406
- refused ??= `An <img> shows a file from another artifact, and '${source}' names none: show a chart, a range, a section, or a slide with <sixb-embed src="${source}"></sixb-embed>.`;
407
- return;
408
- }
409
- references.push({ address: source, as: "embed", at: at() });
410
- }
411
- }).on("sixb-embed", {
412
- element(element) {
413
- const source = decodeHtmlEntities(element.getAttribute("src") ?? "").trim();
414
- if (!isArtifactAddress2(source)) {
415
- refused ??= `<sixb-embed> shows another artifact: give it src="artifact:\u2026", such as artifact:art_k3m9q2x7tp#chart=revenue.`;
416
- return;
417
- }
418
- references.push({ address: source, as: "embed", at: at() });
419
- }
420
- }).on("iframe[src], object[data], embed[src]", {
421
- element(element) {
422
- const source = decodeHtmlEntities(element.getAttribute("src") ?? element.getAttribute("data") ?? "").trim();
423
- if (isArtifactAddress2(source)) {
424
- refused ??= `${file} frames '${source}': show another artifact with <sixb-embed src="${source}"></sixb-embed>, or a file of one with <img>.`;
425
- }
426
- }
427
- });
428
- return { references, refusal: () => refused };
429
- }
430
-
431
- // src/artifacts/frames/kit.ts
432
- var FONTS = {
433
- "--font-sans": '"SF Pro Text", "SF Pro Display", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif',
434
- "--font-serif": 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
435
- "--font-mono": '"SF Mono", "Geist Mono", "JetBrains Mono", ui-monospace, monospace'
436
- };
437
- var FRAME_DEFAULT_THEMES2 = {
438
- light: {
439
- dark: false,
440
- tokens: {
441
- "--background": "#fafafa",
442
- "--foreground": "#101010",
443
- "--card": "#ffffff",
444
- "--card-foreground": "#101010",
445
- "--muted": "#f4f4f4",
446
- "--muted-foreground": "#5f5f5f",
447
- "--primary": "#0a0a0a",
448
- "--primary-foreground": "#ffffff",
449
- "--accent": "#f0f0f0",
450
- "--accent-foreground": "#202020",
451
- "--border": "#e2e2e2",
452
- "--chart-1": "#101010",
453
- "--chart-2": "#404040",
454
- "--chart-3": "#737373",
455
- "--chart-4": "#a3a3a3",
456
- "--chart-5": "#d4d4d4",
457
- ...FONTS,
458
- "--radius": "0.5rem"
459
- }
460
- },
461
- dark: {
462
- dark: true,
463
- tokens: {
464
- "--background": "#0a0a0a",
465
- "--foreground": "#f4f4f4",
466
- "--card": "#141414",
467
- "--card-foreground": "#f4f4f4",
468
- "--muted": "#1c1c1c",
469
- "--muted-foreground": "#8a8a8a",
470
- "--primary": "#f4f4f4",
471
- "--primary-foreground": "#0a0a0a",
472
- "--accent": "#1c1c1c",
473
- "--accent-foreground": "#f4f4f4",
474
- "--border": "#262626",
475
- "--chart-1": "#f4f4f4",
476
- "--chart-2": "#c4c4c4",
477
- "--chart-3": "#8a8a8a",
478
- "--chart-4": "#5f5f5f",
479
- "--chart-5": "#404040",
480
- ...FONTS,
481
- "--radius": "0.5rem"
482
- }
483
- }
484
- };
485
- var LIGHT = FRAME_DEFAULT_THEMES2.light.tokens;
486
- function kit(rules) {
487
- return `
488
- @layer sixb-kit, sixb-theme;
489
-
490
- @layer sixb-kit {
491
- :root {
492
- ${Object.entries(LIGHT).map(([name, value]) => ` ${name}: ${value};`).join(`
493
- `)}
494
- }
495
-
496
- *, *::before, *::after { box-sizing: border-box; }
497
- html, body { margin: 0; padding: 0; }
498
- body {
499
- color: var(--foreground);
500
- font-family: var(--font-sans);
501
- -webkit-font-smoothing: antialiased;
502
- }
503
-
504
- ${rules}}
505
- `;
506
- }
507
- var FRAME_DECK_CSS = kit(` :root {
508
- --sixb-scale: 1;
509
- --sixb-overview-scale: 0.25;
510
- --sixb-columns: 4;
511
- --sixb-stage: ${LIGHT["--muted"]};
512
- --sixb-stage-border: ${LIGHT["--border"]};
513
- --sixb-stage-foreground: ${LIGHT["--foreground"]};
514
- }
515
- body { background: var(--muted); }
516
-
517
- /*
518
- * The stage: a slide's size and scale, which slides show, and the stage around them, in the
519
- * app's colors (--sixb-stage and its kin, which only the app's theme sets). A deck's own CSS, unlayered,
520
- * wins over everything else in the kit, so these alone are important: an important declaration
521
- * in a layer wins over every unlayered one, a deck's own important ones included. Otherwise a
522
- * deck that sets display on its closing slide shows it under every other, and one that sets its
523
- * body's background repaints the stage.
524
- */
525
- html.sixb-deck section.slide { width: 1280px !important; height: 720px !important; flex: none !important; }
526
-
527
- /* One slide at a time, scaled to fit and centered on the stage. */
528
- html.sixb-deck:not([data-mode="overview"]),
529
- html.sixb-deck:not([data-mode="overview"]) body { height: 100% !important; overflow: hidden !important; }
530
- html.sixb-deck:not([data-mode="overview"]) body {
531
- margin: 0 !important;
532
- padding: 0 !important;
533
- display: grid !important;
534
- place-items: center !important;
535
- background: var(--sixb-stage) !important;
536
- }
537
- html.sixb-deck:not([data-mode="overview"]) section.slide { zoom: var(--sixb-scale) !important; }
538
- html.sixb-deck:not([data-mode="overview"]) section.slide:not([data-current]) { display: none !important; }
539
- html.sixb-deck[data-mode="slide"] section.slide {
540
- border-radius: calc(10px / var(--sixb-scale)) !important;
541
- box-shadow: 0 0 0 calc(1px / var(--sixb-scale)) var(--sixb-stage-border) !important;
542
- }
543
- /* Filled, the slide is the whole frame, as a thumbnail or an embed shows it; presented, it
544
- fills the page on black. */
545
- html.sixb-deck:is([data-mode="fill"], [data-mode="present"]) section.slide {
546
- border-radius: 0 !important;
547
- box-shadow: none !important;
548
- }
549
- html.sixb-deck[data-mode="present"] body { background: #000 !important; }
550
-
551
- /* Every slide in a grid. */
552
- html.sixb-deck[data-mode="overview"],
553
- html.sixb-deck[data-mode="overview"] body { height: 100% !important; overflow: auto !important; }
554
- html.sixb-deck[data-mode="overview"] body {
555
- margin: 0 !important;
556
- display: grid !important;
557
- grid-template-columns: repeat(var(--sixb-columns), max-content) !important;
558
- justify-content: center !important;
559
- align-content: start !important;
560
- gap: 16px !important;
561
- padding: 16px !important;
562
- background: var(--sixb-stage) !important;
563
- }
564
- html.sixb-deck[data-mode="overview"] section.slide {
565
- zoom: var(--sixb-overview-scale) !important;
566
- cursor: pointer;
567
- border-radius: calc(6px / var(--sixb-overview-scale)) !important;
568
- box-shadow: 0 0 0 calc(1px / var(--sixb-overview-scale)) var(--sixb-stage-border) !important;
569
- }
570
- html.sixb-deck[data-mode="overview"] section.slide[data-current] {
571
- box-shadow: 0 0 0 calc(1px / var(--sixb-overview-scale)) var(--sixb-stage-foreground) !important;
572
- outline: calc(2px / var(--sixb-overview-scale)) solid var(--sixb-stage-foreground) !important;
573
- outline-offset: calc(2px / var(--sixb-overview-scale)) !important;
574
- }
575
-
576
- /*
577
- * A slide: 1280\xD7720. Its footer, a rule with the source and the slide's number, sits in the
578
- * bottom padding, so content never runs into it.
579
- */
580
- section.slide {
581
- position: relative;
582
- display: flex;
583
- flex-direction: column;
584
- gap: 28px;
585
- width: 1280px;
586
- height: 720px;
587
- flex: none;
588
- padding: 72px 96px 140px;
589
- overflow: hidden;
590
- background: var(--background);
591
- color: var(--foreground);
592
- font-size: 28px;
593
- line-height: 1.4;
594
- }
595
-
596
- /* Type: nothing on a slide is smaller than 18px. */
597
- section.slide :is(h1, h2, h3) { margin: 0; text-wrap: balance; }
598
- section.slide h1 { font-size: 72px; line-height: 1; font-weight: 650; letter-spacing: -0.035em; }
599
- section.slide h2 { max-width: 1000px; font-size: 46px; line-height: 1.08; font-weight: 600; letter-spacing: -0.025em; }
600
- section.slide h3 { font-size: 30px; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
601
- section.slide p { margin: 0; max-width: 34em; }
602
- section.slide :is(ul, ol) {
603
- margin: 0;
604
- padding-left: 30px;
605
- display: flex;
606
- flex-direction: column;
607
- gap: 22px;
608
- font-size: 30px;
609
- line-height: 1.35;
610
- letter-spacing: -0.01em;
611
- }
612
- section.slide li { padding-left: 6px; }
613
- section.slide li::marker { color: var(--muted-foreground); }
614
- section.slide strong { font-weight: 600; }
615
- section.slide a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 5px; }
616
- section.slide small, section.slide .note { font-size: 20px; color: var(--muted-foreground); }
617
- section.slide img, section.slide svg, section.slide video { max-width: 100%; max-height: 100%; }
618
- /* A figure's default 40px margins would squeeze a chart and its labels below the type floor. */
619
- section.slide figure { margin: 0; }
620
- section.slide code { font-family: var(--font-mono); font-size: 0.85em; }
621
-
622
- /* Chrome: a label above the heading (two spans sit at either end), and the footer. */
623
- section.slide .eyebrow {
624
- display: flex;
625
- justify-content: space-between;
626
- gap: 24px;
627
- margin: 0;
628
- max-width: none;
629
- font-size: 20px;
630
- line-height: 1.3;
631
- letter-spacing: 0.01em;
632
- color: var(--muted-foreground);
633
- }
634
- section.slide .eyebrow + :is(h1, h2) { margin-top: -12px; }
635
- section.slide::after {
636
- content: attr(data-number);
637
- position: absolute;
638
- left: 96px;
639
- right: 96px;
640
- bottom: 64px;
641
- padding-top: 22px;
642
- border-top: 1px solid var(--border);
643
- text-align: right;
644
- font-size: 18px;
645
- line-height: 1.4;
646
- font-variant-numeric: tabular-nums;
647
- color: var(--muted-foreground);
648
- }
649
- section.slide.no-number::after { content: ""; }
650
- section.slide.no-number:not(:has(.source))::after { display: none; }
651
- section.slide .source {
652
- position: absolute;
653
- left: 96px;
654
- right: calc(96px + 3em);
655
- bottom: 64px;
656
- z-index: 1;
657
- max-width: none;
658
- overflow: hidden;
659
- white-space: nowrap;
660
- text-overflow: ellipsis;
661
- font-size: 18px;
662
- line-height: 1.4;
663
- font-variant-numeric: tabular-nums;
664
- color: var(--muted-foreground);
665
- }
666
-
667
- /* Layouts. */
668
- section.slide.title > .eyebrow { margin-bottom: auto; }
669
- section.slide.title h1 { margin-top: 0; font-size: 132px; line-height: 0.92; letter-spacing: -0.04em; max-width: 9em; }
670
- section.slide.title > p:not(.eyebrow, .source) { font-size: 36px; line-height: 1.25; letter-spacing: -0.01em; color: var(--muted-foreground); max-width: 24em; text-wrap: balance; }
671
-
672
- section.slide.section { justify-content: flex-end; }
673
- section.slide.section h2 { font-size: 72px; line-height: 1; letter-spacing: -0.035em; max-width: 13em; }
674
-
675
- section.slide.split {
676
- display: grid;
677
- grid-template-columns: 5fr 6fr;
678
- grid-template-rows: auto 1fr;
679
- column-gap: 80px;
680
- row-gap: 28px;
681
- }
682
- section.slide.split:has(> .eyebrow) { grid-template-rows: auto auto 1fr; }
683
- section.slide.split > :is(h1, h2, .eyebrow) { grid-column: 1 / -1; }
684
- section.slide.split > * { min-width: 0; min-height: 0; }
685
- section.slide.split > :not(h1, h2, .eyebrow) { align-self: center; }
686
-
687
- section.slide.stat > .value { margin-top: auto; }
688
- section.slide.stat .value {
689
- font-size: 144px;
690
- line-height: 0.9;
691
- font-weight: 600;
692
- letter-spacing: -0.045em;
693
- font-variant-numeric: tabular-nums;
694
- color: var(--primary);
695
- }
696
- section.slide.stat .label { font-size: 26px; line-height: 1.35; color: var(--muted-foreground); }
697
- section.slide.stat .stats {
698
- margin-top: auto;
699
- display: grid;
700
- grid-auto-flow: column;
701
- grid-auto-columns: minmax(0, 1fr);
702
- gap: 64px;
703
- padding-bottom: 16px;
704
- }
705
- section.slide.stat .stats > * {
706
- display: flex;
707
- flex-direction: column;
708
- gap: 14px;
709
- padding-top: 28px;
710
- border-top: 2px solid var(--foreground);
711
- }
712
- section.slide.stat .stats:has(> :nth-child(3)) .value { font-size: 96px; }
713
- section.slide.stat .stats:has(> :nth-child(4)) .value { font-size: 80px; }
714
-
715
- section.slide.quote { justify-content: center; }
716
- section.slide.quote blockquote {
717
- margin: 0;
718
- font-family: var(--font-serif);
719
- font-size: 52px;
720
- line-height: 1.2;
721
- letter-spacing: -0.01em;
722
- max-width: 22em;
723
- text-wrap: balance;
724
- }
725
- section.slide.quote cite { font-style: normal; font-size: 24px; color: var(--muted-foreground); }
726
-
727
- section.slide.image > :is(img, figure) { flex: 1; min-height: 0; margin: 0; object-fit: contain; }
728
- section.slide.image.bleed { padding: 0; }
729
- section.slide.image.bleed > img { width: 100%; height: 100%; object-fit: cover; }
730
- section.slide.image.bleed::after, section.slide.image.bleed .source { display: none; }
731
-
732
- section.slide.chart > :is(figure, svg, img, .chart) { flex: 1; min-height: 0; margin: 0; }
733
- section.slide.chart figure { display: flex; flex-direction: column; gap: 20px; }
734
- section.slide.chart figure > :is(svg, img) { flex: 1; min-height: 0; width: 100%; }
735
- section.slide figcaption { font-size: 20px; color: var(--muted-foreground); }
736
-
737
- section.slide.table table { width: 100%; border-collapse: collapse; font-size: 26px; font-variant-numeric: tabular-nums; }
738
- section.slide.table :is(th, td) { padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left; }
739
- section.slide.table :is(th, td):first-child { padding-left: 0; }
740
- section.slide.table :is(th, td):last-child { padding-right: 0; }
741
- section.slide.table th { font-size: 20px; font-weight: 500; color: var(--muted-foreground); }
742
- section.slide.table :is(th, td).num, section.slide.table :is(th, td)[data-numeric] { text-align: right; }
743
-
744
- /*
745
- * Another artifact on the slide: the app draws it over this box, sized by the deck's CSS like
746
- * any block. Until it does, and in a thumbnail, the box shows where it goes.
747
- */
748
- sixb-embed {
749
- display: block;
750
- position: relative;
751
- width: 100%;
752
- min-width: 0;
753
- aspect-ratio: 16 / 9;
754
- border-radius: 12px;
755
- background: color-mix(in oklab, var(--muted) 80%, transparent);
756
- }
757
- sixb-embed[title]::after {
758
- content: attr(title);
759
- position: absolute;
760
- inset: auto 24px 20px;
761
- font-size: 20px;
762
- color: var(--muted-foreground);
763
- }
764
- section.slide.chart > sixb-embed,
765
- section.slide.chart figure > sixb-embed { flex: 1; min-height: 0; aspect-ratio: auto; }
766
- /* An image from another artifact its reader cannot see. */
767
- section.slide img[data-sixb-ref="unavailable"] {
768
- display: block;
769
- min-width: 160px;
770
- min-height: 90px;
771
- border-radius: 12px;
772
- background: var(--muted);
773
- }
774
-
775
- /* Components. */
776
- section.slide .legend {
777
- display: flex;
778
- flex-direction: row;
779
- flex-wrap: wrap;
780
- gap: 8px 24px;
781
- margin: 0;
782
- padding: 0;
783
- list-style: none;
784
- font-size: 20px;
785
- line-height: 1.3;
786
- letter-spacing: 0;
787
- color: var(--muted-foreground);
788
- }
789
- section.slide .legend > * { display: flex; align-items: center; gap: 8px; padding: 0; }
790
- section.slide .legend > *::before {
791
- content: "";
792
- width: 0.8em;
793
- height: 0.8em;
794
- border-radius: 2px;
795
- background: var(--swatch, var(--chart-1));
796
- }
797
- section.slide .callout {
798
- padding: 24px 28px;
799
- border-radius: var(--radius);
800
- background: var(--muted);
801
- font-size: 26px;
802
- }
803
- section.slide .tag {
804
- display: inline-block;
805
- padding: 4px 12px;
806
- border-radius: 999px;
807
- background: var(--muted);
808
- font-size: 18px;
809
- font-weight: 600;
810
- }
811
- `);
812
- var FRAME_PAGE_CSS = kit(` html { color-scheme: light; }
813
- html.dark { color-scheme: dark; }
814
- body {
815
- background: var(--background);
816
- font-size: 15px;
817
- line-height: 1.6;
818
- text-rendering: optimizeLegibility;
819
- }
820
-
821
- /* A page reads in a centered column with room around it, narrower on a phone. */
822
- main { display: block; max-width: 1120px; margin: 0 auto; padding: 40px 32px 56px; }
823
- @media (max-width: 640px) { main { padding: 24px 16px 40px; } }
824
-
825
- /*
826
- * Type. Text takes the body's colour, or the colour of whatever the page paints it on: the kit
827
- * colours only the surfaces it paints itself. A rule on a heading would win over the colour a
828
- * page gives its body, and a page with its own light background loses its headings in dark mode.
829
- */
830
- :is(h1, h2, h3, h4) { margin: 0 0 0.5em; text-wrap: balance; }
831
- h1 { font-size: 32px; line-height: 1.15; font-weight: 650; letter-spacing: -0.025em; }
832
- h2 { margin-top: 1.6em; font-size: 21px; line-height: 1.25; font-weight: 620; letter-spacing: -0.015em; }
833
- h3 { margin-top: 1.4em; font-size: 16px; line-height: 1.35; font-weight: 600; }
834
- h4 { font-size: 14px; font-weight: 600; }
835
- :is(h1, h2, h3, h4):first-child { margin-top: 0; }
836
- @media (max-width: 640px) { h1 { font-size: 26px; } h2 { font-size: 19px; } }
837
- p { margin: 0 0 1em; text-wrap: pretty; }
838
- .lede { max-width: 42em; margin-bottom: 1.6em; font-size: 17px; line-height: 1.55; color: var(--muted-foreground); }
839
- .eyebrow {
840
- margin: 0 0 8px;
841
- font-size: 12px;
842
- font-weight: 600;
843
- letter-spacing: 0.06em;
844
- text-transform: uppercase;
845
- color: var(--muted-foreground);
846
- }
847
- small, .muted, .note { color: var(--muted-foreground); }
848
- small, .note { font-size: 13px; }
849
- a { color: inherit; text-decoration-color: color-mix(in oklab, currentColor 35%, transparent); text-underline-offset: 3px; }
850
- a:hover { text-decoration-color: currentColor; }
851
- strong { font-weight: 600; }
852
- hr { margin: 32px 0; border: 0; border-top: 1px solid var(--border); }
853
- :is(ul, ol) { margin: 0 0 1em; padding-left: 1.25em; }
854
- li + li { margin-top: 0.25em; }
855
- code { font-family: var(--font-mono); font-size: 0.88em; padding: 0.1em 0.35em; border-radius: 5px; background: var(--muted); }
856
- pre { margin: 0 0 1em; padding: 14px 16px; overflow-x: auto; border-radius: var(--radius); background: var(--muted); font-size: 13px; line-height: 1.5; }
857
- pre code { padding: 0; background: none; }
858
- img, svg, video, canvas { max-width: 100%; }
859
- img, video { height: auto; }
860
-
861
- /* Tables: hairline rows, quiet headers, numbers aligned. Wide ones scroll in their box. */
862
- table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
863
- :is(th, td) { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
864
- th { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted-foreground); white-space: nowrap; }
865
- :is(th, td):first-child { padding-left: 0; }
866
- :is(th, td):last-child { padding-right: 0; }
867
- :is(th, td).num, :is(th, td)[data-numeric] { text-align: right; white-space: nowrap; }
868
- .table-scroll { overflow-x: auto; }
869
-
870
- /* Forms and buttons, drawn like the app's. */
871
- label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 550; }
872
- :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"]), select, textarea) {
873
- width: 100%;
874
- min-height: 36px;
875
- padding: 7px 10px;
876
- border: 1px solid var(--border);
877
- border-radius: calc(var(--radius) - 2px);
878
- background: var(--card);
879
- color: var(--foreground);
880
- font: inherit;
881
- font-size: 14px;
882
- line-height: 1.4;
883
- box-shadow: 0 1px 1px rgb(0 0 0 / 0.03);
884
- transition: border-color 0.12s, box-shadow 0.12s;
885
- }
886
- :is(input, select, textarea):focus-visible {
887
- outline: none;
888
- border-color: color-mix(in oklab, var(--foreground) 45%, var(--border));
889
- box-shadow: 0 0 0 3px color-mix(in oklab, var(--foreground) 12%, transparent);
890
- }
891
- input[type="range"], input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
892
- textarea { min-height: 88px; resize: vertical; }
893
- button, .button {
894
- display: inline-flex;
895
- align-items: center;
896
- justify-content: center;
897
- gap: 6px;
898
- min-height: 36px;
899
- padding: 0 14px;
900
- border: 1px solid transparent;
901
- border-radius: calc(var(--radius) - 2px);
902
- background: var(--primary);
903
- color: var(--primary-foreground);
904
- font: inherit;
905
- font-size: 14px;
906
- font-weight: 550;
907
- text-decoration: none;
908
- cursor: pointer;
909
- transition: background-color 0.12s, border-color 0.12s, opacity 0.12s;
910
- }
911
- :is(button, .button):hover { background: color-mix(in oklab, var(--primary) 88%, var(--background)); }
912
- :is(button, .button):focus-visible { outline: 2px solid var(--ring, var(--foreground)); outline-offset: 2px; }
913
- :is(button, .button):disabled { opacity: 0.5; cursor: default; }
914
- :is(button, .button).secondary { border-color: var(--border); background: var(--card); color: var(--foreground); }
915
- :is(button, .button).secondary:hover { background: var(--muted); }
916
- :is(button, .button).ghost { background: transparent; color: inherit; }
917
- :is(button, .button).ghost:hover { background: var(--muted); }
918
- fieldset { margin: 0 0 16px; padding: 0; border: 0; }
919
- .field { margin-bottom: 16px; }
920
-
921
- /* Components. */
922
- .card {
923
- padding: 20px;
924
- border: 1px solid var(--border);
925
- border-radius: var(--radius);
926
- background: var(--card);
927
- box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
928
- }
929
- .card > :last-child { margin-bottom: 0; }
930
- /* Cards stack with room between them; in a grid or a row, its gap spaces them. */
931
- .card { margin-bottom: 16px; }
932
- :is(.grid, .row) > .card { margin-bottom: 0; }
933
- .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; margin-bottom: 24px; }
934
- .row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
935
- .stat .label { font-size: 13px; color: var(--muted-foreground); }
936
- .stat .value { margin-top: 4px; font-size: 30px; line-height: 1.1; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
937
- .stat .delta { margin-top: 6px; font-size: 13px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
938
- .tag {
939
- display: inline-flex;
940
- align-items: center;
941
- gap: 6px;
942
- padding: 2px 9px;
943
- border-radius: 999px;
944
- background: var(--muted);
945
- font-size: 12px;
946
- font-weight: 600;
947
- line-height: 1.6;
948
- white-space: nowrap;
949
- }
950
- .callout { margin: 0 0 1em; padding: 14px 16px; border-radius: var(--radius); background: var(--muted); }
951
- .callout > :last-child { margin-bottom: 0; }
952
-
953
- /*
954
- * Another artifact on the page: the app draws it over this box, sized by the page's CSS like any
955
- * block. Until it does, the box shows where it goes.
956
- */
957
- sixb-embed {
958
- display: block;
959
- position: relative;
960
- width: 100%;
961
- aspect-ratio: 16 / 9;
962
- margin-bottom: 1em;
963
- border-radius: var(--radius);
964
- background: var(--muted);
965
- }
966
- sixb-embed[title]::after {
967
- content: attr(title);
968
- position: absolute;
969
- inset: auto 16px 12px;
970
- font-size: 13px;
971
- color: var(--muted-foreground);
972
- }
973
- img[data-sixb-ref="unavailable"] { display: block; min-width: 120px; min-height: 68px; border-radius: var(--radius); background: var(--muted); }
974
- `);
975
- var FRAME_DOCUMENT_CSS = kit(` :root {
976
- --sixb-stage: ${LIGHT["--muted"]};
977
- --sixb-stage-border: ${LIGHT["--border"]};
978
- --sixb-paper-width: 816px;
979
- --sixb-paper-margin-top: 72px;
980
- --sixb-paper-margin-right: 72px;
981
- --sixb-paper-margin-bottom: 72px;
982
- --sixb-paper-margin-left: 72px;
983
- }
984
- html { color-scheme: light; background: var(--sixb-stage); }
985
- body {
986
- width: 100%;
987
- max-width: var(--sixb-paper-width);
988
- min-height: calc(100vh - 64px);
989
- margin: 32px auto;
990
- padding: var(--sixb-paper-margin-top) var(--sixb-paper-margin-right) var(--sixb-paper-margin-bottom) var(--sixb-paper-margin-left);
991
- background: #fff;
992
- color: #18181b;
993
- box-shadow: 0 0 0 1px var(--sixb-stage-border);
994
- }
995
- @media (max-width: 720px) {
996
- body { min-height: 100vh; margin: 0; padding: 28px 20px; box-shadow: none; }
997
- }
998
- img, svg { max-width: 100%; }
999
- /* A page break, as one sheet: the stage shows through, from edge to edge of the sheet. */
1000
- .sixb-page-break {
1001
- display: block;
1002
- height: 24px;
1003
- margin: var(--sixb-paper-margin-bottom) calc(-1 * var(--sixb-paper-margin-right)) var(--sixb-paper-margin-top) calc(-1 * var(--sixb-paper-margin-left));
1004
- background: var(--sixb-stage);
1005
- box-shadow: inset 0 1px 0 var(--sixb-stage-border), inset 0 -1px 0 var(--sixb-stage-border);
1006
- }
1007
- @media (max-width: 720px) {
1008
- .sixb-page-break { height: 0; margin: 32px 0; box-shadow: inset 0 1px 0 var(--sixb-stage-border); }
1009
- }
1010
-
1011
- html.sixb-pages, html.sixb-pages body { min-height: 0 !important; }
1012
- html.sixb-pages body {
1013
- width: auto !important;
1014
- max-width: none !important;
1015
- margin: 0 !important;
1016
- padding: 24px 16px !important;
1017
- background: var(--sixb-stage) !important;
1018
- box-shadow: none !important;
1019
- border: 0 !important;
1020
- }
1021
- /* Until the content is cut into pages, it shows as nothing: never as one long column. */
1022
- html.sixb-pages:not([data-sixb-pages]) body { visibility: hidden !important; }
1023
- .sixb-pages, .sixb-paper, .sixb-paper-content, .sixb-flow {
1024
- box-sizing: content-box !important;
1025
- max-width: none !important;
1026
- margin: 0 !important;
1027
- padding: 0 !important;
1028
- border: 0 !important;
1029
- }
1030
- .sixb-pages {
1031
- display: flex !important;
1032
- flex-direction: column !important;
1033
- align-items: center !important;
1034
- gap: 24px !important;
1035
- width: auto !important;
1036
- zoom: var(--sixb-zoom, 1);
1037
- }
1038
- .sixb-paper {
1039
- position: relative !important;
1040
- flex: none !important;
1041
- width: var(--sixb-paper-width) !important;
1042
- height: var(--sixb-paper-height) !important;
1043
- overflow: hidden !important;
1044
- background: #fff;
1045
- box-shadow: 0 0 0 1px var(--sixb-stage-border), 0 1px 3px rgb(0 0 0 / 0.06);
1046
- }
1047
- .sixb-paper-content {
1048
- position: absolute !important;
1049
- inset: var(--sixb-paper-margin-top) var(--sixb-paper-margin-right) var(--sixb-paper-margin-bottom) var(--sixb-paper-margin-left) !important;
1050
- width: auto !important;
1051
- height: auto !important;
1052
- overflow: hidden !important;
1053
- }
1054
-
1055
- /* Printed, the sheet is the paper: its @page rule gives the margins, and nothing is the stage. */
1056
- @media print {
1057
- html { background: none; }
1058
- body { width: auto; max-width: none; min-height: 0; margin: 0; padding: 0; background: none; box-shadow: none; }
1059
- .sixb-page-break { display: none; }
1060
- }
1061
- `);
1062
-
1063
- // src/artifacts/frames/runtime.ts
1064
- function frameRuntime(data) {
1065
- const PROTOCOL = "sixb-frame/1";
1066
- const EDITOR_GLOBAL = "__sixbFrameEditor";
1067
- const WIDTH = 1280;
1068
- const HEIGHT = 720;
1069
- const KEYS = [
1070
- "ArrowLeft",
1071
- "ArrowRight",
1072
- "ArrowUp",
1073
- "ArrowDown",
1074
- "PageUp",
1075
- "PageDown",
1076
- "Home",
1077
- "End",
1078
- " ",
1079
- "Escape"
1080
- ];
1081
- const MAX_KEY_LENGTH = 128;
1082
- const MAX_VALUE_BYTES = 65536;
1083
- const QUERY_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
1084
- const MAX_LABEL_LENGTH = 120;
1085
- const AT = "data-sixb-at";
1086
- const KIND = "data-sixb-edit";
1087
- const WORDS = "data-sixb-text";
1088
- const MAX_EDIT_LABEL = 80;
1089
- const COMMENT_CURSOR = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M3 21V11a8 8 0 1 1 8 8H3z' fill='%23111' stroke='white' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 3 21, crosshair`;
1090
- const EDITING_CSS = [
1091
- "[data-sixb-editing] [data-sixb-hover] { outline: 1px dashed #0a84ff; outline-offset: 2px; }",
1092
- "[data-sixb-editing] [data-sixb-picked] { outline: 2px solid #0a84ff; outline-offset: 2px; }",
1093
- "[data-sixb-editing] [contenteditable] { cursor: text; }",
1094
- `[data-sixb-commenting], [data-sixb-commenting] * { cursor: ${COMMENT_CURSOR} !important; }`,
1095
- "[data-sixb-commenting] [data-sixb-hover] { outline: 2px dashed #0a84ff; outline-offset: 3px; }",
1096
- "[data-sixb-commenting] [data-sixb-picked] { outline: 2px solid #0a84ff; outline-offset: 3px; }"
1097
- ].join(" ");
1098
- const CANVAS_CSS = "html { overscroll-behavior: none; } html, html * { touch-action: none !important; }";
1099
- const root = document.documentElement;
1100
- const script = document.currentScript;
1101
- const layout = script?.getAttribute("data-sixb-layout") ?? "deck";
1102
- const deck = layout === "deck";
1103
- const designed = layout === "document";
1104
- const start = new URLSearchParams(window.location.hash.slice(1));
1105
- if (deck) {
1106
- root.classList.add("sixb-deck");
1107
- root.dataset.mode = start.has("sixb-fill") ? "fill" : "slide";
1108
- }
1109
- const paper = (script?.getAttribute("data-sixb-paper") ?? "").split(" ").map(Number).filter((value) => Number.isFinite(value) && value >= 0);
1110
- const hasPaper = paper.length === 6 && (paper[0] ?? 0) > 0 && (paper[1] ?? 0) > 0;
1111
- const paged = designed && hasPaper && start.has("sixb-pages");
1112
- if (designed) {
1113
- root.classList.add("sixb-document");
1114
- if (hasPaper) {
1115
- const [width, height, top, right, bottom, left] = paper;
1116
- root.style.setProperty("--sixb-paper-width", `${width}px`);
1117
- root.style.setProperty("--sixb-paper-height", `${height}px`);
1118
- root.style.setProperty("--sixb-paper-margin-top", `${top}px`);
1119
- root.style.setProperty("--sixb-paper-margin-right", `${right}px`);
1120
- root.style.setProperty("--sixb-paper-margin-bottom", `${bottom}px`);
1121
- root.style.setProperty("--sixb-paper-margin-left", `${left}px`);
1122
- }
1123
- if (paged)
1124
- root.classList.add("sixb-pages");
1125
- }
1126
- let current = Number(start.get("sixb-slide")) || 1;
1127
- const slides = () => Array.from(document.querySelectorAll("section.slide"));
1128
- const post = (message) => window.parent.postMessage({ protocol: PROTOCOL, ...message }, "*");
1129
- const webAddress = (href) => {
1130
- try {
1131
- const url = new URL(href, document.baseURI);
1132
- return url.protocol === "http:" || url.protocol === "https:" ? url.href : null;
1133
- } catch {
1134
- return null;
1135
- }
1136
- };
1137
- const fit = () => {
1138
- const columns = window.innerWidth < 720 ? 2 : window.innerWidth < 1100 ? 3 : 4;
1139
- const gap = 16;
1140
- const margin = root.dataset.mode === "fill" || root.dataset.mode === "present" ? 0 : Math.min(32, window.innerWidth * 0.04);
1141
- root.style.setProperty("--sixb-scale", String(Math.min((window.innerWidth - margin * 2) / WIDTH, (window.innerHeight - margin * 2) / HEIGHT)));
1142
- root.style.setProperty("--sixb-columns", String(columns));
1143
- root.style.setProperty("--sixb-overview-scale", String((window.innerWidth - gap * (columns + 1)) / columns / WIDTH));
1144
- };
1145
- let reported = "";
1146
- let reporting = false;
1147
- const ids = new WeakMap;
1148
- let lastId = 0;
1149
- const idOf = (element) => {
1150
- const known = ids.get(element);
1151
- if (known !== undefined)
1152
- return known;
1153
- lastId += 1;
1154
- ids.set(element, lastId);
1155
- return lastId;
1156
- };
1157
- const reportEmbeds = () => {
1158
- if (reporting || root.dataset.mode === "fill")
1159
- return;
1160
- reporting = true;
1161
- requestAnimationFrame(() => {
1162
- reporting = false;
1163
- const scale = deck ? Number(root.style.getPropertyValue("--sixb-scale")) || 1 : 1;
1164
- const scope = deck ? root.dataset.mode === "overview" ? undefined : slides()[current - 1] : document;
1165
- const near = (rect) => deck || rect.bottom > -window.innerHeight && rect.top < window.innerHeight * 2;
1166
- const embeds = Array.from(scope?.querySelectorAll("sixb-embed[src]") ?? []).flatMap((element) => {
1167
- const id = idOf(element);
1168
- const rect = element.getBoundingClientRect();
1169
- return near(rect) && (!paged || shownOnItsPage(element)) ? [
1170
- {
1171
- id,
1172
- address: (element.getAttribute("src") ?? "").trim(),
1173
- rect: { x: rect.left, y: rect.top, width: rect.width, height: rect.height },
1174
- scale
1175
- }
1176
- ] : [];
1177
- });
1178
- const next = JSON.stringify(embeds);
1179
- if (next === reported)
1180
- return;
1181
- reported = next;
1182
- post({ event: "embeds", params: { embeds } });
1183
- });
1184
- };
1185
- const PAGE_BREAKS = ["page", "left", "right", "recto", "verso"];
1186
- const COLUMN_GAP = 64;
1187
- const shownOnItsPage = (element) => {
1188
- const box = element.closest(".sixb-paper-content");
1189
- if (!box)
1190
- return true;
1191
- const rect = element.getBoundingClientRect();
1192
- const page = box.getBoundingClientRect();
1193
- return rect.right > page.left && rect.left < page.right && rect.bottom > page.top && rect.top < page.bottom;
1194
- };
1195
- const NEAR_PAGES = 1;
1196
- let flow = null;
1197
- let stride = 0;
1198
- let sheetsInView = null;
1199
- const pageCopy = (index) => {
1200
- if (index === 0 || !flow)
1201
- return flow;
1202
- const content = document.querySelector(`.sixb-paper[data-page="${index + 1}"] > div`);
1203
- if (!content)
1204
- return null;
1205
- if (content.firstElementChild)
1206
- return content.firstElementChild;
1207
- const copy = flow.cloneNode(true);
1208
- copy.style.transform = `translateX(${-index * stride}px)`;
1209
- copy.setAttribute("aria-hidden", "true");
1210
- copy.inert = true;
1211
- content.append(copy);
1212
- return copy;
1213
- };
1214
- const shownCopy = (selector) => {
1215
- const found = (flow ?? document).querySelector(selector);
1216
- if (!found || !flow)
1217
- return found;
1218
- const box = flow.getBoundingClientRect();
1219
- const scale = box.width / flow.offsetWidth || 1;
1220
- const left = (found.getClientRects()[0] ?? found.getBoundingClientRect()).left;
1221
- const copy = pageCopy(Math.max(0, Math.floor((left - box.left) / scale / stride)));
1222
- if (!copy || copy === flow)
1223
- return found;
1224
- const path = [];
1225
- for (let at = found;at !== flow && at.parentElement; at = at.parentElement) {
1226
- path.unshift(Array.prototype.indexOf.call(at.parentElement.children, at));
1227
- }
1228
- return path.reduce((node, index) => node?.children[index], copy) ?? found;
1229
- };
1230
- const fitPages = () => {
1231
- const width = paper[0] ?? 0;
1232
- const room = window.innerWidth - 32;
1233
- root.style.setProperty("--sixb-zoom", String(width > room ? Math.max(0.2, room / width) : 1));
1234
- };
1235
- const paginate = () => {
1236
- sheetsInView?.disconnect();
1237
- const body = document.body;
1238
- const [width = 0, height = 0, top = 0, right = 0, bottom = 0, left = 0] = paper;
1239
- const contentWidth = Math.max(1, width - left - right);
1240
- const contentHeight = Math.max(1, height - top - bottom);
1241
- const cut = document.createElement("div");
1242
- cut.className = "sixb-flow";
1243
- cut.style.cssText = `width:${contentWidth}px;height:${contentHeight}px;column-width:${contentWidth}px;column-gap:${COLUMN_GAP}px;column-fill:auto;`;
1244
- cut.append(...Array.from(body.childNodes));
1245
- body.append(cut);
1246
- const breaks = Array.from(cut.querySelectorAll("*")).map((element) => {
1247
- const style = getComputedStyle(element);
1248
- return [element, style.breakBefore, style.breakAfter];
1249
- });
1250
- for (const [element, before, after] of breaks) {
1251
- if (PAGE_BREAKS.includes(before))
1252
- element.style.breakBefore = "column";
1253
- if (PAGE_BREAKS.includes(after))
1254
- element.style.breakAfter = "column";
1255
- }
1256
- flow = cut;
1257
- stride = contentWidth + COLUMN_GAP;
1258
- const count = Math.max(1, Math.ceil((cut.scrollWidth + COLUMN_GAP - 1) / stride));
1259
- const pages = document.createElement("div");
1260
- pages.className = "sixb-pages";
1261
- const sheets = Array.from({ length: count }, (_, index) => {
1262
- const page = document.createElement("article");
1263
- page.className = "sixb-paper";
1264
- page.dataset.page = String(index + 1);
1265
- page.setAttribute("aria-label", `Page ${index + 1} of ${count}`);
1266
- const content = document.createElement("div");
1267
- content.className = "sixb-paper-content";
1268
- if (index === 0)
1269
- content.append(cut);
1270
- page.append(content);
1271
- return page;
1272
- });
1273
- pages.append(...sheets);
1274
- body.replaceChildren(pages);
1275
- fitPages();
1276
- const shown = new Set;
1277
- sheetsInView = new IntersectionObserver((entries) => {
1278
- for (const entry of entries) {
1279
- const index = Number(entry.target.dataset.page) - 1;
1280
- if (entry.isIntersecting)
1281
- shown.add(index);
1282
- else
1283
- shown.delete(index);
1284
- }
1285
- for (const [index, sheet] of sheets.entries()) {
1286
- if (index === 0)
1287
- continue;
1288
- if ([...shown].some((each) => Math.abs(each - index) <= NEAR_PAGES))
1289
- pageCopy(index);
1290
- else
1291
- sheet.firstElementChild?.replaceChildren();
1292
- }
1293
- reportEmbeds();
1294
- });
1295
- for (const sheet of sheets)
1296
- sheetsInView.observe(sheet);
1297
- root.setAttribute("data-sixb-pages", String(count));
1298
- };
1299
- const markBreaks = () => {
1300
- const body = document.body;
1301
- if (!body)
1302
- return;
1303
- const divider = () => {
1304
- const element = document.createElement("div");
1305
- element.className = "sixb-page-break";
1306
- element.setAttribute("aria-hidden", "true");
1307
- return element;
1308
- };
1309
- const placed = (element) => element.previousElementSibling?.classList.contains("sixb-page-break") || element.previousElementSibling === null;
1310
- for (const element of Array.from(body.querySelectorAll("*"))) {
1311
- const parent = element.parentElement;
1312
- if (!parent || /flex|grid/.test(getComputedStyle(parent).display))
1313
- continue;
1314
- const style = getComputedStyle(element);
1315
- if (PAGE_BREAKS.includes(style.breakBefore) && !placed(element) && element.offsetTop > 0) {
1316
- element.before(divider());
1317
- }
1318
- const next = element.nextElementSibling;
1319
- if (PAGE_BREAKS.includes(style.breakAfter) && next && !placed(next))
1320
- element.after(divider());
1321
- }
1322
- };
1323
- const settled = () => {
1324
- const images = Array.from(document.images, (image) => {
1325
- if (paged)
1326
- image.loading = "eager";
1327
- return image.complete ? Promise.resolve() : image.decode().catch(() => {});
1328
- });
1329
- const fonts = document.fonts?.ready ?? Promise.resolve();
1330
- const loaded = Promise.all([fonts, ...images]).then(() => {});
1331
- return Promise.race([loaded, new Promise((resolve) => setTimeout(resolve, 5000))]);
1332
- };
1333
- const openSection = () => {
1334
- const section = start.get("sixb-section");
1335
- if (!section)
1336
- return;
1337
- shownCopy(`[data-sixb-section="${CSS.escape(section)}"]`)?.scrollIntoView({ block: "start" });
1338
- };
1339
- let height = -1;
1340
- const reportSize = () => {
1341
- const body = document.body;
1342
- if (deck || !body)
1343
- return;
1344
- const style = getComputedStyle(body);
1345
- const next = Math.ceil(Math.max(body.scrollHeight, body.getBoundingClientRect().height) + (Number.parseFloat(style.marginTop) || 0) + (Number.parseFloat(style.marginBottom) || 0));
1346
- if (next === height)
1347
- return;
1348
- height = next;
1349
- post({ event: "size", params: { height } });
1350
- };
1351
- const show = (slide) => {
1352
- const all = slides();
1353
- current = Math.min(Math.max(1, Math.round(slide) || 1), Math.max(1, all.length));
1354
- all.forEach((element, index) => {
1355
- element.toggleAttribute("data-current", index + 1 === current);
1356
- });
1357
- if (root.dataset.mode === "overview") {
1358
- all[current - 1]?.scrollIntoView({ block: "nearest" });
1359
- }
1360
- reportEmbeds();
1361
- };
1362
- const portPost = typeof MessagePort === "function" ? MessagePort.prototype.postMessage : undefined;
1363
- const apply = Reflect.apply;
1364
- let appPort = null;
1365
- const postPort = (message) => {
1366
- if (appPort && portPost)
1367
- apply(portPost, appPort, [{ protocol: PROTOCOL, ...message }]);
1368
- };
1369
- let editing = false;
1370
- let typable = true;
1371
- let pointed = null;
1372
- let picked = null;
1373
- let typing = null;
1374
- let held = null;
1375
- let typedFrom = "";
1376
- const wordsHash = (text) => {
1377
- let hash = 2166136261;
1378
- for (let index = 0;index < text.length; index += 1) {
1379
- hash ^= text.charCodeAt(index);
1380
- hash = Math.imul(hash, 16777619) >>> 0;
1381
- }
1382
- return hash.toString(16);
1383
- };
1384
- const spokenWords = (element) => {
1385
- const copy = element.cloneNode(true);
1386
- if (!(copy instanceof Element))
1387
- return element.textContent ?? "";
1388
- for (const lineBreak of Array.from(copy.querySelectorAll("br")))
1389
- lineBreak.replaceWith(" ");
1390
- for (const code of Array.from(copy.querySelectorAll("script, style, template")))
1391
- code.remove();
1392
- return copy.textContent ?? "";
1393
- };
1394
- const commentable = (element, node) => element ?? (!typable && node instanceof Element && node !== root && node !== document.body ? node : null);
1395
- const editTarget = (node) => {
1396
- const start = node instanceof Element ? node : null;
1397
- const element = start?.closest(`[${AT}]`) ?? null;
1398
- const box = (start ?? element)?.getBoundingClientRect();
1399
- const rect = {
1400
- x: box?.left ?? 0,
1401
- y: box?.top ?? 0,
1402
- width: box?.width ?? 0,
1403
- height: box?.height ?? 0
1404
- };
1405
- const kind = element?.getAttribute(KIND) ?? "";
1406
- const shown = start && start !== root && start !== document.body ? spokenWords(start).replace(/\s+/g, " ").trim() : "";
1407
- const scripted = {
1408
- address: null,
1409
- kind: "scripted",
1410
- within: element?.getAttribute(AT) ?? null,
1411
- ...shown ? { label: shown.slice(0, MAX_EDIT_LABEL) } : {},
1412
- rect
1413
- };
1414
- if (!element)
1415
- return { element: null, target: scripted };
1416
- if (element !== start && kind !== "text" && kind !== "whole") {
1417
- return { element: null, target: scripted };
1418
- }
1419
- const words = element.textContent ?? "";
1420
- if (kind === "text" && wordsHash(words) !== element.getAttribute(WORDS)) {
1421
- return { element: null, target: { ...scripted, within: element.getAttribute(AT) } };
1422
- }
1423
- const own = element.getBoundingClientRect();
1424
- const label = (kind === "image" ? element.getAttribute("alt") ?? "" : spokenWords(element)).replace(/\s+/g, " ").trim().slice(0, MAX_EDIT_LABEL);
1425
- return {
1426
- element,
1427
- target: {
1428
- address: element.getAttribute(AT),
1429
- kind,
1430
- label,
1431
- rect: { x: own.left, y: own.top, width: own.width, height: own.height }
1432
- }
1433
- };
1434
- };
1435
- const mark = (attribute, previous, next) => {
1436
- previous?.removeAttribute(attribute);
1437
- next?.setAttribute(attribute, "");
1438
- return next;
1439
- };
1440
- const collapseSpaces = (element) => {
1441
- const walker = document.createTreeWalker(element, 4);
1442
- const nodes = [];
1443
- while (walker.nextNode())
1444
- nodes.push(walker.currentNode);
1445
- let after = true;
1446
- const runs = [];
1447
- for (const node of nodes) {
1448
- for (const run of node.data.matchAll(/[ \t\n\r\f]+|[^ \t\n\r\f]+/g)) {
1449
- const index = run.index ?? 0;
1450
- if (!/^[ \t\n\r\f]/.test(run[0])) {
1451
- after = false;
1452
- continue;
1453
- }
1454
- const shown = after ? "" : " ";
1455
- if (run[0] !== shown)
1456
- runs.push({ node, start: index, length: run[0].length, with: shown });
1457
- after = true;
1458
- }
1459
- }
1460
- const last = runs.at(-1);
1461
- if (last && last.with === " " && last.start + last.length === last.node.data.length) {
1462
- const trailing = nodes.slice(nodes.indexOf(last.node) + 1).every((node) => node.data === "");
1463
- if (trailing)
1464
- last.with = "";
1465
- }
1466
- for (const run of runs.reverse())
1467
- run.node.replaceData(run.start, run.length, run.with);
1468
- };
1469
- const stopTyping = () => {
1470
- const element = typing;
1471
- if (!element)
1472
- return;
1473
- typing = null;
1474
- element.removeAttribute("contenteditable");
1475
- const patch = held;
1476
- held = null;
1477
- if (patch)
1478
- applyPatch(element, patch);
1479
- };
1480
- const applyPatch = (element, patch) => {
1481
- const attributes = patch.attributes;
1482
- if (attributes && typeof attributes === "object") {
1483
- const next = attributes;
1484
- for (const name of element.getAttributeNames()) {
1485
- if (!(name in next) && !name.startsWith("data-sixb-"))
1486
- element.removeAttribute(name);
1487
- }
1488
- for (const [name, value] of Object.entries(next)) {
1489
- if (typeof value === "string" && /^[a-z_:][a-z0-9_.:-]*$/i.test(name)) {
1490
- element.setAttribute(name, value);
1491
- }
1492
- }
1493
- }
1494
- if (typeof patch.html === "string")
1495
- element.innerHTML = patch.html;
1496
- };
1497
- const startEditing = (on, typingAllowed) => {
1498
- editing = on;
1499
- typable = typingAllowed;
1500
- if (!typable)
1501
- stopTyping();
1502
- root.toggleAttribute("data-sixb-editing", on);
1503
- root.toggleAttribute("data-sixb-commenting", on && !typable);
1504
- if (on && !document.getElementById("sixb-editing")) {
1505
- const style = document.createElement("style");
1506
- style.id = "sixb-editing";
1507
- style.textContent = EDITING_CSS;
1508
- document.head.append(style);
1509
- }
1510
- if (!on) {
1511
- stopTyping();
1512
- pointed = mark("data-sixb-hover", pointed, null);
1513
- picked = mark("data-sixb-picked", picked, null);
1514
- }
1515
- };
1516
- window.addEventListener("click", (event) => {
1517
- if (!editing || !event.isTrusted)
1518
- return;
1519
- if (typing?.contains(event.target))
1520
- return;
1521
- event.preventDefault();
1522
- event.stopPropagation();
1523
- stopTyping();
1524
- const { element, target } = editTarget(event.target);
1525
- picked = mark("data-sixb-picked", picked, commentable(element, event.target));
1526
- const at = { x: event.clientX, y: event.clientY };
1527
- postPort({ event: "edit.select", params: { target, at } });
1528
- if (typable && element instanceof HTMLElement && target.kind === "text") {
1529
- typing = element;
1530
- if (!/^(pre|pre-wrap|break-spaces)$/.test(getComputedStyle(element).whiteSpace)) {
1531
- collapseSpaces(element);
1532
- element.setAttribute(WORDS, wordsHash(element.textContent ?? ""));
1533
- }
1534
- typedFrom = element.textContent ?? "";
1535
- element.setAttribute("contenteditable", "plaintext-only");
1536
- element.focus();
1537
- }
1538
- }, true);
1539
- document.addEventListener("mouseover", (event) => {
1540
- if (!editing || !event.isTrusted)
1541
- return;
1542
- const { element, target } = editTarget(event.target);
1543
- const shown = commentable(element, event.target);
1544
- if (shown === pointed && shown !== null)
1545
- return;
1546
- pointed = mark("data-sixb-hover", pointed, shown);
1547
- postPort({ event: "edit.hover", params: { target } });
1548
- });
1549
- document.addEventListener("mouseout", (event) => {
1550
- if (!editing || !event.isTrusted || event.relatedTarget !== null || pointed === null)
1551
- return;
1552
- pointed = mark("data-sixb-hover", pointed, null);
1553
- postPort({ event: "edit.hover", params: { target: null } });
1554
- });
1555
- document.addEventListener("input", (event) => {
1556
- if (!editing || !event.isTrusted || !typing || !typing.contains(event.target)) {
1557
- return;
1558
- }
1559
- const text = typing.textContent ?? "";
1560
- typing.setAttribute(WORDS, wordsHash(text));
1561
- postPort({
1562
- event: "edit.text",
1563
- params: { address: typing.getAttribute(AT), base: typedFrom, text }
1564
- });
1565
- typedFrom = text;
1566
- });
1567
- window.addEventListener("keydown", (event) => {
1568
- if (!typing || !event.isTrusted)
1569
- return;
1570
- if (event.key === "Enter")
1571
- event.preventDefault();
1572
- if (event.key === "Escape")
1573
- typing.blur();
1574
- event.stopPropagation();
1575
- }, true);
1576
- document.addEventListener("focusout", (event) => {
1577
- if (typing && event.target === typing)
1578
- stopTyping();
1579
- });
1580
- const mac = /Mac|iPhone|iPad/.test(window.navigator?.platform ?? "");
1581
- const zoom = (params) => postPort({ event: "zoom", params });
1582
- const pan = (x, y, by) => postPort({ event: "pan", params: { x, y, by } });
1583
- const forwards = (event) => appPort !== null && event.isTrusted;
1584
- let onCanvas = false;
1585
- let canvasMoving = false;
1586
- const WHEEL_GESTURE_MS = 150;
1587
- const MIN_OVERFLOW = 16;
1588
- let wheeledAt = Number.NEGATIVE_INFINITY;
1589
- let wheelScrolls = false;
1590
- const scrollsUnder = (target, x, y) => {
1591
- const vertical = Math.abs(y) >= Math.abs(x);
1592
- const delta = vertical ? y : x;
1593
- if (delta === 0)
1594
- return false;
1595
- const overflowOf = (element) => getComputedStyle(element)[vertical ? "overflowY" : "overflowX"];
1596
- const scrolls = (size, shown, at) => size - shown >= MIN_OVERFLOW && (delta > 0 ? at + shown < size - 1 : at > 0);
1597
- for (let element = target instanceof Element ? target : null;element && element !== root && element !== document.body; element = element.parentElement) {
1598
- if (!/auto|scroll/.test(overflowOf(element)))
1599
- continue;
1600
- const scrolled = vertical ? scrolls(element.scrollHeight, element.clientHeight, element.scrollTop) : scrolls(element.scrollWidth, element.clientWidth, element.scrollLeft);
1601
- if (scrolled)
1602
- return true;
1603
- }
1604
- const page = document.scrollingElement;
1605
- if (!page || [root, document.body].some((each) => each && /hidden|clip/.test(overflowOf(each)))) {
1606
- return false;
1607
- }
1608
- return vertical ? scrolls(page.scrollHeight, window.innerHeight, window.scrollY) : scrolls(page.scrollWidth, window.innerWidth, window.scrollX);
1609
- };
1610
- window.addEventListener("wheel", (event) => {
1611
- if (!forwards(event))
1612
- return;
1613
- if (event.ctrlKey || event.metaKey) {
1614
- event.preventDefault();
1615
- const unit = event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002;
1616
- const factor = 2 ** (-event.deltaY * unit * (event.ctrlKey && mac ? 10 : 1));
1617
- zoom({ factor, at: { x: event.clientX, y: event.clientY } });
1618
- return;
1619
- }
1620
- if (!onCanvas)
1621
- return;
1622
- const unit = event.deltaMode === 1 ? 20 : event.deltaMode === 2 ? window.innerHeight : 1;
1623
- const x = (!mac && event.shiftKey ? event.deltaY : event.deltaX) * unit;
1624
- const y = !mac && event.shiftKey ? 0 : event.deltaY * unit;
1625
- if (event.timeStamp - wheeledAt > WHEEL_GESTURE_MS) {
1626
- wheelScrolls = !canvasMoving && scrollsUnder(event.target, x, y);
1627
- }
1628
- wheeledAt = event.timeStamp;
1629
- if (wheelScrolls)
1630
- return;
1631
- event.preventDefault();
1632
- pan(x, y, "wheel");
1633
- }, { passive: false });
1634
- const TOUCH_SLOP = 6;
1635
- let spread = 0;
1636
- let touched = null;
1637
- const spreadOf = (touches) => {
1638
- const [one, two] = [touches[0], touches[1]];
1639
- return one && two ? Math.hypot(one.screenX - two.screenX, one.screenY - two.screenY) : 0;
1640
- };
1641
- const middleOf = (touches) => {
1642
- const fingers = [touches[0], touches[1]].filter((touch) => touch !== undefined);
1643
- const sum = (axis) => fingers.reduce((total, touch) => total + touch[axis], 0) / Math.max(1, fingers.length);
1644
- return { x: sum("screenX"), y: sum("screenY") };
1645
- };
1646
- window.addEventListener("touchstart", (event) => {
1647
- const ours = forwards(event);
1648
- spread = ours && event.touches.length === 2 ? spreadOf(event.touches) : 0;
1649
- touched = ours && onCanvas ? { ...middleOf(event.touches), dragging: event.touches.length > 1 } : null;
1650
- }, { passive: true });
1651
- window.addEventListener("touchmove", (event) => {
1652
- if (!forwards(event))
1653
- return;
1654
- if (touched && event.touches.length <= 2) {
1655
- const middle = middleOf(event.touches);
1656
- const x = touched.x - middle.x;
1657
- const y = touched.y - middle.y;
1658
- if (!touched.dragging && Math.hypot(x, y) < TOUCH_SLOP)
1659
- return;
1660
- event.preventDefault();
1661
- touched = { ...middle, dragging: true };
1662
- if (x !== 0 || y !== 0)
1663
- pan(x, y, "touch");
1664
- }
1665
- if (event.touches.length !== 2 || spread === 0)
1666
- return;
1667
- event.preventDefault();
1668
- const [one, two] = [event.touches[0], event.touches[1]];
1669
- const next = spreadOf(event.touches);
1670
- if (!one || !two || next === 0)
1671
- return;
1672
- zoom({
1673
- factor: next / spread,
1674
- at: { x: (one.clientX + two.clientX) / 2, y: (one.clientY + two.clientY) / 2 }
1675
- });
1676
- spread = next;
1677
- }, { passive: false });
1678
- const untouch = (event) => {
1679
- if (event.touches.length < 2)
1680
- spread = 0;
1681
- if (touched)
1682
- touched = event.touches.length > 0 ? { ...middleOf(event.touches), dragging: true } : null;
1683
- };
1684
- window.addEventListener("touchend", untouch);
1685
- window.addEventListener("touchcancel", untouch);
1686
- let gestured = 1;
1687
- const onGesture = (event) => {
1688
- if (!forwards(event))
1689
- return;
1690
- event.preventDefault();
1691
- const gesture = event;
1692
- const scale = gesture.scale ?? 1;
1693
- if (event.type === "gesturestart" || spread > 0 || scale <= 0) {
1694
- gestured = scale > 0 ? scale : 1;
1695
- return;
1696
- }
1697
- zoom({ factor: scale / gestured, at: { x: gesture.clientX ?? 0, y: gesture.clientY ?? 0 } });
1698
- gestured = scale;
1699
- };
1700
- window.addEventListener("gesturestart", onGesture, { passive: false });
1701
- window.addEventListener("gesturechange", onGesture, { passive: false });
1702
- window.addEventListener("keydown", (event) => {
1703
- if (!forwards(event) || !(event.metaKey || event.ctrlKey) || event.altKey)
1704
- return;
1705
- const step = event.key === "=" || event.key === "+" ? "in" : event.key === "-" ? "out" : event.key === "0" ? "actual" : null;
1706
- if (!step)
1707
- return;
1708
- event.preventDefault();
1709
- zoom({ step });
1710
- }, true);
1711
- const SPACE_TAKERS = [
1712
- "input:not([type=button], [type=submit], [type=reset], [type=image])",
1713
- "textarea",
1714
- "select",
1715
- ...[
1716
- "checkbox",
1717
- "radio",
1718
- "switch",
1719
- "option",
1720
- "menuitemcheckbox",
1721
- "menuitemradio",
1722
- "textbox",
1723
- "searchbox",
1724
- "combobox",
1725
- "slider",
1726
- "spinbutton"
1727
- ].map((role) => `[role=${role}]`)
1728
- ].join(", ");
1729
- let spaceHeld = false;
1730
- const holdSpace = (down) => {
1731
- if (spaceHeld === down)
1732
- return;
1733
- spaceHeld = down;
1734
- postPort({ event: "space", params: { down } });
1735
- };
1736
- const onSpace = (event) => {
1737
- if (!onCanvas || !forwards(event) || event.key !== " ")
1738
- return;
1739
- if (event.metaKey || event.ctrlKey || event.altKey)
1740
- return;
1741
- const down = event.type === "keydown";
1742
- const focused = document.activeElement;
1743
- if (down && focused instanceof HTMLElement) {
1744
- if (focused.isContentEditable || focused.matches(SPACE_TAKERS))
1745
- return;
1746
- }
1747
- if (!down && !spaceHeld)
1748
- return;
1749
- event.preventDefault();
1750
- event.stopPropagation();
1751
- holdSpace(down);
1752
- };
1753
- window.addEventListener("keydown", onSpace, true);
1754
- window.addEventListener("keyup", onSpace, true);
1755
- window.addEventListener("blur", () => holdSpace(false));
1756
- let editorPort = null;
1757
- let editorOn = false;
1758
- const startEditor = (code) => {
1759
- if (editorOn)
1760
- throw new Error("The editor is already running.");
1761
- if (!designed || !new URLSearchParams(window.location.search).has("sixb-edit")) {
1762
- throw new Error("Only a designed document served for editing takes an editor.");
1763
- }
1764
- if (!editorPort || !document.body)
1765
- throw new Error("The editor needs its port and a body.");
1766
- const script = document.createElement("script");
1767
- script.textContent = code;
1768
- document.head.append(script);
1769
- script.remove();
1770
- const scope = window;
1771
- const start = scope[EDITOR_GLOBAL];
1772
- delete scope[EDITOR_GLOBAL];
1773
- if (typeof start !== "function")
1774
- throw new Error("The editor did not start.");
1775
- editorOn = true;
1776
- start({ port: editorPort, body: document.body });
1777
- };
1778
- const handle = (method, params) => {
1779
- switch (method) {
1780
- case "editor":
1781
- startEditor(String(params.code ?? ""));
1782
- return;
1783
- case "theme": {
1784
- const tokens = params.tokens ?? {};
1785
- const declarations = Object.entries(tokens).filter(([name, value]) => /^--[a-z0-9-]+$/.test(name) && typeof value === "string" && !/[;{}<]/.test(value)).map(([name, value]) => `${name}: ${value};`);
1786
- for (const [stage, token] of [
1787
- ["--sixb-stage", "--muted"],
1788
- ["--sixb-stage-border", "--border"],
1789
- ["--sixb-stage-foreground", "--foreground"]
1790
- ]) {
1791
- const value = declarations.find((declaration) => declaration.startsWith(`${token}:`));
1792
- if (value)
1793
- declarations.push(`${stage}${value.slice(token.length)}`);
1794
- }
1795
- let style = document.getElementById("sixb-theme");
1796
- if (!style) {
1797
- style = document.createElement("style");
1798
- style.id = "sixb-theme";
1799
- document.head.append(style);
1800
- }
1801
- style.textContent = `@layer sixb-theme { :root { ${declarations.join(" ")} color-scheme: ${params.dark === true ? "dark" : "light"}; } }`;
1802
- root.classList.toggle("dark", params.dark === true);
1803
- window.dispatchEvent(new CustomEvent("sixb:theme", { detail: { dark: params.dark === true } }));
1804
- return;
1805
- }
1806
- case "goto":
1807
- if (!deck)
1808
- throw new Error("Only a deck has slides.");
1809
- show(Number(params.slide));
1810
- return;
1811
- case "reload":
1812
- setTimeout(() => window.location.reload());
1813
- return;
1814
- case "query.changed": {
1815
- const name = String(params.name);
1816
- if (!QUERY_NAME.test(name))
1817
- throw new Error(`Unknown query '${name}'.`);
1818
- window.dispatchEvent(new CustomEvent("sixb:query", { detail: { name } }));
1819
- return;
1820
- }
1821
- case "edit":
1822
- startEditing(params.on === true, params.typing !== false);
1823
- return;
1824
- case "canvas":
1825
- onCanvas = true;
1826
- canvasMoving = params.moving === true;
1827
- if (!document.getElementById("sixb-canvas")) {
1828
- const style = document.createElement("style");
1829
- style.id = "sixb-canvas";
1830
- style.textContent = CANVAS_CSS;
1831
- document.head.append(style);
1832
- }
1833
- return;
1834
- case "edit.patch": {
1835
- const patches = Array.isArray(params.patches) ? params.patches : [];
1836
- for (const patch of patches) {
1837
- const address = typeof patch?.address === "string" ? patch.address : null;
1838
- const element = address ? document.querySelector(`[${AT}="${CSS.escape(address)}"]`) : null;
1839
- if (!element)
1840
- continue;
1841
- if (element === typing)
1842
- held = { ...held ?? {}, ...patch };
1843
- else
1844
- applyPatch(element, patch);
1845
- }
1846
- return;
1847
- }
1848
- case "scroll":
1849
- if (deck)
1850
- throw new Error("Only a page scrolls.");
1851
- window.scrollBy({ left: Number(params.x) || 0, top: Number(params.y) || 0 });
1852
- return;
1853
- case "mode":
1854
- if (!deck)
1855
- throw new Error("Only a deck has modes.");
1856
- if (root.dataset.mode === "fill")
1857
- return;
1858
- root.dataset.mode = params.mode === "overview" || params.mode === "present" ? params.mode : "slide";
1859
- fit();
1860
- show(current);
1861
- return;
1862
- default:
1863
- throw new Error(`Unknown method '${method}'.`);
1864
- }
1865
- };
1866
- const calls = new Map;
1867
- let called = 0;
1868
- const alone = window.parent === window;
1869
- const memory = new Map;
1870
- const call = (method, params) => {
1871
- if (alone) {
1872
- const key = String(params.key);
1873
- const kept = memory.get(key);
1874
- switch (method) {
1875
- case "state.get":
1876
- return Promise.resolve(kept === undefined ? undefined : JSON.parse(kept));
1877
- case "state.set":
1878
- memory.set(key, JSON.stringify(params.value));
1879
- return Promise.resolve(undefined);
1880
- case "state.delete":
1881
- return Promise.resolve(memory.delete(key));
1882
- default:
1883
- return Promise.resolve([...memory.keys()].sort());
1884
- }
1885
- }
1886
- called += 1;
1887
- const id = called;
1888
- return new Promise((resolve, reject) => {
1889
- calls.set(id, { resolve, reject });
1890
- post({ call: id, method, params });
1891
- });
1892
- };
1893
- const checkKey = (key) => {
1894
- if (typeof key !== "string" || key.length === 0 || key.length > MAX_KEY_LENGTH || key === "." || key === "..") {
1895
- throw new TypeError(`sixb.state: a key is text of 1 to ${MAX_KEY_LENGTH} characters.`);
1896
- }
1897
- return key;
1898
- };
1899
- const state = {
1900
- get: (key) => Promise.resolve().then(() => call("state.get", { key: checkKey(key) })),
1901
- set: (key, value) => Promise.resolve().then(() => {
1902
- const json = JSON.stringify(value);
1903
- if (json === undefined) {
1904
- throw new TypeError("sixb.state: a value is JSON: text, a number, true or false, null, a list, or an object.");
1905
- }
1906
- if (new TextEncoder().encode(json).byteLength > MAX_VALUE_BYTES) {
1907
- throw new RangeError(`sixb.state: a value is at most ${MAX_VALUE_BYTES / 1024} KB as JSON.`);
1908
- }
1909
- return call("state.set", { key: checkKey(key), value: JSON.parse(json) }).then(() => {});
1910
- }),
1911
- delete: (key) => Promise.resolve().then(() => call("state.delete", { key: checkKey(key) })),
1912
- keys: () => call("state.keys", {})
1913
- };
1914
- const readQueryFile = async (name) => {
1915
- const base = script?.src || new URL("__sixb/runtime.js", window.location.href).href;
1916
- const response = await fetch(new URL(`queries/${name}.json`, base));
1917
- if (response.ok)
1918
- return response.json();
1919
- if (response.status === 404) {
1920
- throw new Error(`[Sixb] No query '${name}' in this page's version.`);
1921
- }
1922
- const body = await response.json().catch(() => null);
1923
- throw new Error(typeof body?.error === "string" ? body.error : `[Sixb] Query '${name}' could not be read.`);
1924
- };
1925
- const query = (name) => Promise.resolve().then(() => {
1926
- if (typeof name !== "string" || !QUERY_NAME.test(name)) {
1927
- throw new TypeError("sixb.query: a query's name is that of its file, queries/<name>.json: lowercase letters, digits and hyphens.");
1928
- }
1929
- return alone ? readQueryFile(name) : call("query.run", { name });
1930
- });
1931
- Object.defineProperty(window, "sixb", {
1932
- value: Object.freeze({ state: Object.freeze(state), query }),
1933
- enumerable: true
1934
- });
1935
- window.addEventListener("message", (event) => {
1936
- if (event.source !== window.parent)
1937
- return;
1938
- const data = event.data;
1939
- if (data && data.protocol === PROTOCOL && typeof data.result === "number") {
1940
- const pending = calls.get(data.result);
1941
- calls.delete(data.result);
1942
- if (typeof data.error === "string")
1943
- pending?.reject(new Error(data.error));
1944
- else
1945
- pending?.resolve(data.value);
1946
- return;
1947
- }
1948
- if (!data || data.protocol !== PROTOCOL || typeof data.id !== "number")
1949
- return;
1950
- if (typeof data.method !== "string")
1951
- return;
1952
- event.stopImmediatePropagation();
1953
- const port = event.ports?.[0];
1954
- if ((data.method === "edit" || data.method === "canvas") && port)
1955
- appPort = port;
1956
- if (data.method === "editor" && port)
1957
- editorPort = port;
1958
- try {
1959
- handle(String(data.method), data.params ?? {});
1960
- post({ id: data.id });
1961
- } catch (error) {
1962
- post({ id: data.id, error: error instanceof Error ? error.message : String(error) });
1963
- }
1964
- }, true);
1965
- window.addEventListener("keydown", (event) => {
1966
- if (!deck || event.metaKey || event.ctrlKey || event.altKey)
1967
- return;
1968
- const target = event.target;
1969
- if (target?.closest("input, textarea, select, [contenteditable]"))
1970
- return;
1971
- if (!KEYS.includes(event.key))
1972
- return;
1973
- event.preventDefault();
1974
- post({ event: "key", params: { key: event.key } });
1975
- });
1976
- document.addEventListener("click", (event) => {
1977
- if (editorOn)
1978
- return;
1979
- const target = event.target;
1980
- const pressed = target?.closest('button, [role="button"], a[href^="#"]');
1981
- const words = (pressed?.innerText ?? pressed?.textContent ?? "").replace(/\s+/g, " ").trim();
1982
- if (words && words.length <= MAX_LABEL_LENGTH) {
1983
- post({ event: "press", params: { text: words } });
1984
- if (onCanvas && event.isTrusted)
1985
- postPort({ event: "press", params: { text: words } });
1986
- }
1987
- const link = target?.closest("a[href]");
1988
- if (link) {
1989
- const href = link.getAttribute("href") ?? "";
1990
- if (paged && href.length > 1 && href.startsWith("#") && !event.defaultPrevented) {
1991
- const id = decodeURIComponent(href.slice(1));
1992
- const shown = shownCopy(`[id="${CSS.escape(id)}"], [name="${CSS.escape(id)}"]`);
1993
- if (shown) {
1994
- event.preventDefault();
1995
- shown.scrollIntoView({ block: "start" });
1996
- }
1997
- return;
1998
- }
1999
- if (href.startsWith("#") || event.defaultPrevented)
2000
- return;
2001
- event.preventDefault();
2002
- if (/^artifact:/i.test(href.trim())) {
2003
- post({ event: "open", params: { address: href.trim() } });
2004
- return;
2005
- }
2006
- const url = webAddress(href);
2007
- if (url)
2008
- post({ event: "link", params: { url } });
2009
- return;
2010
- }
2011
- if (!deck || root.dataset.mode !== "overview")
2012
- return;
2013
- const slide = target?.closest("section.slide");
2014
- if (!slide)
2015
- return;
2016
- post({ event: "select", params: { slide: slides().indexOf(slide) + 1 } });
2017
- });
2018
- window.addEventListener("resize", () => {
2019
- if (deck)
2020
- fit();
2021
- if (paged)
2022
- fitPages();
2023
- reportEmbeds();
2024
- });
2025
- const live = designed && data && !new URLSearchParams(window.location.search).has("sixb-edit") ? data() : null;
2026
- const tree = {
2027
- children: (node) => Array.from(node.children),
2028
- attribute: (node, name) => node.getAttribute(name),
2029
- setAttribute: (node, name, value) => node.setAttribute(name, value),
2030
- removeAttribute: (node, name) => node.removeAttribute(name),
2031
- setText: (node, text) => {
2032
- node.textContent = text;
2033
- },
2034
- clone: (node) => node.cloneNode(true),
2035
- replace: (node, nodes) => node.replaceWith(...nodes)
2036
- };
2037
- let published = null;
2038
- let reads = null;
2039
- let showing = 0;
2040
- const showData = async () => {
2041
- const body = document.body;
2042
- if (!live || !body)
2043
- return false;
2044
- reads ??= live.reads(live.marks(body, tree));
2045
- if (!reads.holder && reads.queries.length === 0)
2046
- return false;
2047
- published ??= body.cloneNode(true);
2048
- const read = ++showing;
2049
- const answer = (name) => query(name).then((result) => result, () => {
2050
- return;
2051
- });
2052
- const [holder, ...results] = await Promise.all([
2053
- reads.holder ? answer("holder") : undefined,
2054
- ...reads.queries.map(answer)
2055
- ]);
2056
- if (read !== showing)
2057
- return false;
2058
- const queries = {};
2059
- reads.queries.forEach((name, index) => {
2060
- const result = results[index];
2061
- if (result)
2062
- queries[name] = result;
2063
- });
2064
- const row = holder?.objects?.[0];
2065
- body.replaceChildren(...Array.from(published.cloneNode(true).childNodes));
2066
- live.fill(body, tree, {
2067
- sources: { ...row ? { holder: row } : {}, queries },
2068
- lang: root.lang
2069
- });
2070
- return true;
2071
- };
2072
- if (live) {
2073
- window.addEventListener("sixb:query", (event) => {
2074
- const name = event.detail?.name;
2075
- const shows = name === "holder" ? reads?.holder : reads?.queries.includes(String(name));
2076
- if (!shows)
2077
- return;
2078
- showData().then(async (shown) => {
2079
- if (!shown)
2080
- return;
2081
- if (paged) {
2082
- if (!root.hasAttribute("data-sixb-pages"))
2083
- return;
2084
- await settled();
2085
- paginate();
2086
- } else {
2087
- markBreaks();
2088
- }
2089
- reportSize();
2090
- reportEmbeds();
2091
- });
2092
- });
2093
- }
2094
- const ready = () => {
2095
- if (paged) {
2096
- showData().then(settled).then(() => {
2097
- paginate();
2098
- openSection();
2099
- reportSize();
2100
- reportEmbeds();
2101
- });
2102
- } else if (designed) {
2103
- showData().then(() => {
2104
- markBreaks();
2105
- settled().then(openSection);
2106
- });
2107
- }
2108
- if (!deck) {
2109
- post({ event: "ready", params: {} });
2110
- window.addEventListener("scroll", reportEmbeds, { passive: true });
2111
- const resized = new ResizeObserver(() => {
2112
- reportSize();
2113
- reportEmbeds();
2114
- });
2115
- resized.observe(document.documentElement);
2116
- if (document.body)
2117
- resized.observe(document.body);
2118
- window.addEventListener("load", () => {
2119
- reportSize();
2120
- reportEmbeds();
2121
- });
2122
- reportSize();
2123
- reportEmbeds();
2124
- return;
2125
- }
2126
- slides().forEach((element, index) => {
2127
- element.dataset.number = String(index + 1);
2128
- });
2129
- fit();
2130
- show(current);
2131
- post({ event: "ready", params: { slides: slides().length } });
2132
- const resized = new ResizeObserver(reportEmbeds);
2133
- for (const element of Array.from(document.querySelectorAll("section.slide > *, sixb-embed"))) {
2134
- resized.observe(element);
2135
- }
2136
- window.addEventListener("load", reportEmbeds);
2137
- document.fonts?.ready.then(reportEmbeds);
2138
- };
2139
- if (document.readyState === "loading")
2140
- document.addEventListener("DOMContentLoaded", ready);
2141
- else
2142
- ready();
2143
- }
2144
-
2145
- // src/artifacts/frames/assets.ts
2146
- var FRAME_CDN_ALLOWLIST2 = [
2147
- "https://cdn.jsdelivr.net",
2148
- "https://cdnjs.cloudflare.com",
2149
- "https://unpkg.com",
2150
- "https://fonts.googleapis.com",
2151
- "https://fonts.gstatic.com"
2152
- ];
2153
- var FRAME_ASSETS2 = {
2154
- [`${FRAME_ASSET_PREFIX}deck.css`]: { body: FRAME_DECK_CSS, type: "text/css; charset=utf-8" },
2155
- [`${FRAME_ASSET_PREFIX}page.css`]: { body: FRAME_PAGE_CSS, type: "text/css; charset=utf-8" },
2156
- [`${FRAME_ASSET_PREFIX}document.css`]: {
2157
- body: FRAME_DOCUMENT_CSS,
2158
- type: "text/css; charset=utf-8"
2159
- },
2160
- [`${FRAME_ASSET_PREFIX}runtime.js`]: {
2161
- body: `(${frameRuntime.toString()})(${documentData.toString()})
2162
- `,
2163
- type: "text/javascript; charset=utf-8"
2164
- }
2165
- };
2166
- function injected(layout, base, paper) {
2167
- const sheet = paper ? ` data-sixb-paper="${[paper.width, paper.height, paper.margin.top, paper.margin.right, paper.margin.bottom, paper.margin.left].join(" ")}"` : "";
2168
- return `<link rel="stylesheet" href="${base}${FRAME_ASSET_PREFIX}${layout}.css"><script src="${base}${FRAME_ASSET_PREFIX}runtime.js" data-sixb-layout="${layout}"${sheet}></script>`;
2169
- }
2170
- function rootOf(entry) {
2171
- return "../".repeat(entry.split("/").length - 1);
2172
- }
2173
- function injectFrameAssets2(html, layout, entry = "index.html", paper) {
2174
- const assets = injected(layout, rootOf(entry), paper);
2175
- for (const selector of ["head", "html"]) {
2176
- let injected = false;
2177
- const rewritten = new HTMLRewriter().on(selector, {
2178
- element(element) {
2179
- if (injected)
2180
- return;
2181
- injected = true;
2182
- element.prepend(assets, { html: true });
2183
- }
2184
- }).transform(html);
2185
- if (injected)
2186
- return rewritten;
2187
- }
2188
- const doctype = /^\s*<!doctype[^>]*>/i.exec(html)?.[0] ?? "";
2189
- return `${doctype}${assets}${html.slice(doctype.length)}`;
2190
- }
2191
- function markDocumentSections2(html, headings) {
2192
- let index = 0;
2193
- return new HTMLRewriter().on("h1, h2, h3, h4, h5, h6", {
2194
- element(element) {
2195
- const heading = headings[index];
2196
- index += 1;
2197
- if (heading?.slug)
2198
- element.setAttribute("data-sixb-section", heading.slug);
2199
- }
2200
- }).transform(html);
2201
- }
2202
- var FRAME_REFERENCE_PREFIX2 = `${FRAME_ASSET_PREFIX}ref/`;
2203
- var FRAME_REFERENCE_PATH2 = /^([^/@]+)@(\d+|latest)\/(.+)$/;
2204
- function frameReferencePath(target, entry) {
2205
- const file = parseArtifactAddress2(target.address)?.path;
2206
- if (!file)
2207
- return null;
2208
- const path = file.split("/").map(encodeURIComponent).join("/");
2209
- return `${rootOf(entry)}${FRAME_REFERENCE_PREFIX2}${target.artifactId}@${target.version}/${path}`;
2210
- }
2211
- function rewriteFrameReferences2(html, targets, entry = "index.html") {
2212
- return new HTMLRewriter().on("img[src]", {
2213
- element(element) {
2214
- const source = decodeHtmlEntities(element.getAttribute("src") ?? "").trim();
2215
- if (!isArtifactAddress2(source))
2216
- return;
2217
- const target = targets.find((candidate) => candidate.address === source);
2218
- const path = target ? frameReferencePath(target, entry) : null;
2219
- if (path) {
2220
- element.setAttribute("src", path);
2221
- element.setAttribute("data-sixb-ref", "");
2222
- } else {
2223
- element.removeAttribute("src");
2224
- element.setAttribute("data-sixb-ref", "unavailable");
2225
- }
2226
- }
2227
- }).transform(html);
2228
- }
2229
-
2230
- // src/objects/serialize.ts
2231
- function serializeObject2(row) {
2232
- return {
2233
- ...row.score === undefined ? {} : { score: row.score },
2234
- primaryId: row.primaryId,
2235
- objectTypeId: row.objectTypeId,
2236
- properties: row.properties,
2237
- ...row.redactions === undefined ? {} : { redactions: row.redactions },
2238
- createdAt: row.createdAt.toISOString(),
2239
- updatedAt: row.updatedAt.toISOString()
2240
- };
2241
- }
2242
- function serializeExpandedObject2(row) {
2243
- const serialized = serializeObject2(row);
2244
- if (row.links)
2245
- serialized.links = serializeLinks(row.links);
2246
- if (row.linkProperties !== undefined)
2247
- serialized.linkProperties = row.linkProperties;
2248
- if (row.users)
2249
- serialized.users = row.users;
2250
- return serialized;
2251
- }
2252
- function serializeLinks(links) {
2253
- const result = {};
2254
- for (const [linkId, value] of Object.entries(links)) {
2255
- result[linkId] = serializeLinkValue(value);
2256
- }
2257
- return result;
2258
- }
2259
- function serializeLinkValue(value) {
2260
- if (value === null)
2261
- return null;
2262
- if (Array.isArray(value))
2263
- return value.map(serializeExpandedObject2);
2264
- return serializeExpandedObject2(value);
2265
- }
2266
-
2267
- // src/artifacts/serialize-query.ts
2268
- function serializeArtifactQueryResult2(result) {
2269
- return result.kind === "objects" ? { ...result, objects: result.objects.map(serializeExpandedObject2) } : result;
2270
- }
2271
-
2272
- export { ArtifactRequestError2, documentData, documentMarks, fillDocumentHtml, frozenDocumentHtml2, checkArtifactFiles, readArtifactText, invalidArtifact, decodeHtmlEntities, HTML_ENTRY2, refuseFrameAssetPaths, readHtmlReferences, FRAME_DEFAULT_THEMES2, FRAME_CDN_ALLOWLIST2, FRAME_ASSETS2, injectFrameAssets2, markDocumentSections2, FRAME_REFERENCE_PREFIX2, FRAME_REFERENCE_PATH2, rewriteFrameReferences2, serializeObject2, serializeExpandedObject2, serializeArtifactQueryResult2 };
2273
-
2274
- //# debugId=2AD526FA661FD3B264756E2164756E21