@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.
Files changed (72) hide show
  1. package/README.ja.md +331 -0
  2. package/README.md +200 -188
  3. package/dist/cli.cjs +148 -111
  4. package/dist/cli.cjs.map +1 -1
  5. package/dist/cli.js +148 -111
  6. package/dist/cli.js.map +1 -1
  7. package/dist/export.cjs +139 -109
  8. package/dist/export.cjs.map +1 -1
  9. package/dist/export.js +139 -109
  10. package/dist/export.js.map +1 -1
  11. package/dist/index.cjs +99 -62
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.js +99 -62
  14. package/dist/index.js.map +1 -1
  15. package/dist/light/chunk-CLS6JVKK.cjs.map +1 -1
  16. package/dist/light/{chunk-EHTQUCW4.js → chunk-DVGDEPCV.js} +6 -2
  17. package/dist/light/chunk-DVGDEPCV.js.map +1 -0
  18. package/dist/light/{chunk-5OQV42W3.cjs → chunk-SUL4AJLI.cjs} +6 -2
  19. package/dist/light/chunk-SUL4AJLI.cjs.map +1 -0
  20. package/dist/light/{chunk-JCEKXALJ.cjs → chunk-V34DCH34.cjs} +90 -87
  21. package/dist/light/chunk-V34DCH34.cjs.map +1 -0
  22. package/dist/light/{chunk-YEQSLVIN.js → chunk-YO3UBEC3.js} +12 -9
  23. package/dist/light/chunk-YO3UBEC3.js.map +1 -0
  24. package/dist/light/{git-K3KAAAWW.cjs → git-WBGFDRBD.cjs} +59 -59
  25. package/dist/light/git-WBGFDRBD.cjs.map +1 -0
  26. package/dist/light/{git-GESUYKGR.js → git-WEJL6VAY.js} +3 -3
  27. package/dist/light/index.cjs +407 -375
  28. package/dist/light/index.cjs.map +1 -1
  29. package/dist/light/index.js +92 -60
  30. package/dist/light/index.js.map +1 -1
  31. package/dist/light/{lineup-2V2U7HZH.js → lineup-6LN6Z5T2.js} +3 -3
  32. package/dist/light/{lineup-623J25LU.cjs → lineup-WLGNGTFX.cjs} +40 -40
  33. package/dist/light/lineup-WLGNGTFX.cjs.map +1 -0
  34. package/dist/light/{state-T4OTVING.js → state-DFYTMQI7.js} +2 -2
  35. package/dist/light/{state-OZVCHX7H.cjs → state-JVAH4TSM.cjs} +41 -41
  36. package/dist/light/state-JVAH4TSM.cjs.map +1 -0
  37. package/dist/light/{time-KVMZIKYF.cjs → time-EXRPI34B.cjs} +84 -84
  38. package/dist/light/time-EXRPI34B.cjs.map +1 -0
  39. package/dist/light/{time-O4CMTUV5.js → time-M3EGEFDU.js} +3 -3
  40. package/dist/light/{tree-6D7KI57H.cjs → tree-DECHTXFU.cjs} +62 -62
  41. package/dist/light/tree-DECHTXFU.cjs.map +1 -0
  42. package/dist/light/{tree-ZJZQI5QT.js → tree-MFU54QKY.js} +3 -3
  43. package/dist/node.cjs +115 -49
  44. package/dist/node.cjs.map +1 -1
  45. package/dist/node.js +115 -49
  46. package/dist/node.js.map +1 -1
  47. package/dist/player.global.js +3 -3
  48. package/package.json +1 -1
  49. package/src/field-messages.ts +4 -0
  50. package/src/look/values.ts +5 -1
  51. package/src/messages.ts +11 -1
  52. package/src/nearest.ts +37 -0
  53. package/src/parser.ts +4 -2
  54. package/src/render/draw.ts +2 -1
  55. package/src/render/parts.ts +28 -7
  56. package/src/schema.ts +27 -3
  57. package/src/schemas/diagram.schema.json +3 -2
  58. package/src/schemas/validate-diagram.js +1 -1
  59. package/dist/light/chunk-5OQV42W3.cjs.map +0 -1
  60. package/dist/light/chunk-EHTQUCW4.js.map +0 -1
  61. package/dist/light/chunk-JCEKXALJ.cjs.map +0 -1
  62. package/dist/light/chunk-YEQSLVIN.js.map +0 -1
  63. package/dist/light/git-K3KAAAWW.cjs.map +0 -1
  64. package/dist/light/lineup-623J25LU.cjs.map +0 -1
  65. package/dist/light/state-OZVCHX7H.cjs.map +0 -1
  66. package/dist/light/time-KVMZIKYF.cjs.map +0 -1
  67. package/dist/light/tree-6D7KI57H.cjs.map +0 -1
  68. /package/dist/light/{git-GESUYKGR.js.map → git-WEJL6VAY.js.map} +0 -0
  69. /package/dist/light/{lineup-2V2U7HZH.js.map → lineup-6LN6Z5T2.js.map} +0 -0
  70. /package/dist/light/{state-T4OTVING.js.map → state-DFYTMQI7.js.map} +0 -0
  71. /package/dist/light/{time-O4CMTUV5.js.map → time-M3EGEFDU.js.map} +0 -0
  72. /package/dist/light/{tree-ZJZQI5QT.js.map → tree-MFU54QKY.js.map} +0 -0
package/dist/node.js CHANGED
@@ -26,6 +26,7 @@ var ja = {
26
26
  additionalProperties: (key) => `${key} \u3068\u3044\u3046\u6B04\u306F\u66F8\u3051\u306A\u3044`,
27
27
  required: (key) => `${key} \u306E\u6B04\u304C\u8981\u308B`,
28
28
  enum: (values) => `${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
29
+ unknownIcon: (value, near) => `${value} \u3068\u3044\u3046 icon \u306F\u7121\u3044\u3002\u8FD1\u3044\u540D\u524D\u306F ${near}`,
29
30
  type: (type) => TYPES_JA[type] ?? `${type} \u306B\u3059\u308B`,
30
31
  minLength: (limit) => `${limit} \u5B57\u4EE5\u4E0A\u66F8\u304F`,
31
32
  maxLength: (limit) => `${limit} \u5B57\u307E\u3067\u306B\u3059\u308B`,
@@ -50,6 +51,7 @@ var en = {
50
51
  additionalProperties: (key) => `The ${key} field is not allowed`,
51
52
  required: (key) => `The ${key} field is required`,
52
53
  enum: (values) => `Use one of ${values.join(" / ")}`,
54
+ unknownIcon: (value, near) => `There is no icon named ${value}. The closest is ${near}`,
53
55
  type: (type) => TYPES_EN[type] ?? `Use ${type}`,
54
56
  minLength: (limit) => `Write at least ${plural(limit, "character")}`,
55
57
  maxLength: (limit) => `Write at most ${plural(limit, "character")}`,
@@ -72,6 +74,75 @@ var en = {
72
74
  };
73
75
  var FIELD_MESSAGES = { ja, en };
74
76
 
77
+ // src/nearest.ts
78
+ var MAX_DISTANCE = 2;
79
+ function nearest(word, candidates) {
80
+ const written = [...word.toLowerCase()];
81
+ let limit = Math.min(MAX_DISTANCE, written.length - 1);
82
+ let best;
83
+ for (const candidate of candidates) {
84
+ const d = distance(written, [...candidate.toLowerCase()]);
85
+ if (d > limit) continue;
86
+ best = candidate;
87
+ limit = d - 1;
88
+ }
89
+ return best;
90
+ }
91
+ function distance(a, b) {
92
+ let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
93
+ for (let i = 1; i <= a.length; i++) {
94
+ const current = [i];
95
+ for (let j = 1; j <= b.length; j++) {
96
+ const replace = previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1);
97
+ current.push(Math.min(previous[j] + 1, current[j - 1] + 1, replace));
98
+ }
99
+ previous = current;
100
+ }
101
+ return previous[b.length];
102
+ }
103
+
104
+ // src/render/icons.ts
105
+ var ICONS = {
106
+ app: "M -9 -7 h18 a2 2 0 0 1 2 2 v10 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-10 a2 2 0 0 1 2 -2 z M -11 -2 h22",
107
+ router: "M -9 -4 h16 M 3 -8 l4 4 l-4 4 M 9 5 h-16 M -3 1 l-4 4 l4 4",
108
+ on: "M -7 7 L 7 -7 M -1 -7 h8 v8",
109
+ off: "M -7 -7 L 7 7 M 7 -1 v8 h-8",
110
+ pool: "M -9 -5 a9 3.5 0 1 0 18 0 a9 3.5 0 1 0 -18 0 M -9 -5 v10 a9 3.5 0 0 0 18 0 v-10 M -9 0 a9 3.5 0 0 0 18 0",
111
+ db: "M -9 -5 a9 3.5 0 1 0 18 0 a9 3.5 0 1 0 -18 0 M -9 -5 v10 a9 3.5 0 0 0 18 0 v-10 M -9 0 a9 3.5 0 0 0 18 0",
112
+ exe: "M -5 -8 L 7 0 L -5 8 Z",
113
+ idx: "M -9 -7 h18 M -9 -2 h18 M -9 3 h18 M -9 8 h11",
114
+ sign: "M -9 4 c 3 -9 5 -9 6 0 s 3 7 6 -2 s 3 -6 6 0",
115
+ env: "M -8 -5.5 h16 v11 h-16 z M -8 -5.5 l8 6 l8 -6",
116
+ lock: "M -5.5 -1 h11 v8 h-11 z M -3.5 -1 v-3 a3.5 3.5 0 0 1 7 0 v3",
117
+ check: "M -5 0 l3.5 3.5 l6.5 -7",
118
+ flag: "M -4 8 V -8 M -4 -7 H 6 L 3.5 -3.5 L 6 0 H -4",
119
+ x: "M -5 -5 l10 10 M 5 -5 l-10 10",
120
+ chain: "M -1.5 4.5 l-2 2 a3.5 3.5 0 0 1 -5 -5 l3 -3 a3.5 3.5 0 0 1 5 0 M 1.5 -4.5 l2 -2 a3.5 3.5 0 0 1 5 5 l-3 3 a3.5 3.5 0 0 1 -5 0 M -2.5 2.5 l5 -5",
121
+ net: "M -1.3 -4.6 L -5.8 3 M 1.3 -4.6 L 5.8 3 M -4.3 5.5 H 4.3 M -2.2 -7 a 2.2 2.2 0 1 0 4.4 0 a 2.2 2.2 0 1 0 -4.4 0 M -9.2 5.5 a 2.2 2.2 0 1 0 4.4 0 a 2.2 2.2 0 1 0 -4.4 0 M 4.8 5.5 a 2.2 2.2 0 1 0 4.4 0 a 2.2 2.2 0 1 0 -4.4 0",
122
+ user: "M -4 -4.5 a4 4 0 1 0 8 0 a4 4 0 1 0 -8 0 M -8 9 c0 -5 3.6 -7.5 8 -7.5 s8 2.5 8 7.5",
123
+ server: "M -9 -8 h18 v7 h-18 z M -9 1 h18 v7 h-18 z M -5 -4.5 h0.01 M -5 4.5 h0.01",
124
+ key: "M -9 0 a3.5 3.5 0 1 0 7 0 a3.5 3.5 0 1 0 -7 0 M -2 0 h10 M 5 0 v3.5 M 8 0 v2.5",
125
+ shield: "M 0 -9 l8 3 v5 c0 5 -3.5 8 -8 10 c-4.5 -2 -8 -5 -8 -10 v-5 z",
126
+ globe: "M -9 0 a9 9 0 1 0 18 0 a9 9 0 1 0 -18 0 M -9 0 h18 M 0 -9 c-4.5 4 -4.5 14 0 18 M 0 -9 c4.5 4 4.5 14 0 18",
127
+ bolt: "M 2 -9 L -5 1 h5 l-2 8 l7 -10 h-5 z",
128
+ doc: "M -6 -9 h8 l5 5 v13 h-13 z M 2 -9 v5 h5 M -3 1 h7 M -3 5 h5",
129
+ box: "M -9 -4.5 l9 -4.5 l9 4.5 v9 l-9 4.5 l-9 -4.5 z M -9 -4.5 l9 4.5 l9 -4.5 M 0 0 v9",
130
+ truck: "M -10 -6 h11 v10 h-11 z M 1 -2 h5 l3.5 3.5 v2.5 h-8.5 M -7.5 6.5 a1.8 1.8 0 1 0 3.6 0 a1.8 1.8 0 1 0 -3.6 0 M 3 6.5 a1.8 1.8 0 1 0 3.6 0 a1.8 1.8 0 1 0 -3.6 0",
131
+ card: "M -9 -6.5 h18 a2 2 0 0 1 2 2 v9 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-9 a2 2 0 0 1 2 -2 z M -11 -2 h22 M -7 3 h5",
132
+ cart: "M -10 -8 h3 l3 11 h11 l2.5 -8 h-15.5 M -4.5 7.5 a1.5 1.5 0 1 0 3 0 a1.5 1.5 0 1 0 -3 0 M 5 7.5 a1.5 1.5 0 1 0 3 0 a1.5 1.5 0 1 0 -3 0",
133
+ clock: "M -9 0 a9 9 0 1 0 18 0 a9 9 0 1 0 -18 0 M 0 -5 v5 l3.5 2.5",
134
+ branch: "M -4 -4.5 v9 M 5 0.5 c0 4 -9 3 -9 6.5 M -6.2 -7 a2.2 2.2 0 1 0 4.4 0 a2.2 2.2 0 1 0 -4.4 0 M -6.2 7 a2.2 2.2 0 1 0 4.4 0 a2.2 2.2 0 1 0 -4.4 0 M 2.8 -2 a2.2 2.2 0 1 0 4.4 0 a2.2 2.2 0 1 0 -4.4 0",
135
+ cloud: "M -7 6 h13 a4.5 4.5 0 0 0 0.5 -9 a6 6 0 0 0 -11.5 -1 a4.5 4.5 0 0 0 -2 10 z",
136
+ refresh: "M 7 -3 a7.5 7.5 0 1 0 0.5 5 M 7.5 -8 v5 h-5",
137
+ undo: "M -7 -2 h10 a5 5 0 0 1 0 10 h-6 M -3 -6 l-4 4 l4 4",
138
+ yen: "M -6 -8 l6 7 l6 -7 M 0 -1 v9 M -5 1.5 h10 M -5 5 h10",
139
+ layers: "M 0 -8 l9 4.5 l-9 4.5 l-9 -4.5 z M -9 2.5 l9 4.5 l9 -4.5",
140
+ code: "M -4 -6 l-5 6 l5 6 M 4 -6 l5 6 l-5 6",
141
+ paint: "M -8 8 c 0 -3 2 -5 4.5 -5 l 9 -9 l 3.5 3.5 l -9 9 c 0 2.5 -2 4.5 -5 4.5 z",
142
+ tree: "M 0 -5 v4 M -6 -1 h12 M -6 -1 v3 M 6 -1 v3 M -9 2 h6 v6 h-6 z M 3 2 h6 v6 h-6 z M -3 -10 h6 v5 h-6 z",
143
+ block: "M -9 -7 h18 a2 2 0 0 1 2 2 v10 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-10 a2 2 0 0 1 2 -2 z M -11 -2.5 h22 M -6 2.5 h8"
144
+ };
145
+
75
146
  // src/schemas/validate-diagram.js
76
147
  function ucs2length(str) {
77
148
  let length = 0;
@@ -1030,6 +1101,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
1030
1101
  return errors === 0;
1031
1102
  }
1032
1103
  var schema79 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
1104
+ 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"] };
1033
1105
  var pattern0 = new RegExp("^[^\\s\\[\\]\u300C\u300D=:]+$", "u");
1034
1106
  var func3 = ucs2length;
1035
1107
  function validate30(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
@@ -1145,32 +1217,22 @@ function validate30(data, { instancePath = "", parentData, parentDataProperty, r
1145
1217
  }
1146
1218
  if (data.icon !== void 0) {
1147
1219
  let data4 = data.icon;
1148
- if (typeof data4 === "string") {
1149
- if (func3(data4) < 1) {
1150
- const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1151
- if (vErrors === null) {
1152
- vErrors = [err10];
1153
- } else {
1154
- vErrors.push(err10);
1155
- }
1156
- errors++;
1157
- }
1158
- } else {
1159
- const err11 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1220
+ 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")) {
1221
+ 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" };
1160
1222
  if (vErrors === null) {
1161
- vErrors = [err11];
1223
+ vErrors = [err10];
1162
1224
  } else {
1163
- vErrors.push(err11);
1225
+ vErrors.push(err10);
1164
1226
  }
1165
1227
  errors++;
1166
1228
  }
1167
1229
  }
1168
1230
  } else {
1169
- const err12 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1231
+ const err11 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1170
1232
  if (vErrors === null) {
1171
- vErrors = [err12];
1233
+ vErrors = [err11];
1172
1234
  } else {
1173
- vErrors.push(err12);
1235
+ vErrors.push(err11);
1174
1236
  }
1175
1237
  errors++;
1176
1238
  }
@@ -1291,22 +1353,12 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
1291
1353
  }
1292
1354
  if (data.icon !== void 0) {
1293
1355
  let data4 = data.icon;
1294
- if (typeof data4 === "string") {
1295
- if (func3(data4) < 1) {
1296
- const err10 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
1297
- if (vErrors === null) {
1298
- vErrors = [err10];
1299
- } else {
1300
- vErrors.push(err10);
1301
- }
1302
- errors++;
1303
- }
1304
- } else {
1305
- const err11 = { instancePath: instancePath + "/icon", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1356
+ 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")) {
1357
+ 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" };
1306
1358
  if (vErrors === null) {
1307
- vErrors = [err11];
1359
+ vErrors = [err10];
1308
1360
  } else {
1309
- vErrors.push(err11);
1361
+ vErrors.push(err10);
1310
1362
  }
1311
1363
  errors++;
1312
1364
  }
@@ -1315,20 +1367,20 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
1315
1367
  let data5 = data.region;
1316
1368
  if (typeof data5 === "string") {
1317
1369
  if (!pattern0.test(data5)) {
1318
- const err12 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1370
+ const err11 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
1319
1371
  if (vErrors === null) {
1320
- vErrors = [err12];
1372
+ vErrors = [err11];
1321
1373
  } else {
1322
- vErrors.push(err12);
1374
+ vErrors.push(err11);
1323
1375
  }
1324
1376
  errors++;
1325
1377
  }
1326
1378
  } else {
1327
- const err13 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1379
+ const err12 = { instancePath: instancePath + "/region", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1328
1380
  if (vErrors === null) {
1329
- vErrors = [err13];
1381
+ vErrors = [err12];
1330
1382
  } else {
1331
- vErrors.push(err13);
1383
+ vErrors.push(err12);
1332
1384
  }
1333
1385
  errors++;
1334
1386
  }
@@ -1337,30 +1389,30 @@ function validate32(data, { instancePath = "", parentData, parentDataProperty, r
1337
1389
  let data6 = data.link;
1338
1390
  if (typeof data6 === "string") {
1339
1391
  if (!pattern3.test(data6)) {
1340
- const err14 = { instancePath: instancePath + "/link", schemaPath: "#/definitions/url/pattern", keyword: "pattern", params: { pattern: "^(/|https?://)" }, message: 'must match pattern "^(/|https?://)"' };
1392
+ const err13 = { instancePath: instancePath + "/link", schemaPath: "#/definitions/url/pattern", keyword: "pattern", params: { pattern: "^(/|https?://)" }, message: 'must match pattern "^(/|https?://)"' };
1341
1393
  if (vErrors === null) {
1342
- vErrors = [err14];
1394
+ vErrors = [err13];
1343
1395
  } else {
1344
- vErrors.push(err14);
1396
+ vErrors.push(err13);
1345
1397
  }
1346
1398
  errors++;
1347
1399
  }
1348
1400
  } else {
1349
- const err15 = { instancePath: instancePath + "/link", schemaPath: "#/definitions/url/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1401
+ const err14 = { instancePath: instancePath + "/link", schemaPath: "#/definitions/url/type", keyword: "type", params: { type: "string" }, message: "must be string" };
1350
1402
  if (vErrors === null) {
1351
- vErrors = [err15];
1403
+ vErrors = [err14];
1352
1404
  } else {
1353
- vErrors.push(err15);
1405
+ vErrors.push(err14);
1354
1406
  }
1355
1407
  errors++;
1356
1408
  }
1357
1409
  }
1358
1410
  } else {
1359
- const err16 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1411
+ const err15 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
1360
1412
  if (vErrors === null) {
1361
- vErrors = [err16];
1413
+ vErrors = [err15];
1362
1414
  } else {
1363
- vErrors.push(err16);
1415
+ vErrors.push(err15);
1364
1416
  }
1365
1417
  errors++;
1366
1418
  }
@@ -6412,6 +6464,7 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
6412
6464
  var STATE_ENDS = ["start", "finish"];
6413
6465
 
6414
6466
  // src/schema.ts
6467
+ var ICON_NAMES = Object.keys(ICONS);
6415
6468
  var EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch", "now", "mark", "span", "leaf", "node", "line", "seal", "open", "pick", "stamp"];
6416
6469
  var ABSENT = "#/definitions/absent/not";
6417
6470
  var ABSENT_KINDS = {
@@ -6441,7 +6494,16 @@ var WIRED_EVENTS = ["edge", "action"];
6441
6494
  var DURATION = /^\^\[0-9\]\+\(\\\.\[0-9\]\+\)\?\(([a-z|]+)\)\$$/u;
6442
6495
  var RATIO = /%\)\$$/u;
6443
6496
  var escape = (key) => key.replaceAll("~", "~0").replaceAll("/", "~1");
6497
+ function valueAt(input, pointer) {
6498
+ let value = input;
6499
+ for (const raw of pointer.split("/").slice(1)) {
6500
+ if (typeof value !== "object" || value === null) return void 0;
6501
+ value = value[raw.replaceAll("~1", "/").replaceAll("~0", "~")];
6502
+ }
6503
+ return value;
6504
+ }
6444
6505
  var URL_RULE = "#/definitions/url/pattern";
6506
+ var ICON_RULE = "#/definitions/icon/enum";
6445
6507
  var HEX = /^\^\[0-9a-f\]\{(\d+),(\d+)\}\$$/u;
6446
6508
  function forbiddenOf(pattern) {
6447
6509
  const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
@@ -6452,7 +6514,7 @@ function forbiddenOf(pattern) {
6452
6514
  var branchesOf = (anyOf, errors) => errors.filter(
6453
6515
  (error) => error !== anyOf && error.schemaPath.startsWith(`${anyOf.schemaPath}/`) && (error.instancePath === anyOf.instancePath || error.instancePath.startsWith(`${anyOf.instancePath}/`))
6454
6516
  );
6455
- function toFieldError(error, errors, m) {
6517
+ function toFieldError(error, errors, m, input) {
6456
6518
  const params = error.params;
6457
6519
  const at = error.instancePath;
6458
6520
  switch (error.keyword) {
@@ -6485,8 +6547,12 @@ function toFieldError(error, errors, m) {
6485
6547
  const tag = String(params.tag);
6486
6548
  return { pointer: `${at}/${escape(tag)}`, message: m.discriminator(tag, EVENT_TYPES) };
6487
6549
  }
6488
- case "enum":
6550
+ case "enum": {
6551
+ const written = error.schemaPath === ICON_RULE ? valueAt(input, at) : void 0;
6552
+ const near = typeof written === "string" ? nearest(written, ICON_NAMES) : void 0;
6553
+ if (typeof written === "string" && near !== void 0) return { pointer: at, message: m.unknownIcon(written, near) };
6489
6554
  return { pointer: at, message: m.enum(params.allowedValues.map(String)) };
6555
+ }
6490
6556
  case "type":
6491
6557
  return { pointer: at, message: m.type(String(params.type)) };
6492
6558
  case "minLength":
@@ -6522,7 +6588,7 @@ function validateDiagram(input, options = {}) {
6522
6588
  const all = validate_diagram_default.errors ?? [];
6523
6589
  const inBranch = new Set(all.filter((error) => error.keyword === "anyOf").flatMap((anyOf) => branchesOf(anyOf, all)));
6524
6590
  const m = FIELD_MESSAGES[options.lang ?? "ja"];
6525
- const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m));
6591
+ const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m, input));
6526
6592
  return { ok: false, errors };
6527
6593
  }
6528
6594