@spectratools/graphic-designer-cli 0.4.0 → 0.7.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-BUTof436.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-BUTof436.js';
2
+ import { T as ThemeInput, D as DesignSpec, a as Rect$1, b as DrawCommand, c as Theme, d as RenderedElement, A as AnchorHint, C as ConnectionElement } from './spec.schema-BeFz_nk1.js';
3
+ export { e as AutoLayoutConfig, B as BuiltInTheme, f as CardElement, g as CodeBlockElement, h as ConstraintSpec, i as DEFAULT_GENERATOR_VERSION, j as DEFAULT_RAINBOW_COLORS, k as Decorator, l as DesignCardSpec, m as DesignSafeFrame, n as DesignTheme, o as DiagramElement, p as DiagramLayout, q as DiagramSpec, r as DrawBadge, s as DrawBezier, t as DrawCircle, u as DrawFontFamily, v as DrawGradientRect, w as DrawLine, x as DrawPath, y as DrawPoint, z as DrawRect, E as DrawText, F as Element, G as FlowNodeElement, H as Gradient, I as GradientOverlayDecorator, J as GradientSpec, K as GradientStop, L as GridLayoutConfig, M as ImageElement, N as LayoutConfig, O as LayoutSnapshot, P as ManualLayoutConfig, Q as RainbowRuleDecorator, R as RenderMetadata, S as RenderResult, U as ShapeElement, V as StackLayoutConfig, W as TerminalElement, X as TextElement, Y as ThemeInput, Z as VignetteDecorator, _ as WrittenArtifacts, $ as builtInThemeBackgrounds, a0 as builtInThemes, a1 as computeSpecHash, a2 as connectionElementSchema, a3 as defaultAutoLayout, a4 as defaultCanvas, a5 as defaultConstraints, a6 as defaultGridLayout, a7 as defaultLayout, a8 as defaultStackLayout, a9 as defaultTheme, aa as deriveSafeFrame, ab as designSpecSchema, ac as diagramElementSchema, ad as diagramLayoutSchema, ae as diagramSpecSchema, af as drawGradientRect, ag as drawRainbowRule, ah as drawVignette, ai as flowNodeElementSchema, aj as inferLayout, ak as inferSidecarPath, al as parseDesignSpec, am as parseDiagramSpec, an as renderDesign, ao as resolveTheme, ap as writeRenderArtifacts } from './spec.schema-BeFz_nk1.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,79 @@ 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
+ * When `fromAnchor` or `toAnchor` hints are provided, they override the
280
+ * automatic edge anchor calculation and the outward normal is derived from
281
+ * the hint direction instead of from the diagram center.
282
+ */
283
+ declare function curveRoute(fromBounds: Rect, toBounds: Rect, diagramCenter: Point, tension: number, fromAnchor?: AnchorHint, toAnchor?: AnchorHint): [Point, Point, Point, Point];
284
+ /**
285
+ * Approximate an outward-bowing half-ellipse with two cubic bezier segments.
286
+ *
287
+ * Uses the classic kappa constant (`4 * (sqrt(2) - 1) / 3`) for quarter-ellipse
288
+ * control points, producing a stable arc from source edge anchor to target edge
289
+ * anchor.
290
+ *
291
+ * When `fromAnchor` or `toAnchor` hints are provided, they override the
292
+ * automatic edge anchor calculation.
293
+ */
294
+ declare function arcRoute(fromBounds: Rect, toBounds: Rect, diagramCenter: Point, tension: number, fromAnchor?: AnchorHint, toAnchor?: AnchorHint): [CubicBezierSegment, CubicBezierSegment];
295
+ /**
296
+ * Compute an orthogonal (right-angle) path between two rectangles.
297
+ * Returns an array of waypoints forming a 3-segment path.
298
+ *
299
+ * When `fromAnchor` or `toAnchor` hints are provided, they override the
300
+ * automatic edge anchor calculation.
301
+ */
302
+ declare function orthogonalRoute(fromBounds: Rect, toBounds: Rect, fromAnchor?: AnchorHint, toAnchor?: AnchorHint): Point[];
303
+ /** Evaluate cubic bezier at parameter `t`. */
304
+ declare function bezierPointAt(p0: Point, cp1: Point, cp2: Point, p3: Point, t: number): Point;
305
+ /**
306
+ * Compute the centroid of all node bounding boxes. Falls back to the
307
+ * provided `canvasCenter` when no nodes are supplied.
308
+ */
309
+ declare function computeDiagramCenter(nodeBounds: Rect[], canvasCenter?: Point): Point;
310
+ declare function renderConnection(ctx: SKRSContext2D, conn: ConnectionElement, fromBounds: Rect, toBounds: Rect, theme: Theme, edgeRoute?: EdgeRoute, options?: {
311
+ diagramCenter?: Point;
312
+ }): RenderedElement[];
313
+
204
314
  /**
205
315
  * Register the bundled font families (Inter, JetBrains Mono, Space Grotesk)
206
316
  * with the global `@napi-rs/canvas` font registry.
@@ -256,4 +366,4 @@ declare function highlightCode(code: string, language: string, themeName: string
256
366
  */
257
367
  declare function disposeHighlighter(): void;
258
368
 
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 };
369
+ 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 };