@usemosio/cli-linux-x64 1.0.0-next.1 → 1.0.0-next.4

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 (182) hide show
  1. package/THIRD_PARTY_NOTICES.md +22 -0
  2. package/apps/studio/dist/assets/Workspace-Dr-hVeFd.js +34 -0
  3. package/apps/studio/dist/assets/{agent-panel-CqJuv5Sn.js → agent-panel-DMrVed-J.js} +5 -5
  4. package/apps/studio/dist/assets/{boundary-bK2S8z05.js → boundary-DL9veUlN.js} +1 -1
  5. package/apps/studio/dist/assets/{feedback-BqzXUdVd.js → feedback-x6ZumR_x.js} +1 -1
  6. package/apps/studio/dist/assets/index-C6juWzGV.js +1984 -0
  7. package/apps/studio/dist/assets/index-CjDBKmB_.css +2 -0
  8. package/apps/studio/dist/assets/inspector3d-sqergHSP.js +1 -0
  9. package/apps/studio/dist/index.html +4 -3
  10. package/apps/studio/dist-host/studio-host.mjs +262 -3
  11. package/bin/mosio +0 -0
  12. package/bin/mosio-agent +0 -0
  13. package/crates/mosio/src/adapters/mosio-three.js +112 -8
  14. package/crates/mosio/src/adapters/room-env-pmrem.json +1 -0
  15. package/crates/mosio/src/runtime.js +205 -6
  16. package/fixtures/camera-inspect/mosio.json +56 -0
  17. package/fixtures/camera-inspect/scenes/behind.html +22 -0
  18. package/fixtures/camera-inspect/scenes/cut.html +18 -0
  19. package/fixtures/camera-inspect/scenes/edges.html +18 -0
  20. package/fixtures/camera-inspect/scenes/good.html +23 -0
  21. package/fixtures/camera-inspect/scenes/read.html +22 -0
  22. package/fixtures/camera-inspect/scenes/shake.html +23 -0
  23. package/fixtures/camera-inspect/scenes/speed.html +18 -0
  24. package/fixtures/camera-inspect-vertical/mosio.json +31 -0
  25. package/fixtures/camera-inspect-vertical/scenes/good.html +20 -0
  26. package/fixtures/camera-inspect-vertical/scenes/safe.html +18 -0
  27. package/fixtures/cloudrun-gpu/audio/music.wav +0 -0
  28. package/fixtures/cloudrun-gpu/audio/vo.wav +0 -0
  29. package/fixtures/cloudrun-gpu/mosio.json +18 -0
  30. package/fixtures/cloudrun-gpu/scenes/cube.html +25 -0
  31. package/fixtures/direct-seek/mosio.json +4 -0
  32. package/fixtures/direct-seek/scenes/clock.html +9 -0
  33. package/fixtures/direct-seek/scenes/meta.html +11 -0
  34. package/fixtures/direct-seek/scenes/pure.html +11 -0
  35. package/fixtures/direct-seek/scenes/slow.html +11 -0
  36. package/fixtures/direct-seek-media/mosio.json +6 -0
  37. package/fixtures/direct-seek-media/scenes/pure.html +11 -0
  38. package/fixtures/gl-readback/mosio.json +16 -0
  39. package/fixtures/gl-readback/scenes/compositor.html +23 -0
  40. package/fixtures/gl-readback/scenes/readback.html +23 -0
  41. package/fixtures/inspect-physics/expect.json +18 -0
  42. package/fixtures/inspect-physics/mosio.json +29 -0
  43. package/fixtures/inspect-physics/scenes/calm.html +46 -0
  44. package/fixtures/inspect-physics/scenes/physics.html +47 -0
  45. package/package.json +1 -1
  46. package/primitives/README.md +23 -2
  47. package/primitives/example/shared/mosio-prims.js +349 -1
  48. package/primitives/impact-burst/golden/f030.png +0 -0
  49. package/primitives/impact-burst/golden/f032.png +0 -0
  50. package/primitives/impact-burst/golden/f036.png +0 -0
  51. package/primitives/impact-burst/impact-burst.js +51 -0
  52. package/primitives/impact-burst/primitive.json +130 -0
  53. package/primitives/impact-burst/scene.html +24 -0
  54. package/primitives/stick-figure/golden/f030.png +0 -0
  55. package/primitives/stick-figure/golden/f092.png +0 -0
  56. package/primitives/stick-figure/golden/f140.png +0 -0
  57. package/primitives/stick-figure/primitive.json +179 -0
  58. package/primitives/stick-figure/scene.html +40 -0
  59. package/primitives/stick-figure/stick-figure.js +297 -0
  60. package/primitives/zoom-through/primitive.json +7 -2
  61. package/primitives/zoom-through/zoom-through.js +6 -5
  62. package/scripts/3d-acceptance.sh +8 -1
  63. package/scripts/3d-attach-bench.mjs +119 -0
  64. package/scripts/3d-bake-room-env.mjs +74 -0
  65. package/scripts/3d-e2b-job.sh +1 -0
  66. package/scripts/3d-gen-heavy-fixture.py +65 -0
  67. package/scripts/3d-trace-summary.py +14 -0
  68. package/scripts/acceptance/camera-inspect.sh +49 -0
  69. package/scripts/acceptance/direct-seek.sh +68 -0
  70. package/scripts/acceptance/export.sh +5 -3
  71. package/scripts/acceptance/frames.sh +7 -2
  72. package/scripts/acceptance/hardening.sh +37 -6
  73. package/scripts/acceptance/hub.sh +208 -0
  74. package/scripts/acceptance/inspect.sh +21 -2
  75. package/scripts/acceptance/revisions-git.sh +137 -0
  76. package/scripts/acceptance/revisions-sync.sh +323 -0
  77. package/scripts/acceptance/revisions.sh +118 -4
  78. package/scripts/acceptance/segcache.sh +100 -0
  79. package/scripts/acceptance/split.sh +78 -0
  80. package/scripts/bootstrap.sh +20 -1
  81. package/scripts/check-error-codes.py +9 -1
  82. package/scripts/check-file-size.sh +45 -0
  83. package/scripts/ci.sh +4 -4
  84. package/scripts/dedupe-report.sh +47 -0
  85. package/scripts/e2b/template/provision.sh +1 -1
  86. package/scripts/fastpath/cdp.mjs +25 -0
  87. package/scripts/fastpath/dbg.mjs +11 -0
  88. package/scripts/fastpath/e2b.mjs +40 -0
  89. package/scripts/fastpath/features/gen.py +109 -0
  90. package/scripts/fastpath/features/mosio.json +100 -0
  91. package/scripts/fastpath/features/scenes/backdrop.html +11 -0
  92. package/scripts/fastpath/features/scenes/blend.html +11 -0
  93. package/scripts/fastpath/features/scenes/canvas2d.html +11 -0
  94. package/scripts/fastpath/features/scenes/filter.html +11 -0
  95. package/scripts/fastpath/features/scenes/gradient.html +11 -0
  96. package/scripts/fastpath/features/scenes/iframe.html +11 -0
  97. package/scripts/fastpath/features/scenes/image.html +11 -0
  98. package/scripts/fastpath/features/scenes/svg.html +11 -0
  99. package/scripts/fastpath/features/scenes/text.html +11 -0
  100. package/scripts/fastpath/features/scenes/typo.html +11 -0
  101. package/scripts/fastpath/features/scenes/video.html +11 -0
  102. package/scripts/fastpath/features/scenes/video2.html +11 -0
  103. package/scripts/fastpath/features-xfade/mosio.json +49 -0
  104. package/scripts/fastpath/features-xfade/scenes/image.html +11 -0
  105. package/scripts/fastpath/features-xfade/scenes/video.html +11 -0
  106. package/scripts/fastpath/fixtures/gen_layout.py +80 -0
  107. package/scripts/fastpath/fixtures/l12-no-reset/assets/img/photo-1015.jpg +0 -0
  108. package/scripts/fastpath/fixtures/l12-no-reset/mosio.json +34 -0
  109. package/scripts/fastpath/fixtures/l12-no-reset/scenes/main.html +20 -0
  110. package/scripts/fastpath/fp.mjs +91 -0
  111. package/scripts/fastpath/inpage.js +68 -0
  112. package/scripts/fastpath/recipes.py +49 -0
  113. package/scripts/fastpath/sandbox.sh +68 -0
  114. package/scripts/fastpath/sandbox10.sh +57 -0
  115. package/scripts/fastpath/sandbox11.sh +18 -0
  116. package/scripts/fastpath/sandbox12.sh +30 -0
  117. package/scripts/fastpath/sandbox13.sh +16 -0
  118. package/scripts/fastpath/sandbox14.sh +28 -0
  119. package/scripts/fastpath/sandbox15.sh +36 -0
  120. package/scripts/fastpath/sandbox16.sh +60 -0
  121. package/scripts/fastpath/sandbox17.sh +34 -0
  122. package/scripts/fastpath/sandbox18.sh +59 -0
  123. package/scripts/fastpath/sandbox19.sh +67 -0
  124. package/scripts/fastpath/sandbox2.sh +41 -0
  125. package/scripts/fastpath/sandbox20.sh +34 -0
  126. package/scripts/fastpath/sandbox21.sh +22 -0
  127. package/scripts/fastpath/sandbox22.sh +22 -0
  128. package/scripts/fastpath/sandbox23.sh +21 -0
  129. package/scripts/fastpath/sandbox3.sh +151 -0
  130. package/scripts/fastpath/sandbox4.sh +161 -0
  131. package/scripts/fastpath/sandbox5.sh +69 -0
  132. package/scripts/fastpath/sandbox6.sh +85 -0
  133. package/scripts/fastpath/sandbox7.sh +81 -0
  134. package/scripts/fastpath/sandbox8.sh +62 -0
  135. package/scripts/fastpath/sandbox9.sh +130 -0
  136. package/scripts/fastpath/srv.mjs +15 -0
  137. package/scripts/fastpath/www/probe.html +1 -0
  138. package/scripts/gen-media-fixtures.sh +1 -0
  139. package/scripts/gl-readback-check.sh +26 -0
  140. package/scripts/hpbench/make-bench-fixtures.sh +43 -0
  141. package/scripts/hpbench/render-cgroup.sh +56 -0
  142. package/scripts/install.sh +2 -1
  143. package/scripts/npm-clean-install-proof-win.sh +64 -0
  144. package/scripts/platform-smoke.sh +80 -0
  145. package/scripts/prim.mjs +31 -13
  146. package/scripts/user-journey.sh +68 -0
  147. package/skills/mosio-3d/SKILL.md +31 -3
  148. package/skills/mosio-brief/SKILL.md +80 -0
  149. package/skills/mosio-brief/references/brief.md +141 -0
  150. package/skills/mosio-brief/references/copy.md +99 -0
  151. package/skills/mosio-brief/references/narration.md +61 -0
  152. package/skills/mosio-brief/references/storyboard.md +98 -0
  153. package/skills/mosio-collab/SKILL.md +104 -0
  154. package/skills/mosio-collab/references/hub.md +62 -0
  155. package/skills/mosio-engine/SKILL.md +44 -13
  156. package/skills/mosio-engine/references/camera.md +12 -2
  157. package/skills/mosio-engine/references/character.md +88 -0
  158. package/skills/mosio-engine/references/checks.md +11 -4
  159. package/skills/mosio-engine/references/delivery.md +29 -2
  160. package/skills/mosio-engine/references/kit-primitives.md +8 -4
  161. package/skills/mosio-engine/references/layout.md +8 -0
  162. package/skills/mosio-engine/references/plan.md +3 -1
  163. package/skills/mosio-engine/references/project.md +15 -3
  164. package/skills/mosio-engine/references/publish.md +79 -0
  165. package/skills/mosio-engine/references/registry.md +27 -15
  166. package/skills/mosio-engine/references/timeline.md +19 -1
  167. package/skills/mosio-engine/references/timing.md +2 -1
  168. package/skills/mosio-import/SKILL.md +1 -1
  169. package/skills/mosio-import/references/from-hyperframes.md +1 -1
  170. package/skills/mosio-import/references/from-remotion.md +1 -1
  171. package/skills/mosio-media/SKILL.md +16 -4
  172. package/skills/mosio-media/references/audio.md +29 -11
  173. package/skills/mosio-media/references/captions.md +26 -5
  174. package/skills/mosio-media/references/editing.md +70 -0
  175. package/skills/mosio-media/references/footage.md +40 -8
  176. package/skills/mosio-media/references/voice.md +52 -7
  177. package/skills/mosio-replicate/references/mosio.md +1 -1
  178. package/toolchain.lock.json +151 -4
  179. package/apps/studio/dist/assets/Workspace-KSOFeEgc.js +0 -32
  180. package/apps/studio/dist/assets/index-B-uuTqe9.js +0 -1785
  181. package/apps/studio/dist/assets/index-CajSh04l.css +0 -2
  182. package/apps/studio/dist/assets/inspector3d-vDz97X99.js +0 -1
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #cv{position:absolute;left:90px;top:400px}</style></head><body><div class="lbl">&lt;canvas&gt; 2D drawn per seek</div>
8
+ <canvas id="cv" width="900" height="900"></canvas>
9
+ <script>
10
+ const cx=document.getElementById("cv").getContext("2d");__mosio.onSeek(t=>{cx.fillStyle="#1e293b";cx.fillRect(0,0,900,900);for(let i=0;i<24;i++){cx.fillStyle=`hsl(${i*15+t*90},80%,60%)`;const a=t*2+i*0.26;cx.beginPath();cx.arc(450+Math.cos(a)*(120+i*12),450+Math.sin(a)*(120+i*12),26,0,7);cx.fill();}});
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #b{position:absolute;left:240px;top:700px;width:600px;height:600px;border-radius:50%;background:radial-gradient(#a78bfa,#4c1d95)}</style></head><body><div class="lbl">CSS filter blur + drop-shadow</div>
8
+ <div id="b"></div>
9
+ <script>
10
+ const tl=gsap.timeline({paused:true});tl.fromTo("#b",{filter:"blur(0px) drop-shadow(0 0 0 #f0f)"},{filter:"blur(24px) drop-shadow(40px 40px 0 #f0f)",duration:2},0);__mosio.timeline(tl);
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #a{position:absolute;left:0;top:0;width:1080px;height:960px;background:linear-gradient(#101014,#1c1c24)}#b{position:absolute;left:0;top:960px;width:1080px;height:960px;background:radial-gradient(circle at 50% 40%,#ff6b6b,#5f27cd 60%,#0b0b1a)}</style></head><body><div class="lbl">gradients (banding)</div>
8
+ <div id="a"></div><div id="b"></div>
9
+ <script>
10
+ const tl=gsap.timeline({paused:true});tl.fromTo("#b",{opacity:.6},{opacity:1,duration:2},0);__mosio.timeline(tl);
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ iframe{position:absolute;left:90px;top:400px;width:900px;height:1200px;border:0;background:#fff}</style></head><body><div class="lbl">iframe (same origin)</div>
8
+ <iframe id="f" srcdoc="<body style=&quot;margin:0;background:#fde68a;font:80px sans-serif&quot;><div style=&quot;padding:80px&quot;>inside iframe</div></body>"></iframe>
9
+ <script>
10
+ const tl=gsap.timeline({paused:true});tl.fromTo("#f",{rotation:-8},{rotation:8,duration:2},0);__mosio.timeline(tl);
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #i{position:absolute;left:140px;top:500px;width:800px;height:800px;border-radius:48px}</style></head><body><div class="lbl">img + WAAPI</div>
8
+ <img id="i" src="/assets/image.png">
9
+ <script>
10
+ document.getElementById("i").animate([{transform:"rotate(0deg) scale(.7)"},{transform:"rotate(30deg) scale(1)"}],{duration:2000,iterations:Infinity,direction:"alternate",easing:"ease-in-out"});
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ svg{position:absolute;left:90px;top:400px}</style></head><body><div class="lbl">inline SVG + SVG filter</div>
8
+ <svg width="900" height="900" viewBox="0 0 900 900"><defs><filter id="g"><feGaussianBlur stdDeviation="6"/></filter><linearGradient id="lg"><stop offset="0" stop-color="#f59e0b"/><stop offset="1" stop-color="#ef4444"/></linearGradient></defs><circle id="c" cx="450" cy="450" r="200" fill="url(#lg)" filter="url(#g)"/><path id="p" d="M100 800 Q450 100 800 800" stroke="#22d3ee" stroke-width="18" fill="none" stroke-dasharray="1200" stroke-dashoffset="1200"/></svg>
9
+ <script>
10
+ const tl=gsap.timeline({paused:true});tl.to("#c",{attr:{r:380},duration:2,ease:"sine.inOut"},0).to("#p",{attr:{"stroke-dashoffset":0},duration:2},0);__mosio.timeline(tl);
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #t{position:absolute;left:0;top:800px;width:1080px;text-align:center;font-weight:800;font-size:140px;animation:pop 2s ease-in-out infinite alternate}@keyframes pop{from{transform:scale(.6) rotate(-6deg);opacity:.2}to{transform:scale(1.1) rotate(4deg);opacity:1}}</style></head><body><div class="lbl">text + CSS @keyframes</div>
8
+ <div id="t">Wobble Ag</div>
9
+ <script>
10
+
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ .r{position:absolute;left:40px;white-space:nowrap}</style></head><body><div class="lbl">typography</div>
8
+ <div class="r" style="top:140px;font-weight:800;font-size:200px;letter-spacing:-6px">Besar</div><div class="r" style="top:400px;font-weight:500;font-size:64px">Medium 500: Selamat pagi, Indonesia!</div><div class="r" style="top:500px;font-weight:800;font-size:64px">ExtraBold 800: Rp 1.250.000,-</div><div class="r" style="top:600px;font-weight:500;font-size:56px;letter-spacing:12px">TRACKING +12px</div><div class="r" style="top:700px;font-weight:800;font-size:56px;letter-spacing:-3px">Kerning AV To Wa Ty</div><div class="r" style="top:800px;font-weight:500;font-size:64px">Emoji: 🎬✨🚀🇮🇩😀</div><div class="r" style="top:920px;font-weight:500;font-size:14px;width:1000px;white-space:normal">Teks kecil 14px: Pemerintah menetapkan bahwa setiap warga negara berhak atas pendidikan yang layak, dan negara wajib membiayainya sesuai undang-undang yang berlaku.</div><div class="r" style="top:980px;font-weight:500;font-size:22px;width:1000px;white-space:normal;color:#cbd5e1">Teks 22px abu-abu di atas latar gelap: anti-aliasing tepi huruf dibandingkan langsung.</div><div class="r" id="mv" style="top:1100px;font-weight:800;font-size:96px">Gerak halus →</div><div class="r" id="cnt" style="top:1300px;font-weight:800;font-size:160px;font-variant-numeric:tabular-nums">0</div>
9
+ <script>
10
+ const tl=gsap.timeline({paused:true});tl.fromTo("#mv",{x:0},{x:180,duration:2,ease:"none"},0);const o={v:0};tl.to(o,{v:9999,duration:2,ease:"none",onUpdate:()=>{document.getElementById("cnt").textContent=Math.round(o.v).toLocaleString("id-ID")}},0);__mosio.timeline(tl);
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #v{position:absolute;left:90px;top:300px;width:900px;height:1600px;object-fit:cover;border-radius:32px}</style></head><body><div class="lbl">&lt;video&gt; clip A</div>
8
+ <video id="v" src="/assets/clip.mp4" muted playsinline preload="auto"></video>
9
+ <script>
10
+
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #v{position:absolute;left:0;top:0;width:1080px;height:1920px;object-fit:fill}.lbl{display:none}</style></head><body><div class="lbl">&lt;video&gt; clip B (cut, full frame: compared with the decoded clip)</div>
8
+ <video id="v" src="/assets/clip.mp4" muted playsinline preload="auto"></video>
9
+ <script>
10
+
11
+ </script></body></html>
@@ -0,0 +1,49 @@
1
+ {
2
+ "mosio": 1,
3
+ "name": "features-xfade",
4
+ "width": 1080,
5
+ "height": 1920,
6
+ "fps": 30,
7
+ "seed": 1,
8
+ "background": "#000000",
9
+ "libraries": [
10
+ "gsap@3.15.1"
11
+ ],
12
+ "shared": [],
13
+ "assets": [
14
+ "assets/fonts/Inter-ExtraBold.ttf",
15
+ "assets/fonts/Inter-Medium.ttf",
16
+ "assets/image.png",
17
+ "assets/clip.mp4"
18
+ ],
19
+ "scenes": [
20
+ {
21
+ "id": "video",
22
+ "src": "scenes/video.html",
23
+ "frames": 60
24
+ },
25
+ {
26
+ "id": "image",
27
+ "src": "scenes/image.html",
28
+ "frames": 60
29
+ }
30
+ ],
31
+ "transitions": [
32
+ {
33
+ "from": "video",
34
+ "to": "image",
35
+ "kind": "crossfade",
36
+ "frames": 15
37
+ }
38
+ ],
39
+ "audio": [],
40
+ "output": {
41
+ "default": {
42
+ "codec": "h264",
43
+ "crf": 18,
44
+ "preset": "medium",
45
+ "pix_fmt": "yuv420p",
46
+ "gop_frames": 30
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #i{position:absolute;left:140px;top:500px;width:800px;height:800px;border-radius:48px}</style></head><body><div class="lbl">img + WAAPI</div>
8
+ <img id="i" src="/assets/image.png">
9
+ <script>
10
+ document.getElementById("i").animate([{transform:"rotate(0deg) scale(.7)"},{transform:"rotate(30deg) scale(1)"}],{duration:2000,iterations:Infinity,direction:"alternate",easing:"ease-in-out"});
11
+ </script></body></html>
@@ -0,0 +1,11 @@
1
+ <!doctype html><html lang="id"><head><meta charset="utf-8">
2
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
3
+ <style>@font-face{font-family:"Inter";font-weight:800;src:url("/assets/fonts/Inter-ExtraBold.ttf") format("truetype")}
4
+ @font-face{font-family:"Inter";font-weight:500;src:url("/assets/fonts/Inter-Medium.ttf") format("truetype")}
5
+ *{margin:0;padding:0;box-sizing:border-box}html,body{width:1080px;height:1920px;overflow:hidden;background:#0f172a;font-family:"Inter",sans-serif;color:#fff}
6
+ .lbl{position:absolute;left:40px;top:40px;font-weight:800;font-size:48px}
7
+ #v{position:absolute;left:90px;top:300px;width:900px;height:1600px;object-fit:cover;border-radius:32px}</style></head><body><div class="lbl">&lt;video&gt; clip A</div>
8
+ <video id="v" src="/assets/clip.mp4" muted playsinline preload="auto"></video>
9
+ <script>
10
+
11
+ </script></body></html>
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env python3
2
+ """Layout regression fixtures for `--capture canvas` (docs/design/fast-path.md, "Page layout"): compositions without a
3
+ CSS reset, where the body's own box and the root background decide what a screenshot shows. A canvas render of each
4
+ must match its png render (SSIM >= 0.99). Usage: gen_layout.py <out dir>; writes one project per fixture."""
5
+ import json
6
+ import os
7
+ import sys
8
+
9
+ ANIM = """
10
+ <script>
11
+ const tl = gsap.timeline({ paused: true });
12
+ tl.from(".card", { y: 120, opacity: 0, duration: 0.8, stagger: 0.15, ease: "power2.out" })
13
+ .to(".bar", { width: "100%", duration: 1.5, ease: "none" }, 0.2)
14
+ .to(".dot", { x: 600, rotation: 360, duration: 2, ease: "sine.inOut" }, 0);
15
+ window.__mosio.timeline(tl);
16
+ </script>
17
+ """
18
+
19
+ CONTENT = """
20
+ <div id="root">
21
+ <h1>Tanpa reset CSS</h1>
22
+ <p>Margin bawaan body 8px, latar dari html/body, konten tidak penuh layar.</p>
23
+ <div class="card">Kartu satu</div>
24
+ <div class="card">Kartu dua</div>
25
+ <div class="track"><div class="bar"></div></div>
26
+ <div class="dot"></div>
27
+ </div>
28
+ """
29
+
30
+ BASE_CSS = """
31
+ #root{width:900px}
32
+ h1{font:700 72px sans-serif;color:#111827}
33
+ p{font:400 36px/1.4 sans-serif;color:#374151}
34
+ .card{margin:24px 0;padding:32px;background:#2563eb;color:#fff;font:600 44px sans-serif;border-radius:16px}
35
+ .track{height:24px;background:#e5e7eb;margin-top:40px}
36
+ .bar{height:24px;width:0;background:#f59e0b}
37
+ .dot{width:80px;height:80px;border-radius:40px;background:#10b981;margin-top:40px}
38
+ """
39
+
40
+ FIXTURES = {
41
+ # default margin, no background anywhere: the browser's white base shows around and below the content
42
+ "l10a-noreset-nobg": "",
43
+ # default margin, body white
44
+ "l10b-noreset-bodybg": "body{background:#ffffff}",
45
+ # body as a flex box centring the content in the viewport, its own background, no margin
46
+ "l10c-body-flex": "body{display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0;background:#f3f4f6}",
47
+ # html and body both painted: html fills the viewport, the body box (margin, padding, border, radius) shows on it
48
+ "l10d-html-and-body-bg": "html{background:#111827}body{background:#fde68a;margin:40px;padding:24px;border:6px solid #ef4444;border-radius:24px}",
49
+ # positioned body with a margin: absolute children place themselves against the body box
50
+ "l10e-body-relative": "body{position:relative;margin:60px;background:#ecfeff}.dot{position:absolute;right:0;top:300px}",
51
+ # html with its own box and inherited text settings: margin, padding, border, font, colour, line height, rtl
52
+ "l10f-html-box": "html{margin:30px;padding:20px;border:8px solid #7c3aed;background:#fff7ed;font-family:serif;"
53
+ "color:#7c2d12;line-height:2;direction:rtl}body{margin:12px}h1{font-family:inherit;color:inherit}",
54
+ }
55
+
56
+
57
+ def project(name):
58
+ return {
59
+ "mosio": 1, "name": f"canvas-qa-{name}", "width": 1080, "height": 1920, "fps": 30, "seed": 1,
60
+ "background": "#000000", "libraries": ["gsap@3.15.1"], "shared": [], "assets": [],
61
+ "scenes": [{"id": "main", "src": "scenes/main.html", "frames": 90}], "transitions": [], "audio": [],
62
+ "output": {"default": {"codec": "h264", "crf": 18, "preset": "medium", "pix_fmt": "yuv420p", "gop_frames": 30}},
63
+ }
64
+
65
+
66
+ def main(out):
67
+ for name, css in FIXTURES.items():
68
+ d = os.path.join(out, name)
69
+ os.makedirs(os.path.join(d, "scenes"), exist_ok=True)
70
+ with open(os.path.join(d, "mosio.json"), "w") as f:
71
+ json.dump(project(name), f, indent=2)
72
+ html = ("<!doctype html>\n<html lang=\"id\">\n<head>\n<meta charset=\"utf-8\">\n"
73
+ "<script src=\"/_lib/gsap@3.15.1/gsap.min.js\"></script>\n"
74
+ f"<style>{BASE_CSS}{css}</style>\n</head>\n<body>{CONTENT}{ANIM}</body>\n</html>\n")
75
+ with open(os.path.join(d, "scenes", "main.html"), "w") as f:
76
+ f.write(html)
77
+
78
+
79
+ if __name__ == "__main__":
80
+ main(sys.argv[1])
@@ -0,0 +1,34 @@
1
+ {
2
+ "mosio": 1,
3
+ "name": "canvas-qa-l12-no-reset",
4
+ "width": 1080,
5
+ "height": 1920,
6
+ "fps": 30,
7
+ "seed": 1,
8
+ "background": "#000000",
9
+ "libraries": [
10
+ "gsap@3.15.1"
11
+ ],
12
+ "shared": [],
13
+ "assets": [
14
+ "assets/img/photo-1015.jpg"
15
+ ],
16
+ "scenes": [
17
+ {
18
+ "id": "main",
19
+ "src": "scenes/main.html",
20
+ "frames": 180
21
+ }
22
+ ],
23
+ "transitions": [],
24
+ "audio": [],
25
+ "output": {
26
+ "default": {
27
+ "codec": "h264",
28
+ "crf": 18,
29
+ "preset": "medium",
30
+ "pix_fmt": "yuv420p",
31
+ "gop_frames": 30
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,20 @@
1
+ <!doctype html>
2
+ <html lang="id">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <script src="/_lib/gsap@3.15.1/gsap.min.js"></script>
6
+ </head>
7
+ <body>
8
+ <h1>Judul tanpa reset CSS</h1>
9
+ <p>Paragraf biasa dengan margin bawaan browser. Tidak ada latar, tidak ada ukuran pada html/body.</p>
10
+ <img src="/assets/img/photo-1015.jpg" width="600" height="400" alt="">
11
+ <div id="box" style="width:300px;height:200px;background:#2563eb;color:#fff">kotak bergerak</div>
12
+ <ul><li>satu</li><li>dua</li><li>tiga</li></ul>
13
+ <script>
14
+ const tl = gsap.timeline({ paused: true });
15
+ tl.fromTo("#box", { x: 0 }, { x: 500, duration: 5, ease: "power1.inOut" }, 0);
16
+ tl.to({}, { duration: 6 }, 0);
17
+ __mosio.timeline(tl);
18
+ </script>
19
+ </body>
20
+ </html>
@@ -0,0 +1,91 @@
1
+ // node fp.mjs <chrome> <project dir> <out.mp4> [workers] [mode]
2
+ // mode: canvas (default, in-page H.264) | raw (in-page drawElementImage, raw RGBA to x264 outside) | shot (Mosio-like beginFrame PNG)
3
+ import { launch, newPage } from './cdp.mjs'
4
+ import { serve } from './srv.mjs'
5
+ import fs from 'node:fs'; import path from 'node:path'; import { execFileSync, spawn } from 'node:child_process'
6
+ const [bin, proj, out, workersArg = '1', mode = 'canvas'] = process.argv.slice(2)
7
+ const env = process.env
8
+ const bench = env.BENCH_DIR || path.resolve(proj, '../../..')
9
+ const P = JSON.parse(fs.readFileSync(path.join(proj, 'mosio.json'), 'utf8'))
10
+ const sc = P.scenes[0]; const W = P.width, H = P.height, fps = P.fps, N = +(env.FRAMES || sc.frames)
11
+ const workers = +workersArg
12
+ const sinks = new Map()
13
+ // x264 mode: frames POSTed to /_sink/x264/<slice start>/<frame> go straight into that slice's ffmpeg (CRF 18 medium,
14
+ // the bench/Mosio default preset); each page awaits its POST, so a slice's frames arrive in order
15
+ const x264 = new Map(); const tmpd = fs.mkdtempSync('/tmp/fpx-')
16
+ const x264Args = (out) => ['-v', 'error', '-y', '-f', 'rawvideo', '-pix_fmt', 'rgba', '-s', `${W}x${H}`, '-r', String(fps), '-i', '-', '-c:v', 'libx264', '-preset', env.X264_PRESET || 'medium', '-crf', env.CRF || '18', '-pix_fmt', 'yuv420p', '-g', '60', '-color_range', 'tv', '-colorspace', 'bt709', '-color_primaries', 'bt709', '-color_trc', 'bt709', '-threads', env.X264_THREADS || '0', out]
17
+ const srv = await serve([['/_lib/gsap@3.15.1/', path.join(bench, 'vendor')], ['/assets/', path.join(bench, 'assets')], ['/', proj]],
18
+ (u, body) => {
19
+ const m = u.match(/^\/_sink\/x264\/(\d+)\/(\d+)$/)
20
+ if (!m) return sinks.set(u, body)
21
+ let e = x264.get(m[1])
22
+ if (!e) { const out = `${tmpd}/s${m[1].padStart(6, '0')}.mp4`; const ff = spawn('ffmpeg', x264Args(out), { stdio: ['pipe', 'inherit', 'inherit'] }); e = { ff, out, done: new Promise(r => ff.on('close', r)) }; x264.set(m[1], e) }
23
+ return new Promise(r => e.ff.stdin.write(body) ? r() : e.ff.stdin.once('drain', r))
24
+ })
25
+ const inpage = fs.readFileSync(new URL('./inpage.js', import.meta.url), 'utf8')
26
+ const flags = ['--disable-gpu', '--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--disable-background-timer-throttling',
27
+ '--disable-renderer-backgrounding', '--disable-backgrounding-occluded-windows', '--disable-frame-rate-limit', '--disable-gpu-vsync',
28
+ '--force-color-profile=srgb', '--hide-scrollbars', '--font-render-hinting=none', ...(env.EXTRA_FLAGS || '').split(' ').filter(Boolean)]
29
+ const tmp = fs.mkdtempSync('/tmp/fp-'); const T0 = performance.now()
30
+ const b = await launch(bin, flags)
31
+ const tLaunch = performance.now() - T0
32
+ const ranges = []; const per = Math.ceil(N / workers / 30) * 30
33
+ for (let s = 0; s < N; s += per) ranges.push([s, Math.min(N, s + per)])
34
+ const results = await Promise.all(ranges.map(async ([start, end]) => {
35
+ const pg = await newPage(b, W, H, { beginFrame: mode === 'shot' })
36
+ await pg.s('Page.addScriptToEvaluateOnNewDocument', { source: inpage })
37
+ const tl0 = performance.now()
38
+ await pg.s('Page.navigate', { url: srv.url + '/' + sc.src })
39
+ for (let i = 0; i < 200; i++) { try { if (await pg.ev('!!(window.__tl && document.readyState === "complete")', false)) break } catch {} ; await new Promise(r => setTimeout(r, 25)) }
40
+ const load = performance.now() - tl0
41
+ if (mode === 'shot') {
42
+ let ticks = 10000, tSeek = 0, tShot = 0, tDec = 0; const iv = 1000 / fps; const frames = []
43
+ await pg.s('HeadlessExperimental.beginFrame', { frameTimeTicks: ticks, interval: iv })
44
+ for (let f = start; f < end; f++) {
45
+ let a = performance.now(); await pg.ev(`window.__tl.seek(${f}/${fps}, false), 1`, false); tSeek += performance.now() - a
46
+ a = performance.now(); ticks += iv
47
+ const r = await pg.s('HeadlessExperimental.beginFrame', { frameTimeTicks: ticks, interval: iv, screenshot: { format: 'png', optimizeForSpeed: true } })
48
+ tShot += performance.now() - a
49
+ if (r.screenshotData) { const buf = Buffer.from(r.screenshotData, 'base64'); if (env.KEEP_PNG) fs.writeFileSync(`${tmp}/s${String(f).padStart(5, '0')}.png`, buf) }
50
+ }
51
+ return { start, end, load, frames: end - start, loop: tSeek + tShot, t: { seek: tSeek, shot: tShot } }
52
+ }
53
+ const r = await pg.ev(`__fp.run(${JSON.stringify({ width: W, height: H, fps, start, end, gop: 30, cpu: !!env.CPU, src: env.SRC || 'canvas', encode: mode === 'canvas', raw: mode === 'raw' || mode === 'x264', sink: mode === 'x264' ? 'x264' : 'raw', hash: !!env.HASH,
54
+ codec: env.CODEC || 'avc1.640028', bitrate: +(env.BITRATE || 12e6), bitrateMode: env.BRMODE || 'variable', qp: +(env.QP || 20) })})`)
55
+ return { start, end, load, ...r }
56
+ }))
57
+ const tRender = performance.now() - T0
58
+ // mux: each worker's annexb stream -> concat -> mp4 (stream copy)
59
+ let tMux = 0
60
+ if (mode === 'canvas') {
61
+ const a = performance.now()
62
+ const parts = ranges.map(([s]) => { const f = `${tmp}/p${s}.h264`; fs.writeFileSync(f, sinks.get('/_sink/h264/' + s)); return f })
63
+ fs.writeFileSync(`${tmp}/all.h264`, Buffer.concat(parts.map(p => fs.readFileSync(p))))
64
+ execFileSync('ffmpeg', ['-v', 'error', '-y', '-r', String(fps), '-f', 'h264', '-i', `${tmp}/all.h264`, '-c', 'copy', '-movflags', '+faststart', out])
65
+ tMux = performance.now() - a
66
+ }
67
+ if (mode === 'x264') {
68
+ const a = performance.now()
69
+ for (const e of x264.values()) e.ff.stdin.end()
70
+ await Promise.all([...x264.values()].map(e => e.done))
71
+ const list = [...x264.values()].map(e => e.out).sort()
72
+ fs.writeFileSync(`${tmpd}/list.txt`, list.map(f => `file '${f}'`).join('\n'))
73
+ execFileSync('ffmpeg', ['-v', 'error', '-y', '-f', 'concat', '-safe', '0', '-i', `${tmpd}/list.txt`, '-c', 'copy', '-movflags', '+faststart', out])
74
+ tMux = performance.now() - a
75
+ }
76
+ if (mode === 'raw') {
77
+ const a = performance.now()
78
+ const ff = spawn('ffmpeg', ['-v', 'error', '-y', '-f', 'rawvideo', '-pix_fmt', 'rgba', '-s', `${W}x${H}`, '-r', String(fps), '-i', '-', '-c:v', 'libx264', ...(env.RAW_LOSSLESS === '0' ? ['-crf', '18', '-preset', 'medium'] : ['-qp', '0', '-preset', 'ultrafast']), '-pix_fmt', 'yuv420p', out], { stdio: ['pipe', 'inherit', 'inherit'] })
79
+ for (let f = 0; f < N; f++) { if (!ff.stdin.write(sinks.get('/_sink/raw/' + f))) await new Promise(r => ff.stdin.once('drain', r)) }
80
+ ff.stdin.end(); await new Promise(r => ff.on('close', r)); tMux = performance.now() - a
81
+ }
82
+ const total = performance.now() - T0
83
+ b.close(); srv.close()
84
+ const sum = k => results.reduce((x, r) => x + (r.t?.[k] || 0), 0)
85
+ const frames = results.reduce((x, r) => x + r.frames, 0)
86
+ const rep = { mode, project: P.name, workers: ranges.length, frames, total_ms: Math.round(total), launch_ms: Math.round(tLaunch), render_ms: Math.round(tRender), mux_ms: Math.round(tMux),
87
+ per_frame_ms: Object.fromEntries(['seek', 'paint', 'draw', 'frame', 'encode', 'raw', 'shot'].map(k => [k, +(sum(k) / frames).toFixed(2)])),
88
+ loop_ms: results.map(r => Math.round(r.loop)), load_ms: results.map(r => Math.round(r.load)), flush_ms: results.map(r => Math.round(r.flush || 0)),
89
+ bytes: mode !== 'raw' && mode !== 'shot' ? fs.statSync(out).size : (fs.existsSync(out) ? fs.statSync(out).size : 0), tmp }
90
+ if (env.HASH) fs.writeFileSync(out + '.hashes', results.flatMap(r => r.hashes).join('\n') + '\n')
91
+ console.log(JSON.stringify(rep))
@@ -0,0 +1,68 @@
1
+ // Injected before the scene's own scripts. Collects the GSAP timeline, and exposes __fp.run(opts):
2
+ // moves #root (or body's children) into <canvas layoutsubtree>, then for each frame: seek -> requestPaint ->
3
+ // paint event -> drawElementImage -> VideoFrame -> VideoEncoder (H.264 annexb). Chunks stay in the page and are
4
+ // POSTed once at the end.
5
+ window.__mosio = { timeline(tl) { window.__tl = tl } }
6
+ window.__fp = {
7
+ async run(o) {
8
+ await document.fonts.ready
9
+ await Promise.all([...document.images].map(i => i.decode().catch(() => {})))
10
+ const W = o.width, H = o.height, fps = o.fps
11
+ const c = document.createElement('canvas')
12
+ c.setAttribute('content', 'drawable'); c.setAttribute('layoutsubtree', ''); c.width = W; c.height = H
13
+ c.style.cssText = `display:block;width:${W}px;height:${H}px`
14
+ const kids = [...document.body.childNodes].filter(n => n.nodeName !== 'SCRIPT')
15
+ document.body.prepend(c); for (const k of kids) c.appendChild(k)
16
+ const ctx = c.getContext('2d', { alpha: false, willReadFrequently: !!o.cpu })
17
+ const el = c.firstElementChild; el.setAttribute('drawable', '')
18
+ const chunks = []; let bytes = 0; let encErr = null
19
+ const t = { seek: 0, paint: 0, draw: 0, frame: 0, encode: 0, raw: 0 }
20
+ const enc = o.encode ? new VideoEncoder({
21
+ output: ch => { const b = new Uint8Array(ch.byteLength); ch.copyTo(b); chunks.push(b); bytes += b.length },
22
+ error: e => { encErr = String(e) },
23
+ }) : null
24
+ if (enc) enc.configure({ codec: o.codec, width: W, height: H, framerate: fps, bitrate: o.bitrate, bitrateMode: o.bitrateMode,
25
+ latencyMode: 'quality', avc: { format: 'annexb' }, hardwareAcceleration: 'prefer-software' })
26
+ const hashes = []
27
+ const now = () => performance.now()
28
+ const T0 = now()
29
+ for (let f = o.start; f < o.end; f++) {
30
+ let a = now()
31
+ window.__tl.seek(f / fps, false)
32
+ t.seek += now() - a; a = now()
33
+ await new Promise(res => { c.onpaint = () => { const b = now(); t.paint += b - a; ctx.drawElementImage(el, 0, 0); t.draw += now() - b; res() }; c.requestPaint() })
34
+ if (o.hash || o.raw) {
35
+ a = now()
36
+ const px = ctx.getImageData(0, 0, W, H).data
37
+ if (o.hash) hashes.push(Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', px)).slice(0, 8)).map(x => x.toString(16).padStart(2, '0')).join(''))
38
+ if (o.raw) await fetch(o.sink === 'x264' ? `/_sink/x264/${o.start}/${f}` : '/_sink/raw/' + f, { method: 'POST', body: px })
39
+ t.raw += now() - a
40
+ }
41
+ if (enc) {
42
+ a = now()
43
+ const ts = { timestamp: Math.round((f - o.start) * 1e6 / fps), duration: Math.round(1e6 / fps) }
44
+ let vf
45
+ if (o.src === 'imagedata') {
46
+ const px = ctx.getImageData(0, 0, W, H).data
47
+ vf = new VideoFrame(px, { format: 'RGBX', codedWidth: W, codedHeight: H, ...ts })
48
+ } else if (o.src === 'bitmap') {
49
+ const bm = await createImageBitmap(c); vf = new VideoFrame(bm, ts); bm.close()
50
+ } else vf = new VideoFrame(c, ts)
51
+ t.frame += now() - a; a = now()
52
+ const key = (f - o.start) % o.gop === 0
53
+ enc.encode(vf, o.bitrateMode === 'quantizer' ? { keyFrame: key, avc: { quantizer: o.qp } } : { keyFrame: key })
54
+ vf.close()
55
+ // backpressure: keep the encoder queue short so memory stays flat
56
+ while (enc.encodeQueueSize > 2) await new Promise(r => enc.addEventListener('dequeue', r, { once: true }))
57
+ t.encode += now() - a
58
+ }
59
+ if (encErr) throw new Error(encErr)
60
+ }
61
+ let flush = 0
62
+ if (enc) { const a = now(); await enc.flush(); flush = now() - a; enc.close() }
63
+ const loop = now() - T0
64
+ let post = 0
65
+ if (enc) { const a = now(); await fetch('/_sink/h264/' + o.start, { method: 'POST', body: new Blob(chunks) }); post = now() - a }
66
+ return { frames: o.end - o.start, loop, flush, post, bytes, t, hashes }
67
+ },
68
+ }
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env python3
2
+ """Convert the platform recipes' example compositions (HyperFrames) into Mosio projects for the canvas coverage test
3
+ (docs/design/fast-path.md): python3 recipes.py <mosio> <platform repo> <out dir> [frames]
4
+ Each recipe's example-9x16.html (else example.html) is imported with `mosio import-hyperframes`, its vendored GSAP is
5
+ pointed at Mosio's pinned library, and every scene is cut to `frames` frames (default 90)."""
6
+ import json, os, re, shutil, subprocess, sys
7
+
8
+ mosio, platform, out = sys.argv[1:4]
9
+ frames = int(sys.argv[4]) if len(sys.argv) > 4 else 90
10
+ recipes = os.path.join(platform, "recipes")
11
+ vendor = os.path.join(platform, "apps", "frames", "vendor")
12
+ tmp = os.path.join(out, "_src")
13
+ os.makedirs(out, exist_ok=True)
14
+ ok, failed = [], []
15
+ for name in sorted(os.listdir(recipes)):
16
+ d = os.path.join(recipes, name)
17
+ ex = next((os.path.join(d, f) for f in ("example-9x16.html", "example.html") if os.path.isfile(os.path.join(d, f))), None)
18
+ if not ex:
19
+ continue
20
+ src = os.path.join(tmp, name)
21
+ shutil.rmtree(src, ignore_errors=True)
22
+ os.makedirs(src)
23
+ shutil.copy(ex, os.path.join(src, "index.html"))
24
+ shutil.copytree(vendor, os.path.join(src, "vendor"))
25
+ dst = os.path.join(out, name)
26
+ shutil.rmtree(dst, ignore_errors=True)
27
+ r = subprocess.run([mosio, "import-hyperframes", src, dst], capture_output=True, text=True)
28
+ if r.returncode != 0:
29
+ failed.append((name, (r.stdout + r.stderr).strip()[-200:]))
30
+ continue
31
+ m = json.load(open(os.path.join(dst, "mosio.json")))
32
+ for s in m["scenes"]:
33
+ p = os.path.join(dst, s["src"])
34
+ h = open(p).read()
35
+ h = re.sub(r'src="vendor/([A-Za-z]+)\.min\.js"', r'src="/_lib/gsap@3.15.1/\1.min.js"', h)
36
+ open(p, "w").write(h)
37
+ s["frames"] = min(s["frames"], frames)
38
+ # keep only the vendored files the scenes name (every recipe got the whole font folder)
39
+ used = "".join(open(os.path.join(dst, s["src"])).read() for s in m["scenes"])
40
+ keep = [a for a in m.get("assets", []) if not a.startswith("vendor/") or os.path.basename(a) in used]
41
+ for a in m.get("assets", []):
42
+ if a not in keep:
43
+ os.remove(os.path.join(dst, a))
44
+ m["assets"] = keep
45
+ m["libraries"] = ["gsap@3.15.1"]
46
+ json.dump(m, open(os.path.join(dst, "mosio.json"), "w"), indent=2)
47
+ ok.append(name)
48
+ shutil.rmtree(tmp, ignore_errors=True)
49
+ print(json.dumps({"converted": len(ok), "failed": failed}, indent=1))