yuhwa 1.13.0 → 1.13.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.
- package/dist/{api-CvcW76ln.js → api-BhYpvwgH.js} +1 -1
- package/dist/{api-B4MhXD5r.d.ts → api-rTVcLrc8.d.ts} +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +3 -3
- package/dist/cli.js +159 -4
- package/dist/editor/assets/{index-B2_IDuGn.js → index-CXrkLt53.js} +3 -3
- package/dist/editor/assets/lsp.worker-BJIWqNrh.js +63 -0
- package/dist/editor/index.html +1 -1
- package/dist/{figure-B2E8CnNn.d.ts → figure-BmaGxB4V.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/ironmark.d.ts +1 -1
- package/dist/ironmark.js +1 -1
- package/dist/llms.txt +1 -1
- package/dist/lsp-browser.js +1 -1
- package/dist/lsp-node.js +1 -1
- package/dist/lsp-server.js +1 -1
- package/dist/lsp.js +1 -1
- package/dist/markdown-it.d.ts +1 -1
- package/dist/markdown-it.js +2 -2
- package/dist/{node-hhZr8r_F.js → node-DkjPCH6f.js} +2 -2
- package/dist/{plugins-Dwt5Qgzs.js → plugins-pAwqigp-.js} +60 -42
- package/dist/plugins.js +1 -1
- package/dist/remark.d.ts +1 -1
- package/dist/remark.js +1 -1
- package/dist/satteri.d.ts +1 -1
- package/dist/satteri.js +1 -1
- package/dist/{server-DQz_f9N-.js → server-CstXES9J.js} +2 -2
- package/dist/{service-DmbUk4C1.js → service-AhMJkrM4.js} +2 -2
- package/dist/{shared-C3N1_jLr.js → shared-1cLUDhoj.js} +63 -45
- package/dist/slim.d.ts +1 -1
- package/dist/slim.js +1 -1
- package/dist/{src-HtHsgFUt.js → src-i3e13pro.js} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +3 -3
- package/dist/vuepress.d.ts +1 -1
- package/dist/vuepress.js +1 -1
- package/dist/yuhwa.iife.js +2 -2
- package/package.json +1 -1
- package/dist/editor/assets/lsp.worker-IGttpwSP.js +0 -63
|
@@ -9369,7 +9369,7 @@ function fromGitLog(text, opts = {}) {
|
|
|
9369
9369
|
line: 1,
|
|
9370
9370
|
message: "merges of more than two branches are drawn with their first two parents"
|
|
9371
9371
|
});
|
|
9372
|
-
const header = [`direction: ${opts.direction ?? "
|
|
9372
|
+
const header = [`direction: ${opts.direction ?? "up"}`];
|
|
9373
9373
|
if (main !== "main") header.push(`main: ${prop(panelName.get(main) ?? main)}`);
|
|
9374
9374
|
return {
|
|
9375
9375
|
source: [
|
|
@@ -280,7 +280,7 @@ interface GitLogOptions {
|
|
|
280
280
|
title?: string;
|
|
281
281
|
/** the trunk branch; default main, master, trunk or develop, whichever is there */
|
|
282
282
|
main?: string;
|
|
283
|
-
/** `
|
|
283
|
+
/** `up` (default: newest on top, like `git log --graph`), `down`, `right` or `left` */
|
|
284
284
|
direction?: string;
|
|
285
285
|
}
|
|
286
286
|
/** true when every non-empty line is a `GIT_LOG_FORMAT` record */
|
package/dist/astro.d.ts
CHANGED
package/dist/astro.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import remarkYuhwa from "./remark.js";
|
|
2
2
|
import satteriYuhwa from "./satteri.js";
|
|
3
|
-
import { n as onTrack, o as clientImports, r as pagesUsing } from "./node-
|
|
3
|
+
import { n as onTrack, o as clientImports, r as pagesUsing } from "./node-DkjPCH6f.js";
|
|
4
4
|
// src/integrations/astro.ts
|
|
5
5
|
/**
|
|
6
6
|
* Astro integration, also for Starlight: renders ```yuhwa blocks in .md and
|
package/dist/browser.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* el.source = 'a -> b' // re-renders
|
|
13
13
|
*/
|
|
14
14
|
import { $ as PanelOverride, $t as LineStyle, A as AlignSide, An as approxMeasure, At as optionKind, B as GroupDecl, Bt as Seg, C as serializeProps, Cn as isToneOrHex, Ct as PanelKind, Dt as RowPaint, E as splitTrailingProps, En as registerTheme, Et as RowKind, F as DiagnosticCode, Ft as use, G as LaidNode, Gt as parseInline, H as LabelRef, I as Diagram, It as MarkerKind, J as LayoutOverrides, Jt as segsW, K as LaidPanel, L as Direction, Lt as ShapeKind, M as Component, Mt as recolor, N as Curve, Nt as registry, On as themeNames, Ot as StatementKind, P as Diagnostic, Pt as unuse, Q as PanelHandle, R as EdgeDecl, Rt as renderHead, Sn as isSafeLink, St as PanelCtx, T as setTrailingProp, Tn as ramp, Tt as RowCtx, U as LaidEdge, V as HeadKind, Vt as esc, W as LaidGroup, X as NodeOverride, Y as NodeDecl, Z as PanelDecl, Zt as tspans, _ as TokKind, _n as getScheme, an as Scheme, at as Props, b as onlyColor, bn as isGenericFont, bt as Decoration, cn as THEME_NAMES, ct as ShapeName, d as TextOptions, dn as ThemeInput, dt as dashFor, et as PanelPart, g as Tok, gn as fontStack, gt as lineStyle, h as LexedLine, hn as fontFamilies, ht as groupProp, in as SCHEMES, it as Point, j as Box, jn as canvasMeasure, jt as perPass, k as Align, kt as YuhwaPlugin, ln as TONES, lt as Side, mt as groupPath, nn as RAMPS, nt as PartChange, on as THEMES, ot as ResolvedEdgeStyle, pn as createTheme, q as Layout, qt as renderSegs, r as portOn, rt as PartEdit, sn as THEME_KEYS, st as ResolvedNodeStyle, t as SHAPES, tn as PLAIN_THEMES, tt as PartAction, un as Theme, ut as SourceRef, v as blockBraces, vn as getTheme, w as setLineProp, wn as plainThemeNames, wt as PanelOption, x as parseProps, xn as isSafeCss, xt as FrameKind, y as lex, z as EdgeOverride, zt as InkColors } from "./shapes-EDGQ3ksZ.js";
|
|
15
|
-
import { $ as MdResult, A as fromPackages, At as PANELS, B as parseTable, C as formatSize, Ct as JsonResult, D as isSql, Dt as parse, E as fromSql, Et as layout, F as TableKind, G as fromGitLog, H as GitActivityOptions, I as TableOptions, J as fromMermaid, K as isGitLog, L as fromTable, M as TABLE_KINDS, Mt as SETTING_HELP, N as TABLE_ROLES, Nt as SETTING_VALUES, O as DepsOptions, Ot as isYuhwaPath, P as Table, Pt as ParseOptions, Q as MdOptions, R as parseDate, S as FilesOptions, St as DiagramJSON, T as parseGitStatus, Tt as renderSvg, U as GitLogOptions, V as GIT_LOG_FORMAT, W as fromGitActivity, X as MD_LANGUAGES, Y as isMermaid, Z as MdBlock, _ as lint, _t as setSetting, at as embedFonts, b as SourceFile, bt as ALIGN_SIDES, c as BOOLS, ct as Target, d as ENUMS, dt as editPart, et as findBlocks, f as GROUP_PROPS, ft as formatLayout, g as PANEL_PROP_HELP, gt as setProp, h as PANEL_PROPS, ht as setPartTone, i as hash, it as RasterOptions, j as Role, jt as KNOWN_SETTINGS, k as PackageFile, kt as joinPath, l as COLORS, lt as addEdge, m as NUMBERS, mt as setLabel, n as Options, nt as replaceBlockSource, o as renderText, ot as loadFonts, p as NODE_PROPS, pt as removeElement, q as ConvertResult, r as Result, rt as FontSource, s as toSource, st as svgToCanvas, t as InputFormat, tt as processMarkdown, u as EDGE_PROPS, ut as addNode, v as TypeScriptOptions, vt as writeLayout, w as fromFiles, wt as fromJSON, x as FileStatus, xt as GRID, y as fromTypeScript, yt as writePanelDrag, z as parseNumber } from "./api-
|
|
15
|
+
import { $ as MdResult, A as fromPackages, At as PANELS, B as parseTable, C as formatSize, Ct as JsonResult, D as isSql, Dt as parse, E as fromSql, Et as layout, F as TableKind, G as fromGitLog, H as GitActivityOptions, I as TableOptions, J as fromMermaid, K as isGitLog, L as fromTable, M as TABLE_KINDS, Mt as SETTING_HELP, N as TABLE_ROLES, Nt as SETTING_VALUES, O as DepsOptions, Ot as isYuhwaPath, P as Table, Pt as ParseOptions, Q as MdOptions, R as parseDate, S as FilesOptions, St as DiagramJSON, T as parseGitStatus, Tt as renderSvg, U as GitLogOptions, V as GIT_LOG_FORMAT, W as fromGitActivity, X as MD_LANGUAGES, Y as isMermaid, Z as MdBlock, _ as lint, _t as setSetting, at as embedFonts, b as SourceFile, bt as ALIGN_SIDES, c as BOOLS, ct as Target, d as ENUMS, dt as editPart, et as findBlocks, f as GROUP_PROPS, ft as formatLayout, g as PANEL_PROP_HELP, gt as setProp, h as PANEL_PROPS, ht as setPartTone, i as hash, it as RasterOptions, j as Role, jt as KNOWN_SETTINGS, k as PackageFile, kt as joinPath, l as COLORS, lt as addEdge, m as NUMBERS, mt as setLabel, n as Options, nt as replaceBlockSource, o as renderText, ot as loadFonts, p as NODE_PROPS, pt as removeElement, q as ConvertResult, r as Result, rt as FontSource, s as toSource, st as svgToCanvas, t as InputFormat, tt as processMarkdown, u as EDGE_PROPS, ut as addNode, v as TypeScriptOptions, vt as writeLayout, w as fromFiles, wt as fromJSON, x as FileStatus, xt as GRID, y as fromTypeScript, yt as writePanelDrag, z as parseNumber } from "./api-rTVcLrc8.js";
|
|
16
16
|
import { t as GUIDE } from "./index-Bab6qq3T.js";
|
|
17
17
|
import { _ as markers, a as gantt, c as chart, d as legend, f as footer, g as themes, h as charts, i as quadrant, l as timeline, m as tables, n as treeview, o as mindmap, p as frames, r as kanban, s as git, t as builtins, u as sequence, v as shapes } from "./index-D9DnkCVK.js";
|
|
18
18
|
import { i as zoomable, n as Zoomer, r as zoomHeight, t as ZoomOptions } from "./zoom-CCSUbX1X.js";
|
package/dist/browser.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as GUIDE } from "./src-
|
|
1
|
+
import { t as GUIDE } from "./src-i3e13pro.js";
|
|
2
2
|
import { S as PANELS, _ as unuse, d as canvasMeasure, g as registry, h as recolor, m as perPass, p as optionKind, u as approxMeasure, v as use } from "./plugin-BCLARrq1.js";
|
|
3
3
|
import { n as zoomable, t as zoomHeight } from "./zoom-D3Lahr1T.js";
|
|
4
|
-
import { A as shapes, C as legend, D as charts, E as tables, O as themes, S as sequence, T as frames, _ as gantt, b as chart, g as quadrant, h as kanban, k as markers, m as treeview, t as builtins, v as mindmap, w as footer, x as timeline, y as git } from "./plugins-
|
|
4
|
+
import { A as shapes, C as legend, D as charts, E as tables, O as themes, S as sequence, T as frames, _ as gantt, b as chart, g as quadrant, h as kanban, k as markers, m as treeview, t as builtins, v as mindmap, w as footer, x as timeline, y as git } from "./plugins-pAwqigp-.js";
|
|
5
5
|
import { a as svgFamilies, c as swapForRaster, n as embedFonts, r as loadFonts, s as svgToCanvas } from "./raster-D1uJMbl7.js";
|
|
6
6
|
import { Bn as plainThemeNames, C as SETTING_VALUES, Cn as SCHEMES, Ct as ALIGN_SIDES, D as EDGE_PROPS, Dn as TONES, E as COLORS, En as THEME_NAMES, Ft as groupProp, H as SHAPES, Hn as registerTheme, In as isGenericFont, K as portOn, Ln as isSafeCss, M as NUMBERS, Mn as fontStack, N as PANEL_PROPS, Nn as getScheme, O as ENUMS, Ot as dashFor, P as PANEL_PROP_HELP, Pn as getTheme, Pt as groupPath, Qt as esc, Rn as isSafeLink, Rt as lineStyle, T as BOOLS, Tn as THEME_KEYS, Vn as ramp, Wn as themeNames, _n as tspans, a as lex, b as KNOWN_SETTINGS, bn as PLAIN_THEMES, c as parseProps, d as serializeProps, h as splitTrailingProps, i as blockBraces, in as parseInline, j as NODE_PROPS, jn as fontFamilies, k as GROUP_PROPS, kn as createTheme, m as setTrailingProp, p as setLineProp, rt as renderHead, s as onlyColor, sn as renderSegs, un as segsW, v as unquote, wn as THEMES, x as SETTING_HELP, xn as RAMPS, z as lint, zn as isToneOrHex } from "./lex-BODknbgk.js";
|
|
7
|
-
import { A as setSetting, B as isMermaid, C as addNode, D as setLabel, E as removeElement, F as GIT_LOG_FORMAT, G as parse, H as renderSvg, I as fromGitActivity, K as isYuhwaPath, L as fromGitLog, M as writePanelDrag, N as fromSql, O as setPartTone, P as isSql, R as isGitLog, S as addEdge, T as formatLayout, U as layout, V as fromJSON, W as GRID, _ as findBlocks, a as fromTypeScript, b as processMarkdown, c as parseGitStatus, d as TABLE_ROLES, f as fromTable, g as MD_LANGUAGES, h as parseTable, i as toSource, j as writeLayout, k as setProp, l as fromPackages, m as parseNumber, n as render$1, o as formatSize, p as parseDate, q as joinPath, r as renderText, s as fromFiles, t as hash, u as TABLE_KINDS, w as editPart, x as replaceBlockSource, z as fromMermaid } from "./api-
|
|
7
|
+
import { A as setSetting, B as isMermaid, C as addNode, D as setLabel, E as removeElement, F as GIT_LOG_FORMAT, G as parse, H as renderSvg, I as fromGitActivity, K as isYuhwaPath, L as fromGitLog, M as writePanelDrag, N as fromSql, O as setPartTone, P as isSql, R as isGitLog, S as addEdge, T as formatLayout, U as layout, V as fromJSON, W as GRID, _ as findBlocks, a as fromTypeScript, b as processMarkdown, c as parseGitStatus, d as TABLE_ROLES, f as fromTable, g as MD_LANGUAGES, h as parseTable, i as toSource, j as writeLayout, k as setProp, l as fromPackages, m as parseNumber, n as render$1, o as formatSize, p as parseDate, q as joinPath, r as renderText, s as fromFiles, t as hash, u as TABLE_KINDS, w as editPart, x as replaceBlockSource, z as fromMermaid } from "./api-BhYpvwgH.js";
|
|
8
8
|
// src/browser.ts
|
|
9
9
|
/**
|
|
10
10
|
* Drop-in browser runtime: <script src="yuhwa.js"><\/script>
|
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,118 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { D as canvasMeasure, E as toId, F as
|
|
3
|
+
import { A as blockBraces, D as canvasMeasure, E as toId, F as serializeProps, G as EDGE_PROPS, I as serializeValue, J as NODE_PROPS, K as ENUMS, L as unquote, M as parseProps, N as propKey, O as optionKind, P as quote, R as PANELS, S as parse, T as q, V as SETTING_VALUES, W as COLORS, X as PANEL_PROPS, _ as replaceBlockSource, a as formatPage, at as esc, b as fromGitActivity, c as diskResolve, d as toSource, dt as THEME_KEYS, et as SHAPES, f as MD_LANGUAGES, ft as THEME_NAMES, g as processMarkdown, h as pageBlocks, i as format, j as lex, k as registry, l as render$1, lt as PLAIN_THEMES, m as isMarkdown, mt as isSafeCss, nt as ALIGN_SIDES_HINT, ot as parseInline, p as findBlocks, pt as TONES, q as GROUP_PROPS, s as tidy, t as VERSION, u as renderText, ut as SCHEMES, v as fromSql, vt as isYuhwaPath, w as edgeLabel, x as fromGitLog, y as GIT_LOG_FORMAT, yt as joinPath, z as KNOWN_SETTINGS } from "./shared-1cLUDhoj.js";
|
|
4
4
|
import { createServer } from "node:http";
|
|
5
5
|
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { execFileSync, spawn } from "node:child_process";
|
|
8
8
|
import { randomBytes } from "node:crypto";
|
|
9
9
|
import { deflateSync, inflateRawSync, inflateSync } from "node:zlib";
|
|
10
|
+
// src/core/edit.ts
|
|
11
|
+
/** the source's lines without their endings; `joinLines` writes them back with the source's own ending */
|
|
12
|
+
const splitLines = (source) => source.split(/\r?\n/);
|
|
13
|
+
const eol = (source) => source.includes("\r\n") ? "\r\n" : "\n";
|
|
14
|
+
const joinLines = (lines, source) => lines.join(eol(source));
|
|
15
|
+
/** set or remove one key in the `[...]` block on the statement's own line */
|
|
16
|
+
function editInline(lines, ref, kind, key, value) {
|
|
17
|
+
const text = lines[ref.line];
|
|
18
|
+
let props = {};
|
|
19
|
+
let start = ref.insertAt;
|
|
20
|
+
let end = ref.insertAt;
|
|
21
|
+
if (ref.props) {
|
|
22
|
+
[start, end] = ref.props;
|
|
23
|
+
props = parseProps(text.slice(start + 1, text[end - 1] === "]" ? end - 1 : end));
|
|
24
|
+
}
|
|
25
|
+
if (value === null) delete props[key];
|
|
26
|
+
else props[key] = value;
|
|
27
|
+
const body = serializeProps(props);
|
|
28
|
+
const block = body ? `[${body}]` : "";
|
|
29
|
+
const before = text.slice(0, start);
|
|
30
|
+
const after = text.slice(end);
|
|
31
|
+
lines[ref.line] = ref.props ? before + block + after : before + (block ? (ref.prefix ?? "") + " " + block : "") + after;
|
|
32
|
+
if (!body && ref.props) {
|
|
33
|
+
let head = before.replace(/\s+$/, "");
|
|
34
|
+
if (kind === "edge" && head.endsWith(":") && !after.trim()) head = head.slice(0, -1).replace(/\s+$/, "");
|
|
35
|
+
lines[ref.line] = (head + after).replace(/\s+$/, "");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const findDecl = (d, target) => target.kind === "node" ? d.nodes.get(target.id) : target.kind === "group" ? d.groups.get(target.id) : target.kind === "panel" ? d.panels.find((p) => p.id === target.id) : d.edges.find((e) => e.key === target.id);
|
|
39
|
+
/** implicit node: declare it near the top-level statements */
|
|
40
|
+
function declare(source, lines, d, add) {
|
|
41
|
+
let at = d.layoutBlock ? d.layoutBlock[0] : lines.length;
|
|
42
|
+
if (d.layoutBlock && at > 1 && !lines[at - 1].trim() && lines[at - 2].trim()) at--;
|
|
43
|
+
const insert = d.layoutBlock && at > 0 && lines[at - 1].trim() && lines[at].trim() ? [...add, ""] : add;
|
|
44
|
+
if (!d.layoutBlock && lines[lines.length - 1] === "") lines.splice(lines.length - 1, 0, ...insert);
|
|
45
|
+
else lines.splice(at, 0, ...insert);
|
|
46
|
+
return joinLines(lines, source);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Shorthand flags a prop replaces: setting `style: solid` on a `[dotted]`
|
|
50
|
+
* edge must drop `dotted`, or the flag keeps winning on the next read.
|
|
51
|
+
*/
|
|
52
|
+
const REPLACES = {
|
|
53
|
+
style: ["dashed", "dotted"],
|
|
54
|
+
"border-style": ["dashed", "dotted"]
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Set (value = string) or remove (value = null) one prop on a node, edge, group
|
|
58
|
+
* or panel header.
|
|
59
|
+
* Implicit nodes (only mentioned in edges) get a declaration line appended.
|
|
60
|
+
*/
|
|
61
|
+
function setProp(source, target, key, value, d = parse(source)) {
|
|
62
|
+
key = propKey(key);
|
|
63
|
+
const decl = findDecl(d, target);
|
|
64
|
+
if (!decl) return source;
|
|
65
|
+
let out = writeProp(source, target, key, value, d, decl);
|
|
66
|
+
for (const k of (REPLACES[key] ?? []).filter((k) => k in decl.props)) out = setProp(out, target, k, null);
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
function writeProp(source, target, key, value, d, decl) {
|
|
70
|
+
const lines = splitLines(source);
|
|
71
|
+
const ref = decl.ref?.generated ? void 0 : decl.ref;
|
|
72
|
+
if (!ref) {
|
|
73
|
+
if (value === null || target.kind === "panel") return source;
|
|
74
|
+
return declare(source, lines, d, [`${target.id} [${serializeProps({ [key]: value })}]`]);
|
|
75
|
+
}
|
|
76
|
+
const pl = ref.propLines;
|
|
77
|
+
if (pl) {
|
|
78
|
+
const inline = ref.props ? parseProps(lines[ref.line].slice(ref.props[0] + 1, ref.props[1] - 1)) : {};
|
|
79
|
+
if (key in pl) {
|
|
80
|
+
if (value === null) lines.splice(pl[key], 1);
|
|
81
|
+
else lines[pl[key]] = `${indentOf(lines[pl[key]])}${key}: ${serializeValue(value)}`;
|
|
82
|
+
if (key in inline) editInline(lines, ref, target.kind, key, null);
|
|
83
|
+
return joinLines(lines, source);
|
|
84
|
+
}
|
|
85
|
+
if (value !== null && !(key in inline)) {
|
|
86
|
+
const at = Math.max(...Object.values(pl));
|
|
87
|
+
lines.splice(at + 1, 0, `${indentOf(lines[at])}${key}: ${serializeValue(value)}`);
|
|
88
|
+
return joinLines(lines, source);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
editInline(lines, ref, target.kind, key, value);
|
|
92
|
+
return joinLines(lines, source);
|
|
93
|
+
}
|
|
94
|
+
/** Set or remove a top-level `key: value` setting. */
|
|
95
|
+
function setSetting(source, key, value) {
|
|
96
|
+
const lines = splitLines(source);
|
|
97
|
+
const re = new RegExp(`^(export\\s+)?${key.replace(/[-]/g, "\\-")}\\s*:`);
|
|
98
|
+
let depth = 0;
|
|
99
|
+
const idx = lines.findIndex((l) => {
|
|
100
|
+
if (depth === 0 && re.test(l)) return true;
|
|
101
|
+
for (const b of blockBraces(lex(l).tokens)) depth = Math.max(0, depth + (b === "{" ? 1 : -1));
|
|
102
|
+
return false;
|
|
103
|
+
});
|
|
104
|
+
if (idx >= 0) {
|
|
105
|
+
if (value === null) lines.splice(idx, 1);
|
|
106
|
+
else lines[idx] = `${lines[idx].match(re)[1] ?? ""}${key}: ${value}`;
|
|
107
|
+
return joinLines(lines, source);
|
|
108
|
+
}
|
|
109
|
+
if (value === null) return source;
|
|
110
|
+
let at = 0;
|
|
111
|
+
while (at < lines.length && /^(export\s+)?[\w-]+\s*:(?!:)/.test(lines[at]) && !lines[at].includes("->") || /^\s*(\/\/|#)/.test(lines[at] ?? "")) at++;
|
|
112
|
+
lines.splice(at, 0, `${key}: ${value}`);
|
|
113
|
+
return joinLines(lines, source);
|
|
114
|
+
}
|
|
115
|
+
const indentOf = (line) => line.match(/^\s*/)[0];
|
|
10
116
|
// src/raster.ts
|
|
11
117
|
/**
|
|
12
118
|
* Drawing a rendered SVG into a canvas. No side effects on import, so the
|
|
@@ -3664,8 +3770,48 @@ function fromDeps(args) {
|
|
|
3664
3770
|
production: !!args.production
|
|
3665
3771
|
});
|
|
3666
3772
|
}
|
|
3667
|
-
/**
|
|
3773
|
+
/**
|
|
3774
|
+
* `--set key=value` (repeatable) and `--direction x`: options of the diagram
|
|
3775
|
+
* the importer drew. A key the panel takes goes into its header `[...]`, any
|
|
3776
|
+
* setting into a top-level line, and a panel style such as `color` into the
|
|
3777
|
+
* header again: `--set direction=left` turns a git panel, `--set theme=paper`
|
|
3778
|
+
* themes the whole page.
|
|
3779
|
+
*/
|
|
3780
|
+
function applyOptions(source, args) {
|
|
3781
|
+
const pairs = [];
|
|
3782
|
+
if (str$1(args.direction)) pairs.push(["direction", str$1(args.direction)]);
|
|
3783
|
+
for (const pair of [args.set ?? []].flat()) {
|
|
3784
|
+
const [key, value] = String(pair).split(/=(.*)/s);
|
|
3785
|
+
if (!key || value === void 0) throw new Error(`from: --set takes key=value, got "${pair}"`);
|
|
3786
|
+
pairs.push([key.trim(), value.trim()]);
|
|
3787
|
+
}
|
|
3788
|
+
let out = source;
|
|
3789
|
+
for (const [key, value] of pairs) {
|
|
3790
|
+
const diagram = parse(out);
|
|
3791
|
+
const options = diagram.panels.filter((panel) => key in (PANELS.get(panel.kind)?.options ?? {}));
|
|
3792
|
+
const styled = KNOWN_SETTINGS.has(key) || !PANEL_PROPS.includes(key) ? [] : diagram.panels;
|
|
3793
|
+
const takers = options.length ? options : styled;
|
|
3794
|
+
if (takers.length) for (const panel of takers) out = setProp(out, {
|
|
3795
|
+
kind: "panel",
|
|
3796
|
+
id: panel.id
|
|
3797
|
+
}, key, value);
|
|
3798
|
+
else if (KNOWN_SETTINGS.has(key)) out = setSetting(out, key, value);
|
|
3799
|
+
else {
|
|
3800
|
+
const kinds = [...new Set(diagram.panels.map((panel) => panel.kind))];
|
|
3801
|
+
throw new Error(`from: --set ${key} is not a setting${kinds.length ? ` or an option of the ${kinds.join(", ")} panel` : ""}`);
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
return out;
|
|
3805
|
+
}
|
|
3806
|
+
/** runs the importer for `args._[1]`, then applies `--set` and `--direction` */
|
|
3668
3807
|
function runFrom(args, read) {
|
|
3808
|
+
const result = convertFrom(args, read);
|
|
3809
|
+
return {
|
|
3810
|
+
...result,
|
|
3811
|
+
source: applyOptions(result.source, args)
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3814
|
+
function convertFrom(args, read) {
|
|
3669
3815
|
const kind = args._[1];
|
|
3670
3816
|
if (kind === "git") return fromGit(args);
|
|
3671
3817
|
if (kind === "tree") return fromTree(args);
|
|
@@ -3691,6 +3837,7 @@ Usage
|
|
|
3691
3837
|
yuhwa from class <file.ts|dir...> [--exported] [--no-assoc] [-o out.yu|out.svg]
|
|
3692
3838
|
yuhwa from data <file.csv|.tsv|.json|.md|-> [--as chart|gantt|kanban|...] [--type bar] [--col role=Column] [-o out.yu|out.svg]
|
|
3693
3839
|
yuhwa from deps [dir] [--external] [--production] [-o out.yu|out.svg]
|
|
3840
|
+
yuhwa from ... [--set key=value] [--direction right|down|left|up]
|
|
3694
3841
|
yuhwa md <file.md...> [--out-dir diagrams] [--dark] [--keep-fences] [--view[=base]]
|
|
3695
3842
|
yuhwa edit <file.yu|file.md> [--block n] [--port 4747] [--no-open]
|
|
3696
3843
|
yuhwa serve [--port 4749] [--host 127.0.0.1]
|
|
@@ -3744,6 +3891,8 @@ from Build a diagram from the real thing. git: the history of a repository
|
|
|
3744
3891
|
deps: package.json dependencies; in a workspace (npm, yarn, pnpm)
|
|
3745
3892
|
which package uses which, --external adds outside packages,
|
|
3746
3893
|
--production leaves dev dependencies out.
|
|
3894
|
+
--set key=value (repeatable) sets an option of the panel drawn, or a
|
|
3895
|
+
setting such as theme; --direction is short for --set direction=x.
|
|
3747
3896
|
Writes yuhwa source, or renders when -o names .svg/.png/.html/.txt.
|
|
3748
3897
|
md Render every yuhwa block in Markdown files, write the SVGs and
|
|
3749
3898
|
insert or update the image reference below each block. --view
|
|
@@ -3779,9 +3928,15 @@ const VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
|
3779
3928
|
"title",
|
|
3780
3929
|
"as",
|
|
3781
3930
|
"type",
|
|
3782
|
-
"col"
|
|
3931
|
+
"col",
|
|
3932
|
+
"set",
|
|
3933
|
+
"direction"
|
|
3934
|
+
]);
|
|
3935
|
+
const REPEATABLE = /* @__PURE__ */ new Set([
|
|
3936
|
+
"font",
|
|
3937
|
+
"col",
|
|
3938
|
+
"set"
|
|
3783
3939
|
]);
|
|
3784
|
-
const REPEATABLE = /* @__PURE__ */ new Set(["font", "col"]);
|
|
3785
3940
|
function parseArgs(argv) {
|
|
3786
3941
|
const a = { _: [] };
|
|
3787
3942
|
for (let i = 0; i < argv.length; i++) {
|