@takumi-rs/wasm 2.0.0-beta.6 → 2.0.0-beta.7
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/export.cjs +39 -18
- package/dist/export.d.cts +10 -5
- package/dist/export.d.mts +10 -5
- package/dist/export.mjs +39 -13
- package/package.json +5 -5
package/dist/export.cjs
CHANGED
|
@@ -584,8 +584,12 @@ var Renderer = class {
|
|
|
584
584
|
return [...new Set(families.flat().map((f) => f.name))];
|
|
585
585
|
}
|
|
586
586
|
async render(node, options) {
|
|
587
|
-
const { fonts, fontFamilies, images, ...rest } = options ?? {};
|
|
588
|
-
const registeredFamilies = await this.prepareFonts(
|
|
587
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options ?? {};
|
|
588
|
+
const registeredFamilies = await this.prepareFonts((0, _takumi_rs_helpers.pickFonts)({
|
|
589
|
+
fonts,
|
|
590
|
+
source: node,
|
|
591
|
+
subset
|
|
592
|
+
}));
|
|
589
593
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
590
594
|
return this.inner.render(node, {
|
|
591
595
|
...rest,
|
|
@@ -594,8 +598,12 @@ var Renderer = class {
|
|
|
594
598
|
});
|
|
595
599
|
}
|
|
596
600
|
async renderAsDataUrl(node, options) {
|
|
597
|
-
const { fonts, fontFamilies, images, ...rest } = options ?? {};
|
|
598
|
-
const registeredFamilies = await this.prepareFonts(
|
|
601
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options ?? {};
|
|
602
|
+
const registeredFamilies = await this.prepareFonts((0, _takumi_rs_helpers.pickFonts)({
|
|
603
|
+
fonts,
|
|
604
|
+
source: node,
|
|
605
|
+
subset
|
|
606
|
+
}));
|
|
599
607
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
600
608
|
return this.inner.renderAsDataUrl(node, {
|
|
601
609
|
...rest,
|
|
@@ -604,8 +612,12 @@ var Renderer = class {
|
|
|
604
612
|
});
|
|
605
613
|
}
|
|
606
614
|
async renderSvg(node, options) {
|
|
607
|
-
const { fonts, fontFamilies, images, ...rest } = options ?? {};
|
|
608
|
-
const registeredFamilies = await this.prepareFonts(
|
|
615
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options ?? {};
|
|
616
|
+
const registeredFamilies = await this.prepareFonts((0, _takumi_rs_helpers.pickFonts)({
|
|
617
|
+
fonts,
|
|
618
|
+
source: node,
|
|
619
|
+
subset
|
|
620
|
+
}));
|
|
609
621
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
610
622
|
return this.inner.renderSvg(node, {
|
|
611
623
|
...rest,
|
|
@@ -614,8 +626,12 @@ var Renderer = class {
|
|
|
614
626
|
});
|
|
615
627
|
}
|
|
616
628
|
async measure(node, options) {
|
|
617
|
-
const { fonts, fontFamilies, images, ...rest } = options ?? {};
|
|
618
|
-
const registeredFamilies = await this.prepareFonts(
|
|
629
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options ?? {};
|
|
630
|
+
const registeredFamilies = await this.prepareFonts((0, _takumi_rs_helpers.pickFonts)({
|
|
631
|
+
fonts,
|
|
632
|
+
source: node,
|
|
633
|
+
subset
|
|
634
|
+
}));
|
|
619
635
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
620
636
|
return this.inner.measure(node, {
|
|
621
637
|
...rest,
|
|
@@ -624,8 +640,13 @@ var Renderer = class {
|
|
|
624
640
|
});
|
|
625
641
|
}
|
|
626
642
|
async renderAnimation(options) {
|
|
627
|
-
const { fonts, fontFamilies, images, ...rest } = options;
|
|
628
|
-
const
|
|
643
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options;
|
|
644
|
+
const nodes = options.scenes.map((scene) => scene.node);
|
|
645
|
+
const registeredFamilies = await this.prepareFonts((0, _takumi_rs_helpers.pickFonts)({
|
|
646
|
+
fonts,
|
|
647
|
+
source: nodes,
|
|
648
|
+
subset
|
|
649
|
+
}));
|
|
629
650
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
630
651
|
return this.inner.renderAnimation({
|
|
631
652
|
...rest,
|
|
@@ -634,8 +655,13 @@ var Renderer = class {
|
|
|
634
655
|
});
|
|
635
656
|
}
|
|
636
657
|
async encodeFrames(frames, options) {
|
|
637
|
-
const { fonts, fontFamilies, images, ...rest } = options;
|
|
638
|
-
const
|
|
658
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options;
|
|
659
|
+
const nodes = frames.map((frame) => frame.node);
|
|
660
|
+
const registeredFamilies = await this.prepareFonts((0, _takumi_rs_helpers.pickFonts)({
|
|
661
|
+
fonts,
|
|
662
|
+
source: nodes,
|
|
663
|
+
subset
|
|
664
|
+
}));
|
|
639
665
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
640
666
|
return this.inner.encodeFrames(frames, {
|
|
641
667
|
...rest,
|
|
@@ -685,10 +711,5 @@ function isBuffer(data) {
|
|
|
685
711
|
//#endregion
|
|
686
712
|
exports.Renderer = Renderer;
|
|
687
713
|
exports.default = __wbg_init;
|
|
688
|
-
|
|
689
|
-
enumerable: true,
|
|
690
|
-
get: function() {
|
|
691
|
-
return _takumi_rs_helpers.extractResourceUrls;
|
|
692
|
-
}
|
|
693
|
-
});
|
|
714
|
+
exports.extractResourceUrls = _takumi_rs_helpers.extractResourceUrls;
|
|
694
715
|
exports.initSync = initSync;
|
package/dist/export.d.cts
CHANGED
|
@@ -240,7 +240,8 @@ declare function __wbg_init(module_or_path?: {
|
|
|
240
240
|
//#endregion
|
|
241
241
|
//#region src/export.d.ts
|
|
242
242
|
type FontLoader = Font | (Omit<FontDetails, "data"> & {
|
|
243
|
-
data: () => Promise<FontDetails["data"]> | FontDetails["data"];
|
|
243
|
+
data: () => Promise<FontDetails["data"]> | FontDetails["data"]; /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
|
|
244
|
+
ranges?: [number, number][];
|
|
244
245
|
} & ({
|
|
245
246
|
key: string;
|
|
246
247
|
} | {
|
|
@@ -269,7 +270,8 @@ type OutputFormatOptions = {
|
|
|
269
270
|
};
|
|
270
271
|
type RenderOptions = Omit<RenderOptions$1, "images" | "format" | "quality"> & OutputFormatOptions & {
|
|
271
272
|
fonts?: FontLoader[];
|
|
272
|
-
images?: ImageLoader[];
|
|
273
|
+
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
274
|
+
subset?: boolean;
|
|
273
275
|
};
|
|
274
276
|
/**
|
|
275
277
|
* Animation output format. On wasm, WebP animation is always lossless (lossy
|
|
@@ -284,15 +286,18 @@ type AnimationOutputFormatOptions = {
|
|
|
284
286
|
};
|
|
285
287
|
type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format"> & AnimationOutputFormatOptions & {
|
|
286
288
|
fonts?: FontLoader[];
|
|
287
|
-
images?: ImageLoader[];
|
|
289
|
+
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
290
|
+
subset?: boolean;
|
|
288
291
|
};
|
|
289
292
|
type EncodeFramesOptions = Omit<EncodeFramesOptions$1, "images" | "format"> & AnimationOutputFormatOptions & {
|
|
290
293
|
fonts?: FontLoader[];
|
|
291
|
-
images?: ImageLoader[];
|
|
294
|
+
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
295
|
+
subset?: boolean;
|
|
292
296
|
};
|
|
293
297
|
type SvgRenderOptions = Omit<SvgRenderOptions$1, "images"> & {
|
|
294
298
|
fonts?: FontLoader[];
|
|
295
|
-
images?: ImageLoader[];
|
|
299
|
+
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
300
|
+
subset?: boolean;
|
|
296
301
|
};
|
|
297
302
|
declare class Renderer {
|
|
298
303
|
private fontsByKey;
|
package/dist/export.d.mts
CHANGED
|
@@ -240,7 +240,8 @@ declare function __wbg_init(module_or_path?: {
|
|
|
240
240
|
//#endregion
|
|
241
241
|
//#region src/export.d.ts
|
|
242
242
|
type FontLoader = Font | (Omit<FontDetails, "data"> & {
|
|
243
|
-
data: () => Promise<FontDetails["data"]> | FontDetails["data"];
|
|
243
|
+
data: () => Promise<FontDetails["data"]> | FontDetails["data"]; /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
|
|
244
|
+
ranges?: [number, number][];
|
|
244
245
|
} & ({
|
|
245
246
|
key: string;
|
|
246
247
|
} | {
|
|
@@ -269,7 +270,8 @@ type OutputFormatOptions = {
|
|
|
269
270
|
};
|
|
270
271
|
type RenderOptions = Omit<RenderOptions$1, "images" | "format" | "quality"> & OutputFormatOptions & {
|
|
271
272
|
fonts?: FontLoader[];
|
|
272
|
-
images?: ImageLoader[];
|
|
273
|
+
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
274
|
+
subset?: boolean;
|
|
273
275
|
};
|
|
274
276
|
/**
|
|
275
277
|
* Animation output format. On wasm, WebP animation is always lossless (lossy
|
|
@@ -284,15 +286,18 @@ type AnimationOutputFormatOptions = {
|
|
|
284
286
|
};
|
|
285
287
|
type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format"> & AnimationOutputFormatOptions & {
|
|
286
288
|
fonts?: FontLoader[];
|
|
287
|
-
images?: ImageLoader[];
|
|
289
|
+
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
290
|
+
subset?: boolean;
|
|
288
291
|
};
|
|
289
292
|
type EncodeFramesOptions = Omit<EncodeFramesOptions$1, "images" | "format"> & AnimationOutputFormatOptions & {
|
|
290
293
|
fonts?: FontLoader[];
|
|
291
|
-
images?: ImageLoader[];
|
|
294
|
+
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
295
|
+
subset?: boolean;
|
|
292
296
|
};
|
|
293
297
|
type SvgRenderOptions = Omit<SvgRenderOptions$1, "images"> & {
|
|
294
298
|
fonts?: FontLoader[];
|
|
295
|
-
images?: ImageLoader[];
|
|
299
|
+
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
300
|
+
subset?: boolean;
|
|
296
301
|
};
|
|
297
302
|
declare class Renderer {
|
|
298
303
|
private fontsByKey;
|
package/dist/export.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractResourceUrls } from "@takumi-rs/helpers";
|
|
1
|
+
import { extractResourceUrls, pickFonts } from "@takumi-rs/helpers";
|
|
2
2
|
//#region pkg/takumi_wasm.js
|
|
3
3
|
/**
|
|
4
4
|
* The main renderer for Takumi image rendering engine.
|
|
@@ -580,8 +580,12 @@ var Renderer = class {
|
|
|
580
580
|
return [...new Set(families.flat().map((f) => f.name))];
|
|
581
581
|
}
|
|
582
582
|
async render(node, options) {
|
|
583
|
-
const { fonts, fontFamilies, images, ...rest } = options ?? {};
|
|
584
|
-
const registeredFamilies = await this.prepareFonts(
|
|
583
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options ?? {};
|
|
584
|
+
const registeredFamilies = await this.prepareFonts(pickFonts({
|
|
585
|
+
fonts,
|
|
586
|
+
source: node,
|
|
587
|
+
subset
|
|
588
|
+
}));
|
|
585
589
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
586
590
|
return this.inner.render(node, {
|
|
587
591
|
...rest,
|
|
@@ -590,8 +594,12 @@ var Renderer = class {
|
|
|
590
594
|
});
|
|
591
595
|
}
|
|
592
596
|
async renderAsDataUrl(node, options) {
|
|
593
|
-
const { fonts, fontFamilies, images, ...rest } = options ?? {};
|
|
594
|
-
const registeredFamilies = await this.prepareFonts(
|
|
597
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options ?? {};
|
|
598
|
+
const registeredFamilies = await this.prepareFonts(pickFonts({
|
|
599
|
+
fonts,
|
|
600
|
+
source: node,
|
|
601
|
+
subset
|
|
602
|
+
}));
|
|
595
603
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
596
604
|
return this.inner.renderAsDataUrl(node, {
|
|
597
605
|
...rest,
|
|
@@ -600,8 +608,12 @@ var Renderer = class {
|
|
|
600
608
|
});
|
|
601
609
|
}
|
|
602
610
|
async renderSvg(node, options) {
|
|
603
|
-
const { fonts, fontFamilies, images, ...rest } = options ?? {};
|
|
604
|
-
const registeredFamilies = await this.prepareFonts(
|
|
611
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options ?? {};
|
|
612
|
+
const registeredFamilies = await this.prepareFonts(pickFonts({
|
|
613
|
+
fonts,
|
|
614
|
+
source: node,
|
|
615
|
+
subset
|
|
616
|
+
}));
|
|
605
617
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
606
618
|
return this.inner.renderSvg(node, {
|
|
607
619
|
...rest,
|
|
@@ -610,8 +622,12 @@ var Renderer = class {
|
|
|
610
622
|
});
|
|
611
623
|
}
|
|
612
624
|
async measure(node, options) {
|
|
613
|
-
const { fonts, fontFamilies, images, ...rest } = options ?? {};
|
|
614
|
-
const registeredFamilies = await this.prepareFonts(
|
|
625
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options ?? {};
|
|
626
|
+
const registeredFamilies = await this.prepareFonts(pickFonts({
|
|
627
|
+
fonts,
|
|
628
|
+
source: node,
|
|
629
|
+
subset
|
|
630
|
+
}));
|
|
615
631
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
616
632
|
return this.inner.measure(node, {
|
|
617
633
|
...rest,
|
|
@@ -620,8 +636,13 @@ var Renderer = class {
|
|
|
620
636
|
});
|
|
621
637
|
}
|
|
622
638
|
async renderAnimation(options) {
|
|
623
|
-
const { fonts, fontFamilies, images, ...rest } = options;
|
|
624
|
-
const
|
|
639
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options;
|
|
640
|
+
const nodes = options.scenes.map((scene) => scene.node);
|
|
641
|
+
const registeredFamilies = await this.prepareFonts(pickFonts({
|
|
642
|
+
fonts,
|
|
643
|
+
source: nodes,
|
|
644
|
+
subset
|
|
645
|
+
}));
|
|
625
646
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
626
647
|
return this.inner.renderAnimation({
|
|
627
648
|
...rest,
|
|
@@ -630,8 +651,13 @@ var Renderer = class {
|
|
|
630
651
|
});
|
|
631
652
|
}
|
|
632
653
|
async encodeFrames(frames, options) {
|
|
633
|
-
const { fonts, fontFamilies, images, ...rest } = options;
|
|
634
|
-
const
|
|
654
|
+
const { fonts, fontFamilies, images, subset, ...rest } = options;
|
|
655
|
+
const nodes = frames.map((frame) => frame.node);
|
|
656
|
+
const registeredFamilies = await this.prepareFonts(pickFonts({
|
|
657
|
+
fonts,
|
|
658
|
+
source: nodes,
|
|
659
|
+
subset
|
|
660
|
+
}));
|
|
635
661
|
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
636
662
|
return this.inner.encodeFrames(frames, {
|
|
637
663
|
...rest,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takumi-rs/wasm",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.7",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"css",
|
|
6
6
|
"image",
|
|
@@ -89,13 +89,13 @@
|
|
|
89
89
|
"publish-lint": "attw --pack . && publint --strict ."
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@takumi-rs/helpers": "2.0.0-beta.
|
|
92
|
+
"@takumi-rs/helpers": "2.0.0-beta.7"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@types/bun": "
|
|
95
|
+
"@types/bun": "^1.3.14",
|
|
96
96
|
"csstype": "^3.2.3",
|
|
97
|
-
"tsdown": "
|
|
98
|
-
"unrun": "
|
|
97
|
+
"tsdown": "^0.22.3",
|
|
98
|
+
"unrun": "^0.3.1"
|
|
99
99
|
},
|
|
100
100
|
"readme": "README.md"
|
|
101
101
|
}
|