@wasm-fmt/graphql_fmt 0.0.0 → 0.2.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/README.md +51 -45
- package/graphql_fmt.d.ts +21 -50
- package/graphql_fmt.js +7 -512
- package/graphql_fmt_bg.js +416 -0
- package/graphql_fmt_bg.wasm +0 -0
- package/graphql_fmt_bg.wasm.d.ts +1 -1
- package/graphql_fmt_esm.js +27 -0
- package/graphql_fmt_node.js +17 -6
- package/graphql_fmt_vite.js +35 -5
- package/graphql_fmt_web.d.ts +44 -0
- package/graphql_fmt_web.js +93 -0
- package/layout_config.d.ts +16 -0
- package/options.d.ts +157 -0
- package/package.json +28 -5
- package/jsr.jsonc +0 -33
package/README.md
CHANGED
|
@@ -1,65 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://github.com/wasm-fmt/web_fmt/actions/workflows/test.yml)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Install
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@wasm-fmt/graphql_fmt)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
import init from "graphql_fmt";
|
|
7
|
+
```bash
|
|
8
|
+
npm install @wasm-fmt/graphql_fmt
|
|
9
|
+
```
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
[](https://jsr.io/@fmt/graphql-fmt)
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"query.graphql",
|
|
17
|
-
{
|
|
18
|
-
indentStyle: "space",
|
|
19
|
-
indentWidth: 2,
|
|
20
|
-
lineWidth: 80,
|
|
21
|
-
lineEnding: "lf",
|
|
22
|
-
}
|
|
23
|
-
);
|
|
13
|
+
```bash
|
|
14
|
+
npx jsr add @fmt/graphql-fmt
|
|
24
15
|
```
|
|
25
16
|
|
|
26
|
-
|
|
17
|
+
# Usage
|
|
18
|
+
|
|
19
|
+
## Node.js / Deno / Bun / Bundler
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
```javascript
|
|
22
|
+
import { format } from "@wasm-fmt/graphql_fmt";
|
|
29
23
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
24
|
+
const input = `query { user { name } }`;
|
|
25
|
+
|
|
26
|
+
const formatted = format(input);
|
|
27
|
+
console.log(formatted);
|
|
36
28
|
```
|
|
37
29
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
## Web
|
|
31
|
+
|
|
32
|
+
For web environments, you need to initialize WASM module manually:
|
|
41
33
|
|
|
42
|
-
|
|
34
|
+
```javascript
|
|
35
|
+
import init, { format } from "@wasm-fmt/graphql_fmt/web";
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
import init from "@wasm-fmt/graphql-fmt/vite";
|
|
37
|
+
await init();
|
|
46
38
|
|
|
47
|
-
const {
|
|
39
|
+
const input = `query { user { name } }`;
|
|
48
40
|
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
"query.graphql",
|
|
52
|
-
{
|
|
53
|
-
indentStyle: "space",
|
|
54
|
-
indentWidth: 2,
|
|
55
|
-
lineWidth: 80,
|
|
56
|
-
lineEnding: "lf",
|
|
57
|
-
}
|
|
58
|
-
);
|
|
41
|
+
const formatted = format(input);
|
|
42
|
+
console.log(formatted);
|
|
59
43
|
```
|
|
60
44
|
|
|
61
|
-
|
|
45
|
+
### Vite
|
|
62
46
|
|
|
63
|
-
|
|
47
|
+
```JavaScript
|
|
48
|
+
import init, { format } from "@wasm-fmt/graphql_fmt/vite";
|
|
49
|
+
|
|
50
|
+
await init();
|
|
51
|
+
// ...
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Entry Points
|
|
55
|
+
|
|
56
|
+
- `.` - Auto-detects environment (Node.js uses node, Webpack uses bundler, default is ESM)
|
|
57
|
+
- `./node` - Node.js environment (no init required)
|
|
58
|
+
- `./esm` - ESM environments like Deno (no init required)
|
|
59
|
+
- `./bundler` - Bundlers like Webpack (no init required)
|
|
60
|
+
- `./web` - Web browsers (requires manual init)
|
|
61
|
+
- `./vite` - Vite bundler (requires manual init)
|
|
62
|
+
|
|
63
|
+
# Configuration
|
|
64
64
|
|
|
65
65
|
See [pretty_graphql configuration docs](https://pretty-graphql.netlify.app/) for all available options.
|
|
66
|
+
|
|
67
|
+
# Credits
|
|
68
|
+
|
|
69
|
+
Thanks to:
|
|
70
|
+
|
|
71
|
+
- The [pretty_graphql](https://github.com/g-plane/pretty_graphql) project
|
package/graphql_fmt.d.ts
CHANGED
|
@@ -1,54 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM formatter for GraphQL using pretty_graphql.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { format } from "@wasm-fmt/graphql_fmt";
|
|
7
|
+
*
|
|
8
|
+
* const input = "{ hello }";
|
|
9
|
+
* const output = format(input);
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { Config } from "./options.d.ts";
|
|
16
|
+
|
|
1
17
|
/* tslint:disable */
|
|
2
18
|
/* eslint-disable */
|
|
3
19
|
|
|
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
20
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
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>;
|
|
21
|
+
* Formats the given GraphQL code with the provided Configuration.
|
|
22
|
+
* @param src - The GraphQL code to format
|
|
23
|
+
* @param config - Optional formatter config
|
|
24
|
+
*/
|
|
25
|
+
export function format(src: string, config?: Config | null): string;
|