@spectratools/graphic-designer-cli 0.3.2 → 0.6.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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Cli } from 'incur';
2
- import { T as ThemeInput, D as DesignSpec, a as Rect, b as DrawCommand, c as Theme, d as RenderedElement } from './spec.schema-DhAI-tE8.js';
3
- export { A as AutoLayoutConfig, B as BuiltInTheme, C as CardElement, e as CodeBlockElement, f as ConnectionElement, g as ConstraintSpec, h as DEFAULT_GENERATOR_VERSION, i as DEFAULT_RAINBOW_COLORS, j as Decorator, k as DesignSafeFrame, l as DrawBadge, m as DrawBezier, n as DrawCircle, 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, w as GradientSpec, x as GradientStop, y as GridLayoutConfig, I as ImageElement, L as LayoutConfig, z as LayoutSnapshot, M as ManualLayoutConfig, H as RainbowRuleDecorator, R as RenderMetadata, J as RenderResult, S as ShapeElement, K as StackLayoutConfig, N as TerminalElement, O as TextElement, P as ThemeInput, V as VignetteDecorator, W as WrittenArtifacts, Q as builtInThemeBackgrounds, U as builtInThemes, X as computeSpecHash, 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, a5 as drawGradientRect, a6 as drawRainbowRule, a7 as drawVignette, a8 as inferLayout, a9 as inferSidecarPath, aa as parseDesignSpec, ab as renderDesign, ac as resolveTheme, ad as writeRenderArtifacts } from './spec.schema-DhAI-tE8.js';
2
+ import { T as ThemeInput, D as DesignSpec, a as Rect$1, b as DrawCommand, c as Theme, d as RenderedElement, C as ConnectionElement } from './spec.schema-Dm_wOLTd.js';
3
+ export { A as AutoLayoutConfig, B as BuiltInTheme, e as CardElement, f as CodeBlockElement, g as ConstraintSpec, h as DEFAULT_GENERATOR_VERSION, i as DEFAULT_RAINBOW_COLORS, j as Decorator, k as DesignCardSpec, l as DesignSafeFrame, m as DesignTheme, n as DiagramElement, o as DiagramLayout, p as DiagramSpec, q as DrawBadge, r as DrawBezier, s as DrawCircle, t as DrawFontFamily, u as DrawGradientRect, v as DrawLine, w as DrawPath, x as DrawPoint, y as DrawRect, z as DrawText, E as Element, F as FlowNodeElement, G as Gradient, H as GradientOverlayDecorator, I as GradientSpec, J as GradientStop, K as GridLayoutConfig, L as ImageElement, M as LayoutConfig, N as LayoutSnapshot, O as ManualLayoutConfig, P as RainbowRuleDecorator, R as RenderMetadata, Q as RenderResult, S as ShapeElement, U as StackLayoutConfig, V as TerminalElement, W as TextElement, X as ThemeInput, Y as VignetteDecorator, Z as WrittenArtifacts, _ as builtInThemeBackgrounds, $ as builtInThemes, a0 as computeSpecHash, a1 as connectionElementSchema, a2 as defaultAutoLayout, a3 as defaultCanvas, a4 as defaultConstraints, a5 as defaultGridLayout, a6 as defaultLayout, a7 as defaultStackLayout, a8 as defaultTheme, a9 as deriveSafeFrame, aa as designSpecSchema, ab as diagramElementSchema, ac as diagramLayoutSchema, ad as diagramSpecSchema, ae as drawGradientRect, af as drawRainbowRule, ag as drawVignette, ah as flowNodeElementSchema, ai as inferLayout, aj as inferSidecarPath, ak as parseDesignSpec, al as parseDiagramSpec, am as renderDesign, an as resolveTheme, ao as writeRenderArtifacts } from './spec.schema-Dm_wOLTd.js';
4
4
  import { SKRSContext2D } from '@napi-rs/canvas';
5
- export { QaIssue, QaReport, QaSeverity, readMetadata, runQa } from './qa.js';
5
+ export { QaIssue, QaReferenceResult, QaReport, QaSeverity, readMetadata, runQa } from './qa.js';
6
6
  import { Highlighter } from 'shiki';
7
7
  export { GistPublishOptions, GistPublishResult, GitHubPublishOptions, GitHubPublishResult, publishToGist, publishToGitHub } from './publish/index.js';
8
8
  import 'zod';
@@ -10,6 +10,43 @@ import '@spectratools/cli-shared/middleware';
10
10
 
11
11
  declare const cli: Cli.Cli<{}, undefined, undefined>;
12
12
 
13
+ type CompareVerdict = 'match' | 'close' | 'mismatch';
14
+ type CompareImagesOptions = {
15
+ grid?: number;
16
+ threshold?: number;
17
+ closeMargin?: number;
18
+ };
19
+ type CompareRegionScore = {
20
+ label: string;
21
+ row: number;
22
+ column: number;
23
+ similarity: number;
24
+ };
25
+ type CompareImagesReport = {
26
+ targetPath: string;
27
+ renderedPath: string;
28
+ targetDimensions: {
29
+ width: number;
30
+ height: number;
31
+ };
32
+ renderedDimensions: {
33
+ width: number;
34
+ height: number;
35
+ };
36
+ normalizedDimensions: {
37
+ width: number;
38
+ height: number;
39
+ };
40
+ dimensionMismatch: boolean;
41
+ grid: number;
42
+ threshold: number;
43
+ closeThreshold: number;
44
+ similarity: number;
45
+ verdict: CompareVerdict;
46
+ regions: CompareRegionScore[];
47
+ };
48
+ declare function compareImages(target: string, rendered: string, options?: CompareImagesOptions): Promise<CompareImagesReport>;
49
+
13
50
  declare const themeToShikiMap: Record<string, string>;
14
51
  declare function resolveShikiTheme(theme: ThemeInput): string;
15
52
 
@@ -173,7 +210,7 @@ type EdgeRoute = {
173
210
  }>;
174
211
  };
175
212
  type LayoutResult = {
176
- positions: Map<string, Rect>;
213
+ positions: Map<string, Rect$1>;
177
214
  canvasSize?: {
178
215
  width: number;
179
216
  height: number;
@@ -201,6 +238,69 @@ type ElkLayoutResult = LayoutResult & {
201
238
  */
202
239
  declare function renderDrawCommands(ctx: SKRSContext2D, commands: DrawCommand[], theme: Theme): RenderedElement[];
203
240
 
241
+ type Point$1 = {
242
+ x: number;
243
+ y: number;
244
+ };
245
+
246
+ type Point = Point$1;
247
+ type Rect = Rect$1;
248
+ type ConnectionRouting = 'auto' | 'orthogonal' | 'curve' | 'arc';
249
+ type ConnectionArrow = 'none' | 'end' | 'start' | 'both';
250
+ type ConnectionStrokeStyle = 'solid' | 'dashed' | 'dotted';
251
+ type ConnectionRenderOptions = {
252
+ fromBounds: Rect;
253
+ toBounds: Rect;
254
+ routing: ConnectionRouting;
255
+ tension: number;
256
+ color: string;
257
+ strokeWidth: number;
258
+ strokeStyle: ConnectionStrokeStyle;
259
+ arrow: ConnectionArrow;
260
+ label?: string;
261
+ diagramCenter: Point;
262
+ elkRoute?: Point[];
263
+ };
264
+ type CubicBezierSegment = [Point, Point, Point, Point];
265
+ declare function rectCenter(rect: Rect): Point;
266
+ /**
267
+ * Compute the point where a ray from the center of `bounds` toward `target`
268
+ * exits the bounding rectangle.
269
+ */
270
+ declare function edgeAnchor(bounds: Rect, target: Point): Point;
271
+ /**
272
+ * Unit vector pointing outward from `diagramCenter` through `point`.
273
+ */
274
+ declare function outwardNormal(point: Point, diagramCenter: Point): Point;
275
+ /**
276
+ * Compute a cubic bezier curve that bows outward from the diagram center.
277
+ * Returns `[startPoint, controlPoint1, controlPoint2, endPoint]`.
278
+ */
279
+ declare function curveRoute(fromBounds: Rect, toBounds: Rect, diagramCenter: Point, tension: number): [Point, Point, Point, Point];
280
+ /**
281
+ * Approximate an outward-bowing half-ellipse with two cubic bezier segments.
282
+ *
283
+ * Uses the classic kappa constant (`4 * (sqrt(2) - 1) / 3`) for quarter-ellipse
284
+ * control points, producing a stable arc from source edge anchor to target edge
285
+ * anchor.
286
+ */
287
+ declare function arcRoute(fromBounds: Rect, toBounds: Rect, diagramCenter: Point, tension: number): [CubicBezierSegment, CubicBezierSegment];
288
+ /**
289
+ * Compute an orthogonal (right-angle) path between two rectangles.
290
+ * Returns an array of waypoints forming a 3-segment path.
291
+ */
292
+ declare function orthogonalRoute(fromBounds: Rect, toBounds: Rect): Point[];
293
+ /** Evaluate cubic bezier at parameter `t`. */
294
+ declare function bezierPointAt(p0: Point, cp1: Point, cp2: Point, p3: Point, t: number): Point;
295
+ /**
296
+ * Compute the centroid of all node bounding boxes. Falls back to the
297
+ * provided `canvasCenter` when no nodes are supplied.
298
+ */
299
+ declare function computeDiagramCenter(nodeBounds: Rect[], canvasCenter?: Point): Point;
300
+ declare function renderConnection(ctx: SKRSContext2D, conn: ConnectionElement, fromBounds: Rect, toBounds: Rect, theme: Theme, edgeRoute?: EdgeRoute, options?: {
301
+ diagramCenter?: Point;
302
+ }): RenderedElement[];
303
+
204
304
  /**
205
305
  * Register the bundled font families (Inter, JetBrains Mono, Space Grotesk)
206
306
  * with the global `@napi-rs/canvas` font registry.
@@ -256,4 +356,4 @@ declare function highlightCode(code: string, language: string, themeName: string
256
356
  */
257
357
  declare function disposeHighlighter(): void;
258
358
 
259
- export { DesignSpec, DrawCommand, type EdgeRoute, type ElkLayoutResult, type HighlightedLine, type LayoutResult, Rect, RenderedElement, Theme, buildCardsSpec, buildCodeSpec, buildFlowchartSpec, buildTerminalSpec, cli, disposeHighlighter, highlightCode, initHighlighter, loadFonts, renderDrawCommands, resolveShikiTheme, themeToShikiMap };
359
+ export { type CompareImagesOptions, type CompareImagesReport, type CompareRegionScore, type CompareVerdict, type ConnectionArrow, ConnectionElement, type ConnectionRenderOptions, type ConnectionRouting, type ConnectionStrokeStyle, type CubicBezierSegment, DesignSpec, DrawCommand, type EdgeRoute, type ElkLayoutResult, type HighlightedLine, type LayoutResult, type Point, Rect$1 as Rect, RenderedElement, Theme, arcRoute, bezierPointAt, buildCardsSpec, buildCodeSpec, buildFlowchartSpec, buildTerminalSpec, cli, compareImages, computeDiagramCenter, curveRoute, disposeHighlighter, edgeAnchor, highlightCode, initHighlighter, loadFonts, orthogonalRoute, outwardNormal, rectCenter, renderConnection, renderDrawCommands, resolveShikiTheme, themeToShikiMap };