annealer 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +124 -2
- package/dist/index.d.ts +41 -0
- package/dist/index.es.js +295 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +11 -0
- package/dist/types/FormatOptions.d.ts +31 -0
- package/dist/types/Language.d.ts +14 -0
- package/dist/types/Meta.d.ts +18 -0
- package/dist/wasm/binary.d.ts +11 -0
- package/package.json +94 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Masashi Yoshikawa <https://logue.dev>
|
|
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
CHANGED
|
@@ -1,3 +1,125 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Annealer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/annealer)
|
|
4
|
+
[](https://www.npmjs.com/package/annealer)
|
|
5
|
+
[](https://crates.io/crates/annealer)
|
|
6
|
+
[](https://www.jsdelivr.com/package/npm/annealer)
|
|
7
|
+
[](https://uiwjs.github.io/npm-unpkg/#/pkg/annealer/file/README.md)
|
|
8
|
+
[](https://gitpod.io/#https://github.com/logue/annealer)
|
|
9
|
+
[](https://twitter.com/logue256)
|
|
10
|
+
[](https://github.com/sponsors/logue)
|
|
11
|
+
|
|
12
|
+
Reorders HTML and Vue attributes, Tailwind class names and stylesheet
|
|
13
|
+
declarations **by meaning**, using swappable YAML profiles.
|
|
14
|
+
|
|
15
|
+
> **Alpha (0.1.0-alpha.1).** Until 1.0, a release can change the output for the
|
|
16
|
+
> same input. Pin the exact version and review the diff when you upgrade.
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<!-- Input -->
|
|
20
|
+
<a title="Home" href="/" id="home">Home</a>
|
|
21
|
+
|
|
22
|
+
<!-- Output (html profile) -->
|
|
23
|
+
<a id="home" title="Home" href="/">Home</a>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Try it in the [Playground](https://logue.dev/annealer/playground), or read the
|
|
27
|
+
[documentation](https://logue.dev/annealer/).
|
|
28
|
+
|
|
29
|
+
## Why
|
|
30
|
+
|
|
31
|
+
Attribute order is a code-review problem, not a cosmetic one. Without a rule,
|
|
32
|
+
edits reshuffle attribute lists and diffs fill up with lines that did not really
|
|
33
|
+
change. annealer orders attributes by the role they play: identity first, then
|
|
34
|
+
what an element is and does, supplementary meaning, ARIA, data, and events.
|
|
35
|
+
|
|
36
|
+
None of the tools I evaluated (Biome, rslint, oxlint, oxfmt, markup_fmt)
|
|
37
|
+
reorders Vue/HTML attributes by meaning, so annealer fills that gap. See
|
|
38
|
+
[Introduction](https://logue.dev/annealer/guide/start/introduction) for the
|
|
39
|
+
reasoning and how it relates to `vue/attributes-order`.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Semantic attribute order** for HTML and Vue 3 templates.
|
|
44
|
+
- **A superset of `vue/attributes-order`**: same tiers, plus same-name
|
|
45
|
+
clustering (`class` next to `:class`) and ARIA sub-ordering.
|
|
46
|
+
- **Stylesheets** (CSS, SCSS, Sass, Less) through [malva](https://github.com/g-plane/malva).
|
|
47
|
+
- **Tailwind class order** (opt-in), following Tailwind's own order.
|
|
48
|
+
- **Bootstrap 6 class order** (opt-in, experimental): annealer's own proposal for
|
|
49
|
+
Bootstrap 6 (alpha), derived from its CSS. Not an official Bootstrap order.
|
|
50
|
+
- **YAML profiles**, validated by a JSON Schema; unknown keys are rejected.
|
|
51
|
+
- **Disable directives** (`annealer-disable`, `annealer-enable`,
|
|
52
|
+
`annealer-disable-next-line`) keep selected code exactly as written.
|
|
53
|
+
- **One Rust core** with a CLI (`anyl`), a Rust crate, and an npm package with a
|
|
54
|
+
synchronous WebAssembly API.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
annealer ships in two forms. Pick the one that matches how you want to use it.
|
|
59
|
+
|
|
60
|
+
### CLI (`anyl`) — Rust crate
|
|
61
|
+
|
|
62
|
+
The command-line tool is distributed as a Rust crate only. You need a
|
|
63
|
+
[Rust toolchain](https://rustup.rs/); `cargo install` builds it from source.
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
cargo install annealer --version 0.1.0-alpha.1
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The npm package does **not** include the `anyl` command, so
|
|
70
|
+
`pnpm add -D annealer` will not give you a CLI.
|
|
71
|
+
|
|
72
|
+
### JavaScript API — npm package (WebAssembly)
|
|
73
|
+
|
|
74
|
+
For build tools, scripts and editors. This is a library only; there is no
|
|
75
|
+
binary.
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
pnpm add -D annealer@0.1.0-alpha.1
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Pre-release versions are not picked up by ranges such as `^0.1.0`, so name the
|
|
82
|
+
version in both cases.
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
### CLI
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
anyl src/App.vue # print the result
|
|
90
|
+
anyl --write "src/**/*.vue" # format in place
|
|
91
|
+
anyl --check index.html # exit 1 if a file would change
|
|
92
|
+
anyl --profile my-profile.yaml page.html
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### JavaScript
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
import { format } from 'annealer';
|
|
99
|
+
|
|
100
|
+
format('<a title="Home" href="/" id="home">Home</a>');
|
|
101
|
+
// => '<a id="home" title="Home" href="/">Home</a>'
|
|
102
|
+
|
|
103
|
+
format(source, { language: 'vue' });
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Run annealer **before** your formatter (Prettier, oxfmt, Biome, `rs fmt`); none
|
|
107
|
+
of them reorders attributes, so they keep annealer's order. See
|
|
108
|
+
[Using with other tools](https://logue.dev/annealer/guide/start/integration).
|
|
109
|
+
|
|
110
|
+
## Limitations
|
|
111
|
+
|
|
112
|
+
annealer reads start tags with a lexer; it does not build a DOM, validate HTML
|
|
113
|
+
or reflow text. Inline SVG, MathML and RDF are left as written. Pug and Stylus
|
|
114
|
+
are not supported. See
|
|
115
|
+
[Limitations](https://logue.dev/annealer/guide/start/limitations) for the full
|
|
116
|
+
list.
|
|
117
|
+
|
|
118
|
+
## Feedback
|
|
119
|
+
|
|
120
|
+
This is an early release and the profile format can still change. Issues and
|
|
121
|
+
discussion are welcome on GitHub.
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
©2026 by Logue. Licensed under the [MIT License](LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* annealer
|
|
3
|
+
*
|
|
4
|
+
* @description Reorders HTML/Vue attributes by semantic meaning using swappable YAML profiles.
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @version 0.2.0
|
|
8
|
+
* @see {@link https://github.com/logue/annealer}
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { FormatOptions } from './types/FormatOptions.js';
|
|
12
|
+
import { Language } from './types/Language.js';
|
|
13
|
+
export { FormatOptions } from './types/FormatOptions.js';
|
|
14
|
+
export { Language } from './types/Language.js';
|
|
15
|
+
export { Meta } from './types/Meta.js';
|
|
16
|
+
/** Built-in profile names. */
|
|
17
|
+
export type BuiltinProfile = 'html' | 'vue';
|
|
18
|
+
/** Built-in class order names. */
|
|
19
|
+
export type BuiltinClassOrder = 'tailwind' | 'bootstrap';
|
|
20
|
+
/**
|
|
21
|
+
* Compiles the WebAssembly core ahead of the first `format` call without
|
|
22
|
+
* blocking. Optional: `format` compiles it synchronously when needed.
|
|
23
|
+
*/
|
|
24
|
+
export declare const init: () => Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Reorders attributes (HTML, Vue) or declarations (CSS, SCSS, Sass, Less)
|
|
27
|
+
* by semantic meaning, and optionally the classes of static `class`
|
|
28
|
+
* attributes (`classOrder`).
|
|
29
|
+
*
|
|
30
|
+
* @throws {Error} when the input or the profile is invalid.
|
|
31
|
+
*/
|
|
32
|
+
export declare const format: (input: string, options?: FormatOptions) => string;
|
|
33
|
+
/** Infers the language from a file name or path. */
|
|
34
|
+
export declare const languageFromPath: (path: string) => Language | undefined;
|
|
35
|
+
/** The YAML text of a built-in profile, as a starting point for a custom one. */
|
|
36
|
+
export declare const builtinProfile: (name: BuiltinProfile) => string;
|
|
37
|
+
/**
|
|
38
|
+
* The YAML text of a built-in class order, as a starting point for a custom
|
|
39
|
+
* one.
|
|
40
|
+
*/
|
|
41
|
+
export declare const builtinClassOrder: (name: BuiltinClassOrder) => string;
|