@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.
- package/dist/audio/mix.d.ts +26 -10
- package/dist/audio/mix.js +64 -16
- package/dist/build.d.ts +15 -1
- package/dist/build.js +85 -16
- package/dist/emit/boot.d.ts +17 -2
- package/dist/emit/boot.js +31 -4
- package/dist/emit/boot.template.js +4 -4
- package/dist/emit/interaction-runtime.d.ts +11 -0
- package/dist/emit/interaction-runtime.js +121 -0
- package/dist/emit/vendor.d.ts +23 -0
- package/dist/emit/vendor.js +12 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lint/beat-variety.js +14 -8
- package/dist/lint/custom-source.d.ts +6 -0
- package/dist/lint/custom-source.js +201 -6
- package/dist/lint/index.js +3 -3
- package/dist/lint/visual-variety.d.ts +5 -0
- package/dist/lint/visual-variety.js +33 -10
- package/dist/templates/catalog-quality.d.ts +70 -0
- package/dist/templates/catalog-quality.js +221 -0
- package/dist/templates/index.d.ts +2 -1
- package/dist/templates/index.js +2 -1
- package/dist/templates/search.d.ts +11 -0
- package/dist/templates/search.js +12 -0
- package/dist/templates/validate.d.ts +2 -1
- package/dist/templates/validate.js +6 -23
- package/dist/validate-full.js +38 -45
- package/dist/validate-interaction.d.ts +7 -0
- package/dist/validate-interaction.js +32 -0
- package/dist/video/grain.d.ts +47 -0
- package/dist/video/grain.js +121 -0
- package/package.json +4 -4
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* S8: fresh/default eligibility, kept separate from the storyboard and template
|
|
6
|
+
* schemas. The manifest (`<templates package>/catalog-quality.json`) is generated
|
|
7
|
+
* from the S1 inventory and carries one row per catalog entry. Eligibility is
|
|
8
|
+
* never inferred from tone, popularity or a nearby theme: a row says it or the
|
|
9
|
+
* entry is not eligible.
|
|
10
|
+
*
|
|
11
|
+
* Until S12 applies the reviewed data the shipped rows all say `false`, which is
|
|
12
|
+
* the intended state: canned creation is closed, authored/direct work stays open.
|
|
13
|
+
*/
|
|
14
|
+
export const QUALITY_KINDS = ["template", "blueprint", "style", "theme", "scene", "atom"];
|
|
15
|
+
/** Nothing qualified: the state of a missing or unreadable manifest. */
|
|
16
|
+
export const EMPTY_QUALITY = { rows: new Map() };
|
|
17
|
+
export const qualityKey = (kind, id) => `${kind}:${id}`;
|
|
18
|
+
export const blueprintKey = (template, blueprint) => qualityKey("blueprint", `${template}/${blueprint}`);
|
|
19
|
+
export const styleKey = (template, style) => qualityKey("style", `${template}/${style}`);
|
|
20
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21
|
+
const isKind = (value) => typeof value === "string" && QUALITY_KINDS.includes(value);
|
|
22
|
+
/**
|
|
23
|
+
* Parses the manifest. Only the eligibility fields are required; the inventory's
|
|
24
|
+
* evidence, treatment and hash fields stay with the inventory and are ignored
|
|
25
|
+
* here so a richer manifest never needs this module to change.
|
|
26
|
+
*/
|
|
27
|
+
const SHA256 = /^[0-9a-f]{64}$/;
|
|
28
|
+
const stringList = (value) => {
|
|
29
|
+
if (!Array.isArray(value))
|
|
30
|
+
return null;
|
|
31
|
+
if (!value.every((item) => typeof item === "string" && item !== ""))
|
|
32
|
+
return null;
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
const subjectDigest = (value) => {
|
|
36
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
37
|
+
return null;
|
|
38
|
+
const rows = [];
|
|
39
|
+
for (const row of value) {
|
|
40
|
+
if (!isRecord(row) ||
|
|
41
|
+
typeof row.path !== "string" ||
|
|
42
|
+
row.path === "" ||
|
|
43
|
+
typeof row.sha256 !== "string" ||
|
|
44
|
+
!SHA256.test(row.sha256)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
rows.push({ path: row.path, sha256: row.sha256 });
|
|
48
|
+
}
|
|
49
|
+
rows.sort((left, right) => (left.path < right.path ? -1 : 1));
|
|
50
|
+
return createHash("sha256")
|
|
51
|
+
.update(`${rows.map((row) => `${row.sha256} ${row.path}`).join("\n")}\n`)
|
|
52
|
+
.digest("hex");
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Parses the manifest. Eligibility booleans are never trusted alone: a true
|
|
56
|
+
* flag requires `observed_pass`, a complete declared coverage subset, evidence
|
|
57
|
+
* refs, no critical failures and a content subject whose rows hash to the
|
|
58
|
+
* embedded `contentSubjectSha256`. Missing or stale subject data fails the
|
|
59
|
+
* whole load closed, which closes canned creation while authored work stays open.
|
|
60
|
+
*/
|
|
61
|
+
export const parseCatalogQuality = (value) => {
|
|
62
|
+
if (!isRecord(value)) {
|
|
63
|
+
return { ok: false, errors: [{ path: "", message: "catalog quality must be an object" }] };
|
|
64
|
+
}
|
|
65
|
+
const { entries } = value;
|
|
66
|
+
if (!Array.isArray(entries)) {
|
|
67
|
+
return { ok: false, errors: [{ path: "/entries", message: "entries must be an array" }] };
|
|
68
|
+
}
|
|
69
|
+
const rows = new Map();
|
|
70
|
+
const errors = [];
|
|
71
|
+
const digest = subjectDigest(value.contentSubjectManifest);
|
|
72
|
+
if (digest === null) {
|
|
73
|
+
errors.push({
|
|
74
|
+
path: "/contentSubjectManifest",
|
|
75
|
+
message: "a non-empty { path, sha256 } subject manifest is required",
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else if (value.contentSubjectSha256 !== digest) {
|
|
79
|
+
errors.push({
|
|
80
|
+
path: "/contentSubjectSha256",
|
|
81
|
+
message: "does not match the packaged contentSubjectManifest",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
entries.forEach((entry, index) => {
|
|
85
|
+
const path = `/entries/${index}`;
|
|
86
|
+
if (!isRecord(entry)) {
|
|
87
|
+
errors.push({ path, message: "entry must be an object" });
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const { key, kind, id } = entry;
|
|
91
|
+
if (typeof key !== "string" || key === "") {
|
|
92
|
+
errors.push({ path: `${path}/key`, message: "key must be a non-empty string" });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!isKind(kind)) {
|
|
96
|
+
errors.push({ path: `${path}/kind`, message: `kind must be ${QUALITY_KINDS.join("|")}` });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (typeof id !== "string" || id === "") {
|
|
100
|
+
errors.push({ path: `${path}/id`, message: "id must be a non-empty string" });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const fresh = entry.freshEligible;
|
|
104
|
+
const def = entry.defaultEligible;
|
|
105
|
+
if (typeof fresh !== "boolean" || typeof def !== "boolean") {
|
|
106
|
+
errors.push({
|
|
107
|
+
path,
|
|
108
|
+
message: "freshEligible and defaultEligible must be booleans (no implicit eligibility)",
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (key !== qualityKey(kind, id)) {
|
|
113
|
+
errors.push({
|
|
114
|
+
path: `${path}/key`,
|
|
115
|
+
message: `key must be "${qualityKey(kind, id)}" for ${kind} "${id}"`,
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (rows.has(key)) {
|
|
120
|
+
errors.push({ path: `${path}/key`, message: `duplicate key "${key}"` });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (fresh || def) {
|
|
124
|
+
if (entry.proofState !== "observed_pass") {
|
|
125
|
+
errors.push({
|
|
126
|
+
path: `${path}/proofState`,
|
|
127
|
+
message: "eligibility requires observed_pass evidence",
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const required = stringList(entry.coverageRequired);
|
|
131
|
+
const observed = stringList(entry.coverageObserved);
|
|
132
|
+
if (required === null || required.length === 0) {
|
|
133
|
+
errors.push({
|
|
134
|
+
path: `${path}/coverageRequired`,
|
|
135
|
+
message: "eligibility requires a declared coverage subset",
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (observed === null) {
|
|
139
|
+
errors.push({
|
|
140
|
+
path: `${path}/coverageObserved`,
|
|
141
|
+
message: "eligibility requires observed coverage items",
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else if (required !== null) {
|
|
145
|
+
for (const item of required) {
|
|
146
|
+
if (!observed.includes(item)) {
|
|
147
|
+
errors.push({
|
|
148
|
+
path: `${path}/coverageObserved`,
|
|
149
|
+
message: `missing required coverage "${item}"`,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const evidence = stringList(entry.evidenceRefs);
|
|
155
|
+
if (evidence === null || evidence.length === 0) {
|
|
156
|
+
errors.push({
|
|
157
|
+
path: `${path}/evidenceRefs`,
|
|
158
|
+
message: "eligibility requires current evidence refs",
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (Array.isArray(entry.criticalFailures) && entry.criticalFailures.length > 0) {
|
|
162
|
+
errors.push({
|
|
163
|
+
path: `${path}/criticalFailures`,
|
|
164
|
+
message: "unresolved critical failures block eligibility",
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
rows.set(key, {
|
|
169
|
+
key,
|
|
170
|
+
kind,
|
|
171
|
+
id,
|
|
172
|
+
freshEligible: fresh,
|
|
173
|
+
defaultEligible: def,
|
|
174
|
+
...(typeof entry.disposition === "string" ? { disposition: entry.disposition } : {}),
|
|
175
|
+
...(typeof entry.proofState === "string" ? { proofState: entry.proofState } : {}),
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
return errors.length > 0 ? { ok: false, errors } : { ok: true, value: { rows } };
|
|
179
|
+
};
|
|
180
|
+
/** Reads one manifest; a missing file is an empty index, a malformed one is an error. */
|
|
181
|
+
export const loadCatalogQuality = (path) => {
|
|
182
|
+
if (!existsSync(path))
|
|
183
|
+
return { ok: true, value: { ...EMPTY_QUALITY, source: path } };
|
|
184
|
+
let text;
|
|
185
|
+
try {
|
|
186
|
+
text = readFileSync(path, "utf8");
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
return {
|
|
190
|
+
ok: false,
|
|
191
|
+
errors: [{ path, message: `unreadable: ${error.message}` }],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
let parsed;
|
|
195
|
+
try {
|
|
196
|
+
parsed = JSON.parse(text);
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
return { ok: false, errors: [{ path, message: `invalid JSON: ${error.message}` }] };
|
|
200
|
+
}
|
|
201
|
+
const result = parseCatalogQuality(parsed);
|
|
202
|
+
return result.ok ? { ok: true, value: { rows: result.value.rows, source: path } } : result;
|
|
203
|
+
};
|
|
204
|
+
/** The manifest that ships beside a templates directory (`<pkg>/templates` -> `<pkg>/catalog-quality.json`). */
|
|
205
|
+
export const catalogQualityPathFor = (templatesDir) => join(dirname(templatesDir), "catalog-quality.json");
|
|
206
|
+
/** Loads the manifest for a templates directory; a missing file leaves the index empty. */
|
|
207
|
+
export const loadCatalogQualityFor = (templatesDir) => loadCatalogQuality(catalogQualityPathFor(templatesDir));
|
|
208
|
+
const rowOf = (quality, kind, id) => quality.rows.get(qualityKey(kind, id));
|
|
209
|
+
/** A row must exist and say `true`; absence is not eligibility. */
|
|
210
|
+
export const isFreshEligible = (quality, kind, id) => rowOf(quality, kind, id)?.freshEligible === true;
|
|
211
|
+
export const isDefaultEligible = (quality, kind, id) => rowOf(quality, kind, id)?.defaultEligible === true;
|
|
212
|
+
/** Roots that ship the catalog; project/env/user templates are authored work and never gated. */
|
|
213
|
+
export const CATALOG_SOURCES = ["built-in", "npm"];
|
|
214
|
+
export const isCatalogSource = (source) => CATALOG_SOURCES.includes(source);
|
|
215
|
+
/** A blueprint may be created fresh when it is authored work or its catalog row says so. */
|
|
216
|
+
export const isBlueprintFreshEligible = (quality, source, template, blueprint) => !isCatalogSource(source) || isFreshEligible(quality, "blueprint", `${template}/${blueprint}`);
|
|
217
|
+
/**
|
|
218
|
+
* A template's default style may only be used implicitly when its row says so;
|
|
219
|
+
* an explicitly named style is the author's choice and is never gated here.
|
|
220
|
+
*/
|
|
221
|
+
export const isStyleDefaultEligible = (quality, source, template, style) => !isCatalogSource(source) || isDefaultEligible(quality, "style", `${template}/${style}`);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
export { blueprintKey, CATALOG_SOURCES, type CatalogQuality, catalogQualityPathFor, EMPTY_QUALITY, isBlueprintFreshEligible, isCatalogSource, isDefaultEligible, isFreshEligible, isStyleDefaultEligible, loadCatalogQuality, loadCatalogQualityFor, parseCatalogQuality, QUALITY_KINDS, type QualityKind, type QualityResult, type QualityRow, qualityKey, styleKey, } from "./catalog-quality.ts";
|
|
1
2
|
export { type Discovery, discoverTemplates, type RootsInput, type ShadowedTemplate, type TemplateCandidate, type TemplateRoot, templateRoots, } from "./discover.ts";
|
|
2
3
|
export { type Instantiated, type InstantiateOptions, instantiate, type VendoredTheme, } from "./instantiate.ts";
|
|
3
4
|
export { type LoadOptions, loadTemplate, resolveThemeFile, SHARED_PREFIX } from "./load.ts";
|
|
4
5
|
export type { LengthClass } from "./pacing.ts";
|
|
5
|
-
export { type BlueprintEntry, DEFAULT_STOPWORDS, entriesOf, filterEntries, type Hit, rankEntries, type SearchFilters, templateLengths, tokenize, WEIGHTS, } from "./search.ts";
|
|
6
|
+
export { type BlueprintEntry, DEFAULT_STOPWORDS, eligibleEntriesOf, entriesOf, filterEntries, type Hit, rankEntries, type SearchFilters, templateLengths, tokenize, WEIGHTS, } from "./search.ts";
|
|
6
7
|
export { compareSemver } from "./semver.ts";
|
|
7
8
|
export type { LoadedTemplate, PlatformFrame, PlatformLookup, ThemeFile } from "./types.ts";
|
|
8
9
|
export { type TemplateReport, type ValidateOptions, validateTemplate } from "./validate.ts";
|
package/dist/templates/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export { blueprintKey, CATALOG_SOURCES, catalogQualityPathFor, EMPTY_QUALITY, isBlueprintFreshEligible, isCatalogSource, isDefaultEligible, isFreshEligible, isStyleDefaultEligible, loadCatalogQuality, loadCatalogQualityFor, parseCatalogQuality, QUALITY_KINDS, qualityKey, styleKey, } from "./catalog-quality.js";
|
|
1
2
|
export { discoverTemplates, templateRoots, } from "./discover.js";
|
|
2
3
|
export { instantiate, } from "./instantiate.js";
|
|
3
4
|
export { loadTemplate, resolveThemeFile, SHARED_PREFIX } from "./load.js";
|
|
4
|
-
export { DEFAULT_STOPWORDS, entriesOf, filterEntries, rankEntries, templateLengths, tokenize, WEIGHTS, } from "./search.js";
|
|
5
|
+
export { DEFAULT_STOPWORDS, eligibleEntriesOf, entriesOf, filterEntries, rankEntries, templateLengths, tokenize, WEIGHTS, } from "./search.js";
|
|
5
6
|
export { compareSemver } from "./semver.js";
|
|
6
7
|
export { validateTemplate } from "./validate.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CatalogQuality } from "./catalog-quality.ts";
|
|
1
2
|
import type { LoadedTemplate } from "./types.ts";
|
|
2
3
|
/** One blueprint flattened with the template data it inherits; the unit that is filtered and ranked. */
|
|
3
4
|
export interface BlueprintEntry {
|
|
@@ -62,3 +63,13 @@ export declare const filterEntries: (entries: readonly BlueprintEntry[], filters
|
|
|
62
63
|
* rest, then higher score, higher tag score, then id order. Entries with no positive match are dropped.
|
|
63
64
|
*/
|
|
64
65
|
export declare const rankEntries: (entries: readonly BlueprintEntry[], query: string, stopwords?: readonly string[]) => Hit[];
|
|
66
|
+
/**
|
|
67
|
+
* S8: the entries discovery may offer. Authored roots (project/env/user) always
|
|
68
|
+
* count; a shipped-catalog blueprint must have a row that says it is fresh-eligible.
|
|
69
|
+
* The catalog row is the only source of that answer — never a nearby theme, tone or
|
|
70
|
+
* the fact that a preset happens to exist.
|
|
71
|
+
*/
|
|
72
|
+
export declare const eligibleEntriesOf: (loaded: readonly {
|
|
73
|
+
readonly template: LoadedTemplate;
|
|
74
|
+
readonly source: string;
|
|
75
|
+
}[], quality: CatalogQuality) => BlueprintEntry[];
|
package/dist/templates/search.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isBlueprintFreshEligible } from "./catalog-quality.js";
|
|
1
2
|
export const WEIGHTS = {
|
|
2
3
|
tag: 3,
|
|
3
4
|
audience: 2,
|
|
@@ -127,3 +128,14 @@ export const rankEntries = (entries, query, stopwords = DEFAULT_STOPWORDS) => {
|
|
|
127
128
|
b.tagScore - a.tagScore ||
|
|
128
129
|
idOf(a.entry).localeCompare(idOf(b.entry)));
|
|
129
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* S8: the entries discovery may offer. Authored roots (project/env/user) always
|
|
133
|
+
* count; a shipped-catalog blueprint must have a row that says it is fresh-eligible.
|
|
134
|
+
* The catalog row is the only source of that answer — never a nearby theme, tone or
|
|
135
|
+
* the fact that a preset happens to exist.
|
|
136
|
+
*/
|
|
137
|
+
export const eligibleEntriesOf = (loaded, quality) => loaded
|
|
138
|
+
.flatMap(({ template, source }) => entriesOf([template]).map((entry) => ({ entry, source })))
|
|
139
|
+
.filter(({ entry, source }) => isBlueprintFreshEligible(quality, source, entry.template, entry.blueprint))
|
|
140
|
+
.map(({ entry }) => entry)
|
|
141
|
+
.sort((a, b) => idOf(a).localeCompare(idOf(b)));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ValidationError } from "@anvpx/motion-schema";
|
|
2
|
+
import { WCAG_AA_TEXT } from "@anvpx/motion-themes";
|
|
3
|
+
export { WCAG_AA_TEXT };
|
|
2
4
|
import type { LintFinding } from "../lint/index.ts";
|
|
3
5
|
import type { LoadedTemplate, PlatformLookup } from "./types.ts";
|
|
4
|
-
export declare const WCAG_AA_TEXT = 4.5;
|
|
5
6
|
/** Rough token estimate: 4 characters per token. */
|
|
6
7
|
export declare const COPY_TOKEN_LIMIT = 300;
|
|
7
8
|
export interface ValidateOptions {
|
|
@@ -2,11 +2,11 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { sceneTypes } from "@anvpx/motion-scenes";
|
|
4
4
|
import { SLOT_TRANSFORMS, STORYBOARD_VERSION, } from "@anvpx/motion-schema";
|
|
5
|
-
import {
|
|
5
|
+
import { resolveTheme, THEME_NAMES, themeAccessibility, WCAG_AA_TEXT } from "@anvpx/motion-themes";
|
|
6
|
+
export { WCAG_AA_TEXT };
|
|
6
7
|
import { discoverFindings } from "./discover-check.js";
|
|
7
8
|
import { slotReferences } from "./expand.js";
|
|
8
9
|
import { instantiate } from "./instantiate.js";
|
|
9
|
-
export const WCAG_AA_TEXT = 4.5;
|
|
10
10
|
/** Rough token estimate: 4 characters per token. */
|
|
11
11
|
export const COPY_TOKEN_LIMIT = 300;
|
|
12
12
|
const err = (path, message, suggestion) => suggestion === undefined ? { path, message } : { path, message, suggestion };
|
|
@@ -38,26 +38,13 @@ const themeErrors = (theme) => {
|
|
|
38
38
|
...sameKeys("durations", resolved.durations, reference.durations),
|
|
39
39
|
...(resolved.chart.length < reference.chart.length ? ["chart needs 8 colours"] : []),
|
|
40
40
|
].map((message) => err(theme.file, message));
|
|
41
|
-
const
|
|
42
|
-
const foreground = resolved.colors[fg];
|
|
43
|
-
const background = resolved.colors[bg];
|
|
44
|
-
if (foreground === undefined || background === undefined) {
|
|
45
|
-
return [err(theme.file, `text pair ${fg}/${bg} names an unknown colour`)];
|
|
46
|
-
}
|
|
47
|
-
const ratio = contrastRatio(foreground, background);
|
|
48
|
-
return ratio >= WCAG_AA_TEXT
|
|
49
|
-
? []
|
|
50
|
-
: [err(theme.file, `${fg} on ${bg} is ${ratio.toFixed(2)}:1, AA needs ${WCAG_AA_TEXT}:1`)];
|
|
51
|
-
});
|
|
52
|
-
const strict = isStrictChart(theme.doc);
|
|
53
|
-
const chart = strict ? [...chartContrastIssues(resolved), ...chartCvdIssues(resolved)] : [];
|
|
41
|
+
const accessibility = themeAccessibility(resolved, theme.doc);
|
|
54
42
|
return [
|
|
55
43
|
...incomplete,
|
|
56
|
-
...
|
|
57
|
-
...chart.map((issue) => err(theme.file, issue.message, "raise the chart foreground/background contrast")),
|
|
44
|
+
...accessibility.errors.map((issue) => err(theme.file, issue.message, issue.suggestion)),
|
|
58
45
|
];
|
|
59
46
|
};
|
|
60
|
-
/**
|
|
47
|
+
/** Accessibility findings that never block come from the shared theme authority. */
|
|
61
48
|
const themeWarnings = (theme) => {
|
|
62
49
|
let resolved;
|
|
63
50
|
try {
|
|
@@ -66,11 +53,7 @@ const themeWarnings = (theme) => {
|
|
|
66
53
|
catch {
|
|
67
54
|
return [];
|
|
68
55
|
}
|
|
69
|
-
|
|
70
|
-
...spacingIssues(resolved),
|
|
71
|
-
...(isStrictChart(theme.doc) ? [] : chartContrastIssues(resolved)),
|
|
72
|
-
];
|
|
73
|
-
return issues.map((issue) => ({
|
|
56
|
+
return themeAccessibility(resolved, theme.doc).warnings.map((issue) => ({
|
|
74
57
|
severity: "warning",
|
|
75
58
|
path: theme.file,
|
|
76
59
|
message: issue.message,
|
package/dist/validate-full.js
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
import { CUSTOM_SCENE_TYPE, getScene, sceneRegistry, sceneTypes } from "@anvpx/motion-scenes";
|
|
2
|
-
import { toJsonPointer, validateStoryboard, } from "@anvpx/motion-schema";
|
|
1
|
+
import { CUSTOM_SCENE_TYPE, classifySceneDir, getScene, sceneRegistry, sceneTypes, } from "@anvpx/motion-scenes";
|
|
2
|
+
import { TargetDeclSchema, toJsonPointer, toValidationError, validateStoryboard, } from "@anvpx/motion-schema";
|
|
3
3
|
const WORD_LIMIT = /^scene has \d+ words/;
|
|
4
|
-
const
|
|
5
|
-
const withSuggestion = (base, suggestion) => suggestion === undefined ? base : { ...base, suggestion };
|
|
6
|
-
const describeIssue = (issue, props) => {
|
|
7
|
-
if (issue.code === "invalid_value") {
|
|
8
|
-
const received = JSON.stringify(valueAt(props, issue.path));
|
|
9
|
-
return { message: `${received} invalid`, suggestion: `use one of: ${issue.values.join("|")}` };
|
|
10
|
-
}
|
|
11
|
-
if (issue.code === "unrecognized_keys") {
|
|
12
|
-
const keys = issue.keys.join(", ");
|
|
13
|
-
return {
|
|
14
|
-
message: `unknown key(s): ${keys}`,
|
|
15
|
-
suggestion: `remove ${keys} (check spelling against the catalog)`,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
if (WORD_LIMIT.test(issue.message)) {
|
|
19
|
-
return { message: issue.message, suggestion: "shorten the text or split into two scenes" };
|
|
20
|
-
}
|
|
21
|
-
return { message: issue.message };
|
|
22
|
-
};
|
|
4
|
+
const WORD_LIMIT_HINT = "shorten the text or split into two scenes";
|
|
23
5
|
const propErrors = (entry, index) => {
|
|
24
6
|
const parsed = getScene(entry.type).configSchema.safeParse(entry.props);
|
|
25
7
|
if (parsed.success)
|
|
26
8
|
return [];
|
|
27
|
-
return parsed.error.issues.map((issue) =>
|
|
28
|
-
const { message, suggestion } = describeIssue(issue, entry.props);
|
|
29
|
-
const path = toJsonPointer(["scenes", index, "props", ...issue.path]);
|
|
30
|
-
return withSuggestion({ path, message }, suggestion);
|
|
31
|
-
});
|
|
9
|
+
return parsed.error.issues.map((issue) => toValidationError(issue, entry.props, WORD_LIMIT.test(issue.message) ? WORD_LIMIT_HINT : undefined, ["scenes", index, "props"]));
|
|
32
10
|
};
|
|
33
11
|
const overlayTypes = () => [...sceneRegistry.values()].filter((plugin) => plugin.layer === "overlay").map((p) => p.type);
|
|
34
12
|
/** An overlay entry needs an overlay plugin and the other way round. */
|
|
@@ -54,15 +32,30 @@ const layerErrors = (entry, index) => {
|
|
|
54
32
|
}
|
|
55
33
|
return [];
|
|
56
34
|
};
|
|
57
|
-
const ABSOLUTE_DIR = /^(?:[a-zA-Z]:|[\\/]|~)/;
|
|
58
|
-
const ESCAPING_DIR = /(^|[\\/])\.\.([\\/]|$)/;
|
|
59
35
|
/**
|
|
60
|
-
* `custom` props: the relative directory holding the scene's three files,
|
|
61
|
-
* `elements` count — how many labelled marks the plate draws
|
|
62
|
-
*
|
|
63
|
-
*
|
|
36
|
+
* `custom` props: the relative directory holding the scene's three files, the declared
|
|
37
|
+
* `elements` count — how many labelled marks the plate draws — and the optional `targets` an
|
|
38
|
+
* interaction transcript may address. The count is declared because an authored scene's copy
|
|
39
|
+
* lives in its own files, so no validator can see it; the density rule needs the number to
|
|
40
|
+
* judge a plate at all.
|
|
64
41
|
*/
|
|
65
|
-
const CUSTOM_PROP_KEYS = new Set(["dir", "elements"]);
|
|
42
|
+
const CUSTOM_PROP_KEYS = new Set(["dir", "elements", "targets"]);
|
|
43
|
+
/** Transcript targets must be declared as `{ id, role }` with slug ids. */
|
|
44
|
+
const targetsOf = (props, index) => {
|
|
45
|
+
const targets = props.targets;
|
|
46
|
+
if (targets === undefined ||
|
|
47
|
+
(Array.isArray(targets) &&
|
|
48
|
+
targets.every((target) => TargetDeclSchema.safeParse(target).success))) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
path: toJsonPointer(["scenes", index, "props", "targets"]),
|
|
54
|
+
message: "targets must be an array of { id, role } with slug ids",
|
|
55
|
+
suggestion: 'for example: [{ "id": "cta", "role": "button" }]',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
};
|
|
66
59
|
const customErrors = (entry, index) => {
|
|
67
60
|
const props = entry.props;
|
|
68
61
|
const unknown = Object.keys(props).filter((key) => !CUSTOM_PROP_KEYS.has(key));
|
|
@@ -86,6 +79,9 @@ const customErrors = (entry, index) => {
|
|
|
86
79
|
},
|
|
87
80
|
];
|
|
88
81
|
}
|
|
82
|
+
const targetErrors = targetsOf(props, index);
|
|
83
|
+
if (targetErrors.length > 0)
|
|
84
|
+
return targetErrors;
|
|
89
85
|
const dir = props.dir;
|
|
90
86
|
if (typeof dir !== "string" || dir.trim() === "") {
|
|
91
87
|
return [
|
|
@@ -96,25 +92,22 @@ const customErrors = (entry, index) => {
|
|
|
96
92
|
},
|
|
97
93
|
];
|
|
98
94
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
const verdict = classifySceneDir(dir);
|
|
96
|
+
if (verdict.inside)
|
|
97
|
+
return [];
|
|
98
|
+
return [
|
|
99
|
+
verdict.reason === "absolute"
|
|
100
|
+
? {
|
|
102
101
|
path: toJsonPointer(["scenes", index, "props", "dir"]),
|
|
103
102
|
message: "props.dir must be relative",
|
|
104
103
|
suggestion: "use a path inside the storyboard's directory",
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
if (ESCAPING_DIR.test(dir)) {
|
|
109
|
-
return [
|
|
110
|
-
{
|
|
104
|
+
}
|
|
105
|
+
: {
|
|
111
106
|
path: toJsonPointer(["scenes", index, "props", "dir"]),
|
|
112
107
|
message: "props.dir escapes the storyboard directory",
|
|
113
108
|
suggestion: "keep the scene beside the storyboard",
|
|
114
109
|
},
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
return [];
|
|
110
|
+
];
|
|
118
111
|
};
|
|
119
112
|
const sceneErrors = (entry, index) => {
|
|
120
113
|
if (entry.type === CUSTOM_SCENE_TYPE) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Interaction, type Storyboard, type ValidationError } from "@anvpx/motion-schema";
|
|
2
|
+
/**
|
|
3
|
+
* A transcript may only address what the storyboard actually contains (ADR-0013 §4).
|
|
4
|
+
* This is validated when a transcript is present — never a new lint rule — and reports
|
|
5
|
+
* transcript-relative JSON pointers so a recorder can point at the offending event.
|
|
6
|
+
*/
|
|
7
|
+
export declare const validateInteraction: (board: Storyboard, interaction: Interaction) => readonly ValidationError[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { declaredTargetIds, toJsonPointer, } from "@anvpx/motion-schema";
|
|
2
|
+
/**
|
|
3
|
+
* A transcript may only address what the storyboard actually contains (ADR-0013 §4).
|
|
4
|
+
* This is validated when a transcript is present — never a new lint rule — and reports
|
|
5
|
+
* transcript-relative JSON pointers so a recorder can point at the offending event.
|
|
6
|
+
*/
|
|
7
|
+
export const validateInteraction = (board, interaction) => {
|
|
8
|
+
const errors = [];
|
|
9
|
+
const sceneIds = board.scenes.map((scene) => scene.id);
|
|
10
|
+
interaction.events.forEach((event, index) => {
|
|
11
|
+
const sceneIndex = sceneIds.indexOf(event.scene);
|
|
12
|
+
if (sceneIndex < 0) {
|
|
13
|
+
errors.push({
|
|
14
|
+
path: toJsonPointer(["events", index, "scene"]),
|
|
15
|
+
message: `scene "${event.scene}" is not in the storyboard`,
|
|
16
|
+
suggestion: `use one of: ${sceneIds.join("|")}`,
|
|
17
|
+
});
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const targets = declaredTargetIds(board.scenes[sceneIndex]?.props);
|
|
21
|
+
if (!targets.includes(event.target)) {
|
|
22
|
+
errors.push({
|
|
23
|
+
path: toJsonPointer(["events", index, "target"]),
|
|
24
|
+
message: `target "${event.target}" is not declared by scene "${event.scene}"`,
|
|
25
|
+
suggestion: targets.length === 0
|
|
26
|
+
? `declare "${event.target}" in that scene's props.targets`
|
|
27
|
+
: `declare it in props.targets, or use one of: ${targets.join("|")}`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return errors;
|
|
32
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic raster grain that survives the H.264 delivery chain.
|
|
3
|
+
*
|
|
4
|
+
* HyperFrames writes the master picture; this module builds the ffmpeg argv for a
|
|
5
|
+
* single re-encode that bakes fixed-seed film grain into the pixels. It is a pure
|
|
6
|
+
* function of its inputs: no clock, no randomness, no environment. The mix and
|
|
7
|
+
* loudnorm steps copy the video stream, so grain applied here is present in the
|
|
8
|
+
* delivered mp4 unchanged.
|
|
9
|
+
*/
|
|
10
|
+
/** Fixed seed — the same frame always receives the same grain. */
|
|
11
|
+
export declare const GRAIN_SEED = 1337;
|
|
12
|
+
/** Subtle paper-tooth amplitude (noise `alls`): low enough not to read as TV snow. */
|
|
13
|
+
export declare const GRAIN_STRENGTH = 7;
|
|
14
|
+
/** The exact noise filter: uniform form with a per-frame temporal reseed, fixed seed. */
|
|
15
|
+
export declare const GRAIN_FILTER = "noise=alls=7:allf=t+u:all_seed=1337";
|
|
16
|
+
/** Stable descriptor recorded in the render manifest (a code constant, not input). */
|
|
17
|
+
export declare const GRAIN_DESCRIPTOR = "noise:alls=7:allf=t+u:seed=1337";
|
|
18
|
+
/** Intermediate written by the grain pass before it replaces the master. */
|
|
19
|
+
export declare const GRAIN_TEMP = "final-grain.mp4";
|
|
20
|
+
/** The optional delivery lens. `off` is the default and keeps today's exact bytes. */
|
|
21
|
+
export declare const LENS_OFF = "off";
|
|
22
|
+
export declare const LENS_FILM_HALO = "film-halo";
|
|
23
|
+
export type Lens = typeof LENS_OFF | typeof LENS_FILM_HALO;
|
|
24
|
+
export declare const DEFAULT_LENS: Lens;
|
|
25
|
+
/** The single frozen §5.1 filter_complex; the fixed noise filter is its last node. */
|
|
26
|
+
export declare const FILM_HALO_FILTER: string;
|
|
27
|
+
/** Manifest descriptor extended with the active lens: `off` stays byte-identical. */
|
|
28
|
+
export declare function grainDescriptor(lens?: Lens): string;
|
|
29
|
+
/**
|
|
30
|
+
* Builds the deterministic grain argv. Frame rate, frame count, duration, codec
|
|
31
|
+
* family and pixel format are preserved so `mk verify` / finalExpectation still
|
|
32
|
+
* pass. The encode is lossless (CRF 0): a lossy re-encode reconstructs the static
|
|
33
|
+
* fixed-seed grain with a different quantisation phase at each H.264 I-frame,
|
|
34
|
+
* reseeding the whole field by +/-1 LSB (the G-08 frame-500 pop). CRF 0 keeps
|
|
35
|
+
* I-frames and P-frames bit-identical; the tradeoff is a larger delivered mp4.
|
|
36
|
+
*
|
|
37
|
+
* `lens=off` (the default) is today's exact `-vf noise=` argv. `film-halo`
|
|
38
|
+
* replaces that single filter with the frozen §5.1 `filter_complex` inside this
|
|
39
|
+
* same ffmpeg invocation — one renderer, one encode, one source of truth.
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildGrainArgs(input: string, output: string, fps: string | number, lens?: Lens): string[];
|
|
42
|
+
/**
|
|
43
|
+
* High-pass energy of an 8-bit gray plane: mean squared deviation of each
|
|
44
|
+
* interior pixel from the average of its horizontal neighbours. A flat field is
|
|
45
|
+
* ~0; added grain raises it. Pure over the buffer — no I/O, no randomness.
|
|
46
|
+
*/
|
|
47
|
+
export declare function grainEnergy(gray: Uint8Array, width: number): number;
|