@cardenelabs/dragon 0.36.3 → 0.37.0
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.md +56 -1
- package/dist/cli.cjs +1126 -220
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1118 -212
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +1043 -165
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/export.js +1038 -160
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +1133 -218
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -3
- package/dist/index.d.ts +77 -3
- package/dist/index.js +1132 -219
- package/dist/index.js.map +1 -1
- package/dist/player.global.js +2 -2
- package/dist/{schema-9VLameDG.d.cts → schema-B2MTRv66.d.cts} +11 -2
- package/dist/{schema-9VLameDG.d.ts → schema-B2MTRv66.d.ts} +11 -2
- package/package.json +1 -1
- package/src/field-messages.ts +4 -0
- package/src/figure-text.ts +21 -0
- package/src/index.ts +8 -1
- package/src/layout/architecture.ts +1 -1
- package/src/layout/scene.ts +78 -8
- package/src/layout/sequence.ts +1 -1
- package/src/layout/state.ts +387 -0
- package/src/look/values.ts +40 -5
- package/src/messages.ts +14 -0
- package/src/parser.ts +45 -14
- package/src/printer.ts +6 -1
- package/src/render/icons.ts +4 -0
- package/src/render/parts.ts +170 -23
- package/src/render/svg.ts +78 -8
- package/src/schema.ts +22 -6
- package/src/schemas/diagram.schema.json +30 -4
- package/src/schemas/validate-diagram.js +1 -1
- package/src/timeline.ts +47 -0
- package/src/words.ts +8 -1
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ var ja = {
|
|
|
53
53
|
minimum: (limit) => `${limit} \u4EE5\u4E0A\u306B\u3059\u308B`,
|
|
54
54
|
const: (value2) => `${value2} \u306B\u3059\u308B`,
|
|
55
55
|
not: (allowed) => allowed ? `${allowed.field} \u306E\u6B04\u306F kind \u304C ${allowed.kind} \u306E\u6642\u3060\u3051\u66F8\u3051\u308B` : "\u3053\u306E\u6B04\u306E\u7D44\u307F\u5408\u308F\u305B\u306F\u66F8\u3051\u306A\u3044",
|
|
56
|
+
reserved: (names) => `${names.join(" \u3068 ")} \u306F\u72B6\u614B\u9077\u79FB\u56F3\u306E\u59CB\u307E\u308A\u3068\u7D42\u308F\u308A\u306E\u5370\u306E\u540D\u524D\u3067\u3001\u7BB1\u306E\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
|
|
56
57
|
anyOf: (fields) => fields.length > 0 ? `${fields.join(" \u304B ")} \u306E${fields.length === 2 ? "\u3069\u3061\u3089\u304B" : "\u3069\u308C\u304B"}\u306E\u6B04\u304C\u8981\u308B` : "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u306B\u3082\u5408\u308F\u306A\u3044",
|
|
57
58
|
oneOf: "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u304B 1 \u3064\u3060\u3051\u306B\u5408\u308F\u305B\u308B",
|
|
58
59
|
discriminator: (tag, values) => `${tag} \u306F ${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
|
|
@@ -69,6 +70,7 @@ var en = {
|
|
|
69
70
|
minimum: (limit) => `Use ${limit} or greater`,
|
|
70
71
|
const: (value2) => `Use ${value2}`,
|
|
71
72
|
not: (allowed) => allowed ? `The ${allowed.field} field is allowed only when kind is ${allowed.kind}` : "This combination of fields is not allowed",
|
|
73
|
+
reserved: (names) => `${names.join(" and ")} name the start and end marks of a state diagram and cannot be box ids`,
|
|
72
74
|
anyOf: (fields) => fields.length > 0 ? `Write one of the ${fields.join(" or ")} fields` : "Does not match any of the allowed shapes",
|
|
73
75
|
oneOf: "Match exactly one of the allowed shapes",
|
|
74
76
|
discriminator: (tag, values) => `${tag} is one of ${values.join(" / ")}`,
|
|
@@ -83,7 +85,7 @@ function ucs2length(str) {
|
|
|
83
85
|
return length;
|
|
84
86
|
}
|
|
85
87
|
var validate_diagram_default = validate10;
|
|
86
|
-
var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture"] }, "title": { "$ref": "#/definitions/text" }, "view": { "description": "\u898B\u305B\u65B9\u3002\u66F8\u304B\u306A\u3051\u308C\u3070\u5B57\u306E\u5927\u304D\u3055\u3067\u9078\u3076\u3002fixed \u306F\u5168\u4F53\u3092\u6B62\u3081\u3066\u4E2D\u3060\u3051\u52D5\u304B\u3057\u3001follow \u306F\u5BC4\u3063\u3066\u52D5\u304B\u3057\u5168\u4F53\u56F3\u3067\u4ECA\u3069\u3053\u304B\u3092\u793A\u3059", "enum": ["fixed", "follow"] }, "regions": { "type": "array", "items": { "$ref": "#/definitions/region" } }, "boxes": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/box" } }, "strip": { "$ref": "#/definitions/strip" }, "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/step" } }, "sequence": { "$ref": "#/definitions/sequence" } }};
|
|
88
|
+
var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture", "state"] }, "title": { "$ref": "#/definitions/text" }, "view": { "description": "\u898B\u305B\u65B9\u3002\u66F8\u304B\u306A\u3051\u308C\u3070\u5B57\u306E\u5927\u304D\u3055\u3067\u9078\u3076\u3002fixed \u306F\u5168\u4F53\u3092\u6B62\u3081\u3066\u4E2D\u3060\u3051\u52D5\u304B\u3057\u3001follow \u306F\u5BC4\u3063\u3066\u52D5\u304B\u3057\u5168\u4F53\u56F3\u3067\u4ECA\u3069\u3053\u304B\u3092\u793A\u3059", "enum": ["fixed", "follow"] }, "regions": { "type": "array", "items": { "$ref": "#/definitions/region" } }, "boxes": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/box" } }, "strip": { "$ref": "#/definitions/strip" }, "steps": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/step" } }, "sequence": { "$ref": "#/definitions/sequence" }, "state": { "$ref": "#/definitions/state" } }};
|
|
87
89
|
var func2 = Object.prototype.hasOwnProperty;
|
|
88
90
|
var func3 = ucs2length;
|
|
89
91
|
var schema17 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
|
|
@@ -1477,6 +1479,182 @@ function validate23(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1477
1479
|
validate23.errors = vErrors;
|
|
1478
1480
|
return errors === 0;
|
|
1479
1481
|
}
|
|
1482
|
+
function validate26(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1483
|
+
let vErrors = null;
|
|
1484
|
+
let errors = 0;
|
|
1485
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1486
|
+
if (data.from === void 0) {
|
|
1487
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
|
|
1488
|
+
if (vErrors === null) {
|
|
1489
|
+
vErrors = [err0];
|
|
1490
|
+
} else {
|
|
1491
|
+
vErrors.push(err0);
|
|
1492
|
+
}
|
|
1493
|
+
errors++;
|
|
1494
|
+
}
|
|
1495
|
+
if (data.to === void 0) {
|
|
1496
|
+
const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "to" }, message: "must have required property 'to'" };
|
|
1497
|
+
if (vErrors === null) {
|
|
1498
|
+
vErrors = [err1];
|
|
1499
|
+
} else {
|
|
1500
|
+
vErrors.push(err1);
|
|
1501
|
+
}
|
|
1502
|
+
errors++;
|
|
1503
|
+
}
|
|
1504
|
+
for (const key0 in data) {
|
|
1505
|
+
if (!(key0 === "from" || key0 === "to" || key0 === "label")) {
|
|
1506
|
+
const err2 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1507
|
+
if (vErrors === null) {
|
|
1508
|
+
vErrors = [err2];
|
|
1509
|
+
} else {
|
|
1510
|
+
vErrors.push(err2);
|
|
1511
|
+
}
|
|
1512
|
+
errors++;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
if (data.from !== void 0) {
|
|
1516
|
+
let data0 = data.from;
|
|
1517
|
+
if (typeof data0 === "string") {
|
|
1518
|
+
if (!pattern0.test(data0)) {
|
|
1519
|
+
const err3 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1520
|
+
if (vErrors === null) {
|
|
1521
|
+
vErrors = [err3];
|
|
1522
|
+
} else {
|
|
1523
|
+
vErrors.push(err3);
|
|
1524
|
+
}
|
|
1525
|
+
errors++;
|
|
1526
|
+
}
|
|
1527
|
+
} else {
|
|
1528
|
+
const err4 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1529
|
+
if (vErrors === null) {
|
|
1530
|
+
vErrors = [err4];
|
|
1531
|
+
} else {
|
|
1532
|
+
vErrors.push(err4);
|
|
1533
|
+
}
|
|
1534
|
+
errors++;
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
if (data.to !== void 0) {
|
|
1538
|
+
let data1 = data.to;
|
|
1539
|
+
if (typeof data1 === "string") {
|
|
1540
|
+
if (!pattern0.test(data1)) {
|
|
1541
|
+
const err5 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1542
|
+
if (vErrors === null) {
|
|
1543
|
+
vErrors = [err5];
|
|
1544
|
+
} else {
|
|
1545
|
+
vErrors.push(err5);
|
|
1546
|
+
}
|
|
1547
|
+
errors++;
|
|
1548
|
+
}
|
|
1549
|
+
} else {
|
|
1550
|
+
const err6 = { instancePath: instancePath + "/to", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1551
|
+
if (vErrors === null) {
|
|
1552
|
+
vErrors = [err6];
|
|
1553
|
+
} else {
|
|
1554
|
+
vErrors.push(err6);
|
|
1555
|
+
}
|
|
1556
|
+
errors++;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
if (data.label !== void 0) {
|
|
1560
|
+
let data2 = data.label;
|
|
1561
|
+
if (typeof data2 === "string") {
|
|
1562
|
+
if (func3(data2) < 1) {
|
|
1563
|
+
const err7 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1564
|
+
if (vErrors === null) {
|
|
1565
|
+
vErrors = [err7];
|
|
1566
|
+
} else {
|
|
1567
|
+
vErrors.push(err7);
|
|
1568
|
+
}
|
|
1569
|
+
errors++;
|
|
1570
|
+
}
|
|
1571
|
+
} else {
|
|
1572
|
+
const err8 = { instancePath: instancePath + "/label", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1573
|
+
if (vErrors === null) {
|
|
1574
|
+
vErrors = [err8];
|
|
1575
|
+
} else {
|
|
1576
|
+
vErrors.push(err8);
|
|
1577
|
+
}
|
|
1578
|
+
errors++;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
} else {
|
|
1582
|
+
const err9 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1583
|
+
if (vErrors === null) {
|
|
1584
|
+
vErrors = [err9];
|
|
1585
|
+
} else {
|
|
1586
|
+
vErrors.push(err9);
|
|
1587
|
+
}
|
|
1588
|
+
errors++;
|
|
1589
|
+
}
|
|
1590
|
+
validate26.errors = vErrors;
|
|
1591
|
+
return errors === 0;
|
|
1592
|
+
}
|
|
1593
|
+
function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1594
|
+
let vErrors = null;
|
|
1595
|
+
let errors = 0;
|
|
1596
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1597
|
+
if (data.paths === void 0) {
|
|
1598
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "paths" }, message: "must have required property 'paths'" };
|
|
1599
|
+
if (vErrors === null) {
|
|
1600
|
+
vErrors = [err0];
|
|
1601
|
+
} else {
|
|
1602
|
+
vErrors.push(err0);
|
|
1603
|
+
}
|
|
1604
|
+
errors++;
|
|
1605
|
+
}
|
|
1606
|
+
for (const key0 in data) {
|
|
1607
|
+
if (!(key0 === "paths")) {
|
|
1608
|
+
const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1609
|
+
if (vErrors === null) {
|
|
1610
|
+
vErrors = [err1];
|
|
1611
|
+
} else {
|
|
1612
|
+
vErrors.push(err1);
|
|
1613
|
+
}
|
|
1614
|
+
errors++;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
if (data.paths !== void 0) {
|
|
1618
|
+
let data0 = data.paths;
|
|
1619
|
+
if (Array.isArray(data0)) {
|
|
1620
|
+
if (data0.length < 1) {
|
|
1621
|
+
const err2 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
1622
|
+
if (vErrors === null) {
|
|
1623
|
+
vErrors = [err2];
|
|
1624
|
+
} else {
|
|
1625
|
+
vErrors.push(err2);
|
|
1626
|
+
}
|
|
1627
|
+
errors++;
|
|
1628
|
+
}
|
|
1629
|
+
const len0 = data0.length;
|
|
1630
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
1631
|
+
if (!validate26(data0[i0], { instancePath: instancePath + "/paths/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
|
|
1632
|
+
vErrors = vErrors === null ? validate26.errors : vErrors.concat(validate26.errors);
|
|
1633
|
+
errors = vErrors.length;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
} else {
|
|
1637
|
+
const err3 = { instancePath: instancePath + "/paths", schemaPath: "#/properties/paths/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
1638
|
+
if (vErrors === null) {
|
|
1639
|
+
vErrors = [err3];
|
|
1640
|
+
} else {
|
|
1641
|
+
vErrors.push(err3);
|
|
1642
|
+
}
|
|
1643
|
+
errors++;
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
} else {
|
|
1647
|
+
const err4 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1648
|
+
if (vErrors === null) {
|
|
1649
|
+
vErrors = [err4];
|
|
1650
|
+
} else {
|
|
1651
|
+
vErrors.push(err4);
|
|
1652
|
+
}
|
|
1653
|
+
errors++;
|
|
1654
|
+
}
|
|
1655
|
+
validate25.errors = vErrors;
|
|
1656
|
+
return errors === 0;
|
|
1657
|
+
}
|
|
1480
1658
|
function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1481
1659
|
let vErrors = null;
|
|
1482
1660
|
let errors = 0;
|
|
@@ -1518,9 +1696,11 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1518
1696
|
let ifClause0;
|
|
1519
1697
|
if (_valid0) {
|
|
1520
1698
|
const _errs4 = errors;
|
|
1699
|
+
const _errs5 = errors;
|
|
1700
|
+
const _errs6 = errors;
|
|
1521
1701
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1522
|
-
if (data.
|
|
1523
|
-
const err2 = {
|
|
1702
|
+
if (data.state === void 0 && ("state")) {
|
|
1703
|
+
const err2 = {};
|
|
1524
1704
|
if (vErrors === null) {
|
|
1525
1705
|
vErrors = [err2];
|
|
1526
1706
|
} else {
|
|
@@ -1529,227 +1709,391 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1529
1709
|
errors++;
|
|
1530
1710
|
}
|
|
1531
1711
|
}
|
|
1712
|
+
var valid2 = _errs6 === errors;
|
|
1713
|
+
if (valid2) {
|
|
1714
|
+
const err3 = { instancePath, schemaPath: "#/then/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
1715
|
+
if (vErrors === null) {
|
|
1716
|
+
vErrors = [err3];
|
|
1717
|
+
} else {
|
|
1718
|
+
vErrors.push(err3);
|
|
1719
|
+
}
|
|
1720
|
+
errors++;
|
|
1721
|
+
} else {
|
|
1722
|
+
errors = _errs5;
|
|
1723
|
+
if (vErrors !== null) {
|
|
1724
|
+
if (_errs5) {
|
|
1725
|
+
vErrors.length = _errs5;
|
|
1726
|
+
} else {
|
|
1727
|
+
vErrors = null;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1732
|
+
if (data.sequence === void 0) {
|
|
1733
|
+
const err4 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
|
|
1734
|
+
if (vErrors === null) {
|
|
1735
|
+
vErrors = [err4];
|
|
1736
|
+
} else {
|
|
1737
|
+
vErrors.push(err4);
|
|
1738
|
+
}
|
|
1739
|
+
errors++;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1532
1742
|
var _valid0 = _errs4 === errors;
|
|
1533
1743
|
valid0 = _valid0;
|
|
1534
1744
|
ifClause0 = "then";
|
|
1535
1745
|
} else {
|
|
1536
|
-
const _errs5 = errors;
|
|
1537
|
-
const _errs6 = errors;
|
|
1538
1746
|
const _errs7 = errors;
|
|
1747
|
+
const _errs8 = errors;
|
|
1748
|
+
const _errs9 = errors;
|
|
1539
1749
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1540
1750
|
if (data.sequence === void 0 && ("sequence")) {
|
|
1541
|
-
const
|
|
1751
|
+
const err5 = {};
|
|
1542
1752
|
if (vErrors === null) {
|
|
1543
|
-
vErrors = [
|
|
1753
|
+
vErrors = [err5];
|
|
1544
1754
|
} else {
|
|
1545
|
-
vErrors.push(
|
|
1755
|
+
vErrors.push(err5);
|
|
1546
1756
|
}
|
|
1547
1757
|
errors++;
|
|
1548
1758
|
}
|
|
1549
1759
|
}
|
|
1550
|
-
var
|
|
1551
|
-
if (
|
|
1552
|
-
const
|
|
1760
|
+
var valid3 = _errs9 === errors;
|
|
1761
|
+
if (valid3) {
|
|
1762
|
+
const err6 = { instancePath, schemaPath: "#/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
1553
1763
|
if (vErrors === null) {
|
|
1554
|
-
vErrors = [
|
|
1764
|
+
vErrors = [err6];
|
|
1555
1765
|
} else {
|
|
1556
|
-
vErrors.push(
|
|
1766
|
+
vErrors.push(err6);
|
|
1557
1767
|
}
|
|
1558
1768
|
errors++;
|
|
1559
1769
|
} else {
|
|
1560
|
-
errors =
|
|
1770
|
+
errors = _errs8;
|
|
1561
1771
|
if (vErrors !== null) {
|
|
1562
|
-
if (
|
|
1563
|
-
vErrors.length =
|
|
1772
|
+
if (_errs8) {
|
|
1773
|
+
vErrors.length = _errs8;
|
|
1564
1774
|
} else {
|
|
1565
1775
|
vErrors = null;
|
|
1566
1776
|
}
|
|
1567
1777
|
}
|
|
1568
1778
|
}
|
|
1569
|
-
|
|
1779
|
+
const _errs10 = errors;
|
|
1780
|
+
let valid4 = true;
|
|
1781
|
+
const _errs11 = errors;
|
|
1782
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1783
|
+
if (data.kind === void 0 && ("kind")) {
|
|
1784
|
+
const err7 = {};
|
|
1785
|
+
if (vErrors === null) {
|
|
1786
|
+
vErrors = [err7];
|
|
1787
|
+
} else {
|
|
1788
|
+
vErrors.push(err7);
|
|
1789
|
+
}
|
|
1790
|
+
errors++;
|
|
1791
|
+
} else {
|
|
1792
|
+
if (data.kind !== void 0) {
|
|
1793
|
+
if ("state" !== data.kind) {
|
|
1794
|
+
const err8 = {};
|
|
1795
|
+
if (vErrors === null) {
|
|
1796
|
+
vErrors = [err8];
|
|
1797
|
+
} else {
|
|
1798
|
+
vErrors.push(err8);
|
|
1799
|
+
}
|
|
1800
|
+
errors++;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
var _valid1 = _errs11 === errors;
|
|
1806
|
+
errors = _errs10;
|
|
1807
|
+
if (vErrors !== null) {
|
|
1808
|
+
if (_errs10) {
|
|
1809
|
+
vErrors.length = _errs10;
|
|
1810
|
+
} else {
|
|
1811
|
+
vErrors = null;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
let ifClause1;
|
|
1815
|
+
if (_valid1) {
|
|
1816
|
+
const _errs13 = errors;
|
|
1817
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1818
|
+
if (data.boxes !== void 0) {
|
|
1819
|
+
let data2 = data.boxes;
|
|
1820
|
+
if (Array.isArray(data2)) {
|
|
1821
|
+
const len0 = data2.length;
|
|
1822
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
1823
|
+
let data3 = data2[i0];
|
|
1824
|
+
if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
|
|
1825
|
+
if (data3.id !== void 0) {
|
|
1826
|
+
let data4 = data3.id;
|
|
1827
|
+
const _errs17 = errors;
|
|
1828
|
+
const _errs18 = errors;
|
|
1829
|
+
if (!(data4 === "start" || data4 === "finish")) {
|
|
1830
|
+
const err9 = {};
|
|
1831
|
+
if (vErrors === null) {
|
|
1832
|
+
vErrors = [err9];
|
|
1833
|
+
} else {
|
|
1834
|
+
vErrors.push(err9);
|
|
1835
|
+
}
|
|
1836
|
+
errors++;
|
|
1837
|
+
}
|
|
1838
|
+
var valid10 = _errs18 === errors;
|
|
1839
|
+
if (valid10) {
|
|
1840
|
+
const err10 = { instancePath: instancePath + "/boxes/" + i0 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
1841
|
+
if (vErrors === null) {
|
|
1842
|
+
vErrors = [err10];
|
|
1843
|
+
} else {
|
|
1844
|
+
vErrors.push(err10);
|
|
1845
|
+
}
|
|
1846
|
+
errors++;
|
|
1847
|
+
} else {
|
|
1848
|
+
errors = _errs17;
|
|
1849
|
+
if (vErrors !== null) {
|
|
1850
|
+
if (_errs17) {
|
|
1851
|
+
vErrors.length = _errs17;
|
|
1852
|
+
} else {
|
|
1853
|
+
vErrors = null;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
var _valid1 = _errs13 === errors;
|
|
1864
|
+
valid4 = _valid1;
|
|
1865
|
+
ifClause1 = "then";
|
|
1866
|
+
} else {
|
|
1867
|
+
const _errs19 = errors;
|
|
1868
|
+
const _errs20 = errors;
|
|
1869
|
+
const _errs21 = errors;
|
|
1870
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1871
|
+
if (data.state === void 0 && ("state")) {
|
|
1872
|
+
const err11 = {};
|
|
1873
|
+
if (vErrors === null) {
|
|
1874
|
+
vErrors = [err11];
|
|
1875
|
+
} else {
|
|
1876
|
+
vErrors.push(err11);
|
|
1877
|
+
}
|
|
1878
|
+
errors++;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
var valid11 = _errs21 === errors;
|
|
1882
|
+
if (valid11) {
|
|
1883
|
+
const err12 = { instancePath, schemaPath: "#/else/else/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
1884
|
+
if (vErrors === null) {
|
|
1885
|
+
vErrors = [err12];
|
|
1886
|
+
} else {
|
|
1887
|
+
vErrors.push(err12);
|
|
1888
|
+
}
|
|
1889
|
+
errors++;
|
|
1890
|
+
} else {
|
|
1891
|
+
errors = _errs20;
|
|
1892
|
+
if (vErrors !== null) {
|
|
1893
|
+
if (_errs20) {
|
|
1894
|
+
vErrors.length = _errs20;
|
|
1895
|
+
} else {
|
|
1896
|
+
vErrors = null;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
var _valid1 = _errs19 === errors;
|
|
1901
|
+
valid4 = _valid1;
|
|
1902
|
+
ifClause1 = "else";
|
|
1903
|
+
}
|
|
1904
|
+
if (!valid4) {
|
|
1905
|
+
const err13 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
|
|
1906
|
+
if (vErrors === null) {
|
|
1907
|
+
vErrors = [err13];
|
|
1908
|
+
} else {
|
|
1909
|
+
vErrors.push(err13);
|
|
1910
|
+
}
|
|
1911
|
+
errors++;
|
|
1912
|
+
}
|
|
1913
|
+
var _valid0 = _errs7 === errors;
|
|
1570
1914
|
valid0 = _valid0;
|
|
1571
1915
|
ifClause0 = "else";
|
|
1572
1916
|
}
|
|
1573
1917
|
if (!valid0) {
|
|
1574
|
-
const
|
|
1918
|
+
const err14 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
|
|
1575
1919
|
if (vErrors === null) {
|
|
1576
|
-
vErrors = [
|
|
1920
|
+
vErrors = [err14];
|
|
1577
1921
|
} else {
|
|
1578
|
-
vErrors.push(
|
|
1922
|
+
vErrors.push(err14);
|
|
1579
1923
|
}
|
|
1580
1924
|
errors++;
|
|
1581
1925
|
}
|
|
1582
1926
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1583
1927
|
if (data.version === void 0) {
|
|
1584
|
-
const
|
|
1928
|
+
const err15 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
|
|
1585
1929
|
if (vErrors === null) {
|
|
1586
|
-
vErrors = [
|
|
1930
|
+
vErrors = [err15];
|
|
1587
1931
|
} else {
|
|
1588
|
-
vErrors.push(
|
|
1932
|
+
vErrors.push(err15);
|
|
1589
1933
|
}
|
|
1590
1934
|
errors++;
|
|
1591
1935
|
}
|
|
1592
1936
|
if (data.kind === void 0) {
|
|
1593
|
-
const
|
|
1937
|
+
const err16 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
|
|
1594
1938
|
if (vErrors === null) {
|
|
1595
|
-
vErrors = [
|
|
1939
|
+
vErrors = [err16];
|
|
1596
1940
|
} else {
|
|
1597
|
-
vErrors.push(
|
|
1941
|
+
vErrors.push(err16);
|
|
1598
1942
|
}
|
|
1599
1943
|
errors++;
|
|
1600
1944
|
}
|
|
1601
1945
|
if (data.title === void 0) {
|
|
1602
|
-
const
|
|
1946
|
+
const err17 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
|
|
1603
1947
|
if (vErrors === null) {
|
|
1604
|
-
vErrors = [
|
|
1948
|
+
vErrors = [err17];
|
|
1605
1949
|
} else {
|
|
1606
|
-
vErrors.push(
|
|
1950
|
+
vErrors.push(err17);
|
|
1607
1951
|
}
|
|
1608
1952
|
errors++;
|
|
1609
1953
|
}
|
|
1610
1954
|
if (data.boxes === void 0) {
|
|
1611
|
-
const
|
|
1955
|
+
const err18 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
|
|
1612
1956
|
if (vErrors === null) {
|
|
1613
|
-
vErrors = [
|
|
1957
|
+
vErrors = [err18];
|
|
1614
1958
|
} else {
|
|
1615
|
-
vErrors.push(
|
|
1959
|
+
vErrors.push(err18);
|
|
1616
1960
|
}
|
|
1617
1961
|
errors++;
|
|
1618
1962
|
}
|
|
1619
1963
|
if (data.steps === void 0) {
|
|
1620
|
-
const
|
|
1964
|
+
const err19 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
|
|
1621
1965
|
if (vErrors === null) {
|
|
1622
|
-
vErrors = [
|
|
1966
|
+
vErrors = [err19];
|
|
1623
1967
|
} else {
|
|
1624
|
-
vErrors.push(
|
|
1968
|
+
vErrors.push(err19);
|
|
1625
1969
|
}
|
|
1626
1970
|
errors++;
|
|
1627
1971
|
}
|
|
1628
1972
|
for (const key0 in data) {
|
|
1629
1973
|
if (!func2.call(schema11.properties, key0)) {
|
|
1630
|
-
const
|
|
1974
|
+
const err20 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1631
1975
|
if (vErrors === null) {
|
|
1632
|
-
vErrors = [
|
|
1976
|
+
vErrors = [err20];
|
|
1633
1977
|
} else {
|
|
1634
|
-
vErrors.push(
|
|
1978
|
+
vErrors.push(err20);
|
|
1635
1979
|
}
|
|
1636
1980
|
errors++;
|
|
1637
1981
|
}
|
|
1638
1982
|
}
|
|
1639
1983
|
if (data.version !== void 0) {
|
|
1640
|
-
let
|
|
1641
|
-
if (!(typeof
|
|
1642
|
-
const
|
|
1984
|
+
let data5 = data.version;
|
|
1985
|
+
if (!(typeof data5 == "number" && (!(data5 % 1) && !isNaN(data5)) && isFinite(data5))) {
|
|
1986
|
+
const err21 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
1643
1987
|
if (vErrors === null) {
|
|
1644
|
-
vErrors = [
|
|
1988
|
+
vErrors = [err21];
|
|
1645
1989
|
} else {
|
|
1646
|
-
vErrors.push(
|
|
1990
|
+
vErrors.push(err21);
|
|
1647
1991
|
}
|
|
1648
1992
|
errors++;
|
|
1649
1993
|
}
|
|
1650
|
-
if (typeof
|
|
1651
|
-
if (
|
|
1652
|
-
const
|
|
1994
|
+
if (typeof data5 == "number" && isFinite(data5)) {
|
|
1995
|
+
if (data5 < 1 || isNaN(data5)) {
|
|
1996
|
+
const err22 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
|
|
1653
1997
|
if (vErrors === null) {
|
|
1654
|
-
vErrors = [
|
|
1998
|
+
vErrors = [err22];
|
|
1655
1999
|
} else {
|
|
1656
|
-
vErrors.push(
|
|
2000
|
+
vErrors.push(err22);
|
|
1657
2001
|
}
|
|
1658
2002
|
errors++;
|
|
1659
2003
|
}
|
|
1660
2004
|
}
|
|
1661
2005
|
}
|
|
1662
2006
|
if (data.kind !== void 0) {
|
|
1663
|
-
let
|
|
1664
|
-
if (!(
|
|
1665
|
-
const
|
|
2007
|
+
let data6 = data.kind;
|
|
2008
|
+
if (!(data6 === "sequence" || data6 === "architecture" || data6 === "state")) {
|
|
2009
|
+
const err23 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema11.properties.kind.enum }, message: "must be equal to one of the allowed values" };
|
|
1666
2010
|
if (vErrors === null) {
|
|
1667
|
-
vErrors = [
|
|
2011
|
+
vErrors = [err23];
|
|
1668
2012
|
} else {
|
|
1669
|
-
vErrors.push(
|
|
2013
|
+
vErrors.push(err23);
|
|
1670
2014
|
}
|
|
1671
2015
|
errors++;
|
|
1672
2016
|
}
|
|
1673
2017
|
}
|
|
1674
2018
|
if (data.title !== void 0) {
|
|
1675
|
-
let
|
|
1676
|
-
if (typeof
|
|
1677
|
-
if (func3(
|
|
1678
|
-
const
|
|
2019
|
+
let data7 = data.title;
|
|
2020
|
+
if (typeof data7 === "string") {
|
|
2021
|
+
if (func3(data7) < 1) {
|
|
2022
|
+
const err24 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1679
2023
|
if (vErrors === null) {
|
|
1680
|
-
vErrors = [
|
|
2024
|
+
vErrors = [err24];
|
|
1681
2025
|
} else {
|
|
1682
|
-
vErrors.push(
|
|
2026
|
+
vErrors.push(err24);
|
|
1683
2027
|
}
|
|
1684
2028
|
errors++;
|
|
1685
2029
|
}
|
|
1686
2030
|
} else {
|
|
1687
|
-
const
|
|
2031
|
+
const err25 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1688
2032
|
if (vErrors === null) {
|
|
1689
|
-
vErrors = [
|
|
2033
|
+
vErrors = [err25];
|
|
1690
2034
|
} else {
|
|
1691
|
-
vErrors.push(
|
|
2035
|
+
vErrors.push(err25);
|
|
1692
2036
|
}
|
|
1693
2037
|
errors++;
|
|
1694
2038
|
}
|
|
1695
2039
|
}
|
|
1696
2040
|
if (data.view !== void 0) {
|
|
1697
|
-
let
|
|
1698
|
-
if (!(
|
|
1699
|
-
const
|
|
2041
|
+
let data8 = data.view;
|
|
2042
|
+
if (!(data8 === "fixed" || data8 === "follow")) {
|
|
2043
|
+
const err26 = { instancePath: instancePath + "/view", schemaPath: "#/properties/view/enum", keyword: "enum", params: { allowedValues: schema11.properties.view.enum }, message: "must be equal to one of the allowed values" };
|
|
1700
2044
|
if (vErrors === null) {
|
|
1701
|
-
vErrors = [
|
|
2045
|
+
vErrors = [err26];
|
|
1702
2046
|
} else {
|
|
1703
|
-
vErrors.push(
|
|
2047
|
+
vErrors.push(err26);
|
|
1704
2048
|
}
|
|
1705
2049
|
errors++;
|
|
1706
2050
|
}
|
|
1707
2051
|
}
|
|
1708
2052
|
if (data.regions !== void 0) {
|
|
1709
|
-
let
|
|
1710
|
-
if (Array.isArray(
|
|
1711
|
-
const
|
|
1712
|
-
for (let
|
|
1713
|
-
if (!validate11(
|
|
2053
|
+
let data9 = data.regions;
|
|
2054
|
+
if (Array.isArray(data9)) {
|
|
2055
|
+
const len1 = data9.length;
|
|
2056
|
+
for (let i1 = 0; i1 < len1; i1++) {
|
|
2057
|
+
if (!validate11(data9[i1], { instancePath: instancePath + "/regions/" + i1, parentData: data9, parentDataProperty: i1, rootData })) {
|
|
1714
2058
|
vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors);
|
|
1715
2059
|
errors = vErrors.length;
|
|
1716
2060
|
}
|
|
1717
2061
|
}
|
|
1718
2062
|
} else {
|
|
1719
|
-
const
|
|
2063
|
+
const err27 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
1720
2064
|
if (vErrors === null) {
|
|
1721
|
-
vErrors = [
|
|
2065
|
+
vErrors = [err27];
|
|
1722
2066
|
} else {
|
|
1723
|
-
vErrors.push(
|
|
2067
|
+
vErrors.push(err27);
|
|
1724
2068
|
}
|
|
1725
2069
|
errors++;
|
|
1726
2070
|
}
|
|
1727
2071
|
}
|
|
1728
2072
|
if (data.boxes !== void 0) {
|
|
1729
|
-
let
|
|
1730
|
-
if (Array.isArray(
|
|
1731
|
-
if (
|
|
1732
|
-
const
|
|
2073
|
+
let data11 = data.boxes;
|
|
2074
|
+
if (Array.isArray(data11)) {
|
|
2075
|
+
if (data11.length < 1) {
|
|
2076
|
+
const err28 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
1733
2077
|
if (vErrors === null) {
|
|
1734
|
-
vErrors = [
|
|
2078
|
+
vErrors = [err28];
|
|
1735
2079
|
} else {
|
|
1736
|
-
vErrors.push(
|
|
2080
|
+
vErrors.push(err28);
|
|
1737
2081
|
}
|
|
1738
2082
|
errors++;
|
|
1739
2083
|
}
|
|
1740
|
-
const
|
|
1741
|
-
for (let
|
|
1742
|
-
if (!validate13(
|
|
2084
|
+
const len2 = data11.length;
|
|
2085
|
+
for (let i2 = 0; i2 < len2; i2++) {
|
|
2086
|
+
if (!validate13(data11[i2], { instancePath: instancePath + "/boxes/" + i2, parentData: data11, parentDataProperty: i2, rootData })) {
|
|
1743
2087
|
vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
|
|
1744
2088
|
errors = vErrors.length;
|
|
1745
2089
|
}
|
|
1746
2090
|
}
|
|
1747
2091
|
} else {
|
|
1748
|
-
const
|
|
2092
|
+
const err29 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
1749
2093
|
if (vErrors === null) {
|
|
1750
|
-
vErrors = [
|
|
2094
|
+
vErrors = [err29];
|
|
1751
2095
|
} else {
|
|
1752
|
-
vErrors.push(
|
|
2096
|
+
vErrors.push(err29);
|
|
1753
2097
|
}
|
|
1754
2098
|
errors++;
|
|
1755
2099
|
}
|
|
@@ -1761,30 +2105,30 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1761
2105
|
}
|
|
1762
2106
|
}
|
|
1763
2107
|
if (data.steps !== void 0) {
|
|
1764
|
-
let
|
|
1765
|
-
if (Array.isArray(
|
|
1766
|
-
if (
|
|
1767
|
-
const
|
|
2108
|
+
let data14 = data.steps;
|
|
2109
|
+
if (Array.isArray(data14)) {
|
|
2110
|
+
if (data14.length < 1) {
|
|
2111
|
+
const err30 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
1768
2112
|
if (vErrors === null) {
|
|
1769
|
-
vErrors = [
|
|
2113
|
+
vErrors = [err30];
|
|
1770
2114
|
} else {
|
|
1771
|
-
vErrors.push(
|
|
2115
|
+
vErrors.push(err30);
|
|
1772
2116
|
}
|
|
1773
2117
|
errors++;
|
|
1774
2118
|
}
|
|
1775
|
-
const
|
|
1776
|
-
for (let
|
|
1777
|
-
if (!validate17(
|
|
2119
|
+
const len3 = data14.length;
|
|
2120
|
+
for (let i3 = 0; i3 < len3; i3++) {
|
|
2121
|
+
if (!validate17(data14[i3], { instancePath: instancePath + "/steps/" + i3, parentData: data14, parentDataProperty: i3, rootData })) {
|
|
1778
2122
|
vErrors = vErrors === null ? validate17.errors : vErrors.concat(validate17.errors);
|
|
1779
2123
|
errors = vErrors.length;
|
|
1780
2124
|
}
|
|
1781
2125
|
}
|
|
1782
2126
|
} else {
|
|
1783
|
-
const
|
|
2127
|
+
const err31 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
1784
2128
|
if (vErrors === null) {
|
|
1785
|
-
vErrors = [
|
|
2129
|
+
vErrors = [err31];
|
|
1786
2130
|
} else {
|
|
1787
|
-
vErrors.push(
|
|
2131
|
+
vErrors.push(err31);
|
|
1788
2132
|
}
|
|
1789
2133
|
errors++;
|
|
1790
2134
|
}
|
|
@@ -1795,12 +2139,18 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1795
2139
|
errors = vErrors.length;
|
|
1796
2140
|
}
|
|
1797
2141
|
}
|
|
2142
|
+
if (data.state !== void 0) {
|
|
2143
|
+
if (!validate25(data.state, { instancePath: instancePath + "/state", parentData: data, parentDataProperty: "state", rootData })) {
|
|
2144
|
+
vErrors = vErrors === null ? validate25.errors : vErrors.concat(validate25.errors);
|
|
2145
|
+
errors = vErrors.length;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
1798
2148
|
} else {
|
|
1799
|
-
const
|
|
2149
|
+
const err32 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1800
2150
|
if (vErrors === null) {
|
|
1801
|
-
vErrors = [
|
|
2151
|
+
vErrors = [err32];
|
|
1802
2152
|
} else {
|
|
1803
|
-
vErrors.push(
|
|
2153
|
+
vErrors.push(err32);
|
|
1804
2154
|
}
|
|
1805
2155
|
errors++;
|
|
1806
2156
|
}
|
|
@@ -1808,13 +2158,43 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1808
2158
|
return errors === 0;
|
|
1809
2159
|
}
|
|
1810
2160
|
|
|
2161
|
+
// src/words.ts
|
|
2162
|
+
var keys = (table) => Object.keys(table);
|
|
2163
|
+
var KINDS = keys({ sequence: true, architecture: true, state: true });
|
|
2164
|
+
var STATE_ENDS = ["start", "finish"];
|
|
2165
|
+
var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set"];
|
|
2166
|
+
var AS = "as";
|
|
2167
|
+
var ATTRS = {
|
|
2168
|
+
diagram: ["view"],
|
|
2169
|
+
group: ["note", "color", "icon"],
|
|
2170
|
+
box: ["note", "color", "icon"],
|
|
2171
|
+
edge: ["carry", "tag", "side"],
|
|
2172
|
+
set: ["tag"]
|
|
2173
|
+
};
|
|
2174
|
+
var CARRIES = keys({ coin: true, none: true });
|
|
2175
|
+
var VIEWS = keys({ fixed: true, follow: true });
|
|
2176
|
+
var SIDES = keys({ above: true, below: true, left: true, right: true });
|
|
2177
|
+
var OLD_HEADS = {
|
|
2178
|
+
\u6642\u7CFB\u5217\u56F3: "sequence",
|
|
2179
|
+
\u69CB\u6210\u56F3: "architecture",
|
|
2180
|
+
\u533A\u753B: "group",
|
|
2181
|
+
\u898B\u305B\u65B9: "view",
|
|
2182
|
+
region: "group",
|
|
2183
|
+
view: "view"
|
|
2184
|
+
};
|
|
2185
|
+
|
|
1811
2186
|
// src/schema.ts
|
|
1812
2187
|
var COLORS = ["blue", "amber", "green", "violet", "rose", "slate", "coin"];
|
|
1813
2188
|
var EVENT_TYPES = ["edge", "action", "swap", "strip"];
|
|
2189
|
+
var ROOT_NOT_ALLOWED = {
|
|
2190
|
+
"#/else/not": { field: "sequence", kind: "sequence" },
|
|
2191
|
+
"#/then/not": { field: "state", kind: "state" },
|
|
2192
|
+
"#/else/else/not": { field: "state", kind: "state" }
|
|
2193
|
+
};
|
|
1814
2194
|
var NOT_ALLOWED = {
|
|
1815
|
-
"": { field: "sequence", kind: "sequence" },
|
|
1816
2195
|
carry: { field: "text", kind: "tag" }
|
|
1817
2196
|
};
|
|
2197
|
+
var RESERVED_ID = /\/boxes\/items\/properties\/id\/not$/u;
|
|
1818
2198
|
var escape = (key2) => key2.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
1819
2199
|
function forbiddenOf(pattern) {
|
|
1820
2200
|
const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
|
|
@@ -1838,7 +2218,8 @@ function toFieldError(error, errors, m) {
|
|
|
1838
2218
|
return { pointer: `${at}/${escape(key2)}`, message: m.required(key2) };
|
|
1839
2219
|
}
|
|
1840
2220
|
case "not": {
|
|
1841
|
-
|
|
2221
|
+
if (RESERVED_ID.test(error.schemaPath)) return { pointer: at, message: m.reserved(STATE_ENDS) };
|
|
2222
|
+
const allowed = at === "" ? ROOT_NOT_ALLOWED[error.schemaPath] : NOT_ALLOWED[at.slice(at.lastIndexOf("/") + 1)];
|
|
1842
2223
|
return { pointer: allowed ? `${at}/${allowed.field}` : at, message: m.not(allowed) };
|
|
1843
2224
|
}
|
|
1844
2225
|
case "anyOf": {
|
|
@@ -1879,30 +2260,6 @@ function validateDiagram(input, options = {}) {
|
|
|
1879
2260
|
return { ok: false, errors };
|
|
1880
2261
|
}
|
|
1881
2262
|
|
|
1882
|
-
// src/words.ts
|
|
1883
|
-
var keys = (table) => Object.keys(table);
|
|
1884
|
-
var KINDS = keys({ sequence: true, architecture: true });
|
|
1885
|
-
var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set"];
|
|
1886
|
-
var AS = "as";
|
|
1887
|
-
var ATTRS = {
|
|
1888
|
-
diagram: ["view"],
|
|
1889
|
-
group: ["note", "color", "icon"],
|
|
1890
|
-
box: ["note", "color", "icon"],
|
|
1891
|
-
edge: ["carry", "tag", "side"],
|
|
1892
|
-
set: ["tag"]
|
|
1893
|
-
};
|
|
1894
|
-
var CARRIES = keys({ coin: true, none: true });
|
|
1895
|
-
var VIEWS = keys({ fixed: true, follow: true });
|
|
1896
|
-
var SIDES = keys({ above: true, below: true, left: true, right: true });
|
|
1897
|
-
var OLD_HEADS = {
|
|
1898
|
-
\u6642\u7CFB\u5217\u56F3: "sequence",
|
|
1899
|
-
\u69CB\u6210\u56F3: "architecture",
|
|
1900
|
-
\u533A\u753B: "group",
|
|
1901
|
-
\u898B\u305B\u65B9: "view",
|
|
1902
|
-
region: "group",
|
|
1903
|
-
view: "view"
|
|
1904
|
-
};
|
|
1905
|
-
|
|
1906
2263
|
// src/messages.ts
|
|
1907
2264
|
var list = (words) => words.join(" / ");
|
|
1908
2265
|
var ja2 = () => {
|
|
@@ -1967,7 +2324,11 @@ var ja2 = () => {
|
|
|
1967
2324
|
badView: `view \u306F ${list(VIEWS)} \u306E\u3069\u308C\u304B`,
|
|
1968
2325
|
badCarry: `carry \u306F ${list(CARRIES)} \u306E\u3069\u308C\u304B\u3002\u672D\u306F tag: <\u5024> \u3067\u66F8\u304F`,
|
|
1969
2326
|
badSide: `side \u306F ${list(SIDES)} \u306E\u3069\u308C\u304B`,
|
|
1970
|
-
carryTwice: "\u904B\u3076\u7269\u306F 1 \u672C\u306E\u7DDA\u306B 1 \u3064\u307E\u3067\u3002carry \u3068 tag \u306F\u4E00\u7DD2\u306B\u66F8\u304B\u306A\u3044"
|
|
2327
|
+
carryTwice: "\u904B\u3076\u7269\u306F 1 \u672C\u306E\u7DDA\u306B 1 \u3064\u307E\u3067\u3002carry \u3068 tag \u306F\u4E00\u7DD2\u306B\u66F8\u304B\u306A\u3044",
|
|
2328
|
+
reservedId: (id) => `${id} \u306F\u72B6\u614B\u9077\u79FB\u56F3\u306E\u59CB\u307E\u308A\u3068\u7D42\u308F\u308A\u306E\u5370\u306E\u540D\u524D\u3067\u3001\u7BB1\u306E\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
|
|
2329
|
+
intoStart: "start \u3078\u5165\u308B\u7DDA\u306F\u66F8\u3051\u306A\u3044\u3002start \u306F\u59CB\u307E\u308A\u306E\u5370\u3067\u3001\u7DDA\u306F start \u304B\u3089\u51FA\u308B",
|
|
2330
|
+
outOfFinish: "finish \u304B\u3089\u51FA\u308B\u7DDA\u306F\u66F8\u3051\u306A\u3044\u3002finish \u306F\u7D42\u308F\u308A\u306E\u5370\u3067\u3001\u7DDA\u306F finish \u3078\u5165\u308B",
|
|
2331
|
+
pathNoAttrs: "\u6700\u521D\u306E step \u3088\u308A\u524D\u306E\u7DDA\u306F\u4ECA\u56DE\u306F\u901A\u3089\u306A\u3044\u9053\u306A\u306E\u3067\u3001\u5C5E\u6027 (carry \u3068 tag \u3068 side) \u3092\u66F8\u3051\u306A\u3044"
|
|
1971
2332
|
};
|
|
1972
2333
|
};
|
|
1973
2334
|
var en2 = () => {
|
|
@@ -2032,7 +2393,11 @@ var en2 = () => {
|
|
|
2032
2393
|
badView: `view is one of ${list(VIEWS)}`,
|
|
2033
2394
|
badCarry: `carry is one of ${list(CARRIES)}. Write a tag as tag: <value>`,
|
|
2034
2395
|
badSide: `side is one of ${list(SIDES)}`,
|
|
2035
|
-
carryTwice: "A line carries one thing. Do not write carry and tag together"
|
|
2396
|
+
carryTwice: "A line carries one thing. Do not write carry and tag together",
|
|
2397
|
+
reservedId: (id) => `${id} names the start or end mark of a state diagram and cannot be a box id`,
|
|
2398
|
+
intoStart: "A line cannot go into start. start is the start mark, and lines leave it",
|
|
2399
|
+
outOfFinish: "A line cannot leave finish. finish is the end mark, and lines go into it",
|
|
2400
|
+
pathNoAttrs: "A line before the first step is a path not taken, so it takes no attributes (carry, tag, side)"
|
|
2036
2401
|
};
|
|
2037
2402
|
};
|
|
2038
2403
|
var MESSAGES = { ja: ja2(), en: en2() };
|
|
@@ -2068,19 +2433,19 @@ function readDiagram(input, options = {}) {
|
|
|
2068
2433
|
if (!checked.ok) return checked;
|
|
2069
2434
|
return { ok: true, diagram: input, warnings: [] };
|
|
2070
2435
|
}
|
|
2071
|
-
async function migrateFile(
|
|
2436
|
+
async function migrateFile(path2) {
|
|
2072
2437
|
const { readFile } = await import('fs/promises');
|
|
2073
|
-
const input = JSON.parse(await readFile(
|
|
2438
|
+
const input = JSON.parse(await readFile(path2, "utf8"));
|
|
2074
2439
|
const read = readDiagram(input);
|
|
2075
|
-
if (!read.ok) throw new Error(`${
|
|
2440
|
+
if (!read.ok) throw new Error(`${path2} \u3092\u79FB\u305B\u306A\u3044: ${read.errors.map((error) => `${error.pointer} ${error.message}`).join(" / ")}`);
|
|
2076
2441
|
return { changed: false, from: read.diagram.version, to: FORMAT_VERSION };
|
|
2077
2442
|
}
|
|
2078
2443
|
|
|
2079
2444
|
// src/parser.ts
|
|
2080
2445
|
var NotationError = class extends Error {
|
|
2081
|
-
constructor(
|
|
2446
|
+
constructor(line2, column, message) {
|
|
2082
2447
|
super(message);
|
|
2083
|
-
this.line =
|
|
2448
|
+
this.line = line2;
|
|
2084
2449
|
this.column = column;
|
|
2085
2450
|
}
|
|
2086
2451
|
line;
|
|
@@ -2236,8 +2601,10 @@ function parseLines(lines, m) {
|
|
|
2236
2601
|
const shown2 = titled.rest < head.text.length ? readAttrs(head, titled.rest, ATTRS.diagram, m).get("view") : void 0;
|
|
2237
2602
|
if (shown2 && !isOneOf(VIEWS, shown2.value)) throw fail(head, shown2.at, m.badView);
|
|
2238
2603
|
const view = shown2?.value;
|
|
2604
|
+
const isState = kind === "state";
|
|
2239
2605
|
const regions = [];
|
|
2240
2606
|
const boxes = [];
|
|
2607
|
+
const paths = [];
|
|
2241
2608
|
const ids = /* @__PURE__ */ new Set();
|
|
2242
2609
|
let strip2;
|
|
2243
2610
|
const steps = [];
|
|
@@ -2251,6 +2618,14 @@ function parseLines(lines, m) {
|
|
|
2251
2618
|
if (!boxes.some((box) => box.id === id)) throw fail(source, at, m.undeclaredBox(id));
|
|
2252
2619
|
return id;
|
|
2253
2620
|
};
|
|
2621
|
+
const endAt = (source, id, at, side2) => {
|
|
2622
|
+
if (!isState || !isOneOf(STATE_ENDS, id)) return boxAt(source, id, at);
|
|
2623
|
+
if (id === "start" !== (side2 === "from")) throw fail(source, at, id === "start" ? m.intoStart : m.outOfFinish);
|
|
2624
|
+
return id;
|
|
2625
|
+
};
|
|
2626
|
+
const notReserved = (source, id, at) => {
|
|
2627
|
+
if (isState && isOneOf(STATE_ENDS, id)) throw fail(source, at, m.reservedId(id));
|
|
2628
|
+
};
|
|
2254
2629
|
const inStep = (source) => {
|
|
2255
2630
|
if (!building) throw fail(source, 0, m.stepLineBeforeStep);
|
|
2256
2631
|
return building;
|
|
@@ -2275,7 +2650,8 @@ function parseLines(lines, m) {
|
|
|
2275
2650
|
const text2 = source.text;
|
|
2276
2651
|
const edge2 = EDGE.exec(text2);
|
|
2277
2652
|
if (edge2) {
|
|
2278
|
-
|
|
2653
|
+
if (isState && !building) paths.push(readPath(source, edge2));
|
|
2654
|
+
else inStep(source).events.push(readEdge(source, edge2));
|
|
2279
2655
|
continue;
|
|
2280
2656
|
}
|
|
2281
2657
|
const word = text2.split(/\s/u)[0] ?? "";
|
|
@@ -2347,7 +2723,8 @@ function parseLines(lines, m) {
|
|
|
2347
2723
|
boxes,
|
|
2348
2724
|
...strip2 ? { strip: strip2 } : {},
|
|
2349
2725
|
steps,
|
|
2350
|
-
...kind === "sequence" ? { sequence: { lifelines: boxes.map((box) => box.id) } } : {}
|
|
2726
|
+
...kind === "sequence" ? { sequence: { lifelines: boxes.map((box) => box.id) } } : {},
|
|
2727
|
+
...paths.length > 0 ? { state: { paths } } : {}
|
|
2351
2728
|
};
|
|
2352
2729
|
function readGroup(source) {
|
|
2353
2730
|
beforeSteps(source);
|
|
@@ -2356,6 +2733,7 @@ function parseLines(lines, m) {
|
|
|
2356
2733
|
if (regions.some((region) => region.id === declared.id)) {
|
|
2357
2734
|
if (declared.name !== void 0 || declared.attrs.size > 0) throw fail(source, 0, m.regionReopened(declared.id));
|
|
2358
2735
|
} else {
|
|
2736
|
+
notReserved(source, declared.id, declared.idAt);
|
|
2359
2737
|
declare(source, declared.id, declared.idAt);
|
|
2360
2738
|
regions.push({ id: declared.id, name: declared.name ?? declared.id, ...lookOf(source, declared.attrs, m) });
|
|
2361
2739
|
}
|
|
@@ -2364,6 +2742,7 @@ function parseLines(lines, m) {
|
|
|
2364
2742
|
function readBox(source) {
|
|
2365
2743
|
beforeSteps(source);
|
|
2366
2744
|
const declared = readDeclared(source, "box", ATTRS.box, m);
|
|
2745
|
+
notReserved(source, declared.id, declared.idAt);
|
|
2367
2746
|
declare(source, declared.id, declared.idAt);
|
|
2368
2747
|
const { note, ...look } = lookOf(source, declared.attrs, m);
|
|
2369
2748
|
boxes.push({
|
|
@@ -2421,26 +2800,32 @@ function parseLines(lines, m) {
|
|
|
2421
2800
|
if (!found || idAt === void 0 || (found[2] ?? "") === "") throw fail(source, 0, shape);
|
|
2422
2801
|
return { box: boxAt(source, found[1] ?? "", idAt), text: found[2] ?? "" };
|
|
2423
2802
|
}
|
|
2803
|
+
function readLine(source, edge2) {
|
|
2804
|
+
const text2 = source.text;
|
|
2805
|
+
const from = endAt(source, edge2[1] ?? "", edge2.indices?.[1]?.[0] ?? 0, "from");
|
|
2806
|
+
const to = endAt(source, edge2[2] ?? "", edge2.indices?.[2]?.[0] ?? 0, "to");
|
|
2807
|
+
const at = skipSpaces(text2, edge2[0].length);
|
|
2808
|
+
if (text2[at] !== ":") return { from, to, at };
|
|
2809
|
+
const named = readName(source, at + 1, m);
|
|
2810
|
+
if (named.value === "") throw fail(source, at, m.emptyLabel);
|
|
2811
|
+
return { from, to, label: named.value, at: named.rest };
|
|
2812
|
+
}
|
|
2813
|
+
function readPath(source, edge2) {
|
|
2814
|
+
const { from, to, label: label2, at } = readLine(source, edge2);
|
|
2815
|
+
if (at < source.text.length) throw fail(source, at, source.text[at] === "[" ? m.pathNoAttrs : m.edgeShape);
|
|
2816
|
+
return { from, to, ...label2 !== void 0 ? { label: label2 } : {} };
|
|
2817
|
+
}
|
|
2424
2818
|
function readEdge(source, edge2) {
|
|
2425
2819
|
const text2 = source.text;
|
|
2426
|
-
const from
|
|
2427
|
-
const to = boxAt(source, edge2[2] ?? "", edge2.indices?.[2]?.[0] ?? 0);
|
|
2428
|
-
let at = skipSpaces(text2, edge2[0].length);
|
|
2429
|
-
let label2;
|
|
2430
|
-
if (text2[at] === ":") {
|
|
2431
|
-
const named = readName(source, at + 1, m);
|
|
2432
|
-
if (named.value === "") throw fail(source, at, m.emptyLabel);
|
|
2433
|
-
label2 = named.value;
|
|
2434
|
-
at = named.rest;
|
|
2435
|
-
}
|
|
2820
|
+
const { from, to, label: label2, at } = readLine(source, edge2);
|
|
2436
2821
|
if (at < text2.length && text2[at] !== "[") throw fail(source, at, m.edgeShape);
|
|
2437
2822
|
const attrs2 = at < text2.length ? readAttrs(source, at, ATTRS.edge, m) : /* @__PURE__ */ new Map();
|
|
2438
2823
|
const tag = attrs2.get("tag");
|
|
2439
2824
|
const carried = attrs2.get("carry");
|
|
2440
2825
|
if (tag && carried) throw fail(source, Math.max(tag.at, carried.at), m.carryTwice);
|
|
2441
2826
|
if (carried && !isOneOf(CARRIES, carried.value)) throw fail(source, carried.at, m.badCarry);
|
|
2442
|
-
const
|
|
2443
|
-
if (
|
|
2827
|
+
const side2 = attrs2.get("side");
|
|
2828
|
+
if (side2 && !isOneOf(SIDES, side2.value)) throw fail(source, side2.at, m.badSide);
|
|
2444
2829
|
let carry = { kind: "envelope" };
|
|
2445
2830
|
if (tag) carry = { kind: "tag", text: tag.value };
|
|
2446
2831
|
else if (carried) carry = carried.value === "coin" ? { kind: "coin" } : { kind: "none" };
|
|
@@ -2450,7 +2835,7 @@ function parseLines(lines, m) {
|
|
|
2450
2835
|
to,
|
|
2451
2836
|
...label2 !== void 0 ? { label: label2 } : {},
|
|
2452
2837
|
carry,
|
|
2453
|
-
...
|
|
2838
|
+
...side2 ? { labelSide: side2.value } : {}
|
|
2454
2839
|
};
|
|
2455
2840
|
}
|
|
2456
2841
|
function readSet(source) {
|
|
@@ -2518,11 +2903,12 @@ var declareBox = (b) => `box ${b.id}${shown(b.id, b.name)}${attrs([
|
|
|
2518
2903
|
["color", b.color],
|
|
2519
2904
|
["icon", b.icon]
|
|
2520
2905
|
])}`;
|
|
2906
|
+
var line = (from, to, label2) => `${from} -> ${to}${label2 === void 0 ? "" : `: ${name(label2)}`}`;
|
|
2521
2907
|
function event(e) {
|
|
2522
2908
|
switch (e.type) {
|
|
2523
2909
|
case "edge": {
|
|
2524
2910
|
const carry = e.carry.kind === "tag" ? [["tag", e.carry.text]] : e.carry.kind === "envelope" ? [] : [["carry", e.carry.kind]];
|
|
2525
|
-
return `${e.from
|
|
2911
|
+
return `${line(e.from, e.to, e.label)}${attrs([...carry, ["side", e.labelSide]])}`;
|
|
2526
2912
|
}
|
|
2527
2913
|
case "action":
|
|
2528
2914
|
return `act ${e.box}: ${e.label}`;
|
|
@@ -2560,16 +2946,17 @@ end`);
|
|
|
2560
2946
|
const region = regions.find((r) => r.id === run.region);
|
|
2561
2947
|
const open = declared.has(run.region) || !region ? `group ${run.region}` : declareRegion(region);
|
|
2562
2948
|
declared.add(run.region);
|
|
2563
|
-
blocks.push([open, ...lines.map((
|
|
2949
|
+
blocks.push([open, ...lines.map((line2) => ` ${line2}`), "end"].join("\n"));
|
|
2564
2950
|
}
|
|
2565
2951
|
return blocks;
|
|
2566
2952
|
}
|
|
2567
2953
|
function printNotation(diagram) {
|
|
2568
2954
|
const blocks = [`${diagram.kind} ${name(diagram.title)}${attrs([["view", diagram.view]])}`, ...declarations(diagram)];
|
|
2569
2955
|
if (diagram.strip) blocks.push(`strip ${key(diagram.strip.title)}: ${diagram.strip.fields.map(field).join(", ")}`);
|
|
2956
|
+
if (diagram.state) blocks.push(diagram.state.paths.map((p) => line(p.from, p.to, p.label)).join("\n"));
|
|
2570
2957
|
for (const step of diagram.steps) {
|
|
2571
2958
|
const body = step.body.split("\n");
|
|
2572
|
-
const say = body.length === 1 ? [` say ${step.body}`] : [" say", ...body.map((
|
|
2959
|
+
const say = body.length === 1 ? [` say ${step.body}`] : [" say", ...body.map((line2) => line2 === "" ? "" : ` ${line2}`)];
|
|
2573
2960
|
blocks.push(
|
|
2574
2961
|
[`step ${step.title}`, ...say, ...step.code === void 0 ? [] : [` code ${step.code}`], ...step.events.map((e) => ` ${event(e)}`)].join("\n")
|
|
2575
2962
|
);
|
|
@@ -2848,13 +3235,46 @@ var LOOK = {
|
|
|
2848
3235
|
region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
|
|
2849
3236
|
architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
|
|
2850
3237
|
sequence: { columnGap: 40, labelRoom: 16, firstRow: 22, rowGap: 14, stepGap: 8, minPitch: 40, tail: 18, selfW: 34, selfH: 18 },
|
|
2851
|
-
|
|
3238
|
+
/**
|
|
3239
|
+
* 状態遷移図 (#3163)。状態は `columns` つずつ並べて次の段へ折り返し、段の間 (`rowGap`) の真ん中を、段をまたぐ線が通る。
|
|
3240
|
+
* `start` と `end` は始まりと終わりの印の半径と、印の中の丸の半径。`drop` は最初の状態の上端から始まりの印の中心まで、
|
|
3241
|
+
* `below` は状態の下端から終わりの印の中心まで、`beside` は状態の右端から右に置く終わりの印の中心まで、`text` は印の中心から字の左端まで。
|
|
3242
|
+
* `loop` は同じ状態へ戻る輪の幅と深さ。`side` は脇道の囲みの内側の余白、1 段目の上端との間、脇道へ入る線が横に通る所の囲みの下端からの離れ、
|
|
3243
|
+
* 点線の線が箱へ入る所を箱の端から離す幅。
|
|
3244
|
+
* `ghost` は脇道の点線の札で、絵柄を左に、名前と下の字を右に並べる (#3171)。`h` は札の高さ、`pad` は左右の余白、`gap` は絵柄と字の間、
|
|
3245
|
+
* `nameY` と `subY` は札の真ん中から名前と下の字の基準線まで。
|
|
3246
|
+
* `done` は出た状態の右上の済んだ印の半径と、箱の右上の角からの離れ。
|
|
3247
|
+
* `loop` の `samples` は同じ状態へ戻る弧を区切る点の数、`badgeAt` は弧の段の番号を弧の上端から深さのどこに置くかの割合。
|
|
3248
|
+
* `pastLabel` は段が終わった後に薄く残す線の名前の濃さ (#3171)
|
|
3249
|
+
*/
|
|
3250
|
+
state: {
|
|
3251
|
+
columns: 4,
|
|
3252
|
+
columnGap: 64,
|
|
3253
|
+
rowGap: 108,
|
|
3254
|
+
labelRoom: 16,
|
|
3255
|
+
start: 7,
|
|
3256
|
+
end: { r: 9, inner: 5 },
|
|
3257
|
+
drop: 56,
|
|
3258
|
+
below: 64,
|
|
3259
|
+
beside: 38,
|
|
3260
|
+
text: 16,
|
|
3261
|
+
loop: { w: 24, h: 34, samples: 12, badgeAt: 0.6 },
|
|
3262
|
+
side: { pad: 16, gap: 76, lane: 30, entry: 28 },
|
|
3263
|
+
ghost: { h: 52, pad: 12, gap: 10, nameY: -2, subY: 14 },
|
|
3264
|
+
done: { r: 6.5, inset: 13 },
|
|
3265
|
+
pastLabel: 0.85
|
|
3266
|
+
},
|
|
3267
|
+
/** `bend` は線の曲がりを丸める半径 (#3171) */
|
|
3268
|
+
edge: { inset: 3, arrow: 6, arrowHalf: 3.5, parallel: 5, ghostDash: 5, flowDash: 9, bend: 12 },
|
|
2852
3269
|
label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6 },
|
|
2853
3270
|
action: { h: 22, padX: 10, radius: 11 },
|
|
2854
3271
|
badge: { r: 9.5, ring: 9, inset: 4, along: 14, short: 44 },
|
|
2855
3272
|
carrier: { envW: 24, envH: 17, coinR: 6.5, coinIn: 3.8, tagH: 18, tagPadX: 8, samples: 16 },
|
|
2856
|
-
|
|
2857
|
-
|
|
3273
|
+
/**
|
|
3274
|
+
* `trail` は状態遷移図の帯の最後の、通った状態の点 (#3171)。`r` は点の半径、`step` は点の中心どうしの間、`now` は変わった値の欄の名前の横の点の半径と、名前からの離れ
|
|
3275
|
+
*/
|
|
3276
|
+
strip: { h: 72, line: 44, pad: 12, icon: 24, titleX: 44, fieldGap: 22, sepInset: 14, tagGap: 6, tagH: 15, tagPadX: 7, nameY: 22, valueY: 43, trail: { r: 5.4, step: 16 }, now: { r: 3, gap: 7 } },
|
|
3277
|
+
stroke: { hair: 1, edge: 1.7, edgeOn: 2.25, arrow: 1.5, flow: 1.3, halo: 7, on: 1.75, glyph: 2, lifeline: 1.2, envelope: 1.5, badgeRing: 1.5, path: 1.6, end: 1.6, done: 1.2, trail: 1.2 },
|
|
2858
3278
|
shadow: { near: 0.8, far: 4, nearY: 1, farY: 3 },
|
|
2859
3279
|
mini: { w: 168, pad: 8, title: 14, inset: 12, radius: 10 },
|
|
2860
3280
|
/**
|
|
@@ -2868,9 +3288,9 @@ var LOOK = {
|
|
|
2868
3288
|
*/
|
|
2869
3289
|
follow: { aspect: 0.75, minH: 320, fitMinH: 160, ease: 0.6, narrow: 440, badgeRoom: 8, headRoom: 10, head: { pad: 8, h: 40, nameY: 17, subY: 31 } },
|
|
2870
3290
|
/** 色を混ぜる割合 (%) */
|
|
2871
|
-
mix: { icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6 },
|
|
3291
|
+
mix: { icon: 14, regionIcon: 16, regionIconEdge: 34, cap: 12, capEdge: 42, badgePast: 14, badgePastEdge: 70, mini: 62, miniBand: 16, miniBandEdge: 36, view: 6, side: 4, sideEdge: 36, ghostEdge: 60, path: 55, past: 72 },
|
|
2872
3292
|
/** 字の並びの基準線を、置きたい高さの真ん中からどれだけ下げるか */
|
|
2873
|
-
baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8 },
|
|
3293
|
+
baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8, mark: 4 },
|
|
2874
3294
|
/** 浮いて出る物が下から上がる長さと、弾んで出る物の始まりの大きさ */
|
|
2875
3295
|
rise: 5,
|
|
2876
3296
|
popFrom: 0.4,
|
|
@@ -2911,7 +3331,9 @@ var MOTION = {
|
|
|
2911
3331
|
popFade: 0.4,
|
|
2912
3332
|
untilFade: 0.2,
|
|
2913
3333
|
/** 段の止め絵を撮る時刻を、段の終わりからどれだけ前にするか */
|
|
2914
|
-
still: 0.45
|
|
3334
|
+
still: 0.45,
|
|
3335
|
+
/** 状態遷移図で、札が状態を出てから済んだ印が出るまで */
|
|
3336
|
+
done: 0.3
|
|
2915
3337
|
};
|
|
2916
3338
|
var READABLE_PX = 10.5;
|
|
2917
3339
|
var EASE = {
|
|
@@ -2929,7 +3351,13 @@ var FIGURE_TEXT = {
|
|
|
2929
3351
|
pause: "\u6B62\u3081\u308B",
|
|
2930
3352
|
play: "\u52D5\u304B\u3059",
|
|
2931
3353
|
next: "\u6B21\u306E\u6BB5",
|
|
2932
|
-
steps: (title) => `${title} \u306E\u6BB5
|
|
3354
|
+
steps: (title) => `${title} \u306E\u6BB5`,
|
|
3355
|
+
side: "\u8107\u9053",
|
|
3356
|
+
sideNote: "\u4ECA\u56DE\u306F\u901A\u3089\u306A\u3044",
|
|
3357
|
+
sideFrom: (count) => `${count} \u3064\u306E\u72B6\u614B\u304B\u3089\u5165\u308C\u308B`,
|
|
3358
|
+
trail: "\u901A\u3063\u305F\u72B6\u614B",
|
|
3359
|
+
start: "\u59CB\u307E\u308A",
|
|
3360
|
+
end: "\u7D42\u308F\u308A"
|
|
2933
3361
|
},
|
|
2934
3362
|
en: {
|
|
2935
3363
|
cannotDraw: (detail) => `Cannot draw the diagram: ${detail}`,
|
|
@@ -2938,7 +3366,13 @@ var FIGURE_TEXT = {
|
|
|
2938
3366
|
pause: "Pause",
|
|
2939
3367
|
play: "Play",
|
|
2940
3368
|
next: "Next step",
|
|
2941
|
-
steps: (title) => `Steps of ${title}
|
|
3369
|
+
steps: (title) => `Steps of ${title}`,
|
|
3370
|
+
side: "Side path",
|
|
3371
|
+
sideNote: "Not taken this time",
|
|
3372
|
+
sideFrom: (count) => `Enterable from ${count} ${count === 1 ? "state" : "states"}`,
|
|
3373
|
+
trail: "States passed",
|
|
3374
|
+
start: "Start",
|
|
3375
|
+
end: "End"
|
|
2942
3376
|
}
|
|
2943
3377
|
};
|
|
2944
3378
|
|
|
@@ -3033,12 +3467,12 @@ function placeLabel(request, obstacles) {
|
|
|
3033
3467
|
const segment = longest(request.points);
|
|
3034
3468
|
const mx = (segment.a[0] + segment.b[0]) / 2;
|
|
3035
3469
|
const my = (segment.a[1] + segment.b[1]) / 2;
|
|
3036
|
-
const
|
|
3470
|
+
const side2 = request.side ?? (segment.vertical ? "right" : "above");
|
|
3037
3471
|
const { offset, side: sideGap } = LOOK.label;
|
|
3038
|
-
const base =
|
|
3039
|
-
const away =
|
|
3472
|
+
const base = side2 === "above" ? { x: mx - w / 2, y: my - offset - h / 2, w, h } : side2 === "below" ? { x: mx - w / 2, y: my + offset - h / 2, w, h } : side2 === "left" ? { x: mx - sideGap - w, y: my - h / 2, w, h } : { x: mx + sideGap, y: my - h / 2, w, h };
|
|
3473
|
+
const away = side2 === "above" ? [0, -1] : side2 === "below" ? [0, 1] : side2 === "left" ? [-1, 0] : [1, 0];
|
|
3040
3474
|
const slideAxis = [Math.abs(away[1]), Math.abs(away[0])];
|
|
3041
|
-
const slideMax =
|
|
3475
|
+
const slideMax = side2 === "above" || side2 === "below" ? w : h * 4;
|
|
3042
3476
|
const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft);
|
|
3043
3477
|
const { search, searchMax } = LOOK.label;
|
|
3044
3478
|
for (let d = 0; d <= searchMax; d += search) {
|
|
@@ -3064,29 +3498,36 @@ function fieldWidth(diagram, name2) {
|
|
|
3064
3498
|
const both = value2 + (tag > 0 ? (value2 > 0 ? LOOK.strip.tagGap : 0) + tag : 0);
|
|
3065
3499
|
return Math.max(textWidth(name2, TYPE.fieldName), both);
|
|
3066
3500
|
}
|
|
3067
|
-
|
|
3501
|
+
var trailWidth = (trail) => Math.max(textWidth(trail.title, TYPE.fieldName), trail.states.length * LOOK.strip.trail.step);
|
|
3502
|
+
function stripNeed(diagram, trail) {
|
|
3068
3503
|
if (!diagram.strip) return 0;
|
|
3069
3504
|
const { titleX, fieldGap, pad: pad2 } = LOOK.strip;
|
|
3070
3505
|
const start = titleX + textWidth(diagram.strip.title, TYPE.stripTitle) + fieldGap;
|
|
3071
|
-
|
|
3506
|
+
const widths = [...diagram.strip.fields.map((name2) => fieldWidth(diagram, name2)), ...trail ? [trailWidth(trail)] : []];
|
|
3507
|
+
return start + widths.reduce((sum, w) => sum + w + fieldGap, 0) - fieldGap + pad2;
|
|
3072
3508
|
}
|
|
3073
|
-
function layoutStrip(diagram, x, y, width) {
|
|
3509
|
+
function layoutStrip(diagram, x, y, width, trail) {
|
|
3074
3510
|
if (!diagram.strip) return void 0;
|
|
3075
|
-
const { titleX, fieldGap, pad: pad2, line, h } = LOOK.strip;
|
|
3511
|
+
const { titleX, fieldGap, pad: pad2, line: line2, h } = LOOK.strip;
|
|
3076
3512
|
const start = titleX + textWidth(diagram.strip.title, TYPE.stripTitle) + fieldGap;
|
|
3077
3513
|
const fields = [];
|
|
3078
3514
|
let cx = start;
|
|
3079
3515
|
let row = 0;
|
|
3080
|
-
|
|
3081
|
-
const w = fieldWidth(diagram, name2);
|
|
3516
|
+
const place = (w) => {
|
|
3082
3517
|
if (cx > start && cx + w > width - pad2) {
|
|
3083
3518
|
cx = start;
|
|
3084
3519
|
row++;
|
|
3085
3520
|
}
|
|
3086
|
-
|
|
3521
|
+
const at = { x: x + cx, y: y + row * line2 };
|
|
3087
3522
|
cx += w + fieldGap;
|
|
3523
|
+
return at;
|
|
3524
|
+
};
|
|
3525
|
+
for (const name2 of diagram.strip.fields) {
|
|
3526
|
+
const w = fieldWidth(diagram, name2);
|
|
3527
|
+
fields.push({ name: name2, ...place(w), w });
|
|
3088
3528
|
}
|
|
3089
|
-
|
|
3529
|
+
const laidTrail = trail ? { ...trail, ...place(trailWidth(trail)), w: trailWidth(trail) } : void 0;
|
|
3530
|
+
return { x, y, w: width, h: h + row * line2, title: diagram.strip.title, fields, ...laidTrail ? { trail: laidTrail } : {} };
|
|
3090
3531
|
}
|
|
3091
3532
|
function shiftContent(layout, dx, dy) {
|
|
3092
3533
|
const move = (rect) => {
|
|
@@ -3102,16 +3543,25 @@ function shiftContent(layout, dx, dy) {
|
|
|
3102
3543
|
region.y += dy;
|
|
3103
3544
|
move(region.header);
|
|
3104
3545
|
}
|
|
3105
|
-
for (const
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3546
|
+
for (const line2 of layout.lifelines) {
|
|
3547
|
+
line2.x += dx;
|
|
3548
|
+
line2.y1 += dy;
|
|
3549
|
+
line2.y2 += dy;
|
|
3109
3550
|
}
|
|
3110
3551
|
for (const edge2 of layout.edges) {
|
|
3111
3552
|
edge2.points = edge2.points.map(([px2, py]) => [px2 + dx, py + dy]);
|
|
3112
3553
|
if (edge2.settle) edge2.settle = [edge2.settle[0] + dx, edge2.settle[1] + dy];
|
|
3113
3554
|
}
|
|
3114
3555
|
for (const label2 of layout.labels) move(label2);
|
|
3556
|
+
for (const path2 of layout.paths) {
|
|
3557
|
+
path2.points = path2.points.map(([px2, py]) => [px2 + dx, py + dy]);
|
|
3558
|
+
if (path2.label) move(path2.label);
|
|
3559
|
+
}
|
|
3560
|
+
for (const end of layout.ends) {
|
|
3561
|
+
end.x += dx;
|
|
3562
|
+
end.y += dy;
|
|
3563
|
+
}
|
|
3564
|
+
if (layout.side) move(layout.side);
|
|
3115
3565
|
for (const action2 of layout.actions) move(action2);
|
|
3116
3566
|
for (const badge2 of layout.badges) {
|
|
3117
3567
|
badge2.x += dx;
|
|
@@ -3123,6 +3573,10 @@ function shiftContent(layout, dx, dy) {
|
|
|
3123
3573
|
field2.x += dx;
|
|
3124
3574
|
field2.y += dy;
|
|
3125
3575
|
}
|
|
3576
|
+
if (layout.strip.trail) {
|
|
3577
|
+
layout.strip.trail.x += dx;
|
|
3578
|
+
layout.strip.trail.y += dy;
|
|
3579
|
+
}
|
|
3126
3580
|
}
|
|
3127
3581
|
}
|
|
3128
3582
|
function cornerBadge(events, step, layout) {
|
|
@@ -3154,7 +3608,7 @@ function groupsOf(diagram) {
|
|
|
3154
3608
|
if (loose.length > 0) groups.push({ members: loose });
|
|
3155
3609
|
return groups;
|
|
3156
3610
|
}
|
|
3157
|
-
var vertical = (
|
|
3611
|
+
var vertical = (side2) => side2 === "left" || side2 === "right";
|
|
3158
3612
|
function placeBoxes(diagram, groups) {
|
|
3159
3613
|
const columns = LOOK.architecture.columns;
|
|
3160
3614
|
const edges = edgesOf(diagram).map((e) => e.edge);
|
|
@@ -3221,10 +3675,10 @@ function nameLines(name2) {
|
|
|
3221
3675
|
return [name2.slice(0, at), name2.slice(at + 1)];
|
|
3222
3676
|
}
|
|
3223
3677
|
function headerSize(region) {
|
|
3224
|
-
const { icon, nameY, line, inset } = LOOK.region;
|
|
3678
|
+
const { icon, nameY, line: line2, inset } = LOOK.region;
|
|
3225
3679
|
const lines = nameLines(region.name);
|
|
3226
3680
|
const w = Math.max(icon, ...lines.map((l) => textWidth(l, TYPE.regionName)), textWidth(region.note ?? "", TYPE.regionNote));
|
|
3227
|
-
const h = nameY - inset + (lines.length - 1) *
|
|
3681
|
+
const h = nameY - inset + (lines.length - 1) * line2 + (region.note ? line2 : 0) + LOOK.gap / 2;
|
|
3228
3682
|
return { w, h, lines };
|
|
3229
3683
|
}
|
|
3230
3684
|
function arrange(diagram, groups, slots, rooms) {
|
|
@@ -3401,7 +3855,7 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3401
3855
|
)
|
|
3402
3856
|
);
|
|
3403
3857
|
}
|
|
3404
|
-
const layout = { kind: "architecture", width: 0, height: 0, regions, boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [] };
|
|
3858
|
+
const layout = { kind: "architecture", width: 0, height: 0, regions, boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [], paths: [], ends: [] };
|
|
3405
3859
|
const shift = labels.length > 0 ? Math.max(0, margin + LOOK.label.soft - Math.min(...labels.map((l) => l.x))) : 0;
|
|
3406
3860
|
if (shift > 0) shiftContent(layout, shift, 0);
|
|
3407
3861
|
const contentRight = Math.max(...boxes.map((b) => b.x + b.w + R.pad), ...labels.map((l) => l.x + l.w + LOOK.label.soft), ...sceneEdges.flatMap((e) => e.points.map((p) => p[0] + R.pad)));
|
|
@@ -3508,11 +3962,11 @@ function layoutSequence(diagram) {
|
|
|
3508
3962
|
let above;
|
|
3509
3963
|
let under;
|
|
3510
3964
|
if (event2.type === "edge") {
|
|
3511
|
-
const
|
|
3965
|
+
const side2 = event2.labelSide ?? "above";
|
|
3512
3966
|
const self = event2.from === event2.to;
|
|
3513
3967
|
const named = event2.label !== void 0;
|
|
3514
|
-
above = named &&
|
|
3515
|
-
under = self ? Q.selfH + gap : named &&
|
|
3968
|
+
above = named && side2 === "above" ? L.offset + L.h / 2 : gap;
|
|
3969
|
+
under = self ? Q.selfH + gap : named && side2 === "below" ? L.offset + L.h / 2 : gap;
|
|
3516
3970
|
} else {
|
|
3517
3971
|
above = LOOK.action.h / 2;
|
|
3518
3972
|
under = LOOK.action.h / 2;
|
|
@@ -3559,7 +4013,7 @@ function layoutSequence(diagram) {
|
|
|
3559
4013
|
const soft = [...labels.filter((l) => l.step === request.step), ...actions];
|
|
3560
4014
|
labels.push(placeLabel(request, { hard: boxes, soft }));
|
|
3561
4015
|
}
|
|
3562
|
-
const layout = { kind: "sequence", width: 0, height: 0, regions: [], boxes, lifelines, edges, labels, actions, badges: [] };
|
|
4016
|
+
const layout = { kind: "sequence", width: 0, height: 0, regions: [], boxes, lifelines, edges, labels, actions, badges: [], paths: [], ends: [] };
|
|
3563
4017
|
const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...actions.map((a) => a.x)];
|
|
3564
4018
|
const shift = Math.max(0, margin - Math.min(...lefts));
|
|
3565
4019
|
if (shift > 0) shiftContent(layout, shift, 0);
|
|
@@ -3586,6 +4040,301 @@ function badges(diagram, layout) {
|
|
|
3586
4040
|
});
|
|
3587
4041
|
}
|
|
3588
4042
|
|
|
4043
|
+
// src/layout/state.ts
|
|
4044
|
+
var isEnd = (id) => STATE_ENDS.includes(id);
|
|
4045
|
+
function visitOrder(diagram) {
|
|
4046
|
+
const order = [];
|
|
4047
|
+
const add = (id) => {
|
|
4048
|
+
if (!isEnd(id) && !order.includes(id)) order.push(id);
|
|
4049
|
+
};
|
|
4050
|
+
for (const { edge: edge2 } of edgesOf(diagram)) {
|
|
4051
|
+
add(edge2.from);
|
|
4052
|
+
add(edge2.to);
|
|
4053
|
+
}
|
|
4054
|
+
return order;
|
|
4055
|
+
}
|
|
4056
|
+
function carrierHalf(carry) {
|
|
4057
|
+
const C = LOOK.carrier;
|
|
4058
|
+
if (carry.kind === "tag") return (textWidth(carry.text, hasWide(carry.text) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2) / 2;
|
|
4059
|
+
if (carry.kind === "coin") return C.coinR;
|
|
4060
|
+
return C.envW / 2;
|
|
4061
|
+
}
|
|
4062
|
+
var same = (a, b) => a.from === b.from && a.to === b.to;
|
|
4063
|
+
function layoutState(diagram, lang) {
|
|
4064
|
+
const { box: B, state: T, margin, gap } = LOOK;
|
|
4065
|
+
const inset = LOOK.edge.inset;
|
|
4066
|
+
const words = FIGURE_TEXT[lang];
|
|
4067
|
+
const colors = boxColors(diagram);
|
|
4068
|
+
const steps = edgesOf(diagram);
|
|
4069
|
+
const walked = visitOrder(diagram);
|
|
4070
|
+
const ghosts = diagram.boxes.map((b) => b.id).filter((id) => !walked.includes(id));
|
|
4071
|
+
const notTaken = (diagram.state?.paths ?? []).filter((p) => !steps.some(({ edge: edge2 }) => same(edge2, p)));
|
|
4072
|
+
const lines = [...steps.map(({ edge: edge2 }) => edge2), ...notTaken];
|
|
4073
|
+
const G = T.ghost;
|
|
4074
|
+
const ghostWidth = (id) => {
|
|
4075
|
+
const source = diagram.boxes.find((b) => b.id === id);
|
|
4076
|
+
return G.pad * 2 + B.icon + G.gap + Math.max(textWidth(source?.name ?? id, TYPE.boxName), textWidth(source?.sub ?? "", TYPE.boxSub));
|
|
4077
|
+
};
|
|
4078
|
+
const widths = new Map(diagram.boxes.map((b) => [b.id, ghosts.includes(b.id) ? ghostWidth(b.id) : boxWidth(diagram, b.id, true)]));
|
|
4079
|
+
const columnCount = Math.max(1, Math.min(T.columns, walked.length));
|
|
4080
|
+
const rowCount = Math.max(1, Math.ceil(walked.length / T.columns));
|
|
4081
|
+
const slot = new Map(
|
|
4082
|
+
walked.map((id, k) => {
|
|
4083
|
+
const row = Math.floor(k / T.columns);
|
|
4084
|
+
const at = k % T.columns;
|
|
4085
|
+
return [id, { row, col: row % 2 === 0 ? at : columnCount - 1 - at }];
|
|
4086
|
+
})
|
|
4087
|
+
);
|
|
4088
|
+
const colW = Array.from({ length: columnCount }, (_, c) => Math.max(B.minW, ...walked.filter((id) => slot.get(id)?.col === c).map((id) => widths.get(id) ?? B.minW)));
|
|
4089
|
+
const between = Array.from({ length: Math.max(0, columnCount - 1) }, () => T.columnGap);
|
|
4090
|
+
for (const line2 of lines) {
|
|
4091
|
+
const a = slot.get(line2.from);
|
|
4092
|
+
const b = slot.get(line2.to);
|
|
4093
|
+
if (!a || !b || line2.label === void 0 || a.row !== b.row || Math.abs(a.col - b.col) !== 1) continue;
|
|
4094
|
+
const i = Math.min(a.col, b.col);
|
|
4095
|
+
between[i] = Math.max(between[i] ?? 0, textWidth(line2.label, labelStyle(line2.label)) + LOOK.label.padX * 2 + T.labelRoom * 2);
|
|
4096
|
+
}
|
|
4097
|
+
const colLeft = [];
|
|
4098
|
+
for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
|
|
4099
|
+
const center = (c) => colLeft[c] + colW[c] / 2;
|
|
4100
|
+
const isGhost = (id) => ghosts.includes(id);
|
|
4101
|
+
const enteringFrom = new Set(notTaken.filter((p) => isGhost(p.to) && !isGhost(p.from) && !isEnd(p.from)).map((p) => p.from));
|
|
4102
|
+
const notes = [words.sideNote, ...enteringFrom.size > 0 ? [words.sideFrom(enteringFrom.size)] : []];
|
|
4103
|
+
const titleW = Math.max(textWidth(words.side, TYPE.regionName), ...notes.map((note) => textWidth(note, TYPE.regionNote)));
|
|
4104
|
+
const sideH = T.side.pad * 2 + Math.max(G.h, TYPE.regionName.size + LOOK.region.line * notes.length + T.side.pad / 4);
|
|
4105
|
+
const starts = lines.some((line2) => line2.from === "start");
|
|
4106
|
+
const top0 = margin + (ghosts.length > 0 ? sideH + T.side.gap : starts ? T.start + T.drop : 0);
|
|
4107
|
+
const rowY = (row) => top0 + row * (B.h + T.rowGap);
|
|
4108
|
+
const boxOf = (id, cx, y, ghost) => {
|
|
4109
|
+
const source = diagram.boxes.find((b) => b.id === id);
|
|
4110
|
+
const w = widths.get(id) ?? B.minW;
|
|
4111
|
+
const h = ghost ? G.h : B.h;
|
|
4112
|
+
return {
|
|
4113
|
+
id,
|
|
4114
|
+
name: source?.name ?? id,
|
|
4115
|
+
...source?.sub !== void 0 ? { sub: source.sub } : {},
|
|
4116
|
+
...source?.icon !== void 0 ? { icon: source.icon } : {},
|
|
4117
|
+
color: colors.get(id) ?? "slate",
|
|
4118
|
+
x: cx - w / 2,
|
|
4119
|
+
y,
|
|
4120
|
+
w,
|
|
4121
|
+
h,
|
|
4122
|
+
cx,
|
|
4123
|
+
cy: y + h / 2,
|
|
4124
|
+
...ghost ? { ghost: true } : {}
|
|
4125
|
+
};
|
|
4126
|
+
};
|
|
4127
|
+
const boxes = walked.map((id) => {
|
|
4128
|
+
const s = slot.get(id);
|
|
4129
|
+
return boxOf(id, center(s.col), rowY(s.row), false);
|
|
4130
|
+
});
|
|
4131
|
+
const byId = new Map(boxes.map((b) => [b.id, b]));
|
|
4132
|
+
const below = (box) => boxes.some((other) => other !== box && Math.abs(other.cx - box.cx) < 0.5 && other.y > box.y);
|
|
4133
|
+
const ends = [];
|
|
4134
|
+
const first = boxes[0];
|
|
4135
|
+
const contentRight = Math.max(...boxes.map((b) => b.x + b.w));
|
|
4136
|
+
let side2;
|
|
4137
|
+
const lane = margin + sideH + T.side.lane;
|
|
4138
|
+
if (ghosts.length > 0) {
|
|
4139
|
+
const sourcesOf = (id) => notTaken.filter((p) => p.to === id).flatMap((p) => byId.get(p.from) ?? []);
|
|
4140
|
+
const all = ghosts.flatMap(sourcesOf);
|
|
4141
|
+
const x = Math.max(margin, Math.min(...all.length > 0 ? all.map((b) => b.x) : [margin + T.side.pad]) - T.side.pad);
|
|
4142
|
+
let cursor = x + T.side.pad + titleW + gap * 2;
|
|
4143
|
+
const wanted = ghosts.map((id) => {
|
|
4144
|
+
const from = sourcesOf(id);
|
|
4145
|
+
return { id, cx: from.length > 0 ? from.reduce((sum, b) => sum + b.cx, 0) / from.length : cursor };
|
|
4146
|
+
});
|
|
4147
|
+
wanted.sort((a, b) => a.cx - b.cx);
|
|
4148
|
+
let right = x;
|
|
4149
|
+
for (const { id, cx } of wanted) {
|
|
4150
|
+
const w = widths.get(id) ?? B.minW;
|
|
4151
|
+
const left = Math.max(cx - w / 2, cursor);
|
|
4152
|
+
const ghost = boxOf(id, left + w / 2, margin + (sideH - G.h) / 2, true);
|
|
4153
|
+
boxes.push(ghost);
|
|
4154
|
+
byId.set(id, ghost);
|
|
4155
|
+
const finishes = notTaken.some((p) => p.from === id && p.to === "finish");
|
|
4156
|
+
if (finishes) ends.push({ kind: "finish", x: ghost.x + ghost.w + T.beside, y: ghost.cy, r: T.end.r, ghost: true, text: "", box: id });
|
|
4157
|
+
right = finishes ? ghost.x + ghost.w + T.beside + T.end.r : ghost.x + ghost.w;
|
|
4158
|
+
cursor = right + gap * 2;
|
|
4159
|
+
}
|
|
4160
|
+
const rightmost = Math.max(right + T.side.pad, contentRight);
|
|
4161
|
+
side2 = { x, y: margin, w: rightmost - x, h: sideH, title: words.side, notes };
|
|
4162
|
+
}
|
|
4163
|
+
if (first && starts) {
|
|
4164
|
+
const reach = first.cx + T.start + T.text + textWidth(words.start, TYPE.regionNote) + gap;
|
|
4165
|
+
const y = side2 && reach < side2.x ? side2.y + T.side.pad + T.start : first.y - T.drop;
|
|
4166
|
+
ends.unshift({ kind: "start", x: first.cx, y, r: T.start, ghost: false, text: words.start });
|
|
4167
|
+
}
|
|
4168
|
+
for (const box of boxes.filter((b) => !b.ghost && lines.some((line2) => line2.from === b.id && line2.to === "finish"))) {
|
|
4169
|
+
ends.push(
|
|
4170
|
+
below(box) ? { kind: "finish", x: box.x + box.w + T.beside, y: box.cy, r: T.end.r, ghost: false, text: words.end, box: box.id } : { kind: "finish", x: box.cx, y: box.y + box.h + T.below, r: T.end.r, ghost: false, text: words.end, box: box.id }
|
|
4171
|
+
);
|
|
4172
|
+
}
|
|
4173
|
+
const between2 = (a, b) => {
|
|
4174
|
+
const sa = slot.get(a.id);
|
|
4175
|
+
const sb = slot.get(b.id);
|
|
4176
|
+
if (!sa || !sb) return [[a.cx, a.y + a.h], [b.cx, b.y - inset]];
|
|
4177
|
+
if (sa.row === sb.row && Math.abs(sa.col - sb.col) === 1) {
|
|
4178
|
+
return b.cx > a.cx ? [[a.x + a.w, a.cy], [b.x - inset, b.cy]] : [[a.x, a.cy], [b.x + b.w + inset, b.cy]];
|
|
4179
|
+
}
|
|
4180
|
+
if (sa.row === sb.row) {
|
|
4181
|
+
const y2 = a.y + a.h + T.rowGap / 4;
|
|
4182
|
+
return [[a.cx, a.y + a.h], [a.cx, y2], [b.cx, y2], [b.cx, b.y + b.h + inset]];
|
|
4183
|
+
}
|
|
4184
|
+
if (sb.row > sa.row) {
|
|
4185
|
+
if (Math.abs(a.cx - b.cx) < 0.5) return [[a.cx, a.y + a.h], [b.cx, b.y - inset]];
|
|
4186
|
+
const y2 = a.y + a.h + T.rowGap / 2;
|
|
4187
|
+
return [[a.cx, a.y + a.h], [a.cx, y2], [b.cx, y2], [b.cx, b.y - inset]];
|
|
4188
|
+
}
|
|
4189
|
+
if (Math.abs(a.cx - b.cx) < 0.5) return [[a.cx, a.y], [b.cx, b.y + b.h + inset]];
|
|
4190
|
+
const y = b.y + b.h + T.rowGap / 2;
|
|
4191
|
+
return [[a.cx, a.y], [a.cx, y], [b.cx, y], [b.cx, b.y + b.h + inset]];
|
|
4192
|
+
};
|
|
4193
|
+
const entryOf = (from, to) => {
|
|
4194
|
+
const sources = notTaken.filter((p) => p.to === to.id).flatMap((p) => byId.get(p.from) ?? []).sort((a, b) => a.cx - b.cx);
|
|
4195
|
+
const k = sources.findIndex((b) => b.id === from);
|
|
4196
|
+
if (sources.length <= 1) return Math.min(Math.max(sources[0]?.cx ?? to.cx, to.x + T.side.entry), to.x + to.w - T.side.entry);
|
|
4197
|
+
return to.x + T.side.entry + (to.w - T.side.entry * 2) * Math.max(0, k) / (sources.length - 1);
|
|
4198
|
+
};
|
|
4199
|
+
const exitX = (box) => starts && box === first ? box.cx + T.side.entry : box.cx;
|
|
4200
|
+
const finishOf = (id) => ends.find((e) => e.kind === "finish" && e.box === id);
|
|
4201
|
+
const loopOf = (box) => {
|
|
4202
|
+
const { w, h, samples } = T.loop;
|
|
4203
|
+
const bottom2 = box.y + box.h;
|
|
4204
|
+
const p0 = [box.cx + w / 2, bottom2];
|
|
4205
|
+
const c1 = [box.cx + w * 3 / 4, bottom2 + h * 4 / 3];
|
|
4206
|
+
const c2 = [box.cx - w * 3 / 4, bottom2 + h * 4 / 3];
|
|
4207
|
+
const p3 = [box.cx - w / 2, bottom2 + inset];
|
|
4208
|
+
return Array.from({ length: samples + 1 }, (_, k) => {
|
|
4209
|
+
const t = k / samples;
|
|
4210
|
+
const u = 1 - t;
|
|
4211
|
+
const at = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
|
|
4212
|
+
return [at(0), at(1)];
|
|
4213
|
+
});
|
|
4214
|
+
};
|
|
4215
|
+
const route = (from, to) => {
|
|
4216
|
+
if (from === "start") {
|
|
4217
|
+
const start = ends.find((e) => e.kind === "start");
|
|
4218
|
+
const target = byId.get(to);
|
|
4219
|
+
if (!start || !target) return [];
|
|
4220
|
+
return [[start.x, start.y + start.r], [target.cx, target.y - inset]];
|
|
4221
|
+
}
|
|
4222
|
+
const a = byId.get(from);
|
|
4223
|
+
if (!a) return [];
|
|
4224
|
+
if (to === "finish") {
|
|
4225
|
+
const end = finishOf(from);
|
|
4226
|
+
if (!end) return [];
|
|
4227
|
+
return Math.abs(end.x - a.cx) < 0.5 ? [[a.cx, a.y + a.h], [a.cx, end.y - end.r - inset]] : [[a.x + a.w, a.cy], [end.x - end.r - inset, a.cy]];
|
|
4228
|
+
}
|
|
4229
|
+
const b = byId.get(to);
|
|
4230
|
+
if (!b) return [];
|
|
4231
|
+
if (from === to) return loopOf(a);
|
|
4232
|
+
if (b.ghost && !a.ghost) {
|
|
4233
|
+
const sx = exitX(a);
|
|
4234
|
+
const ex = entryOf(from, b);
|
|
4235
|
+
return Math.abs(sx - ex) < 0.5 ? [[sx, a.y], [ex, b.y + b.h + inset]] : [[sx, a.y], [sx, lane], [ex, lane], [ex, b.y + b.h + inset]];
|
|
4236
|
+
}
|
|
4237
|
+
if (a.ghost && b.ghost) return [[a.x + a.w, a.cy], [b.x - inset, b.cy]];
|
|
4238
|
+
if (a.ghost) return [[a.cx, a.y + a.h], [a.cx, lane], [b.cx, lane], [b.cx, b.y - inset]];
|
|
4239
|
+
return between2(a, b);
|
|
4240
|
+
};
|
|
4241
|
+
const settleOf = (edge2) => {
|
|
4242
|
+
const target = byId.get(edge2.to);
|
|
4243
|
+
if (target) return [target.cx, target.cy + B.iconY];
|
|
4244
|
+
const end = edge2.to === "finish" ? finishOf(edge2.from) : void 0;
|
|
4245
|
+
if (!end) return void 0;
|
|
4246
|
+
const from = byId.get(edge2.from);
|
|
4247
|
+
return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge2.carry), end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
|
|
4248
|
+
};
|
|
4249
|
+
const sceneEdges = steps.map(({ step, event: event2, edge: edge2 }) => {
|
|
4250
|
+
const settle = settleOf(edge2);
|
|
4251
|
+
return {
|
|
4252
|
+
step,
|
|
4253
|
+
event: event2,
|
|
4254
|
+
from: edge2.from,
|
|
4255
|
+
to: edge2.to,
|
|
4256
|
+
points: route(edge2.from, edge2.to),
|
|
4257
|
+
color: colorOf(edge2, colors),
|
|
4258
|
+
carry: edge2.carry,
|
|
4259
|
+
...settle ? { settle } : {}
|
|
4260
|
+
};
|
|
4261
|
+
});
|
|
4262
|
+
for (const e of sceneEdges) {
|
|
4263
|
+
if (e.points.length !== 2 || !sceneEdges.some((o) => o.from === e.to && o.to === e.from && o.points.length === 2)) continue;
|
|
4264
|
+
const [p, q] = e.points;
|
|
4265
|
+
const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
|
|
4266
|
+
const d = (e.from < e.to ? 1 : -1) * LOOK.edge.parallel;
|
|
4267
|
+
e.points = e.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
|
|
4268
|
+
}
|
|
4269
|
+
const paths = notTaken.map((p) => ({ from: p.from, to: p.to, points: route(p.from, p.to) }));
|
|
4270
|
+
const labels = [];
|
|
4271
|
+
const soft = side2 ? [{ x: side2.x, y: side2.y, w: T.side.pad + titleW, h: side2.h }] : [];
|
|
4272
|
+
for (const e of sceneEdges) {
|
|
4273
|
+
const source = diagram.steps[e.step]?.events[e.event];
|
|
4274
|
+
if (source?.type !== "edge" || source.label === void 0) continue;
|
|
4275
|
+
const style = labelStyle(source.label);
|
|
4276
|
+
if (e.from === e.to) {
|
|
4277
|
+
const w = textWidth(source.label, style) + LOOK.label.padX * 2;
|
|
4278
|
+
const bottom2 = Math.max(...e.points.map(([, y]) => y));
|
|
4279
|
+
labels.push({ step: e.step, event: e.event, text: source.label, family: style.family, color: e.color, x: (e.points[0]?.[0] ?? 0) - T.loop.w / 2 - w / 2, y: bottom2 + LOOK.label.soft, w, h: LOOK.label.h });
|
|
4280
|
+
continue;
|
|
4281
|
+
}
|
|
4282
|
+
const side22 = source.labelSide ?? (e.to === "finish" ? "left" : void 0);
|
|
4283
|
+
labels.push(
|
|
4284
|
+
placeLabel(
|
|
4285
|
+
{ step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...side22 ? { side: side22 } : {} },
|
|
4286
|
+
{ hard: boxes, soft: [...soft, ...labels.filter((l) => l.step === e.step)] }
|
|
4287
|
+
)
|
|
4288
|
+
);
|
|
4289
|
+
}
|
|
4290
|
+
notTaken.forEach((p, i) => {
|
|
4291
|
+
const path2 = paths[i];
|
|
4292
|
+
if (p.label === void 0 || path2.points.length === 0) return;
|
|
4293
|
+
const style = labelStyle(p.label);
|
|
4294
|
+
const into = byId.get(p.to)?.ghost === true && byId.get(p.from)?.ghost !== true;
|
|
4295
|
+
const rect = into ? { x: path2.points[0][0] + LOOK.label.soft, y: lane + LOOK.label.soft, w: textWidth(p.label, style) + LOOK.label.padX * 2, h: LOOK.label.h } : placeLabel({ step: -1, event: i, text: p.label, points: path2.points, color: "slate" }, { hard: boxes, soft });
|
|
4296
|
+
path2.label = { x: rect.x, y: rect.y, w: rect.w, h: rect.h, text: p.label, family: style.family };
|
|
4297
|
+
});
|
|
4298
|
+
const layout = { kind: "state", width: 0, height: 0, regions: [], boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [], paths, ends, ...side2 ? { side: side2 } : {} };
|
|
4299
|
+
const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...paths.flatMap((p) => p.label ? [p.label.x] : [])];
|
|
4300
|
+
const shift = Math.max(0, margin - Math.min(...lefts));
|
|
4301
|
+
if (shift > 0) shiftContent(layout, shift, 0);
|
|
4302
|
+
const endRight = (e) => e.x + (e.text === "" ? e.r : T.text + textWidth(e.text, TYPE.regionNote));
|
|
4303
|
+
const rights = [
|
|
4304
|
+
...boxes.map((b) => b.x + b.w),
|
|
4305
|
+
...labels.map((l) => l.x + l.w),
|
|
4306
|
+
...ends.map(endRight),
|
|
4307
|
+
...sceneEdges.flatMap((e) => e.points.map((p) => p[0])),
|
|
4308
|
+
...paths.flatMap((p) => [...p.points.map((q) => q[0]), ...p.label ? [p.label.x + p.label.w] : []]),
|
|
4309
|
+
...side2 ? [side2.x + side2.w] : []
|
|
4310
|
+
];
|
|
4311
|
+
const bottoms = [...boxes.map((b) => b.y + b.h), ...labels.map((l) => l.y + l.h), ...ends.map((e) => e.y + e.r), ...sceneEdges.flatMap((e) => e.points.map((p) => p[1]))];
|
|
4312
|
+
const trail = { title: words.trail, states: walked.map((id) => ({ box: id, color: colors.get(id) ?? "slate" })) };
|
|
4313
|
+
const width = Math.max(Math.max(...rights) + margin, stripNeed(diagram, trail) + margin * 2);
|
|
4314
|
+
const bottom = Math.max(...bottoms, rowY(rowCount - 1) + B.h);
|
|
4315
|
+
const strip2 = layoutStrip(diagram, margin, bottom + gap, width - margin * 2, trail);
|
|
4316
|
+
layout.width = width;
|
|
4317
|
+
layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
|
|
4318
|
+
if (strip2) layout.strip = strip2;
|
|
4319
|
+
layout.badges = diagram.steps.map((step, s) => {
|
|
4320
|
+
const edge2 = sceneEdges.find((e) => e.step === s && e.points.length > 0);
|
|
4321
|
+
if (!edge2) return cornerBadge(step.events, s, layout);
|
|
4322
|
+
if (edge2.from === edge2.to) {
|
|
4323
|
+
const right = Math.max(...edge2.points.map(([px2]) => px2));
|
|
4324
|
+
const top = edge2.points[0][1];
|
|
4325
|
+
const deep = Math.max(...edge2.points.map(([, py]) => py));
|
|
4326
|
+
return { step: s, x: right + LOOK.badge.r + LOOK.badge.inset, y: top + (deep - top) * T.loop.badgeAt, color: edge2.color };
|
|
4327
|
+
}
|
|
4328
|
+
const [x, y] = badgeOnPath(edge2.points);
|
|
4329
|
+
return { step: s, x, y, color: edge2.color };
|
|
4330
|
+
});
|
|
4331
|
+
return layout;
|
|
4332
|
+
}
|
|
4333
|
+
function colorOf(edge2, colors) {
|
|
4334
|
+
if (edge2.carry.kind === "coin") return edgeColor(edge2, colors);
|
|
4335
|
+
return colors.get(edge2.to === "finish" ? edge2.from : edge2.to) ?? "slate";
|
|
4336
|
+
}
|
|
4337
|
+
|
|
3589
4338
|
// src/timeline.ts
|
|
3590
4339
|
function plan(step) {
|
|
3591
4340
|
const out = { edges: [], events: [], busy: 0 };
|
|
@@ -3645,6 +4394,7 @@ function buildTimeline(diagram) {
|
|
|
3645
4394
|
const later = named[k + 2];
|
|
3646
4395
|
if (later) label2.end = Math.min(label2.end, later.start);
|
|
3647
4396
|
});
|
|
4397
|
+
if (diagram.kind === "state") for (const label2 of named) label2.after = { start: label2.end, end: last };
|
|
3648
4398
|
labels.push(...named);
|
|
3649
4399
|
for (const event2 of p.events) events.push({ step: s, event: event2.event, at: span.start + event2.at });
|
|
3650
4400
|
});
|
|
@@ -3668,6 +4418,7 @@ function buildTimeline(diagram) {
|
|
|
3668
4418
|
});
|
|
3669
4419
|
}
|
|
3670
4420
|
carriers.sort((x, y) => x.depart - y.depart);
|
|
4421
|
+
const states = diagram.kind === "state" ? stateTimes(diagram, edges, last) : void 0;
|
|
3671
4422
|
return {
|
|
3672
4423
|
total,
|
|
3673
4424
|
last,
|
|
@@ -3677,9 +4428,33 @@ function buildTimeline(diagram) {
|
|
|
3677
4428
|
labels,
|
|
3678
4429
|
badges: steps.map((span, s) => ({ step: s, appears: span.start })),
|
|
3679
4430
|
events,
|
|
3680
|
-
stills: steps.map((span) => span.end - MOTION.still)
|
|
4431
|
+
stills: steps.map((span) => span.end - MOTION.still),
|
|
4432
|
+
...states ? { states } : {}
|
|
3681
4433
|
};
|
|
3682
4434
|
}
|
|
4435
|
+
var isEnd2 = (id) => STATE_ENDS.includes(id);
|
|
4436
|
+
function stateTimes(diagram, edges, last) {
|
|
4437
|
+
const times = /* @__PURE__ */ new Map();
|
|
4438
|
+
const of = (box) => {
|
|
4439
|
+
const found = times.get(box) ?? { box, lit: [] };
|
|
4440
|
+
times.set(box, found);
|
|
4441
|
+
return found;
|
|
4442
|
+
};
|
|
4443
|
+
let on;
|
|
4444
|
+
for (const edge2 of edges) {
|
|
4445
|
+
const event2 = diagram.steps[edge2.step]?.events[edge2.event];
|
|
4446
|
+
if (event2?.type !== "edge" || event2.from === event2.to) continue;
|
|
4447
|
+
if (on) {
|
|
4448
|
+
const left = of(on.box);
|
|
4449
|
+
left.lit.push({ start: on.since, end: edge2.start });
|
|
4450
|
+
if (on.box === event2.from && left.done === void 0) left.done = edge2.start + MOTION.done;
|
|
4451
|
+
on = void 0;
|
|
4452
|
+
}
|
|
4453
|
+
if (!isEnd2(event2.to)) on = { box: event2.to, since: edge2.drawn };
|
|
4454
|
+
}
|
|
4455
|
+
if (on) of(on.box).lit.push({ start: on.since, end: last });
|
|
4456
|
+
return [...times.values()];
|
|
4457
|
+
}
|
|
3683
4458
|
|
|
3684
4459
|
// src/render/icons.ts
|
|
3685
4460
|
var ICONS = {
|
|
@@ -3713,6 +4488,8 @@ var ICONS = {
|
|
|
3713
4488
|
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",
|
|
3714
4489
|
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",
|
|
3715
4490
|
refresh: "M 7 -3 a7.5 7.5 0 1 0 0.5 5 M 7.5 -8 v5 h-5",
|
|
4491
|
+
undo: "M -7 -2 h10 a5 5 0 0 1 0 10 h-6 M -3 -6 l-4 4 l4 4",
|
|
4492
|
+
yen: "M -6 -8 l6 7 l6 -7 M 0 -1 v9 M -5 1.5 h10 M -5 5 h10",
|
|
3716
4493
|
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",
|
|
3717
4494
|
code: "M -4 -6 l-5 6 l5 6 M 4 -6 l5 6 l-5 6",
|
|
3718
4495
|
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",
|
|
@@ -3727,7 +4504,30 @@ function glyph(name2, x, y, scale, cls = "dg-gl") {
|
|
|
3727
4504
|
const d = name2 === void 0 ? void 0 : ICONS[name2];
|
|
3728
4505
|
return d ? `<path class="${cls}" transform="translate(${r1(x)} ${r1(y)}) scale(${scale})" d="${d}"/>` : "";
|
|
3729
4506
|
}
|
|
3730
|
-
|
|
4507
|
+
function iconSvg(name2) {
|
|
4508
|
+
if (!Object.hasOwn(ICONS, name2)) return void 0;
|
|
4509
|
+
const width = LOOK.stroke.glyph * LOOK.box.iconScale;
|
|
4510
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="-12 -12 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="${width}" stroke-linecap="round" stroke-linejoin="round"><path d="${ICONS[name2]}"/></svg>`;
|
|
4511
|
+
}
|
|
4512
|
+
function pathOf(points) {
|
|
4513
|
+
const pts = points.filter((p, i) => i === 0 || p[0] !== points[i - 1][0] || p[1] !== points[i - 1][1]);
|
|
4514
|
+
const [x0, y0] = pts[0];
|
|
4515
|
+
let d = `M ${r1(x0)} ${r1(y0)}`;
|
|
4516
|
+
for (let i = 1; i < pts.length - 1; i++) {
|
|
4517
|
+
const [ax, ay] = pts[i - 1];
|
|
4518
|
+
const [bx, by] = pts[i];
|
|
4519
|
+
const [cx, cy] = pts[i + 1];
|
|
4520
|
+
const l1 = Math.hypot(bx - ax, by - ay);
|
|
4521
|
+
const l2 = Math.hypot(cx - bx, cy - by);
|
|
4522
|
+
const a = Math.min(LOOK.edge.bend, l1 / 2, l2 / 2);
|
|
4523
|
+
d += ` L ${r1(bx - (bx - ax) / l1 * a)} ${r1(by - (by - ay) / l1 * a)} Q ${r1(bx)} ${r1(by)} ${r1(bx + (cx - bx) / l2 * a)} ${r1(by + (cy - by) / l2 * a)}`;
|
|
4524
|
+
}
|
|
4525
|
+
if (pts.length > 1) {
|
|
4526
|
+
const [lx, ly] = pts[pts.length - 1];
|
|
4527
|
+
d += ` L ${r1(lx)} ${r1(ly)}`;
|
|
4528
|
+
}
|
|
4529
|
+
return d;
|
|
4530
|
+
}
|
|
3731
4531
|
function arrowHead(points) {
|
|
3732
4532
|
const [ex, ey] = points[points.length - 1];
|
|
3733
4533
|
const [px2, py] = points[points.length - 2];
|
|
@@ -3754,10 +4554,10 @@ function activeKf(ctx, on) {
|
|
|
3754
4554
|
return rangeKf(ctx.m, ranges);
|
|
3755
4555
|
}
|
|
3756
4556
|
function band(region) {
|
|
3757
|
-
const { radius, icon, iconRadius, iconScale, nameY, line } = LOOK.region;
|
|
4557
|
+
const { radius, icon, iconRadius, iconScale, nameY, line: line2 } = LOOK.region;
|
|
3758
4558
|
const { x, y } = region.header;
|
|
3759
|
-
const lines = region.lines.map((t, k) => `<text class="dg-bz" x="${r1(x)}" y="${r1(region.y + nameY + k *
|
|
3760
|
-
const note = region.note ? `<text class="dg-bx" x="${r1(x)}" y="${r1(region.y + nameY + region.lines.length *
|
|
4559
|
+
const lines = region.lines.map((t, k) => `<text class="dg-bz" x="${r1(x)}" y="${r1(region.y + nameY + k * line2)}">${esc(t)}</text>`).join("");
|
|
4560
|
+
const note = region.note ? `<text class="dg-bx" x="${r1(x)}" y="${r1(region.y + nameY + region.lines.length * line2 + 1)}">${esc(region.note)}</text>` : "";
|
|
3761
4561
|
const mark = region.icon && ICONS[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)}` : "";
|
|
3762
4562
|
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>`;
|
|
3763
4563
|
}
|
|
@@ -3774,10 +4574,10 @@ function cardFrame(box, ctx, act, y, h) {
|
|
|
3774
4574
|
const rect = (cls, extra = "") => `<rect class="${cls}" x="${r1(box.x)}" y="${r1(y)}" width="${r1(box.w)}" height="${h}" rx="${LOOK.box.radius}"${extra}/>`;
|
|
3775
4575
|
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>` : ""}`;
|
|
3776
4576
|
}
|
|
3777
|
-
function card(box, ctx, on, changes) {
|
|
4577
|
+
function card(box, ctx, on, changes, lit) {
|
|
3778
4578
|
const { icon, iconRadius, iconScale, iconY, nameY, subY } = LOOK.box;
|
|
3779
4579
|
const subs = subLines(box, ctx.m, changes, box.cy + subY);
|
|
3780
|
-
const act = on.length > 0 ? activeKf(ctx, on) : void 0;
|
|
4580
|
+
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;
|
|
3781
4581
|
const mark = box.icon && ICONS[box.icon] ? `<rect class="dg-ic" x="${r1(box.cx - icon / 2)}" y="${r1(box.cy + iconY - icon / 2)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, box.cx, box.cy + iconY, iconScale)}` : "";
|
|
3782
4582
|
return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${mark}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(box.cy + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
|
|
3783
4583
|
}
|
|
@@ -3787,15 +4587,54 @@ function headCard(box, ctx, on, changes) {
|
|
|
3787
4587
|
const act = on.length > 0 ? activeKf(ctx, on) : void 0;
|
|
3788
4588
|
return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, pad2, h)}<text class="dg-sn" x="${r1(box.cx)}" y="${r1(pad2 + nameY)}" text-anchor="middle">${esc(box.name)}</text>${subs}</g>`;
|
|
3789
4589
|
}
|
|
4590
|
+
function ghostCard(box) {
|
|
4591
|
+
const { icon, iconRadius, iconScale, radius } = LOOK.box;
|
|
4592
|
+
const G = LOOK.state.ghost;
|
|
4593
|
+
const ix = box.x + G.pad + icon / 2;
|
|
4594
|
+
const tx = box.x + G.pad + icon + G.gap;
|
|
4595
|
+
const mark = box.icon && ICONS[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)}` : "";
|
|
4596
|
+
const nameY = box.sub ? G.nameY : LOOK.baseline.mark;
|
|
4597
|
+
const sub = box.sub ? `<text class="dg-ss" x="${r1(tx)}" y="${r1(box.cy + G.subY)}" text-anchor="start">${esc(box.sub)}</text>` : "";
|
|
4598
|
+
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}<text class="dg-sn" x="${r1(tx)}" y="${r1(box.cy + nameY)}" text-anchor="start">${esc(box.name)}</text>${sub}</g>`;
|
|
4599
|
+
}
|
|
4600
|
+
function doneMark(box, at, ctx) {
|
|
4601
|
+
const { r, inset } = LOOK.state.done;
|
|
4602
|
+
const x = box.x + box.w - inset;
|
|
4603
|
+
const y = box.y + inset;
|
|
4604
|
+
return `<g class="dg-popc dg-a" data-done="${esc(box.id)}" style="${cs(box.color)};${ctx.m.pop(at)}"><circle class="dg-done" cx="${r1(x)}" cy="${r1(y)}" r="${r}"/>${glyph("check", x, y, 0.5, "dg-done-ck")}</g>`;
|
|
4605
|
+
}
|
|
4606
|
+
function path(p, color) {
|
|
4607
|
+
const label2 = p.label ? `<text class="dg-path-t${p.label.family === "sans" ? " dg-path-tj" : ""}" x="${r1(p.label.x + LOOK.label.padX)}" y="${r1(p.label.y + p.label.h / 2 + LOOK.baseline.label)}">${esc(p.label.text)}</text>` : "";
|
|
4608
|
+
return `<g data-path="${esc(`${p.from}->${p.to}`)}" style="${cs(color)}"><path class="dg-path" d="${pathOf(p.points)}"/><path class="dg-path-h" d="${arrowHead(p.points)}"/>${label2}</g>`;
|
|
4609
|
+
}
|
|
4610
|
+
function side(s, color) {
|
|
4611
|
+
const { pad: pad2 } = LOOK.state.side;
|
|
4612
|
+
const title = s.y + pad2 + TYPE.regionName.size;
|
|
4613
|
+
const notes = s.notes.map((note, k) => `<text class="dg-side-n" x="${r1(s.x + pad2)}" y="${r1(title + LOOK.region.line * (k + 1))}">${esc(note)}</text>`).join("");
|
|
4614
|
+
return `<g style="${cs(color)}"><rect class="dg-side" x="${r1(s.x + 0.5)}" y="${r1(s.y + 0.5)}" width="${r1(s.w - 1)}" height="${r1(s.h - 1)}" rx="${LOOK.region.radius}"/><text class="dg-side-t" x="${r1(s.x + pad2)}" y="${r1(title)}">${esc(s.title)}</text>${notes}</g>`;
|
|
4615
|
+
}
|
|
4616
|
+
function endMark(e, color) {
|
|
4617
|
+
const { end } = LOOK.state;
|
|
4618
|
+
const text2 = e.text === "" ? "" : `<text class="dg-mark" x="${r1(e.x + LOOK.state.text)}" y="${r1(e.y + LOOK.baseline.mark)}">${esc(e.text)}</text>`;
|
|
4619
|
+
const x = r1(e.x);
|
|
4620
|
+
const y = r1(e.y);
|
|
4621
|
+
if (e.kind === "start") return `<g data-end="start"><circle class="dg-start" cx="${x}" cy="${y}" r="${e.r}"/>${text2}</g>`;
|
|
4622
|
+
if (e.ghost) return `<g data-end="finish" style="${cs(color)}"><circle class="dg-end-x" cx="${x}" cy="${y}" r="${e.r}"/><circle class="dg-end-xi" cx="${x}" cy="${y}" r="${end.inner}"/>${text2}</g>`;
|
|
4623
|
+
return `<g data-end="finish"><circle class="dg-end" cx="${x}" cy="${y}" r="${e.r}"/><circle class="dg-end-in" cx="${x}" cy="${y}" r="${end.inner}"/>${text2}</g>`;
|
|
4624
|
+
}
|
|
3790
4625
|
function lifeline(x, y1, y2) {
|
|
3791
4626
|
return `<line class="dg-ll" x1="${r1(x)}" y1="${r1(y1)}" x2="${r1(x)}" y2="${r1(y2)}"/>`;
|
|
3792
4627
|
}
|
|
3793
|
-
function edge(e, time, ctx) {
|
|
4628
|
+
function edge(e, time, ctx, past = false) {
|
|
3794
4629
|
const { m } = ctx;
|
|
3795
4630
|
const d = pathOf(e.points);
|
|
3796
4631
|
const head = arrowHead(e.points);
|
|
3797
4632
|
const { start: a, drawn: b, end } = time;
|
|
3798
|
-
const tail = [
|
|
4633
|
+
const tail = past ? [
|
|
4634
|
+
[end, { opacity: 1 }, EASE.inOut],
|
|
4635
|
+
[end + 0.4, { opacity: 0 }],
|
|
4636
|
+
[m.total, { opacity: 0 }]
|
|
4637
|
+
] : [
|
|
3799
4638
|
[end, { opacity: 1 }, EASE.inOut],
|
|
3800
4639
|
[end + 0.4, { opacity: 0.45 }],
|
|
3801
4640
|
[ctx.end + 0.3, { opacity: 0.45 }, EASE.inOut],
|
|
@@ -3803,7 +4642,7 @@ function edge(e, time, ctx) {
|
|
|
3803
4642
|
[m.last, { opacity: 0.95 }, EASE.inOut],
|
|
3804
4643
|
[m.total, { opacity: 0 }]
|
|
3805
4644
|
];
|
|
3806
|
-
const
|
|
4645
|
+
const line2 = m.kf([
|
|
3807
4646
|
[0, { opacity: 0, "stroke-dashoffset": 1 }],
|
|
3808
4647
|
[a, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
|
|
3809
4648
|
[a + 0.05, { opacity: 1 }],
|
|
@@ -3822,15 +4661,19 @@ function edge(e, time, ctx) {
|
|
|
3822
4661
|
[end + 0.2, { opacity: 0, "stroke-dashoffset": run }],
|
|
3823
4662
|
[m.total, { opacity: 0, "stroke-dashoffset": run }]
|
|
3824
4663
|
]);
|
|
4664
|
+
const grey = past ? m.kf([[0, { opacity: 0 }], [end, { opacity: 0 }, EASE.inOut], [end + 0.4, { opacity: 1 }], [m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]]) : "";
|
|
3825
4665
|
return {
|
|
3826
|
-
base: `<path class="dg-e" d="${d}"/><path class="dg-eh" d="${head}"
|
|
3827
|
-
lit: `<g style="${cs(e.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${d}" style="${
|
|
4666
|
+
base: `<path class="dg-e" d="${d}"/><path class="dg-eh" d="${head}"/>${past ? `<path class="dg-e-past dg-a" d="${d}" style="${grey}"/><path class="dg-eh-past dg-a" d="${head}" style="${grey}"/>` : ""}`,
|
|
4667
|
+
lit: `<g style="${cs(e.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${d}" style="${line2}"/><path class="dg-eh-on dg-a" d="${head}" style="${hk}"/><path class="dg-flow dg-a" d="${d}" style="${flow}"/></g>`
|
|
3828
4668
|
};
|
|
3829
4669
|
}
|
|
3830
4670
|
function label(l, time, ctx) {
|
|
3831
4671
|
const ja3 = l.family === "sans" ? " dg-capj" : "";
|
|
3832
4672
|
const { radius } = LOOK.label;
|
|
3833
|
-
|
|
4673
|
+
const x = r1(l.x + l.w / 2);
|
|
4674
|
+
const y = r1(l.y + l.h / 2 + LOOK.baseline.label);
|
|
4675
|
+
const past = time.after ? `<g class="dg-cap-past${l.family === "sans" ? " dg-cap-pastj" : ""} dg-a" style="${ctx.m.vis(time.after.start, time.after.end)}"><text x="${x}" y="${y}" text-anchor="middle">${esc(l.text)}</text></g>` : "";
|
|
4676
|
+
return `${past}<g class="dg-cap${ja3} dg-a" style="${cs(l.color)};${ctx.m.rise(time.start, time.end, true)}"><rect x="${r1(l.x)}" y="${r1(l.y)}" width="${r1(l.w)}" height="${l.h}" rx="${radius}"/><text x="${x}" y="${y}" text-anchor="middle">${esc(l.text)}</text></g>`;
|
|
3834
4677
|
}
|
|
3835
4678
|
function action(a, at, until, ctx) {
|
|
3836
4679
|
return `<g class="dg-act dg-a" style="${cs(a.color)};${ctx.m.rise(at, until, true)}"><rect x="${r1(a.x)}" y="${r1(a.y)}" width="${r1(a.w)}" height="${a.h}" rx="${LOOK.action.radius}"/><text x="${r1(a.x + a.w / 2)}" y="${r1(a.y + a.h / 2 + LOOK.baseline.action)}" text-anchor="middle">${esc(a.text)}</text></g>`;
|
|
@@ -3852,21 +4695,21 @@ function carrier(e, time, ctx) {
|
|
|
3852
4695
|
const n = LOOK.carrier.samples;
|
|
3853
4696
|
const length = pathLength(e.points);
|
|
3854
4697
|
const { depart: a, arrive: b, start: from, end: gone } = time;
|
|
3855
|
-
const
|
|
4698
|
+
const path2 = [];
|
|
3856
4699
|
for (let k = 0; k <= n; k++) {
|
|
3857
4700
|
const [x, y] = along(e.points, easeInOut(k / n) * length);
|
|
3858
|
-
|
|
4701
|
+
path2.push([a + (b - a) * k / n, x, y]);
|
|
3859
4702
|
}
|
|
3860
|
-
const first =
|
|
3861
|
-
const lastPoint =
|
|
4703
|
+
const first = path2[0];
|
|
4704
|
+
const lastPoint = path2[path2.length - 1];
|
|
3862
4705
|
const rest = e.settle ?? [lastPoint[1], lastPoint[2]];
|
|
3863
|
-
const pts = [[0, first[1], first[2]], ...
|
|
4706
|
+
const pts = [[0, first[1], first[2]], ...path2];
|
|
3864
4707
|
if (e.settle) pts.push([Math.min(b + 0.3, Math.max(gone, b + 0.01)), rest[0], rest[1]]);
|
|
3865
4708
|
pts.push([gone, rest[0], rest[1]], [m.total, rest[0], rest[1]]);
|
|
3866
4709
|
const fade = gone < m.last ? 0.05 : 0.18;
|
|
3867
4710
|
return `<g class="dg-a" style="${m.move(pts, m.blink(from + 0.02, gone, fade))}">${carrierShape(e, ctx.sh)}</g>`;
|
|
3868
4711
|
}
|
|
3869
|
-
function badge(b, ctx) {
|
|
4712
|
+
function badge(b, ctx, grey = false) {
|
|
3870
4713
|
const { m } = ctx;
|
|
3871
4714
|
const span = ctx.t.steps[b.step];
|
|
3872
4715
|
const a = span.start;
|
|
@@ -3892,9 +4735,9 @@ function badge(b, ctx) {
|
|
|
3892
4735
|
const y = r1(b.y);
|
|
3893
4736
|
const ty = r1(b.y + LOOK.baseline.badge);
|
|
3894
4737
|
const no = b.step + 1;
|
|
3895
|
-
return `<g class="dg-bd" data-step="${b.step}" style="${cs(b.color)}"><circle class="dg-bdr dg-popc dg-a" cx="${x}" cy="${y}" r="${rr}" style="${ring}"/><g class="dg-a" style="${past}"><circle class="dg-bdp" cx="${x}" cy="${y}" r="${rr}"/><text class="dg-bdpt" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g><g class="dg-popc dg-a" style="${fill}"><circle class="dg-bdf" cx="${x}" cy="${y}" r="${r}"/><text class="dg-bdft" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g></g>`;
|
|
4738
|
+
return `<g class="dg-bd" data-step="${b.step}" style="${cs(b.color)}"><circle class="dg-bdr dg-popc dg-a" cx="${x}" cy="${y}" r="${rr}" style="${ring}"/><g class="dg-a" style="${past}"><circle class="${grey ? "dg-bdp-g" : "dg-bdp"}" cx="${x}" cy="${y}" r="${rr}"/><text class="${grey ? "dg-bdpt-g" : "dg-bdpt"}" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g><g class="dg-popc dg-a" style="${fill}"><circle class="dg-bdf" cx="${x}" cy="${y}" r="${r}"/><text class="dg-bdft" x="${x}" y="${ty}" text-anchor="middle">${no}</text></g></g>`;
|
|
3896
4739
|
}
|
|
3897
|
-
function strip(s, changes, ctx) {
|
|
4740
|
+
function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map()) {
|
|
3898
4741
|
const { m, sh } = ctx;
|
|
3899
4742
|
const S2 = LOOK.strip;
|
|
3900
4743
|
const my = s.y + S2.h / 2;
|
|
@@ -3916,8 +4759,18 @@ function strip(s, changes, ctx) {
|
|
|
3916
4759
|
values.forEach((c, k) => {
|
|
3917
4760
|
const next = values[k + 1]?.at;
|
|
3918
4761
|
const value2 = c.value;
|
|
3919
|
-
const
|
|
3920
|
-
|
|
4762
|
+
const cls = hasWide(value2) ? "dg-fvj" : "dg-fv";
|
|
4763
|
+
const textOf = (c2) => `<text class="${c2}" x="${r1(field2.x)}" y="${r1(field2.y + S2.valueY)}">${esc(value2)}</text>`;
|
|
4764
|
+
const text2 = textOf(cls);
|
|
4765
|
+
if (!now) {
|
|
4766
|
+
const anim = next === void 0 ? m.rise(c.at) : m.rise(c.at, next - MOTION.untilFade);
|
|
4767
|
+
parts.push(`<g class="dg-a" style="${anim}">${text2}</g>`);
|
|
4768
|
+
return;
|
|
4769
|
+
}
|
|
4770
|
+
const until = Math.min(c.until, next ?? c.until);
|
|
4771
|
+
const dot = `<circle class="dg-fl-now" cx="${r1(field2.x + textWidth(field2.name, TYPE.fieldName) + S2.now.gap)}" cy="${r1(field2.y + S2.nameY - TYPE.fieldName.size / 3)}" r="${S2.now.r}"/>`;
|
|
4772
|
+
parts.push(`<g class="dg-fv-now dg-a" data-step="${c.step}" style="${cs(c.color)};${m.rise(c.at, until - MOTION.untilFade)}">${textOf(`${cls} dg-fv-c`)}${dot}</g>`);
|
|
4773
|
+
if (next === void 0 || next > until) parts.push(`<g class="dg-a" style="${m.vis(until - MOTION.untilFade, next === void 0 ? m.last : next - MOTION.untilFade)}">${text2}</g>`);
|
|
3921
4774
|
});
|
|
3922
4775
|
tags.forEach((c, k) => {
|
|
3923
4776
|
const next = tags[k + 1]?.at;
|
|
@@ -3931,6 +4784,22 @@ function strip(s, changes, ctx) {
|
|
|
3931
4784
|
);
|
|
3932
4785
|
});
|
|
3933
4786
|
});
|
|
4787
|
+
if (s.trail) {
|
|
4788
|
+
const t = s.trail;
|
|
4789
|
+
const last = s.fields[s.fields.length - 1];
|
|
4790
|
+
if (last && last.y === t.y) {
|
|
4791
|
+
const sx = t.x - S2.fieldGap / 2;
|
|
4792
|
+
parts.push(`<line class="dg-sep" x1="${r1(sx)}" y1="${r1(t.y + S2.sepInset)}" x2="${r1(sx)}" y2="${r1(t.y + S2.h - S2.sepInset)}"/>`);
|
|
4793
|
+
}
|
|
4794
|
+
parts.push(`<text class="dg-fl" x="${r1(t.x)}" y="${r1(t.y + S2.nameY)}">${esc(t.title)}</text>`);
|
|
4795
|
+
const dy = t.y + S2.valueY - TYPE.fieldValue.size / 3;
|
|
4796
|
+
t.states.forEach((state, k) => {
|
|
4797
|
+
const cx = r1(t.x + S2.trail.r + k * S2.trail.step);
|
|
4798
|
+
const at = arrivals.get(state.box);
|
|
4799
|
+
const fill = at === void 0 ? "" : `<circle class="dg-tr-fill dg-a" cx="${cx}" cy="${r1(dy)}" r="${S2.trail.r}" style="${m.pop(at)}"/>`;
|
|
4800
|
+
parts.push(`<g data-trail="${esc(state.box)}" style="${cs(state.color)}"><circle class="dg-tr-ring" cx="${cx}" cy="${r1(dy)}" r="${S2.trail.r}"/>${fill}</g>`);
|
|
4801
|
+
});
|
|
4802
|
+
}
|
|
3934
4803
|
return parts.join("");
|
|
3935
4804
|
}
|
|
3936
4805
|
|
|
@@ -4027,6 +4896,7 @@ var font = (t) => `font:${t.weight} ${t.size}px var(--${t.family})`;
|
|
|
4027
4896
|
var mix = (pct, base = "var(--surf)") => `color-mix(in srgb,var(--c) ${pct}%,${base})`;
|
|
4028
4897
|
var S = LOOK.stroke;
|
|
4029
4898
|
var X = LOOK.mix;
|
|
4899
|
+
var PAST = `color-mix(in srgb,var(--mute) ${X.past}%,var(--bg))`;
|
|
4030
4900
|
var PART_CSS = [
|
|
4031
4901
|
".dg{display:block;width:100%;height:auto;overflow:visible}",
|
|
4032
4902
|
".dg .dg-a{animation-duration:var(--T);animation-timing-function:linear;animation-iteration-count:infinite;animation-fill-mode:both;animation-delay:calc(var(--at,0) * -1s);animation-play-state:var(--play,running)}",
|
|
@@ -4051,15 +4921,21 @@ var PART_CSS = [
|
|
|
4051
4921
|
`.dg-e-on{fill:none;stroke:var(--c);stroke-width:${S.edgeOn};stroke-linecap:round;stroke-dasharray:1 2}`,
|
|
4052
4922
|
`.dg-eh-on{fill:none;stroke:var(--c);stroke-width:${S.edgeOn};stroke-linecap:round;stroke-linejoin:round}`,
|
|
4053
4923
|
`.dg-flow{fill:none;stroke:var(--surf);stroke-width:${S.flow};stroke-linecap:round;stroke-dasharray:1.5 ${LOOK.edge.flowDash}}`,
|
|
4924
|
+
`.dg-e-past{fill:none;stroke:${PAST};stroke-width:${S.edge};stroke-linecap:round}`,
|
|
4925
|
+
`.dg-eh-past{fill:none;stroke:${PAST};stroke-width:${S.arrow};stroke-linecap:round;stroke-linejoin:round}`,
|
|
4054
4926
|
".dg-bd{cursor:pointer}",
|
|
4055
4927
|
".dg-bdf{fill:var(--c)}",
|
|
4056
4928
|
`.dg-bdft{${font(TYPE.badge)};fill:var(--on-c)}`,
|
|
4057
4929
|
`.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing}}`,
|
|
4058
4930
|
`.dg-bdp{fill:${mix(X.badgePast)};stroke:${mix(X.badgePastEdge, "transparent")};stroke-width:${S.hair}}`,
|
|
4059
4931
|
`.dg-bdpt{${font(TYPE.badge)};fill:var(--ct)}`,
|
|
4932
|
+
`.dg-bdp-g{fill:var(--surf);stroke:${PAST};stroke-width:${S.hair}}`,
|
|
4933
|
+
`.dg-bdpt-g{${font(TYPE.badge)};fill:var(--mute)}`,
|
|
4060
4934
|
`.dg-cap rect,.dg-act rect{fill:${mix(X.cap)};stroke:${mix(X.capEdge, "transparent")}}`,
|
|
4061
4935
|
`.dg-cap text{${font(TYPE.label)};fill:var(--ct)}`,
|
|
4062
4936
|
`.dg-capj text{${font(TYPE.labelJa)}}`,
|
|
4937
|
+
`.dg-cap-past text{${font(TYPE.label)};fill:var(--mute);fill-opacity:${LOOK.state.pastLabel}}`,
|
|
4938
|
+
`.dg-cap-pastj text{${font(TYPE.labelJa)}}`,
|
|
4063
4939
|
`.dg-act text{${font(TYPE.action)};fill:var(--ct)}`,
|
|
4064
4940
|
".dg-car{fill:var(--carry,var(--ink))}",
|
|
4065
4941
|
`.dg-car-t{${font(TYPE.carrier)};fill:var(--bg)}`,
|
|
@@ -4074,8 +4950,28 @@ var PART_CSS = [
|
|
|
4074
4950
|
`.dg-fl{${font(TYPE.fieldName)};fill:var(--mute)}`,
|
|
4075
4951
|
`.dg-fv{${font(TYPE.fieldValue)};fill:var(--ink)}`,
|
|
4076
4952
|
`.dg-fvj{${font(TYPE.fieldValueJa)};fill:var(--ink)}`,
|
|
4953
|
+
".dg-fv-c{fill:var(--ct)}",
|
|
4954
|
+
".dg-fl-now{fill:var(--c)}",
|
|
4955
|
+
`.dg-tr-ring{fill:none;stroke:var(--line);stroke-width:${S.trail}}`,
|
|
4956
|
+
".dg-tr-fill{fill:var(--c)}",
|
|
4077
4957
|
".dg-tg rect{fill:var(--c)}",
|
|
4078
4958
|
`.dg-tg text{${font(TYPE.tag)};fill:var(--on-c)}`,
|
|
4959
|
+
`.dg-side{fill:color-mix(in srgb,var(--c) ${X.side}%,var(--bg));stroke:${mix(X.sideEdge, "transparent")};stroke-dasharray:4 4}`,
|
|
4960
|
+
`.dg-side-t{${font(TYPE.regionName)};fill:var(--ct)}`,
|
|
4961
|
+
`.dg-side-n{${font(TYPE.regionNote)};fill:var(--mute)}`,
|
|
4962
|
+
`.dg-ghost{fill:var(--surf);stroke:${mix(X.ghostEdge, "transparent")};stroke-dasharray:4 3}`,
|
|
4963
|
+
`.dg-path{fill:none;stroke:${mix(X.path, "transparent")};stroke-width:${S.path};stroke-linecap:round;stroke-dasharray:0 ${LOOK.edge.ghostDash}}`,
|
|
4964
|
+
`.dg-path-h{fill:none;stroke:${mix(X.path, "transparent")};stroke-width:${S.arrow};stroke-linecap:round;stroke-linejoin:round}`,
|
|
4965
|
+
`.dg-path-t{${font(TYPE.label)};fill:var(--ct)}`,
|
|
4966
|
+
`.dg-path-tj{${font(TYPE.labelJa)}}`,
|
|
4967
|
+
".dg-start{fill:var(--ink)}",
|
|
4968
|
+
`.dg-end{fill:var(--bg);stroke:var(--ink);stroke-width:${S.end}}`,
|
|
4969
|
+
".dg-end-in{fill:var(--ink)}",
|
|
4970
|
+
`.dg-end-x{fill:var(--bg);stroke:${mix(X.path, "transparent")};stroke-width:${S.arrow};stroke-dasharray:2 2.5}`,
|
|
4971
|
+
`.dg-end-xi{fill:${mix(X.path, "transparent")}}`,
|
|
4972
|
+
`.dg-mark{${font(TYPE.regionNote)};fill:var(--mute)}`,
|
|
4973
|
+
`.dg-done{fill:var(--ink);stroke:var(--surf);stroke-width:${S.done}}`,
|
|
4974
|
+
`.dg-done-ck{fill:none;stroke:var(--surf);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
|
|
4079
4975
|
".dg-vp-bg{fill:var(--bg)}",
|
|
4080
4976
|
".dg-vp-frame{fill:none;stroke:var(--hair)}",
|
|
4081
4977
|
".dg-hd-bg{fill:var(--bg)}",
|
|
@@ -4153,7 +5049,8 @@ function fieldChanges(diagram, timeline, layout) {
|
|
|
4153
5049
|
if (event2?.type !== "strip") continue;
|
|
4154
5050
|
const color = layout.badges[time.step]?.color ?? "slate";
|
|
4155
5051
|
const list2 = out.get(event2.field) ?? [];
|
|
4156
|
-
|
|
5052
|
+
const until = timeline.steps[time.step].end;
|
|
5053
|
+
list2.push({ at: time.at, color, step: time.step, until, ...event2.value !== void 0 ? { value: event2.value } : {}, ...event2.tag !== void 0 ? { tag: event2.tag } : {} });
|
|
4157
5054
|
out.set(event2.field, list2);
|
|
4158
5055
|
}
|
|
4159
5056
|
return out;
|
|
@@ -4163,20 +5060,36 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
|
|
|
4163
5060
|
const m = new Motion(`dg${id}`, timeline.total, timeline.last);
|
|
4164
5061
|
const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end };
|
|
4165
5062
|
const on = involved(diagram);
|
|
4166
|
-
const subs = subChanges(diagram, timeline, layout.kind
|
|
5063
|
+
const subs = subChanges(diagram, timeline, layout.kind !== "sequence");
|
|
4167
5064
|
const L = { band: [], base: [], lit: [], node: [], badge: [], top: [] };
|
|
4168
5065
|
for (const region of layout.regions) L.band.push(band(region));
|
|
4169
|
-
|
|
4170
|
-
|
|
5066
|
+
const ghostColor = layout.boxes.find((b) => b.ghost)?.color ?? "slate";
|
|
5067
|
+
if (layout.side) L.band.push(side(layout.side, ghostColor));
|
|
5068
|
+
const boxColor = (id2, ghost) => layout.boxes.find((b) => b.id === id2 && (ghost === void 0 || b.ghost === ghost))?.color;
|
|
5069
|
+
for (const p of layout.paths) L.base.push(path(p, boxColor(p.to, true) ?? boxColor(p.from) ?? ghostColor));
|
|
5070
|
+
for (const e of layout.ends) L.node.push(endMark(e, ghostColor));
|
|
5071
|
+
const isState = layout.kind === "state";
|
|
5072
|
+
const arrivals = new Map((timeline.states ?? []).flatMap((s) => s.lit[0] ? [[s.box, s.lit[0].start]] : []));
|
|
5073
|
+
if (layout.strip) L.band.push(strip(layout.strip, fieldChanges(diagram, timeline, layout), ctx, isState, arrivals));
|
|
5074
|
+
for (const line2 of layout.lifelines) L.base.push(lifeline(line2.x, line2.y1, line2.y2));
|
|
4171
5075
|
for (const e of layout.edges) {
|
|
4172
5076
|
const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
|
|
4173
5077
|
if (!time) continue;
|
|
4174
|
-
const drawn = edge(e, time, ctx);
|
|
5078
|
+
const drawn = edge(e, time, ctx, isState);
|
|
4175
5079
|
L.base.push(drawn.base);
|
|
4176
5080
|
L.lit.push(drawn.lit);
|
|
4177
5081
|
}
|
|
4178
|
-
|
|
4179
|
-
for (const
|
|
5082
|
+
const states = new Map((timeline.states ?? []).map((s) => [s.box, s]));
|
|
5083
|
+
for (const box of layout.boxes) {
|
|
5084
|
+
if (box.ghost) {
|
|
5085
|
+
L.node.push(ghostCard(box));
|
|
5086
|
+
continue;
|
|
5087
|
+
}
|
|
5088
|
+
const state = states.get(box.id);
|
|
5089
|
+
L.node.push(card(box, ctx, on.get(box.id) ?? [], subs.get(box.id) ?? [], isState ? state?.lit ?? [] : void 0));
|
|
5090
|
+
if (state?.done !== void 0) L.node.push(doneMark(box, state.done, ctx));
|
|
5091
|
+
}
|
|
5092
|
+
for (const b of layout.badges) L.badge.push(badge(b, ctx, isState));
|
|
4180
5093
|
for (const l of layout.labels) {
|
|
4181
5094
|
const time = timeline.labels.find((t) => t.step === l.step && t.event === l.event);
|
|
4182
5095
|
if (time) L.top.push(label(l, time, ctx));
|
|
@@ -4312,7 +5225,7 @@ function renderDiagram(input, options = {}) {
|
|
|
4312
5225
|
const diagram = read.diagram;
|
|
4313
5226
|
const palette = resolvePalette(options.palette);
|
|
4314
5227
|
const theme = options.theme === "dark" ? "dark" : "light";
|
|
4315
|
-
const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : layoutArchitecture(diagram);
|
|
5228
|
+
const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : layoutArchitecture(diagram);
|
|
4316
5229
|
const timeline = buildTimeline(diagram);
|
|
4317
5230
|
return {
|
|
4318
5231
|
svg: drawSvg(diagram, layout, timeline, palette, theme),
|
|
@@ -4460,9 +5373,9 @@ function mountDiagram(host, diagram, options = {}) {
|
|
|
4460
5373
|
const head = doc.createElement("strong");
|
|
4461
5374
|
head.textContent = step2.title;
|
|
4462
5375
|
item.append(head);
|
|
4463
|
-
for (const
|
|
5376
|
+
for (const line2 of step2.body.split("\n")) {
|
|
4464
5377
|
const p = doc.createElement("p");
|
|
4465
|
-
p.textContent =
|
|
5378
|
+
p.textContent = line2;
|
|
4466
5379
|
item.append(p);
|
|
4467
5380
|
}
|
|
4468
5381
|
list2.append(item);
|
|
@@ -4597,6 +5510,6 @@ function mountDiagram(host, diagram, options = {}) {
|
|
|
4597
5510
|
};
|
|
4598
5511
|
}
|
|
4599
5512
|
|
|
4600
|
-
export { DEFAULT_PALETTE, FONTS, FORMAT_VERSION, PALETTES, READABLE_PX, chooseView, extractDiagrams, migrateFile, mountDiagram, parseNotation, printNotation, readDiagram, renderDiagram, resolvePalette, validateDiagram };
|
|
5513
|
+
export { DEFAULT_PALETTE, FONTS, FORMAT_VERSION, ICONS, PALETTES, READABLE_PX, chooseView, extractDiagrams, iconSvg, migrateFile, mountDiagram, parseNotation, printNotation, readDiagram, renderDiagram, resolvePalette, validateDiagram };
|
|
4601
5514
|
//# sourceMappingURL=index.js.map
|
|
4602
5515
|
//# sourceMappingURL=index.js.map
|