yuhwa 0.0.1 → 1.0.1

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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +234 -121
  3. package/dist/astro.d.ts +3 -3
  4. package/dist/astro.js +2 -2
  5. package/dist/browser.d.ts +3 -3
  6. package/dist/browser.js +18 -9
  7. package/dist/cli.js +72 -10942
  8. package/dist/editor/assets/{index-BWzT0Wd7.js → index-B1-eRTKY.js} +39 -39
  9. package/dist/editor/assets/{lsp.worker-DSWloYB1.js → lsp.worker-C79O_uwt.js} +1 -1
  10. package/dist/editor/index.html +4 -7
  11. package/dist/{figure-CYW54wev.d.ts → figure-Cp1kIReq.d.ts} +3 -3
  12. package/dist/{index-PDbKFm2X.d.ts → index-DY1ZuIhZ.d.ts} +17 -17
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.js +1 -1
  15. package/dist/ironmark.d.ts +4 -4
  16. package/dist/ironmark.js +1 -1
  17. package/dist/lsp-browser.d.ts +3 -0
  18. package/dist/lsp-browser.js +343 -0
  19. package/dist/lsp-client.d.ts +34 -0
  20. package/dist/lsp-client.js +98 -0
  21. package/dist/lsp-node.js +11781 -0
  22. package/dist/lsp-server.d.ts +10 -0
  23. package/dist/lsp-server.js +1 -0
  24. package/dist/lsp.d.ts +16 -0
  25. package/dist/lsp.js +1 -0
  26. package/dist/main-DYrwpkoa.d.ts +3280 -0
  27. package/dist/markdown-it.d.ts +3 -3
  28. package/dist/markdown-it.js +1 -1
  29. package/dist/{node-DBf7JVVp.js → node-D5c2mPhI.js} +4 -4
  30. package/dist/remark.d.ts +5 -5
  31. package/dist/remark.js +5 -5
  32. package/dist/server--6FqJ1gI.js +9889 -0
  33. package/dist/server-DJC_fQMe.d.ts +5892 -0
  34. package/dist/service-ClZ8clSQ.d.ts +71 -0
  35. package/dist/service-DDbTh7nO.js +930 -0
  36. package/dist/shared-CEPwGvSm.js +10915 -0
  37. package/dist/{src-BNOnUjQh.js → src-Dl2VCr7N.js} +30 -15
  38. package/dist/vite.d.ts +3 -3
  39. package/dist/vite.js +2 -2
  40. package/dist/vuepress.d.ts +3 -3
  41. package/dist/yuhwa.iife.js +51 -51
  42. package/package.json +30 -5
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ph1p
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,172 +1,285 @@
1
+ <div align="center">
2
+
3
+ <img src="https://raw.githubusercontent.com/ph1p/yuhwa/main/.github/assets/logo.svg" width="72" alt="" />
4
+
1
5
  # yuhwa
2
6
 
3
- Diagrams that look good and stay where you put them.
7
+ **Text diagrams that look good and stay where you put them.**
8
+
9
+ A few lines of text become a clean SVG. A friendlier alternative to Mermaid,
10
+ with a visual editor that writes your tweaks back into the source.
11
+
12
+ [![npm](https://img.shields.io/npm/v/yuhwa?color=2563eb)](https://www.npmjs.com/package/yuhwa)
13
+ [![license](https://img.shields.io/npm/l/yuhwa?color=9333ea)](https://github.com/ph1p/yuhwa/blob/main/LICENSE)
14
+ ![dependencies](https://img.shields.io/badge/runtime%20deps-0-16a34a)
15
+
16
+ [**Try it in the browser**](https://ph1p.github.io/yuhwa/editor/) ·
17
+ [Docs](https://ph1p.github.io/yuhwa/) ·
18
+ [Syntax](https://ph1p.github.io/yuhwa/guide/syntax) ·
19
+ [Examples](https://ph1p.github.io/yuhwa/guide/examples)
20
+
21
+ <br />
22
+
23
+ <picture>
24
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ph1p/yuhwa/main/.github/assets/hero-dark.svg" />
25
+ <img src="https://raw.githubusercontent.com/ph1p/yuhwa/main/.github/assets/hero-light.svg" alt="How yuhwa works: write text in a window, render it in the terminal, ship the SVG to the browser, tweak it in the visual editor; below it sequence, chart, mindmap, kanban and timeline panels from the same file" width="820" />
26
+ </picture>
4
27
 
5
- yuhwa is a text diagram language for Markdown and documentation, built as a
6
- friendlier alternative to Mermaid.
28
+ </div>
7
29
 
8
- **[Documentation](apps/docs/index.md)** ·
9
- **[Editor](apps/docs/guide/editor.md)** ·
10
- **[Syntax](apps/docs/guide/syntax.md)**
30
+ <details>
31
+ <summary><b>The source of this picture</b>: one <code>.yuhwa</code> file</summary>
11
32
 
12
33
  ```yuhwa
13
- title: Checkout flow
34
+ title: How **yuhwa** works
35
+ subtitle: one text file: graphs, windows, charts, sequences and more
36
+ direction: right
37
+ panels: wrap
38
+ legend: .tool yuhwa | .you You | --> live | ..> writes back
39
+ footer: `npx yuhwa render` | 0 runtime deps | light + dark | {green: 0 diagnostics}
40
+
41
+ .tool [blue]
42
+ .you [purple]
43
+
44
+ src "1. Write text" .you [frame: window diagram.yuhwa] {
45
+ web -> api -> db
46
+ db [cylinder, amber]
47
+ api -> cache: read [dashed]
48
+ }
49
+
50
+ group yuhwa "yuhwa" [blue, dashed] {
51
+ cli "2. Render" .tool [frame: terminal ~/docs, meta: 1ms] {
52
+ $$ yuhwa render diagram.yuhwa
53
+ ✓ parse || [[green: ok]]
54
+ ✓ layout || [[green: ok]]
55
+ ✓ route || [[green: ok]]
56
+ }
57
+ lsp "Language server" .tool [hexagon, sub: "check, hover, format"]
58
+ }
14
59
 
15
- .svc [blue]
16
- .store [cylinder, amber]
60
+ site "3. Ship the SVG" [frame: browser docs.example.com, green] {
61
+ stat: 0 deps | 12 themes | 100% text
62
+ ---
63
+ spark green: 3 5 4 6 8 7 9 12
64
+ }
17
65
 
18
- user "Customer" [circle, purple]
66
+ edit "Tweak visually" [frame: window yuhwa edit, amber] {
67
+ drag boxes || [[green: on]]
68
+ bend edges || [[green: on]]
69
+ recolour || [[green: on]]
70
+ }
19
71
 
20
- group core "Core services" [blue] {
21
- cart "Cart" .svc
22
- orders "Orders" .svc
23
- pay "Payments" .svc [green]
72
+ src -> cli
73
+ src -> lsp: as you type
74
+ cli -> site: SVG [flow]
75
+ cli --> edit: live preview
76
+ edit ..> src: "writes layout { }"
77
+
78
+ sequence save "Saving a drag" [numbered] {
79
+ actor you "You" [purple]
80
+ you -> editor: drag a box
81
+ editor -> file: write layout { }
82
+ file --> editor: re-render
24
83
  }
25
84
 
26
- user -> cart: add item
27
- user -> orders: checkout
28
- orders -> pay: [flow]
29
- cart, orders -> db "Postgres" .store
85
+ chart speed "Render time" [type: column, unit: ms] {
86
+ checkout [blue]: 0.6
87
+ this picture [purple]: 1.0
88
+ showcase [green]: 2.7
89
+ }
90
+
91
+ mindmap kinds "One language" {
92
+ yuhwa
93
+ graphs
94
+ panels
95
+ sequence
96
+ gantt
97
+ kanban
98
+ cards
99
+ }
100
+
101
+ kanban plan "Docs to draw" {
102
+ Todo
103
+ - auth flow
104
+ - deploy pipeline
105
+ Doing
106
+ - login sequence
107
+ Done
108
+ - architecture
109
+ - README hero
110
+ }
111
+
112
+ timeline ship "Ship it" [direction: right] {
113
+ write [purple]: source
114
+ check [blue]: 0 errors
115
+ tweak [amber]: drag
116
+ render [green]: SVG
117
+ }
30
118
  ```
31
119
 
32
- - **Readable by default.** Clean auto-layout, soft colours, twelve themes, or define your own.
33
- - **More than flowcharts.** Sequence diagrams, timelines, charts and git
34
- branch histories sit next to the graph in one file. `import` splits a
35
- diagram over files.
36
- - **Presentation-ready.** Cards with charts, stats, progress bars and tables,
37
- browser and terminal window frames, footers. All of it as plugins.
38
- - **Styleable everywhere.** Tones, shapes, borders, icons, line styles, arrow
39
- heads and animation, with reusable classes.
40
- - **Hand-tunable.** Drag boxes and bend edges in the visual editor. Positions
41
- are written back into the source as a small `layout {}` block. The editor
42
- also imports Mermaid and JSON and holds several files as tabs.
43
- - **Made for AI agents.** `yuhwa guide` prints the language reference and
44
- `yuhwa check --json` returns diagnostics that name the fix.
45
- - **Embeds anywhere.** A script tag, a web component, an ES module, an image
46
- URL service, or static SVGs for GitHub via `yuhwa md`.
47
- - **Speaks Mermaid.** Mermaid flowcharts render as-is and convert to yuhwa.
48
- - **No runtime dependencies.** TypeScript, deterministic output.
120
+ </details>
121
+
122
+ ## Get started
123
+
124
+ **1. Try it without installing.** Open the
125
+ [visual editor](https://ph1p.github.io/yuhwa/editor/), paste the source of the picture
126
+ above and change something. Drag a box and watch the source update.
127
+
128
+ **2. Render your first diagram.** No install needed: `npx` or `pnpm dlx`
129
+ fetch the CLI (Node.js 22+):
130
+
131
+ ```bash
132
+ echo 'web "Web app" -> api "API" -> db "Postgres" [cylinder]' > hello.yuhwa
49
133
 
50
- ## Quick start
134
+ npx yuhwa render hello.yuhwa -o hello.svg # npm
135
+ pnpm dlx yuhwa render hello.yuhwa -o hello.svg # pnpm
136
+ ```
137
+
138
+ **3. Edit it visually and check it:**
139
+
140
+ ```bash
141
+ npx yuhwa edit hello.yuhwa # visual editor, saves back to the file
142
+ npx yuhwa check hello.yuhwa # diagnostics, exit 1 on errors
143
+ ```
51
144
 
52
- Node.js 20 or later.
145
+ **4. Keep it around.** Install globally to drop the `npx`, or add it to a
146
+ project:
53
147
 
54
- ```sh
55
- npm install -g yuhwa
56
- echo 'web -> api -> db [cylinder]' > hello.yuhwa
57
- yuhwa render hello.yuhwa -o hello.svg # SVG
58
- yuhwa check hello.yuhwa # diagnostics, exit 1 on errors
59
- yuhwa edit hello.yuhwa # visual editor, saves back to the file
60
- yuhwa md README.md # render the diagrams in a Markdown file
148
+ ```bash
149
+ npm install -g yuhwa # or: pnpm add -g yuhwa
150
+ pnpm add -D yuhwa # or: npm install -D yuhwa
61
151
  ```
62
152
 
63
- Or skip the install: `npx yuhwa <command>`. Step by step:
64
- [getting started](apps/docs/guide/getting-started.md).
153
+ ### The syntax in 30 seconds
154
+
155
+ ```yuhwa
156
+ direction: right // a setting
157
+ .svc [blue] // a class
158
+ api "Orders API" .svc // a node: id, label, class
159
+ db [cylinder, amber] // props in brackets
160
+ api -> db: SQL [dashed] // an edge with a label and props
161
+ group core "Core" { api } // a group
162
+ ```
163
+
164
+ Arrows: `->` solid, `-->` dashed, `..>` dotted, `=>` thick, `<->` both ways.
165
+ Full reference: [syntax](https://ph1p.github.io/yuhwa/guide/syntax) ·
166
+ [cheatsheet](https://ph1p.github.io/yuhwa/guide/cheatsheet).
167
+
168
+ ## Why yuhwa
169
+
170
+ - **Looks good with zero styling.** Clean auto-layout, curved routing, soft
171
+ colours. Twelve built-in themes, or define your own in a `theme { }` block.
172
+ - **Layout you control.** Drag boxes and bend edges in the visual editor.
173
+ Positions land in the source as a small `layout { }` block, so the diagram
174
+ stays put on every re-render and in every diff.
175
+ - **One language, every diagram.** Flowcharts, sequence, timeline, gantt,
176
+ kanban, mindmap, quadrant, git history and charts, side by side in one file.
177
+ - **Built for docs.** Plugins for VitePress, Astro, Docusaurus, VuePress, MDX
178
+ and more. Light and dark variants, and a broken diagram fails the build.
179
+ - **Built for AI agents.** `yuhwa guide` prints the language reference.
180
+ `yuhwa check --json` returns diagnostics that name the fix.
181
+ - **Speaks Mermaid.** Mermaid flowcharts render as-is and convert to yuhwa.
182
+ - **Small and deterministic.** TypeScript, no runtime dependencies, same
183
+ input gives the same SVG.
184
+
185
+ <details>
186
+ <summary><b>See everything in one file</b> (the editor's <i>Everything</i> template)</summary>
187
+ <br />
188
+ <img src="https://raw.githubusercontent.com/ph1p/yuhwa/main/.github/assets/showcase.svg" alt="yuhwa showcase: a service graph with cards, plus sequence, chart, quadrant, gantt, timeline, kanban, git and mindmap panels" />
189
+ </details>
190
+
191
+ ## Use it anywhere
192
+
193
+ **In the browser**
65
194
 
66
195
  ```html
67
196
  <script src="https://cdn.jsdelivr.net/npm/yuhwa/dist/yuhwa.iife.js"></script>
68
197
  <yuhwa-diagram>web -> api -> db [shape: cylinder]</yuhwa-diagram>
69
198
  ```
70
199
 
200
+ **From JavaScript**
201
+
71
202
  ```js
72
203
  import { render } from 'yuhwa';
204
+
73
205
  const { svg, diagnostics } = render('a -> b -> c', { theme: 'midnight' });
74
206
  ```
75
207
 
76
- ## Docs sites
77
-
78
- Write ` ```yuhwa ` blocks in Markdown. A build plugin turns them into SVG
79
- figures with light and dark variants, and a broken diagram fails the build.
80
-
81
- | site generator | plugin |
82
- | --- | --- |
83
- | VitePress, Eleventy, any markdown-it | `yuhwa/markdown-it` |
84
- | VuePress 2 | `yuhwa/vuepress` |
85
- | Astro, Starlight | `yuhwa/astro` |
86
- | Docusaurus, Vocs, Nextra, Fumadocs, Rspress, any MDX | `yuhwa/remark` |
87
- | ironmark (`.md`, `.mdx`, runtime) | `yuhwa/ironmark` |
88
- | Vite apps (React, Vue, Svelte, Solid) | `yuhwa/vite` |
89
- | Docsify, Hugo, Jekyll | the script tag |
90
- | GitHub, GitLab | `yuhwa md` writes SVG files |
91
-
92
- Setup for each: [integrations](apps/docs/guide/integrations.md).
93
-
94
- ## AI agents
208
+ `render()` never throws. Problems come back as `diagnostics` with line, message and severity.
95
209
 
96
- ```sh
97
- npx yuhwa guide # language reference, written for agents
98
- npx yuhwa check x.yuhwa --json # diagnostics that name the fix
99
- ```
210
+ **In Markdown on GitHub or GitLab**: `npx yuhwa md README.md` renders every
211
+ ` ```yuhwa ` block to an SVG file and links it in ([details](https://ph1p.github.io/yuhwa/guide/markdown)).
100
212
 
101
- Rules-file and skill snippets: [ai](apps/docs/guide/ai.md).
102
- Quick reference: [cheatsheet](apps/docs/guide/cheatsheet.md).
213
+ **In docs sites**: `pnpm add -D yuhwa`, write ` ```yuhwa ` blocks, get SVG
214
+ figures at build time.
103
215
 
104
- ## Editors
216
+ | site generator | plugin |
217
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
218
+ | [VitePress](https://ph1p.github.io/yuhwa/guide/integrations#vitepress), [Eleventy](https://ph1p.github.io/yuhwa/guide/integrations#eleventy), any markdown-it | `yuhwa/markdown-it` |
219
+ | [VuePress 2](https://ph1p.github.io/yuhwa/guide/integrations#vuepress) | `yuhwa/vuepress` |
220
+ | [Astro, Starlight](https://ph1p.github.io/yuhwa/guide/integrations#astro-and-starlight) | `yuhwa/astro` |
221
+ | [Docusaurus](https://ph1p.github.io/yuhwa/guide/integrations#docusaurus), [Vocs](https://ph1p.github.io/yuhwa/guide/integrations#vocs), [Nextra](https://ph1p.github.io/yuhwa/guide/integrations#nextra), [Fumadocs](https://ph1p.github.io/yuhwa/guide/integrations#fumadocs), [Rspress](https://ph1p.github.io/yuhwa/guide/integrations#rspress), any MDX | `yuhwa/remark` |
222
+ | [ironmark](https://ph1p.github.io/yuhwa/guide/integrations#ironmark) | `yuhwa/ironmark` |
223
+ | [Vite apps](https://ph1p.github.io/yuhwa/guide/integrations#vite-apps) (React, Vue, Svelte, Solid) | `yuhwa/vite` |
224
+ | [Docsify](https://ph1p.github.io/yuhwa/guide/integrations#docsify), [Hugo](https://ph1p.github.io/yuhwa/guide/integrations#hugo), [Jekyll, plain HTML](https://ph1p.github.io/yuhwa/guide/integrations#jekyll-and-plain-html) | the script tag |
105
225
 
106
- `yuhwa-lsp` is a language server: diagnostics, quick fixes,
107
- completion, hover, rename, formatting and colouring.
226
+ VitePress, for example:
108
227
 
109
- - **VS Code, Cursor, VSCodium:** `pnpm --filter ./packages/vscode package`, then
110
- `code --install-extension packages/vscode/yuhwa.vsix`. The server is
111
- bundled.
112
- - **Neovim, Helix, Sublime, Emacs, JetBrains, Vim, Kate:** install the
113
- server, then point the editor at `yuhwa-lsp --stdio` for `.yuhwa` files.
228
+ ```ts
229
+ // .vitepress/config.ts
230
+ import { defineConfig } from 'vitepress';
231
+ import yuhwa from 'yuhwa/markdown-it';
114
232
 
115
- ```sh
116
- npm install -g yuhwa-lsp
117
- yuhwa-lsp --version
233
+ export default defineConfig({
234
+ markdown: { config: (md) => md.use(yuhwa) },
235
+ });
118
236
  ```
119
237
 
120
- Config snippet per editor and troubleshooting:
121
- [editor setup](apps/docs/guide/lsp.md).
238
+ Add `import 'yuhwa/style.css'` to `.vitepress/theme/index.ts`. Other tools:
239
+ [how the plugins work](https://ph1p.github.io/yuhwa/guide/integrations#what-the-plugins-do) and
240
+ [anything else](https://ph1p.github.io/yuhwa/guide/integrations#something-else).
122
241
 
123
- ## Development
242
+ Also: an [HTTP render service](https://ph1p.github.io/yuhwa/guide/embedding) for `<img src>` URLs.
124
243
 
125
- ```sh
126
- pnpm install
127
- pnpm dev # editor with hot reload
128
- pnpm docs:dev # documentation site
129
- pnpm check # typecheck, tests, build
130
- pnpm docs:build # library, editor and docs into apps/docs/.vitepress/dist
131
- ```
244
+ ## For AI agents
132
245
 
133
- A pnpm workspace. `packages/core` and `packages/lsp` are published.
134
- The apps import them and read their `src` through the `yuhwa-source` export
135
- condition, so changes show up without a package build.
246
+ ```bash
247
+ npx yuhwa guide # language reference, written for agents
248
+ npx yuhwa check x.yuhwa --json # diagnostics that name the fix
249
+ ```
136
250
 
137
- | path | contents |
138
- | --- | --- |
139
- | `packages/core/src/core` | parser, linter, layout, router, SVG renderer |
140
- | `packages/core/src/plugins` | built-in plugins: themes, card rows, tables, frames, footer, and the sequence, timeline, chart and git panels |
141
- | `packages/core/src/convert` | Mermaid and JSON input |
142
- | `packages/core/src/integrations` | docs-site plugins (markdown-it, remark, Astro, VuePress, Vite, ironmark) |
143
- | `packages/core/src/cli` | CLI and HTTP render service |
144
- | `packages/core/src/browser.ts` | script build and `<yuhwa-diagram>` |
145
- | `packages/lsp` | language server, for editors and the browser |
146
- | `apps/editor` | visual editor (Vite); builds into `packages/core/dist/editor` |
147
- | `apps/docs` | documentation site (VitePress) |
251
+ Point your agent at `yuhwa guide`, let it write source, loop on `check --json`
252
+ until clean. The docs site also serves `llms.txt` and `llms-full.txt`.
253
+ Rules-file and skill snippets: [AI guide](https://ph1p.github.io/yuhwa/guide/ai).
148
254
 
149
- ### Releases
255
+ ## Editor support
150
256
 
151
- [semantic-release](https://semantic-release.gitbook.io/) publishes from `main`. Write [conventional commits](https://www.conventionalcommits.org/):
257
+ `yuhwa-lsp` ships with the `yuhwa` package: diagnostics, quick fixes,
258
+ completion, hover, rename, formatting and semantic colouring.
152
259
 
153
- - `feat:` publishes a minor version.
154
- - `fix:`, `perf:`, `refactor:` and `revert:` publish a patch version.
155
- - `feat!:` or a `BREAKING CHANGE:` footer publishes a major version.
156
- - `docs:`, `chore:`, `test:` and `ci:` publish nothing.
260
+ - **VS Code, Cursor, VSCodium:** the extension in [`packages/vscode`](https://github.com/ph1p/yuhwa/blob/main/packages/vscode) bundles the server.
261
+ - **Zed:** extension in [`packages/zed`](https://github.com/ph1p/yuhwa/blob/main/packages/zed).
262
+ - **Neovim, Helix, Sublime, Emacs, JetBrains, Vim, Kate:** point the editor at `yuhwa-lsp --stdio` for `.yuhwa` files.
157
263
 
158
- All three packages share one version. Each push to `main` runs CI first. When a commit warrants a release, the release job:
264
+ Per-editor config: [editor setup](https://ph1p.github.io/yuhwa/guide/lsp).
159
265
 
160
- 1. sets the version in `packages/core`, `packages/lsp` and `packages/vscode`, and builds,
161
- 2. publishes `yuhwa` and `yuhwa-lsp` to npm through trusted publishing (no token),
162
- 3. publishes the extension to the VS Code Marketplace (skipped while `VSCE_PAT` is unset),
163
- 4. tags `vX.Y.Z` and writes a GitHub release with the `.vsix` attached,
164
- 5. commits the new version back to the three `package.json` files,
165
- 6. redeploys the docs.
266
+ ## Contributing
166
267
 
167
- `scripts/release.mjs` does steps 1 to 3.
268
+ ```bash
269
+ pnpm install
270
+ pnpm dev # visual editor with hot reload
271
+ pnpm docs:dev # docs site
272
+ pnpm check # lint, format, typecheck, tests, build (what CI runs)
273
+ ```
168
274
 
169
- `pnpm release:dry` previews the next version.
275
+ | path | contents |
276
+ | ---------------------- | ------------------------------------------------------------------------------------------ |
277
+ | `packages/core` | library, CLI, language server: parser, layout, router, SVG renderer, plugins, integrations |
278
+ | `packages/vscode` | VS Code extension and TextMate grammar |
279
+ | `packages/tree-sitter` | tree-sitter grammar |
280
+ | `packages/zed` | Zed extension |
281
+ | `apps/editor` | visual editor (Vite), served by `yuhwa edit` |
282
+ | `apps/docs` | docs site (VitePress) |
170
283
 
171
284
  ## License
172
285
 
package/dist/astro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as yuhwaDocsOptions } from "./figure-CYW54wev.js";
1
+ import { t as YuhwaDocsOptions } from "./figure-Cp1kIReq.js";
2
2
  interface SetupParams {
3
3
  updateConfig: (config: {
4
4
  markdown: {
@@ -13,5 +13,5 @@ export interface AstroIntegration {
13
13
  "astro:config:setup": (params: SetupParams) => void;
14
14
  };
15
15
  }
16
- export default function yuhwa(opts?: yuhwaDocsOptions): AstroIntegration;
17
- export type { yuhwaDocsOptions };
16
+ export default function yuhwa(opts?: YuhwaDocsOptions): AstroIntegration;
17
+ export type { YuhwaDocsOptions };
package/dist/astro.js CHANGED
@@ -1,4 +1,4 @@
1
- import remarkyuhwa from "./remark.js";
1
+ import remarkYuhwa from "./remark.js";
2
2
  // src/integrations/astro.ts
3
3
  /**
4
4
  * Astro integration, also for Starlight: renders ```yuhwa blocks in .md and
@@ -12,7 +12,7 @@ function yuhwa(opts = {}) {
12
12
  return {
13
13
  name: "yuhwa",
14
14
  hooks: { "astro:config:setup": ({ updateConfig, injectScript }) => {
15
- updateConfig({ markdown: { remarkPlugins: [[remarkyuhwa, opts]] } });
15
+ updateConfig({ markdown: { remarkPlugins: [[remarkYuhwa, opts]] } });
16
16
  injectScript("page-ssr", `import 'yuhwa/style.css';`);
17
17
  } }
18
18
  };
package/dist/browser.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * <yuhwa-diagram src="docs/arch.yuhwa"></yuhwa-diagram>
9
9
  * el.source = 'a -> b' // re-renders
10
10
  */
11
- import { $ as ParseOptions, $t as PanelKind, A as MdBlock, An as registerTheme, At as LayoutOverrides, B as setProp, Bt as Point, C as NODE_PROPS, Cn as TONES, Ct as HeadKind, D as ConvertResult, Dn as getTheme, Dt as LaidNode, E as lint, En as createTheme, Et as LaidGroup, F as replaceBlockSource, Ft as PanelOverride, G as SHAPES, Gt as Side, H as writeLayout, Ht as ResolvedEdgeStyle, I as editPart, It as PanelPart, J as fromJSON, Jt as groupPath, K as DiagramJSON, Kt as SourceRef, L as formatLayout, Lt as PartAction, M as MdResult, Mn as approxMeasure, Mt as NodeOverride, N as findBlocks, Nn as canvasMeasure, Nt as PanelDecl, O as fromMermaid, On as isToneOrHex, Ot as LaidPanel, P as processMarkdown, Pt as PanelHandle, Q as PANELS, Qt as PanelCtx, R as setLabel, Rt as PartChange, S as GROUP_PROPS, Sn as THEME_NAMES, St as GroupDecl, T as PANEL_PROPS, Tn as ThemeInput, Tt as LaidEdge, U as dashFor, Ut as ResolvedNodeStyle, V as setSetting, Vt as Props, W as lineStyle, Wt as ShapeName, X as KNOWN_SETTINGS, Xt as Decoration, Y as renderSvg, Yt as layout, Z as LexedLine, Zt as FrameKind, _ as themes, _n as tspans, _t as Diagnostic, an as recolor, at as joinPath, b as EDGE_PROPS, bn as THEMES, bt as EdgeDecl, c as git, cn as yuhwaPlugin, ct as parse, d as sequence, dn as renderHead, dt as setLineProp, en as RowCtx, et as SETTING_VALUES, f as legend, fn as InkColors, ft as setTrailingProp, g as charts, gn as segsW, gt as Curve, h as tables, hn as renderSegs, ht as Component, i as hash, in as perPass, it as isyuhwaPath, j as MdOptions, jn as themeNames, jt as NodeDecl, k as isMermaid, kn as ramp, kt as Layout, l as chart, ln as MarkerKind, lt as parseProps, m as frames, mn as parseInline, mt as Box, n as Options, nn as RowPaint, nt as TokKind, o as toSource, on as registry, ot as lex, p as footer, pn as Seg, pt as splitTrailingProps, q as JsonResult, qt as GRID, r as Result, rn as StatementKind, rt as blockBraces, s as builtins, sn as use, st as onlyColor, t as InputFormat, tn as RowKind, tt as Tok, u as timeline, un as ShapeKind, ut as serializeProps, v as GUIDE, vn as LineStyle, vt as Diagram, w as NUMBERS, wn as Theme, wt as LabelRef, x as ENUMS, xn as THEME_KEYS, xt as EdgeOverride, y as BOOLS, yn as RAMPS, yt as Direction, z as setPartTone, zt as PartEdit } from "./index-PDbKFm2X.js";
11
+ import { $ as ParseOptions, $t as PanelKind, A as MdBlock, An as registerTheme, At as LayoutOverrides, B as setProp, Bt as Point, C as NODE_PROPS, Cn as TONES, Ct as HeadKind, D as ConvertResult, Dn as getTheme, Dt as LaidNode, E as lint, En as createTheme, Et as LaidGroup, F as replaceBlockSource, Ft as PanelOverride, G as SHAPES, Gt as Side, H as writeLayout, Ht as ResolvedEdgeStyle, I as editPart, It as PanelPart, J as fromJSON, Jt as groupPath, K as DiagramJSON, Kt as SourceRef, L as formatLayout, Lt as PartAction, M as MdResult, Mn as approxMeasure, Mt as NodeOverride, N as findBlocks, Nn as canvasMeasure, Nt as PanelDecl, O as fromMermaid, On as isToneOrHex, Ot as LaidPanel, P as processMarkdown, Pt as PanelHandle, Q as PANELS, Qt as PanelCtx, R as setLabel, Rt as PartChange, S as GROUP_PROPS, Sn as THEME_NAMES, St as GroupDecl, T as PANEL_PROPS, Tn as ThemeInput, Tt as LaidEdge, U as dashFor, Ut as ResolvedNodeStyle, V as setSetting, Vt as Props, W as lineStyle, Wt as ShapeName, X as KNOWN_SETTINGS, Xt as Decoration, Y as renderSvg, Yt as layout, Z as LexedLine, Zt as FrameKind, _ as themes, _n as tspans, _t as Diagnostic, an as perPass, at as joinPath, b as EDGE_PROPS, bn as THEMES, bt as EdgeDecl, c as git, cn as use, ct as parse, d as sequence, dn as renderHead, dt as setLineProp, en as RowCtx, et as SETTING_VALUES, f as legend, fn as InkColors, ft as setTrailingProp, g as charts, gn as segsW, gt as Curve, h as tables, hn as renderSegs, ht as Component, i as hash, in as YuhwaPlugin, it as isYuhwaPath, j as MdOptions, jn as themeNames, jt as NodeDecl, k as isMermaid, kn as ramp, kt as Layout, l as chart, ln as MarkerKind, lt as parseProps, m as frames, mn as parseInline, mt as Box, n as Options, nn as RowPaint, nt as TokKind, o as toSource, on as recolor, ot as lex, p as footer, pn as Seg, pt as splitTrailingProps, q as JsonResult, qt as GRID, r as Result, rn as StatementKind, rt as blockBraces, s as builtins, sn as registry, st as onlyColor, t as InputFormat, tn as RowKind, tt as Tok, u as timeline, un as ShapeKind, ut as serializeProps, v as GUIDE, vn as LineStyle, vt as Diagram, w as NUMBERS, wn as Theme, wt as LabelRef, x as ENUMS, xn as THEME_KEYS, xt as EdgeOverride, y as BOOLS, yn as RAMPS, yt as Direction, z as setPartTone, zt as PartEdit } from "./index-DY1ZuIhZ.js";
12
12
  export declare function render(source: string, opts?: Options): Result;
13
13
  /**
14
14
  * Fetches every file that `source` imports, and what those import, so
@@ -20,7 +20,7 @@ export declare function fetchImports(source: string, file: string, load?: (path:
20
20
  export declare function run(root?: ParentNode, opts?: Options): void;
21
21
  declare const Base: typeof HTMLElement;
22
22
  /** <yuhwa-diagram [theme] [src]>source</yuhwa-diagram>; fires `yuhwa:render` with the diagnostics */
23
- export declare class yuhwaDiagram extends Base {
23
+ export declare class YuhwaDiagram extends Base {
24
24
  #private;
25
25
  static observedAttributes: string[];
26
26
  get source(): string;
@@ -28,4 +28,4 @@ export declare class yuhwaDiagram extends Base {
28
28
  connectedCallback(): void;
29
29
  attributeChangedCallback(): void;
30
30
  }
31
- export { BOOLS, type Box, type Component, type ConvertResult, type Curve, type Decoration, type Diagnostic, type Diagram, type DiagramJSON, type Direction, EDGE_PROPS, ENUMS, type EdgeDecl, type EdgeOverride, type FrameKind, GRID, GROUP_PROPS, GUIDE, type GroupDecl, type HeadKind, type InkColors, InputFormat, type JsonResult, KNOWN_SETTINGS, type LabelRef, type LaidEdge, type LaidGroup, type LaidNode, type LaidPanel, type Layout, type LayoutOverrides, type LexedLine, type LineStyle, type MarkerKind, type MdBlock, type MdOptions, type MdResult, NODE_PROPS, NUMBERS, type NodeDecl, type NodeOverride, Options, PANELS, PANEL_PROPS, type PanelCtx, type PanelDecl, type PanelHandle, type PanelKind, type PanelOverride, type PanelPart, type ParseOptions, type PartAction, type PartChange, type PartEdit, type Point, type Props, RAMPS, type ResolvedEdgeStyle, type ResolvedNodeStyle, Result, type RowCtx, type RowKind, type RowPaint, SETTING_VALUES, SHAPES, type Seg, type ShapeKind, type ShapeName, type Side, type SourceRef, type StatementKind, THEMES, THEME_KEYS, THEME_NAMES, TONES, type Theme, type ThemeInput, type Tok, type TokKind, approxMeasure, blockBraces, builtins, canvasMeasure, chart, charts, createTheme, dashFor, editPart, findBlocks, footer, formatLayout, frames, fromJSON, fromMermaid, getTheme, git, groupPath, hash, isMermaid, isToneOrHex, isyuhwaPath, joinPath, layout, legend, lex, lineStyle, lint, onlyColor, parse, parseInline, parseProps, perPass, processMarkdown, ramp, recolor, registerTheme, registry, renderHead, renderSegs, renderSvg, replaceBlockSource, segsW, sequence, serializeProps, setLabel, setLineProp, setPartTone, setProp, setSetting, setTrailingProp, splitTrailingProps, tables, themeNames, themes, timeline, toSource, tspans, use, writeLayout, type yuhwaPlugin };
31
+ export { BOOLS, type Box, type Component, type ConvertResult, type Curve, type Decoration, type Diagnostic, type Diagram, type DiagramJSON, type Direction, EDGE_PROPS, ENUMS, type EdgeDecl, type EdgeOverride, type FrameKind, GRID, GROUP_PROPS, GUIDE, type GroupDecl, type HeadKind, type InkColors, InputFormat, type JsonResult, KNOWN_SETTINGS, type LabelRef, type LaidEdge, type LaidGroup, type LaidNode, type LaidPanel, type Layout, type LayoutOverrides, type LexedLine, type LineStyle, type MarkerKind, type MdBlock, type MdOptions, type MdResult, NODE_PROPS, NUMBERS, type NodeDecl, type NodeOverride, Options, PANELS, PANEL_PROPS, type PanelCtx, type PanelDecl, type PanelHandle, type PanelKind, type PanelOverride, type PanelPart, type ParseOptions, type PartAction, type PartChange, type PartEdit, type Point, type Props, RAMPS, type ResolvedEdgeStyle, type ResolvedNodeStyle, Result, type RowCtx, type RowKind, type RowPaint, SETTING_VALUES, SHAPES, type Seg, type ShapeKind, type ShapeName, type Side, type SourceRef, type StatementKind, THEMES, THEME_KEYS, THEME_NAMES, TONES, type Theme, type ThemeInput, type Tok, type TokKind, type YuhwaPlugin, approxMeasure, blockBraces, builtins, canvasMeasure, chart, charts, createTheme, dashFor, editPart, findBlocks, footer, formatLayout, frames, fromJSON, fromMermaid, getTheme, git, groupPath, hash, isMermaid, isToneOrHex, isYuhwaPath, joinPath, layout, legend, lex, lineStyle, lint, onlyColor, parse, parseInline, parseProps, perPass, processMarkdown, ramp, recolor, registerTheme, registry, renderHead, renderSegs, renderSvg, replaceBlockSource, segsW, sequence, serializeProps, setLabel, setLineProp, setPartTone, setProp, setSetting, setTrailingProp, splitTrailingProps, tables, themeNames, themes, timeline, toSource, tspans, use, writeLayout };
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as BOOLS, A as footer, B as PANELS, C as git, Ct as ramp, D as legend, E as sequence, F as perPass, G as lex, H as blockBraces, I as recolor, J as parseProps, K as onlyColor, L as registry, M as tables, N as charts, O as approxMeasure, P as themes, Q as splitTrailingProps, R as use, S as builtins, St as isToneOrHex, T as timeline, Tt as themeNames, U as isyuhwaPath, V as SETTING_VALUES, W as joinPath, X as setLineProp, Y as serializeProps, Z as setTrailingProp, _ as fromJSON, _t as THEME_KEYS, a as findBlocks, at as PANEL_PROPS, b as groupPath, bt as createTheme, c as editPart, ct as renderHead, d as setPartTone, dt as parseInline, et as EDGE_PROPS, f as setProp, ft as renderSegs, g as isMermaid, gt as THEMES, h as fromMermaid, ht as RAMPS, i as GUIDE, it as NUMBERS, j as frames, k as canvasMeasure, l as formatLayout, lt as dashFor, m as writeLayout, mt as tspans, n as render$1, nt as GROUP_PROPS, o as processMarkdown, ot as lint, p as setSetting, pt as segsW, q as parse, r as toSource, rt as NODE_PROPS, s as replaceBlockSource, st as SHAPES, t as hash, tt as ENUMS, u as setLabel, ut as lineStyle, v as renderSvg, vt as THEME_NAMES, w as chart, wt as registerTheme, x as layout, xt as getTheme, y as GRID, yt as TONES, z as KNOWN_SETTINGS } from "./src-BNOnUjQh.js";
1
+ import { $ as BOOLS, A as footer, B as PANELS, C as git, Ct as ramp, D as legend, E as sequence, F as perPass, G as lex, H as blockBraces, I as recolor, J as parseProps, K as onlyColor, L as registry, M as tables, N as charts, O as approxMeasure, P as themes, Q as splitTrailingProps, R as use, S as builtins, St as isToneOrHex, T as timeline, Tt as themeNames, U as isYuhwaPath, V as SETTING_VALUES, W as joinPath, X as setLineProp, Y as serializeProps, Z as setTrailingProp, _ as fromJSON, _t as THEME_KEYS, a as findBlocks, at as PANEL_PROPS, b as groupPath, bt as createTheme, c as editPart, ct as renderHead, d as setPartTone, dt as parseInline, et as EDGE_PROPS, f as setProp, ft as renderSegs, g as isMermaid, gt as THEMES, h as fromMermaid, ht as RAMPS, i as GUIDE, it as NUMBERS, j as frames, k as canvasMeasure, l as formatLayout, lt as dashFor, m as writeLayout, mt as tspans, n as render$1, nt as GROUP_PROPS, o as processMarkdown, ot as lint, p as setSetting, pt as segsW, q as parse, r as toSource, rt as NODE_PROPS, s as replaceBlockSource, st as SHAPES, t as hash, tt as ENUMS, u as setLabel, ut as lineStyle, v as renderSvg, vt as THEME_NAMES, w as chart, wt as registerTheme, x as layout, xt as getTheme, y as GRID, yt as TONES, z as KNOWN_SETTINGS } from "./src-Dl2VCr7N.js";
2
2
  // src/browser.ts
3
3
  /**
4
4
  * Drop-in browser runtime: <script src="yuhwa.js"><\/script>
@@ -38,7 +38,7 @@ async function fetchImports(source, file, load = fetchText) {
38
38
  const queue = [[source, file]];
39
39
  while (queue.length) {
40
40
  const [text, from] = queue.shift();
41
- const paths = [...text.matchAll(IMPORT_RE)].map((m) => joinPath(from, m[1])).filter((p) => isyuhwaPath(p) && !(p in files));
41
+ const paths = [...text.matchAll(IMPORT_RE)].map((m) => joinPath(from, m[1])).filter((p) => isYuhwaPath(p) && !(p in files));
42
42
  await Promise.all(paths.map(async (p) => {
43
43
  files[p] = "";
44
44
  try {
@@ -84,16 +84,18 @@ function run(root = document, opts = {}) {
84
84
  }
85
85
  const Base = typeof HTMLElement === "undefined" ? class {} : HTMLElement;
86
86
  /** <yuhwa-diagram [theme] [src]>source</yuhwa-diagram>; fires `yuhwa:render` with the diagnostics */
87
- var yuhwaDiagram = class extends Base {
87
+ var YuhwaDiagram = class extends Base {
88
88
  static observedAttributes = ["theme", "src"];
89
89
  #source = null;
90
- #fetched = "";
90
+ #fetched = null;
91
+ #request = 0;
91
92
  #file;
92
93
  #files = {};
93
94
  get source() {
94
95
  return this.#source ?? "";
95
96
  }
96
97
  set source(v) {
98
+ this.#request++;
97
99
  this.#source = v;
98
100
  this.#draw();
99
101
  }
@@ -107,15 +109,22 @@ var yuhwaDiagram = class extends Base {
107
109
  }
108
110
  #update() {
109
111
  const src = this.getAttribute("src");
110
- if (!src || src === this.#fetched) return this.#draw();
112
+ if (src === this.#fetched) return this.#draw();
113
+ const request = ++this.#request;
111
114
  this.#fetched = src;
115
+ if (!src) return this.#draw();
112
116
  const url = new URL(src, location.href);
113
117
  const file = url.origin === location.origin ? url.pathname : url.href;
114
118
  fetchText(url.href).then(async (t) => {
115
- this.#files = await fetchImports(t, file);
119
+ if (request !== this.#request) return;
120
+ const files = await fetchImports(t, file);
121
+ if (request !== this.#request) return;
122
+ this.#files = files;
116
123
  this.#file = file;
117
124
  this.source = t;
118
- }).catch((e) => this.#fail(e.message));
125
+ }).catch((e) => {
126
+ if (request === this.#request) this.#fail(e.message);
127
+ });
119
128
  }
120
129
  #draw() {
121
130
  if (this.#source === null) return;
@@ -148,11 +157,11 @@ var yuhwaDiagram = class extends Base {
148
157
  this.style.color = "crimson";
149
158
  }
150
159
  };
151
- if (typeof customElements !== "undefined" && !customElements.get("yuhwa-diagram")) customElements.define("yuhwa-diagram", yuhwaDiagram);
160
+ if (typeof customElements !== "undefined" && !customElements.get("yuhwa-diagram")) customElements.define("yuhwa-diagram", YuhwaDiagram);
152
161
  if (typeof document !== "undefined") {
153
162
  if (!document.currentScript?.hasAttribute("data-manual")) {
154
163
  if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", () => run());
155
164
  else run();
156
165
  }
157
166
  }
158
- export { BOOLS, EDGE_PROPS, ENUMS, GRID, GROUP_PROPS, GUIDE, KNOWN_SETTINGS, NODE_PROPS, NUMBERS, PANELS, PANEL_PROPS, RAMPS, SETTING_VALUES, SHAPES, THEMES, THEME_KEYS, THEME_NAMES, TONES, approxMeasure, blockBraces, builtins, canvasMeasure, chart, charts, createTheme, dashFor, editPart, fetchImports, findBlocks, footer, formatLayout, frames, fromJSON, fromMermaid, getTheme, git, groupPath, hash, isMermaid, isToneOrHex, isyuhwaPath, joinPath, layout, legend, lex, lineStyle, lint, onlyColor, parse, parseInline, parseProps, perPass, processMarkdown, ramp, recolor, registerTheme, registry, render, renderHead, renderSegs, renderSvg, replaceBlockSource, run, segsW, sequence, serializeProps, setLabel, setLineProp, setPartTone, setProp, setSetting, setTrailingProp, splitTrailingProps, tables, themeNames, themes, timeline, toSource, tspans, use, writeLayout, yuhwaDiagram };
167
+ export { BOOLS, EDGE_PROPS, ENUMS, GRID, GROUP_PROPS, GUIDE, KNOWN_SETTINGS, NODE_PROPS, NUMBERS, PANELS, PANEL_PROPS, RAMPS, SETTING_VALUES, SHAPES, THEMES, THEME_KEYS, THEME_NAMES, TONES, YuhwaDiagram, approxMeasure, blockBraces, builtins, canvasMeasure, chart, charts, createTheme, dashFor, editPart, fetchImports, findBlocks, footer, formatLayout, frames, fromJSON, fromMermaid, getTheme, git, groupPath, hash, isMermaid, isToneOrHex, isYuhwaPath, joinPath, layout, legend, lex, lineStyle, lint, onlyColor, parse, parseInline, parseProps, perPass, processMarkdown, ramp, recolor, registerTheme, registry, render, renderHead, renderSegs, renderSvg, replaceBlockSource, run, segsW, sequence, serializeProps, setLabel, setLineProp, setPartTone, setProp, setSetting, setTrailingProp, splitTrailingProps, tables, themeNames, themes, timeline, toSource, tspans, use, writeLayout };