@wasm-fmt/json_fmt 0.1.10 → 0.1.11

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/json_fmt.d.ts CHANGED
@@ -27,18 +27,18 @@ export type SyncInitInput = BufferSource | WebAssembly.Module;
27
27
  * Instantiates the given `module`, which can either be bytes or
28
28
  * a precompiled `WebAssembly.Module`.
29
29
  *
30
- * @param {SyncInitInput} module
30
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
31
31
  *
32
32
  * @returns {InitOutput}
33
33
  */
34
- export function initSync(module: SyncInitInput): InitOutput;
34
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
35
35
 
36
36
  /**
37
37
  * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
38
38
  * for everything else, calls `WebAssembly.instantiate` directly.
39
39
  *
40
- * @param {InitInput | Promise<InitInput>} module_or_path
40
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
41
41
  *
42
42
  * @returns {Promise<InitOutput>}
43
43
  */
44
- export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
44
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/json_fmt.js CHANGED
@@ -22,13 +22,13 @@ function takeObject(idx) {
22
22
 
23
23
  let WASM_VECTOR_LEN = 0;
24
24
 
25
- let cachedUint8Memory0 = null;
25
+ let cachedUint8ArrayMemory0 = null;
26
26
 
27
- function getUint8Memory0() {
28
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
29
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
27
+ function getUint8ArrayMemory0() {
28
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
29
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
30
30
  }
31
- return cachedUint8Memory0;
31
+ return cachedUint8ArrayMemory0;
32
32
  }
33
33
 
34
34
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
@@ -51,7 +51,7 @@ function passStringToWasm0(arg, malloc, realloc) {
51
51
  if (realloc === undefined) {
52
52
  const buf = cachedTextEncoder.encode(arg);
53
53
  const ptr = malloc(buf.length, 1) >>> 0;
54
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
54
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
55
55
  WASM_VECTOR_LEN = buf.length;
56
56
  return ptr;
57
57
  }
@@ -59,7 +59,7 @@ function passStringToWasm0(arg, malloc, realloc) {
59
59
  let len = arg.length;
60
60
  let ptr = malloc(len, 1) >>> 0;
61
61
 
62
- const mem = getUint8Memory0();
62
+ const mem = getUint8ArrayMemory0();
63
63
 
64
64
  let offset = 0;
65
65
 
@@ -74,7 +74,7 @@ function passStringToWasm0(arg, malloc, realloc) {
74
74
  arg = arg.slice(offset);
75
75
  }
76
76
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
77
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
77
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
78
78
  const ret = encodeString(arg, view);
79
79
 
80
80
  offset += ret.written;
@@ -89,13 +89,13 @@ function isLikeNone(x) {
89
89
  return x === undefined || x === null;
90
90
  }
91
91
 
92
- let cachedInt32Memory0 = null;
92
+ let cachedDataViewMemory0 = null;
93
93
 
94
- function getInt32Memory0() {
95
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
96
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
94
+ function getDataViewMemory0() {
95
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
96
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
97
97
  }
98
- return cachedInt32Memory0;
98
+ return cachedDataViewMemory0;
99
99
  }
100
100
 
101
101
  function addHeapObject(obj) {
@@ -113,16 +113,7 @@ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
113
113
 
114
114
  function getStringFromWasm0(ptr, len) {
115
115
  ptr = ptr >>> 0;
116
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
117
- }
118
-
119
- let cachedFloat64Memory0 = null;
120
-
121
- function getFloat64Memory0() {
122
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
123
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
124
- }
125
- return cachedFloat64Memory0;
116
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
126
117
  }
127
118
 
128
119
  function debugString(val) {
@@ -190,10 +181,10 @@ function debugString(val) {
190
181
  return className;
191
182
  }
192
183
  /**
193
- * @param {string} src
194
- * @param {Config | undefined} [config]
195
- * @returns {string}
196
- */
184
+ * @param {string} src
185
+ * @param {Config | undefined} [config]
186
+ * @returns {string}
187
+ */
197
188
  export function format(src, config) {
198
189
  let deferred3_0;
199
190
  let deferred3_1;
@@ -202,10 +193,10 @@ export function format(src, config) {
202
193
  const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
203
194
  const len0 = WASM_VECTOR_LEN;
204
195
  wasm.format(retptr, ptr0, len0, isLikeNone(config) ? 0 : addHeapObject(config));
205
- var r0 = getInt32Memory0()[retptr / 4 + 0];
206
- var r1 = getInt32Memory0()[retptr / 4 + 1];
207
- var r2 = getInt32Memory0()[retptr / 4 + 2];
208
- var r3 = getInt32Memory0()[retptr / 4 + 3];
196
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
197
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
198
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
199
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
209
200
  var ptr2 = r0;
210
201
  var len2 = r1;
211
202
  if (r3) {
@@ -229,7 +220,7 @@ async function __wbg_load(module, imports) {
229
220
 
230
221
  } catch (e) {
231
222
  if (module.headers.get('Content-Type') != 'application/wasm') {
232
- 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);
223
+ 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);
233
224
 
234
225
  } else {
235
226
  throw e;
@@ -275,8 +266,8 @@ function __wbg_get_imports() {
275
266
  const ret = typeof(obj) === 'string' ? obj : undefined;
276
267
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
277
268
  var len1 = WASM_VECTOR_LEN;
278
- getInt32Memory0()[arg0 / 4 + 1] = len1;
279
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
269
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
270
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
280
271
  };
281
272
  imports.wbg.__wbindgen_is_object = function(arg0) {
282
273
  const val = getObject(arg0);
@@ -303,8 +294,8 @@ function __wbg_get_imports() {
303
294
  imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
304
295
  const obj = getObject(arg1);
305
296
  const ret = typeof(obj) === 'number' ? obj : undefined;
306
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
307
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
297
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
298
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
308
299
  };
309
300
  imports.wbg.__wbindgen_as_number = function(arg0) {
310
301
  const ret = +getObject(arg0);
@@ -314,8 +305,8 @@ function __wbg_get_imports() {
314
305
  const ret = String(getObject(arg1));
315
306
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
316
307
  const len1 = WASM_VECTOR_LEN;
317
- getInt32Memory0()[arg0 / 4 + 1] = len1;
318
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
308
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
309
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
319
310
  };
320
311
  imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
321
312
  const ret = new Error(getStringFromWasm0(arg0, arg1));
@@ -325,15 +316,15 @@ function __wbg_get_imports() {
325
316
  const ret = getObject(arg0)[getObject(arg1)];
326
317
  return addHeapObject(ret);
327
318
  };
328
- imports.wbg.__wbg_get_bd8e338fbd5f5cc8 = function(arg0, arg1) {
319
+ imports.wbg.__wbg_get_5419cf6b954aa11d = function(arg0, arg1) {
329
320
  const ret = getObject(arg0)[arg1 >>> 0];
330
321
  return addHeapObject(ret);
331
322
  };
332
- imports.wbg.__wbg_length_cd7af8117672b8b8 = function(arg0) {
323
+ imports.wbg.__wbg_length_f217bbbf7e8e4df4 = function(arg0) {
333
324
  const ret = getObject(arg0).length;
334
325
  return ret;
335
326
  };
336
- imports.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2 = function(arg0) {
327
+ imports.wbg.__wbg_instanceof_ArrayBuffer_74945570b4a62ec7 = function(arg0) {
337
328
  let result;
338
329
  try {
339
330
  result = getObject(arg0) instanceof ArrayBuffer;
@@ -343,30 +334,30 @@ function __wbg_get_imports() {
343
334
  const ret = result;
344
335
  return ret;
345
336
  };
346
- imports.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2 = function(arg0) {
337
+ imports.wbg.__wbg_isSafeInteger_b9dff570f01a9100 = function(arg0) {
347
338
  const ret = Number.isSafeInteger(getObject(arg0));
348
339
  return ret;
349
340
  };
350
- imports.wbg.__wbg_entries_95cc2c823b285a09 = function(arg0) {
341
+ imports.wbg.__wbg_entries_c02034de337d3ee2 = function(arg0) {
351
342
  const ret = Object.entries(getObject(arg0));
352
343
  return addHeapObject(ret);
353
344
  };
354
- imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
345
+ imports.wbg.__wbg_buffer_ccaed51a635d8a2d = function(arg0) {
355
346
  const ret = getObject(arg0).buffer;
356
347
  return addHeapObject(ret);
357
348
  };
358
- imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
349
+ imports.wbg.__wbg_new_fec2611eb9180f95 = function(arg0) {
359
350
  const ret = new Uint8Array(getObject(arg0));
360
351
  return addHeapObject(ret);
361
352
  };
362
- imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
353
+ imports.wbg.__wbg_set_ec2fcf81bc573fd9 = function(arg0, arg1, arg2) {
363
354
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
364
355
  };
365
- imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
356
+ imports.wbg.__wbg_length_9254c4bd3b9f23c4 = function(arg0) {
366
357
  const ret = getObject(arg0).length;
367
358
  return ret;
368
359
  };
369
- imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) {
360
+ imports.wbg.__wbg_instanceof_Uint8Array_df0761410414ef36 = function(arg0) {
370
361
  let result;
371
362
  try {
372
363
  result = getObject(arg0) instanceof Uint8Array;
@@ -380,8 +371,8 @@ function __wbg_get_imports() {
380
371
  const ret = debugString(getObject(arg1));
381
372
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
382
373
  const len1 = WASM_VECTOR_LEN;
383
- getInt32Memory0()[arg0 / 4 + 1] = len1;
384
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
374
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
375
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
385
376
  };
386
377
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
387
378
  throw new Error(getStringFromWasm0(arg0, arg1));
@@ -394,16 +385,16 @@ function __wbg_get_imports() {
394
385
  return imports;
395
386
  }
396
387
 
397
- function __wbg_init_memory(imports, maybe_memory) {
388
+ function __wbg_init_memory(imports, memory) {
398
389
 
399
390
  }
400
391
 
401
392
  function __wbg_finalize_init(instance, module) {
402
393
  wasm = instance.exports;
403
394
  __wbg_init.__wbindgen_wasm_module = module;
404
- cachedFloat64Memory0 = null;
405
- cachedInt32Memory0 = null;
406
- cachedUint8Memory0 = null;
395
+ cachedDataViewMemory0 = null;
396
+ cachedUint8ArrayMemory0 = null;
397
+
407
398
 
408
399
 
409
400
  return wasm;
@@ -412,6 +403,15 @@ function __wbg_finalize_init(instance, module) {
412
403
  function initSync(module) {
413
404
  if (wasm !== undefined) return wasm;
414
405
 
406
+
407
+ if (typeof module !== 'undefined') {
408
+ if (Object.getPrototypeOf(module) === Object.prototype) {
409
+ ({module} = module)
410
+ } else {
411
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
412
+ }
413
+ }
414
+
415
415
  const imports = __wbg_get_imports();
416
416
 
417
417
  __wbg_init_memory(imports);
@@ -425,24 +425,33 @@ function initSync(module) {
425
425
  return __wbg_finalize_init(instance, module);
426
426
  }
427
427
 
428
- async function __wbg_init(input) {
428
+ async function __wbg_init(module_or_path) {
429
429
  if (wasm !== undefined) return wasm;
430
430
 
431
- if (typeof input === 'undefined') {
432
- input = new URL('json_fmt_bg.wasm', import.meta.url);
431
+
432
+ if (typeof module_or_path !== 'undefined') {
433
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
434
+ ({module_or_path} = module_or_path)
435
+ } else {
436
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
437
+ }
438
+ }
439
+
440
+ if (typeof module_or_path === 'undefined') {
441
+ module_or_path = new URL('json_fmt_bg.wasm', import.meta.url);
433
442
  }
434
443
  const imports = __wbg_get_imports();
435
444
 
436
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
437
- input = fetch(input);
445
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
446
+ module_or_path = fetch(module_or_path);
438
447
  }
439
448
 
440
449
  __wbg_init_memory(imports);
441
450
 
442
- const { instance, module } = await __wbg_load(await input, imports);
451
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
443
452
 
444
453
  return __wbg_finalize_init(instance, module);
445
454
  }
446
455
 
447
- export { initSync }
456
+ export { initSync };
448
457
  export default __wbg_init;
package/json_fmt_bg.wasm CHANGED
Binary file
package/jsr.jsonc ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@fmt/json-fmt",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "magic-akari <akari.ccino@gmail.com>"
6
+ ],
7
+ "description": "JSON formatter powered by WASM ported from Biome",
8
+ "version": "0.1.11",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/wasm-fmt/web_fmt"
13
+ },
14
+ "homepage": "https://github.com/wasm-fmt/web_fmt",
15
+ "types": "json_fmt.d.ts",
16
+ "sideEffects": [
17
+ "./snippets/*"
18
+ ],
19
+ "keywords": [
20
+ "wasm",
21
+ "formatter",
22
+ "json",
23
+ "biome"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "exports": "./json_fmt.js",
29
+ "exclude": [
30
+ "!**",
31
+ "*.tgz"
32
+ ]
33
+ }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@wasm-fmt/json_fmt",
3
+ "type": "module",
3
4
  "collaborators": [
4
5
  "magic-akari <akari.ccino@gmail.com>"
5
6
  ],
6
7
  "description": "JSON formatter powered by WASM ported from Biome",
7
- "version": "0.1.10",
8
+ "version": "0.1.11",
8
9
  "license": "MIT",
9
10
  "repository": {
10
11
  "type": "git",
11
12
  "url": "https://github.com/wasm-fmt/web_fmt"
12
13
  },
13
- "module": "json_fmt.js",
14
14
  "homepage": "https://github.com/wasm-fmt/web_fmt",
15
15
  "types": "json_fmt.d.ts",
16
16
  "sideEffects": [
@@ -22,8 +22,6 @@
22
22
  "json",
23
23
  "biome"
24
24
  ],
25
- "main": "json_fmt.js",
26
- "type": "module",
27
25
  "publishConfig": {
28
26
  "access": "public"
29
27
  },
Binary file