@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.cjs
CHANGED
|
@@ -321,7 +321,11 @@ var LOOK = {
|
|
|
321
321
|
gap: 10,
|
|
322
322
|
/** 図の外周の余白 */
|
|
323
323
|
margin: 14,
|
|
324
|
-
|
|
324
|
+
/**
|
|
325
|
+
* 箱。`iconY` と `nameY` と `subY` は箱の真ん中から絵柄の真ん中と名前と下の字の基準線まで。
|
|
326
|
+
* `nameMid` と `subMid` はアイコンも置き場の枠も持つ箱が無い図の名前と下の字の基準線で、名前を箱の真ん中に置き、下の字を名前から `subY - nameY` と同じ間で置く (#3307、#3309)
|
|
327
|
+
*/
|
|
328
|
+
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 },
|
|
325
329
|
region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
|
|
326
330
|
architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
|
|
327
331
|
/**
|
|
@@ -832,8 +836,8 @@ function longest(points) {
|
|
|
832
836
|
}
|
|
833
837
|
return { a: best.a, b: best.b, vertical: Math.abs(best.b[0] - best.a[0]) < Math.abs(best.b[1] - best.a[1]) };
|
|
834
838
|
}
|
|
835
|
-
function along(points,
|
|
836
|
-
let left =
|
|
839
|
+
function along(points, distance2) {
|
|
840
|
+
let left = distance2;
|
|
837
841
|
for (let i = 1; i < points.length; i++) {
|
|
838
842
|
const a = points[i - 1];
|
|
839
843
|
const b = points[i];
|
|
@@ -1752,7 +1756,7 @@ var linkTo = (link, markup) => link === void 0 ? markup : `<a href="${esc(link)}
|
|
|
1752
1756
|
var r1 = (v) => Math.round(v * 100) / 100;
|
|
1753
1757
|
var cs = (k) => k === "coin" ? "--c:var(--coin);--ct:var(--coint)" : `--c:var(--c-${k});--ct:var(--t-${k})`;
|
|
1754
1758
|
function glyph(name2, x, y, scale, cls = "dg-gl") {
|
|
1755
|
-
const d = name2
|
|
1759
|
+
const d = name2 !== void 0 && drawsIcon(name2) ? ICONS[name2] : void 0;
|
|
1756
1760
|
return d ? `<path class="${cls}" transform="translate(${r1(x)} ${r1(y)}) scale(${scale})" d="${d}"/>` : "";
|
|
1757
1761
|
}
|
|
1758
1762
|
function iconSvg(name2) {
|
|
@@ -1788,6 +1792,8 @@ function arrowHead(points) {
|
|
|
1788
1792
|
const { arrow: a, arrowHalf: h } = LOOK.edge;
|
|
1789
1793
|
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)}`;
|
|
1790
1794
|
}
|
|
1795
|
+
var drawsIcon = (name2) => name2 !== void 0 && Object.hasOwn(ICONS, name2);
|
|
1796
|
+
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 };
|
|
1791
1797
|
var sansOf = (t) => ({ ...t, family: "sans" });
|
|
1792
1798
|
function write(ink, cls, x, y, text2, style, shown2 = ALWAYS, anchor) {
|
|
1793
1799
|
ink?.push({ text: text2, rect: textBox(text2, x, y, style, anchor), shown: shown2 });
|
|
@@ -1814,7 +1820,7 @@ function band(region, ink) {
|
|
|
1814
1820
|
const { x, y } = region.header;
|
|
1815
1821
|
const lines = region.lines.map((t, k) => write(ink, "dg-bz", x, region.y + nameY + k * line2, t, TYPE.regionName)).join("");
|
|
1816
1822
|
const note = region.note ? write(ink, "dg-bx", x, region.y + nameY + region.lines.length * line2 + 1, region.note, TYPE.regionNote) : "";
|
|
1817
|
-
const mark = region.icon
|
|
1823
|
+
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)}` : "";
|
|
1818
1824
|
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>`;
|
|
1819
1825
|
}
|
|
1820
1826
|
function subLines(box, m, changes, y, ink, right) {
|
|
@@ -1834,18 +1840,18 @@ function cardFrame(box, ctx, act, y, h) {
|
|
|
1834
1840
|
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>` : ""}`;
|
|
1835
1841
|
}
|
|
1836
1842
|
function card(box, ctx, on, changes, lit) {
|
|
1837
|
-
const { icon, iconRadius, iconScale, iconY
|
|
1838
|
-
const subs = subLines(box, ctx.m, changes, box.cy +
|
|
1843
|
+
const { icon, iconRadius, iconScale, iconY } = LOOK.box;
|
|
1844
|
+
const subs = subLines(box, ctx.m, changes, box.cy + ctx.boxText.sub, ctx.ink);
|
|
1839
1845
|
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;
|
|
1840
1846
|
const ix = box.iconX ?? box.cx;
|
|
1841
1847
|
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}"/>` : "";
|
|
1842
1848
|
let mark = "";
|
|
1843
|
-
if (box.icon
|
|
1849
|
+
if (drawsIcon(box.icon)) {
|
|
1844
1850
|
const rect = { x: ix - icon / 2, y: box.cy + iconY - icon / 2, w: icon, h: icon };
|
|
1845
1851
|
ctx.ink.push({ text: `${box.name} \u306E\u7D75\u67C4`, rect, shown: ALWAYS, boxed: true, part: { kind: "icon", box: box.name } });
|
|
1846
1852
|
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)}`;
|
|
1847
1853
|
}
|
|
1848
|
-
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 +
|
|
1854
|
+
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>`;
|
|
1849
1855
|
}
|
|
1850
1856
|
function headCard(box, ctx, on, changes) {
|
|
1851
1857
|
const { pad: pad2, h, nameY, subY } = LOOK.follow.head;
|
|
@@ -1858,7 +1864,7 @@ function ghostCard(box, ink) {
|
|
|
1858
1864
|
const G = LOOK.state.ghost;
|
|
1859
1865
|
const ix = box.x + G.pad + icon / 2;
|
|
1860
1866
|
const tx = box.x + G.pad + icon + G.gap;
|
|
1861
|
-
const mark = box.icon
|
|
1867
|
+
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)}` : "";
|
|
1862
1868
|
const nameY = box.sub ? G.nameY : LOOK.baseline.mark;
|
|
1863
1869
|
const sub = box.sub ? write(ink, "dg-ss", tx, box.cy + G.subY, box.sub, TYPE.boxSub, ALWAYS, "start") : "";
|
|
1864
1870
|
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>`;
|
|
@@ -3968,6 +3974,33 @@ function extractDiagrams(markdown) {
|
|
|
3968
3974
|
return fences;
|
|
3969
3975
|
}
|
|
3970
3976
|
|
|
3977
|
+
// src/nearest.ts
|
|
3978
|
+
var MAX_DISTANCE = 2;
|
|
3979
|
+
function nearest(word, candidates) {
|
|
3980
|
+
const written = [...word.toLowerCase()];
|
|
3981
|
+
let limit = Math.min(MAX_DISTANCE, written.length - 1);
|
|
3982
|
+
let best;
|
|
3983
|
+
for (const candidate of candidates) {
|
|
3984
|
+
const d = distance(written, [...candidate.toLowerCase()]);
|
|
3985
|
+
if (d > limit) continue;
|
|
3986
|
+
best = candidate;
|
|
3987
|
+
limit = d - 1;
|
|
3988
|
+
}
|
|
3989
|
+
return best;
|
|
3990
|
+
}
|
|
3991
|
+
function distance(a, b) {
|
|
3992
|
+
let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
3993
|
+
for (let i = 1; i <= a.length; i++) {
|
|
3994
|
+
const current = [i];
|
|
3995
|
+
for (let j = 1; j <= b.length; j++) {
|
|
3996
|
+
const replace = previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1);
|
|
3997
|
+
current.push(Math.min(previous[j] + 1, current[j - 1] + 1, replace));
|
|
3998
|
+
}
|
|
3999
|
+
previous = current;
|
|
4000
|
+
}
|
|
4001
|
+
return previous[b.length];
|
|
4002
|
+
}
|
|
4003
|
+
|
|
3971
4004
|
// src/field-messages.ts
|
|
3972
4005
|
var TYPES_JA = {
|
|
3973
4006
|
string: "\u6587\u5B57\u5217\u306B\u3059\u308B",
|
|
@@ -3992,6 +4025,7 @@ var ja2 = {
|
|
|
3992
4025
|
additionalProperties: (key2) => `${key2} \u3068\u3044\u3046\u6B04\u306F\u66F8\u3051\u306A\u3044`,
|
|
3993
4026
|
required: (key2) => `${key2} \u306E\u6B04\u304C\u8981\u308B`,
|
|
3994
4027
|
enum: (values) => `${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
|
|
4028
|
+
unknownIcon: (value2, near) => `${value2} \u3068\u3044\u3046 icon \u306F\u7121\u3044\u3002\u8FD1\u3044\u540D\u524D\u306F ${near}`,
|
|
3995
4029
|
type: (type) => TYPES_JA[type] ?? `${type} \u306B\u3059\u308B`,
|
|
3996
4030
|
minLength: (limit) => `${limit} \u5B57\u4EE5\u4E0A\u66F8\u304F`,
|
|
3997
4031
|
maxLength: (limit) => `${limit} \u5B57\u307E\u3067\u306B\u3059\u308B`,
|
|
@@ -4016,6 +4050,7 @@ var en = {
|
|
|
4016
4050
|
additionalProperties: (key2) => `The ${key2} field is not allowed`,
|
|
4017
4051
|
required: (key2) => `The ${key2} field is required`,
|
|
4018
4052
|
enum: (values) => `Use one of ${values.join(" / ")}`,
|
|
4053
|
+
unknownIcon: (value2, near) => `There is no icon named ${value2}. The closest is ${near}`,
|
|
4019
4054
|
type: (type) => TYPES_EN[type] ?? `Use ${type}`,
|
|
4020
4055
|
minLength: (limit) => `Write at least ${plural(limit, "character")}`,
|
|
4021
4056
|
maxLength: (limit) => `Write at most ${plural(limit, "character")}`,
|
|
@@ -4996,6 +5031,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
4996
5031
|
return errors === 0;
|
|
4997
5032
|
}
|
|
4998
5033
|
var schema79 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
|
|
5034
|
+
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"] };
|
|
4999
5035
|
var pattern0 = new RegExp("^[^\\s\\[\\]\u300C\u300D=:]+$", "u");
|
|
5000
5036
|
var func3 = ucs2length;
|
|
5001
5037
|
function validate30(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
@@ -5111,32 +5147,22 @@ function validate30(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
5111
5147
|
}
|
|
5112
5148
|
if (data.icon !== void 0) {
|
|
5113
5149
|
let data4 = data.icon;
|
|
5114
|
-
if (
|
|
5115
|
-
|
|
5116
|
-
const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
5117
|
-
if (vErrors === null) {
|
|
5118
|
-
vErrors = [err10];
|
|
5119
|
-
} else {
|
|
5120
|
-
vErrors.push(err10);
|
|
5121
|
-
}
|
|
5122
|
-
errors++;
|
|
5123
|
-
}
|
|
5124
|
-
} else {
|
|
5125
|
-
const err11 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
5150
|
+
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")) {
|
|
5151
|
+
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" };
|
|
5126
5152
|
if (vErrors === null) {
|
|
5127
|
-
vErrors = [
|
|
5153
|
+
vErrors = [err10];
|
|
5128
5154
|
} else {
|
|
5129
|
-
vErrors.push(
|
|
5155
|
+
vErrors.push(err10);
|
|
5130
5156
|
}
|
|
5131
5157
|
errors++;
|
|
5132
5158
|
}
|
|
5133
5159
|
}
|
|
5134
5160
|
} else {
|
|
5135
|
-
const
|
|
5161
|
+
const err11 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
5136
5162
|
if (vErrors === null) {
|
|
5137
|
-
vErrors = [
|
|
5163
|
+
vErrors = [err11];
|
|
5138
5164
|
} else {
|
|
5139
|
-
vErrors.push(
|
|
5165
|
+
vErrors.push(err11);
|
|
5140
5166
|
}
|
|
5141
5167
|
errors++;
|
|
5142
5168
|
}
|
|
@@ -5257,22 +5283,12 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
5257
5283
|
}
|
|
5258
5284
|
if (data.icon !== void 0) {
|
|
5259
5285
|
let data4 = data.icon;
|
|
5260
|
-
if (
|
|
5261
|
-
|
|
5262
|
-
const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
5263
|
-
if (vErrors === null) {
|
|
5264
|
-
vErrors = [err10];
|
|
5265
|
-
} else {
|
|
5266
|
-
vErrors.push(err10);
|
|
5267
|
-
}
|
|
5268
|
-
errors++;
|
|
5269
|
-
}
|
|
5270
|
-
} else {
|
|
5271
|
-
const err11 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
5286
|
+
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")) {
|
|
5287
|
+
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" };
|
|
5272
5288
|
if (vErrors === null) {
|
|
5273
|
-
vErrors = [
|
|
5289
|
+
vErrors = [err10];
|
|
5274
5290
|
} else {
|
|
5275
|
-
vErrors.push(
|
|
5291
|
+
vErrors.push(err10);
|
|
5276
5292
|
}
|
|
5277
5293
|
errors++;
|
|
5278
5294
|
}
|
|
@@ -5281,20 +5297,20 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
5281
5297
|
let data5 = data.region;
|
|
5282
5298
|
if (typeof data5 === "string") {
|
|
5283
5299
|
if (!pattern0.test(data5)) {
|
|
5284
|
-
const
|
|
5300
|
+
const err11 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
5285
5301
|
if (vErrors === null) {
|
|
5286
|
-
vErrors = [
|
|
5302
|
+
vErrors = [err11];
|
|
5287
5303
|
} else {
|
|
5288
|
-
vErrors.push(
|
|
5304
|
+
vErrors.push(err11);
|
|
5289
5305
|
}
|
|
5290
5306
|
errors++;
|
|
5291
5307
|
}
|
|
5292
5308
|
} else {
|
|
5293
|
-
const
|
|
5309
|
+
const err12 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
5294
5310
|
if (vErrors === null) {
|
|
5295
|
-
vErrors = [
|
|
5311
|
+
vErrors = [err12];
|
|
5296
5312
|
} else {
|
|
5297
|
-
vErrors.push(
|
|
5313
|
+
vErrors.push(err12);
|
|
5298
5314
|
}
|
|
5299
5315
|
errors++;
|
|
5300
5316
|
}
|
|
@@ -5303,30 +5319,30 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
5303
5319
|
let data6 = data.link;
|
|
5304
5320
|
if (typeof data6 === "string") {
|
|
5305
5321
|
if (!pattern3.test(data6)) {
|
|
5306
|
-
const
|
|
5322
|
+
const err13 = { instancePath: instancePath + "/link", schemaPath: "#/definitions/url/pattern", keyword: "pattern", params: { pattern: "^(/|https?://)" }, message: 'must match pattern "^(/|https?://)"' };
|
|
5307
5323
|
if (vErrors === null) {
|
|
5308
|
-
vErrors = [
|
|
5324
|
+
vErrors = [err13];
|
|
5309
5325
|
} else {
|
|
5310
|
-
vErrors.push(
|
|
5326
|
+
vErrors.push(err13);
|
|
5311
5327
|
}
|
|
5312
5328
|
errors++;
|
|
5313
5329
|
}
|
|
5314
5330
|
} else {
|
|
5315
|
-
const
|
|
5331
|
+
const err14 = { instancePath: instancePath + "/link", schemaPath: "#/definitions/url/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
5316
5332
|
if (vErrors === null) {
|
|
5317
|
-
vErrors = [
|
|
5333
|
+
vErrors = [err14];
|
|
5318
5334
|
} else {
|
|
5319
|
-
vErrors.push(
|
|
5335
|
+
vErrors.push(err14);
|
|
5320
5336
|
}
|
|
5321
5337
|
errors++;
|
|
5322
5338
|
}
|
|
5323
5339
|
}
|
|
5324
5340
|
} else {
|
|
5325
|
-
const
|
|
5341
|
+
const err15 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
5326
5342
|
if (vErrors === null) {
|
|
5327
|
-
vErrors = [
|
|
5343
|
+
vErrors = [err15];
|
|
5328
5344
|
} else {
|
|
5329
|
-
vErrors.push(
|
|
5345
|
+
vErrors.push(err15);
|
|
5330
5346
|
}
|
|
5331
5347
|
errors++;
|
|
5332
5348
|
}
|
|
@@ -10378,6 +10394,7 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
10378
10394
|
|
|
10379
10395
|
// src/schema.ts
|
|
10380
10396
|
var COLORS = ["blue", "amber", "green", "violet", "rose", "slate", "coin"];
|
|
10397
|
+
var ICON_NAMES = Object.keys(ICONS);
|
|
10381
10398
|
var EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch", "now", "mark", "span", "leaf", "node", "line", "seal", "open", "pick", "stamp"];
|
|
10382
10399
|
var ABSENT = "#/definitions/absent/not";
|
|
10383
10400
|
var ABSENT_KINDS = {
|
|
@@ -10407,7 +10424,16 @@ var WIRED_EVENTS = ["edge", "action"];
|
|
|
10407
10424
|
var DURATION = /^\^\[0-9\]\+\(\\\.\[0-9\]\+\)\?\(([a-z|]+)\)\$$/u;
|
|
10408
10425
|
var RATIO = /%\)\$$/u;
|
|
10409
10426
|
var escape = (key2) => key2.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
10427
|
+
function valueAt2(input, pointer) {
|
|
10428
|
+
let value2 = input;
|
|
10429
|
+
for (const raw of pointer.split("/").slice(1)) {
|
|
10430
|
+
if (typeof value2 !== "object" || value2 === null) return void 0;
|
|
10431
|
+
value2 = value2[raw.replaceAll("~1", "/").replaceAll("~0", "~")];
|
|
10432
|
+
}
|
|
10433
|
+
return value2;
|
|
10434
|
+
}
|
|
10410
10435
|
var URL_RULE = "#/definitions/url/pattern";
|
|
10436
|
+
var ICON_RULE = "#/definitions/icon/enum";
|
|
10411
10437
|
var HEX = /^\^\[0-9a-f\]\{(\d+),(\d+)\}\$$/u;
|
|
10412
10438
|
function forbiddenOf(pattern) {
|
|
10413
10439
|
const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
|
|
@@ -10418,7 +10444,7 @@ function forbiddenOf(pattern) {
|
|
|
10418
10444
|
var branchesOf = (anyOf, errors) => errors.filter(
|
|
10419
10445
|
(error) => error !== anyOf && error.schemaPath.startsWith(`${anyOf.schemaPath}/`) && (error.instancePath === anyOf.instancePath || error.instancePath.startsWith(`${anyOf.instancePath}/`))
|
|
10420
10446
|
);
|
|
10421
|
-
function toFieldError(error, errors, m) {
|
|
10447
|
+
function toFieldError(error, errors, m, input) {
|
|
10422
10448
|
const params = error.params;
|
|
10423
10449
|
const at = error.instancePath;
|
|
10424
10450
|
switch (error.keyword) {
|
|
@@ -10451,8 +10477,12 @@ function toFieldError(error, errors, m) {
|
|
|
10451
10477
|
const tag = String(params.tag);
|
|
10452
10478
|
return { pointer: `${at}/${escape(tag)}`, message: m.discriminator(tag, EVENT_TYPES) };
|
|
10453
10479
|
}
|
|
10454
|
-
case "enum":
|
|
10480
|
+
case "enum": {
|
|
10481
|
+
const written = error.schemaPath === ICON_RULE ? valueAt2(input, at) : void 0;
|
|
10482
|
+
const near = typeof written === "string" ? nearest(written, ICON_NAMES) : void 0;
|
|
10483
|
+
if (typeof written === "string" && near !== void 0) return { pointer: at, message: m.unknownIcon(written, near) };
|
|
10455
10484
|
return { pointer: at, message: m.enum(params.allowedValues.map(String)) };
|
|
10485
|
+
}
|
|
10456
10486
|
case "type":
|
|
10457
10487
|
return { pointer: at, message: m.type(String(params.type)) };
|
|
10458
10488
|
case "minLength":
|
|
@@ -10488,12 +10518,16 @@ function validateDiagram(input, options = {}) {
|
|
|
10488
10518
|
const all = validate_diagram_default.errors ?? [];
|
|
10489
10519
|
const inBranch = new Set(all.filter((error) => error.keyword === "anyOf").flatMap((anyOf) => branchesOf(anyOf, all)));
|
|
10490
10520
|
const m = FIELD_MESSAGES[options.lang ?? "ja"];
|
|
10491
|
-
const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m));
|
|
10521
|
+
const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m, input));
|
|
10492
10522
|
return { ok: false, errors };
|
|
10493
10523
|
}
|
|
10494
10524
|
|
|
10495
10525
|
// src/messages.ts
|
|
10496
10526
|
var list = (words) => words.join(" / ");
|
|
10527
|
+
var withNear = (value2, near, none) => {
|
|
10528
|
+
const name2 = nearest(value2, ICON_NAMES);
|
|
10529
|
+
return name2 === void 0 ? none : near(name2);
|
|
10530
|
+
};
|
|
10497
10531
|
var ja3 = () => {
|
|
10498
10532
|
const shapes = {
|
|
10499
10533
|
sequence: "sequence <\u984C>",
|
|
@@ -10554,6 +10588,7 @@ var ja3 = () => {
|
|
|
10554
10588
|
attrTwice: (key2) => `${key2} \u306F 1 \u3064\u306E\u884C\u306B 1 \u3064\u307E\u3067`,
|
|
10555
10589
|
badAttr: (key2, allowed) => `${key2} \u306F\u3053\u306E\u884C\u306B\u66F8\u3051\u306A\u3044\u5C5E\u6027\u3002\u66F8\u3051\u308B\u306E\u306F ${list(allowed)}`,
|
|
10556
10590
|
badColor: `color \u306F ${list(COLORS)} \u306E\u3069\u308C\u304B`,
|
|
10591
|
+
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`),
|
|
10557
10592
|
badView: `view \u306F ${list(VIEWS)} \u306E\u3069\u308C\u304B`,
|
|
10558
10593
|
badCarry: `carry \u306F ${list(CARRIES)} \u306E\u3069\u308C\u304B\u3002\u672D\u306F tag: <\u5024> \u3067\u66F8\u304F`,
|
|
10559
10594
|
badSide: `side \u306F ${list(SIDES)} \u306E\u3069\u308C\u304B`,
|
|
@@ -10692,6 +10727,7 @@ var en2 = () => {
|
|
|
10692
10727
|
attrTwice: (key2) => `Write ${key2} only once on a line`,
|
|
10693
10728
|
badAttr: (key2, allowed) => `${key2} cannot be written on this line. Write ${list(allowed)}`,
|
|
10694
10729
|
badColor: `color is one of ${list(COLORS)}`,
|
|
10730
|
+
badIcon: (value2) => withNear(value2, (near) => `There is no icon named ${value2}. The closest is ${near}`, `icon is one of ${list(ICON_NAMES)}`),
|
|
10695
10731
|
badView: `view is one of ${list(VIEWS)}`,
|
|
10696
10732
|
badCarry: `carry is one of ${list(CARRIES)}. Write a tag as tag: <value>`,
|
|
10697
10733
|
badSide: `side is one of ${list(SIDES)}`,
|
|
@@ -10951,12 +10987,13 @@ function readDeclared(source, word, allowed, m) {
|
|
|
10951
10987
|
function lookOf(source, attrs2, m) {
|
|
10952
10988
|
const color = attrs2.get("color");
|
|
10953
10989
|
if (color && !isOneOf(COLORS, color.value)) throw fail(source, color.at, m.badColor);
|
|
10990
|
+
const icon = attrs2.get("icon");
|
|
10991
|
+
if (icon && !ICON_NAMES.includes(icon.value)) throw fail(source, icon.at, m.badIcon(icon.value));
|
|
10954
10992
|
const note = attrs2.get("note")?.value;
|
|
10955
|
-
const icon = attrs2.get("icon")?.value;
|
|
10956
10993
|
return {
|
|
10957
10994
|
...note !== void 0 ? { note } : {},
|
|
10958
10995
|
...color ? { color: color.value } : {},
|
|
10959
|
-
...icon
|
|
10996
|
+
...icon ? { icon: icon.value } : {}
|
|
10960
10997
|
};
|
|
10961
10998
|
}
|
|
10962
10999
|
function oldForm(text2, inStep) {
|
|
@@ -13079,7 +13116,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], tr
|
|
|
13079
13116
|
const vars = paletteVars(palette, theme);
|
|
13080
13117
|
const id = nameOf(`${JSON.stringify(diagram)}|${vars}|${follow ? `${follow.width}|${follow.lang}` : ""}`);
|
|
13081
13118
|
const m = new Motion(`dg${id}`, timeline.total, timeline.last);
|
|
13082
|
-
const ctx = { m, t: timeline, id, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end, ink, traces };
|
|
13119
|
+
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) };
|
|
13083
13120
|
const on = involved(diagram);
|
|
13084
13121
|
const subs = subChanges(diagram, timeline, layout.kind !== "sequence");
|
|
13085
13122
|
const L = { band: [], base: [], lit: [], node: [], badge: [], top: [] };
|