@wasm-fmt/web_fmt 0.1.9 → 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/jsr.jsonc ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@fmt/web-fmt",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "magic-akari <akari.ccino@gmail.com>"
6
+ ],
7
+ "description": "a formatter for web development powered by WASM",
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": "web_fmt.d.ts",
16
+ "sideEffects": [
17
+ "./snippets/*"
18
+ ],
19
+ "keywords": [
20
+ "wasm",
21
+ "formatter",
22
+ "html",
23
+ "css",
24
+ "javascript"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "exports": "./web_fmt.js",
30
+ "exclude": [
31
+ "!**",
32
+ "*.tgz"
33
+ ]
34
+ }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@wasm-fmt/web_fmt",
3
+ "type": "module",
3
4
  "collaborators": [
4
5
  "magic-akari <akari.ccino@gmail.com>"
5
6
  ],
6
7
  "description": "a formatter for web development powered by WASM",
7
- "version": "0.1.9",
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": "web_fmt.js",
14
14
  "homepage": "https://github.com/wasm-fmt/web_fmt",
15
15
  "types": "web_fmt.d.ts",
16
16
  "sideEffects": [
@@ -23,8 +23,6 @@
23
23
  "css",
24
24
  "javascript"
25
25
  ],
26
- "main": "web_fmt.js",
27
- "type": "module",
28
26
  "publishConfig": {
29
27
  "access": "public"
30
28
  },
Binary file
package/web_fmt.d.ts CHANGED
@@ -1,39 +1,41 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {string} src
5
- * @param {string} filename
6
- * @param {StyleConfig | undefined} [config]
7
- * @returns {string}
8
- */
4
+ * @param {string} src
5
+ * @param {JsonConfig | undefined} [config]
6
+ * @returns {string}
7
+ */
8
+ export function format_json(src: string, config?: JsonConfig): string;
9
+ /**
10
+ * @param {string} src
11
+ * @param {string} filename
12
+ * @param {StyleConfig | undefined} [config]
13
+ * @returns {string}
14
+ */
9
15
  export function format_style(src: string, filename: string, config?: StyleConfig): string;
10
16
  /**
11
- * @param {string} src
12
- * @param {string} filename
13
- * @param {MarkupConfig | undefined} [config]
14
- * @returns {string}
15
- */
16
- export function format_markup(src: string, filename: string, config?: MarkupConfig): string;
17
+ * @param {string} src
18
+ * @param {string} filename
19
+ * @param {Config | undefined} [config]
20
+ * @returns {string}
21
+ */
22
+ export function format(src: string, filename: string, config?: Config): string;
17
23
  /**
18
- * @param {string} src
19
- * @param {JsonConfig | undefined} [config]
20
- * @returns {string}
21
- */
22
- export function format_json(src: string, config?: JsonConfig): string;
24
+ * @param {string} src
25
+ * @param {string} filename
26
+ * @param {MarkupConfig | undefined} [config]
27
+ * @returns {string}
28
+ */
29
+ export function format_markup(src: string, filename: string, config?: MarkupConfig): string;
23
30
  /**
24
- * @param {string} src
25
- * @param {string} filename
26
- * @param {ScriptConfig | undefined} [config]
27
- * @returns {string}
28
- */
31
+ * @param {string} src
32
+ * @param {string} filename
33
+ * @param {ScriptConfig | undefined} [config]
34
+ * @returns {string}
35
+ */
29
36
  export function format_script(src: string, filename: string, config?: ScriptConfig): string;
30
- /**
31
- * @param {string} src
32
- * @param {string} filename
33
- * @param {Config | undefined} [config]
34
- * @returns {string}
35
- */
36
- export function format(src: string, filename: string, config?: Config): string;
37
+ export type JsonConfig = LayoutConfig;
38
+
37
39
 
38
40
  export interface StyleConfig extends LayoutConfig {
39
41
  /**
@@ -43,6 +45,14 @@ export interface StyleConfig extends LayoutConfig {
43
45
  }
44
46
 
45
47
 
48
+ export interface Config extends LayoutConfig {
49
+ markup?: MarkupConfig;
50
+ script?: ScriptConfig;
51
+ style?: StyleConfig;
52
+ json?: JsonConfig;
53
+ }
54
+
55
+
46
56
  export interface MarkupConfig extends LayoutConfig {
47
57
  /**
48
58
  * See {@link https://github.com/g-plane/markup_fmt/blob/main/docs/config.md}
@@ -50,8 +60,6 @@ export interface MarkupConfig extends LayoutConfig {
50
60
  [other: string]: any;
51
61
  }
52
62
 
53
- export type JsonConfig = LayoutConfig;
54
-
55
63
 
56
64
  export interface ScriptConfig extends LayoutConfig {
57
65
  quote_style?: "double" | "single";
@@ -65,14 +73,6 @@ export interface ScriptConfig extends LayoutConfig {
65
73
  }
66
74
 
67
75
 
68
- export interface Config extends LayoutConfig {
69
- markup?: MarkupConfig;
70
- script?: ScriptConfig;
71
- style?: StyleConfig;
72
- json?: JsonConfig;
73
- }
74
-
75
-
76
76
  interface LayoutConfig {
77
77
  indent_style?: "tab" | "space";
78
78
  indent_width?: number;
@@ -85,16 +85,16 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
85
85
 
86
86
  export interface InitOutput {
87
87
  readonly memory: WebAssembly.Memory;
88
+ readonly format_json: (a: number, b: number, c: number, d: number) => void;
88
89
  readonly format_style: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
90
+ readonly format: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
89
91
  readonly format_markup: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
90
- readonly format_json: (a: number, b: number, c: number, d: number) => void;
91
92
  readonly format_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
92
- readonly format: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
93
- readonly __wbindgen_malloc: (a: number, b: number) => number;
94
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
93
+ readonly __wbindgen_export_0: (a: number, b: number) => number;
94
+ readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
95
95
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
96
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
97
- readonly __wbindgen_exn_store: (a: number) => void;
96
+ readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
97
+ readonly __wbindgen_export_3: (a: number) => void;
98
98
  }
99
99
 
100
100
  export type SyncInitInput = BufferSource | WebAssembly.Module;
@@ -102,18 +102,18 @@ export type SyncInitInput = BufferSource | WebAssembly.Module;
102
102
  * Instantiates the given `module`, which can either be bytes or
103
103
  * a precompiled `WebAssembly.Module`.
104
104
  *
105
- * @param {SyncInitInput} module
105
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
106
106
  *
107
107
  * @returns {InitOutput}
108
108
  */
109
- export function initSync(module: SyncInitInput): InitOutput;
109
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
110
110
 
111
111
  /**
112
112
  * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
113
113
  * for everything else, calls `WebAssembly.instantiate` directly.
114
114
  *
115
- * @param {InitInput | Promise<InitInput>} module_or_path
115
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
116
116
  *
117
117
  * @returns {Promise<InitOutput>}
118
118
  */
119
- export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
119
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/web_fmt.js CHANGED
@@ -1,13 +1,40 @@
1
1
  let wasm;
2
2
 
3
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
4
+
5
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ function getStringFromWasm0(ptr, len) {
17
+ ptr = ptr >>> 0;
18
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
19
+ }
20
+
3
21
  const heap = new Array(128).fill(undefined);
4
22
 
5
23
  heap.push(undefined, null, true, false);
6
24
 
7
- function getObject(idx) { return heap[idx]; }
8
-
9
25
  let heap_next = heap.length;
10
26
 
27
+ function addHeapObject(obj) {
28
+ if (heap_next === heap.length) heap.push(heap.length + 1);
29
+ const idx = heap_next;
30
+ heap_next = heap[idx];
31
+
32
+ heap[idx] = obj;
33
+ return idx;
34
+ }
35
+
36
+ function getObject(idx) { return heap[idx]; }
37
+
11
38
  function dropObject(idx) {
12
39
  if (idx < 132) return;
13
40
  heap[idx] = heap_next;
@@ -24,44 +51,17 @@ function isLikeNone(x) {
24
51
  return x === undefined || x === null;
25
52
  }
26
53
 
27
- let cachedFloat64Memory0 = null;
54
+ let cachedDataViewMemory0 = null;
28
55
 
29
- function getFloat64Memory0() {
30
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
31
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
56
+ function getDataViewMemory0() {
57
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
58
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
32
59
  }
33
- return cachedFloat64Memory0;
34
- }
35
-
36
- let cachedInt32Memory0 = null;
37
-
38
- function getInt32Memory0() {
39
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
40
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
41
- }
42
- return cachedInt32Memory0;
43
- }
44
-
45
- function addHeapObject(obj) {
46
- if (heap_next === heap.length) heap.push(heap.length + 1);
47
- const idx = heap_next;
48
- heap_next = heap[idx];
49
-
50
- heap[idx] = obj;
51
- return idx;
60
+ return cachedDataViewMemory0;
52
61
  }
53
62
 
54
63
  let WASM_VECTOR_LEN = 0;
55
64
 
56
- let cachedUint8Memory0 = null;
57
-
58
- function getUint8Memory0() {
59
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
60
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
61
- }
62
- return cachedUint8Memory0;
63
- }
64
-
65
65
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
66
66
 
67
67
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -82,7 +82,7 @@ function passStringToWasm0(arg, malloc, realloc) {
82
82
  if (realloc === undefined) {
83
83
  const buf = cachedTextEncoder.encode(arg);
84
84
  const ptr = malloc(buf.length, 1) >>> 0;
85
- getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
85
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
86
86
  WASM_VECTOR_LEN = buf.length;
87
87
  return ptr;
88
88
  }
@@ -90,7 +90,7 @@ function passStringToWasm0(arg, malloc, realloc) {
90
90
  let len = arg.length;
91
91
  let ptr = malloc(len, 1) >>> 0;
92
92
 
93
- const mem = getUint8Memory0();
93
+ const mem = getUint8ArrayMemory0();
94
94
 
95
95
  let offset = 0;
96
96
 
@@ -105,7 +105,7 @@ function passStringToWasm0(arg, malloc, realloc) {
105
105
  arg = arg.slice(offset);
106
106
  }
107
107
  ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
108
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
108
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
109
109
  const ret = encodeString(arg, view);
110
110
 
111
111
  offset += ret.written;
@@ -116,24 +116,6 @@ function passStringToWasm0(arg, malloc, realloc) {
116
116
  return ptr;
117
117
  }
118
118
 
119
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
120
-
121
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
122
-
123
- function getStringFromWasm0(ptr, len) {
124
- ptr = ptr >>> 0;
125
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
126
- }
127
-
128
- let cachedBigInt64Memory0 = null;
129
-
130
- function getBigInt64Memory0() {
131
- if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
132
- cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
133
- }
134
- return cachedBigInt64Memory0;
135
- }
136
-
137
119
  function debugString(val) {
138
120
  // primitive types
139
121
  const type = typeof val;
@@ -199,60 +181,57 @@ function debugString(val) {
199
181
  return className;
200
182
  }
201
183
  /**
202
- * @param {string} src
203
- * @param {string} filename
204
- * @param {StyleConfig | undefined} [config]
205
- * @returns {string}
206
- */
207
- export function format_style(src, filename, config) {
208
- let deferred4_0;
209
- let deferred4_1;
184
+ * @param {string} src
185
+ * @param {JsonConfig | undefined} [config]
186
+ * @returns {string}
187
+ */
188
+ export function format_json(src, config) {
189
+ let deferred3_0;
190
+ let deferred3_1;
210
191
  try {
211
192
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
212
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
193
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
213
194
  const len0 = WASM_VECTOR_LEN;
214
- const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
215
- const len1 = WASM_VECTOR_LEN;
216
- wasm.format_style(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
217
- var r0 = getInt32Memory0()[retptr / 4 + 0];
218
- var r1 = getInt32Memory0()[retptr / 4 + 1];
219
- var r2 = getInt32Memory0()[retptr / 4 + 2];
220
- var r3 = getInt32Memory0()[retptr / 4 + 3];
221
- var ptr3 = r0;
222
- var len3 = r1;
195
+ wasm.format_json(retptr, ptr0, len0, isLikeNone(config) ? 0 : addHeapObject(config));
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);
200
+ var ptr2 = r0;
201
+ var len2 = r1;
223
202
  if (r3) {
224
- ptr3 = 0; len3 = 0;
203
+ ptr2 = 0; len2 = 0;
225
204
  throw takeObject(r2);
226
205
  }
227
- deferred4_0 = ptr3;
228
- deferred4_1 = len3;
229
- return getStringFromWasm0(ptr3, len3);
206
+ deferred3_0 = ptr2;
207
+ deferred3_1 = len2;
208
+ return getStringFromWasm0(ptr2, len2);
230
209
  } finally {
231
210
  wasm.__wbindgen_add_to_stack_pointer(16);
232
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
211
+ wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
233
212
  }
234
213
  }
235
214
 
236
215
  /**
237
- * @param {string} src
238
- * @param {string} filename
239
- * @param {MarkupConfig | undefined} [config]
240
- * @returns {string}
241
- */
242
- export function format_markup(src, filename, config) {
216
+ * @param {string} src
217
+ * @param {string} filename
218
+ * @param {StyleConfig | undefined} [config]
219
+ * @returns {string}
220
+ */
221
+ export function format_style(src, filename, config) {
243
222
  let deferred4_0;
244
223
  let deferred4_1;
245
224
  try {
246
225
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
247
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
226
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
248
227
  const len0 = WASM_VECTOR_LEN;
249
- const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
228
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
250
229
  const len1 = WASM_VECTOR_LEN;
251
- wasm.format_markup(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
252
- var r0 = getInt32Memory0()[retptr / 4 + 0];
253
- var r1 = getInt32Memory0()[retptr / 4 + 1];
254
- var r2 = getInt32Memory0()[retptr / 4 + 2];
255
- var r3 = getInt32Memory0()[retptr / 4 + 3];
230
+ wasm.format_style(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
231
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
232
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
233
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
234
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
256
235
  var ptr3 = r0;
257
236
  var len3 = r1;
258
237
  if (r3) {
@@ -264,62 +243,65 @@ export function format_markup(src, filename, config) {
264
243
  return getStringFromWasm0(ptr3, len3);
265
244
  } finally {
266
245
  wasm.__wbindgen_add_to_stack_pointer(16);
267
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
246
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
268
247
  }
269
248
  }
270
249
 
271
250
  /**
272
- * @param {string} src
273
- * @param {JsonConfig | undefined} [config]
274
- * @returns {string}
275
- */
276
- export function format_json(src, config) {
277
- let deferred3_0;
278
- let deferred3_1;
251
+ * @param {string} src
252
+ * @param {string} filename
253
+ * @param {Config | undefined} [config]
254
+ * @returns {string}
255
+ */
256
+ export function format(src, filename, config) {
257
+ let deferred4_0;
258
+ let deferred4_1;
279
259
  try {
280
260
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
281
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
261
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
282
262
  const len0 = WASM_VECTOR_LEN;
283
- wasm.format_json(retptr, ptr0, len0, isLikeNone(config) ? 0 : addHeapObject(config));
284
- var r0 = getInt32Memory0()[retptr / 4 + 0];
285
- var r1 = getInt32Memory0()[retptr / 4 + 1];
286
- var r2 = getInt32Memory0()[retptr / 4 + 2];
287
- var r3 = getInt32Memory0()[retptr / 4 + 3];
288
- var ptr2 = r0;
289
- var len2 = r1;
263
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
264
+ const len1 = WASM_VECTOR_LEN;
265
+ wasm.format(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
266
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
267
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
268
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
269
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
270
+ var ptr3 = r0;
271
+ var len3 = r1;
290
272
  if (r3) {
291
- ptr2 = 0; len2 = 0;
273
+ ptr3 = 0; len3 = 0;
292
274
  throw takeObject(r2);
293
275
  }
294
- deferred3_0 = ptr2;
295
- deferred3_1 = len2;
296
- return getStringFromWasm0(ptr2, len2);
276
+ deferred4_0 = ptr3;
277
+ deferred4_1 = len3;
278
+ return getStringFromWasm0(ptr3, len3);
297
279
  } finally {
298
280
  wasm.__wbindgen_add_to_stack_pointer(16);
299
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
281
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
300
282
  }
301
283
  }
302
284
 
303
285
  /**
304
- * @param {string} src
305
- * @param {string} filename
306
- * @param {ScriptConfig | undefined} [config]
307
- * @returns {string}
308
- */
309
- export function format_script(src, filename, config) {
286
+ * @param {string} src
287
+ * @param {string} filename
288
+ * @param {MarkupConfig | undefined} [config]
289
+ * @returns {string}
290
+ */
291
+ export function format_markup(src, filename, config) {
310
292
  let deferred4_0;
311
293
  let deferred4_1;
312
294
  try {
313
295
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
314
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
296
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
315
297
  const len0 = WASM_VECTOR_LEN;
316
- const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
298
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
317
299
  const len1 = WASM_VECTOR_LEN;
318
- wasm.format_script(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
319
- var r0 = getInt32Memory0()[retptr / 4 + 0];
320
- var r1 = getInt32Memory0()[retptr / 4 + 1];
321
- var r2 = getInt32Memory0()[retptr / 4 + 2];
322
- var r3 = getInt32Memory0()[retptr / 4 + 3];
300
+ wasm.format_markup(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
301
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
302
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
303
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
304
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
323
305
  var ptr3 = r0;
324
306
  var len3 = r1;
325
307
  if (r3) {
@@ -331,30 +313,30 @@ export function format_script(src, filename, config) {
331
313
  return getStringFromWasm0(ptr3, len3);
332
314
  } finally {
333
315
  wasm.__wbindgen_add_to_stack_pointer(16);
334
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
316
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
335
317
  }
336
318
  }
337
319
 
338
320
  /**
339
- * @param {string} src
340
- * @param {string} filename
341
- * @param {Config | undefined} [config]
342
- * @returns {string}
343
- */
344
- export function format(src, filename, config) {
321
+ * @param {string} src
322
+ * @param {string} filename
323
+ * @param {ScriptConfig | undefined} [config]
324
+ * @returns {string}
325
+ */
326
+ export function format_script(src, filename, config) {
345
327
  let deferred4_0;
346
328
  let deferred4_1;
347
329
  try {
348
330
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
349
- const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
331
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
350
332
  const len0 = WASM_VECTOR_LEN;
351
- const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
333
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
352
334
  const len1 = WASM_VECTOR_LEN;
353
- wasm.format(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
354
- var r0 = getInt32Memory0()[retptr / 4 + 0];
355
- var r1 = getInt32Memory0()[retptr / 4 + 1];
356
- var r2 = getInt32Memory0()[retptr / 4 + 2];
357
- var r3 = getInt32Memory0()[retptr / 4 + 3];
335
+ wasm.format_script(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
336
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
337
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
338
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
339
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
358
340
  var ptr3 = r0;
359
341
  var len3 = r1;
360
342
  if (r3) {
@@ -366,7 +348,7 @@ export function format(src, filename, config) {
366
348
  return getStringFromWasm0(ptr3, len3);
367
349
  } finally {
368
350
  wasm.__wbindgen_add_to_stack_pointer(16);
369
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
351
+ wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
370
352
  }
371
353
  }
372
354
 
@@ -374,7 +356,7 @@ function handleError(f, args) {
374
356
  try {
375
357
  return f.apply(this, args);
376
358
  } catch (e) {
377
- wasm.__wbindgen_exn_store(addHeapObject(e));
359
+ wasm.__wbindgen_export_3(addHeapObject(e));
378
360
  }
379
361
  }
380
362
 
@@ -386,7 +368,7 @@ async function __wbg_load(module, imports) {
386
368
 
387
369
  } catch (e) {
388
370
  if (module.headers.get('Content-Type') != 'application/wasm') {
389
- 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);
371
+ 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);
390
372
 
391
373
  } else {
392
374
  throw e;
@@ -412,6 +394,10 @@ async function __wbg_load(module, imports) {
412
394
  function __wbg_get_imports() {
413
395
  const imports = {};
414
396
  imports.wbg = {};
397
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
398
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
399
+ return addHeapObject(ret);
400
+ };
415
401
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
416
402
  takeObject(arg0);
417
403
  };
@@ -435,8 +421,8 @@ function __wbg_get_imports() {
435
421
  imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
436
422
  const obj = getObject(arg1);
437
423
  const ret = typeof(obj) === 'number' ? obj : undefined;
438
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
439
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
424
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
425
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
440
426
  };
441
427
  imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
442
428
  const ret = arg0;
@@ -449,10 +435,10 @@ function __wbg_get_imports() {
449
435
  imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
450
436
  const obj = getObject(arg1);
451
437
  const ret = typeof(obj) === 'string' ? obj : undefined;
452
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
438
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
453
439
  var len1 = WASM_VECTOR_LEN;
454
- getInt32Memory0()[arg0 / 4 + 1] = len1;
455
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
440
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
441
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
456
442
  };
457
443
  imports.wbg.__wbindgen_is_object = function(arg0) {
458
444
  const val = getObject(arg0);
@@ -475,30 +461,30 @@ function __wbg_get_imports() {
475
461
  const ret = getStringFromWasm0(arg0, arg1);
476
462
  return addHeapObject(ret);
477
463
  };
478
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
479
- const ret = new Error(getStringFromWasm0(arg0, arg1));
480
- return addHeapObject(ret);
481
- };
482
464
  imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
483
465
  const ret = getObject(arg0) == getObject(arg1);
484
466
  return ret;
485
467
  };
486
- imports.wbg.__wbg_String_917f38a1211cf44b = function(arg0, arg1) {
468
+ imports.wbg.__wbindgen_as_number = function(arg0) {
469
+ const ret = +getObject(arg0);
470
+ return ret;
471
+ };
472
+ imports.wbg.__wbg_String_b9412f8799faab3e = function(arg0, arg1) {
487
473
  const ret = String(getObject(arg1));
488
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
474
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
489
475
  const len1 = WASM_VECTOR_LEN;
490
- getInt32Memory0()[arg0 / 4 + 1] = len1;
491
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
476
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
477
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
492
478
  };
493
- imports.wbg.__wbg_getwithrefkey_3b3c46ba20582127 = function(arg0, arg1) {
479
+ imports.wbg.__wbg_getwithrefkey_edc2c8960f0f1191 = function(arg0, arg1) {
494
480
  const ret = getObject(arg0)[getObject(arg1)];
495
481
  return addHeapObject(ret);
496
482
  };
497
- imports.wbg.__wbg_get_44be0491f933a435 = function(arg0, arg1) {
483
+ imports.wbg.__wbg_get_5419cf6b954aa11d = function(arg0, arg1) {
498
484
  const ret = getObject(arg0)[arg1 >>> 0];
499
485
  return addHeapObject(ret);
500
486
  };
501
- imports.wbg.__wbg_length_fff51ee6522a1a18 = function(arg0) {
487
+ imports.wbg.__wbg_length_f217bbbf7e8e4df4 = function(arg0) {
502
488
  const ret = getObject(arg0).length;
503
489
  return ret;
504
490
  };
@@ -506,39 +492,39 @@ function __wbg_get_imports() {
506
492
  const ret = typeof(getObject(arg0)) === 'function';
507
493
  return ret;
508
494
  };
509
- imports.wbg.__wbg_next_526fc47e980da008 = function(arg0) {
495
+ imports.wbg.__wbg_next_13b477da1eaa3897 = function(arg0) {
510
496
  const ret = getObject(arg0).next;
511
497
  return addHeapObject(ret);
512
498
  };
513
- imports.wbg.__wbg_next_ddb3312ca1c4e32a = function() { return handleError(function (arg0) {
499
+ imports.wbg.__wbg_next_b06e115d1b01e10b = function() { return handleError(function (arg0) {
514
500
  const ret = getObject(arg0).next();
515
501
  return addHeapObject(ret);
516
502
  }, arguments) };
517
- imports.wbg.__wbg_done_5c1f01fb660d73b5 = function(arg0) {
503
+ imports.wbg.__wbg_done_983b5ffcaec8c583 = function(arg0) {
518
504
  const ret = getObject(arg0).done;
519
505
  return ret;
520
506
  };
521
- imports.wbg.__wbg_value_1695675138684bd5 = function(arg0) {
507
+ imports.wbg.__wbg_value_2ab8a198c834c26a = function(arg0) {
522
508
  const ret = getObject(arg0).value;
523
509
  return addHeapObject(ret);
524
510
  };
525
- imports.wbg.__wbg_iterator_97f0c81209c6c35a = function() {
511
+ imports.wbg.__wbg_iterator_695d699a44d6234c = function() {
526
512
  const ret = Symbol.iterator;
527
513
  return addHeapObject(ret);
528
514
  };
529
- imports.wbg.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) {
515
+ imports.wbg.__wbg_get_ef828680c64da212 = function() { return handleError(function (arg0, arg1) {
530
516
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
531
517
  return addHeapObject(ret);
532
518
  }, arguments) };
533
- imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) {
519
+ imports.wbg.__wbg_call_a9ef466721e824f2 = function() { return handleError(function (arg0, arg1) {
534
520
  const ret = getObject(arg0).call(getObject(arg1));
535
521
  return addHeapObject(ret);
536
522
  }, arguments) };
537
- imports.wbg.__wbg_isArray_4c24b343cb13cfb1 = function(arg0) {
523
+ imports.wbg.__wbg_isArray_6f3b47f09adb61b5 = function(arg0) {
538
524
  const ret = Array.isArray(getObject(arg0));
539
525
  return ret;
540
526
  };
541
- imports.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function(arg0) {
527
+ imports.wbg.__wbg_instanceof_ArrayBuffer_74945570b4a62ec7 = function(arg0) {
542
528
  let result;
543
529
  try {
544
530
  result = getObject(arg0) instanceof ArrayBuffer;
@@ -548,30 +534,40 @@ function __wbg_get_imports() {
548
534
  const ret = result;
549
535
  return ret;
550
536
  };
551
- imports.wbg.__wbg_isSafeInteger_bb8e18dd21c97288 = function(arg0) {
537
+ imports.wbg.__wbg_instanceof_Map_f96986929e7e89ed = function(arg0) {
538
+ let result;
539
+ try {
540
+ result = getObject(arg0) instanceof Map;
541
+ } catch (_) {
542
+ result = false;
543
+ }
544
+ const ret = result;
545
+ return ret;
546
+ };
547
+ imports.wbg.__wbg_isSafeInteger_b9dff570f01a9100 = function(arg0) {
552
548
  const ret = Number.isSafeInteger(getObject(arg0));
553
549
  return ret;
554
550
  };
555
- imports.wbg.__wbg_entries_e51f29c7bba0c054 = function(arg0) {
551
+ imports.wbg.__wbg_entries_c02034de337d3ee2 = function(arg0) {
556
552
  const ret = Object.entries(getObject(arg0));
557
553
  return addHeapObject(ret);
558
554
  };
559
- imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) {
555
+ imports.wbg.__wbg_buffer_ccaed51a635d8a2d = function(arg0) {
560
556
  const ret = getObject(arg0).buffer;
561
557
  return addHeapObject(ret);
562
558
  };
563
- imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) {
559
+ imports.wbg.__wbg_new_fec2611eb9180f95 = function(arg0) {
564
560
  const ret = new Uint8Array(getObject(arg0));
565
561
  return addHeapObject(ret);
566
562
  };
567
- imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
563
+ imports.wbg.__wbg_set_ec2fcf81bc573fd9 = function(arg0, arg1, arg2) {
568
564
  getObject(arg0).set(getObject(arg1), arg2 >>> 0);
569
565
  };
570
- imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) {
566
+ imports.wbg.__wbg_length_9254c4bd3b9f23c4 = function(arg0) {
571
567
  const ret = getObject(arg0).length;
572
568
  return ret;
573
569
  };
574
- imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) {
570
+ imports.wbg.__wbg_instanceof_Uint8Array_df0761410414ef36 = function(arg0) {
575
571
  let result;
576
572
  try {
577
573
  result = getObject(arg0) instanceof Uint8Array;
@@ -584,15 +580,15 @@ function __wbg_get_imports() {
584
580
  imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
585
581
  const v = getObject(arg1);
586
582
  const ret = typeof(v) === 'bigint' ? v : undefined;
587
- getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
588
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
583
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
584
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
589
585
  };
590
586
  imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
591
587
  const ret = debugString(getObject(arg1));
592
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
588
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
593
589
  const len1 = WASM_VECTOR_LEN;
594
- getInt32Memory0()[arg0 / 4 + 1] = len1;
595
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
590
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
591
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
596
592
  };
597
593
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
598
594
  throw new Error(getStringFromWasm0(arg0, arg1));
@@ -605,17 +601,16 @@ function __wbg_get_imports() {
605
601
  return imports;
606
602
  }
607
603
 
608
- function __wbg_init_memory(imports, maybe_memory) {
604
+ function __wbg_init_memory(imports, memory) {
609
605
 
610
606
  }
611
607
 
612
608
  function __wbg_finalize_init(instance, module) {
613
609
  wasm = instance.exports;
614
610
  __wbg_init.__wbindgen_wasm_module = module;
615
- cachedBigInt64Memory0 = null;
616
- cachedFloat64Memory0 = null;
617
- cachedInt32Memory0 = null;
618
- cachedUint8Memory0 = null;
611
+ cachedDataViewMemory0 = null;
612
+ cachedUint8ArrayMemory0 = null;
613
+
619
614
 
620
615
 
621
616
  return wasm;
@@ -624,6 +619,15 @@ function __wbg_finalize_init(instance, module) {
624
619
  function initSync(module) {
625
620
  if (wasm !== undefined) return wasm;
626
621
 
622
+
623
+ if (typeof module !== 'undefined') {
624
+ if (Object.getPrototypeOf(module) === Object.prototype) {
625
+ ({module} = module)
626
+ } else {
627
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
628
+ }
629
+ }
630
+
627
631
  const imports = __wbg_get_imports();
628
632
 
629
633
  __wbg_init_memory(imports);
@@ -637,24 +641,33 @@ function initSync(module) {
637
641
  return __wbg_finalize_init(instance, module);
638
642
  }
639
643
 
640
- async function __wbg_init(input) {
644
+ async function __wbg_init(module_or_path) {
641
645
  if (wasm !== undefined) return wasm;
642
646
 
643
- if (typeof input === 'undefined') {
644
- input = new URL('web_fmt_bg.wasm', import.meta.url);
647
+
648
+ if (typeof module_or_path !== 'undefined') {
649
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
650
+ ({module_or_path} = module_or_path)
651
+ } else {
652
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
653
+ }
654
+ }
655
+
656
+ if (typeof module_or_path === 'undefined') {
657
+ module_or_path = new URL('web_fmt_bg.wasm', import.meta.url);
645
658
  }
646
659
  const imports = __wbg_get_imports();
647
660
 
648
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
649
- input = fetch(input);
661
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
662
+ module_or_path = fetch(module_or_path);
650
663
  }
651
664
 
652
665
  __wbg_init_memory(imports);
653
666
 
654
- const { instance, module } = await __wbg_load(await input, imports);
667
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
655
668
 
656
669
  return __wbg_finalize_init(instance, module);
657
670
  }
658
671
 
659
- export { initSync }
672
+ export { initSync };
660
673
  export default __wbg_init;
package/web_fmt_bg.wasm CHANGED
Binary file
@@ -1,13 +1,13 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export function format_json(a: number, b: number, c: number, d: number): void;
4
5
  export function format_style(a: number, b: number, c: number, d: number, e: number, f: number): void;
6
+ export function format(a: number, b: number, c: number, d: number, e: number, f: number): void;
5
7
  export function format_markup(a: number, b: number, c: number, d: number, e: number, f: number): void;
6
- export function format_json(a: number, b: number, c: number, d: number): void;
7
8
  export function format_script(a: number, b: number, c: number, d: number, e: number, f: number): void;
8
- export function format(a: number, b: number, c: number, d: number, e: number, f: number): void;
9
- export function __wbindgen_malloc(a: number, b: number): number;
10
- export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
9
+ export function __wbindgen_export_0(a: number, b: number): number;
10
+ export function __wbindgen_export_1(a: number, b: number, c: number, d: number): number;
11
11
  export function __wbindgen_add_to_stack_pointer(a: number): number;
12
- export function __wbindgen_free(a: number, b: number, c: number): void;
13
- export function __wbindgen_exn_store(a: number): void;
12
+ export function __wbindgen_export_2(a: number, b: number, c: number): void;
13
+ export function __wbindgen_export_3(a: number): void;