mergestory 0.0.0-stage → 1.0.0

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 (474) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +2 -0
  3. package/README.md +48 -2
  4. package/assets/kokoro-plugin/package-lock.json +1139 -0
  5. package/dist/analyzer/analyze.d.ts +8 -0
  6. package/dist/analyzer/analyze.js +328 -0
  7. package/dist/analyzer/components.d.ts +18 -0
  8. package/dist/analyzer/components.js +266 -0
  9. package/dist/analyzer/dependencies.d.ts +13 -0
  10. package/dist/analyzer/dependencies.js +349 -0
  11. package/dist/analyzer/evidence.d.ts +15 -0
  12. package/dist/analyzer/evidence.js +73 -0
  13. package/dist/analyzer/hunks.d.ts +21 -0
  14. package/dist/analyzer/hunks.js +88 -0
  15. package/dist/analyzer/imports.d.ts +46 -0
  16. package/dist/analyzer/imports.js +87 -0
  17. package/dist/analyzer/index.d.ts +14 -0
  18. package/dist/analyzer/index.js +16 -0
  19. package/dist/analyzer/languages/go.d.ts +2 -0
  20. package/dist/analyzer/languages/go.js +76 -0
  21. package/dist/analyzer/languages/index.d.ts +18 -0
  22. package/dist/analyzer/languages/index.js +72 -0
  23. package/dist/analyzer/languages/javascript.d.ts +2 -0
  24. package/dist/analyzer/languages/javascript.js +336 -0
  25. package/dist/analyzer/languages/jvm.d.ts +2 -0
  26. package/dist/analyzer/languages/jvm.js +157 -0
  27. package/dist/analyzer/languages/others.d.ts +2 -0
  28. package/dist/analyzer/languages/others.js +40 -0
  29. package/dist/analyzer/languages/php.d.ts +2 -0
  30. package/dist/analyzer/languages/php.js +81 -0
  31. package/dist/analyzer/languages/python.d.ts +2 -0
  32. package/dist/analyzer/languages/python.js +180 -0
  33. package/dist/analyzer/languages/ruby.d.ts +2 -0
  34. package/dist/analyzer/languages/ruby.js +99 -0
  35. package/dist/analyzer/languages/rust.d.ts +2 -0
  36. package/dist/analyzer/languages/rust.js +164 -0
  37. package/dist/analyzer/languages/shared.d.ts +35 -0
  38. package/dist/analyzer/languages/shared.js +43 -0
  39. package/dist/analyzer/languages/types.d.ts +78 -0
  40. package/dist/analyzer/languages/types.js +2 -0
  41. package/dist/analyzer/pack-format.d.ts +27 -0
  42. package/dist/analyzer/pack-format.js +139 -0
  43. package/dist/analyzer/pack.d.ts +26 -0
  44. package/dist/analyzer/pack.js +498 -0
  45. package/dist/analyzer/relationships.d.ts +17 -0
  46. package/dist/analyzer/relationships.js +34 -0
  47. package/dist/analyzer/risk-rules.d.ts +287 -0
  48. package/dist/analyzer/risk-rules.js +373 -0
  49. package/dist/analyzer/risks.d.ts +36 -0
  50. package/dist/analyzer/risks.js +480 -0
  51. package/dist/analyzer/roles.d.ts +11 -0
  52. package/dist/analyzer/roles.js +280 -0
  53. package/dist/analyzer/scan.d.ts +26 -0
  54. package/dist/analyzer/scan.js +157 -0
  55. package/dist/analyzer/signals.d.ts +20 -0
  56. package/dist/analyzer/signals.js +51 -0
  57. package/dist/analyzer/symbol-changes.d.ts +11 -0
  58. package/dist/analyzer/symbol-changes.js +101 -0
  59. package/dist/analyzer/symbol-types.d.ts +17 -0
  60. package/dist/analyzer/symbol-types.js +9 -0
  61. package/dist/analyzer/symbols.d.ts +4 -0
  62. package/dist/analyzer/symbols.js +16 -0
  63. package/dist/analyzer/trivial.d.ts +13 -0
  64. package/dist/analyzer/trivial.js +137 -0
  65. package/dist/analyzer/util.d.ts +6 -0
  66. package/dist/analyzer/util.js +24 -0
  67. package/dist/cli/commands/authoring.d.ts +9 -0
  68. package/dist/cli/commands/authoring.js +98 -0
  69. package/dist/cli/commands/cache.d.ts +4 -0
  70. package/dist/cli/commands/cache.js +37 -0
  71. package/dist/cli/commands/doctor.d.ts +5 -0
  72. package/dist/cli/commands/doctor.js +37 -0
  73. package/dist/cli/commands/generate.d.ts +8 -0
  74. package/dist/cli/commands/generate.js +69 -0
  75. package/dist/cli/commands/jobs.d.ts +8 -0
  76. package/dist/cli/commands/jobs.js +70 -0
  77. package/dist/cli/commands/publish.d.ts +8 -0
  78. package/dist/cli/commands/publish.js +120 -0
  79. package/dist/cli/commands/serve.d.ts +4 -0
  80. package/dist/cli/commands/serve.js +69 -0
  81. package/dist/cli/commands/setup.d.ts +14 -0
  82. package/dist/cli/commands/setup.js +108 -0
  83. package/dist/cli/commands/shared.d.ts +18 -0
  84. package/dist/cli/commands/shared.js +24 -0
  85. package/dist/cli/files.d.ts +26 -0
  86. package/dist/cli/files.js +98 -0
  87. package/dist/cli/format.d.ts +55 -0
  88. package/dist/cli/format.js +295 -0
  89. package/dist/cli/inputs.d.ts +23 -0
  90. package/dist/cli/inputs.js +96 -0
  91. package/dist/cli/io.d.ts +19 -0
  92. package/dist/cli/io.js +31 -0
  93. package/dist/cli/main.d.ts +2 -0
  94. package/dist/cli/main.js +15 -0
  95. package/dist/cli/options.d.ts +105 -0
  96. package/dist/cli/options.js +324 -0
  97. package/dist/cli/program.d.ts +12 -0
  98. package/dist/cli/program.js +146 -0
  99. package/dist/cli/runtime.d.ts +59 -0
  100. package/dist/cli/runtime.js +83 -0
  101. package/dist/cli/style.d.ts +13 -0
  102. package/dist/cli/style.js +27 -0
  103. package/dist/core/binaries.d.ts +7 -0
  104. package/dist/core/binaries.js +33 -0
  105. package/dist/core/binary-paths.d.ts +5 -0
  106. package/dist/core/binary-paths.js +92 -0
  107. package/dist/core/cache.d.ts +14 -0
  108. package/dist/core/cache.js +43 -0
  109. package/dist/core/child-env.d.ts +9 -0
  110. package/dist/core/child-env.js +61 -0
  111. package/dist/core/concurrency.d.ts +13 -0
  112. package/dist/core/concurrency.js +58 -0
  113. package/dist/core/config.d.ts +223 -0
  114. package/dist/core/config.js +454 -0
  115. package/dist/core/context.d.ts +39 -0
  116. package/dist/core/context.js +44 -0
  117. package/dist/core/cost.d.ts +46 -0
  118. package/dist/core/cost.js +108 -0
  119. package/dist/core/diagram-metrics.d.ts +57 -0
  120. package/dist/core/diagram-metrics.js +63 -0
  121. package/dist/core/diff-view.d.ts +44 -0
  122. package/dist/core/diff-view.js +136 -0
  123. package/dist/core/errors.d.ts +47 -0
  124. package/dist/core/errors.js +94 -0
  125. package/dist/core/ids.d.ts +11 -0
  126. package/dist/core/ids.js +36 -0
  127. package/dist/core/json.d.ts +8 -0
  128. package/dist/core/json.js +17 -0
  129. package/dist/core/languages.d.ts +19 -0
  130. package/dist/core/languages.js +292 -0
  131. package/dist/core/logger.d.ts +29 -0
  132. package/dist/core/logger.js +68 -0
  133. package/dist/core/net.d.ts +16 -0
  134. package/dist/core/net.js +80 -0
  135. package/dist/core/path-policy.d.ts +20 -0
  136. package/dist/core/path-policy.js +202 -0
  137. package/dist/core/paths.d.ts +18 -0
  138. package/dist/core/paths.js +53 -0
  139. package/dist/core/posix.d.ts +12 -0
  140. package/dist/core/posix.js +50 -0
  141. package/dist/core/process.d.ts +22 -0
  142. package/dist/core/process.js +117 -0
  143. package/dist/core/providers.d.ts +204 -0
  144. package/dist/core/providers.js +2 -0
  145. package/dist/core/redact.d.ts +11 -0
  146. package/dist/core/redact.js +70 -0
  147. package/dist/core/render-plan.d.ts +307 -0
  148. package/dist/core/render-plan.js +7 -0
  149. package/dist/core/retry.d.ts +54 -0
  150. package/dist/core/retry.js +116 -0
  151. package/dist/core/run-folder.d.ts +74 -0
  152. package/dist/core/run-folder.js +129 -0
  153. package/dist/core/secrets.d.ts +56 -0
  154. package/dist/core/secrets.js +301 -0
  155. package/dist/core/storyboard-facts.d.ts +22 -0
  156. package/dist/core/storyboard-facts.js +61 -0
  157. package/dist/core/storyboard-schema.d.ts +1279 -0
  158. package/dist/core/storyboard-schema.js +342 -0
  159. package/dist/core/text.d.ts +43 -0
  160. package/dist/core/text.js +94 -0
  161. package/dist/core/types.d.ts +459 -0
  162. package/dist/core/types.js +17 -0
  163. package/dist/doctor/check.d.ts +6 -0
  164. package/dist/doctor/check.js +18 -0
  165. package/dist/doctor/deps.d.ts +2 -0
  166. package/dist/doctor/deps.js +90 -0
  167. package/dist/doctor/format.d.ts +9 -0
  168. package/dist/doctor/format.js +19 -0
  169. package/dist/doctor/github.d.ts +2 -0
  170. package/dist/doctor/github.js +13 -0
  171. package/dist/doctor/home.d.ts +2 -0
  172. package/dist/doctor/home.js +26 -0
  173. package/dist/doctor/index.d.ts +18 -0
  174. package/dist/doctor/index.js +81 -0
  175. package/dist/doctor/llm.d.ts +2 -0
  176. package/dist/doctor/llm.js +32 -0
  177. package/dist/doctor/publish.d.ts +2 -0
  178. package/dist/doctor/publish.js +16 -0
  179. package/dist/doctor/s3.d.ts +2 -0
  180. package/dist/doctor/s3.js +125 -0
  181. package/dist/doctor/speech.d.ts +2 -0
  182. package/dist/doctor/speech.js +112 -0
  183. package/dist/doctor/tools.d.ts +5 -0
  184. package/dist/doctor/tools.js +58 -0
  185. package/dist/doctor/types.d.ts +92 -0
  186. package/dist/doctor/types.js +2 -0
  187. package/dist/doctor/youtube.d.ts +2 -0
  188. package/dist/doctor/youtube.js +73 -0
  189. package/dist/github/client.d.ts +108 -0
  190. package/dist/github/client.js +499 -0
  191. package/dist/github/errors.d.ts +37 -0
  192. package/dist/github/errors.js +155 -0
  193. package/dist/github/index.d.ts +13 -0
  194. package/dist/github/index.js +9 -0
  195. package/dist/github/linked-issues.d.ts +37 -0
  196. package/dist/github/linked-issues.js +131 -0
  197. package/dist/github/model.d.ts +81 -0
  198. package/dist/github/model.js +114 -0
  199. package/dist/github/notify.d.ts +27 -0
  200. package/dist/github/notify.js +118 -0
  201. package/dist/github/pr-url.d.ts +27 -0
  202. package/dist/github/pr-url.js +122 -0
  203. package/dist/github/token.d.ts +16 -0
  204. package/dist/github/token.js +69 -0
  205. package/dist/index.d.ts +29 -0
  206. package/dist/index.js +19 -0
  207. package/dist/jobs/input-rules.d.ts +20 -0
  208. package/dist/jobs/input-rules.js +100 -0
  209. package/dist/jobs/model.d.ts +47 -0
  210. package/dist/jobs/model.js +18 -0
  211. package/dist/jobs/runner.d.ts +43 -0
  212. package/dist/jobs/runner.js +165 -0
  213. package/dist/jobs/store.d.ts +67 -0
  214. package/dist/jobs/store.js +314 -0
  215. package/dist/jobs/view.d.ts +48 -0
  216. package/dist/jobs/view.js +111 -0
  217. package/dist/jobs/worker.d.ts +24 -0
  218. package/dist/jobs/worker.js +47 -0
  219. package/dist/llm/anthropic.d.ts +11 -0
  220. package/dist/llm/anthropic.js +225 -0
  221. package/dist/llm/index.d.ts +10 -0
  222. package/dist/llm/index.js +27 -0
  223. package/dist/llm/openai-compatible.d.ts +33 -0
  224. package/dist/llm/openai-compatible.js +378 -0
  225. package/dist/llm/prices.d.ts +26 -0
  226. package/dist/llm/prices.js +41 -0
  227. package/dist/llm/shared.d.ts +30 -0
  228. package/dist/llm/shared.js +115 -0
  229. package/dist/narration/assemble.d.ts +36 -0
  230. package/dist/narration/assemble.js +282 -0
  231. package/dist/narration/audio.d.ts +61 -0
  232. package/dist/narration/audio.js +301 -0
  233. package/dist/narration/captions.d.ts +37 -0
  234. package/dist/narration/captions.js +195 -0
  235. package/dist/narration/chunking.d.ts +6 -0
  236. package/dist/narration/chunking.js +46 -0
  237. package/dist/narration/convert.d.ts +9 -0
  238. package/dist/narration/convert.js +90 -0
  239. package/dist/narration/elevenlabs.d.ts +5 -0
  240. package/dist/narration/elevenlabs.js +53 -0
  241. package/dist/narration/http-errors.d.ts +14 -0
  242. package/dist/narration/http-errors.js +74 -0
  243. package/dist/narration/index.d.ts +21 -0
  244. package/dist/narration/index.js +22 -0
  245. package/dist/narration/kokoro-install.d.ts +30 -0
  246. package/dist/narration/kokoro-install.js +284 -0
  247. package/dist/narration/kokoro-model.d.ts +54 -0
  248. package/dist/narration/kokoro-model.js +168 -0
  249. package/dist/narration/kokoro-plugin.d.ts +78 -0
  250. package/dist/narration/kokoro-plugin.js +245 -0
  251. package/dist/narration/kokoro.d.ts +22 -0
  252. package/dist/narration/kokoro.js +231 -0
  253. package/dist/narration/openai.d.ts +4 -0
  254. package/dist/narration/openai.js +54 -0
  255. package/dist/narration/pricing.d.ts +8 -0
  256. package/dist/narration/pricing.js +17 -0
  257. package/dist/narration/remote-speech.d.ts +53 -0
  258. package/dist/narration/remote-speech.js +100 -0
  259. package/dist/narration/say.d.ts +28 -0
  260. package/dist/narration/say.js +178 -0
  261. package/dist/narration/select.d.ts +27 -0
  262. package/dist/narration/select.js +80 -0
  263. package/dist/narration/silent.d.ts +2 -0
  264. package/dist/narration/silent.js +18 -0
  265. package/dist/narration/speakable.d.ts +20 -0
  266. package/dist/narration/speakable.js +398 -0
  267. package/dist/narration/synthesize.d.ts +25 -0
  268. package/dist/narration/synthesize.js +220 -0
  269. package/dist/narration/wav.d.ts +37 -0
  270. package/dist/narration/wav.js +170 -0
  271. package/dist/pipeline/authoring.d.ts +8 -0
  272. package/dist/pipeline/authoring.js +117 -0
  273. package/dist/pipeline/commands.d.ts +9 -0
  274. package/dist/pipeline/commands.js +21 -0
  275. package/dist/pipeline/fit-duration.d.ts +41 -0
  276. package/dist/pipeline/fit-duration.js +150 -0
  277. package/dist/pipeline/index.d.ts +9 -0
  278. package/dist/pipeline/index.js +9 -0
  279. package/dist/pipeline/inputs.d.ts +42 -0
  280. package/dist/pipeline/inputs.js +171 -0
  281. package/dist/pipeline/plan.d.ts +8 -0
  282. package/dist/pipeline/plan.js +85 -0
  283. package/dist/pipeline/planned-egress.d.ts +21 -0
  284. package/dist/pipeline/planned-egress.js +43 -0
  285. package/dist/pipeline/prepare.d.ts +26 -0
  286. package/dist/pipeline/prepare.js +84 -0
  287. package/dist/pipeline/presentation.d.ts +26 -0
  288. package/dist/pipeline/presentation.js +110 -0
  289. package/dist/pipeline/publish-run.d.ts +71 -0
  290. package/dist/pipeline/publish-run.js +295 -0
  291. package/dist/pipeline/run.d.ts +7 -0
  292. package/dist/pipeline/run.js +196 -0
  293. package/dist/pipeline/storyboard-choice.d.ts +34 -0
  294. package/dist/pipeline/storyboard-choice.js +129 -0
  295. package/dist/pipeline/types.d.ts +76 -0
  296. package/dist/pipeline/types.js +2 -0
  297. package/dist/publish/access-probe.d.ts +55 -0
  298. package/dist/publish/access-probe.js +249 -0
  299. package/dist/publish/bundle.d.ts +20 -0
  300. package/dist/publish/bundle.js +57 -0
  301. package/dist/publish/comment.d.ts +10 -0
  302. package/dist/publish/comment.js +184 -0
  303. package/dist/publish/content-types.d.ts +15 -0
  304. package/dist/publish/content-types.js +41 -0
  305. package/dist/publish/index.d.ts +18 -0
  306. package/dist/publish/index.js +30 -0
  307. package/dist/publish/keys.d.ts +10 -0
  308. package/dist/publish/keys.js +30 -0
  309. package/dist/publish/local.d.ts +33 -0
  310. package/dist/publish/local.js +143 -0
  311. package/dist/publish/privacy.d.ts +20 -0
  312. package/dist/publish/privacy.js +21 -0
  313. package/dist/publish/s3/bucket.d.ts +22 -0
  314. package/dist/publish/s3/bucket.js +82 -0
  315. package/dist/publish/s3/client.d.ts +33 -0
  316. package/dist/publish/s3/client.js +134 -0
  317. package/dist/publish/s3/failures.d.ts +22 -0
  318. package/dist/publish/s3/failures.js +110 -0
  319. package/dist/publish/s3/index.d.ts +5 -0
  320. package/dist/publish/s3/index.js +6 -0
  321. package/dist/publish/s3/links.d.ts +38 -0
  322. package/dist/publish/s3/links.js +60 -0
  323. package/dist/publish/s3/protected-links.d.ts +29 -0
  324. package/dist/publish/s3/protected-links.js +67 -0
  325. package/dist/publish/s3/publisher.d.ts +32 -0
  326. package/dist/publish/s3/publisher.js +123 -0
  327. package/dist/publish/s3/settings.d.ts +29 -0
  328. package/dist/publish/s3/settings.js +64 -0
  329. package/dist/publish/s3/upload.d.ts +29 -0
  330. package/dist/publish/s3/upload.js +145 -0
  331. package/dist/publish/severity.d.ts +9 -0
  332. package/dist/publish/severity.js +18 -0
  333. package/dist/publish/text.d.ts +23 -0
  334. package/dist/publish/text.js +94 -0
  335. package/dist/publish/types.d.ts +67 -0
  336. package/dist/publish/types.js +12 -0
  337. package/dist/publish/vtt.d.ts +9 -0
  338. package/dist/publish/vtt.js +43 -0
  339. package/dist/publish/watch-page.d.ts +4 -0
  340. package/dist/publish/watch-page.js +463 -0
  341. package/dist/publish/youtube/credentials.d.ts +33 -0
  342. package/dist/publish/youtube/credentials.js +162 -0
  343. package/dist/publish/youtube/description.d.ts +56 -0
  344. package/dist/publish/youtube/description.js +197 -0
  345. package/dist/publish/youtube/google-api.d.ts +95 -0
  346. package/dist/publish/youtube/google-api.js +339 -0
  347. package/dist/publish/youtube/index.d.ts +7 -0
  348. package/dist/publish/youtube/index.js +8 -0
  349. package/dist/publish/youtube/loopback.d.ts +13 -0
  350. package/dist/publish/youtube/loopback.js +144 -0
  351. package/dist/publish/youtube/oauth.d.ts +68 -0
  352. package/dist/publish/youtube/oauth.js +159 -0
  353. package/dist/publish/youtube/prompt.d.ts +27 -0
  354. package/dist/publish/youtube/prompt.js +94 -0
  355. package/dist/publish/youtube/publisher.d.ts +38 -0
  356. package/dist/publish/youtube/publisher.js +346 -0
  357. package/dist/publish/youtube/scopes.d.ts +32 -0
  358. package/dist/publish/youtube/scopes.js +55 -0
  359. package/dist/publish/youtube/sign-in.d.ts +37 -0
  360. package/dist/publish/youtube/sign-in.js +137 -0
  361. package/dist/publish/youtube/upload.d.ts +43 -0
  362. package/dist/publish/youtube/upload.js +210 -0
  363. package/dist/render/browser.d.ts +23 -0
  364. package/dist/render/browser.js +219 -0
  365. package/dist/render/chromium-renderer.d.ts +56 -0
  366. package/dist/render/chromium-renderer.js +519 -0
  367. package/dist/render/ffmpeg.d.ts +55 -0
  368. package/dist/render/ffmpeg.js +212 -0
  369. package/dist/render/fonts.d.ts +10 -0
  370. package/dist/render/fonts.js +42 -0
  371. package/dist/render/index.d.ts +9 -0
  372. package/dist/render/index.js +11 -0
  373. package/dist/render/page.d.ts +46 -0
  374. package/dist/render/page.js +123 -0
  375. package/dist/render/playwright.d.ts +3 -0
  376. package/dist/render/playwright.js +6 -0
  377. package/dist/render/runtime-bundle.d.ts +2 -0
  378. package/dist/render/runtime-bundle.js +72 -0
  379. package/dist/runtime/runtime.js +1626 -0
  380. package/dist/server/auth.d.ts +17 -0
  381. package/dist/server/auth.js +58 -0
  382. package/dist/server/http.d.ts +43 -0
  383. package/dist/server/http.js +119 -0
  384. package/dist/server/index.d.ts +46 -0
  385. package/dist/server/index.js +310 -0
  386. package/dist/server/queue.d.ts +30 -0
  387. package/dist/server/queue.js +76 -0
  388. package/dist/server/schema.d.ts +103 -0
  389. package/dist/server/schema.js +121 -0
  390. package/dist/server/source.d.ts +17 -0
  391. package/dist/server/source.js +100 -0
  392. package/dist/sources/assemble.d.ts +86 -0
  393. package/dist/sources/assemble.js +117 -0
  394. package/dist/sources/diff-parser.d.ts +14 -0
  395. package/dist/sources/diff-parser.js +84 -0
  396. package/dist/sources/git.d.ts +28 -0
  397. package/dist/sources/git.js +108 -0
  398. package/dist/sources/github.d.ts +20 -0
  399. package/dist/sources/github.js +192 -0
  400. package/dist/sources/hunk-selection.d.ts +25 -0
  401. package/dist/sources/hunk-selection.js +46 -0
  402. package/dist/sources/index.d.ts +23 -0
  403. package/dist/sources/index.js +62 -0
  404. package/dist/sources/limits.d.ts +27 -0
  405. package/dist/sources/limits.js +22 -0
  406. package/dist/sources/local.d.ts +34 -0
  407. package/dist/sources/local.js +555 -0
  408. package/dist/sources/reader.d.ts +13 -0
  409. package/dist/sources/reader.js +45 -0
  410. package/dist/sources/remote.d.ts +13 -0
  411. package/dist/sources/remote.js +41 -0
  412. package/dist/sources/repo-context.d.ts +34 -0
  413. package/dist/sources/repo-context.js +144 -0
  414. package/dist/sources/text.d.ts +25 -0
  415. package/dist/sources/text.js +71 -0
  416. package/dist/storyboard/authoring.d.ts +108 -0
  417. package/dist/storyboard/authoring.js +196 -0
  418. package/dist/storyboard/claims.d.ts +35 -0
  419. package/dist/storyboard/claims.js +318 -0
  420. package/dist/storyboard/coderef.d.ts +28 -0
  421. package/dist/storyboard/coderef.js +118 -0
  422. package/dist/storyboard/generate.d.ts +25 -0
  423. package/dist/storyboard/generate.js +194 -0
  424. package/dist/storyboard/heuristic-code.d.ts +91 -0
  425. package/dist/storyboard/heuristic-code.js +524 -0
  426. package/dist/storyboard/heuristic-context.d.ts +42 -0
  427. package/dist/storyboard/heuristic-context.js +102 -0
  428. package/dist/storyboard/heuristic-facts.d.ts +106 -0
  429. package/dist/storyboard/heuristic-facts.js +415 -0
  430. package/dist/storyboard/heuristic-overview.d.ts +4 -0
  431. package/dist/storyboard/heuristic-overview.js +151 -0
  432. package/dist/storyboard/heuristic-review.d.ts +10 -0
  433. package/dist/storyboard/heuristic-review.js +158 -0
  434. package/dist/storyboard/heuristic-scenes.d.ts +8 -0
  435. package/dist/storyboard/heuristic-scenes.js +357 -0
  436. package/dist/storyboard/heuristic-shared.d.ts +43 -0
  437. package/dist/storyboard/heuristic-shared.js +136 -0
  438. package/dist/storyboard/heuristic.d.ts +15 -0
  439. package/dist/storyboard/heuristic.js +324 -0
  440. package/dist/storyboard/identifiers.d.ts +51 -0
  441. package/dist/storyboard/identifiers.js +195 -0
  442. package/dist/storyboard/index.d.ts +10 -0
  443. package/dist/storyboard/index.js +10 -0
  444. package/dist/storyboard/prompts.d.ts +16 -0
  445. package/dist/storyboard/prompts.js +61 -0
  446. package/dist/storyboard/run.d.ts +82 -0
  447. package/dist/storyboard/run.js +332 -0
  448. package/dist/storyboard/text.d.ts +16 -0
  449. package/dist/storyboard/text.js +103 -0
  450. package/dist/storyboard/types.d.ts +47 -0
  451. package/dist/storyboard/types.js +2 -0
  452. package/dist/storyboard/urls.d.ts +15 -0
  453. package/dist/storyboard/urls.js +83 -0
  454. package/dist/storyboard/validate.d.ts +8 -0
  455. package/dist/storyboard/validate.js +525 -0
  456. package/dist/storyboard/visuals.d.ts +23 -0
  457. package/dist/storyboard/visuals.js +324 -0
  458. package/dist/version.d.ts +2 -0
  459. package/dist/version.js +3 -0
  460. package/dist/visuals/code.d.ts +68 -0
  461. package/dist/visuals/code.js +385 -0
  462. package/dist/visuals/highlight.d.ts +17 -0
  463. package/dist/visuals/highlight.js +85 -0
  464. package/dist/visuals/image.d.ts +12 -0
  465. package/dist/visuals/image.js +96 -0
  466. package/dist/visuals/index.d.ts +10 -0
  467. package/dist/visuals/index.js +10 -0
  468. package/dist/visuals/layout.d.ts +89 -0
  469. package/dist/visuals/layout.js +506 -0
  470. package/dist/visuals/plan.d.ts +33 -0
  471. package/dist/visuals/plan.js +511 -0
  472. package/dist/visuals/timeline.d.ts +31 -0
  473. package/dist/visuals/timeline.js +96 -0
  474. package/package.json +74 -4
@@ -0,0 +1,212 @@
1
+ /**
2
+ * FFmpeg helpers: encoder arguments, segment encoders fed over a pipe, concatenation with the
3
+ * audio mux, and probing.
4
+ *
5
+ * All commands run without a shell and with argument arrays. Paths passed to FFmpeg are always
6
+ * absolute, so they can never be read as options.
7
+ */
8
+ import { spawn } from 'node:child_process';
9
+ import { MergeStoryError } from '../core/errors.js';
10
+ import { runCommand } from '../core/process.js';
11
+ /**
12
+ * Chrome writes JPEG frames as full-range BT.601 YCbCr. The video is limited-range BT.709, so the
13
+ * frames go through RGB (exact in every FFmpeg version) and are then tagged. Without this the
14
+ * output keeps the JPEG's full range, and players that ignore the range flag show washed colours.
15
+ */
16
+ export const COLOR_FILTER = [
17
+ 'scale=in_range=full:in_color_matrix=bt601:flags=accurate_rnd+full_chroma_int',
18
+ 'format=rgb24',
19
+ 'scale=out_range=limited:out_color_matrix=bt709:flags=accurate_rnd+full_chroma_int',
20
+ 'format=yuv420p',
21
+ 'setparams=range=tv:colorspace=bt709:color_primaries=bt709:color_trc=bt709',
22
+ ].join(',');
23
+ /** Arguments that turn a stream of JPEG frames on stdin into one H.264 segment. */
24
+ export function segmentEncodeArgs(o) {
25
+ return [
26
+ ...['-hide_banner', '-loglevel', 'error', '-y'],
27
+ ...['-f', 'image2pipe', '-framerate', String(o.fps), '-c:v', 'mjpeg', '-i', '-'],
28
+ ...['-vf', COLOR_FILTER],
29
+ ...['-c:v', 'libx264', '-preset', o.x264Preset, '-crf', String(o.crf)],
30
+ ...['-pix_fmt', 'yuv420p', '-profile:v', 'high'],
31
+ ...['-g', String(o.gop), '-keyint_min', String(o.gop), '-sc_threshold', '0'],
32
+ ...['-threads', String(o.threads)],
33
+ ...['-colorspace', 'bt709', '-color_primaries', 'bt709', '-color_trc', 'bt709', '-color_range', 'tv'],
34
+ ...['-an', '-map_metadata', '-1', '-fflags', '+bitexact', '-flags:v', '+bitexact'],
35
+ o.outPath,
36
+ ];
37
+ }
38
+ /**
39
+ * Arguments that join the segments without re-encoding and add the audio as AAC. Metadata is
40
+ * stripped, including the encoder's own settings string, and the index is moved to the front so
41
+ * the video starts playing before it has fully downloaded.
42
+ */
43
+ export function muxArgs(o) {
44
+ const args = ['-hide_banner', '-loglevel', 'error', '-y', '-f', 'concat', '-safe', '0', '-i', o.listPath];
45
+ if (o.audioPath)
46
+ args.push('-i', o.audioPath);
47
+ args.push('-map', '0:v:0');
48
+ if (o.audioPath)
49
+ args.push('-map', '1:a:0');
50
+ // SEI NAL units carry only the encoder's version and settings text.
51
+ args.push('-c:v', 'copy', '-bsf:v', 'filter_units=remove_types=6');
52
+ if (o.audioPath) {
53
+ args.push('-c:a', 'aac', '-b:a', '128k', '-ar', '48000', '-af', 'apad', '-t', o.durationSec.toFixed(6));
54
+ }
55
+ args.push(...['-movflags', '+faststart', '-map_metadata', '-1'], ...['-fflags', '+bitexact', '-flags:v', '+bitexact', '-flags:a', '+bitexact'], o.outPath);
56
+ return args;
57
+ }
58
+ /** Text of a concat demuxer list. Single quotes in paths are escaped. */
59
+ export function concatListText(paths, platform = process.platform) {
60
+ return paths
61
+ .map((path) => {
62
+ if (/[\r\n]/.test(path)) {
63
+ throw new MergeStoryError('RENDER_FAILED', 'A temporary file path contains a line break.', {
64
+ hint: 'Use an output folder whose path has no line breaks.',
65
+ });
66
+ }
67
+ const normal = platform === 'win32' ? path.replace(/\\/g, '/') : path;
68
+ return `file '${normal.replace(/'/g, `'\\''`)}'`;
69
+ })
70
+ .join('\n')
71
+ .concat('\n');
72
+ }
73
+ /** Joining the segments takes seconds to minutes; this only stops FFmpeg when it hangs. */
74
+ const MUX_TIMEOUT_MS = 30 * 60_000;
75
+ export async function concatAndMux(ffmpegPath, options, signal) {
76
+ try {
77
+ await runCommand(ffmpegPath, muxArgs(options), {
78
+ signal,
79
+ maxOutputBytes: 1024 * 1024,
80
+ timeoutMs: MUX_TIMEOUT_MS,
81
+ });
82
+ }
83
+ catch (err) {
84
+ if (signal?.aborted)
85
+ throw err;
86
+ throw new MergeStoryError('RENDER_FAILED', 'FFmpeg could not assemble the video.', {
87
+ hint: 'Check that FFmpeg 4.4 or newer with libx264 is installed. Run "mergestory doctor".',
88
+ cause: err,
89
+ });
90
+ }
91
+ }
92
+ // ---------------------------------------------------------------------------
93
+ // Probing
94
+ // ---------------------------------------------------------------------------
95
+ /** Duration of a media file in seconds. */
96
+ export async function probeDuration(ffprobePath, file, signal) {
97
+ const result = await runCommand(ffprobePath, [
98
+ '-v',
99
+ 'error',
100
+ '-show_entries',
101
+ 'format=duration',
102
+ '-of',
103
+ 'default=noprint_wrappers=1:nokey=1',
104
+ '-i',
105
+ file,
106
+ ], { signal });
107
+ const seconds = Number.parseFloat(result.stdout.trim());
108
+ if (!Number.isFinite(seconds)) {
109
+ throw new MergeStoryError('RENDER_FAILED', 'The rendered video has no readable duration.');
110
+ }
111
+ return seconds;
112
+ }
113
+ // ---------------------------------------------------------------------------
114
+ // Segment encoder
115
+ // ---------------------------------------------------------------------------
116
+ /** An FFmpeg process that encodes JPEG frames written to it. */
117
+ export class SegmentEncoder {
118
+ child;
119
+ stderr = '';
120
+ failure = null;
121
+ closed = false;
122
+ done;
123
+ constructor(child, done) {
124
+ this.child = child;
125
+ this.done = done;
126
+ }
127
+ /** Start ffmpeg with the given arguments. Frames go to its stdin. */
128
+ static start(ffmpegPath, args) {
129
+ const child = spawn(ffmpegPath, args, {
130
+ stdio: ['pipe', 'ignore', 'pipe'],
131
+ shell: false,
132
+ windowsHide: true,
133
+ });
134
+ let self = null;
135
+ const done = new Promise((resolve, reject) => {
136
+ child.on('error', (err) => {
137
+ const error = err.code === 'ENOENT'
138
+ ? new MergeStoryError('FFMPEG_NOT_FOUND', 'ffmpeg could not be started.', {
139
+ hint: 'Install FFmpeg or set MERGESTORY_FFMPEG_PATH.',
140
+ cause: err,
141
+ })
142
+ : new MergeStoryError('RENDER_FAILED', 'ffmpeg could not be started.', { cause: err });
143
+ if (self)
144
+ self.failure = error;
145
+ reject(error);
146
+ });
147
+ child.on('close', (code) => {
148
+ if (self)
149
+ self.closed = true;
150
+ if (code === 0) {
151
+ resolve();
152
+ return;
153
+ }
154
+ const tail = (self?.stderr ?? '').trim().split('\n').slice(-3).join(' ').slice(0, 400);
155
+ const error = new MergeStoryError('RENDER_FAILED', `ffmpeg stopped while encoding (exit code ${code}): ${tail}`, {
156
+ hint: 'Check that FFmpeg 4.4 or newer with libx264 is installed. Run "mergestory doctor".',
157
+ });
158
+ if (self)
159
+ self.failure = error;
160
+ reject(error);
161
+ });
162
+ });
163
+ done.catch(() => undefined); // callers observe the failure through write() and finish()
164
+ self = new SegmentEncoder(child, done);
165
+ child.stderr?.on('data', (chunk) => {
166
+ if (self && self.stderr.length < 8192)
167
+ self.stderr += chunk.toString('utf8');
168
+ });
169
+ child.stdin?.on('error', () => undefined); // a broken pipe is reported by the close handler
170
+ return self;
171
+ }
172
+ /** Write one JPEG frame, waiting when the pipe is full. */
173
+ async write(frame) {
174
+ const stdin = this.child.stdin;
175
+ if (this.failure)
176
+ throw this.failure;
177
+ if (!stdin || this.closed || stdin.destroyed || !stdin.writable) {
178
+ throw new MergeStoryError('RENDER_FAILED', 'ffmpeg stopped before all frames were written.');
179
+ }
180
+ if (stdin.write(frame))
181
+ return;
182
+ await new Promise((resolve, reject) => {
183
+ const cleanup = () => {
184
+ stdin.off('drain', onDrain);
185
+ this.child.off('close', onClose);
186
+ };
187
+ const onDrain = () => {
188
+ cleanup();
189
+ resolve();
190
+ };
191
+ const onClose = () => {
192
+ cleanup();
193
+ reject(this.failure ??
194
+ new MergeStoryError('RENDER_FAILED', 'ffmpeg stopped before all frames were written.'));
195
+ };
196
+ stdin.once('drain', onDrain);
197
+ this.child.once('close', onClose);
198
+ });
199
+ }
200
+ /** Close the input and wait for ffmpeg to finish. Rejects when ffmpeg fails. */
201
+ finish() {
202
+ if (!this.closed && this.child.stdin && !this.child.stdin.destroyed)
203
+ this.child.stdin.end();
204
+ return this.done;
205
+ }
206
+ /** Stop ffmpeg now. */
207
+ kill() {
208
+ if (!this.closed)
209
+ this.child.kill('SIGKILL');
210
+ }
211
+ }
212
+ //# sourceMappingURL=ffmpeg.js.map
@@ -0,0 +1,10 @@
1
+ interface FontFace {
2
+ family: string;
3
+ weight: number;
4
+ /** Module path of the woff2 file. */
5
+ file: string;
6
+ }
7
+ export declare const FONT_FACES: readonly FontFace[];
8
+ /** CSS with every bundled font face embedded. Read once per process. */
9
+ export declare function fontFacesCss(): Promise<string>;
10
+ export {};
@@ -0,0 +1,42 @@
1
+ /** Bundled fonts as @font-face rules with base64 data URLs, so the render page never loads anything. */
2
+ import { readFile } from 'node:fs/promises';
3
+ import { createRequire } from 'node:module';
4
+ const INTER = (weight) => ({
5
+ family: 'Inter',
6
+ weight,
7
+ file: `@fontsource/inter/files/inter-latin-${weight}-normal.woff2`,
8
+ });
9
+ const MONO = (weight) => ({
10
+ family: 'JetBrains Mono',
11
+ weight,
12
+ file: `@fontsource/jetbrains-mono/files/jetbrains-mono-latin-${weight}-normal.woff2`,
13
+ });
14
+ export const FONT_FACES = [
15
+ INTER(400),
16
+ INTER(500),
17
+ INTER(600),
18
+ INTER(700),
19
+ INTER(800),
20
+ MONO(400),
21
+ MONO(500),
22
+ MONO(700),
23
+ ];
24
+ let cached = null;
25
+ /** CSS with every bundled font face embedded. Read once per process. */
26
+ export function fontFacesCss() {
27
+ cached ??= (async () => {
28
+ const require = createRequire(import.meta.url);
29
+ const rules = [];
30
+ for (const face of FONT_FACES) {
31
+ const data = await readFile(require.resolve(face.file));
32
+ rules.push(`@font-face{font-family:'${face.family}';font-weight:${face.weight};font-style:normal;font-display:block;` +
33
+ `src:url(data:font/woff2;base64,${data.toString('base64')}) format('woff2');}`);
34
+ }
35
+ return rules.join('\n');
36
+ })().catch((err) => {
37
+ cached = null;
38
+ throw err;
39
+ });
40
+ return cached;
41
+ }
42
+ //# sourceMappingURL=fonts.js.map
@@ -0,0 +1,9 @@
1
+ /** Rendering: RenderPlan -> MP4, through the browser runtime and FFmpeg. */
2
+ import type { Config } from '../core/config.ts';
3
+ import type { Renderer } from '../core/providers.ts';
4
+ import { type BrowserExecutable } from './browser.ts';
5
+ export type { BrowserExecutable } from './browser.ts';
6
+ export { ChromiumRenderer } from './chromium-renderer.ts';
7
+ export declare function createRenderer(config: Config): Renderer;
8
+ /** Find a Chromium-family browser to render with. Throws BROWSER_NOT_FOUND with install hints. */
9
+ export declare function resolveBrowserExecutable(config: Config): Promise<BrowserExecutable>;
@@ -0,0 +1,11 @@
1
+ import { locateBrowser } from './browser.js';
2
+ import { ChromiumRenderer } from './chromium-renderer.js';
3
+ export { ChromiumRenderer } from './chromium-renderer.js';
4
+ export function createRenderer(config) {
5
+ return new ChromiumRenderer(config);
6
+ }
7
+ /** Find a Chromium-family browser to render with. Throws BROWSER_NOT_FOUND with install hints. */
8
+ export async function resolveBrowserExecutable(config) {
9
+ return locateBrowser(config);
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The render page: one self-contained HTML document (fonts and runtime inlined) and a small
3
+ * wrapper around a Playwright page that seeks the runtime and captures frames over CDP.
4
+ *
5
+ * The page has no network access. Three layers enforce this: a content security policy, request
6
+ * blocking in the browser context, and the context's offline mode.
7
+ */
8
+ import type { Browser } from 'playwright-core';
9
+ import type { Logger } from '../core/logger.ts';
10
+ import type { RenderPlan } from '../core/render-plan.ts';
11
+ export declare const PAGE_CSP = "default-src 'none'; img-src data:; font-src data:; style-src 'unsafe-inline'; script-src 'unsafe-inline'";
12
+ /** A "</script" inside inline script text would end the element early. */
13
+ export declare function escapeInlineScript(source: string): string;
14
+ export interface PageSources {
15
+ runtimeJs: string;
16
+ fontsCss: string;
17
+ }
18
+ /** The HTML document that hosts the runtime. */
19
+ export declare function buildPageHtml({ runtimeJs, fontsCss }: PageSources): string;
20
+ export type CaptureFormat = {
21
+ format: 'jpeg';
22
+ quality: number;
23
+ optimizeForSpeed: boolean;
24
+ } | {
25
+ format: 'png';
26
+ optimizeForSpeed: boolean;
27
+ };
28
+ /** A plan loaded in a page of its own browser context. */
29
+ export declare class PlanPage {
30
+ private readonly context;
31
+ private readonly cdp;
32
+ private blocked;
33
+ private readonly errors;
34
+ private constructor();
35
+ /** Open a page, load the runtime and the plan, and wait until fonts and images are ready. */
36
+ static open(browser: Browser, plan: RenderPlan, html: string, logger?: Logger): Promise<PlanPage>;
37
+ /** Requests the page tried to make (all were blocked). */
38
+ get blockedRequests(): number;
39
+ /** Errors the page reported (console errors and uncaught exceptions). */
40
+ get pageErrors(): readonly string[];
41
+ /** Show the frame at `timeSec`. Returns false only when the frame is identical to the previous seek's. */
42
+ seek(timeSec: number): Promise<boolean>;
43
+ /** Capture the current frame. */
44
+ capture(options: CaptureFormat): Promise<Buffer>;
45
+ close(): Promise<void>;
46
+ }
@@ -0,0 +1,123 @@
1
+ import { MergeStoryError } from '../core/errors.js';
2
+ export const PAGE_CSP = "default-src 'none'; img-src data:; font-src data:; style-src 'unsafe-inline'; script-src 'unsafe-inline'";
3
+ /** A "</script" inside inline script text would end the element early. */
4
+ export function escapeInlineScript(source) {
5
+ return source.replace(/<\/(script)/gi, '<\\/$1');
6
+ }
7
+ /** The HTML document that hosts the runtime. */
8
+ export function buildPageHtml({ runtimeJs, fontsCss }) {
9
+ return ('<!doctype html><html lang="en"><head><meta charset="utf-8">' +
10
+ `<meta http-equiv="Content-Security-Policy" content="${PAGE_CSP}">` +
11
+ '<title>MergeStory</title>' +
12
+ `<style>${fontsCss}</style></head>` +
13
+ `<body><script>${escapeInlineScript(runtimeJs)}</script></body></html>`);
14
+ }
15
+ /** A page that does not answer within this time is treated as stuck. */
16
+ const COMMAND_TIMEOUT_MS = 60_000;
17
+ const LOAD_TIMEOUT_MS = 120_000;
18
+ /** Wait for `work`, but give up with a clear error when the browser does not answer in time. */
19
+ async function within(work, ms, what) {
20
+ let timer;
21
+ const stuck = new Promise((_, reject) => {
22
+ timer = setTimeout(() => reject(new MergeStoryError('RENDER_FAILED', `The browser stopped responding while ${what}.`, {
23
+ hint: 'Close other heavy programs, lower render.concurrency, or try another browser with MERGESTORY_BROWSER_PATH.',
24
+ })), ms);
25
+ });
26
+ try {
27
+ return await Promise.race([work, stuck]);
28
+ }
29
+ finally {
30
+ clearTimeout(timer);
31
+ }
32
+ }
33
+ /** A plan loaded in a page of its own browser context. */
34
+ export class PlanPage {
35
+ context;
36
+ cdp;
37
+ blocked = 0;
38
+ errors = [];
39
+ constructor(context, cdp) {
40
+ this.context = context;
41
+ this.cdp = cdp;
42
+ }
43
+ /** Open a page, load the runtime and the plan, and wait until fonts and images are ready. */
44
+ static async open(browser, plan, html, logger) {
45
+ const context = await browser.newContext({
46
+ viewport: { width: plan.width, height: plan.height },
47
+ deviceScaleFactor: 1,
48
+ serviceWorkers: 'block',
49
+ locale: 'en-US',
50
+ timezoneId: 'UTC',
51
+ offline: true,
52
+ });
53
+ let instance = null;
54
+ try {
55
+ await context.route('**/*', (route) => {
56
+ if (instance)
57
+ instance.blocked++;
58
+ return route.abort();
59
+ });
60
+ const page = await context.newPage();
61
+ const cdp = await context.newCDPSession(page);
62
+ instance = new PlanPage(context, cdp);
63
+ page.on('pageerror', (error) => instance?.errors.push(error.message));
64
+ page.on('console', (message) => {
65
+ if (message.type() === 'error')
66
+ instance?.errors.push(message.text());
67
+ });
68
+ await page.setContent(html, { waitUntil: 'load' });
69
+ // Fonts of scenes that are not visible yet would otherwise load late and flash in a frame.
70
+ await page.evaluate(() => {
71
+ const host = globalThis;
72
+ return Promise.all(Array.from(host.document.fonts, (face) => face.load())).then(() => undefined);
73
+ });
74
+ await within(page.evaluate((p) => globalThis.__MERGESTORY__.load(p), plan), LOAD_TIMEOUT_MS, 'loading the render plan');
75
+ logger?.debug('Render page ready', { width: plan.width, height: plan.height });
76
+ return instance;
77
+ }
78
+ catch (err) {
79
+ await context.close().catch(() => undefined);
80
+ if (err instanceof MergeStoryError)
81
+ throw err;
82
+ throw new MergeStoryError('RENDER_FAILED', 'The video runtime could not load the render plan.', {
83
+ hint: 'Run "mergestory doctor" and try again. If it keeps failing, report the error with --debug output.',
84
+ cause: err,
85
+ details: { pageErrors: instance?.errors.slice(0, 3) ?? [] },
86
+ });
87
+ }
88
+ }
89
+ /** Requests the page tried to make (all were blocked). */
90
+ get blockedRequests() {
91
+ return this.blocked;
92
+ }
93
+ /** Errors the page reported (console errors and uncaught exceptions). */
94
+ get pageErrors() {
95
+ return this.errors;
96
+ }
97
+ /** Show the frame at `timeSec`. Returns false only when the frame is identical to the previous seek's. */
98
+ async seek(timeSec) {
99
+ if (!Number.isFinite(timeSec))
100
+ throw new MergeStoryError('INTERNAL', 'Cannot seek to a time that is not a number.');
101
+ const response = (await within(this.cdp.send('Runtime.evaluate', {
102
+ expression: `window.__MERGESTORY__.seek(${timeSec})`,
103
+ returnByValue: true,
104
+ }), COMMAND_TIMEOUT_MS, `showing the frame at ${timeSec.toFixed(2)} s`));
105
+ if (response.exceptionDetails) {
106
+ const detail = response.exceptionDetails.exception?.description ?? response.exceptionDetails.text ?? 'unknown error';
107
+ throw new MergeStoryError('RENDER_FAILED', `The video runtime failed at ${timeSec.toFixed(2)} s: ${detail.split('\n')[0]}`, {
108
+ hint: 'This is a bug in a scene template. Report it with the storyboard that triggered it.',
109
+ });
110
+ }
111
+ const value = response.result?.value;
112
+ return value?.dirty !== false;
113
+ }
114
+ /** Capture the current frame. */
115
+ async capture(options) {
116
+ const { data } = await within(this.cdp.send('Page.captureScreenshot', options), COMMAND_TIMEOUT_MS, 'capturing a frame');
117
+ return Buffer.from(data, 'base64');
118
+ }
119
+ async close() {
120
+ await this.context.close().catch(() => undefined);
121
+ }
122
+ }
123
+ //# sourceMappingURL=page.js.map
@@ -0,0 +1,3 @@
1
+ /** playwright-core is large, so it is loaded the first time a browser is needed. */
2
+ import type * as PlaywrightCore from 'playwright-core';
3
+ export declare function loadPlaywright(): Promise<typeof PlaywrightCore>;
@@ -0,0 +1,6 @@
1
+ let loaded = null;
2
+ export function loadPlaywright() {
3
+ loaded ??= import('playwright-core');
4
+ return loaded;
5
+ }
6
+ //# sourceMappingURL=playwright.js.map
@@ -0,0 +1,2 @@
1
+ /** The runtime script (an IIFE that defines window.__MERGESTORY__). Cached for the process. */
2
+ export declare function loadRuntimeBundle(): Promise<string>;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The browser runtime as a script string.
3
+ *
4
+ * An installed package ships it prebuilt (dist/runtime/runtime.js). In a source checkout the
5
+ * prebuilt file may be stale, so the runtime is bundled from source with esbuild instead, in
6
+ * memory, once per process.
7
+ */
8
+ import { existsSync } from 'node:fs';
9
+ import { readFile } from 'node:fs/promises';
10
+ import { dirname, join } from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ import { MergeStoryError } from '../core/errors.js';
13
+ let cached = null;
14
+ async function bundleFromSource(entry) {
15
+ let esbuild;
16
+ try {
17
+ esbuild = await import('esbuild');
18
+ }
19
+ catch {
20
+ return null; // esbuild is a development dependency
21
+ }
22
+ try {
23
+ const result = await esbuild.build({
24
+ entryPoints: [entry],
25
+ bundle: true,
26
+ write: false,
27
+ format: 'iife',
28
+ platform: 'browser',
29
+ target: ['chrome120'],
30
+ logLevel: 'silent',
31
+ });
32
+ const output = result.outputFiles[0];
33
+ if (!output)
34
+ throw new Error('esbuild produced no output');
35
+ return output.text;
36
+ }
37
+ catch (err) {
38
+ throw new MergeStoryError('RENDER_FAILED', 'The video runtime could not be bundled from source.', {
39
+ hint: 'Fix the error in src/runtime or run "npm run build:runtime".',
40
+ cause: err,
41
+ });
42
+ }
43
+ }
44
+ async function load() {
45
+ const here = dirname(fileURLToPath(import.meta.url));
46
+ const sourceEntry = join(here, '..', 'runtime', 'main.ts');
47
+ if (existsSync(sourceEntry)) {
48
+ const bundled = await bundleFromSource(sourceEntry);
49
+ if (bundled !== null)
50
+ return bundled;
51
+ }
52
+ // From dist/render the bundle is ../runtime/runtime.js; from src/render it is ../../dist/runtime/runtime.js.
53
+ for (const file of [
54
+ join(here, '..', 'runtime', 'runtime.js'),
55
+ join(here, '..', '..', 'dist', 'runtime', 'runtime.js'),
56
+ ]) {
57
+ if (existsSync(file))
58
+ return readFile(file, 'utf8');
59
+ }
60
+ throw new MergeStoryError('RENDER_FAILED', 'The video runtime is missing.', {
61
+ hint: 'Run "npm run build" (or "npm run build:runtime") in the engine package, or reinstall mergestory.',
62
+ });
63
+ }
64
+ /** The runtime script (an IIFE that defines window.__MERGESTORY__). Cached for the process. */
65
+ export function loadRuntimeBundle() {
66
+ cached ??= load().catch((err) => {
67
+ cached = null;
68
+ throw err;
69
+ });
70
+ return cached;
71
+ }
72
+ //# sourceMappingURL=runtime-bundle.js.map