@neatico/visual-core 0.14.2 → 0.14.26
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/cjs/composition.js +62 -36
- package/dist/cjs/compositionScenes.js +91 -38
- package/dist/cjs/content.js +538 -120
- package/dist/cjs/designBlueprint.js +94 -19
- package/dist/cjs/designSystem.js +464 -77
- package/dist/cjs/editorial.js +76 -20
- package/dist/cjs/fontCatalog.js +75 -23
- package/dist/cjs/layoutContracts.js +57 -11
- package/dist/cjs/layouts.js +5 -92
- package/dist/cjs/pagination.js +16 -5
- package/dist/cjs/socialLayouts.js +127 -387
- package/dist/cjs/text.js +12 -2
- package/dist/composition.d.ts +4 -4
- package/dist/composition.js +62 -36
- package/dist/compositionScenes.d.ts +2 -2
- package/dist/compositionScenes.js +91 -38
- package/dist/content.d.ts +55 -20
- package/dist/content.js +539 -121
- package/dist/designBlueprint.d.ts +4 -4
- package/dist/designBlueprint.js +95 -20
- package/dist/designSystem.d.ts +11 -7
- package/dist/designSystem.js +465 -79
- package/dist/editorial.d.ts +1 -1
- package/dist/editorial.js +77 -21
- package/dist/fontCatalog.d.ts +1 -1
- package/dist/fontCatalog.js +75 -23
- package/dist/layoutContracts.d.ts +3 -3
- package/dist/layoutContracts.js +58 -12
- package/dist/layouts.d.ts +2 -2
- package/dist/layouts.js +5 -92
- package/dist/pagination.js +16 -5
- package/dist/socialLayouts.d.ts +40 -232
- package/dist/socialLayouts.js +127 -387
- package/dist/text.js +12 -2
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ContentPage, type SemanticKind } from
|
|
1
|
+
import { type ContentPage, type SemanticKind } from "./content.js";
|
|
2
2
|
export interface DesignBlueprint {
|
|
3
3
|
version: 2;
|
|
4
4
|
id: string;
|
|
@@ -11,14 +11,14 @@ export interface DesignBlueprint {
|
|
|
11
11
|
maxBlocks: number;
|
|
12
12
|
};
|
|
13
13
|
layout: {
|
|
14
|
-
mode:
|
|
14
|
+
mode: "stack" | "split" | "editorial";
|
|
15
15
|
margin: number;
|
|
16
16
|
gap: number;
|
|
17
17
|
titleScale: number;
|
|
18
18
|
bodyScale: number;
|
|
19
19
|
columns: number;
|
|
20
|
-
surface:
|
|
21
|
-
accent:
|
|
20
|
+
surface: "none" | "panels" | "bands";
|
|
21
|
+
accent: "none" | "rail" | "rule";
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
export declare const DESIGN_SAMPLE_LOCALES: readonly ["en-US", "zh-CH", "ja-JP", "de-DE", "fr-FR", "es-ES", "pt-PT"];
|
package/dist/designBlueprint.js
CHANGED
|
@@ -1,29 +1,104 @@
|
|
|
1
|
-
import { contentBlockText } from
|
|
2
|
-
export const DESIGN_SAMPLE_LOCALES = [
|
|
1
|
+
import { contentBlockText, } from "./content.js";
|
|
2
|
+
export const DESIGN_SAMPLE_LOCALES = [
|
|
3
|
+
"en-US",
|
|
4
|
+
"zh-CH",
|
|
5
|
+
"ja-JP",
|
|
6
|
+
"de-DE",
|
|
7
|
+
"fr-FR",
|
|
8
|
+
"es-ES",
|
|
9
|
+
"pt-PT",
|
|
10
|
+
];
|
|
3
11
|
export function validateDesignBlueprint(raw) {
|
|
4
12
|
const v = raw;
|
|
5
|
-
if (!v ||
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
throw new Error(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (!v ||
|
|
14
|
+
v.version !== 2 ||
|
|
15
|
+
typeof v.id !== "string" ||
|
|
16
|
+
!/^[a-z][a-z0-9-]{0,79}$/.test(v.id))
|
|
17
|
+
throw new Error("DESIGN_BLUEPRINT_ID");
|
|
18
|
+
const kinds = [
|
|
19
|
+
"paragraph",
|
|
20
|
+
"steps",
|
|
21
|
+
"features",
|
|
22
|
+
"comparison",
|
|
23
|
+
"code",
|
|
24
|
+
"parameters",
|
|
25
|
+
"quote",
|
|
26
|
+
"chart",
|
|
27
|
+
"image",
|
|
28
|
+
];
|
|
29
|
+
if (!Array.isArray(v.kinds) ||
|
|
30
|
+
!v.kinds.length ||
|
|
31
|
+
v.kinds.length > 9 ||
|
|
32
|
+
v.kinds.some((k) => !kinds.includes(k)))
|
|
33
|
+
throw new Error("DESIGN_BLUEPRINT_KINDS");
|
|
34
|
+
if (!v.labels ||
|
|
35
|
+
typeof v.labels !== "object" ||
|
|
36
|
+
Array.isArray(v.labels) ||
|
|
37
|
+
typeof v.labels.en !== "string" ||
|
|
38
|
+
!v.labels.en.trim() ||
|
|
39
|
+
Object.entries(v.labels).some(([key, value]) => !/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(key) ||
|
|
40
|
+
typeof value !== "string" ||
|
|
41
|
+
!value.trim() ||
|
|
42
|
+
value.length > 120))
|
|
43
|
+
throw new Error("DESIGN_BLUEPRINT_LABELS");
|
|
44
|
+
if (!Array.isArray(v.ratios) ||
|
|
45
|
+
!v.ratios.length ||
|
|
46
|
+
v.ratios.length > 8 ||
|
|
47
|
+
v.ratios.some((n) => !Number.isFinite(n) || n < 0.25 || n > 4))
|
|
48
|
+
throw new Error("DESIGN_BLUEPRINT_RATIOS");
|
|
49
|
+
const number = (n, min, max) => {
|
|
50
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n < min || n > max)
|
|
51
|
+
throw new Error("DESIGN_BLUEPRINT_RANGE");
|
|
52
|
+
return n;
|
|
53
|
+
};
|
|
16
54
|
const c = v.capacity, l = v.layout;
|
|
17
55
|
if (!c || !l)
|
|
18
|
-
throw new Error(
|
|
19
|
-
if (![
|
|
20
|
-
|
|
56
|
+
throw new Error("DESIGN_BLUEPRINT_MISSING");
|
|
57
|
+
if (!["stack", "split", "editorial"].includes(l.mode) ||
|
|
58
|
+
!["none", "panels", "bands"].includes(l.surface) ||
|
|
59
|
+
!["none", "rail", "rule"].includes(l.accent))
|
|
60
|
+
throw new Error("DESIGN_BLUEPRINT_LAYOUT");
|
|
21
61
|
const maxEntries = number(c.maxEntries, 1, 20), maxBlocks = number(c.maxBlocks, 1, 8), columns = number(l.columns, 1, 4);
|
|
22
62
|
if (![maxEntries, maxBlocks, columns].every(Number.isInteger))
|
|
23
|
-
throw new Error(
|
|
24
|
-
return {
|
|
63
|
+
throw new Error("DESIGN_BLUEPRINT_INTEGER");
|
|
64
|
+
return {
|
|
65
|
+
version: 2,
|
|
66
|
+
id: v.id,
|
|
67
|
+
labels: { ...v.labels },
|
|
68
|
+
kinds: [...new Set(v.kinds)],
|
|
69
|
+
ratios: [...new Set(v.ratios)],
|
|
70
|
+
capacity: {
|
|
71
|
+
maxCharacters: number(c.maxCharacters, 40, 20000),
|
|
72
|
+
maxEntries,
|
|
73
|
+
maxBlocks,
|
|
74
|
+
},
|
|
75
|
+
layout: {
|
|
76
|
+
mode: l.mode,
|
|
77
|
+
margin: number(l.margin, 32, 80),
|
|
78
|
+
gap: number(l.gap, 12, 40),
|
|
79
|
+
titleScale: number(l.titleScale, 0.8, 1.15),
|
|
80
|
+
bodyScale: number(l.bodyScale, 0.9, 1.15),
|
|
81
|
+
columns,
|
|
82
|
+
surface: l.surface,
|
|
83
|
+
accent: l.accent,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
25
86
|
}
|
|
26
87
|
export function blueprintFitsContent(blueprint, page, ratio) {
|
|
27
|
-
const entries = page.blocks.reduce((sum, b) => sum +
|
|
28
|
-
|
|
88
|
+
const entries = page.blocks.reduce((sum, b) => sum +
|
|
89
|
+
("entries" in b
|
|
90
|
+
? b.entries.length
|
|
91
|
+
: "columns" in b
|
|
92
|
+
? b.columns.length
|
|
93
|
+
: "rows" in b
|
|
94
|
+
? b.rows.length
|
|
95
|
+
: "values" in b
|
|
96
|
+
? b.values.length
|
|
97
|
+
: 0), 0);
|
|
98
|
+
return (blueprint.ratios.some((r) => Math.abs(r - ratio) < 0.001) &&
|
|
99
|
+
page.blocks.length <= blueprint.capacity.maxBlocks &&
|
|
100
|
+
page.blocks.every((b) => blueprint.kinds.includes(b.kind)) &&
|
|
101
|
+
page.blocks.flatMap(contentBlockText).join("").length <=
|
|
102
|
+
blueprint.capacity.maxCharacters &&
|
|
103
|
+
entries <= blueprint.capacity.maxEntries);
|
|
29
104
|
}
|
package/dist/designSystem.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ContentPage, type SemanticKind } from
|
|
1
|
+
import { type ContentPage, type SemanticKind } from "./content.js";
|
|
2
2
|
export interface DesignTheme {
|
|
3
3
|
id: string;
|
|
4
4
|
palette: {
|
|
@@ -18,7 +18,7 @@ export interface DesignTheme {
|
|
|
18
18
|
geometry: {
|
|
19
19
|
radius: number;
|
|
20
20
|
spacing: number;
|
|
21
|
-
rule:
|
|
21
|
+
rule: "none" | "hairline" | "accent";
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
/** Complete, deterministic token sets; decorative geometry belongs to individual compositions. */
|
|
@@ -26,8 +26,8 @@ export declare const DESIGN_THEMES: readonly DesignTheme[];
|
|
|
26
26
|
export declare function designTheme(id: string): DesignTheme;
|
|
27
27
|
export interface DesignRecipe {
|
|
28
28
|
id: string;
|
|
29
|
-
renderer:
|
|
30
|
-
kind:
|
|
29
|
+
renderer: "catalog" | "semantic";
|
|
30
|
+
kind: "presentation" | "social";
|
|
31
31
|
family: string;
|
|
32
32
|
accepts: readonly SemanticKind[];
|
|
33
33
|
minEntries: number;
|
|
@@ -35,12 +35,16 @@ export interface DesignRecipe {
|
|
|
35
35
|
requiresImage: boolean;
|
|
36
36
|
/** Unmodelled domain-specific catalogs remain manual-only until their required evidence is expressible. */
|
|
37
37
|
automatic?: boolean;
|
|
38
|
+
scenes?: readonly string[];
|
|
39
|
+
manualReason?: string;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
export declare const MANUAL_COMPOSITION_REASONS: Readonly<Record<string, string>>;
|
|
42
|
+
/** Stable aliases keep saved documents readable while excluding duplicate candidates. */
|
|
43
|
+
export declare function canonicalRecipeId(id: string, kind: DesignRecipe["kind"]): string;
|
|
44
|
+
export declare const DESIGN_RECIPES: DesignRecipe[];
|
|
41
45
|
export declare function pageEntryCount(page: ContentPage): number;
|
|
42
46
|
export interface CandidateContext {
|
|
43
|
-
kind: DesignRecipe[
|
|
47
|
+
kind: DesignRecipe["kind"];
|
|
44
48
|
ratio: number;
|
|
45
49
|
previousFamilies?: readonly string[];
|
|
46
50
|
excluded?: readonly string[];
|