@shotstack/shotstack-canvas 1.6.5 → 1.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/entry.node.cjs +127 -114
- package/dist/entry.node.d.cts +124 -102
- package/dist/entry.node.d.ts +124 -102
- package/dist/entry.node.js +135 -114
- package/dist/entry.web.d.ts +123 -101
- package/dist/entry.web.js +135 -114
- package/package.json +63 -62
package/dist/entry.node.cjs
CHANGED
|
@@ -30,14 +30,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/env/entry.node.ts
|
|
31
31
|
var entry_node_exports = {};
|
|
32
32
|
__export(entry_node_exports, {
|
|
33
|
+
CanvasRichTextAssetSchema: () => CanvasRichTextAssetSchema,
|
|
33
34
|
createTextEngine: () => createTextEngine,
|
|
34
35
|
isGlyphFill: () => isGlyphFill2,
|
|
35
36
|
isShadowFill: () => isShadowFill2
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(entry_node_exports);
|
|
38
39
|
|
|
39
|
-
// src/schema/
|
|
40
|
-
var
|
|
40
|
+
// src/schema/zod-schema.ts
|
|
41
|
+
var import_zod = require("zod");
|
|
42
|
+
var import_zod2 = require("@shotstack/schemas/zod");
|
|
41
43
|
|
|
42
44
|
// src/config/canvas-constants.ts
|
|
43
45
|
var CANVAS_CONFIG = {
|
|
@@ -71,110 +73,127 @@ var CANVAS_CONFIG = {
|
|
|
71
73
|
]
|
|
72
74
|
};
|
|
73
75
|
|
|
74
|
-
// src/schema/
|
|
76
|
+
// src/schema/zod-schema.ts
|
|
75
77
|
var HEX6 = /^#[A-Fa-f0-9]{6}$/;
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
).min(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
opacity: import_joi.default.number().min(0).max(1).default(1)
|
|
97
|
-
}).unknown(false);
|
|
98
|
-
var fontSchema = import_joi.default.object({
|
|
99
|
-
family: import_joi.default.string().default(CANVAS_CONFIG.DEFAULTS.fontFamily),
|
|
100
|
-
size: import_joi.default.number().min(CANVAS_CONFIG.LIMITS.minFontSize).max(CANVAS_CONFIG.LIMITS.maxFontSize).default(CANVAS_CONFIG.DEFAULTS.fontSize),
|
|
101
|
-
weight: import_joi.default.alternatives().try(import_joi.default.string(), import_joi.default.number()).default("400"),
|
|
102
|
-
color: import_joi.default.string().pattern(HEX6).default(CANVAS_CONFIG.DEFAULTS.color),
|
|
103
|
-
opacity: import_joi.default.number().min(0).max(1).default(1),
|
|
104
|
-
background: import_joi.default.string().pattern(HEX6).optional()
|
|
105
|
-
}).unknown(false);
|
|
106
|
-
var styleSchema = import_joi.default.object({
|
|
107
|
-
letterSpacing: import_joi.default.number().default(0),
|
|
108
|
-
lineHeight: import_joi.default.number().min(0).max(10).default(1.2),
|
|
109
|
-
textTransform: import_joi.default.string().valid("none", "uppercase", "lowercase", "capitalize").default("none"),
|
|
110
|
-
textDecoration: import_joi.default.string().valid("none", "underline", "line-through").default("none"),
|
|
111
|
-
gradient: gradientSchema.optional()
|
|
112
|
-
}).unknown(false);
|
|
113
|
-
var alignmentSchema = import_joi.default.object({
|
|
114
|
-
horizontal: import_joi.default.string().valid("left", "center", "right").default(CANVAS_CONFIG.DEFAULTS.textAlign),
|
|
115
|
-
vertical: import_joi.default.string().valid("top", "middle", "bottom").default("middle")
|
|
116
|
-
}).unknown(false);
|
|
117
|
-
var animationSchema = import_joi.default.object({
|
|
118
|
-
preset: import_joi.default.string().valid(...CANVAS_CONFIG.ANIMATION_TYPES),
|
|
119
|
-
speed: import_joi.default.number().min(0.1).max(10).default(1),
|
|
120
|
-
duration: import_joi.default.number().min(CANVAS_CONFIG.LIMITS.minDuration).max(CANVAS_CONFIG.LIMITS.maxDuration).optional(),
|
|
121
|
-
style: import_joi.default.string().valid("character", "word").optional().when("preset", {
|
|
122
|
-
is: import_joi.default.valid("typewriter", "shift", "fadeIn", "slideIn"),
|
|
123
|
-
then: import_joi.default.optional(),
|
|
124
|
-
otherwise: import_joi.default.forbidden()
|
|
125
|
-
}),
|
|
126
|
-
direction: import_joi.default.string().optional().when("preset", {
|
|
127
|
-
switch: [
|
|
128
|
-
{ is: "ascend", then: import_joi.default.valid("up", "down") },
|
|
129
|
-
{ is: "shift", then: import_joi.default.valid("left", "right", "up", "down") },
|
|
130
|
-
{ is: "slideIn", then: import_joi.default.valid("left", "right", "up", "down") },
|
|
131
|
-
{ is: "movingLetters", then: import_joi.default.valid("left", "right", "up", "down") }
|
|
132
|
-
],
|
|
133
|
-
otherwise: import_joi.default.forbidden()
|
|
78
|
+
var customFontSchema = import_zod.z.object({
|
|
79
|
+
src: import_zod.z.string().url(),
|
|
80
|
+
family: import_zod.z.string(),
|
|
81
|
+
weight: import_zod.z.union([import_zod.z.string(), import_zod.z.number()]).optional(),
|
|
82
|
+
style: import_zod.z.string().optional(),
|
|
83
|
+
originalFamily: import_zod.z.string().optional()
|
|
84
|
+
});
|
|
85
|
+
var borderSchema = import_zod.z.object({
|
|
86
|
+
width: import_zod.z.number().min(0).default(0),
|
|
87
|
+
color: import_zod.z.string().regex(HEX6).default("#000000"),
|
|
88
|
+
opacity: import_zod.z.number().min(0).max(1).default(1),
|
|
89
|
+
radius: import_zod.z.number().min(0).default(0)
|
|
90
|
+
});
|
|
91
|
+
var paddingSchema = import_zod.z.union([
|
|
92
|
+
import_zod.z.number().min(0),
|
|
93
|
+
import_zod.z.object({
|
|
94
|
+
top: import_zod.z.number().min(0).default(0),
|
|
95
|
+
right: import_zod.z.number().min(0).default(0),
|
|
96
|
+
bottom: import_zod.z.number().min(0).default(0),
|
|
97
|
+
left: import_zod.z.number().min(0).default(0)
|
|
134
98
|
})
|
|
135
|
-
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
99
|
+
]);
|
|
100
|
+
var canvasFontSchema = import_zod2.richTextFontSchema.extend({
|
|
101
|
+
family: import_zod.z.string().default(CANVAS_CONFIG.DEFAULTS.fontFamily),
|
|
102
|
+
size: import_zod.z.number().int().min(CANVAS_CONFIG.LIMITS.minFontSize).max(CANVAS_CONFIG.LIMITS.maxFontSize).default(CANVAS_CONFIG.DEFAULTS.fontSize),
|
|
103
|
+
weight: import_zod.z.union([import_zod.z.string(), import_zod.z.number()]).default("400"),
|
|
104
|
+
color: import_zod.z.string().regex(HEX6).default(CANVAS_CONFIG.DEFAULTS.color),
|
|
105
|
+
opacity: import_zod.z.number().min(0).max(1).default(1),
|
|
106
|
+
background: import_zod.z.string().regex(HEX6).optional()
|
|
107
|
+
});
|
|
108
|
+
var canvasGradientSchema = import_zod.z.object({
|
|
109
|
+
type: import_zod.z.enum(["linear", "radial"]).default("linear"),
|
|
110
|
+
angle: import_zod.z.number().min(0).max(360).default(0),
|
|
111
|
+
stops: import_zod.z.array(import_zod.z.object({
|
|
112
|
+
offset: import_zod.z.number().min(0).max(1),
|
|
113
|
+
color: import_zod.z.string().regex(HEX6)
|
|
114
|
+
})).min(2)
|
|
115
|
+
});
|
|
116
|
+
var canvasStyleSchema = import_zod2.richTextStyleSchema.extend({
|
|
117
|
+
letterSpacing: import_zod.z.number().default(0),
|
|
118
|
+
lineHeight: import_zod.z.number().min(0).max(10).default(1.2),
|
|
119
|
+
textTransform: import_zod.z.enum(["none", "uppercase", "lowercase", "capitalize"]).default("none"),
|
|
120
|
+
textDecoration: import_zod.z.enum(["none", "underline", "line-through"]).default("none"),
|
|
121
|
+
gradient: canvasGradientSchema.optional()
|
|
122
|
+
});
|
|
123
|
+
var canvasStrokeSchema = import_zod2.richTextStrokeSchema.extend({
|
|
124
|
+
width: import_zod.z.number().min(0).default(0),
|
|
125
|
+
color: import_zod.z.string().regex(HEX6).default("#000000"),
|
|
126
|
+
opacity: import_zod.z.number().min(0).max(1).default(1)
|
|
127
|
+
});
|
|
128
|
+
var canvasShadowSchema = import_zod2.richTextShadowSchema.extend({
|
|
129
|
+
offsetX: import_zod.z.number().default(0),
|
|
130
|
+
offsetY: import_zod.z.number().default(0),
|
|
131
|
+
blur: import_zod.z.number().min(0).default(0),
|
|
132
|
+
color: import_zod.z.string().regex(HEX6).default("#000000"),
|
|
133
|
+
opacity: import_zod.z.number().min(0).max(1).default(0.5)
|
|
134
|
+
});
|
|
135
|
+
var canvasBackgroundSchema = import_zod2.richTextBackgroundSchema.extend({
|
|
136
|
+
color: import_zod.z.string().regex(HEX6).optional(),
|
|
137
|
+
opacity: import_zod.z.number().min(0).max(1).default(1)
|
|
138
|
+
});
|
|
139
|
+
var canvasAlignmentSchema = import_zod2.richTextAlignmentSchema.extend({
|
|
140
|
+
horizontal: import_zod.z.enum(["left", "center", "right"]).default(CANVAS_CONFIG.DEFAULTS.textAlign),
|
|
141
|
+
vertical: import_zod.z.enum(["top", "middle", "bottom"]).default("middle")
|
|
142
|
+
});
|
|
143
|
+
var canvasAnimationSchema = import_zod2.richTextAnimationSchema.extend({
|
|
144
|
+
preset: import_zod.z.enum(CANVAS_CONFIG.ANIMATION_TYPES),
|
|
145
|
+
speed: import_zod.z.number().min(0.1).max(10).default(1),
|
|
146
|
+
duration: import_zod.z.number().min(CANVAS_CONFIG.LIMITS.minDuration).max(CANVAS_CONFIG.LIMITS.maxDuration).optional(),
|
|
147
|
+
style: import_zod.z.enum(["character", "word"]).optional(),
|
|
148
|
+
direction: import_zod.z.enum(["left", "right", "up", "down"]).optional()
|
|
149
|
+
}).superRefine((data, ctx) => {
|
|
150
|
+
const presetsWithStyle = ["typewriter", "shift", "fadeIn", "slideIn"];
|
|
151
|
+
if (data.style && !presetsWithStyle.includes(data.preset)) {
|
|
152
|
+
ctx.addIssue({
|
|
153
|
+
code: import_zod.z.ZodIssueCode.custom,
|
|
154
|
+
message: `style is not allowed for preset "${data.preset}"`,
|
|
155
|
+
path: ["style"]
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const directionRules = {
|
|
159
|
+
ascend: ["up", "down"],
|
|
160
|
+
shift: ["left", "right", "up", "down"],
|
|
161
|
+
slideIn: ["left", "right", "up", "down"],
|
|
162
|
+
movingLetters: ["left", "right", "up", "down"]
|
|
163
|
+
};
|
|
164
|
+
if (data.direction) {
|
|
165
|
+
const allowedDirections = directionRules[data.preset];
|
|
166
|
+
if (!allowedDirections) {
|
|
167
|
+
ctx.addIssue({
|
|
168
|
+
code: import_zod.z.ZodIssueCode.custom,
|
|
169
|
+
message: `direction is not allowed for preset "${data.preset}"`,
|
|
170
|
+
path: ["direction"]
|
|
171
|
+
});
|
|
172
|
+
} else if (!allowedDirections.includes(data.direction)) {
|
|
173
|
+
ctx.addIssue({
|
|
174
|
+
code: import_zod.z.ZodIssueCode.custom,
|
|
175
|
+
message: `direction "${data.direction}" is not valid for preset "${data.preset}"`,
|
|
176
|
+
path: ["direction"]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
var CanvasRichTextAssetSchema = import_zod2.richTextAssetSchema.extend({
|
|
182
|
+
type: import_zod.z.literal("rich-text"),
|
|
183
|
+
text: import_zod.z.string().max(CANVAS_CONFIG.LIMITS.maxTextLength).default(""),
|
|
184
|
+
width: import_zod.z.number().int().min(CANVAS_CONFIG.LIMITS.minWidth).max(CANVAS_CONFIG.LIMITS.maxWidth).default(CANVAS_CONFIG.DEFAULTS.width).optional(),
|
|
185
|
+
height: import_zod.z.number().int().min(CANVAS_CONFIG.LIMITS.minHeight).max(CANVAS_CONFIG.LIMITS.maxHeight).default(CANVAS_CONFIG.DEFAULTS.height).optional(),
|
|
186
|
+
font: canvasFontSchema.optional(),
|
|
187
|
+
style: canvasStyleSchema.optional(),
|
|
188
|
+
stroke: canvasStrokeSchema.optional(),
|
|
189
|
+
shadow: canvasShadowSchema.optional(),
|
|
190
|
+
background: canvasBackgroundSchema.optional(),
|
|
172
191
|
border: borderSchema.optional(),
|
|
173
192
|
padding: paddingSchema.optional(),
|
|
174
|
-
align:
|
|
175
|
-
animation:
|
|
176
|
-
customFonts:
|
|
177
|
-
}).
|
|
193
|
+
align: canvasAlignmentSchema.optional(),
|
|
194
|
+
animation: canvasAnimationSchema.optional(),
|
|
195
|
+
customFonts: import_zod.z.array(customFontSchema).optional()
|
|
196
|
+
}).strict();
|
|
178
197
|
|
|
179
198
|
// src/wasm/hb-loader.ts
|
|
180
199
|
var import_meta = {};
|
|
@@ -2483,19 +2502,12 @@ async function createTextEngine(opts = {}) {
|
|
|
2483
2502
|
}
|
|
2484
2503
|
return {
|
|
2485
2504
|
validate(input) {
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
});
|
|
2491
|
-
if (error) throw error;
|
|
2492
|
-
return { value };
|
|
2493
|
-
} catch (err) {
|
|
2494
|
-
if (err instanceof Error) {
|
|
2495
|
-
throw new Error(`Validation failed: ${err.message}`);
|
|
2496
|
-
}
|
|
2497
|
-
throw new Error(`Validation failed: ${String(err)}`);
|
|
2505
|
+
const result = CanvasRichTextAssetSchema.safeParse(input);
|
|
2506
|
+
if (!result.success) {
|
|
2507
|
+
const messages = result.error.issues.map((i) => i.message).join(". ");
|
|
2508
|
+
throw new Error(`Validation failed: ${messages}`);
|
|
2498
2509
|
}
|
|
2510
|
+
return { value: result.data };
|
|
2499
2511
|
},
|
|
2500
2512
|
async registerFontFromFile(path, desc) {
|
|
2501
2513
|
try {
|
|
@@ -2690,6 +2702,7 @@ async function createTextEngine(opts = {}) {
|
|
|
2690
2702
|
}
|
|
2691
2703
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2692
2704
|
0 && (module.exports = {
|
|
2705
|
+
CanvasRichTextAssetSchema,
|
|
2693
2706
|
createTextEngine,
|
|
2694
2707
|
isGlyphFill,
|
|
2695
2708
|
isShadowFill
|
package/dist/entry.node.d.cts
CHANGED
|
@@ -1,102 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
pixelRatio: number;
|
|
6
|
-
fontFamily: string;
|
|
7
|
-
fontSize: number;
|
|
8
|
-
color: string;
|
|
9
|
-
textAlign: "center";
|
|
10
|
-
};
|
|
11
|
-
LIMITS: {
|
|
12
|
-
minWidth: number;
|
|
13
|
-
maxWidth: number;
|
|
14
|
-
minHeight: number;
|
|
15
|
-
maxHeight: number;
|
|
16
|
-
minFontSize: number;
|
|
17
|
-
maxFontSize: number;
|
|
18
|
-
minDuration: number;
|
|
19
|
-
maxDuration: number;
|
|
20
|
-
maxTextLength: number;
|
|
21
|
-
};
|
|
22
|
-
ANIMATION_TYPES: readonly ["typewriter", "fadeIn", "slideIn", "shift", "ascend", "movingLetters"];
|
|
23
|
-
};
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { components } from '@shotstack/schemas';
|
|
24
3
|
|
|
25
|
-
|
|
26
|
-
type: "rich-text"
|
|
27
|
-
text:
|
|
28
|
-
width
|
|
29
|
-
height
|
|
30
|
-
font
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
4
|
+
declare const CanvasRichTextAssetSchema: z.ZodObject<{
|
|
5
|
+
type: z.ZodLiteral<"rich-text">;
|
|
6
|
+
text: z.ZodDefault<z.ZodString>;
|
|
7
|
+
width: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
8
|
+
height: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
9
|
+
font: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
11
|
+
normal: "normal";
|
|
12
|
+
italic: "italic";
|
|
13
|
+
oblique: "oblique";
|
|
14
|
+
}>>;
|
|
15
|
+
family: z.ZodDefault<z.ZodString>;
|
|
16
|
+
size: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
weight: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
18
|
+
color: z.ZodDefault<z.ZodString>;
|
|
19
|
+
opacity: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
background: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
letterSpacing: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
lineHeight: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
textTransform: z.ZodDefault<z.ZodEnum<{
|
|
26
|
+
none: "none";
|
|
27
|
+
uppercase: "uppercase";
|
|
28
|
+
lowercase: "lowercase";
|
|
29
|
+
capitalize: "capitalize";
|
|
30
|
+
}>>;
|
|
31
|
+
textDecoration: z.ZodDefault<z.ZodEnum<{
|
|
32
|
+
none: "none";
|
|
33
|
+
underline: "underline";
|
|
34
|
+
"line-through": "line-through";
|
|
35
|
+
}>>;
|
|
36
|
+
gradient: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
38
|
+
linear: "linear";
|
|
39
|
+
radial: "radial";
|
|
40
|
+
}>>;
|
|
41
|
+
angle: z.ZodDefault<z.ZodNumber>;
|
|
42
|
+
stops: z.ZodArray<z.ZodObject<{
|
|
43
|
+
offset: z.ZodNumber;
|
|
44
|
+
color: z.ZodString;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
stroke: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
width: z.ZodDefault<z.ZodNumber>;
|
|
50
|
+
color: z.ZodDefault<z.ZodString>;
|
|
51
|
+
opacity: z.ZodDefault<z.ZodNumber>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
shadow: z.ZodOptional<z.ZodObject<{
|
|
54
|
+
offsetX: z.ZodDefault<z.ZodNumber>;
|
|
55
|
+
offsetY: z.ZodDefault<z.ZodNumber>;
|
|
56
|
+
blur: z.ZodDefault<z.ZodNumber>;
|
|
57
|
+
color: z.ZodDefault<z.ZodString>;
|
|
58
|
+
opacity: z.ZodDefault<z.ZodNumber>;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
background: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
borderRadius: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
62
|
+
color: z.ZodOptional<z.ZodString>;
|
|
63
|
+
opacity: z.ZodDefault<z.ZodNumber>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
border: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
width: z.ZodDefault<z.ZodNumber>;
|
|
67
|
+
color: z.ZodDefault<z.ZodString>;
|
|
68
|
+
opacity: z.ZodDefault<z.ZodNumber>;
|
|
69
|
+
radius: z.ZodDefault<z.ZodNumber>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
72
|
+
top: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
right: z.ZodDefault<z.ZodNumber>;
|
|
74
|
+
bottom: z.ZodDefault<z.ZodNumber>;
|
|
75
|
+
left: z.ZodDefault<z.ZodNumber>;
|
|
76
|
+
}, z.core.$strip>]>>;
|
|
77
|
+
align: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
horizontal: z.ZodDefault<z.ZodEnum<{
|
|
79
|
+
center: "center";
|
|
80
|
+
right: "right";
|
|
81
|
+
left: "left";
|
|
82
|
+
}>>;
|
|
83
|
+
vertical: z.ZodDefault<z.ZodEnum<{
|
|
84
|
+
top: "top";
|
|
85
|
+
bottom: "bottom";
|
|
86
|
+
middle: "middle";
|
|
87
|
+
}>>;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
animation: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
preset: z.ZodEnum<{
|
|
91
|
+
typewriter: "typewriter";
|
|
92
|
+
fadeIn: "fadeIn";
|
|
93
|
+
slideIn: "slideIn";
|
|
94
|
+
shift: "shift";
|
|
95
|
+
ascend: "ascend";
|
|
96
|
+
movingLetters: "movingLetters";
|
|
97
|
+
}>;
|
|
98
|
+
speed: z.ZodDefault<z.ZodNumber>;
|
|
99
|
+
duration: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
101
|
+
character: "character";
|
|
102
|
+
word: "word";
|
|
103
|
+
}>>;
|
|
104
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
105
|
+
right: "right";
|
|
106
|
+
left: "left";
|
|
107
|
+
up: "up";
|
|
108
|
+
down: "down";
|
|
109
|
+
}>>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
customFonts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
112
|
+
src: z.ZodString;
|
|
113
|
+
family: z.ZodString;
|
|
114
|
+
weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
115
|
+
style: z.ZodOptional<z.ZodString>;
|
|
116
|
+
originalFamily: z.ZodOptional<z.ZodString>;
|
|
117
|
+
}, z.core.$strip>>>;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
type CanvasRichTextAsset = z.infer<typeof CanvasRichTextAssetSchema>;
|
|
99
120
|
|
|
121
|
+
type ShotstackRichTextAsset = components["schemas"]["RichTextAsset"];
|
|
100
122
|
type RGBA = {
|
|
101
123
|
r: number;
|
|
102
124
|
g: number;
|
|
@@ -218,7 +240,7 @@ type Renderer = {
|
|
|
218
240
|
render(ops: DrawOp[]): Promise<void>;
|
|
219
241
|
toPNG?: () => Promise<Buffer>;
|
|
220
242
|
};
|
|
221
|
-
type ValidAsset =
|
|
243
|
+
type ValidAsset = CanvasRichTextAsset;
|
|
222
244
|
declare const isShadowFill: (op: DrawOp) => op is Extract<DrawOp, {
|
|
223
245
|
op: "FillPath";
|
|
224
246
|
}> & {
|
|
@@ -255,7 +277,7 @@ declare function createTextEngine(opts?: {
|
|
|
255
277
|
wasmBaseURL?: string;
|
|
256
278
|
}): Promise<{
|
|
257
279
|
validate(input: unknown): {
|
|
258
|
-
value:
|
|
280
|
+
value: CanvasRichTextAsset;
|
|
259
281
|
};
|
|
260
282
|
registerFontFromFile(path: string, desc: {
|
|
261
283
|
family: string;
|
|
@@ -265,7 +287,7 @@ declare function createTextEngine(opts?: {
|
|
|
265
287
|
family: string;
|
|
266
288
|
weight?: string | number;
|
|
267
289
|
}): Promise<void>;
|
|
268
|
-
renderFrame(asset:
|
|
290
|
+
renderFrame(asset: CanvasRichTextAsset, tSeconds: number, clipDuration?: number): Promise<DrawOp[]>;
|
|
269
291
|
createRenderer(p: {
|
|
270
292
|
width?: number;
|
|
271
293
|
height?: number;
|
|
@@ -274,8 +296,8 @@ declare function createTextEngine(opts?: {
|
|
|
274
296
|
render(ops: DrawOp[]): Promise<void>;
|
|
275
297
|
toPNG(): Promise<Buffer>;
|
|
276
298
|
}>;
|
|
277
|
-
generateVideo(asset:
|
|
299
|
+
generateVideo(asset: CanvasRichTextAsset, options: Partial<VideoGenerationOptions>): Promise<string>;
|
|
278
300
|
destroy(): void;
|
|
279
301
|
}>;
|
|
280
302
|
|
|
281
|
-
export { type DrawOp, type EngineInit, type Glyph, type GradientSpec, type RGBA, type Renderer, type ShapedLine, type ValidAsset, createTextEngine, isGlyphFill, isShadowFill };
|
|
303
|
+
export { type CanvasRichTextAsset, CanvasRichTextAssetSchema, type DrawOp, type EngineInit, type Glyph, type GradientSpec, type RGBA, type Renderer, type ShapedLine, type ShotstackRichTextAsset, type ValidAsset, createTextEngine, isGlyphFill, isShadowFill };
|