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

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 (163) hide show
  1. package/THIRD_PARTY_NOTICES.md +22 -0
  2. package/apps/studio/dist/assets/Workspace-DsbQ04kb.js +34 -0
  3. package/apps/studio/dist/assets/{agent-panel-CqJuv5Sn.js → agent-panel-DUWPbpew.js} +5 -5
  4. package/apps/studio/dist/assets/{boundary-bK2S8z05.js → boundary-DuK3AiqM.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-CjDBKmB_.css +2 -0
  7. package/apps/studio/dist/assets/index-DPLtb0kT.js +1905 -0
  8. package/apps/studio/dist/assets/inspector3d-B8pkZTye.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 +111 -7
  14. package/crates/mosio/src/adapters/room-env-pmrem.json +1 -0
  15. package/crates/mosio/src/runtime.js +126 -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/inspect-physics/expect.json +18 -0
  28. package/fixtures/inspect-physics/mosio.json +29 -0
  29. package/fixtures/inspect-physics/scenes/calm.html +46 -0
  30. package/fixtures/inspect-physics/scenes/physics.html +47 -0
  31. package/package.json +1 -1
  32. package/primitives/README.md +23 -2
  33. package/primitives/example/shared/mosio-prims.js +349 -1
  34. package/primitives/impact-burst/golden/f030.png +0 -0
  35. package/primitives/impact-burst/golden/f032.png +0 -0
  36. package/primitives/impact-burst/golden/f036.png +0 -0
  37. package/primitives/impact-burst/impact-burst.js +51 -0
  38. package/primitives/impact-burst/primitive.json +130 -0
  39. package/primitives/impact-burst/scene.html +24 -0
  40. package/primitives/stick-figure/golden/f030.png +0 -0
  41. package/primitives/stick-figure/golden/f092.png +0 -0
  42. package/primitives/stick-figure/golden/f140.png +0 -0
  43. package/primitives/stick-figure/primitive.json +179 -0
  44. package/primitives/stick-figure/scene.html +40 -0
  45. package/primitives/stick-figure/stick-figure.js +297 -0
  46. package/primitives/zoom-through/primitive.json +7 -2
  47. package/primitives/zoom-through/zoom-through.js +6 -5
  48. package/scripts/3d-acceptance.sh +8 -1
  49. package/scripts/3d-attach-bench.mjs +119 -0
  50. package/scripts/3d-bake-room-env.mjs +74 -0
  51. package/scripts/3d-e2b-job.sh +1 -0
  52. package/scripts/3d-gen-heavy-fixture.py +65 -0
  53. package/scripts/3d-trace-summary.py +14 -0
  54. package/scripts/acceptance/camera-inspect.sh +49 -0
  55. package/scripts/acceptance/export.sh +5 -3
  56. package/scripts/acceptance/hardening.sh +37 -6
  57. package/scripts/acceptance/hub.sh +208 -0
  58. package/scripts/acceptance/inspect.sh +21 -2
  59. package/scripts/acceptance/revisions-git.sh +137 -0
  60. package/scripts/acceptance/revisions-sync.sh +323 -0
  61. package/scripts/acceptance/revisions.sh +118 -4
  62. package/scripts/acceptance/segcache.sh +100 -0
  63. package/scripts/acceptance/split.sh +78 -0
  64. package/scripts/bootstrap.sh +20 -1
  65. package/scripts/check-error-codes.py +8 -0
  66. package/scripts/check-file-size.sh +49 -0
  67. package/scripts/ci.sh +4 -4
  68. package/scripts/dedupe-report.sh +47 -0
  69. package/scripts/e2b/template/provision.sh +1 -1
  70. package/scripts/fastpath/cdp.mjs +25 -0
  71. package/scripts/fastpath/dbg.mjs +11 -0
  72. package/scripts/fastpath/e2b.mjs +40 -0
  73. package/scripts/fastpath/features/gen.py +109 -0
  74. package/scripts/fastpath/features/mosio.json +100 -0
  75. package/scripts/fastpath/features/scenes/backdrop.html +11 -0
  76. package/scripts/fastpath/features/scenes/blend.html +11 -0
  77. package/scripts/fastpath/features/scenes/canvas2d.html +11 -0
  78. package/scripts/fastpath/features/scenes/filter.html +11 -0
  79. package/scripts/fastpath/features/scenes/gradient.html +11 -0
  80. package/scripts/fastpath/features/scenes/iframe.html +11 -0
  81. package/scripts/fastpath/features/scenes/image.html +11 -0
  82. package/scripts/fastpath/features/scenes/svg.html +11 -0
  83. package/scripts/fastpath/features/scenes/text.html +11 -0
  84. package/scripts/fastpath/features/scenes/typo.html +11 -0
  85. package/scripts/fastpath/features/scenes/video.html +11 -0
  86. package/scripts/fastpath/features/scenes/video2.html +11 -0
  87. package/scripts/fastpath/features-xfade/mosio.json +49 -0
  88. package/scripts/fastpath/features-xfade/scenes/image.html +11 -0
  89. package/scripts/fastpath/features-xfade/scenes/video.html +11 -0
  90. package/scripts/fastpath/fixtures/gen_layout.py +80 -0
  91. package/scripts/fastpath/fixtures/l12-no-reset/assets/img/photo-1015.jpg +0 -0
  92. package/scripts/fastpath/fixtures/l12-no-reset/mosio.json +34 -0
  93. package/scripts/fastpath/fixtures/l12-no-reset/scenes/main.html +20 -0
  94. package/scripts/fastpath/fp.mjs +91 -0
  95. package/scripts/fastpath/inpage.js +68 -0
  96. package/scripts/fastpath/recipes.py +49 -0
  97. package/scripts/fastpath/sandbox.sh +68 -0
  98. package/scripts/fastpath/sandbox10.sh +57 -0
  99. package/scripts/fastpath/sandbox11.sh +18 -0
  100. package/scripts/fastpath/sandbox12.sh +30 -0
  101. package/scripts/fastpath/sandbox13.sh +16 -0
  102. package/scripts/fastpath/sandbox14.sh +28 -0
  103. package/scripts/fastpath/sandbox15.sh +36 -0
  104. package/scripts/fastpath/sandbox16.sh +60 -0
  105. package/scripts/fastpath/sandbox17.sh +34 -0
  106. package/scripts/fastpath/sandbox18.sh +59 -0
  107. package/scripts/fastpath/sandbox19.sh +67 -0
  108. package/scripts/fastpath/sandbox2.sh +41 -0
  109. package/scripts/fastpath/sandbox20.sh +34 -0
  110. package/scripts/fastpath/sandbox21.sh +22 -0
  111. package/scripts/fastpath/sandbox22.sh +22 -0
  112. package/scripts/fastpath/sandbox23.sh +21 -0
  113. package/scripts/fastpath/sandbox3.sh +151 -0
  114. package/scripts/fastpath/sandbox4.sh +161 -0
  115. package/scripts/fastpath/sandbox5.sh +69 -0
  116. package/scripts/fastpath/sandbox6.sh +85 -0
  117. package/scripts/fastpath/sandbox7.sh +81 -0
  118. package/scripts/fastpath/sandbox8.sh +62 -0
  119. package/scripts/fastpath/sandbox9.sh +130 -0
  120. package/scripts/fastpath/srv.mjs +15 -0
  121. package/scripts/fastpath/www/probe.html +1 -0
  122. package/scripts/hpbench/make-bench-fixtures.sh +43 -0
  123. package/scripts/hpbench/render-cgroup.sh +56 -0
  124. package/scripts/install.sh +2 -1
  125. package/scripts/npm-clean-install-proof-win.sh +64 -0
  126. package/scripts/platform-smoke.sh +67 -0
  127. package/scripts/prim.mjs +31 -13
  128. package/skills/mosio-3d/SKILL.md +1 -1
  129. package/skills/mosio-brief/SKILL.md +80 -0
  130. package/skills/mosio-brief/references/brief.md +141 -0
  131. package/skills/mosio-brief/references/copy.md +99 -0
  132. package/skills/mosio-brief/references/narration.md +61 -0
  133. package/skills/mosio-brief/references/storyboard.md +98 -0
  134. package/skills/mosio-collab/SKILL.md +104 -0
  135. package/skills/mosio-collab/references/hub.md +62 -0
  136. package/skills/mosio-engine/SKILL.md +44 -13
  137. package/skills/mosio-engine/references/camera.md +12 -2
  138. package/skills/mosio-engine/references/character.md +88 -0
  139. package/skills/mosio-engine/references/checks.md +10 -3
  140. package/skills/mosio-engine/references/delivery.md +29 -2
  141. package/skills/mosio-engine/references/kit-primitives.md +8 -4
  142. package/skills/mosio-engine/references/layout.md +8 -0
  143. package/skills/mosio-engine/references/plan.md +3 -1
  144. package/skills/mosio-engine/references/project.md +3 -3
  145. package/skills/mosio-engine/references/publish.md +79 -0
  146. package/skills/mosio-engine/references/registry.md +27 -15
  147. package/skills/mosio-engine/references/timeline.md +18 -0
  148. package/skills/mosio-engine/references/timing.md +2 -1
  149. package/skills/mosio-import/SKILL.md +1 -1
  150. package/skills/mosio-import/references/from-hyperframes.md +1 -1
  151. package/skills/mosio-import/references/from-remotion.md +1 -1
  152. package/skills/mosio-media/SKILL.md +16 -4
  153. package/skills/mosio-media/references/audio.md +29 -11
  154. package/skills/mosio-media/references/captions.md +22 -4
  155. package/skills/mosio-media/references/editing.md +70 -0
  156. package/skills/mosio-media/references/footage.md +40 -8
  157. package/skills/mosio-media/references/voice.md +52 -7
  158. package/skills/mosio-replicate/references/mosio.md +1 -1
  159. package/toolchain.lock.json +151 -4
  160. package/apps/studio/dist/assets/Workspace-KSOFeEgc.js +0 -32
  161. package/apps/studio/dist/assets/index-B-uuTqe9.js +0 -1785
  162. package/apps/studio/dist/assets/index-CajSh04l.css +0 -2
  163. package/apps/studio/dist/assets/inspector3d-vDz97X99.js +0 -1
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+ # Round 8 (FP_SCRIPT=sandbox8.sh): canvas coverage over the platform recipes (_local/recipes from recipes.py, not in
3
+ # git). Every recipe (90 frames) renders with png and with --capture canvas; per recipe: exit code, how many frames took
4
+ # the canvas path, the scenes that fell back and why, SSIM canvas vs png, both wall times. Result: $O/recipes.jsonl
5
+ set -uo pipefail
6
+ O=/home/user/out; W=/home/user/work; mkdir -p "$O" "$W"
7
+ export MOSIO_HOME=/opt/mosio
8
+ MOSIO=/home/user/mosio-custom
9
+ ms() { python3 -c 'import time;print(int(time.time()*1000))'; }
10
+ "$MOSIO" --version 2>/dev/null | head -1
11
+ for d in /home/user/fp/_local/recipes/*/; do
12
+ n=$(basename "$d")
13
+ rm -rf "$W/p" "$W/c"; cp -r "$d" "$W/p"; cp -r "$d" "$W/c"
14
+ t0=$(ms); timeout 600 "$MOSIO" render "$W/p" -o "$W/p.mp4" --workers 8 --no-cache > "$W/p.json" 2> /dev/null; prc=$?; t1=$(ms)
15
+ timeout 600 "$MOSIO" render "$W/c" -o "$W/c.mp4" --workers 8 --no-cache --capture canvas > "$W/c.json" 2> /dev/null; crc=$?; t2=$(ms)
16
+ ss=""
17
+ if [ $prc = 0 ] && [ $crc = 0 ]; then
18
+ ss=$(ffmpeg -v info -i "$W/c.mp4" -i "$W/p.mp4" -lavfi "[0:v]scale=in_range=auto:in_color_matrix=auto,format=gbrp[a];[1:v]scale=in_range=auto:in_color_matrix=auto,format=gbrp[b];[a][b]ssim=stats_file=$W/s.txt" -f null - 2>&1 | grep -o 'All:[0-9.]*' | tail -1 | cut -d: -f2)
19
+ smin=$(python3 -c 'import sys; print(min(float(l.split("All:")[1].split()[0]) for l in open(sys.argv[1])))' "$W/s.txt" 2>/dev/null)
20
+ fi
21
+ python3 - "$n" "$prc" "$crc" "$((t1 - t0))" "$((t2 - t1))" "${ss:-}" "${smin:-}" "$W/c.json" "$W/p.json" >> "$O/recipes.jsonl" <<'PY'
22
+ import json, sys
23
+ n, prc, crc, pms, cms, ss, smin, cj, pj = sys.argv[1:10]
24
+ row = {"recipe": n, "png_rc": int(prc), "canvas_rc": int(crc), "png_ms": int(pms), "canvas_ms": int(cms),
25
+ "ssim": float(ss) if ss else None, "ssim_min": float(smin) if smin else None}
26
+ try:
27
+ r = json.load(open(cj))
28
+ if r.get("ok") is False:
29
+ row["canvas_error"] = (r.get("error") or "")[:300]
30
+ e = r.get("execution") or {}
31
+ c = e.get("capture") or {}
32
+ row.update({"canvas_frames": c.get("canvas_frames"), "screenshot_frames": c.get("screenshot_frames"),
33
+ "fallback_scenes": [(s["scene"], s["why"][:160]) for s in c.get("screenshot_scenes", [])],
34
+ "mode": (e.get("encode") or {}).get("mode"), "warnings": [w["code"] + ": " + w["message"][:200] for w in r.get("warnings", [])]})
35
+ except Exception as x:
36
+ row["canvas_report"] = str(x)[:200]
37
+ try:
38
+ p = json.load(open(pj))
39
+ if p.get("ok") is False:
40
+ row["png_error"] = (p.get("error") or "")[:300]
41
+ except Exception:
42
+ pass
43
+ print(json.dumps(row))
44
+ PY
45
+ tail -1 "$O/recipes.jsonl" | cut -c1-260
46
+ done
47
+ python3 - "$O/recipes.jsonl" <<'PY'
48
+ import json, sys
49
+ rows = [json.loads(l) for l in open(sys.argv[1])]
50
+ ok = [r for r in rows if r["png_rc"] == 0]
51
+ full = [r for r in ok if r["canvas_rc"] == 0 and r.get("screenshot_frames") == 0]
52
+ part = [r for r in ok if r["canvas_rc"] == 0 and (r.get("screenshot_frames") or 0) > 0]
53
+ whole_fb = [r for r in ok if r["canvas_rc"] == 0 and any("W_CAPTURE_CANVAS_FALLBACK" in w for w in r.get("warnings", []))]
54
+ bad = [r for r in ok if r["canvas_rc"] != 0]
55
+ lowss = [r for r in full if r["ssim"] is not None and r["ssim"] < 0.98]
56
+ print(f"recipes {len(rows)}; png ok {len(ok)}; all-canvas {len(full)}; mixed {len(part)}; whole fallback {len(whole_fb)}; canvas failed {len(bad)}; all-canvas with SSIM<0.98 vs png: {len(lowss)}")
57
+ sp = [r["png_ms"] / r["canvas_ms"] for r in full if r["canvas_ms"]]
58
+ if sp:
59
+ sp.sort(); print(f"speedup png/canvas (all-canvas recipes): median {sp[len(sp)//2]:.2f} min {sp[0]:.2f} max {sp[-1]:.2f}")
60
+ for r in lowss + bad:
61
+ print("check", r["recipe"], r.get("ssim"), r.get("canvas_error", ""), r.get("fallback_scenes", ""))
62
+ PY
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env bash
2
+ # Round 9 (FP_SCRIPT=sandbox9.sh, MOSIO_BIN_FILE=<release build>): the per-worker sequential canvas scheduler.
3
+ # quality pack of the canvas path (direct output) against png and a lossless screenshot render:
4
+ # 1. features project, every scene on the canvas path (MOSIO_CANVAS_VIDEO=1 keeps the <video> scenes on it):
5
+ # per-scene SSIM, side-by-side frames, <video> frame accuracy, audio (PCM + click positions)
6
+ # 2. crossfade project: mixed output (bodies canvas, transition + <video> scene screenshots, concurrently)
7
+ # 3. VMAF of P1/P2 direct vs png against lossless
8
+ set -uo pipefail
9
+ cd /home/user/fp
10
+ B=/home/user/bench/engines/mosio; O=/home/user/out; W=/home/user/work; mkdir -p "$O" "$W"
11
+ export BENCH_DIR=/home/user/bench MOSIO_HOME=/opt/mosio
12
+ MOSIO=/home/user/mosio-custom
13
+ ms() { python3 -c 'import time;print(int(time.time()*1000))'; }
14
+ proj() { rm -rf "$2"; cp -r "$1" "$2"; mkdir -p "$2/assets"; cp -r /home/user/bench/assets/. "$2/assets/"; }
15
+ lossless() {
16
+ python3 - "$1/mosio.json" <<'PY'
17
+ import json, sys
18
+ m = json.load(open(sys.argv[1])); m.setdefault("output", {})["lossless"] = {"codec": "h264", "crf": 0, "preset": "ultrafast", "pix_fmt": "yuv420p", "gop_frames": 30}
19
+ json.dump(m, open(sys.argv[1], "w"))
20
+ PY
21
+ }
22
+ score() {
23
+ ffmpeg -v info -i "$1" -i "$2" -lavfi "[0:v]scale=in_range=auto:in_color_matrix=auto,format=gbrp[a];[1:v]scale=in_range=auto:in_color_matrix=auto,format=gbrp[b];[a]split[a1][a2];[b]split[b1][b2];[a1][b1]ssim;[a2][b2]psnr" -f null - > "$W/m.log" 2>&1
24
+ echo "ssim_$(grep -o 'All:[0-9.]*' "$W/m.log" | tail -1) psnr_$(grep -o 'average:[0-9.inf]*' "$W/m.log" | tail -1) bytes=$(stat -c %s "$1")"
25
+ }
26
+ summary() {
27
+ python3 - "$1" <<'PY' 2>/dev/null
28
+ import json, sys
29
+ r = json.load(open(sys.argv[1])); e = r["execution"]; sl = e["slices"]; n = sum(s["to"] - s["from"] for s in sl)
30
+ keys = sorted({k for s in sl for k in s["in_page_ms"] if k not in ("replayed",)})
31
+ st = {k: round(sum(s["in_page_ms"].get(k, 0) for s in sl) / n, 2) for k in keys}
32
+ print("slices", [(s["from"], s["to"]) for s in sl][:12], "replayed", [s["in_page_ms"].get("replayed") for s in sl][:12])
33
+ print(" per_frame", st)
34
+ print(" load_ms_max", max(round(s["load_ms"]) for s in sl), "replay_ms_max", round(max(s["in_page_ms"].get("replay", 0) for s in sl)),
35
+ "transcode_tail_ms_max", round(max(s["transcode_ms"] for s in sl)), "canvas_ms", e.get("canvas_ms"), "launch_ms", round(r["profile"]["browser_launch_ms"]),
36
+ "mux_ms", round(r["profile"]["concat_mux_ms"]), "warn", [w["code"] for w in r.get("warnings", [])])
37
+ PY
38
+ }
39
+ "$MOSIO" --version 2>/dev/null | head -1
40
+ mkdir -p "$O/frames"
41
+ (cd /home/user/fp/features && python3 gen.py)
42
+ proj /home/user/fp/features "$W/feat"; lossless "$W/feat"
43
+ "$MOSIO" render "$W/feat" -o "$W/feat-ref.mp4" --workers 8 --no-cache --preset lossless > /dev/null 2>&1; echo "feat ref rc=$?" | tee -a "$O/r9.txt"
44
+ proj /home/user/fp/features "$W/feat-png"
45
+ t0=$(ms); "$MOSIO" render "$W/feat-png" -o "$W/feat-png.mp4" --workers 8 --no-cache > /dev/null 2>&1; t1=$(ms); echo "feat png wall_ms=$((t1 - t0))" | tee -a "$O/r9.txt"
46
+ proj /home/user/fp/features "$W/feat-cv"
47
+ t0=$(ms); MOSIO_CANVAS_VIDEO=1 MOSIO_CANVAS_DRAINS=1 "$MOSIO" render "$W/feat-cv" -o "$W/feat-canvas.mp4" --workers 8 --no-cache --capture canvas > "$W/feat-canvas.json" 2> "$W/feat-canvas.err"; rc=$?; t1=$(ms)
48
+ cp "$W/feat-canvas.json" "$O/"
49
+ echo "feat canvas rc=$rc wall_ms=$((t1 - t0)) mode=$(python3 -c 'import json,sys; r=json.load(open(sys.argv[1])); print(r["execution"]["encode"]["mode"], r["execution"]["capture"]["canvas_frames"], r["execution"]["capture"]["screenshot_frames"])' "$W/feat-canvas.json" 2>&1 | tail -1)" | tee -a "$O/r9.txt"
50
+ for v in canvas png; do
51
+ ffmpeg -v info -i "$W/feat-$v.mp4" -i "$W/feat-ref.mp4" -lavfi "[0:v]scale=in_range=auto:in_color_matrix=auto,format=gbrp[a];[1:v]scale=in_range=auto:in_color_matrix=auto,format=gbrp[b];[a][b]ssim=stats_file=$W/feat-$v.ssim" -f null - > /dev/null 2>&1
52
+ done
53
+ python3 - "$W" "$W/feat/mosio.json" <<'PY' | tee -a "$O/r9.txt"
54
+ import json, sys
55
+ w, man = sys.argv[1:3]
56
+ def load(p):
57
+ v = {}
58
+ for line in open(p):
59
+ d = dict(kv.split(":", 1) for kv in line.split() if ":" in kv)
60
+ v[int(d["n"]) - 1] = float(d["All"])
61
+ return v
62
+ c, p = load(f"{w}/feat-canvas.ssim"), load(f"{w}/feat-png.ssim")
63
+ f = 0
64
+ print("scene canvas_vs_lossless(mean/min) png_vs_lossless(mean/min)")
65
+ for s in json.load(open(man))["scenes"]:
66
+ r = range(f, f + s["frames"])
67
+ a = [c[i] for i in r if i in c]; b = [p[i] for i in r if i in p]
68
+ print(f"{s['id']:10s} {sum(a)/len(a):.5f}/{min(a):.5f} {sum(b)/len(b):.5f}/{min(b):.5f}")
69
+ f += s["frames"]
70
+ PY
71
+ i=0
72
+ for s in text typo image video video2 svg filter blend backdrop gradient iframe canvas2d; do
73
+ f=$((i * 60 + 40))
74
+ ffmpeg -v error -y -i "$W/feat-canvas.mp4" -i "$W/feat-png.mp4" -filter_complex "[0:v]select=eq(n\,$f)[a];[1:v]select=eq(n\,$f)[b];[a][b]hstack" -frames:v 1 "$O/frames/fastpath-$s-canvas-vs-png.png"
75
+ i=$((i + 1))
76
+ done
77
+ # typography detail: 1:1 crop of the small text rows (canvas left, png right)
78
+ ffmpeg -v error -y -i "$W/feat-canvas.mp4" -i "$W/feat-png.mp4" -filter_complex "[0:v]select=eq(n\,100),crop=1080:200:0:900[a];[1:v]select=eq(n\,100),crop=1080:200:0:900[b];[a][b]vstack" -frames:v 1 "$O/frames/fastpath-typo-smalltext-crop.png"
79
+ # <video> frame accuracy: scene video2 (frames 240..299) is clip.mp4 full frame; frame k must be clip frame k
80
+ ffmpeg -v error -y -i /home/user/bench/assets/clip.mp4 -frames:v 62 -vf format=gbrp "$W/clip-%03d.png"
81
+ for v in canvas png; do
82
+ ffmpeg -v error -y -i "$W/feat-$v.mp4" -vf "select=between(n\,240\,299),scale=in_range=auto:in_color_matrix=auto,format=gbrp" -vsync 0 "$W/v2-$v-%03d.png"
83
+ python3 - "$W" "$v" <<'PY' | tee -a "$O/r9.txt"
84
+ import subprocess, sys, re
85
+ w, v = sys.argv[1], sys.argv[2]
86
+ def ssim(a, b):
87
+ out = subprocess.run(["ffmpeg", "-v", "info", "-i", a, "-i", b, "-lavfi", "ssim", "-f", "null", "-"], capture_output=True, text=True).stderr
88
+ m = re.findall(r"All:([0-9.]+)", out); return float(m[-1]) if m else 0.0
89
+ off = []
90
+ for k in range(0, 60, 6):
91
+ sc = {d: ssim(f"{w}/v2-{v}-{k + 1:03d}.png", f"{w}/clip-{k + 1 + d:03d}.png") for d in (-1, 0, 1) if 0 <= k + d < 62}
92
+ off.append(max(sc, key=sc.get))
93
+ print(f"video-accuracy {v}: best clip offset per sampled frame {off}")
94
+ PY
95
+ done
96
+ for v in canvas png; do ffmpeg -v error -y -i "$W/feat-$v.mp4" -map 0:a -f s16le -ac 1 -ar 48000 "$W/a-$v.pcm"; done
97
+ python3 - "$W" <<'PY' | tee -a "$O/r9.txt"
98
+ import sys, array, hashlib
99
+ w = sys.argv[1]; r = {}
100
+ for v in ("canvas", "png"):
101
+ a = array.array("h", open(f"{w}/a-{v}.pcm", "rb").read())
102
+ clicks, last = [], -10**9
103
+ for i in range(1, len(a)):
104
+ if abs(a[i] - a[i - 1]) > 9000 and i - last > 24000:
105
+ clicks.append(round(i / 48000, 4)); last = i
106
+ r[v] = (hashlib.sha256(a.tobytes()).hexdigest()[:16], round(len(a) / 48000, 3), clicks[:8])
107
+ print(f"audio {v}: pcm_sha={r[v][0]} seconds={r[v][1]} clicks_s={r[v][2]}")
108
+ print("audio identical:", r["canvas"][0] == r["png"][0])
109
+ PY
110
+ echo "== xfade (mixed)" | tee -a "$O/r9.txt"
111
+ proj /home/user/fp/features-xfade "$W/xf"; proj /home/user/fp/features-xfade "$W/xfp"
112
+ t0=$(ms); "$MOSIO" render "$W/xfp" -o "$W/xf-png.mp4" --workers 8 --no-cache > /dev/null 2>&1; t1=$(ms); echo "xfade png wall_ms=$((t1 - t0))" | tee -a "$O/r9.txt"
113
+ t0=$(ms); MOSIO_CANVAS_DRAINS=1 "$MOSIO" render "$W/xf" -o "$W/xf.mp4" --workers 8 --no-cache --capture canvas > "$W/xf.json" 2> "$W/xf.err"; rc=$?; t1=$(ms)
114
+ cp "$W/xf.json" "$O/"
115
+ echo "xfade canvas rc=$rc wall_ms=$((t1 - t0)) $(python3 -c 'import json,sys; r=json.load(open(sys.argv[1])); e=r["execution"]; print(e["encode"]["mode"], e["capture"]["canvas_frames"], e["capture"]["screenshot_frames"], "canvas_ms", e["canvas_ms"], "screenshot_ms", e["screenshot_ms"])' "$W/xf.json" 2>&1 | tail -1) $(score "$W/xf.mp4" "$W/xf-png.mp4")" | tee -a "$O/r9.txt"
116
+ for f in 40 52 60 70; do ffmpeg -v error -y -i "$W/xf.mp4" -i "$W/xf-png.mp4" -filter_complex "[0:v]select=eq(n\,$f)[a];[1:v]select=eq(n\,$f)[b];[a][b]hstack,scale=1080:-1" -frames:v 1 "$O/frames/fastpath-xfade-f$f-canvas-vs-png.png"; done
117
+ if ffmpeg -hide_banner -filters 2>/dev/null | grep -q libvmaf; then
118
+ for p in p1 p2; do
119
+ proj "$B/$p" "$W/r-$p"; lossless "$W/r-$p"; "$MOSIO" render "$W/r-$p" -o "$W/$p-ref.mp4" --workers 8 --no-cache --preset lossless > /dev/null 2>&1
120
+ proj "$B/$p" "$W/m-$p"
121
+ "$MOSIO" render "$W/m-$p" -o "$W/$p-png.mp4" --workers 8 --no-cache > /dev/null 2>&1
122
+ MOSIO_CANVAS_DRAINS=1 "$MOSIO" render "$W/m-$p" -o "$W/$p-canvas.mp4" --workers 8 --no-cache --capture canvas > /dev/null 2>&1
123
+ for v in canvas png; do
124
+ m=$(ffmpeg -v info -i "$W/$p-$v.mp4" -i "$W/$p-ref.mp4" -lavfi "[0:v]scale=in_range=auto:in_color_matrix=auto:out_range=tv,format=yuv420p[a];[1:v]format=yuv420p[b];[a][b]libvmaf=n_threads=8" -f null - 2>&1 | grep -o 'VMAF score: [0-9.]*')
125
+ echo "vmaf $p $v $m bytes=$(stat -c %s "$W/$p-$v.mp4")" | tee -a "$O/r9.txt"
126
+ done
127
+ done
128
+ else
129
+ echo "no libvmaf in this ffmpeg" | tee -a "$O/r9.txt"
130
+ fi
@@ -0,0 +1,15 @@
1
+ import http from 'node:http'; import fs from 'node:fs'; import path from 'node:path'
2
+ // static server: routes map url prefix -> dir; POST /_sink/<name> collects raw bodies
3
+ export function serve(routes, onPost) {
4
+ const types = { '.html': 'text/html', '.js': 'text/javascript', '.mjs': 'text/javascript', '.ttf': 'font/ttf', '.png': 'image/png', '.jpg': 'image/jpeg', '.mp4': 'video/mp4', '.webm': 'video/webm', '.woff2': 'font/woff2' }
5
+ const s = http.createServer((q, r) => {
6
+ const u = decodeURIComponent(new URL(q.url, 'http://x').pathname)
7
+ if (q.method === 'POST') { const parts = []; q.on('data', d => parts.push(d)); q.on('end', async () => { await onPost?.(u, Buffer.concat(parts)); r.end('ok') }); return }
8
+ for (const [pre, dir] of routes) if (u.startsWith(pre)) {
9
+ const f = path.join(dir, u.slice(pre.length))
10
+ if (fs.existsSync(f) && fs.statSync(f).isFile()) { r.writeHead(200, { 'content-type': types[path.extname(f)] || 'application/octet-stream', 'cross-origin-opener-policy': 'same-origin', 'cross-origin-embedder-policy': 'require-corp', 'cross-origin-resource-policy': 'same-origin' }); return fs.createReadStream(f).pipe(r) }
11
+ }
12
+ r.writeHead(404); r.end()
13
+ })
14
+ return new Promise(res => s.listen(0, '127.0.0.1', () => res({ url: `http://127.0.0.1:${s.address().port}`, close: () => s.close() })))
15
+ }
@@ -0,0 +1 @@
1
+ <canvas id=c content=drawable layoutsubtree width=400 height=300><div id=d drawable style="width:200px;height:100px;background:red">hi</div></canvas>
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env bash
2
+ # Two extra benchmark projects for scripts/hpbench/render-cgroup.sh, generated (nothing binary is committed):
3
+ # OUT/hold-bench 1080x1920, 15 s, 3 scenes of text that appears step by step and is then held (education-style)
4
+ # OUT/three-bench 1280x720, 5 s, one Three.js scene (procedural torus knot, shadows, environment light), WebGL on SwiftShader
5
+ # Needs the repo's pinned fonts (system Inter) and fixtures/3d/t1-turntable for the Three.js scaffolding.
6
+ set -euo pipefail
7
+ REPO="$(cd "$(dirname "$0")/../.." && pwd)"; OUT="${1:?out dir}"
8
+ rm -rf "$OUT/hold-bench" "$OUT/three-bench"; mkdir -p "$OUT"
9
+ H="$OUT/hold-bench"; mkdir -p "$H/scenes" "$H/assets/fonts" "$H/shared"
10
+ cp "$REPO"/deploy/cloudrun/bench-project/shared/* "$H/shared/"
11
+ for f in Inter-Regular Inter-Bold Inter-ExtraBold; do cp "/usr/share/fonts/opentype/inter/$f.otf" "$H/assets/fonts/"; done
12
+ python3 - "$H" <<'PY'
13
+ import json, sys
14
+ h = sys.argv[1]
15
+ scenes = []
16
+ titles = ["Why seasons change", "Earth is tilted", "Sun angle matters"]
17
+ for i, t in enumerate(titles):
18
+ sid = f"s{i+1}"
19
+ bullets = "".join(f'<li class="b" style="animation-delay:{1.0+1.5*k}s" data-mosio-id="{sid}/b{k}">{b}</li>' for k, b in enumerate(
20
+ ["Axis tilt is about 23.5 degrees", "Hemisphere facing the sun gets summer", "Days are longer in summer"]))
21
+ open(f"{h}/scenes/{sid}.html", "w").write(f'''<!doctype html><html><head><meta charset="utf-8">
22
+ <link rel="stylesheet" href="/shared/tokens.css"><link rel="stylesheet" href="/shared/base.css">
23
+ <style>.wrap{{position:absolute;inset:120px 90px;display:flex;flex-direction:column;gap:60px;justify-content:center}}
24
+ h1{{font-size:110px;animation:in .5s ease-out both}}ul{{list-style:none;display:flex;flex-direction:column;gap:44px}}
25
+ .b{{font-size:58px;opacity:0;animation:in .5s ease-out both}}@keyframes in{{from{{opacity:0;transform:translateY(30px)}}to{{opacity:1;transform:none}}}}
26
+ </style></head><body><div class="scene" data-mosio-id="{sid}/scene"><div class="wrap"><h1 data-mosio-id="{sid}/h">{t}</h1><ul>{bullets}</ul></div></div></body></html>''')
27
+ scenes.append({"id": sid, "src": f"scenes/{sid}.html", "frames": 150})
28
+ j = {"mosio": 1, "name": "hold-bench", "width": 1080, "height": 1920, "fps": 30, "seed": 1, "background": "#0f172a", "libraries": [],
29
+ "shared": ["shared/tokens.css", "shared/base.css"],
30
+ "assets": [f"assets/fonts/Inter-{w}.otf" for w in ("Regular", "Bold", "ExtraBold")], "scenes": scenes, "audio": []}
31
+ json.dump(j, open(f"{h}/mosio.json", "w"), indent=1)
32
+ PY
33
+ T="$OUT/three-bench"; cp -r "$REPO/fixtures/3d/t1-turntable" "$T"
34
+ python3 - "$T" <<'PY'
35
+ import json, re, sys
36
+ t = sys.argv[1]; p = f"{t}/scenes/turntable.html"; s = open(p).read()
37
+ s = re.sub(r'const gltf = .*?ctx\.scene\.add\(gltf\.scene\);',
38
+ 'const m = new THREE.Mesh(new THREE.TorusKnotGeometry(0.06, 0.02, 400, 64), new THREE.MeshStandardMaterial({ color: "#c0a060", roughness: 0.3, metalness: 0.8 }));\n'
39
+ ' m.position.y = 0.08; m.castShadow = true; m.receiveShadow = true; ctx.model = ctx.id(m, "knot"); ctx.scene.add(m);', s, flags=re.S)
40
+ open(p, "w").write(s)
41
+ j = json.load(open(f"{t}/mosio.json")); j["assets"] = []; j["scenes"][0]["frames"] = 150; json.dump(j, open(f"{t}/mosio.json", "w"), indent=1)
42
+ PY
43
+ echo "wrote $H and $T"
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env bash
2
+ # Render fixtures under a cgroup v2 CPU quota (like a Cloud Run instance) and print one JSON line per run: wall time,
3
+ # vCPU-seconds (cgroup cpu.stat), peak memory, the engine's own stage profile, and hashes of the video and frame manifest.
4
+ # Run as root in the sandbox after `cargo build --release --locked`; Chromium runs as the unprivileged `mosio` user.
5
+ # scripts/hpbench/render-cgroup.sh OUT_DIR "2 4" FIXTURE_DIR... [-- extra mosio render args]
6
+ # Every run uses --no-cache (a cold render); a run's frame manifest is kept as OUT_DIR/<name>-<cpus>cpu.frames.json.
7
+ set -uo pipefail
8
+ REPO="$(cd "$(dirname "$0")/../.." && pwd)"
9
+ OUT="${1:?out dir}"; CPUS="${2:?cpu list, e.g. \"2 4\"}"; shift 2
10
+ FIX=(); while [ $# -gt 0 ] && [ "$1" != -- ]; do FIX+=("$1"); shift; done; [ "${1:-}" = -- ] && shift
11
+ EXTRA=("$@")
12
+ MEM="${MEM_LIMIT:-4G}"; REPS="${REPS:-1}"; CG=/sys/fs/cgroup
13
+ mkdir -p "$OUT"; OUT="$(cd "$OUT" && pwd)"
14
+ id mosio >/dev/null 2>&1 || useradd -m mosio
15
+ chmod o+rx "$REPO" "$(dirname "$REPO")" 2>/dev/null || true; chmod -R o+rX "$REPO" 2>/dev/null || true
16
+ echo "+cpu +memory" > $CG/cgroup.subtree_control 2>/dev/null || true
17
+ for fx in "${FIX[@]}"; do
18
+ name="$(basename "$fx")"; src="$(cd "$fx" && pwd)"
19
+ for c in $CPUS; do
20
+ for rep in $(seq 1 "$REPS"); do
21
+ w=/home/mosio/rb/$name-$c; rm -rf "$w" /tmp/rb-out; mkdir -p /home/mosio/rb /tmp/rb-out; cp -a "$src" "$w"
22
+ chown -R mosio:mosio /home/mosio/rb /tmp/rb-out
23
+ cg=$CG/rb-$name-$c; mkdir -p "$cg"; echo "$((c * 100000)) 100000" > "$cg/cpu.max"; echo "$MEM" > "$cg/memory.max"
24
+ sync; echo 3 > /proc/sys/vm/drop_caches 2>/dev/null
25
+ t0=$(date +%s.%N)
26
+ ( echo $BASHPID > "$cg/cgroup.procs"
27
+ exec runuser -u mosio -- env HOME=/home/mosio MOSIO_HOME="${MOSIO_HOME:-$REPO/.mosio-home}" MOSIO_LOCK="$REPO/toolchain.lock.json" \
28
+ PATH="$REPO/target/release:/usr/local/bin:/usr/bin:/bin" \
29
+ mosio render "$w" -o /tmp/rb-out/out.mp4 --no-cache "${EXTRA[@]}" ) > "$OUT/$name-${c}cpu.report.json" 2> "$OUT/$name-${c}cpu.err"
30
+ rc=$?; t1=$(date +%s.%N)
31
+ cp /tmp/rb-out/out.frames.json "$OUT/$name-${c}cpu.frames.json" 2>/dev/null
32
+ python3 - "$OUT/$name-${c}cpu.report.json" "$cg" "$name" "$c" "$rc" "$t0" "$t1" /tmp/rb-out/out.mp4 "$REPO" <<'PY'
33
+ import json, sys, hashlib, os, subprocess
34
+ rep, cg, name, c, rc, t0, t1, mp4, repo = sys.argv[1:]
35
+ def stat(k):
36
+ for l in open(cg + "/cpu.stat"):
37
+ a = l.split()
38
+ if a[0] == k: return int(a[1])
39
+ try: r = json.load(open(rep))
40
+ except Exception: r = {}
41
+ p = r.get("profile", {}); s = p.get("stages", {})
42
+ peak = int(open(cg + "/memory.peak").read()) / 1048576 if os.path.exists(cg + "/memory.peak") else None
43
+ sha = hashlib.sha256(open(mp4, "rb").read()).hexdigest()[:16] if os.path.exists(mp4) else None
44
+ print(json.dumps({"fixture": name, "vcpu": int(c), "rc": int(rc), "wall_s": round(float(t1) - float(t0), 2),
45
+ "cpu_s": round(stat("usage_usec") / 1e6, 1), "throttled_s": round(stat("throttled_usec") / 1e6, 1), "cgroup_peak_mib": peak and round(peak),
46
+ "workers": r.get("workers"), "frames": r.get("total_frames"), "mp4_sha": sha,
47
+ "ms": {k: round(v) for k, v in {"plan": p.get("plan_ms", 0), "browser_launch": p.get("browser_launch_ms", 0), "page_load": s.get("page_load_ms", 0),
48
+ "seek": s.get("seek_barrier_ms", 0), "capture": s.get("capture_ms", 0), "png_decode": s.get("decode_ms", 0), "hash": p.get("hash_ms", 0),
49
+ "enc_write": p.get("encode_write_ms", 0), "enc_finish": p.get("encode_finish_ms", 0), "cache_store": p.get("cache_store_ms", 0),
50
+ "canary": p.get("canary_ms", 0), "blend": p.get("transition_blend_ms", 0), "audio": p.get("audio_mix_ms", 0), "mux": p.get("concat_mux_ms", 0)}.items()},
51
+ "captured": s.get("captured_frames"), "still": s.get("still_frames"), "shots": [s.get("shot_calls"), round(s.get("shot_ms",0))], "idle": [s.get("idle_calls"), round(s.get("idle_ms",0))], "replayed": s.get("replayed_frames")}))
52
+ PY
53
+ rmdir "$cg" 2>/dev/null; rm -rf "$w"
54
+ done
55
+ done
56
+ done
@@ -222,7 +222,8 @@ main() {
222
222
  ROOT="$REPO"
223
223
  if [ "$SKIP_TOOLCHAIN" -eq 0 ]; then
224
224
  log "toolchain: scripts/bootstrap.sh"
225
- MOSIO_APPARMOR_SKIP=1 SKIP_APT="${MOSIO_APT_DONE:-0}" "$REPO/scripts/bootstrap.sh" </dev/null
225
+ skip_apt=0; [ "${SKIP_APT:-0}" = 1 ] || [ "${MOSIO_APT_DONE:-0}" = 1 ] && skip_apt=1
226
+ MOSIO_APPARMOR_SKIP=1 SKIP_APT="$skip_apt" "$REPO/scripts/bootstrap.sh" </dev/null
226
227
  fi
227
228
  apparmor_step "$REPO"
228
229
  # bootstrap installs rustup for this user (or finds a system one through CARGO_HOME)
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env bash
2
+ # Prove the npm packages work on a clean Windows machine: install the packed tarballs into a fresh npm prefix with a
3
+ # fresh %LOCALAPPDATA% (so no Mosio home, toolchain or cache exists yet), then run the first-run flow from PowerShell,
4
+ # the shell a Windows 11 user types into. The Windows counterpart of scripts/npm-clean-install-proof.sh.
5
+ #
6
+ # scripts/npm-clean-install-proof-win.sh <dir with usemosio-cli-*.tgz> [<evidence dir>]
7
+ #
8
+ # Runs in Git Bash on a Windows runner (windows-latest). Every step's output and exit code go to the evidence
9
+ # directory; the script's own exit code is non-zero when any step failed.
10
+ set -uo pipefail
11
+ SRC="$(cd "${1:?usage: $0 <tarball dir> [evidence dir]}" && pwd)"
12
+ EV="${2:-$RUNNER_TEMP/npm-proof}"
13
+ mkdir -p "$EV"
14
+ ROOT=$(mktemp -d)
15
+ mkdir -p "$ROOT/prefix" "$ROOT/cache" "$ROOT/localappdata" "$ROOT/work"
16
+ W() { cygpath -w "$1"; }
17
+ P=$(W "$SRC")
18
+ LAUNCHER=$(W "$(ls "$SRC"/usemosio-cli-[0-9]*.tgz)")
19
+ PLATFORM=$(W "$(ls "$SRC"/usemosio-cli-win32-x64-*.tgz)")
20
+ {
21
+ echo "windows: $(cmd //c ver | tr -d '\r' | grep -v '^$')"
22
+ echo "node $(node --version) npm $(npm --version)"
23
+ echo "ffmpeg on PATH: $(command -v ffmpeg || echo none)"
24
+ echo "fresh LOCALAPPDATA: $(W "$ROOT/localappdata")"
25
+ echo "tarballs: $P"
26
+ } | tee "$EV/00-machine.txt"
27
+
28
+ FAIL=0
29
+ # step <name> <expected exit code> <powershell command>: run in a fresh PowerShell with the fresh prefix first on PATH
30
+ step() {
31
+ local name="$1" want="$2" cmd="$3"
32
+ local t0; t0=$(date +%s%N)
33
+ env -u MOSIO_HOME -u MOSIO_LOCK -u MOSIO_KIT NPM_CONFIG_PREFIX="$(W "$ROOT/prefix")" NPM_CONFIG_CACHE="$(W "$ROOT/cache")" LOCALAPPDATA="$(W "$ROOT/localappdata")" \
34
+ NPM_CONFIG_UPDATE_NOTIFIER=false NPM_CONFIG_FUND=false NPM_CONFIG_AUDIT=false \
35
+ PATH="$ROOT/prefix:$PATH" \
36
+ pwsh -NoProfile -NonInteractive -Command "Set-Location '$(W "$ROOT/work")'; \$ErrorActionPreference='Continue'; $cmd; exit \$LASTEXITCODE" \
37
+ >"$EV/$name.out" 2>"$EV/$name.err"
38
+ local rc=$?
39
+ local ms=$(( ($(date +%s%N) - t0) / 1000000 )) dt; dt="$((ms / 1000)).$(( (ms % 1000) / 100 ))"
40
+ local verdict=PASS; [ "$rc" -eq "$want" ] || { verdict=FAIL; FAIL=1; }
41
+ printf '%-4s %-22s exit %-3s (want %s) %6ss > %s\n' "$verdict" "$name" "$rc" "$want" "$dt" "$cmd" | tee -a "$EV/summary.txt"
42
+ }
43
+ FFPROBE="\$env:LOCALAPPDATA\\mosio\\home\\ffmpeg\\bin\\ffprobe.exe"
44
+
45
+ step 01-npm-install-g 0 "npm i -g '$LAUNCHER' '$PLATFORM'"
46
+ step 02-which-version 0 "(Get-Command mosio).Source; mosio --version"
47
+ step 03-doctor-before 1 "mosio doctor"
48
+ step 05-init 0 "mosio init ./v"
49
+ step 06-check 0 "mosio check ./v"
50
+ step 07-render-first-run 0 "Measure-Command { mosio render ./v -o v.mp4 | Out-Host } | Select-Object TotalSeconds; if (-not (Test-Path v.mp4)) { exit 1 }"
51
+ step 08-ffprobe 0 "& \"$FFPROBE\" -v error -show_entries stream=codec_name,width,height,r_frame_rate,nb_frames:format=duration,size -of default=nw=1 v.mp4"
52
+ step 09-doctor-after 0 "mosio doctor"
53
+ step 10-setup-check-after 0 "mosio setup --check"
54
+ step 11-studio-help 0 "mosio studio --help"
55
+ step 11b-agent-help 0 "mosio-agent --help | Select-Object -First 3"
56
+ step 12-render-again 0 "Measure-Command { mosio render ./v -o v2.mp4 | Out-Host } | Select-Object TotalSeconds; if (-not (Test-Path v2.mp4)) { exit 1 }"
57
+ step 19-uninstall 0 "npm rm -g @usemosio/cli @usemosio/cli-win32-x64; if (Get-Command mosio -ErrorAction SilentlyContinue) { exit 1 }"
58
+ {
59
+ echo "--- sizes ---"; ls -l "$SRC"/*.tgz
60
+ echo "--- installed ---"
61
+ du -sh "$ROOT/localappdata/mosio/home" "$ROOT/localappdata/mosio/npm" "$ROOT/cache" 2>/dev/null
62
+ } | tee "$EV/99-sizes.txt"
63
+ echo; awk '{print $1}' "$EV/summary.txt" | sort | uniq -c
64
+ exit $FAIL
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ # Render the same projects on any platform and write the MP4s plus timings, for the cross-platform check
3
+ # (.github/workflows/macos.yml): Linux renders the reference, macOS renders again and compares (SSIM).
4
+ #
5
+ # scripts/platform-smoke.sh <mosio> <fonts-dir> <out-dir> [capture...]
6
+ #
7
+ # <fonts-dir> holds Inter-ExtraBold.otf and Inter-Medium.otf; both platforms use the same files, so a difference in
8
+ # the frames comes from the platform (rasteriser, encoder), not from the fonts. Projects: fixtures/w1-kinetic and the
9
+ # two speed projects tests/bench/p1 ("titles", 10 s) and tests/bench/p2 ("dense", 30 s), all 1080x1920 at 30 fps.
10
+ # Each capture mode given (default: the screenshot path only; "canvas" adds `--capture canvas` when this build has it)
11
+ # renders every project once, with --no-cache. Writes <out>/<project>-<capture>.mp4 and <out>/timings.tsv.
12
+ set -euo pipefail
13
+ MOSIO=$(cd "$(dirname "$1")" && pwd)/$(basename "$1")
14
+ FONTS=$(cd "$2" && pwd)
15
+ OUT=$3
16
+ shift 3
17
+ if [ $# -gt 0 ]; then CAPTURES=("$@"); else CAPTURES=(screenshot); fi
18
+ REPO=$(cd "$(dirname "$0")/.." && pwd)
19
+ mkdir -p "$OUT"
20
+ OUT=$(cd "$OUT" && pwd)
21
+ WORK=$(mktemp -d)
22
+ # Windows runners (Git Bash) have `python`, not `python3`
23
+ PY=$(command -v python3 || command -v python)
24
+ trap 'rm -rf "$WORK"' EXIT
25
+
26
+ printf 'project\tcapture\tframes\tseconds\n' > "$OUT/timings.tsv"
27
+ for proj in fixtures/w1-kinetic tests/bench/p1 tests/bench/p2; do
28
+ name=$(basename "$proj")
29
+ [ "$name" = w1-kinetic ] || name=bench-$name
30
+ d="$WORK/$name"
31
+ cp -R "$REPO/$proj" "$d"
32
+ mkdir -p "$d/assets/fonts"
33
+ cp "$FONTS/Inter-ExtraBold.otf" "$FONTS/Inter-Medium.otf" "$d/assets/fonts/"
34
+ for cap in "${CAPTURES[@]}"; do
35
+ args=()
36
+ if [ "$cap" = canvas ]; then
37
+ if ! "$MOSIO" render --help 2>&1 | grep -q -- 'canvas'; then
38
+ echo "[smoke] this mosio has no --capture canvas; skipping $name/canvas" >&2
39
+ continue
40
+ fi
41
+ args=(--capture canvas)
42
+ fi
43
+ out="$OUT/$name-$cap.mp4"
44
+ t0=$("$PY" -c 'import time; print(time.time())')
45
+ if ! "$MOSIO" render "$d" -o "$out" --no-cache ${args[@]+"${args[@]}"} > "$WORK/$name-$cap.json"; then
46
+ echo "[smoke] $name/$cap failed:" >&2
47
+ cat "$WORK/$name-$cap.json" >&2
48
+ exit 1
49
+ fi
50
+ t1=$("$PY" -c 'import time; print(time.time())')
51
+ frames=$(ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of csv=p=0 "$out")
52
+ secs=$("$PY" -c "print(f'{$t1 - $t0:.2f}')")
53
+ printf '%s\t%s\t%s\t%s\n' "$name" "$cap" "$frames" "$secs" | tee -a "$OUT/timings.tsv"
54
+ done
55
+ done
56
+
57
+ # The render daemon (MOSIO_DAEMON=1, opt-in): two renders of bench-p1 through it must give the same bytes as the
58
+ # in-process render above. The first starts the daemon, the second reuses its warm browser; it quits after 20 s idle.
59
+ d="$WORK/bench-p1"
60
+ for i in 1 2; do
61
+ MOSIO_DAEMON=1 MOSIO_DAEMON_IDLE_S=20 "$MOSIO" render "$d" -o "$OUT/daemon-$i.mp4" --no-cache > "$WORK/daemon-$i.json"
62
+ done
63
+ [ -f "$d/.mosio/daemon.json" ] || { echo "[smoke] daemon: no $d/.mosio/daemon.json, the renders did not go through a daemon" >&2; exit 1; }
64
+ for i in 1 2; do
65
+ cmp -s "$OUT/daemon-$i.mp4" "$OUT/bench-p1-${CAPTURES[0]}.mp4" || { echo "[smoke] daemon: render $i differs from the in-process render" >&2; exit 1; }
66
+ done
67
+ echo "[smoke] daemon: 2 renders through the daemon, byte-identical to the in-process render"
package/scripts/prim.mjs CHANGED
@@ -4,7 +4,8 @@
4
4
  // node scripts/prim.mjs show ID the manifest, as JSON
5
5
  // node scripts/prim.mjs validate [--no-golden] manifests, files, drift against the code, house rules
6
6
  // node scripts/prim.mjs bundle [ID,ID,...] [--out FILE] core + the chosen primitives (default all) as one script
7
- // node scripts/prim.mjs install PROJECT [ID,ID,...] copy the bundle, prim.css and tokens (if absent) into PROJECT/shared
7
+ // node scripts/prim.mjs install PROJECT [ID,ID,...] [--fonts-from DIR] copy the bundle, prim.css and tokens sized for
8
+ // the project (if absent) into PROJECT/shared; Inter is copied in when found, else prim.css has no @font-face
8
9
  // and declare them and the gsap library in PROJECT/mosio.json
9
10
  // node scripts/prim.mjs gallery OUT [--fonts-from DIR] [--size WxH] [--only ID,ID] [--name N] a test project with one scene per primitive (default 640x360, all)
10
11
  // node scripts/prim.mjs particles-perf OUT [--count N] a 1920x1080 project, one scene per particle preset (performance test)
@@ -15,7 +16,7 @@ import { fileURLToPath } from 'node:url'
15
16
 
16
17
  export const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'primitives')
17
18
  export const GSAP = 'gsap@3.15.1'
18
- const KINDS = ['motion', 'text', 'structure', 'data', 'transition', 'particles', 'commerce']
19
+ const KINDS = ['motion', 'text', 'structure', 'data', 'transition', 'particles', 'commerce', 'character']
19
20
  const read = (p) => fs.readFileSync(p, 'utf8')
20
21
  const fail = (msg) => { const e = new Error(msg); e.code = 'E_PRIM'; throw e }
21
22
 
@@ -96,8 +97,8 @@ export function validate({ golden = true } = {}) {
96
97
  const js = read(path.join(dir, `${id}.js`)), scene = read(path.join(dir, 'scene.html'))
97
98
  for (const [re, why] of HOUSE) {
98
99
  if (!re.test(js)) continue
99
- // a converted item may drive a frame clock (a tween of a counter with onUpdate) with a linear ease: that is a clock, not motion
100
- if (m.source && /linear ease/.test(why) && [...js.matchAll(new RegExp(re.source, 'g'))].every((x) => /onUpdate/.test(js.slice(Math.max(0, x.index - 220), x.index + 220)))) continue
100
+ // a primitive may drive a frame clock (a tween of a counter with onUpdate: a jump's flight, a run's distance) with a linear ease: that is a clock, not motion
101
+ if (/linear ease/.test(why) && [...js.matchAll(new RegExp(re.source, 'g'))].every((x) => /onUpdate/.test(js.slice(Math.max(0, x.index - 220), x.index + 220)))) continue
101
102
  bad(id, `${id}.js: ${why}`)
102
103
  }
103
104
  if (/#[0-9a-fA-F]{3,8}\b/.test(js)) bad(id, `${id}.js: colours come from theme tokens, not hex`)
@@ -123,26 +124,43 @@ const HOUSE = [
123
124
  ]
124
125
  const sortKeys = (o) => Object.fromEntries(Object.keys(o).sort().map((k) => [k, o[k]]))
125
126
 
126
- export function install(project, only) {
127
+ export function install(project, only, { fontsFrom } = {}) {
127
128
  const mp = path.join(project, 'mosio.json')
128
129
  if (!fs.existsSync(mp)) fail(`${mp} not found`)
130
+ const j = JSON.parse(read(mp))
129
131
  const sh = path.join(project, 'shared')
130
132
  fs.mkdirSync(sh, { recursive: true })
131
133
  fs.writeFileSync(path.join(sh, 'mosio-prims.js'), bundle(only))
132
- fs.writeFileSync(path.join(sh, 'prim.css'), primCss())
133
- if (!fs.existsSync(path.join(sh, 'tokens.css'))) fs.copyFileSync(path.join(ROOT, 'shared', 'tokens.css'), path.join(sh, 'tokens.css'))
134
- const j = JSON.parse(read(mp))
134
+ // tokens sized for this canvas: --w/--h and the type scale follow the project (a 9:16 project gets 1080x1920)
135
+ if (!fs.existsSync(path.join(sh, 'tokens.css'))) fs.writeFileSync(path.join(sh, 'tokens.css'), tokensFor(j.width || 1920, j.height || 1080))
136
+ // Inter: copy it in and declare it when this machine has it; otherwise leave the @font-face rules out, so nothing
137
+ // reads a missing file (E_UNDECLARED_READ) and the primitives use the project's --font-* tokens
138
+ const assets = j.assets || (j.assets = [])
139
+ let fonts = FONTS.every((f) => fs.existsSync(path.join(project, 'assets', 'fonts', f)))
140
+ if (!fonts && fontDir(fontsFrom)) { copyFonts(project, fontsFrom); fonts = true }
141
+ if (fonts) for (const f of FONTS) if (!assets.includes(`assets/fonts/${f}`)) assets.push(`assets/fonts/${f}`)
142
+ fs.writeFileSync(path.join(sh, 'prim.css'), fonts ? primCss() : primCss().replace(/^@font-face[^\n]*\n/gm, ''))
135
143
  for (const f of ['shared/tokens.css', 'shared/prim.css', 'shared/mosio-prims.js']) if (!(j.shared || (j.shared = [])).includes(f)) j.shared.push(f)
136
144
  if (!(j.libraries || (j.libraries = [])).includes(GSAP)) j.libraries.push(GSAP)
137
145
  fs.writeFileSync(mp, JSON.stringify(j, null, 2) + '\n')
138
- return { installed: only?.length ? only : ids(), shared: j.shared, libraries: j.libraries, note: 'fonts: prim.css expects /assets/fonts/Inter-{Regular,Bold,ExtraBold}.otf declared in "assets"' }
146
+ return { installed: only?.length ? only : ids(), shared: j.shared, libraries: j.libraries, size: [j.width, j.height],
147
+ fonts: fonts ? 'Inter copied to assets/fonts and declared' : 'Inter not found here (use --fonts-from DIR): prim.css has no @font-face; set --font-display/--font-body in shared/tokens.css to your fonts' }
148
+ }
149
+
150
+ /** shared/tokens.css for a W x H canvas: the sizes scale with the shorter side (1080 is the reference). */
151
+ export function tokensFor(W, H) {
152
+ const k = Math.min(W, H) / 1080, px = (n) => `${Math.round(n * k)}px`
153
+ return read(path.join(ROOT, 'shared', 'tokens.css')).replace(/--w: \d+px;/, `--w: ${W}px;`).replace(/--h: \d+px;/, `--h: ${H}px;`)
154
+ .replace(/--fs-display: \d+px;/, `--fs-display: ${px(112)};`).replace(/--fs-body: \d+px;/, `--fs-body: ${px(48)};`)
155
+ .replace(/--margin: \d+px;/, `--margin: ${px(W < H ? 72 : 140)};`).replace(/--radius: \d+px;/, `--radius: ${px(16)};`)
139
156
  }
140
157
 
141
158
  const FONTS = ['Inter-Regular.otf', 'Inter-Bold.otf', 'Inter-ExtraBold.otf']
159
+ const fontDirs = (fontsFrom) => [fontsFrom, process.env.MOSIO_FONT_DIR, process.env.FONT_DIR, '/usr/share/fonts/opentype/inter'].filter(Boolean)
160
+ const fontDir = (fontsFrom) => fontDirs(fontsFrom).find((d) => FONTS.every((f) => fs.existsSync(path.join(d, f))))
142
161
  export function copyFonts(dest, fontsFrom) {
143
- const dirs = [fontsFrom, process.env.MOSIO_FONT_DIR, process.env.FONT_DIR, '/usr/share/fonts/opentype/inter'].filter(Boolean)
144
- const dir = dirs.find((d) => FONTS.every((f) => fs.existsSync(path.join(d, f))))
145
- if (!dir) fail(`Inter fonts not found in ${dirs.join(', ')} (use --fonts-from DIR)`)
162
+ const dir = fontDir(fontsFrom)
163
+ if (!dir) fail(`Inter fonts not found in ${fontDirs(fontsFrom).join(', ')} (use --fonts-from DIR)`)
146
164
  fs.mkdirSync(path.join(dest, 'assets', 'fonts'), { recursive: true })
147
165
  for (const f of FONTS) fs.copyFileSync(path.join(dir, f), path.join(dest, 'assets', 'fonts', f))
148
166
  return FONTS.map((f) => `assets/fonts/${f}`)
@@ -209,7 +227,7 @@ function main(argv) {
209
227
  case 'show': return print(manifest(pos[0]))
210
228
  case 'validate': { const p = validate({ golden: !flags['no-golden'] }); print({ ok: p.length === 0, problems: p }); if (p.length) process.exitCode = 1; return }
211
229
  case 'bundle': { const s = bundle(list(pos[0])); if (flags.out) fs.writeFileSync(flags.out, s); else process.stdout.write(s); return }
212
- case 'install': return print(install(pos[0], list(pos[1])))
230
+ case 'install': return print(install(pos[0], list(pos[1]), { fontsFrom: flags['fonts-from'] }))
213
231
  case 'particles-perf': return print(particlesPerf(pos[0], { count: Number(flags.count) || 2000, fontsFrom: flags['fonts-from'] }))
214
232
  case 'gallery': return print(gallery(pos[0], { fontsFrom: flags['fonts-from'], size: typeof flags.size === 'string' ? flags.size.split('x').map(Number) : undefined, only: list(flags.only), name: flags.name === true ? undefined : flags.name }))
215
233
  default: console.error('usage: prim.mjs list|show|validate|bundle|install|gallery (see the header of this file)'); process.exitCode = 2
@@ -69,6 +69,6 @@ Starting points; adjust timing with `mosio-engine` `references/timing.md`.
69
69
  | `mosio caps --project P [--blender-render-test]` | what this machine can render |
70
70
  | `node scripts/kit3d.mjs list`, `project DIR --only ID` | browser kit examples, a ready project |
71
71
  | `mosio stills P --at scene.start,1.5s,scene.end` | frames across a camera move |
72
- | `mosio render P -o out.mp4` | render; Blender clips are cached by their scene file and settings |
72
+ | `mosio render P -o out/final.mp4` | render; Blender clips are cached by their scene file and settings |
73
73
 
74
74
  Every option: `docs/3d/KIT.md` and `docs/3d/BLENDER-SCENES.md` in the Mosio repo.