@cardenelabs/dragon 0.45.5 → 0.46.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/README.ja.md +331 -0
- package/README.md +200 -188
- package/dist/cli.cjs +148 -111
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +148 -111
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +139 -109
- package/dist/export.cjs.map +1 -1
- package/dist/export.js +139 -109
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +99 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +99 -62
- package/dist/index.js.map +1 -1
- package/dist/light/chunk-CLS6JVKK.cjs.map +1 -1
- package/dist/light/{chunk-EHTQUCW4.js → chunk-DVGDEPCV.js} +6 -2
- package/dist/light/chunk-DVGDEPCV.js.map +1 -0
- package/dist/light/{chunk-5OQV42W3.cjs → chunk-SUL4AJLI.cjs} +6 -2
- package/dist/light/chunk-SUL4AJLI.cjs.map +1 -0
- package/dist/light/{chunk-JCEKXALJ.cjs → chunk-V34DCH34.cjs} +90 -87
- package/dist/light/chunk-V34DCH34.cjs.map +1 -0
- package/dist/light/{chunk-YEQSLVIN.js → chunk-YO3UBEC3.js} +12 -9
- package/dist/light/chunk-YO3UBEC3.js.map +1 -0
- package/dist/light/{git-K3KAAAWW.cjs → git-WBGFDRBD.cjs} +59 -59
- package/dist/light/git-WBGFDRBD.cjs.map +1 -0
- package/dist/light/{git-GESUYKGR.js → git-WEJL6VAY.js} +3 -3
- package/dist/light/index.cjs +407 -375
- package/dist/light/index.cjs.map +1 -1
- package/dist/light/index.js +92 -60
- package/dist/light/index.js.map +1 -1
- package/dist/light/{lineup-2V2U7HZH.js → lineup-6LN6Z5T2.js} +3 -3
- package/dist/light/{lineup-623J25LU.cjs → lineup-WLGNGTFX.cjs} +40 -40
- package/dist/light/lineup-WLGNGTFX.cjs.map +1 -0
- package/dist/light/{state-T4OTVING.js → state-DFYTMQI7.js} +2 -2
- package/dist/light/{state-OZVCHX7H.cjs → state-JVAH4TSM.cjs} +41 -41
- package/dist/light/state-JVAH4TSM.cjs.map +1 -0
- package/dist/light/{time-KVMZIKYF.cjs → time-EXRPI34B.cjs} +84 -84
- package/dist/light/time-EXRPI34B.cjs.map +1 -0
- package/dist/light/{time-O4CMTUV5.js → time-M3EGEFDU.js} +3 -3
- package/dist/light/{tree-6D7KI57H.cjs → tree-DECHTXFU.cjs} +62 -62
- package/dist/light/tree-DECHTXFU.cjs.map +1 -0
- package/dist/light/{tree-ZJZQI5QT.js → tree-MFU54QKY.js} +3 -3
- package/dist/node.cjs +115 -49
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +115 -49
- package/dist/node.js.map +1 -1
- package/dist/player.global.js +3 -3
- package/package.json +1 -1
- package/src/field-messages.ts +4 -0
- package/src/look/values.ts +5 -1
- package/src/messages.ts +11 -1
- package/src/nearest.ts +37 -0
- package/src/parser.ts +4 -2
- package/src/render/draw.ts +2 -1
- package/src/render/parts.ts +28 -7
- package/src/schema.ts +27 -3
- package/src/schemas/diagram.schema.json +3 -2
- package/src/schemas/validate-diagram.js +1 -1
- package/dist/light/chunk-5OQV42W3.cjs.map +0 -1
- package/dist/light/chunk-EHTQUCW4.js.map +0 -1
- package/dist/light/chunk-JCEKXALJ.cjs.map +0 -1
- package/dist/light/chunk-YEQSLVIN.js.map +0 -1
- package/dist/light/git-K3KAAAWW.cjs.map +0 -1
- package/dist/light/lineup-623J25LU.cjs.map +0 -1
- package/dist/light/state-OZVCHX7H.cjs.map +0 -1
- package/dist/light/time-KVMZIKYF.cjs.map +0 -1
- package/dist/light/tree-6D7KI57H.cjs.map +0 -1
- /package/dist/light/{git-GESUYKGR.js.map → git-WEJL6VAY.js.map} +0 -0
- /package/dist/light/{lineup-2V2U7HZH.js.map → lineup-6LN6Z5T2.js.map} +0 -0
- /package/dist/light/{state-T4OTVING.js.map → state-DFYTMQI7.js.map} +0 -0
- /package/dist/light/{time-O4CMTUV5.js.map → time-M3EGEFDU.js.map} +0 -0
- /package/dist/light/{tree-ZJZQI5QT.js.map → tree-MFU54QKY.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -319,7 +319,11 @@ var LOOK = {
|
|
|
319
319
|
gap: 10,
|
|
320
320
|
/** 図の外周の余白 */
|
|
321
321
|
margin: 14,
|
|
322
|
-
|
|
322
|
+
/**
|
|
323
|
+
* 箱。`iconY` と `nameY` と `subY` は箱の真ん中から絵柄の真ん中と名前と下の字の基準線まで。
|
|
324
|
+
* `nameMid` と `subMid` はアイコンも置き場の枠も持つ箱が無い図の名前と下の字の基準線で、名前を箱の真ん中に置き、下の字を名前から `subY - nameY` と同じ間で置く (#3307、#3309)
|
|
325
|
+
*/
|
|
326
|
+
box: { h: 72, minW: 92, padX: 12, radius: 12, icon: 24, iconRadius: 7, iconY: -16, iconScale: 0.74, nameY: 12, nameMid: 5, subY: 27, subMid: 20 },
|
|
323
327
|
region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
|
|
324
328
|
architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
|
|
325
329
|
/**
|
|
@@ -830,8 +834,8 @@ function longest(points) {
|
|
|
830
834
|
}
|
|
831
835
|
return { a: best.a, b: best.b, vertical: Math.abs(best.b[0] - best.a[0]) < Math.abs(best.b[1] - best.a[1]) };
|
|
832
836
|
}
|
|
833
|
-
function along(points,
|
|
834
|
-
let left =
|
|
837
|
+
function along(points, distance2) {
|
|
838
|
+
let left = distance2;
|
|
835
839
|
for (let i = 1; i < points.length; i++) {
|
|
836
840
|
const a = points[i - 1];
|
|
837
841
|
const b = points[i];
|
|
@@ -1750,7 +1754,7 @@ var linkTo = (link, markup) => link === void 0 ? markup : `<a href="${esc(link)}
|
|
|
1750
1754
|
var r1 = (v) => Math.round(v * 100) / 100;
|
|
1751
1755
|
var cs = (k) => k === "coin" ? "--c:var(--coin);--ct:var(--coint)" : `--c:var(--c-${k});--ct:var(--t-${k})`;
|
|
1752
1756
|
function glyph(name2, x, y, scale, cls = "dg-gl") {
|
|
1753
|
-
const d = name2
|
|
1757
|
+
const d = name2 !== void 0 && drawsIcon(name2) ? ICONS[name2] : void 0;
|
|
1754
1758
|
return d ? `<path class="${cls}" transform="translate(${r1(x)} ${r1(y)}) scale(${scale})" d="${d}"/>` : "";
|
|
1755
1759
|
}
|
|
1756
1760
|
function iconSvg(name2) {
|
|
@@ -1786,6 +1790,8 @@ function arrowHead(points) {
|
|
|
1786
1790
|
const { arrow: a, arrowHalf: h } = LOOK.edge;
|
|
1787
1791
|
return `M ${r1(ex - dx * a - dy * h)} ${r1(ey - dy * a + dx * h)} L ${r1(ex)} ${r1(ey)} L ${r1(ex - dx * a + dy * h)} ${r1(ey - dy * a - dx * h)}`;
|
|
1788
1792
|
}
|
|
1793
|
+
var drawsIcon = (name2) => name2 !== void 0 && Object.hasOwn(ICONS, name2);
|
|
1794
|
+
var boxTextY = (boxes) => boxes.some((b) => drawsIcon(b.icon) || b.slot !== void 0) ? { name: LOOK.box.nameY, sub: LOOK.box.subY } : { name: LOOK.box.nameMid, sub: LOOK.box.subMid };
|
|
1789
1795
|
var sansOf = (t) => ({ ...t, family: "sans" });
|
|
1790
1796
|
function write(ink, cls, x, y, text2, style, shown2 = ALWAYS, anchor) {
|
|
1791
1797
|
ink?.push({ text: text2, rect: textBox(text2, x, y, style, anchor), shown: shown2 });
|
|
@@ -1812,7 +1818,7 @@ function band(region, ink) {
|
|
|
1812
1818
|
const { x, y } = region.header;
|
|
1813
1819
|
const lines = region.lines.map((t, k) => write(ink, "dg-bz", x, region.y + nameY + k * line2, t, TYPE.regionName)).join("");
|
|
1814
1820
|
const note = region.note ? write(ink, "dg-bx", x, region.y + nameY + region.lines.length * line2 + 1, region.note, TYPE.regionNote) : "";
|
|
1815
|
-
const mark = region.icon
|
|
1821
|
+
const mark = drawsIcon(region.icon) ? `<rect class="dg-bi" x="${r1(x)}" y="${r1(y)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(region.icon, x + icon / 2, y + icon / 2, iconScale)}` : "";
|
|
1816
1822
|
return `<g style="${cs(region.color)}"><rect class="dg-band" x="${r1(region.x + 0.5)}" y="${r1(region.y + 0.5)}" width="${r1(region.w - 1)}" height="${r1(region.h - 1)}" rx="${radius}"/>${mark}${lines}${note}</g>`;
|
|
1817
1823
|
}
|
|
1818
1824
|
function subLines(box, m, changes, y, ink, right) {
|
|
@@ -1832,18 +1838,18 @@ function cardFrame(box, ctx, act, y, h) {
|
|
|
1832
1838
|
return `${act ? `<g class="dg-a" style="${act}">${rect("dg-halo")}</g>` : ""}${rect("dg-st", ` ${ctx.sh}`)}${act ? `<g class="dg-a" style="${act}">${rect("dg-on")}</g>` : ""}`;
|
|
1833
1839
|
}
|
|
1834
1840
|
function card(box, ctx, on, changes, lit) {
|
|
1835
|
-
const { icon, iconRadius, iconScale, iconY
|
|
1836
|
-
const subs = subLines(box, ctx.m, changes, box.cy +
|
|
1841
|
+
const { icon, iconRadius, iconScale, iconY } = LOOK.box;
|
|
1842
|
+
const subs = subLines(box, ctx.m, changes, box.cy + ctx.boxText.sub, ctx.ink);
|
|
1837
1843
|
const act = lit ? lit.length > 0 ? rangeKf(ctx.m, lit.map((s) => [s.start, s.end])) : void 0 : on.length > 0 ? activeKf(ctx, on) : void 0;
|
|
1838
1844
|
const ix = box.iconX ?? box.cx;
|
|
1839
1845
|
const slot = box.slot ? `<rect class="dg-slot" x="${r1(box.slot.x)}" y="${r1(box.slot.y)}" width="${r1(box.slot.w)}" height="${r1(box.slot.h)}" rx="${LOOK.slot.radius}"/>` : "";
|
|
1840
1846
|
let mark = "";
|
|
1841
|
-
if (box.icon
|
|
1847
|
+
if (drawsIcon(box.icon)) {
|
|
1842
1848
|
const rect = { x: ix - icon / 2, y: box.cy + iconY - icon / 2, w: icon, h: icon };
|
|
1843
1849
|
ctx.ink.push({ text: `${box.name} \u306E\u7D75\u67C4`, rect, shown: ALWAYS, boxed: true, part: { kind: "icon", box: box.name } });
|
|
1844
1850
|
mark = `<rect class="dg-ic" x="${r1(rect.x)}" y="${r1(rect.y)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, ix, box.cy + iconY, iconScale)}`;
|
|
1845
1851
|
}
|
|
1846
|
-
return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${slot}${mark}${write(ctx.ink, "dg-sn", box.cx, box.cy +
|
|
1852
|
+
return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${slot}${mark}${write(ctx.ink, "dg-sn", box.cx, box.cy + ctx.boxText.name, box.name, TYPE.boxName, ALWAYS, "middle")}${subs}</g>`;
|
|
1847
1853
|
}
|
|
1848
1854
|
function headCard(box, ctx, on, changes) {
|
|
1849
1855
|
const { pad: pad2, h, nameY, subY } = LOOK.follow.head;
|
|
@@ -1856,7 +1862,7 @@ function ghostCard(box, ink) {
|
|
|
1856
1862
|
const G = LOOK.state.ghost;
|
|
1857
1863
|
const ix = box.x + G.pad + icon / 2;
|
|
1858
1864
|
const tx = box.x + G.pad + icon + G.gap;
|
|
1859
|
-
const mark = box.icon
|
|
1865
|
+
const mark = drawsIcon(box.icon) ? `<rect class="dg-ic" x="${r1(ix - icon / 2)}" y="${r1(box.cy - icon / 2)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, ix, box.cy, iconScale)}` : "";
|
|
1860
1866
|
const nameY = box.sub ? G.nameY : LOOK.baseline.mark;
|
|
1861
1867
|
const sub = box.sub ? write(ink, "dg-ss", tx, box.cy + G.subY, box.sub, TYPE.boxSub, ALWAYS, "start") : "";
|
|
1862
1868
|
return `<g data-ghost="${esc(box.id)}" style="${cs(box.color)}"><rect class="dg-ghost" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${radius}"/>${mark}${write(ink, "dg-sn", tx, box.cy + nameY, box.name, TYPE.boxName, ALWAYS, "start")}${sub}</g>`;
|
|
@@ -3966,6 +3972,33 @@ function extractDiagrams(markdown) {
|
|
|
3966
3972
|
return fences;
|
|
3967
3973
|
}
|
|
3968
3974
|
|
|
3975
|
+
// src/nearest.ts
|
|
3976
|
+
var MAX_DISTANCE = 2;
|
|
3977
|
+
function nearest(word, candidates) {
|
|
3978
|
+
const written = [...word.toLowerCase()];
|
|
3979
|
+
let limit = Math.min(MAX_DISTANCE, written.length - 1);
|
|
3980
|
+
let best;
|
|
3981
|
+
for (const candidate of candidates) {
|
|
3982
|
+
const d = distance(written, [...candidate.toLowerCase()]);
|
|
3983
|
+
if (d > limit) continue;
|
|
3984
|
+
best = candidate;
|
|
3985
|
+
limit = d - 1;
|
|
3986
|
+
}
|
|
3987
|
+
return best;
|
|
3988
|
+
}
|
|
3989
|
+
function distance(a, b) {
|
|
3990
|
+
let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
3991
|
+
for (let i = 1; i <= a.length; i++) {
|
|
3992
|
+
const current = [i];
|
|
3993
|
+
for (let j = 1; j <= b.length; j++) {
|
|
3994
|
+
const replace = previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1);
|
|
3995
|
+
current.push(Math.min(previous[j] + 1, current[j - 1] + 1, replace));
|
|
3996
|
+
}
|
|
3997
|
+
previous = current;
|
|
3998
|
+
}
|
|
3999
|
+
return previous[b.length];
|
|
4000
|
+
}
|
|
4001
|
+
|
|
3969
4002
|
// src/field-messages.ts
|
|
3970
4003
|
var TYPES_JA = {
|
|
3971
4004
|
string: "\u6587\u5B57\u5217\u306B\u3059\u308B",
|
|
@@ -3990,6 +4023,7 @@ var ja2 = {
|
|
|
3990
4023
|
additionalProperties: (key2) => `${key2} \u3068\u3044\u3046\u6B04\u306F\u66F8\u3051\u306A\u3044`,
|
|
3991
4024
|
required: (key2) => `${key2} \u306E\u6B04\u304C\u8981\u308B`,
|
|
3992
4025
|
enum: (values) => `${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
|
|
4026
|
+
unknownIcon: (value2, near) => `${value2} \u3068\u3044\u3046 icon \u306F\u7121\u3044\u3002\u8FD1\u3044\u540D\u524D\u306F ${near}`,
|
|
3993
4027
|
type: (type) => TYPES_JA[type] ?? `${type} \u306B\u3059\u308B`,
|
|
3994
4028
|
minLength: (limit) => `${limit} \u5B57\u4EE5\u4E0A\u66F8\u304F`,
|
|
3995
4029
|
maxLength: (limit) => `${limit} \u5B57\u307E\u3067\u306B\u3059\u308B`,
|
|
@@ -4014,6 +4048,7 @@ var en = {
|
|
|
4014
4048
|
additionalProperties: (key2) => `The ${key2} field is not allowed`,
|
|
4015
4049
|
required: (key2) => `The ${key2} field is required`,
|
|
4016
4050
|
enum: (values) => `Use one of ${values.join(" / ")}`,
|
|
4051
|
+
unknownIcon: (value2, near) => `There is no icon named ${value2}. The closest is ${near}`,
|
|
4017
4052
|
type: (type) => TYPES_EN[type] ?? `Use ${type}`,
|
|
4018
4053
|
minLength: (limit) => `Write at least ${plural(limit, "character")}`,
|
|
4019
4054
|
maxLength: (limit) => `Write at most ${plural(limit, "character")}`,
|
|
@@ -4994,6 +5029,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
4994
5029
|
return errors === 0;
|
|
4995
5030
|
}
|
|
4996
5031
|
var schema79 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
|
|
5032
|
+
var schema80 = { "enum": ["app", "router", "on", "off", "pool", "db", "exe", "idx", "sign", "env", "lock", "check", "flag", "x", "chain", "net", "user", "server", "key", "shield", "globe", "bolt", "doc", "box", "truck", "card", "cart", "clock", "branch", "cloud", "refresh", "undo", "yen", "layers", "code", "paint", "tree", "block"] };
|
|
4997
5033
|
var pattern0 = new RegExp("^[^\\s\\[\\]\u300C\u300D=:]+$", "u");
|
|
4998
5034
|
var func3 = ucs2length;
|
|
4999
5035
|
function validate30(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
@@ -5109,32 +5145,22 @@ function validate30(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
5109
5145
|
}
|
|
5110
5146
|
if (data.icon !== void 0) {
|
|
5111
5147
|
let data4 = data.icon;
|
|
5112
|
-
if (
|
|
5113
|
-
|
|
5114
|
-
const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
5115
|
-
if (vErrors === null) {
|
|
5116
|
-
vErrors = [err10];
|
|
5117
|
-
} else {
|
|
5118
|
-
vErrors.push(err10);
|
|
5119
|
-
}
|
|
5120
|
-
errors++;
|
|
5121
|
-
}
|
|
5122
|
-
} else {
|
|
5123
|
-
const err11 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
5148
|
+
if (!(data4 === "app" || data4 === "router" || data4 === "on" || data4 === "off" || data4 === "pool" || data4 === "db" || data4 === "exe" || data4 === "idx" || data4 === "sign" || data4 === "env" || data4 === "lock" || data4 === "check" || data4 === "flag" || data4 === "x" || data4 === "chain" || data4 === "net" || data4 === "user" || data4 === "server" || data4 === "key" || data4 === "shield" || data4 === "globe" || data4 === "bolt" || data4 === "doc" || data4 === "box" || data4 === "truck" || data4 === "card" || data4 === "cart" || data4 === "clock" || data4 === "branch" || data4 === "cloud" || data4 === "refresh" || data4 === "undo" || data4 === "yen" || data4 === "layers" || data4 === "code" || data4 === "paint" || data4 === "tree" || data4 === "block")) {
|
|
5149
|
+
const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/icon/enum", keyword: "enum", params: { allowedValues: schema80.enum }, message: "must be equal to one of the allowed values" };
|
|
5124
5150
|
if (vErrors === null) {
|
|
5125
|
-
vErrors = [
|
|
5151
|
+
vErrors = [err10];
|
|
5126
5152
|
} else {
|
|
5127
|
-
vErrors.push(
|
|
5153
|
+
vErrors.push(err10);
|
|
5128
5154
|
}
|
|
5129
5155
|
errors++;
|
|
5130
5156
|
}
|
|
5131
5157
|
}
|
|
5132
5158
|
} else {
|
|
5133
|
-
const
|
|
5159
|
+
const err11 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
5134
5160
|
if (vErrors === null) {
|
|
5135
|
-
vErrors = [
|
|
5161
|
+
vErrors = [err11];
|
|
5136
5162
|
} else {
|
|
5137
|
-
vErrors.push(
|
|
5163
|
+
vErrors.push(err11);
|
|
5138
5164
|
}
|
|
5139
5165
|
errors++;
|
|
5140
5166
|
}
|
|
@@ -5255,22 +5281,12 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
5255
5281
|
}
|
|
5256
5282
|
if (data.icon !== void 0) {
|
|
5257
5283
|
let data4 = data.icon;
|
|
5258
|
-
if (
|
|
5259
|
-
|
|
5260
|
-
const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
5261
|
-
if (vErrors === null) {
|
|
5262
|
-
vErrors = [err10];
|
|
5263
|
-
} else {
|
|
5264
|
-
vErrors.push(err10);
|
|
5265
|
-
}
|
|
5266
|
-
errors++;
|
|
5267
|
-
}
|
|
5268
|
-
} else {
|
|
5269
|
-
const err11 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
5284
|
+
if (!(data4 === "app" || data4 === "router" || data4 === "on" || data4 === "off" || data4 === "pool" || data4 === "db" || data4 === "exe" || data4 === "idx" || data4 === "sign" || data4 === "env" || data4 === "lock" || data4 === "check" || data4 === "flag" || data4 === "x" || data4 === "chain" || data4 === "net" || data4 === "user" || data4 === "server" || data4 === "key" || data4 === "shield" || data4 === "globe" || data4 === "bolt" || data4 === "doc" || data4 === "box" || data4 === "truck" || data4 === "card" || data4 === "cart" || data4 === "clock" || data4 === "branch" || data4 === "cloud" || data4 === "refresh" || data4 === "undo" || data4 === "yen" || data4 === "layers" || data4 === "code" || data4 === "paint" || data4 === "tree" || data4 === "block")) {
|
|
5285
|
+
const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/icon/enum", keyword: "enum", params: { allowedValues: schema80.enum }, message: "must be equal to one of the allowed values" };
|
|
5270
5286
|
if (vErrors === null) {
|
|
5271
|
-
vErrors = [
|
|
5287
|
+
vErrors = [err10];
|
|
5272
5288
|
} else {
|
|
5273
|
-
vErrors.push(
|
|
5289
|
+
vErrors.push(err10);
|
|
5274
5290
|
}
|
|
5275
5291
|
errors++;
|
|
5276
5292
|
}
|
|
@@ -5279,20 +5295,20 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
5279
5295
|
let data5 = data.region;
|
|
5280
5296
|
if (typeof data5 === "string") {
|
|
5281
5297
|
if (!pattern0.test(data5)) {
|
|
5282
|
-
const
|
|
5298
|
+
const err11 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
5283
5299
|
if (vErrors === null) {
|
|
5284
|
-
vErrors = [
|
|
5300
|
+
vErrors = [err11];
|
|
5285
5301
|
} else {
|
|
5286
|
-
vErrors.push(
|
|
5302
|
+
vErrors.push(err11);
|
|
5287
5303
|
}
|
|
5288
5304
|
errors++;
|
|
5289
5305
|
}
|
|
5290
5306
|
} else {
|
|
5291
|
-
const
|
|
5307
|
+
const err12 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
5292
5308
|
if (vErrors === null) {
|
|
5293
|
-
vErrors = [
|
|
5309
|
+
vErrors = [err12];
|
|
5294
5310
|
} else {
|
|
5295
|
-
vErrors.push(
|
|
5311
|
+
vErrors.push(err12);
|
|
5296
5312
|
}
|
|
5297
5313
|
errors++;
|
|
5298
5314
|
}
|
|
@@ -5301,30 +5317,30 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
5301
5317
|
let data6 = data.link;
|
|
5302
5318
|
if (typeof data6 === "string") {
|
|
5303
5319
|
if (!pattern3.test(data6)) {
|
|
5304
|
-
const
|
|
5320
|
+
const err13 = { instancePath: instancePath + "/link", schemaPath: "#/definitions/url/pattern", keyword: "pattern", params: { pattern: "^(/|https?://)" }, message: 'must match pattern "^(/|https?://)"' };
|
|
5305
5321
|
if (vErrors === null) {
|
|
5306
|
-
vErrors = [
|
|
5322
|
+
vErrors = [err13];
|
|
5307
5323
|
} else {
|
|
5308
|
-
vErrors.push(
|
|
5324
|
+
vErrors.push(err13);
|
|
5309
5325
|
}
|
|
5310
5326
|
errors++;
|
|
5311
5327
|
}
|
|
5312
5328
|
} else {
|
|
5313
|
-
const
|
|
5329
|
+
const err14 = { instancePath: instancePath + "/link", schemaPath: "#/definitions/url/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
5314
5330
|
if (vErrors === null) {
|
|
5315
|
-
vErrors = [
|
|
5331
|
+
vErrors = [err14];
|
|
5316
5332
|
} else {
|
|
5317
|
-
vErrors.push(
|
|
5333
|
+
vErrors.push(err14);
|
|
5318
5334
|
}
|
|
5319
5335
|
errors++;
|
|
5320
5336
|
}
|
|
5321
5337
|
}
|
|
5322
5338
|
} else {
|
|
5323
|
-
const
|
|
5339
|
+
const err15 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
5324
5340
|
if (vErrors === null) {
|
|
5325
|
-
vErrors = [
|
|
5341
|
+
vErrors = [err15];
|
|
5326
5342
|
} else {
|
|
5327
|
-
vErrors.push(
|
|
5343
|
+
vErrors.push(err15);
|
|
5328
5344
|
}
|
|
5329
5345
|
errors++;
|
|
5330
5346
|
}
|
|
@@ -10376,6 +10392,7 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
10376
10392
|
|
|
10377
10393
|
// src/schema.ts
|
|
10378
10394
|
var COLORS = ["blue", "amber", "green", "violet", "rose", "slate", "coin"];
|
|
10395
|
+
var ICON_NAMES = Object.keys(ICONS);
|
|
10379
10396
|
var EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch", "now", "mark", "span", "leaf", "node", "line", "seal", "open", "pick", "stamp"];
|
|
10380
10397
|
var ABSENT = "#/definitions/absent/not";
|
|
10381
10398
|
var ABSENT_KINDS = {
|
|
@@ -10405,7 +10422,16 @@ var WIRED_EVENTS = ["edge", "action"];
|
|
|
10405
10422
|
var DURATION = /^\^\[0-9\]\+\(\\\.\[0-9\]\+\)\?\(([a-z|]+)\)\$$/u;
|
|
10406
10423
|
var RATIO = /%\)\$$/u;
|
|
10407
10424
|
var escape = (key2) => key2.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
10425
|
+
function valueAt2(input, pointer) {
|
|
10426
|
+
let value2 = input;
|
|
10427
|
+
for (const raw of pointer.split("/").slice(1)) {
|
|
10428
|
+
if (typeof value2 !== "object" || value2 === null) return void 0;
|
|
10429
|
+
value2 = value2[raw.replaceAll("~1", "/").replaceAll("~0", "~")];
|
|
10430
|
+
}
|
|
10431
|
+
return value2;
|
|
10432
|
+
}
|
|
10408
10433
|
var URL_RULE = "#/definitions/url/pattern";
|
|
10434
|
+
var ICON_RULE = "#/definitions/icon/enum";
|
|
10409
10435
|
var HEX = /^\^\[0-9a-f\]\{(\d+),(\d+)\}\$$/u;
|
|
10410
10436
|
function forbiddenOf(pattern) {
|
|
10411
10437
|
const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
|
|
@@ -10416,7 +10442,7 @@ function forbiddenOf(pattern) {
|
|
|
10416
10442
|
var branchesOf = (anyOf, errors) => errors.filter(
|
|
10417
10443
|
(error) => error !== anyOf && error.schemaPath.startsWith(`${anyOf.schemaPath}/`) && (error.instancePath === anyOf.instancePath || error.instancePath.startsWith(`${anyOf.instancePath}/`))
|
|
10418
10444
|
);
|
|
10419
|
-
function toFieldError(error, errors, m) {
|
|
10445
|
+
function toFieldError(error, errors, m, input) {
|
|
10420
10446
|
const params = error.params;
|
|
10421
10447
|
const at = error.instancePath;
|
|
10422
10448
|
switch (error.keyword) {
|
|
@@ -10449,8 +10475,12 @@ function toFieldError(error, errors, m) {
|
|
|
10449
10475
|
const tag = String(params.tag);
|
|
10450
10476
|
return { pointer: `${at}/${escape(tag)}`, message: m.discriminator(tag, EVENT_TYPES) };
|
|
10451
10477
|
}
|
|
10452
|
-
case "enum":
|
|
10478
|
+
case "enum": {
|
|
10479
|
+
const written = error.schemaPath === ICON_RULE ? valueAt2(input, at) : void 0;
|
|
10480
|
+
const near = typeof written === "string" ? nearest(written, ICON_NAMES) : void 0;
|
|
10481
|
+
if (typeof written === "string" && near !== void 0) return { pointer: at, message: m.unknownIcon(written, near) };
|
|
10453
10482
|
return { pointer: at, message: m.enum(params.allowedValues.map(String)) };
|
|
10483
|
+
}
|
|
10454
10484
|
case "type":
|
|
10455
10485
|
return { pointer: at, message: m.type(String(params.type)) };
|
|
10456
10486
|
case "minLength":
|
|
@@ -10486,12 +10516,16 @@ function validateDiagram(input, options = {}) {
|
|
|
10486
10516
|
const all = validate_diagram_default.errors ?? [];
|
|
10487
10517
|
const inBranch = new Set(all.filter((error) => error.keyword === "anyOf").flatMap((anyOf) => branchesOf(anyOf, all)));
|
|
10488
10518
|
const m = FIELD_MESSAGES[options.lang ?? "ja"];
|
|
10489
|
-
const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m));
|
|
10519
|
+
const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m, input));
|
|
10490
10520
|
return { ok: false, errors };
|
|
10491
10521
|
}
|
|
10492
10522
|
|
|
10493
10523
|
// src/messages.ts
|
|
10494
10524
|
var list = (words) => words.join(" / ");
|
|
10525
|
+
var withNear = (value2, near, none) => {
|
|
10526
|
+
const name2 = nearest(value2, ICON_NAMES);
|
|
10527
|
+
return name2 === void 0 ? none : near(name2);
|
|
10528
|
+
};
|
|
10495
10529
|
var ja3 = () => {
|
|
10496
10530
|
const shapes = {
|
|
10497
10531
|
sequence: "sequence <\u984C>",
|
|
@@ -10552,6 +10586,7 @@ var ja3 = () => {
|
|
|
10552
10586
|
attrTwice: (key2) => `${key2} \u306F 1 \u3064\u306E\u884C\u306B 1 \u3064\u307E\u3067`,
|
|
10553
10587
|
badAttr: (key2, allowed) => `${key2} \u306F\u3053\u306E\u884C\u306B\u66F8\u3051\u306A\u3044\u5C5E\u6027\u3002\u66F8\u3051\u308B\u306E\u306F ${list(allowed)}`,
|
|
10554
10588
|
badColor: `color \u306F ${list(COLORS)} \u306E\u3069\u308C\u304B`,
|
|
10589
|
+
badIcon: (value2) => withNear(value2, (near) => `${value2} \u3068\u3044\u3046 icon \u306F\u7121\u3044\u3002\u8FD1\u3044\u540D\u524D\u306F ${near}`, `icon \u306F ${list(ICON_NAMES)} \u306E\u3069\u308C\u304B`),
|
|
10555
10590
|
badView: `view \u306F ${list(VIEWS)} \u306E\u3069\u308C\u304B`,
|
|
10556
10591
|
badCarry: `carry \u306F ${list(CARRIES)} \u306E\u3069\u308C\u304B\u3002\u672D\u306F tag: <\u5024> \u3067\u66F8\u304F`,
|
|
10557
10592
|
badSide: `side \u306F ${list(SIDES)} \u306E\u3069\u308C\u304B`,
|
|
@@ -10690,6 +10725,7 @@ var en2 = () => {
|
|
|
10690
10725
|
attrTwice: (key2) => `Write ${key2} only once on a line`,
|
|
10691
10726
|
badAttr: (key2, allowed) => `${key2} cannot be written on this line. Write ${list(allowed)}`,
|
|
10692
10727
|
badColor: `color is one of ${list(COLORS)}`,
|
|
10728
|
+
badIcon: (value2) => withNear(value2, (near) => `There is no icon named ${value2}. The closest is ${near}`, `icon is one of ${list(ICON_NAMES)}`),
|
|
10693
10729
|
badView: `view is one of ${list(VIEWS)}`,
|
|
10694
10730
|
badCarry: `carry is one of ${list(CARRIES)}. Write a tag as tag: <value>`,
|
|
10695
10731
|
badSide: `side is one of ${list(SIDES)}`,
|
|
@@ -10949,12 +10985,13 @@ function readDeclared(source, word, allowed, m) {
|
|
|
10949
10985
|
function lookOf(source, attrs2, m) {
|
|
10950
10986
|
const color = attrs2.get("color");
|
|
10951
10987
|
if (color && !isOneOf(COLORS, color.value)) throw fail(source, color.at, m.badColor);
|
|
10988
|
+
const icon = attrs2.get("icon");
|
|
10989
|
+
if (icon && !ICON_NAMES.includes(icon.value)) throw fail(source, icon.at, m.badIcon(icon.value));
|
|
10952
10990
|
const note = attrs2.get("note")?.value;
|
|
10953
|
-
const icon = attrs2.get("icon")?.value;
|
|
10954
10991
|
return {
|
|
10955
10992
|
...note !== void 0 ? { note } : {},
|
|
10956
10993
|
...color ? { color: color.value } : {},
|
|
10957
|
-
...icon
|
|
10994
|
+
...icon ? { icon: icon.value } : {}
|
|
10958
10995
|
};
|
|
10959
10996
|
}
|
|
10960
10997
|
function oldForm(text2, inStep) {
|
|
@@ -13077,7 +13114,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], tr
|
|
|
13077
13114
|
const vars = paletteVars(palette, theme);
|
|
13078
13115
|
const id = nameOf(`${JSON.stringify(diagram)}|${vars}|${follow ? `${follow.width}|${follow.lang}` : ""}`);
|
|
13079
13116
|
const m = new Motion(`dg${id}`, timeline.total, timeline.last);
|
|
13080
|
-
const ctx = { m, t: timeline, id, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end, ink, traces };
|
|
13117
|
+
const ctx = { m, t: timeline, id, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end, ink, traces, boxText: boxTextY(layout.boxes) };
|
|
13081
13118
|
const on = involved(diagram);
|
|
13082
13119
|
const subs = subChanges(diagram, timeline, layout.kind !== "sequence");
|
|
13083
13120
|
const L = { band: [], base: [], lit: [], node: [], badge: [], top: [] };
|