@anvpx/motion-build 0.1.94 → 0.1.95

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.
@@ -0,0 +1,121 @@
1
+ /**
2
+ * ADR-0013 runtime, emitted into boot.js only for `mk publish --interactive`.
3
+ *
4
+ * It is the schema's `stateAt` reducer as shipped to the browser: same total order, same
5
+ * transitions, same clamp. `boot.interaction.test.ts` pins this copy to
6
+ * `@anvpx/motion-schema` over every action, a permuted transcript and a grid of film times,
7
+ * so the live page and the rendered film cannot fold differently. It is a TypeScript module
8
+ * (not an asset) so `tsc -b` emits it into `dist` with boot.js — no runtime file to copy, no
9
+ * path that can go missing. No clock, randomness, DOM or pointer input.
10
+ */
11
+ export const INTERACTION_RUNTIME = `const MK_ACTIONS = [
12
+ "hover",
13
+ "press",
14
+ "release",
15
+ "click",
16
+ "type",
17
+ "focus",
18
+ "blur",
19
+ "scroll",
20
+ "advance",
21
+ ];
22
+
23
+ /** The wrapper's transcript in the schema's total order; one container, never rebound. */
24
+ const interactionState = {
25
+ events: [],
26
+ memo: { t: null, state: new Map() },
27
+ };
28
+
29
+ const interactionCompare = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
30
+
31
+ const interactionCompareValue = (a, b) =>
32
+ a === b ? 0 : a === null ? -1 : b === null ? 1 : interactionCompare(a, b);
33
+
34
+ const interactionByEvent = (a, b) =>
35
+ interactionCompare(a.at, b.at) ||
36
+ interactionCompare(a.scene, b.scene) ||
37
+ interactionCompare(a.target, b.target) ||
38
+ interactionCompare(MK_ACTIONS.indexOf(a.action), MK_ACTIONS.indexOf(b.action)) ||
39
+ interactionCompareValue(a.value, b.value);
40
+
41
+ const interactionEmpty = () => ({
42
+ pressed: false,
43
+ hovered: false,
44
+ focused: false,
45
+ typed: null,
46
+ scroll: 0,
47
+ activations: 0,
48
+ });
49
+
50
+ const interactionScroll = (value) => {
51
+ const parsed = Number(value);
52
+ return Number.isFinite(parsed) ? Math.min(1, Math.max(0, parsed)) : 0;
53
+ };
54
+
55
+ /** One event onto one target's state; \`advance\` is transport and leaves the target alone. */
56
+ const interactionNext = (state, action, value) => {
57
+ if (action === "hover") return Object.assign({}, state, { hovered: true });
58
+ if (action === "press") return Object.assign({}, state, { pressed: true });
59
+ if (action === "release") return Object.assign({}, state, { pressed: false });
60
+ if (action === "click") return Object.assign({}, state, { activations: state.activations + 1 });
61
+ if (action === "type") return Object.assign({}, state, { typed: value });
62
+ if (action === "focus") return Object.assign({}, state, { focused: true });
63
+ if (action === "blur") return Object.assign({}, state, { focused: false });
64
+ if (action === "scroll") return Object.assign({}, state, { scroll: interactionScroll(value) });
65
+ return state;
66
+ };
67
+
68
+ /** \`stateAt\` for the live page: every event with \`at <= t\`, keyed \`"<scene>:<target>"\`. */
69
+ const interactionAt = (t) => {
70
+ if (interactionState.memo.t === t) return interactionState.memo.state;
71
+ const state = new Map();
72
+ for (const event of interactionState.events) {
73
+ if (!(event.at <= t)) continue;
74
+ const key = event.scene + ":" + event.target;
75
+ state.set(
76
+ key,
77
+ interactionNext(state.get(key) || interactionEmpty(), event.action, event.value),
78
+ );
79
+ }
80
+ interactionState.memo = { t, state };
81
+ return state;
82
+ };
83
+
84
+ /** The wrapper posts the whole transcript with input; sort once per change, not per seek. */
85
+ const setInteractionTranscript = (events) => {
86
+ interactionState.events = events.slice().sort(interactionByEvent);
87
+ interactionState.memo = { t: null, state: new Map() };
88
+ };
89
+
90
+ /**
91
+ * Paints the folded state onto one scene's declared targets. The scene emits a
92
+ * [data-mk-target] mark only when its props declare that id, so a board without targets
93
+ * has no elements to address. Film time is the caller's absolute t; the key is
94
+ * "<scene>:<target>", the same key the reducer stores.
95
+ */
96
+ const interactionApplyTargets = (root, sceneId, t) => {
97
+ if (!root || typeof root.querySelectorAll !== "function") return;
98
+ const state = interactionAt(t);
99
+ for (const el of root.querySelectorAll("[data-mk-target]")) {
100
+ const target = state.get(sceneId + ":" + el.getAttribute("data-mk-target"));
101
+ const flag = (name, on) => {
102
+ if (on) el.setAttribute("data-mk-" + name, "");
103
+ else el.removeAttribute("data-mk-" + name);
104
+ };
105
+ flag("pressed", target ? target.pressed : false);
106
+ flag("hovered", target ? target.hovered : false);
107
+ flag("focused", target ? target.focused : false);
108
+ if (target && target.typed !== null) el.setAttribute("data-mk-typed", target.typed);
109
+ else el.removeAttribute("data-mk-typed");
110
+ const scroll = target ? target.scroll : 0;
111
+ el.setAttribute("data-mk-scroll", String(scroll));
112
+ el.setAttribute("data-mk-activations", String(target ? target.activations : 0));
113
+ if (el.style && typeof el.style.setProperty === "function") {
114
+ el.style.setProperty("--mk-target-scroll", String(scroll));
115
+ }
116
+ const slot =
117
+ typeof el.querySelector === "function" ? el.querySelector("[data-mk-typed-slot]") : null;
118
+ if (slot) slot.textContent = target && target.typed !== null ? target.typed : "";
119
+ }
120
+ };
121
+ `;
@@ -1,4 +1,27 @@
1
1
  import type { VendorLib } from "@anvpx/motion-schema";
2
+ /**
3
+ * A browser library copied verbatim into the emitted project (ADR-0006). No bundler, no CDN: the
4
+ * package's own ESM entry is written under `vendor/` and an import map points the bare specifier at
5
+ * it, so `import ... from "three"` in a scene script resolves offline under `script-src 'self'`.
6
+ */
7
+ export interface VendorSpec {
8
+ /** The bare specifier a scene script writes. */
9
+ readonly specifier: VendorLib;
10
+ /** Package name resolved from this module; its directory is where the files are read. */
11
+ readonly pkg: string;
12
+ /** Source file -> path under `vendor/`, keeping relative imports between entries intact. */
13
+ readonly files: readonly (readonly [source: string, dest: string])[];
14
+ /** Import-map target for `specifier`. */
15
+ readonly target: string;
16
+ }
17
+ /**
18
+ * The spec table is the single enumeration the build copies from, keyed by the schema's
19
+ * `VendorLib` union so a new member cannot compile without a spec. The census test
20
+ * (`vendor-parity.test.ts`) also holds it equal to the scanner's allow-list.
21
+ */
22
+ export declare const SPECS: Record<VendorLib, VendorSpec>;
23
+ /** Every vendored specifier, in spec-table order; the census uses it as one of the enumerations. */
24
+ export declare const vendorSpecifiers: () => readonly VendorLib[];
2
25
  /** Vendor libraries named by scenes, deduplicated and in a stable order. */
3
26
  export declare const vendorLibs: (used: readonly VendorLib[]) => readonly VendorLib[];
4
27
  /** `vendor/…` path -> bytes, for every library in `libs`. Empty when nothing is vendored. */
@@ -1,8 +1,13 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- const SPECS = [
5
- {
4
+ /**
5
+ * The spec table is the single enumeration the build copies from, keyed by the schema's
6
+ * `VendorLib` union so a new member cannot compile without a spec. The census test
7
+ * (`vendor-parity.test.ts`) also holds it equal to the scanner's allow-list.
8
+ */
9
+ export const SPECS = {
10
+ three: {
6
11
  specifier: "three",
7
12
  pkg: "three",
8
13
  // three.module.js re-exports the core build, so both files are required.
@@ -12,16 +17,18 @@ const SPECS = [
12
17
  ],
13
18
  target: "vendor/three.module.js",
14
19
  },
15
- {
20
+ postprocessing: {
16
21
  specifier: "postprocessing",
17
22
  pkg: "postprocessing",
18
23
  // Imports `three` by bare specifier; the import map resolves it to the copy above.
19
24
  files: [["index.js", "postprocessing.js"]],
20
25
  target: "vendor/postprocessing.js",
21
26
  },
22
- ];
27
+ };
28
+ /** Every vendored specifier, in spec-table order; the census uses it as one of the enumerations. */
29
+ export const vendorSpecifiers = () => Object.keys(SPECS);
23
30
  const specOf = (lib) => {
24
- const spec = SPECS.find((candidate) => candidate.specifier === lib);
31
+ const spec = SPECS[lib];
25
32
  if (spec === undefined)
26
33
  throw new Error(`unknown vendor library "${lib}"`);
27
34
  return spec;
package/dist/index.d.ts CHANGED
@@ -16,4 +16,6 @@ export { createRenderManifest, type RenderManifest, type RenderManifestInput, re
16
16
  export * from "./templates/index.ts";
17
17
  export { autoDuration, placementsFromTimeline, resolveTimeline, type ScenePlacement, type TimedScene, type Timeline, } from "./timing.ts";
18
18
  export { validateStoryboardFull } from "./validate-full.ts";
19
+ export { validateInteraction } from "./validate-interaction.ts";
19
20
  export { type FindingLevel, type MediaExpectation, type VerifyFinding, type VerifyInput, type VerifyReport, type VerifyStatus, verifyMedia, } from "./verify.ts";
21
+ export { buildGrainArgs, GRAIN_DESCRIPTOR, GRAIN_FILTER, GRAIN_SEED, GRAIN_STRENGTH, GRAIN_TEMP, grainEnergy, } from "./video/grain.ts";
package/dist/index.js CHANGED
@@ -16,4 +16,6 @@ export { createRenderManifest, renderRenderManifest, } from "./render-manifest.j
16
16
  export * from "./templates/index.js";
17
17
  export { autoDuration, placementsFromTimeline, resolveTimeline, } from "./timing.js";
18
18
  export { validateStoryboardFull } from "./validate-full.js";
19
+ export { validateInteraction } from "./validate-interaction.js";
19
20
  export { verifyMedia, } from "./verify.js";
21
+ export { buildGrainArgs, GRAIN_DESCRIPTOR, GRAIN_FILTER, GRAIN_SEED, GRAIN_STRENGTH, GRAIN_TEMP, grainEnergy, } from "./video/grain.js";
@@ -4,19 +4,25 @@
4
4
  * a slide deck however good each frame is.
5
5
  */
6
6
  const PICTURE_FORMS = new Set([
7
- "chart",
8
- "flow",
9
- "steps",
10
- "timeline",
11
- "compare",
12
- "icon-grid",
13
7
  "scene3d",
14
8
  "media-frame",
9
+ "kinetic",
15
10
  "stair",
16
- "table",
17
11
  "code",
18
12
  "waveform",
13
+ "sticker",
19
14
  "world",
15
+ "custom",
16
+ // Diagrams stay in this set: a chart, timeline or compare visibly changes the frame, unlike
17
+ // the poster/title/quote/stat type-on-a-ground cards this rule actually measures. They are
18
+ // deliberately excluded from visual-variety's moving-picture count instead.
19
+ "chart",
20
+ "flow",
21
+ "steps",
22
+ "timeline",
23
+ "compare",
24
+ "table",
25
+ "icon-grid",
20
26
  ]);
21
27
  /** Three type-only beats in a row is a deck; two is a warning. Calibrated against the repo''s own templates: erroring at two broke 30 test files, which means the shipped boards use pairs deliberately. */
22
28
  const MAX_TYPE_RUN = 2;
@@ -68,7 +74,7 @@ export const beatVarietyRule = ({ storyboard }) => {
68
74
  severity: "warning",
69
75
  path: `/scenes/${scene.id}`,
70
76
  message: `${typeRun} type-only beats in a row (from "${base[typeRunStart]?.id ?? ""}"): the film reads as a slide deck`,
71
- suggestion: "give one of them a picture (chart, flow/steps, timeline, compare, world, scene3d, media-frame) so the film changes what it shows; see references/visual-forms.md",
77
+ suggestion: "give one of them a moving picture (world, scene3d, media-frame, kinetic or an authored custom scene) so the film changes what it shows; see references/visual-forms.md",
72
78
  });
73
79
  }
74
80
  });
@@ -10,3 +10,9 @@ export interface CustomSourceInput {
10
10
  * pointing at the first offending line. Pure, so the CLI can run it before a build.
11
11
  */
12
12
  export declare const lintCustomSource: (input: CustomSourceInput, dir: string) => LintFinding[];
13
+ /**
14
+ * Every authored scene in the build, gathered at the emit seam so library consumers
15
+ * get the same lint gate the CLI's read-time check gives. `ids` keeps sources that are
16
+ * not part of this storyboard out of the report.
17
+ */
18
+ export declare const collectCustomFindings: (ids: readonly string[], sources: Readonly<Record<string, CustomSourceInput>> | undefined) => LintFinding[];
@@ -53,6 +53,12 @@ const PROBES = [
53
53
  message: "window is reserved by the renderer",
54
54
  suggestion: "use the root element and the props you were given",
55
55
  },
56
+ {
57
+ file: "scene.js",
58
+ pattern: /\bwindow\b/,
59
+ message: "window is reserved by the renderer",
60
+ suggestion: "use the root element and the props you were given",
61
+ },
56
62
  {
57
63
  file: "style.css",
58
64
  pattern: /(^|[\s;{])animation(?:-name)?\s*:/,
@@ -92,7 +98,173 @@ const PROBES = [
92
98
  ];
93
99
  /** Blanks a span while preserving newlines, so reported line numbers stay true. */
94
100
  const blank = (text) => text.replace(/[^\n]/g, " ");
95
- const stripJs = (source) => source.replace(/\/\*[\s\S]*?\*\//g, blank).replace(/\/\/[^\n]*/g, blank);
101
+ /**
102
+ * Rewrites indirect global access into the direct form the probes already know:
103
+ * `globalThis['Date']['now']()` becomes `Date.now()`, `self.Math.random()` becomes
104
+ * `Math.random()`, and `globalThis['window']` becomes a bare `window` reference.
105
+ * Runs on the RAW source, before tokenizing, so computed keys are still readable.
106
+ */
107
+ const normaliseGlobals = (source) => source
108
+ .replace(/\b(?:globalThis|self)\s*\[\s*(['"])([A-Za-z_$][\w$]*)\1\s*\]/g, "$2")
109
+ .replace(/\b(?:globalThis|self)\s*\.\s*([A-Za-z_$][\w$]*)/g, "$1")
110
+ .replace(/\b(Date|Math|performance)\s*\[\s*(['"])(now|random)\2\s*\]/g, "$1.$3");
111
+ const isNewline = (ch) => ch === "\n" || ch === "\r";
112
+ const top = (state) => state.stack[state.stack.length - 1];
113
+ const emitBlank = (state, ch) => {
114
+ state.out.push(isNewline(ch) ? ch : " ");
115
+ };
116
+ /** Blanks a `\` and its escaped character, preserving a newline if escaped. */
117
+ const blankEscape = (state, at) => {
118
+ state.out.push(" ");
119
+ if (at + 1 >= state.source.length)
120
+ return 1;
121
+ emitBlank(state, state.source[at + 1]);
122
+ return 2;
123
+ };
124
+ const stepLineComment = (state, i) => {
125
+ const ch = state.source[i];
126
+ if (isNewline(ch))
127
+ state.stack.pop();
128
+ emitBlank(state, ch);
129
+ return 1;
130
+ };
131
+ const stepBlockComment = (state, i) => {
132
+ const ch = state.source[i];
133
+ const next = state.source[i + 1];
134
+ if (ch === "*" && next === "/") {
135
+ state.out.push(" ");
136
+ state.stack.pop();
137
+ return 2;
138
+ }
139
+ emitBlank(state, ch);
140
+ return 1;
141
+ };
142
+ const stepQuoted = (state, i, quote) => {
143
+ const ch = state.source[i];
144
+ if (ch === "\\")
145
+ return blankEscape(state, i);
146
+ if (ch === quote) {
147
+ state.out.push(quote);
148
+ state.stack.pop();
149
+ return 1;
150
+ }
151
+ emitBlank(state, ch);
152
+ return 1;
153
+ };
154
+ const stepTemplate = (state, i) => {
155
+ const ch = state.source[i];
156
+ const next = state.source[i + 1];
157
+ if (ch === "`") {
158
+ state.out.push("`");
159
+ state.stack.pop();
160
+ return 1;
161
+ }
162
+ if (ch === "\\")
163
+ return blankEscape(state, i);
164
+ if (ch === "$" && next === "{") {
165
+ state.out.push(" ");
166
+ state.stack.push({ kind: "code", interpolation: true, braceDepth: 0 });
167
+ return 2;
168
+ }
169
+ emitBlank(state, ch);
170
+ return 1;
171
+ };
172
+ /** Tracks braces inside a `${...}` so nested blocks don't close it early. */
173
+ const stepBraces = (state, frame, ch) => {
174
+ if (ch === "{") {
175
+ frame.braceDepth += 1;
176
+ state.out.push(ch);
177
+ return;
178
+ }
179
+ if (ch === "}") {
180
+ if (frame.braceDepth === 0)
181
+ state.stack.pop(); // back to the template frame
182
+ else
183
+ frame.braceDepth -= 1;
184
+ state.out.push(ch);
185
+ return;
186
+ }
187
+ state.out.push(ch);
188
+ };
189
+ const stepCode = (state, frame, i) => {
190
+ const ch = state.source[i];
191
+ const next = state.source[i + 1];
192
+ if (ch === "'") {
193
+ state.out.push("'");
194
+ state.stack.push({ kind: "single" });
195
+ return 1;
196
+ }
197
+ if (ch === '"') {
198
+ state.out.push('"');
199
+ state.stack.push({ kind: "double" });
200
+ return 1;
201
+ }
202
+ if (ch === "`") {
203
+ state.out.push("`");
204
+ state.stack.push({ kind: "template" });
205
+ return 1;
206
+ }
207
+ if (ch === "/" && next === "/") {
208
+ state.out.push(" ");
209
+ state.stack.push({ kind: "line-comment" });
210
+ return 2;
211
+ }
212
+ if (ch === "/" && next === "*") {
213
+ state.out.push(" ");
214
+ state.stack.push({ kind: "block-comment" });
215
+ return 2;
216
+ }
217
+ if (frame.interpolation) {
218
+ stepBraces(state, frame, ch);
219
+ return 1;
220
+ }
221
+ state.out.push(ch);
222
+ return 1;
223
+ };
224
+ /**
225
+ * Single string-aware pass over JS source. Returns a stream the same length as
226
+ * the input (so reported line numbers stay true) where comment text and string
227
+ * CONTENT are blanked while quotes/delimiters, newlines and every character of
228
+ * real code are kept searchable by the probes.
229
+ *
230
+ * Unlike the old `stripStrings(stripJs(raw))` chain, a `//` or `/*` inside a
231
+ * string or template literal is never mistaken for a comment opener, so it
232
+ * cannot blank the rest of the line or leave a dangling quote that swallows
233
+ * later code. Template interpolation is re-entered as code so real calls in it
234
+ * remain visible.
235
+ */
236
+ const codeStream = (source) => {
237
+ const state = {
238
+ source,
239
+ out: [],
240
+ stack: [{ kind: "code", interpolation: false, braceDepth: 0 }],
241
+ };
242
+ let i = 0;
243
+ while (i < source.length) {
244
+ const frame = top(state);
245
+ switch (frame.kind) {
246
+ case "line-comment":
247
+ i += stepLineComment(state, i);
248
+ break;
249
+ case "block-comment":
250
+ i += stepBlockComment(state, i);
251
+ break;
252
+ case "single":
253
+ i += stepQuoted(state, i, "'");
254
+ break;
255
+ case "double":
256
+ i += stepQuoted(state, i, '"');
257
+ break;
258
+ case "template":
259
+ i += stepTemplate(state, i);
260
+ break;
261
+ case "code":
262
+ i += stepCode(state, frame, i);
263
+ break;
264
+ }
265
+ }
266
+ return state.out.join("");
267
+ };
96
268
  const stripCss = (source) => source.replace(/\/\*[\s\S]*?\*\//g, blank);
97
269
  const stripHtml = (source) => source.replace(/<!--[\s\S]*?-->/g, blank);
98
270
  const sourceOf = (input, file) => {
@@ -100,7 +272,10 @@ const sourceOf = (input, file) => {
100
272
  if (raw === undefined)
101
273
  return undefined;
102
274
  // Comments describe the rules ("no window.") and must not trip them.
103
- return file === "scene.js" ? stripJs(raw) : file === "style.css" ? stripCss(raw) : stripHtml(raw);
275
+ if (file !== "scene.js") {
276
+ return file === "style.css" ? stripCss(raw) : stripHtml(raw);
277
+ }
278
+ return codeStream(normaliseGlobals(raw));
104
279
  };
105
280
  /** First offending line of one file, as a finding path of `<dir>/<file>:<line>`. */
106
281
  const scan = (input, probe, dir) => {
@@ -124,7 +299,27 @@ const scan = (input, probe, dir) => {
124
299
  * Determinism and safety lint for an authored scene: one finding per rule and file,
125
300
  * pointing at the first offending line. Pure, so the CLI can run it before a build.
126
301
  */
127
- export const lintCustomSource = (input, dir) => PROBES.flatMap((probe) => {
128
- const finding = scan(input, probe, dir);
129
- return finding === undefined ? [] : [finding];
130
- });
302
+ export const lintCustomSource = (input, dir) => {
303
+ const seen = new Set();
304
+ return PROBES.flatMap((probe) => {
305
+ const finding = scan(input, probe, dir);
306
+ return finding === undefined ? [] : [finding];
307
+ }).filter((finding) => {
308
+ const key = `${finding.path}\u0000${finding.message}`;
309
+ if (seen.has(key))
310
+ return false;
311
+ seen.add(key);
312
+ return true;
313
+ });
314
+ };
315
+ /**
316
+ * Every authored scene in the build, gathered at the emit seam so library consumers
317
+ * get the same lint gate the CLI's read-time check gives. `ids` keeps sources that are
318
+ * not part of this storyboard out of the report.
319
+ */
320
+ export const collectCustomFindings = (ids, sources) => sources === undefined
321
+ ? []
322
+ : ids.flatMap((id) => {
323
+ const source = sources[id];
324
+ return source === undefined ? [] : lintCustomSource(source, `scenes/${id}`);
325
+ });
@@ -62,9 +62,9 @@ export const LINT_RULES = [
62
62
  duplicatedEmphasisRule,
63
63
  visualVarietyRule,
64
64
  worldStopsRule,
65
- // beatVarietyRule: implemented and tested (beat-variety.ts) but not registered yet. The
66
- // repo's own templates declare exact warning sets that it legitimately changes, so it ships
67
- // disabled until those templates are rewritten. See findings/round33-beat-variety.md.
65
+ // Registered after the shipped blueprints were rewritten to keep every same-family run <= 2;
66
+ // the shipped boards now produce no beat-variety warnings.
67
+ beatVarietyRule,
68
68
  ];
69
69
  export const lintStoryboard = (input) => {
70
70
  const findings = LINT_RULES.flatMap((rule) => rule(input));
@@ -5,6 +5,11 @@ import type { LintRule } from "./types.ts";
5
5
  * board-level rule on purpose — it judges the film's visual vocabulary, not any
6
6
  * single frame — so it fires once, not per scene.
7
7
  *
8
+ * Two findings share this rule (never both for one board):
9
+ * - an all-diagram board gets the world-first default: slides are an explicit
10
+ * brief request, not the fallback for a film with no picture in it;
11
+ * - any other shortfall keeps the moving-picture floor message.
12
+ *
8
13
  * Overlays never carry the visual language of the film, so they neither count
9
14
  * as base beats nor satisfy the rule.
10
15
  */
@@ -1,32 +1,46 @@
1
1
  /**
2
- * Scene types that put a visual form on screen — a picture, a diagram or a
3
- * moving display — rather than copy on a background.
2
+ * Scene types that put a moving picture on screen — rather than copy on a
3
+ * background or a static diagram. Diagram forms (chart, flow/steps, timeline,
4
+ * compare, table, icon-grid) deliberately do not count: a board of diagrams
5
+ * reads as a slide deck, not a film with a visual language.
4
6
  */
5
7
  const VISUAL_FORMS = new Set([
6
- "chart",
7
- "flow",
8
- "steps",
9
- "timeline",
10
- "compare",
11
- "icon-grid",
12
8
  "scene3d",
13
9
  "media-frame",
14
10
  "kinetic",
15
11
  "stair",
16
- "table",
17
12
  "code",
18
13
  "waveform",
19
14
  "sticker",
20
15
  "world",
16
+ "custom",
17
+ ]);
18
+ /** The diagram forms ADR-0012 says are supporting facts, never the film's world. */
19
+ const DIAGRAM_FORMS = new Set([
20
+ "chart",
21
+ "flow",
22
+ "steps",
23
+ "timeline",
24
+ "compare",
25
+ "table",
26
+ "icon-grid",
21
27
  ]);
22
28
  /** Concrete forms the author can reach for, named in the suggestion. */
23
- const FORMS = "chart, flow/steps, world, scene3d, media-frame, kinetic or compare";
29
+ const FORMS = "world, scene3d, media-frame, kinetic, sticker, custom or an authored scene";
30
+ /** A board made only of diagrams: no world-bearing or other visual base beat. */
31
+ const isAllDiagrams = (base) => base.every((scene) => DIAGRAM_FORMS.has(scene.type)) &&
32
+ !base.some((scene) => scene.type === "media-frame");
24
33
  /**
25
34
  * A film long enough to establish a visual language must show one: at least a
26
35
  * third of the base beats are visual-bearing (`design-taste.md` law 1). This is a
27
36
  * board-level rule on purpose — it judges the film's visual vocabulary, not any
28
37
  * single frame — so it fires once, not per scene.
29
38
  *
39
+ * Two findings share this rule (never both for one board):
40
+ * - an all-diagram board gets the world-first default: slides are an explicit
41
+ * brief request, not the fallback for a film with no picture in it;
42
+ * - any other shortfall keeps the moving-picture floor message.
43
+ *
30
44
  * Overlays never carry the visual language of the film, so they neither count
31
45
  * as base beats nor satisfy the rule.
32
46
  */
@@ -38,6 +52,15 @@ export const visualVarietyRule = ({ storyboard }) => {
38
52
  const need = Math.ceil(base.length / 3);
39
53
  if (visual >= need)
40
54
  return [];
55
+ if (visual === 0 && isAllDiagrams(base))
56
+ return [
57
+ {
58
+ severity: "warning",
59
+ path: "/scenes",
60
+ message: `all ${base.length} base scenes are diagram forms: the world-first default is a moving-picture film; slides or a deck are used only when the brief asks for them`,
61
+ suggestion: `give the film a world (${FORMS}); keep diagrams as supporting facts for sourced numbers`,
62
+ },
63
+ ];
41
64
  return [
42
65
  {
43
66
  severity: "warning",
@@ -0,0 +1,70 @@
1
+ /**
2
+ * S8: fresh/default eligibility, kept separate from the storyboard and template
3
+ * schemas. The manifest (`<templates package>/catalog-quality.json`) is generated
4
+ * from the S1 inventory and carries one row per catalog entry. Eligibility is
5
+ * never inferred from tone, popularity or a nearby theme: a row says it or the
6
+ * entry is not eligible.
7
+ *
8
+ * Until S12 applies the reviewed data the shipped rows all say `false`, which is
9
+ * the intended state: canned creation is closed, authored/direct work stays open.
10
+ */
11
+ export declare const QUALITY_KINDS: readonly ["template", "blueprint", "style", "theme", "scene", "atom"];
12
+ export type QualityKind = (typeof QUALITY_KINDS)[number];
13
+ export interface QualityRow {
14
+ /** `kind:id`, with `template/blueprint` and `template/style` for those kinds. */
15
+ readonly key: string;
16
+ readonly kind: QualityKind;
17
+ readonly id: string;
18
+ readonly freshEligible: boolean;
19
+ readonly defaultEligible: boolean;
20
+ readonly disposition?: string;
21
+ readonly proofState?: string;
22
+ }
23
+ export interface CatalogQuality {
24
+ readonly rows: ReadonlyMap<string, QualityRow>;
25
+ /** Absolute path the rows came from; absent for the built-in empty index. */
26
+ readonly source?: string;
27
+ }
28
+ export interface QualityIssue {
29
+ readonly path: string;
30
+ readonly message: string;
31
+ }
32
+ export type QualityResult = {
33
+ readonly ok: true;
34
+ readonly value: CatalogQuality;
35
+ } | {
36
+ readonly ok: false;
37
+ readonly errors: readonly QualityIssue[];
38
+ };
39
+ /** Nothing qualified: the state of a missing or unreadable manifest. */
40
+ export declare const EMPTY_QUALITY: CatalogQuality;
41
+ export declare const qualityKey: (kind: QualityKind, id: string) => string;
42
+ export declare const blueprintKey: (template: string, blueprint: string) => string;
43
+ export declare const styleKey: (template: string, style: string) => string;
44
+ /**
45
+ * Parses the manifest. Eligibility booleans are never trusted alone: a true
46
+ * flag requires `observed_pass`, a complete declared coverage subset, evidence
47
+ * refs, no critical failures and a content subject whose rows hash to the
48
+ * embedded `contentSubjectSha256`. Missing or stale subject data fails the
49
+ * whole load closed, which closes canned creation while authored work stays open.
50
+ */
51
+ export declare const parseCatalogQuality: (value: unknown) => QualityResult;
52
+ /** Reads one manifest; a missing file is an empty index, a malformed one is an error. */
53
+ export declare const loadCatalogQuality: (path: string) => QualityResult;
54
+ /** The manifest that ships beside a templates directory (`<pkg>/templates` -> `<pkg>/catalog-quality.json`). */
55
+ export declare const catalogQualityPathFor: (templatesDir: string) => string;
56
+ /** Loads the manifest for a templates directory; a missing file leaves the index empty. */
57
+ export declare const loadCatalogQualityFor: (templatesDir: string) => QualityResult;
58
+ /** A row must exist and say `true`; absence is not eligibility. */
59
+ export declare const isFreshEligible: (quality: CatalogQuality, kind: QualityKind, id: string) => boolean;
60
+ export declare const isDefaultEligible: (quality: CatalogQuality, kind: QualityKind, id: string) => boolean;
61
+ /** Roots that ship the catalog; project/env/user templates are authored work and never gated. */
62
+ export declare const CATALOG_SOURCES: readonly string[];
63
+ export declare const isCatalogSource: (source: string) => boolean;
64
+ /** A blueprint may be created fresh when it is authored work or its catalog row says so. */
65
+ export declare const isBlueprintFreshEligible: (quality: CatalogQuality, source: string, template: string, blueprint: string) => boolean;
66
+ /**
67
+ * A template's default style may only be used implicitly when its row says so;
68
+ * an explicitly named style is the author's choice and is never gated here.
69
+ */
70
+ export declare const isStyleDefaultEligible: (quality: CatalogQuality, source: string, template: string, style: string) => boolean;