@takumi-rs/wasm 2.0.0-beta.8 → 2.0.0-rc.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/bundlers/bun.mjs +2 -2
- package/bundlers/node.mjs +2 -2
- package/dist/export.cjs +49 -100
- package/dist/export.d.cts +7 -44
- package/dist/export.d.mts +7 -44
- package/dist/export.mjs +50 -101
- package/package.json +43 -13
- package/pkg/takumi_wasm_bg.wasm +0 -0
- package/pkg/takumi_wasm_bg.wasm.d.ts +1 -3
- package/bundlers/type.d.ts +0 -3
- /package/bundlers/{next.d.ts → wasm-module.d.ts} +0 -0
package/bundlers/bun.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as wasm from "../dist/export";
|
|
1
|
+
import * as wasm from "../dist/export.mjs";
|
|
2
2
|
import wasmPath from "../pkg/takumi_wasm_bg.wasm";
|
|
3
3
|
|
|
4
4
|
const wasmBytes = await Bun.file(new URL(wasmPath, import.meta.url)).arrayBuffer();
|
|
5
5
|
|
|
6
6
|
wasm.initSync({ module: wasmBytes });
|
|
7
7
|
|
|
8
|
-
export * from "../dist/export";
|
|
8
|
+
export * from "../dist/export.mjs";
|
|
9
9
|
export default wasm.default;
|
package/bundlers/node.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import * as wasm from "../dist/export";
|
|
2
|
+
import * as wasm from "../dist/export.mjs";
|
|
3
3
|
|
|
4
4
|
const wasmBytes = readFileSync(new URL("../pkg/takumi_wasm_bg.wasm", import.meta.url));
|
|
5
5
|
|
|
6
6
|
wasm.initSync({ module: wasmBytes });
|
|
7
7
|
|
|
8
|
-
export * from "../dist/export";
|
|
8
|
+
export * from "../dist/export.mjs";
|
|
9
9
|
export default wasm.default;
|
package/dist/export.cjs
CHANGED
|
@@ -23,21 +23,6 @@ var Renderer$1 = class {
|
|
|
23
23
|
wasm.__wbg_renderer_free(ptr, 0);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Encodes a precomputed frame sequence into an animated image buffer.
|
|
27
|
-
* @param {AnimationFrameSource[]} frames
|
|
28
|
-
* @param {EncodeFramesOptions} options
|
|
29
|
-
* @returns {Uint8Array}
|
|
30
|
-
*/
|
|
31
|
-
encodeFrames(frames, options) {
|
|
32
|
-
const ptr0 = passArrayJsValueToWasm0(frames, wasm.__wbindgen_malloc);
|
|
33
|
-
const len0 = WASM_VECTOR_LEN;
|
|
34
|
-
const ret = wasm.renderer_encodeFrames(this.__wbg_ptr, ptr0, len0, options);
|
|
35
|
-
if (ret[3]) throw takeFromExternrefTable0(ret[2]);
|
|
36
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
37
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
38
|
-
return v2;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
26
|
* Measures a node tree and returns layout information.
|
|
42
27
|
* @param {Node} node
|
|
43
28
|
* @param {RenderOptions | null} [options]
|
|
@@ -152,10 +137,10 @@ function __wbg_get_imports() {
|
|
|
152
137
|
__proto__: null,
|
|
153
138
|
"./takumi_wasm_bg.js": {
|
|
154
139
|
__proto__: null,
|
|
155
|
-
|
|
140
|
+
__wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
|
|
156
141
|
return Error(getStringFromWasm0(arg0, arg1));
|
|
157
142
|
},
|
|
158
|
-
|
|
143
|
+
__wbg_Number_9a4e0ecb0fa16705: function(arg0) {
|
|
159
144
|
return Number(arg0);
|
|
160
145
|
},
|
|
161
146
|
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
@@ -164,55 +149,55 @@ function __wbg_get_imports() {
|
|
|
164
149
|
getDataViewMemory0().setInt32(arg0 + 4, len1, true);
|
|
165
150
|
getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
|
|
166
151
|
},
|
|
167
|
-
|
|
152
|
+
__wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f: function(arg0, arg1) {
|
|
168
153
|
const v = arg1;
|
|
169
154
|
const ret = typeof v === "bigint" ? v : void 0;
|
|
170
155
|
getDataViewMemory0().setBigInt64(arg0 + 8, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
171
156
|
getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), true);
|
|
172
157
|
},
|
|
173
|
-
|
|
158
|
+
__wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
|
|
174
159
|
const v = arg0;
|
|
175
160
|
const ret = typeof v === "boolean" ? v : void 0;
|
|
176
161
|
return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
|
|
177
162
|
},
|
|
178
|
-
|
|
163
|
+
__wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
|
|
179
164
|
const ptr1 = passStringToWasm0(debugString(arg1), wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
180
165
|
const len1 = WASM_VECTOR_LEN;
|
|
181
166
|
getDataViewMemory0().setInt32(arg0 + 4, len1, true);
|
|
182
167
|
getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
|
|
183
168
|
},
|
|
184
|
-
|
|
169
|
+
__wbg___wbindgen_in_aca499c5de7ff5e5: function(arg0, arg1) {
|
|
185
170
|
return arg0 in arg1;
|
|
186
171
|
},
|
|
187
|
-
|
|
172
|
+
__wbg___wbindgen_is_bigint_2f76dc55065b4273: function(arg0) {
|
|
188
173
|
return typeof arg0 === "bigint";
|
|
189
174
|
},
|
|
190
|
-
|
|
175
|
+
__wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
|
|
191
176
|
return typeof arg0 === "function";
|
|
192
177
|
},
|
|
193
|
-
|
|
178
|
+
__wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
|
|
194
179
|
const val = arg0;
|
|
195
180
|
return typeof val === "object" && val !== null;
|
|
196
181
|
},
|
|
197
|
-
|
|
182
|
+
__wbg___wbindgen_is_string_ea5e6cc2e4141dfe: function(arg0) {
|
|
198
183
|
return typeof arg0 === "string";
|
|
199
184
|
},
|
|
200
|
-
|
|
185
|
+
__wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
|
|
201
186
|
return arg0 === void 0;
|
|
202
187
|
},
|
|
203
|
-
|
|
188
|
+
__wbg___wbindgen_jsval_eq_e659fcf7b0e32763: function(arg0, arg1) {
|
|
204
189
|
return arg0 === arg1;
|
|
205
190
|
},
|
|
206
|
-
|
|
191
|
+
__wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170: function(arg0, arg1) {
|
|
207
192
|
return arg0 == arg1;
|
|
208
193
|
},
|
|
209
|
-
|
|
194
|
+
__wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
|
|
210
195
|
const obj = arg1;
|
|
211
196
|
const ret = typeof obj === "number" ? obj : void 0;
|
|
212
197
|
getDataViewMemory0().setFloat64(arg0 + 8, isLikeNone(ret) ? 0 : ret, true);
|
|
213
198
|
getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), true);
|
|
214
199
|
},
|
|
215
|
-
|
|
200
|
+
__wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
|
|
216
201
|
const obj = arg1;
|
|
217
202
|
const ret = typeof obj === "string" ? obj : void 0;
|
|
218
203
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -220,35 +205,35 @@ function __wbg_get_imports() {
|
|
|
220
205
|
getDataViewMemory0().setInt32(arg0 + 4, len1, true);
|
|
221
206
|
getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
|
|
222
207
|
},
|
|
223
|
-
|
|
208
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
224
209
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
225
210
|
},
|
|
226
|
-
|
|
211
|
+
__wbg_call_8a2dd23819f8a60a: function() {
|
|
227
212
|
return handleError(function(arg0, arg1) {
|
|
228
213
|
return arg0.call(arg1);
|
|
229
214
|
}, arguments);
|
|
230
215
|
},
|
|
231
|
-
|
|
216
|
+
__wbg_done_89b2b13e91a60321: function(arg0) {
|
|
232
217
|
return arg0.done;
|
|
233
218
|
},
|
|
234
|
-
|
|
219
|
+
__wbg_entries_015dc610cd81ede0: function(arg0) {
|
|
235
220
|
return Object.entries(arg0);
|
|
236
221
|
},
|
|
237
|
-
|
|
222
|
+
__wbg_get_507a50627bffa49b: function(arg0, arg1) {
|
|
238
223
|
return arg0[arg1 >>> 0];
|
|
239
224
|
},
|
|
240
|
-
|
|
225
|
+
__wbg_get_c7eb1f358a7654df: function() {
|
|
241
226
|
return handleError(function(arg0, arg1) {
|
|
242
227
|
return Reflect.get(arg0, arg1);
|
|
243
228
|
}, arguments);
|
|
244
229
|
},
|
|
245
|
-
|
|
230
|
+
__wbg_get_unchecked_6e0ad6d2a41b06f6: function(arg0, arg1) {
|
|
246
231
|
return arg0[arg1 >>> 0];
|
|
247
232
|
},
|
|
248
233
|
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
249
234
|
return arg0[arg1];
|
|
250
235
|
},
|
|
251
|
-
|
|
236
|
+
__wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
|
|
252
237
|
let result;
|
|
253
238
|
try {
|
|
254
239
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -257,7 +242,7 @@ function __wbg_get_imports() {
|
|
|
257
242
|
}
|
|
258
243
|
return result;
|
|
259
244
|
},
|
|
260
|
-
|
|
245
|
+
__wbg_instanceof_Map_e5b5e3db98422fcc: function(arg0) {
|
|
261
246
|
let result;
|
|
262
247
|
try {
|
|
263
248
|
result = arg0 instanceof Map;
|
|
@@ -266,7 +251,7 @@ function __wbg_get_imports() {
|
|
|
266
251
|
}
|
|
267
252
|
return result;
|
|
268
253
|
},
|
|
269
|
-
|
|
254
|
+
__wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
|
|
270
255
|
let result;
|
|
271
256
|
try {
|
|
272
257
|
result = arg0 instanceof Uint8Array;
|
|
@@ -275,51 +260,51 @@ function __wbg_get_imports() {
|
|
|
275
260
|
}
|
|
276
261
|
return result;
|
|
277
262
|
},
|
|
278
|
-
|
|
263
|
+
__wbg_isArray_0677c962b281d01a: function(arg0) {
|
|
279
264
|
return Array.isArray(arg0);
|
|
280
265
|
},
|
|
281
|
-
|
|
266
|
+
__wbg_isSafeInteger_04f36e4056f1b851: function(arg0) {
|
|
282
267
|
return Number.isSafeInteger(arg0);
|
|
283
268
|
},
|
|
284
|
-
|
|
269
|
+
__wbg_iterator_6f722e4a93058b71: function() {
|
|
285
270
|
return Symbol.iterator;
|
|
286
271
|
},
|
|
287
|
-
|
|
272
|
+
__wbg_length_1f0964f4a5e2c6d8: function(arg0) {
|
|
288
273
|
return arg0.length;
|
|
289
274
|
},
|
|
290
|
-
|
|
275
|
+
__wbg_length_370319915dc99107: function(arg0) {
|
|
291
276
|
return arg0.length;
|
|
292
277
|
},
|
|
293
|
-
|
|
294
|
-
return /* @__PURE__ */ new Object();
|
|
295
|
-
},
|
|
296
|
-
__wbg_new_36e147a8ced3c6e0: function() {
|
|
278
|
+
__wbg_new_32b398fb48b6d94a: function() {
|
|
297
279
|
return new Array();
|
|
298
280
|
},
|
|
299
|
-
|
|
281
|
+
__wbg_new_b667d279fd5aa943: function(arg0, arg1) {
|
|
282
|
+
return new Error(getStringFromWasm0(arg0, arg1));
|
|
283
|
+
},
|
|
284
|
+
__wbg_new_cd45aabdf6073e84: function(arg0) {
|
|
300
285
|
return new Uint8Array(arg0);
|
|
301
286
|
},
|
|
302
|
-
|
|
303
|
-
return new
|
|
287
|
+
__wbg_new_da52cf8fe3429cb2: function() {
|
|
288
|
+
return /* @__PURE__ */ new Object();
|
|
289
|
+
},
|
|
290
|
+
__wbg_next_6dbf2c0ac8cde20f: function(arg0) {
|
|
291
|
+
return arg0.next;
|
|
304
292
|
},
|
|
305
|
-
|
|
293
|
+
__wbg_next_71f2aa1cb3d1e37e: function() {
|
|
306
294
|
return handleError(function(arg0) {
|
|
307
295
|
return arg0.next();
|
|
308
296
|
}, arguments);
|
|
309
297
|
},
|
|
310
|
-
|
|
311
|
-
return arg0.next;
|
|
312
|
-
},
|
|
313
|
-
__wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
|
|
298
|
+
__wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
|
|
314
299
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
315
300
|
},
|
|
316
301
|
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
317
302
|
arg0[arg1] = arg2;
|
|
318
303
|
},
|
|
319
|
-
|
|
304
|
+
__wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
|
|
320
305
|
arg0[arg1 >>> 0] = arg2;
|
|
321
306
|
},
|
|
322
|
-
|
|
307
|
+
__wbg_value_a5d5488a9589444a: function(arg0) {
|
|
323
308
|
return arg0.value;
|
|
324
309
|
},
|
|
325
310
|
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
@@ -334,11 +319,6 @@ function __wbg_get_imports() {
|
|
|
334
319
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
335
320
|
return BigInt.asUintN(64, arg0);
|
|
336
321
|
},
|
|
337
|
-
__wbindgen_cast_0000000000000005: function(arg0, arg1) {
|
|
338
|
-
var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
|
|
339
|
-
wasm.__wbindgen_free(arg0, arg1 * 4, 4);
|
|
340
|
-
return v0;
|
|
341
|
-
},
|
|
342
322
|
__wbindgen_init_externref_table: function() {
|
|
343
323
|
const table = wasm.__wbindgen_externrefs;
|
|
344
324
|
const offset = table.grow(4);
|
|
@@ -394,14 +374,6 @@ function debugString(val) {
|
|
|
394
374
|
if (val instanceof Error) return `${val.name}: ${val.message}\n${val.stack}`;
|
|
395
375
|
return className;
|
|
396
376
|
}
|
|
397
|
-
function getArrayJsValueFromWasm0(ptr, len) {
|
|
398
|
-
ptr = ptr >>> 0;
|
|
399
|
-
const mem = getDataViewMemory0();
|
|
400
|
-
const result = [];
|
|
401
|
-
for (let i = ptr; i < ptr + 4 * len; i += 4) result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
402
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
403
|
-
return result;
|
|
404
|
-
}
|
|
405
377
|
function getArrayU8FromWasm0(ptr, len) {
|
|
406
378
|
ptr = ptr >>> 0;
|
|
407
379
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -430,15 +402,6 @@ function handleError(f, args) {
|
|
|
430
402
|
function isLikeNone(x) {
|
|
431
403
|
return x === void 0 || x === null;
|
|
432
404
|
}
|
|
433
|
-
function passArrayJsValueToWasm0(array, malloc) {
|
|
434
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
435
|
-
for (let i = 0; i < array.length; i++) {
|
|
436
|
-
const add = addToExternrefTable0(array[i]);
|
|
437
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
438
|
-
}
|
|
439
|
-
WASM_VECTOR_LEN = array.length;
|
|
440
|
-
return ptr;
|
|
441
|
-
}
|
|
442
405
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
443
406
|
if (realloc === void 0) {
|
|
444
407
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -654,31 +617,17 @@ var Renderer = class {
|
|
|
654
617
|
fontFamilies: fontFamilies ?? registeredFamilies
|
|
655
618
|
});
|
|
656
619
|
}
|
|
657
|
-
async encodeFrames(frames, options) {
|
|
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
|
-
}));
|
|
665
|
-
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
666
|
-
return this.inner.encodeFrames(frames, {
|
|
667
|
-
...rest,
|
|
668
|
-
images: resolvedImages,
|
|
669
|
-
fontFamilies: fontFamilies ?? registeredFamilies
|
|
670
|
-
});
|
|
671
|
-
}
|
|
672
620
|
free() {
|
|
673
621
|
this.inner.free();
|
|
674
622
|
}
|
|
675
623
|
async registerFont(font) {
|
|
676
|
-
const
|
|
624
|
+
const loader = typeof font === "string" ? (0, _takumi_rs_helpers.fontFromUrl)(font) : font;
|
|
625
|
+
const key = createFontKey(loader);
|
|
677
626
|
const cached = this.getFont(key);
|
|
678
627
|
if (cached) return cached;
|
|
679
|
-
const extracted = extractFontBuffer(
|
|
680
|
-
const register = (data) => this.inner.registerFont(isBuffer(
|
|
681
|
-
...
|
|
628
|
+
const extracted = extractFontBuffer(loader);
|
|
629
|
+
const register = (data) => this.inner.registerFont(isBuffer(loader) ? data : {
|
|
630
|
+
...loader,
|
|
682
631
|
data
|
|
683
632
|
});
|
|
684
633
|
if (isBuffer(extracted)) {
|
package/dist/export.d.cts
CHANGED
|
@@ -105,35 +105,6 @@ type RenderAnimationOptions$1 = {
|
|
|
105
105
|
*/
|
|
106
106
|
fontFamilies?: string[];
|
|
107
107
|
};
|
|
108
|
-
type EncodeFramesOptions$1 = {
|
|
109
|
-
width: number;
|
|
110
|
-
height: number;
|
|
111
|
-
format?: "webp" | "apng" | "gif";
|
|
112
|
-
/**
|
|
113
|
-
* The quality of WebP format (0-100). Ignored for APNG and GIF.
|
|
114
|
-
*/
|
|
115
|
-
quality?: number;
|
|
116
|
-
/**
|
|
117
|
-
* Images keyed by `src`, each carrying raw bytes. Provided up front and used
|
|
118
|
-
* in place of fetching external `src` URLs during rendering.
|
|
119
|
-
*/
|
|
120
|
-
images?: ImageSource[];
|
|
121
|
-
drawDebugBorder?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* CSS stylesheets to apply before rendering.
|
|
124
|
-
*/
|
|
125
|
-
stylesheets?: string[];
|
|
126
|
-
/**
|
|
127
|
-
* Defines the ratio resolution of the image to the physical pixels.
|
|
128
|
-
* @default 1.0
|
|
129
|
-
*/
|
|
130
|
-
devicePixelRatio?: number;
|
|
131
|
-
/**
|
|
132
|
-
* Per-render font stack: ordered family names used as the fallback chain.
|
|
133
|
-
* Defaults to all registered families in registration order.
|
|
134
|
-
*/
|
|
135
|
-
fontFamilies?: string[];
|
|
136
|
-
};
|
|
137
108
|
type FontDetails = {
|
|
138
109
|
name?: string;
|
|
139
110
|
data: ByteBuf;
|
|
@@ -184,10 +155,6 @@ type MeasuredNode = {
|
|
|
184
155
|
children: MeasuredNode[];
|
|
185
156
|
runs: MeasuredTextRun[];
|
|
186
157
|
};
|
|
187
|
-
type AnimationFrameSource = {
|
|
188
|
-
node: Node$1;
|
|
189
|
-
durationMs: number;
|
|
190
|
-
};
|
|
191
158
|
type AnimationSceneSource = {
|
|
192
159
|
node: Node$1;
|
|
193
160
|
durationMs: number;
|
|
@@ -196,7 +163,6 @@ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Modul
|
|
|
196
163
|
interface InitOutput {
|
|
197
164
|
readonly memory: WebAssembly.Memory;
|
|
198
165
|
readonly __wbg_renderer_free: (a: number, b: number) => void;
|
|
199
|
-
readonly renderer_encodeFrames: (a: number, b: number, c: number, d: any) => [number, number, number, number];
|
|
200
166
|
readonly renderer_measure: (a: number, b: any, c: number) => [number, number, number];
|
|
201
167
|
readonly renderer_new: () => [number, number, number];
|
|
202
168
|
readonly renderer_registerFont: (a: number, b: any) => [number, number, number];
|
|
@@ -209,9 +175,8 @@ interface InitOutput {
|
|
|
209
175
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
210
176
|
readonly __externref_table_alloc: () => number;
|
|
211
177
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
212
|
-
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
213
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
214
178
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
179
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
215
180
|
readonly __wbindgen_start: () => void;
|
|
216
181
|
}
|
|
217
182
|
type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
@@ -239,7 +204,11 @@ declare function __wbg_init(module_or_path?: {
|
|
|
239
204
|
} | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
240
205
|
//#endregion
|
|
241
206
|
//#region src/export.d.ts
|
|
242
|
-
|
|
207
|
+
/**
|
|
208
|
+
* A font to register. Either a URL string (fetched on demand, with name/weight/style read from the
|
|
209
|
+
* file), raw bytes, or a descriptor with a lazy `data()` loader.
|
|
210
|
+
*/
|
|
211
|
+
type FontLoader = string | Font | (Omit<FontDetails, "data"> & {
|
|
243
212
|
data: () => Promise<FontDetails["data"]> | FontDetails["data"]; /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
|
|
244
213
|
ranges?: [number, number][];
|
|
245
214
|
} & ({
|
|
@@ -289,11 +258,6 @@ type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format"
|
|
|
289
258
|
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
290
259
|
subset?: boolean;
|
|
291
260
|
};
|
|
292
|
-
type EncodeFramesOptions = Omit<EncodeFramesOptions$1, "images" | "format"> & AnimationOutputFormatOptions & {
|
|
293
|
-
fonts?: FontLoader[];
|
|
294
|
-
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
295
|
-
subset?: boolean;
|
|
296
|
-
};
|
|
297
261
|
type SvgRenderOptions = Omit<SvgRenderOptions$1, "images"> & {
|
|
298
262
|
fonts?: FontLoader[];
|
|
299
263
|
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
@@ -312,9 +276,8 @@ declare class Renderer {
|
|
|
312
276
|
renderSvg(node: Node, options?: SvgRenderOptions): Promise<string>;
|
|
313
277
|
measure(node: Node, options?: RenderOptions): Promise<MeasuredNode>;
|
|
314
278
|
renderAnimation(options: RenderAnimationOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
315
|
-
encodeFrames(frames: AnimationFrameSource[], options: EncodeFramesOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
316
279
|
free(): void;
|
|
317
280
|
registerFont(font: FontLoader): Promise<RegisteredFamily[]>;
|
|
318
281
|
}
|
|
319
282
|
//#endregion
|
|
320
|
-
export {
|
|
283
|
+
export { AnimationOutputFormatOptions, AnimationSceneSource, ByteBuf, ContainerNode, Font, FontDetails, FontLoader, ImageLoader, ImageNode, ImageSource, InitInput, InitOutput, KeyframeRule, Keyframes, KeyframesMap, KeyframesRule, KeyframesRuleList, MeasuredNode, MeasuredTextRun, type Node, NodeMetadata, OutputFormatOptions, RegisteredFace, RegisteredFamily, RenderAnimationOptions, RenderOptions, Renderer, SvgRenderOptions, SyncInitInput, TextNode, __wbg_init as default, extractResourceUrls, initSync };
|
package/dist/export.d.mts
CHANGED
|
@@ -105,35 +105,6 @@ type RenderAnimationOptions$1 = {
|
|
|
105
105
|
*/
|
|
106
106
|
fontFamilies?: string[];
|
|
107
107
|
};
|
|
108
|
-
type EncodeFramesOptions$1 = {
|
|
109
|
-
width: number;
|
|
110
|
-
height: number;
|
|
111
|
-
format?: "webp" | "apng" | "gif";
|
|
112
|
-
/**
|
|
113
|
-
* The quality of WebP format (0-100). Ignored for APNG and GIF.
|
|
114
|
-
*/
|
|
115
|
-
quality?: number;
|
|
116
|
-
/**
|
|
117
|
-
* Images keyed by `src`, each carrying raw bytes. Provided up front and used
|
|
118
|
-
* in place of fetching external `src` URLs during rendering.
|
|
119
|
-
*/
|
|
120
|
-
images?: ImageSource[];
|
|
121
|
-
drawDebugBorder?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* CSS stylesheets to apply before rendering.
|
|
124
|
-
*/
|
|
125
|
-
stylesheets?: string[];
|
|
126
|
-
/**
|
|
127
|
-
* Defines the ratio resolution of the image to the physical pixels.
|
|
128
|
-
* @default 1.0
|
|
129
|
-
*/
|
|
130
|
-
devicePixelRatio?: number;
|
|
131
|
-
/**
|
|
132
|
-
* Per-render font stack: ordered family names used as the fallback chain.
|
|
133
|
-
* Defaults to all registered families in registration order.
|
|
134
|
-
*/
|
|
135
|
-
fontFamilies?: string[];
|
|
136
|
-
};
|
|
137
108
|
type FontDetails = {
|
|
138
109
|
name?: string;
|
|
139
110
|
data: ByteBuf;
|
|
@@ -184,10 +155,6 @@ type MeasuredNode = {
|
|
|
184
155
|
children: MeasuredNode[];
|
|
185
156
|
runs: MeasuredTextRun[];
|
|
186
157
|
};
|
|
187
|
-
type AnimationFrameSource = {
|
|
188
|
-
node: Node$1;
|
|
189
|
-
durationMs: number;
|
|
190
|
-
};
|
|
191
158
|
type AnimationSceneSource = {
|
|
192
159
|
node: Node$1;
|
|
193
160
|
durationMs: number;
|
|
@@ -196,7 +163,6 @@ type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Modul
|
|
|
196
163
|
interface InitOutput {
|
|
197
164
|
readonly memory: WebAssembly.Memory;
|
|
198
165
|
readonly __wbg_renderer_free: (a: number, b: number) => void;
|
|
199
|
-
readonly renderer_encodeFrames: (a: number, b: number, c: number, d: any) => [number, number, number, number];
|
|
200
166
|
readonly renderer_measure: (a: number, b: any, c: number) => [number, number, number];
|
|
201
167
|
readonly renderer_new: () => [number, number, number];
|
|
202
168
|
readonly renderer_registerFont: (a: number, b: any) => [number, number, number];
|
|
@@ -209,9 +175,8 @@ interface InitOutput {
|
|
|
209
175
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
210
176
|
readonly __externref_table_alloc: () => number;
|
|
211
177
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
212
|
-
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
213
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
214
178
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
179
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
215
180
|
readonly __wbindgen_start: () => void;
|
|
216
181
|
}
|
|
217
182
|
type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
@@ -239,7 +204,11 @@ declare function __wbg_init(module_or_path?: {
|
|
|
239
204
|
} | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
240
205
|
//#endregion
|
|
241
206
|
//#region src/export.d.ts
|
|
242
|
-
|
|
207
|
+
/**
|
|
208
|
+
* A font to register. Either a URL string (fetched on demand, with name/weight/style read from the
|
|
209
|
+
* file), raw bytes, or a descriptor with a lazy `data()` loader.
|
|
210
|
+
*/
|
|
211
|
+
type FontLoader = string | Font | (Omit<FontDetails, "data"> & {
|
|
243
212
|
data: () => Promise<FontDetails["data"]> | FontDetails["data"]; /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
|
|
244
213
|
ranges?: [number, number][];
|
|
245
214
|
} & ({
|
|
@@ -289,11 +258,6 @@ type RenderAnimationOptions = Omit<RenderAnimationOptions$1, "images" | "format"
|
|
|
289
258
|
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
290
259
|
subset?: boolean;
|
|
291
260
|
};
|
|
292
|
-
type EncodeFramesOptions = Omit<EncodeFramesOptions$1, "images" | "format"> & AnimationOutputFormatOptions & {
|
|
293
|
-
fonts?: FontLoader[];
|
|
294
|
-
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
295
|
-
subset?: boolean;
|
|
296
|
-
};
|
|
297
261
|
type SvgRenderOptions = Omit<SvgRenderOptions$1, "images"> & {
|
|
298
262
|
fonts?: FontLoader[];
|
|
299
263
|
images?: ImageLoader[]; /** Register only the `fonts` subsets the content renders. @default true */
|
|
@@ -312,9 +276,8 @@ declare class Renderer {
|
|
|
312
276
|
renderSvg(node: Node, options?: SvgRenderOptions): Promise<string>;
|
|
313
277
|
measure(node: Node, options?: RenderOptions): Promise<MeasuredNode>;
|
|
314
278
|
renderAnimation(options: RenderAnimationOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
315
|
-
encodeFrames(frames: AnimationFrameSource[], options: EncodeFramesOptions): Promise<Uint8Array<ArrayBufferLike>>;
|
|
316
279
|
free(): void;
|
|
317
280
|
registerFont(font: FontLoader): Promise<RegisteredFamily[]>;
|
|
318
281
|
}
|
|
319
282
|
//#endregion
|
|
320
|
-
export {
|
|
283
|
+
export { AnimationOutputFormatOptions, AnimationSceneSource, ByteBuf, ContainerNode, Font, FontDetails, FontLoader, ImageLoader, ImageNode, ImageSource, InitInput, InitOutput, KeyframeRule, Keyframes, KeyframesMap, KeyframesRule, KeyframesRuleList, MeasuredNode, MeasuredTextRun, type Node, NodeMetadata, OutputFormatOptions, RegisteredFace, RegisteredFamily, RenderAnimationOptions, RenderOptions, Renderer, SvgRenderOptions, SyncInitInput, TextNode, __wbg_init as default, extractResourceUrls, initSync };
|
package/dist/export.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractResourceUrls, pickFonts } from "@takumi-rs/helpers";
|
|
1
|
+
import { extractResourceUrls, fontFromUrl, pickFonts } from "@takumi-rs/helpers";
|
|
2
2
|
//#region pkg/takumi_wasm.js
|
|
3
3
|
/**
|
|
4
4
|
* The main renderer for Takumi image rendering engine.
|
|
@@ -19,21 +19,6 @@ var Renderer$1 = class {
|
|
|
19
19
|
wasm.__wbg_renderer_free(ptr, 0);
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Encodes a precomputed frame sequence into an animated image buffer.
|
|
23
|
-
* @param {AnimationFrameSource[]} frames
|
|
24
|
-
* @param {EncodeFramesOptions} options
|
|
25
|
-
* @returns {Uint8Array}
|
|
26
|
-
*/
|
|
27
|
-
encodeFrames(frames, options) {
|
|
28
|
-
const ptr0 = passArrayJsValueToWasm0(frames, wasm.__wbindgen_malloc);
|
|
29
|
-
const len0 = WASM_VECTOR_LEN;
|
|
30
|
-
const ret = wasm.renderer_encodeFrames(this.__wbg_ptr, ptr0, len0, options);
|
|
31
|
-
if (ret[3]) throw takeFromExternrefTable0(ret[2]);
|
|
32
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
33
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
34
|
-
return v2;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
22
|
* Measures a node tree and returns layout information.
|
|
38
23
|
* @param {Node} node
|
|
39
24
|
* @param {RenderOptions | null} [options]
|
|
@@ -148,10 +133,10 @@ function __wbg_get_imports() {
|
|
|
148
133
|
__proto__: null,
|
|
149
134
|
"./takumi_wasm_bg.js": {
|
|
150
135
|
__proto__: null,
|
|
151
|
-
|
|
136
|
+
__wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
|
|
152
137
|
return Error(getStringFromWasm0(arg0, arg1));
|
|
153
138
|
},
|
|
154
|
-
|
|
139
|
+
__wbg_Number_9a4e0ecb0fa16705: function(arg0) {
|
|
155
140
|
return Number(arg0);
|
|
156
141
|
},
|
|
157
142
|
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
@@ -160,55 +145,55 @@ function __wbg_get_imports() {
|
|
|
160
145
|
getDataViewMemory0().setInt32(arg0 + 4, len1, true);
|
|
161
146
|
getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
|
|
162
147
|
},
|
|
163
|
-
|
|
148
|
+
__wbg___wbindgen_bigint_get_as_i64_d968e41184ae354f: function(arg0, arg1) {
|
|
164
149
|
const v = arg1;
|
|
165
150
|
const ret = typeof v === "bigint" ? v : void 0;
|
|
166
151
|
getDataViewMemory0().setBigInt64(arg0 + 8, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
167
152
|
getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), true);
|
|
168
153
|
},
|
|
169
|
-
|
|
154
|
+
__wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
|
|
170
155
|
const v = arg0;
|
|
171
156
|
const ret = typeof v === "boolean" ? v : void 0;
|
|
172
157
|
return isLikeNone(ret) ? 16777215 : ret ? 1 : 0;
|
|
173
158
|
},
|
|
174
|
-
|
|
159
|
+
__wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
|
|
175
160
|
const ptr1 = passStringToWasm0(debugString(arg1), wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
176
161
|
const len1 = WASM_VECTOR_LEN;
|
|
177
162
|
getDataViewMemory0().setInt32(arg0 + 4, len1, true);
|
|
178
163
|
getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
|
|
179
164
|
},
|
|
180
|
-
|
|
165
|
+
__wbg___wbindgen_in_aca499c5de7ff5e5: function(arg0, arg1) {
|
|
181
166
|
return arg0 in arg1;
|
|
182
167
|
},
|
|
183
|
-
|
|
168
|
+
__wbg___wbindgen_is_bigint_2f76dc55065b4273: function(arg0) {
|
|
184
169
|
return typeof arg0 === "bigint";
|
|
185
170
|
},
|
|
186
|
-
|
|
171
|
+
__wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
|
|
187
172
|
return typeof arg0 === "function";
|
|
188
173
|
},
|
|
189
|
-
|
|
174
|
+
__wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
|
|
190
175
|
const val = arg0;
|
|
191
176
|
return typeof val === "object" && val !== null;
|
|
192
177
|
},
|
|
193
|
-
|
|
178
|
+
__wbg___wbindgen_is_string_ea5e6cc2e4141dfe: function(arg0) {
|
|
194
179
|
return typeof arg0 === "string";
|
|
195
180
|
},
|
|
196
|
-
|
|
181
|
+
__wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
|
|
197
182
|
return arg0 === void 0;
|
|
198
183
|
},
|
|
199
|
-
|
|
184
|
+
__wbg___wbindgen_jsval_eq_e659fcf7b0e32763: function(arg0, arg1) {
|
|
200
185
|
return arg0 === arg1;
|
|
201
186
|
},
|
|
202
|
-
|
|
187
|
+
__wbg___wbindgen_jsval_loose_eq_db4c3b15f63fc170: function(arg0, arg1) {
|
|
203
188
|
return arg0 == arg1;
|
|
204
189
|
},
|
|
205
|
-
|
|
190
|
+
__wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
|
|
206
191
|
const obj = arg1;
|
|
207
192
|
const ret = typeof obj === "number" ? obj : void 0;
|
|
208
193
|
getDataViewMemory0().setFloat64(arg0 + 8, isLikeNone(ret) ? 0 : ret, true);
|
|
209
194
|
getDataViewMemory0().setInt32(arg0 + 0, !isLikeNone(ret), true);
|
|
210
195
|
},
|
|
211
|
-
|
|
196
|
+
__wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
|
|
212
197
|
const obj = arg1;
|
|
213
198
|
const ret = typeof obj === "string" ? obj : void 0;
|
|
214
199
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -216,35 +201,35 @@ function __wbg_get_imports() {
|
|
|
216
201
|
getDataViewMemory0().setInt32(arg0 + 4, len1, true);
|
|
217
202
|
getDataViewMemory0().setInt32(arg0 + 0, ptr1, true);
|
|
218
203
|
},
|
|
219
|
-
|
|
204
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
220
205
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
221
206
|
},
|
|
222
|
-
|
|
207
|
+
__wbg_call_8a2dd23819f8a60a: function() {
|
|
223
208
|
return handleError(function(arg0, arg1) {
|
|
224
209
|
return arg0.call(arg1);
|
|
225
210
|
}, arguments);
|
|
226
211
|
},
|
|
227
|
-
|
|
212
|
+
__wbg_done_89b2b13e91a60321: function(arg0) {
|
|
228
213
|
return arg0.done;
|
|
229
214
|
},
|
|
230
|
-
|
|
215
|
+
__wbg_entries_015dc610cd81ede0: function(arg0) {
|
|
231
216
|
return Object.entries(arg0);
|
|
232
217
|
},
|
|
233
|
-
|
|
218
|
+
__wbg_get_507a50627bffa49b: function(arg0, arg1) {
|
|
234
219
|
return arg0[arg1 >>> 0];
|
|
235
220
|
},
|
|
236
|
-
|
|
221
|
+
__wbg_get_c7eb1f358a7654df: function() {
|
|
237
222
|
return handleError(function(arg0, arg1) {
|
|
238
223
|
return Reflect.get(arg0, arg1);
|
|
239
224
|
}, arguments);
|
|
240
225
|
},
|
|
241
|
-
|
|
226
|
+
__wbg_get_unchecked_6e0ad6d2a41b06f6: function(arg0, arg1) {
|
|
242
227
|
return arg0[arg1 >>> 0];
|
|
243
228
|
},
|
|
244
229
|
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
245
230
|
return arg0[arg1];
|
|
246
231
|
},
|
|
247
|
-
|
|
232
|
+
__wbg_instanceof_ArrayBuffer_4480b9e0068a8adb: function(arg0) {
|
|
248
233
|
let result;
|
|
249
234
|
try {
|
|
250
235
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -253,7 +238,7 @@ function __wbg_get_imports() {
|
|
|
253
238
|
}
|
|
254
239
|
return result;
|
|
255
240
|
},
|
|
256
|
-
|
|
241
|
+
__wbg_instanceof_Map_e5b5e3db98422fcc: function(arg0) {
|
|
257
242
|
let result;
|
|
258
243
|
try {
|
|
259
244
|
result = arg0 instanceof Map;
|
|
@@ -262,7 +247,7 @@ function __wbg_get_imports() {
|
|
|
262
247
|
}
|
|
263
248
|
return result;
|
|
264
249
|
},
|
|
265
|
-
|
|
250
|
+
__wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
|
|
266
251
|
let result;
|
|
267
252
|
try {
|
|
268
253
|
result = arg0 instanceof Uint8Array;
|
|
@@ -271,51 +256,51 @@ function __wbg_get_imports() {
|
|
|
271
256
|
}
|
|
272
257
|
return result;
|
|
273
258
|
},
|
|
274
|
-
|
|
259
|
+
__wbg_isArray_0677c962b281d01a: function(arg0) {
|
|
275
260
|
return Array.isArray(arg0);
|
|
276
261
|
},
|
|
277
|
-
|
|
262
|
+
__wbg_isSafeInteger_04f36e4056f1b851: function(arg0) {
|
|
278
263
|
return Number.isSafeInteger(arg0);
|
|
279
264
|
},
|
|
280
|
-
|
|
265
|
+
__wbg_iterator_6f722e4a93058b71: function() {
|
|
281
266
|
return Symbol.iterator;
|
|
282
267
|
},
|
|
283
|
-
|
|
268
|
+
__wbg_length_1f0964f4a5e2c6d8: function(arg0) {
|
|
284
269
|
return arg0.length;
|
|
285
270
|
},
|
|
286
|
-
|
|
271
|
+
__wbg_length_370319915dc99107: function(arg0) {
|
|
287
272
|
return arg0.length;
|
|
288
273
|
},
|
|
289
|
-
|
|
290
|
-
return /* @__PURE__ */ new Object();
|
|
291
|
-
},
|
|
292
|
-
__wbg_new_36e147a8ced3c6e0: function() {
|
|
274
|
+
__wbg_new_32b398fb48b6d94a: function() {
|
|
293
275
|
return new Array();
|
|
294
276
|
},
|
|
295
|
-
|
|
277
|
+
__wbg_new_b667d279fd5aa943: function(arg0, arg1) {
|
|
278
|
+
return new Error(getStringFromWasm0(arg0, arg1));
|
|
279
|
+
},
|
|
280
|
+
__wbg_new_cd45aabdf6073e84: function(arg0) {
|
|
296
281
|
return new Uint8Array(arg0);
|
|
297
282
|
},
|
|
298
|
-
|
|
299
|
-
return new
|
|
283
|
+
__wbg_new_da52cf8fe3429cb2: function() {
|
|
284
|
+
return /* @__PURE__ */ new Object();
|
|
285
|
+
},
|
|
286
|
+
__wbg_next_6dbf2c0ac8cde20f: function(arg0) {
|
|
287
|
+
return arg0.next;
|
|
300
288
|
},
|
|
301
|
-
|
|
289
|
+
__wbg_next_71f2aa1cb3d1e37e: function() {
|
|
302
290
|
return handleError(function(arg0) {
|
|
303
291
|
return arg0.next();
|
|
304
292
|
}, arguments);
|
|
305
293
|
},
|
|
306
|
-
|
|
307
|
-
return arg0.next;
|
|
308
|
-
},
|
|
309
|
-
__wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
|
|
294
|
+
__wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) {
|
|
310
295
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
311
296
|
},
|
|
312
297
|
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
313
298
|
arg0[arg1] = arg2;
|
|
314
299
|
},
|
|
315
|
-
|
|
300
|
+
__wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
|
|
316
301
|
arg0[arg1 >>> 0] = arg2;
|
|
317
302
|
},
|
|
318
|
-
|
|
303
|
+
__wbg_value_a5d5488a9589444a: function(arg0) {
|
|
319
304
|
return arg0.value;
|
|
320
305
|
},
|
|
321
306
|
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
@@ -330,11 +315,6 @@ function __wbg_get_imports() {
|
|
|
330
315
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
331
316
|
return BigInt.asUintN(64, arg0);
|
|
332
317
|
},
|
|
333
|
-
__wbindgen_cast_0000000000000005: function(arg0, arg1) {
|
|
334
|
-
var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
|
|
335
|
-
wasm.__wbindgen_free(arg0, arg1 * 4, 4);
|
|
336
|
-
return v0;
|
|
337
|
-
},
|
|
338
318
|
__wbindgen_init_externref_table: function() {
|
|
339
319
|
const table = wasm.__wbindgen_externrefs;
|
|
340
320
|
const offset = table.grow(4);
|
|
@@ -390,14 +370,6 @@ function debugString(val) {
|
|
|
390
370
|
if (val instanceof Error) return `${val.name}: ${val.message}\n${val.stack}`;
|
|
391
371
|
return className;
|
|
392
372
|
}
|
|
393
|
-
function getArrayJsValueFromWasm0(ptr, len) {
|
|
394
|
-
ptr = ptr >>> 0;
|
|
395
|
-
const mem = getDataViewMemory0();
|
|
396
|
-
const result = [];
|
|
397
|
-
for (let i = ptr; i < ptr + 4 * len; i += 4) result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
398
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
399
|
-
return result;
|
|
400
|
-
}
|
|
401
373
|
function getArrayU8FromWasm0(ptr, len) {
|
|
402
374
|
ptr = ptr >>> 0;
|
|
403
375
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
@@ -426,15 +398,6 @@ function handleError(f, args) {
|
|
|
426
398
|
function isLikeNone(x) {
|
|
427
399
|
return x === void 0 || x === null;
|
|
428
400
|
}
|
|
429
|
-
function passArrayJsValueToWasm0(array, malloc) {
|
|
430
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
431
|
-
for (let i = 0; i < array.length; i++) {
|
|
432
|
-
const add = addToExternrefTable0(array[i]);
|
|
433
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
434
|
-
}
|
|
435
|
-
WASM_VECTOR_LEN = array.length;
|
|
436
|
-
return ptr;
|
|
437
|
-
}
|
|
438
401
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
439
402
|
if (realloc === void 0) {
|
|
440
403
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -650,31 +613,17 @@ var Renderer = class {
|
|
|
650
613
|
fontFamilies: fontFamilies ?? registeredFamilies
|
|
651
614
|
});
|
|
652
615
|
}
|
|
653
|
-
async encodeFrames(frames, options) {
|
|
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
|
-
}));
|
|
661
|
-
const resolvedImages = images ? await resolveImageLoaders(images) : void 0;
|
|
662
|
-
return this.inner.encodeFrames(frames, {
|
|
663
|
-
...rest,
|
|
664
|
-
images: resolvedImages,
|
|
665
|
-
fontFamilies: fontFamilies ?? registeredFamilies
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
616
|
free() {
|
|
669
617
|
this.inner.free();
|
|
670
618
|
}
|
|
671
619
|
async registerFont(font) {
|
|
672
|
-
const
|
|
620
|
+
const loader = typeof font === "string" ? fontFromUrl(font) : font;
|
|
621
|
+
const key = createFontKey(loader);
|
|
673
622
|
const cached = this.getFont(key);
|
|
674
623
|
if (cached) return cached;
|
|
675
|
-
const extracted = extractFontBuffer(
|
|
676
|
-
const register = (data) => this.inner.registerFont(isBuffer(
|
|
677
|
-
...
|
|
624
|
+
const extracted = extractFontBuffer(loader);
|
|
625
|
+
const register = (data) => this.inner.registerFont(isBuffer(loader) ? data : {
|
|
626
|
+
...loader,
|
|
678
627
|
data
|
|
679
628
|
});
|
|
680
629
|
if (isBuffer(extracted)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takumi-rs/wasm",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"css",
|
|
6
6
|
"image",
|
|
@@ -61,20 +61,47 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"./auto": {
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
"bun": {
|
|
65
|
+
"types": "./bundlers/bun.d.ts",
|
|
66
|
+
"default": "./bundlers/bun.mjs"
|
|
67
|
+
},
|
|
68
|
+
"workerd": {
|
|
69
|
+
"types": "./bundlers/wasm-module.d.ts",
|
|
70
|
+
"default": "./bundlers/workerd.js"
|
|
71
|
+
},
|
|
72
|
+
"edge-light": {
|
|
73
|
+
"types": "./bundlers/wasm-module.d.ts",
|
|
74
|
+
"default": "./bundlers/next.mjs"
|
|
75
|
+
},
|
|
76
|
+
"unwasm": {
|
|
77
|
+
"types": "./bundlers/wasm-module.d.ts",
|
|
78
|
+
"default": "./bundlers/next.mjs"
|
|
79
|
+
},
|
|
80
|
+
"module": {
|
|
81
|
+
"types": "./bundlers/vite.d.ts",
|
|
82
|
+
"default": "./bundlers/vite.mjs"
|
|
83
|
+
},
|
|
84
|
+
"node": {
|
|
85
|
+
"require": {
|
|
86
|
+
"types": "./bundlers/node.d.cts",
|
|
87
|
+
"default": "./bundlers/node.cjs"
|
|
88
|
+
},
|
|
89
|
+
"default": {
|
|
90
|
+
"types": "./bundlers/node.d.ts",
|
|
91
|
+
"default": "./bundlers/node.mjs"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"default": {
|
|
95
|
+
"types": "./bundlers/wasm-module.d.ts",
|
|
96
|
+
"default": "./bundlers/vite.mjs"
|
|
97
|
+
}
|
|
71
98
|
},
|
|
72
99
|
"./takumi_wasm_bg.wasm": {
|
|
73
100
|
"types": "./pkg/takumi_wasm_bg.wasm.d.ts",
|
|
74
101
|
"default": "./pkg/takumi_wasm_bg.wasm"
|
|
75
102
|
},
|
|
76
103
|
"./next": {
|
|
77
|
-
"types": "./bundlers/
|
|
104
|
+
"types": "./bundlers/wasm-module.d.ts",
|
|
78
105
|
"default": "./bundlers/next.mjs"
|
|
79
106
|
},
|
|
80
107
|
"./vite": {
|
|
@@ -83,19 +110,22 @@
|
|
|
83
110
|
}
|
|
84
111
|
},
|
|
85
112
|
"scripts": {
|
|
86
|
-
"build": "wasm-pack build --no-pack --release --out-dir pkg --target web && bun build:js
|
|
113
|
+
"build": "wasm-pack build --no-pack --release --out-dir pkg --target web && bun build:js",
|
|
87
114
|
"build:js": "tsdown",
|
|
88
|
-
"build:debug": "wasm-pack build --no-pack --dev --out-dir pkg --target web && bun build:js
|
|
115
|
+
"build:debug": "wasm-pack build --no-pack --dev --out-dir pkg --target web && bun build:js",
|
|
89
116
|
"publish-lint": "attw --pack . && publint --strict ."
|
|
90
117
|
},
|
|
91
118
|
"dependencies": {
|
|
92
|
-
"@takumi-rs/helpers": "2.0.0-
|
|
119
|
+
"@takumi-rs/helpers": "2.0.0-rc.0",
|
|
120
|
+
"csstype": "^3.2.3"
|
|
93
121
|
},
|
|
94
122
|
"devDependencies": {
|
|
95
123
|
"@types/bun": "^1.3.14",
|
|
96
|
-
"csstype": "^3.2.3",
|
|
97
124
|
"tsdown": "^0.22.3",
|
|
98
125
|
"unrun": "^0.3.1"
|
|
99
126
|
},
|
|
127
|
+
"engines": {
|
|
128
|
+
"node": ">=18"
|
|
129
|
+
},
|
|
100
130
|
"readme": "README.md"
|
|
101
131
|
}
|
package/pkg/takumi_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_renderer_free: (a: number, b: number) => void;
|
|
5
|
-
export const renderer_encodeFrames: (a: number, b: number, c: number, d: any) => [number, number, number, number];
|
|
6
5
|
export const renderer_measure: (a: number, b: any, c: number) => [number, number, number];
|
|
7
6
|
export const renderer_new: () => [number, number, number];
|
|
8
7
|
export const renderer_registerFont: (a: number, b: any) => [number, number, number];
|
|
@@ -15,7 +14,6 @@ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) =>
|
|
|
15
14
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
16
15
|
export const __externref_table_alloc: () => number;
|
|
17
16
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
18
|
-
export const __externref_drop_slice: (a: number, b: number) => void;
|
|
19
|
-
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
20
17
|
export const __externref_table_dealloc: (a: number) => void;
|
|
18
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
21
19
|
export const __wbindgen_start: () => void;
|
package/bundlers/type.d.ts
DELETED
|
File without changes
|