@spectratools/graphic-designer-cli 0.3.1 → 0.4.0

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.
@@ -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-BxXBTOn-.js';
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-BUTof436.js';
3
3
  import '@napi-rs/canvas';
@@ -3,7 +3,62 @@ import { z as z2 } from "zod";
3
3
 
4
4
  // src/themes/builtin.ts
5
5
  import { z } from "zod";
6
- var colorHexSchema = z.string().regex(/^#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, "Expected #RRGGBB or #RRGGBBAA color");
6
+
7
+ // src/utils/color.ts
8
+ var rgbaRegex = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*([01](?:\.\d+)?|0?\.\d+)\s*)?\)$/;
9
+ var hexColorRegex = /^#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
10
+ function toHex(n) {
11
+ return n.toString(16).padStart(2, "0");
12
+ }
13
+ function parseRgbaToHex(color) {
14
+ const match = rgbaRegex.exec(color);
15
+ if (!match) {
16
+ throw new Error(`Invalid rgb/rgba color: ${color}`);
17
+ }
18
+ const r = Number.parseInt(match[1], 10);
19
+ const g = Number.parseInt(match[2], 10);
20
+ const b = Number.parseInt(match[3], 10);
21
+ if (r > 255 || g > 255 || b > 255) {
22
+ throw new Error(`RGB channel values must be 0-255, got: ${color}`);
23
+ }
24
+ if (match[4] !== void 0) {
25
+ const a = Number.parseFloat(match[4]);
26
+ if (a < 0 || a > 1) {
27
+ throw new Error(`Alpha value must be 0-1, got: ${a}`);
28
+ }
29
+ const alphaByte = Math.round(a * 255);
30
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}${toHex(alphaByte)}`;
31
+ }
32
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
33
+ }
34
+ function isRgbaColor(color) {
35
+ return rgbaRegex.test(color);
36
+ }
37
+ function isHexColor(color) {
38
+ return hexColorRegex.test(color);
39
+ }
40
+ function normalizeColor(color) {
41
+ if (isHexColor(color)) {
42
+ return color;
43
+ }
44
+ if (isRgbaColor(color)) {
45
+ return parseRgbaToHex(color);
46
+ }
47
+ throw new Error(`Expected #RRGGBB, #RRGGBBAA, rgb(), or rgba() color, got: ${color}`);
48
+ }
49
+
50
+ // src/themes/builtin.ts
51
+ var colorHexSchema = z.string().refine(
52
+ (v) => {
53
+ try {
54
+ normalizeColor(v);
55
+ return true;
56
+ } catch {
57
+ return false;
58
+ }
59
+ },
60
+ { message: "Expected #RRGGBB, #RRGGBBAA, rgb(), or rgba() color" }
61
+ ).transform((v) => normalizeColor(v));
7
62
  var fontFamilySchema = z.string().min(1).max(120);
8
63
  var codeThemeSchema = z.object({
9
64
  background: colorHexSchema,
@@ -194,7 +249,17 @@ function resolveTheme(theme) {
194
249
  }
195
250
 
196
251
  // src/spec.schema.ts
197
- var colorHexSchema2 = z2.string().regex(/^#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, "Expected #RRGGBB or #RRGGBBAA color");
252
+ var colorHexSchema2 = z2.string().refine(
253
+ (v) => {
254
+ try {
255
+ normalizeColor(v);
256
+ return true;
257
+ } catch {
258
+ return false;
259
+ }
260
+ },
261
+ { message: "Expected #RRGGBB, #RRGGBBAA, rgb(), or rgba() color" }
262
+ ).transform((v) => normalizeColor(v));
198
263
  var gradientStopSchema = z2.object({
199
264
  offset: z2.number().min(0).max(1),
200
265
  color: colorHexSchema2
@@ -386,6 +451,9 @@ var flowNodeElementSchema = z2.object({
386
451
  label: z2.string().min(1).max(200),
387
452
  sublabel: z2.string().min(1).max(300).optional(),
388
453
  sublabelColor: colorHexSchema2.optional(),
454
+ sublabel2: z2.string().min(1).max(300).optional(),
455
+ sublabel2Color: colorHexSchema2.optional(),
456
+ sublabel2FontSize: z2.number().min(8).max(32).optional(),
389
457
  labelColor: colorHexSchema2.optional(),
390
458
  labelFontSize: z2.number().min(10).max(48).optional(),
391
459
  color: colorHexSchema2.optional(),
@@ -394,7 +462,12 @@ var flowNodeElementSchema = z2.object({
394
462
  cornerRadius: z2.number().min(0).max(64).optional(),
395
463
  width: z2.number().int().min(40).max(800).optional(),
396
464
  height: z2.number().int().min(30).max(600).optional(),
397
- opacity: z2.number().min(0).max(1).default(1)
465
+ fillOpacity: z2.number().min(0).max(1).default(1),
466
+ opacity: z2.number().min(0).max(1).default(1),
467
+ badgeText: z2.string().min(1).max(32).optional(),
468
+ badgeColor: colorHexSchema2.optional(),
469
+ badgeBackground: colorHexSchema2.optional(),
470
+ badgePosition: z2.enum(["top", "inside-top"]).default("inside-top")
398
471
  }).strict();
399
472
  var connectionElementSchema = z2.object({
400
473
  type: z2.literal("connection"),
@@ -483,7 +556,15 @@ var autoLayoutConfigSchema = z2.object({
483
556
  nodeSpacing: z2.number().int().min(0).max(512).default(80),
484
557
  rankSpacing: z2.number().int().min(0).max(512).default(120),
485
558
  edgeRouting: z2.enum(["orthogonal", "polyline", "spline"]).default("polyline"),
486
- aspectRatio: z2.number().min(0.5).max(3).optional()
559
+ aspectRatio: z2.number().min(0.5).max(3).optional(),
560
+ /** ID of the root node for radial layout. Only relevant when algorithm is 'radial'. */
561
+ radialRoot: z2.string().min(1).max(120).optional(),
562
+ /** Fixed radius in pixels for radial layout. Only relevant when algorithm is 'radial'. */
563
+ radialRadius: z2.number().positive().optional(),
564
+ /** Compaction strategy for radial layout. Only relevant when algorithm is 'radial'. */
565
+ radialCompaction: z2.enum(["none", "radial", "wedge"]).optional(),
566
+ /** Sort strategy for radial layout node ordering. Only relevant when algorithm is 'radial'. */
567
+ radialSortBy: z2.enum(["id", "connections"]).optional()
487
568
  }).strict();
488
569
  var gridLayoutConfigSchema = z2.object({
489
570
  mode: z2.literal("grid"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectratools/graphic-designer-cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
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",