@wasm-fmt/biome_fmt 0.1.15 → 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 +36 -17
- package/biome_fmt.d.ts +21 -65
- package/biome_fmt.js +7 -565
- package/biome_fmt_bg.js +471 -0
- package/biome_fmt_bg.wasm +0 -0
- package/biome_fmt_esm.js +27 -0
- package/biome_fmt_node.js +17 -6
- package/biome_fmt_vite.js +35 -5
- package/biome_fmt_web.d.ts +44 -0
- package/biome_fmt_web.js +93 -0
- package/layout_config.d.ts +16 -0
- package/options.d.ts +41 -0
- package/package.json +28 -5
- package/jsr.jsonc +0 -34
- package/wasm-fmt-biome_fmt-0.1.15.tgz +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://github.com/wasm-fmt/web_fmt/actions/workflows/test.yml)
|
|
2
|
+
|
|
1
3
|
# Install
|
|
2
4
|
|
|
3
5
|
[](https://www.npmjs.com/package/@wasm-fmt/biome_fmt)
|
|
@@ -14,10 +16,10 @@ npx jsr add @fmt/biome-fmt
|
|
|
14
16
|
|
|
15
17
|
# Usage
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
import init, { format } from "@wasm-fmt/biome_fmt";
|
|
19
|
+
## Node.js / Deno / Bun / Bundler
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
```javascript
|
|
22
|
+
import { format } from "@wasm-fmt/biome_fmt";
|
|
21
23
|
|
|
22
24
|
const input = `function foo() {console.log("Hello, world!")}`;
|
|
23
25
|
|
|
@@ -25,28 +27,45 @@ const formatted = format(input, "app.js");
|
|
|
25
27
|
console.log(formatted);
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
## Web
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
For web environments, you need to initialize WASM module manually:
|
|
31
33
|
|
|
32
|
-
```
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
```
|
|
34
|
+
```javascript
|
|
35
|
+
import init, { format } from "@wasm-fmt/biome_fmt/web";
|
|
36
|
+
|
|
37
|
+
await init();
|
|
38
|
+
|
|
39
|
+
const input = `function foo() {console.log("Hello, world!")}`;
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const formatted = format(input, "app.js");
|
|
42
|
+
console.log(formatted);
|
|
43
|
+
```
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
### Vite
|
|
45
46
|
|
|
46
47
|
```JavaScript
|
|
47
48
|
import init, { format } from "@wasm-fmt/biome_fmt/vite";
|
|
48
49
|
|
|
50
|
+
await init();
|
|
49
51
|
// ...
|
|
50
52
|
```
|
|
51
53
|
|
|
52
|
-
|
|
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
|
+
|
|
65
|
+
See [Biome formatter configuration docs](https://biomejs.dev/reference/configuration/#formatter) for all available options.
|
|
66
|
+
|
|
67
|
+
# Credits
|
|
68
|
+
|
|
69
|
+
Thanks to:
|
|
70
|
+
|
|
71
|
+
- The [Biome](https://github.com/biomejs/biome) project
|
package/biome_fmt.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM formatter for JavaScript/TypeScript using Biome.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { format } from "@wasm-fmt/biome_fmt";
|
|
7
|
+
*
|
|
8
|
+
* const input = "const x=1";
|
|
9
|
+
* const output = format(input, "index.js");
|
|
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
|
|
|
@@ -5,22 +21,22 @@ type Mod = "" | "m" | "c";
|
|
|
5
21
|
type Lang = "j" | "t";
|
|
6
22
|
type X = "" | "x";
|
|
7
23
|
|
|
8
|
-
|
|
24
|
+
type Filename = `index.${Mod}${"t" | "j"}s${X}` | `index.d.${Mod}ts${X}` | (string & {});
|
|
9
25
|
|
|
10
26
|
/**
|
|
11
27
|
* A range in text, using UTF-8 byte offsets.
|
|
12
28
|
*/
|
|
13
29
|
export interface TextRange {
|
|
14
|
-
|
|
15
|
-
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
16
32
|
}
|
|
17
33
|
|
|
18
34
|
/**
|
|
19
35
|
* Result of formatting a range of code.
|
|
20
36
|
*/
|
|
21
37
|
export interface PrintedRange {
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
code: string;
|
|
39
|
+
source_range: TextRange;
|
|
24
40
|
}
|
|
25
41
|
|
|
26
42
|
/**
|
|
@@ -32,63 +48,3 @@ export function format(src: string, filename: Filename, config?: Config): string
|
|
|
32
48
|
* Format a range of the source code.
|
|
33
49
|
*/
|
|
34
50
|
export function formatRange(src: string, range: TextRange, filename: Filename, config?: Config): PrintedRange;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export interface Config extends LayoutConfig {
|
|
39
|
-
quoteStyle?: "double" | "single";
|
|
40
|
-
jsxQuoteStyle?: "double" | "single";
|
|
41
|
-
quoteProperties?: "preserve" | "as-needed";
|
|
42
|
-
trailingComma?: "es5" | "all" | "none";
|
|
43
|
-
semicolons?: "always" | "as-needed";
|
|
44
|
-
arrowParentheses?: "always" | "as-needed";
|
|
45
|
-
bracketSpacing?: boolean;
|
|
46
|
-
bracketSameLine?: boolean;
|
|
47
|
-
attributePosition?: "auto" | "multiline";
|
|
48
|
-
expand?: "always" | "never" | "auto";
|
|
49
|
-
operatorLinebreak?: "before" | "after";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
interface LayoutConfig {
|
|
54
|
-
indentStyle?: "tab" | "space";
|
|
55
|
-
indentWidth?: number;
|
|
56
|
-
lineWidth?: number;
|
|
57
|
-
lineEnding?: "lf" | "crlf";
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
62
|
-
|
|
63
|
-
export interface InitOutput {
|
|
64
|
-
readonly memory: WebAssembly.Memory;
|
|
65
|
-
readonly format: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
66
|
-
readonly formatRange: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
67
|
-
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
68
|
-
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
69
|
-
readonly __wbindgen_export3: (a: number) => void;
|
|
70
|
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
71
|
-
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
78
|
-
* a precompiled `WebAssembly.Module`.
|
|
79
|
-
*
|
|
80
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
81
|
-
*
|
|
82
|
-
* @returns {InitOutput}
|
|
83
|
-
*/
|
|
84
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
88
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
89
|
-
*
|
|
90
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
91
|
-
*
|
|
92
|
-
* @returns {Promise<InitOutput>}
|
|
93
|
-
*/
|
|
94
|
-
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|