@litfamily/litgravity 0.1.0 → 0.1.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.
- package/CHANGELOG.md +32 -0
- package/README.md +72 -17
- package/README_ko-KR.md +72 -17
- package/package.json +1 -1
- package/plugin/hooks/lib/lanes.mjs +65 -0
- package/plugin/hooks/lib/motion.mjs +34 -5
- package/plugin/hooks/lib/reentry.mjs +7 -0
- package/plugin/hooks/lib/rewind/brief.mjs +332 -0
- package/plugin/hooks/lib/rewind/collect.mjs +328 -0
- package/plugin/hooks/lib/rewind/gauge.mjs +55 -0
- package/plugin/hooks/lib/rewind/next-step.mjs +77 -0
- package/plugin/hooks/lib/rewind/redact.mjs +60 -0
- package/plugin/hooks/lib/rewind/transcripts.mjs +211 -0
- package/plugin/hooks/lib/routes.mjs +79 -5
- package/plugin/hooks/lib/workflow-stack.mjs +213 -0
- package/plugin/hooks/post-tool-use.mjs +37 -1
- package/plugin/hooks/pre-invocation.mjs +91 -2
- package/plugin/hooks/session-start.mjs +26 -3
- package/plugin/hooks/stop.mjs +22 -2
- package/plugin/hud/looks.mjs +29 -0
- package/plugin/hud/render.mjs +234 -12
- package/plugin/plugin.json +1 -1
- package/plugin/skills/frontend-ui-ux/SKILL.md +12 -1
- package/plugin/skills/frontend-ui-ux/kit/components.css +417 -0
- package/plugin/skills/frontend-ui-ux/kit/fonts.json +22 -0
- package/plugin/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
- package/plugin/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
- package/plugin/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
- package/plugin/skills/frontend-ui-ux/kit/ui.js +226 -0
- package/plugin/skills/frontend-ui-ux/references/house-styles.md +234 -0
- package/plugin/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
- package/plugin/skills/frontend-ui-ux/scripts/interface-probe-lock.mjs +196 -0
- package/plugin/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +30 -9
- package/plugin/skills/frontend-ui-ux/scripts/interface-probe-rules.mjs +20 -8
- package/plugin/skills/frontend-ui-ux/scripts/interface-probe.mjs +42 -9
- package/plugin/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
- package/plugin/skills/lit-adhd/SKILL.md +157 -0
- package/plugin/skills/lit-adhd/references/card-examples.md +101 -0
- package/plugin/skills/lit-adhd/references/status-taxonomy.md +32 -0
- package/plugin/skills/lit-adhd/scripts/rewind.mjs +5 -0
- package/plugin/skills/lit-diagram-drawer/SKILL.md +5 -3
- package/plugin/skills/lit-diagram-drawer/references/drawing-rules.md +1 -1
- package/plugin/skills/lit-diagram-drawer/references/style-guide.md +21 -12
- package/plugin/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
- package/plugin/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
- package/plugin/skills/lit-diagram-drawer/references/type-tree.md +3 -3
- package/plugin/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
- package/plugin/skills/lit-diagram-drawer/scripts/diagram-craft-rules.mjs +1 -2
- package/plugin/skills/lit-diagram-drawer/scripts/visual-quality.mjs +1 -2
- package/plugin/skills/lit-docx/SKILL.md +3 -3
- package/plugin/skills/lit-handoff/SKILL.md +1 -0
- package/plugin/skills/lit-hijack/SKILL.md +263 -0
- package/plugin/skills/lit-hijack/references/capture-and-provenance.md +100 -0
- package/plugin/skills/lit-hijack/references/clean-room-build.md +75 -0
- package/plugin/skills/lit-hijack/references/distil-and-licence.md +67 -0
- package/plugin/skills/lit-hijack/references/gap-and-port-design.md +100 -0
- package/plugin/skills/lit-hijack/references/parity-and-report.md +85 -0
- package/plugin/skills/lit-hijack/scripts/hijack.mjs +953 -0
- package/plugin/skills/lit-plan/SKILL.md +1 -1
- package/plugin/skills/lit-pptx/SKILL.md +8 -8
- package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
- package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
- package/plugin/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
- package/plugin/skills/lit-pptx/fonts/provenance.json +32 -1
- package/plugin/skills/lit-pptx/references/agents/analyst.md +34 -56
- package/plugin/skills/lit-pptx/references/agents/antithesis.md +49 -67
- package/plugin/skills/lit-pptx/references/agents/architect.md +38 -51
- package/plugin/skills/lit-pptx/references/agents/critic.md +25 -41
- package/plugin/skills/lit-pptx/references/agents/synthesizer.md +37 -46
- package/plugin/skills/lit-pptx/references/agents/thesis.md +29 -49
- package/plugin/skills/lit-pptx/references/anti-slop-checklist.md +119 -145
- package/plugin/skills/lit-pptx/references/authoring-guide.md +187 -278
- package/plugin/skills/lit-pptx/references/consensus-protocol.md +99 -97
- package/plugin/skills/lit-pptx/references/data-display-cookbook.md +36 -137
- package/plugin/skills/lit-pptx/references/density-and-fill.md +147 -216
- package/plugin/skills/lit-pptx/references/design-system-azure.md +56 -85
- package/plugin/skills/lit-pptx/references/direction-step.md +134 -176
- package/plugin/skills/lit-pptx/references/examples/01-pitch-signal-ko.md +114 -115
- package/plugin/skills/lit-pptx/references/examples/02-pitch-studio-ko.md +66 -66
- package/plugin/skills/lit-pptx/references/examples/03-business-review-ledger-ko.md +63 -63
- package/plugin/skills/lit-pptx/references/examples/04-business-review-night-en.md +96 -96
- package/plugin/skills/lit-pptx/references/examples/05-research-talk-paper-en.md +81 -81
- package/plugin/skills/lit-pptx/references/examples/06-lecture-chalk-ko.md +103 -103
- package/plugin/skills/lit-pptx/references/examples/07-data-review-night-en.md +100 -98
- package/plugin/skills/lit-pptx/references/examples/08-image-led-atlas-ko.md +76 -76
- package/plugin/skills/lit-pptx/references/examples/09-briefing-gazette-ko.md +96 -96
- package/plugin/skills/lit-pptx/references/examples/10-status-update-ledger-ko.md +80 -80
- package/plugin/skills/lit-pptx/references/examples/11-portfolio-studio-en.md +72 -72
- package/plugin/skills/lit-pptx/references/examples/12-research-tutorial-chalk-en.md +95 -95
- package/plugin/skills/lit-pptx/references/examples/13-engineering-review-computational-brutalism-ko.md +173 -0
- package/plugin/skills/lit-pptx/references/examples/14-launch-pitch-neo-brutalism-ko.md +154 -0
- package/plugin/skills/lit-pptx/references/examples/15-design-lecture-bauhaus-ko.md +139 -0
- package/plugin/skills/lit-pptx/references/examples/16-community-programme-riso-ko.md +158 -0
- package/plugin/skills/lit-pptx/references/examples/17-public-data-briefing-newsroom-ko.md +179 -0
- package/plugin/skills/lit-pptx/references/interview-protocol.md +83 -102
- package/plugin/skills/lit-pptx/references/layout-families.md +161 -265
- package/plugin/skills/lit-pptx/references/stages/autopilot.md +30 -70
- package/plugin/skills/lit-pptx/references/stages/interview.md +36 -68
- package/plugin/skills/lit-pptx/references/stages/plan.md +26 -67
- package/plugin/skills/lit-pptx/references/title-treatments.md +93 -145
- package/plugin/skills/lit-pptx/references/tonalities/atlas.md +95 -108
- package/plugin/skills/lit-pptx/references/tonalities/bauhaus.md +140 -0
- package/plugin/skills/lit-pptx/references/tonalities/chalk.md +107 -122
- package/plugin/skills/lit-pptx/references/tonalities/computational-brutalism.md +150 -0
- package/plugin/skills/lit-pptx/references/tonalities/gazette.md +87 -111
- package/plugin/skills/lit-pptx/references/tonalities/ledger.md +96 -125
- package/plugin/skills/lit-pptx/references/tonalities/neo-brutalism.md +161 -0
- package/plugin/skills/lit-pptx/references/tonalities/newsroom.md +144 -0
- package/plugin/skills/lit-pptx/references/tonalities/night.md +104 -131
- package/plugin/skills/lit-pptx/references/tonalities/paper.md +114 -130
- package/plugin/skills/lit-pptx/references/tonalities/riso.md +137 -0
- package/plugin/skills/lit-pptx/references/tonalities/signal.md +96 -103
- package/plugin/skills/lit-pptx/references/tonalities/studio.md +81 -112
- package/plugin/skills/lit-pptx/scripts/compile-deck.js +4 -6
- package/plugin/skills/lit-pptx/scripts/craft_extras.py +135 -91
- package/plugin/skills/lit-pptx/scripts/deck_craft.py +1 -1
- package/plugin/skills/lit-pptx/scripts/embed_fonts.py +13 -1
- package/plugin/skills/lit-pptx/scripts/layout_inventory.py +1 -1
- package/plugin/skills/lit-pptx/scripts/learn_template.py +1 -1
- package/plugin/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
- package/plugin/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
- package/plugin/skills/lit-pptx/scripts/lib/render-pack.js +370 -563
- package/plugin/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
- package/plugin/skills/lit-pptx/scripts/lib/template-registry.js +57 -6
- package/plugin/skills/lit-pptx/scripts/qa_deck.py +6 -6
- package/plugin/skills/lit-pptx/scripts/render_pages.py +31 -0
- package/plugin/skills/lit-pptx/scripts/validate_pptx.py +1 -1
- package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v1.md +167 -191
- package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v2.md +117 -166
- package/plugin/skills/lit-pptx/specs/template-enrollment-contract.md +307 -330
- package/plugin/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
- package/plugin/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +99 -0
- package/plugin/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
- package/plugin/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
- package/plugin/skills/lit-pptx/templates/tonalities/night/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/paper/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
- package/plugin/skills/lit-pptx/templates/tonalities/signal/pack.yaml +2 -2
- package/plugin/skills/lit-pptx/templates/tonalities/studio/pack.yaml +1 -1
- package/plugin/skills/lit-schematic/SKILL.md +114 -0
- package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
- package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
- package/plugin/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
- package/plugin/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
- package/plugin/skills/lit-schematic/references/cutaway-outputs.md +70 -0
- package/plugin/skills/lit-schematic/references/isometric-craft.md +101 -0
- package/plugin/skills/lit-schematic/references/journal-figures.md +72 -0
- package/plugin/skills/lit-schematic/references/kit-api.md +134 -0
- package/plugin/skills/lit-schematic/references/pfd-and-layout.md +53 -0
- package/plugin/skills/lit-schematic/references/pid-drafting.md +103 -0
- package/plugin/skills/lit-schematic/references/pid-symbols.md +163 -0
- package/plugin/skills/lit-schematic/references/verification.md +100 -0
- package/plugin/skills/lit-schematic/scripts/doctor.mjs +57 -0
- package/plugin/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
- package/plugin/skills/lit-schematic/scripts/lib/fonts.mjs +27 -0
- package/plugin/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
- package/plugin/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
- package/plugin/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
- package/plugin/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
- package/plugin/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
- package/plugin/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
- package/plugin/skills/lit-schematic/scripts/lib/png.mjs +132 -0
- package/plugin/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
- package/plugin/skills/lit-schematic/scripts/lib/route.mjs +218 -0
- package/plugin/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
- package/plugin/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
- package/plugin/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
- package/plugin/skills/lit-schematic/scripts/motion.mjs +129 -0
- package/plugin/skills/lit-schematic/scripts/qa.mjs +92 -0
- package/plugin/skills/lit-schematic/scripts/render.mjs +233 -0
- package/plugin/skills/lit-schematic/scripts/scaffold.mjs +60 -0
- package/plugin/skills/lit-scientific-visualization/SKILL.md +17 -6
- package/plugin/skills/lit-typographic-motion/SKILL.md +58 -48
- package/plugin/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +13 -2
- package/plugin/skills/lit-typographic-motion/engine/blender/runner.py +218 -0
- package/plugin/skills/lit-typographic-motion/engine/core/presets.mjs +1 -1
- package/plugin/skills/lit-typographic-motion/engine/node/analysis.mjs +65 -1
- package/plugin/skills/lit-typographic-motion/engine/node/assets.mjs +298 -0
- package/plugin/skills/lit-typographic-motion/engine/node/blender.mjs +143 -0
- package/plugin/skills/lit-typographic-motion/engine/node/board.mjs +136 -0
- package/plugin/skills/lit-typographic-motion/engine/node/brief.mjs +7 -1
- package/plugin/skills/lit-typographic-motion/engine/node/chrome.mjs +9 -12
- package/plugin/skills/lit-typographic-motion/engine/node/cover-assets.mjs +5 -3
- package/plugin/skills/lit-typographic-motion/engine/node/cover-capture.mjs +7 -6
- package/plugin/skills/lit-typographic-motion/engine/node/cover-treatment.mjs +37 -4
- package/plugin/skills/lit-typographic-motion/engine/node/cover.mjs +19 -8
- package/plugin/skills/lit-typographic-motion/engine/node/done.mjs +45 -6
- package/plugin/skills/lit-typographic-motion/engine/node/frame-worker.mjs +7 -5
- package/plugin/skills/lit-typographic-motion/engine/node/gallery.mjs +121 -0
- package/plugin/skills/lit-typographic-motion/engine/node/host.mjs +34 -0
- package/plugin/skills/lit-typographic-motion/engine/node/house.mjs +44 -0
- package/plugin/skills/lit-typographic-motion/engine/node/look.mjs +34 -20
- package/plugin/skills/lit-typographic-motion/engine/node/pipeline.mjs +19 -9
- package/plugin/skills/lit-typographic-motion/engine/node/scaffold.mjs +210 -0
- package/plugin/skills/lit-typographic-motion/engine/node/score.mjs +639 -0
- package/plugin/skills/lit-typographic-motion/engine/node/sound-cli.mjs +21 -4
- package/plugin/skills/lit-typographic-motion/engine/node/sound.mjs +127 -29
- package/plugin/skills/lit-typographic-motion/engine/node/stage-capture.mjs +7 -6
- package/plugin/skills/lit-typographic-motion/engine/node/stage-gate.mjs +59 -5
- package/plugin/skills/lit-typographic-motion/engine/node/stage-qa.mjs +141 -9
- package/plugin/skills/lit-typographic-motion/engine/node/stage-serve.mjs +28 -5
- package/plugin/skills/lit-typographic-motion/engine/node/stage.mjs +82 -14
- package/plugin/skills/lit-typographic-motion/engine/node/styles.mjs +213 -0
- package/plugin/skills/lit-typographic-motion/engine/node/treatment.mjs +311 -10
- package/plugin/skills/lit-typographic-motion/engine/stage/cover-init.js +14 -2
- package/plugin/skills/lit-typographic-motion/engine/stage/init.js +11 -1
- package/plugin/skills/lit-typographic-motion/engine/stage/qa.js +6 -1
- package/plugin/skills/lit-typographic-motion/engine/stage/stage-kit.js +83 -0
- package/plugin/skills/lit-typographic-motion/engine/vendor/three/LICENSE +21 -0
- package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +144 -0
- package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
- package/plugin/skills/lit-typographic-motion/engine/vendor/three/three.module.js +54571 -0
- package/plugin/skills/lit-typographic-motion/recipes/hero-3d/expected.json +69 -0
- package/plugin/skills/lit-typographic-motion/recipes/hero-3d/index.html +139 -0
- package/plugin/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +6 -4
- package/plugin/skills/lit-typographic-motion/recipes/painted-light/expected.json +4 -2
- package/plugin/skills/lit-typographic-motion/recipes/weight-tide/expected.json +7 -5
- package/plugin/skills/lit-typographic-motion/references/cover.md +394 -443
- package/plugin/skills/lit-typographic-motion/references/craft-loop.md +57 -87
- package/plugin/skills/lit-typographic-motion/references/depth.md +122 -0
- package/plugin/skills/lit-typographic-motion/references/look.md +94 -129
- package/plugin/skills/lit-typographic-motion/references/runtime.md +58 -91
- package/plugin/skills/lit-typographic-motion/references/sound.md +130 -99
- package/plugin/skills/lit-typographic-motion/references/stage.md +190 -215
- package/plugin/skills/lit-typographic-motion/references/studio.md +245 -0
- package/plugin/skills/lit-typographic-motion/references/style-bibles.md +108 -97
- package/plugin/skills/lit-typographic-motion/references/treatment.md +191 -143
- package/plugin/skills/lit-typographic-motion/scripts/motion-doctor.mjs +17 -5
- package/plugin/skills/lit-typographic-motion/scripts/motion.mjs +47 -7
- package/plugin/skills/lit-typographic-motion/styles/paper.json +41 -0
- package/plugin/skills/lit-typographic-motion/styles/swiss-signal.json +41 -0
- package/plugin/skills/lit-typographic-motion/styles/terminalcore.json +42 -0
- package/plugin/skills/lit-typographic-motion/styles/tidal.json +41 -0
- package/plugin/skills/litresearch/SKILL.md +1 -0
- package/plugin/skills/readme-studio/SKILL.md +2 -0
- package/plugin/skills/readme-studio/templates/hyperframes-cover/package-lock.json +3 -3
- package/plugin/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
- package/plugin/skills/review-work/SKILL.md +1 -1
- package/plugin/skills/start-work/SKILL.md +1 -1
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
// registered canvas text) with its rects and opacity; at the QA samples (each beat midpoint plus two
|
|
4
4
|
// settled frames per beat) it captures A, switches the ink rule on, captures B, and measures the ink
|
|
5
5
|
// mask A != B inside each run's rects. From those it judges copy found, contrast, title-safe, the
|
|
6
|
-
// reading floor, decor limits, meta labels, fonts, unmeasured canvas text and non-text presence
|
|
6
|
+
// reading floor, decor limits, meta labels, fonts, unmeasured canvas text and non-text presence, and
|
|
7
|
+
// against the film's house style: text over text, copy off the style's colours, faces or type scale,
|
|
8
|
+
// and copy outside its shot's type zone (references/studio.md).
|
|
7
9
|
import { readFileSync } from "node:fs";
|
|
8
10
|
import { fileURLToPath } from "node:url";
|
|
9
11
|
import { EXIT, GATE } from "../core/constants.mjs";
|
|
10
12
|
import { measureContrast } from "../core/contrast.mjs";
|
|
11
13
|
import { readingFloor } from "../core/text.mjs";
|
|
14
|
+
import { regionFill } from "./analysis.mjs";
|
|
15
|
+
import { LAYOUTS, ZONE_TOLERANCE, styleFamilies, styleTextColors, readStyle, scaleStep } from "./styles.mjs";
|
|
12
16
|
import { STAGE_FAMILIES } from "./stage-serve.mjs";
|
|
13
17
|
import { normalizeText, stripQuoted } from "./treatment.mjs";
|
|
14
18
|
|
|
@@ -16,8 +20,9 @@ const QA_FILE = fileURLToPath(new URL("../stage/qa.js", import.meta.url));
|
|
|
16
20
|
|
|
17
21
|
export const TEXT_QA = Object.freeze({
|
|
18
22
|
sampleFps: 10, visibleOpacity: 0.6, settledOpacity: 0.95, settledMovePx: 2, minInkPx: 12, inkDelta: 2,
|
|
19
|
-
titleSafeInset: 0.05, largeShare: 0.03, decorAreaShare: 0.25, readingToleranceSec: 0.1, presenceStd: 8 / 255,
|
|
23
|
+
titleSafeInset: 0.05, largeShare: 0.03, decorAreaShare: 0.25, decorAreaShareRich: 0.6, labelsFound: 0.75, labelRuns: 3, emptyRegion: 0.15, emptyRegionsMax: 2, readingToleranceSec: 0.1, presenceStd: 8 / 255,
|
|
20
24
|
settledAt: [0.75, 0.9], internalTerms: /\b(?:path|preset|gate|beat|treatment)\b/iu,
|
|
25
|
+
overlapShare: 0.08, colourDistance: 12, cutWindowSec: 0.4, cutStep: 2,
|
|
21
26
|
fileName: /\b[\w-]+\.(?:html?|m?js|css|png|jpe?g|webp|gif|svg|json|wav|mp4)\b/iu,
|
|
22
27
|
});
|
|
23
28
|
|
|
@@ -36,7 +41,11 @@ export function runClass(run, copyNorm) {
|
|
|
36
41
|
return copyNorm.some((line) => line.includes(n) || n.includes(line)) ? "copy" : "other";
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* The QA sample frames: each beat midpoint plus two settled frames late in the beat, and every second
|
|
46
|
+
* frame within 0.4 s of each cut (`cut: true`), where an outgoing and an incoming line can cross. The
|
|
47
|
+
* cut rows feed only the text-over-text check; a line mid-transition is not judged for style or zone.
|
|
48
|
+
*/
|
|
40
49
|
export function qaSamples({ beats, fps, frameCount }) {
|
|
41
50
|
const clamp = (f) => Math.max(0, Math.min(frameCount - 1, f));
|
|
42
51
|
const rows = [];
|
|
@@ -46,6 +55,14 @@ export function qaSamples({ beats, fps, frameCount }) {
|
|
|
46
55
|
});
|
|
47
56
|
const seen = new Map();
|
|
48
57
|
for (const row of rows) if (!seen.has(row.frame) || row.mid) seen.set(row.frame, row);
|
|
58
|
+
const reach = Math.round(TEXT_QA.cutWindowSec * fps);
|
|
59
|
+
beats.forEach((b, i) => {
|
|
60
|
+
if (i === 0) return;
|
|
61
|
+
const at = Math.round(b.t0 * fps);
|
|
62
|
+
for (let f = clamp(at - reach); f <= clamp(at + reach); f += TEXT_QA.cutStep) {
|
|
63
|
+
if (!seen.has(f)) seen.set(f, { frame: f, beat: f < at ? i - 1 : i, mid: false, cut: true });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
49
66
|
return [...seen.values()].sort((a, b) => a.frame - b.frame);
|
|
50
67
|
}
|
|
51
68
|
|
|
@@ -96,6 +113,86 @@ export function groundStd(rgba, width, height, rects) {
|
|
|
96
113
|
return n ? Math.sqrt(Math.max(0, sq / n - (sum / n) ** 2)) : 0;
|
|
97
114
|
}
|
|
98
115
|
|
|
116
|
+
/** [r, g, b] of a CSS colour string (rgb(), rgba() or #hex), or null. */
|
|
117
|
+
export function parseCssColour(value) {
|
|
118
|
+
const text = String(value ?? "").trim();
|
|
119
|
+
const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/u.exec(text);
|
|
120
|
+
if (rgb) return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])];
|
|
121
|
+
const hex = /^#([0-9a-f]{6})$/iu.exec(text);
|
|
122
|
+
if (hex) return [0, 2, 4].map((i) => Number.parseInt(hex[1].slice(i, i + 2), 16));
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const area = (b) => Math.max(0, b[2] - b[0]) * Math.max(0, b[3] - b[1]);
|
|
127
|
+
const overlapArea = (a, b) => area([Math.max(a[0], b[0]), Math.max(a[1], b[1]), Math.min(a[2], b[2]), Math.min(a[3], b[3])]);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The style rules on the collected samples: text over text (any visible runs), and for copy at its
|
|
131
|
+
* settled samples, the style's colours, faces and type scale and the shot's type zone.
|
|
132
|
+
*/
|
|
133
|
+
export function judgeStyle({ treatment, width, height, samples, settled, copyNorm }) {
|
|
134
|
+
const style = readStyle(treatment.style);
|
|
135
|
+
const format = width >= height ? "16:9" : "9:16";
|
|
136
|
+
const colours = styleTextColors(style).map(parseCssColour);
|
|
137
|
+
const families = styleFamilies(style);
|
|
138
|
+
const overlaps = [];
|
|
139
|
+
const offColour = [];
|
|
140
|
+
const offFace = [];
|
|
141
|
+
const offScale = [];
|
|
142
|
+
const offScaleOther = [];
|
|
143
|
+
const offZone = [];
|
|
144
|
+
const tolX = width * ZONE_TOLERANCE;
|
|
145
|
+
const tolY = height * ZONE_TOLERANCE;
|
|
146
|
+
for (const s of samples) {
|
|
147
|
+
const visible = s.runs
|
|
148
|
+
.map((run) => ({ run, box: union(run.rects) }))
|
|
149
|
+
.filter(({ run, box }) => box && !run.decor && run.opacity >= TEXT_QA.visibleOpacity && (run.kind === "canvas" || countIn(s.mask, width, box) >= TEXT_QA.minInkPx));
|
|
150
|
+
for (let i = 0; i < visible.length; i++) {
|
|
151
|
+
for (let j = i + 1; j < visible.length; j++) {
|
|
152
|
+
const a = visible[i];
|
|
153
|
+
const b = visible[j];
|
|
154
|
+
const shared = overlapArea(a.box, b.box);
|
|
155
|
+
if (shared > TEXT_QA.overlapShare * Math.min(area(a.box), area(b.box))) overlaps.push(`"${a.run.text.slice(0, 24)}" × "${b.run.text.slice(0, 24)}"@${s.frame}${s.cut ? " (cut)" : ""}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (s.cut) continue;
|
|
159
|
+
const beat = treatment.beats[s.beat];
|
|
160
|
+
const layout = beat?.layout ? LAYOUTS[format][beat.layout] : null;
|
|
161
|
+
for (const { run, box } of visible) {
|
|
162
|
+
if (run.kind === "canvas" || !settled(s.frame, run)) continue;
|
|
163
|
+
const copy = runClass(run, copyNorm) === "copy";
|
|
164
|
+
const where = `"${run.text.slice(0, 32)}"@${s.frame}`;
|
|
165
|
+
if (copy) {
|
|
166
|
+
const rgb = parseCssColour(run.color);
|
|
167
|
+
if (!run.gradient && rgb && !colours.some((c) => Math.hypot(c[0] - rgb[0], c[1] - rgb[1], c[2] - rgb[2]) <= TEXT_QA.colourDistance)) offColour.push(`${where} ${run.color}`);
|
|
168
|
+
if (run.family && !families.has(run.family)) offFace.push(`${where} ${run.family}`);
|
|
169
|
+
}
|
|
170
|
+
if (!scaleStep(style, format, run.fontSizePx)) (copy ? offScale : offScaleOther).push(`${where} ${run.fontSizePx}px`);
|
|
171
|
+
if (copy && layout) {
|
|
172
|
+
const z = layout.type;
|
|
173
|
+
if (!z) offZone.push(`${where} in a full shot (no copy zone)`);
|
|
174
|
+
else {
|
|
175
|
+
const [zx, zy, zw, zh] = [z[0] * width, z[1] * height, z[2] * width, z[3] * height];
|
|
176
|
+
if (box[0] < zx - tolX || box[1] < zy - tolY || box[2] > zx + zw + tolX || box[3] > zy + zh + tolY) offZone.push(`${where} outside the ${beat.layout} type zone`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const steps = Object.entries(style.scale[format]).map(([k, v]) => `${k} ${v}`).join(", ");
|
|
182
|
+
const rules = [];
|
|
183
|
+
rules.push(overlaps.length ? r("TEXT-OVERLAP", "FAIL", `text over text: ${overlaps.slice(0, 4).join(", ")}`) : r("TEXT-OVERLAP", "PASS", `no two visible text runs overlap at the QA samples${samples.some((s) => s.cut) ? " or across the cuts" : ""}`));
|
|
184
|
+
const styleFails = [
|
|
185
|
+
offColour.length ? `colour off the ${style.id} text roles (${style.textRoles.join(", ")}): ${offColour.slice(0, 3).join(", ")}` : null,
|
|
186
|
+
offFace.length ? `face outside the style (${[...families].join(", ")}): ${offFace.slice(0, 3).join(", ")}` : null,
|
|
187
|
+
offScale.length ? `size off the type scale (${steps} px, ±4 %): ${offScale.slice(0, 3).join(", ")}` : null,
|
|
188
|
+
].filter(Boolean);
|
|
189
|
+
rules.push(styleFails.length ? r("TEXT-ON-STYLE", "FAIL", styleFails.join("; "))
|
|
190
|
+
: offScaleOther.length ? r("TEXT-ON-STYLE", "WARN", `copy is on the ${style.id} style; other text off the scale: ${offScaleOther.slice(0, 3).join(", ")}`)
|
|
191
|
+
: r("TEXT-ON-STYLE", "PASS", `copy uses the ${style.id} colours, faces and type scale`));
|
|
192
|
+
rules.push(offZone.length ? r("TEXT-ZONE", "FAIL", offZone.slice(0, 4).join(", ")) : r("TEXT-ZONE", "PASS", "every settled copy run sits in its shot's type zone"));
|
|
193
|
+
return rules;
|
|
194
|
+
}
|
|
195
|
+
|
|
99
196
|
/**
|
|
100
197
|
* Judge the collected samples. `timeline` is [{ frame, t, runs }] at 10 fps; `samples` is
|
|
101
198
|
* [{ frame, beat, mid, runs, mask, rgbaA, rgbaB, stray, fonts }]. Pure, so the tests can drive it.
|
|
@@ -114,8 +211,9 @@ export function judgeText({ treatment, width, height, timeline, samples, canvasU
|
|
|
114
211
|
const exit = missing.length ? { exit: EXIT.STAGE_CONTRACT_ERROR, message: `STAGE_CONTRACT_ERROR: copy line not on screen: "${missing[0]}"; every copy.lines entry must appear in one text run (mark its element with LitStage.text)` } : null;
|
|
115
212
|
rules.push(missing.length ? r("TEXT-COPY-FOUND", "FAIL", `not on screen: ${missing.map((m) => `"${m}"`).join(", ")}`) : r("TEXT-COPY-FOUND", "PASS", `all ${copy.length} copy lines found on screen`));
|
|
116
213
|
|
|
117
|
-
const usable = samples.filter((s) => !s.discarded);
|
|
118
|
-
const
|
|
214
|
+
const usable = samples.filter((s) => !s.discarded && !s.cut);
|
|
215
|
+
const crossing = samples.filter((s) => !s.discarded && s.cut);
|
|
216
|
+
const moved = samples.filter((s) => s.discarded && !s.cut);
|
|
119
217
|
if (moved.length) rules.push(r("TEXT-SAMPLES", "WARN", `${moved.length} QA sample(s) discarded: state moved between the A and B captures (frames ${moved.map((s) => s.frame).join(", ")})`));
|
|
120
218
|
|
|
121
219
|
// Settled: the run's box moved < 2 px since the neighbouring 10 fps samples, opacity >= 0.95.
|
|
@@ -170,10 +268,28 @@ export function judgeText({ treatment, width, height, timeline, samples, canvasU
|
|
|
170
268
|
: measured === 0 ? r("TEXT-CONTRAST", "WARN", "no settled text sample could be measured; the look must answer legibility")
|
|
171
269
|
: r("TEXT-CONTRAST", contrastWarns.length ? "WARN" : "PASS", contrastWarns.length ? `copy passes; non-copy text: ${contrastWarns.slice(0, 3).join(", ")}` : `${measured} settled text measurements at or above 4.5:1 (3:1 at >= 3 % of the short side)`));
|
|
172
270
|
rules.push(safeFails.length ? r("TEXT-TITLE-SAFE", "FAIL", `copy outside the central 90 %: ${safeFails.slice(0, 4).join(", ")}`) : r("TEXT-TITLE-SAFE", "PASS", "every copy run inside the central 90 % of the frame at the QA samples"));
|
|
173
|
-
|
|
271
|
+
// A rich film may fill its world with decor text (readouts, part numbers); a minimal one keeps it rare.
|
|
272
|
+
const rich = treatment.register !== "minimal";
|
|
273
|
+
const decorCap = rich ? TEXT_QA.decorAreaShareRich : TEXT_QA.decorAreaShare;
|
|
274
|
+
const heavy = decorShare.filter((d) => d.share > decorCap);
|
|
174
275
|
rules.push(decorCopy.size || heavy.length
|
|
175
|
-
? r("TEXT-DECOR", "FAIL", [decorCopy.size ? `decor text carries copy: ${[...decorCopy].map((t) => `"${t.slice(0, 40)}"`).join(", ")}` : null, heavy.length ? `decor text over
|
|
176
|
-
: r("TEXT-DECOR", "PASS",
|
|
276
|
+
? r("TEXT-DECOR", "FAIL", [decorCopy.size ? `decor text carries copy: ${[...decorCopy].map((t) => `"${t.slice(0, 40)}"`).join(", ")}` : null, heavy.length ? `decor text over ${decorCap * 100} % of the visible text area at frame ${heavy[0].frame} (${(heavy[0].share * 100).toFixed(0)} %)` : null].filter(Boolean).join("; "))
|
|
277
|
+
: r("TEXT-DECOR", "PASS", `decor text carries no copy and stays within ${decorCap * 100} % of the text area`));
|
|
278
|
+
|
|
279
|
+
// Labels: a rich film shows the labelled parts its world plans, and each shot carries several
|
|
280
|
+
// readable runs, not one line alone on a field.
|
|
281
|
+
const planned = rich ? (treatment.world?.labels ?? []) : [];
|
|
282
|
+
if (!planned.length) rules.push(r("TEXT-LABELS", "N/A", rich ? "the treatment plans no world labels" : "minimal register: no label density asked"));
|
|
283
|
+
else {
|
|
284
|
+
const unseen = planned.filter((label) => !allRuns.some((run) => shown(run) && normalizeText(run.text).includes(normalizeText(label))));
|
|
285
|
+
const mids = usable.filter((s) => s.mid);
|
|
286
|
+
const thin = mids.filter((s) => s.runs.filter((run) => !run.decor && shown(run) && normalizeText(run.text)).length < TEXT_QA.labelRuns);
|
|
287
|
+
const found = planned.length - unseen.length;
|
|
288
|
+
const fail = found < TEXT_QA.labelsFound * planned.length || thin.length * 2 > mids.length;
|
|
289
|
+
rules.push(fail
|
|
290
|
+
? r("TEXT-LABELS", "FAIL", [found < TEXT_QA.labelsFound * planned.length ? `${found} of ${planned.length} planned labels on screen (not seen: ${unseen.slice(0, 3).map((l) => `"${l}"`).join(", ")})` : null, thin.length * 2 > mids.length ? `${thin.length} of ${mids.length} beat midpoints show fewer than ${TEXT_QA.labelRuns} readable text runs (frames ${thin.map((s) => s.frame).slice(0, 6).join(", ")})` : null].filter(Boolean).join("; "))
|
|
291
|
+
: r("TEXT-LABELS", "PASS", `${found} of ${planned.length} planned labels on screen; ${mids.length - thin.length} of ${mids.length} beat midpoints carry ${TEXT_QA.labelRuns}+ readable runs`));
|
|
292
|
+
}
|
|
177
293
|
|
|
178
294
|
// Reading floor at 10 fps: the longest continuous visible span of each copy line.
|
|
179
295
|
const reading = [];
|
|
@@ -227,12 +343,28 @@ export function judgeText({ treatment, width, height, timeline, samples, canvasU
|
|
|
227
343
|
|
|
228
344
|
rules.push(canvasUnmeasured.length ? r("TEXT-CANVAS", "WARN", `canvas text not measured at frames ${canvasUnmeasured.slice(0, 6).join(", ")}: register it with LitStage.text({content, x, y, w, h}); the look must answer it`) : r("TEXT-CANVAS", "PASS", "no unregistered canvas text"));
|
|
229
345
|
|
|
346
|
+
if (treatment.style) rules.push(...judgeStyle({ treatment, width, height, samples: [...usable, ...crossing], settled, copyNorm }));
|
|
347
|
+
|
|
230
348
|
const mids = usable.filter((s) => s.mid);
|
|
231
349
|
const present = mids.filter((s) => s.groundStd > TEXT_QA.presenceStd).length;
|
|
232
350
|
rules.push(mids.length && present * 2 >= mids.length ? r("TEXT-PRESENCE", "PASS", `${present} of ${mids.length} beat midpoints show drawn content outside the text`) : r("TEXT-PRESENCE", "WARN", `only ${present} of ${mids.length} beat midpoints show drawn content outside the text; the film may only name its subject`));
|
|
351
|
+
rules.push(richFill({ treatment, mids }));
|
|
233
352
|
return { rules, ...(exit ?? {}) };
|
|
234
353
|
}
|
|
235
354
|
|
|
355
|
+
// A rich film fills its frame the way a dense reference does: at each beat midpoint at most two of
|
|
356
|
+
// the 12 regions may sit empty (busy share under 0.15). The end card may breathe, so one beat may miss.
|
|
357
|
+
function richFill({ treatment, mids }) {
|
|
358
|
+
if (treatment.register === "minimal") return r("RICH-FILL", "N/A", "minimal register: negative space is the point");
|
|
359
|
+
const measured = mids.filter((s) => Array.isArray(s.regions));
|
|
360
|
+
if (!measured.length) return r("RICH-FILL", "N/A", "region fill not measured");
|
|
361
|
+
const thin = measured
|
|
362
|
+
.map((s) => ({ beat: s.beat, empty: s.regions.filter((v) => v < TEXT_QA.emptyRegion).length }))
|
|
363
|
+
.filter((x) => x.empty > TEXT_QA.emptyRegionsMax);
|
|
364
|
+
if (thin.length <= 1) return r("RICH-FILL", "PASS", `${measured.length - thin.length} of ${measured.length} beat midpoints fill the frame (at most ${TEXT_QA.emptyRegionsMax} of 12 regions empty)`);
|
|
365
|
+
return r("RICH-FILL", "FAIL", `${thin.length} of ${measured.length} beat midpoints leave the frame empty: ${thin.map((x) => `beat ${x.beat + 1} has ${x.empty} of 12 regions empty`).join(", ")}. Fill them with the world's parts: labelled panels, counters, a log, the product's own screens (references/studio.md, Register)`);
|
|
366
|
+
}
|
|
367
|
+
|
|
236
368
|
/**
|
|
237
369
|
* The QA replay, as the stage renderer's `qa` hook: opens its own Chrome, steps the clock from 0,
|
|
238
370
|
* collects the timeline and the A/B samples, and returns { rules, exit?, message? }.
|
|
@@ -268,7 +400,7 @@ export function textQaReplay({ pool, stageFiles = [] }) {
|
|
|
268
400
|
const stray = strayInk(mask, width, height, rects);
|
|
269
401
|
let fonts = {};
|
|
270
402
|
if (sample.mid) fonts = await platformFonts(browser, runs);
|
|
271
|
-
collected.push({ ...sample, runs, mask, rgbaA: a.rgba, discarded: stray > 0, stray, fonts, groundStd: groundStd(b.rgba, width, height, rects) });
|
|
403
|
+
collected.push({ ...sample, runs, mask, rgbaA: a.rgba, discarded: stray > 0, stray, fonts, groundStd: groundStd(b.rgba, width, height, rects), ...(sample.mid ? { regions: regionFill(a.rgba, width, height) } : {}) });
|
|
272
404
|
}
|
|
273
405
|
} finally {
|
|
274
406
|
await browser.close();
|
|
@@ -7,6 +7,7 @@ import { existsSync, lstatSync, readFileSync, readdirSync, realpathSync, statSyn
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
import { EXIT } from "../core/constants.mjs";
|
|
10
|
+
import { readPlate } from "./blender.mjs";
|
|
10
11
|
import { BlockedError } from "./chrome.mjs";
|
|
11
12
|
import { checkFont, fontLocation, fontsDir, loadFontManifest } from "./runtime.mjs";
|
|
12
13
|
|
|
@@ -15,6 +16,9 @@ export const KIT_FILE = fileURLToPath(new URL("../stage/stage-kit.js", import.me
|
|
|
15
16
|
export const INIT_FILE = fileURLToPath(new URL("../stage/init.js", import.meta.url));
|
|
16
17
|
export const LOOP_KIT_FILE = fileURLToPath(new URL("../stage/loop-kit.js", import.meta.url));
|
|
17
18
|
export const COVER_INIT_FILE = fileURLToPath(new URL("../stage/cover-init.js", import.meta.url));
|
|
19
|
+
// The pinned three.js build and its few addons (engine/vendor/three, MIT), served at /lit/three/ for
|
|
20
|
+
// the 3D route (references/depth.md). Pages import them through an import map; nothing is fetched.
|
|
21
|
+
export const THREE_DIR = fileURLToPath(new URL("../vendor/three/", import.meta.url));
|
|
18
22
|
|
|
19
23
|
export const CONTENT_TYPES = Object.freeze({
|
|
20
24
|
".html": "text/html; charset=utf-8", ".js": "text/javascript; charset=utf-8", ".mjs": "text/javascript; charset=utf-8",
|
|
@@ -179,17 +183,22 @@ const NETWORK_API = /\bnew\s+(WebSocket|WebTransport|RTCPeerConnection|EventSour
|
|
|
179
183
|
|
|
180
184
|
/**
|
|
181
185
|
* Scan the stage dir before launch. Throws exit 17 (contract) or 19 (network) naming the file and
|
|
182
|
-
* the thing found; returns { files, rasters, warnings } otherwise.
|
|
186
|
+
* the thing found; returns { files, rasters, warnings, plate } otherwise (plate: the Blender plate, or null).
|
|
183
187
|
*/
|
|
184
188
|
export function scanStage(stageDir) {
|
|
185
189
|
if (!existsSync(path.join(stageDir, "index.html"))) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${path.join(stageDir, "index.html")} is missing; write the stage page first (references/stage.md)`);
|
|
186
190
|
const files = listStage(stageDir);
|
|
187
191
|
const warnings = [];
|
|
188
192
|
const rasters = [];
|
|
193
|
+
// A Blender plate and its preview stills are frames the runner wrote and plate.json lists by name
|
|
194
|
+
// and size; they are not page rasters. Anything not listed is held to the raster limits.
|
|
195
|
+
const plate = readPlate(stageDir, "plate");
|
|
196
|
+
const preview = readPlate(stageDir, "plate-preview");
|
|
197
|
+
const listed = new Set([plate, preview].filter(Boolean).flatMap((p) => p.frames.map((f) => path.join(p.dir, f.name))));
|
|
189
198
|
for (const f of files) {
|
|
190
199
|
const ext = path.extname(f.rel).toLowerCase();
|
|
191
|
-
if (!CONTENT_TYPES[ext]) warnings.push(`${f.rel}: not a servable type; the page cannot load it`);
|
|
192
|
-
if (RASTER.includes(ext)) {
|
|
200
|
+
if (!CONTENT_TYPES[ext] && f.rel !== "scene.py") warnings.push(`${f.rel}: not a servable type; the page cannot load it`);
|
|
201
|
+
if (RASTER.includes(ext) && !listed.has(f.rel)) {
|
|
193
202
|
const info = rasterInfo(f.real);
|
|
194
203
|
if (!info) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${f.rel} is not a readable ${ext.slice(1)} image`);
|
|
195
204
|
if (info.animated) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${f.rel} is an animated image; rasters are textures and stills, never a frame sequence`);
|
|
@@ -225,14 +234,14 @@ export function scanStage(stageDir) {
|
|
|
225
234
|
for (const [size, names] of bySize) {
|
|
226
235
|
if (names.length >= RASTER_LIMITS.flipbook) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${names.length} rasters of ${size} look like a flipbook; animate the page, not a frame sequence`);
|
|
227
236
|
}
|
|
228
|
-
return { files, rasters, warnings };
|
|
237
|
+
return { files, rasters, warnings, plate };
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
/**
|
|
232
241
|
* The request router for one stage run. Returns { kind: "file", file, type } | { kind: "body", body,
|
|
233
242
|
* type } | { kind: "blocked", reason } | { kind: "missing" }, and records every refusal.
|
|
234
243
|
*/
|
|
235
|
-
export function stageRouter({ stageDir, faces }) {
|
|
244
|
+
export function stageRouter({ stageDir, faces, style = null }) {
|
|
236
245
|
const root = realpathSync(stageDir);
|
|
237
246
|
const css = fontsCss(faces);
|
|
238
247
|
const byRoute = new Map(faces.map((f) => [f.route, f.file]));
|
|
@@ -251,9 +260,23 @@ export function stageRouter({ stageDir, faces }) {
|
|
|
251
260
|
return { kind: "blocked" };
|
|
252
261
|
}
|
|
253
262
|
const pathname = decodeURIComponent(parsed.pathname);
|
|
263
|
+
// Chrome asks for a favicon on its own; the page did not, so it is not a missing file of the page.
|
|
264
|
+
if (pathname === "/favicon.ico") return { kind: "missing" };
|
|
254
265
|
if (pathname === "/lit/stage-kit.js") return { kind: "file", file: KIT_FILE, type: CONTENT_TYPES[".js"] };
|
|
255
266
|
if (pathname === "/lit/loop-kit.js") return { kind: "file", file: LOOP_KIT_FILE, type: CONTENT_TYPES[".js"] };
|
|
256
267
|
if (pathname === "/lit/fonts.css") return { kind: "body", body: css, type: CONTENT_TYPES[".css"] };
|
|
268
|
+
if (pathname.startsWith("/lit/three/")) {
|
|
269
|
+
const rel = pathname.slice("/lit/three/".length);
|
|
270
|
+
const file = path.join(THREE_DIR, rel);
|
|
271
|
+
if (rel.split("/").includes("..") || !rel.endsWith(".js") || !existsSync(file)) {
|
|
272
|
+
missing.push({ url, reason: "not a vendored three.js file" });
|
|
273
|
+
return { kind: "missing" };
|
|
274
|
+
}
|
|
275
|
+
return { kind: "file", file, type: CONTENT_TYPES[".js"] };
|
|
276
|
+
}
|
|
277
|
+
// The film's house style (references/studio.md): type, colour and zone tokens, and the shot timeline.
|
|
278
|
+
if (style && pathname === "/lit/style.css") return { kind: "body", body: style.css, type: CONTENT_TYPES[".css"] };
|
|
279
|
+
if (style && pathname === "/lit/style.js") return { kind: "body", body: style.js, type: CONTENT_TYPES[".js"] };
|
|
257
280
|
if (byRoute.has(pathname)) return { kind: "file", file: byRoute.get(pathname), type: CONTENT_TYPES[path.extname(pathname)] };
|
|
258
281
|
const rel = pathname === "/" ? "index.html" : pathname.replace(/^\/+/u, "");
|
|
259
282
|
if (rel.split("/").includes("..")) {
|
|
@@ -11,6 +11,9 @@ import path from "node:path";
|
|
|
11
11
|
import { EXIT, GATE, PREVIEW } from "../core/constants.mjs";
|
|
12
12
|
import { FlashDetector, cellsFromRgba, detectSequence, gridFor } from "../core/flash.mjs";
|
|
13
13
|
import { areaDownscale } from "./analysis.mjs";
|
|
14
|
+
import { assetUsed } from "./assets.mjs";
|
|
15
|
+
import { BLENDER } from "./blender.mjs";
|
|
16
|
+
import { addToStills, writeBoard } from "./board.mjs";
|
|
14
17
|
import { BlockedError } from "./chrome.mjs";
|
|
15
18
|
import { findFfmpeg, findFfprobe, findImg2webp, previewRungs, startMaster, encodePreview, probeVideo } from "./encode.mjs";
|
|
16
19
|
import { resolveViewed, asBlocked } from "./pipeline.mjs";
|
|
@@ -21,6 +24,8 @@ import { StageBrowser, FramePool, analyzeChecked } from "./stage-capture.mjs";
|
|
|
21
24
|
import { evaluateStageGate, formatStageReport } from "./stage-gate.mjs";
|
|
22
25
|
import { textQaReplay } from "./stage-qa.mjs";
|
|
23
26
|
import { treatmentSha } from "./done.mjs";
|
|
27
|
+
import { recordHouse } from "./house.mjs";
|
|
28
|
+
import { styleCss, styleScript, readStyle } from "./styles.mjs";
|
|
24
29
|
import { scanStage, stageFonts } from "./stage-serve.mjs";
|
|
25
30
|
import { beatCuts, stillsPlan, writeStills } from "./stills.mjs";
|
|
26
31
|
import { FORMATS, loadTreatment } from "./treatment.mjs";
|
|
@@ -33,11 +38,19 @@ const writeJson = (file, value) => {
|
|
|
33
38
|
writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
34
39
|
};
|
|
35
40
|
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
41
|
+
/** The house style the page is served (/lit/style.css, /lit/style.js) for this treatment and format. */
|
|
42
|
+
export const styleAssets = (treatment) => {
|
|
43
|
+
const style = readStyle(treatment.style);
|
|
44
|
+
return { style, css: styleCss(style, treatment.format), js: styleScript(style, treatment.format, treatment) };
|
|
45
|
+
};
|
|
36
46
|
const percentile = (values, p) => {
|
|
37
47
|
const sorted = [...values].sort((a, b) => a - b);
|
|
38
48
|
return sorted.length ? +sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))].toFixed(1) : null;
|
|
39
49
|
};
|
|
40
50
|
|
|
51
|
+
/** The beat stills of a stills set, as absolute paths, in beat order. */
|
|
52
|
+
export const beatStillFiles = (out, stills) => stills.index.files.filter((f) => f.kind === "beat").sort((a, b) => a.beat - b.beat).map((f) => path.join(out, f.file));
|
|
53
|
+
|
|
41
54
|
/** Determinism samples: frame 0, the last frame, each beat's first frame, beat midpoints to 8, at most 16. */
|
|
42
55
|
export function determinismFrames({ beats, fps, frameCount }) {
|
|
43
56
|
const clamp = (f) => Math.max(0, Math.min(frameCount - 1, f));
|
|
@@ -83,10 +96,30 @@ function violationExit(state, router) {
|
|
|
83
96
|
return null;
|
|
84
97
|
}
|
|
85
98
|
|
|
86
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Open a stage browser on the round's rung and check the page's LitStage contract. A 3D film asks for
|
|
101
|
+
* the GPU rung; when that rung cannot launch or gives the page no WebGL, the round falls back to the
|
|
102
|
+
* software rung for every browser (master and replays must share one rung) and records a notice.
|
|
103
|
+
*/
|
|
87
104
|
async function openChecked({ label, ctx }) {
|
|
105
|
+
if (ctx.rung === "gpu") {
|
|
106
|
+
try {
|
|
107
|
+
const browser = await openOnRung({ label, ctx });
|
|
108
|
+
if (!browser.state.webglMissing) return browser;
|
|
109
|
+
await browser.close();
|
|
110
|
+
ctx.notices.push("the 3D route asked for the GPU rung and the page got no WebGL there; rendered on the software rung (SwiftShader), slower, same frames");
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof BlockedError) throw error;
|
|
113
|
+
ctx.notices.push(`the 3D route asked for the GPU rung and it did not start (${String(error.message).slice(0, 120)}); rendered on the software rung (SwiftShader), slower, same frames`);
|
|
114
|
+
}
|
|
115
|
+
ctx.rung = "software";
|
|
116
|
+
}
|
|
117
|
+
return openOnRung({ label, ctx });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function openOnRung({ label, ctx }) {
|
|
88
121
|
const { stageDir, faces, scan, width, height, treatment, runDir, env, log } = ctx;
|
|
89
|
-
const browser = await StageBrowser.open({ stageDir, faces, rasters: scan.rasters, width, height, seed: treatment.seed, profileDir: path.join(runDir, `c${process.pid % 100000}${label}`), env, log });
|
|
122
|
+
const browser = await StageBrowser.open({ stageDir, faces, style: ctx.style, rasters: scan.rasters, width, height, seed: treatment.seed, profileDir: path.join(runDir, `c${process.pid % 100000}${label}`), rung: ctx.rung, env, log });
|
|
90
123
|
const state = browser.state;
|
|
91
124
|
const fail = (message) => new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${message}`);
|
|
92
125
|
const early = violationExit(state, browser.router);
|
|
@@ -97,9 +130,9 @@ async function openChecked({ label, ctx }) {
|
|
|
97
130
|
else if (!error && spec.render !== "function") error = fail("LitStage.define needs render(t)");
|
|
98
131
|
else if (!error && spec.fps !== (treatment.fps ?? 60)) error = fail(`the page runs at ${spec.fps} fps; the treatment asks for ${treatment.fps ?? 60} (30 only when the treatment says fps: 30)`);
|
|
99
132
|
else if (!error && !(spec.duration > 0)) error = fail("the page's duration must be a positive number of seconds");
|
|
100
|
-
if (!error && state.webglMissing) error = new BlockedError(EXIT.BLOCKED_NO_WEBGL2,
|
|
133
|
+
if (!error && state.webglMissing) error = new BlockedError(EXIT.BLOCKED_NO_WEBGL2, `BLOCKED_NO_WEBGL2: the page asked for a WebGL context and the ${ctx.rung} rung gave none`);
|
|
101
134
|
if (!error && browser.prepared?.failedFaces?.length) log(`warning: faces that did not load: ${browser.prepared.failedFaces.join(", ")}`);
|
|
102
|
-
if (error) {
|
|
135
|
+
if (error && !(ctx.rung === "gpu" && error.code === EXIT.BLOCKED_NO_WEBGL2)) {
|
|
103
136
|
await browser.close();
|
|
104
137
|
throw error;
|
|
105
138
|
}
|
|
@@ -141,6 +174,18 @@ async function captureFrames({ browser, pool, fps, frames, width, height, asMast
|
|
|
141
174
|
return out;
|
|
142
175
|
}
|
|
143
176
|
|
|
177
|
+
/**
|
|
178
|
+
* The browser rung: a three.js world asks for the GPU; a Blender film shows its path-traced plate
|
|
179
|
+
* under HTML type, so its page needs only the software rung, and it needs the plate, all of it.
|
|
180
|
+
*/
|
|
181
|
+
export function stageRung(treatment, scan, out) {
|
|
182
|
+
if (treatment.render3d !== "blender") return treatment.depth === "3d" ? "gpu" : "software";
|
|
183
|
+
const want = Math.round(treatment.durationSec * BLENDER.plateFps);
|
|
184
|
+
if (!scan.plate) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: render3d is blender but stage/plate/plate.json is missing or does not match its frames; render the plate first: blender --out ${out} --final (no Blender: set render3d to three and use the GPU rung)`);
|
|
185
|
+
if (scan.plate.frames.length !== want) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: the plate has ${scan.plate.frames.length} frames; a ${treatment.durationSec} s film needs ${want} at ${BLENDER.plateFps} fps (render it again: blender --out ${out} --final)`);
|
|
186
|
+
return "software";
|
|
187
|
+
}
|
|
188
|
+
|
|
144
189
|
function renderId(treatment, scan) {
|
|
145
190
|
const h = createHash("sha256").update(JSON.stringify(treatment));
|
|
146
191
|
for (const f of scan.files) h.update(f.rel).update(readFileSync(f.real));
|
|
@@ -213,7 +258,7 @@ export async function captureStageFrames({ out, frames, env = process.env, log =
|
|
|
213
258
|
const faces = stageFonts(env);
|
|
214
259
|
const runDir = path.join(out, ".run");
|
|
215
260
|
mkdirSync(runDir, { recursive: true });
|
|
216
|
-
const ctx = { stageDir, faces, scan, width, height, treatment, runDir, env, log };
|
|
261
|
+
const ctx = { stageDir, faces, scan, width, height, treatment, runDir, env, log, style: styleAssets(treatment), rung: stageRung(treatment, scan, out), notices: [] };
|
|
217
262
|
const browser = await openChecked({ label: "x", ctx });
|
|
218
263
|
const pool = new FramePool(2);
|
|
219
264
|
try {
|
|
@@ -285,7 +330,7 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
|
|
|
285
330
|
const runDir = path.join(out, ".run");
|
|
286
331
|
mkdirSync(runDir, { recursive: true });
|
|
287
332
|
const ffmpeg = findFfmpeg(env);
|
|
288
|
-
const ctx = { stageDir, faces, scan, width, height, treatment, runDir, env, log };
|
|
333
|
+
const ctx = { stageDir, faces, scan, width, height, treatment, runDir, env, log, style: styleAssets(treatment), rung: stageRung(treatment, scan, out), notices: [] };
|
|
289
334
|
progress(out, { phase: "open", round, stillsOnly });
|
|
290
335
|
const master = await openChecked({ label: "m", ctx });
|
|
291
336
|
const spec = master.state.spec;
|
|
@@ -300,11 +345,30 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
|
|
|
300
345
|
if (stillsOnly) {
|
|
301
346
|
const frames = await captureFrames({ browser: master, pool, fps, frames: plan.all, width, height });
|
|
302
347
|
const stills = writeStills({ out, plan, frames: new Map([...frames].map(([f, a]) => [f, a.rgba])), width, height, fps, frameCount, round, stillsOnly: true, path: "stage" });
|
|
348
|
+
// The board round: the text and style rules run on the board frames before any film is encoded,
|
|
349
|
+
// and the storyboard is drawn with the verdict on it.
|
|
350
|
+
progress(out, { phase: "board-check", round, stillsOnly });
|
|
351
|
+
const replayQa = qa ?? textQaReplay({ pool, stageFiles: scan.files.map((f) => path.basename(f.rel)) });
|
|
352
|
+
const check = await replayQa({ ctx, fps, frameCount, plan, openBrowser: (label) => openChecked({ label, ctx }), stepChecked });
|
|
353
|
+
const assetRule = assetUsed(treatment, scan.files);
|
|
354
|
+
if (assetRule) check.rules.push(assetRule);
|
|
355
|
+
writeJson(path.join(out, "stills", "check.json"), { rules: check.rules });
|
|
356
|
+
const boardFile = await writeBoard({ out, treatment, beatFiles: beatStillFiles(out, stills), check, env, log });
|
|
357
|
+
stills.sha256 = addToStills(out, { file: "stills/board.png", kind: "board", frames: plan.beats }, { sha256 });
|
|
303
358
|
progress(out, { phase: "done", round, stillsOnly });
|
|
359
|
+
const failed = check.rules.filter((x) => x.status === "FAIL");
|
|
360
|
+
if (check.exit) return { code: check.exit, message: `${check.message} (board check; the storyboard is ${boardFile})`, stills, renderId: id, check };
|
|
361
|
+
if (failed.length) {
|
|
362
|
+
return {
|
|
363
|
+
code: EXIT.GATE_FAIL_QA,
|
|
364
|
+
message: `BOARD_CHECK_FAIL: ${failed.map((x) => `${x.id} ${x.detail}`).join("; ")}. Fix the page, render --stills-only again, then look at the board ${boardFile} and every file in ${path.join(out, "stills")}`,
|
|
365
|
+
stills, renderId: id, check,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
304
368
|
return {
|
|
305
369
|
code: EXIT.OK,
|
|
306
|
-
message: `STILLS_ONLY:
|
|
307
|
-
stills, renderId: id,
|
|
370
|
+
message: `STILLS_ONLY: board check PASS; open the storyboard ${boardFile} and every file in ${path.join(out, "stills")} (index.json lists them), record the round with look --round ${round}, make the change, then render the film with --round ${round + 1} (no --stills-only)`,
|
|
371
|
+
stills, renderId: id, check,
|
|
308
372
|
};
|
|
309
373
|
}
|
|
310
374
|
if (!ffmpeg) {
|
|
@@ -350,7 +414,7 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
|
|
|
350
414
|
const a = await entry.analysis;
|
|
351
415
|
await encoder.write(a.rgba);
|
|
352
416
|
const flash = detector.push(a.cells);
|
|
353
|
-
lines.push({ frame: entry.f, artifact: "master", rgbaSha256: a.rgbaSha256, luminanceP995: a.luminanceP995, flash });
|
|
417
|
+
lines.push({ frame: entry.f, artifact: "master", rgbaSha256: a.rgbaSha256, luminanceP995: a.luminanceP995, luminanceP005: a.luminanceP005, busy: a.busy, flash });
|
|
354
418
|
if (plan.all.has(entry.f)) kept.set(entry.f, a.rgba);
|
|
355
419
|
if (detFrames.includes(entry.f)) detMaster.set(entry.f, a);
|
|
356
420
|
if (entry.f % previewEvery === 0) {
|
|
@@ -401,23 +465,27 @@ export async function renderStage({ out, round = 1, stillsOnly = false, env = pr
|
|
|
401
465
|
};
|
|
402
466
|
const gate = evaluateStageGate({
|
|
403
467
|
masterFlash: lines.map((l) => l.flash), previewFlash: preview.records ? { records: preview.records, fps: preview.rung.fps } : null, fps,
|
|
404
|
-
probe, width, height, treatment, exports, reducedFrame: plan.reduced, frames: lines, usesWebGL: finalState.usesWebGL, renderer:
|
|
405
|
-
determinism, extraRules: [...soundAudit.rules, ...(qaResult?.rules ?? [])],
|
|
468
|
+
probe, width, height, treatment, exports, reducedFrame: plan.reduced, frames: lines, usesWebGL: finalState.usesWebGL, renderer: finalState.webglRenderer, rung: ctx.rung,
|
|
469
|
+
determinism, extraRules: [...soundAudit.rules, ...(qaResult?.rules ?? []), assetUsed(treatment, scan.files)].filter(Boolean),
|
|
406
470
|
});
|
|
407
471
|
const promoted = promote(out, gate.flashFail);
|
|
408
472
|
const loc = (name) => path.join(promoted.dir, name);
|
|
409
473
|
const stills = writeStills({ out, plan, frames: kept, width, height, fps, frameCount, round, stillsOnly: false, path: "stage", posterFile: existsSync(loc("poster.png")) ? loc("poster.png") : null });
|
|
474
|
+
await writeBoard({ out, treatment, beatFiles: beatStillFiles(out, stills), check: qaResult, env, log });
|
|
475
|
+
stills.sha256 = addToStills(out, { file: "stills/board.png", kind: "board", frames: plan.beats }, { sha256 });
|
|
476
|
+
if (gate.pass && !promoted.withheld) recordHouse(out, { style: treatment.style, path: "stage", format: treatment.format, durationSec: treatment.durationSec });
|
|
410
477
|
const totalSec = (Date.now() - t0) / 1000;
|
|
411
478
|
const manifest = {
|
|
412
479
|
schemaVersion: 1, path: "stage", renderId: id, round, treatmentSha256: treatmentSha(out), format: treatment.format, width, height, fps, durationSec: spec.duration, treatmentDurationSec: treatment.durationSec,
|
|
413
|
-
frameCount, seed: treatment.seed, renderer: "
|
|
480
|
+
frameCount, seed: treatment.seed, renderer: finalState.webglRenderer ?? "no WebGL", rung: ctx.rung, chromeFlags: master.flags, usesWebGL: finalState.usesWebGL,
|
|
414
481
|
cuts, stills: { sha256: stills.sha256, poster: plan.poster, reduced: plan.reduced }, posterEncoding: poster,
|
|
415
482
|
geometry: geometryFor(width, height),
|
|
483
|
+
plate: scan.plate ? { blender: scan.plate.blender, engine: scan.plate.engine, device: scan.plate.device, samples: scan.plate.samples, fps: scan.plate.fps, frames: scan.plate.frames.length } : null,
|
|
416
484
|
sound: { mode: sound.mode, label: sound.label, file: sound.file ? path.relative(out, sound.file) : null, sha256: sound.file ? sha256(readFileSync(sound.file)) : null, lufs: sound.bed?.lufs ?? null },
|
|
417
485
|
preview: { encoder: preview.encoder, rung: preview.rung, attempts: preview.attempts },
|
|
418
486
|
pageErrors: finalState.errors, missingAssets: master.router.missing,
|
|
419
487
|
timing: { frameP50Ms: percentile(frameMs, 0.5), frameP95Ms: percentile(frameMs, 0.95), masterSec: +masterSec.toFixed(1), totalSec: +totalSec.toFixed(1) },
|
|
420
|
-
warnings: [...scan.warnings, ...master.router.missing.map((m) => `the page asked for a missing file ${m.url} (${m.reason})`)],
|
|
488
|
+
warnings: [...ctx.notices, ...scan.warnings, ...master.router.missing.map((m) => `the page asked for a missing file ${m.url} (${m.reason})`)],
|
|
421
489
|
generatedAt: new Date().toISOString(),
|
|
422
490
|
};
|
|
423
491
|
writeJson(path.join(out, "manifest.json"), manifest);
|
|
@@ -492,7 +560,7 @@ export async function renderStageDetached({ out, round, cli, mode = "stage", env
|
|
|
492
560
|
}
|
|
493
561
|
try {
|
|
494
562
|
const p = JSON.parse(readFileSync(path.join(runDir, "progress.json"), "utf8"));
|
|
495
|
-
const phase = `${p.phase}${p.frame !== undefined && p.phase === "master" ? ` ${Math.floor((p.frame / p.frameCount) * 10) * 10}%` : ""}`;
|
|
563
|
+
const phase = `${p.phase}${p.frame !== undefined && (p.phase === "master" || p.phase === "plate") ? ` ${Math.floor((p.frame / p.frameCount) * 10) * 10}%` : ""}`;
|
|
496
564
|
if (phase !== lastPhase) log(`render: ${phase}`);
|
|
497
565
|
lastPhase = phase;
|
|
498
566
|
} catch {
|