@cardenelabs/dragon 0.46.0 → 0.46.3
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 +61 -15
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +61 -15
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +57 -12
- package/dist/export.cjs.map +1 -1
- package/dist/export.js +57 -12
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +54 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -8
- package/dist/index.js.map +1 -1
- package/dist/light/index.cjs +52 -6
- package/dist/light/index.cjs.map +1 -1
- package/dist/light/index.js +52 -6
- package/dist/light/index.js.map +1 -1
- package/dist/node.cjs +90 -3
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +90 -3
- package/dist/node.js.map +1 -1
- package/dist/player.global.js +3 -3
- package/package.json +2 -2
- package/src/field-messages.ts +4 -0
- package/src/messages.ts +10 -3
- package/src/nearest.ts +37 -0
- package/src/parser.ts +1 -1
- package/src/schema.ts +21 -3
package/dist/export.cjs
CHANGED
|
@@ -839,8 +839,8 @@ function longest(points) {
|
|
|
839
839
|
}
|
|
840
840
|
return { a: best.a, b: best.b, vertical: Math.abs(best.b[0] - best.a[0]) < Math.abs(best.b[1] - best.a[1]) };
|
|
841
841
|
}
|
|
842
|
-
function along(points,
|
|
843
|
-
let left =
|
|
842
|
+
function along(points, distance2) {
|
|
843
|
+
let left = distance2;
|
|
844
844
|
for (let i = 1; i < points.length; i++) {
|
|
845
845
|
const a = points[i - 1];
|
|
846
846
|
const b = points[i];
|
|
@@ -1673,6 +1673,7 @@ var ja = {
|
|
|
1673
1673
|
additionalProperties: (key) => `${key} \u3068\u3044\u3046\u6B04\u306F\u66F8\u3051\u306A\u3044`,
|
|
1674
1674
|
required: (key) => `${key} \u306E\u6B04\u304C\u8981\u308B`,
|
|
1675
1675
|
enum: (values) => `${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
|
|
1676
|
+
unknownIcon: (value, near) => `${value} \u3068\u3044\u3046 icon \u306F\u7121\u3044\u3002\u8FD1\u3044\u540D\u524D\u306F ${near}`,
|
|
1676
1677
|
type: (type) => TYPES_JA[type] ?? `${type} \u306B\u3059\u308B`,
|
|
1677
1678
|
minLength: (limit) => `${limit} \u5B57\u4EE5\u4E0A\u66F8\u304F`,
|
|
1678
1679
|
maxLength: (limit) => `${limit} \u5B57\u307E\u3067\u306B\u3059\u308B`,
|
|
@@ -1697,6 +1698,7 @@ var en = {
|
|
|
1697
1698
|
additionalProperties: (key) => `The ${key} field is not allowed`,
|
|
1698
1699
|
required: (key) => `The ${key} field is required`,
|
|
1699
1700
|
enum: (values) => `Use one of ${values.join(" / ")}`,
|
|
1701
|
+
unknownIcon: (value, near) => `There is no icon named ${value}. The closest is ${near}`,
|
|
1700
1702
|
type: (type) => TYPES_EN[type] ?? `Use ${type}`,
|
|
1701
1703
|
minLength: (limit) => `Write at least ${plural(limit, "character")}`,
|
|
1702
1704
|
maxLength: (limit) => `Write at most ${plural(limit, "character")}`,
|
|
@@ -1719,6 +1721,33 @@ var en = {
|
|
|
1719
1721
|
};
|
|
1720
1722
|
var FIELD_MESSAGES = { ja, en };
|
|
1721
1723
|
|
|
1724
|
+
// src/nearest.ts
|
|
1725
|
+
var MAX_DISTANCE = 2;
|
|
1726
|
+
function nearest(word, candidates) {
|
|
1727
|
+
const written = [...word.toLowerCase()];
|
|
1728
|
+
let limit = Math.min(MAX_DISTANCE, written.length - 1);
|
|
1729
|
+
let best;
|
|
1730
|
+
for (const candidate of candidates) {
|
|
1731
|
+
const d = distance(written, [...candidate.toLowerCase()]);
|
|
1732
|
+
if (d > limit) continue;
|
|
1733
|
+
best = candidate;
|
|
1734
|
+
limit = d - 1;
|
|
1735
|
+
}
|
|
1736
|
+
return best;
|
|
1737
|
+
}
|
|
1738
|
+
function distance(a, b) {
|
|
1739
|
+
let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
1740
|
+
for (let i = 1; i <= a.length; i++) {
|
|
1741
|
+
const current = [i];
|
|
1742
|
+
for (let j = 1; j <= b.length; j++) {
|
|
1743
|
+
const replace = previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1);
|
|
1744
|
+
current.push(Math.min(previous[j] + 1, current[j - 1] + 1, replace));
|
|
1745
|
+
}
|
|
1746
|
+
previous = current;
|
|
1747
|
+
}
|
|
1748
|
+
return previous[b.length];
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1722
1751
|
// src/render/icons.ts
|
|
1723
1752
|
var ICONS = {
|
|
1724
1753
|
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",
|
|
@@ -8082,6 +8111,9 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
8082
8111
|
var STATE_ENDS = ["start", "finish"];
|
|
8083
8112
|
var LANE_MOST = 12;
|
|
8084
8113
|
var HEAD = "HEAD";
|
|
8114
|
+
|
|
8115
|
+
// src/schema.ts
|
|
8116
|
+
var ICON_NAMES = Object.keys(ICONS);
|
|
8085
8117
|
var EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch", "now", "mark", "span", "leaf", "node", "line", "seal", "open", "pick", "stamp"];
|
|
8086
8118
|
var ABSENT = "#/definitions/absent/not";
|
|
8087
8119
|
var ABSENT_KINDS = {
|
|
@@ -8111,7 +8143,16 @@ var WIRED_EVENTS = ["edge", "action"];
|
|
|
8111
8143
|
var DURATION = /^\^\[0-9\]\+\(\\\.\[0-9\]\+\)\?\(([a-z|]+)\)\$$/u;
|
|
8112
8144
|
var RATIO = /%\)\$$/u;
|
|
8113
8145
|
var escape = (key) => key.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
8146
|
+
function valueAt(input, pointer) {
|
|
8147
|
+
let value = input;
|
|
8148
|
+
for (const raw of pointer.split("/").slice(1)) {
|
|
8149
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
8150
|
+
value = value[raw.replaceAll("~1", "/").replaceAll("~0", "~")];
|
|
8151
|
+
}
|
|
8152
|
+
return value;
|
|
8153
|
+
}
|
|
8114
8154
|
var URL_RULE = "#/definitions/url/pattern";
|
|
8155
|
+
var ICON_RULE = "#/definitions/icon/enum";
|
|
8115
8156
|
var HEX = /^\^\[0-9a-f\]\{(\d+),(\d+)\}\$$/u;
|
|
8116
8157
|
function forbiddenOf(pattern) {
|
|
8117
8158
|
const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
|
|
@@ -8122,7 +8163,7 @@ function forbiddenOf(pattern) {
|
|
|
8122
8163
|
var branchesOf = (anyOf, errors) => errors.filter(
|
|
8123
8164
|
(error) => error !== anyOf && error.schemaPath.startsWith(`${anyOf.schemaPath}/`) && (error.instancePath === anyOf.instancePath || error.instancePath.startsWith(`${anyOf.instancePath}/`))
|
|
8124
8165
|
);
|
|
8125
|
-
function toFieldError(error, errors, m) {
|
|
8166
|
+
function toFieldError(error, errors, m, input) {
|
|
8126
8167
|
const params = error.params;
|
|
8127
8168
|
const at2 = error.instancePath;
|
|
8128
8169
|
switch (error.keyword) {
|
|
@@ -8155,8 +8196,12 @@ function toFieldError(error, errors, m) {
|
|
|
8155
8196
|
const tag = String(params.tag);
|
|
8156
8197
|
return { pointer: `${at2}/${escape(tag)}`, message: m.discriminator(tag, EVENT_TYPES) };
|
|
8157
8198
|
}
|
|
8158
|
-
case "enum":
|
|
8199
|
+
case "enum": {
|
|
8200
|
+
const written = error.schemaPath === ICON_RULE ? valueAt(input, at2) : void 0;
|
|
8201
|
+
const near = typeof written === "string" ? nearest(written, ICON_NAMES) : void 0;
|
|
8202
|
+
if (typeof written === "string" && near !== void 0) return { pointer: at2, message: m.unknownIcon(written, near) };
|
|
8159
8203
|
return { pointer: at2, message: m.enum(params.allowedValues.map(String)) };
|
|
8204
|
+
}
|
|
8160
8205
|
case "type":
|
|
8161
8206
|
return { pointer: at2, message: m.type(String(params.type)) };
|
|
8162
8207
|
case "minLength":
|
|
@@ -8192,7 +8237,7 @@ function validateDiagram(input, options = {}) {
|
|
|
8192
8237
|
const all = validate_diagram_default.errors ?? [];
|
|
8193
8238
|
const inBranch = new Set(all.filter((error) => error.keyword === "anyOf").flatMap((anyOf) => branchesOf(anyOf, all)));
|
|
8194
8239
|
const m = FIELD_MESSAGES[options.lang ?? "ja"];
|
|
8195
|
-
const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m));
|
|
8240
|
+
const errors = all.filter((error) => error.keyword !== "if" && !inBranch.has(error)).map((error) => toFieldError(error, all, m, input));
|
|
8196
8241
|
return { ok: false, errors };
|
|
8197
8242
|
}
|
|
8198
8243
|
|
|
@@ -11117,7 +11162,7 @@ function simplify(keys2) {
|
|
|
11117
11162
|
}
|
|
11118
11163
|
return out;
|
|
11119
11164
|
}
|
|
11120
|
-
function
|
|
11165
|
+
function valueAt2(keys2, t) {
|
|
11121
11166
|
const first = keys2[0];
|
|
11122
11167
|
if (!first) return 0;
|
|
11123
11168
|
if (t <= first[0]) return first[1];
|
|
@@ -11299,7 +11344,7 @@ function meterField(field, keys2, ctx) {
|
|
|
11299
11344
|
const y = field.y + M.y;
|
|
11300
11345
|
const kf = m.kf([
|
|
11301
11346
|
...simplify(keys2).map(([t, v]) => [t, { transform: `scaleX(${r14(v * 1e3) / 1e3})` }]),
|
|
11302
|
-
[m.last, { transform: `scaleX(${r14(
|
|
11347
|
+
[m.last, { transform: `scaleX(${r14(valueAt2(keys2, m.last) * 1e3) / 1e3})` }, EASE.inOut],
|
|
11303
11348
|
[m.total, { transform: "scaleX(0)" }]
|
|
11304
11349
|
]);
|
|
11305
11350
|
const lx = x + w * line;
|
|
@@ -11307,9 +11352,9 @@ function meterField(field, keys2, ctx) {
|
|
|
11307
11352
|
}
|
|
11308
11353
|
function timeFocus(layout, timeline, step, parts, vw, vh) {
|
|
11309
11354
|
const span = timeline.steps[step];
|
|
11310
|
-
const position =
|
|
11355
|
+
const position = valueAt2(timeline.needle ?? [], span.end - MOTION.still);
|
|
11311
11356
|
const badge2 = layout.badges.find((b) => b.step === step);
|
|
11312
|
-
const anchored = badge2 &&
|
|
11357
|
+
const anchored = badge2 && valueAt2(timeline.needle ?? [], span.start) === position && !(layout.strip && badge2.y >= layout.strip.y);
|
|
11313
11358
|
const ax = anchored ? badge2.x : layout.axis.x + position * layout.axis.unit;
|
|
11314
11359
|
const top = Math.min(...layout.rows.map((r) => r.y));
|
|
11315
11360
|
const bottom = Math.max(...layout.rows.map((r) => r.y + r.h));
|
|
@@ -11891,16 +11936,16 @@ async function film(stage2, plan2) {
|
|
|
11891
11936
|
const delay = gifEvery / fps * 1e3;
|
|
11892
11937
|
const sampled = [];
|
|
11893
11938
|
let colors = [];
|
|
11894
|
-
const
|
|
11939
|
+
const nearest2 = /* @__PURE__ */ new Map();
|
|
11895
11940
|
const toIndex = (data) => {
|
|
11896
11941
|
const index = new Uint8Array(data.length / 4);
|
|
11897
11942
|
for (let p = 0; p < index.length; p++) {
|
|
11898
11943
|
const i = p * 4;
|
|
11899
11944
|
const key = data[i] << 16 | data[i + 1] << 8 | data[i + 2];
|
|
11900
|
-
let k =
|
|
11945
|
+
let k = nearest2.get(key);
|
|
11901
11946
|
if (k === void 0) {
|
|
11902
11947
|
k = gif.nearestColorIndex(colors, [data[i], data[i + 1], data[i + 2]]);
|
|
11903
|
-
|
|
11948
|
+
nearest2.set(key, k);
|
|
11904
11949
|
}
|
|
11905
11950
|
index[p] = k;
|
|
11906
11951
|
}
|