merfix 0.1.71 → 0.1.72

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/merfix.d.ts CHANGED
@@ -2,18 +2,18 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  export class ExifRemovalResult {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
- status(): string;
9
- get_data(): Uint8Array | undefined;
10
- is_error(): boolean;
11
- get_error(): string | undefined;
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ get_data(): Uint8Array | undefined;
9
+ get_error(): string | undefined;
10
+ is_error(): boolean;
11
+ status(): string;
12
12
  }
13
13
 
14
14
  export enum ExifRemovalStatus {
15
- Success = 0,
16
- Error = 1,
15
+ Success = 0,
16
+ Error = 1,
17
17
  }
18
18
 
19
19
  export function detect_image_extension(data: Uint8Array): string | undefined;
@@ -31,44 +31,44 @@ export function version(): string;
31
31
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
32
32
 
33
33
  export interface InitOutput {
34
- readonly memory: WebAssembly.Memory;
35
- readonly __wbg_exifremovalresult_free: (a: number, b: number) => void;
36
- readonly detect_image_extension: (a: number, b: number) => [number, number];
37
- readonly detect_image_mime_type: (a: number, b: number) => [number, number];
38
- readonly exifremovalresult_get_data: (a: number) => [number, number];
39
- readonly exifremovalresult_get_error: (a: number) => [number, number];
40
- readonly exifremovalresult_is_error: (a: number) => number;
41
- readonly exifremovalresult_status: (a: number) => [number, number];
42
- readonly remove_exif: (a: number, b: number, c: number, d: number) => number;
43
- readonly supported_extensions: () => [number, number];
44
- readonly supported_mime_types: () => [number, number];
45
- readonly version: () => [number, number];
46
- readonly __wbindgen_externrefs: WebAssembly.Table;
47
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
48
- readonly __wbindgen_malloc: (a: number, b: number) => number;
49
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
50
- readonly __externref_drop_slice: (a: number, b: number) => void;
51
- readonly __wbindgen_start: () => void;
34
+ readonly memory: WebAssembly.Memory;
35
+ readonly __wbg_exifremovalresult_free: (a: number, b: number) => void;
36
+ readonly detect_image_extension: (a: number, b: number) => [number, number];
37
+ readonly detect_image_mime_type: (a: number, b: number) => [number, number];
38
+ readonly exifremovalresult_get_data: (a: number) => [number, number];
39
+ readonly exifremovalresult_get_error: (a: number) => [number, number];
40
+ readonly exifremovalresult_is_error: (a: number) => number;
41
+ readonly exifremovalresult_status: (a: number) => [number, number];
42
+ readonly remove_exif: (a: number, b: number, c: number, d: number) => number;
43
+ readonly supported_extensions: () => [number, number];
44
+ readonly supported_mime_types: () => [number, number];
45
+ readonly version: () => [number, number];
46
+ readonly __wbindgen_externrefs: WebAssembly.Table;
47
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
48
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
49
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
50
+ readonly __externref_drop_slice: (a: number, b: number) => void;
51
+ readonly __wbindgen_start: () => void;
52
52
  }
53
53
 
54
54
  export type SyncInitInput = BufferSource | WebAssembly.Module;
55
55
 
56
56
  /**
57
- * Instantiates the given `module`, which can either be bytes or
58
- * a precompiled `WebAssembly.Module`.
59
- *
60
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
61
- *
62
- * @returns {InitOutput}
63
- */
57
+ * Instantiates the given `module`, which can either be bytes or
58
+ * a precompiled `WebAssembly.Module`.
59
+ *
60
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
61
+ *
62
+ * @returns {InitOutput}
63
+ */
64
64
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
65
65
 
66
66
  /**
67
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
68
- * for everything else, calls `WebAssembly.instantiate` directly.
69
- *
70
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
71
- *
72
- * @returns {Promise<InitOutput>}
73
- */
67
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
68
+ * for everything else, calls `WebAssembly.instantiate` directly.
69
+ *
70
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
71
+ *
72
+ * @returns {Promise<InitOutput>}
73
+ */
74
74
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/merfix.js CHANGED
@@ -1,118 +1,4 @@
1
- let wasm;
2
-
3
- function getArrayJsValueFromWasm0(ptr, len) {
4
- ptr = ptr >>> 0;
5
- const mem = getDataViewMemory0();
6
- const result = [];
7
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
8
- result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
9
- }
10
- wasm.__externref_drop_slice(ptr, len);
11
- return result;
12
- }
13
-
14
- function getArrayU8FromWasm0(ptr, len) {
15
- ptr = ptr >>> 0;
16
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
17
- }
18
-
19
- let cachedDataViewMemory0 = null;
20
- function getDataViewMemory0() {
21
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
22
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
23
- }
24
- return cachedDataViewMemory0;
25
- }
26
-
27
- function getStringFromWasm0(ptr, len) {
28
- ptr = ptr >>> 0;
29
- return decodeText(ptr, len);
30
- }
31
-
32
- let cachedUint8ArrayMemory0 = null;
33
- function getUint8ArrayMemory0() {
34
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
35
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
36
- }
37
- return cachedUint8ArrayMemory0;
38
- }
39
-
40
- function passArray8ToWasm0(arg, malloc) {
41
- const ptr = malloc(arg.length * 1, 1) >>> 0;
42
- getUint8ArrayMemory0().set(arg, ptr / 1);
43
- WASM_VECTOR_LEN = arg.length;
44
- return ptr;
45
- }
46
-
47
- function passStringToWasm0(arg, malloc, realloc) {
48
- if (realloc === undefined) {
49
- const buf = cachedTextEncoder.encode(arg);
50
- const ptr = malloc(buf.length, 1) >>> 0;
51
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
52
- WASM_VECTOR_LEN = buf.length;
53
- return ptr;
54
- }
55
-
56
- let len = arg.length;
57
- let ptr = malloc(len, 1) >>> 0;
58
-
59
- const mem = getUint8ArrayMemory0();
60
-
61
- let offset = 0;
62
-
63
- for (; offset < len; offset++) {
64
- const code = arg.charCodeAt(offset);
65
- if (code > 0x7F) break;
66
- mem[ptr + offset] = code;
67
- }
68
- if (offset !== len) {
69
- if (offset !== 0) {
70
- arg = arg.slice(offset);
71
- }
72
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
73
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
74
- const ret = cachedTextEncoder.encodeInto(arg, view);
75
-
76
- offset += ret.written;
77
- ptr = realloc(ptr, len, offset, 1) >>> 0;
78
- }
79
-
80
- WASM_VECTOR_LEN = offset;
81
- return ptr;
82
- }
83
-
84
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
85
- cachedTextDecoder.decode();
86
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
87
- let numBytesDecoded = 0;
88
- function decodeText(ptr, len) {
89
- numBytesDecoded += len;
90
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
91
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
92
- cachedTextDecoder.decode();
93
- numBytesDecoded = len;
94
- }
95
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
96
- }
97
-
98
- const cachedTextEncoder = new TextEncoder();
99
-
100
- if (!('encodeInto' in cachedTextEncoder)) {
101
- cachedTextEncoder.encodeInto = function (arg, view) {
102
- const buf = cachedTextEncoder.encode(arg);
103
- view.set(buf);
104
- return {
105
- read: arg.length,
106
- written: buf.length
107
- };
108
- }
109
- }
110
-
111
- let WASM_VECTOR_LEN = 0;
112
-
113
- const ExifRemovalResultFinalization = (typeof FinalizationRegistry === 'undefined')
114
- ? { register: () => {}, unregister: () => {} }
115
- : new FinalizationRegistry(ptr => wasm.__wbg_exifremovalresult_free(ptr >>> 0, 1));
1
+ /* @ts-self-types="./merfix.d.ts" */
116
2
 
117
3
  export class ExifRemovalResult {
118
4
  static __wrap(ptr) {
@@ -132,21 +18,6 @@ export class ExifRemovalResult {
132
18
  const ptr = this.__destroy_into_raw();
133
19
  wasm.__wbg_exifremovalresult_free(ptr, 0);
134
20
  }
135
- /**
136
- * @returns {string}
137
- */
138
- status() {
139
- let deferred1_0;
140
- let deferred1_1;
141
- try {
142
- const ret = wasm.exifremovalresult_status(this.__wbg_ptr);
143
- deferred1_0 = ret[0];
144
- deferred1_1 = ret[1];
145
- return getStringFromWasm0(ret[0], ret[1]);
146
- } finally {
147
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
148
- }
149
- }
150
21
  /**
151
22
  * @returns {Uint8Array | undefined}
152
23
  */
@@ -159,13 +30,6 @@ export class ExifRemovalResult {
159
30
  }
160
31
  return v1;
161
32
  }
162
- /**
163
- * @returns {boolean}
164
- */
165
- is_error() {
166
- const ret = wasm.exifremovalresult_is_error(this.__wbg_ptr);
167
- return ret !== 0;
168
- }
169
33
  /**
170
34
  * @returns {string | undefined}
171
35
  */
@@ -178,6 +42,28 @@ export class ExifRemovalResult {
178
42
  }
179
43
  return v1;
180
44
  }
45
+ /**
46
+ * @returns {boolean}
47
+ */
48
+ is_error() {
49
+ const ret = wasm.exifremovalresult_is_error(this.__wbg_ptr);
50
+ return ret !== 0;
51
+ }
52
+ /**
53
+ * @returns {string}
54
+ */
55
+ status() {
56
+ let deferred1_0;
57
+ let deferred1_1;
58
+ try {
59
+ const ret = wasm.exifremovalresult_status(this.__wbg_ptr);
60
+ deferred1_0 = ret[0];
61
+ deferred1_1 = ret[1];
62
+ return getStringFromWasm0(ret[0], ret[1]);
63
+ } finally {
64
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
65
+ }
66
+ }
181
67
  }
182
68
  if (Symbol.dispose) ExifRemovalResult.prototype[Symbol.dispose] = ExifRemovalResult.prototype.free;
183
69
 
@@ -271,7 +157,156 @@ export function version() {
271
157
  }
272
158
  }
273
159
 
274
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
160
+ function __wbg_get_imports() {
161
+ const import0 = {
162
+ __proto__: null,
163
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
164
+ throw new Error(getStringFromWasm0(arg0, arg1));
165
+ },
166
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
167
+ // Cast intrinsic for `Ref(String) -> Externref`.
168
+ const ret = getStringFromWasm0(arg0, arg1);
169
+ return ret;
170
+ },
171
+ __wbindgen_init_externref_table: function() {
172
+ const table = wasm.__wbindgen_externrefs;
173
+ const offset = table.grow(4);
174
+ table.set(0, undefined);
175
+ table.set(offset + 0, undefined);
176
+ table.set(offset + 1, null);
177
+ table.set(offset + 2, true);
178
+ table.set(offset + 3, false);
179
+ },
180
+ };
181
+ return {
182
+ __proto__: null,
183
+ "./merfix_bg.js": import0,
184
+ };
185
+ }
186
+
187
+ const ExifRemovalResultFinalization = (typeof FinalizationRegistry === 'undefined')
188
+ ? { register: () => {}, unregister: () => {} }
189
+ : new FinalizationRegistry(ptr => wasm.__wbg_exifremovalresult_free(ptr >>> 0, 1));
190
+
191
+ function getArrayJsValueFromWasm0(ptr, len) {
192
+ ptr = ptr >>> 0;
193
+ const mem = getDataViewMemory0();
194
+ const result = [];
195
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
196
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
197
+ }
198
+ wasm.__externref_drop_slice(ptr, len);
199
+ return result;
200
+ }
201
+
202
+ function getArrayU8FromWasm0(ptr, len) {
203
+ ptr = ptr >>> 0;
204
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
205
+ }
206
+
207
+ let cachedDataViewMemory0 = null;
208
+ function getDataViewMemory0() {
209
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
210
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
211
+ }
212
+ return cachedDataViewMemory0;
213
+ }
214
+
215
+ function getStringFromWasm0(ptr, len) {
216
+ ptr = ptr >>> 0;
217
+ return decodeText(ptr, len);
218
+ }
219
+
220
+ let cachedUint8ArrayMemory0 = null;
221
+ function getUint8ArrayMemory0() {
222
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
223
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
224
+ }
225
+ return cachedUint8ArrayMemory0;
226
+ }
227
+
228
+ function passArray8ToWasm0(arg, malloc) {
229
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
230
+ getUint8ArrayMemory0().set(arg, ptr / 1);
231
+ WASM_VECTOR_LEN = arg.length;
232
+ return ptr;
233
+ }
234
+
235
+ function passStringToWasm0(arg, malloc, realloc) {
236
+ if (realloc === undefined) {
237
+ const buf = cachedTextEncoder.encode(arg);
238
+ const ptr = malloc(buf.length, 1) >>> 0;
239
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
240
+ WASM_VECTOR_LEN = buf.length;
241
+ return ptr;
242
+ }
243
+
244
+ let len = arg.length;
245
+ let ptr = malloc(len, 1) >>> 0;
246
+
247
+ const mem = getUint8ArrayMemory0();
248
+
249
+ let offset = 0;
250
+
251
+ for (; offset < len; offset++) {
252
+ const code = arg.charCodeAt(offset);
253
+ if (code > 0x7F) break;
254
+ mem[ptr + offset] = code;
255
+ }
256
+ if (offset !== len) {
257
+ if (offset !== 0) {
258
+ arg = arg.slice(offset);
259
+ }
260
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
261
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
262
+ const ret = cachedTextEncoder.encodeInto(arg, view);
263
+
264
+ offset += ret.written;
265
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
266
+ }
267
+
268
+ WASM_VECTOR_LEN = offset;
269
+ return ptr;
270
+ }
271
+
272
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
273
+ cachedTextDecoder.decode();
274
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
275
+ let numBytesDecoded = 0;
276
+ function decodeText(ptr, len) {
277
+ numBytesDecoded += len;
278
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
279
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
280
+ cachedTextDecoder.decode();
281
+ numBytesDecoded = len;
282
+ }
283
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
284
+ }
285
+
286
+ const cachedTextEncoder = new TextEncoder();
287
+
288
+ if (!('encodeInto' in cachedTextEncoder)) {
289
+ cachedTextEncoder.encodeInto = function (arg, view) {
290
+ const buf = cachedTextEncoder.encode(arg);
291
+ view.set(buf);
292
+ return {
293
+ read: arg.length,
294
+ written: buf.length
295
+ };
296
+ };
297
+ }
298
+
299
+ let WASM_VECTOR_LEN = 0;
300
+
301
+ let wasmModule, wasm;
302
+ function __wbg_finalize_init(instance, module) {
303
+ wasm = instance.exports;
304
+ wasmModule = module;
305
+ cachedDataViewMemory0 = null;
306
+ cachedUint8ArrayMemory0 = null;
307
+ wasm.__wbindgen_start();
308
+ return wasm;
309
+ }
275
310
 
276
311
  async function __wbg_load(module, imports) {
277
312
  if (typeof Response === 'function' && module instanceof Response) {
@@ -279,14 +314,12 @@ async function __wbg_load(module, imports) {
279
314
  try {
280
315
  return await WebAssembly.instantiateStreaming(module, imports);
281
316
  } catch (e) {
282
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
317
+ const validResponse = module.ok && expectedResponseType(module.type);
283
318
 
284
319
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
285
320
  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
321
 
287
- } else {
288
- throw e;
289
- }
322
+ } else { throw e; }
290
323
  }
291
324
  }
292
325
 
@@ -301,48 +334,20 @@ async function __wbg_load(module, imports) {
301
334
  return instance;
302
335
  }
303
336
  }
304
- }
305
-
306
- function __wbg_get_imports() {
307
- const imports = {};
308
- imports.wbg = {};
309
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
310
- throw new Error(getStringFromWasm0(arg0, arg1));
311
- };
312
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
313
- // Cast intrinsic for `Ref(String) -> Externref`.
314
- const ret = getStringFromWasm0(arg0, arg1);
315
- return ret;
316
- };
317
- imports.wbg.__wbindgen_init_externref_table = function() {
318
- const table = wasm.__wbindgen_externrefs;
319
- const offset = table.grow(4);
320
- table.set(0, undefined);
321
- table.set(offset + 0, undefined);
322
- table.set(offset + 1, null);
323
- table.set(offset + 2, true);
324
- table.set(offset + 3, false);
325
- };
326
-
327
- return imports;
328
- }
329
-
330
- function __wbg_finalize_init(instance, module) {
331
- wasm = instance.exports;
332
- __wbg_init.__wbindgen_wasm_module = module;
333
- cachedDataViewMemory0 = null;
334
- cachedUint8ArrayMemory0 = null;
335
-
336
337
 
337
- wasm.__wbindgen_start();
338
- return wasm;
338
+ function expectedResponseType(type) {
339
+ switch (type) {
340
+ case 'basic': case 'cors': case 'default': return true;
341
+ }
342
+ return false;
343
+ }
339
344
  }
340
345
 
341
346
  function initSync(module) {
342
347
  if (wasm !== undefined) return wasm;
343
348
 
344
349
 
345
- if (typeof module !== 'undefined') {
350
+ if (module !== undefined) {
346
351
  if (Object.getPrototypeOf(module) === Object.prototype) {
347
352
  ({module} = module)
348
353
  } else {
@@ -362,7 +367,7 @@ async function __wbg_init(module_or_path) {
362
367
  if (wasm !== undefined) return wasm;
363
368
 
364
369
 
365
- if (typeof module_or_path !== 'undefined') {
370
+ if (module_or_path !== undefined) {
366
371
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
367
372
  ({module_or_path} = module_or_path)
368
373
  } else {
@@ -370,7 +375,7 @@ async function __wbg_init(module_or_path) {
370
375
  }
371
376
  }
372
377
 
373
- if (typeof module_or_path === 'undefined') {
378
+ if (module_or_path === undefined) {
374
379
  module_or_path = new URL('merfix_bg.wasm', import.meta.url);
375
380
  }
376
381
  const imports = __wbg_get_imports();
@@ -384,5 +389,4 @@ async function __wbg_init(module_or_path) {
384
389
  return __wbg_finalize_init(instance, module);
385
390
  }
386
391
 
387
- export { initSync };
388
- export default __wbg_init;
392
+ export { initSync, __wbg_init as default };
package/merfix_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "merfix",
3
3
  "type": "module",
4
4
  "description": "Utility to remove EXIF metadata from images from browser",
5
- "version": "0.1.71",
5
+ "version": "0.1.72",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",