merfix 0.1.70 → 0.1.71

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
@@ -1,15 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function detect_image_extension(data: Uint8Array): string | undefined;
4
- export function supported_extensions(): any[];
5
- export function detect_image_mime_type(data: Uint8Array): string | undefined;
6
- export function supported_mime_types(): any[];
7
- export function version(): string;
8
- export function remove_exif(input: Uint8Array, extension: string): ExifRemovalResult;
9
- export enum ExifRemovalStatus {
10
- Success = 0,
11
- Error = 1,
12
- }
3
+
13
4
  export class ExifRemovalResult {
14
5
  private constructor();
15
6
  free(): void;
@@ -20,6 +11,23 @@ export class ExifRemovalResult {
20
11
  get_error(): string | undefined;
21
12
  }
22
13
 
14
+ export enum ExifRemovalStatus {
15
+ Success = 0,
16
+ Error = 1,
17
+ }
18
+
19
+ export function detect_image_extension(data: Uint8Array): string | undefined;
20
+
21
+ export function detect_image_mime_type(data: Uint8Array): string | undefined;
22
+
23
+ export function remove_exif(input: Uint8Array, extension: string): ExifRemovalResult;
24
+
25
+ export function supported_extensions(): any[];
26
+
27
+ export function supported_mime_types(): any[];
28
+
29
+ export function version(): string;
30
+
23
31
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
24
32
 
25
33
  export interface InitOutput {
@@ -38,12 +46,13 @@ export interface InitOutput {
38
46
  readonly __wbindgen_externrefs: WebAssembly.Table;
39
47
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
40
48
  readonly __wbindgen_malloc: (a: number, b: number) => number;
41
- readonly __externref_drop_slice: (a: number, b: number) => void;
42
49
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
50
+ readonly __externref_drop_slice: (a: number, b: number) => void;
43
51
  readonly __wbindgen_start: () => void;
44
52
  }
45
53
 
46
54
  export type SyncInitInput = BufferSource | WebAssembly.Module;
55
+
47
56
  /**
48
57
  * Instantiates the given `module`, which can either be bytes or
49
58
  * a precompiled `WebAssembly.Module`.
package/merfix.js CHANGED
@@ -1,33 +1,14 @@
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 = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
-
14
- 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 = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
- cachedTextDecoder.decode();
23
- numBytesDecoded = len;
24
- }
25
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
- }
27
-
28
- function getStringFromWasm0(ptr, len) {
3
+ function getArrayJsValueFromWasm0(ptr, len) {
29
4
  ptr = ptr >>> 0;
30
- return decodeText(ptr, len);
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;
31
12
  }
32
13
 
33
14
  function getArrayU8FromWasm0(ptr, len) {
@@ -35,32 +16,7 @@ function getArrayU8FromWasm0(ptr, len) {
35
16
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
36
17
  }
37
18
 
38
- let WASM_VECTOR_LEN = 0;
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
- * @param {Uint8Array} data
48
- * @returns {string | undefined}
49
- */
50
- export function detect_image_extension(data) {
51
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
52
- const len0 = WASM_VECTOR_LEN;
53
- const ret = wasm.detect_image_extension(ptr0, len0);
54
- let v2;
55
- if (ret[0] !== 0) {
56
- v2 = getStringFromWasm0(ret[0], ret[1]).slice();
57
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
58
- }
59
- return v2;
60
- }
61
-
62
19
  let cachedDataViewMemory0 = null;
63
-
64
20
  function getDataViewMemory0() {
65
21
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
66
22
  cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
@@ -68,83 +24,27 @@ function getDataViewMemory0() {
68
24
  return cachedDataViewMemory0;
69
25
  }
70
26
 
71
- function getArrayJsValueFromWasm0(ptr, len) {
27
+ function getStringFromWasm0(ptr, len) {
72
28
  ptr = ptr >>> 0;
73
- const mem = getDataViewMemory0();
74
- const result = [];
75
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
76
- result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
77
- }
78
- wasm.__externref_drop_slice(ptr, len);
79
- return result;
80
- }
81
- /**
82
- * @returns {any[]}
83
- */
84
- export function supported_extensions() {
85
- const ret = wasm.supported_extensions();
86
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
87
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
88
- return v1;
89
- }
90
-
91
- /**
92
- * @param {Uint8Array} data
93
- * @returns {string | undefined}
94
- */
95
- export function detect_image_mime_type(data) {
96
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
97
- const len0 = WASM_VECTOR_LEN;
98
- const ret = wasm.detect_image_mime_type(ptr0, len0);
99
- let v2;
100
- if (ret[0] !== 0) {
101
- v2 = getStringFromWasm0(ret[0], ret[1]).slice();
102
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
103
- }
104
- return v2;
105
- }
106
-
107
- /**
108
- * @returns {any[]}
109
- */
110
- export function supported_mime_types() {
111
- const ret = wasm.supported_mime_types();
112
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
113
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
114
- return v1;
29
+ return decodeText(ptr, len);
115
30
  }
116
31
 
117
- /**
118
- * @returns {string}
119
- */
120
- export function version() {
121
- let deferred1_0;
122
- let deferred1_1;
123
- try {
124
- const ret = wasm.version();
125
- deferred1_0 = ret[0];
126
- deferred1_1 = ret[1];
127
- return getStringFromWasm0(ret[0], ret[1]);
128
- } finally {
129
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
32
+ let cachedUint8ArrayMemory0 = null;
33
+ function getUint8ArrayMemory0() {
34
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
35
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
130
36
  }
37
+ return cachedUint8ArrayMemory0;
131
38
  }
132
39
 
133
- const cachedTextEncoder = new TextEncoder();
134
-
135
- if (!('encodeInto' in cachedTextEncoder)) {
136
- cachedTextEncoder.encodeInto = function (arg, view) {
137
- const buf = cachedTextEncoder.encode(arg);
138
- view.set(buf);
139
- return {
140
- read: arg.length,
141
- written: buf.length
142
- };
143
- }
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;
144
45
  }
145
46
 
146
47
  function passStringToWasm0(arg, malloc, realloc) {
147
-
148
48
  if (realloc === undefined) {
149
49
  const buf = cachedTextEncoder.encode(arg);
150
50
  const ptr = malloc(buf.length, 1) >>> 0;
@@ -165,7 +65,6 @@ function passStringToWasm0(arg, malloc, realloc) {
165
65
  if (code > 0x7F) break;
166
66
  mem[ptr + offset] = code;
167
67
  }
168
-
169
68
  if (offset !== len) {
170
69
  if (offset !== 0) {
171
70
  arg = arg.slice(offset);
@@ -181,34 +80,41 @@ function passStringToWasm0(arg, malloc, realloc) {
181
80
  WASM_VECTOR_LEN = offset;
182
81
  return ptr;
183
82
  }
184
- /**
185
- * @param {Uint8Array} input
186
- * @param {string} extension
187
- * @returns {ExifRemovalResult}
188
- */
189
- export function remove_exif(input, extension) {
190
- const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
191
- const len0 = WASM_VECTOR_LEN;
192
- const ptr1 = passStringToWasm0(extension, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
193
- const len1 = WASM_VECTOR_LEN;
194
- const ret = wasm.remove_exif(ptr0, len0, ptr1, len1);
195
- return ExifRemovalResult.__wrap(ret);
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));
196
96
  }
197
97
 
198
- /**
199
- * @enum {0 | 1}
200
- */
201
- export const ExifRemovalStatus = Object.freeze({
202
- Success: 0, "0": "Success",
203
- Error: 1, "1": "Error",
204
- });
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;
205
112
 
206
113
  const ExifRemovalResultFinalization = (typeof FinalizationRegistry === 'undefined')
207
114
  ? { register: () => {}, unregister: () => {} }
208
115
  : new FinalizationRegistry(ptr => wasm.__wbg_exifremovalresult_free(ptr >>> 0, 1));
209
116
 
210
117
  export class ExifRemovalResult {
211
-
212
118
  static __wrap(ptr) {
213
119
  ptr = ptr >>> 0;
214
120
  const obj = Object.create(ExifRemovalResult.prototype);
@@ -216,14 +122,12 @@ export class ExifRemovalResult {
216
122
  ExifRemovalResultFinalization.register(obj, obj.__wbg_ptr, obj);
217
123
  return obj;
218
124
  }
219
-
220
125
  __destroy_into_raw() {
221
126
  const ptr = this.__wbg_ptr;
222
127
  this.__wbg_ptr = 0;
223
128
  ExifRemovalResultFinalization.unregister(this);
224
129
  return ptr;
225
130
  }
226
-
227
131
  free() {
228
132
  const ptr = this.__destroy_into_raw();
229
133
  wasm.__wbg_exifremovalresult_free(ptr, 0);
@@ -277,6 +181,96 @@ export class ExifRemovalResult {
277
181
  }
278
182
  if (Symbol.dispose) ExifRemovalResult.prototype[Symbol.dispose] = ExifRemovalResult.prototype.free;
279
183
 
184
+ /**
185
+ * @enum {0 | 1}
186
+ */
187
+ export const ExifRemovalStatus = Object.freeze({
188
+ Success: 0, "0": "Success",
189
+ Error: 1, "1": "Error",
190
+ });
191
+
192
+ /**
193
+ * @param {Uint8Array} data
194
+ * @returns {string | undefined}
195
+ */
196
+ export function detect_image_extension(data) {
197
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
198
+ const len0 = WASM_VECTOR_LEN;
199
+ const ret = wasm.detect_image_extension(ptr0, len0);
200
+ let v2;
201
+ if (ret[0] !== 0) {
202
+ v2 = getStringFromWasm0(ret[0], ret[1]).slice();
203
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
204
+ }
205
+ return v2;
206
+ }
207
+
208
+ /**
209
+ * @param {Uint8Array} data
210
+ * @returns {string | undefined}
211
+ */
212
+ export function detect_image_mime_type(data) {
213
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
214
+ const len0 = WASM_VECTOR_LEN;
215
+ const ret = wasm.detect_image_mime_type(ptr0, len0);
216
+ let v2;
217
+ if (ret[0] !== 0) {
218
+ v2 = getStringFromWasm0(ret[0], ret[1]).slice();
219
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
220
+ }
221
+ return v2;
222
+ }
223
+
224
+ /**
225
+ * @param {Uint8Array} input
226
+ * @param {string} extension
227
+ * @returns {ExifRemovalResult}
228
+ */
229
+ export function remove_exif(input, extension) {
230
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
231
+ const len0 = WASM_VECTOR_LEN;
232
+ const ptr1 = passStringToWasm0(extension, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
233
+ const len1 = WASM_VECTOR_LEN;
234
+ const ret = wasm.remove_exif(ptr0, len0, ptr1, len1);
235
+ return ExifRemovalResult.__wrap(ret);
236
+ }
237
+
238
+ /**
239
+ * @returns {any[]}
240
+ */
241
+ export function supported_extensions() {
242
+ const ret = wasm.supported_extensions();
243
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
244
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
245
+ return v1;
246
+ }
247
+
248
+ /**
249
+ * @returns {any[]}
250
+ */
251
+ export function supported_mime_types() {
252
+ const ret = wasm.supported_mime_types();
253
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
254
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
255
+ return v1;
256
+ }
257
+
258
+ /**
259
+ * @returns {string}
260
+ */
261
+ export function version() {
262
+ let deferred1_0;
263
+ let deferred1_1;
264
+ try {
265
+ const ret = wasm.version();
266
+ deferred1_0 = ret[0];
267
+ deferred1_1 = ret[1];
268
+ return getStringFromWasm0(ret[0], ret[1]);
269
+ } finally {
270
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
271
+ }
272
+ }
273
+
280
274
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
281
275
 
282
276
  async function __wbg_load(module, imports) {
@@ -284,7 +278,6 @@ async function __wbg_load(module, imports) {
284
278
  if (typeof WebAssembly.instantiateStreaming === 'function') {
285
279
  try {
286
280
  return await WebAssembly.instantiateStreaming(module, imports);
287
-
288
281
  } catch (e) {
289
282
  const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
290
283
 
@@ -299,13 +292,11 @@ async function __wbg_load(module, imports) {
299
292
 
300
293
  const bytes = await module.arrayBuffer();
301
294
  return await WebAssembly.instantiate(bytes, imports);
302
-
303
295
  } else {
304
296
  const instance = await WebAssembly.instantiate(module, imports);
305
297
 
306
298
  if (instance instanceof WebAssembly.Instance) {
307
299
  return { instance, module };
308
-
309
300
  } else {
310
301
  return instance;
311
302
  }
@@ -315,7 +306,7 @@ async function __wbg_load(module, imports) {
315
306
  function __wbg_get_imports() {
316
307
  const imports = {};
317
308
  imports.wbg = {};
318
- imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
309
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
319
310
  throw new Error(getStringFromWasm0(arg0, arg1));
320
311
  };
321
312
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
@@ -331,7 +322,6 @@ function __wbg_get_imports() {
331
322
  table.set(offset + 1, null);
332
323
  table.set(offset + 2, true);
333
324
  table.set(offset + 3, false);
334
- ;
335
325
  };
336
326
 
337
327
  return imports;
@@ -361,13 +351,10 @@ function initSync(module) {
361
351
  }
362
352
 
363
353
  const imports = __wbg_get_imports();
364
-
365
354
  if (!(module instanceof WebAssembly.Module)) {
366
355
  module = new WebAssembly.Module(module);
367
356
  }
368
-
369
357
  const instance = new WebAssembly.Instance(module, imports);
370
-
371
358
  return __wbg_finalize_init(instance, module);
372
359
  }
373
360
 
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.70",
5
+ "version": "0.1.71",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",