smart-downscaler 0.3.8 → 0.3.9
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/smart_downscaler.d.ts +48 -0
- package/smart_downscaler.js +1 -1
- package/smart_downscaler_bg.js +395 -0
- package/smart_downscaler_bg.wasm +0 -0
package/package.json
CHANGED
package/smart_downscaler.d.ts
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
export class ColorAnalysisResult {
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
getColor(index: number): ColorEntry | undefined;
|
|
9
|
+
getColorsFlat(): Uint8Array;
|
|
10
|
+
toJson(): ColorEntry[];
|
|
11
|
+
readonly colorCount: number;
|
|
12
|
+
readonly success: boolean;
|
|
13
|
+
readonly totalPixels: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ColorEntry {
|
|
17
|
+
private constructor();
|
|
18
|
+
free(): void;
|
|
19
|
+
[Symbol.dispose](): void;
|
|
20
|
+
readonly hex: string;
|
|
21
|
+
b: number;
|
|
22
|
+
count: number;
|
|
23
|
+
g: number;
|
|
24
|
+
percentage: number;
|
|
25
|
+
r: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
4
28
|
export class SmartDownscaler {
|
|
5
29
|
free(): void;
|
|
6
30
|
[Symbol.dispose](): void;
|
|
@@ -22,6 +46,26 @@ export class SmartDownscaler {
|
|
|
22
46
|
set_slic_params(region_size: number, _compactness: number, _iterations: number): void;
|
|
23
47
|
}
|
|
24
48
|
|
|
49
|
+
export class WasmDownscaleConfig {
|
|
50
|
+
free(): void;
|
|
51
|
+
[Symbol.dispose](): void;
|
|
52
|
+
constructor();
|
|
53
|
+
set_edge_weight(weight: number): void;
|
|
54
|
+
set_hierarchy_params(threshold: number): void;
|
|
55
|
+
set_k_centroid(k: number): void;
|
|
56
|
+
set_k_centroid_iterations(iterations: number): void;
|
|
57
|
+
set_kmeans_iterations(iterations: number): void;
|
|
58
|
+
set_max_color_preprocess(count: number): void;
|
|
59
|
+
set_max_resolution(mp: number): void;
|
|
60
|
+
set_neighbor_weight(weight: number): void;
|
|
61
|
+
set_palette_size(size: number): void;
|
|
62
|
+
set_palette_strategy(strategy: number): void;
|
|
63
|
+
set_refinement_iterations(iterations: number): void;
|
|
64
|
+
set_region_weight(weight: number): void;
|
|
65
|
+
set_segmentation_method(method: number): void;
|
|
66
|
+
set_slic_params(region_size: number, _compactness: number, _iterations: number): void;
|
|
67
|
+
}
|
|
68
|
+
|
|
25
69
|
export class WasmDownscaleResult {
|
|
26
70
|
private constructor();
|
|
27
71
|
free(): void;
|
|
@@ -32,3 +76,7 @@ export class WasmDownscaleResult {
|
|
|
32
76
|
height(): number;
|
|
33
77
|
width(): number;
|
|
34
78
|
}
|
|
79
|
+
|
|
80
|
+
export function analyze_colors(image_data: Uint8Array, max_colors: number, sort_method: string): ColorAnalysisResult;
|
|
81
|
+
|
|
82
|
+
export function downscale_rgba(image_data: Uint8Array, width: number, height: number, target_width: number, target_height: number, config: WasmDownscaleConfig): WasmDownscaleResult;
|
package/smart_downscaler.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./smart_downscaler_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
SmartDownscaler, WasmDownscaleResult
|
|
8
|
+
ColorAnalysisResult, ColorEntry, SmartDownscaler, WasmDownscaleConfig, WasmDownscaleResult, analyze_colors, downscale_rgba
|
|
9
9
|
} from "./smart_downscaler_bg.js";
|
package/smart_downscaler_bg.js
CHANGED
|
@@ -1,3 +1,172 @@
|
|
|
1
|
+
export class ColorAnalysisResult {
|
|
2
|
+
static __wrap(ptr) {
|
|
3
|
+
ptr = ptr >>> 0;
|
|
4
|
+
const obj = Object.create(ColorAnalysisResult.prototype);
|
|
5
|
+
obj.__wbg_ptr = ptr;
|
|
6
|
+
ColorAnalysisResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
7
|
+
return obj;
|
|
8
|
+
}
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
ColorAnalysisResultFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_coloranalysisresult_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @returns {number}
|
|
21
|
+
*/
|
|
22
|
+
get colorCount() {
|
|
23
|
+
const ret = wasm.coloranalysisresult_color_count(this.__wbg_ptr);
|
|
24
|
+
return ret >>> 0;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @param {number} index
|
|
28
|
+
* @returns {ColorEntry | undefined}
|
|
29
|
+
*/
|
|
30
|
+
getColor(index) {
|
|
31
|
+
const ret = wasm.coloranalysisresult_getColor(this.__wbg_ptr, index);
|
|
32
|
+
return ret === 0 ? undefined : ColorEntry.__wrap(ret);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @returns {Uint8Array}
|
|
36
|
+
*/
|
|
37
|
+
getColorsFlat() {
|
|
38
|
+
const ret = wasm.coloranalysisresult_getColorsFlat(this.__wbg_ptr);
|
|
39
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
40
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
41
|
+
return v1;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @returns {boolean}
|
|
45
|
+
*/
|
|
46
|
+
get success() {
|
|
47
|
+
const ret = wasm.coloranalysisresult_success(this.__wbg_ptr);
|
|
48
|
+
return ret !== 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @returns {ColorEntry[]}
|
|
52
|
+
*/
|
|
53
|
+
toJson() {
|
|
54
|
+
const ret = wasm.coloranalysisresult_toJson(this.__wbg_ptr);
|
|
55
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
56
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
57
|
+
return v1;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @returns {number}
|
|
61
|
+
*/
|
|
62
|
+
get totalPixels() {
|
|
63
|
+
const ret = wasm.coloranalysisresult_total_pixels(this.__wbg_ptr);
|
|
64
|
+
return ret >>> 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (Symbol.dispose) ColorAnalysisResult.prototype[Symbol.dispose] = ColorAnalysisResult.prototype.free;
|
|
68
|
+
|
|
69
|
+
export class ColorEntry {
|
|
70
|
+
static __wrap(ptr) {
|
|
71
|
+
ptr = ptr >>> 0;
|
|
72
|
+
const obj = Object.create(ColorEntry.prototype);
|
|
73
|
+
obj.__wbg_ptr = ptr;
|
|
74
|
+
ColorEntryFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
75
|
+
return obj;
|
|
76
|
+
}
|
|
77
|
+
__destroy_into_raw() {
|
|
78
|
+
const ptr = this.__wbg_ptr;
|
|
79
|
+
this.__wbg_ptr = 0;
|
|
80
|
+
ColorEntryFinalization.unregister(this);
|
|
81
|
+
return ptr;
|
|
82
|
+
}
|
|
83
|
+
free() {
|
|
84
|
+
const ptr = this.__destroy_into_raw();
|
|
85
|
+
wasm.__wbg_colorentry_free(ptr, 0);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @returns {string}
|
|
89
|
+
*/
|
|
90
|
+
get hex() {
|
|
91
|
+
let deferred1_0;
|
|
92
|
+
let deferred1_1;
|
|
93
|
+
try {
|
|
94
|
+
const ret = wasm.colorentry_hex(this.__wbg_ptr);
|
|
95
|
+
deferred1_0 = ret[0];
|
|
96
|
+
deferred1_1 = ret[1];
|
|
97
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
98
|
+
} finally {
|
|
99
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @returns {number}
|
|
104
|
+
*/
|
|
105
|
+
get b() {
|
|
106
|
+
const ret = wasm.__wbg_get_colorentry_b(this.__wbg_ptr);
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @returns {number}
|
|
111
|
+
*/
|
|
112
|
+
get count() {
|
|
113
|
+
const ret = wasm.__wbg_get_colorentry_count(this.__wbg_ptr);
|
|
114
|
+
return ret >>> 0;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @returns {number}
|
|
118
|
+
*/
|
|
119
|
+
get g() {
|
|
120
|
+
const ret = wasm.__wbg_get_colorentry_g(this.__wbg_ptr);
|
|
121
|
+
return ret;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @returns {number}
|
|
125
|
+
*/
|
|
126
|
+
get percentage() {
|
|
127
|
+
const ret = wasm.__wbg_get_colorentry_percentage(this.__wbg_ptr);
|
|
128
|
+
return ret;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @returns {number}
|
|
132
|
+
*/
|
|
133
|
+
get r() {
|
|
134
|
+
const ret = wasm.__wbg_get_colorentry_r(this.__wbg_ptr);
|
|
135
|
+
return ret;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @param {number} arg0
|
|
139
|
+
*/
|
|
140
|
+
set b(arg0) {
|
|
141
|
+
wasm.__wbg_set_colorentry_b(this.__wbg_ptr, arg0);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* @param {number} arg0
|
|
145
|
+
*/
|
|
146
|
+
set count(arg0) {
|
|
147
|
+
wasm.__wbg_set_colorentry_count(this.__wbg_ptr, arg0);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @param {number} arg0
|
|
151
|
+
*/
|
|
152
|
+
set g(arg0) {
|
|
153
|
+
wasm.__wbg_set_colorentry_g(this.__wbg_ptr, arg0);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @param {number} arg0
|
|
157
|
+
*/
|
|
158
|
+
set percentage(arg0) {
|
|
159
|
+
wasm.__wbg_set_colorentry_percentage(this.__wbg_ptr, arg0);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @param {number} arg0
|
|
163
|
+
*/
|
|
164
|
+
set r(arg0) {
|
|
165
|
+
wasm.__wbg_set_colorentry_r(this.__wbg_ptr, arg0);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (Symbol.dispose) ColorEntry.prototype[Symbol.dispose] = ColorEntry.prototype.free;
|
|
169
|
+
|
|
1
170
|
export class SmartDownscaler {
|
|
2
171
|
__destroy_into_raw() {
|
|
3
172
|
const ptr = this.__wbg_ptr;
|
|
@@ -118,6 +287,112 @@ export class SmartDownscaler {
|
|
|
118
287
|
}
|
|
119
288
|
if (Symbol.dispose) SmartDownscaler.prototype[Symbol.dispose] = SmartDownscaler.prototype.free;
|
|
120
289
|
|
|
290
|
+
export class WasmDownscaleConfig {
|
|
291
|
+
__destroy_into_raw() {
|
|
292
|
+
const ptr = this.__wbg_ptr;
|
|
293
|
+
this.__wbg_ptr = 0;
|
|
294
|
+
WasmDownscaleConfigFinalization.unregister(this);
|
|
295
|
+
return ptr;
|
|
296
|
+
}
|
|
297
|
+
free() {
|
|
298
|
+
const ptr = this.__destroy_into_raw();
|
|
299
|
+
wasm.__wbg_wasmdownscaleconfig_free(ptr, 0);
|
|
300
|
+
}
|
|
301
|
+
constructor() {
|
|
302
|
+
const ret = wasm.smartdownscaler_new();
|
|
303
|
+
this.__wbg_ptr = ret >>> 0;
|
|
304
|
+
WasmDownscaleConfigFinalization.register(this, this.__wbg_ptr, this);
|
|
305
|
+
return this;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* @param {number} weight
|
|
309
|
+
*/
|
|
310
|
+
set_edge_weight(weight) {
|
|
311
|
+
wasm.smartdownscaler_set_edge_weight(this.__wbg_ptr, weight);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* @param {number} threshold
|
|
315
|
+
*/
|
|
316
|
+
set_hierarchy_params(threshold) {
|
|
317
|
+
wasm.wasmdownscaleconfig_set_hierarchy_params(this.__wbg_ptr, threshold);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* @param {number} k
|
|
321
|
+
*/
|
|
322
|
+
set_k_centroid(k) {
|
|
323
|
+
wasm.smartdownscaler_set_k_centroid(this.__wbg_ptr, k);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* @param {number} iterations
|
|
327
|
+
*/
|
|
328
|
+
set_k_centroid_iterations(iterations) {
|
|
329
|
+
wasm.smartdownscaler_set_k_centroid_iterations(this.__wbg_ptr, iterations);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* @param {number} iterations
|
|
333
|
+
*/
|
|
334
|
+
set_kmeans_iterations(iterations) {
|
|
335
|
+
wasm.smartdownscaler_set_kmeans_iterations(this.__wbg_ptr, iterations);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* @param {number} count
|
|
339
|
+
*/
|
|
340
|
+
set_max_color_preprocess(count) {
|
|
341
|
+
wasm.smartdownscaler_set_max_color_preprocess(this.__wbg_ptr, count);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* @param {number} mp
|
|
345
|
+
*/
|
|
346
|
+
set_max_resolution(mp) {
|
|
347
|
+
wasm.smartdownscaler_set_max_resolution(this.__wbg_ptr, mp);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* @param {number} weight
|
|
351
|
+
*/
|
|
352
|
+
set_neighbor_weight(weight) {
|
|
353
|
+
wasm.smartdownscaler_set_neighbor_weight(this.__wbg_ptr, weight);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* @param {number} size
|
|
357
|
+
*/
|
|
358
|
+
set_palette_size(size) {
|
|
359
|
+
wasm.smartdownscaler_set_palette_size(this.__wbg_ptr, size);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* @param {number} strategy
|
|
363
|
+
*/
|
|
364
|
+
set_palette_strategy(strategy) {
|
|
365
|
+
wasm.smartdownscaler_set_palette_strategy(this.__wbg_ptr, strategy);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* @param {number} iterations
|
|
369
|
+
*/
|
|
370
|
+
set_refinement_iterations(iterations) {
|
|
371
|
+
wasm.smartdownscaler_set_refinement_iterations(this.__wbg_ptr, iterations);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* @param {number} weight
|
|
375
|
+
*/
|
|
376
|
+
set_region_weight(weight) {
|
|
377
|
+
wasm.smartdownscaler_set_region_weight(this.__wbg_ptr, weight);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* @param {number} method
|
|
381
|
+
*/
|
|
382
|
+
set_segmentation_method(method) {
|
|
383
|
+
wasm.wasmdownscaleconfig_set_segmentation_method(this.__wbg_ptr, method);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* @param {number} region_size
|
|
387
|
+
* @param {number} _compactness
|
|
388
|
+
* @param {number} _iterations
|
|
389
|
+
*/
|
|
390
|
+
set_slic_params(region_size, _compactness, _iterations) {
|
|
391
|
+
wasm.wasmdownscaleconfig_set_slic_params(this.__wbg_ptr, region_size, _compactness, _iterations);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (Symbol.dispose) WasmDownscaleConfig.prototype[Symbol.dispose] = WasmDownscaleConfig.prototype.free;
|
|
395
|
+
|
|
121
396
|
export class WasmDownscaleResult {
|
|
122
397
|
static __wrap(ptr) {
|
|
123
398
|
ptr = ptr >>> 0;
|
|
@@ -179,9 +454,45 @@ export class WasmDownscaleResult {
|
|
|
179
454
|
}
|
|
180
455
|
}
|
|
181
456
|
if (Symbol.dispose) WasmDownscaleResult.prototype[Symbol.dispose] = WasmDownscaleResult.prototype.free;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* @param {Uint8Array} image_data
|
|
460
|
+
* @param {number} max_colors
|
|
461
|
+
* @param {string} sort_method
|
|
462
|
+
* @returns {ColorAnalysisResult}
|
|
463
|
+
*/
|
|
464
|
+
export function analyze_colors(image_data, max_colors, sort_method) {
|
|
465
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_malloc);
|
|
466
|
+
const len0 = WASM_VECTOR_LEN;
|
|
467
|
+
const ptr1 = passStringToWasm0(sort_method, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
468
|
+
const len1 = WASM_VECTOR_LEN;
|
|
469
|
+
const ret = wasm.analyze_colors(ptr0, len0, max_colors, ptr1, len1);
|
|
470
|
+
return ColorAnalysisResult.__wrap(ret);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* @param {Uint8Array} image_data
|
|
475
|
+
* @param {number} width
|
|
476
|
+
* @param {number} height
|
|
477
|
+
* @param {number} target_width
|
|
478
|
+
* @param {number} target_height
|
|
479
|
+
* @param {WasmDownscaleConfig} config
|
|
480
|
+
* @returns {WasmDownscaleResult}
|
|
481
|
+
*/
|
|
482
|
+
export function downscale_rgba(image_data, width, height, target_width, target_height, config) {
|
|
483
|
+
const ptr0 = passArray8ToWasm0(image_data, wasm.__wbindgen_malloc);
|
|
484
|
+
const len0 = WASM_VECTOR_LEN;
|
|
485
|
+
_assertClass(config, WasmDownscaleConfig);
|
|
486
|
+
const ret = wasm.downscale_rgba(ptr0, len0, width, height, target_width, target_height, config.__wbg_ptr);
|
|
487
|
+
return WasmDownscaleResult.__wrap(ret);
|
|
488
|
+
}
|
|
182
489
|
export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
|
|
183
490
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
184
491
|
}
|
|
492
|
+
export function __wbg_colorentry_new(arg0) {
|
|
493
|
+
const ret = ColorEntry.__wrap(arg0);
|
|
494
|
+
return ret;
|
|
495
|
+
}
|
|
185
496
|
export function __wbindgen_init_externref_table() {
|
|
186
497
|
const table = wasm.__wbindgen_externrefs;
|
|
187
498
|
const offset = table.grow(4);
|
|
@@ -191,18 +502,52 @@ export function __wbindgen_init_externref_table() {
|
|
|
191
502
|
table.set(offset + 2, true);
|
|
192
503
|
table.set(offset + 3, false);
|
|
193
504
|
}
|
|
505
|
+
const ColorAnalysisResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
506
|
+
? { register: () => {}, unregister: () => {} }
|
|
507
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_coloranalysisresult_free(ptr >>> 0, 1));
|
|
508
|
+
const ColorEntryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
509
|
+
? { register: () => {}, unregister: () => {} }
|
|
510
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_colorentry_free(ptr >>> 0, 1));
|
|
194
511
|
const SmartDownscalerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
195
512
|
? { register: () => {}, unregister: () => {} }
|
|
196
513
|
: new FinalizationRegistry(ptr => wasm.__wbg_smartdownscaler_free(ptr >>> 0, 1));
|
|
514
|
+
const WasmDownscaleConfigFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
515
|
+
? { register: () => {}, unregister: () => {} }
|
|
516
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdownscaleconfig_free(ptr >>> 0, 1));
|
|
197
517
|
const WasmDownscaleResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
198
518
|
? { register: () => {}, unregister: () => {} }
|
|
199
519
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmdownscaleresult_free(ptr >>> 0, 1));
|
|
200
520
|
|
|
521
|
+
function _assertClass(instance, klass) {
|
|
522
|
+
if (!(instance instanceof klass)) {
|
|
523
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
528
|
+
ptr = ptr >>> 0;
|
|
529
|
+
const mem = getDataViewMemory0();
|
|
530
|
+
const result = [];
|
|
531
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
532
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
533
|
+
}
|
|
534
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
535
|
+
return result;
|
|
536
|
+
}
|
|
537
|
+
|
|
201
538
|
function getArrayU8FromWasm0(ptr, len) {
|
|
202
539
|
ptr = ptr >>> 0;
|
|
203
540
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
204
541
|
}
|
|
205
542
|
|
|
543
|
+
let cachedDataViewMemory0 = null;
|
|
544
|
+
function getDataViewMemory0() {
|
|
545
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
546
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
547
|
+
}
|
|
548
|
+
return cachedDataViewMemory0;
|
|
549
|
+
}
|
|
550
|
+
|
|
206
551
|
function getStringFromWasm0(ptr, len) {
|
|
207
552
|
ptr = ptr >>> 0;
|
|
208
553
|
return decodeText(ptr, len);
|
|
@@ -223,6 +568,43 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
223
568
|
return ptr;
|
|
224
569
|
}
|
|
225
570
|
|
|
571
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
572
|
+
if (realloc === undefined) {
|
|
573
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
574
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
575
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
576
|
+
WASM_VECTOR_LEN = buf.length;
|
|
577
|
+
return ptr;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
let len = arg.length;
|
|
581
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
582
|
+
|
|
583
|
+
const mem = getUint8ArrayMemory0();
|
|
584
|
+
|
|
585
|
+
let offset = 0;
|
|
586
|
+
|
|
587
|
+
for (; offset < len; offset++) {
|
|
588
|
+
const code = arg.charCodeAt(offset);
|
|
589
|
+
if (code > 0x7F) break;
|
|
590
|
+
mem[ptr + offset] = code;
|
|
591
|
+
}
|
|
592
|
+
if (offset !== len) {
|
|
593
|
+
if (offset !== 0) {
|
|
594
|
+
arg = arg.slice(offset);
|
|
595
|
+
}
|
|
596
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
597
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
598
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
599
|
+
|
|
600
|
+
offset += ret.written;
|
|
601
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
WASM_VECTOR_LEN = offset;
|
|
605
|
+
return ptr;
|
|
606
|
+
}
|
|
607
|
+
|
|
226
608
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
227
609
|
cachedTextDecoder.decode();
|
|
228
610
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
@@ -237,6 +619,19 @@ function decodeText(ptr, len) {
|
|
|
237
619
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
238
620
|
}
|
|
239
621
|
|
|
622
|
+
const cachedTextEncoder = new TextEncoder();
|
|
623
|
+
|
|
624
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
625
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
626
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
627
|
+
view.set(buf);
|
|
628
|
+
return {
|
|
629
|
+
read: arg.length,
|
|
630
|
+
written: buf.length
|
|
631
|
+
};
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
|
|
240
635
|
let WASM_VECTOR_LEN = 0;
|
|
241
636
|
|
|
242
637
|
|
package/smart_downscaler_bg.wasm
CHANGED
|
Binary file
|