merfix 0.1.69 → 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 supported_mime_types(): any[];
4
- export function version(): string;
5
- export function remove_exif(input: Uint8Array, extension: string): ExifRemovalResult;
6
- export function detect_image_mime_type(data: Uint8Array): string | undefined;
7
- export function supported_extensions(): any[];
8
- export function detect_image_extension(data: Uint8Array): string | undefined;
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 {
@@ -37,13 +45,14 @@ export interface InitOutput {
37
45
  readonly version: () => [number, number];
38
46
  readonly __wbindgen_externrefs: WebAssembly.Table;
39
47
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
40
- readonly __externref_drop_slice: (a: number, b: number) => void;
41
48
  readonly __wbindgen_malloc: (a: number, b: number) => number;
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) {
@@ -36,7 +17,6 @@ function getArrayU8FromWasm0(ptr, len) {
36
17
  }
37
18
 
38
19
  let cachedDataViewMemory0 = null;
39
-
40
20
  function getDataViewMemory0() {
41
21
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
42
22
  cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
@@ -44,44 +24,19 @@ function getDataViewMemory0() {
44
24
  return cachedDataViewMemory0;
45
25
  }
46
26
 
47
- function getArrayJsValueFromWasm0(ptr, len) {
27
+ function getStringFromWasm0(ptr, len) {
48
28
  ptr = ptr >>> 0;
49
- const mem = getDataViewMemory0();
50
- const result = [];
51
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
52
- result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
53
- }
54
- wasm.__externref_drop_slice(ptr, len);
55
- return result;
56
- }
57
- /**
58
- * @returns {any[]}
59
- */
60
- export function supported_mime_types() {
61
- const ret = wasm.supported_mime_types();
62
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
63
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
64
- return v1;
29
+ return decodeText(ptr, len);
65
30
  }
66
31
 
67
- /**
68
- * @returns {string}
69
- */
70
- export function version() {
71
- let deferred1_0;
72
- let deferred1_1;
73
- try {
74
- const ret = wasm.version();
75
- deferred1_0 = ret[0];
76
- deferred1_1 = ret[1];
77
- return getStringFromWasm0(ret[0], ret[1]);
78
- } finally {
79
- 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);
80
36
  }
37
+ return cachedUint8ArrayMemory0;
81
38
  }
82
39
 
83
- let WASM_VECTOR_LEN = 0;
84
-
85
40
  function passArray8ToWasm0(arg, malloc) {
86
41
  const ptr = malloc(arg.length * 1, 1) >>> 0;
87
42
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -89,21 +44,7 @@ function passArray8ToWasm0(arg, malloc) {
89
44
  return ptr;
90
45
  }
91
46
 
92
- const cachedTextEncoder = new TextEncoder();
93
-
94
- if (!('encodeInto' in cachedTextEncoder)) {
95
- cachedTextEncoder.encodeInto = function (arg, view) {
96
- const buf = cachedTextEncoder.encode(arg);
97
- view.set(buf);
98
- return {
99
- read: arg.length,
100
- written: buf.length
101
- };
102
- }
103
- }
104
-
105
47
  function passStringToWasm0(arg, malloc, realloc) {
106
-
107
48
  if (realloc === undefined) {
108
49
  const buf = cachedTextEncoder.encode(arg);
109
50
  const ptr = malloc(buf.length, 1) >>> 0;
@@ -124,7 +65,6 @@ function passStringToWasm0(arg, malloc, realloc) {
124
65
  if (code > 0x7F) break;
125
66
  mem[ptr + offset] = code;
126
67
  }
127
-
128
68
  if (offset !== len) {
129
69
  if (offset !== 0) {
130
70
  arg = arg.slice(offset);
@@ -140,76 +80,41 @@ function passStringToWasm0(arg, malloc, realloc) {
140
80
  WASM_VECTOR_LEN = offset;
141
81
  return ptr;
142
82
  }
143
- /**
144
- * @param {Uint8Array} input
145
- * @param {string} extension
146
- * @returns {ExifRemovalResult}
147
- */
148
- export function remove_exif(input, extension) {
149
- const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
150
- const len0 = WASM_VECTOR_LEN;
151
- const ptr1 = passStringToWasm0(extension, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
152
- const len1 = WASM_VECTOR_LEN;
153
- const ret = wasm.remove_exif(ptr0, len0, ptr1, len1);
154
- return ExifRemovalResult.__wrap(ret);
155
- }
156
83
 
157
- /**
158
- * @param {Uint8Array} data
159
- * @returns {string | undefined}
160
- */
161
- export function detect_image_mime_type(data) {
162
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
163
- const len0 = WASM_VECTOR_LEN;
164
- const ret = wasm.detect_image_mime_type(ptr0, len0);
165
- let v2;
166
- if (ret[0] !== 0) {
167
- v2 = getStringFromWasm0(ret[0], ret[1]).slice();
168
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
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;
169
94
  }
170
- return v2;
95
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
171
96
  }
172
97
 
173
- /**
174
- * @returns {any[]}
175
- */
176
- export function supported_extensions() {
177
- const ret = wasm.supported_extensions();
178
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
179
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
180
- return v1;
181
- }
98
+ const cachedTextEncoder = new TextEncoder();
182
99
 
183
- /**
184
- * @param {Uint8Array} data
185
- * @returns {string | undefined}
186
- */
187
- export function detect_image_extension(data) {
188
- const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
189
- const len0 = WASM_VECTOR_LEN;
190
- const ret = wasm.detect_image_extension(ptr0, len0);
191
- let v2;
192
- if (ret[0] !== 0) {
193
- v2 = getStringFromWasm0(ret[0], ret[1]).slice();
194
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
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
+ };
195
108
  }
196
- return v2;
197
109
  }
198
110
 
199
- /**
200
- * @enum {0 | 1}
201
- */
202
- export const ExifRemovalStatus = Object.freeze({
203
- Success: 0, "0": "Success",
204
- Error: 1, "1": "Error",
205
- });
111
+ let WASM_VECTOR_LEN = 0;
206
112
 
207
113
  const ExifRemovalResultFinalization = (typeof FinalizationRegistry === 'undefined')
208
114
  ? { register: () => {}, unregister: () => {} }
209
115
  : new FinalizationRegistry(ptr => wasm.__wbg_exifremovalresult_free(ptr >>> 0, 1));
210
116
 
211
117
  export class ExifRemovalResult {
212
-
213
118
  static __wrap(ptr) {
214
119
  ptr = ptr >>> 0;
215
120
  const obj = Object.create(ExifRemovalResult.prototype);
@@ -217,14 +122,12 @@ export class ExifRemovalResult {
217
122
  ExifRemovalResultFinalization.register(obj, obj.__wbg_ptr, obj);
218
123
  return obj;
219
124
  }
220
-
221
125
  __destroy_into_raw() {
222
126
  const ptr = this.__wbg_ptr;
223
127
  this.__wbg_ptr = 0;
224
128
  ExifRemovalResultFinalization.unregister(this);
225
129
  return ptr;
226
130
  }
227
-
228
131
  free() {
229
132
  const ptr = this.__destroy_into_raw();
230
133
  wasm.__wbg_exifremovalresult_free(ptr, 0);
@@ -278,6 +181,96 @@ export class ExifRemovalResult {
278
181
  }
279
182
  if (Symbol.dispose) ExifRemovalResult.prototype[Symbol.dispose] = ExifRemovalResult.prototype.free;
280
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
+
281
274
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
282
275
 
283
276
  async function __wbg_load(module, imports) {
@@ -285,7 +278,6 @@ async function __wbg_load(module, imports) {
285
278
  if (typeof WebAssembly.instantiateStreaming === 'function') {
286
279
  try {
287
280
  return await WebAssembly.instantiateStreaming(module, imports);
288
-
289
281
  } catch (e) {
290
282
  const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
291
283
 
@@ -300,13 +292,11 @@ async function __wbg_load(module, imports) {
300
292
 
301
293
  const bytes = await module.arrayBuffer();
302
294
  return await WebAssembly.instantiate(bytes, imports);
303
-
304
295
  } else {
305
296
  const instance = await WebAssembly.instantiate(module, imports);
306
297
 
307
298
  if (instance instanceof WebAssembly.Instance) {
308
299
  return { instance, module };
309
-
310
300
  } else {
311
301
  return instance;
312
302
  }
@@ -316,7 +306,7 @@ async function __wbg_load(module, imports) {
316
306
  function __wbg_get_imports() {
317
307
  const imports = {};
318
308
  imports.wbg = {};
319
- imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
309
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
320
310
  throw new Error(getStringFromWasm0(arg0, arg1));
321
311
  };
322
312
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
@@ -332,7 +322,6 @@ function __wbg_get_imports() {
332
322
  table.set(offset + 1, null);
333
323
  table.set(offset + 2, true);
334
324
  table.set(offset + 3, false);
335
- ;
336
325
  };
337
326
 
338
327
  return imports;
@@ -362,13 +351,10 @@ function initSync(module) {
362
351
  }
363
352
 
364
353
  const imports = __wbg_get_imports();
365
-
366
354
  if (!(module instanceof WebAssembly.Module)) {
367
355
  module = new WebAssembly.Module(module);
368
356
  }
369
-
370
357
  const instance = new WebAssembly.Instance(module, imports);
371
-
372
358
  return __wbg_finalize_init(instance, module);
373
359
  }
374
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.69",
5
+ "version": "0.1.71",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",