@shotstack/shotstack-canvas 1.4.1 → 1.4.2
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 +6 -13
- package/dist/entry.node.d.cts +0 -4
- package/dist/entry.node.d.ts +0 -4
- package/dist/entry.node.js +6 -13
- package/dist/entry.web.d.ts +0 -4
- package/dist/entry.web.js +11 -20
- package/package.json +1 -1
package/dist/entry.node.cjs
CHANGED
|
@@ -99,7 +99,6 @@ var fontSchema = import_joi.default.object({
|
|
|
99
99
|
family: import_joi.default.string().default(CANVAS_CONFIG.DEFAULTS.fontFamily),
|
|
100
100
|
size: import_joi.default.number().min(CANVAS_CONFIG.LIMITS.minFontSize).max(CANVAS_CONFIG.LIMITS.maxFontSize).default(CANVAS_CONFIG.DEFAULTS.fontSize),
|
|
101
101
|
weight: import_joi.default.alternatives().try(import_joi.default.string(), import_joi.default.number()).default("400"),
|
|
102
|
-
style: import_joi.default.string().valid("normal", "italic", "oblique").default("normal"),
|
|
103
102
|
color: import_joi.default.string().pattern(HEX6).default(CANVAS_CONFIG.DEFAULTS.color),
|
|
104
103
|
opacity: import_joi.default.number().min(0).max(1).default(1)
|
|
105
104
|
}).unknown(false);
|
|
@@ -419,8 +418,7 @@ var FontRegistry = class _FontRegistry {
|
|
|
419
418
|
return this.hb;
|
|
420
419
|
}
|
|
421
420
|
key(desc) {
|
|
422
|
-
|
|
423
|
-
return `${desc.family}__${desc.weight ?? "400"}__${normalizedStyle}`;
|
|
421
|
+
return `${desc.family}__${desc.weight ?? "400"}`;
|
|
424
422
|
}
|
|
425
423
|
async registerFromBytes(bytes, desc) {
|
|
426
424
|
try {
|
|
@@ -469,14 +467,12 @@ var FontRegistry = class _FontRegistry {
|
|
|
469
467
|
try {
|
|
470
468
|
const bytes = await loader({
|
|
471
469
|
family: desc.family,
|
|
472
|
-
weight: desc.weight ?? "400"
|
|
473
|
-
style: desc.style ?? "normal"
|
|
470
|
+
weight: desc.weight ?? "400"
|
|
474
471
|
});
|
|
475
472
|
if (!bytes) return false;
|
|
476
473
|
await this.registerFromBytes(bytes, {
|
|
477
474
|
family: desc.family,
|
|
478
|
-
weight: desc.weight ?? "400"
|
|
479
|
-
style: desc.style ?? "normal"
|
|
475
|
+
weight: desc.weight ?? "400"
|
|
480
476
|
});
|
|
481
477
|
return true;
|
|
482
478
|
} catch {
|
|
@@ -2220,8 +2216,7 @@ async function createTextEngine(opts = {}) {
|
|
|
2220
2216
|
const bytes = await loadFileOrHttpToArrayBuffer(cf.src);
|
|
2221
2217
|
await fonts.registerFromBytes(bytes, {
|
|
2222
2218
|
family: cf.family,
|
|
2223
|
-
weight: cf.weight ?? "400"
|
|
2224
|
-
style: cf.style ?? "normal"
|
|
2219
|
+
weight: cf.weight ?? "400"
|
|
2225
2220
|
});
|
|
2226
2221
|
} catch (err) {
|
|
2227
2222
|
throw new Error(
|
|
@@ -2233,7 +2228,6 @@ async function createTextEngine(opts = {}) {
|
|
|
2233
2228
|
const main = asset.font ?? {
|
|
2234
2229
|
family: "Roboto",
|
|
2235
2230
|
weight: "400",
|
|
2236
|
-
style: "normal",
|
|
2237
2231
|
size: 48,
|
|
2238
2232
|
color: "#000000",
|
|
2239
2233
|
opacity: 1
|
|
@@ -2285,10 +2279,10 @@ async function createTextEngine(opts = {}) {
|
|
|
2285
2279
|
async renderFrame(asset, tSeconds, clipDuration) {
|
|
2286
2280
|
try {
|
|
2287
2281
|
const main = await ensureFonts(asset);
|
|
2288
|
-
const desc = { family: main.family, weight: `${main.weight}
|
|
2282
|
+
const desc = { family: main.family, weight: `${main.weight}` };
|
|
2289
2283
|
let lines;
|
|
2290
2284
|
try {
|
|
2291
|
-
const emojiDesc = { family: "NotoEmoji", weight: "400"
|
|
2285
|
+
const emojiDesc = { family: "NotoEmoji", weight: "400" };
|
|
2292
2286
|
let emojiAvailable = false;
|
|
2293
2287
|
try {
|
|
2294
2288
|
await fonts.getFace(emojiDesc);
|
|
@@ -2329,7 +2323,6 @@ async function createTextEngine(opts = {}) {
|
|
|
2329
2323
|
family: main.family,
|
|
2330
2324
|
size: main.size,
|
|
2331
2325
|
weight: `${main.weight}`,
|
|
2332
|
-
style: main.style,
|
|
2333
2326
|
color: main.color,
|
|
2334
2327
|
opacity: main.opacity
|
|
2335
2328
|
},
|
package/dist/entry.node.d.cts
CHANGED
|
@@ -31,7 +31,6 @@ type RichTextValidated = Required<{
|
|
|
31
31
|
family: string;
|
|
32
32
|
size: number;
|
|
33
33
|
weight: string | number;
|
|
34
|
-
style: "normal" | "italic" | "oblique";
|
|
35
34
|
color: string;
|
|
36
35
|
opacity: number;
|
|
37
36
|
};
|
|
@@ -124,7 +123,6 @@ type Glyph = {
|
|
|
124
123
|
fontDesc?: {
|
|
125
124
|
family: string;
|
|
126
125
|
weight?: string | number;
|
|
127
|
-
style?: string;
|
|
128
126
|
};
|
|
129
127
|
};
|
|
130
128
|
type ShapedLine = {
|
|
@@ -232,12 +230,10 @@ declare function createTextEngine(opts?: {
|
|
|
232
230
|
registerFontFromFile(path: string, desc: {
|
|
233
231
|
family: string;
|
|
234
232
|
weight?: string | number;
|
|
235
|
-
style?: string;
|
|
236
233
|
}): Promise<void>;
|
|
237
234
|
registerFontFromUrl(url: string, desc: {
|
|
238
235
|
family: string;
|
|
239
236
|
weight?: string | number;
|
|
240
|
-
style?: string;
|
|
241
237
|
}): Promise<void>;
|
|
242
238
|
renderFrame(asset: RichTextValidated, tSeconds: number, clipDuration?: number): Promise<DrawOp[]>;
|
|
243
239
|
createRenderer(p: {
|
package/dist/entry.node.d.ts
CHANGED
|
@@ -31,7 +31,6 @@ type RichTextValidated = Required<{
|
|
|
31
31
|
family: string;
|
|
32
32
|
size: number;
|
|
33
33
|
weight: string | number;
|
|
34
|
-
style: "normal" | "italic" | "oblique";
|
|
35
34
|
color: string;
|
|
36
35
|
opacity: number;
|
|
37
36
|
};
|
|
@@ -124,7 +123,6 @@ type Glyph = {
|
|
|
124
123
|
fontDesc?: {
|
|
125
124
|
family: string;
|
|
126
125
|
weight?: string | number;
|
|
127
|
-
style?: string;
|
|
128
126
|
};
|
|
129
127
|
};
|
|
130
128
|
type ShapedLine = {
|
|
@@ -232,12 +230,10 @@ declare function createTextEngine(opts?: {
|
|
|
232
230
|
registerFontFromFile(path: string, desc: {
|
|
233
231
|
family: string;
|
|
234
232
|
weight?: string | number;
|
|
235
|
-
style?: string;
|
|
236
233
|
}): Promise<void>;
|
|
237
234
|
registerFontFromUrl(url: string, desc: {
|
|
238
235
|
family: string;
|
|
239
236
|
weight?: string | number;
|
|
240
|
-
style?: string;
|
|
241
237
|
}): Promise<void>;
|
|
242
238
|
renderFrame(asset: RichTextValidated, tSeconds: number, clipDuration?: number): Promise<DrawOp[]>;
|
|
243
239
|
createRenderer(p: {
|
package/dist/entry.node.js
CHANGED
|
@@ -61,7 +61,6 @@ var fontSchema = Joi.object({
|
|
|
61
61
|
family: Joi.string().default(CANVAS_CONFIG.DEFAULTS.fontFamily),
|
|
62
62
|
size: Joi.number().min(CANVAS_CONFIG.LIMITS.minFontSize).max(CANVAS_CONFIG.LIMITS.maxFontSize).default(CANVAS_CONFIG.DEFAULTS.fontSize),
|
|
63
63
|
weight: Joi.alternatives().try(Joi.string(), Joi.number()).default("400"),
|
|
64
|
-
style: Joi.string().valid("normal", "italic", "oblique").default("normal"),
|
|
65
64
|
color: Joi.string().pattern(HEX6).default(CANVAS_CONFIG.DEFAULTS.color),
|
|
66
65
|
opacity: Joi.number().min(0).max(1).default(1)
|
|
67
66
|
}).unknown(false);
|
|
@@ -380,8 +379,7 @@ var FontRegistry = class _FontRegistry {
|
|
|
380
379
|
return this.hb;
|
|
381
380
|
}
|
|
382
381
|
key(desc) {
|
|
383
|
-
|
|
384
|
-
return `${desc.family}__${desc.weight ?? "400"}__${normalizedStyle}`;
|
|
382
|
+
return `${desc.family}__${desc.weight ?? "400"}`;
|
|
385
383
|
}
|
|
386
384
|
async registerFromBytes(bytes, desc) {
|
|
387
385
|
try {
|
|
@@ -430,14 +428,12 @@ var FontRegistry = class _FontRegistry {
|
|
|
430
428
|
try {
|
|
431
429
|
const bytes = await loader({
|
|
432
430
|
family: desc.family,
|
|
433
|
-
weight: desc.weight ?? "400"
|
|
434
|
-
style: desc.style ?? "normal"
|
|
431
|
+
weight: desc.weight ?? "400"
|
|
435
432
|
});
|
|
436
433
|
if (!bytes) return false;
|
|
437
434
|
await this.registerFromBytes(bytes, {
|
|
438
435
|
family: desc.family,
|
|
439
|
-
weight: desc.weight ?? "400"
|
|
440
|
-
style: desc.style ?? "normal"
|
|
436
|
+
weight: desc.weight ?? "400"
|
|
441
437
|
});
|
|
442
438
|
return true;
|
|
443
439
|
} catch {
|
|
@@ -2181,8 +2177,7 @@ async function createTextEngine(opts = {}) {
|
|
|
2181
2177
|
const bytes = await loadFileOrHttpToArrayBuffer(cf.src);
|
|
2182
2178
|
await fonts.registerFromBytes(bytes, {
|
|
2183
2179
|
family: cf.family,
|
|
2184
|
-
weight: cf.weight ?? "400"
|
|
2185
|
-
style: cf.style ?? "normal"
|
|
2180
|
+
weight: cf.weight ?? "400"
|
|
2186
2181
|
});
|
|
2187
2182
|
} catch (err) {
|
|
2188
2183
|
throw new Error(
|
|
@@ -2194,7 +2189,6 @@ async function createTextEngine(opts = {}) {
|
|
|
2194
2189
|
const main = asset.font ?? {
|
|
2195
2190
|
family: "Roboto",
|
|
2196
2191
|
weight: "400",
|
|
2197
|
-
style: "normal",
|
|
2198
2192
|
size: 48,
|
|
2199
2193
|
color: "#000000",
|
|
2200
2194
|
opacity: 1
|
|
@@ -2246,10 +2240,10 @@ async function createTextEngine(opts = {}) {
|
|
|
2246
2240
|
async renderFrame(asset, tSeconds, clipDuration) {
|
|
2247
2241
|
try {
|
|
2248
2242
|
const main = await ensureFonts(asset);
|
|
2249
|
-
const desc = { family: main.family, weight: `${main.weight}
|
|
2243
|
+
const desc = { family: main.family, weight: `${main.weight}` };
|
|
2250
2244
|
let lines;
|
|
2251
2245
|
try {
|
|
2252
|
-
const emojiDesc = { family: "NotoEmoji", weight: "400"
|
|
2246
|
+
const emojiDesc = { family: "NotoEmoji", weight: "400" };
|
|
2253
2247
|
let emojiAvailable = false;
|
|
2254
2248
|
try {
|
|
2255
2249
|
await fonts.getFace(emojiDesc);
|
|
@@ -2290,7 +2284,6 @@ async function createTextEngine(opts = {}) {
|
|
|
2290
2284
|
family: main.family,
|
|
2291
2285
|
size: main.size,
|
|
2292
2286
|
weight: `${main.weight}`,
|
|
2293
|
-
style: main.style,
|
|
2294
2287
|
color: main.color,
|
|
2295
2288
|
opacity: main.opacity
|
|
2296
2289
|
},
|
package/dist/entry.web.d.ts
CHANGED
|
@@ -31,7 +31,6 @@ type RichTextValidated = Required<{
|
|
|
31
31
|
family: string;
|
|
32
32
|
size: number;
|
|
33
33
|
weight: string | number;
|
|
34
|
-
style: "normal" | "italic" | "oblique";
|
|
35
34
|
color: string;
|
|
36
35
|
opacity: number;
|
|
37
36
|
};
|
|
@@ -124,7 +123,6 @@ type Glyph = {
|
|
|
124
123
|
fontDesc?: {
|
|
125
124
|
family: string;
|
|
126
125
|
weight?: string | number;
|
|
127
|
-
style?: string;
|
|
128
126
|
};
|
|
129
127
|
};
|
|
130
128
|
type ShapedLine = {
|
|
@@ -215,12 +213,10 @@ declare function createTextEngine(opts?: {
|
|
|
215
213
|
registerFontFromUrl(url: string, desc: {
|
|
216
214
|
family: string;
|
|
217
215
|
weight?: string | number;
|
|
218
|
-
style?: string;
|
|
219
216
|
}): Promise<void>;
|
|
220
217
|
registerFontFromFile(source: string | Blob, desc: {
|
|
221
218
|
family: string;
|
|
222
219
|
weight?: string | number;
|
|
223
|
-
style?: string;
|
|
224
220
|
}): Promise<void>;
|
|
225
221
|
renderFrame(asset: RichTextValidated, tSeconds: number, clipDuration?: number): Promise<DrawOp[]>;
|
|
226
222
|
createRenderer(canvas: HTMLCanvasElement | OffscreenCanvas): {
|
package/dist/entry.web.js
CHANGED
|
@@ -65,7 +65,6 @@ var fontSchema = Joi.object({
|
|
|
65
65
|
family: Joi.string().default(CANVAS_CONFIG.DEFAULTS.fontFamily),
|
|
66
66
|
size: Joi.number().min(CANVAS_CONFIG.LIMITS.minFontSize).max(CANVAS_CONFIG.LIMITS.maxFontSize).default(CANVAS_CONFIG.DEFAULTS.fontSize),
|
|
67
67
|
weight: Joi.alternatives().try(Joi.string(), Joi.number()).default("400"),
|
|
68
|
-
style: Joi.string().valid("normal", "italic", "oblique").default("normal"),
|
|
69
68
|
color: Joi.string().pattern(HEX6).default(CANVAS_CONFIG.DEFAULTS.color),
|
|
70
69
|
opacity: Joi.number().min(0).max(1).default(1)
|
|
71
70
|
}).unknown(false);
|
|
@@ -383,8 +382,7 @@ var _FontRegistry = class _FontRegistry {
|
|
|
383
382
|
return this.hb;
|
|
384
383
|
}
|
|
385
384
|
key(desc) {
|
|
386
|
-
|
|
387
|
-
return `${desc.family}__${desc.weight ?? "400"}__${normalizedStyle}`;
|
|
385
|
+
return `${desc.family}__${desc.weight ?? "400"}`;
|
|
388
386
|
}
|
|
389
387
|
async registerFromBytes(bytes, desc) {
|
|
390
388
|
try {
|
|
@@ -433,14 +431,12 @@ var _FontRegistry = class _FontRegistry {
|
|
|
433
431
|
try {
|
|
434
432
|
const bytes = await loader({
|
|
435
433
|
family: desc.family,
|
|
436
|
-
weight: desc.weight ?? "400"
|
|
437
|
-
style: desc.style ?? "normal"
|
|
434
|
+
weight: desc.weight ?? "400"
|
|
438
435
|
});
|
|
439
436
|
if (!bytes) return false;
|
|
440
437
|
await this.registerFromBytes(bytes, {
|
|
441
438
|
family: desc.family,
|
|
442
|
-
weight: desc.weight ?? "400"
|
|
443
|
-
style: desc.style ?? "normal"
|
|
439
|
+
weight: desc.weight ?? "400"
|
|
444
440
|
});
|
|
445
441
|
return true;
|
|
446
442
|
} catch {
|
|
@@ -1843,8 +1839,7 @@ async function createTextEngine(opts = {}) {
|
|
|
1843
1839
|
FontRegistry.setFallbackLoader(async (desc) => {
|
|
1844
1840
|
const family = (desc.family ?? "Roboto").toLowerCase();
|
|
1845
1841
|
const weight = `${desc.weight ?? "400"}`;
|
|
1846
|
-
|
|
1847
|
-
if (family === "roboto" && weight === "400" && style === "normal") {
|
|
1842
|
+
if (family === "roboto" && weight === "400") {
|
|
1848
1843
|
return fetchToArrayBuffer(DEFAULT_ROBOTO_URL);
|
|
1849
1844
|
}
|
|
1850
1845
|
return void 0;
|
|
@@ -1863,8 +1858,7 @@ async function createTextEngine(opts = {}) {
|
|
|
1863
1858
|
const bytes = await fetchToArrayBuffer(cf.src);
|
|
1864
1859
|
await fonts.registerFromBytes(bytes, {
|
|
1865
1860
|
family: cf.family,
|
|
1866
|
-
weight: cf.weight ?? "400"
|
|
1867
|
-
style: cf.style ?? "normal"
|
|
1861
|
+
weight: cf.weight ?? "400"
|
|
1868
1862
|
});
|
|
1869
1863
|
} catch (err) {
|
|
1870
1864
|
throw new Error(
|
|
@@ -1876,27 +1870,25 @@ async function createTextEngine(opts = {}) {
|
|
|
1876
1870
|
const main = asset.font ?? {
|
|
1877
1871
|
family: "Roboto",
|
|
1878
1872
|
weight: "400",
|
|
1879
|
-
style: "normal",
|
|
1880
1873
|
size: 48,
|
|
1881
1874
|
color: "#000000",
|
|
1882
1875
|
opacity: 1
|
|
1883
1876
|
};
|
|
1884
|
-
const desc = { family: main.family, weight: `${main.weight}
|
|
1877
|
+
const desc = { family: main.family, weight: `${main.weight}` };
|
|
1885
1878
|
const ensureFace = async () => {
|
|
1886
1879
|
try {
|
|
1887
1880
|
await fonts.getFace(desc);
|
|
1888
1881
|
} catch {
|
|
1889
|
-
const wantsDefaultRoboto = (main.family || "Roboto").toLowerCase() === "roboto" && `${main.weight}` === "400"
|
|
1882
|
+
const wantsDefaultRoboto = (main.family || "Roboto").toLowerCase() === "roboto" && `${main.weight}` === "400";
|
|
1890
1883
|
if (wantsDefaultRoboto) {
|
|
1891
1884
|
const bytes = await fetchToArrayBuffer(DEFAULT_ROBOTO_URL);
|
|
1892
1885
|
await fonts.registerFromBytes(bytes, {
|
|
1893
1886
|
family: "Roboto",
|
|
1894
|
-
weight: "400"
|
|
1895
|
-
style: "normal"
|
|
1887
|
+
weight: "400"
|
|
1896
1888
|
});
|
|
1897
1889
|
} else {
|
|
1898
1890
|
throw new Error(
|
|
1899
|
-
`Font not registered for ${desc.family}__${desc.weight}
|
|
1891
|
+
`Font not registered for ${desc.family}__${desc.weight}`
|
|
1900
1892
|
);
|
|
1901
1893
|
}
|
|
1902
1894
|
}
|
|
@@ -1967,10 +1959,10 @@ async function createTextEngine(opts = {}) {
|
|
|
1967
1959
|
async renderFrame(asset, tSeconds, clipDuration) {
|
|
1968
1960
|
try {
|
|
1969
1961
|
const main = await ensureFonts(asset);
|
|
1970
|
-
const desc = { family: main.family, weight: `${main.weight}
|
|
1962
|
+
const desc = { family: main.family, weight: `${main.weight}` };
|
|
1971
1963
|
let lines;
|
|
1972
1964
|
try {
|
|
1973
|
-
const emojiDesc = { family: "NotoEmoji", weight: "400"
|
|
1965
|
+
const emojiDesc = { family: "NotoEmoji", weight: "400" };
|
|
1974
1966
|
let emojiAvailable = false;
|
|
1975
1967
|
try {
|
|
1976
1968
|
await fonts.getFace(emojiDesc);
|
|
@@ -2011,7 +2003,6 @@ async function createTextEngine(opts = {}) {
|
|
|
2011
2003
|
family: main.family,
|
|
2012
2004
|
size: main.size,
|
|
2013
2005
|
weight: `${main.weight}`,
|
|
2014
|
-
style: main.style,
|
|
2015
2006
|
color: main.color,
|
|
2016
2007
|
opacity: main.opacity
|
|
2017
2008
|
},
|
package/package.json
CHANGED