@anvpx/motion-build 0.1.56 → 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 +29 -11
- package/dist/audio/mix.js +79 -17
- 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/index-html.js +3 -0
- 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.d.ts +17 -0
- package/dist/lint/beat-variety.js +92 -0
- package/dist/lint/custom-source.d.ts +6 -0
- package/dist/lint/custom-source.js +201 -6
- package/dist/lint/index.d.ts +4 -1
- package/dist/lint/index.js +9 -1
- package/dist/lint/visual-variety.d.ts +16 -0
- package/dist/lint/visual-variety.js +72 -0
- package/dist/lint/world-stops.d.ts +11 -0
- package/dist/lint/world-stops.js +39 -0
- 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,72 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
6
|
+
*/
|
|
7
|
+
const VISUAL_FORMS = new Set([
|
|
8
|
+
"scene3d",
|
|
9
|
+
"media-frame",
|
|
10
|
+
"kinetic",
|
|
11
|
+
"stair",
|
|
12
|
+
"code",
|
|
13
|
+
"waveform",
|
|
14
|
+
"sticker",
|
|
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",
|
|
27
|
+
]);
|
|
28
|
+
/** Concrete forms the author can reach for, named in the suggestion. */
|
|
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");
|
|
33
|
+
/**
|
|
34
|
+
* A film long enough to establish a visual language must show one: at least a
|
|
35
|
+
* third of the base beats are visual-bearing (`design-taste.md` law 1). This is a
|
|
36
|
+
* board-level rule on purpose — it judges the film's visual vocabulary, not any
|
|
37
|
+
* single frame — so it fires once, not per scene.
|
|
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
|
+
*
|
|
44
|
+
* Overlays never carry the visual language of the film, so they neither count
|
|
45
|
+
* as base beats nor satisfy the rule.
|
|
46
|
+
*/
|
|
47
|
+
export const visualVarietyRule = ({ storyboard }) => {
|
|
48
|
+
const base = storyboard.scenes.filter((scene) => scene.layer !== "overlay");
|
|
49
|
+
if (base.length < 4)
|
|
50
|
+
return [];
|
|
51
|
+
const visual = base.filter((scene) => VISUAL_FORMS.has(scene.type)).length;
|
|
52
|
+
const need = Math.ceil(base.length / 3);
|
|
53
|
+
if (visual >= need)
|
|
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
|
+
];
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
severity: "warning",
|
|
67
|
+
path: "/scenes",
|
|
68
|
+
message: `${visual} of ${base.length} base scenes visual-bearing; at least ${need} needed: the film reads as a slide deck`,
|
|
69
|
+
suggestion: `give another base beat a visual form (${FORMS}), or cut the board down; see references/visual-forms.md`,
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LintRule } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* World stops share one lit path across the ground: posts spread over a fixed
|
|
4
|
+
* span, so long labels collide. Heuristic guardrail from two observed boards:
|
|
5
|
+
* four stops at ~20 chars each overlapped with zero warnings, while three
|
|
6
|
+
* stops at ~14 chars each read clean. Schema caps each stop at 40 chars, which
|
|
7
|
+
* still collides at 4 stops, so this rule judges the total, not the cap.
|
|
8
|
+
*/
|
|
9
|
+
export declare const WORLD_STOP_SINGLE_MAX = 30;
|
|
10
|
+
export declare const WORLD_STOPS_TOTAL_MAX = 60;
|
|
11
|
+
export declare const worldStopsRule: LintRule;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* World stops share one lit path across the ground: posts spread over a fixed
|
|
3
|
+
* span, so long labels collide. Heuristic guardrail from two observed boards:
|
|
4
|
+
* four stops at ~20 chars each overlapped with zero warnings, while three
|
|
5
|
+
* stops at ~14 chars each read clean. Schema caps each stop at 40 chars, which
|
|
6
|
+
* still collides at 4 stops, so this rule judges the total, not the cap.
|
|
7
|
+
*/
|
|
8
|
+
export const WORLD_STOP_SINGLE_MAX = 30;
|
|
9
|
+
export const WORLD_STOPS_TOTAL_MAX = 60;
|
|
10
|
+
export const worldStopsRule = ({ storyboard }) => {
|
|
11
|
+
const findings = [];
|
|
12
|
+
storyboard.scenes.forEach((scene, index) => {
|
|
13
|
+
if (scene.type !== "world" || scene.layer === "overlay")
|
|
14
|
+
return;
|
|
15
|
+
const props = (scene.props ?? {});
|
|
16
|
+
if (!Array.isArray(props.stops))
|
|
17
|
+
return;
|
|
18
|
+
// Type errors belong to the schema (stops must be strings <= 40 chars);
|
|
19
|
+
// this rule judges layout only and stays quiet on malformed props.
|
|
20
|
+
if (props.stops.some((stop) => typeof stop !== "string"))
|
|
21
|
+
return;
|
|
22
|
+
const labels = props.stops;
|
|
23
|
+
if (labels.length === 0)
|
|
24
|
+
return;
|
|
25
|
+
const total = labels.reduce((sum, label) => sum + label.length, 0);
|
|
26
|
+
const long = labels.findIndex((label) => label.length > WORLD_STOP_SINGLE_MAX);
|
|
27
|
+
if (long === -1 && total <= WORLD_STOPS_TOTAL_MAX)
|
|
28
|
+
return;
|
|
29
|
+
findings.push({
|
|
30
|
+
severity: "warning",
|
|
31
|
+
path: `/scenes/${index}/props/stops`,
|
|
32
|
+
message: long === -1
|
|
33
|
+
? `world stops total ${total} chars across ${labels.length} posts: labels collide on the path`
|
|
34
|
+
: `world stop ${long + 1} is ${labels[long]?.length ?? 0} chars: a post label that long overlaps its neighbour`,
|
|
35
|
+
suggestion: "shorten each stop to ~12 chars or drop to fewer stops; see references/world-design.md",
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return findings;
|
|
39
|
+
};
|
|
@@ -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;
|
|
@@ -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,
|