@spectratools/graphic-designer-cli 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +65 -136
- package/dist/index.d.ts +156 -2
- package/dist/index.js +65 -136
- package/dist/publish/index.d.ts +38 -9
- package/dist/publish/index.js +62 -130
- package/dist/qa.d.ts +25 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/{spec.schema-BxXBTOn-.d.ts → spec.schema-DhAI-tE8.d.ts} +164 -20
- package/dist/spec.schema.d.ts +1 -1
- package/package.json +3 -2
package/dist/qa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RenderMetadata, D as DesignSpec } from './spec.schema-
|
|
1
|
+
import { R as RenderMetadata, D as DesignSpec } from './spec.schema-DhAI-tE8.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@napi-rs/canvas';
|
|
4
4
|
|
|
@@ -28,7 +28,31 @@ type QaReport = {
|
|
|
28
28
|
};
|
|
29
29
|
issues: QaIssue[];
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Read and parse a sidecar `.meta.json` file produced by
|
|
33
|
+
* {@link writeRenderArtifacts}.
|
|
34
|
+
*
|
|
35
|
+
* @param path - Absolute or relative path to the `.meta.json` sidecar file.
|
|
36
|
+
* @returns The parsed {@link RenderMetadata} object.
|
|
37
|
+
*/
|
|
31
38
|
declare function readMetadata(path: string): Promise<RenderMetadata>;
|
|
39
|
+
/**
|
|
40
|
+
* Run quality-assurance checks on a rendered design image.
|
|
41
|
+
*
|
|
42
|
+
* Validates the rendered PNG against the source spec and optional metadata.
|
|
43
|
+
* Checks include: dimension matching, element clipping against the safe frame,
|
|
44
|
+
* element overlap detection, WCAG contrast ratio, footer spacing, text
|
|
45
|
+
* truncation, and draw-command bounds.
|
|
46
|
+
*
|
|
47
|
+
* @param options - QA configuration.
|
|
48
|
+
* @param options.imagePath - Path to the rendered PNG image to validate.
|
|
49
|
+
* @param options.spec - The {@link DesignSpec} used to produce the image.
|
|
50
|
+
* @param options.metadata - Optional {@link RenderMetadata} from the render
|
|
51
|
+
* pass. When provided, layout-level checks (overlap, clipping, contrast) are
|
|
52
|
+
* performed against the element positions recorded in the metadata.
|
|
53
|
+
* @returns A {@link QaReport} summarising whether the image passes and listing
|
|
54
|
+
* any issues found.
|
|
55
|
+
*/
|
|
32
56
|
declare function runQa(options: {
|
|
33
57
|
imagePath: string;
|
|
34
58
|
spec: DesignSpec;
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { h as DEFAULT_GENERATOR_VERSION, z as LayoutSnapshot, a as Rect, R as RenderMetadata, J as RenderResult, d as RenderedElement, W as WrittenArtifacts, X as computeSpecHash, a9 as inferSidecarPath, ab as renderDesign, ad as writeRenderArtifacts } from './spec.schema-
|
|
1
|
+
export { h as DEFAULT_GENERATOR_VERSION, z as LayoutSnapshot, a as Rect, R as RenderMetadata, J as RenderResult, d as RenderedElement, W as WrittenArtifacts, X as computeSpecHash, a9 as inferSidecarPath, ab as renderDesign, ad as writeRenderArtifacts } from './spec.schema-DhAI-tE8.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@napi-rs/canvas';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { SKRSContext2D } from '@napi-rs/canvas';
|
|
3
3
|
|
|
4
|
+
/** Default generator version stamped into render metadata when none is provided. */
|
|
4
5
|
declare const DEFAULT_GENERATOR_VERSION = "0.2.0";
|
|
5
6
|
type Rect = {
|
|
6
7
|
x: number;
|
|
@@ -44,12 +45,64 @@ type WrittenArtifacts = {
|
|
|
44
45
|
metadataPath: string;
|
|
45
46
|
metadata: RenderMetadata;
|
|
46
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Compute a deterministic SHA-256 hash of a design spec.
|
|
50
|
+
*
|
|
51
|
+
* The spec is serialised to canonical JSON (sorted keys, no whitespace) before
|
|
52
|
+
* hashing, so two structurally identical specs always produce the same hash
|
|
53
|
+
* regardless of property order.
|
|
54
|
+
*
|
|
55
|
+
* @param spec - The parsed design spec to hash.
|
|
56
|
+
* @returns A lowercase hex-encoded SHA-256 digest string.
|
|
57
|
+
*/
|
|
47
58
|
declare function computeSpecHash(spec: DesignSpec): string;
|
|
59
|
+
/**
|
|
60
|
+
* Render a design spec to a PNG image buffer and accompanying metadata.
|
|
61
|
+
*
|
|
62
|
+
* This is the main entry point for the graphic-designer rendering pipeline.
|
|
63
|
+
* Fonts are loaded automatically (via {@link loadFonts}), the spec is validated
|
|
64
|
+
* and parsed, layout is computed, and all elements are drawn onto an
|
|
65
|
+
* off-screen canvas backed by `@napi-rs/canvas`.
|
|
66
|
+
*
|
|
67
|
+
* @param input - A raw or parsed {@link DesignSpec} object. It will be
|
|
68
|
+
* validated through Zod before rendering.
|
|
69
|
+
* @param options - Optional overrides for metadata fields.
|
|
70
|
+
* @param options.generatorVersion - Semantic version stamped into metadata.
|
|
71
|
+
* Defaults to {@link DEFAULT_GENERATOR_VERSION}.
|
|
72
|
+
* @param options.renderedAt - ISO-8601 timestamp for the render. Defaults to
|
|
73
|
+
* `new Date().toISOString()`.
|
|
74
|
+
* @returns A {@link RenderResult} containing the PNG buffer and full render
|
|
75
|
+
* metadata (spec hash, artifact hash, layout snapshot, etc.).
|
|
76
|
+
*/
|
|
48
77
|
declare function renderDesign(input: DesignSpec, options?: {
|
|
49
78
|
generatorVersion?: string;
|
|
50
79
|
renderedAt?: string;
|
|
51
80
|
}): Promise<RenderResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Write a render result to disk as a PNG image and a sidecar `.meta.json` file.
|
|
83
|
+
*
|
|
84
|
+
* If {@link out} points to a `.png` file the metadata file is placed alongside
|
|
85
|
+
* it with a `.meta.json` extension. If {@link out} is a directory, both files
|
|
86
|
+
* are named after the deterministic artifact base name derived from the spec
|
|
87
|
+
* hash and generator version.
|
|
88
|
+
*
|
|
89
|
+
* Parent directories are created recursively when they do not exist.
|
|
90
|
+
*
|
|
91
|
+
* @param result - The {@link RenderResult} returned by {@link renderDesign}.
|
|
92
|
+
* @param out - Destination path — either a `.png` file path or a directory.
|
|
93
|
+
* @returns A {@link WrittenArtifacts} object with the resolved file paths and
|
|
94
|
+
* metadata.
|
|
95
|
+
*/
|
|
52
96
|
declare function writeRenderArtifacts(result: RenderResult, out: string): Promise<WrittenArtifacts>;
|
|
97
|
+
/**
|
|
98
|
+
* Infer the conventional sidecar metadata path for a rendered image.
|
|
99
|
+
*
|
|
100
|
+
* For `.png` files the extension is replaced with `.meta.json`. For all other
|
|
101
|
+
* paths `.meta.json` is appended to the basename.
|
|
102
|
+
*
|
|
103
|
+
* @param imagePath - Absolute or relative path to the rendered image file.
|
|
104
|
+
* @returns The resolved path to the expected `.meta.json` sidecar file.
|
|
105
|
+
*/
|
|
53
106
|
declare function inferSidecarPath(imagePath: string): string;
|
|
54
107
|
|
|
55
108
|
type GradientStop$1 = {
|
|
@@ -66,9 +119,56 @@ type RadialGradientSpec = {
|
|
|
66
119
|
stops: GradientStop$1[];
|
|
67
120
|
};
|
|
68
121
|
type GradientSpec = LinearGradientSpec | RadialGradientSpec;
|
|
122
|
+
/** Default seven-colour rainbow palette used by {@link drawRainbowRule} when no custom colours are provided. */
|
|
69
123
|
declare const DEFAULT_RAINBOW_COLORS: readonly ["#FF6B6B", "#FFA94D", "#FFD43B", "#69DB7C", "#4DABF7", "#9775FA", "#DA77F2"];
|
|
124
|
+
/**
|
|
125
|
+
* Fill a rectangle with a linear or radial gradient.
|
|
126
|
+
*
|
|
127
|
+
* Supports optional rounded corners via {@link borderRadius}. Linear gradients
|
|
128
|
+
* are rotated around the rectangle's centre according to the spec's `angle`
|
|
129
|
+
* field; radial gradients originate from the centre.
|
|
130
|
+
*
|
|
131
|
+
* @param ctx - The `@napi-rs/canvas` 2D rendering context.
|
|
132
|
+
* @param rect - The target {@link Rect} to fill.
|
|
133
|
+
* @param gradient - A {@link GradientSpec} describing the gradient type, angle
|
|
134
|
+
* (for linear), and colour stops.
|
|
135
|
+
* @param borderRadius - Corner radius in pixels. Defaults to `0` (sharp
|
|
136
|
+
* corners).
|
|
137
|
+
*/
|
|
70
138
|
declare function drawGradientRect(ctx: SKRSContext2D, rect: Rect, gradient: GradientSpec, borderRadius?: number): void;
|
|
139
|
+
/**
|
|
140
|
+
* Draw a horizontal rainbow gradient rule (decorative divider line).
|
|
141
|
+
*
|
|
142
|
+
* The rule is centred vertically on {@link y} and spans from {@link x} to
|
|
143
|
+
* `x + width`. When fewer than two colours are supplied the
|
|
144
|
+
* {@link DEFAULT_RAINBOW_COLORS} palette is used as a fallback.
|
|
145
|
+
*
|
|
146
|
+
* @param ctx - The `@napi-rs/canvas` 2D rendering context.
|
|
147
|
+
* @param x - Left edge x-coordinate.
|
|
148
|
+
* @param y - Vertical centre y-coordinate of the rule.
|
|
149
|
+
* @param width - Horizontal width in pixels.
|
|
150
|
+
* @param thickness - Rule thickness in pixels. Defaults to `2`.
|
|
151
|
+
* @param colors - Array of hex colour strings for the gradient stops. Defaults
|
|
152
|
+
* to {@link DEFAULT_RAINBOW_COLORS}.
|
|
153
|
+
* @param borderRadius - Corner radius. Defaults to half the thickness for a
|
|
154
|
+
* pill shape.
|
|
155
|
+
*/
|
|
71
156
|
declare function drawRainbowRule(ctx: SKRSContext2D, x: number, y: number, width: number, thickness?: number, colors?: string[], borderRadius?: number): void;
|
|
157
|
+
/**
|
|
158
|
+
* Draw a radial vignette overlay across the full canvas.
|
|
159
|
+
*
|
|
160
|
+
* The vignette fades from fully transparent at the centre to the specified
|
|
161
|
+
* {@link color} at the edges, controlled by {@link intensity}. It is a no-op
|
|
162
|
+
* when width, height, or intensity are zero or negative.
|
|
163
|
+
*
|
|
164
|
+
* @param ctx - The `@napi-rs/canvas` 2D rendering context.
|
|
165
|
+
* @param width - Canvas width in pixels.
|
|
166
|
+
* @param height - Canvas height in pixels.
|
|
167
|
+
* @param intensity - Opacity of the vignette at the edges, clamped to 0–1.
|
|
168
|
+
* Defaults to `0.3`.
|
|
169
|
+
* @param color - Hex colour string for the vignette tint. Defaults to
|
|
170
|
+
* `'#000000'`.
|
|
171
|
+
*/
|
|
72
172
|
declare function drawVignette(ctx: SKRSContext2D, width: number, height: number, intensity?: number, color?: string): void;
|
|
73
173
|
|
|
74
174
|
declare const themeSchema: z.ZodObject<{
|
|
@@ -1037,17 +1137,20 @@ declare const drawCommandSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1037
1137
|
opacity?: number | undefined;
|
|
1038
1138
|
radius?: number | undefined;
|
|
1039
1139
|
}>]>;
|
|
1140
|
+
/** Default canvas dimensions and padding (1200 × 675 px, 48 px padding). */
|
|
1040
1141
|
declare const defaultCanvas: {
|
|
1041
1142
|
readonly width: 1200;
|
|
1042
1143
|
readonly height: 675;
|
|
1043
1144
|
readonly padding: 48;
|
|
1044
1145
|
};
|
|
1146
|
+
/** Default QA constraint thresholds applied when no explicit constraints are given. */
|
|
1045
1147
|
declare const defaultConstraints: {
|
|
1046
1148
|
readonly minContrastRatio: 4.5;
|
|
1047
1149
|
readonly minFooterSpacing: 16;
|
|
1048
1150
|
readonly checkOverlaps: true;
|
|
1049
1151
|
readonly maxTextTruncation: 0.1;
|
|
1050
1152
|
};
|
|
1153
|
+
/** Default auto-layout config used for flowcharts (ELK layered, top-to-bottom). */
|
|
1051
1154
|
declare const defaultAutoLayout: {
|
|
1052
1155
|
readonly mode: "auto";
|
|
1053
1156
|
readonly algorithm: "layered";
|
|
@@ -1056,24 +1159,44 @@ declare const defaultAutoLayout: {
|
|
|
1056
1159
|
readonly rankSpacing: 120;
|
|
1057
1160
|
readonly edgeRouting: "polyline";
|
|
1058
1161
|
};
|
|
1162
|
+
/** Default grid layout config (3 columns, 24 px gap, variable height). */
|
|
1059
1163
|
declare const defaultGridLayout: {
|
|
1060
1164
|
readonly mode: "grid";
|
|
1061
1165
|
readonly columns: 3;
|
|
1062
1166
|
readonly gap: 24;
|
|
1063
1167
|
readonly equalHeight: false;
|
|
1064
1168
|
};
|
|
1169
|
+
/** Default stack layout config (vertical direction, 24 px gap, stretch alignment). */
|
|
1065
1170
|
declare const defaultStackLayout: {
|
|
1066
1171
|
readonly mode: "stack";
|
|
1067
1172
|
readonly direction: "vertical";
|
|
1068
1173
|
readonly gap: 24;
|
|
1069
1174
|
readonly alignment: "stretch";
|
|
1070
1175
|
};
|
|
1176
|
+
/** Default layout configuration — alias for {@link defaultGridLayout}. */
|
|
1071
1177
|
declare const defaultLayout: {
|
|
1072
1178
|
readonly mode: "grid";
|
|
1073
1179
|
readonly columns: 3;
|
|
1074
1180
|
readonly gap: 24;
|
|
1075
1181
|
readonly equalHeight: false;
|
|
1076
1182
|
};
|
|
1183
|
+
/**
|
|
1184
|
+
* Infer the most appropriate layout mode from the element types present in a
|
|
1185
|
+
* design spec.
|
|
1186
|
+
*
|
|
1187
|
+
* When an explicit layout is provided it is returned as-is. Otherwise the
|
|
1188
|
+
* heuristic inspects the element list:
|
|
1189
|
+
*
|
|
1190
|
+
* - Flow-nodes **and** connections → {@link defaultAutoLayout} (ELK graph).
|
|
1191
|
+
* - All cards → {@link defaultGridLayout}.
|
|
1192
|
+
* - Contains code-block or terminal → {@link defaultStackLayout}.
|
|
1193
|
+
* - Fallback → {@link defaultGridLayout}.
|
|
1194
|
+
*
|
|
1195
|
+
* @param elements - The array of spec elements to inspect.
|
|
1196
|
+
* @param explicitLayout - An optional explicit layout config that short-circuits
|
|
1197
|
+
* inference when provided.
|
|
1198
|
+
* @returns The resolved {@link LayoutConfig}.
|
|
1199
|
+
*/
|
|
1077
1200
|
declare function inferLayout(elements: Element[], explicitLayout?: LayoutConfig): LayoutConfig;
|
|
1078
1201
|
declare const cardElementSchema: z.ZodObject<{
|
|
1079
1202
|
type: z.ZodLiteral<"card">;
|
|
@@ -1085,19 +1208,19 @@ declare const cardElementSchema: z.ZodObject<{
|
|
|
1085
1208
|
tone: z.ZodDefault<z.ZodEnum<["neutral", "accent", "success", "warning", "error"]>>;
|
|
1086
1209
|
icon: z.ZodOptional<z.ZodString>;
|
|
1087
1210
|
}, "strict", z.ZodTypeAny, {
|
|
1211
|
+
body: string;
|
|
1088
1212
|
type: "card";
|
|
1089
1213
|
id: string;
|
|
1090
1214
|
title: string;
|
|
1091
|
-
body: string;
|
|
1092
1215
|
tone: "neutral" | "accent" | "success" | "warning" | "error";
|
|
1093
1216
|
badge?: string | undefined;
|
|
1094
1217
|
metric?: string | undefined;
|
|
1095
1218
|
icon?: string | undefined;
|
|
1096
1219
|
}, {
|
|
1220
|
+
body: string;
|
|
1097
1221
|
type: "card";
|
|
1098
1222
|
id: string;
|
|
1099
1223
|
title: string;
|
|
1100
|
-
body: string;
|
|
1101
1224
|
badge?: string | undefined;
|
|
1102
1225
|
metric?: string | undefined;
|
|
1103
1226
|
tone?: "neutral" | "accent" | "success" | "warning" | "error" | undefined;
|
|
@@ -1402,14 +1525,14 @@ declare const textElementSchema: z.ZodObject<{
|
|
|
1402
1525
|
}, "strict", z.ZodTypeAny, {
|
|
1403
1526
|
type: "text";
|
|
1404
1527
|
id: string;
|
|
1405
|
-
style: "
|
|
1528
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
1406
1529
|
content: string;
|
|
1407
1530
|
align: "left" | "center" | "right";
|
|
1408
1531
|
color?: string | undefined;
|
|
1409
1532
|
}, {
|
|
1410
1533
|
type: "text";
|
|
1411
1534
|
id: string;
|
|
1412
|
-
style: "
|
|
1535
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
1413
1536
|
content: string;
|
|
1414
1537
|
color?: string | undefined;
|
|
1415
1538
|
align?: "left" | "center" | "right" | undefined;
|
|
@@ -1468,19 +1591,19 @@ declare const elementSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1468
1591
|
tone: z.ZodDefault<z.ZodEnum<["neutral", "accent", "success", "warning", "error"]>>;
|
|
1469
1592
|
icon: z.ZodOptional<z.ZodString>;
|
|
1470
1593
|
}, "strict", z.ZodTypeAny, {
|
|
1594
|
+
body: string;
|
|
1471
1595
|
type: "card";
|
|
1472
1596
|
id: string;
|
|
1473
1597
|
title: string;
|
|
1474
|
-
body: string;
|
|
1475
1598
|
tone: "neutral" | "accent" | "success" | "warning" | "error";
|
|
1476
1599
|
badge?: string | undefined;
|
|
1477
1600
|
metric?: string | undefined;
|
|
1478
1601
|
icon?: string | undefined;
|
|
1479
1602
|
}, {
|
|
1603
|
+
body: string;
|
|
1480
1604
|
type: "card";
|
|
1481
1605
|
id: string;
|
|
1482
1606
|
title: string;
|
|
1483
|
-
body: string;
|
|
1484
1607
|
badge?: string | undefined;
|
|
1485
1608
|
metric?: string | undefined;
|
|
1486
1609
|
tone?: "neutral" | "accent" | "success" | "warning" | "error" | undefined;
|
|
@@ -1746,14 +1869,14 @@ declare const elementSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1746
1869
|
}, "strict", z.ZodTypeAny, {
|
|
1747
1870
|
type: "text";
|
|
1748
1871
|
id: string;
|
|
1749
|
-
style: "
|
|
1872
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
1750
1873
|
content: string;
|
|
1751
1874
|
align: "left" | "center" | "right";
|
|
1752
1875
|
color?: string | undefined;
|
|
1753
1876
|
}, {
|
|
1754
1877
|
type: "text";
|
|
1755
1878
|
id: string;
|
|
1756
|
-
style: "
|
|
1879
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
1757
1880
|
content: string;
|
|
1758
1881
|
color?: string | undefined;
|
|
1759
1882
|
align?: "left" | "center" | "right" | undefined;
|
|
@@ -2265,6 +2388,7 @@ declare const themeInputSchema: z.ZodUnion<[z.ZodEnum<["dark", "light", "dracula
|
|
|
2265
2388
|
mono: string;
|
|
2266
2389
|
};
|
|
2267
2390
|
}>]>;
|
|
2391
|
+
/** Zod schema that validates and transforms raw input into a fully resolved {@link DesignSpec}. This is the source of truth for spec validation. */
|
|
2268
2392
|
declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
2269
2393
|
version: z.ZodDefault<z.ZodLiteral<2>>;
|
|
2270
2394
|
canvas: z.ZodDefault<z.ZodObject<{
|
|
@@ -2497,19 +2621,19 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2497
2621
|
tone: z.ZodDefault<z.ZodEnum<["neutral", "accent", "success", "warning", "error"]>>;
|
|
2498
2622
|
icon: z.ZodOptional<z.ZodString>;
|
|
2499
2623
|
}, "strict", z.ZodTypeAny, {
|
|
2624
|
+
body: string;
|
|
2500
2625
|
type: "card";
|
|
2501
2626
|
id: string;
|
|
2502
2627
|
title: string;
|
|
2503
|
-
body: string;
|
|
2504
2628
|
tone: "neutral" | "accent" | "success" | "warning" | "error";
|
|
2505
2629
|
badge?: string | undefined;
|
|
2506
2630
|
metric?: string | undefined;
|
|
2507
2631
|
icon?: string | undefined;
|
|
2508
2632
|
}, {
|
|
2633
|
+
body: string;
|
|
2509
2634
|
type: "card";
|
|
2510
2635
|
id: string;
|
|
2511
2636
|
title: string;
|
|
2512
|
-
body: string;
|
|
2513
2637
|
badge?: string | undefined;
|
|
2514
2638
|
metric?: string | undefined;
|
|
2515
2639
|
tone?: "neutral" | "accent" | "success" | "warning" | "error" | undefined;
|
|
@@ -2775,14 +2899,14 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2775
2899
|
}, "strict", z.ZodTypeAny, {
|
|
2776
2900
|
type: "text";
|
|
2777
2901
|
id: string;
|
|
2778
|
-
style: "
|
|
2902
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
2779
2903
|
content: string;
|
|
2780
2904
|
align: "left" | "center" | "right";
|
|
2781
2905
|
color?: string | undefined;
|
|
2782
2906
|
}, {
|
|
2783
2907
|
type: "text";
|
|
2784
2908
|
id: string;
|
|
2785
|
-
style: "
|
|
2909
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
2786
2910
|
content: string;
|
|
2787
2911
|
color?: string | undefined;
|
|
2788
2912
|
align?: "left" | "center" | "right" | undefined;
|
|
@@ -3562,10 +3686,10 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3562
3686
|
padding: number;
|
|
3563
3687
|
};
|
|
3564
3688
|
elements: ({
|
|
3689
|
+
body: string;
|
|
3565
3690
|
type: "card";
|
|
3566
3691
|
id: string;
|
|
3567
3692
|
title: string;
|
|
3568
|
-
body: string;
|
|
3569
3693
|
tone: "neutral" | "accent" | "success" | "warning" | "error";
|
|
3570
3694
|
badge?: string | undefined;
|
|
3571
3695
|
metric?: string | undefined;
|
|
@@ -3642,7 +3766,7 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3642
3766
|
} | {
|
|
3643
3767
|
type: "text";
|
|
3644
3768
|
id: string;
|
|
3645
|
-
style: "
|
|
3769
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
3646
3770
|
content: string;
|
|
3647
3771
|
align: "left" | "center" | "right";
|
|
3648
3772
|
color?: string | undefined;
|
|
@@ -3921,10 +4045,10 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3921
4045
|
padding?: number | undefined;
|
|
3922
4046
|
} | undefined;
|
|
3923
4047
|
elements?: ({
|
|
4048
|
+
body: string;
|
|
3924
4049
|
type: "card";
|
|
3925
4050
|
id: string;
|
|
3926
4051
|
title: string;
|
|
3927
|
-
body: string;
|
|
3928
4052
|
badge?: string | undefined;
|
|
3929
4053
|
metric?: string | undefined;
|
|
3930
4054
|
tone?: "neutral" | "accent" | "success" | "warning" | "error" | undefined;
|
|
@@ -4001,7 +4125,7 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
4001
4125
|
} | {
|
|
4002
4126
|
type: "text";
|
|
4003
4127
|
id: string;
|
|
4004
|
-
style: "
|
|
4128
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
4005
4129
|
content: string;
|
|
4006
4130
|
color?: string | undefined;
|
|
4007
4131
|
align?: "left" | "center" | "right" | undefined;
|
|
@@ -4257,10 +4381,10 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
4257
4381
|
padding: number;
|
|
4258
4382
|
};
|
|
4259
4383
|
elements: ({
|
|
4384
|
+
body: string;
|
|
4260
4385
|
type: "card";
|
|
4261
4386
|
id: string;
|
|
4262
4387
|
title: string;
|
|
4263
|
-
body: string;
|
|
4264
4388
|
tone: "neutral" | "accent" | "success" | "warning" | "error";
|
|
4265
4389
|
badge?: string | undefined;
|
|
4266
4390
|
metric?: string | undefined;
|
|
@@ -4337,7 +4461,7 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
4337
4461
|
} | {
|
|
4338
4462
|
type: "text";
|
|
4339
4463
|
id: string;
|
|
4340
|
-
style: "
|
|
4464
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
4341
4465
|
content: string;
|
|
4342
4466
|
align: "left" | "center" | "right";
|
|
4343
4467
|
color?: string | undefined;
|
|
@@ -4587,10 +4711,10 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
4587
4711
|
padding?: number | undefined;
|
|
4588
4712
|
} | undefined;
|
|
4589
4713
|
elements?: ({
|
|
4714
|
+
body: string;
|
|
4590
4715
|
type: "card";
|
|
4591
4716
|
id: string;
|
|
4592
4717
|
title: string;
|
|
4593
|
-
body: string;
|
|
4594
4718
|
badge?: string | undefined;
|
|
4595
4719
|
metric?: string | undefined;
|
|
4596
4720
|
tone?: "neutral" | "accent" | "success" | "warning" | "error" | undefined;
|
|
@@ -4667,7 +4791,7 @@ declare const designSpecSchema: z.ZodEffects<z.ZodObject<{
|
|
|
4667
4791
|
} | {
|
|
4668
4792
|
type: "text";
|
|
4669
4793
|
id: string;
|
|
4670
|
-
style: "
|
|
4794
|
+
style: "body" | "code" | "heading" | "subheading" | "caption";
|
|
4671
4795
|
content: string;
|
|
4672
4796
|
color?: string | undefined;
|
|
4673
4797
|
align?: "left" | "center" | "right" | undefined;
|
|
@@ -4803,7 +4927,27 @@ type DesignSafeFrame = {
|
|
|
4803
4927
|
height: number;
|
|
4804
4928
|
};
|
|
4805
4929
|
|
|
4930
|
+
/**
|
|
4931
|
+
* Compute the safe rendering area by insetting the canvas by its padding value.
|
|
4932
|
+
*
|
|
4933
|
+
* Elements positioned within the safe frame are guaranteed not to be clipped by
|
|
4934
|
+
* the canvas edges.
|
|
4935
|
+
*
|
|
4936
|
+
* @param spec - A parsed {@link DesignSpec} with resolved canvas dimensions and
|
|
4937
|
+
* padding.
|
|
4938
|
+
* @returns A {@link DesignSafeFrame} rectangle describing the usable area.
|
|
4939
|
+
*/
|
|
4806
4940
|
declare function deriveSafeFrame(spec: DesignSpec): DesignSafeFrame;
|
|
4941
|
+
/**
|
|
4942
|
+
* Validate and parse raw input into a fully resolved {@link DesignSpec}.
|
|
4943
|
+
*
|
|
4944
|
+
* Uses {@link designSpecSchema} under the hood. Throws a `ZodError` if the
|
|
4945
|
+
* input does not conform to the schema.
|
|
4946
|
+
*
|
|
4947
|
+
* @param input - Raw (unvalidated) input object to parse.
|
|
4948
|
+
* @returns A validated and transformed {@link DesignSpec}.
|
|
4949
|
+
* @throws {import('zod').ZodError} When the input fails schema validation.
|
|
4950
|
+
*/
|
|
4807
4951
|
declare function parseDesignSpec(input: unknown): DesignSpec;
|
|
4808
4952
|
|
|
4809
4953
|
export { defaultGridLayout as $, type AutoLayoutConfig as A, type BuiltInTheme as B, type CardElement as C, type DesignSpec as D, type Element as E, type FlowNodeElement as F, type Gradient as G, type RainbowRuleDecorator as H, type ImageElement as I, type RenderResult as J, type StackLayoutConfig as K, type LayoutConfig as L, type ManualLayoutConfig as M, type TerminalElement as N, type TextElement as O, type ThemeInput as P, builtInThemeBackgrounds as Q, type RenderMetadata as R, type ShapeElement as S, type ThemeInput$1 as T, builtInThemes as U, type VignetteDecorator as V, type WrittenArtifacts as W, computeSpecHash as X, defaultAutoLayout as Y, defaultCanvas as Z, defaultConstraints as _, type Rect as a, defaultLayout as a0, defaultStackLayout as a1, defaultTheme as a2, deriveSafeFrame as a3, designSpecSchema as a4, drawGradientRect as a5, drawRainbowRule as a6, drawVignette as a7, inferLayout as a8, inferSidecarPath as a9, parseDesignSpec as aa, renderDesign as ab, resolveTheme as ac, writeRenderArtifacts as ad, type CodeBlockStyle as ae, type GradientStop as af, type LinearGradient as ag, type RadialGradient as ah, type DrawCommand as b, type Theme as c, type RenderedElement as d, type CodeBlockElement as e, type ConnectionElement as f, type ConstraintSpec as g, DEFAULT_GENERATOR_VERSION as h, DEFAULT_RAINBOW_COLORS as i, type Decorator as j, type DesignSafeFrame as k, type DrawBadge as l, type DrawBezier as m, type DrawCircle as n, type DrawFontFamily as o, type DrawGradientRect as p, type DrawLine as q, type DrawPath as r, type DrawPoint as s, type DrawRect as t, type DrawText as u, type GradientOverlayDecorator as v, type GradientSpec as w, type GradientStop$1 as x, type GridLayoutConfig as y, type LayoutSnapshot as z };
|
package/dist/spec.schema.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export { A as AutoLayoutConfig, B as BuiltInTheme, C as CardElement, e as CodeBlockElement, ae as CodeBlockStyle, f as ConnectionElement, g as ConstraintSpec, j as Decorator, k as DesignSafeFrame, D as DesignSpec, l as DrawBadge, m as DrawBezier, n as DrawCircle, b as DrawCommand, o as DrawFontFamily, p as DrawGradientRect, q as DrawLine, r as DrawPath, s as DrawPoint, t as DrawRect, u as DrawText, E as Element, F as FlowNodeElement, G as Gradient, v as GradientOverlayDecorator, af as GradientStop, y as GridLayoutConfig, I as ImageElement, L as LayoutConfig, ag as LinearGradient, M as ManualLayoutConfig, ah as RadialGradient, H as RainbowRuleDecorator, S as ShapeElement, K as StackLayoutConfig, N as TerminalElement, O as TextElement, c as Theme, P as ThemeInput, V as VignetteDecorator, Q as builtInThemeBackgrounds, U as builtInThemes, Y as defaultAutoLayout, Z as defaultCanvas, _ as defaultConstraints, $ as defaultGridLayout, a0 as defaultLayout, a1 as defaultStackLayout, a2 as defaultTheme, a3 as deriveSafeFrame, a4 as designSpecSchema, a8 as inferLayout, aa as parseDesignSpec, ac as resolveTheme } from './spec.schema-
|
|
2
|
+
export { A as AutoLayoutConfig, B as BuiltInTheme, C as CardElement, e as CodeBlockElement, ae as CodeBlockStyle, f as ConnectionElement, g as ConstraintSpec, j as Decorator, k as DesignSafeFrame, D as DesignSpec, l as DrawBadge, m as DrawBezier, n as DrawCircle, b as DrawCommand, o as DrawFontFamily, p as DrawGradientRect, q as DrawLine, r as DrawPath, s as DrawPoint, t as DrawRect, u as DrawText, E as Element, F as FlowNodeElement, G as Gradient, v as GradientOverlayDecorator, af as GradientStop, y as GridLayoutConfig, I as ImageElement, L as LayoutConfig, ag as LinearGradient, M as ManualLayoutConfig, ah as RadialGradient, H as RainbowRuleDecorator, S as ShapeElement, K as StackLayoutConfig, N as TerminalElement, O as TextElement, c as Theme, P as ThemeInput, V as VignetteDecorator, Q as builtInThemeBackgrounds, U as builtInThemes, Y as defaultAutoLayout, Z as defaultCanvas, _ as defaultConstraints, $ as defaultGridLayout, a0 as defaultLayout, a1 as defaultStackLayout, a2 as defaultTheme, a3 as deriveSafeFrame, a4 as designSpecSchema, a8 as inferLayout, aa as parseDesignSpec, ac as resolveTheme } from './spec.schema-DhAI-tE8.js';
|
|
3
3
|
import '@napi-rs/canvas';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectratools/graphic-designer-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Deterministic visual content generator — code screenshots, terminal shots, flowcharts, and infographics. No browser dependency.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"incur": "^0.3.0",
|
|
40
40
|
"sharp": "^0.34.4",
|
|
41
41
|
"shiki": "^4.0.2",
|
|
42
|
-
"zod": "^3.24.1"
|
|
42
|
+
"zod": "^3.24.1",
|
|
43
|
+
"@spectratools/cli-shared": "0.1.1"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"typescript": "5.7.3",
|