yuhwa 1.0.1 → 1.0.2
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/astro.d.ts +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/cli.js +26 -22
- package/dist/editor/assets/index-BQLsumas.js +587 -0
- package/dist/editor/assets/lsp.worker-RlPj9blG.js +26 -0
- package/dist/editor/index.html +1 -1
- package/dist/{figure-Cp1kIReq.d.ts → figure-BZHIKnxv.d.ts} +1 -1
- package/dist/{index-DY1ZuIhZ.d.ts → index-Dl845tUQ.d.ts} +19 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/ironmark.d.ts +1 -1
- package/dist/ironmark.js +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 +1 -1
- package/dist/{node-D5c2mPhI.js → node-Bneu5eJV.js} +1 -1
- package/dist/remark.d.ts +1 -1
- package/dist/remark.js +1 -1
- package/dist/{server--6FqJ1gI.js → server-DmQuHQrG.js} +1 -1
- package/dist/{service-DDbTh7nO.js → service-BYS9Qfkq.js} +1 -1
- package/dist/{shared-CEPwGvSm.js → shared-qo_r6RUN.js} +355 -288
- package/dist/{src-Dl2VCr7N.js → src-wk7tBpWs.js} +387 -288
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/dist/vuepress.d.ts +1 -1
- package/dist/yuhwa.iife.js +62 -60
- package/package.json +1 -1
- package/dist/editor/assets/index-B1-eRTKY.js +0 -585
- package/dist/editor/assets/lsp.worker-C79O_uwt.js +0 -26
package/dist/astro.d.ts
CHANGED
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
|
|
11
|
+
import { $ as PANELS, $t as PanelCtx, A as MdBlock, An as isSafeLink, At as Layout, B as setProp, Bt as PartEdit, C as NODE_PROPS, Cn as THEME_NAMES, Ct as GroupDecl, D as ConvertResult, Dn as createTheme, Dt as LaidGroup, E as lint, En as ThemeInput, Et as LaidEdge, F as replaceBlockSource, Fn as approxMeasure, Ft as PanelHandle, G as lineStyle, Gt as ShapeName, H as writeLayout, Ht as Props, I as editPart, In as canvasMeasure, It as PanelOverride, J as JsonResult, Jt as GRID, K as SHAPES, Kt as Side, L as formatLayout, Lt as PanelPart, M as MdResult, Mn as ramp, Mt as NodeDecl, N as findBlocks, Nn as registerTheme, Nt as NodeOverride, O as fromMermaid, On as getTheme, Ot as LaidNode, P as processMarkdown, Pn as themeNames, Pt as PanelDecl, Q as LexedLine, Qt as FrameKind, R as setLabel, Rt as PartAction, S as GROUP_PROPS, Sn as THEME_KEYS, St as EdgeOverride, T as PANEL_PROPS, Tn as Theme, Tt as LabelRef, U as writePanelDrag, Ut as ResolvedEdgeStyle, V as setSetting, Vt as Point, W as dashFor, Wt as ResolvedNodeStyle, X as renderSvg, Xt as layout, Y as fromJSON, Yt as groupPath, Z as KNOWN_SETTINGS, Zt as Decoration, _ as themes, _n as segsW, _t as Curve, an as YuhwaPlugin, at as isYuhwaPath, b as EDGE_PROPS, bn as RAMPS, bt as Direction, c as git, cn as registry, ct as onlyColor, d as sequence, dn as ShapeKind, dt as serializeProps, en as PanelKind, et as ParseOptions, f as legend, fn as renderHead, ft as setLineProp, g as charts, gn as renderSegs, gt as Component, h as tables, hn as parseInline, ht as Box, i as hash, in as StatementKind, it as blockBraces, j as MdOptions, jn as isToneOrHex, jt as LayoutOverrides, k as isMermaid, kn as isSafeCss, kt as LaidPanel, l as chart, ln as use, lt as parse, m as frames, mn as Seg, mt as splitTrailingProps, n as Options, nn as RowKind, nt as Tok, o as toSource, on as perPass, ot as joinPath, p as footer, pn as InkColors, pt as setTrailingProp, q as DiagramJSON, qt as SourceRef, r as Result, rn as RowPaint, rt as TokKind, s as builtins, sn as recolor, st as lex, t as InputFormat, tn as RowCtx, tt as SETTING_VALUES, u as timeline, un as MarkerKind, ut as parseProps, v as GUIDE, vn as tspans, vt as Diagnostic, w as NUMBERS, wn as TONES, wt as HeadKind, x as ENUMS, xn as THEMES, xt as EdgeDecl, y as BOOLS, yn as LineStyle, yt as Diagram, z as setPartTone, zt as PartChange } from "./index-Dl845tUQ.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
|
|
@@ -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, 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 };
|
|
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, isSafeCss, isSafeLink, 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, writePanelDrag };
|
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as splitTrailingProps, A as canvasMeasure, B as KNOWN_SETTINGS, C as builtins, Ct as isSafeCss, D as sequence, Dt as registerTheme, E as timeline, Et as ramp, F as themes, G as joinPath, H as SETTING_VALUES, I as perPass, J as parse, K as lex, L as recolor, M as frames, N as tables, O as legend, Ot as themeNames, P as charts, Q as setTrailingProp, R as registry, S as layout, St as getTheme, T as chart, Tt as isToneOrHex, U as blockBraces, V as PANELS, W as isYuhwaPath, X as serializeProps, Y as parseProps, Z as setLineProp, _ as isMermaid, _t as THEMES, a as findBlocks, at as NUMBERS, b as GRID, bt as TONES, c as editPart, ct as SHAPES, d as setPartTone, dt as lineStyle, et as BOOLS, f as setProp, ft as parseInline, g as fromMermaid, gt as RAMPS, h as writePanelDrag, ht as tspans, i as GUIDE, it as NODE_PROPS, j as footer, k as approxMeasure, l as formatLayout, lt as renderHead, m as writeLayout, mt as segsW, n as render$1, nt as ENUMS, o as processMarkdown, ot as PANEL_PROPS, p as setSetting, pt as renderSegs, q as onlyColor, r as toSource, rt as GROUP_PROPS, s as replaceBlockSource, st as lint, t as hash, tt as EDGE_PROPS, u as setLabel, ut as dashFor, v as fromJSON, vt as THEME_KEYS, w as git, wt as isSafeLink, x as groupPath, xt as createTheme, y as renderSvg, yt as THEME_NAMES, z as use } from "./src-wk7tBpWs.js";
|
|
2
2
|
// src/browser.ts
|
|
3
3
|
/**
|
|
4
4
|
* Drop-in browser runtime: <script src="yuhwa.js"><\/script>
|
|
@@ -164,4 +164,4 @@ if (typeof document !== "undefined") {
|
|
|
164
164
|
else run();
|
|
165
165
|
}
|
|
166
166
|
}
|
|
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 };
|
|
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, isSafeCss, isSafeLink, 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, writePanelDrag };
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { C as PANEL_PROPS, D as TONES, E as THEME_NAMES, T as THEME_KEYS, a as canvasMeasure, b as GROUP_PROPS, c as KNOWN_SETTINGS, f as isYuhwaPath, n as render$1, o as registry, p as joinPath$1, r as toSource, s as diskResolve, t as VERSION, u as SETTING_VALUES, v as EDGE_PROPS, w as SHAPES, x as NODE_PROPS, y as ENUMS } from "./shared-
|
|
3
|
+
import { C as PANEL_PROPS, D as TONES, E as THEME_NAMES, T as THEME_KEYS, a as canvasMeasure, b as GROUP_PROPS, c as KNOWN_SETTINGS, f as isYuhwaPath, n as render$1, o as registry, p as joinPath$1, r as toSource, s as diskResolve, t as VERSION, u as SETTING_VALUES, v as EDGE_PROPS, w as SHAPES, x as NODE_PROPS, y as ENUMS } from "./shared-qo_r6RUN.js";
|
|
4
4
|
import { createServer } from "node:http";
|
|
5
|
-
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
5
|
+
import { basename, dirname, extname, join, resolve, sep } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
8
|
import { deflateSync, inflateRawSync, inflateSync } from "node:zlib";
|
|
@@ -374,16 +374,15 @@ function decodeSource(encoded, compressed) {
|
|
|
374
374
|
return inflateRawSync(buf).toString("utf8");
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
function readBody(req) {
|
|
377
|
+
function readBody(req, max = MAX_BODY) {
|
|
378
378
|
return new Promise((ok, fail) => {
|
|
379
379
|
let size = 0;
|
|
380
380
|
const chunks = [];
|
|
381
381
|
req.on("data", (c) => {
|
|
382
382
|
size += c.length;
|
|
383
|
-
if (size
|
|
384
|
-
else chunks.push(c);
|
|
383
|
+
if (size <= max) chunks.push(c);
|
|
385
384
|
});
|
|
386
|
-
req.on("end", () => ok(Buffer.concat(chunks).toString("utf8")));
|
|
385
|
+
req.on("end", () => size > max ? fail(Object.assign(/* @__PURE__ */ new Error("body too large"), { status: 413 })) : ok(Buffer.concat(chunks).toString("utf8")));
|
|
387
386
|
req.on("error", fail);
|
|
388
387
|
});
|
|
389
388
|
}
|
|
@@ -424,6 +423,8 @@ function handler(req, res) {
|
|
|
424
423
|
const r = render$1(source, { theme });
|
|
425
424
|
const errors = r.diagnostics.filter((d) => d.severity === "error");
|
|
426
425
|
res.setHeader("content-type", "image/svg+xml; charset=utf-8");
|
|
426
|
+
res.setHeader("content-security-policy", "default-src 'none'; style-src 'unsafe-inline'; img-src data:");
|
|
427
|
+
res.setHeader("x-content-type-options", "nosniff");
|
|
427
428
|
res.setHeader("x-yuhwa-format", r.format);
|
|
428
429
|
if (errors.length) res.setHeader("x-yuhwa-errors", errors.map((d) => `${d.line}: ${d.message}`).join(" | ").slice(0, 2e3));
|
|
429
430
|
if (cache && !errors.length) res.setHeader("cache-control", "public, max-age=31536000, immutable");
|
|
@@ -881,7 +882,14 @@ function cmdEdit(a) {
|
|
|
881
882
|
}
|
|
882
883
|
if (url.pathname === "/api/source") {
|
|
883
884
|
if (req.method === "GET") {
|
|
884
|
-
|
|
885
|
+
let source;
|
|
886
|
+
try {
|
|
887
|
+
source = readSource();
|
|
888
|
+
} catch (e) {
|
|
889
|
+
res.statusCode = 500;
|
|
890
|
+
res.end(JSON.stringify({ error: String(e) }));
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
885
893
|
fetchImports(source, basename(file), async (p) => diskResolve(join(base, p)) ?? Promise.reject(/* @__PURE__ */ new Error(`cannot import ${p}`))).then((files) => {
|
|
886
894
|
for (const p of Object.keys(files)) loaded.add(p);
|
|
887
895
|
res.setHeader("content-type", "application/json");
|
|
@@ -895,27 +903,23 @@ function cmdEdit(a) {
|
|
|
895
903
|
return;
|
|
896
904
|
}
|
|
897
905
|
if (req.method === "PUT") {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
} catch (e) {
|
|
909
|
-
res.statusCode = 400;
|
|
910
|
-
res.end(JSON.stringify({ error: String(e) }));
|
|
911
|
-
}
|
|
906
|
+
readBody(req, 16 << 20).then((body) => {
|
|
907
|
+
const j = JSON.parse(body);
|
|
908
|
+
const written = saveEditorFiles(file, mainName, isMd ? blockIdx : void 0, loaded, j);
|
|
909
|
+
res.end(JSON.stringify({
|
|
910
|
+
ok: true,
|
|
911
|
+
written
|
|
912
|
+
}));
|
|
913
|
+
}).catch((e) => {
|
|
914
|
+
res.statusCode = e.status ?? 400;
|
|
915
|
+
res.end(JSON.stringify({ error: String(e) }));
|
|
912
916
|
});
|
|
913
917
|
return;
|
|
914
918
|
}
|
|
915
919
|
}
|
|
916
920
|
const name = url.pathname === "/" ? "index.html" : url.pathname.slice(1);
|
|
917
921
|
const p = join(dir, name);
|
|
918
|
-
if (!p.startsWith(dir) || !existsSync(p) || statSync(p).isDirectory()) {
|
|
922
|
+
if (!p.startsWith(dir + sep) || !existsSync(p) || statSync(p).isDirectory()) {
|
|
919
923
|
res.statusCode = 404;
|
|
920
924
|
res.end("not found");
|
|
921
925
|
return;
|