@wasm-fmt/graphql_fmt 0.0.0 → 0.1.17
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/README.md +27 -36
- package/graphql_fmt.d.ts +2 -2
- package/graphql_fmt.js +11 -14
- package/graphql_fmt_bg.wasm +0 -0
- package/graphql_fmt_bg.wasm.d.ts +1 -1
- package/jsr.jsonc +1 -1
- package/package.json +1 -1
- package/wasm-fmt-graphql_fmt-0.1.17.tgz +0 -0
package/README.md
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Install
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@wasm-fmt/graphql_fmt)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```bash
|
|
6
|
+
npm install @wasm-fmt/graphql_fmt
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
[](https://jsr.io/@fmt/graphql-fmt)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx jsr add @fmt/graphql-fmt
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# Usage
|
|
6
16
|
|
|
7
|
-
|
|
17
|
+
```javascript
|
|
18
|
+
import init, { format } from "@wasm-fmt/graphql_fmt";
|
|
8
19
|
|
|
9
|
-
|
|
10
|
-
import init from "graphql_fmt";
|
|
20
|
+
await init();
|
|
11
21
|
|
|
12
|
-
const {
|
|
22
|
+
const input = `query { user { name } }`;
|
|
13
23
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
"query.graphql",
|
|
17
|
-
{
|
|
18
|
-
indentStyle: "space",
|
|
19
|
-
indentWidth: 2,
|
|
20
|
-
lineWidth: 80,
|
|
21
|
-
lineEnding: "lf",
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
+
const formatted = format(input);
|
|
25
|
+
console.log(formatted);
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
For Vite users:
|
|
27
29
|
|
|
28
|
-
Add `"@wasm-fmt/
|
|
30
|
+
Add `"@wasm-fmt/graphql_fmt"` to `optimizeDeps.exclude` in your vite config:
|
|
29
31
|
|
|
30
32
|
```JSON
|
|
31
33
|
{
|
|
32
34
|
"optimizeDeps": {
|
|
33
|
-
"exclude": ["@wasm-fmt/
|
|
35
|
+
"exclude": ["@wasm-fmt/graphql_fmt"]
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
```
|
|
@@ -41,25 +43,14 @@ If you cannot change the vite config, you can use another import entry
|
|
|
41
43
|
|
|
42
44
|
</summary>
|
|
43
45
|
|
|
44
|
-
```
|
|
45
|
-
import init from "@wasm-fmt/
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
);
|
|
46
|
+
```JavaScript
|
|
47
|
+
import init, { format } from "@wasm-fmt/graphql_fmt/vite";
|
|
48
|
+
|
|
49
|
+
// ...
|
|
59
50
|
```
|
|
60
51
|
|
|
61
52
|
</details>
|
|
62
53
|
|
|
63
|
-
|
|
54
|
+
# Configuration
|
|
64
55
|
|
|
65
56
|
See [pretty_graphql configuration docs](https://pretty-graphql.netlify.app/) for all available options.
|
package/graphql_fmt.d.ts
CHANGED
|
@@ -17,13 +17,13 @@ interface LayoutConfig {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
export function format(src: string,
|
|
20
|
+
export function format(src: string, config?: Config | null): string;
|
|
21
21
|
|
|
22
22
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
23
23
|
|
|
24
24
|
export interface InitOutput {
|
|
25
25
|
readonly memory: WebAssembly.Memory;
|
|
26
|
-
readonly format: (a: number, b: number, c: number, d: number
|
|
26
|
+
readonly format: (a: number, b: number, c: number, d: number) => void;
|
|
27
27
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
28
28
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
29
29
|
readonly __wbindgen_export3: (a: number) => void;
|
package/graphql_fmt.js
CHANGED
|
@@ -199,36 +199,33 @@ let WASM_VECTOR_LEN = 0;
|
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
201
|
* @param {string} src
|
|
202
|
-
* @param {string} filename
|
|
203
202
|
* @param {Config | null} [config]
|
|
204
203
|
* @returns {string}
|
|
205
204
|
*/
|
|
206
|
-
export function format(src,
|
|
207
|
-
let
|
|
208
|
-
let
|
|
205
|
+
export function format(src, config) {
|
|
206
|
+
let deferred3_0;
|
|
207
|
+
let deferred3_1;
|
|
209
208
|
try {
|
|
210
209
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
211
210
|
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
212
211
|
const len0 = WASM_VECTOR_LEN;
|
|
213
|
-
|
|
214
|
-
const len1 = WASM_VECTOR_LEN;
|
|
215
|
-
wasm.format(retptr, ptr0, len0, ptr1, len1, isLikeNone(config) ? 0 : addHeapObject(config));
|
|
212
|
+
wasm.format(retptr, ptr0, len0, isLikeNone(config) ? 0 : addHeapObject(config));
|
|
216
213
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
217
214
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
218
215
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
219
216
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
220
|
-
var
|
|
221
|
-
var
|
|
217
|
+
var ptr2 = r0;
|
|
218
|
+
var len2 = r1;
|
|
222
219
|
if (r3) {
|
|
223
|
-
|
|
220
|
+
ptr2 = 0; len2 = 0;
|
|
224
221
|
throw takeObject(r2);
|
|
225
222
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return getStringFromWasm0(
|
|
223
|
+
deferred3_0 = ptr2;
|
|
224
|
+
deferred3_1 = len2;
|
|
225
|
+
return getStringFromWasm0(ptr2, len2);
|
|
229
226
|
} finally {
|
|
230
227
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
231
|
-
wasm.__wbindgen_export4(
|
|
228
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
232
229
|
}
|
|
233
230
|
}
|
|
234
231
|
|
package/graphql_fmt_bg.wasm
CHANGED
|
Binary file
|
package/graphql_fmt_bg.wasm.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const format: (a: number, b: number, c: number, d: number
|
|
4
|
+
export const format: (a: number, b: number, c: number, d: number) => void;
|
|
5
5
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
6
6
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
7
7
|
export const __wbindgen_export3: (a: number) => void;
|
package/jsr.jsonc
CHANGED
package/package.json
CHANGED
|
Binary file
|