@wasm-fmt/graphql_fmt 0.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 wasm-fmt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # graphql_fmt
2
+
3
+ GraphQL formatter powered by WASM ported from [pretty_graphql](https://github.com/g-plane/pretty_graphql).
4
+
5
+ ## Usage
6
+
7
+ ### Node.js
8
+
9
+ ```js
10
+ import init from "graphql_fmt";
11
+
12
+ const { format } = await init();
13
+
14
+ const result = format(
15
+ "query { user { name } }",
16
+ "query.graphql",
17
+ {
18
+ indentStyle: "space",
19
+ indentWidth: 2,
20
+ lineWidth: 80,
21
+ lineEnding: "lf",
22
+ }
23
+ );
24
+ ```
25
+
26
+ ### Vite
27
+
28
+ Add `"@wasm-fmt/graphql-fmt"` to `optimizeDeps.exclude` in your vite config:
29
+
30
+ ```JSON
31
+ {
32
+ "optimizeDeps": {
33
+ "exclude": ["@wasm-fmt/graphql-fmt"]
34
+ }
35
+ }
36
+ ```
37
+
38
+ <details>
39
+ <summary>
40
+ If you cannot change the vite config, you can use another import entry
41
+
42
+ </summary>
43
+
44
+ ```js
45
+ import init from "@wasm-fmt/graphql-fmt/vite";
46
+
47
+ const { format } = await init();
48
+
49
+ const result = format(
50
+ "query { user { name } }",
51
+ "query.graphql",
52
+ {
53
+ indentStyle: "space",
54
+ indentWidth: 2,
55
+ lineWidth: 80,
56
+ lineEnding: "lf",
57
+ }
58
+ );
59
+ ```
60
+
61
+ </details>
62
+
63
+ ## Configuration
64
+
65
+ See [pretty_graphql configuration docs](https://pretty-graphql.netlify.app/) for all available options.
@@ -0,0 +1,54 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export interface Config extends LayoutConfig {
5
+ /**
6
+ * See {@link https://pretty-graphql.netlify.app/}
7
+ */
8
+ [other: string]: any;
9
+ }
10
+
11
+
12
+ interface LayoutConfig {
13
+ indentStyle?: "tab" | "space";
14
+ indentWidth?: number;
15
+ lineWidth?: number;
16
+ lineEnding?: "lf" | "crlf";
17
+ }
18
+
19
+
20
+ export function format(src: string, filename: string, config?: Config | null): string;
21
+
22
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
23
+
24
+ export interface InitOutput {
25
+ readonly memory: WebAssembly.Memory;
26
+ readonly format: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
27
+ readonly __wbindgen_export: (a: number, b: number) => number;
28
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
29
+ readonly __wbindgen_export3: (a: number) => void;
30
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
31
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
32
+ }
33
+
34
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
35
+
36
+ /**
37
+ * Instantiates the given `module`, which can either be bytes or
38
+ * a precompiled `WebAssembly.Module`.
39
+ *
40
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
41
+ *
42
+ * @returns {InitOutput}
43
+ */
44
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
45
+
46
+ /**
47
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
48
+ * for everything else, calls `WebAssembly.instantiate` directly.
49
+ *
50
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
51
+ *
52
+ * @returns {Promise<InitOutput>}
53
+ */
54
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/graphql_fmt.js ADDED
@@ -0,0 +1,514 @@
1
+ let wasm;
2
+
3
+ function addHeapObject(obj) {
4
+ if (heap_next === heap.length) heap.push(heap.length + 1);
5
+ const idx = heap_next;
6
+ heap_next = heap[idx];
7
+
8
+ heap[idx] = obj;
9
+ return idx;
10
+ }
11
+
12
+ function debugString(val) {
13
+ // primitive types
14
+ const type = typeof val;
15
+ if (type == 'number' || type == 'boolean' || val == null) {
16
+ return `${val}`;
17
+ }
18
+ if (type == 'string') {
19
+ return `"${val}"`;
20
+ }
21
+ if (type == 'symbol') {
22
+ const description = val.description;
23
+ if (description == null) {
24
+ return 'Symbol';
25
+ } else {
26
+ return `Symbol(${description})`;
27
+ }
28
+ }
29
+ if (type == 'function') {
30
+ const name = val.name;
31
+ if (typeof name == 'string' && name.length > 0) {
32
+ return `Function(${name})`;
33
+ } else {
34
+ return 'Function';
35
+ }
36
+ }
37
+ // objects
38
+ if (Array.isArray(val)) {
39
+ const length = val.length;
40
+ let debug = '[';
41
+ if (length > 0) {
42
+ debug += debugString(val[0]);
43
+ }
44
+ for(let i = 1; i < length; i++) {
45
+ debug += ', ' + debugString(val[i]);
46
+ }
47
+ debug += ']';
48
+ return debug;
49
+ }
50
+ // Test for built-in
51
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
52
+ let className;
53
+ if (builtInMatches && builtInMatches.length > 1) {
54
+ className = builtInMatches[1];
55
+ } else {
56
+ // Failed to match the standard '[object ClassName]'
57
+ return toString.call(val);
58
+ }
59
+ if (className == 'Object') {
60
+ // we're a user defined class or Object
61
+ // JSON.stringify avoids problems with cycles, and is generally much
62
+ // easier than looping through ownProperties of `val`.
63
+ try {
64
+ return 'Object(' + JSON.stringify(val) + ')';
65
+ } catch (_) {
66
+ return 'Object';
67
+ }
68
+ }
69
+ // errors
70
+ if (val instanceof Error) {
71
+ return `${val.name}: ${val.message}\n${val.stack}`;
72
+ }
73
+ // TODO we could test for more things here, like `Set`s and `Map`s.
74
+ return className;
75
+ }
76
+
77
+ function dropObject(idx) {
78
+ if (idx < 132) return;
79
+ heap[idx] = heap_next;
80
+ heap_next = idx;
81
+ }
82
+
83
+ function getArrayU8FromWasm0(ptr, len) {
84
+ ptr = ptr >>> 0;
85
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
86
+ }
87
+
88
+ let cachedDataViewMemory0 = null;
89
+ function getDataViewMemory0() {
90
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
91
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
92
+ }
93
+ return cachedDataViewMemory0;
94
+ }
95
+
96
+ function getStringFromWasm0(ptr, len) {
97
+ ptr = ptr >>> 0;
98
+ return decodeText(ptr, len);
99
+ }
100
+
101
+ let cachedUint8ArrayMemory0 = null;
102
+ function getUint8ArrayMemory0() {
103
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
104
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
105
+ }
106
+ return cachedUint8ArrayMemory0;
107
+ }
108
+
109
+ function getObject(idx) { return heap[idx]; }
110
+
111
+ function handleError(f, args) {
112
+ try {
113
+ return f.apply(this, args);
114
+ } catch (e) {
115
+ wasm.__wbindgen_export3(addHeapObject(e));
116
+ }
117
+ }
118
+
119
+ let heap = new Array(128).fill(undefined);
120
+ heap.push(undefined, null, true, false);
121
+
122
+ let heap_next = heap.length;
123
+
124
+ function isLikeNone(x) {
125
+ return x === undefined || x === null;
126
+ }
127
+
128
+ function passStringToWasm0(arg, malloc, realloc) {
129
+ if (realloc === undefined) {
130
+ const buf = cachedTextEncoder.encode(arg);
131
+ const ptr = malloc(buf.length, 1) >>> 0;
132
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
133
+ WASM_VECTOR_LEN = buf.length;
134
+ return ptr;
135
+ }
136
+
137
+ let len = arg.length;
138
+ let ptr = malloc(len, 1) >>> 0;
139
+
140
+ const mem = getUint8ArrayMemory0();
141
+
142
+ let offset = 0;
143
+
144
+ for (; offset < len; offset++) {
145
+ const code = arg.charCodeAt(offset);
146
+ if (code > 0x7F) break;
147
+ mem[ptr + offset] = code;
148
+ }
149
+ if (offset !== len) {
150
+ if (offset !== 0) {
151
+ arg = arg.slice(offset);
152
+ }
153
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
154
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
155
+ const ret = cachedTextEncoder.encodeInto(arg, view);
156
+
157
+ offset += ret.written;
158
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
159
+ }
160
+
161
+ WASM_VECTOR_LEN = offset;
162
+ return ptr;
163
+ }
164
+
165
+ function takeObject(idx) {
166
+ const ret = getObject(idx);
167
+ dropObject(idx);
168
+ return ret;
169
+ }
170
+
171
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
172
+ cachedTextDecoder.decode();
173
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
174
+ let numBytesDecoded = 0;
175
+ function decodeText(ptr, len) {
176
+ numBytesDecoded += len;
177
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
178
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
179
+ cachedTextDecoder.decode();
180
+ numBytesDecoded = len;
181
+ }
182
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
183
+ }
184
+
185
+ const cachedTextEncoder = new TextEncoder();
186
+
187
+ if (!('encodeInto' in cachedTextEncoder)) {
188
+ cachedTextEncoder.encodeInto = function (arg, view) {
189
+ const buf = cachedTextEncoder.encode(arg);
190
+ view.set(buf);
191
+ return {
192
+ read: arg.length,
193
+ written: buf.length
194
+ };
195
+ }
196
+ }
197
+
198
+ let WASM_VECTOR_LEN = 0;
199
+
200
+ /**
201
+ * @param {string} src
202
+ * @param {string} filename
203
+ * @param {Config | null} [config]
204
+ * @returns {string}
205
+ */
206
+ export function format(src, filename, config) {
207
+ let deferred4_0;
208
+ let deferred4_1;
209
+ try {
210
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
211
+ const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
212
+ const len0 = WASM_VECTOR_LEN;
213
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
214
+ const len1 = WASM_VECTOR_LEN;
215
+ wasm.format(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
216
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
217
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
218
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
219
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
220
+ var ptr3 = r0;
221
+ var len3 = r1;
222
+ if (r3) {
223
+ ptr3 = 0; len3 = 0;
224
+ throw takeObject(r2);
225
+ }
226
+ deferred4_0 = ptr3;
227
+ deferred4_1 = len3;
228
+ return getStringFromWasm0(ptr3, len3);
229
+ } finally {
230
+ wasm.__wbindgen_add_to_stack_pointer(16);
231
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
232
+ }
233
+ }
234
+
235
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
236
+
237
+ async function __wbg_load(module, imports) {
238
+ if (typeof Response === 'function' && module instanceof Response) {
239
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
240
+ try {
241
+ return await WebAssembly.instantiateStreaming(module, imports);
242
+ } catch (e) {
243
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
244
+
245
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
246
+ 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);
247
+
248
+ } else {
249
+ throw e;
250
+ }
251
+ }
252
+ }
253
+
254
+ const bytes = await module.arrayBuffer();
255
+ return await WebAssembly.instantiate(bytes, imports);
256
+ } else {
257
+ const instance = await WebAssembly.instantiate(module, imports);
258
+
259
+ if (instance instanceof WebAssembly.Instance) {
260
+ return { instance, module };
261
+ } else {
262
+ return instance;
263
+ }
264
+ }
265
+ }
266
+
267
+ function __wbg_get_imports() {
268
+ const imports = {};
269
+ imports.wbg = {};
270
+ imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
271
+ const ret = Error(getStringFromWasm0(arg0, arg1));
272
+ return addHeapObject(ret);
273
+ };
274
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
275
+ const ret = String(getObject(arg1));
276
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
277
+ const len1 = WASM_VECTOR_LEN;
278
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
279
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
280
+ };
281
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
282
+ const v = getObject(arg1);
283
+ const ret = typeof(v) === 'bigint' ? v : undefined;
284
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
285
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
286
+ };
287
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
288
+ const v = getObject(arg0);
289
+ const ret = typeof(v) === 'boolean' ? v : undefined;
290
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
291
+ };
292
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
293
+ const ret = debugString(getObject(arg1));
294
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
295
+ const len1 = WASM_VECTOR_LEN;
296
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
297
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
298
+ };
299
+ imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
300
+ const ret = getObject(arg0) in getObject(arg1);
301
+ return ret;
302
+ };
303
+ imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
304
+ const ret = typeof(getObject(arg0)) === 'bigint';
305
+ return ret;
306
+ };
307
+ imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
308
+ const ret = typeof(getObject(arg0)) === 'function';
309
+ return ret;
310
+ };
311
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
312
+ const val = getObject(arg0);
313
+ const ret = typeof(val) === 'object' && val !== null;
314
+ return ret;
315
+ };
316
+ imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
317
+ const ret = getObject(arg0) === getObject(arg1);
318
+ return ret;
319
+ };
320
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
321
+ const ret = getObject(arg0) == getObject(arg1);
322
+ return ret;
323
+ };
324
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
325
+ const obj = getObject(arg1);
326
+ const ret = typeof(obj) === 'number' ? obj : undefined;
327
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
328
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
329
+ };
330
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
331
+ const obj = getObject(arg1);
332
+ const ret = typeof(obj) === 'string' ? obj : undefined;
333
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
334
+ var len1 = WASM_VECTOR_LEN;
335
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
336
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
337
+ };
338
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
339
+ throw new Error(getStringFromWasm0(arg0, arg1));
340
+ };
341
+ imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
342
+ const ret = getObject(arg0).call(getObject(arg1));
343
+ return addHeapObject(ret);
344
+ }, arguments) };
345
+ imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
346
+ const ret = getObject(arg0).done;
347
+ return ret;
348
+ };
349
+ imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
350
+ const ret = Object.entries(getObject(arg0));
351
+ return addHeapObject(ret);
352
+ };
353
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
354
+ const ret = getObject(arg0)[arg1 >>> 0];
355
+ return addHeapObject(ret);
356
+ };
357
+ imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
358
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
359
+ return addHeapObject(ret);
360
+ }, arguments) };
361
+ imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
362
+ let result;
363
+ try {
364
+ result = getObject(arg0) instanceof ArrayBuffer;
365
+ } catch (_) {
366
+ result = false;
367
+ }
368
+ const ret = result;
369
+ return ret;
370
+ };
371
+ imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
372
+ let result;
373
+ try {
374
+ result = getObject(arg0) instanceof Map;
375
+ } catch (_) {
376
+ result = false;
377
+ }
378
+ const ret = result;
379
+ return ret;
380
+ };
381
+ imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
382
+ let result;
383
+ try {
384
+ result = getObject(arg0) instanceof Uint8Array;
385
+ } catch (_) {
386
+ result = false;
387
+ }
388
+ const ret = result;
389
+ return ret;
390
+ };
391
+ imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
392
+ const ret = Array.isArray(getObject(arg0));
393
+ return ret;
394
+ };
395
+ imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
396
+ const ret = Number.isSafeInteger(getObject(arg0));
397
+ return ret;
398
+ };
399
+ imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
400
+ const ret = Symbol.iterator;
401
+ return addHeapObject(ret);
402
+ };
403
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
404
+ const ret = getObject(arg0).length;
405
+ return ret;
406
+ };
407
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
408
+ const ret = getObject(arg0).length;
409
+ return ret;
410
+ };
411
+ imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
412
+ const ret = new Uint8Array(getObject(arg0));
413
+ return addHeapObject(ret);
414
+ };
415
+ imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
416
+ const ret = getObject(arg0).next;
417
+ return addHeapObject(ret);
418
+ };
419
+ imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
420
+ const ret = getObject(arg0).next();
421
+ return addHeapObject(ret);
422
+ }, arguments) };
423
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
424
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
425
+ };
426
+ imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
427
+ const ret = getObject(arg0).value;
428
+ return addHeapObject(ret);
429
+ };
430
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
431
+ // Cast intrinsic for `Ref(String) -> Externref`.
432
+ const ret = getStringFromWasm0(arg0, arg1);
433
+ return addHeapObject(ret);
434
+ };
435
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
436
+ // Cast intrinsic for `U64 -> Externref`.
437
+ const ret = BigInt.asUintN(64, arg0);
438
+ return addHeapObject(ret);
439
+ };
440
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
441
+ // Cast intrinsic for `I64 -> Externref`.
442
+ const ret = arg0;
443
+ return addHeapObject(ret);
444
+ };
445
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
446
+ const ret = getObject(arg0);
447
+ return addHeapObject(ret);
448
+ };
449
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
450
+ takeObject(arg0);
451
+ };
452
+
453
+ return imports;
454
+ }
455
+
456
+ function __wbg_finalize_init(instance, module) {
457
+ wasm = instance.exports;
458
+ __wbg_init.__wbindgen_wasm_module = module;
459
+ cachedDataViewMemory0 = null;
460
+ cachedUint8ArrayMemory0 = null;
461
+
462
+
463
+
464
+ return wasm;
465
+ }
466
+
467
+ function initSync(module) {
468
+ if (wasm !== undefined) return wasm;
469
+
470
+
471
+ if (typeof module !== 'undefined') {
472
+ if (Object.getPrototypeOf(module) === Object.prototype) {
473
+ ({module} = module)
474
+ } else {
475
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
476
+ }
477
+ }
478
+
479
+ const imports = __wbg_get_imports();
480
+ if (!(module instanceof WebAssembly.Module)) {
481
+ module = new WebAssembly.Module(module);
482
+ }
483
+ const instance = new WebAssembly.Instance(module, imports);
484
+ return __wbg_finalize_init(instance, module);
485
+ }
486
+
487
+ async function __wbg_init(module_or_path) {
488
+ if (wasm !== undefined) return wasm;
489
+
490
+
491
+ if (typeof module_or_path !== 'undefined') {
492
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
493
+ ({module_or_path} = module_or_path)
494
+ } else {
495
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
496
+ }
497
+ }
498
+
499
+ if (typeof module_or_path === 'undefined') {
500
+ module_or_path = new URL('graphql_fmt_bg.wasm', import.meta.url);
501
+ }
502
+ const imports = __wbg_get_imports();
503
+
504
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
505
+ module_or_path = fetch(module_or_path);
506
+ }
507
+
508
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
509
+
510
+ return __wbg_finalize_init(instance, module);
511
+ }
512
+
513
+ export { initSync };
514
+ export default __wbg_init;
Binary file
@@ -0,0 +1,9 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const format: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
5
+ export const __wbindgen_export: (a: number, b: number) => number;
6
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
7
+ export const __wbindgen_export3: (a: number) => void;
8
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
9
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
@@ -0,0 +1,10 @@
1
+ import fs from "node:fs/promises";
2
+ import initAsync from "./graphql_fmt.js";
3
+
4
+ const wasm = new URL("./graphql_fmt_bg.wasm", import.meta.url);
5
+
6
+ export default function __wbg_init(init = { module_or_path: fs.readFile(wasm) }) {
7
+ return initAsync(init);
8
+ }
9
+
10
+ export * from "./graphql_fmt.js";
@@ -0,0 +1,8 @@
1
+ import initAsync from "./graphql_fmt.js";
2
+ import wasm from "./graphql_fmt_bg.wasm?url";
3
+
4
+ export default function __wbg_init(input = { module_or_path: wasm }) {
5
+ return initAsync(input);
6
+ }
7
+
8
+ export * from "./graphql_fmt.js";
package/jsr.jsonc ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@fmt/graphql-fmt",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "magic-akari <akari.ccino@gmail.com>"
6
+ ],
7
+ "description": "GraphQL formatter powered by WASM ported from pretty_graphql",
8
+ "version": "0.1.14",
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": "graphql_fmt.d.ts",
16
+ "sideEffects": [
17
+ "./snippets/*"
18
+ ],
19
+ "keywords": [
20
+ "wasm",
21
+ "formatter",
22
+ "graphql",
23
+ "pretty_graphql"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "exports": "./graphql_fmt.js",
29
+ "exclude": [
30
+ "!**",
31
+ "*.tgz"
32
+ ]
33
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@wasm-fmt/graphql_fmt",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "magic-akari <akari.ccino@gmail.com>"
6
+ ],
7
+ "description": "GraphQL formatter powered by WASM ported from pretty_graphql",
8
+ "version": "0.0.0",
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": "graphql_fmt.d.ts",
16
+ "sideEffects": [
17
+ "./snippets/*"
18
+ ],
19
+ "keywords": [
20
+ "wasm",
21
+ "formatter",
22
+ "graphql",
23
+ "pretty_graphql"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "types": "./graphql_fmt.d.ts",
31
+ "node": "./graphql_fmt_node.js",
32
+ "default": "./graphql_fmt.js"
33
+ },
34
+ "./vite": {
35
+ "types": "./graphql_fmt.d.ts",
36
+ "default": "./graphql_fmt_vite.js"
37
+ },
38
+ "./package.json": "./package.json",
39
+ "./*": "./*"
40
+ }
41
+ }