|
38 | 38 | // `lint` failures surface HERE instead of after assembly + a wasted render): |
39 | 39 | // ① AUTO-REPAIR — a sub-comp root missing data-width/data-height: inject the canvas |
40 | 40 | // dims (the renderer needs them on the cloned root; else lint root_missing_dimensions). |
41 | | -// ② HARD FAIL — <video>/<audio> inside a sub-comp: the runtime only drives media that |
42 | | -// is a DIRECT child of the host root, so sub-comp media renders blank/black. |
43 | | -// ③ HARD FAIL — a timed element (data-start+duration+track-index) that is not the root |
| 41 | +// ② HARD FAIL — a timed element (data-start+duration+track-index) that is not the root |
44 | 42 | // and lacks class="clip" (shows the whole frame), or two same-track clips that overlap. |
| 43 | +// (Media inside a sub-comp is NOT a violation: the runtime seeks + decodes nested |
| 44 | +// <video>/<audio> at any depth — see packages/core/src/runtime/{media,startResolver}.ts.) |
45 | 45 | // |
46 | 46 | // Exit 0 = index.html written + summary. Exit 1 = fatal contract break (no |
47 | 47 | // frames, a built/animated frame missing its src/file, a frame with no |
48 | | -// duration, an inner data-composition-id mismatch, or a guard ②/③ violation). |
| 48 | +// duration, an inner data-composition-id mismatch, or a guard ② violation). |
49 | 49 | // No backstop: fix upstream. |
50 | 50 |
|
51 | 51 | import { existsSync, readFileSync, writeFileSync } from "node:fs"; |
@@ -121,15 +121,15 @@ const outPath = resolve(flag("out", join(hyperframesDir, "index.html"))); |
121 | 121 |
|
122 | 122 | const r3 = (x) => Math.round(x * 1000) / 1000; |
123 | 123 | const anomalies = []; |
124 | | -const frameErrors = []; // fatal per-frame composition violations (guards ②/③) — reported together |
| 124 | +const frameErrors = []; // fatal per-frame composition violations (guard ②) — reported together |
125 | 125 | const repairs = []; // auto-repairs applied to frame files in place (guard ①) |
126 | 126 |
|
127 | 127 | // ---------- parse storyboard ---------- |
128 | 128 | if (!existsSync(storyboardPath)) die(`STORYBOARD.md not found at ${storyboardPath}`); |
129 | 129 | const manifest = parseStoryboard(readFileSync(storyboardPath, "utf8")); |
130 | 130 | const { width: WIDTH, height: HEIGHT } = parseFormat(manifest.globals.format); |
131 | 131 |
|
132 | | -// ---------- per-frame composition guards (see header ①②③) ---------- |
| 132 | +// ---------- per-frame composition guards (see header ①②) ---------- |
133 | 133 | // String-level checks on each frame's HTML — no DOM parse, deterministic, run in |
134 | 134 | // the same pass that already reads the file. OPEN_TAG matches one opening tag while |
135 | 135 | // tolerating quoted attribute values that contain ">" (e.g. inline styles). |
@@ -166,21 +166,17 @@ function guardFrame(html, label) { |
166 | 166 | const errors = []; |
167 | 167 | // Scan a copy with comments + <script>/<style> bodies blanked, so a tag-like string |
168 | 168 | // in a comment (e.g. "<!-- match the host <video> coords -->") or in GSAP code can't |
169 | | - // trip ②/③. ① still splices into the ORIGINAL html, so its offsets stay correct. |
| 169 | + // trip ②. ① still splices into the ORIGINAL html, so its offsets stay correct. |
170 | 170 | const scan = html |
171 | 171 | .replace(/<!--[\s\S]*?-->/g, " ") |
172 | 172 | .replace(/<script\b[\s\S]*?<\/script[^>]*>/gi, " ") |
173 | 173 | .replace(/<style\b[\s\S]*?<\/style[^>]*>/gi, " "); |
174 | 174 |
|
175 | | - // ② media inside a sub-comp — never driven by the runtime (renders blank/black). |
176 | | - const media = scan.match(/<(video|audio)(?=[\s/>])/i); |
177 | | - if (media) { |
178 | | - errors.push( |
179 | | - `${label}: has a <${media[1].toLowerCase()}> inside the sub-composition. The runtime only drives media that is a DIRECT child of the host root (index.html) — sub-comp media renders blank/black. Move the clip to index.html as a root-level <video>/<audio> and drive any per-scene motion on the main timeline (composition-patterns.md archetype B).`, |
180 | | - ); |
181 | | - } |
182 | | - |
183 | | - // ③ timed-element checks: missing class="clip", and same-track window overlap. |
| 175 | + // ② timed-element checks: missing class="clip", and same-track window overlap. |
| 176 | + // (Media inside a sub-comp is fine: the runtime's global media sweep seeks + decodes |
| 177 | + // <video>/<audio> at any nesting depth, re-basing each clip's local data-start by its |
| 178 | + // host composition's absolute start — no root-child requirement. See |
| 179 | + // packages/core/src/runtime/{media,startResolver}.ts.) |
184 | 180 | const re = new RegExp(OPEN_TAG, "g"); |
185 | 181 | const clips = []; |
186 | 182 | let m; |
@@ -285,7 +281,7 @@ for (const f of manifest.frames) { |
285 | 281 | `${label}: ${f.src} is empty or has no HTML — the worker wrote a blank/partial file. Re-dispatch that worker before assembling.`, |
286 | 282 | ); |
287 | 283 | } |
288 | | - // pre-assembly guards: ① repair missing root dims in place, ②/③ collect fatal violations. |
| 284 | + // pre-assembly guards: ① repair missing root dims in place, ② collects fatal violations. |
289 | 285 | const guard = guardFrame(html, label); |
290 | 286 | if (guard.repairedHtml) { |
291 | 287 | writeFileSync(compAbs, guard.repairedHtml); |
|
0 commit comments