@spectratools/graphic-designer-cli 0.7.0 → 0.8.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/cli.js +83 -16
- package/dist/index.d.ts +2 -2
- package/dist/index.js +83 -16
- package/dist/qa.d.ts +1 -1
- package/dist/qa.js +56 -10
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +83 -16
- package/dist/{spec.schema-BeFz_nk1.d.ts → spec.schema-B_Z-KNqt.d.ts} +1494 -28
- package/dist/spec.schema.d.ts +1 -1
- package/dist/spec.schema.js +56 -10
- package/package.json +1 -1
package/dist/renderer.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { i as DEFAULT_GENERATOR_VERSION,
|
|
1
|
+
export { i as DEFAULT_GENERATOR_VERSION, S as LayoutSnapshot, a as Rect, R as RenderMetadata, W as RenderResult, d as RenderedElement, a1 as WrittenArtifacts, a4 as computeSpecHash, an as inferSidecarPath, aq as renderDesign, as as writeRenderArtifacts } from './spec.schema-B_Z-KNqt.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import '@napi-rs/canvas';
|
package/dist/renderer.js
CHANGED
|
@@ -1151,12 +1151,12 @@ function withAlpha2(color, alpha) {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
function drawGradientRect(ctx, rect, gradient, borderRadius = 0) {
|
|
1153
1153
|
const fill = gradient.type === "linear" ? createLinearRectGradient(ctx, rect, gradient.angle ?? 180) : ctx.createRadialGradient(
|
|
1154
|
-
rect.x + rect.width / 2,
|
|
1155
|
-
rect.y + rect.height / 2,
|
|
1156
|
-
0,
|
|
1157
|
-
rect.x + rect.width / 2,
|
|
1158
|
-
rect.y + rect.height / 2,
|
|
1159
|
-
Math.max(rect.width, rect.height) / 2
|
|
1154
|
+
gradient.cx ?? rect.x + rect.width / 2,
|
|
1155
|
+
gradient.cy ?? rect.y + rect.height / 2,
|
|
1156
|
+
gradient.innerRadius ?? 0,
|
|
1157
|
+
gradient.cx ?? rect.x + rect.width / 2,
|
|
1158
|
+
gradient.cy ?? rect.y + rect.height / 2,
|
|
1159
|
+
gradient.outerRadius ?? Math.max(rect.width, rect.height) / 2
|
|
1160
1160
|
);
|
|
1161
1161
|
addGradientStops(fill, gradient.stops);
|
|
1162
1162
|
ctx.save();
|
|
@@ -2610,6 +2610,13 @@ function expandRect(rect, amount) {
|
|
|
2610
2610
|
height: rect.height + amount * 2
|
|
2611
2611
|
};
|
|
2612
2612
|
}
|
|
2613
|
+
function applyDrawShadow(ctx, shadow) {
|
|
2614
|
+
if (!shadow) return;
|
|
2615
|
+
ctx.shadowColor = shadow.color;
|
|
2616
|
+
ctx.shadowBlur = shadow.blur;
|
|
2617
|
+
ctx.shadowOffsetX = shadow.offsetX;
|
|
2618
|
+
ctx.shadowOffsetY = shadow.offsetY;
|
|
2619
|
+
}
|
|
2613
2620
|
function fromPoints(points) {
|
|
2614
2621
|
const minX = Math.min(...points.map((point) => point.x));
|
|
2615
2622
|
const minY = Math.min(...points.map((point) => point.y));
|
|
@@ -2791,6 +2798,7 @@ function renderDrawCommands(ctx, commands, theme) {
|
|
|
2791
2798
|
height: command.height
|
|
2792
2799
|
};
|
|
2793
2800
|
withOpacity(ctx, command.opacity, () => {
|
|
2801
|
+
applyDrawShadow(ctx, command.shadow);
|
|
2794
2802
|
roundRectPath(ctx, rect, command.radius);
|
|
2795
2803
|
if (command.fill) {
|
|
2796
2804
|
ctx.fillStyle = command.fill;
|
|
@@ -2814,6 +2822,7 @@ function renderDrawCommands(ctx, commands, theme) {
|
|
|
2814
2822
|
}
|
|
2815
2823
|
case "circle": {
|
|
2816
2824
|
withOpacity(ctx, command.opacity, () => {
|
|
2825
|
+
applyDrawShadow(ctx, command.shadow);
|
|
2817
2826
|
ctx.beginPath();
|
|
2818
2827
|
ctx.arc(command.cx, command.cy, command.radius, 0, Math.PI * 2);
|
|
2819
2828
|
ctx.closePath();
|
|
@@ -2848,6 +2857,7 @@ function renderDrawCommands(ctx, commands, theme) {
|
|
|
2848
2857
|
case "text": {
|
|
2849
2858
|
const fontFamily = resolveDrawFont(theme, command.fontFamily);
|
|
2850
2859
|
withOpacity(ctx, command.opacity, () => {
|
|
2860
|
+
applyDrawShadow(ctx, command.shadow);
|
|
2851
2861
|
applyFont(ctx, {
|
|
2852
2862
|
size: command.fontSize,
|
|
2853
2863
|
weight: command.fontWeight,
|
|
@@ -2898,6 +2908,7 @@ function renderDrawCommands(ctx, commands, theme) {
|
|
|
2898
2908
|
const to = { x: command.x2, y: command.y2 };
|
|
2899
2909
|
const lineAngle = angleBetween(from, to);
|
|
2900
2910
|
withOpacity(ctx, command.opacity, () => {
|
|
2911
|
+
applyDrawShadow(ctx, command.shadow);
|
|
2901
2912
|
drawLine(ctx, from, to, {
|
|
2902
2913
|
color: command.color,
|
|
2903
2914
|
width: command.width,
|
|
@@ -2922,6 +2933,7 @@ function renderDrawCommands(ctx, commands, theme) {
|
|
|
2922
2933
|
case "bezier": {
|
|
2923
2934
|
const points = command.points;
|
|
2924
2935
|
withOpacity(ctx, command.opacity, () => {
|
|
2936
|
+
applyDrawShadow(ctx, command.shadow);
|
|
2925
2937
|
drawBezier(ctx, points, {
|
|
2926
2938
|
color: command.color,
|
|
2927
2939
|
width: command.width,
|
|
@@ -2955,6 +2967,7 @@ function renderDrawCommands(ctx, commands, theme) {
|
|
|
2955
2967
|
const operations = parseSvgPath(command.d);
|
|
2956
2968
|
const baseBounds = pathBounds(operations);
|
|
2957
2969
|
withOpacity(ctx, command.opacity, () => {
|
|
2970
|
+
applyDrawShadow(ctx, command.shadow);
|
|
2958
2971
|
applySvgOperations(ctx, operations);
|
|
2959
2972
|
if (command.fill) {
|
|
2960
2973
|
ctx.fillStyle = command.fill;
|
|
@@ -2995,9 +3008,16 @@ function renderDrawCommands(ctx, commands, theme) {
|
|
|
2995
3008
|
height: textHeight + command.paddingY * 2
|
|
2996
3009
|
};
|
|
2997
3010
|
withOpacity(ctx, command.opacity, () => {
|
|
3011
|
+
applyDrawShadow(ctx, command.shadow);
|
|
2998
3012
|
roundRectPath(ctx, rect, command.borderRadius);
|
|
2999
3013
|
ctx.fillStyle = command.background;
|
|
3000
3014
|
ctx.fill();
|
|
3015
|
+
if (command.shadow) {
|
|
3016
|
+
ctx.shadowColor = "transparent";
|
|
3017
|
+
ctx.shadowBlur = 0;
|
|
3018
|
+
ctx.shadowOffsetX = 0;
|
|
3019
|
+
ctx.shadowOffsetY = 0;
|
|
3020
|
+
}
|
|
3001
3021
|
applyFont(ctx, {
|
|
3002
3022
|
size: command.fontSize,
|
|
3003
3023
|
weight: 600,
|
|
@@ -3025,6 +3045,7 @@ function renderDrawCommands(ctx, commands, theme) {
|
|
|
3025
3045
|
height: command.height
|
|
3026
3046
|
};
|
|
3027
3047
|
withOpacity(ctx, command.opacity, () => {
|
|
3048
|
+
applyDrawShadow(ctx, command.shadow);
|
|
3028
3049
|
drawGradientRect(ctx, rect, command.gradient, command.radius);
|
|
3029
3050
|
});
|
|
3030
3051
|
rendered.push({
|
|
@@ -3346,9 +3367,19 @@ var linearGradientSchema = z2.object({
|
|
|
3346
3367
|
}).strict();
|
|
3347
3368
|
var radialGradientSchema = z2.object({
|
|
3348
3369
|
type: z2.literal("radial"),
|
|
3370
|
+
cx: z2.number().optional(),
|
|
3371
|
+
cy: z2.number().optional(),
|
|
3372
|
+
innerRadius: z2.number().min(0).optional(),
|
|
3373
|
+
outerRadius: z2.number().min(0).optional(),
|
|
3349
3374
|
stops: z2.array(gradientStopSchema).min(2)
|
|
3350
3375
|
}).strict();
|
|
3351
3376
|
var gradientSchema = z2.discriminatedUnion("type", [linearGradientSchema, radialGradientSchema]);
|
|
3377
|
+
var drawShadowSchema = z2.object({
|
|
3378
|
+
color: colorHexSchema2.default("rgba(0,0,0,0.5)"),
|
|
3379
|
+
blur: z2.number().min(0).max(64).default(10),
|
|
3380
|
+
offsetX: z2.number().default(0),
|
|
3381
|
+
offsetY: z2.number().default(4)
|
|
3382
|
+
}).strict();
|
|
3352
3383
|
var drawFontFamilySchema = z2.enum(["heading", "body", "mono"]);
|
|
3353
3384
|
var drawRectSchema = z2.object({
|
|
3354
3385
|
type: z2.literal("rect"),
|
|
@@ -3360,7 +3391,8 @@ var drawRectSchema = z2.object({
|
|
|
3360
3391
|
stroke: colorHexSchema2.optional(),
|
|
3361
3392
|
strokeWidth: z2.number().min(0).max(32).default(0),
|
|
3362
3393
|
radius: z2.number().min(0).max(256).default(0),
|
|
3363
|
-
opacity: z2.number().min(0).max(1).default(1)
|
|
3394
|
+
opacity: z2.number().min(0).max(1).default(1),
|
|
3395
|
+
shadow: drawShadowSchema.optional()
|
|
3364
3396
|
}).strict();
|
|
3365
3397
|
var drawCircleSchema = z2.object({
|
|
3366
3398
|
type: z2.literal("circle"),
|
|
@@ -3370,7 +3402,8 @@ var drawCircleSchema = z2.object({
|
|
|
3370
3402
|
fill: colorHexSchema2.optional(),
|
|
3371
3403
|
stroke: colorHexSchema2.optional(),
|
|
3372
3404
|
strokeWidth: z2.number().min(0).max(32).default(0),
|
|
3373
|
-
opacity: z2.number().min(0).max(1).default(1)
|
|
3405
|
+
opacity: z2.number().min(0).max(1).default(1),
|
|
3406
|
+
shadow: drawShadowSchema.optional()
|
|
3374
3407
|
}).strict();
|
|
3375
3408
|
var drawTextSchema = z2.object({
|
|
3376
3409
|
type: z2.literal("text"),
|
|
@@ -3385,7 +3418,8 @@ var drawTextSchema = z2.object({
|
|
|
3385
3418
|
baseline: z2.enum(["top", "middle", "alphabetic", "bottom"]).default("alphabetic"),
|
|
3386
3419
|
letterSpacing: z2.number().min(-10).max(50).default(0),
|
|
3387
3420
|
maxWidth: z2.number().positive().optional(),
|
|
3388
|
-
opacity: z2.number().min(0).max(1).default(1)
|
|
3421
|
+
opacity: z2.number().min(0).max(1).default(1),
|
|
3422
|
+
shadow: drawShadowSchema.optional()
|
|
3389
3423
|
}).strict();
|
|
3390
3424
|
var drawLineSchema = z2.object({
|
|
3391
3425
|
type: z2.literal("line"),
|
|
@@ -3398,7 +3432,8 @@ var drawLineSchema = z2.object({
|
|
|
3398
3432
|
dash: z2.array(z2.number()).max(6).optional(),
|
|
3399
3433
|
arrow: z2.enum(["none", "end", "start", "both"]).default("none"),
|
|
3400
3434
|
arrowSize: z2.number().min(4).max(32).default(10),
|
|
3401
|
-
opacity: z2.number().min(0).max(1).default(1)
|
|
3435
|
+
opacity: z2.number().min(0).max(1).default(1),
|
|
3436
|
+
shadow: drawShadowSchema.optional()
|
|
3402
3437
|
}).strict();
|
|
3403
3438
|
var drawPointSchema = z2.object({
|
|
3404
3439
|
x: z2.number(),
|
|
@@ -3412,7 +3447,8 @@ var drawBezierSchema = z2.object({
|
|
|
3412
3447
|
dash: z2.array(z2.number()).max(6).optional(),
|
|
3413
3448
|
arrow: z2.enum(["none", "end", "start", "both"]).default("none"),
|
|
3414
3449
|
arrowSize: z2.number().min(4).max(32).default(10),
|
|
3415
|
-
opacity: z2.number().min(0).max(1).default(1)
|
|
3450
|
+
opacity: z2.number().min(0).max(1).default(1),
|
|
3451
|
+
shadow: drawShadowSchema.optional()
|
|
3416
3452
|
}).strict();
|
|
3417
3453
|
var drawPathSchema = z2.object({
|
|
3418
3454
|
type: z2.literal("path"),
|
|
@@ -3420,7 +3456,8 @@ var drawPathSchema = z2.object({
|
|
|
3420
3456
|
fill: colorHexSchema2.optional(),
|
|
3421
3457
|
stroke: colorHexSchema2.optional(),
|
|
3422
3458
|
strokeWidth: z2.number().min(0).max(32).default(0),
|
|
3423
|
-
opacity: z2.number().min(0).max(1).default(1)
|
|
3459
|
+
opacity: z2.number().min(0).max(1).default(1),
|
|
3460
|
+
shadow: drawShadowSchema.optional()
|
|
3424
3461
|
}).strict();
|
|
3425
3462
|
var drawBadgeSchema = z2.object({
|
|
3426
3463
|
type: z2.literal("badge"),
|
|
@@ -3434,7 +3471,8 @@ var drawBadgeSchema = z2.object({
|
|
|
3434
3471
|
paddingX: z2.number().min(0).max(64).default(10),
|
|
3435
3472
|
paddingY: z2.number().min(0).max(32).default(4),
|
|
3436
3473
|
borderRadius: z2.number().min(0).max(64).default(12),
|
|
3437
|
-
opacity: z2.number().min(0).max(1).default(1)
|
|
3474
|
+
opacity: z2.number().min(0).max(1).default(1),
|
|
3475
|
+
shadow: drawShadowSchema.optional()
|
|
3438
3476
|
}).strict();
|
|
3439
3477
|
var drawGradientRectSchema = z2.object({
|
|
3440
3478
|
type: z2.literal("gradient-rect"),
|
|
@@ -3444,7 +3482,8 @@ var drawGradientRectSchema = z2.object({
|
|
|
3444
3482
|
height: z2.number().positive(),
|
|
3445
3483
|
gradient: gradientSchema,
|
|
3446
3484
|
radius: z2.number().min(0).max(256).default(0),
|
|
3447
|
-
opacity: z2.number().min(0).max(1).default(1)
|
|
3485
|
+
opacity: z2.number().min(0).max(1).default(1),
|
|
3486
|
+
shadow: drawShadowSchema.optional()
|
|
3448
3487
|
}).strict();
|
|
3449
3488
|
var drawGridSchema = z2.object({
|
|
3450
3489
|
type: z2.literal("grid"),
|
|
@@ -3455,6 +3494,26 @@ var drawGridSchema = z2.object({
|
|
|
3455
3494
|
offsetX: z2.number().default(0),
|
|
3456
3495
|
offsetY: z2.number().default(0)
|
|
3457
3496
|
}).strict();
|
|
3497
|
+
var drawTextRowSegmentSchema = z2.object({
|
|
3498
|
+
text: z2.string().min(1).max(500),
|
|
3499
|
+
color: colorHexSchema2.optional(),
|
|
3500
|
+
fontSize: z2.number().min(6).max(200).optional(),
|
|
3501
|
+
fontWeight: z2.number().int().min(100).max(900).optional(),
|
|
3502
|
+
fontFamily: drawFontFamilySchema.optional()
|
|
3503
|
+
}).strict();
|
|
3504
|
+
var drawTextRowSchema = z2.object({
|
|
3505
|
+
type: z2.literal("text-row"),
|
|
3506
|
+
segments: z2.array(drawTextRowSegmentSchema).min(1).max(20),
|
|
3507
|
+
x: z2.number(),
|
|
3508
|
+
y: z2.number(),
|
|
3509
|
+
align: z2.enum(["left", "center", "right"]).default("center"),
|
|
3510
|
+
baseline: z2.enum(["top", "middle", "alphabetic", "bottom"]).default("alphabetic"),
|
|
3511
|
+
defaultFontSize: z2.number().min(6).max(200).default(16),
|
|
3512
|
+
defaultFontWeight: z2.number().int().min(100).max(900).default(400),
|
|
3513
|
+
defaultFontFamily: drawFontFamilySchema.default("body"),
|
|
3514
|
+
defaultColor: colorHexSchema2.default("#FFFFFF"),
|
|
3515
|
+
opacity: z2.number().min(0).max(1).default(1)
|
|
3516
|
+
}).strict();
|
|
3458
3517
|
var drawCommandSchema = z2.discriminatedUnion("type", [
|
|
3459
3518
|
drawRectSchema,
|
|
3460
3519
|
drawCircleSchema,
|
|
@@ -3464,7 +3523,8 @@ var drawCommandSchema = z2.discriminatedUnion("type", [
|
|
|
3464
3523
|
drawPathSchema,
|
|
3465
3524
|
drawBadgeSchema,
|
|
3466
3525
|
drawGradientRectSchema,
|
|
3467
|
-
drawGridSchema
|
|
3526
|
+
drawGridSchema,
|
|
3527
|
+
drawTextRowSchema
|
|
3468
3528
|
]);
|
|
3469
3529
|
var defaultCanvas = {
|
|
3470
3530
|
width: 1200,
|
|
@@ -3568,7 +3628,14 @@ var flowNodeElementSchema = z2.object({
|
|
|
3568
3628
|
badgeColor: colorHexSchema2.optional(),
|
|
3569
3629
|
badgeBackground: colorHexSchema2.optional(),
|
|
3570
3630
|
badgePosition: z2.enum(["top", "inside-top"]).default("inside-top"),
|
|
3571
|
-
shadow: flowNodeShadowSchema.optional()
|
|
3631
|
+
shadow: flowNodeShadowSchema.optional(),
|
|
3632
|
+
// Accent bar (left edge colored bar)
|
|
3633
|
+
accentColor: colorHexSchema2.optional(),
|
|
3634
|
+
accentBarWidth: z2.number().min(0).max(16).default(3),
|
|
3635
|
+
// Inner glow (gradient overlay from accent color inward)
|
|
3636
|
+
glowColor: colorHexSchema2.optional(),
|
|
3637
|
+
glowWidth: z2.number().min(0).max(64).default(16),
|
|
3638
|
+
glowOpacity: z2.number().min(0).max(1).default(0.15)
|
|
3572
3639
|
}).strict();
|
|
3573
3640
|
var anchorHintSchema = z2.union([
|
|
3574
3641
|
z2.enum(["top", "bottom", "left", "right", "center"]),
|