@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
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// The storyboard: `stills/board.png`, one page a person can read before the full render. One keyframe
|
|
2
|
+
// per shot (the beat still), with the shot's number, time, layout, hand-off and hero move under it and
|
|
3
|
+
// the shot's type zone outlined on the frame; a header with the house style (name, palette, type) and the
|
|
4
|
+
// film's format, length and sound; a footer with the layout check. It is drawn as a page in the same
|
|
5
|
+
// headless Chrome the stage uses, so its type is the product's own faces.
|
|
6
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { LAYOUTS, readStyle } from "./styles.mjs";
|
|
9
|
+
import { StageBrowser } from "./stage-capture.mjs";
|
|
10
|
+
import { stageFonts } from "./stage-serve.mjs";
|
|
11
|
+
|
|
12
|
+
export const BOARD = Object.freeze({ width: 1920, height: 1080, margin: 48, gap: 20, header: 150, footer: 56, caption: 104 });
|
|
13
|
+
|
|
14
|
+
const esc = (text) => String(text ?? "").replace(/[&<>"]/gu, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
15
|
+
const secs = (v) => `${Number(v).toFixed(1)}`;
|
|
16
|
+
|
|
17
|
+
/** Tile geometry: columns, thumbnail size, for n shots of a film of size width x height. */
|
|
18
|
+
export function boardGrid(n, width, height) {
|
|
19
|
+
const usableW = BOARD.width - 2 * BOARD.margin;
|
|
20
|
+
const usableH = BOARD.height - BOARD.header - BOARD.footer - BOARD.margin;
|
|
21
|
+
const aspect = width / height;
|
|
22
|
+
const options = [];
|
|
23
|
+
for (let cols = 1; cols <= Math.max(1, n); cols++) {
|
|
24
|
+
const rows = Math.ceil(n / cols);
|
|
25
|
+
const tw = Math.floor((usableW - (cols - 1) * BOARD.gap) / cols);
|
|
26
|
+
const byHeight = Math.floor((usableH - (rows - 1) * BOARD.gap) / rows) - BOARD.caption;
|
|
27
|
+
const th = Math.min(Math.round(tw / aspect), byHeight);
|
|
28
|
+
if (th <= 0) continue;
|
|
29
|
+
options.push({ cols, rows, tw: Math.round(th * aspect), th, empty: rows * cols - n });
|
|
30
|
+
}
|
|
31
|
+
// The largest tiles, unless a grid with fewer empty slots keeps 85 % of their area.
|
|
32
|
+
const largest = Math.max(...options.map((o) => o.tw * o.th));
|
|
33
|
+
return options.filter((o) => o.tw * o.th >= 0.85 * largest).sort((a, b) => a.empty - b.empty || b.tw * b.th - a.tw * a.th)[0];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The board page's HTML for a treatment and its beat stills (file names relative to the page). */
|
|
37
|
+
export function boardHtml({ treatment, stills, check = null }) {
|
|
38
|
+
const style = treatment.style ? readStyle(treatment.style) : null;
|
|
39
|
+
const [width, height] = treatment.format === "9:16" ? [1080, 1920] : [1920, 1080];
|
|
40
|
+
const grid = boardGrid(stills.length, width, height);
|
|
41
|
+
const zones = LAYOUTS[treatment.format === "9:16" ? "9:16" : "16:9"];
|
|
42
|
+
const pal = style?.palette ?? {};
|
|
43
|
+
const chips = Object.entries(pal).filter(([k]) => ["ground", "ink", "muted", "signal", "accent"].includes(k))
|
|
44
|
+
.map(([k, v]) => `<span class="chip"><i style="background:${esc(v)}"></i>${esc(k)} ${esc(v)}</span>`).join("");
|
|
45
|
+
const tiles = stills.map((file, i) => {
|
|
46
|
+
const b = treatment.beats[i] ?? {};
|
|
47
|
+
const z = b.layout && zones[b.layout]?.type;
|
|
48
|
+
const guide = z ? `<b class="zone" style="left:${(z[0] * 100).toFixed(2)}%;top:${(z[1] * 100).toFixed(2)}%;width:${(z[2] * 100).toFixed(2)}%;height:${(z[3] * 100).toFixed(2)}%"></b>` : "";
|
|
49
|
+
const meta = [String(i + 1).padStart(2, "0"), `${secs(b.t0)}–${secs(b.t1)} s`, b.layout, b.transition && b.transition !== "end" ? `→ ${b.transition}` : b.transition].filter(Boolean).map(esc).join(" · ");
|
|
50
|
+
return `<figure style="width:${grid.tw}px"><div class="frame" style="width:${grid.tw}px;height:${grid.th}px"><img src="${esc(file)}">${guide}</div>`
|
|
51
|
+
+ `<figcaption><span class="meta">${meta}</span><span class="hero">${esc(b.hero ?? b.onScreen ?? "")}</span></figcaption></figure>`;
|
|
52
|
+
}).join("");
|
|
53
|
+
const failed = (check?.rules ?? []).filter((x) => x.status === "FAIL");
|
|
54
|
+
const verdict = !check ? "layout check: not run on this render"
|
|
55
|
+
: failed.length ? `layout check: FAIL — ${failed.map((x) => x.id).join(", ")}` : "layout check: PASS";
|
|
56
|
+
const sound = treatment.sound?.mode === "generated" && treatment.sound.palette
|
|
57
|
+
? `${treatment.sound.palette.timbre}, ${treatment.sound.palette.key} ${treatment.sound.palette.mode}, ${treatment.sound.palette.tempo} BPM`
|
|
58
|
+
: treatment.sound?.mode === "score" ? `score (${treatment.sound.genre ?? readStyle(treatment.style).score.genre})` : treatment.sound?.mode ?? "none";
|
|
59
|
+
const ground = pal.ground ?? "#101216";
|
|
60
|
+
return `<!doctype html>
|
|
61
|
+
<meta charset="utf-8">
|
|
62
|
+
<link rel="stylesheet" href="/lit/fonts.css">
|
|
63
|
+
<script src="/lit/stage-kit.js"></script>
|
|
64
|
+
<style>
|
|
65
|
+
html, body { margin: 0; width: ${BOARD.width}px; height: ${BOARD.height}px; overflow: hidden; background: #15171b; color: #e8e9e6; font-family: "Pretendard"; }
|
|
66
|
+
header { position: absolute; left: ${BOARD.margin}px; right: ${BOARD.margin}px; top: 36px; height: ${BOARD.header - 48}px; display: flex; justify-content: space-between; align-items: flex-start; }
|
|
67
|
+
h1 { margin: 0; font: 700 40px/1.1 "Pretendard"; }
|
|
68
|
+
.sub { margin-top: 10px; font: 400 20px/1.3 "MesloLGS NF"; color: #a8aba6; }
|
|
69
|
+
.style { text-align: right; }
|
|
70
|
+
.specimen { display: inline-block; padding: 6px 14px; margin-bottom: 10px; background: ${esc(ground)}; color: ${esc(pal.ink ?? "#fff")}; font: ${style?.faces.display.weight ?? 700} 34px/1.1 "${esc(style?.faces.display.family ?? "Pretendard")}", "Pretendard"; }
|
|
71
|
+
.chips { display: flex; gap: 14px; justify-content: flex-end; font: 400 16px/1 "MesloLGS NF"; color: #a8aba6; }
|
|
72
|
+
.chip i { display: inline-block; width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; border: 1px solid #555; }
|
|
73
|
+
main { position: absolute; left: ${BOARD.margin}px; right: ${BOARD.margin}px; top: ${BOARD.header}px; display: flex; flex-wrap: wrap; gap: ${BOARD.gap}px; }
|
|
74
|
+
figure { margin: 0; }
|
|
75
|
+
.frame { position: relative; overflow: hidden; background: #000; }
|
|
76
|
+
.frame img { display: block; width: 100%; height: 100%; }
|
|
77
|
+
.zone { position: absolute; box-sizing: border-box; border: 2px dashed rgba(255, 196, 0, 0.75); }
|
|
78
|
+
figcaption { display: block; height: ${BOARD.caption - 8}px; padding-top: 8px; overflow: hidden; }
|
|
79
|
+
.meta { display: block; font: 400 16px/1.3 "MesloLGS NF"; color: #c9cbc6; }
|
|
80
|
+
.hero { display: block; margin-top: 4px; font: 400 18px/1.35 "Pretendard"; color: #e8e9e6; }
|
|
81
|
+
footer { position: absolute; left: ${BOARD.margin}px; right: ${BOARD.margin}px; bottom: 18px; font: 400 18px/1.2 "MesloLGS NF"; color: ${failed.length ? "#ff8a7a" : "#9fd3a4"}; }
|
|
82
|
+
</style>
|
|
83
|
+
<body>
|
|
84
|
+
<header>
|
|
85
|
+
<div><h1>Storyboard · ${esc(treatment.subject?.name ?? "")}</h1>
|
|
86
|
+
<div class="sub">${esc(treatment.format)} · ${esc(treatment.durationSec)} s · ${treatment.beats.length} shots · ${esc(treatment.path)} path · sound: ${esc(sound)}</div></div>
|
|
87
|
+
<div class="style"><div class="specimen">${esc(style?.name ?? treatment.style ?? "")} Aa 가</div><div class="chips">${chips}</div></div>
|
|
88
|
+
</header>
|
|
89
|
+
<main>${tiles}</main>
|
|
90
|
+
<footer>${esc(verdict)} · dashed box: the shot's type zone</footer>
|
|
91
|
+
<script>LitStage.define({ width: ${BOARD.width}, height: ${BOARD.height}, fps: 30, duration: 1, render() {} });</script>
|
|
92
|
+
</body>
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Render `<out>/stills/board.png` from the beat stills already written. Returns the file path.
|
|
98
|
+
* `check` is the layout check ({ rules }) when one ran.
|
|
99
|
+
*/
|
|
100
|
+
export async function writeBoard({ out, treatment, beatFiles, check = null, env = process.env, log = () => {} }) {
|
|
101
|
+
const dir = path.join(out, ".run", "board");
|
|
102
|
+
rmSync(dir, { recursive: true, force: true });
|
|
103
|
+
mkdirSync(dir, { recursive: true });
|
|
104
|
+
const names = beatFiles.map((f, i) => {
|
|
105
|
+
const name = `s${String(i + 1).padStart(2, "0")}.png`;
|
|
106
|
+
copyFileSync(f, path.join(dir, name));
|
|
107
|
+
return name;
|
|
108
|
+
});
|
|
109
|
+
writeFileSync(path.join(dir, "index.html"), boardHtml({ treatment, stills: names, check }));
|
|
110
|
+
const browser = await StageBrowser.open({
|
|
111
|
+
stageDir: dir, faces: stageFonts(env), rasters: names.map((rel) => ({ rel })), width: BOARD.width, height: BOARD.height, seed: 1,
|
|
112
|
+
profileDir: path.join(out, ".run", `cb${process.pid % 100000}`), env, log,
|
|
113
|
+
});
|
|
114
|
+
try {
|
|
115
|
+
await browser.step(0, 30, { paint: true });
|
|
116
|
+
const png = await browser.capture();
|
|
117
|
+
const file = path.join(out, "stills", "board.png");
|
|
118
|
+
writeFileSync(file, png);
|
|
119
|
+
return file;
|
|
120
|
+
} finally {
|
|
121
|
+
await browser.close();
|
|
122
|
+
rmSync(dir, { recursive: true, force: true });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Add a file the renderer wrote after the stills set to `stills/index.json`; returns the new index SHA-256. */
|
|
127
|
+
export function addToStills(out, entry, { sha256 }) {
|
|
128
|
+
const indexFile = path.join(out, "stills", "index.json");
|
|
129
|
+
const index = JSON.parse(readFileSync(indexFile, "utf8"));
|
|
130
|
+
const file = path.join(out, entry.file);
|
|
131
|
+
if (!existsSync(file)) throw new Error(`addToStills: ${entry.file} was not written`);
|
|
132
|
+
index.files = [...index.files.filter((f) => f.file !== entry.file), { ...entry, sha256: sha256(readFileSync(file)) }];
|
|
133
|
+
const bytes = Buffer.from(`${JSON.stringify(index, null, 2)}\n`);
|
|
134
|
+
writeFileSync(indexFile, bytes);
|
|
135
|
+
return sha256(bytes);
|
|
136
|
+
}
|
|
@@ -88,7 +88,13 @@ export function planFromBrief(brief, { fps = TIMELINE.defaultFps, beatGrid = nul
|
|
|
88
88
|
const rawShots = Array.isArray(brief.shots) && brief.shots.length ? brief.shots : composeFromLines(brief.lines ?? [], brief.title);
|
|
89
89
|
const shots = rawShots.map(normalizeShot);
|
|
90
90
|
const text = briefText(shots, [str(brief.title), str(brief.request)]);
|
|
91
|
-
|
|
91
|
+
// The treatment's house style decides the preset on the type path, so a style means one thing on
|
|
92
|
+
// both paths; a brief style that disagrees with it is refused rather than silently winning.
|
|
93
|
+
const style = brief.style && brief.style !== "auto" ? brief.style : treatment?.style ?? brief.style;
|
|
94
|
+
if (treatment?.style && brief.style && brief.style !== "auto" && brief.style !== treatment.style) {
|
|
95
|
+
throw new TreatmentError("style", `the brief asks for ${brief.style} but the treatment's style is ${treatment.style}; drop style from the brief (the treatment's style decides the preset)`);
|
|
96
|
+
}
|
|
97
|
+
const { presetId, reason } = pickPreset({ style, text, request: treatment?.request ?? brief.request ?? "" });
|
|
92
98
|
const preset = PRESETS[presetId];
|
|
93
99
|
// The terminal look is a typed-input voice: it keeps typewriter punctuation (MO-A-34 plain()).
|
|
94
100
|
if (presetId === "terminalcore") {
|
|
@@ -8,7 +8,7 @@ import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
|
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { CHROME_ALWAYS, CHROME_RUNGS, EXIT, UNKNOWN_RENDERER } from "../core/constants.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { which } from "./host.mjs";
|
|
12
12
|
|
|
13
13
|
export class BlockedError extends Error {
|
|
14
14
|
constructor(code, message) {
|
|
@@ -28,12 +28,9 @@ const CANDIDATES = {
|
|
|
28
28
|
win32: [
|
|
29
29
|
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
|
|
30
30
|
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
|
|
31
|
-
...(process.env.LOCALAPPDATA ? [path.join(process.env.LOCALAPPDATA, "Google", "Chrome", "Application", "chrome.exe")] : []),
|
|
32
31
|
],
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
const onPath = (name) => resolveOnPath(name);
|
|
36
|
-
|
|
37
34
|
/** Resolve Chrome: $CHROME_PATH, then the platform's usual locations. Returns null when absent. */
|
|
38
35
|
export function findChrome(env = process.env) {
|
|
39
36
|
if (env.CHROME_PATH) return existsSync(env.CHROME_PATH) ? env.CHROME_PATH : null;
|
|
@@ -41,7 +38,7 @@ export function findChrome(env = process.env) {
|
|
|
41
38
|
if (path.isAbsolute(candidate)) {
|
|
42
39
|
if (existsSync(candidate)) return candidate;
|
|
43
40
|
} else {
|
|
44
|
-
const found =
|
|
41
|
+
const found = which(candidate);
|
|
45
42
|
if (found) return found;
|
|
46
43
|
}
|
|
47
44
|
}
|
|
@@ -49,21 +46,21 @@ export function findChrome(env = process.env) {
|
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
export function chromeVersion(chrome) {
|
|
52
|
-
// chrome.exe is a GUI program on Windows: `--version` prints nothing there and may open a window.
|
|
53
|
-
if (process.platform === "win32") return "installed (version not probed on Windows)";
|
|
54
49
|
const probe = spawnSync(chrome, ["--version"], { encoding: "utf8", timeout: 15000 });
|
|
55
|
-
return probe.status === 0 ? probe.stdout.trim() : `unknown (${(probe.stderr || probe.error?.message || "").trim().split(
|
|
50
|
+
return probe.status === 0 ? probe.stdout.trim() : `unknown (${(probe.stderr || probe.error?.message || "").trim().split(/\r?\n/u)[0]})`;
|
|
56
51
|
}
|
|
57
52
|
|
|
58
53
|
/**
|
|
59
|
-
* The stage path's flag set (director brief 6d): the software rung
|
|
60
|
-
* the compositor and animation flags that keep a captured frame a function of the page's state,
|
|
54
|
+
* The stage path's flag set (director brief 6d): the software rung (SwiftShader) by default, or the
|
|
55
|
+
* platform's GPU rung for a 3D film (WebGL on the GPU; page raster stays on the CPU either way), the compositor and animation flags that keep a captured frame a function of the page's state,
|
|
61
56
|
* sRGB at scale 1, the window at the format's size, no background networking, and a resolver rule
|
|
62
57
|
* that leaves only the synthetic stage origin resolvable.
|
|
63
58
|
*/
|
|
64
|
-
export function stageFlags({ width, height }) {
|
|
59
|
+
export function stageFlags({ width, height, rung = "software" }) {
|
|
60
|
+
const base = rung === "gpu" ? CHROME_RUNGS[process.platform]?.[0]?.filter((f) => f !== "--enable-gpu-rasterization") : CHROME_RUNGS.software;
|
|
61
|
+
if (!base) throw new Error(`no GPU rung on ${process.platform}`);
|
|
65
62
|
return [
|
|
66
|
-
...
|
|
63
|
+
...base, "--disable-gpu-rasterization", "--disable-partial-raster",
|
|
67
64
|
"--run-all-compositor-stages-before-draw", "--disable-checker-imaging", "--disable-new-content-rendering-timeout",
|
|
68
65
|
"--disable-threaded-animation", "--disable-threaded-scrolling", "--disable-image-animation-resync", "--disable-lcd-text",
|
|
69
66
|
"--force-color-profile=srgb", "--hide-scrollbars", "--mute-audio", "--force-device-scale-factor=1", `--window-size=${width},${height}`,
|
|
@@ -27,7 +27,9 @@ const isBox = (b) => Array.isArray(b) && b.length === 4 && b.every((v) => typeof
|
|
|
27
27
|
export function checkAssets({ out, treatment, rasters, coverDir = "cover" }) {
|
|
28
28
|
const file = path.join(out, ASSETS_FILE);
|
|
29
29
|
const needsArt = treatment.recipe === "painted-light";
|
|
30
|
-
|
|
30
|
+
// The painted recipe relights a painting the user supplied. Without one the cover takes hero-3d
|
|
31
|
+
// (or weight-tide, orbit-loop) instead of a stand-in painting drawn for the occasion.
|
|
32
|
+
const blockedArt = new BlockedError(EXIT.BLOCKED_ASSET_MISSING, "BLOCKED_ASSET_MISSING: the painted-light recipe needs its base art listed in assets.json ({ path, role: base-art, source: user, sha256, box }): a painting the user supplied; without one, take hero-3d (or weight-tide, orbit-loop), never draw or generate a stand-in");
|
|
31
33
|
let assets = [];
|
|
32
34
|
if (existsSync(file)) {
|
|
33
35
|
let doc;
|
|
@@ -42,7 +44,7 @@ export function checkAssets({ out, treatment, rasters, coverDir = "cover" }) {
|
|
|
42
44
|
if (!a || typeof a !== "object") throw invalid(f, "must be an object");
|
|
43
45
|
if (typeof a.path !== "string" || !a.path.startsWith(`${coverDir}/`) || a.path.split("/").includes("..")) throw invalid(`${f}.path`, `must be a path inside ${coverDir}/, relative to the output directory`);
|
|
44
46
|
if (!ASSET_ROLES.includes(a.role)) throw invalid(`${f}.role`, `must be one of ${ASSET_ROLES.join(", ")}`);
|
|
45
|
-
if (!["user", "generated"].includes(a.source)) throw invalid(`${f}.source`, "must be user (supplied) or generated");
|
|
47
|
+
if (!["user", "fetched", "generated"].includes(a.source)) throw invalid(`${f}.source`, "must be user (supplied), fetched (by motion.mjs assets --cover) or generated");
|
|
46
48
|
if (!/^[0-9a-f]{64}$/u.test(a.sha256 ?? "")) throw invalid(`${f}.sha256`, "must be the file's SHA-256 (64 hex)");
|
|
47
49
|
if ("box" in a && !isBox(a.box)) throw invalid(`${f}.box`, "must be [x, y, w, h], fractions of the cover, inside it");
|
|
48
50
|
if ("checkBox" in a) {
|
|
@@ -62,7 +64,7 @@ export function checkAssets({ out, treatment, rasters, coverDir = "cover" }) {
|
|
|
62
64
|
if (sha256(readFileSync(real)) !== a.sha256) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${a.path} does not match its sha256 in assets.json; list it again after changing it`);
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
if (needsArt && !assets.some((a) => a.role === "base-art")) throw blockedArt;
|
|
67
|
+
if (needsArt && !assets.some((a) => a.role === "base-art" && a.source === "user")) throw blockedArt;
|
|
66
68
|
const listed = new Set(assets.map((a) => a.path));
|
|
67
69
|
for (const r of rasters) {
|
|
68
70
|
const rel = `${coverDir}/${r.rel.split(path.sep).join("/")}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Cover capture: one headless Chrome on the stage path's software rung, laid out at the cover's CSS
|
|
1
|
+
// Cover capture: one headless Chrome on the stage path's software rung (the GPU rung for a 3D hero), laid out at the cover's CSS
|
|
2
2
|
// size and captured at twice that (device scale 2), the page served from disk on the synthetic stage
|
|
3
3
|
// origin, the cover init script injected before any page script. The renderer SEEKS: it calls
|
|
4
4
|
// window.renderFrame(t, { mask }) for any t in [0, 1) in any order, captures, and a worker pool
|
|
@@ -18,13 +18,13 @@ const withTimeout = (promise, ms, message) => Promise.race([
|
|
|
18
18
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
19
19
|
|
|
20
20
|
/** The stage flag set at the cover's device scale. */
|
|
21
|
-
export const coverFlags = ({ width, height, scale }) => stageFlags({ width, height }).map((f) => (f === "--force-device-scale-factor=1" ? `--force-device-scale-factor=${scale}` : f));
|
|
21
|
+
export const coverFlags = ({ width, height, scale, rung = "software" }) => stageFlags({ width, height, rung }).map((f) => (f === "--force-device-scale-factor=1" ? `--force-device-scale-factor=${scale}` : f));
|
|
22
22
|
|
|
23
23
|
export class CoverBrowser {
|
|
24
|
-
static async open({ stageDir, faces, width, height, scale, profileDir, env = process.env, log = () => {}, page = "index.html" }) {
|
|
24
|
+
static async open({ stageDir, faces, width, height, scale, profileDir, rung = "software", env = process.env, log = () => {}, page = "index.html" }) {
|
|
25
25
|
const chrome = findChrome(env);
|
|
26
26
|
if (!chrome) throw new BlockedError(EXIT.BLOCKED_NO_CHROME, "BLOCKED_NO_CHROME: Chrome/Chromium not found (set CHROME_PATH or install Google Chrome)");
|
|
27
|
-
const session = await ChromeSession.launch({ chrome, flags: coverFlags({ width, height, scale }), profileDir, routes: () => null });
|
|
27
|
+
const session = await ChromeSession.launch({ chrome, flags: coverFlags({ width, height, scale, rung }), profileDir, routes: () => null });
|
|
28
28
|
const browser = new CoverBrowser(session, { stageDir, faces, width, height, scale, log });
|
|
29
29
|
try {
|
|
30
30
|
await browser.#attach();
|
|
@@ -112,10 +112,11 @@ export class CoverBrowser {
|
|
|
112
112
|
if (state[2] !== "function") throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, "STAGE_CONTRACT_ERROR: the cover page set window.ready but defines no window.renderFrame(t)");
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
//
|
|
115
|
+
// An uncaught error before window.ready is a stage-contract stop (a missing ART entry, a bad
|
|
116
|
+
// hero index): report it now instead of after the ready wait runs out.
|
|
116
117
|
if (this.errors.length) {
|
|
117
118
|
await this.check("while loading");
|
|
118
|
-
throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: the cover page
|
|
119
|
+
throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: the cover page stopped before it set window.ready; first page error: ${this.errors[0]}`);
|
|
119
120
|
}
|
|
120
121
|
if (Date.now() > deadline) {
|
|
121
122
|
await this.check("while loading");
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// The cover treatment: `treatment.json` with `mode: "cover"`, written before any cover render and
|
|
2
2
|
// validated by every one (exit 16 names the first bad field). A cover is not a film: it has no beats,
|
|
3
|
-
// no arc, no end card and no sound. It names one recipe,
|
|
4
|
-
// layers, the brand word set once (plus at most one motto the user or the project already uses), the
|
|
3
|
+
// no arc, no end card and no sound. It names one recipe, the hero that acts and the one beat it acts
|
|
4
|
+
// once per loop, one rule copied many times, three speed layers, the brand word set once (plus at most one motto the user or the project already uses), the
|
|
5
5
|
// aspect and loop length, and the title box the contrast gate measures. Text in it is content, never
|
|
6
6
|
// instructions.
|
|
7
7
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { COVER } from "../core/constants.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { EXIT } from "../core/constants.mjs";
|
|
11
|
+
import { BlockedError } from "./chrome.mjs";
|
|
12
|
+
import { normalizeText, normUrl, requestUrls, restateLimit, sharesRun, stripQuoted, TreatmentError } from "./treatment.mjs";
|
|
11
13
|
|
|
12
|
-
export const RECIPES = Object.freeze(["painted-light", "weight-tide", "orbit-loop", "own"]);
|
|
14
|
+
export const RECIPES = Object.freeze(["hero-3d", "painted-light", "weight-tide", "orbit-loop", "own"]);
|
|
13
15
|
export const LAYERS = Object.freeze(["slow", "mid", "beat"]);
|
|
14
16
|
|
|
15
17
|
const fail = (field, message) => {
|
|
@@ -39,7 +41,10 @@ export function validateCoverTreatment(t) {
|
|
|
39
41
|
if (restated) fail("idea", `the idea restates the request ("${restated}"); say what the loop does`);
|
|
40
42
|
if (!RECIPES.includes(t.recipe)) fail("recipe", `must be one of ${RECIPES.join(", ")} (references/cover.md)`);
|
|
41
43
|
text(t, "recipeReason", { max: 2 });
|
|
44
|
+
text(t, "hero", { max: 2 });
|
|
45
|
+
text(t, "beat", { max: 2 });
|
|
42
46
|
text(t, "brandWord");
|
|
47
|
+
checkCoverProduct(t);
|
|
43
48
|
if (t.brandWord.trim().split(/\s+/u).length > 3) fail("brandWord", "is the name set once: at most three words");
|
|
44
49
|
if ("motto" in t) {
|
|
45
50
|
const m = t.motto;
|
|
@@ -85,6 +90,21 @@ export function validateCoverTreatment(t) {
|
|
|
85
90
|
return { ...t, page, out, frames, encode, seed: Number.isInteger(t.seed) ? t.seed >>> 0 : 0 };
|
|
86
91
|
}
|
|
87
92
|
|
|
93
|
+
// A link in the request names the product: the cover is built from its real logo, images and words,
|
|
94
|
+
// fetched by `motion.mjs assets --cover` before the treatment, never from the name alone.
|
|
95
|
+
function checkCoverProduct(t) {
|
|
96
|
+
const urls = requestUrls(t.request);
|
|
97
|
+
if (!("product" in t)) {
|
|
98
|
+
if (urls.length) fail("product", `missing: the request links ${urls[0]}; fetch its real assets first with motion.mjs assets --out <dir> --url <link> --cover, look at them, and set product { name, url } (cover.md, Named products)`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const p = t.product;
|
|
102
|
+
if (!p || typeof p !== "object") fail("product", "must be an object { name, url }");
|
|
103
|
+
text(t, "product.name");
|
|
104
|
+
if (urls.length && !urls.includes(normUrl(p.url))) fail("product.url", `must be the link the request gives (${urls.join(", ")})`);
|
|
105
|
+
if ("unreachable" in p) text(t, "product.unreachable");
|
|
106
|
+
}
|
|
107
|
+
|
|
88
108
|
/** Load and validate `<out>/treatment.json` as a cover; keeps the first valid one for the done-check. */
|
|
89
109
|
export function loadCoverTreatment(out) {
|
|
90
110
|
const file = path.join(out, "treatment.json");
|
|
@@ -97,6 +117,19 @@ export function loadCoverTreatment(out) {
|
|
|
97
117
|
}
|
|
98
118
|
if (raw?.mode !== "cover") fail("mode", "this treatment is a film: render it with stage or make (references/treatment.md); a cover sets mode: cover");
|
|
99
119
|
const treatment = validateCoverTreatment(raw);
|
|
120
|
+
const p = treatment.product;
|
|
121
|
+
if (p?.unreachable) throw new BlockedError(EXIT.BLOCKED_ASSET_MISSING, `BLOCKED_ASSET_MISSING: ${p.name}'s real assets could not be reached (${p.unreachable}); ask the user for its logo or README images, put them in ${path.join(out, "cover", "assets")} and list them in assets.json`);
|
|
122
|
+
if (p && !existsSync(path.join(out, "product.json"))) fail("product", `no ${path.join(out, "product.json")}: run motion.mjs assets --out ${out} --url ${p.url} --cover first`);
|
|
123
|
+
if (p) {
|
|
124
|
+
let fetched = [];
|
|
125
|
+
try {
|
|
126
|
+
fetched = JSON.parse(readFileSync(path.join(out, "product.json"), "utf8"))?.product?.assets ?? [];
|
|
127
|
+
} catch (error) {
|
|
128
|
+
fail("product", `${path.join(out, "product.json")} is not valid JSON (${error.message}); run motion.mjs assets --out ${out} --url ${p.url} --cover again`);
|
|
129
|
+
}
|
|
130
|
+
const astray = fetched.filter((a) => !String(a?.path ?? "").startsWith("cover/assets/"));
|
|
131
|
+
if (astray.length) fail("product", `${astray[0].path} sits outside cover/assets/, where the cover page cannot load it; run motion.mjs assets --out ${out} --url ${p.url} --cover again`);
|
|
132
|
+
}
|
|
100
133
|
const first = path.join(out, ".run", "treatment.first.json");
|
|
101
134
|
if (!existsSync(first)) {
|
|
102
135
|
mkdirSync(path.dirname(first), { recursive: true });
|
|
@@ -28,7 +28,6 @@ import { encodePng, rgbaToRgb } from "./png.mjs";
|
|
|
28
28
|
import { rasterInfo, scanStage, stageFonts } from "./stage-serve.mjs";
|
|
29
29
|
import { STILLS_DIR, INDEX_FILE } from "./stills.mjs";
|
|
30
30
|
import { findDwebp } from "./webp.mjs";
|
|
31
|
-
import { describeSpawn } from "../../../../lib/host-exec.mjs";
|
|
32
31
|
|
|
33
32
|
export const COVER_STAGE = "cover";
|
|
34
33
|
export const COVER_OUTPUTS = Object.freeze(["cover.webp", "cover.gif", "poster.png"]);
|
|
@@ -62,14 +61,14 @@ export function encodeCover({ files, fps, encode, out, env = process.env }) {
|
|
|
62
61
|
if (img2webp && dwebp) {
|
|
63
62
|
const file = path.join(out, "cover.webp");
|
|
64
63
|
const r = spawnSync(img2webp, img2webpArgs({ files, fps, encode, out: file }), { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
|
|
65
|
-
if (r.status !== 0) throw new Error(`img2webp failed
|
|
64
|
+
if (r.status !== 0) throw new Error(`img2webp failed: ${(r.stderr || r.error?.message || "").trim().split("\n").slice(-1)[0]}`);
|
|
66
65
|
return { file, encoder: "img2webp" };
|
|
67
66
|
}
|
|
68
67
|
const gifski = which("gifski", env);
|
|
69
68
|
if (gifski) {
|
|
70
69
|
const file = path.join(out, "cover.gif");
|
|
71
70
|
const r = spawnSync(gifski, ["--fps", String(fps), "--quality", "90", "--repeat", "0", "-o", file, ...files], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
|
|
72
|
-
if (r.status !== 0) throw new Error(`gifski failed
|
|
71
|
+
if (r.status !== 0) throw new Error(`gifski failed: ${(r.stderr || r.error?.message || "").trim().split("\n").slice(-1)[0]}`);
|
|
73
72
|
return { file, encoder: "gifski" };
|
|
74
73
|
}
|
|
75
74
|
throw new BlockedError(EXIT.BLOCKED_NO_COVER_ENCODER, "BLOCKED_NO_COVER_ENCODER: install libwebp (img2webp and dwebp) or gifski; a cover is never an MP4");
|
|
@@ -214,9 +213,21 @@ export async function renderCover({ out, round = 1, env = process.env, log = ()
|
|
|
214
213
|
let replay;
|
|
215
214
|
let sought;
|
|
216
215
|
const order = seekOrder(times.length, treatment.seed || 20261020);
|
|
216
|
+
let rung = treatment.recipe === "hero-3d" ? "gpu" : "software";
|
|
217
|
+
const notices = [];
|
|
217
218
|
try {
|
|
218
|
-
const open = (label) => CoverBrowser.open({ stageDir, faces, width: pw, height: ph, scale: COVER.captureScale, profileDir: path.join(runDir, `chrome-${label}`), env, log });
|
|
219
|
-
|
|
219
|
+
const open = (label) => CoverBrowser.open({ stageDir, faces, width: pw, height: ph, scale: COVER.captureScale, profileDir: path.join(runDir, `chrome-${label}`), rung, env, log });
|
|
220
|
+
let a;
|
|
221
|
+
try {
|
|
222
|
+
a = await open("master");
|
|
223
|
+
} catch (error) {
|
|
224
|
+
// The 3D hero asks for the GPU rung; when it cannot start or draw there, all three passes take
|
|
225
|
+
// the software rung (they must share one) and the report says so.
|
|
226
|
+
if (rung !== "gpu" || error.code === EXIT.BLOCKED_NO_CHROME || error.code === EXIT.STAGE_NETWORK_REQUEST || error.code === EXIT.STAGE_NONDETERMINISTIC) throw error;
|
|
227
|
+
notices.push(`the 3D hero asked for the GPU rung and it failed there (${String(error.message).slice(0, 120)}); rendered on the software rung (SwiftShader), slower, same frames`);
|
|
228
|
+
rung = "software";
|
|
229
|
+
a = await open("master");
|
|
230
|
+
}
|
|
220
231
|
try {
|
|
221
232
|
master = await capturePass({ browser: a, pool, times, dir: dirs.frames, prefix: "f", width: w, height: h });
|
|
222
233
|
await capturePass({ browser: a, pool, times, dir: dirs.masks, prefix: "m", mask: true, width: w, height: h });
|
|
@@ -291,12 +302,12 @@ export async function renderCover({ out, round = 1, env = process.env, log = ()
|
|
|
291
302
|
});
|
|
292
303
|
const indexed = stills.finish(sheetFile);
|
|
293
304
|
writeFileSync(path.join(out, "poster.png"), readFileSync(path.join(stills.dir, "poster.png")));
|
|
294
|
-
const report = formatCoverReport(gate, { strict: true })
|
|
305
|
+
const report = `${formatCoverReport(gate, { strict: true })}${notices.map((n) => `warning: ${n}\n`).join("")}`;
|
|
295
306
|
writeFileSync(path.join(out, "gate-report.txt"), report);
|
|
296
307
|
const manifest = {
|
|
297
308
|
schema: "litgravity.motion-cover/v1", mode: "cover", round, recipe: treatment.recipe,
|
|
298
309
|
treatmentSha256: sha256(readFileSync(path.join(out, "treatment.json"))), stillsSha256: indexed.sha256,
|
|
299
|
-
page: treatment.page, size: treatment.out, scale: COVER.captureScale, fps: treatment.fps, frames: times.length, frameMs: ms,
|
|
310
|
+
page: treatment.page, size: treatment.out, scale: COVER.captureScale, rung, warnings: notices, fps: treatment.fps, frames: times.length, frameMs: ms,
|
|
300
311
|
encoder: encoded.encoder, encode: treatment.encode, file: path.basename(encoded.file), bytes: statSync(encoded.file).size, captureSec,
|
|
301
312
|
gate: { pass: gate.pass, target: gate.target, medianD: gate.medianD, movingFrac: gate.movingFrac, longestStillSec: gate.longestStillSec, spike: gate.spike, seamLocal: gate.seamLocal, gates: gate.gates },
|
|
302
313
|
};
|
|
@@ -342,7 +353,7 @@ export async function renderCoverWindow({ out, round = 1, window: [t0, t1], env
|
|
|
342
353
|
mkdirSync(dir, { recursive: true });
|
|
343
354
|
const [w, h] = treatment.out;
|
|
344
355
|
const pool = new CoverPool();
|
|
345
|
-
const browser = await CoverBrowser.open({ stageDir, faces, width: treatment.page[0], height: treatment.page[1], scale: COVER.captureScale, profileDir: path.join(out, ".run", "cover-window-chrome"), env, log });
|
|
356
|
+
const browser = await CoverBrowser.open({ stageDir, faces, width: treatment.page[0], height: treatment.page[1], scale: COVER.captureScale, profileDir: path.join(out, ".run", "cover-window-chrome"), rung: treatment.recipe === "hero-3d" ? "gpu" : "software", env, log });
|
|
346
357
|
try {
|
|
347
358
|
await capturePass({ browser, pool, times: [...new Set(picks.map((p) => p.index))].map((i) => [i, i / treatment.frames]), dir, prefix: "f", width: w, height: h });
|
|
348
359
|
} finally {
|
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
// treatment with the first valid one and records any downgrade. A cover (treatment mode: cover) is
|
|
7
7
|
// done on its own terms: the decoded cover reached every TARGET gate, and the last look round viewed
|
|
8
8
|
// the contact sheet, the poster and the seam pair of that render. A generated asset in assets.json
|
|
9
|
-
// becomes a label the reply has to carry.
|
|
9
|
+
// becomes a label the reply has to carry. A film whose treatment asks for a preview (`preview: true`)
|
|
10
|
+
// is done at its board: a stills-only render whose layout check passed, looked at, storyboard included.
|
|
10
11
|
import { createHash } from "node:crypto";
|
|
11
12
|
import { existsSync, readFileSync } from "node:fs";
|
|
12
13
|
import path from "node:path";
|
|
13
14
|
import { generatedLabels } from "./cover-assets.mjs";
|
|
14
15
|
import { validateCoverTreatment } from "./cover-treatment.mjs";
|
|
16
|
+
import { readHouse } from "./house.mjs";
|
|
15
17
|
import { readLook } from "./look.mjs";
|
|
16
18
|
import { readStills } from "./stills.mjs";
|
|
17
19
|
import { validateTreatment } from "./treatment.mjs";
|
|
@@ -49,10 +51,11 @@ export function evaluateDone({ out, viewedFiles = null }) {
|
|
|
49
51
|
try {
|
|
50
52
|
const raw = JSON.parse(readFileSync(tFile, "utf8"));
|
|
51
53
|
if (raw?.mode === "cover") return evaluateCoverDone({ out, raw, viewedFiles });
|
|
52
|
-
treatment = validateTreatment(raw);
|
|
54
|
+
treatment = validateTreatment(raw, { house: readHouse(out) });
|
|
53
55
|
} catch (error) {
|
|
54
56
|
return notDone(`treatment.json is not valid: ${error.message}`);
|
|
55
57
|
}
|
|
58
|
+
if (treatment.preview === true) return evaluatePreviewDone({ out, viewedFiles });
|
|
56
59
|
const manifestFile = path.join(out, "manifest.json");
|
|
57
60
|
const reportFile = path.join(out, "gate-report.txt");
|
|
58
61
|
if (!existsSync(manifestFile) || !existsSync(reportFile)) return notDone("no full render has finished (manifest.json or gate-report.txt is missing)");
|
|
@@ -85,12 +88,12 @@ export function evaluateDone({ out, viewedFiles = null }) {
|
|
|
85
88
|
if (stills && last.stillsSha256 !== stills.sha256) reasons.push("the last look round was recorded before the final render (its stills manifest differs); look again and record it");
|
|
86
89
|
if (last.blocked === "no-vision-tool") unviewed = true;
|
|
87
90
|
else if (stills) {
|
|
88
|
-
const required = stills.index.files.filter((f) => ["poster", "sheet", "beat", "strip"].includes(f.kind)).map((f) => f.file);
|
|
91
|
+
const required = stills.index.files.filter((f) => ["poster", "sheet", "beat", "strip", "board"].includes(f.kind)).map((f) => f.file);
|
|
89
92
|
const missing = required.filter((f) => !last.viewed?.includes(f));
|
|
90
93
|
if (missing.length) reasons.push(`the last look round did not view ${missing.slice(0, 4).join(", ")}${missing.length > 4 ? ` (+${missing.length - 4})` : ""}`);
|
|
91
94
|
if (viewedFiles) {
|
|
92
95
|
const unopened = (last.viewed ?? []).filter((f) => !viewedFiles.has(path.resolve(out, f)));
|
|
93
|
-
if (unopened.length) reasons.push(`these frames are listed as viewed but were never opened with
|
|
96
|
+
if (unopened.length) reasons.push(`these frames are listed as viewed but were never opened with the image tool: ${unopened.slice(0, 4).join(", ")}${unopened.length > 4 ? ` (+${unopened.length - 4})` : ""}`);
|
|
94
97
|
}
|
|
95
98
|
if (last.revise?.length) {
|
|
96
99
|
if (last.round >= 3) openItems.push(...last.revise.map((q) => `look question ${q}`));
|
|
@@ -110,6 +113,42 @@ export function evaluateDone({ out, viewedFiles = null }) {
|
|
|
110
113
|
return { status: unviewed ? "DONE_UNVIEWED" : "DONE", reasons: [], downgraded, openItems };
|
|
111
114
|
}
|
|
112
115
|
|
|
116
|
+
/** A preview: the board round of a film is the deliverable; the full render waits for the user. */
|
|
117
|
+
export function evaluatePreviewDone({ out, viewedFiles = null }) {
|
|
118
|
+
const reasons = [];
|
|
119
|
+
const stills = readStills(out);
|
|
120
|
+
if (!stills) return { status: "NOT_DONE", reasons: ["no board yet: render with --stills-only"], downgraded: [], openItems: [], preview: true };
|
|
121
|
+
const board = stills.index.files.find((f) => f.kind === "board");
|
|
122
|
+
if (!board) reasons.push("the stills set has no storyboard (stills/board.png); render with --stills-only again");
|
|
123
|
+
try {
|
|
124
|
+
const check = JSON.parse(readFileSync(path.join(out, "stills", "check.json"), "utf8"));
|
|
125
|
+
const failed = (check.rules ?? []).filter((x) => x.status === "FAIL").map((x) => x.id);
|
|
126
|
+
if (failed.length) reasons.push(`the board check failed (${failed.join(", ")}); fix the page and render the board again`);
|
|
127
|
+
} catch {
|
|
128
|
+
if (stills.index.path === "stage") reasons.push("the board check result (stills/check.json) is missing");
|
|
129
|
+
}
|
|
130
|
+
let look;
|
|
131
|
+
try {
|
|
132
|
+
look = readLook(out);
|
|
133
|
+
} catch {
|
|
134
|
+
return { status: "NOT_DONE", reasons: ["look.json is unreadable"], downgraded: [], openItems: [], preview: true };
|
|
135
|
+
}
|
|
136
|
+
const last = look.rounds[look.rounds.length - 1];
|
|
137
|
+
if (!last) reasons.push("no look round on the board: open the storyboard and the stills with Read and record round 1");
|
|
138
|
+
else {
|
|
139
|
+
if (last.stillsSha256 !== stills.sha256) reasons.push("the look round was recorded before the latest board; look again and record it");
|
|
140
|
+
const required = stills.index.files.filter((f) => ["board", "sheet", "beat"].includes(f.kind)).map((f) => f.file);
|
|
141
|
+
const missing = required.filter((f) => !last.viewed?.includes(f));
|
|
142
|
+
if (missing.length) reasons.push(`the look round did not view ${missing.slice(0, 4).join(", ")}`);
|
|
143
|
+
if (viewedFiles) {
|
|
144
|
+
const unopened = (last.viewed ?? []).filter((f) => !viewedFiles.has(path.resolve(out, f)));
|
|
145
|
+
if (unopened.length) reasons.push(`these files are listed as viewed but were never opened with the image tool: ${unopened.slice(0, 4).join(", ")}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (reasons.length) return { status: "NOT_DONE", reasons, downgraded: [], openItems: [], preview: true };
|
|
149
|
+
return { status: last.blocked === "no-vision-tool" ? "DONE_UNVIEWED" : "DONE", reasons: [], downgraded: [], openItems: [], preview: true, labels: [`this is the storyboard preview (${path.join(out, "stills", "board.png")}); the film is not rendered yet, and the user can say go to render it`] };
|
|
150
|
+
}
|
|
151
|
+
|
|
113
152
|
/** The cover branch of the done-check (references/cover.md, Done). */
|
|
114
153
|
export function evaluateCoverDone({ out, raw, viewedFiles = null }) {
|
|
115
154
|
const notDone = (reason) => ({ status: "NOT_DONE", reasons: [reason], downgraded: [], openItems: [], mode: "cover" });
|
|
@@ -142,7 +181,7 @@ export function evaluateCoverDone({ out, raw, viewedFiles = null }) {
|
|
|
142
181
|
const rounds = look.rounds;
|
|
143
182
|
const openItems = [];
|
|
144
183
|
let unviewed = false;
|
|
145
|
-
if (!rounds.length) reasons.push("look.json has no round: open the sheet, the poster and the seam pair with
|
|
184
|
+
if (!rounds.length) reasons.push("look.json has no round: open the sheet, the poster and the seam pair with Read and record a look round");
|
|
146
185
|
else {
|
|
147
186
|
const first = rounds[0];
|
|
148
187
|
const last = rounds[rounds.length - 1];
|
|
@@ -156,7 +195,7 @@ export function evaluateCoverDone({ out, raw, viewedFiles = null }) {
|
|
|
156
195
|
if (missing.length) reasons.push(`the last look round did not view ${missing.join(", ")}`);
|
|
157
196
|
if (viewedFiles) {
|
|
158
197
|
const unopened = (last.viewed ?? []).filter((f) => !viewedFiles.has(path.resolve(out, f)));
|
|
159
|
-
if (unopened.length) reasons.push(`these files are listed as viewed but were never opened with
|
|
198
|
+
if (unopened.length) reasons.push(`these files are listed as viewed but were never opened with the image tool: ${unopened.slice(0, 4).join(", ")}${unopened.length > 4 ? ` (+${unopened.length - 4})` : ""}`);
|
|
160
199
|
}
|
|
161
200
|
if (last.revise?.length) {
|
|
162
201
|
if (last.round >= 3) openItems.push(...last.revise.map((q) => `cover look question ${q}`));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// One frame-analysis worker: decode a captured PNG to RGBA and analyse it off the capture thread
|
|
2
|
-
// (the SHA-256 of the decoded RGBA, the flash-audit cells on the frame's own grid, the
|
|
3
|
-
// percentile luminance). The capture loop steps the next
|
|
2
|
+
// (the SHA-256 of the decoded RGBA, the flash-audit cells on the frame's own grid, the 0.5th and
|
|
3
|
+
// 99.5th percentile luminance, the busy-cell share for DEAD-AIR). The capture loop steps the next
|
|
4
|
+
// frame while a pool of these decodes.
|
|
4
5
|
import { parentPort } from "node:worker_threads";
|
|
5
|
-
import { analyzeFrame } from "./analysis.mjs";
|
|
6
|
+
import { analyzeFrame, busyShare } from "./analysis.mjs";
|
|
6
7
|
import { decodePng } from "./png.mjs";
|
|
7
8
|
|
|
8
9
|
parentPort.on("message", ({ id, png, width, height }) => {
|
|
@@ -14,9 +15,10 @@ parentPort.on("message", ({ id, png, width, height }) => {
|
|
|
14
15
|
}
|
|
15
16
|
const rgba = image.channels === 4 ? image.pixels : toRgba(image.pixels, image.channels);
|
|
16
17
|
// A stage frame is opaque: analyzeFrame's alpha-as-ink count is meaningless here and is dropped.
|
|
17
|
-
const { cells, luminanceP995, rgbaSha256 } = analyzeFrame(rgba, width, height);
|
|
18
|
+
const { cells, luminanceP995, luminanceP005, rgbaSha256 } = analyzeFrame(rgba, width, height);
|
|
19
|
+
const busy = busyShare(rgba, width, height);
|
|
18
20
|
const buffer = rgba.buffer.slice(rgba.byteOffset, rgba.byteOffset + rgba.byteLength);
|
|
19
|
-
parentPort.postMessage({ id, rgba: buffer, cells, luminanceP995, rgbaSha256 }, [buffer, cells.R.buffer, cells.G.buffer, cells.B.buffer]);
|
|
21
|
+
parentPort.postMessage({ id, rgba: buffer, cells, luminanceP995, luminanceP005, rgbaSha256, busy }, [buffer, cells.R.buffer, cells.G.buffer, cells.B.buffer]);
|
|
20
22
|
} catch (error) {
|
|
21
23
|
parentPort.postMessage({ id, error: error.message });
|
|
22
24
|
}
|