yuhwa 1.2.0 → 1.4.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.
Files changed (57) hide show
  1. package/README.md +5 -3
  2. package/dist/astro.d.ts +1 -1
  3. package/dist/astro.js +4 -3
  4. package/dist/browser.d.ts +10 -3
  5. package/dist/browser.js +85 -21
  6. package/dist/canvas.d.ts +2 -0
  7. package/dist/canvas.js +40 -0
  8. package/dist/cli.js +485 -236
  9. package/dist/editor/assets/index-DWm3xV_v.js +689 -0
  10. package/dist/editor/assets/{lsp.worker-sZtzIA6-.js → lsp.worker-N6A9m364.js} +23 -17
  11. package/dist/editor/index.html +4 -1
  12. package/dist/{figure-CA2hy0xh.d.ts → figure-BLHfxz_e.d.ts} +28 -5
  13. package/dist/index-xVW43gqW.d.ts +261 -0
  14. package/dist/index.d.ts +3 -2
  15. package/dist/index.js +5 -1
  16. package/dist/ironmark.d.ts +1 -1
  17. package/dist/ironmark.js +1 -1
  18. package/dist/lsp-browser.d.ts +2 -2
  19. package/dist/lsp-browser.js +2 -1
  20. package/dist/lsp-node.js +47 -27
  21. package/dist/lsp-server.d.ts +5 -1
  22. package/dist/lsp-server.js +1 -1
  23. package/dist/lsp.d.ts +1 -1
  24. package/dist/lsp.js +1 -1
  25. package/dist/markdown-it.d.ts +1 -1
  26. package/dist/markdown-it.js +5 -3
  27. package/dist/{node-Bzn2uKXZ.js → node-CkrQnPFb.js} +90 -12
  28. package/dist/parse--ljBMU60.js +3884 -0
  29. package/dist/plugin-CitzbblK.js +301 -0
  30. package/dist/{index-CnnoZYl0.d.ts → plugin-NMP_uf1a.d.ts} +93 -208
  31. package/dist/plugin.d.ts +12 -0
  32. package/dist/plugin.js +3 -0
  33. package/dist/raster-iqi6XRPU.js +299 -0
  34. package/dist/remark.d.ts +1 -1
  35. package/dist/remark.js +1 -1
  36. package/dist/rolldown-runtime-CEjnN5Q1.js +37 -0
  37. package/dist/{server-Dxo7OG8K.js → server-BTYtmr6B.js} +41 -63
  38. package/dist/{server--jHjJjOS.d.ts → server-DMAOtqqK.d.ts} +1 -1
  39. package/dist/{service-B1fpOg_L.js → service-C60VdeKS.js} +35 -3
  40. package/dist/{service-Brvpt7Do.d.ts → service-DimTFsE3.d.ts} +2 -0
  41. package/dist/{shared-Ddw88O9D.js → shared-h8tkFLY4.js} +719 -421
  42. package/dist/{src-DkQj7aIV.js → src-NCXCTK_4.js} +512 -4548
  43. package/dist/svg-uri-Dx8SGV-n.js +7 -0
  44. package/dist/vite.d.ts +1 -1
  45. package/dist/vite.js +3 -2
  46. package/dist/vuepress.d.ts +3 -2
  47. package/dist/vuepress.js +4 -2
  48. package/dist/watch-2VeW5DUN.js +35 -0
  49. package/dist/yuhwa.iife.js +55 -54
  50. package/dist/zoom-script-CaJ5MNUw.js +29 -0
  51. package/dist/{zoom-QeqB6QlH.js → zoom-yxhxX16c.js} +1 -1
  52. package/dist/zoom.d.ts +16 -7
  53. package/dist/zoom.js +2 -2
  54. package/package.json +24 -2
  55. package/skills/yuhwa/SKILL.md +12 -0
  56. package/dist/editor/assets/index-BphHLTvA.js +0 -689
  57. package/dist/zoom-script-CVdAzMhX.js +0 -51
@@ -9,7 +9,7 @@
9
9
  rel="icon"
10
10
  href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%232563eb'/%3E%3Cstop offset='1' stop-color='%239333ea'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='64' height='64' rx='15' fill='url%28%23g%29'/%3E%3Crect x='9' y='11' width='26' height='17' rx='5' fill='%23fff'/%3E%3Cpath d='M15 17.5h10M15 22h14' stroke='%237c3aed' stroke-opacity='.35' stroke-width='2.5' stroke-linecap='round'/%3E%3Cpath d='M18 28v5a11 11 0 0 0 11 11h1' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round'/%3E%3Cpath d='m29 38 6 6-6 6' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'/%3E%3Crect x='38' y='36' width='17' height='16' rx='5' fill='%23fff' fill-opacity='.9'/%3E%3C/svg%3E"
11
11
  />
12
- <script type="module" crossorigin src="./assets/index-BphHLTvA.js"></script>
12
+ <script type="module" crossorigin src="./assets/index-DWm3xV_v.js"></script>
13
13
  <link rel="stylesheet" crossorigin href="./assets/index-DaWl0OPj.css">
14
14
  </head>
15
15
  <body>
@@ -173,6 +173,9 @@
173
173
  <button id="download" title="Download SVG">
174
174
  <svg><use href="#i-download" /></svg><span class="wide">Download</span>
175
175
  </button>
176
+ <button id="download-png" title="Download PNG">
177
+ <svg><use href="#i-download" /></svg>PNG
178
+ </button>
176
179
  <button id="copy-md" title="Copy as Markdown">
177
180
  <svg><use href="#i-md" /></svg><span class="wide">Markdown</span>
178
181
  </button>
@@ -1,4 +1,18 @@
1
- import { n as Options } from "./index-CnnoZYl0.js";
1
+ import { n as Options } from "./index-xVW43gqW.js";
2
+ /**
3
+ * SVG to PNG in Node, with @resvg/resvg-js (an optional peer dependency: Node
4
+ * has no canvas). Synchronous, so markdown plugins can call it while they
5
+ * render. Node modules load on first use only, so bundlers that pull in the
6
+ * integrations for the browser never meet them.
7
+ */
8
+ interface PngOptions {
9
+ /** pixels per SVG unit (default 2) */
10
+ scale?: number;
11
+ /** font files (ttf, otf, ttc) or folders of them */
12
+ fonts?: string[];
13
+ /** also use the fonts installed on the system (default `true`) */
14
+ systemFonts?: boolean;
15
+ }
2
16
  interface YuhwaDocsOptions extends Omit<Options, "theme" | "file"> {
3
17
  /** theme for light mode (default `paper`) */
4
18
  theme?: string;
@@ -16,13 +30,22 @@ interface YuhwaDocsOptions extends Omit<Options, "theme" | "file"> {
16
30
  */
17
31
  darkMode?: "class" | "media";
18
32
  /**
19
- * `svg` inlines the SVG instead of an `<img>` (markdown-it only; keeps
20
- * diagram text selectable and links clickable). Not for Vue-based sites.
33
+ * What the page gets:
34
+ * - `img` (default): the SVG as an `<img>`
35
+ * - `svg`: the SVG inline (markdown-it only; keeps diagram text selectable
36
+ * and links clickable). Not for Vue-based sites
37
+ * - `png`: a PNG drawn at build time, as an `<img>`. Needs the optional
38
+ * `@resvg/resvg-js` package; `png` sets its scale and fonts
39
+ * - `canvas`: a `<canvas>` drawn in the browser with the page's web fonts.
40
+ * The page gets the SVG `<img>`, and `yuhwa/canvas` swaps it for the
41
+ * canvas (Astro and VuePress load it for you)
21
42
  */
22
- output?: "img" | "svg";
43
+ output?: "img" | "svg" | "png" | "canvas";
44
+ /** scale and fonts for `output: 'png'` (default scale 2, system fonts) */
45
+ png?: PngOptions;
23
46
  /** throw on errors and fail the build (default `true`); `false` shows them under the diagram */
24
47
  strict?: boolean;
25
- /** fence languages handled (default `['yuhwa']`) */
48
+ /** fence languages handled (default `['yuhwa', 'yu']`) */
26
49
  languages?: string[];
27
50
  /**
28
51
  * Folder that `file="..."` blocks and imports must stay inside. A `file`
@@ -0,0 +1,261 @@
1
+ import { Et as YuhwaPlugin, L as Diagnostic, R as Diagram, X as LayoutOverrides, Y as Layout, at as PartEdit, et as PanelHandle, mt as LayoutOptions, v as ParseOptions, xn as Measure, xt as PanelOption } from "./plugin-NMP_uf1a.js";
2
+ interface RenderOptions {
3
+ /** prefix for ids inside the SVG, so several diagrams can live on one page */
4
+ idPrefix?: string;
5
+ /** add invisible wide strokes on edges and data attributes for editors */
6
+ interactive?: boolean;
7
+ /** fixed width attribute; default is the natural size */
8
+ width?: number | string;
9
+ /** drop the background rect */
10
+ transparent?: boolean;
11
+ /** text measuring for panels; the same one layout used */
12
+ measure?: Measure;
13
+ /** draw a dot every n units, from the origin: shows an editor's snap grid */
14
+ snapGrid?: number;
15
+ }
16
+ /** the SVG for a laid out diagram; a plugin that throws becomes a diagnostic on `d` */
17
+ declare function renderSvg(d: Diagram, L: Layout, opts?: RenderOptions): string;
18
+ type Scalar = string | number | boolean;
19
+ type PropBag = Record<string, unknown>;
20
+ interface DiagramJSON {
21
+ title?: string;
22
+ direction?: "right" | "down" | "left" | "up";
23
+ theme?: string;
24
+ settings?: Record<string, Scalar>;
25
+ classes?: Record<string, Record<string, Scalar>>;
26
+ groups?: ({
27
+ id: string;
28
+ label?: string;
29
+ parent?: string;
30
+ class?: string | string[];
31
+ } & PropBag)[];
32
+ nodes?: ({
33
+ id: string;
34
+ label?: string;
35
+ group?: string;
36
+ class?: string | string[];
37
+ body?: string | string[];
38
+ } & PropBag)[];
39
+ edges?: ({
40
+ from: string | string[];
41
+ to: string | string[];
42
+ label?: string;
43
+ arrow?: string;
44
+ class?: string | string[];
45
+ } & PropBag)[];
46
+ }
47
+ interface JsonResult {
48
+ source: string;
49
+ errors: string[];
50
+ }
51
+ declare function fromJSON(input: DiagramJSON | string): JsonResult;
52
+ /** Serialise layout overrides as a `layout { ... }` block (without trailing newline). */
53
+ declare function formatLayout(o: LayoutOverrides): string;
54
+ /** Replace (or append, or remove) the layout block. */
55
+ declare function writeLayout(source: string, o: LayoutOverrides, d?: Diagram): string;
56
+ type Target = {
57
+ kind: "node" | "edge" | "group" | "panel";
58
+ id: string;
59
+ };
60
+ /**
61
+ * Set or remove (text = '') the label of a node, edge, group or panel.
62
+ * Node, group and panel labels are written quoted; edge labels stay bare when
63
+ * they can. Every edge of one statement (`a -> b, c: label`) shares the label.
64
+ */
65
+ declare function setLabel(source: string, target: Target, text: string, d?: Diagram): string;
66
+ /**
67
+ * Set (value = string) or remove (value = null) one prop on a node, edge, group
68
+ * or panel header.
69
+ * Implicit nodes (only mentioned in edges) get a declaration line appended.
70
+ */
71
+ declare function setProp(source: string, target: Target, key: string, value: string | null, d?: Diagram): string;
72
+ /** Set or remove a top-level `key: value` setting. */
73
+ declare function setSetting(source: string, key: string, value: string | null): string;
74
+ /**
75
+ * Colour one part of a panel (a participant, message, event, bar, branch, …).
76
+ * `tone` is a tone name or `#hex`; null removes the colour. Returns the source
77
+ * unchanged when the panel or part cannot be edited in place.
78
+ */
79
+ declare function setPartTone(source: string, panelId: string, partId: string, tone: string | null, d?: Diagram): string;
80
+ /**
81
+ * Apply one part edit (set a field, move, add, remove) through the panel
82
+ * kind's `editPart`. `id` is the edited part's id afterwards (it can change
83
+ * when the part moves or is renamed); the source comes back unchanged when
84
+ * the edit does not apply.
85
+ */
86
+ declare function editPart(source: string, panelId: string, edit: PartEdit, d?: Diagram): {
87
+ source: string;
88
+ id?: string;
89
+ };
90
+ /** Finish a panel drag. Prefer the declaration; a purely visual handle uses layout. */
91
+ declare function writePanelDrag(source: string, d: Diagram, id: string, handle: PanelHandle): string;
92
+ /** a font file to embed, as `@font-face` would name it */
93
+ interface FontSource {
94
+ family: string;
95
+ /** URL of the font file (woff2, woff, ttf, otf) or a `data:` URL */
96
+ url: string;
97
+ /** CSS font-weight, e.g. `400` or `100 900` for a variable font */
98
+ weight?: string;
99
+ /** CSS font-style: `normal` or `italic` */
100
+ style?: string;
101
+ /** CSS unicode-range; the font is left out when the diagram uses none of it */
102
+ unicodeRange?: string;
103
+ }
104
+ interface RasterOptions {
105
+ /** canvas to draw into; resized to fit. Default: a new canvas */
106
+ canvas?: HTMLCanvasElement;
107
+ /** pixels per SVG unit. Default: `devicePixelRatio`, or 1 */
108
+ scale?: number;
109
+ /** fill behind the diagram, e.g. white under a `transparent` SVG saved as JPEG */
110
+ background?: string;
111
+ /**
112
+ * Fonts to embed. `'page'` (default) embeds the page's `@font-face` fonts
113
+ * that the diagram names; a list embeds those files; `false` embeds
114
+ * nothing, so only fonts installed on the system are used.
115
+ */
116
+ fonts?: "page" | false | FontSource[];
117
+ }
118
+ /**
119
+ * Embeds the fonts the SVG names as an `@font-face` `<style>` inside it.
120
+ * Fonts it cannot fetch are skipped: the image then falls back to system fonts.
121
+ */
122
+ declare function embedFonts(svg: string, fonts?: "page" | FontSource[]): Promise<string>;
123
+ /**
124
+ * Loads the page's web fonts that the SVG names, in the weights and styles
125
+ * it uses. Text is measured when the diagram renders, and a font that has
126
+ * not loaded yet is measured with its fallback. Resolves true when a font
127
+ * finished loading that was not ready before: render again for exact boxes.
128
+ */
129
+ declare function loadFonts(svg: string): Promise<boolean>;
130
+ /**
131
+ * Draws an SVG string, such as `render(...).svg`, into a canvas. The page's
132
+ * web fonts that the diagram names are embedded first (see `fonts`).
133
+ */
134
+ declare function svgToCanvas(svg: string, opts?: RasterOptions): Promise<HTMLCanvasElement>;
135
+ interface MdBlock {
136
+ index: number;
137
+ name: string;
138
+ source: string;
139
+ kind: "comment" | "fence";
140
+ /** line range [start, end] (inclusive) of the block itself */
141
+ start: number;
142
+ end: number;
143
+ /** line range of the generated image reference, if present */
144
+ image?: [number, number];
145
+ }
146
+ interface MdOptions {
147
+ /** directory for SVGs, relative to the markdown file (default "diagrams") */
148
+ outDir?: string;
149
+ /** used to name unnamed blocks: <baseName>-<n> */
150
+ baseName?: string;
151
+ /** also write a dark variant and emit a <picture> element */
152
+ dark?: boolean;
153
+ /** keep ```yuhwa and ```yu fences instead of converting them to comments */
154
+ keepFences?: boolean;
155
+ /** reads `import "..."` targets, see Options.resolve */
156
+ resolve?: (path: string) => string | undefined;
157
+ /** path of the markdown file; imports in blocks resolve against its folder */
158
+ file?: string;
159
+ /**
160
+ * Link each image to this URL, such as a page that pans and zooms the
161
+ * diagram (`yuhwa md --view`). Gets the block's source.
162
+ */
163
+ view?: (source: string) => string;
164
+ }
165
+ interface MdResult {
166
+ markdown: string;
167
+ files: {
168
+ path: string;
169
+ svg: string;
170
+ }[];
171
+ blocks: MdBlock[];
172
+ diagnostics: {
173
+ block: string;
174
+ line: number;
175
+ message: string;
176
+ severity: string;
177
+ }[];
178
+ }
179
+ /** fence languages that hold a diagram */
180
+ declare const MD_LANGUAGES: string[];
181
+ declare function findBlocks(md: string, baseName?: string, outDir?: string): MdBlock[];
182
+ declare function processMarkdown(md: string, opts?: MdOptions): MdResult;
183
+ /** Replace the source of block `index` in a markdown document. */
184
+ declare function replaceBlockSource(md: string, index: number, source: string): string;
185
+ interface ConvertResult {
186
+ source: string;
187
+ warnings: {
188
+ line: number;
189
+ message: string;
190
+ }[];
191
+ }
192
+ /** true when the source is Mermaid that yuhwa converts (a flowchart or one of the types above) */
193
+ declare function isMermaid(source: string): boolean;
194
+ declare function fromMermaid(source: string): ConvertResult;
195
+ declare const NODE_PROPS: string[];
196
+ declare const EDGE_PROPS: string[];
197
+ declare const GROUP_PROPS: string[];
198
+ /** frame props every panel takes, next to the plugin's own */
199
+ declare const PANEL_PROPS: string[];
200
+ /** allowed values for enum-like props */
201
+ declare const ENUMS: Record<string, string[]>;
202
+ /** props whose value must be a colour (or `none`/`transparent`), on nodes, edges, groups and panels */
203
+ declare const COLORS: string[];
204
+ declare const BOOLS: string[];
205
+ declare const NUMBERS: string[];
206
+ /** a panel kind's typed header props, looked up by kind name */
207
+ type PanelOptions = (kind: string) => Record<string, PanelOption> | undefined;
208
+ declare function lint(d: Diagram, panelOptions?: PanelOptions): void;
209
+ declare const GUIDE: string;
210
+ declare const shapes: YuhwaPlugin;
211
+ declare const markers: YuhwaPlugin;
212
+ declare const themes: YuhwaPlugin;
213
+ declare const charts: YuhwaPlugin;
214
+ declare const tables: YuhwaPlugin;
215
+ declare const frames: YuhwaPlugin;
216
+ declare const footer: YuhwaPlugin;
217
+ declare const legend: YuhwaPlugin;
218
+ declare const sequence: YuhwaPlugin;
219
+ declare const timeline: YuhwaPlugin;
220
+ declare const chart: YuhwaPlugin;
221
+ declare const git: YuhwaPlugin;
222
+ declare const mindmap: YuhwaPlugin;
223
+ declare const gantt: YuhwaPlugin;
224
+ declare const quadrant: YuhwaPlugin;
225
+ declare const kanban: YuhwaPlugin;
226
+ declare const treeview: YuhwaPlugin;
227
+ declare const builtins: YuhwaPlugin[];
228
+ interface Options extends LayoutOptions, RenderOptions {
229
+ /**
230
+ * Reads files named by `import "..."`: gets the resolved path, returns the
231
+ * source or undefined. In Node: `(p) => readFileSync(p, 'utf8')`.
232
+ */
233
+ resolve?: ParseOptions["resolve"];
234
+ /** path of the source being rendered; relative imports resolve against it */
235
+ file?: string;
236
+ }
237
+ interface Result {
238
+ svg: string;
239
+ /** yuhwa source that was rendered (converted when the input was Mermaid or JSON) */
240
+ source: string;
241
+ /** what the input was detected as */
242
+ format: InputFormat;
243
+ diagram: Diagram;
244
+ layout: Layout;
245
+ diagnostics: Diagnostic[];
246
+ }
247
+ type InputFormat = "yuhwa" | "mermaid" | "json";
248
+ /** Stable short hash, used for deterministic SVG ids. */
249
+ declare function hash(s: string): string;
250
+ /**
251
+ * Normalise any accepted input to yuhwa source.
252
+ * Accepts yuhwa text, a Mermaid flowchart, a JSON string or a DiagramJSON object.
253
+ */
254
+ declare function toSource(input: string | DiagramJSON): {
255
+ source: string;
256
+ format: InputFormat;
257
+ diagnostics: Diagnostic[];
258
+ };
259
+ /** Parse, lay out and render a diagram to an SVG string. Never throws on bad input. */
260
+ declare function render(input: string | DiagramJSON, opts?: Options): Result;
261
+ export { setPartTone as $, GROUP_PROPS as A, MdOptions as B, markers as C, COLORS as D, BOOLS as E, ConvertResult as F, FontSource as G, findBlocks as H, fromMermaid as I, loadFonts as J, RasterOptions as K, isMermaid as L, NUMBERS as M, PANEL_PROPS as N, EDGE_PROPS as O, lint as P, setLabel as Q, MD_LANGUAGES as R, themes as S, GUIDE as T, processMarkdown as U, MdResult as V, replaceBlockSource as W, editPart as X, svgToCanvas as Y, formatLayout as Z, legend as _, render as a, JsonResult as at, tables as b, treeview as c, gantt as d, setProp as et, mindmap as f, sequence as g, timeline as h, hash as i, DiagramJSON as it, NODE_PROPS as j, ENUMS as k, kanban as l, chart as m, Options as n, writeLayout as nt, toSource as o, fromJSON as ot, git as p, embedFonts as q, Result as r, writePanelDrag as rt, builtins as s, renderSvg as st, InputFormat as t, setSetting as tt, quadrant as u, footer as v, shapes as w, charts as x, frames as y, MdBlock as z };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- import { $ as LexedLine, $t as FrameKind, A as isMermaid, An as ThemeInput, At as LaidPanel, B as setPartTone, Bn as canvasMeasure, Bt as PartChange, C as GROUP_PROPS, Cn as LineStyle, Ct as EdgeOverride, D as lint, Dn as THEME_NAMES, Dt as LaidEdge, E as PANEL_PROPS, En as THEME_KEYS, Et as LabelRef, F as processMarkdown, Fn as isToneOrHex, Ft as PanelDecl, G as dashFor, Gt as ResolvedNodeStyle, H as setSetting, Ht as Point, I as replaceBlockSource, In as ramp, It as PanelHandle, J as DiagramJSON, Jt as SourceRef, K as lineStyle, Kt as ShapeName, L as editPart, Ln as registerTheme, Lt as PanelOverride, M as MdOptions, Mn as getTheme, Mt as LayoutOverrides, N as MdResult, Nn as isSafeCss, Nt as NodeDecl, O as ConvertResult, On as TONES, Ot as LaidGroup, P as findBlocks, Pn as isSafeLink, Pt as NodeOverride, Q as KNOWN_SETTINGS, Qt as Decoration, R as formatLayout, Rn as themeNames, Rt as PanelPart, S as ENUMS, Sn as tspans, St as EdgeDecl, T as NUMBERS, Tn as THEMES, Tt as HeadKind, U as writeLayout, Ut as Props, V as setProp, Vt as PartEdit, W as writePanelDrag, Wt as ResolvedEdgeStyle, X as fromJSON, Xt as groupPath, Y as JsonResult, Yt as GRID, Z as renderSvg, Zt as layout, _ as themes, _n as InkColors, _t as Component, a as render, an as RowPaint, at as blockBraces, b as COLORS, bn as renderSegs, bt as Diagram, c as git, cn as optionKind, ct as lex, d as sequence, dn as registry, dt as parseProps, en as PanelCtx, et as PANELS, f as legend, fn as unuse, ft as serializeProps, g as charts, gn as renderHead, gt as Box, h as tables, hn as ShapeKind, ht as splitTrailingProps, i as hash, in as RowKind, it as TokKind, j as MdBlock, jn as createTheme, jt as Layout, k as fromMermaid, kn as Theme, kt as LaidNode, l as chart, ln as perPass, lt as onlyColor, m as frames, mn as MarkerKind, mt as setTrailingProp, n as Options, nn as PanelOption, nt as SETTING_VALUES, o as toSource, on as StatementKind, ot as isYuhwaPath, p as footer, pn as use, pt as setLineProp, q as SHAPES, qt as Side, r as Result, rn as RowCtx, rt as Tok, s as builtins, sn as YuhwaPlugin, st as joinPath, t as InputFormat, tn as PanelKind, tt as ParseOptions, u as timeline, un as recolor, ut as parse, v as GUIDE, vn as Seg, vt as Curve, w as NODE_PROPS, wn as RAMPS, wt as GroupDecl, x as EDGE_PROPS, xn as segsW, xt as Direction, y as BOOLS, yn as parseInline, yt as Diagnostic, z as setLabel, zn as approxMeasure, zt as PartAction } from "./index-CnnoZYl0.js";
2
- export { BOOLS, type Box, COLORS, 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 PanelOption, 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, isSafeCss, isSafeLink, isToneOrHex, isYuhwaPath, joinPath, layout, legend, lex, lineStyle, lint, onlyColor, optionKind, parse, parseInline, parseProps, perPass, processMarkdown, ramp, recolor, registerTheme, registry, render, renderHead, renderSegs, renderSvg, replaceBlockSource, segsW, sequence, serializeProps, setLabel, setLineProp, setPartTone, setProp, setSetting, setTrailingProp, splitTrailingProps, tables, themeNames, themes, timeline, toSource, tspans, unuse, use, writeLayout, writePanelDrag };
1
+ import { $ as PanelDecl, A as setLineProp, At as registry, B as EdgeDecl, C as isYuhwaPath, Cn as canvasMeasure, Ct as RowKind, D as parse, Dt as optionKind, E as onlyColor, Et as YuhwaPlugin, F as Component, Ft as renderHead, G as LaidEdge, Gt as segsW, H as GroupDecl, Ht as parseInline, I as Curve, It as InkColors, J as LaidPanel, Jt as tspans, K as LaidGroup, L as Diagnostic, Lt as Seg, M as splitTrailingProps, Mt as use, Nt as MarkerKind, O as parseProps, Ot as perPass, P as Box, Pt as ShapeKind, Q as NodeOverride, Qt as RAMPS, R as Diagram, Rt as esc, S as blockBraces, Sn as approxMeasure, St as RowCtx, T as lex, Tt as StatementKind, U as HeadKind, V as EdgeOverride, W as LabelRef, Wt as renderSegs, X as LayoutOverrides, Xt as LineStyle, Y as Layout, Z as NodeDecl, _ as PANELS, _n as ramp, _t as Decoration, an as ThemeInput, at as PartEdit, b as Tok, bn as themeNames, bt as PanelKind, ct as ResolvedEdgeStyle, dn as getTheme, dt as Side, en as THEMES, et as PanelHandle, f as portOn, ft as SourceRef, g as LexedLine, gn as isToneOrHex, gt as layout, h as KNOWN_SETTINGS, hn as isSafeLink, ht as groupPath, in as Theme, it as PartChange, j as setTrailingProp, jt as unuse, k as serializeProps, kt as recolor, ln as fontFamilies, lt as ResolvedNodeStyle, mn as isSafeCss, nn as THEME_NAMES, nt as PanelPart, o as lineStyle, ot as Point, pn as isGenericFont, pt as GRID, q as LaidNode, r as dashFor, rn as TONES, rt as PartAction, sn as createTheme, st as Props, tn as THEME_KEYS, tt as PanelOverride, u as SHAPES, un as fontStack, ut as ShapeName, v as ParseOptions, vn as registerTheme, vt as FrameKind, w as joinPath, wt as RowPaint, x as TokKind, xt as PanelOption, y as SETTING_VALUES, yt as PanelCtx, z as Direction } from "./plugin-NMP_uf1a.js";
2
+ import { $ as setPartTone, A as GROUP_PROPS, B as MdOptions, C as markers, D as COLORS, E as BOOLS, F as ConvertResult, G as FontSource, H as findBlocks, I as fromMermaid, J as loadFonts, K as RasterOptions, L as isMermaid, M as NUMBERS, N as PANEL_PROPS, O as EDGE_PROPS, P as lint, Q as setLabel, R as MD_LANGUAGES, S as themes, T as GUIDE, U as processMarkdown, V as MdResult, W as replaceBlockSource, X as editPart, Y as svgToCanvas, Z as formatLayout, _ as legend, a as render, at as JsonResult, b as tables, c as treeview, d as gantt, et as setProp, f as mindmap, g as sequence, h as timeline, i as hash, it as DiagramJSON, j as NODE_PROPS, k as ENUMS, l as kanban, m as chart, n as Options, nt as writeLayout, o as toSource, ot as fromJSON, p as git, q as embedFonts, r as Result, rt as writePanelDrag, s as builtins, st as renderSvg, t as InputFormat, tt as setSetting, u as quadrant, v as footer, w as shapes, x as charts, y as frames, z as MdBlock } from "./index-xVW43gqW.js";
3
+ export { BOOLS, type Box, COLORS, type Component, type ConvertResult, type Curve, type Decoration, type Diagnostic, type Diagram, type DiagramJSON, type Direction, EDGE_PROPS, ENUMS, type EdgeDecl, type EdgeOverride, type FontSource, 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, MD_LANGUAGES, 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 PanelOption, type PanelOverride, type PanelPart, type ParseOptions, type PartAction, type PartChange, type PartEdit, type Point, type Props, RAMPS, type RasterOptions, 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, embedFonts, esc, findBlocks, fontFamilies, fontStack, footer, formatLayout, frames, fromJSON, fromMermaid, gantt, getTheme, git, groupPath, hash, isGenericFont, isMermaid, isSafeCss, isSafeLink, isToneOrHex, isYuhwaPath, joinPath, kanban, layout, legend, lex, lineStyle, lint, loadFonts, markers, mindmap, onlyColor, optionKind, parse, parseInline, parseProps, perPass, portOn, processMarkdown, quadrant, ramp, recolor, registerTheme, registry, render, renderHead, renderSegs, renderSvg, replaceBlockSource, segsW, sequence, serializeProps, setLabel, setLineProp, setPartTone, setProp, setSetting, setTrailingProp, shapes, splitTrailingProps, svgToCanvas, tables, themeNames, themes, timeline, toSource, treeview, tspans, unuse, use, writeLayout, writePanelDrag };
package/dist/index.js CHANGED
@@ -1 +1,5 @@
1
- export { nt as BOOLS, rt as COLORS, it as EDGE_PROPS, at as ENUMS, b as GRID, ot as GROUP_PROPS, i as GUIDE, H as KNOWN_SETTINGS, st as NODE_PROPS, ct as NUMBERS, U as PANELS, lt as PANEL_PROPS, Ct as RAMPS, W as SETTING_VALUES, ft as SHAPES, wt as THEMES, Tt as THEME_KEYS, Et as THEME_NAMES, Dt as TONES, A as approxMeasure, G as blockBraces, C as builtins, j as canvasMeasure, T as chart, P as charts, Ot as createTheme, mt as dashFor, c as editPart, a as findBlocks, k as footer, l as formatLayout, M as frames, v as fromJSON, g as fromMermaid, kt as getTheme, w as git, x as groupPath, t as hash, _ as isMermaid, At as isSafeCss, jt as isSafeLink, Mt as isToneOrHex, K as isYuhwaPath, q as joinPath, S as layout, O as legend, J as lex, ht as lineStyle, dt as lint, Y as onlyColor, I as optionKind, X as parse, _t as parseInline, Z as parseProps, L as perPass, o as processMarkdown, Nt as ramp, R as recolor, Pt as registerTheme, z as registry, n as render, pt as renderHead, yt as renderSegs, y as renderSvg, s as replaceBlockSource, bt as segsW, D as sequence, Q as serializeProps, u as setLabel, $ as setLineProp, d as setPartTone, f as setProp, p as setSetting, et as setTrailingProp, tt as splitTrailingProps, N as tables, Ft as themeNames, F as themes, E as timeline, r as toSource, St as tspans, B as unuse, V as use, m as writeLayout, h as writePanelDrag } from "./src-DkQj7aIV.js";
1
+ import { Bt as getTheme, C as ENUMS, D as PANEL_PROPS, E as NUMBERS, Et as tspans, F as portOn, G as renderHead, Gt as isToneOrHex, Ht as isGenericFont, It as createTheme, Kt as ramp, M as SHAPES, Mt as THEME_KEYS, Nt as THEME_NAMES, Pt as TONES, Rt as fontFamilies, S as EDGE_PROPS, T as NODE_PROPS, Ut as isSafeCss, Wt as isSafeLink, Yt as themeNames, Z as lineStyle, _ as setTrailingProp, b as BOOLS, c as joinPath, ct as esc, d as parse, f as parseProps, g as setLineProp, gt as renderSegs, h as serializeProps, jt as THEMES, k as lint, kt as RAMPS, l as lex, n as PANELS, o as blockBraces, pt as parseInline, q as dashFor, qt as registerTheme, r as SETTING_VALUES, s as isYuhwaPath, t as KNOWN_SETTINGS, u as onlyColor, v as splitTrailingProps, w as GROUP_PROPS, x as COLORS, yt as segsW, zt as fontStack } from "./parse--ljBMU60.js";
2
+ import { a as perPass, c as unuse, i as optionKind, l as use, n as approxMeasure, o as recolor, r as canvasMeasure, s as registry } from "./plugin-CitzbblK.js";
3
+ import { A as gantt, B as charts, C as GRID, D as treeview, E as builtins, F as sequence, H as markers, I as legend, L as footer, M as git, N as chart, O as kanban, P as timeline, R as frames, S as renderSvg, T as layout, U as shapes, V as themes, _ as writeLayout, a as MD_LANGUAGES, b as isMermaid, d as editPart, f as formatLayout, g as setSetting, h as setProp, i as GUIDE, j as mindmap, k as quadrant, l as processMarkdown, m as setPartTone, n as render, o as findBlocks, p as setLabel, r as toSource, t as hash, u as replaceBlockSource, v as writePanelDrag, w as groupPath, x as fromJSON, y as fromMermaid, z as tables } from "./src-NCXCTK_4.js";
4
+ import { n as embedFonts, r as loadFonts, s as svgToCanvas } from "./raster-iqi6XRPU.js";
5
+ export { BOOLS, COLORS, EDGE_PROPS, ENUMS, GRID, GROUP_PROPS, GUIDE, KNOWN_SETTINGS, MD_LANGUAGES, 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, embedFonts, esc, findBlocks, fontFamilies, fontStack, footer, formatLayout, frames, fromJSON, fromMermaid, gantt, getTheme, git, groupPath, hash, isGenericFont, isMermaid, isSafeCss, isSafeLink, isToneOrHex, isYuhwaPath, joinPath, kanban, layout, legend, lex, lineStyle, lint, loadFonts, markers, mindmap, onlyColor, optionKind, parse, parseInline, parseProps, perPass, portOn, processMarkdown, quadrant, ramp, recolor, registerTheme, registry, render, renderHead, renderSegs, renderSvg, replaceBlockSource, segsW, sequence, serializeProps, setLabel, setLineProp, setPartTone, setProp, setSetting, setTrailingProp, shapes, splitTrailingProps, svgToCanvas, tables, themeNames, themes, timeline, toSource, treeview, tspans, unuse, use, writeLayout, writePanelDrag };
@@ -18,7 +18,7 @@
18
18
  * ```yuhwa file="diagrams/arch.yu" renders that file instead of the block.
19
19
  * `zoom: 'inline'` adds the zoom script to `.md` output only; in `.mdx`, import `yuhwa/zoom`.
20
20
  */
21
- import { t as YuhwaDocsOptions } from "./figure-CA2hy0xh.js";
21
+ import { t as YuhwaDocsOptions } from "./figure-BLHfxz_e.js";
22
22
  /** replaces every yuhwa fence in `md` with its rendered figure */
23
23
  export declare function renderFences(md: string, opts?: YuhwaDocsOptions, file?: string): string;
24
24
  interface VitePlugin {
package/dist/ironmark.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as wantsRender, i as toHtml, n as renderBlock, o as zoomTag } from "./node-Bzn2uKXZ.js";
1
+ import { a as toHtml, n as renderBlock, o as wantsRender, s as zoomTag } from "./node-CkrQnPFb.js";
2
2
  // src/integrations/ironmark.ts
3
3
  /**
4
4
  * ironmark support: renders ```yuhwa fences before ironmark parses the file.
@@ -1,3 +1,3 @@
1
- import { t as ServerOptions } from "./server--jHjJjOS.js";
2
- import { a as YuhwaService } from "./service-Brvpt7Do.js";
1
+ import { t as ServerOptions } from "./server-DMAOtqqK.js";
2
+ import { a as YuhwaService } from "./service-DimTFsE3.js";
3
3
  export declare function startWorkerServer(opts?: ServerOptions): YuhwaService;
@@ -1,4 +1,5 @@
1
- import { a as __commonJSMin, i as require_api, n as require_api$2, r as require_api$1, t as startServer } from "./server-Dxo7OG8K.js";
1
+ import { t as __commonJSMin } from "./rolldown-runtime-CEjnN5Q1.js";
2
+ import { i as require_api, n as require_api$2, r as require_api$1, t as startServer } from "./server-BTYtmr6B.js";
2
3
  // ../../node_modules/.pnpm/vscode-jsonrpc@10.0.0/node_modules/vscode-jsonrpc/lib/browser/ril.js
3
4
  var require_ril = /* @__PURE__ */ __commonJSMin(((exports) => {
4
5
  Object.defineProperty(exports, "__esModule", { value: true });
package/dist/lsp-node.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
- import { A as PLACEMENT_PROPS, B as themeNames, C as COLORS, D as NODE_PROPS, E as GROUP_PROPS, F as spanKey, I as THEME_KEYS, M as SPAN_KEYS, O as NUMBERS, P as parseSpanStyle, R as TONES, S as BOOLS, T as ENUMS, V as table, a as onTypeEdits, b as parse, d as optionKind, g as blockBraces, h as SETTING_VALUES, i as format, j as SHAPES, k as PANEL_PROPS, m as PANELS, n as applyChange, o as tidy, p as KNOWN_SETTINGS, r as diffEdits, s as diskResolve, t as VERSION, v as joinPath, w as EDGE_PROPS, x as serializeProps, y as lex } from "./shared-Ddw88O9D.js";
3
+ import { A as BOOLS, B as SPAN_KEYS, C as blockBraces, D as parse, E as lex, F as NODE_PROPS, H as parseSpanStyle, I as NUMBERS, J as themeNames, K as TONES, L as PANEL_PROPS, M as EDGE_PROPS, N as ENUMS, O as serializeProps, P as GROUP_PROPS, R as PLACEMENT_PROPS, S as SETTING_VALUES, T as joinPath, U as spanKey, W as THEME_KEYS, Y as table, a as formatPage, b as KNOWN_SETTINGS, c as diskResolve, i as format, j as COLORS, n as applyChange, o as onTypeEdits, p as isMarkdown, r as diffEdits, s as tidy, t as VERSION, v as optionKind, x as PANELS, z as SHAPES } from "./shared-h8tkFLY4.js";
4
4
  import { fileURLToPath, pathToFileURL } from "node:url";
5
5
  // \0rolldown/runtime.js
6
6
  var __defProp = Object.defineProperty;
@@ -10886,7 +10886,7 @@ function findQuoted(code, q, props) {
10886
10886
  const re = new RegExp(`(?<![\\w-])${q.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w-])`, "g");
10887
10887
  let first = -1;
10888
10888
  for (const m of code.matchAll(re)) {
10889
- const depth = [...code.slice(0, m.index)].reduce((n, c) => n + (c === "[" ? 1 : c === "]" ? -1 : 0), 0);
10889
+ const depth = code.slice(0, m.index).split("").reduce((n, c) => n + (c === "[" ? 1 : c === "]" ? -1 : 0), 0);
10890
10890
  if (props && depth > 0) return m.index;
10891
10891
  if (first < 0) first = m.index;
10892
10892
  }
@@ -11535,6 +11535,10 @@ var YuhwaService = class {
11535
11535
  format(text) {
11536
11536
  return diffEdits(text, format(text));
11537
11537
  }
11538
+ /** Edits that format the diagram blocks of a Markdown page. */
11539
+ formatPage(text) {
11540
+ return diffEdits(text, formatPage(text).text);
11541
+ }
11538
11542
  /** Re-indent after a newline or `}` was typed at `pos`. */
11539
11543
  onType(text, pos, ch) {
11540
11544
  return onTypeEdits(text, pos, ch);
@@ -11570,6 +11574,10 @@ var YuhwaService = class {
11570
11574
  *
11571
11575
  * Diagnostics are pulled (`textDocument/diagnostic`) by clients that can, and
11572
11576
  * pushed (`publishDiagnostics`) to the rest, never both.
11577
+ *
11578
+ * Markdown documents (`.md`, `.mdx`, `.markdown`) only get formatting: the
11579
+ * diagram blocks in them are formatted like `.yu` files. Every other feature
11580
+ * sees them as empty. `yuhwa/formatMarkdown` formats a page sent as text.
11573
11581
  */
11574
11582
  const REQUEST_FAILED = -32803;
11575
11583
  const DEBOUNCE_MS = 150;
@@ -11591,7 +11599,10 @@ function startServer(connection, opts = {}) {
11591
11599
  resolve: (p) => docs.get(p) ?? opts.readFile?.(p),
11592
11600
  files: () => [...docs.keys()]
11593
11601
  });
11602
+ const pages = /* @__PURE__ */ new Map();
11594
11603
  const text = (uri) => docs.get(toPath(uri)) ?? "";
11604
+ const isPage = (uri) => isMarkdown(toPath(uri));
11605
+ const pageText = (uri) => pages.get(toPath(uri));
11595
11606
  let pull = false;
11596
11607
  let refresh = false;
11597
11608
  let watch = false;
@@ -11613,6 +11624,7 @@ function startServer(connection, opts = {}) {
11613
11624
  };
11614
11625
  const changed = (uri, src) => {
11615
11626
  const path = toPath(uri);
11627
+ if (isMarkdown(path)) return void (src === void 0 ? pages.delete(path) : pages.set(path, src));
11616
11628
  if (src === void 0) {
11617
11629
  docs.delete(path);
11618
11630
  uris.delete(path);
@@ -11679,7 +11691,7 @@ function startServer(connection, opts = {}) {
11679
11691
  connection.onDidOpenTextDocument((p) => changed(p.textDocument.uri, p.textDocument.text));
11680
11692
  connection.onDidChangeTextDocument((p) => {
11681
11693
  if (!p.contentChanges.length) return;
11682
- changed(p.textDocument.uri, p.contentChanges.reduce((t, ch) => applyChange(t, ch), text(p.textDocument.uri)));
11694
+ changed(p.textDocument.uri, p.contentChanges.reduce((t, ch) => applyChange(t, ch), pageText(p.textDocument.uri) ?? text(p.textDocument.uri)));
11683
11695
  });
11684
11696
  connection.onDidCloseTextDocument((p) => changed(p.textDocument.uri, void 0));
11685
11697
  connection.onDidChangeWatchedFiles(() => {
@@ -11687,46 +11699,54 @@ function startServer(connection, opts = {}) {
11687
11699
  validate();
11688
11700
  });
11689
11701
  connection.onDidChangeConfiguration(() => {});
11690
- connection.languages.diagnostics.on((p) => ({
11702
+ const yu = (none, f) => (p) => {
11703
+ const uri = p.textDocument.uri;
11704
+ return isPage(uri) ? none : f(p, text(uri), toPath(uri));
11705
+ };
11706
+ connection.languages.diagnostics.on(yu({
11691
11707
  kind: "full",
11692
- items: service.diagnostics(text(p.textDocument.uri), toPath(p.textDocument.uri))
11693
- }));
11694
- connection.onDocumentFormatting((p) => service.format(text(p.textDocument.uri)));
11695
- connection.onDocumentOnTypeFormatting((p) => service.onType(text(p.textDocument.uri), p.position, p.ch));
11696
- connection.onCompletion((p) => service.completion(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri)));
11697
- connection.onHover((p) => service.hover(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri)));
11698
- connection.onDefinition((p) => {
11699
- const t = service.definition(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri));
11708
+ items: []
11709
+ }, (_, src, path) => ({
11710
+ kind: "full",
11711
+ items: service.diagnostics(src, path)
11712
+ })));
11713
+ connection.onDocumentFormatting((p) => isPage(p.textDocument.uri) ? service.formatPage(pageText(p.textDocument.uri) ?? "") : service.format(text(p.textDocument.uri)));
11714
+ connection.onRequest("yuhwa/formatMarkdown", (p) => service.formatPage(p.text));
11715
+ connection.onDocumentOnTypeFormatting(yu([], (p, src) => service.onType(src, p.position, p.ch)));
11716
+ connection.onCompletion(yu([], (p, src, path) => service.completion(src, p.position, path)));
11717
+ connection.onHover(yu(null, (p, src, path) => service.hover(src, p.position, path)));
11718
+ connection.onDefinition(yu(null, (p, src, path) => {
11719
+ const t = service.definition(src, p.position, path);
11700
11720
  return t && {
11701
11721
  uri: t.file ? uris.get(t.file) ?? toUri(t.file) : p.textDocument.uri,
11702
11722
  range: t.range
11703
11723
  };
11704
- });
11705
- connection.onReferences((p) => service.references(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri), p.context.includeDeclaration).map((range) => ({
11724
+ }));
11725
+ connection.onReferences(yu([], (p, src, path) => service.references(src, p.position, path, p.context.includeDeclaration).map((range) => ({
11706
11726
  uri: p.textDocument.uri,
11707
11727
  range
11708
- })));
11709
- connection.onDocumentHighlight((p) => service.highlights(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri)));
11710
- connection.onDocumentSymbol((p) => service.symbols(text(p.textDocument.uri), toPath(p.textDocument.uri)));
11711
- connection.languages.semanticTokens.on((p) => service.semanticTokens(text(p.textDocument.uri), toPath(p.textDocument.uri)));
11712
- connection.onFoldingRanges((p) => service.folding(text(p.textDocument.uri), toPath(p.textDocument.uri)));
11713
- connection.onPrepareRename((p) => {
11714
- const r = service.prepareRename(text(p.textDocument.uri), p.position, toPath(p.textDocument.uri));
11728
+ }))));
11729
+ connection.onDocumentHighlight(yu([], (p, src, path) => service.highlights(src, p.position, path)));
11730
+ connection.onDocumentSymbol(yu([], (_, src, path) => service.symbols(src, path)));
11731
+ connection.languages.semanticTokens.on(yu({ data: [] }, (_, src, path) => service.semanticTokens(src, path)));
11732
+ connection.onFoldingRanges(yu([], (_, src, path) => service.folding(src, path)));
11733
+ connection.onPrepareRename(yu(null, (p, src, path) => {
11734
+ const r = service.prepareRename(src, p.position, path);
11715
11735
  if ("error" in r) throw new import_api.ResponseError(REQUEST_FAILED, r.error);
11716
11736
  return r;
11717
- });
11718
- connection.onRenameRequest((p) => {
11719
- const r = service.rename(text(p.textDocument.uri), p.position, p.newName, toPath(p.textDocument.uri));
11737
+ }));
11738
+ connection.onRenameRequest(yu(null, (p, src, path) => {
11739
+ const r = service.rename(src, p.position, p.newName, path);
11720
11740
  if ("error" in r) throw new import_api.ResponseError(REQUEST_FAILED, r.error);
11721
11741
  return { changes: { [p.textDocument.uri]: r } };
11722
- });
11723
- connection.onCodeAction((p) => service.fixes(text(p.textDocument.uri), p.context.diagnostics).map((f) => ({
11742
+ }));
11743
+ connection.onCodeAction(yu([], (p, src) => service.fixes(src, p.context.diagnostics).map((f) => ({
11724
11744
  title: f.title,
11725
11745
  kind: "quickfix",
11726
11746
  diagnostics: [f.diagnostic],
11727
11747
  isPreferred: true,
11728
11748
  edit: { changes: { [p.textDocument.uri]: f.edits } }
11729
- })));
11749
+ }))));
11730
11750
  connection.listen();
11731
11751
  return service;
11732
11752
  }
@@ -5,6 +5,10 @@
5
5
  *
6
6
  * Diagnostics are pulled (`textDocument/diagnostic`) by clients that can, and
7
7
  * pushed (`publishDiagnostics`) to the rest, never both.
8
+ *
9
+ * Markdown documents (`.md`, `.mdx`, `.markdown`) only get formatting: the
10
+ * diagram blocks in them are formatted like `.yu` files. Every other feature
11
+ * sees them as empty. `yuhwa/formatMarkdown` formats a page sent as text.
8
12
  */
9
- import { n as startServer, t as ServerOptions } from "./server--jHjJjOS.js";
13
+ import { n as startServer, t as ServerOptions } from "./server-DMAOtqqK.js";
10
14
  export { ServerOptions, startServer };
@@ -1 +1 @@
1
- export { t as startServer } from "./server-Dxo7OG8K.js";
1
+ export { t as startServer } from "./server-BTYtmr6B.js";
package/dist/lsp.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as YuhwaService, i as Target, n as SEMANTIC_LEGEND, r as ServiceOptions, t as Fix } from "./service-Brvpt7Do.js";
1
+ import { a as YuhwaService, i as Target, n as SEMANTIC_LEGEND, r as ServiceOptions, t as Fix } from "./service-DimTFsE3.js";
2
2
  import { H as Position, U as Range, nt as TextEdit } from "./main-DYrwpkoa.js";
3
3
  /** Format yuhwa source. Returns the new text; whitespace is all that changes. */
4
4
  export declare function format(text: string): string;
package/dist/lsp.js CHANGED
@@ -1 +1 @@
1
- export { t as SEMANTIC_LEGEND, n as YuhwaService, r as applyChange, i as closeIndent, a as diffEdits, o as enterEdit, s as format, c as newlineIndent, l as newlinePrefix, u as offsetAt, d as onTypeEdits, f as positionAt, p as shiftLines } from "./service-B1fpOg_L.js";
1
+ export { t as SEMANTIC_LEGEND, n as YuhwaService, r as applyChange, i as closeIndent, a as diffEdits, o as enterEdit, s as format, c as newlineIndent, l as newlinePrefix, u as offsetAt, d as onTypeEdits, f as positionAt, p as shiftLines } from "./service-C60VdeKS.js";
@@ -9,7 +9,7 @@
9
9
  * A fence with `no-render` (```yuhwa no-render) stays a code block.
10
10
  * ```yuhwa file="diagrams/arch.yu" renders that file instead of the block.
11
11
  */
12
- import { t as YuhwaDocsOptions } from "./figure-CA2hy0xh.js";
12
+ import { t as YuhwaDocsOptions } from "./figure-BLHfxz_e.js";
13
13
  type Rule = (tokens: any[], idx: number, options: any, env: any, self: any) => string;
14
14
  interface MarkdownIt {
15
15
  renderer: {
@@ -1,4 +1,5 @@
1
- import { a as wantsRender, i as toHtml, n as renderBlock, o as zoomTag } from "./node-Bzn2uKXZ.js";
1
+ import { a as toHtml, n as renderBlock, o as wantsRender, s as zoomTag } from "./node-CkrQnPFb.js";
2
+ import { a as MD_LANGUAGES } from "./src-NCXCTK_4.js";
2
3
  // src/integrations/markdown-it.ts
3
4
  /**
4
5
  * markdown-it plugin: renders ```yuhwa fences at build time.
@@ -17,11 +18,12 @@ function fileOf(env) {
17
18
  }
18
19
  function yuhwaMarkdownIt(md, opts = {}) {
19
20
  const fence = md.renderer.rules.fence;
21
+ const languages = opts.languages ?? MD_LANGUAGES;
20
22
  md.renderer.rules.fence = (tokens, idx, options, env, self) => {
21
23
  const token = tokens[idx];
22
24
  const [lang, ...meta] = token.info.trim().split(/\s+/);
23
- if (!wantsRender(lang, meta.join(" "), opts.languages)) {
24
- if (lang && (opts.languages ?? ["yuhwa"]).includes(lang)) token.info = lang;
25
+ if (!wantsRender(lang, meta.join(" "), languages)) {
26
+ if (lang && languages.includes(lang)) token.info = "yuhwa";
25
27
  return fence(tokens, idx, options, env, self);
26
28
  }
27
29
  const file = fileOf(env);