@takumi-rs/wasm 0.28.4 → 0.29.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/package.json +1 -1
- package/pkg/takumi_wasm.d.ts +9 -6
- package/pkg/takumi_wasm.js +96 -56
- package/pkg/takumi_wasm_bg.wasm +0 -0
- package/pkg/takumi_wasm_bg.wasm.d.ts +2 -0
package/package.json
CHANGED
package/pkg/takumi_wasm.d.ts
CHANGED
|
@@ -5,11 +5,7 @@
|
|
|
5
5
|
* This is needed because wasm-bindgen doesn't support cfg macro in enum variants.
|
|
6
6
|
* https://github.com/erwanvivien/fast_qr/pull/41/files
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
WebP = 0,
|
|
10
|
-
Png = 1,
|
|
11
|
-
Jpeg = 2,
|
|
12
|
-
}
|
|
8
|
+
type ImageOutputFormat = "webp" | "png" | "jpeg";
|
|
13
9
|
|
|
14
10
|
export interface AnyNode {
|
|
15
11
|
type: string;
|
|
@@ -17,10 +13,15 @@ export interface AnyNode {
|
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
|
|
16
|
+
export class FontInfo {
|
|
17
|
+
private constructor();
|
|
18
|
+
free(): void;
|
|
19
|
+
}
|
|
20
20
|
export class Renderer {
|
|
21
21
|
free(): void;
|
|
22
22
|
constructor(debug?: boolean | null);
|
|
23
|
-
|
|
23
|
+
loadFontWithInfo(font_data: FontInfo): void;
|
|
24
|
+
loadFont(buffer: Uint8Array): void;
|
|
24
25
|
putPersistentImage(src: string, data: Uint8Array): void;
|
|
25
26
|
clearImageStore(): void;
|
|
26
27
|
render(node: AnyNode, width: number, height: number, format?: ImageOutputFormat | null, quality?: number | null): Uint8Array;
|
|
@@ -31,8 +32,10 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
31
32
|
|
|
32
33
|
export interface InitOutput {
|
|
33
34
|
readonly memory: WebAssembly.Memory;
|
|
35
|
+
readonly __wbg_fontinfo_free: (a: number, b: number) => void;
|
|
34
36
|
readonly __wbg_renderer_free: (a: number, b: number) => void;
|
|
35
37
|
readonly renderer_new: (a: number) => number;
|
|
38
|
+
readonly renderer_loadFontWithInfo: (a: number, b: number) => void;
|
|
36
39
|
readonly renderer_loadFont: (a: number, b: number, c: number) => void;
|
|
37
40
|
readonly renderer_putPersistentImage: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
38
41
|
readonly renderer_clearImageStore: (a: number) => void;
|
package/pkg/takumi_wasm.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
let wasm;
|
|
2
2
|
|
|
3
|
+
let cachedUint8ArrayMemory0 = null;
|
|
4
|
+
|
|
5
|
+
function getUint8ArrayMemory0() {
|
|
6
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
7
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
8
|
+
}
|
|
9
|
+
return cachedUint8ArrayMemory0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
13
|
+
|
|
14
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
15
|
+
|
|
16
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
+
let numBytesDecoded = 0;
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
numBytesDecoded += len;
|
|
20
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
+
cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
22
|
+
cachedTextDecoder.decode();
|
|
23
|
+
numBytesDecoded = len;
|
|
24
|
+
}
|
|
25
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getStringFromWasm0(ptr, len) {
|
|
29
|
+
ptr = ptr >>> 0;
|
|
30
|
+
return decodeText(ptr, len);
|
|
31
|
+
}
|
|
32
|
+
|
|
3
33
|
function addToExternrefTable0(obj) {
|
|
4
34
|
const idx = wasm.__externref_table_alloc();
|
|
5
35
|
wasm.__wbindgen_export_2.set(idx, obj);
|
|
@@ -95,15 +125,6 @@ function debugString(val) {
|
|
|
95
125
|
|
|
96
126
|
let WASM_VECTOR_LEN = 0;
|
|
97
127
|
|
|
98
|
-
let cachedUint8ArrayMemory0 = null;
|
|
99
|
-
|
|
100
|
-
function getUint8ArrayMemory0() {
|
|
101
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
102
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
103
|
-
}
|
|
104
|
-
return cachedUint8ArrayMemory0;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
128
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
108
129
|
|
|
109
130
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -158,13 +179,10 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
158
179
|
return ptr;
|
|
159
180
|
}
|
|
160
181
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
function getStringFromWasm0(ptr, len) {
|
|
166
|
-
ptr = ptr >>> 0;
|
|
167
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
182
|
+
function _assertClass(instance, klass) {
|
|
183
|
+
if (!(instance instanceof klass)) {
|
|
184
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
185
|
+
}
|
|
168
186
|
}
|
|
169
187
|
|
|
170
188
|
function passArray8ToWasm0(arg, malloc) {
|
|
@@ -178,17 +196,27 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
178
196
|
ptr = ptr >>> 0;
|
|
179
197
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
180
198
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
199
|
+
|
|
200
|
+
const __wbindgen_enum_ImageOutputFormat = ["webp", "png", "jpeg"];
|
|
201
|
+
|
|
202
|
+
const FontInfoFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
203
|
+
? { register: () => {}, unregister: () => {} }
|
|
204
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_fontinfo_free(ptr >>> 0, 1));
|
|
205
|
+
|
|
206
|
+
export class FontInfo {
|
|
207
|
+
|
|
208
|
+
__destroy_into_raw() {
|
|
209
|
+
const ptr = this.__wbg_ptr;
|
|
210
|
+
this.__wbg_ptr = 0;
|
|
211
|
+
FontInfoFinalization.unregister(this);
|
|
212
|
+
return ptr;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
free() {
|
|
216
|
+
const ptr = this.__destroy_into_raw();
|
|
217
|
+
wasm.__wbg_fontinfo_free(ptr, 0);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
192
220
|
|
|
193
221
|
const RendererFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
194
222
|
? { register: () => {}, unregister: () => {} }
|
|
@@ -217,10 +245,18 @@ export class Renderer {
|
|
|
217
245
|
return this;
|
|
218
246
|
}
|
|
219
247
|
/**
|
|
220
|
-
* @param {
|
|
248
|
+
* @param {FontInfo} font_data
|
|
221
249
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
250
|
+
loadFontWithInfo(font_data) {
|
|
251
|
+
_assertClass(font_data, FontInfo);
|
|
252
|
+
var ptr0 = font_data.__destroy_into_raw();
|
|
253
|
+
wasm.renderer_loadFontWithInfo(this.__wbg_ptr, ptr0);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* @param {Uint8Array} buffer
|
|
257
|
+
*/
|
|
258
|
+
loadFont(buffer) {
|
|
259
|
+
const ptr0 = passArray8ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
224
260
|
const len0 = WASM_VECTOR_LEN;
|
|
225
261
|
wasm.renderer_loadFont(this.__wbg_ptr, ptr0, len0);
|
|
226
262
|
}
|
|
@@ -247,7 +283,7 @@ export class Renderer {
|
|
|
247
283
|
* @returns {Uint8Array}
|
|
248
284
|
*/
|
|
249
285
|
render(node, width, height, format, quality) {
|
|
250
|
-
const ret = wasm.renderer_render(this.__wbg_ptr, node, width, height, isLikeNone(format) ?
|
|
286
|
+
const ret = wasm.renderer_render(this.__wbg_ptr, node, width, height, isLikeNone(format) ? 4 : ((__wbindgen_enum_ImageOutputFormat.indexOf(format) + 1 || 4) - 1), isLikeNone(quality) ? 0xFFFFFF : quality);
|
|
251
287
|
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
252
288
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
253
289
|
return v1;
|
|
@@ -264,7 +300,7 @@ export class Renderer {
|
|
|
264
300
|
let deferred1_0;
|
|
265
301
|
let deferred1_1;
|
|
266
302
|
try {
|
|
267
|
-
const ret = wasm.renderer_renderAsDataUrl(this.__wbg_ptr, node, width, height, isLikeNone(format) ?
|
|
303
|
+
const ret = wasm.renderer_renderAsDataUrl(this.__wbg_ptr, node, width, height, isLikeNone(format) ? 4 : ((__wbindgen_enum_ImageOutputFormat.indexOf(format) + 1 || 4) - 1), isLikeNone(quality) ? 0xFFFFFF : quality);
|
|
268
304
|
deferred1_0 = ret[0];
|
|
269
305
|
deferred1_1 = ret[1];
|
|
270
306
|
return getStringFromWasm0(ret[0], ret[1]);
|
|
@@ -274,6 +310,8 @@ export class Renderer {
|
|
|
274
310
|
}
|
|
275
311
|
}
|
|
276
312
|
|
|
313
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
314
|
+
|
|
277
315
|
async function __wbg_load(module, imports) {
|
|
278
316
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
279
317
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
@@ -281,7 +319,9 @@ async function __wbg_load(module, imports) {
|
|
|
281
319
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
282
320
|
|
|
283
321
|
} catch (e) {
|
|
284
|
-
|
|
322
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
323
|
+
|
|
324
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
285
325
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
286
326
|
|
|
287
327
|
} else {
|
|
@@ -308,31 +348,35 @@ async function __wbg_load(module, imports) {
|
|
|
308
348
|
function __wbg_get_imports() {
|
|
309
349
|
const imports = {};
|
|
310
350
|
imports.wbg = {};
|
|
311
|
-
imports.wbg.
|
|
351
|
+
imports.wbg.__wbg_Error_0497d5bdba9362e5 = function(arg0, arg1) {
|
|
352
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
353
|
+
return ret;
|
|
354
|
+
};
|
|
355
|
+
imports.wbg.__wbg_buffer_a1a27a0dfa70165d = function(arg0) {
|
|
312
356
|
const ret = arg0.buffer;
|
|
313
357
|
return ret;
|
|
314
358
|
};
|
|
315
|
-
imports.wbg.
|
|
359
|
+
imports.wbg.__wbg_call_fbe8be8bf6436ce5 = function() { return handleError(function (arg0, arg1) {
|
|
316
360
|
const ret = arg0.call(arg1);
|
|
317
361
|
return ret;
|
|
318
362
|
}, arguments) };
|
|
319
|
-
imports.wbg.
|
|
363
|
+
imports.wbg.__wbg_done_4d01f352bade43b7 = function(arg0) {
|
|
320
364
|
const ret = arg0.done;
|
|
321
365
|
return ret;
|
|
322
366
|
};
|
|
323
|
-
imports.wbg.
|
|
367
|
+
imports.wbg.__wbg_entries_41651c850143b957 = function(arg0) {
|
|
324
368
|
const ret = Object.entries(arg0);
|
|
325
369
|
return ret;
|
|
326
370
|
};
|
|
327
|
-
imports.wbg.
|
|
371
|
+
imports.wbg.__wbg_get_92470be87867c2e5 = function() { return handleError(function (arg0, arg1) {
|
|
328
372
|
const ret = Reflect.get(arg0, arg1);
|
|
329
373
|
return ret;
|
|
330
374
|
}, arguments) };
|
|
331
|
-
imports.wbg.
|
|
375
|
+
imports.wbg.__wbg_get_a131a44bd1eb6979 = function(arg0, arg1) {
|
|
332
376
|
const ret = arg0[arg1 >>> 0];
|
|
333
377
|
return ret;
|
|
334
378
|
};
|
|
335
|
-
imports.wbg.
|
|
379
|
+
imports.wbg.__wbg_instanceof_ArrayBuffer_a8b6f580b363f2bc = function(arg0) {
|
|
336
380
|
let result;
|
|
337
381
|
try {
|
|
338
382
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -342,7 +386,7 @@ function __wbg_get_imports() {
|
|
|
342
386
|
const ret = result;
|
|
343
387
|
return ret;
|
|
344
388
|
};
|
|
345
|
-
imports.wbg.
|
|
389
|
+
imports.wbg.__wbg_instanceof_Map_80cc65041c96417a = function(arg0) {
|
|
346
390
|
let result;
|
|
347
391
|
try {
|
|
348
392
|
result = arg0 instanceof Map;
|
|
@@ -352,7 +396,7 @@ function __wbg_get_imports() {
|
|
|
352
396
|
const ret = result;
|
|
353
397
|
return ret;
|
|
354
398
|
};
|
|
355
|
-
imports.wbg.
|
|
399
|
+
imports.wbg.__wbg_instanceof_Uint8Array_ca460677bc155827 = function(arg0) {
|
|
356
400
|
let result;
|
|
357
401
|
try {
|
|
358
402
|
result = arg0 instanceof Uint8Array;
|
|
@@ -362,42 +406,42 @@ function __wbg_get_imports() {
|
|
|
362
406
|
const ret = result;
|
|
363
407
|
return ret;
|
|
364
408
|
};
|
|
365
|
-
imports.wbg.
|
|
409
|
+
imports.wbg.__wbg_isArray_5f090bed72bd4f89 = function(arg0) {
|
|
366
410
|
const ret = Array.isArray(arg0);
|
|
367
411
|
return ret;
|
|
368
412
|
};
|
|
369
|
-
imports.wbg.
|
|
413
|
+
imports.wbg.__wbg_isSafeInteger_90d7c4674047d684 = function(arg0) {
|
|
370
414
|
const ret = Number.isSafeInteger(arg0);
|
|
371
415
|
return ret;
|
|
372
416
|
};
|
|
373
|
-
imports.wbg.
|
|
417
|
+
imports.wbg.__wbg_iterator_4068add5b2aef7a6 = function() {
|
|
374
418
|
const ret = Symbol.iterator;
|
|
375
419
|
return ret;
|
|
376
420
|
};
|
|
377
|
-
imports.wbg.
|
|
421
|
+
imports.wbg.__wbg_length_ab6d22b5ead75c72 = function(arg0) {
|
|
378
422
|
const ret = arg0.length;
|
|
379
423
|
return ret;
|
|
380
424
|
};
|
|
381
|
-
imports.wbg.
|
|
425
|
+
imports.wbg.__wbg_length_f00ec12454a5d9fd = function(arg0) {
|
|
382
426
|
const ret = arg0.length;
|
|
383
427
|
return ret;
|
|
384
428
|
};
|
|
385
|
-
imports.wbg.
|
|
429
|
+
imports.wbg.__wbg_new_e52b3efaaa774f96 = function(arg0) {
|
|
386
430
|
const ret = new Uint8Array(arg0);
|
|
387
431
|
return ret;
|
|
388
432
|
};
|
|
389
|
-
imports.wbg.
|
|
433
|
+
imports.wbg.__wbg_next_8bb824d217961b5d = function(arg0) {
|
|
390
434
|
const ret = arg0.next;
|
|
391
435
|
return ret;
|
|
392
436
|
};
|
|
393
|
-
imports.wbg.
|
|
437
|
+
imports.wbg.__wbg_next_e2da48d8fff7439a = function() { return handleError(function (arg0) {
|
|
394
438
|
const ret = arg0.next();
|
|
395
439
|
return ret;
|
|
396
440
|
}, arguments) };
|
|
397
|
-
imports.wbg.
|
|
441
|
+
imports.wbg.__wbg_set_fe4e79d1ed3b0e9b = function(arg0, arg1, arg2) {
|
|
398
442
|
arg0.set(arg1, arg2 >>> 0);
|
|
399
443
|
};
|
|
400
|
-
imports.wbg.
|
|
444
|
+
imports.wbg.__wbg_value_17b896954e14f896 = function(arg0) {
|
|
401
445
|
const ret = arg0.value;
|
|
402
446
|
return ret;
|
|
403
447
|
};
|
|
@@ -427,10 +471,6 @@ function __wbg_get_imports() {
|
|
|
427
471
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
428
472
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
429
473
|
};
|
|
430
|
-
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
431
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
432
|
-
return ret;
|
|
433
|
-
};
|
|
434
474
|
imports.wbg.__wbindgen_in = function(arg0, arg1) {
|
|
435
475
|
const ret = arg0 in arg1;
|
|
436
476
|
return ret;
|
package/pkg/takumi_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_fontinfo_free: (a: number, b: number) => void;
|
|
4
5
|
export const __wbg_renderer_free: (a: number, b: number) => void;
|
|
5
6
|
export const renderer_new: (a: number) => number;
|
|
7
|
+
export const renderer_loadFontWithInfo: (a: number, b: number) => void;
|
|
6
8
|
export const renderer_loadFont: (a: number, b: number, c: number) => void;
|
|
7
9
|
export const renderer_putPersistentImage: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
8
10
|
export const renderer_clearImageStore: (a: number) => void;
|