@cardenelabs/dragon 0.37.0 → 0.40.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 +38 -1
- package/dist/cli.cjs +2403 -550
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2408 -555
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +2252 -537
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +3 -1
- package/dist/export.d.ts +3 -1
- package/dist/export.js +2257 -542
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +2387 -495
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -154
- package/dist/index.d.ts +11 -154
- package/dist/index.js +2387 -496
- package/dist/index.js.map +1 -1
- package/dist/ink-B_7OXxtb.d.cts +360 -0
- package/dist/ink-B_7OXxtb.d.ts +360 -0
- package/dist/player.global.js +2 -2
- package/package.json +1 -1
- package/src/cli.ts +9 -0
- package/src/export/index.ts +4 -1
- package/src/field-messages.ts +8 -0
- package/src/figure-text.ts +28 -0
- package/src/index.ts +3 -0
- package/src/layout/architecture.ts +123 -44
- package/src/layout/git.ts +728 -0
- package/src/layout/measure.ts +10 -0
- package/src/layout/scene.ts +300 -19
- package/src/layout/sequence.ts +29 -11
- package/src/layout/state.ts +82 -62
- package/src/look/values.ts +57 -4
- package/src/messages.ts +47 -4
- package/src/parser.ts +142 -7
- package/src/player.ts +44 -0
- package/src/printer.ts +16 -4
- package/src/render/git.ts +161 -0
- package/src/render/ink.ts +104 -0
- package/src/render/parts.ts +103 -36
- package/src/render/svg.ts +63 -15
- package/src/schema.ts +47 -13
- package/src/schemas/diagram.schema.json +75 -8
- package/src/schemas/validate-diagram.js +1 -1
- package/src/timeline.ts +18 -3
- package/src/words.ts +19 -3
- package/dist/schema-B2MTRv66.d.cts +0 -133
- package/dist/schema-B2MTRv66.d.ts +0 -133
package/dist/index.js
CHANGED
|
@@ -54,6 +54,8 @@ var ja = {
|
|
|
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
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`,
|
|
57
|
+
kindOnly: (types, kind) => `${types.join(" \u3068 ")} \u306E\u51FA\u6765\u4E8B\u306F kind \u304C ${kind} \u306E\u6642\u3060\u3051\u66F8\u3051\u308B`,
|
|
58
|
+
hex: (min, max) => `0 \u304B\u3089 9 \u3068 a \u304B\u3089 f \u306E\u5B57\u3067 ${min} \u304B\u3089 ${max} \u5B57\u306B\u3059\u308B`,
|
|
57
59
|
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",
|
|
58
60
|
oneOf: "\u66F8\u3051\u308B\u5F62\u306E\u3069\u308C\u304B 1 \u3064\u3060\u3051\u306B\u5408\u308F\u305B\u308B",
|
|
59
61
|
discriminator: (tag, values) => `${tag} \u306F ${values.join(" / ")} \u306E\u3069\u308C\u304B\u306B\u3059\u308B`,
|
|
@@ -71,6 +73,8 @@ var en = {
|
|
|
71
73
|
const: (value2) => `Use ${value2}`,
|
|
72
74
|
not: (allowed) => allowed ? `The ${allowed.field} field is allowed only when kind is ${allowed.kind}` : "This combination of fields is not allowed",
|
|
73
75
|
reserved: (names) => `${names.join(" and ")} name the start and end marks of a state diagram and cannot be box ids`,
|
|
76
|
+
kindOnly: (types, kind) => `${types.join(" and ")} events are allowed only when kind is ${kind}`,
|
|
77
|
+
hex: (min, max) => `Use ${min} to ${max} characters of 0-9 and a-f`,
|
|
74
78
|
anyOf: (fields) => fields.length > 0 ? `Write one of the ${fields.join(" or ")} fields` : "Does not match any of the allowed shapes",
|
|
75
79
|
oneOf: "Match exactly one of the allowed shapes",
|
|
76
80
|
discriminator: (tag, values) => `${tag} is one of ${values.join(" / ")}`,
|
|
@@ -85,10 +89,10 @@ function ucs2length(str) {
|
|
|
85
89
|
return length;
|
|
86
90
|
}
|
|
87
91
|
var validate_diagram_default = validate10;
|
|
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", "
|
|
92
|
+
var schema11 = { "properties": { "version": { "description": "\u5F62\u5F0F\u306E\u7248", "type": "integer", "minimum": 1 }, "kind": { "description": "\u56F3\u306E\u7A2E\u985E", "enum": ["sequence", "architecture", "state", "git"] }, "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", "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" }, "git": { "$ref": "#/definitions/git" } }};
|
|
89
93
|
var func2 = Object.prototype.hasOwnProperty;
|
|
90
94
|
var func3 = ucs2length;
|
|
91
|
-
var
|
|
95
|
+
var schema28 = { "enum": ["blue", "amber", "green", "violet", "rose", "slate", "coin"] };
|
|
92
96
|
var pattern0 = new RegExp("^[^\\s\\[\\]\u300C\u300D=:]+$", "u");
|
|
93
97
|
function validate11(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
94
98
|
let vErrors = null;
|
|
@@ -192,7 +196,7 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
192
196
|
if (data.color !== void 0) {
|
|
193
197
|
let data3 = data.color;
|
|
194
198
|
if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
|
|
195
|
-
const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues:
|
|
199
|
+
const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema28.enum }, message: "must be equal to one of the allowed values" };
|
|
196
200
|
if (vErrors === null) {
|
|
197
201
|
vErrors = [err9];
|
|
198
202
|
} else {
|
|
@@ -337,7 +341,7 @@ function validate13(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
337
341
|
if (data.color !== void 0) {
|
|
338
342
|
let data3 = data.color;
|
|
339
343
|
if (!(data3 === "blue" || data3 === "amber" || data3 === "green" || data3 === "violet" || data3 === "rose" || data3 === "slate" || data3 === "coin")) {
|
|
340
|
-
const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues:
|
|
344
|
+
const err9 = { instancePath: instancePath + "/color", schemaPath: "#/definitions/color/enum", keyword: "enum", params: { allowedValues: schema28.enum }, message: "must be equal to one of the allowed values" };
|
|
341
345
|
if (vErrors === null) {
|
|
342
346
|
vErrors = [err9];
|
|
343
347
|
} else {
|
|
@@ -514,8 +518,9 @@ function validate15(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
514
518
|
validate15.errors = vErrors;
|
|
515
519
|
return errors === 0;
|
|
516
520
|
}
|
|
517
|
-
var
|
|
518
|
-
var
|
|
521
|
+
var schema44 = { "oneOf": [{ "description": "\u7DDA\u3002\u904B\u3076\u7269\u3092\u8F09\u305B\u3066\u9001\u308B\u5074\u304B\u3089\u53D7\u3051\u308B\u5074\u3078\u8D70\u308B", "type": "object", "additionalProperties": false, "required": ["type", "from", "to", "carry"], "properties": { "type": { "const": "edge" }, "from": { "$ref": "#/definitions/id" }, "to": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" }, "carry": { "$ref": "#/definitions/carry" }, "labelSide": { "description": "\u7DDA\u306E\u540D\u524D\u3092\u7F6E\u304F\u5074 (\u5BC4\u305B\u306E\u6307\u793A)", "enum": ["above", "below", "left", "right"] } } }, { "description": "\u7BB1\u306E\u4E2D\u306E\u51E6\u7406", "type": "object", "additionalProperties": false, "required": ["type", "box", "label"], "properties": { "type": { "const": "action" }, "box": { "$ref": "#/definitions/id" }, "label": { "$ref": "#/definitions/text" } } }, { "description": "\u7BB1\u306E\u4E0B\u306E\u5C0F\u3055\u306A\u5B57\u306E\u66F8\u304D\u63DB\u3048", "type": "object", "additionalProperties": false, "required": ["type", "box", "text"], "properties": { "type": { "const": "swap" }, "box": { "$ref": "#/definitions/id" }, "text": { "$ref": "#/definitions/text" } } }, { "description": "commit \u3092\u7A4D\u3080\u3002\u679D\u5206\u304B\u308C\u306E\u56F3\u3060\u3051\u304C\u66F8\u3051\u308B\u3002\u7A4D\u3093\u3060\u679D\u306E\u672D\u3068\u3001\u305D\u306E\u679D\u3092\u6307\u3059 HEAD \u304C\u9032\u3080\u3002\u5F53\u3066\u76F4\u3057 (copy) \u306F\u679D\u306E\u672D\u3092\u52D5\u304B\u3055\u305A\u3001merge commit (merge) \u306F\u53D6\u308A\u8FBC\u3080\u679D\u306E\u5148\u7AEF\u3082\u89AA\u306B\u6301\u3064", "type": "object", "additionalProperties": false, "required": ["type", "id", "branch"], "properties": { "type": { "const": "commit" }, "id": { "$ref": "#/definitions/id" }, "branch": { "$ref": "#/definitions/id" }, "copy": { "$ref": "#/definitions/id" }, "merge": { "$ref": "#/definitions/id" }, "hash": { "$ref": "#/definitions/hash" }, "note": { "$ref": "#/definitions/text" } } }, { "description": "\u679D\u3092\u5207\u308B\u3002\u679D\u5206\u304B\u308C\u306E\u56F3\u3060\u3051\u304C\u66F8\u3051\u308B\u3002\u679D\u306E\u672D\u3092 from \u306E commit \u3078\u7F6E\u304D\u3001HEAD \u3092\u305D\u306E\u679D\u3078\u79FB\u3059", "type": "object", "additionalProperties": false, "required": ["type", "branch", "from"], "properties": { "type": { "const": "branch" }, "branch": { "$ref": "#/definitions/id" }, "from": { "$ref": "#/definitions/id" } } }, { "description": "\u4E2D\u8EAB\u306E\u5E2F\u306E\u6B04\u306E\u5024\u3068\u672D", "type": "object", "additionalProperties": false, "required": ["type", "field"], "anyOf": [{ "required": ["value"] }, { "required": ["tag"] }], "properties": { "type": { "const": "strip" }, "field": { "$ref": "#/definitions/text" }, "value": { "$ref": "#/definitions/text" }, "tag": { "$ref": "#/definitions/text" } } }] };
|
|
522
|
+
var pattern11 = new RegExp("^[0-9a-f]{4,40}$", "u");
|
|
523
|
+
var schema48 = { "properties": { "kind": { "enum": ["envelope", "tag", "coin", "none"] }}};
|
|
519
524
|
function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
520
525
|
let vErrors = null;
|
|
521
526
|
let errors = 0;
|
|
@@ -642,7 +647,7 @@ function validate19(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
642
647
|
if (data.kind !== void 0) {
|
|
643
648
|
let data1 = data.kind;
|
|
644
649
|
if (!(data1 === "envelope" || data1 === "tag" || data1 === "coin" || data1 === "none")) {
|
|
645
|
-
const err8 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues:
|
|
650
|
+
const err8 = { instancePath: instancePath + "/kind", schemaPath: "#/properties/kind/enum", keyword: "enum", params: { allowedValues: schema48.properties.kind.enum }, message: "must be equal to one of the allowed values" };
|
|
646
651
|
if (vErrors === null) {
|
|
647
652
|
vErrors = [err8];
|
|
648
653
|
} else {
|
|
@@ -835,7 +840,7 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
835
840
|
if (data.labelSide !== void 0) {
|
|
836
841
|
let data5 = data.labelSide;
|
|
837
842
|
if (!(data5 === "above" || data5 === "below" || data5 === "left" || data5 === "right")) {
|
|
838
|
-
const err13 = { instancePath: instancePath + "/labelSide", schemaPath: "#/oneOf/0/properties/labelSide/enum", keyword: "enum", params: { allowedValues:
|
|
843
|
+
const err13 = { instancePath: instancePath + "/labelSide", schemaPath: "#/oneOf/0/properties/labelSide/enum", keyword: "enum", params: { allowedValues: schema44.oneOf[0].properties.labelSide.enum }, message: "must be equal to one of the allowed values" };
|
|
839
844
|
if (vErrors === null) {
|
|
840
845
|
vErrors = [err13];
|
|
841
846
|
} else {
|
|
@@ -1061,13 +1066,10 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1061
1066
|
}
|
|
1062
1067
|
errors++;
|
|
1063
1068
|
}
|
|
1064
|
-
} else if (tag0 === "
|
|
1065
|
-
const _errs39 = errors;
|
|
1066
|
-
let valid15 = false;
|
|
1067
|
-
const _errs40 = errors;
|
|
1069
|
+
} else if (tag0 === "commit") {
|
|
1068
1070
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1069
|
-
if (data.
|
|
1070
|
-
const err35 = { instancePath, schemaPath: "#/oneOf/3/
|
|
1071
|
+
if (data.type === void 0) {
|
|
1072
|
+
const err35 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
1071
1073
|
if (vErrors === null) {
|
|
1072
1074
|
vErrors = [err35];
|
|
1073
1075
|
} else {
|
|
@@ -1075,38 +1077,337 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1075
1077
|
}
|
|
1076
1078
|
errors++;
|
|
1077
1079
|
}
|
|
1080
|
+
if (data.id === void 0) {
|
|
1081
|
+
const err36 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
|
|
1082
|
+
if (vErrors === null) {
|
|
1083
|
+
vErrors = [err36];
|
|
1084
|
+
} else {
|
|
1085
|
+
vErrors.push(err36);
|
|
1086
|
+
}
|
|
1087
|
+
errors++;
|
|
1088
|
+
}
|
|
1089
|
+
if (data.branch === void 0) {
|
|
1090
|
+
const err37 = { instancePath, schemaPath: "#/oneOf/3/required", keyword: "required", params: { missingProperty: "branch" }, message: "must have required property 'branch'" };
|
|
1091
|
+
if (vErrors === null) {
|
|
1092
|
+
vErrors = [err37];
|
|
1093
|
+
} else {
|
|
1094
|
+
vErrors.push(err37);
|
|
1095
|
+
}
|
|
1096
|
+
errors++;
|
|
1097
|
+
}
|
|
1098
|
+
for (const key3 in data) {
|
|
1099
|
+
if (!(key3 === "type" || key3 === "id" || key3 === "branch" || key3 === "copy" || key3 === "merge" || key3 === "hash" || key3 === "note")) {
|
|
1100
|
+
const err38 = { instancePath, schemaPath: "#/oneOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
|
|
1101
|
+
if (vErrors === null) {
|
|
1102
|
+
vErrors = [err38];
|
|
1103
|
+
} else {
|
|
1104
|
+
vErrors.push(err38);
|
|
1105
|
+
}
|
|
1106
|
+
errors++;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
if (data.type !== void 0) {
|
|
1110
|
+
if ("commit" !== data.type) {
|
|
1111
|
+
const err39 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/3/properties/type/const", keyword: "const", params: { allowedValue: "commit" }, message: "must be equal to constant" };
|
|
1112
|
+
if (vErrors === null) {
|
|
1113
|
+
vErrors = [err39];
|
|
1114
|
+
} else {
|
|
1115
|
+
vErrors.push(err39);
|
|
1116
|
+
}
|
|
1117
|
+
errors++;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
if (data.id !== void 0) {
|
|
1121
|
+
let data13 = data.id;
|
|
1122
|
+
if (typeof data13 === "string") {
|
|
1123
|
+
if (!pattern0.test(data13)) {
|
|
1124
|
+
const err40 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1125
|
+
if (vErrors === null) {
|
|
1126
|
+
vErrors = [err40];
|
|
1127
|
+
} else {
|
|
1128
|
+
vErrors.push(err40);
|
|
1129
|
+
}
|
|
1130
|
+
errors++;
|
|
1131
|
+
}
|
|
1132
|
+
} else {
|
|
1133
|
+
const err41 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1134
|
+
if (vErrors === null) {
|
|
1135
|
+
vErrors = [err41];
|
|
1136
|
+
} else {
|
|
1137
|
+
vErrors.push(err41);
|
|
1138
|
+
}
|
|
1139
|
+
errors++;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
if (data.branch !== void 0) {
|
|
1143
|
+
let data14 = data.branch;
|
|
1144
|
+
if (typeof data14 === "string") {
|
|
1145
|
+
if (!pattern0.test(data14)) {
|
|
1146
|
+
const err42 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1147
|
+
if (vErrors === null) {
|
|
1148
|
+
vErrors = [err42];
|
|
1149
|
+
} else {
|
|
1150
|
+
vErrors.push(err42);
|
|
1151
|
+
}
|
|
1152
|
+
errors++;
|
|
1153
|
+
}
|
|
1154
|
+
} else {
|
|
1155
|
+
const err43 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1156
|
+
if (vErrors === null) {
|
|
1157
|
+
vErrors = [err43];
|
|
1158
|
+
} else {
|
|
1159
|
+
vErrors.push(err43);
|
|
1160
|
+
}
|
|
1161
|
+
errors++;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
if (data.copy !== void 0) {
|
|
1165
|
+
let data15 = data.copy;
|
|
1166
|
+
if (typeof data15 === "string") {
|
|
1167
|
+
if (!pattern0.test(data15)) {
|
|
1168
|
+
const err44 = { instancePath: instancePath + "/copy", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1169
|
+
if (vErrors === null) {
|
|
1170
|
+
vErrors = [err44];
|
|
1171
|
+
} else {
|
|
1172
|
+
vErrors.push(err44);
|
|
1173
|
+
}
|
|
1174
|
+
errors++;
|
|
1175
|
+
}
|
|
1176
|
+
} else {
|
|
1177
|
+
const err45 = { instancePath: instancePath + "/copy", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1178
|
+
if (vErrors === null) {
|
|
1179
|
+
vErrors = [err45];
|
|
1180
|
+
} else {
|
|
1181
|
+
vErrors.push(err45);
|
|
1182
|
+
}
|
|
1183
|
+
errors++;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
if (data.merge !== void 0) {
|
|
1187
|
+
let data16 = data.merge;
|
|
1188
|
+
if (typeof data16 === "string") {
|
|
1189
|
+
if (!pattern0.test(data16)) {
|
|
1190
|
+
const err46 = { instancePath: instancePath + "/merge", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1191
|
+
if (vErrors === null) {
|
|
1192
|
+
vErrors = [err46];
|
|
1193
|
+
} else {
|
|
1194
|
+
vErrors.push(err46);
|
|
1195
|
+
}
|
|
1196
|
+
errors++;
|
|
1197
|
+
}
|
|
1198
|
+
} else {
|
|
1199
|
+
const err47 = { instancePath: instancePath + "/merge", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1200
|
+
if (vErrors === null) {
|
|
1201
|
+
vErrors = [err47];
|
|
1202
|
+
} else {
|
|
1203
|
+
vErrors.push(err47);
|
|
1204
|
+
}
|
|
1205
|
+
errors++;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (data.hash !== void 0) {
|
|
1209
|
+
let data17 = data.hash;
|
|
1210
|
+
if (typeof data17 === "string") {
|
|
1211
|
+
if (!pattern11.test(data17)) {
|
|
1212
|
+
const err48 = { instancePath: instancePath + "/hash", schemaPath: "#/definitions/hash/pattern", keyword: "pattern", params: { pattern: "^[0-9a-f]{4,40}$" }, message: 'must match pattern "^[0-9a-f]{4,40}$"' };
|
|
1213
|
+
if (vErrors === null) {
|
|
1214
|
+
vErrors = [err48];
|
|
1215
|
+
} else {
|
|
1216
|
+
vErrors.push(err48);
|
|
1217
|
+
}
|
|
1218
|
+
errors++;
|
|
1219
|
+
}
|
|
1220
|
+
} else {
|
|
1221
|
+
const err49 = { instancePath: instancePath + "/hash", schemaPath: "#/definitions/hash/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1222
|
+
if (vErrors === null) {
|
|
1223
|
+
vErrors = [err49];
|
|
1224
|
+
} else {
|
|
1225
|
+
vErrors.push(err49);
|
|
1226
|
+
}
|
|
1227
|
+
errors++;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
if (data.note !== void 0) {
|
|
1231
|
+
let data18 = data.note;
|
|
1232
|
+
if (typeof data18 === "string") {
|
|
1233
|
+
if (func3(data18) < 1) {
|
|
1234
|
+
const err50 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1235
|
+
if (vErrors === null) {
|
|
1236
|
+
vErrors = [err50];
|
|
1237
|
+
} else {
|
|
1238
|
+
vErrors.push(err50);
|
|
1239
|
+
}
|
|
1240
|
+
errors++;
|
|
1241
|
+
}
|
|
1242
|
+
} else {
|
|
1243
|
+
const err51 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1244
|
+
if (vErrors === null) {
|
|
1245
|
+
vErrors = [err51];
|
|
1246
|
+
} else {
|
|
1247
|
+
vErrors.push(err51);
|
|
1248
|
+
}
|
|
1249
|
+
errors++;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
} else {
|
|
1253
|
+
const err52 = { instancePath, schemaPath: "#/oneOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1254
|
+
if (vErrors === null) {
|
|
1255
|
+
vErrors = [err52];
|
|
1256
|
+
} else {
|
|
1257
|
+
vErrors.push(err52);
|
|
1258
|
+
}
|
|
1259
|
+
errors++;
|
|
1260
|
+
}
|
|
1261
|
+
} else if (tag0 === "branch") {
|
|
1262
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1263
|
+
if (data.type === void 0) {
|
|
1264
|
+
const err53 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
1265
|
+
if (vErrors === null) {
|
|
1266
|
+
vErrors = [err53];
|
|
1267
|
+
} else {
|
|
1268
|
+
vErrors.push(err53);
|
|
1269
|
+
}
|
|
1270
|
+
errors++;
|
|
1271
|
+
}
|
|
1272
|
+
if (data.branch === void 0) {
|
|
1273
|
+
const err54 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "branch" }, message: "must have required property 'branch'" };
|
|
1274
|
+
if (vErrors === null) {
|
|
1275
|
+
vErrors = [err54];
|
|
1276
|
+
} else {
|
|
1277
|
+
vErrors.push(err54);
|
|
1278
|
+
}
|
|
1279
|
+
errors++;
|
|
1280
|
+
}
|
|
1281
|
+
if (data.from === void 0) {
|
|
1282
|
+
const err55 = { instancePath, schemaPath: "#/oneOf/4/required", keyword: "required", params: { missingProperty: "from" }, message: "must have required property 'from'" };
|
|
1283
|
+
if (vErrors === null) {
|
|
1284
|
+
vErrors = [err55];
|
|
1285
|
+
} else {
|
|
1286
|
+
vErrors.push(err55);
|
|
1287
|
+
}
|
|
1288
|
+
errors++;
|
|
1289
|
+
}
|
|
1290
|
+
for (const key4 in data) {
|
|
1291
|
+
if (!(key4 === "type" || key4 === "branch" || key4 === "from")) {
|
|
1292
|
+
const err56 = { instancePath, schemaPath: "#/oneOf/4/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key4 }, message: "must NOT have additional properties" };
|
|
1293
|
+
if (vErrors === null) {
|
|
1294
|
+
vErrors = [err56];
|
|
1295
|
+
} else {
|
|
1296
|
+
vErrors.push(err56);
|
|
1297
|
+
}
|
|
1298
|
+
errors++;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
if (data.type !== void 0) {
|
|
1302
|
+
if ("branch" !== data.type) {
|
|
1303
|
+
const err57 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/4/properties/type/const", keyword: "const", params: { allowedValue: "branch" }, message: "must be equal to constant" };
|
|
1304
|
+
if (vErrors === null) {
|
|
1305
|
+
vErrors = [err57];
|
|
1306
|
+
} else {
|
|
1307
|
+
vErrors.push(err57);
|
|
1308
|
+
}
|
|
1309
|
+
errors++;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
if (data.branch !== void 0) {
|
|
1313
|
+
let data20 = data.branch;
|
|
1314
|
+
if (typeof data20 === "string") {
|
|
1315
|
+
if (!pattern0.test(data20)) {
|
|
1316
|
+
const err58 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1317
|
+
if (vErrors === null) {
|
|
1318
|
+
vErrors = [err58];
|
|
1319
|
+
} else {
|
|
1320
|
+
vErrors.push(err58);
|
|
1321
|
+
}
|
|
1322
|
+
errors++;
|
|
1323
|
+
}
|
|
1324
|
+
} else {
|
|
1325
|
+
const err59 = { instancePath: instancePath + "/branch", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1326
|
+
if (vErrors === null) {
|
|
1327
|
+
vErrors = [err59];
|
|
1328
|
+
} else {
|
|
1329
|
+
vErrors.push(err59);
|
|
1330
|
+
}
|
|
1331
|
+
errors++;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
if (data.from !== void 0) {
|
|
1335
|
+
let data21 = data.from;
|
|
1336
|
+
if (typeof data21 === "string") {
|
|
1337
|
+
if (!pattern0.test(data21)) {
|
|
1338
|
+
const err60 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1339
|
+
if (vErrors === null) {
|
|
1340
|
+
vErrors = [err60];
|
|
1341
|
+
} else {
|
|
1342
|
+
vErrors.push(err60);
|
|
1343
|
+
}
|
|
1344
|
+
errors++;
|
|
1345
|
+
}
|
|
1346
|
+
} else {
|
|
1347
|
+
const err61 = { instancePath: instancePath + "/from", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1348
|
+
if (vErrors === null) {
|
|
1349
|
+
vErrors = [err61];
|
|
1350
|
+
} else {
|
|
1351
|
+
vErrors.push(err61);
|
|
1352
|
+
}
|
|
1353
|
+
errors++;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
} else {
|
|
1357
|
+
const err62 = { instancePath, schemaPath: "#/oneOf/4/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1358
|
+
if (vErrors === null) {
|
|
1359
|
+
vErrors = [err62];
|
|
1360
|
+
} else {
|
|
1361
|
+
vErrors.push(err62);
|
|
1362
|
+
}
|
|
1363
|
+
errors++;
|
|
1364
|
+
}
|
|
1365
|
+
} else if (tag0 === "strip") {
|
|
1366
|
+
const _errs71 = errors;
|
|
1367
|
+
let valid27 = false;
|
|
1368
|
+
const _errs72 = errors;
|
|
1369
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1370
|
+
if (data.value === void 0) {
|
|
1371
|
+
const err63 = { instancePath, schemaPath: "#/oneOf/5/anyOf/0/required", keyword: "required", params: { missingProperty: "value" }, message: "must have required property 'value'" };
|
|
1372
|
+
if (vErrors === null) {
|
|
1373
|
+
vErrors = [err63];
|
|
1374
|
+
} else {
|
|
1375
|
+
vErrors.push(err63);
|
|
1376
|
+
}
|
|
1377
|
+
errors++;
|
|
1378
|
+
}
|
|
1078
1379
|
}
|
|
1079
|
-
var _valid0 =
|
|
1080
|
-
|
|
1081
|
-
if (!
|
|
1082
|
-
const
|
|
1380
|
+
var _valid0 = _errs72 === errors;
|
|
1381
|
+
valid27 = valid27 || _valid0;
|
|
1382
|
+
if (!valid27) {
|
|
1383
|
+
const _errs73 = errors;
|
|
1083
1384
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1084
1385
|
if (data.tag === void 0) {
|
|
1085
|
-
const
|
|
1386
|
+
const err64 = { instancePath, schemaPath: "#/oneOf/5/anyOf/1/required", keyword: "required", params: { missingProperty: "tag" }, message: "must have required property 'tag'" };
|
|
1086
1387
|
if (vErrors === null) {
|
|
1087
|
-
vErrors = [
|
|
1388
|
+
vErrors = [err64];
|
|
1088
1389
|
} else {
|
|
1089
|
-
vErrors.push(
|
|
1390
|
+
vErrors.push(err64);
|
|
1090
1391
|
}
|
|
1091
1392
|
errors++;
|
|
1092
1393
|
}
|
|
1093
1394
|
}
|
|
1094
|
-
var _valid0 =
|
|
1095
|
-
|
|
1395
|
+
var _valid0 = _errs73 === errors;
|
|
1396
|
+
valid27 = valid27 || _valid0;
|
|
1096
1397
|
}
|
|
1097
|
-
if (!
|
|
1098
|
-
const
|
|
1398
|
+
if (!valid27) {
|
|
1399
|
+
const err65 = { instancePath, schemaPath: "#/oneOf/5/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
|
|
1099
1400
|
if (vErrors === null) {
|
|
1100
|
-
vErrors = [
|
|
1401
|
+
vErrors = [err65];
|
|
1101
1402
|
} else {
|
|
1102
|
-
vErrors.push(
|
|
1403
|
+
vErrors.push(err65);
|
|
1103
1404
|
}
|
|
1104
1405
|
errors++;
|
|
1105
1406
|
} else {
|
|
1106
|
-
errors =
|
|
1407
|
+
errors = _errs71;
|
|
1107
1408
|
if (vErrors !== null) {
|
|
1108
|
-
if (
|
|
1109
|
-
vErrors.length =
|
|
1409
|
+
if (_errs71) {
|
|
1410
|
+
vErrors.length = _errs71;
|
|
1110
1411
|
} else {
|
|
1111
1412
|
vErrors = null;
|
|
1112
1413
|
}
|
|
@@ -1114,144 +1415,144 @@ function validate18(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1114
1415
|
}
|
|
1115
1416
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1116
1417
|
if (data.type === void 0) {
|
|
1117
|
-
const
|
|
1418
|
+
const err66 = { instancePath, schemaPath: "#/oneOf/5/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
|
|
1118
1419
|
if (vErrors === null) {
|
|
1119
|
-
vErrors = [
|
|
1420
|
+
vErrors = [err66];
|
|
1120
1421
|
} else {
|
|
1121
|
-
vErrors.push(
|
|
1422
|
+
vErrors.push(err66);
|
|
1122
1423
|
}
|
|
1123
1424
|
errors++;
|
|
1124
1425
|
}
|
|
1125
1426
|
if (data.field === void 0) {
|
|
1126
|
-
const
|
|
1427
|
+
const err67 = { instancePath, schemaPath: "#/oneOf/5/required", keyword: "required", params: { missingProperty: "field" }, message: "must have required property 'field'" };
|
|
1127
1428
|
if (vErrors === null) {
|
|
1128
|
-
vErrors = [
|
|
1429
|
+
vErrors = [err67];
|
|
1129
1430
|
} else {
|
|
1130
|
-
vErrors.push(
|
|
1431
|
+
vErrors.push(err67);
|
|
1131
1432
|
}
|
|
1132
1433
|
errors++;
|
|
1133
1434
|
}
|
|
1134
|
-
for (const
|
|
1135
|
-
if (!(
|
|
1136
|
-
const
|
|
1435
|
+
for (const key5 in data) {
|
|
1436
|
+
if (!(key5 === "type" || key5 === "field" || key5 === "value" || key5 === "tag")) {
|
|
1437
|
+
const err68 = { instancePath, schemaPath: "#/oneOf/5/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key5 }, message: "must NOT have additional properties" };
|
|
1137
1438
|
if (vErrors === null) {
|
|
1138
|
-
vErrors = [
|
|
1439
|
+
vErrors = [err68];
|
|
1139
1440
|
} else {
|
|
1140
|
-
vErrors.push(
|
|
1441
|
+
vErrors.push(err68);
|
|
1141
1442
|
}
|
|
1142
1443
|
errors++;
|
|
1143
1444
|
}
|
|
1144
1445
|
}
|
|
1145
1446
|
if (data.type !== void 0) {
|
|
1146
1447
|
if ("strip" !== data.type) {
|
|
1147
|
-
const
|
|
1448
|
+
const err69 = { instancePath: instancePath + "/type", schemaPath: "#/oneOf/5/properties/type/const", keyword: "const", params: { allowedValue: "strip" }, message: "must be equal to constant" };
|
|
1148
1449
|
if (vErrors === null) {
|
|
1149
|
-
vErrors = [
|
|
1450
|
+
vErrors = [err69];
|
|
1150
1451
|
} else {
|
|
1151
|
-
vErrors.push(
|
|
1452
|
+
vErrors.push(err69);
|
|
1152
1453
|
}
|
|
1153
1454
|
errors++;
|
|
1154
1455
|
}
|
|
1155
1456
|
}
|
|
1156
1457
|
if (data.field !== void 0) {
|
|
1157
|
-
let
|
|
1158
|
-
if (typeof
|
|
1159
|
-
if (func3(
|
|
1160
|
-
const
|
|
1458
|
+
let data23 = data.field;
|
|
1459
|
+
if (typeof data23 === "string") {
|
|
1460
|
+
if (func3(data23) < 1) {
|
|
1461
|
+
const err70 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1161
1462
|
if (vErrors === null) {
|
|
1162
|
-
vErrors = [
|
|
1463
|
+
vErrors = [err70];
|
|
1163
1464
|
} else {
|
|
1164
|
-
vErrors.push(
|
|
1465
|
+
vErrors.push(err70);
|
|
1165
1466
|
}
|
|
1166
1467
|
errors++;
|
|
1167
1468
|
}
|
|
1168
1469
|
} else {
|
|
1169
|
-
const
|
|
1470
|
+
const err71 = { instancePath: instancePath + "/field", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1170
1471
|
if (vErrors === null) {
|
|
1171
|
-
vErrors = [
|
|
1472
|
+
vErrors = [err71];
|
|
1172
1473
|
} else {
|
|
1173
|
-
vErrors.push(
|
|
1474
|
+
vErrors.push(err71);
|
|
1174
1475
|
}
|
|
1175
1476
|
errors++;
|
|
1176
1477
|
}
|
|
1177
1478
|
}
|
|
1178
1479
|
if (data.value !== void 0) {
|
|
1179
|
-
let
|
|
1180
|
-
if (typeof
|
|
1181
|
-
if (func3(
|
|
1182
|
-
const
|
|
1480
|
+
let data24 = data.value;
|
|
1481
|
+
if (typeof data24 === "string") {
|
|
1482
|
+
if (func3(data24) < 1) {
|
|
1483
|
+
const err72 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1183
1484
|
if (vErrors === null) {
|
|
1184
|
-
vErrors = [
|
|
1485
|
+
vErrors = [err72];
|
|
1185
1486
|
} else {
|
|
1186
|
-
vErrors.push(
|
|
1487
|
+
vErrors.push(err72);
|
|
1187
1488
|
}
|
|
1188
1489
|
errors++;
|
|
1189
1490
|
}
|
|
1190
1491
|
} else {
|
|
1191
|
-
const
|
|
1492
|
+
const err73 = { instancePath: instancePath + "/value", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1192
1493
|
if (vErrors === null) {
|
|
1193
|
-
vErrors = [
|
|
1494
|
+
vErrors = [err73];
|
|
1194
1495
|
} else {
|
|
1195
|
-
vErrors.push(
|
|
1496
|
+
vErrors.push(err73);
|
|
1196
1497
|
}
|
|
1197
1498
|
errors++;
|
|
1198
1499
|
}
|
|
1199
1500
|
}
|
|
1200
1501
|
if (data.tag !== void 0) {
|
|
1201
|
-
let
|
|
1202
|
-
if (typeof
|
|
1203
|
-
if (func3(
|
|
1204
|
-
const
|
|
1502
|
+
let data25 = data.tag;
|
|
1503
|
+
if (typeof data25 === "string") {
|
|
1504
|
+
if (func3(data25) < 1) {
|
|
1505
|
+
const err74 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
1205
1506
|
if (vErrors === null) {
|
|
1206
|
-
vErrors = [
|
|
1507
|
+
vErrors = [err74];
|
|
1207
1508
|
} else {
|
|
1208
|
-
vErrors.push(
|
|
1509
|
+
vErrors.push(err74);
|
|
1209
1510
|
}
|
|
1210
1511
|
errors++;
|
|
1211
1512
|
}
|
|
1212
1513
|
} else {
|
|
1213
|
-
const
|
|
1514
|
+
const err75 = { instancePath: instancePath + "/tag", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1214
1515
|
if (vErrors === null) {
|
|
1215
|
-
vErrors = [
|
|
1516
|
+
vErrors = [err75];
|
|
1216
1517
|
} else {
|
|
1217
|
-
vErrors.push(
|
|
1518
|
+
vErrors.push(err75);
|
|
1218
1519
|
}
|
|
1219
1520
|
errors++;
|
|
1220
1521
|
}
|
|
1221
1522
|
}
|
|
1222
1523
|
} else {
|
|
1223
|
-
const
|
|
1524
|
+
const err76 = { instancePath, schemaPath: "#/oneOf/5/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1224
1525
|
if (vErrors === null) {
|
|
1225
|
-
vErrors = [
|
|
1526
|
+
vErrors = [err76];
|
|
1226
1527
|
} else {
|
|
1227
|
-
vErrors.push(
|
|
1528
|
+
vErrors.push(err76);
|
|
1228
1529
|
}
|
|
1229
1530
|
errors++;
|
|
1230
1531
|
}
|
|
1231
1532
|
} else {
|
|
1232
|
-
const
|
|
1533
|
+
const err77 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "mapping", tag: "type", tagValue: tag0 }, message: 'value of tag "type" must be in oneOf' };
|
|
1233
1534
|
if (vErrors === null) {
|
|
1234
|
-
vErrors = [
|
|
1535
|
+
vErrors = [err77];
|
|
1235
1536
|
} else {
|
|
1236
|
-
vErrors.push(
|
|
1537
|
+
vErrors.push(err77);
|
|
1237
1538
|
}
|
|
1238
1539
|
errors++;
|
|
1239
1540
|
}
|
|
1240
1541
|
} else {
|
|
1241
|
-
const
|
|
1542
|
+
const err78 = { instancePath, schemaPath: "#/discriminator", keyword: "discriminator", params: { error: "tag", tag: "type", tagValue: tag0 }, message: 'tag "type" must be string' };
|
|
1242
1543
|
if (vErrors === null) {
|
|
1243
|
-
vErrors = [
|
|
1544
|
+
vErrors = [err78];
|
|
1244
1545
|
} else {
|
|
1245
|
-
vErrors.push(
|
|
1546
|
+
vErrors.push(err78);
|
|
1246
1547
|
}
|
|
1247
1548
|
errors++;
|
|
1248
1549
|
}
|
|
1249
1550
|
} else {
|
|
1250
|
-
const
|
|
1551
|
+
const err79 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
1251
1552
|
if (vErrors === null) {
|
|
1252
|
-
vErrors = [
|
|
1553
|
+
vErrors = [err79];
|
|
1253
1554
|
} else {
|
|
1254
|
-
vErrors.push(
|
|
1555
|
+
vErrors.push(err79);
|
|
1255
1556
|
}
|
|
1256
1557
|
errors++;
|
|
1257
1558
|
}
|
|
@@ -1655,6 +1956,151 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1655
1956
|
validate25.errors = vErrors;
|
|
1656
1957
|
return errors === 0;
|
|
1657
1958
|
}
|
|
1959
|
+
function validate30(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1960
|
+
let vErrors = null;
|
|
1961
|
+
let errors = 0;
|
|
1962
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1963
|
+
if (data.id === void 0) {
|
|
1964
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "id" }, message: "must have required property 'id'" };
|
|
1965
|
+
if (vErrors === null) {
|
|
1966
|
+
vErrors = [err0];
|
|
1967
|
+
} else {
|
|
1968
|
+
vErrors.push(err0);
|
|
1969
|
+
}
|
|
1970
|
+
errors++;
|
|
1971
|
+
}
|
|
1972
|
+
for (const key0 in data) {
|
|
1973
|
+
if (!(key0 === "id" || key0 === "note")) {
|
|
1974
|
+
const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1975
|
+
if (vErrors === null) {
|
|
1976
|
+
vErrors = [err1];
|
|
1977
|
+
} else {
|
|
1978
|
+
vErrors.push(err1);
|
|
1979
|
+
}
|
|
1980
|
+
errors++;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
if (data.id !== void 0) {
|
|
1984
|
+
let data0 = data.id;
|
|
1985
|
+
if (typeof data0 === "string") {
|
|
1986
|
+
if (!pattern0.test(data0)) {
|
|
1987
|
+
const err2 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/pattern", keyword: "pattern", params: { pattern: "^[^\\s\\[\\]\u300C\u300D=:]+$" }, message: 'must match pattern "^[^\\s\\[\\]\u300C\u300D=:]+$"' };
|
|
1988
|
+
if (vErrors === null) {
|
|
1989
|
+
vErrors = [err2];
|
|
1990
|
+
} else {
|
|
1991
|
+
vErrors.push(err2);
|
|
1992
|
+
}
|
|
1993
|
+
errors++;
|
|
1994
|
+
}
|
|
1995
|
+
} else {
|
|
1996
|
+
const err3 = { instancePath: instancePath + "/id", schemaPath: "#/definitions/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
1997
|
+
if (vErrors === null) {
|
|
1998
|
+
vErrors = [err3];
|
|
1999
|
+
} else {
|
|
2000
|
+
vErrors.push(err3);
|
|
2001
|
+
}
|
|
2002
|
+
errors++;
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
if (data.note !== void 0) {
|
|
2006
|
+
let data1 = data.note;
|
|
2007
|
+
if (typeof data1 === "string") {
|
|
2008
|
+
if (func3(data1) < 1) {
|
|
2009
|
+
const err4 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2010
|
+
if (vErrors === null) {
|
|
2011
|
+
vErrors = [err4];
|
|
2012
|
+
} else {
|
|
2013
|
+
vErrors.push(err4);
|
|
2014
|
+
}
|
|
2015
|
+
errors++;
|
|
2016
|
+
}
|
|
2017
|
+
} else {
|
|
2018
|
+
const err5 = { instancePath: instancePath + "/note", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2019
|
+
if (vErrors === null) {
|
|
2020
|
+
vErrors = [err5];
|
|
2021
|
+
} else {
|
|
2022
|
+
vErrors.push(err5);
|
|
2023
|
+
}
|
|
2024
|
+
errors++;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
} else {
|
|
2028
|
+
const err6 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2029
|
+
if (vErrors === null) {
|
|
2030
|
+
vErrors = [err6];
|
|
2031
|
+
} else {
|
|
2032
|
+
vErrors.push(err6);
|
|
2033
|
+
}
|
|
2034
|
+
errors++;
|
|
2035
|
+
}
|
|
2036
|
+
validate30.errors = vErrors;
|
|
2037
|
+
return errors === 0;
|
|
2038
|
+
}
|
|
2039
|
+
function validate29(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
2040
|
+
let vErrors = null;
|
|
2041
|
+
let errors = 0;
|
|
2042
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2043
|
+
if (data.branches === void 0) {
|
|
2044
|
+
const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "branches" }, message: "must have required property 'branches'" };
|
|
2045
|
+
if (vErrors === null) {
|
|
2046
|
+
vErrors = [err0];
|
|
2047
|
+
} else {
|
|
2048
|
+
vErrors.push(err0);
|
|
2049
|
+
}
|
|
2050
|
+
errors++;
|
|
2051
|
+
}
|
|
2052
|
+
for (const key0 in data) {
|
|
2053
|
+
if (!(key0 === "branches")) {
|
|
2054
|
+
const err1 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
2055
|
+
if (vErrors === null) {
|
|
2056
|
+
vErrors = [err1];
|
|
2057
|
+
} else {
|
|
2058
|
+
vErrors.push(err1);
|
|
2059
|
+
}
|
|
2060
|
+
errors++;
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
if (data.branches !== void 0) {
|
|
2064
|
+
let data0 = data.branches;
|
|
2065
|
+
if (Array.isArray(data0)) {
|
|
2066
|
+
if (data0.length < 1) {
|
|
2067
|
+
const err2 = { instancePath: instancePath + "/branches", schemaPath: "#/properties/branches/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2068
|
+
if (vErrors === null) {
|
|
2069
|
+
vErrors = [err2];
|
|
2070
|
+
} else {
|
|
2071
|
+
vErrors.push(err2);
|
|
2072
|
+
}
|
|
2073
|
+
errors++;
|
|
2074
|
+
}
|
|
2075
|
+
const len0 = data0.length;
|
|
2076
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
2077
|
+
if (!validate30(data0[i0], { instancePath: instancePath + "/branches/" + i0, parentData: data0, parentDataProperty: i0, rootData })) {
|
|
2078
|
+
vErrors = vErrors === null ? validate30.errors : vErrors.concat(validate30.errors);
|
|
2079
|
+
errors = vErrors.length;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
} else {
|
|
2083
|
+
const err3 = { instancePath: instancePath + "/branches", schemaPath: "#/properties/branches/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2084
|
+
if (vErrors === null) {
|
|
2085
|
+
vErrors = [err3];
|
|
2086
|
+
} else {
|
|
2087
|
+
vErrors.push(err3);
|
|
2088
|
+
}
|
|
2089
|
+
errors++;
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
} else {
|
|
2093
|
+
const err4 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2094
|
+
if (vErrors === null) {
|
|
2095
|
+
vErrors = [err4];
|
|
2096
|
+
} else {
|
|
2097
|
+
vErrors.push(err4);
|
|
2098
|
+
}
|
|
2099
|
+
errors++;
|
|
2100
|
+
}
|
|
2101
|
+
validate29.errors = vErrors;
|
|
2102
|
+
return errors === 0;
|
|
2103
|
+
}
|
|
1658
2104
|
function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
|
|
1659
2105
|
let vErrors = null;
|
|
1660
2106
|
let errors = 0;
|
|
@@ -1696,11 +2142,9 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1696
2142
|
let ifClause0;
|
|
1697
2143
|
if (_valid0) {
|
|
1698
2144
|
const _errs4 = errors;
|
|
1699
|
-
const _errs5 = errors;
|
|
1700
|
-
const _errs6 = errors;
|
|
1701
2145
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1702
|
-
if (data.
|
|
1703
|
-
const err2 = {};
|
|
2146
|
+
if (data.sequence === void 0) {
|
|
2147
|
+
const err2 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
|
|
1704
2148
|
if (vErrors === null) {
|
|
1705
2149
|
vErrors = [err2];
|
|
1706
2150
|
} else {
|
|
@@ -1708,147 +2152,181 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1708
2152
|
}
|
|
1709
2153
|
errors++;
|
|
1710
2154
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
2155
|
+
if (data.boxes !== void 0) {
|
|
2156
|
+
let data1 = data.boxes;
|
|
2157
|
+
if (Array.isArray(data1)) {
|
|
2158
|
+
if (data1.length < 1) {
|
|
2159
|
+
const err3 = { instancePath: instancePath + "/boxes", schemaPath: "#/then/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2160
|
+
if (vErrors === null) {
|
|
2161
|
+
vErrors = [err3];
|
|
2162
|
+
} else {
|
|
2163
|
+
vErrors.push(err3);
|
|
2164
|
+
}
|
|
2165
|
+
errors++;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
1719
2168
|
}
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
2169
|
+
if (data.steps !== void 0) {
|
|
2170
|
+
let data2 = data.steps;
|
|
2171
|
+
if (Array.isArray(data2)) {
|
|
2172
|
+
const len0 = data2.length;
|
|
2173
|
+
for (let i0 = 0; i0 < len0; i0++) {
|
|
2174
|
+
let data3 = data2[i0];
|
|
2175
|
+
if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
|
|
2176
|
+
if (data3.events !== void 0) {
|
|
2177
|
+
let data4 = data3.events;
|
|
2178
|
+
if (Array.isArray(data4)) {
|
|
2179
|
+
const len1 = data4.length;
|
|
2180
|
+
for (let i1 = 0; i1 < len1; i1++) {
|
|
2181
|
+
let data5 = data4[i1];
|
|
2182
|
+
if (data5 && typeof data5 == "object" && !Array.isArray(data5)) {
|
|
2183
|
+
if (data5.type !== void 0) {
|
|
2184
|
+
let data6 = data5.type;
|
|
2185
|
+
const _errs12 = errors;
|
|
2186
|
+
const _errs13 = errors;
|
|
2187
|
+
if (!(data6 === "commit" || data6 === "branch")) {
|
|
2188
|
+
const err4 = {};
|
|
2189
|
+
if (vErrors === null) {
|
|
2190
|
+
vErrors = [err4];
|
|
2191
|
+
} else {
|
|
2192
|
+
vErrors.push(err4);
|
|
2193
|
+
}
|
|
2194
|
+
errors++;
|
|
2195
|
+
}
|
|
2196
|
+
var valid10 = _errs13 === errors;
|
|
2197
|
+
if (valid10) {
|
|
2198
|
+
const err5 = { instancePath: instancePath + "/steps/" + i0 + "/events/" + i1 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2199
|
+
if (vErrors === null) {
|
|
2200
|
+
vErrors = [err5];
|
|
2201
|
+
} else {
|
|
2202
|
+
vErrors.push(err5);
|
|
2203
|
+
}
|
|
2204
|
+
errors++;
|
|
2205
|
+
} else {
|
|
2206
|
+
errors = _errs12;
|
|
2207
|
+
if (vErrors !== null) {
|
|
2208
|
+
if (_errs12) {
|
|
2209
|
+
vErrors.length = _errs12;
|
|
2210
|
+
} else {
|
|
2211
|
+
vErrors = null;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
1728
2222
|
}
|
|
1729
2223
|
}
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
if (data.sequence === void 0) {
|
|
1733
|
-
const err4 = { instancePath, schemaPath: "#/then/required", keyword: "required", params: { missingProperty: "sequence" }, message: "must have required property 'sequence'" };
|
|
2224
|
+
if (data.state !== void 0) {
|
|
2225
|
+
const err6 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
1734
2226
|
if (vErrors === null) {
|
|
1735
|
-
vErrors = [
|
|
2227
|
+
vErrors = [err6];
|
|
1736
2228
|
} else {
|
|
1737
|
-
vErrors.push(
|
|
2229
|
+
vErrors.push(err6);
|
|
1738
2230
|
}
|
|
1739
2231
|
errors++;
|
|
1740
2232
|
}
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
valid0 = _valid0;
|
|
1744
|
-
ifClause0 = "then";
|
|
1745
|
-
} else {
|
|
1746
|
-
const _errs7 = errors;
|
|
1747
|
-
const _errs8 = errors;
|
|
1748
|
-
const _errs9 = errors;
|
|
1749
|
-
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1750
|
-
if (data.sequence === void 0 && ("sequence")) {
|
|
1751
|
-
const err5 = {};
|
|
2233
|
+
if (data.git !== void 0) {
|
|
2234
|
+
const err7 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
1752
2235
|
if (vErrors === null) {
|
|
1753
|
-
vErrors = [
|
|
2236
|
+
vErrors = [err7];
|
|
1754
2237
|
} else {
|
|
1755
|
-
vErrors.push(
|
|
2238
|
+
vErrors.push(err7);
|
|
1756
2239
|
}
|
|
1757
2240
|
errors++;
|
|
1758
2241
|
}
|
|
1759
2242
|
}
|
|
1760
|
-
var
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
errors++;
|
|
1769
|
-
} else {
|
|
1770
|
-
errors = _errs8;
|
|
1771
|
-
if (vErrors !== null) {
|
|
1772
|
-
if (_errs8) {
|
|
1773
|
-
vErrors.length = _errs8;
|
|
1774
|
-
} else {
|
|
1775
|
-
vErrors = null;
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
const _errs10 = errors;
|
|
1780
|
-
let valid4 = true;
|
|
1781
|
-
const _errs11 = errors;
|
|
2243
|
+
var _valid0 = _errs4 === errors;
|
|
2244
|
+
valid0 = _valid0;
|
|
2245
|
+
ifClause0 = "then";
|
|
2246
|
+
} else {
|
|
2247
|
+
const _errs20 = errors;
|
|
2248
|
+
const _errs21 = errors;
|
|
2249
|
+
let valid13 = true;
|
|
2250
|
+
const _errs22 = errors;
|
|
1782
2251
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1783
2252
|
if (data.kind === void 0 && ("kind")) {
|
|
1784
|
-
const
|
|
2253
|
+
const err8 = {};
|
|
1785
2254
|
if (vErrors === null) {
|
|
1786
|
-
vErrors = [
|
|
2255
|
+
vErrors = [err8];
|
|
1787
2256
|
} else {
|
|
1788
|
-
vErrors.push(
|
|
2257
|
+
vErrors.push(err8);
|
|
1789
2258
|
}
|
|
1790
2259
|
errors++;
|
|
1791
2260
|
} else {
|
|
1792
2261
|
if (data.kind !== void 0) {
|
|
1793
2262
|
if ("state" !== data.kind) {
|
|
1794
|
-
const
|
|
2263
|
+
const err9 = {};
|
|
1795
2264
|
if (vErrors === null) {
|
|
1796
|
-
vErrors = [
|
|
2265
|
+
vErrors = [err9];
|
|
1797
2266
|
} else {
|
|
1798
|
-
vErrors.push(
|
|
2267
|
+
vErrors.push(err9);
|
|
1799
2268
|
}
|
|
1800
2269
|
errors++;
|
|
1801
2270
|
}
|
|
1802
2271
|
}
|
|
1803
2272
|
}
|
|
1804
2273
|
}
|
|
1805
|
-
var _valid1 =
|
|
1806
|
-
errors =
|
|
2274
|
+
var _valid1 = _errs22 === errors;
|
|
2275
|
+
errors = _errs21;
|
|
1807
2276
|
if (vErrors !== null) {
|
|
1808
|
-
if (
|
|
1809
|
-
vErrors.length =
|
|
2277
|
+
if (_errs21) {
|
|
2278
|
+
vErrors.length = _errs21;
|
|
1810
2279
|
} else {
|
|
1811
2280
|
vErrors = null;
|
|
1812
2281
|
}
|
|
1813
2282
|
}
|
|
1814
2283
|
let ifClause1;
|
|
1815
2284
|
if (_valid1) {
|
|
1816
|
-
const
|
|
2285
|
+
const _errs24 = errors;
|
|
1817
2286
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1818
2287
|
if (data.boxes !== void 0) {
|
|
1819
|
-
let
|
|
1820
|
-
if (Array.isArray(
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
2288
|
+
let data10 = data.boxes;
|
|
2289
|
+
if (Array.isArray(data10)) {
|
|
2290
|
+
if (data10.length < 1) {
|
|
2291
|
+
const err10 = { instancePath: instancePath + "/boxes", schemaPath: "#/else/then/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2292
|
+
if (vErrors === null) {
|
|
2293
|
+
vErrors = [err10];
|
|
2294
|
+
} else {
|
|
2295
|
+
vErrors.push(err10);
|
|
2296
|
+
}
|
|
2297
|
+
errors++;
|
|
2298
|
+
}
|
|
2299
|
+
const len2 = data10.length;
|
|
2300
|
+
for (let i2 = 0; i2 < len2; i2++) {
|
|
2301
|
+
let data11 = data10[i2];
|
|
2302
|
+
if (data11 && typeof data11 == "object" && !Array.isArray(data11)) {
|
|
2303
|
+
if (data11.id !== void 0) {
|
|
2304
|
+
let data12 = data11.id;
|
|
2305
|
+
const _errs28 = errors;
|
|
2306
|
+
const _errs29 = errors;
|
|
2307
|
+
if (!(data12 === "start" || data12 === "finish")) {
|
|
2308
|
+
const err11 = {};
|
|
1831
2309
|
if (vErrors === null) {
|
|
1832
|
-
vErrors = [
|
|
2310
|
+
vErrors = [err11];
|
|
1833
2311
|
} else {
|
|
1834
|
-
vErrors.push(
|
|
2312
|
+
vErrors.push(err11);
|
|
1835
2313
|
}
|
|
1836
2314
|
errors++;
|
|
1837
2315
|
}
|
|
1838
|
-
var
|
|
1839
|
-
if (
|
|
1840
|
-
const
|
|
2316
|
+
var valid19 = _errs29 === errors;
|
|
2317
|
+
if (valid19) {
|
|
2318
|
+
const err12 = { instancePath: instancePath + "/boxes/" + i2 + "/id", schemaPath: "#/else/then/properties/boxes/items/properties/id/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
1841
2319
|
if (vErrors === null) {
|
|
1842
|
-
vErrors = [
|
|
2320
|
+
vErrors = [err12];
|
|
1843
2321
|
} else {
|
|
1844
|
-
vErrors.push(
|
|
2322
|
+
vErrors.push(err12);
|
|
1845
2323
|
}
|
|
1846
2324
|
errors++;
|
|
1847
2325
|
} else {
|
|
1848
|
-
errors =
|
|
2326
|
+
errors = _errs28;
|
|
1849
2327
|
if (vErrors !== null) {
|
|
1850
|
-
if (
|
|
1851
|
-
vErrors.length =
|
|
2328
|
+
if (_errs28) {
|
|
2329
|
+
vErrors.length = _errs28;
|
|
1852
2330
|
} else {
|
|
1853
2331
|
vErrors = null;
|
|
1854
2332
|
}
|
|
@@ -1859,241 +2337,449 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
1859
2337
|
}
|
|
1860
2338
|
}
|
|
1861
2339
|
}
|
|
2340
|
+
if (data.steps !== void 0) {
|
|
2341
|
+
let data13 = data.steps;
|
|
2342
|
+
if (Array.isArray(data13)) {
|
|
2343
|
+
const len3 = data13.length;
|
|
2344
|
+
for (let i3 = 0; i3 < len3; i3++) {
|
|
2345
|
+
let data14 = data13[i3];
|
|
2346
|
+
if (data14 && typeof data14 == "object" && !Array.isArray(data14)) {
|
|
2347
|
+
if (data14.events !== void 0) {
|
|
2348
|
+
let data15 = data14.events;
|
|
2349
|
+
if (Array.isArray(data15)) {
|
|
2350
|
+
const len4 = data15.length;
|
|
2351
|
+
for (let i4 = 0; i4 < len4; i4++) {
|
|
2352
|
+
let data16 = data15[i4];
|
|
2353
|
+
if (data16 && typeof data16 == "object" && !Array.isArray(data16)) {
|
|
2354
|
+
if (data16.type !== void 0) {
|
|
2355
|
+
let data17 = data16.type;
|
|
2356
|
+
const _errs36 = errors;
|
|
2357
|
+
const _errs37 = errors;
|
|
2358
|
+
if (!(data17 === "commit" || data17 === "branch")) {
|
|
2359
|
+
const err13 = {};
|
|
2360
|
+
if (vErrors === null) {
|
|
2361
|
+
vErrors = [err13];
|
|
2362
|
+
} else {
|
|
2363
|
+
vErrors.push(err13);
|
|
2364
|
+
}
|
|
2365
|
+
errors++;
|
|
2366
|
+
}
|
|
2367
|
+
var valid27 = _errs37 === errors;
|
|
2368
|
+
if (valid27) {
|
|
2369
|
+
const err14 = { instancePath: instancePath + "/steps/" + i3 + "/events/" + i4 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2370
|
+
if (vErrors === null) {
|
|
2371
|
+
vErrors = [err14];
|
|
2372
|
+
} else {
|
|
2373
|
+
vErrors.push(err14);
|
|
2374
|
+
}
|
|
2375
|
+
errors++;
|
|
2376
|
+
} else {
|
|
2377
|
+
errors = _errs36;
|
|
2378
|
+
if (vErrors !== null) {
|
|
2379
|
+
if (_errs36) {
|
|
2380
|
+
vErrors.length = _errs36;
|
|
2381
|
+
} else {
|
|
2382
|
+
vErrors = null;
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
if (data.git !== void 0) {
|
|
2396
|
+
const err15 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2397
|
+
if (vErrors === null) {
|
|
2398
|
+
vErrors = [err15];
|
|
2399
|
+
} else {
|
|
2400
|
+
vErrors.push(err15);
|
|
2401
|
+
}
|
|
2402
|
+
errors++;
|
|
2403
|
+
}
|
|
1862
2404
|
}
|
|
1863
|
-
var _valid1 =
|
|
1864
|
-
|
|
2405
|
+
var _valid1 = _errs24 === errors;
|
|
2406
|
+
valid13 = _valid1;
|
|
1865
2407
|
ifClause1 = "then";
|
|
1866
2408
|
} else {
|
|
1867
|
-
const
|
|
1868
|
-
const
|
|
1869
|
-
|
|
2409
|
+
const _errs41 = errors;
|
|
2410
|
+
const _errs42 = errors;
|
|
2411
|
+
let valid29 = true;
|
|
2412
|
+
const _errs43 = errors;
|
|
1870
2413
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1871
|
-
if (data.
|
|
1872
|
-
const
|
|
2414
|
+
if (data.kind === void 0 && ("kind")) {
|
|
2415
|
+
const err16 = {};
|
|
1873
2416
|
if (vErrors === null) {
|
|
1874
|
-
vErrors = [
|
|
2417
|
+
vErrors = [err16];
|
|
1875
2418
|
} else {
|
|
1876
|
-
vErrors.push(
|
|
2419
|
+
vErrors.push(err16);
|
|
1877
2420
|
}
|
|
1878
2421
|
errors++;
|
|
2422
|
+
} else {
|
|
2423
|
+
if (data.kind !== void 0) {
|
|
2424
|
+
if ("git" !== data.kind) {
|
|
2425
|
+
const err17 = {};
|
|
2426
|
+
if (vErrors === null) {
|
|
2427
|
+
vErrors = [err17];
|
|
2428
|
+
} else {
|
|
2429
|
+
vErrors.push(err17);
|
|
2430
|
+
}
|
|
2431
|
+
errors++;
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
1879
2434
|
}
|
|
1880
2435
|
}
|
|
1881
|
-
var
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
if (
|
|
1885
|
-
vErrors =
|
|
2436
|
+
var _valid2 = _errs43 === errors;
|
|
2437
|
+
errors = _errs42;
|
|
2438
|
+
if (vErrors !== null) {
|
|
2439
|
+
if (_errs42) {
|
|
2440
|
+
vErrors.length = _errs42;
|
|
1886
2441
|
} else {
|
|
1887
|
-
vErrors
|
|
2442
|
+
vErrors = null;
|
|
1888
2443
|
}
|
|
1889
|
-
|
|
2444
|
+
}
|
|
2445
|
+
let ifClause2;
|
|
2446
|
+
if (_valid2) {
|
|
2447
|
+
const _errs45 = errors;
|
|
2448
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2449
|
+
if (data.git === void 0) {
|
|
2450
|
+
const err18 = { instancePath, schemaPath: "#/else/else/then/required", keyword: "required", params: { missingProperty: "git" }, message: "must have required property 'git'" };
|
|
2451
|
+
if (vErrors === null) {
|
|
2452
|
+
vErrors = [err18];
|
|
2453
|
+
} else {
|
|
2454
|
+
vErrors.push(err18);
|
|
2455
|
+
}
|
|
2456
|
+
errors++;
|
|
2457
|
+
}
|
|
2458
|
+
if (data.state !== void 0) {
|
|
2459
|
+
const err19 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2460
|
+
if (vErrors === null) {
|
|
2461
|
+
vErrors = [err19];
|
|
2462
|
+
} else {
|
|
2463
|
+
vErrors.push(err19);
|
|
2464
|
+
}
|
|
2465
|
+
errors++;
|
|
2466
|
+
}
|
|
2467
|
+
if (data.regions !== void 0) {
|
|
2468
|
+
const err20 = { instancePath: instancePath + "/regions", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2469
|
+
if (vErrors === null) {
|
|
2470
|
+
vErrors = [err20];
|
|
2471
|
+
} else {
|
|
2472
|
+
vErrors.push(err20);
|
|
2473
|
+
}
|
|
2474
|
+
errors++;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
var _valid2 = _errs45 === errors;
|
|
2478
|
+
valid29 = _valid2;
|
|
2479
|
+
ifClause2 = "then";
|
|
1890
2480
|
} else {
|
|
1891
|
-
|
|
1892
|
-
if (
|
|
1893
|
-
if (
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
2481
|
+
const _errs52 = errors;
|
|
2482
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2483
|
+
if (data.boxes !== void 0) {
|
|
2484
|
+
let data22 = data.boxes;
|
|
2485
|
+
if (Array.isArray(data22)) {
|
|
2486
|
+
if (data22.length < 1) {
|
|
2487
|
+
const err21 = { instancePath: instancePath + "/boxes", schemaPath: "#/else/else/else/properties/boxes/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2488
|
+
if (vErrors === null) {
|
|
2489
|
+
vErrors = [err21];
|
|
2490
|
+
} else {
|
|
2491
|
+
vErrors.push(err21);
|
|
2492
|
+
}
|
|
2493
|
+
errors++;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
if (data.steps !== void 0) {
|
|
2498
|
+
let data23 = data.steps;
|
|
2499
|
+
if (Array.isArray(data23)) {
|
|
2500
|
+
const len5 = data23.length;
|
|
2501
|
+
for (let i5 = 0; i5 < len5; i5++) {
|
|
2502
|
+
let data24 = data23[i5];
|
|
2503
|
+
if (data24 && typeof data24 == "object" && !Array.isArray(data24)) {
|
|
2504
|
+
if (data24.events !== void 0) {
|
|
2505
|
+
let data25 = data24.events;
|
|
2506
|
+
if (Array.isArray(data25)) {
|
|
2507
|
+
const len6 = data25.length;
|
|
2508
|
+
for (let i6 = 0; i6 < len6; i6++) {
|
|
2509
|
+
let data26 = data25[i6];
|
|
2510
|
+
if (data26 && typeof data26 == "object" && !Array.isArray(data26)) {
|
|
2511
|
+
if (data26.type !== void 0) {
|
|
2512
|
+
let data27 = data26.type;
|
|
2513
|
+
const _errs60 = errors;
|
|
2514
|
+
const _errs61 = errors;
|
|
2515
|
+
if (!(data27 === "commit" || data27 === "branch")) {
|
|
2516
|
+
const err22 = {};
|
|
2517
|
+
if (vErrors === null) {
|
|
2518
|
+
vErrors = [err22];
|
|
2519
|
+
} else {
|
|
2520
|
+
vErrors.push(err22);
|
|
2521
|
+
}
|
|
2522
|
+
errors++;
|
|
2523
|
+
}
|
|
2524
|
+
var valid42 = _errs61 === errors;
|
|
2525
|
+
if (valid42) {
|
|
2526
|
+
const err23 = { instancePath: instancePath + "/steps/" + i5 + "/events/" + i6 + "/type", schemaPath: "#/definitions/plainSteps/items/properties/events/items/properties/type/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2527
|
+
if (vErrors === null) {
|
|
2528
|
+
vErrors = [err23];
|
|
2529
|
+
} else {
|
|
2530
|
+
vErrors.push(err23);
|
|
2531
|
+
}
|
|
2532
|
+
errors++;
|
|
2533
|
+
} else {
|
|
2534
|
+
errors = _errs60;
|
|
2535
|
+
if (vErrors !== null) {
|
|
2536
|
+
if (_errs60) {
|
|
2537
|
+
vErrors.length = _errs60;
|
|
2538
|
+
} else {
|
|
2539
|
+
vErrors = null;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
if (data.state !== void 0) {
|
|
2553
|
+
const err24 = { instancePath: instancePath + "/state", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2554
|
+
if (vErrors === null) {
|
|
2555
|
+
vErrors = [err24];
|
|
2556
|
+
} else {
|
|
2557
|
+
vErrors.push(err24);
|
|
2558
|
+
}
|
|
2559
|
+
errors++;
|
|
2560
|
+
}
|
|
2561
|
+
if (data.git !== void 0) {
|
|
2562
|
+
const err25 = { instancePath: instancePath + "/git", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2563
|
+
if (vErrors === null) {
|
|
2564
|
+
vErrors = [err25];
|
|
2565
|
+
} else {
|
|
2566
|
+
vErrors.push(err25);
|
|
2567
|
+
}
|
|
2568
|
+
errors++;
|
|
1897
2569
|
}
|
|
1898
2570
|
}
|
|
2571
|
+
var _valid2 = _errs52 === errors;
|
|
2572
|
+
valid29 = _valid2;
|
|
2573
|
+
ifClause2 = "else";
|
|
1899
2574
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
2575
|
+
if (!valid29) {
|
|
2576
|
+
const err26 = { instancePath, schemaPath: "#/else/else/if", keyword: "if", params: { failingKeyword: ifClause2 }, message: 'must match "' + ifClause2 + '" schema' };
|
|
2577
|
+
if (vErrors === null) {
|
|
2578
|
+
vErrors = [err26];
|
|
2579
|
+
} else {
|
|
2580
|
+
vErrors.push(err26);
|
|
2581
|
+
}
|
|
2582
|
+
errors++;
|
|
2583
|
+
}
|
|
2584
|
+
var _valid1 = _errs41 === errors;
|
|
2585
|
+
valid13 = _valid1;
|
|
1902
2586
|
ifClause1 = "else";
|
|
1903
2587
|
}
|
|
1904
|
-
if (!
|
|
1905
|
-
const
|
|
2588
|
+
if (!valid13) {
|
|
2589
|
+
const err27 = { instancePath, schemaPath: "#/else/if", keyword: "if", params: { failingKeyword: ifClause1 }, message: 'must match "' + ifClause1 + '" schema' };
|
|
1906
2590
|
if (vErrors === null) {
|
|
1907
|
-
vErrors = [
|
|
2591
|
+
vErrors = [err27];
|
|
1908
2592
|
} else {
|
|
1909
|
-
vErrors.push(
|
|
2593
|
+
vErrors.push(err27);
|
|
1910
2594
|
}
|
|
1911
2595
|
errors++;
|
|
1912
2596
|
}
|
|
1913
|
-
|
|
2597
|
+
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
2598
|
+
if (data.sequence !== void 0) {
|
|
2599
|
+
const err28 = { instancePath: instancePath + "/sequence", schemaPath: "#/definitions/absent/not", keyword: "not", params: {}, message: "must NOT be valid" };
|
|
2600
|
+
if (vErrors === null) {
|
|
2601
|
+
vErrors = [err28];
|
|
2602
|
+
} else {
|
|
2603
|
+
vErrors.push(err28);
|
|
2604
|
+
}
|
|
2605
|
+
errors++;
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
var _valid0 = _errs20 === errors;
|
|
1914
2609
|
valid0 = _valid0;
|
|
1915
2610
|
ifClause0 = "else";
|
|
1916
2611
|
}
|
|
1917
2612
|
if (!valid0) {
|
|
1918
|
-
const
|
|
2613
|
+
const err29 = { instancePath, schemaPath: "#/if", keyword: "if", params: { failingKeyword: ifClause0 }, message: 'must match "' + ifClause0 + '" schema' };
|
|
1919
2614
|
if (vErrors === null) {
|
|
1920
|
-
vErrors = [
|
|
2615
|
+
vErrors = [err29];
|
|
1921
2616
|
} else {
|
|
1922
|
-
vErrors.push(
|
|
2617
|
+
vErrors.push(err29);
|
|
1923
2618
|
}
|
|
1924
2619
|
errors++;
|
|
1925
2620
|
}
|
|
1926
2621
|
if (data && typeof data == "object" && !Array.isArray(data)) {
|
|
1927
2622
|
if (data.version === void 0) {
|
|
1928
|
-
const
|
|
2623
|
+
const err30 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
|
|
1929
2624
|
if (vErrors === null) {
|
|
1930
|
-
vErrors = [
|
|
2625
|
+
vErrors = [err30];
|
|
1931
2626
|
} else {
|
|
1932
|
-
vErrors.push(
|
|
2627
|
+
vErrors.push(err30);
|
|
1933
2628
|
}
|
|
1934
2629
|
errors++;
|
|
1935
2630
|
}
|
|
1936
2631
|
if (data.kind === void 0) {
|
|
1937
|
-
const
|
|
2632
|
+
const err31 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "kind" }, message: "must have required property 'kind'" };
|
|
1938
2633
|
if (vErrors === null) {
|
|
1939
|
-
vErrors = [
|
|
2634
|
+
vErrors = [err31];
|
|
1940
2635
|
} else {
|
|
1941
|
-
vErrors.push(
|
|
2636
|
+
vErrors.push(err31);
|
|
1942
2637
|
}
|
|
1943
2638
|
errors++;
|
|
1944
2639
|
}
|
|
1945
2640
|
if (data.title === void 0) {
|
|
1946
|
-
const
|
|
2641
|
+
const err32 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "title" }, message: "must have required property 'title'" };
|
|
1947
2642
|
if (vErrors === null) {
|
|
1948
|
-
vErrors = [
|
|
2643
|
+
vErrors = [err32];
|
|
1949
2644
|
} else {
|
|
1950
|
-
vErrors.push(
|
|
2645
|
+
vErrors.push(err32);
|
|
1951
2646
|
}
|
|
1952
2647
|
errors++;
|
|
1953
2648
|
}
|
|
1954
2649
|
if (data.boxes === void 0) {
|
|
1955
|
-
const
|
|
2650
|
+
const err33 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "boxes" }, message: "must have required property 'boxes'" };
|
|
1956
2651
|
if (vErrors === null) {
|
|
1957
|
-
vErrors = [
|
|
2652
|
+
vErrors = [err33];
|
|
1958
2653
|
} else {
|
|
1959
|
-
vErrors.push(
|
|
2654
|
+
vErrors.push(err33);
|
|
1960
2655
|
}
|
|
1961
2656
|
errors++;
|
|
1962
2657
|
}
|
|
1963
2658
|
if (data.steps === void 0) {
|
|
1964
|
-
const
|
|
2659
|
+
const err34 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "steps" }, message: "must have required property 'steps'" };
|
|
1965
2660
|
if (vErrors === null) {
|
|
1966
|
-
vErrors = [
|
|
2661
|
+
vErrors = [err34];
|
|
1967
2662
|
} else {
|
|
1968
|
-
vErrors.push(
|
|
2663
|
+
vErrors.push(err34);
|
|
1969
2664
|
}
|
|
1970
2665
|
errors++;
|
|
1971
2666
|
}
|
|
1972
2667
|
for (const key0 in data) {
|
|
1973
2668
|
if (!func2.call(schema11.properties, key0)) {
|
|
1974
|
-
const
|
|
2669
|
+
const err35 = { instancePath, schemaPath: "#/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
|
|
1975
2670
|
if (vErrors === null) {
|
|
1976
|
-
vErrors = [
|
|
2671
|
+
vErrors = [err35];
|
|
1977
2672
|
} else {
|
|
1978
|
-
vErrors.push(
|
|
2673
|
+
vErrors.push(err35);
|
|
1979
2674
|
}
|
|
1980
2675
|
errors++;
|
|
1981
2676
|
}
|
|
1982
2677
|
}
|
|
1983
2678
|
if (data.version !== void 0) {
|
|
1984
|
-
let
|
|
1985
|
-
if (!(typeof
|
|
1986
|
-
const
|
|
2679
|
+
let data31 = data.version;
|
|
2680
|
+
if (!(typeof data31 == "number" && (!(data31 % 1) && !isNaN(data31)) && isFinite(data31))) {
|
|
2681
|
+
const err36 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
|
|
1987
2682
|
if (vErrors === null) {
|
|
1988
|
-
vErrors = [
|
|
2683
|
+
vErrors = [err36];
|
|
1989
2684
|
} else {
|
|
1990
|
-
vErrors.push(
|
|
2685
|
+
vErrors.push(err36);
|
|
1991
2686
|
}
|
|
1992
2687
|
errors++;
|
|
1993
2688
|
}
|
|
1994
|
-
if (typeof
|
|
1995
|
-
if (
|
|
1996
|
-
const
|
|
2689
|
+
if (typeof data31 == "number" && isFinite(data31)) {
|
|
2690
|
+
if (data31 < 1 || isNaN(data31)) {
|
|
2691
|
+
const err37 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
|
|
1997
2692
|
if (vErrors === null) {
|
|
1998
|
-
vErrors = [
|
|
2693
|
+
vErrors = [err37];
|
|
1999
2694
|
} else {
|
|
2000
|
-
vErrors.push(
|
|
2695
|
+
vErrors.push(err37);
|
|
2001
2696
|
}
|
|
2002
2697
|
errors++;
|
|
2003
2698
|
}
|
|
2004
2699
|
}
|
|
2005
2700
|
}
|
|
2006
2701
|
if (data.kind !== void 0) {
|
|
2007
|
-
let
|
|
2008
|
-
if (!(
|
|
2009
|
-
const
|
|
2702
|
+
let data32 = data.kind;
|
|
2703
|
+
if (!(data32 === "sequence" || data32 === "architecture" || data32 === "state" || data32 === "git")) {
|
|
2704
|
+
const err38 = { 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" };
|
|
2010
2705
|
if (vErrors === null) {
|
|
2011
|
-
vErrors = [
|
|
2706
|
+
vErrors = [err38];
|
|
2012
2707
|
} else {
|
|
2013
|
-
vErrors.push(
|
|
2708
|
+
vErrors.push(err38);
|
|
2014
2709
|
}
|
|
2015
2710
|
errors++;
|
|
2016
2711
|
}
|
|
2017
2712
|
}
|
|
2018
2713
|
if (data.title !== void 0) {
|
|
2019
|
-
let
|
|
2020
|
-
if (typeof
|
|
2021
|
-
if (func3(
|
|
2022
|
-
const
|
|
2714
|
+
let data33 = data.title;
|
|
2715
|
+
if (typeof data33 === "string") {
|
|
2716
|
+
if (func3(data33) < 1) {
|
|
2717
|
+
const err39 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
|
|
2023
2718
|
if (vErrors === null) {
|
|
2024
|
-
vErrors = [
|
|
2719
|
+
vErrors = [err39];
|
|
2025
2720
|
} else {
|
|
2026
|
-
vErrors.push(
|
|
2721
|
+
vErrors.push(err39);
|
|
2027
2722
|
}
|
|
2028
2723
|
errors++;
|
|
2029
2724
|
}
|
|
2030
2725
|
} else {
|
|
2031
|
-
const
|
|
2726
|
+
const err40 = { instancePath: instancePath + "/title", schemaPath: "#/definitions/text/type", keyword: "type", params: { type: "string" }, message: "must be string" };
|
|
2032
2727
|
if (vErrors === null) {
|
|
2033
|
-
vErrors = [
|
|
2728
|
+
vErrors = [err40];
|
|
2034
2729
|
} else {
|
|
2035
|
-
vErrors.push(
|
|
2730
|
+
vErrors.push(err40);
|
|
2036
2731
|
}
|
|
2037
2732
|
errors++;
|
|
2038
2733
|
}
|
|
2039
2734
|
}
|
|
2040
2735
|
if (data.view !== void 0) {
|
|
2041
|
-
let
|
|
2042
|
-
if (!(
|
|
2043
|
-
const
|
|
2736
|
+
let data34 = data.view;
|
|
2737
|
+
if (!(data34 === "fixed" || data34 === "follow")) {
|
|
2738
|
+
const err41 = { 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" };
|
|
2044
2739
|
if (vErrors === null) {
|
|
2045
|
-
vErrors = [
|
|
2740
|
+
vErrors = [err41];
|
|
2046
2741
|
} else {
|
|
2047
|
-
vErrors.push(
|
|
2742
|
+
vErrors.push(err41);
|
|
2048
2743
|
}
|
|
2049
2744
|
errors++;
|
|
2050
2745
|
}
|
|
2051
2746
|
}
|
|
2052
2747
|
if (data.regions !== void 0) {
|
|
2053
|
-
let
|
|
2054
|
-
if (Array.isArray(
|
|
2055
|
-
const
|
|
2056
|
-
for (let
|
|
2057
|
-
if (!validate11(
|
|
2748
|
+
let data35 = data.regions;
|
|
2749
|
+
if (Array.isArray(data35)) {
|
|
2750
|
+
const len7 = data35.length;
|
|
2751
|
+
for (let i7 = 0; i7 < len7; i7++) {
|
|
2752
|
+
if (!validate11(data35[i7], { instancePath: instancePath + "/regions/" + i7, parentData: data35, parentDataProperty: i7, rootData })) {
|
|
2058
2753
|
vErrors = vErrors === null ? validate11.errors : vErrors.concat(validate11.errors);
|
|
2059
2754
|
errors = vErrors.length;
|
|
2060
2755
|
}
|
|
2061
2756
|
}
|
|
2062
2757
|
} else {
|
|
2063
|
-
const
|
|
2758
|
+
const err42 = { instancePath: instancePath + "/regions", schemaPath: "#/properties/regions/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2064
2759
|
if (vErrors === null) {
|
|
2065
|
-
vErrors = [
|
|
2760
|
+
vErrors = [err42];
|
|
2066
2761
|
} else {
|
|
2067
|
-
vErrors.push(
|
|
2762
|
+
vErrors.push(err42);
|
|
2068
2763
|
}
|
|
2069
2764
|
errors++;
|
|
2070
2765
|
}
|
|
2071
2766
|
}
|
|
2072
2767
|
if (data.boxes !== void 0) {
|
|
2073
|
-
let
|
|
2074
|
-
if (Array.isArray(
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
if (
|
|
2078
|
-
vErrors = [err28];
|
|
2079
|
-
} else {
|
|
2080
|
-
vErrors.push(err28);
|
|
2081
|
-
}
|
|
2082
|
-
errors++;
|
|
2083
|
-
}
|
|
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 })) {
|
|
2768
|
+
let data37 = data.boxes;
|
|
2769
|
+
if (Array.isArray(data37)) {
|
|
2770
|
+
const len8 = data37.length;
|
|
2771
|
+
for (let i8 = 0; i8 < len8; i8++) {
|
|
2772
|
+
if (!validate13(data37[i8], { instancePath: instancePath + "/boxes/" + i8, parentData: data37, parentDataProperty: i8, rootData })) {
|
|
2087
2773
|
vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
|
|
2088
2774
|
errors = vErrors.length;
|
|
2089
2775
|
}
|
|
2090
2776
|
}
|
|
2091
2777
|
} else {
|
|
2092
|
-
const
|
|
2778
|
+
const err43 = { instancePath: instancePath + "/boxes", schemaPath: "#/properties/boxes/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2093
2779
|
if (vErrors === null) {
|
|
2094
|
-
vErrors = [
|
|
2780
|
+
vErrors = [err43];
|
|
2095
2781
|
} else {
|
|
2096
|
-
vErrors.push(
|
|
2782
|
+
vErrors.push(err43);
|
|
2097
2783
|
}
|
|
2098
2784
|
errors++;
|
|
2099
2785
|
}
|
|
@@ -2105,30 +2791,30 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2105
2791
|
}
|
|
2106
2792
|
}
|
|
2107
2793
|
if (data.steps !== void 0) {
|
|
2108
|
-
let
|
|
2109
|
-
if (Array.isArray(
|
|
2110
|
-
if (
|
|
2111
|
-
const
|
|
2794
|
+
let data40 = data.steps;
|
|
2795
|
+
if (Array.isArray(data40)) {
|
|
2796
|
+
if (data40.length < 1) {
|
|
2797
|
+
const err44 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
|
|
2112
2798
|
if (vErrors === null) {
|
|
2113
|
-
vErrors = [
|
|
2799
|
+
vErrors = [err44];
|
|
2114
2800
|
} else {
|
|
2115
|
-
vErrors.push(
|
|
2801
|
+
vErrors.push(err44);
|
|
2116
2802
|
}
|
|
2117
2803
|
errors++;
|
|
2118
2804
|
}
|
|
2119
|
-
const
|
|
2120
|
-
for (let
|
|
2121
|
-
if (!validate17(
|
|
2805
|
+
const len9 = data40.length;
|
|
2806
|
+
for (let i9 = 0; i9 < len9; i9++) {
|
|
2807
|
+
if (!validate17(data40[i9], { instancePath: instancePath + "/steps/" + i9, parentData: data40, parentDataProperty: i9, rootData })) {
|
|
2122
2808
|
vErrors = vErrors === null ? validate17.errors : vErrors.concat(validate17.errors);
|
|
2123
2809
|
errors = vErrors.length;
|
|
2124
2810
|
}
|
|
2125
2811
|
}
|
|
2126
2812
|
} else {
|
|
2127
|
-
const
|
|
2813
|
+
const err45 = { instancePath: instancePath + "/steps", schemaPath: "#/properties/steps/type", keyword: "type", params: { type: "array" }, message: "must be array" };
|
|
2128
2814
|
if (vErrors === null) {
|
|
2129
|
-
vErrors = [
|
|
2815
|
+
vErrors = [err45];
|
|
2130
2816
|
} else {
|
|
2131
|
-
vErrors.push(
|
|
2817
|
+
vErrors.push(err45);
|
|
2132
2818
|
}
|
|
2133
2819
|
errors++;
|
|
2134
2820
|
}
|
|
@@ -2145,12 +2831,18 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2145
2831
|
errors = vErrors.length;
|
|
2146
2832
|
}
|
|
2147
2833
|
}
|
|
2834
|
+
if (data.git !== void 0) {
|
|
2835
|
+
if (!validate29(data.git, { instancePath: instancePath + "/git", parentData: data, parentDataProperty: "git", rootData })) {
|
|
2836
|
+
vErrors = vErrors === null ? validate29.errors : vErrors.concat(validate29.errors);
|
|
2837
|
+
errors = vErrors.length;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2148
2840
|
} else {
|
|
2149
|
-
const
|
|
2841
|
+
const err46 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
|
|
2150
2842
|
if (vErrors === null) {
|
|
2151
|
-
vErrors = [
|
|
2843
|
+
vErrors = [err46];
|
|
2152
2844
|
} else {
|
|
2153
|
-
vErrors.push(
|
|
2845
|
+
vErrors.push(err46);
|
|
2154
2846
|
}
|
|
2155
2847
|
errors++;
|
|
2156
2848
|
}
|
|
@@ -2160,16 +2852,23 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
2160
2852
|
|
|
2161
2853
|
// src/words.ts
|
|
2162
2854
|
var keys = (table) => Object.keys(table);
|
|
2163
|
-
var KINDS = keys({ sequence: true, architecture: true, state: true });
|
|
2855
|
+
var KINDS = keys({ sequence: true, architecture: true, state: true, git: true });
|
|
2164
2856
|
var STATE_ENDS = ["start", "finish"];
|
|
2165
|
-
var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set"];
|
|
2857
|
+
var HEADS = ["group", "end", "box", "strip", "step", "say", "code", "act", "note", "set", "branch", "commit"];
|
|
2166
2858
|
var AS = "as";
|
|
2859
|
+
var ON = "on";
|
|
2860
|
+
var COPY = "copy";
|
|
2861
|
+
var MERGE = "merge";
|
|
2862
|
+
var FROM = "from";
|
|
2863
|
+
var HEAD = "HEAD";
|
|
2167
2864
|
var ATTRS = {
|
|
2168
2865
|
diagram: ["view"],
|
|
2169
2866
|
group: ["note", "color", "icon"],
|
|
2170
2867
|
box: ["note", "color", "icon"],
|
|
2171
2868
|
edge: ["carry", "tag", "side"],
|
|
2172
|
-
set: ["tag"]
|
|
2869
|
+
set: ["tag"],
|
|
2870
|
+
branch: ["note"],
|
|
2871
|
+
commit: ["hash", "note"]
|
|
2173
2872
|
};
|
|
2174
2873
|
var CARRIES = keys({ coin: true, none: true });
|
|
2175
2874
|
var VIEWS = keys({ fixed: true, follow: true });
|
|
@@ -2185,17 +2884,17 @@ var OLD_HEADS = {
|
|
|
2185
2884
|
|
|
2186
2885
|
// src/schema.ts
|
|
2187
2886
|
var COLORS = ["blue", "amber", "green", "violet", "rose", "slate", "coin"];
|
|
2188
|
-
var EVENT_TYPES = ["edge", "action", "swap", "strip"];
|
|
2189
|
-
var
|
|
2190
|
-
|
|
2191
|
-
"#/then/not": { field: "state", kind: "state" },
|
|
2192
|
-
"#/else/else/not": { field: "state", kind: "state" }
|
|
2193
|
-
};
|
|
2887
|
+
var EVENT_TYPES = ["edge", "action", "swap", "strip", "commit", "branch"];
|
|
2888
|
+
var ABSENT = "#/definitions/absent/not";
|
|
2889
|
+
var ABSENT_KINDS = { regions: "sequence / architecture / state" };
|
|
2194
2890
|
var NOT_ALLOWED = {
|
|
2195
2891
|
carry: { field: "text", kind: "tag" }
|
|
2196
2892
|
};
|
|
2197
2893
|
var RESERVED_ID = /\/boxes\/items\/properties\/id\/not$/u;
|
|
2894
|
+
var GIT_EVENT = /\/events\/items\/properties\/type\/not$/u;
|
|
2895
|
+
var GIT_EVENTS = ["commit", "branch"];
|
|
2198
2896
|
var escape = (key2) => key2.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
2897
|
+
var HEX = /^\^\[0-9a-f\]\{(\d+),(\d+)\}\$$/u;
|
|
2199
2898
|
function forbiddenOf(pattern) {
|
|
2200
2899
|
const inside = /^\^\[\^(.+)\]\+\$$/u.exec(pattern)?.[1];
|
|
2201
2900
|
if (inside === void 0) return void 0;
|
|
@@ -2219,7 +2918,10 @@ function toFieldError(error, errors, m) {
|
|
|
2219
2918
|
}
|
|
2220
2919
|
case "not": {
|
|
2221
2920
|
if (RESERVED_ID.test(error.schemaPath)) return { pointer: at, message: m.reserved(STATE_ENDS) };
|
|
2222
|
-
|
|
2921
|
+
if (GIT_EVENT.test(error.schemaPath)) return { pointer: at, message: m.kindOnly(GIT_EVENTS, "git") };
|
|
2922
|
+
const last = at.slice(at.lastIndexOf("/") + 1);
|
|
2923
|
+
if (error.schemaPath === ABSENT) return { pointer: at, message: m.not({ field: last, kind: ABSENT_KINDS[last] ?? last }) };
|
|
2924
|
+
const allowed = NOT_ALLOWED[last];
|
|
2223
2925
|
return { pointer: allowed ? `${at}/${allowed.field}` : at, message: m.not(allowed) };
|
|
2224
2926
|
}
|
|
2225
2927
|
case "anyOf": {
|
|
@@ -2237,8 +2939,10 @@ function toFieldError(error, errors, m) {
|
|
|
2237
2939
|
return { pointer: at, message: m.type(String(params.type)) };
|
|
2238
2940
|
case "minLength":
|
|
2239
2941
|
return { pointer: at, message: m.minLength(Number(params.limit)) };
|
|
2240
|
-
case "pattern":
|
|
2241
|
-
|
|
2942
|
+
case "pattern": {
|
|
2943
|
+
const hex = HEX.exec(String(params.pattern));
|
|
2944
|
+
return { pointer: at, message: hex ? m.hex(Number(hex[1]), Number(hex[2])) : m.pattern(forbiddenOf(String(params.pattern))) };
|
|
2945
|
+
}
|
|
2242
2946
|
case "minItems":
|
|
2243
2947
|
return { pointer: at, message: m.minItems(Number(params.limit)) };
|
|
2244
2948
|
case "minimum":
|
|
@@ -2295,8 +2999,8 @@ var ja2 = () => {
|
|
|
2295
2999
|
sayTwice: "1 \u3064\u306E\u6BB5\u306B say \u306F 1 \u3064\u307E\u3067\u3002\u9577\u3044\u672C\u6587\u306F say \u306E\u4E0B\u306B\u5B57\u4E0B\u3052\u3057\u3066\u7D9A\u3051\u308B",
|
|
2296
3000
|
codeTwice: "1 \u3064\u306E\u6BB5\u306B code \u306F 1 \u884C\u307E\u3067",
|
|
2297
3001
|
emptyCode: "code \u306E\u5F8C\u308D\u306B\u547D\u4EE4\u3092\u66F8\u304F",
|
|
2298
|
-
declarationInStep: "group \u3068 box \u3068 strip \u306F\u6700\u521D\u306E step \u3088\u308A\u524D\u306B\u66F8\u304F",
|
|
2299
|
-
stepLineBeforeStep: "\u7DDA\u3068 say \u3068 code \u3068 act \u3068 note \u3068 set \u306F step \u306E\u4E0B\u306B\u66F8\u304F",
|
|
3002
|
+
declarationInStep: "group \u3068 box \u3068 strip \u3068 branch \u306F\u6700\u521D\u306E step \u3088\u308A\u524D\u306B\u66F8\u304F",
|
|
3003
|
+
stepLineBeforeStep: "\u7DDA\u3068 say \u3068 code \u3068 act \u3068 note \u3068 set \u3068 commit \u3068\u679D\u3092\u5207\u308B\u884C\u306F step \u306E\u4E0B\u306B\u66F8\u304F",
|
|
2300
3004
|
nestedGroup: "group \u306E\u4E2D\u306B group \u306F\u66F8\u3051\u306A\u3044\u3002\u5148\u306B end \u3067\u9589\u3058\u308B",
|
|
2301
3005
|
strayEnd: "end \u306E\u524D\u306B\u3001\u9589\u3058\u308B group \u304C\u7121\u3044",
|
|
2302
3006
|
endTakesNothing: "end \u306E\u5F8C\u308D\u306B\u306F\u4F55\u3082\u66F8\u304B\u306A\u3044",
|
|
@@ -2328,7 +3032,20 @@ var ja2 = () => {
|
|
|
2328
3032
|
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
3033
|
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
3034
|
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"
|
|
3035
|
+
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",
|
|
3036
|
+
gitOnly: (word) => `${word} \u306E\u884C\u306F git (\u679D\u5206\u304B\u308C\u306E\u56F3) \u3067\u3060\u3051\u66F8\u3051\u308B`,
|
|
3037
|
+
gitNoGroup: "git (\u679D\u5206\u304B\u308C\u306E\u56F3) \u306B\u306F group \u3092\u66F8\u3051\u306A\u3044\u3002\u679D\u306F branch \u306E\u884C\u3067\u5BA3\u8A00\u3059\u308B",
|
|
3038
|
+
noBranches: "branch \u306E\u884C\u3067\u679D\u3092 1 \u3064\u4EE5\u4E0A\u5BA3\u8A00\u3059\u308B",
|
|
3039
|
+
branchShape: "branch \u306F branch <\u540D\u672D> [note: <\u6DFB\u3048\u66F8\u304D>] \u306E\u5F62\u3067\u66F8\u304F",
|
|
3040
|
+
commitShape: "commit \u306F commit <\u540D\u672D> on <\u679D> [hash: <hash>, note: <\u4E00\u8A00>] \u306E\u5F62\u3067\u66F8\u304F\u3002\u5F53\u3066\u76F4\u3057\u306F copy <commit> \u3092\u3001\u53D6\u308A\u8FBC\u307F\u306F merge <\u679D> \u3092 on <\u679D> \u306E\u5F8C\u308D\u306B\u66F8\u304F",
|
|
3041
|
+
fromShape: "\u679D\u3092\u5207\u308B\u884C\u306F <\u679D> from <commit> \u306E\u5F62\u3067\u66F8\u304F",
|
|
3042
|
+
undeclaredBranch: (id) => `${id} \u3068\u3044\u3046\u679D\u306F\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044`,
|
|
3043
|
+
undeclaredRef: (id) => `${id} \u3068\u3044\u3046\u679D\u306F\u5BA3\u8A00\u3057\u3066\u3044\u306A\u3044\u3002\u672D\u3092\u52D5\u304B\u3059\u7DDA\u306F\u679D\u306E\u540D\u672D\u304B HEAD \u304B\u3089\u5F15\u304F`,
|
|
3044
|
+
noCommit: (id) => `${id} \u3068\u3044\u3046 commit \u306F\u307E\u3060\u7A4D\u3093\u3067\u3044\u306A\u3044`,
|
|
3045
|
+
emptyBranch: (id) => `${id} \u306E\u679D\u306F\u307E\u3060\u3069\u306E commit \u3082\u6307\u3057\u3066\u3044\u306A\u3044\u306E\u3067\u53D6\u308A\u8FBC\u3081\u306A\u3044`,
|
|
3046
|
+
mergeSelf: (id) => `${id} \u306F\u7A4D\u3080\u679D\u306A\u306E\u3067\u3001\u53D6\u308A\u8FBC\u3080\u679D\u306B\u3067\u304D\u306A\u3044`,
|
|
3047
|
+
headReserved: (name2) => `${name2} \u306F\u679D\u5206\u304B\u308C\u306E\u56F3\u3067\u4ECA\u3044\u308B\u5834\u6240\u306E\u672D\u306E\u540D\u524D\u3067\u3001\u540D\u672D\u306B\u4F7F\u3048\u306A\u3044`,
|
|
3048
|
+
badHash: "hash \u306F 0 \u304B\u3089 9 \u3068 a \u304B\u3089 f \u306E\u5B57\u3067 4 \u304B\u3089 40 \u5B57\u306B\u3059\u308B"
|
|
2332
3049
|
};
|
|
2333
3050
|
};
|
|
2334
3051
|
var en2 = () => {
|
|
@@ -2364,8 +3081,8 @@ var en2 = () => {
|
|
|
2364
3081
|
sayTwice: "A step takes one say. Continue a long body on indented lines below it",
|
|
2365
3082
|
codeTwice: "A step takes at most one code line",
|
|
2366
3083
|
emptyCode: "Write the command after code",
|
|
2367
|
-
declarationInStep: "Write group, box and
|
|
2368
|
-
stepLineBeforeStep: "Write lines, say, code, act, note and
|
|
3084
|
+
declarationInStep: "Write group, box, strip and branch before the first step",
|
|
3085
|
+
stepLineBeforeStep: "Write lines, say, code, act, note, set, commit and branch cuts under a step",
|
|
2369
3086
|
nestedGroup: "A group cannot hold another group. Close it with end first",
|
|
2370
3087
|
strayEnd: "There is no group for this end to close",
|
|
2371
3088
|
endTakesNothing: "Write nothing after end",
|
|
@@ -2397,7 +3114,20 @@ var en2 = () => {
|
|
|
2397
3114
|
reservedId: (id) => `${id} names the start or end mark of a state diagram and cannot be a box id`,
|
|
2398
3115
|
intoStart: "A line cannot go into start. start is the start mark, and lines leave it",
|
|
2399
3116
|
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)"
|
|
3117
|
+
pathNoAttrs: "A line before the first step is a path not taken, so it takes no attributes (carry, tag, side)",
|
|
3118
|
+
gitOnly: (word) => `${word} lines can be written only in git diagrams`,
|
|
3119
|
+
gitNoGroup: "A git diagram takes no group. Declare branches with branch lines",
|
|
3120
|
+
noBranches: "Declare at least one branch with a branch line",
|
|
3121
|
+
branchShape: "Write a branch as branch <id> [note: <note>]",
|
|
3122
|
+
commitShape: "Write a commit as commit <id> on <branch> [hash: <hash>, note: <note>]. For a replayed commit add copy <commit>, and for a merge commit add merge <branch>, after on <branch>",
|
|
3123
|
+
fromShape: "Write a branch cut as <branch> from <commit>",
|
|
3124
|
+
undeclaredBranch: (id) => `No branch named ${id} is declared`,
|
|
3125
|
+
undeclaredRef: (id) => `No branch named ${id} is declared. A line that moves a ref starts from a branch id or HEAD`,
|
|
3126
|
+
noCommit: (id) => `No commit named ${id} has been made yet`,
|
|
3127
|
+
emptyBranch: (id) => `Branch ${id} does not point at any commit yet, so it cannot be merged`,
|
|
3128
|
+
mergeSelf: (id) => `${id} is the branch being committed to, so it cannot be the branch merged in`,
|
|
3129
|
+
headReserved: (name2) => `${name2} names where you are in a git diagram and cannot be an id`,
|
|
3130
|
+
badHash: "Write a hash as 4 to 40 characters of 0-9 and a-f"
|
|
2401
3131
|
};
|
|
2402
3132
|
};
|
|
2403
3133
|
var MESSAGES = { ja: ja2(), en: en2() };
|
|
@@ -2454,6 +3184,9 @@ var NotationError = class extends Error {
|
|
|
2454
3184
|
var fail = (source, index, message) => new NotationError(source.line, columnOf(source, index), message);
|
|
2455
3185
|
var ID = /^[^\s[\]「」=:]+$/u;
|
|
2456
3186
|
var EDGE = /^([^\s:[\]]+?)\s*->\s*([^\s:[\]]+)/du;
|
|
3187
|
+
var COMMIT = new RegExp(`^commit\\s+([^\\s[]+)(?:\\s+${ON}\\s+([^\\s[]+))?(?:\\s+${COPY}\\s+([^\\s[]+))?(?:\\s+${MERGE}\\s+([^\\s[]+))?`, "du");
|
|
3188
|
+
var CUT = new RegExp(`^([^\\s[]+)\\s+${FROM}(?:\\s+([^\\s[]+))?\\s*$`, "du");
|
|
3189
|
+
var HASH = /^[0-9a-f]{4,40}$/u;
|
|
2457
3190
|
var isOneOf = (list2, word) => list2.includes(word);
|
|
2458
3191
|
function skipSpaces(text2, at) {
|
|
2459
3192
|
let i = at;
|
|
@@ -2602,6 +3335,10 @@ function parseLines(lines, m) {
|
|
|
2602
3335
|
if (shown2 && !isOneOf(VIEWS, shown2.value)) throw fail(head, shown2.at, m.badView);
|
|
2603
3336
|
const view = shown2?.value;
|
|
2604
3337
|
const isState = kind === "state";
|
|
3338
|
+
const isGit = kind === "git";
|
|
3339
|
+
const branches = [];
|
|
3340
|
+
const commits = /* @__PURE__ */ new Set();
|
|
3341
|
+
const tips = /* @__PURE__ */ new Map();
|
|
2605
3342
|
const regions = [];
|
|
2606
3343
|
const boxes = [];
|
|
2607
3344
|
const paths = [];
|
|
@@ -2618,13 +3355,27 @@ function parseLines(lines, m) {
|
|
|
2618
3355
|
if (!boxes.some((box) => box.id === id)) throw fail(source, at, m.undeclaredBox(id));
|
|
2619
3356
|
return id;
|
|
2620
3357
|
};
|
|
3358
|
+
const branchAt = (source, id, at) => {
|
|
3359
|
+
if (!tips.has(id)) throw fail(source, at, m.undeclaredBranch(id));
|
|
3360
|
+
return id;
|
|
3361
|
+
};
|
|
3362
|
+
const commitAt = (source, id, at) => {
|
|
3363
|
+
if (!commits.has(id)) throw fail(source, at, m.noCommit(id));
|
|
3364
|
+
return id;
|
|
3365
|
+
};
|
|
2621
3366
|
const endAt = (source, id, at, side2) => {
|
|
3367
|
+
if (isGit) {
|
|
3368
|
+
if (side2 === "to") return commitAt(source, id, at);
|
|
3369
|
+
if (id !== HEAD && !tips.has(id)) throw fail(source, at, m.undeclaredRef(id));
|
|
3370
|
+
return id;
|
|
3371
|
+
}
|
|
2622
3372
|
if (!isState || !isOneOf(STATE_ENDS, id)) return boxAt(source, id, at);
|
|
2623
3373
|
if (id === "start" !== (side2 === "from")) throw fail(source, at, id === "start" ? m.intoStart : m.outOfFinish);
|
|
2624
3374
|
return id;
|
|
2625
3375
|
};
|
|
2626
3376
|
const notReserved = (source, id, at) => {
|
|
2627
3377
|
if (isState && isOneOf(STATE_ENDS, id)) throw fail(source, at, m.reservedId(id));
|
|
3378
|
+
if (isGit && id === HEAD) throw fail(source, at, m.headReserved(id));
|
|
2628
3379
|
};
|
|
2629
3380
|
const inStep = (source) => {
|
|
2630
3381
|
if (!building) throw fail(source, 0, m.stepLineBeforeStep);
|
|
@@ -2654,7 +3405,13 @@ function parseLines(lines, m) {
|
|
|
2654
3405
|
else inStep(source).events.push(readEdge(source, edge2));
|
|
2655
3406
|
continue;
|
|
2656
3407
|
}
|
|
2657
|
-
const word = text2.split(/\s
|
|
3408
|
+
const [word = "", second] = text2.split(/\s+/u);
|
|
3409
|
+
if (isGit && tips.has(word) && second === FROM) {
|
|
3410
|
+
const step = inStep(source);
|
|
3411
|
+
step.events.push(readCut(source));
|
|
3412
|
+
continue;
|
|
3413
|
+
}
|
|
3414
|
+
if (!isGit && (word === "branch" || word === "commit")) throw fail(source, 0, m.gitOnly(word));
|
|
2658
3415
|
if (!isOneOf(HEADS, word)) {
|
|
2659
3416
|
const old = oldForm(text2, building !== void 0);
|
|
2660
3417
|
throw fail(source, 0, old ? m.oldForm(old.word, old.shape) : m.unknownHead(word));
|
|
@@ -2708,11 +3465,20 @@ function parseLines(lines, m) {
|
|
|
2708
3465
|
case "set":
|
|
2709
3466
|
inStep(source).events.push(readSet(source));
|
|
2710
3467
|
break;
|
|
3468
|
+
case "branch":
|
|
3469
|
+
readBranch(source);
|
|
3470
|
+
break;
|
|
3471
|
+
case "commit": {
|
|
3472
|
+
const step = inStep(source);
|
|
3473
|
+
step.events.push(readCommit(source));
|
|
3474
|
+
break;
|
|
3475
|
+
}
|
|
2711
3476
|
}
|
|
2712
3477
|
}
|
|
2713
3478
|
if (group) throw fail(group.source, 0, m.unclosedGroup(group.id));
|
|
2714
3479
|
finish();
|
|
2715
|
-
if (
|
|
3480
|
+
if (isGit && branches.length === 0) throw fail(head, 0, m.noBranches);
|
|
3481
|
+
if (boxes.length === 0 && !isGit) throw fail(head, 0, m.noBoxes);
|
|
2716
3482
|
if (steps.length === 0) throw fail(head, 0, m.noSteps);
|
|
2717
3483
|
return {
|
|
2718
3484
|
version: FORMAT_VERSION,
|
|
@@ -2724,10 +3490,12 @@ function parseLines(lines, m) {
|
|
|
2724
3490
|
...strip2 ? { strip: strip2 } : {},
|
|
2725
3491
|
steps,
|
|
2726
3492
|
...kind === "sequence" ? { sequence: { lifelines: boxes.map((box) => box.id) } } : {},
|
|
2727
|
-
...paths.length > 0 ? { state: { paths } } : {}
|
|
3493
|
+
...paths.length > 0 ? { state: { paths } } : {},
|
|
3494
|
+
...isGit ? { git: { branches } } : {}
|
|
2728
3495
|
};
|
|
2729
3496
|
function readGroup(source) {
|
|
2730
3497
|
beforeSteps(source);
|
|
3498
|
+
if (isGit) throw fail(source, 0, m.gitNoGroup);
|
|
2731
3499
|
if (group) throw fail(source, 0, m.nestedGroup);
|
|
2732
3500
|
const declared = readDeclared(source, "group", ATTRS.group, m);
|
|
2733
3501
|
if (regions.some((region) => region.id === declared.id)) {
|
|
@@ -2753,6 +3521,62 @@ function parseLines(lines, m) {
|
|
|
2753
3521
|
...group ? { region: group.id } : {}
|
|
2754
3522
|
});
|
|
2755
3523
|
}
|
|
3524
|
+
function readBranch(source) {
|
|
3525
|
+
beforeSteps(source);
|
|
3526
|
+
const declared = readDeclared(source, "branch", ATTRS.branch, m);
|
|
3527
|
+
if (declared.name !== void 0) throw fail(source, 0, m.branchShape);
|
|
3528
|
+
notReserved(source, declared.id, declared.idAt);
|
|
3529
|
+
declare(source, declared.id, declared.idAt);
|
|
3530
|
+
const note = declared.attrs.get("note")?.value;
|
|
3531
|
+
branches.push({ id: declared.id, ...note !== void 0 ? { note } : {} });
|
|
3532
|
+
tips.set(declared.id, null);
|
|
3533
|
+
}
|
|
3534
|
+
function readCommit(source) {
|
|
3535
|
+
const text2 = source.text;
|
|
3536
|
+
const found = COMMIT.exec(text2);
|
|
3537
|
+
const at = (k) => found?.indices?.[k]?.[0] ?? 0;
|
|
3538
|
+
const id = found?.[1];
|
|
3539
|
+
const on = found?.[2];
|
|
3540
|
+
if (!found || id === void 0 || on === void 0) throw fail(source, 0, m.commitShape);
|
|
3541
|
+
const rest2 = skipSpaces(text2, found[0].length);
|
|
3542
|
+
if (rest2 < text2.length && text2[rest2] !== "[") throw fail(source, rest2, m.commitShape);
|
|
3543
|
+
if (!ID.test(id)) throw fail(source, at(1), m.badId(id));
|
|
3544
|
+
notReserved(source, id, at(1));
|
|
3545
|
+
declare(source, id, at(1));
|
|
3546
|
+
const branch = branchAt(source, on, at(2));
|
|
3547
|
+
const copy = found[3] === void 0 ? void 0 : commitAt(source, found[3], at(3));
|
|
3548
|
+
const merge = found[4] === void 0 ? void 0 : mergedAt(source, found[4], at(4), branch);
|
|
3549
|
+
const attrs2 = rest2 < text2.length ? readAttrs(source, rest2, ATTRS.commit, m) : /* @__PURE__ */ new Map();
|
|
3550
|
+
const hash = attrs2.get("hash");
|
|
3551
|
+
if (hash && !HASH.test(hash.value)) throw fail(source, hash.at, m.badHash);
|
|
3552
|
+
const note = attrs2.get("note")?.value;
|
|
3553
|
+
commits.add(id);
|
|
3554
|
+
if (copy === void 0) tips.set(branch, id);
|
|
3555
|
+
return {
|
|
3556
|
+
type: "commit",
|
|
3557
|
+
id,
|
|
3558
|
+
branch,
|
|
3559
|
+
...copy !== void 0 ? { copy } : {},
|
|
3560
|
+
...merge !== void 0 ? { merge } : {},
|
|
3561
|
+
...hash ? { hash: hash.value } : {},
|
|
3562
|
+
...note !== void 0 ? { note } : {}
|
|
3563
|
+
};
|
|
3564
|
+
}
|
|
3565
|
+
function mergedAt(source, id, at, into) {
|
|
3566
|
+
branchAt(source, id, at);
|
|
3567
|
+
if (id === into) throw fail(source, at, m.mergeSelf(id));
|
|
3568
|
+
if (tips.get(id) === null) throw fail(source, at, m.emptyBranch(id));
|
|
3569
|
+
return id;
|
|
3570
|
+
}
|
|
3571
|
+
function readCut(source) {
|
|
3572
|
+
const found = CUT.exec(source.text);
|
|
3573
|
+
const branch = found?.[1];
|
|
3574
|
+
const from = found?.[2];
|
|
3575
|
+
if (!found || branch === void 0 || from === void 0) throw fail(source, 0, m.fromShape);
|
|
3576
|
+
commitAt(source, from, found.indices?.[2]?.[0] ?? 0);
|
|
3577
|
+
tips.set(branch, from);
|
|
3578
|
+
return { type: "branch", branch, from };
|
|
3579
|
+
}
|
|
2756
3580
|
function readStrip(source) {
|
|
2757
3581
|
beforeSteps(source);
|
|
2758
3582
|
if (strip2) throw fail(source, 0, m.stripTwice);
|
|
@@ -2826,9 +3650,10 @@ function parseLines(lines, m) {
|
|
|
2826
3650
|
if (carried && !isOneOf(CARRIES, carried.value)) throw fail(source, carried.at, m.badCarry);
|
|
2827
3651
|
const side2 = attrs2.get("side");
|
|
2828
3652
|
if (side2 && !isOneOf(SIDES, side2.value)) throw fail(source, side2.at, m.badSide);
|
|
2829
|
-
let carry = { kind: "envelope" };
|
|
3653
|
+
let carry = isGit ? { kind: "tag", text: from } : { kind: "envelope" };
|
|
2830
3654
|
if (tag) carry = { kind: "tag", text: tag.value };
|
|
2831
3655
|
else if (carried) carry = carried.value === "coin" ? { kind: "coin" } : { kind: "none" };
|
|
3656
|
+
if (isGit && from !== HEAD) tips.set(from, to);
|
|
2832
3657
|
return {
|
|
2833
3658
|
type: "edge",
|
|
2834
3659
|
from,
|
|
@@ -2904,10 +3729,11 @@ var declareBox = (b) => `box ${b.id}${shown(b.id, b.name)}${attrs([
|
|
|
2904
3729
|
["icon", b.icon]
|
|
2905
3730
|
])}`;
|
|
2906
3731
|
var line = (from, to, label2) => `${from} -> ${to}${label2 === void 0 ? "" : `: ${name(label2)}`}`;
|
|
2907
|
-
function event(e) {
|
|
3732
|
+
function event(e, git) {
|
|
2908
3733
|
switch (e.type) {
|
|
2909
3734
|
case "edge": {
|
|
2910
|
-
const
|
|
3735
|
+
const plain = git ? e.carry.kind === "tag" && e.carry.text === e.from : e.carry.kind === "envelope";
|
|
3736
|
+
const carry = plain ? [] : e.carry.kind === "tag" ? [["tag", e.carry.text]] : [["carry", e.carry.kind]];
|
|
2911
3737
|
return `${line(e.from, e.to, e.label)}${attrs([...carry, ["side", e.labelSide]])}`;
|
|
2912
3738
|
}
|
|
2913
3739
|
case "action":
|
|
@@ -2916,6 +3742,13 @@ function event(e) {
|
|
|
2916
3742
|
return `note ${e.box}: ${e.text}`;
|
|
2917
3743
|
case "strip":
|
|
2918
3744
|
return `set ${key(e.field)}${e.value === void 0 ? "" : `: ${name(e.value)}`}${attrs([["tag", e.tag]])}`;
|
|
3745
|
+
case "commit":
|
|
3746
|
+
return `commit ${e.id} ${ON} ${e.branch}${e.copy === void 0 ? "" : ` ${COPY} ${e.copy}`}${e.merge === void 0 ? "" : ` ${MERGE} ${e.merge}`}${attrs([
|
|
3747
|
+
["hash", e.hash],
|
|
3748
|
+
["note", e.note]
|
|
3749
|
+
])}`;
|
|
3750
|
+
case "branch":
|
|
3751
|
+
return `${e.branch} ${FROM} ${e.from}`;
|
|
2919
3752
|
}
|
|
2920
3753
|
}
|
|
2921
3754
|
function declarations(diagram) {
|
|
@@ -2951,14 +3784,15 @@ end`);
|
|
|
2951
3784
|
return blocks;
|
|
2952
3785
|
}
|
|
2953
3786
|
function printNotation(diagram) {
|
|
2954
|
-
const
|
|
3787
|
+
const branches = (diagram.git?.branches ?? []).map((b) => `branch ${b.id}${attrs([["note", b.note]])}`);
|
|
3788
|
+
const blocks = [`${diagram.kind} ${name(diagram.title)}${attrs([["view", diagram.view]])}`, ...branches.length > 0 ? [branches.join("\n")] : [], ...declarations(diagram)];
|
|
2955
3789
|
if (diagram.strip) blocks.push(`strip ${key(diagram.strip.title)}: ${diagram.strip.fields.map(field).join(", ")}`);
|
|
2956
3790
|
if (diagram.state) blocks.push(diagram.state.paths.map((p) => line(p.from, p.to, p.label)).join("\n"));
|
|
2957
3791
|
for (const step of diagram.steps) {
|
|
2958
3792
|
const body = step.body.split("\n");
|
|
2959
3793
|
const say = body.length === 1 ? [` say ${step.body}`] : [" say", ...body.map((line2) => line2 === "" ? "" : ` ${line2}`)];
|
|
2960
3794
|
blocks.push(
|
|
2961
|
-
[`step ${step.title}`, ...say, ...step.code === void 0 ? [] : [` code ${step.code}`], ...step.events.map((e) => ` ${event(e)}`)].join("\n")
|
|
3795
|
+
[`step ${step.title}`, ...say, ...step.code === void 0 ? [] : [` code ${step.code}`], ...step.events.map((e) => ` ${event(e, diagram.kind === "git")}`)].join("\n")
|
|
2962
3796
|
);
|
|
2963
3797
|
}
|
|
2964
3798
|
return `${blocks.join("\n\n")}
|
|
@@ -3224,7 +4058,11 @@ var TYPE = {
|
|
|
3224
4058
|
stepTitle: text(15, 700),
|
|
3225
4059
|
stepBody: text(13.5, 500),
|
|
3226
4060
|
stepNo: text(13, 700, "mono"),
|
|
3227
|
-
button: text(14, 700)
|
|
4061
|
+
button: text(14, 700),
|
|
4062
|
+
/** 枝分かれの図 (#3164) の、丸の中の commit の名札と、丸の外に添える hash と一言 */
|
|
4063
|
+
gitId: text(11, 700),
|
|
4064
|
+
gitHash: text(10.5, 600, "mono"),
|
|
4065
|
+
gitNote: text(10.5, 650)
|
|
3228
4066
|
};
|
|
3229
4067
|
var LOOK = {
|
|
3230
4068
|
/** 部品どうしの最小の隙間 */
|
|
@@ -3234,7 +4072,11 @@ var LOOK = {
|
|
|
3234
4072
|
box: { h: 72, minW: 92, padX: 12, radius: 12, icon: 24, iconRadius: 7, iconY: -16, iconScale: 0.74, nameY: 12, subY: 27 },
|
|
3235
4073
|
region: { pad: 18, gap: 10, radius: 14, inset: 14, icon: 24, iconRadius: 7, iconScale: 0.68, nameY: 58, line: 16, minH: 108 },
|
|
3236
4074
|
architecture: { columns: 4, columnGap: 56, maxColumnGap: 160, rowGap: 44, labelRoom: 16 },
|
|
3237
|
-
|
|
4075
|
+
/**
|
|
4076
|
+
* 時系列図。線の名前の札は、構成図と状態遷移図より線に寄せる (`labelOffset` は線から札の真ん中まで)。
|
|
4077
|
+
* 札と線の離れが図の他の空きと同じ 6 になり、行を詰めても札がどの線の名前かが分かる (#3177)。
|
|
4078
|
+
*/
|
|
4079
|
+
sequence: { columnGap: 40, labelRoom: 16, labelOffset: 16, firstRow: 10, rowGap: 6, stepGap: 6, minPitch: 32, tail: 10, selfW: 34, selfH: 18 },
|
|
3238
4080
|
/**
|
|
3239
4081
|
* 状態遷移図 (#3163)。状態は `columns` つずつ並べて次の段へ折り返し、段の間 (`rowGap`) の真ん中を、段をまたぐ線が通る。
|
|
3240
4082
|
* `start` と `end` は始まりと終わりの印の半径と、印の中の丸の半径。`drop` は最初の状態の上端から始まりの印の中心まで、
|
|
@@ -3264,17 +4106,62 @@ var LOOK = {
|
|
|
3264
4106
|
done: { r: 6.5, inset: 13 },
|
|
3265
4107
|
pastLabel: 0.85
|
|
3266
4108
|
},
|
|
4109
|
+
/**
|
|
4110
|
+
* 枝分かれの図 (#3164)。見本帳の試作 (`scenes/git.js`) の寸法を写す。
|
|
4111
|
+
* commit は列ごとに `pitch` ずつ右へ並べ、一番上でない帯の commit は列の半分だけ右へずらす。`x0` は最初の列の真ん中の x の下限、
|
|
4112
|
+
* `textGap` は隣の列の hash と一言の間に空ける最小の隙間。`r` は丸の半径、`orphan` はどの札からも辿れなくなった commit の点線の丸の半径。
|
|
4113
|
+
* `topLine` と `line` は帯の上端から丸を並べる線まで (一番上の帯と、それより下の帯)、`topBelow` と `below` は線から帯の下端まで。
|
|
4114
|
+
* `bare` は線の名前を下に置かない帯の、線から帯の下端まで。
|
|
4115
|
+
* hash と一言は一番上の帯では丸の上に、ほかの帯では丸の下に置き、`above` と `under` は丸の真ん中から丸に近い行の基準線まで、`lineStep` は行の間。
|
|
4116
|
+
* 札は丸の上に段を重ねて置き、`tagTop` と `tag` は丸の真ん中から 1 段目の札の真ん中まで (一番上の帯と、ほかの帯)、`row` は札の段の間。
|
|
4117
|
+
* 札の段が 2 段より多い commit がある帯は、多い段の分だけ線を下げる。
|
|
4118
|
+
* `turn` は枝へ分かれる線と枝から入る線が曲がり終えて横へ進むまでの長さ、`samples` は曲がりを区切る点の数、`boxGap` は commit の並びと箱の間。
|
|
4119
|
+
* `labelUnder` はほかの帯で、丸の真ん中から線の名前の札の上端まで。`colors` は帯の色を上から配る順
|
|
4120
|
+
*/
|
|
4121
|
+
git: {
|
|
4122
|
+
x0: 120,
|
|
4123
|
+
pitch: 90,
|
|
4124
|
+
textGap: 12,
|
|
4125
|
+
r: 12,
|
|
4126
|
+
orphan: 13.5,
|
|
4127
|
+
topLine: 120,
|
|
4128
|
+
line: 90,
|
|
4129
|
+
topBelow: 30,
|
|
4130
|
+
below: 82,
|
|
4131
|
+
bare: 62,
|
|
4132
|
+
above: 18,
|
|
4133
|
+
under: 27,
|
|
4134
|
+
lineStep: 13,
|
|
4135
|
+
tagTop: 58,
|
|
4136
|
+
tag: 30,
|
|
4137
|
+
row: 22,
|
|
4138
|
+
turn: 60,
|
|
4139
|
+
samples: 12,
|
|
4140
|
+
boxGap: 24,
|
|
4141
|
+
labelUnder: 50,
|
|
4142
|
+
colors: ["blue", "violet", "green", "amber", "rose"]
|
|
4143
|
+
},
|
|
3267
4144
|
/** `bend` は線の曲がりを丸める半径 (#3171) */
|
|
3268
4145
|
edge: { inset: 3, arrow: 6, arrowHalf: 3.5, parallel: 5, ghostDash: 5, flowDash: 9, bend: 12 },
|
|
3269
|
-
|
|
4146
|
+
/** `touch` は線の名前と、同じ時刻に見えている段の番号の丸の間に空ける最小の隙間 (#3175) */
|
|
4147
|
+
label: { h: 20, padX: 9, radius: 10, offset: 22, side: 14, search: 4, searchMax: 400, soft: 6, touch: 2 },
|
|
3270
4148
|
action: { h: 22, padX: 10, radius: 11 },
|
|
3271
4149
|
badge: { r: 9.5, ring: 9, inset: 4, along: 14, short: 44 },
|
|
3272
4150
|
carrier: { envW: 24, envH: 17, coinR: 6.5, coinIn: 3.8, tagH: 18, tagPadX: 8, samples: 16 },
|
|
4151
|
+
/**
|
|
4152
|
+
* 運ぶ物の置き場 (#3176)。運ぶ物を出し入れする箱は、絵柄の右に点線の枠を持ち、運ぶ物は着いた後と走り出す前にそこで待つ。
|
|
4153
|
+
* `gap` は絵柄と枠の間、`pad` は枠と運ぶ物の間、`spread` は枠の中に横に並べた運ぶ物の間、`h` と `radius` は枠の高さと角の丸み。
|
|
4154
|
+
* `clear` は状態遷移図の右上の済んだ印と枠の間に空ける最小の隙間。`lifeline` は時系列図で生存線と運ぶ物の間、
|
|
4155
|
+
* `mark` は状態遷移図の始まりの印と、その左で走り出しを待つ運ぶ物の間
|
|
4156
|
+
*/
|
|
4157
|
+
slot: { gap: 6, pad: 3, spread: 4, h: 24, radius: 7, clear: 2, lifeline: 5, mark: 4 },
|
|
4158
|
+
/** 編集画面が重なる字を囲む点線の四角 (#3178)。`pad` は字の四角の外へ広げる幅、`dash` と `gap` は点線の線と隙間の長さ */
|
|
4159
|
+
mark: { pad: 3, radius: 5, dash: 4, gap: 3 },
|
|
3273
4160
|
/**
|
|
3274
4161
|
* `trail` は状態遷移図の帯の最後の、通った状態の点 (#3171)。`r` は点の半径、`step` は点の中心どうしの間、`now` は変わった値の欄の名前の横の点の半径と、名前からの離れ
|
|
3275
4162
|
*/
|
|
3276
4163
|
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 },
|
|
4164
|
+
stroke: { git: 2.25, gitOrphan: 1.5, mark: 1.6, slot: 1.2, 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 },
|
|
3278
4165
|
shadow: { near: 0.8, far: 4, nearY: 1, farY: 3 },
|
|
3279
4166
|
mini: { w: 168, pad: 8, title: 14, inset: 12, radius: 10 },
|
|
3280
4167
|
/**
|
|
@@ -3288,7 +4175,7 @@ var LOOK = {
|
|
|
3288
4175
|
*/
|
|
3289
4176
|
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 } },
|
|
3290
4177
|
/** 色を混ぜる割合 (%) */
|
|
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 },
|
|
4178
|
+
mix: { slot: 45, 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 },
|
|
3292
4179
|
/** 字の並びの基準線を、置きたい高さの真ん中からどれだけ下げるか */
|
|
3293
4180
|
baseline: { label: 3.8, badge: 3.5, carrier: 3.7, stripTitle: 4.5, tag: 3.6, action: 3.8, mark: 4 },
|
|
3294
4181
|
/** 浮いて出る物が下から上がる長さと、弾んで出る物の始まりの大きさ */
|
|
@@ -3343,6 +4230,8 @@ var EASE = {
|
|
|
3343
4230
|
};
|
|
3344
4231
|
|
|
3345
4232
|
// src/figure-text.ts
|
|
4233
|
+
var spaced = (word) => /[0-9A-Za-z]$/u.test(word) ? `${word} ` : word;
|
|
4234
|
+
var capital = (text2) => text2.charAt(0).toUpperCase() + text2.slice(1);
|
|
3346
4235
|
var FIGURE_TEXT = {
|
|
3347
4236
|
ja: {
|
|
3348
4237
|
cannotDraw: (detail) => `\u56F3\u3092\u63CF\u3051\u306A\u3044: ${detail}`,
|
|
@@ -3357,7 +4246,14 @@ var FIGURE_TEXT = {
|
|
|
3357
4246
|
sideFrom: (count) => `${count} \u3064\u306E\u72B6\u614B\u304B\u3089\u5165\u308C\u308B`,
|
|
3358
4247
|
trail: "\u901A\u3063\u305F\u72B6\u614B",
|
|
3359
4248
|
start: "\u59CB\u307E\u308A",
|
|
3360
|
-
end: "\u7D42\u308F\u308A"
|
|
4249
|
+
end: "\u7D42\u308F\u308A",
|
|
4250
|
+
badgeName: (no) => `\u6BB5\u306E\u756A\u53F7 ${no}`,
|
|
4251
|
+
quoted: (text2) => `\u300C${text2}\u300D`,
|
|
4252
|
+
iconOf: (box) => `\u300C${box} \u306E\u7D75\u67C4\u300D`,
|
|
4253
|
+
coin: "\u300C\u786C\u8CA8\u300D",
|
|
4254
|
+
envelope: "\u300C\u5C01\u7B52\u300D",
|
|
4255
|
+
textsOverlap: (a, b) => `${spaced(a)}\u3068${spaced(b)}\u304C\u91CD\u306A\u308B`,
|
|
4256
|
+
lineCrosses: (from, to, text2) => `\u7DDA ${from} \u2192 ${to} \u304C${spaced(text2)}\u3092\u6A2A\u5207\u308B`
|
|
3361
4257
|
},
|
|
3362
4258
|
en: {
|
|
3363
4259
|
cannotDraw: (detail) => `Cannot draw the diagram: ${detail}`,
|
|
@@ -3372,7 +4268,14 @@ var FIGURE_TEXT = {
|
|
|
3372
4268
|
sideFrom: (count) => `Enterable from ${count} ${count === 1 ? "state" : "states"}`,
|
|
3373
4269
|
trail: "States passed",
|
|
3374
4270
|
start: "Start",
|
|
3375
|
-
end: "End"
|
|
4271
|
+
end: "End",
|
|
4272
|
+
badgeName: (no) => `step number ${no}`,
|
|
4273
|
+
quoted: (text2) => `"${text2}"`,
|
|
4274
|
+
iconOf: (box) => `the icon of "${box}"`,
|
|
4275
|
+
coin: "the coin",
|
|
4276
|
+
envelope: "the envelope",
|
|
4277
|
+
textsOverlap: (a, b) => capital(`${a} and ${b} overlap`),
|
|
4278
|
+
lineCrosses: (from, to, text2) => `The line ${from} \u2192 ${to} crosses ${text2}`
|
|
3376
4279
|
}
|
|
3377
4280
|
};
|
|
3378
4281
|
|
|
@@ -3387,6 +4290,10 @@ function textWidth(text2, style) {
|
|
|
3387
4290
|
for (const ch of text2) sum += advance(ch, family);
|
|
3388
4291
|
return sum * style.size / EM;
|
|
3389
4292
|
}
|
|
4293
|
+
function textBox(text2, x, y, style, anchor = "start") {
|
|
4294
|
+
const w = textWidth(text2, style);
|
|
4295
|
+
return { x: anchor === "middle" ? x - w / 2 : x, y: y - style.size * 0.8, w, h: style.size };
|
|
4296
|
+
}
|
|
3390
4297
|
|
|
3391
4298
|
// src/layout/scene.ts
|
|
3392
4299
|
function edgesOf(diagram) {
|
|
@@ -3421,11 +4328,93 @@ function boxWidth(diagram, id, withActions) {
|
|
|
3421
4328
|
}
|
|
3422
4329
|
return Math.max(LOOK.box.minW, Math.max(...lines) + LOOK.box.padX * 2);
|
|
3423
4330
|
}
|
|
4331
|
+
function carrierHalf(carry) {
|
|
4332
|
+
const C = LOOK.carrier;
|
|
4333
|
+
if (carry.kind === "tag") return [(textWidth(carry.text, hasWide(carry.text) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2) / 2, C.tagH / 2];
|
|
4334
|
+
if (carry.kind === "coin") return [C.coinR, C.coinR];
|
|
4335
|
+
return [C.envW / 2, C.envH / 2];
|
|
4336
|
+
}
|
|
4337
|
+
var roomWidth = (room) => room.main + room.coin + (room.main > 0 && room.coin > 0 ? LOOK.slot.spread : 0);
|
|
4338
|
+
function slotRooms(diagram) {
|
|
4339
|
+
const rooms = /* @__PURE__ */ new Map();
|
|
4340
|
+
const ids = new Set(diagram.boxes.map((b) => b.id));
|
|
4341
|
+
for (const step of diagram.steps) {
|
|
4342
|
+
for (const event2 of step.events) {
|
|
4343
|
+
if (event2.type !== "edge" || event2.carry.kind === "none") continue;
|
|
4344
|
+
const who = event2.carry.kind === "coin" ? "coin" : "main";
|
|
4345
|
+
const w = carrierHalf(event2.carry)[0] * 2;
|
|
4346
|
+
for (const id of [event2.from, event2.to]) {
|
|
4347
|
+
if (!ids.has(id)) continue;
|
|
4348
|
+
const room = rooms.get(id) ?? { main: 0, coin: 0 };
|
|
4349
|
+
room[who] = Math.max(room[who], w);
|
|
4350
|
+
rooms.set(id, room);
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
return rooms;
|
|
4355
|
+
}
|
|
4356
|
+
function slotBoxWidth(room, icon, right) {
|
|
4357
|
+
if (!room) return 0;
|
|
4358
|
+
return (icon ? LOOK.box.icon + LOOK.slot.gap : 0) + roomWidth(room) + LOOK.slot.pad * 2 + LOOK.box.padX + right;
|
|
4359
|
+
}
|
|
4360
|
+
function placeSlot(box, room, right = LOOK.box.padX) {
|
|
4361
|
+
if (!room) return;
|
|
4362
|
+
const B = LOOK.box;
|
|
4363
|
+
const S2 = LOOK.slot;
|
|
4364
|
+
const w = roomWidth(room) + S2.pad * 2;
|
|
4365
|
+
const lead = box.icon ? B.icon + S2.gap : 0;
|
|
4366
|
+
const left = Math.max(box.x + B.padX, Math.min(box.cx - (lead + w) / 2, box.x + box.w - right - (lead + w)));
|
|
4367
|
+
if (box.icon) box.iconX = left + B.icon / 2;
|
|
4368
|
+
box.slot = { x: left + lead, y: box.cy + B.iconY - S2.h / 2, w, h: S2.h };
|
|
4369
|
+
}
|
|
4370
|
+
function seatCarriers(edges, boxes, rooms) {
|
|
4371
|
+
const S2 = LOOK.slot;
|
|
4372
|
+
const seat = (id, carry) => {
|
|
4373
|
+
const box = boxes.get(id);
|
|
4374
|
+
const room = rooms.get(id);
|
|
4375
|
+
if (!box?.slot || !room) return void 0;
|
|
4376
|
+
const inner = box.slot.x + S2.pad;
|
|
4377
|
+
const y = box.slot.y + box.slot.h / 2;
|
|
4378
|
+
if (room.main > 0 && room.coin > 0) return carry.kind === "coin" ? [inner + room.main + S2.spread + room.coin / 2, y] : [inner + room.main / 2, y];
|
|
4379
|
+
return [box.slot.x + box.slot.w / 2, y];
|
|
4380
|
+
};
|
|
4381
|
+
for (const edge2 of edges) {
|
|
4382
|
+
if (edge2.carry.kind === "none") continue;
|
|
4383
|
+
const settle = seat(edge2.to, edge2.carry);
|
|
4384
|
+
const wait = seat(edge2.from, edge2.carry);
|
|
4385
|
+
if (settle) edge2.settle = settle;
|
|
4386
|
+
if (wait) edge2.wait = wait;
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
3424
4389
|
function gapBetween(a, b) {
|
|
3425
4390
|
const dx = Math.max(b.x - (a.x + a.w), a.x - (b.x + b.w));
|
|
3426
4391
|
const dy = Math.max(b.y - (a.y + a.h), a.y - (b.y + b.h));
|
|
3427
4392
|
return Math.max(dx, dy);
|
|
3428
4393
|
}
|
|
4394
|
+
function crossesRect(points, rect, inset = 0) {
|
|
4395
|
+
const x0 = rect.x + inset;
|
|
4396
|
+
const y0 = rect.y + inset;
|
|
4397
|
+
const x1 = rect.x + rect.w - inset;
|
|
4398
|
+
const y1 = rect.y + rect.h - inset;
|
|
4399
|
+
if (x1 <= x0 || y1 <= y0) return false;
|
|
4400
|
+
for (let i = 1; i < points.length; i++) {
|
|
4401
|
+
const [ax, ay] = points[i - 1];
|
|
4402
|
+
const [bx, by] = points[i];
|
|
4403
|
+
const dx = bx - ax;
|
|
4404
|
+
const dy = by - ay;
|
|
4405
|
+
let lo = 0;
|
|
4406
|
+
let hi = 1;
|
|
4407
|
+
const cut = (p, q) => {
|
|
4408
|
+
if (p === 0) return q > 0;
|
|
4409
|
+
const r = q / p;
|
|
4410
|
+
if (p < 0) lo = Math.max(lo, r);
|
|
4411
|
+
else hi = Math.min(hi, r);
|
|
4412
|
+
return lo < hi;
|
|
4413
|
+
};
|
|
4414
|
+
if (cut(-dx, ax - x0) && cut(dx, x1 - ax) && cut(-dy, ay - y0) && cut(dy, y1 - ay)) return true;
|
|
4415
|
+
}
|
|
4416
|
+
return false;
|
|
4417
|
+
}
|
|
3429
4418
|
function longest(points) {
|
|
3430
4419
|
let best = { a: points[0], b: points[1] ?? points[0], length: -1 };
|
|
3431
4420
|
for (let i = 1; i < points.length; i++) {
|
|
@@ -3456,34 +4445,122 @@ function pathLength(points) {
|
|
|
3456
4445
|
}
|
|
3457
4446
|
return sum;
|
|
3458
4447
|
}
|
|
3459
|
-
function
|
|
4448
|
+
function loopUnder(box) {
|
|
4449
|
+
const { w, h, samples } = LOOK.state.loop;
|
|
4450
|
+
const bottom = box.y + box.h;
|
|
4451
|
+
const p0 = [box.cx + w / 2, bottom];
|
|
4452
|
+
const c1 = [box.cx + w * 3 / 4, bottom + h * 4 / 3];
|
|
4453
|
+
const c2 = [box.cx - w * 3 / 4, bottom + h * 4 / 3];
|
|
4454
|
+
const p3 = [box.cx - w / 2, bottom + LOOK.edge.inset];
|
|
4455
|
+
return Array.from({ length: samples + 1 }, (_, k) => {
|
|
4456
|
+
const t = k / samples;
|
|
4457
|
+
const u = 1 - t;
|
|
4458
|
+
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];
|
|
4459
|
+
return [at(0), at(1)];
|
|
4460
|
+
});
|
|
4461
|
+
}
|
|
4462
|
+
function loopBadge(points) {
|
|
4463
|
+
const right = Math.max(...points.map(([px2]) => px2));
|
|
4464
|
+
const top = points[0][1];
|
|
4465
|
+
const deep = Math.max(...points.map(([, py]) => py));
|
|
4466
|
+
return [right + LOOK.badge.r + LOOK.badge.inset, top + (deep - top) * LOOK.state.loop.badgeAt];
|
|
4467
|
+
}
|
|
4468
|
+
function loopLabelBase(points, w) {
|
|
4469
|
+
return { x: (points[0]?.[0] ?? 0) - LOOK.state.loop.w / 2 - w / 2, y: Math.max(...points.map(([, y]) => y)) + LOOK.label.soft };
|
|
4470
|
+
}
|
|
4471
|
+
var LOOP_ROOM = LOOK.state.loop.h + LOOK.label.soft * 2 + LOOK.label.h;
|
|
4472
|
+
function badgeOnPath(points, taken = [], lines = []) {
|
|
4473
|
+
const length = pathLength(points);
|
|
4474
|
+
const first = length < LOOK.badge.short ? Math.min(LOOK.badge.r + 1, length / 2) : LOOK.badge.along;
|
|
4475
|
+
const apart = LOOK.badge.r * 2 + LOOK.badge.inset;
|
|
4476
|
+
for (let d = first; d <= length; d += 1) {
|
|
4477
|
+
const p = along(points, d);
|
|
4478
|
+
if (taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart)) return p;
|
|
4479
|
+
}
|
|
4480
|
+
return besideLine(points, first, taken, lines) ?? along(points, first);
|
|
4481
|
+
}
|
|
4482
|
+
function besideLine(points, at, taken, lines) {
|
|
3460
4483
|
const length = pathLength(points);
|
|
3461
|
-
|
|
4484
|
+
const [px2, py] = along(points, at);
|
|
4485
|
+
const [ax, ay] = along(points, Math.max(0, at - 1));
|
|
4486
|
+
const [bx, by] = along(points, Math.min(length, at + 1));
|
|
4487
|
+
const n = Math.hypot(bx - ax, by - ay);
|
|
4488
|
+
if (n === 0) return void 0;
|
|
4489
|
+
const [nx, ny] = [-(by - ay) / n, (bx - ax) / n];
|
|
4490
|
+
const size = LOOK.badge.r * 2;
|
|
4491
|
+
for (const margin of [LOOK.edge.arrowHalf, 0]) {
|
|
4492
|
+
for (let s = 1; s <= size + LOOK.badge.inset; s++) {
|
|
4493
|
+
for (const sign of [1, -1]) {
|
|
4494
|
+
const c = [px2 + nx * s * sign, py + ny * s * sign];
|
|
4495
|
+
const free = taken.every(([x, y]) => Math.max(Math.abs(c[0] - x), Math.abs(c[1] - y)) >= size + 1);
|
|
4496
|
+
if (free && lines.every((line2) => !crossesRect(line2, badgeRect(c), -margin))) return c;
|
|
4497
|
+
}
|
|
4498
|
+
}
|
|
4499
|
+
}
|
|
4500
|
+
return void 0;
|
|
4501
|
+
}
|
|
4502
|
+
var lineKey = (edge2) => edge2.points.map(([x, y]) => `${Math.round(x * 10)},${Math.round(y * 10)}`).join(" ");
|
|
4503
|
+
function lineBadges(edges, steps, at = (edge2, taken, lines) => badgeOnPath(edge2.points, taken, lines)) {
|
|
4504
|
+
const out = /* @__PURE__ */ new Map();
|
|
4505
|
+
const taken = [];
|
|
4506
|
+
const placed = /* @__PURE__ */ new Map();
|
|
4507
|
+
for (let s = 0; s < steps; s++) {
|
|
4508
|
+
const edge2 = edges.find((e) => e.step === s && e.points.length > 0);
|
|
4509
|
+
if (!edge2) continue;
|
|
4510
|
+
const key2 = lineKey(edge2);
|
|
4511
|
+
const before = placed.get(key2);
|
|
4512
|
+
if (before) {
|
|
4513
|
+
out.set(s, { point: before, edge: edge2 });
|
|
4514
|
+
continue;
|
|
4515
|
+
}
|
|
4516
|
+
const lines = edges.filter((e) => e.points.length > 1 && lineKey(e) !== key2).map((e) => e.points);
|
|
4517
|
+
const point = at(edge2, taken, lines);
|
|
4518
|
+
taken.push(point);
|
|
4519
|
+
placed.set(key2, point);
|
|
4520
|
+
out.set(s, { point, edge: edge2 });
|
|
4521
|
+
}
|
|
4522
|
+
return out;
|
|
4523
|
+
}
|
|
4524
|
+
function replaceSameSpot(badges2) {
|
|
4525
|
+
const same2 = (a, b) => Math.hypot(a.x - b.x, a.y - b.y) <= 0.5;
|
|
4526
|
+
return badges2.map((badge2) => {
|
|
4527
|
+
const next = badges2.filter((other) => other.step > badge2.step && same2(other, badge2)).sort((a, b) => a.step - b.step)[0];
|
|
4528
|
+
return next ? { ...badge2, until: next.step } : badge2;
|
|
4529
|
+
});
|
|
3462
4530
|
}
|
|
4531
|
+
var badgeRect = ([x, y]) => ({ x: x - LOOK.badge.r, y: y - LOOK.badge.r, w: LOOK.badge.r * 2, h: LOOK.badge.r * 2 });
|
|
4532
|
+
var markText = (e) => [e.x + LOOK.state.text, e.y + LOOK.baseline.mark];
|
|
3463
4533
|
var labelStyle = (text2) => hasWide(text2) ? TYPE.labelJa : TYPE.label;
|
|
4534
|
+
var OPPOSITE = { above: "below", below: "above", left: "right", right: "left" };
|
|
3464
4535
|
function placeLabel(request, obstacles) {
|
|
3465
4536
|
const w = textWidth(request.text, labelStyle(request.text)) + LOOK.label.padX * 2;
|
|
3466
4537
|
const h = LOOK.label.h;
|
|
3467
4538
|
const segment = longest(request.points);
|
|
3468
4539
|
const mx = (segment.a[0] + segment.b[0]) / 2;
|
|
3469
4540
|
const my = (segment.a[1] + segment.b[1]) / 2;
|
|
3470
|
-
const
|
|
3471
|
-
const {
|
|
3472
|
-
const
|
|
3473
|
-
const
|
|
3474
|
-
const
|
|
3475
|
-
const
|
|
3476
|
-
const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft);
|
|
4541
|
+
const preferred = request.side ?? (segment.vertical ? "right" : "above");
|
|
4542
|
+
const { side: sideGap } = LOOK.label;
|
|
4543
|
+
const offset = request.offset ?? LOOK.label.offset;
|
|
4544
|
+
const baseOf = (side2) => 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 };
|
|
4545
|
+
const first = request.base ? { ...request.base, w, h } : baseOf(preferred);
|
|
4546
|
+
const sides = request.flip ? [preferred, OPPOSITE[preferred]] : [preferred];
|
|
4547
|
+
const clear = (rect) => obstacles.hard.every((box) => gapBetween(rect, box) >= LOOK.gap) && obstacles.soft.every((other) => gapBetween(rect, other) >= LOOK.label.soft) && (obstacles.touch ?? []).every((mark) => gapBetween(rect, mark) >= LOOK.label.touch) && (obstacles.lines ?? []).every((line2) => !crossesRect(line2, rect, -2));
|
|
3477
4548
|
const { search, searchMax } = LOOK.label;
|
|
3478
4549
|
for (let d = 0; d <= searchMax; d += search) {
|
|
3479
|
-
for (
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
4550
|
+
for (const side2 of sides) {
|
|
4551
|
+
const base = side2 === preferred ? first : baseOf(side2);
|
|
4552
|
+
const away = side2 === "above" ? [0, -1] : side2 === "below" ? [0, 1] : side2 === "left" ? [-1, 0] : [1, 0];
|
|
4553
|
+
const slideAxis = [Math.abs(away[1]), Math.abs(away[0])];
|
|
4554
|
+
const slideMax = request.slide ?? (side2 === "above" || side2 === "below" ? w : h * 4);
|
|
4555
|
+
for (let s = 0; s <= slideMax; s += search) {
|
|
4556
|
+
for (const sign of s === 0 ? [1] : [1, -1]) {
|
|
4557
|
+
const rect = { x: base.x + away[0] * d + slideAxis[0] * s * sign, y: base.y + away[1] * d + slideAxis[1] * s * sign, w, h };
|
|
4558
|
+
if (clear(rect)) return { ...rect, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
|
|
4559
|
+
}
|
|
3483
4560
|
}
|
|
3484
4561
|
}
|
|
3485
4562
|
}
|
|
3486
|
-
return { ...
|
|
4563
|
+
return { ...first, step: request.step, event: request.event, text: request.text, family: labelStyle(request.text).family, color: request.color };
|
|
3487
4564
|
}
|
|
3488
4565
|
function fieldWidth(diagram, name2) {
|
|
3489
4566
|
let value2 = 0;
|
|
@@ -3538,6 +4615,8 @@ function shiftContent(layout, dx, dy) {
|
|
|
3538
4615
|
move(box);
|
|
3539
4616
|
box.cx += dx;
|
|
3540
4617
|
box.cy += dy;
|
|
4618
|
+
if (box.slot) move(box.slot);
|
|
4619
|
+
if (box.iconX !== void 0) box.iconX += dx;
|
|
3541
4620
|
}
|
|
3542
4621
|
for (const region of layout.regions) {
|
|
3543
4622
|
region.y += dy;
|
|
@@ -3551,6 +4630,7 @@ function shiftContent(layout, dx, dy) {
|
|
|
3551
4630
|
for (const edge2 of layout.edges) {
|
|
3552
4631
|
edge2.points = edge2.points.map(([px2, py]) => [px2 + dx, py + dy]);
|
|
3553
4632
|
if (edge2.settle) edge2.settle = [edge2.settle[0] + dx, edge2.settle[1] + dy];
|
|
4633
|
+
if (edge2.wait) edge2.wait = [edge2.wait[0] + dx, edge2.wait[1] + dy];
|
|
3554
4634
|
}
|
|
3555
4635
|
for (const label2 of layout.labels) move(label2);
|
|
3556
4636
|
for (const path2 of layout.paths) {
|
|
@@ -3584,11 +4664,11 @@ function cornerBadge(events, step, layout) {
|
|
|
3584
4664
|
for (const event2 of events) {
|
|
3585
4665
|
const id = event2.type === "swap" || event2.type === "action" ? event2.box : void 0;
|
|
3586
4666
|
const box2 = layout.boxes.find((b) => b.id === id);
|
|
3587
|
-
if (box2) return { step, x: box2.x
|
|
4667
|
+
if (box2) return { step, x: box2.x, y: box2.y, color: box2.color };
|
|
3588
4668
|
}
|
|
3589
4669
|
if (layout.strip && events.some((event2) => event2.type === "strip")) return { step, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" };
|
|
3590
4670
|
const box = layout.boxes[0];
|
|
3591
|
-
return { step, x: box.x
|
|
4671
|
+
return { step, x: box.x, y: box.y, color: box.color };
|
|
3592
4672
|
}
|
|
3593
4673
|
|
|
3594
4674
|
// src/layout/architecture.ts
|
|
@@ -3687,7 +4767,8 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3687
4767
|
const regionColor = regionColors(diagram);
|
|
3688
4768
|
const edges = edgesOf(diagram);
|
|
3689
4769
|
const columnCount = Math.max(1, ...[...slots.values()].map((s) => s.col + 1));
|
|
3690
|
-
const
|
|
4770
|
+
const carriedIn = slotRooms(diagram);
|
|
4771
|
+
const widths = new Map(diagram.boxes.map((b) => [b.id, Math.max(boxWidth(diagram, b.id, true), slotBoxWidth(carriedIn.get(b.id), b.icon !== void 0, B.padX))]));
|
|
3691
4772
|
const colW = Array.from({ length: columnCount }, (_, c) => Math.max(B.minW, ...[...slots].filter(([, s]) => s.col === c).map(([id]) => widths.get(id) ?? B.minW)));
|
|
3692
4773
|
const between = Array.from({ length: Math.max(0, columnCount - 1) }, () => A.columnGap);
|
|
3693
4774
|
for (const { edge: edge2 } of edges) {
|
|
@@ -3702,7 +4783,13 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3702
4783
|
const headerW = Math.max(0, ...headers.map((h) => h ? h.w + R.inset * 2 : 0));
|
|
3703
4784
|
const colLeft = [];
|
|
3704
4785
|
for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin + (headerW > 0 ? headerW : R.pad) : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
|
|
3705
|
-
const
|
|
4786
|
+
const center2 = (c) => colLeft[c] + colW[c] / 2;
|
|
4787
|
+
const looped = new Set(edges.filter(({ edge: edge2 }) => edge2.from === edge2.to).map(({ edge: edge2 }) => edge2.from));
|
|
4788
|
+
const loopRows = new Set([...looped].flatMap((id) => {
|
|
4789
|
+
const slot = slots.get(id);
|
|
4790
|
+
return slot ? [`${slot.group}:${slot.row}`] : [];
|
|
4791
|
+
}));
|
|
4792
|
+
const loopRoom = (g, row) => loopRows.has(`${g}:${row}`) ? LOOP_ROOM : 0;
|
|
3706
4793
|
const boxes = [];
|
|
3707
4794
|
const bands = [];
|
|
3708
4795
|
let cursor = margin;
|
|
@@ -3710,12 +4797,14 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3710
4797
|
const rows = Math.max(1, ...group.members.map((id) => (slots.get(id)?.row ?? 0) + 1));
|
|
3711
4798
|
const room = rooms[g];
|
|
3712
4799
|
const top = cursor + R.pad + room.top;
|
|
4800
|
+
const rowTop = [0];
|
|
4801
|
+
for (let r = 1; r < rows; r++) rowTop.push(rowTop[r - 1] + B.h + A.rowGap + loopRoom(g, r - 1));
|
|
3713
4802
|
for (const id of group.members) {
|
|
3714
4803
|
const slot = slots.get(id);
|
|
3715
4804
|
const source = diagram.boxes.find((b) => b.id === id);
|
|
3716
4805
|
const w = widths.get(id) ?? B.minW;
|
|
3717
|
-
const cx =
|
|
3718
|
-
const y = top + slot.row
|
|
4806
|
+
const cx = center2(slot.col);
|
|
4807
|
+
const y = top + rowTop[slot.row];
|
|
3719
4808
|
boxes.push({
|
|
3720
4809
|
id,
|
|
3721
4810
|
name: source?.name ?? id,
|
|
@@ -3730,29 +4819,36 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3730
4819
|
cy: y + B.h / 2
|
|
3731
4820
|
});
|
|
3732
4821
|
}
|
|
3733
|
-
const
|
|
4822
|
+
const contentBottom2 = top + rowTop[rows - 1] + B.h + loopRoom(g, rows - 1);
|
|
3734
4823
|
const header = headers[g];
|
|
3735
|
-
const h = Math.max(
|
|
4824
|
+
const h = Math.max(contentBottom2 + R.pad + room.bottom - cursor, header ? header.h + R.inset * 2 : 0, group.region ? R.minH : 0);
|
|
3736
4825
|
bands.push({ group: g, y: cursor, h, rows });
|
|
3737
4826
|
cursor += h + R.gap;
|
|
3738
4827
|
});
|
|
3739
4828
|
const bandsBottom = cursor - R.gap;
|
|
4829
|
+
for (const box of boxes) placeSlot(box, carriedIn.get(box.id));
|
|
3740
4830
|
const byId = new Map(boxes.map((b) => [b.id, b]));
|
|
3741
4831
|
const bandOf = (id) => bands[slots.get(id)?.group ?? 0];
|
|
3742
|
-
const
|
|
3743
|
-
if (box.id === a || box.id === b) return false;
|
|
3744
|
-
const pad2 = LOOK.label.search;
|
|
4832
|
+
const crosses = (points, rect, pad2) => {
|
|
3745
4833
|
for (let i = 1; i < points.length; i++) {
|
|
3746
4834
|
const [x1, y1] = points[i - 1];
|
|
3747
4835
|
const [x2, y2] = points[i];
|
|
3748
|
-
if (Math.min(x1, x2) <=
|
|
4836
|
+
if (Math.min(x1, x2) <= rect.x + rect.w + pad2 && Math.max(x1, x2) >= rect.x - pad2 && Math.min(y1, y2) <= rect.y + rect.h + pad2 && Math.max(y1, y2) >= rect.y - pad2) return true;
|
|
3749
4837
|
}
|
|
3750
4838
|
return false;
|
|
4839
|
+
};
|
|
4840
|
+
const loopZones = [...looped].flatMap((id) => {
|
|
4841
|
+
const box = byId.get(id);
|
|
4842
|
+
return box ? [{ x: box.x, y: box.y + box.h, w: box.w, h: LOOP_ROOM }] : [];
|
|
3751
4843
|
});
|
|
4844
|
+
const onLoop = (points) => loopZones.some((zone) => crosses(points, zone, 0));
|
|
4845
|
+
const blocked = (points, a, b) => boxes.some((box) => box.id !== a && box.id !== b && crosses(points, box, LOOK.label.search)) || onLoop(points);
|
|
3752
4846
|
const laneBelow = (id) => {
|
|
3753
4847
|
const box = byId.get(id);
|
|
3754
4848
|
const band2 = bandOf(id);
|
|
3755
|
-
|
|
4849
|
+
const slot = slots.get(id);
|
|
4850
|
+
const under = box.y + box.h + (slot ? loopRoom(slot.group, slot.row) : 0);
|
|
4851
|
+
return (slot?.row ?? 0) < band2.rows - 1 ? under + A.rowGap / 2 : Math.min(under + R.pad / 2, band2.y + band2.h - LOOK.edge.inset);
|
|
3756
4852
|
};
|
|
3757
4853
|
const laneAbove = (id) => {
|
|
3758
4854
|
const box = byId.get(id);
|
|
@@ -3760,9 +4856,11 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3760
4856
|
return (slots.get(id)?.row ?? 0) > 0 ? box.y - A.rowGap / 2 : Math.max(box.y - R.pad / 2, band2.y + LOOK.edge.inset);
|
|
3761
4857
|
};
|
|
3762
4858
|
const inset = LOOK.edge.inset;
|
|
4859
|
+
const gapX = (col, toRight) => toRight ? colLeft[col] + colW[col] + (between[col] ?? A.columnGap) / 2 : colLeft[col] - (between[col - 1] ?? A.columnGap) / 2;
|
|
3763
4860
|
const route = (from, to) => {
|
|
3764
4861
|
const a = byId.get(from);
|
|
3765
4862
|
const b = byId.get(to);
|
|
4863
|
+
if (from === to) return loopUnder(a);
|
|
3766
4864
|
const sa = slots.get(from);
|
|
3767
4865
|
const sb = slots.get(to);
|
|
3768
4866
|
if (sa.group === sb.group && sa.row === sb.row) {
|
|
@@ -3772,13 +4870,22 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3772
4870
|
[right2 ? b.x - inset : b.x + b.w + inset, b.cy]
|
|
3773
4871
|
];
|
|
3774
4872
|
if (!blocked(straight, from, to)) return straight;
|
|
3775
|
-
const
|
|
3776
|
-
|
|
4873
|
+
const below = laneBelow(from);
|
|
4874
|
+
const under = [
|
|
3777
4875
|
[a.cx, a.y + a.h],
|
|
3778
|
-
[a.cx,
|
|
3779
|
-
[b.cx,
|
|
4876
|
+
[a.cx, below],
|
|
4877
|
+
[b.cx, below],
|
|
3780
4878
|
[b.cx, b.y + b.h + inset]
|
|
3781
4879
|
];
|
|
4880
|
+
if (!onLoop(under)) return under;
|
|
4881
|
+
const above = laneAbove(from);
|
|
4882
|
+
const over = [
|
|
4883
|
+
[a.cx, a.y],
|
|
4884
|
+
[a.cx, above],
|
|
4885
|
+
[b.cx, above],
|
|
4886
|
+
[b.cx, b.y - inset]
|
|
4887
|
+
];
|
|
4888
|
+
return onLoop(over) ? under : over;
|
|
3782
4889
|
}
|
|
3783
4890
|
const down = b.cy > a.cy;
|
|
3784
4891
|
const leave = [a.cx, down ? a.y + a.h : a.y];
|
|
@@ -3786,7 +4893,7 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3786
4893
|
if (sa.col === sb.col) {
|
|
3787
4894
|
const straight = [leave, enter];
|
|
3788
4895
|
if (!blocked(straight, from, to)) return straight;
|
|
3789
|
-
const x =
|
|
4896
|
+
const x = gapX(sa.col, true);
|
|
3790
4897
|
return [
|
|
3791
4898
|
[a.x + a.w, a.cy],
|
|
3792
4899
|
[x, a.cy],
|
|
@@ -3801,21 +4908,34 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3801
4908
|
[[right ? a.x + a.w : a.x, a.cy], [b.cx, a.cy], enter],
|
|
3802
4909
|
[leave, [a.cx, lane], [b.cx, lane], enter]
|
|
3803
4910
|
];
|
|
4911
|
+
if (looped.has(from) || looped.has(to)) {
|
|
4912
|
+
const ax = gapX(sa.col, right);
|
|
4913
|
+
const bx = gapX(sb.col, !right);
|
|
4914
|
+
const out = [
|
|
4915
|
+
[right ? a.x + a.w : a.x, a.cy],
|
|
4916
|
+
[ax, a.cy]
|
|
4917
|
+
];
|
|
4918
|
+
const side2 = [right ? b.x - inset : b.x + b.w + inset, b.cy];
|
|
4919
|
+
candidates.push(
|
|
4920
|
+
[...out, [ax, b.cy], side2],
|
|
4921
|
+
[...out, [ax, lane], [b.cx, lane], enter],
|
|
4922
|
+
[leave, [a.cx, lane], [bx, lane], [bx, b.cy], side2],
|
|
4923
|
+
[...out, [ax, lane], [bx, lane], [bx, b.cy], side2]
|
|
4924
|
+
);
|
|
4925
|
+
}
|
|
3804
4926
|
return candidates.find((points) => !blocked(points, from, to)) ?? candidates[2];
|
|
3805
4927
|
};
|
|
3806
|
-
const sceneEdges = edges.map(({ step, event: event2, edge: edge2 }) => {
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
};
|
|
3818
|
-
});
|
|
4928
|
+
const sceneEdges = edges.map(({ step, event: event2, edge: edge2 }) => ({
|
|
4929
|
+
step,
|
|
4930
|
+
event: event2,
|
|
4931
|
+
from: edge2.from,
|
|
4932
|
+
to: edge2.to,
|
|
4933
|
+
points: route(edge2.from, edge2.to),
|
|
4934
|
+
color: edgeColor(edge2, colors),
|
|
4935
|
+
carry: edge2.carry
|
|
4936
|
+
}));
|
|
4937
|
+
seatCarriers(sceneEdges, byId, carriedIn);
|
|
4938
|
+
const outward = /* @__PURE__ */ new Map();
|
|
3819
4939
|
for (const edge2 of sceneEdges) {
|
|
3820
4940
|
if (edge2.points.length !== 2) continue;
|
|
3821
4941
|
const back = sceneEdges.some((other) => other.from === edge2.to && other.to === edge2.from && other.points.length === 2);
|
|
@@ -3824,6 +4944,7 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3824
4944
|
const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
|
|
3825
4945
|
const d = (edge2.from < edge2.to ? 1 : -1) * LOOK.edge.parallel;
|
|
3826
4946
|
edge2.points = edge2.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
|
|
4947
|
+
outward.set(edge2, flat ? d > 0 ? "below" : "above" : d > 0 ? "right" : "left");
|
|
3827
4948
|
}
|
|
3828
4949
|
const regions = [];
|
|
3829
4950
|
groups.forEach((group, g) => {
|
|
@@ -3843,15 +4964,20 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3843
4964
|
header: { x: margin + R.inset, y: band2.y + R.inset, w: header.w, h: header.h }
|
|
3844
4965
|
});
|
|
3845
4966
|
});
|
|
4967
|
+
const badgeAt = (edge2, taken, lines2) => edge2.from === edge2.to ? loopBadge(edge2.points) : badgeOnPath(edge2.points, taken, lines2);
|
|
4968
|
+
const early = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
|
|
3846
4969
|
const labels = [];
|
|
3847
4970
|
for (const edge2 of sceneEdges) {
|
|
3848
4971
|
const source = diagram.steps[edge2.step]?.events[edge2.event];
|
|
3849
4972
|
if (source?.type !== "edge" || source.label === void 0) continue;
|
|
4973
|
+
const seen = [...early].filter(([s]) => s <= edge2.step).map(([, b]) => badgeRect(b.point));
|
|
3850
4974
|
const soft = [...regions.map((r) => r.header), ...labels.filter((l) => l.step === edge2.step)];
|
|
4975
|
+
const side2 = source.labelSide ?? outward.get(edge2);
|
|
4976
|
+
const below = edge2.from === edge2.to ? { side: "below", base: loopLabelBase(edge2.points, textWidth(source.label, labelStyle(source.label)) + LOOK.label.padX * 2) } : void 0;
|
|
3851
4977
|
labels.push(
|
|
3852
4978
|
placeLabel(
|
|
3853
|
-
{ step: edge2.step, event: edge2.event, text: source.label, points: edge2.points, color: edge2.color, ...
|
|
3854
|
-
{ hard: boxes, soft }
|
|
4979
|
+
{ step: edge2.step, event: edge2.event, text: source.label, points: edge2.points, color: edge2.color, ...below ?? (side2 ? { side: side2 } : { flip: true }) },
|
|
4980
|
+
{ hard: boxes, soft, touch: seen }
|
|
3855
4981
|
)
|
|
3856
4982
|
);
|
|
3857
4983
|
}
|
|
@@ -3861,16 +4987,19 @@ function arrange(diagram, groups, slots, rooms) {
|
|
|
3861
4987
|
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)));
|
|
3862
4988
|
const width = Math.max(contentRight + margin, stripNeed(diagram) + margin * 2);
|
|
3863
4989
|
for (const region of regions) region.w = width - margin * 2;
|
|
3864
|
-
const
|
|
4990
|
+
const contentBottom = Math.max(bandsBottom, ...labels.map((l) => l.y + l.h));
|
|
4991
|
+
const strip2 = layoutStrip(diagram, margin, contentBottom + gap, width - margin * 2);
|
|
3865
4992
|
layout.width = width;
|
|
3866
|
-
layout.height = (strip2 ? strip2.y + strip2.h :
|
|
4993
|
+
layout.height = (strip2 ? strip2.y + strip2.h : contentBottom) + margin;
|
|
3867
4994
|
if (strip2) layout.strip = strip2;
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
4995
|
+
const lines = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
|
|
4996
|
+
layout.badges = replaceSameSpot(
|
|
4997
|
+
diagram.steps.map((step, s) => {
|
|
4998
|
+
const line2 = lines.get(s);
|
|
4999
|
+
if (!line2) return cornerBadge(step.events, s, layout);
|
|
5000
|
+
return { step: s, x: line2.point[0], y: line2.point[1], color: line2.edge.color };
|
|
5001
|
+
})
|
|
5002
|
+
);
|
|
3874
5003
|
return layout;
|
|
3875
5004
|
}
|
|
3876
5005
|
function grow(layout, groups, slots, rooms) {
|
|
@@ -3898,6 +5027,492 @@ function grow(layout, groups, slots, rooms) {
|
|
|
3898
5027
|
return grown;
|
|
3899
5028
|
}
|
|
3900
5029
|
|
|
5030
|
+
// src/layout/git.ts
|
|
5031
|
+
var isGitLayout = (layout) => layout.kind === "git";
|
|
5032
|
+
function walk(diagram) {
|
|
5033
|
+
const branches = (diagram.git?.branches ?? []).map((b) => b.id);
|
|
5034
|
+
const lane = (id) => {
|
|
5035
|
+
if (!branches.includes(id)) branches.push(id);
|
|
5036
|
+
};
|
|
5037
|
+
for (const step of diagram.steps) for (const e of step.events) if (e.type === "commit" || e.type === "branch") lane(e.branch);
|
|
5038
|
+
const tips = new Map(branches.map((b) => [b, null]));
|
|
5039
|
+
let headAt = null;
|
|
5040
|
+
let attached = null;
|
|
5041
|
+
const made = [];
|
|
5042
|
+
const byId = /* @__PURE__ */ new Map();
|
|
5043
|
+
const links = [];
|
|
5044
|
+
const moves = [];
|
|
5045
|
+
const tags = [];
|
|
5046
|
+
const rows = /* @__PURE__ */ new Map();
|
|
5047
|
+
const most = /* @__PURE__ */ new Map();
|
|
5048
|
+
const shown2 = /* @__PURE__ */ new Map();
|
|
5049
|
+
const names = [...branches, HEAD];
|
|
5050
|
+
const at = new Map(names.map((n) => [n, []]));
|
|
5051
|
+
const heads = [];
|
|
5052
|
+
const visible2 = (ref) => ref === HEAD ? attached === null ? headAt : null : tips.get(ref) ?? null;
|
|
5053
|
+
const freeRow = (commit2) => {
|
|
5054
|
+
const list2 = rows.get(commit2) ?? [];
|
|
5055
|
+
const free = list2.indexOf(null);
|
|
5056
|
+
return free < 0 ? list2.length : free;
|
|
5057
|
+
};
|
|
5058
|
+
const settle = (step, event2, change, lineFor) => {
|
|
5059
|
+
const before = new Map(names.map((n) => [n, visible2(n)]));
|
|
5060
|
+
const headBefore = headAt;
|
|
5061
|
+
change();
|
|
5062
|
+
const changed = names.filter((n) => before.get(n) !== visible2(n));
|
|
5063
|
+
const leaving = changed.map((ref) => {
|
|
5064
|
+
const slot = shown2.get(ref);
|
|
5065
|
+
if (slot) {
|
|
5066
|
+
rows.get(slot.commit)[slot.row] = null;
|
|
5067
|
+
shown2.delete(ref);
|
|
5068
|
+
}
|
|
5069
|
+
return { ref, slot };
|
|
5070
|
+
});
|
|
5071
|
+
for (const { ref, slot } of leaving) {
|
|
5072
|
+
const from = slot ?? (ref === HEAD && headBefore !== null ? { commit: headBefore, row: freeRow(headBefore) } : void 0);
|
|
5073
|
+
const target = visible2(ref);
|
|
5074
|
+
let to;
|
|
5075
|
+
if (target !== null) {
|
|
5076
|
+
to = { commit: target, row: freeRow(target) };
|
|
5077
|
+
const list2 = rows.get(target) ?? [];
|
|
5078
|
+
list2[to.row] = ref;
|
|
5079
|
+
rows.set(target, list2);
|
|
5080
|
+
most.set(target, Math.max(most.get(target) ?? 0, list2.filter((r) => r !== null).length));
|
|
5081
|
+
shown2.set(ref, to);
|
|
5082
|
+
}
|
|
5083
|
+
moves.push({ ref, step, event: event2, ...from ? { from } : {}, ...to ? { to } : {}, line: ref === lineFor });
|
|
5084
|
+
}
|
|
5085
|
+
};
|
|
5086
|
+
const prune = (step, event2) => {
|
|
5087
|
+
const reach = /* @__PURE__ */ new Set();
|
|
5088
|
+
const stack = [...tips.values(), headAt].filter((c) => c !== null);
|
|
5089
|
+
while (stack.length > 0) {
|
|
5090
|
+
const id = stack.pop();
|
|
5091
|
+
if (reach.has(id)) continue;
|
|
5092
|
+
reach.add(id);
|
|
5093
|
+
stack.push(...byId.get(id)?.parents ?? []);
|
|
5094
|
+
}
|
|
5095
|
+
for (const c of made) if (!reach.has(c.id) && c.orphan === void 0) c.orphan = { step, event: event2 };
|
|
5096
|
+
};
|
|
5097
|
+
diagram.steps.forEach((step, s) => {
|
|
5098
|
+
step.events.forEach((e, k) => {
|
|
5099
|
+
if (e.type === "commit") commit(e, s, k);
|
|
5100
|
+
else if (e.type === "branch") {
|
|
5101
|
+
if (!byId.has(e.from)) return;
|
|
5102
|
+
if (laneOf(e.from) !== e.branch) links.push({ kind: "branch", from: e.from, to: e.branch, step: s, event: k });
|
|
5103
|
+
settle(s, k, () => {
|
|
5104
|
+
tips.set(e.branch, e.from);
|
|
5105
|
+
attached = e.branch;
|
|
5106
|
+
headAt = e.from;
|
|
5107
|
+
});
|
|
5108
|
+
} else if (e.type === "edge") {
|
|
5109
|
+
const ref = e.from;
|
|
5110
|
+
if (ref !== HEAD && !tips.has(ref) || !byId.has(e.to)) return;
|
|
5111
|
+
settle(
|
|
5112
|
+
s,
|
|
5113
|
+
k,
|
|
5114
|
+
() => {
|
|
5115
|
+
if (ref === HEAD) {
|
|
5116
|
+
attached = null;
|
|
5117
|
+
headAt = e.to;
|
|
5118
|
+
return;
|
|
5119
|
+
}
|
|
5120
|
+
tips.set(ref, e.to);
|
|
5121
|
+
if (attached === ref) headAt = e.to;
|
|
5122
|
+
else if (attached === null && headAt === e.to) attached = ref;
|
|
5123
|
+
},
|
|
5124
|
+
ref
|
|
5125
|
+
);
|
|
5126
|
+
} else return;
|
|
5127
|
+
prune(s, k);
|
|
5128
|
+
});
|
|
5129
|
+
for (const n of names) at.get(n)?.push(n === HEAD ? headAt : tips.get(n) ?? null);
|
|
5130
|
+
heads.push(attached);
|
|
5131
|
+
for (const n of names) {
|
|
5132
|
+
const slot = shown2.get(n);
|
|
5133
|
+
if (slot) tags.push({ ref: n, step: s, slot });
|
|
5134
|
+
}
|
|
5135
|
+
});
|
|
5136
|
+
function laneOf(id) {
|
|
5137
|
+
return byId.get(id)?.branch;
|
|
5138
|
+
}
|
|
5139
|
+
function commit(e, s, k) {
|
|
5140
|
+
if (byId.has(e.id)) return;
|
|
5141
|
+
const copy = e.copy !== void 0 && byId.has(e.copy) ? e.copy : void 0;
|
|
5142
|
+
const base = copy !== void 0 && attached === null && headAt !== null ? headAt : tips.get(e.branch) ?? null;
|
|
5143
|
+
const joined = e.merge !== void 0 && e.merge !== e.branch ? tips.get(e.merge) ?? void 0 : void 0;
|
|
5144
|
+
const parents = [...new Set([base, joined].filter((c2) => c2 !== null && c2 !== void 0))];
|
|
5145
|
+
const c = {
|
|
5146
|
+
id: e.id,
|
|
5147
|
+
branch: e.branch,
|
|
5148
|
+
parents,
|
|
5149
|
+
...joined !== void 0 && joined !== base ? { joined } : {},
|
|
5150
|
+
...copy !== void 0 ? { copy } : {},
|
|
5151
|
+
...e.hash !== void 0 ? { hash: e.hash } : {},
|
|
5152
|
+
...e.note !== void 0 ? { note: e.note } : {},
|
|
5153
|
+
step: s,
|
|
5154
|
+
event: k
|
|
5155
|
+
};
|
|
5156
|
+
made.push(c);
|
|
5157
|
+
byId.set(c.id, c);
|
|
5158
|
+
for (const p of parents) links.push({ kind: "parent", from: p, to: c.id, step: s, event: k });
|
|
5159
|
+
if (copy !== void 0) links.push({ kind: "copy", from: copy, to: c.id, step: s, event: k });
|
|
5160
|
+
const first = attached === null && headAt === null;
|
|
5161
|
+
settle(s, k, () => {
|
|
5162
|
+
if (copy === void 0) {
|
|
5163
|
+
tips.set(e.branch, c.id);
|
|
5164
|
+
if (attached === e.branch) headAt = c.id;
|
|
5165
|
+
} else if (attached === null) headAt = c.id;
|
|
5166
|
+
if (first) {
|
|
5167
|
+
attached = e.branch;
|
|
5168
|
+
headAt = c.id;
|
|
5169
|
+
}
|
|
5170
|
+
});
|
|
5171
|
+
}
|
|
5172
|
+
const refs = names.map((name2) => ({ name: name2, at: at.get(name2) ?? [], ...name2 === HEAD ? { attached: heads } : {} }));
|
|
5173
|
+
return { branches, made, links, moves, refs, tags, rows: most };
|
|
5174
|
+
}
|
|
5175
|
+
function cubic(p0, c1, c2, p3) {
|
|
5176
|
+
const n = LOOK.git.samples;
|
|
5177
|
+
return Array.from({ length: n }, (_, k) => {
|
|
5178
|
+
const t = (k + 1) / n;
|
|
5179
|
+
const u = 1 - t;
|
|
5180
|
+
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];
|
|
5181
|
+
return [at(0), at(1)];
|
|
5182
|
+
});
|
|
5183
|
+
}
|
|
5184
|
+
function elbow(from, to) {
|
|
5185
|
+
if (Math.abs(from[1] - to[1]) < 0.5) return [from, to];
|
|
5186
|
+
return from[1] > to[1] ? [from, [from[0], to[1]], to] : [from, [to[0], from[1]], to];
|
|
5187
|
+
}
|
|
5188
|
+
function fork(p, tx, ty) {
|
|
5189
|
+
const sign = ty > p.cy ? 1 : -1;
|
|
5190
|
+
const p0 = [p.cx, p.cy + sign * p.r];
|
|
5191
|
+
const turn = Math.max(0, Math.min(LOOK.git.turn, tx - p.cx));
|
|
5192
|
+
const p3 = [p.cx + turn, ty];
|
|
5193
|
+
const curve = cubic(p0, [p0[0], p0[1] + (ty - p0[1]) * 0.7], [p.cx + turn * 0.2, ty], p3);
|
|
5194
|
+
return [p0, ...curve, ...tx > p3[0] ? [[tx, ty]] : []];
|
|
5195
|
+
}
|
|
5196
|
+
function join(p, c) {
|
|
5197
|
+
const sign = c.cy < p.cy ? 1 : -1;
|
|
5198
|
+
const p0 = [p.cx + p.r, p.cy];
|
|
5199
|
+
const p3 = [c.cx, c.cy + sign * c.r];
|
|
5200
|
+
const turn = Math.max(0, Math.min(LOOK.git.turn, c.cx - p0[0]));
|
|
5201
|
+
const h = [c.cx - turn, p.cy];
|
|
5202
|
+
const curve = cubic(h, [c.cx - turn * 0.2, p.cy], [c.cx, p3[1] + (p.cy - p3[1]) * 0.7], p3);
|
|
5203
|
+
return [p0, ...h[0] > p0[0] ? [h] : [], ...curve];
|
|
5204
|
+
}
|
|
5205
|
+
function copyLine(p, c) {
|
|
5206
|
+
if (Math.abs(p.cy - c.cy) < 0.5) {
|
|
5207
|
+
const top = p.cy - p.r;
|
|
5208
|
+
const lift = LOOK.git.turn * 0.7;
|
|
5209
|
+
return [[p.cx, top], ...cubic([p.cx, top], [p.cx, top - lift], [c.cx, top - lift], [c.cx, top])];
|
|
5210
|
+
}
|
|
5211
|
+
const sign = c.cy < p.cy ? -1 : 1;
|
|
5212
|
+
const p0 = [p.cx, p.cy + sign * p.r];
|
|
5213
|
+
const p3 = [c.cx, c.cy - sign * c.r];
|
|
5214
|
+
const mid = (p3[1] - p0[1]) * 0.5;
|
|
5215
|
+
return [p0, ...cubic(p0, [p0[0], p0[1] + mid], [p3[0], p3[1] - mid], p3)];
|
|
5216
|
+
}
|
|
5217
|
+
function layoutGit(diagram) {
|
|
5218
|
+
const { margin, gap, box: B, region: R, git: G, carrier: C } = LOOK;
|
|
5219
|
+
const walked = walk(diagram);
|
|
5220
|
+
const notes = new Map((diagram.git?.branches ?? []).map((b) => [b.id, b.note]));
|
|
5221
|
+
const laneIndex = new Map(walked.branches.map((id, i) => [id, i]));
|
|
5222
|
+
const colorOf2 = (branch) => G.colors[(laneIndex.get(branch) ?? 0) % G.colors.length];
|
|
5223
|
+
const col = /* @__PURE__ */ new Map();
|
|
5224
|
+
const laneLast = /* @__PURE__ */ new Map();
|
|
5225
|
+
for (const c of walked.made) {
|
|
5226
|
+
const k = Math.max(0, ...c.parents.map((p) => (col.get(p) ?? -1) + 1), (laneLast.get(c.branch) ?? -1) + 1);
|
|
5227
|
+
col.set(c.id, k);
|
|
5228
|
+
laneLast.set(c.branch, k);
|
|
5229
|
+
}
|
|
5230
|
+
const linesOf = (c) => [
|
|
5231
|
+
...c.hash !== void 0 ? [{ text: c.hash, style: TYPE.gitHash }] : [],
|
|
5232
|
+
...c.note !== void 0 ? [{ text: c.note, style: TYPE.gitNote }] : []
|
|
5233
|
+
];
|
|
5234
|
+
const textW = (c) => Math.max(0, ...linesOf(c).map((line2) => textWidth(line2.text, line2.style)));
|
|
5235
|
+
const tagW = (ref) => textWidth(ref, hasWide(ref) ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
|
|
5236
|
+
const refWidth = Math.max(0, ...walked.refs.map((r) => tagW(r.name)));
|
|
5237
|
+
const pitch = Math.max(G.pitch, ...walked.made.map((c) => textW(c) + G.textGap), refWidth + G.textGap);
|
|
5238
|
+
const headers = walked.branches.map((id) => ({ w: Math.max(R.icon, textWidth(id, TYPE.regionName), textWidth(notes.get(id) ?? "", TYPE.regionNote)) }));
|
|
5239
|
+
const headerRight = margin + R.inset + Math.max(0, ...headers.map((h) => h.w));
|
|
5240
|
+
const firstHalf = Math.max(G.r, ...walked.made.filter((c) => col.get(c.id) === 0 && laneIndex.get(c.branch) === 0).map((c) => textW(c) / 2), refWidth / 2);
|
|
5241
|
+
const x0 = Math.max(G.x0, headerRight + gap + firstHalf);
|
|
5242
|
+
const named = new Set(
|
|
5243
|
+
walked.moves.flatMap((mv) => {
|
|
5244
|
+
const source = diagram.steps[mv.step]?.events[mv.event];
|
|
5245
|
+
return mv.line && mv.to && source?.type === "edge" && source.label !== void 0 ? [walked.made.find((c) => c.id === mv.to?.commit)?.branch ?? ""] : [];
|
|
5246
|
+
})
|
|
5247
|
+
);
|
|
5248
|
+
const extraRows = (branch) => Math.max(0, ...walked.made.filter((c) => c.branch === branch).map((c) => (walked.rows.get(c.id) ?? 0) - 2)) * G.row;
|
|
5249
|
+
const topText = walked.made.some((c) => laneIndex.get(c.branch) === 0 && linesOf(c).length > 0);
|
|
5250
|
+
const lanes = [];
|
|
5251
|
+
let y = margin;
|
|
5252
|
+
walked.branches.forEach((id, i) => {
|
|
5253
|
+
const top = i === 0;
|
|
5254
|
+
const tagBase = top && topText ? G.tagTop : G.tag;
|
|
5255
|
+
const line2 = y + (top ? G.topLine - (G.tagTop - tagBase) : G.line) + extraRows(id);
|
|
5256
|
+
const h = line2 - y + (top ? G.topBelow : named.has(id) ? G.below : G.bare);
|
|
5257
|
+
lanes.push({ id, x: margin, y, w: 0, h, line: line2, color: colorOf2(id), tagBase });
|
|
5258
|
+
y += h + R.gap;
|
|
5259
|
+
});
|
|
5260
|
+
const lanesBottom = y - R.gap;
|
|
5261
|
+
const laneOf = new Map(lanes.map((l) => [l.id, l]));
|
|
5262
|
+
const commits = walked.made.map((c) => {
|
|
5263
|
+
const lane = laneOf.get(c.branch);
|
|
5264
|
+
const isTop = laneIndex.get(c.branch) === 0;
|
|
5265
|
+
const cx = x0 + pitch * (col.get(c.id) ?? 0) + (isTop ? 0 : pitch / 2);
|
|
5266
|
+
const cy = lane.line;
|
|
5267
|
+
const lines = linesOf(c);
|
|
5268
|
+
const baselines = lines.map((_, k) => isTop ? cy - G.above - (lines.length - 1 - k) * G.lineStep : cy + G.under + k * G.lineStep);
|
|
5269
|
+
const boxes2 = lines.map((line2, k) => textBox(line2.text, cx, baselines[k], line2.style, "middle"));
|
|
5270
|
+
const text2 = boxes2.length === 0 ? void 0 : { ...union(boxes2), lines: lines.map((line2) => line2.text), baselines };
|
|
5271
|
+
const color = c.copy !== void 0 ? colorOf2(walked.made.find((m) => m.id === c.copy)?.branch ?? c.branch) : colorOf2(c.branch);
|
|
5272
|
+
return {
|
|
5273
|
+
id: c.id,
|
|
5274
|
+
branch: c.branch,
|
|
5275
|
+
color,
|
|
5276
|
+
cx,
|
|
5277
|
+
cy,
|
|
5278
|
+
r: G.r,
|
|
5279
|
+
step: c.step,
|
|
5280
|
+
event: c.event,
|
|
5281
|
+
parents: c.parents,
|
|
5282
|
+
...c.copy !== void 0 ? { copy: c.copy } : {},
|
|
5283
|
+
...c.hash !== void 0 ? { hash: c.hash } : {},
|
|
5284
|
+
...c.note !== void 0 ? { note: c.note } : {},
|
|
5285
|
+
...text2 ? { text: text2 } : {},
|
|
5286
|
+
...c.orphan ? { orphan: c.orphan.step, orphanEvent: c.orphan.event } : {}
|
|
5287
|
+
};
|
|
5288
|
+
});
|
|
5289
|
+
const placed = new Map(commits.map((c) => [c.id, c]));
|
|
5290
|
+
const links = walked.links.flatMap((l) => {
|
|
5291
|
+
const from = placed.get(l.from);
|
|
5292
|
+
if (!from) return [];
|
|
5293
|
+
if (l.kind === "branch") {
|
|
5294
|
+
if (!walked.made.some((c) => c.branch === l.to)) return [];
|
|
5295
|
+
const lane = laneOf.get(l.to);
|
|
5296
|
+
return [{ ...l, points: fork(from, from.cx + G.turn, lane.line), color: colorOf2(l.to) }];
|
|
5297
|
+
}
|
|
5298
|
+
const to = placed.get(l.to);
|
|
5299
|
+
const made = walked.made.find((m) => m.id === l.to);
|
|
5300
|
+
let points;
|
|
5301
|
+
if (l.kind === "copy") points = copyLine(from, to);
|
|
5302
|
+
else if (Math.abs(from.cy - to.cy) < 0.5) points = [[from.cx + from.r, from.cy], [to.cx - to.r, to.cy]];
|
|
5303
|
+
else if (made?.joined === l.from) points = join(from, to);
|
|
5304
|
+
else points = fork(from, to.cx - to.r, to.cy);
|
|
5305
|
+
return [{ ...l, points, color: to.color }];
|
|
5306
|
+
});
|
|
5307
|
+
const tagRect = (ref, slot) => {
|
|
5308
|
+
const c = placed.get(slot.commit);
|
|
5309
|
+
const base = laneOf.get(c.branch)?.tagBase ?? G.tag;
|
|
5310
|
+
const w = tagW(ref);
|
|
5311
|
+
return { x: c.cx - w / 2, y: c.cy - base - slot.row * G.row - C.tagH / 2, w, h: C.tagH };
|
|
5312
|
+
};
|
|
5313
|
+
const center2 = (r) => [r.x + r.w / 2, r.y + r.h / 2];
|
|
5314
|
+
const moves = walked.moves.map((m) => {
|
|
5315
|
+
const from = m.from ? tagRect(m.ref, m.from) : void 0;
|
|
5316
|
+
const to = m.to ? tagRect(m.ref, m.to) : void 0;
|
|
5317
|
+
const source = diagram.steps[m.step]?.events[m.event];
|
|
5318
|
+
const carried = m.line && source?.type === "edge" && source.carry.kind !== "none" && !(source.carry.kind === "tag" && source.carry.text === source.from);
|
|
5319
|
+
return {
|
|
5320
|
+
ref: m.ref,
|
|
5321
|
+
step: m.step,
|
|
5322
|
+
event: m.event,
|
|
5323
|
+
...from ? { from } : {},
|
|
5324
|
+
...to ? { to } : {},
|
|
5325
|
+
...m.to ? { target: m.to.commit } : {},
|
|
5326
|
+
...carried ? { carried: true } : {},
|
|
5327
|
+
...m.line && from && to ? { line: elbow(center2(from), center2(to)) } : {},
|
|
5328
|
+
color: "slate"
|
|
5329
|
+
};
|
|
5330
|
+
});
|
|
5331
|
+
const tags = walked.tags.map((t) => ({ ...tagRect(t.ref, t.slot), ref: t.ref, step: t.step }));
|
|
5332
|
+
const colors = boxColors(diagram);
|
|
5333
|
+
const right = Math.max(
|
|
5334
|
+
x0,
|
|
5335
|
+
...commits.flatMap((c) => [c.cx + c.r, ...c.text ? [c.text.x + c.text.w] : []]),
|
|
5336
|
+
...tags.map((t) => t.x + t.w),
|
|
5337
|
+
...moves.flatMap((m) => [m.from, m.to].flatMap((r) => r ? [r.x + r.w] : []))
|
|
5338
|
+
);
|
|
5339
|
+
const boxX = right + G.boxGap;
|
|
5340
|
+
const firstCy = (lanes[1] ?? lanes[0])?.line ?? margin + B.h / 2;
|
|
5341
|
+
const boxes = diagram.boxes.map((b, i) => {
|
|
5342
|
+
const w = boxWidth(diagram, b.id, true);
|
|
5343
|
+
const cy = firstCy + i * (B.h + gap);
|
|
5344
|
+
return {
|
|
5345
|
+
id: b.id,
|
|
5346
|
+
name: b.name,
|
|
5347
|
+
...b.sub !== void 0 ? { sub: b.sub } : {},
|
|
5348
|
+
...b.icon !== void 0 ? { icon: b.icon } : {},
|
|
5349
|
+
color: colors.get(b.id) ?? "slate",
|
|
5350
|
+
x: boxX,
|
|
5351
|
+
y: cy - B.h / 2,
|
|
5352
|
+
w,
|
|
5353
|
+
h: B.h,
|
|
5354
|
+
cx: boxX + w / 2,
|
|
5355
|
+
cy
|
|
5356
|
+
};
|
|
5357
|
+
});
|
|
5358
|
+
const regions = lanes.map((lane, i) => {
|
|
5359
|
+
const note = notes.get(lane.id);
|
|
5360
|
+
return {
|
|
5361
|
+
id: lane.id,
|
|
5362
|
+
lines: [lane.id],
|
|
5363
|
+
...note !== void 0 ? { note } : {},
|
|
5364
|
+
icon: "branch",
|
|
5365
|
+
color: lane.color,
|
|
5366
|
+
x: lane.x,
|
|
5367
|
+
y: lane.y,
|
|
5368
|
+
w: 0,
|
|
5369
|
+
h: lane.h,
|
|
5370
|
+
header: { x: lane.x + R.inset, y: lane.y + R.inset, w: headers[i]?.w ?? 0, h: R.nameY - R.inset + (note !== void 0 ? R.line : 0) + gap / 2 }
|
|
5371
|
+
};
|
|
5372
|
+
});
|
|
5373
|
+
const layout = {
|
|
5374
|
+
kind: "git",
|
|
5375
|
+
width: 0,
|
|
5376
|
+
height: 0,
|
|
5377
|
+
regions,
|
|
5378
|
+
boxes,
|
|
5379
|
+
lifelines: [],
|
|
5380
|
+
edges: [],
|
|
5381
|
+
labels: [],
|
|
5382
|
+
actions: [],
|
|
5383
|
+
badges: [],
|
|
5384
|
+
paths: [],
|
|
5385
|
+
ends: [],
|
|
5386
|
+
lanes,
|
|
5387
|
+
commits,
|
|
5388
|
+
links,
|
|
5389
|
+
tags,
|
|
5390
|
+
refs: walked.refs,
|
|
5391
|
+
moves
|
|
5392
|
+
};
|
|
5393
|
+
layout.badges = badgesOf(diagram, layout);
|
|
5394
|
+
layout.labels = labelsOf(diagram, layout);
|
|
5395
|
+
const contentRight = Math.max(right, ...boxes.map((b) => b.x + b.w), ...layout.labels.map((l) => l.x + l.w)) + R.pad;
|
|
5396
|
+
const width = Math.max(contentRight + margin, stripNeed(diagram) + margin * 2);
|
|
5397
|
+
for (const region of regions) region.w = width - margin * 2;
|
|
5398
|
+
for (const lane of lanes) lane.w = width - margin * 2;
|
|
5399
|
+
const bottom = Math.max(lanesBottom, ...boxes.map((b) => b.y + b.h), ...layout.labels.map((l) => l.y + l.h));
|
|
5400
|
+
const strip2 = layoutStrip(diagram, margin, bottom + gap, width - margin * 2);
|
|
5401
|
+
layout.width = width;
|
|
5402
|
+
layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
|
|
5403
|
+
if (strip2) layout.strip = strip2;
|
|
5404
|
+
layout.badges = badgesOf(diagram, layout);
|
|
5405
|
+
return layout;
|
|
5406
|
+
}
|
|
5407
|
+
function union(rects) {
|
|
5408
|
+
const x = Math.min(...rects.map((r) => r.x));
|
|
5409
|
+
const y = Math.min(...rects.map((r) => r.y));
|
|
5410
|
+
return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
|
|
5411
|
+
}
|
|
5412
|
+
function firstMark(layout, step) {
|
|
5413
|
+
const marks = [
|
|
5414
|
+
...layout.links.filter((l) => l.step === step && l.kind !== "copy").map((l) => ({ event: l.event, points: l.points, color: l.color })),
|
|
5415
|
+
...layout.moves.flatMap((m) => {
|
|
5416
|
+
const target = layout.commits.find((c) => c.id === m.target);
|
|
5417
|
+
return m.step === step && m.line && target ? [{ event: m.event, target, color: target.color }] : [];
|
|
5418
|
+
})
|
|
5419
|
+
].sort((a, b) => a.event - b.event);
|
|
5420
|
+
return marks[0];
|
|
5421
|
+
}
|
|
5422
|
+
function besideCommit(c, taken, avoid) {
|
|
5423
|
+
const { r, inset } = LOOK.badge;
|
|
5424
|
+
const d = c.r + inset + r;
|
|
5425
|
+
const apart = r * 2 + inset;
|
|
5426
|
+
const spots = [
|
|
5427
|
+
[c.cx + d, c.cy],
|
|
5428
|
+
[c.cx, c.cy + d],
|
|
5429
|
+
[c.cx - d, c.cy],
|
|
5430
|
+
[c.cx, c.cy - d]
|
|
5431
|
+
];
|
|
5432
|
+
return spots.find((p) => taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => gapBetween(badgeRect(p), a) >= LOOK.label.touch));
|
|
5433
|
+
}
|
|
5434
|
+
function clearOnPath(points, taken, avoid) {
|
|
5435
|
+
const { r, inset, along: start, short } = LOOK.badge;
|
|
5436
|
+
const length = pathLength(points);
|
|
5437
|
+
const first = length < short ? Math.min(r + 1, length / 2) : start;
|
|
5438
|
+
const apart = r * 2 + inset;
|
|
5439
|
+
for (let d = first; d <= length; d += 1) {
|
|
5440
|
+
const p = along(points, d);
|
|
5441
|
+
const rect = badgeRect(p);
|
|
5442
|
+
if (taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => gapBetween(rect, a) >= LOOK.label.touch)) return p;
|
|
5443
|
+
}
|
|
5444
|
+
return void 0;
|
|
5445
|
+
}
|
|
5446
|
+
function badgesOf(diagram, layout) {
|
|
5447
|
+
const { inset } = LOOK.badge;
|
|
5448
|
+
const taken = [];
|
|
5449
|
+
const all = [...layout.links.map((l) => l.points), ...layout.moves.flatMap((m) => m.line ? [m.line] : [])];
|
|
5450
|
+
const out = [];
|
|
5451
|
+
const avoid = [
|
|
5452
|
+
...layout.tags,
|
|
5453
|
+
...layout.commits.flatMap((c) => [{ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }, ...c.text ? [c.text] : []])
|
|
5454
|
+
];
|
|
5455
|
+
diagram.steps.forEach((step, s) => {
|
|
5456
|
+
const mark = firstMark(layout, s);
|
|
5457
|
+
const near = mark?.target ? besideCommit(mark.target, taken, avoid) : void 0;
|
|
5458
|
+
if (mark && (mark.points || near)) {
|
|
5459
|
+
const points = mark.points;
|
|
5460
|
+
const point = near ?? (points ? clearOnPath(points, taken, avoid) ?? badgeOnPath(points, taken, all.filter((p) => p !== points)) : [0, 0]);
|
|
5461
|
+
taken.push(point);
|
|
5462
|
+
out.push({ step: s, x: point[0], y: point[1], color: mark.color });
|
|
5463
|
+
return;
|
|
5464
|
+
}
|
|
5465
|
+
const box = step.events.flatMap((e) => e.type === "swap" || e.type === "action" ? [e.box] : []).map((id) => layout.boxes.find((b) => b.id === id))[0];
|
|
5466
|
+
if (box) {
|
|
5467
|
+
out.push({ step: s, x: box.x, y: box.y, color: box.color });
|
|
5468
|
+
return;
|
|
5469
|
+
}
|
|
5470
|
+
if (layout.strip && step.events.some((e) => e.type === "strip")) {
|
|
5471
|
+
out.push({ step: s, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" });
|
|
5472
|
+
return;
|
|
5473
|
+
}
|
|
5474
|
+
const tip = layout.commits.find((c) => c.id === layout.refs[0]?.at[s]);
|
|
5475
|
+
const spot = tip ? besideCommit(tip, taken, avoid) : void 0;
|
|
5476
|
+
if (tip && spot) {
|
|
5477
|
+
taken.push(spot);
|
|
5478
|
+
out.push({ step: s, x: spot[0], y: spot[1], color: tip.color });
|
|
5479
|
+
return;
|
|
5480
|
+
}
|
|
5481
|
+
const before = out[out.length - 1];
|
|
5482
|
+
const lane = layout.lanes[0];
|
|
5483
|
+
out.push(before ? { ...before, step: s } : { step: s, x: (lane?.x ?? 0) + (lane?.w ?? 0) - inset - LOOK.badge.r, y: (lane?.y ?? 0) + inset + LOOK.badge.r, color: lane?.color ?? "slate" });
|
|
5484
|
+
});
|
|
5485
|
+
return replaceSameSpot(out);
|
|
5486
|
+
}
|
|
5487
|
+
function labelsOf(diagram, layout) {
|
|
5488
|
+
const G = LOOK.git;
|
|
5489
|
+
const labels = [];
|
|
5490
|
+
const circles = layout.commits.map((c) => ({ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }));
|
|
5491
|
+
const texts = layout.commits.flatMap((c) => c.text ? [c.text] : []);
|
|
5492
|
+
const headers = layout.regions.map((r) => r.header);
|
|
5493
|
+
for (const move of layout.moves) {
|
|
5494
|
+
const source = diagram.steps[move.step]?.events[move.event];
|
|
5495
|
+
if (source?.type !== "edge" || source.label === void 0 || !move.line) continue;
|
|
5496
|
+
const target = layout.commits.find((c) => c.id === source.to);
|
|
5497
|
+
if (!target) continue;
|
|
5498
|
+
const top = layout.lanes[0]?.id === target.branch;
|
|
5499
|
+
const w = textWidth(source.label, hasWide(source.label) ? TYPE.labelJa : TYPE.label) + LOOK.label.padX * 2;
|
|
5500
|
+
const [mx] = move.line.reduce((sum, p) => [sum[0] + p[0] / move.line.length, 0], [0, 0]);
|
|
5501
|
+
const rows = Math.max(0, ...layout.tags.filter((t) => t.step === move.step && Math.abs(t.x + t.w / 2 - target.cx) < 0.5).map((t) => target.cy - t.y));
|
|
5502
|
+
const side2 = source.labelSide ?? (top ? "above" : "below");
|
|
5503
|
+
const base = source.labelSide !== void 0 ? void 0 : top ? { x: mx - w / 2, y: target.cy - Math.max(rows, (layout.lanes[0]?.tagBase ?? G.tag) + LOOK.carrier.tagH / 2) - LOOK.label.soft - LOOK.label.h } : { x: mx - w / 2, y: target.cy + G.labelUnder };
|
|
5504
|
+
const seen = layout.badges.filter((b) => b.step <= move.step).map((b) => badgeRect([b.x, b.y]));
|
|
5505
|
+
const tags = layout.tags.filter((t) => t.step === move.step);
|
|
5506
|
+
labels.push(
|
|
5507
|
+
placeLabel(
|
|
5508
|
+
{ step: move.step, event: move.event, text: source.label, points: move.line, color: move.color, side: side2, ...base ? { base } : {} },
|
|
5509
|
+
{ hard: [...circles, ...layout.boxes], soft: [...texts, ...tags, ...headers, ...labels.filter((l) => l.step === move.step)], touch: seen }
|
|
5510
|
+
)
|
|
5511
|
+
);
|
|
5512
|
+
}
|
|
5513
|
+
return labels;
|
|
5514
|
+
}
|
|
5515
|
+
|
|
3901
5516
|
// src/layout/sequence.ts
|
|
3902
5517
|
function layoutSequence(diagram) {
|
|
3903
5518
|
const { box: B, sequence: Q, label: L, margin, gap } = LOOK;
|
|
@@ -3965,8 +5580,8 @@ function layoutSequence(diagram) {
|
|
|
3965
5580
|
const side2 = event2.labelSide ?? "above";
|
|
3966
5581
|
const self = event2.from === event2.to;
|
|
3967
5582
|
const named = event2.label !== void 0;
|
|
3968
|
-
above = named && side2 === "above" ?
|
|
3969
|
-
under = self ? Q.selfH + gap : named && side2 === "below" ?
|
|
5583
|
+
above = named && side2 === "above" ? Q.labelOffset + L.h / 2 : gap;
|
|
5584
|
+
under = self ? Q.selfH + gap : named && side2 === "below" ? Q.labelOffset + L.h / 2 : gap;
|
|
3970
5585
|
} else {
|
|
3971
5586
|
above = LOOK.action.h / 2;
|
|
3972
5587
|
under = LOOK.action.h / 2;
|
|
@@ -3988,7 +5603,17 @@ function layoutSequence(diagram) {
|
|
|
3988
5603
|
[xt - dir * LOOK.edge.inset, y]
|
|
3989
5604
|
];
|
|
3990
5605
|
const color = edgeColor(event2, colors);
|
|
3991
|
-
|
|
5606
|
+
const seats = {};
|
|
5607
|
+
if (event2.carry.kind !== "none") {
|
|
5608
|
+
const reach = LOOK.slot.lifeline + carrierHalf(event2.carry)[0];
|
|
5609
|
+
const [p0, p1] = points;
|
|
5610
|
+
const [q0, q1] = points.slice(-2);
|
|
5611
|
+
const out = Math.sign(p1[0] - p0[0]) || 1;
|
|
5612
|
+
const into = Math.sign(q1[0] - q0[0]) || -1;
|
|
5613
|
+
seats.wait = [xf - out * reach, p0[1]];
|
|
5614
|
+
seats.settle = [xt + into * reach, q1[1]];
|
|
5615
|
+
}
|
|
5616
|
+
edges.push({ step: s, event: e, from: event2.from, to: event2.to, points, color, carry: event2.carry, ...seats });
|
|
3992
5617
|
if (event2.label !== void 0) {
|
|
3993
5618
|
requests.push({
|
|
3994
5619
|
step: s,
|
|
@@ -3996,7 +5621,8 @@ function layoutSequence(diagram) {
|
|
|
3996
5621
|
text: event2.label,
|
|
3997
5622
|
points,
|
|
3998
5623
|
color,
|
|
3999
|
-
...event2.labelSide ? { side: event2.labelSide } : xf === xt ? { side: "right" } : {}
|
|
5624
|
+
...event2.labelSide ? { side: event2.labelSide } : xf === xt ? { side: "right" } : {},
|
|
5625
|
+
offset: Q.labelOffset
|
|
4000
5626
|
});
|
|
4001
5627
|
}
|
|
4002
5628
|
} else {
|
|
@@ -4008,10 +5634,12 @@ function layoutSequence(diagram) {
|
|
|
4008
5634
|
});
|
|
4009
5635
|
const bottom = (first ? headBottom : y + below) + Q.tail;
|
|
4010
5636
|
const lifelines = order.map((id, i) => ({ id, x: xs[i], y1: headBottom, y2: bottom }));
|
|
5637
|
+
const early = lineBadges(edges, diagram.steps.length);
|
|
4011
5638
|
const labels = [];
|
|
4012
5639
|
for (const request of requests) {
|
|
5640
|
+
const seen = [...early].filter(([s]) => s <= request.step).map(([, b]) => badgeRect(b.point));
|
|
4013
5641
|
const soft = [...labels.filter((l) => l.step === request.step), ...actions];
|
|
4014
|
-
labels.push(placeLabel(request, { hard: boxes, soft }));
|
|
5642
|
+
labels.push(placeLabel(request, { hard: boxes, soft, touch: seen }));
|
|
4015
5643
|
}
|
|
4016
5644
|
const layout = { kind: "sequence", width: 0, height: 0, regions: [], boxes, lifelines, edges, labels, actions, badges: [], paths: [], ends: [] };
|
|
4017
5645
|
const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...actions.map((a) => a.x)];
|
|
@@ -4027,17 +5655,16 @@ function layoutSequence(diagram) {
|
|
|
4027
5655
|
return layout;
|
|
4028
5656
|
}
|
|
4029
5657
|
function badges(diagram, layout) {
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
return { step: s, x, y, color: edge2.color };
|
|
4035
|
-
}
|
|
5658
|
+
const lines = lineBadges(layout.edges, diagram.steps.length);
|
|
5659
|
+
const placed = diagram.steps.map((step, s) => {
|
|
5660
|
+
const line2 = lines.get(s);
|
|
5661
|
+
if (line2) return { step: s, x: line2.point[0], y: line2.point[1], color: line2.edge.color };
|
|
4036
5662
|
const action2 = layout.actions.find((a) => a.step === s);
|
|
4037
5663
|
const lifeline2 = action2 && layout.lifelines.find((l) => l.id === action2.box);
|
|
4038
5664
|
if (action2 && lifeline2) return { step: s, x: lifeline2.x, y: action2.y + action2.h / 2, color: action2.color };
|
|
4039
5665
|
return cornerBadge(step.events, s, layout);
|
|
4040
5666
|
});
|
|
5667
|
+
return replaceSameSpot(placed);
|
|
4041
5668
|
}
|
|
4042
5669
|
|
|
4043
5670
|
// src/layout/state.ts
|
|
@@ -4053,12 +5680,6 @@ function visitOrder(diagram) {
|
|
|
4053
5680
|
}
|
|
4054
5681
|
return order;
|
|
4055
5682
|
}
|
|
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
5683
|
var same = (a, b) => a.from === b.from && a.to === b.to;
|
|
4063
5684
|
function layoutState(diagram, lang) {
|
|
4064
5685
|
const { box: B, state: T, margin, gap } = LOOK;
|
|
@@ -4075,7 +5696,11 @@ function layoutState(diagram, lang) {
|
|
|
4075
5696
|
const source = diagram.boxes.find((b) => b.id === id);
|
|
4076
5697
|
return G.pad * 2 + B.icon + G.gap + Math.max(textWidth(source?.name ?? id, TYPE.boxName), textWidth(source?.sub ?? "", TYPE.boxSub));
|
|
4077
5698
|
};
|
|
4078
|
-
const
|
|
5699
|
+
const carriedIn = slotRooms(diagram);
|
|
5700
|
+
const doneSide = Math.max(B.padX, T.done.inset + T.done.r + LOOK.slot.clear);
|
|
5701
|
+
const widths = new Map(
|
|
5702
|
+
diagram.boxes.map((b) => [b.id, ghosts.includes(b.id) ? ghostWidth(b.id) : Math.max(boxWidth(diagram, b.id, true), slotBoxWidth(carriedIn.get(b.id), b.icon !== void 0, doneSide))])
|
|
5703
|
+
);
|
|
4079
5704
|
const columnCount = Math.max(1, Math.min(T.columns, walked.length));
|
|
4080
5705
|
const rowCount = Math.max(1, Math.ceil(walked.length / T.columns));
|
|
4081
5706
|
const slot = new Map(
|
|
@@ -4096,7 +5721,7 @@ function layoutState(diagram, lang) {
|
|
|
4096
5721
|
}
|
|
4097
5722
|
const colLeft = [];
|
|
4098
5723
|
for (let c = 0; c < columnCount; c++) colLeft.push(c === 0 ? margin : colLeft[c - 1] + colW[c - 1] + between[c - 1]);
|
|
4099
|
-
const
|
|
5724
|
+
const center2 = (c) => colLeft[c] + colW[c] / 2;
|
|
4100
5725
|
const isGhost = (id) => ghosts.includes(id);
|
|
4101
5726
|
const enteringFrom = new Set(notTaken.filter((p) => isGhost(p.to) && !isGhost(p.from) && !isEnd(p.from)).map((p) => p.from));
|
|
4102
5727
|
const notes = [words.sideNote, ...enteringFrom.size > 0 ? [words.sideFrom(enteringFrom.size)] : []];
|
|
@@ -4126,8 +5751,9 @@ function layoutState(diagram, lang) {
|
|
|
4126
5751
|
};
|
|
4127
5752
|
const boxes = walked.map((id) => {
|
|
4128
5753
|
const s = slot.get(id);
|
|
4129
|
-
return boxOf(id,
|
|
5754
|
+
return boxOf(id, center2(s.col), rowY(s.row), false);
|
|
4130
5755
|
});
|
|
5756
|
+
for (const box of boxes) placeSlot(box, carriedIn.get(box.id), doneSide);
|
|
4131
5757
|
const byId = new Map(boxes.map((b) => [b.id, b]));
|
|
4132
5758
|
const below = (box) => boxes.some((other) => other !== box && Math.abs(other.cx - box.cx) < 0.5 && other.y > box.y);
|
|
4133
5759
|
const ends = [];
|
|
@@ -4198,20 +5824,6 @@ function layoutState(diagram, lang) {
|
|
|
4198
5824
|
};
|
|
4199
5825
|
const exitX = (box) => starts && box === first ? box.cx + T.side.entry : box.cx;
|
|
4200
5826
|
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
5827
|
const route = (from, to) => {
|
|
4216
5828
|
if (from === "start") {
|
|
4217
5829
|
const start = ends.find((e) => e.kind === "start");
|
|
@@ -4228,7 +5840,7 @@ function layoutState(diagram, lang) {
|
|
|
4228
5840
|
}
|
|
4229
5841
|
const b = byId.get(to);
|
|
4230
5842
|
if (!b) return [];
|
|
4231
|
-
if (from === to) return
|
|
5843
|
+
if (from === to) return loopUnder(a);
|
|
4232
5844
|
if (b.ghost && !a.ghost) {
|
|
4233
5845
|
const sx = exitX(a);
|
|
4234
5846
|
const ex = entryOf(from, b);
|
|
@@ -4239,15 +5851,18 @@ function layoutState(diagram, lang) {
|
|
|
4239
5851
|
return between2(a, b);
|
|
4240
5852
|
};
|
|
4241
5853
|
const settleOf = (edge2) => {
|
|
4242
|
-
const target = byId.get(edge2.to);
|
|
4243
|
-
if (target) return [target.cx, target.cy + B.iconY];
|
|
4244
5854
|
const end = edge2.to === "finish" ? finishOf(edge2.from) : void 0;
|
|
4245
5855
|
if (!end) return void 0;
|
|
4246
5856
|
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];
|
|
5857
|
+
return from && Math.abs(end.x - from.cx) < 0.5 ? [end.x - end.r - gap - carrierHalf(edge2.carry)[0], end.y] : [end.x, end.y + end.r + gap + LOOK.carrier.tagH / 2];
|
|
5858
|
+
};
|
|
5859
|
+
const waitOf = (edge2) => {
|
|
5860
|
+
const start = edge2.from === "start" ? ends.find((e) => e.kind === "start") : void 0;
|
|
5861
|
+
return start ? [start.x - start.r - LOOK.slot.mark - carrierHalf(edge2.carry)[0], start.y] : void 0;
|
|
4248
5862
|
};
|
|
4249
5863
|
const sceneEdges = steps.map(({ step, event: event2, edge: edge2 }) => {
|
|
4250
5864
|
const settle = settleOf(edge2);
|
|
5865
|
+
const wait = edge2.carry.kind === "none" ? void 0 : waitOf(edge2);
|
|
4251
5866
|
return {
|
|
4252
5867
|
step,
|
|
4253
5868
|
event: event2,
|
|
@@ -4256,49 +5871,67 @@ function layoutState(diagram, lang) {
|
|
|
4256
5871
|
points: route(edge2.from, edge2.to),
|
|
4257
5872
|
color: colorOf(edge2, colors),
|
|
4258
5873
|
carry: edge2.carry,
|
|
4259
|
-
...settle ? { settle } : {}
|
|
5874
|
+
...settle ? { settle } : {},
|
|
5875
|
+
...wait ? { wait } : {}
|
|
4260
5876
|
};
|
|
4261
5877
|
});
|
|
5878
|
+
seatCarriers(sceneEdges, byId, carriedIn);
|
|
5879
|
+
const outward = /* @__PURE__ */ new Map();
|
|
4262
5880
|
for (const e of sceneEdges) {
|
|
4263
5881
|
if (e.points.length !== 2 || !sceneEdges.some((o) => o.from === e.to && o.to === e.from && o.points.length === 2)) continue;
|
|
4264
5882
|
const [p, q] = e.points;
|
|
4265
5883
|
const flat = Math.abs(q[1] - p[1]) < Math.abs(q[0] - p[0]);
|
|
4266
5884
|
const d = (e.from < e.to ? 1 : -1) * LOOK.edge.parallel;
|
|
4267
5885
|
e.points = e.points.map(([x, y]) => flat ? [x, y + d] : [x + d, y]);
|
|
5886
|
+
outward.set(e, flat ? d > 0 ? "below" : "above" : d > 0 ? "right" : "left");
|
|
4268
5887
|
}
|
|
4269
5888
|
const paths = notTaken.map((p) => ({ from: p.from, to: p.to, points: route(p.from, p.to) }));
|
|
5889
|
+
const badgeAt = (edge2, taken, lines2) => edge2.from === edge2.to ? loopBadge(edge2.points) : badgeOnPath(edge2.points, taken, lines2);
|
|
4270
5890
|
const labels = [];
|
|
4271
|
-
const
|
|
5891
|
+
const marks = ends.flatMap((e) => e.text === "" ? [] : [textBox(e.text, ...markText(e), TYPE.regionNote)]);
|
|
5892
|
+
const badgeRects = [...lineBadges(sceneEdges, diagram.steps.length, badgeAt).values()].map((b) => badgeRect(b.point));
|
|
5893
|
+
const soft = [...side2 ? [{ x: side2.x, y: side2.y, w: T.side.pad + titleW, h: side2.h }] : [], ...marks];
|
|
5894
|
+
const others = (own) => [...sceneEdges.map((o) => o.points), ...paths.map((o) => o.points)].filter((line2) => line2 !== own);
|
|
4272
5895
|
for (const e of sceneEdges) {
|
|
4273
5896
|
const source = diagram.steps[e.step]?.events[e.event];
|
|
4274
5897
|
if (source?.type !== "edge" || source.label === void 0) continue;
|
|
4275
|
-
const
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
5898
|
+
const loop = e.from === e.to;
|
|
5899
|
+
const key2 = lineKey(e);
|
|
5900
|
+
const named = labels.filter((l) => l.text === source.label && sceneEdges.some((o) => o.step === l.step && o.event === l.event && lineKey(o) === key2));
|
|
5901
|
+
const same2 = named[named.length - 1];
|
|
5902
|
+
if (same2) {
|
|
5903
|
+
same2.until = e.step;
|
|
5904
|
+
labels.push({ x: same2.x, y: same2.y, w: same2.w, h: same2.h, step: e.step, event: e.event, text: same2.text, family: same2.family, color: e.color });
|
|
4280
5905
|
continue;
|
|
4281
5906
|
}
|
|
4282
|
-
const
|
|
5907
|
+
const w = textWidth(source.label, labelStyle(source.label)) + LOOK.label.padX * 2;
|
|
5908
|
+
const below2 = loop ? { side: "below", base: loopLabelBase(e.points, w) } : {};
|
|
5909
|
+
const side22 = source.labelSide ?? (e.to === "finish" ? "left" : outward.get(e));
|
|
4283
5910
|
labels.push(
|
|
4284
5911
|
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
|
|
5912
|
+
{ step: e.step, event: e.event, text: source.label, points: e.points, color: e.color, ...side22 ? { side: side22 } : loop ? {} : { flip: true }, ...below2 },
|
|
5913
|
+
{ hard: boxes, soft: [...soft, ...labels], touch: badgeRects, lines: others(e.points) }
|
|
4287
5914
|
)
|
|
4288
5915
|
);
|
|
4289
5916
|
}
|
|
5917
|
+
const placed = [];
|
|
4290
5918
|
notTaken.forEach((p, i) => {
|
|
4291
5919
|
const path2 = paths[i];
|
|
4292
5920
|
if (p.label === void 0 || path2.points.length === 0) return;
|
|
4293
5921
|
const style = labelStyle(p.label);
|
|
4294
5922
|
const into = byId.get(p.to)?.ghost === true && byId.get(p.from)?.ghost !== true;
|
|
4295
|
-
const
|
|
5923
|
+
const x0 = path2.points[0][0];
|
|
5924
|
+
const lead = into ? { side: "below", base: { x: x0 + LOOK.label.soft, y: lane + LOOK.label.soft }, slide: Math.max(...path2.points.map(([x]) => Math.abs(x - x0))) } : {};
|
|
5925
|
+
const rect = placeLabel({ step: -1, event: i, text: p.label, points: path2.points, color: "slate", ...lead }, { hard: boxes, soft: [...soft, ...labels, ...placed], touch: badgeRects, lines: others(path2.points) });
|
|
5926
|
+
placed.push(rect);
|
|
4296
5927
|
path2.label = { x: rect.x, y: rect.y, w: rect.w, h: rect.h, text: p.label, family: style.family };
|
|
4297
5928
|
});
|
|
4298
5929
|
const layout = { kind: "state", width: 0, height: 0, regions: [], boxes, lifelines: [], edges: sceneEdges, labels, actions: [], badges: [], paths, ends, ...side2 ? { side: side2 } : {} };
|
|
4299
5930
|
const lefts = [...boxes.map((b) => b.x), ...labels.map((l) => l.x), ...paths.flatMap((p) => p.label ? [p.label.x] : [])];
|
|
5931
|
+
const tops = [...labels.map((l) => l.y), ...paths.flatMap((p) => p.label ? [p.label.y] : [])];
|
|
4300
5932
|
const shift = Math.max(0, margin - Math.min(...lefts));
|
|
4301
|
-
|
|
5933
|
+
const drop = tops.length > 0 ? Math.max(0, margin - Math.min(...tops)) : 0;
|
|
5934
|
+
if (shift > 0 || drop > 0) shiftContent(layout, shift, drop);
|
|
4302
5935
|
const endRight = (e) => e.x + (e.text === "" ? e.r : T.text + textWidth(e.text, TYPE.regionNote));
|
|
4303
5936
|
const rights = [
|
|
4304
5937
|
...boxes.map((b) => b.x + b.w),
|
|
@@ -4316,18 +5949,14 @@ function layoutState(diagram, lang) {
|
|
|
4316
5949
|
layout.width = width;
|
|
4317
5950
|
layout.height = (strip2 ? strip2.y + strip2.h : bottom) + margin;
|
|
4318
5951
|
if (strip2) layout.strip = strip2;
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
}
|
|
4328
|
-
const [x, y] = badgeOnPath(edge2.points);
|
|
4329
|
-
return { step: s, x, y, color: edge2.color };
|
|
4330
|
-
});
|
|
5952
|
+
const placedBadges = lineBadges(sceneEdges, diagram.steps.length, badgeAt);
|
|
5953
|
+
layout.badges = replaceSameSpot(
|
|
5954
|
+
diagram.steps.map((step, s) => {
|
|
5955
|
+
const line2 = placedBadges.get(s);
|
|
5956
|
+
if (!line2) return cornerBadge(step.events, s, layout);
|
|
5957
|
+
return { step: s, x: line2.point[0], y: line2.point[1], color: line2.edge.color };
|
|
5958
|
+
})
|
|
5959
|
+
);
|
|
4331
5960
|
return layout;
|
|
4332
5961
|
}
|
|
4333
5962
|
function colorOf(edge2, colors) {
|
|
@@ -4342,7 +5971,15 @@ function plan(step) {
|
|
|
4342
5971
|
let arrived;
|
|
4343
5972
|
let changes = 0;
|
|
4344
5973
|
step.events.forEach((event2, e) => {
|
|
4345
|
-
if (event2.type === "
|
|
5974
|
+
if (event2.type === "commit" || event2.type === "branch") {
|
|
5975
|
+
const a = cursor;
|
|
5976
|
+
const b = a + MOTION.draw;
|
|
5977
|
+
out.edges.push({ event: e, a, b, carries: false, coin: false, named: false });
|
|
5978
|
+
cursor = a + MOTION.stagger;
|
|
5979
|
+
arrived = b;
|
|
5980
|
+
changes = 0;
|
|
5981
|
+
out.busy = Math.max(out.busy, b);
|
|
5982
|
+
} else if (event2.type === "edge") {
|
|
4346
5983
|
const carries = event2.carry.kind !== "none";
|
|
4347
5984
|
const a = cursor;
|
|
4348
5985
|
const b = a + (carries ? MOTION.drawCarry : MOTION.draw);
|
|
@@ -4387,7 +6024,9 @@ function buildTimeline(diagram) {
|
|
|
4387
6024
|
for (const edge2 of p.edges) {
|
|
4388
6025
|
const a = span.start + edge2.a;
|
|
4389
6026
|
edges.push({ step: s, event: edge2.event, start: a, drawn: span.start + edge2.b, end: span.end });
|
|
4390
|
-
|
|
6027
|
+
const event2 = diagram.steps[s]?.events[edge2.event];
|
|
6028
|
+
const own = diagram.kind === "git" && event2?.type === "edge" && event2.carry.kind === "tag" && event2.carry.text === event2.from;
|
|
6029
|
+
if (edge2.carries && !own) departures.push({ step: s, event: edge2.event, who: edge2.coin ? "coin" : "main", a, b: span.start + edge2.b });
|
|
4391
6030
|
if (edge2.named) named.push({ step: s, event: edge2.event, start: a + MOTION.labelDelay, end: span.end });
|
|
4392
6031
|
}
|
|
4393
6032
|
named.forEach((label2, k) => {
|
|
@@ -4496,6 +6135,38 @@ var ICONS = {
|
|
|
4496
6135
|
block: "M -9 -7 h18 a2 2 0 0 1 2 2 v10 a2 2 0 0 1 -2 2 h-18 a2 2 0 0 1 -2 -2 v-10 a2 2 0 0 1 2 -2 z M -11 -2.5 h22 M -6 2.5 h8"
|
|
4497
6136
|
};
|
|
4498
6137
|
|
|
6138
|
+
// src/render/ink.ts
|
|
6139
|
+
var ALWAYS = [[0, Number.POSITIVE_INFINITY]];
|
|
6140
|
+
var BITE = 0.5;
|
|
6141
|
+
var visible = (item, t) => item.shown.some(([a, b]) => a <= t && t < b);
|
|
6142
|
+
var spotOf = (ink) => ({ text: ink.text, rect: { x: ink.rect.x, y: ink.rect.y, w: ink.rect.w, h: ink.rect.h }, badge: ink.badge === true, ...ink.part ? { part: ink.part } : {} });
|
|
6143
|
+
function findOverlaps(inks, stills, traces = []) {
|
|
6144
|
+
const out = [];
|
|
6145
|
+
stills.forEach((t, step) => {
|
|
6146
|
+
const seen = inks.filter((ink) => visible(ink, t));
|
|
6147
|
+
seen.forEach((a, i) => {
|
|
6148
|
+
for (const b of seen.slice(i + 1)) {
|
|
6149
|
+
const w = Math.min(a.rect.x + a.rect.w, b.rect.x + b.rect.w) - Math.max(a.rect.x, b.rect.x);
|
|
6150
|
+
const h = Math.min(a.rect.y + a.rect.h, b.rect.y + b.rect.h) - Math.max(a.rect.y, b.rect.y);
|
|
6151
|
+
if (w > BITE && h > BITE) out.push({ kind: "texts", step, texts: [a.text, b.text], spots: [spotOf(a), spotOf(b)] });
|
|
6152
|
+
}
|
|
6153
|
+
});
|
|
6154
|
+
const lines = traces.filter((trace) => visible(trace, t));
|
|
6155
|
+
for (const ink of seen) {
|
|
6156
|
+
if (ink.boxed) continue;
|
|
6157
|
+
for (const line2 of lines) if (crossesRect(line2.points, ink.rect, BITE)) out.push({ kind: "line", step, text: ink.text, line: { from: line2.from, to: line2.to }, spots: [spotOf(ink)] });
|
|
6158
|
+
}
|
|
6159
|
+
});
|
|
6160
|
+
return out;
|
|
6161
|
+
}
|
|
6162
|
+
function describeOverlap(overlap, lang = "ja") {
|
|
6163
|
+
const t = FIGURE_TEXT[lang];
|
|
6164
|
+
const partName = (part) => part.kind === "icon" ? t.iconOf(part.box) : part.kind === "coin" ? t.coin : t.envelope;
|
|
6165
|
+
const name2 = (spot) => spot.badge ? t.badgeName(spot.text) : spot.part ? partName(spot.part) : t.quoted(spot.text);
|
|
6166
|
+
if (overlap.kind === "texts") return t.textsOverlap(name2(overlap.spots[0]), name2(overlap.spots[1]));
|
|
6167
|
+
return t.lineCrosses(overlap.line.from, overlap.line.to, name2(overlap.spots[0]));
|
|
6168
|
+
}
|
|
6169
|
+
|
|
4499
6170
|
// src/render/parts.ts
|
|
4500
6171
|
var esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
4501
6172
|
var r1 = (v) => Math.round(v * 100) / 100;
|
|
@@ -4537,6 +6208,10 @@ function arrowHead(points) {
|
|
|
4537
6208
|
const { arrow: a, arrowHalf: h } = LOOK.edge;
|
|
4538
6209
|
return `M ${r1(ex - dx * a - dy * h)} ${r1(ey - dy * a + dx * h)} L ${r1(ex)} ${r1(ey)} L ${r1(ex - dx * a + dy * h)} ${r1(ey - dy * a - dx * h)}`;
|
|
4539
6210
|
}
|
|
6211
|
+
function write(ink, cls, x, y, text2, style, shown2 = ALWAYS, anchor) {
|
|
6212
|
+
ink?.push({ text: text2, rect: textBox(text2, x, y, style, anchor), shown: shown2 });
|
|
6213
|
+
return `<text class="${cls}" x="${r1(x)}" y="${r1(y)}"${anchor ? ` text-anchor="${anchor}"` : ""}>${esc(text2)}</text>`;
|
|
6214
|
+
}
|
|
4540
6215
|
function rangeKf(m, ranges) {
|
|
4541
6216
|
const pts = [[0, { opacity: 0 }]];
|
|
4542
6217
|
for (const [a, b] of ranges) pts.push([a, { opacity: 0 }, EASE.out], [a + MOTION.fade, { opacity: 1 }], [b - 0.1, { opacity: 1 }, EASE.inOut], [b + 0.25, { opacity: 0 }]);
|
|
@@ -4553,21 +6228,22 @@ function activeKf(ctx, on) {
|
|
|
4553
6228
|
}
|
|
4554
6229
|
return rangeKf(ctx.m, ranges);
|
|
4555
6230
|
}
|
|
4556
|
-
function band(region) {
|
|
6231
|
+
function band(region, ink) {
|
|
4557
6232
|
const { radius, icon, iconRadius, iconScale, nameY, line: line2 } = LOOK.region;
|
|
4558
6233
|
const { x, y } = region.header;
|
|
4559
|
-
const lines = region.lines.map((t, k) =>
|
|
4560
|
-
const note = region.note ?
|
|
6234
|
+
const lines = region.lines.map((t, k) => write(ink, "dg-bz", x, region.y + nameY + k * line2, t, TYPE.regionName)).join("");
|
|
6235
|
+
const note = region.note ? write(ink, "dg-bx", x, region.y + nameY + region.lines.length * line2 + 1, region.note, TYPE.regionNote) : "";
|
|
4561
6236
|
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)}` : "";
|
|
4562
6237
|
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>`;
|
|
4563
6238
|
}
|
|
4564
|
-
function subLines(box, m, changes, y) {
|
|
6239
|
+
function subLines(box, m, changes, y, ink) {
|
|
4565
6240
|
const seq = [[0, box.sub ?? "", "dg-ss"], ...changes];
|
|
4566
6241
|
return seq.map(([t, text2, cls], k) => {
|
|
4567
6242
|
const next = seq[k + 1]?.[0];
|
|
4568
6243
|
const anim = k === 0 ? next === void 0 ? "" : m.until(next - MOTION.untilFade) : next === void 0 ? m.rise(t) : m.rise(t, next - MOTION.untilFade);
|
|
4569
6244
|
if (text2 === "") return "";
|
|
4570
|
-
|
|
6245
|
+
const shown2 = [[k === 0 ? 0 : t, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]];
|
|
6246
|
+
return `<g${anim ? ` class="dg-a" style="${anim}"` : ""}>${write(ink, cls, box.cx, y, text2, cls === "dg-ss" ? TYPE.boxSub : TYPE.boxSubStrong, shown2, "middle")}</g>`;
|
|
4571
6247
|
}).join("");
|
|
4572
6248
|
}
|
|
4573
6249
|
function cardFrame(box, ctx, act, y, h) {
|
|
@@ -4576,10 +6252,17 @@ function cardFrame(box, ctx, act, y, h) {
|
|
|
4576
6252
|
}
|
|
4577
6253
|
function card(box, ctx, on, changes, lit) {
|
|
4578
6254
|
const { icon, iconRadius, iconScale, iconY, nameY, subY } = LOOK.box;
|
|
4579
|
-
const subs = subLines(box, ctx.m, changes, box.cy + subY);
|
|
6255
|
+
const subs = subLines(box, ctx.m, changes, box.cy + subY, ctx.ink);
|
|
4580
6256
|
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;
|
|
4581
|
-
const
|
|
4582
|
-
|
|
6257
|
+
const ix = box.iconX ?? box.cx;
|
|
6258
|
+
const slot = box.slot ? `<rect class="dg-slot" x="${r1(box.slot.x)}" y="${r1(box.slot.y)}" width="${r1(box.slot.w)}" height="${r1(box.slot.h)}" rx="${LOOK.slot.radius}"/>` : "";
|
|
6259
|
+
let mark = "";
|
|
6260
|
+
if (box.icon && ICONS[box.icon]) {
|
|
6261
|
+
const rect = { x: ix - icon / 2, y: box.cy + iconY - icon / 2, w: icon, h: icon };
|
|
6262
|
+
ctx.ink.push({ text: `${box.name} \u306E\u7D75\u67C4`, rect, shown: ALWAYS, boxed: true, part: { kind: "icon", box: box.name } });
|
|
6263
|
+
mark = `<rect class="dg-ic" x="${r1(rect.x)}" y="${r1(rect.y)}" width="${icon}" height="${icon}" rx="${iconRadius}"/>${glyph(box.icon, ix, box.cy + iconY, iconScale)}`;
|
|
6264
|
+
}
|
|
6265
|
+
return `<g style="${cs(box.color)}">${cardFrame(box, ctx, act, box.y, box.h)}${slot}${mark}${write(ctx.ink, "dg-sn", box.cx, box.cy + nameY, box.name, TYPE.boxName, ALWAYS, "middle")}${subs}</g>`;
|
|
4583
6266
|
}
|
|
4584
6267
|
function headCard(box, ctx, on, changes) {
|
|
4585
6268
|
const { pad: pad2, h, nameY, subY } = LOOK.follow.head;
|
|
@@ -4587,15 +6270,15 @@ function headCard(box, ctx, on, changes) {
|
|
|
4587
6270
|
const act = on.length > 0 ? activeKf(ctx, on) : void 0;
|
|
4588
6271
|
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>`;
|
|
4589
6272
|
}
|
|
4590
|
-
function ghostCard(box) {
|
|
6273
|
+
function ghostCard(box, ink) {
|
|
4591
6274
|
const { icon, iconRadius, iconScale, radius } = LOOK.box;
|
|
4592
6275
|
const G = LOOK.state.ghost;
|
|
4593
6276
|
const ix = box.x + G.pad + icon / 2;
|
|
4594
6277
|
const tx = box.x + G.pad + icon + G.gap;
|
|
4595
6278
|
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
6279
|
const nameY = box.sub ? G.nameY : LOOK.baseline.mark;
|
|
4597
|
-
const sub = box.sub ?
|
|
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}
|
|
6280
|
+
const sub = box.sub ? write(ink, "dg-ss", tx, box.cy + G.subY, box.sub, TYPE.boxSub, ALWAYS, "start") : "";
|
|
6281
|
+
return `<g data-ghost="${esc(box.id)}" style="${cs(box.color)}"><rect class="dg-ghost" x="${r1(box.x)}" y="${r1(box.y)}" width="${r1(box.w)}" height="${box.h}" rx="${radius}"/>${mark}${write(ink, "dg-sn", tx, box.cy + nameY, box.name, TYPE.boxName, ALWAYS, "start")}${sub}</g>`;
|
|
4599
6282
|
}
|
|
4600
6283
|
function doneMark(box, at, ctx) {
|
|
4601
6284
|
const { r, inset } = LOOK.state.done;
|
|
@@ -4603,19 +6286,22 @@ function doneMark(box, at, ctx) {
|
|
|
4603
6286
|
const y = box.y + inset;
|
|
4604
6287
|
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
6288
|
}
|
|
4606
|
-
function path(p, color) {
|
|
4607
|
-
|
|
6289
|
+
function path(p, color, ink, traces) {
|
|
6290
|
+
traces.push({ from: p.from, to: p.to, points: p.points, shown: ALWAYS });
|
|
6291
|
+
const sans = p.label?.family === "sans";
|
|
6292
|
+
const label2 = p.label ? write(ink, `dg-path-t${sans ? " dg-path-tj" : ""}`, p.label.x + LOOK.label.padX, p.label.y + p.label.h / 2 + LOOK.baseline.label, p.label.text, sans ? TYPE.labelJa : TYPE.label) : "";
|
|
4608
6293
|
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
6294
|
}
|
|
4610
|
-
function side(s, color) {
|
|
6295
|
+
function side(s, color, ink) {
|
|
4611
6296
|
const { pad: pad2 } = LOOK.state.side;
|
|
4612
6297
|
const title = s.y + pad2 + TYPE.regionName.size;
|
|
4613
|
-
const notes = s.notes.map((note, k) =>
|
|
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}"
|
|
6298
|
+
const notes = s.notes.map((note, k) => write(ink, "dg-side-n", s.x + pad2, title + LOOK.region.line * (k + 1), note, TYPE.regionNote)).join("");
|
|
6299
|
+
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}"/>${write(ink, "dg-side-t", s.x + pad2, title, s.title, TYPE.regionName)}${notes}</g>`;
|
|
4615
6300
|
}
|
|
4616
|
-
function endMark(e, color) {
|
|
6301
|
+
function endMark(e, color, ink) {
|
|
4617
6302
|
const { end } = LOOK.state;
|
|
4618
|
-
const
|
|
6303
|
+
const at = markText(e);
|
|
6304
|
+
const text2 = e.text === "" ? "" : write(ink, "dg-mark", at[0], at[1], e.text, TYPE.regionNote);
|
|
4619
6305
|
const x = r1(e.x);
|
|
4620
6306
|
const y = r1(e.y);
|
|
4621
6307
|
if (e.kind === "start") return `<g data-end="start"><circle class="dg-start" cx="${x}" cy="${y}" r="${e.r}"/>${text2}</g>`;
|
|
@@ -4627,6 +6313,7 @@ function lifeline(x, y1, y2) {
|
|
|
4627
6313
|
}
|
|
4628
6314
|
function edge(e, time, ctx, past = false) {
|
|
4629
6315
|
const { m } = ctx;
|
|
6316
|
+
ctx.traces.push({ from: e.from, to: e.to, points: e.points, shown: ALWAYS });
|
|
4630
6317
|
const d = pathOf(e.points);
|
|
4631
6318
|
const head = arrowHead(e.points);
|
|
4632
6319
|
const { start: a, drawn: b, end } = time;
|
|
@@ -4670,12 +6357,15 @@ function edge(e, time, ctx, past = false) {
|
|
|
4670
6357
|
function label(l, time, ctx) {
|
|
4671
6358
|
const ja3 = l.family === "sans" ? " dg-capj" : "";
|
|
4672
6359
|
const { radius } = LOOK.label;
|
|
6360
|
+
ctx.ink.push({ text: l.text, rect: l, shown: [[time.start, time.end]], boxed: true });
|
|
6361
|
+
if (time.after) ctx.ink.push({ text: l.text, rect: textBox(l.text, l.x + l.w / 2, l.y + l.h / 2 + LOOK.baseline.label, l.family === "sans" ? TYPE.labelJa : TYPE.label, "middle"), shown: [[time.after.start, time.after.end]] });
|
|
4673
6362
|
const x = r1(l.x + l.w / 2);
|
|
4674
6363
|
const y = r1(l.y + l.h / 2 + LOOK.baseline.label);
|
|
4675
6364
|
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
6365
|
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>`;
|
|
4677
6366
|
}
|
|
4678
6367
|
function action(a, at, until, ctx) {
|
|
6368
|
+
ctx.ink.push({ text: a.text, rect: a, shown: [[at, until]], boxed: true });
|
|
4679
6369
|
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>`;
|
|
4680
6370
|
}
|
|
4681
6371
|
function carrierShape(e, sh) {
|
|
@@ -4693,11 +6383,12 @@ var easeInOut = (t) => t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
|
|
|
4693
6383
|
function carrier(e, time, ctx) {
|
|
4694
6384
|
const { m } = ctx;
|
|
4695
6385
|
const n = LOOK.carrier.samples;
|
|
4696
|
-
const
|
|
6386
|
+
const route = e.wait ? [e.wait, ...e.points] : e.points;
|
|
6387
|
+
const length = pathLength(route);
|
|
4697
6388
|
const { depart: a, arrive: b, start: from, end: gone } = time;
|
|
4698
6389
|
const path2 = [];
|
|
4699
6390
|
for (let k = 0; k <= n; k++) {
|
|
4700
|
-
const [x, y] = along(
|
|
6391
|
+
const [x, y] = along(route, easeInOut(k / n) * length);
|
|
4701
6392
|
path2.push([a + (b - a) * k / n, x, y]);
|
|
4702
6393
|
}
|
|
4703
6394
|
const first = path2[0];
|
|
@@ -4706,6 +6397,12 @@ function carrier(e, time, ctx) {
|
|
|
4706
6397
|
const pts = [[0, first[1], first[2]], ...path2];
|
|
4707
6398
|
if (e.settle) pts.push([Math.min(b + 0.3, Math.max(gone, b + 0.01)), rest[0], rest[1]]);
|
|
4708
6399
|
pts.push([gone, rest[0], rest[1]], [m.total, rest[0], rest[1]]);
|
|
6400
|
+
const [hx, hy] = carrierHalf(e.carry);
|
|
6401
|
+
const name2 = e.carry.kind === "tag" ? e.carry.text : e.carry.kind === "coin" ? "\u786C\u8CA8" : "\u5C01\u7B52";
|
|
6402
|
+
const part = e.carry.kind === "tag" ? {} : { part: { kind: e.carry.kind === "coin" ? "coin" : "envelope" } };
|
|
6403
|
+
const box = (p) => ({ x: p[0] - hx, y: p[1] - hy, w: hx * 2, h: hy * 2 });
|
|
6404
|
+
if (a > from) ctx.ink.push({ text: name2, rect: box([first[1], first[2]]), shown: [[from, a]], boxed: true, ...part });
|
|
6405
|
+
ctx.ink.push({ text: name2, rect: box(rest), shown: [[b, gone]], boxed: true, ...part });
|
|
4709
6406
|
const fade = gone < m.last ? 0.05 : 0.18;
|
|
4710
6407
|
return `<g class="dg-a" style="${m.move(pts, m.blink(from + 0.02, gone, fade))}">${carrierShape(e, ctx.sh)}</g>`;
|
|
4711
6408
|
}
|
|
@@ -4715,15 +6412,30 @@ function badge(b, ctx, grey = false) {
|
|
|
4715
6412
|
const a = span.start;
|
|
4716
6413
|
const e = span.end;
|
|
4717
6414
|
const { r, ring: rr } = LOOK.badge;
|
|
6415
|
+
const shown2 = { visibility: "visible" };
|
|
6416
|
+
const hidden = { visibility: "hidden" };
|
|
6417
|
+
const swap = b.until === void 0 ? void 0 : ctx.t.steps[b.until].start;
|
|
6418
|
+
const next = swap !== void 0 && swap <= e + 1e-6;
|
|
4718
6419
|
const fill = m.kf([
|
|
4719
|
-
[0, { opacity: 0, transform: "scale(.5)" }],
|
|
4720
|
-
[a, { opacity: 0, transform: "scale(.5)" }, EASE.pop],
|
|
4721
|
-
[a + 0.35, { opacity: 1, transform: "scale(1)" }],
|
|
4722
|
-
[e, { opacity: 1, transform: "scale(1)" }, EASE.inOut],
|
|
4723
|
-
[e + 0.4, { opacity: 0, transform: "scale(1)" }],
|
|
4724
|
-
[m.total, { opacity: 0, transform: "scale(.5)" }]
|
|
6420
|
+
[0, { opacity: 0, transform: "scale(.5)", ...hidden }],
|
|
6421
|
+
[a, { opacity: 0, transform: "scale(.5)", ...hidden }, EASE.pop],
|
|
6422
|
+
[a + 0.35, { opacity: 1, transform: "scale(1)", ...shown2 }],
|
|
6423
|
+
[e, { opacity: 1, transform: "scale(1)", ...shown2 }, EASE.inOut],
|
|
6424
|
+
[e + (next ? MOTION.untilFade : 0.4), { opacity: 0, transform: "scale(1)", ...hidden }],
|
|
6425
|
+
[m.total, { opacity: 0, transform: "scale(.5)", ...hidden }]
|
|
6426
|
+
]);
|
|
6427
|
+
const pastEnd = swap ?? m.last;
|
|
6428
|
+
const past = next ? m.kf([
|
|
6429
|
+
[0, { opacity: 0, ...hidden }],
|
|
6430
|
+
[m.total, { opacity: 0, ...hidden }]
|
|
6431
|
+
]) : m.kf([
|
|
6432
|
+
[0, { opacity: 0, ...hidden }],
|
|
6433
|
+
[e, { opacity: 0, ...hidden }, EASE.inOut],
|
|
6434
|
+
[e + 0.4, { opacity: 1, ...shown2 }],
|
|
6435
|
+
[pastEnd, { opacity: 1, ...shown2 }, EASE.inOut],
|
|
6436
|
+
...swap === void 0 ? [] : [[swap + MOTION.untilFade, { opacity: 0, ...hidden }]],
|
|
6437
|
+
[m.total, { opacity: 0, ...hidden }]
|
|
4725
6438
|
]);
|
|
4726
|
-
const past = m.kf([[0, { opacity: 0 }], [e, { opacity: 0 }, EASE.inOut], [e + 0.4, { opacity: 1 }], [m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]]);
|
|
4727
6439
|
const ring = m.kf([
|
|
4728
6440
|
[0, { opacity: 0, transform: "scale(1)" }],
|
|
4729
6441
|
[a + 0.05, { opacity: 0, transform: "scale(1)" }],
|
|
@@ -4735,6 +6447,7 @@ function badge(b, ctx, grey = false) {
|
|
|
4735
6447
|
const y = r1(b.y);
|
|
4736
6448
|
const ty = r1(b.y + LOOK.baseline.badge);
|
|
4737
6449
|
const no = b.step + 1;
|
|
6450
|
+
ctx.ink.push({ text: String(no), rect: { x: b.x - r, y: b.y - r, w: r * 2, h: r * 2 }, shown: [[a, pastEnd]], boxed: true, badge: true });
|
|
4738
6451
|
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>`;
|
|
4739
6452
|
}
|
|
4740
6453
|
function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map()) {
|
|
@@ -4744,7 +6457,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
|
|
|
4744
6457
|
const parts = [
|
|
4745
6458
|
`<rect class="dg-strip" 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}" ${sh}/>`,
|
|
4746
6459
|
`<g style="${cs("slate")}"><rect class="dg-bi" x="${r1(s.x + S2.pad)}" y="${r1(my - S2.icon / 2)}" width="${S2.icon}" height="${S2.icon}" rx="${LOOK.box.iconRadius}"/>${glyph("env", s.x + S2.pad + S2.icon / 2, my, 0.78)}</g>`,
|
|
4747
|
-
|
|
6460
|
+
write(ctx.ink, "dg-sh", s.x + S2.titleX, my + LOOK.baseline.stripTitle, s.title, TYPE.stripTitle)
|
|
4748
6461
|
];
|
|
4749
6462
|
s.fields.forEach((field2, i) => {
|
|
4750
6463
|
const prev = s.fields[i - 1];
|
|
@@ -4752,7 +6465,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
|
|
|
4752
6465
|
const sx = field2.x - S2.fieldGap / 2;
|
|
4753
6466
|
parts.push(`<line class="dg-sep" x1="${r1(sx)}" y1="${r1(field2.y + S2.sepInset)}" x2="${r1(sx)}" y2="${r1(field2.y + S2.h - S2.sepInset)}"/>`);
|
|
4754
6467
|
}
|
|
4755
|
-
parts.push(
|
|
6468
|
+
parts.push(write(ctx.ink, "dg-fl", field2.x, field2.y + S2.nameY, field2.name, TYPE.fieldName));
|
|
4756
6469
|
const list2 = changes.get(field2.name) ?? [];
|
|
4757
6470
|
const values = list2.filter((c) => c.value !== void 0);
|
|
4758
6471
|
const tags = list2.filter((c) => c.tag !== void 0);
|
|
@@ -4760,6 +6473,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
|
|
|
4760
6473
|
const next = values[k + 1]?.at;
|
|
4761
6474
|
const value2 = c.value;
|
|
4762
6475
|
const cls = hasWide(value2) ? "dg-fvj" : "dg-fv";
|
|
6476
|
+
ctx.ink.push({ text: value2, rect: textBox(value2, field2.x, field2.y + S2.valueY, hasWide(value2) ? TYPE.fieldValueJa : TYPE.fieldValue), shown: [[c.at, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]] });
|
|
4763
6477
|
const textOf = (c2) => `<text class="${c2}" x="${r1(field2.x)}" y="${r1(field2.y + S2.valueY)}">${esc(value2)}</text>`;
|
|
4764
6478
|
const text2 = textOf(cls);
|
|
4765
6479
|
if (!now) {
|
|
@@ -4779,6 +6493,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
|
|
|
4779
6493
|
const x = field2.x + (shown2 ? textWidth(shown2, hasWide(shown2) ? TYPE.fieldValueJa : TYPE.fieldValue) + S2.tagGap : 0);
|
|
4780
6494
|
const w = textWidth(tag, TYPE.tag) + S2.tagPadX * 2;
|
|
4781
6495
|
const y = field2.y + S2.valueY - S2.tagH / 2 - LOOK.baseline.tag;
|
|
6496
|
+
ctx.ink.push({ text: tag, rect: { x, y, w, h: S2.tagH }, shown: [[c.at, next === void 0 ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]], boxed: true });
|
|
4782
6497
|
parts.push(
|
|
4783
6498
|
`<g class="dg-tg dg-popc dg-a" style="${cs(c.color)};${next === void 0 ? m.pop(c.at) : m.pop(c.at, next - MOTION.untilFade)}"><rect x="${r1(x)}" y="${r1(y)}" width="${r1(w)}" height="${S2.tagH}" rx="${S2.tagH / 2}"/><text x="${r1(x + w / 2)}" y="${r1(y + S2.tagH / 2 + LOOK.baseline.tag)}" text-anchor="middle">${esc(tag)}</text></g>`
|
|
4784
6499
|
);
|
|
@@ -4791,7 +6506,7 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
|
|
|
4791
6506
|
const sx = t.x - S2.fieldGap / 2;
|
|
4792
6507
|
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
6508
|
}
|
|
4794
|
-
parts.push(
|
|
6509
|
+
parts.push(write(ctx.ink, "dg-fl", t.x, t.y + S2.nameY, t.title, TYPE.fieldName));
|
|
4795
6510
|
const dy = t.y + S2.valueY - TYPE.fieldValue.size / 3;
|
|
4796
6511
|
t.states.forEach((state, k) => {
|
|
4797
6512
|
const cx = r1(t.x + S2.trail.r + k * S2.trail.step);
|
|
@@ -4803,6 +6518,123 @@ function strip(s, changes, ctx, now = false, arrivals = /* @__PURE__ */ new Map(
|
|
|
4803
6518
|
return parts.join("");
|
|
4804
6519
|
}
|
|
4805
6520
|
|
|
6521
|
+
// src/render/git.ts
|
|
6522
|
+
var r12 = (v) => Math.round(v * 100) / 100;
|
|
6523
|
+
var center = (r) => [r.x + r.w / 2, r.y + r.h / 2];
|
|
6524
|
+
function tagShape(text2, sh) {
|
|
6525
|
+
const C = LOOK.carrier;
|
|
6526
|
+
const ja3 = hasWide(text2);
|
|
6527
|
+
const w = textWidth(text2, ja3 ? TYPE.carrierJa : TYPE.carrier) + C.tagPadX * 2;
|
|
6528
|
+
return `<rect class="dg-car" x="${r12(-w / 2)}" y="${ -18 / 2}" width="${r12(w)}" height="${C.tagH}" rx="${C.tagH / 2}" ${sh}/><text class="dg-car-t${ja3 ? " dg-car-tj" : ""}" y="${LOOK.baseline.carrier}" text-anchor="middle">${esc(text2)}</text>`;
|
|
6529
|
+
}
|
|
6530
|
+
function drawGit(layout, diagram, timeline, ctx) {
|
|
6531
|
+
const { m } = ctx;
|
|
6532
|
+
const G = LOOK.git;
|
|
6533
|
+
const timeOf = (step, event2) => timeline.edges.find((t) => t.step === step && t.event === event2);
|
|
6534
|
+
const links = layout.links.map((l) => {
|
|
6535
|
+
const time = timeOf(l.step, l.event);
|
|
6536
|
+
if (!time) return "";
|
|
6537
|
+
ctx.traces.push({ from: l.from, to: l.to, points: l.points, shown: [[time.start, Number.POSITIVE_INFINITY]] });
|
|
6538
|
+
const d = pathOf(l.points);
|
|
6539
|
+
if (l.kind === "copy") return `<g style="${cs(l.color)}"><path class="dg-git-cp dg-a" d="${d}" style="${m.vis(time.start, m.last)}"/></g>`;
|
|
6540
|
+
const kf = m.kf([
|
|
6541
|
+
[0, { opacity: 0, "stroke-dashoffset": 1 }],
|
|
6542
|
+
[time.start, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
|
|
6543
|
+
[time.start + 0.05, { opacity: 1 }],
|
|
6544
|
+
[time.drawn, { "stroke-dashoffset": 0 }],
|
|
6545
|
+
[m.last, { opacity: 1, "stroke-dashoffset": 0 }, EASE.inOut],
|
|
6546
|
+
[m.total, { opacity: 0, "stroke-dashoffset": 0 }]
|
|
6547
|
+
]);
|
|
6548
|
+
return `<g style="${cs(l.color)}"><path class="dg-git-l dg-a" pathLength="1" d="${d}" style="${kf}"/></g>`;
|
|
6549
|
+
}).join("");
|
|
6550
|
+
const commits = layout.commits.map((c) => {
|
|
6551
|
+
const at = timeOf(c.step, c.event)?.drawn ?? 0;
|
|
6552
|
+
const ring = { x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 };
|
|
6553
|
+
ctx.ink.push({ text: c.id, rect: ring, shown: [[at, Number.POSITIVE_INFINITY]], boxed: true });
|
|
6554
|
+
const lines2 = (c.text?.lines ?? []).map((line2, k) => {
|
|
6555
|
+
const hash = k === 0 && c.hash !== void 0;
|
|
6556
|
+
const baseline = c.text?.baselines[k] ?? c.cy;
|
|
6557
|
+
return write(ctx.ink, hash ? "dg-git-h" : "dg-git-n", c.cx, baseline, line2, hash ? TYPE.gitHash : TYPE.gitNote, [[at, Number.POSITIVE_INFINITY]], "middle");
|
|
6558
|
+
}).join("");
|
|
6559
|
+
const id = `<text class="dg-git-id" x="${r12(c.cx)}" y="${r12(c.cy + LOOK.baseline.badge)}" text-anchor="middle">${esc(c.id)}</text>`;
|
|
6560
|
+
const node = `<g class="dg-popc dg-a" style="${m.pop(at)}"><circle class="dg-git-c" cx="${r12(c.cx)}" cy="${r12(c.cy)}" r="${c.r}" ${ctx.sh}/>${id}</g>`;
|
|
6561
|
+
const text2 = lines2 === "" ? "" : `<g class="dg-a" style="${m.vis(at)}">${lines2}</g>`;
|
|
6562
|
+
const orphanAt = c.orphan === void 0 ? void 0 : timeOf(c.orphan, c.orphanEvent ?? 0)?.drawn;
|
|
6563
|
+
const orphan = orphanAt === void 0 ? "" : `<g class="dg-a" data-orphan="${esc(c.id)}" style="${m.vis(orphanAt, m.last, { f: 0.5 })}"><circle class="dg-git-old" cx="${r12(c.cx)}" cy="${r12(c.cy)}" r="${G.orphan}"/><text class="dg-git-oldl" x="${r12(c.cx)}" y="${r12(c.cy + LOOK.baseline.badge)}" text-anchor="middle">${esc(c.id)}</text></g>`;
|
|
6564
|
+
return `<g data-commit="${esc(c.id)}" style="${cs(c.color)}">${node}${text2}${orphan}</g>`;
|
|
6565
|
+
}).join("");
|
|
6566
|
+
const lines = layout.moves.flatMap((mv) => {
|
|
6567
|
+
const time = timeOf(mv.step, mv.event);
|
|
6568
|
+
if (!mv.line || !time) return [];
|
|
6569
|
+
const end = timeline.steps[mv.step].end;
|
|
6570
|
+
ctx.traces.push({ from: mv.ref, to: mv.target ?? mv.ref, points: mv.line, shown: [[time.start, end + 0.4]] });
|
|
6571
|
+
const kf = m.kf([
|
|
6572
|
+
[0, { opacity: 0, "stroke-dashoffset": 1 }],
|
|
6573
|
+
[time.start, { opacity: 0, "stroke-dashoffset": 1 }, EASE.inOut],
|
|
6574
|
+
[time.start + 0.05, { opacity: 1 }],
|
|
6575
|
+
[time.drawn, { "stroke-dashoffset": 0 }],
|
|
6576
|
+
[end, { opacity: 1 }, EASE.inOut],
|
|
6577
|
+
[end + 0.4, { opacity: 0 }],
|
|
6578
|
+
[m.total, { opacity: 0, "stroke-dashoffset": 0 }]
|
|
6579
|
+
]);
|
|
6580
|
+
return [`<g style="${cs(mv.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${pathOf(mv.line)}" style="${kf}"/></g>`];
|
|
6581
|
+
}).join("");
|
|
6582
|
+
const carried = timeline.carriers.flatMap((t) => {
|
|
6583
|
+
const mv = layout.moves.find((x) => x.step === t.step && x.event === t.event && x.line);
|
|
6584
|
+
const source = diagram.steps[t.step]?.events[t.event];
|
|
6585
|
+
if (!mv?.line || source?.type !== "edge") return [];
|
|
6586
|
+
const edge2 = { step: t.step, event: t.event, from: mv.ref, to: mv.target ?? mv.ref, points: mv.line, color: mv.color, carry: source.carry };
|
|
6587
|
+
return [carrier(edge2, { ...t, start: t.depart, end: t.arrive + MOTION.fade }, ctx)];
|
|
6588
|
+
}).join("");
|
|
6589
|
+
const refs = [...new Set(layout.moves.map((mv) => mv.ref))];
|
|
6590
|
+
const tags = refs.map((ref) => tagMotion(ref, layout.moves.filter((mv) => mv.ref === ref), timeOf, ctx)).join("") + carried;
|
|
6591
|
+
return { links, lines, commits, tags };
|
|
6592
|
+
}
|
|
6593
|
+
function tagMotion(ref, list2, timeOf, ctx) {
|
|
6594
|
+
const { m } = ctx;
|
|
6595
|
+
const points = [];
|
|
6596
|
+
const fades = [[0, { opacity: 0 }]];
|
|
6597
|
+
let on = false;
|
|
6598
|
+
let rest;
|
|
6599
|
+
const leave = (t) => {
|
|
6600
|
+
if (rest) ctx.ink.push({ text: ref, rect: rest.rect, shown: [[rest.since, t]], boxed: true });
|
|
6601
|
+
rest = void 0;
|
|
6602
|
+
};
|
|
6603
|
+
for (const mv of list2) {
|
|
6604
|
+
const time = timeOf(mv.step, mv.event);
|
|
6605
|
+
if (!time) continue;
|
|
6606
|
+
const { start: a, drawn: b } = time;
|
|
6607
|
+
const from = mv.from ? center(mv.from) : void 0;
|
|
6608
|
+
const to = mv.to ? center(mv.to) : void 0;
|
|
6609
|
+
leave(a);
|
|
6610
|
+
if (mv.carried && from && to && on) {
|
|
6611
|
+
points.push([a + MOTION.fade, from[0], from[1]], [b - MOTION.fade, to[0], to[1]]);
|
|
6612
|
+
fades.push([a, { opacity: 1 }, EASE.inOut], [a + MOTION.fade, { opacity: 0 }], [b - MOTION.fade, { opacity: 0 }, EASE.out], [b, { opacity: 1 }]);
|
|
6613
|
+
rest = { rect: mv.to, since: b };
|
|
6614
|
+
continue;
|
|
6615
|
+
}
|
|
6616
|
+
if (from) points.push([a, from[0], from[1]]);
|
|
6617
|
+
if (to) points.push([b, to[0], to[1]]);
|
|
6618
|
+
if (to && !on) {
|
|
6619
|
+
const show = from ? a : b - MOTION.fade;
|
|
6620
|
+
fades.push([show, { opacity: 0 }, EASE.out], [show + MOTION.fade, { opacity: 1 }]);
|
|
6621
|
+
on = true;
|
|
6622
|
+
} else if (!to && on) {
|
|
6623
|
+
fades.push([b, { opacity: 1 }, EASE.inOut], [b + MOTION.untilFade, { opacity: 0 }]);
|
|
6624
|
+
on = false;
|
|
6625
|
+
}
|
|
6626
|
+
if (mv.to) rest = { rect: mv.to, since: b };
|
|
6627
|
+
}
|
|
6628
|
+
leave(Number.POSITIVE_INFINITY);
|
|
6629
|
+
if (points.length === 0) return "";
|
|
6630
|
+
const first = points[0];
|
|
6631
|
+
const last = points[points.length - 1];
|
|
6632
|
+
if (on) fades.push([m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]);
|
|
6633
|
+
else fades.push([m.total, { opacity: 0 }]);
|
|
6634
|
+
const style = m.move([[0, first[1], first[2]], ...points, [m.total, last[1], last[2]]], fades);
|
|
6635
|
+
return `<g class="dg-a" data-ref="${esc(ref)}" style="${style}">${tagShape(ref, ctx.sh)}</g>`;
|
|
6636
|
+
}
|
|
6637
|
+
|
|
4806
6638
|
// src/render/motion.ts
|
|
4807
6639
|
var r2 = (v) => Math.round(v * 100) / 100;
|
|
4808
6640
|
var Motion = class {
|
|
@@ -4910,6 +6742,7 @@ var PART_CSS = [
|
|
|
4910
6742
|
`.dg-halo{fill:none;stroke:var(--c);stroke-width:${S.halo};stroke-opacity:.16}`,
|
|
4911
6743
|
`.dg-on{fill:none;stroke:var(--c);stroke-width:${S.on}}`,
|
|
4912
6744
|
`.dg-ic{fill:${mix(X.icon)}}`,
|
|
6745
|
+
`.dg-slot{fill:none;stroke:${mix(X.slot, "transparent")};stroke-width:${S.slot};stroke-dasharray:3 3}`,
|
|
4913
6746
|
`.dg-gl{fill:none;stroke:var(--c);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
|
|
4914
6747
|
`.dg-sn{${font(TYPE.boxName)};fill:var(--ink)}`,
|
|
4915
6748
|
`.dg-ss{${font(TYPE.boxSub)};fill:var(--mute)}`,
|
|
@@ -4926,7 +6759,7 @@ var PART_CSS = [
|
|
|
4926
6759
|
".dg-bd{cursor:pointer}",
|
|
4927
6760
|
".dg-bdf{fill:var(--c)}",
|
|
4928
6761
|
`.dg-bdft{${font(TYPE.badge)};fill:var(--on-c)}`,
|
|
4929
|
-
`.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing}}`,
|
|
6762
|
+
`.dg-bdr{fill:none;stroke:var(--c);stroke-width:${S.badgeRing};pointer-events:none}`,
|
|
4930
6763
|
`.dg-bdp{fill:${mix(X.badgePast)};stroke:${mix(X.badgePastEdge, "transparent")};stroke-width:${S.hair}}`,
|
|
4931
6764
|
`.dg-bdpt{${font(TYPE.badge)};fill:var(--ct)}`,
|
|
4932
6765
|
`.dg-bdp-g{fill:var(--surf);stroke:${PAST};stroke-width:${S.hair}}`,
|
|
@@ -4972,6 +6805,14 @@ var PART_CSS = [
|
|
|
4972
6805
|
`.dg-mark{${font(TYPE.regionNote)};fill:var(--mute)}`,
|
|
4973
6806
|
`.dg-done{fill:var(--ink);stroke:var(--surf);stroke-width:${S.done}}`,
|
|
4974
6807
|
`.dg-done-ck{fill:none;stroke:var(--surf);stroke-width:${S.glyph};stroke-linecap:round;stroke-linejoin:round}`,
|
|
6808
|
+
`.dg-git-l{fill:none;stroke:var(--c);stroke-width:${S.git};stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1 2}`,
|
|
6809
|
+
`.dg-git-cp{fill:none;stroke:var(--c);stroke-width:${S.gitOrphan};stroke-linecap:round;stroke-dasharray:3 3;stroke-opacity:.7}`,
|
|
6810
|
+
`.dg-git-c{fill:var(--surf);stroke:var(--c);stroke-width:${S.git}}`,
|
|
6811
|
+
`.dg-git-id{${font(TYPE.gitId)};fill:var(--ct)}`,
|
|
6812
|
+
`.dg-git-h{${font(TYPE.gitHash)};fill:var(--mute)}`,
|
|
6813
|
+
`.dg-git-n{${font(TYPE.gitNote)};fill:var(--ink2)}`,
|
|
6814
|
+
`.dg-git-old{fill:var(--surf);stroke:var(--c);stroke-width:${S.gitOrphan};stroke-dasharray:3 3;stroke-opacity:.6}`,
|
|
6815
|
+
`.dg-git-oldl{${font(TYPE.gitId)};fill:var(--ct);opacity:.55}`,
|
|
4975
6816
|
".dg-vp-bg{fill:var(--bg)}",
|
|
4976
6817
|
".dg-vp-frame{fill:none;stroke:var(--hair)}",
|
|
4977
6818
|
".dg-hd-bg{fill:var(--bg)}",
|
|
@@ -5055,23 +6896,36 @@ function fieldChanges(diagram, timeline, layout) {
|
|
|
5055
6896
|
}
|
|
5056
6897
|
return out;
|
|
5057
6898
|
}
|
|
5058
|
-
function
|
|
6899
|
+
function fadeBefore(l, time, steps) {
|
|
6900
|
+
if (l.until === void 0 || !time.after) return time;
|
|
6901
|
+
const cut = steps[l.until].start;
|
|
6902
|
+
const { after, ...rest } = time;
|
|
6903
|
+
return cut > after.start ? { ...rest, after: { start: after.start, end: Math.min(after.end, cut) } } : rest;
|
|
6904
|
+
}
|
|
6905
|
+
function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], traces = []) {
|
|
5059
6906
|
const id = nameOf(`${JSON.stringify(diagram)}|${palette.id}|${theme}|${follow ? `${follow.width}|${follow.lang}` : ""}`);
|
|
5060
6907
|
const m = new Motion(`dg${id}`, timeline.total, timeline.last);
|
|
5061
|
-
const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end };
|
|
6908
|
+
const ctx = { m, t: timeline, sh: `filter="url(#dg-sh-${id})"`, end: timeline.steps[timeline.steps.length - 1].end, ink, traces };
|
|
5062
6909
|
const on = involved(diagram);
|
|
5063
6910
|
const subs = subChanges(diagram, timeline, layout.kind !== "sequence");
|
|
5064
6911
|
const L = { band: [], base: [], lit: [], node: [], badge: [], top: [] };
|
|
5065
|
-
for (const region of layout.regions) L.band.push(band(region));
|
|
6912
|
+
for (const region of layout.regions) L.band.push(band(region, ink));
|
|
5066
6913
|
const ghostColor = layout.boxes.find((b) => b.ghost)?.color ?? "slate";
|
|
5067
|
-
if (layout.side) L.band.push(side(layout.side, ghostColor));
|
|
6914
|
+
if (layout.side) L.band.push(side(layout.side, ghostColor, ink));
|
|
5068
6915
|
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));
|
|
6916
|
+
for (const p of layout.paths) L.base.push(path(p, boxColor(p.to, true) ?? boxColor(p.from) ?? ghostColor, ink, traces));
|
|
6917
|
+
for (const e of layout.ends) L.node.push(endMark(e, ghostColor, ink));
|
|
5071
6918
|
const isState = layout.kind === "state";
|
|
5072
6919
|
const arrivals = new Map((timeline.states ?? []).flatMap((s) => s.lit[0] ? [[s.box, s.lit[0].start]] : []));
|
|
5073
6920
|
if (layout.strip) L.band.push(strip(layout.strip, fieldChanges(diagram, timeline, layout), ctx, isState, arrivals));
|
|
5074
6921
|
for (const line2 of layout.lifelines) L.base.push(lifeline(line2.x, line2.y1, line2.y2));
|
|
6922
|
+
if (isGitLayout(layout)) {
|
|
6923
|
+
const git = drawGit(layout, diagram, timeline, ctx);
|
|
6924
|
+
L.base.push(git.links);
|
|
6925
|
+
L.lit.push(git.lines);
|
|
6926
|
+
L.node.push(git.commits);
|
|
6927
|
+
L.top.push(git.tags);
|
|
6928
|
+
}
|
|
5075
6929
|
for (const e of layout.edges) {
|
|
5076
6930
|
const time = timeline.edges.find((t) => t.step === e.step && t.event === e.event);
|
|
5077
6931
|
if (!time) continue;
|
|
@@ -5082,7 +6936,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
|
|
|
5082
6936
|
const states = new Map((timeline.states ?? []).map((s) => [s.box, s]));
|
|
5083
6937
|
for (const box of layout.boxes) {
|
|
5084
6938
|
if (box.ghost) {
|
|
5085
|
-
L.node.push(ghostCard(box));
|
|
6939
|
+
L.node.push(ghostCard(box, ink));
|
|
5086
6940
|
continue;
|
|
5087
6941
|
}
|
|
5088
6942
|
const state = states.get(box.id);
|
|
@@ -5092,7 +6946,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
|
|
|
5092
6946
|
for (const b of layout.badges) L.badge.push(badge(b, ctx, isState));
|
|
5093
6947
|
for (const l of layout.labels) {
|
|
5094
6948
|
const time = timeline.labels.find((t) => t.step === l.step && t.event === l.event);
|
|
5095
|
-
if (time) L.top.push(label(l, time, ctx));
|
|
6949
|
+
if (time) L.top.push(label(l, fadeBefore(l, time, timeline.steps), ctx));
|
|
5096
6950
|
}
|
|
5097
6951
|
for (const a of layout.actions) {
|
|
5098
6952
|
const time = timeline.events.find((t) => t.step === a.step && t.event === a.event);
|
|
@@ -5110,14 +6964,14 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow) {
|
|
|
5110
6964
|
const css = `.dg-${id}{${FONT_VARS};--T:${timeline.total}s;${paletteVars(palette, theme)}}${PART_CSS}${m.frames.join("")}`;
|
|
5111
6965
|
return `<svg xmlns="http://www.w3.org/2000/svg" class="dg dg-${id}" viewBox="0 0 ${Math.ceil(view.w)} ${Math.ceil(view.h)}" width="${Math.ceil(view.w)}" height="${Math.ceil(view.h)}" role="img" aria-label="${esc(diagram.title)}" data-dragon="figure" data-view="${follow ? "follow" : "fixed"}"><style>${css}</style><defs>${shadow}</defs>${view.body}</svg>`;
|
|
5112
6966
|
}
|
|
5113
|
-
function
|
|
6967
|
+
function union2(rects) {
|
|
5114
6968
|
const x = Math.min(...rects.map((r) => r.x));
|
|
5115
6969
|
const y = Math.min(...rects.map((r) => r.y));
|
|
5116
6970
|
return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
|
|
5117
6971
|
}
|
|
5118
6972
|
function focusOf(layout, diagram, step) {
|
|
5119
6973
|
const rects = focusParts(layout, diagram, step);
|
|
5120
|
-
return rects.length === 0 ? void 0 :
|
|
6974
|
+
return rects.length === 0 ? void 0 : union2(rects);
|
|
5121
6975
|
}
|
|
5122
6976
|
function badgeFocus(badge2, parts, vw, vh) {
|
|
5123
6977
|
const room = LOOK.badge.r + LOOK.follow.badgeRoom;
|
|
@@ -5125,7 +6979,7 @@ function badgeFocus(badge2, parts, vw, vh) {
|
|
|
5125
6979
|
const away = (p) => Math.hypot(Math.max(0, p.x - bx, bx - p.x - p.w), Math.max(0, p.y - by, by - p.y - p.h));
|
|
5126
6980
|
let held = { x: bx - room, y: by - room, w: room * 2, h: room * 2 };
|
|
5127
6981
|
for (const p of [...parts].sort((a, b) => away(a) - away(b))) {
|
|
5128
|
-
const next =
|
|
6982
|
+
const next = union2([held, p]);
|
|
5129
6983
|
if (next.w <= vw && next.h <= vh) held = next;
|
|
5130
6984
|
}
|
|
5131
6985
|
return held;
|
|
@@ -5223,19 +7077,25 @@ function renderDiagram(input, options = {}) {
|
|
|
5223
7077
|
const read = readDiagram(input, { lang });
|
|
5224
7078
|
if (!read.ok) throw new Error(FIGURE_TEXT[lang].cannotDraw(read.errors.map((e) => `${e.pointer} ${e.message}`).join(" / ")));
|
|
5225
7079
|
const diagram = read.diagram;
|
|
7080
|
+
const layout = diagram.kind === "sequence" ? layoutSequence(diagram) : diagram.kind === "state" ? layoutState(diagram, lang) : diagram.kind === "git" ? layoutGit(diagram) : layoutArchitecture(diagram);
|
|
7081
|
+
return renderLayout(diagram, layout, buildTimeline(diagram), options);
|
|
7082
|
+
}
|
|
7083
|
+
function renderLayout(diagram, layout, timeline, options = {}) {
|
|
5226
7084
|
const palette = resolvePalette(options.palette);
|
|
5227
7085
|
const theme = options.theme === "dark" ? "dark" : "light";
|
|
5228
|
-
const
|
|
5229
|
-
const
|
|
7086
|
+
const ink = [];
|
|
7087
|
+
const traces = [];
|
|
7088
|
+
const svg = drawSvg(diagram, layout, timeline, palette, theme, void 0, ink, traces);
|
|
5230
7089
|
return {
|
|
5231
|
-
svg
|
|
7090
|
+
svg,
|
|
5232
7091
|
palette: palette.id,
|
|
5233
7092
|
theme,
|
|
5234
7093
|
...diagram.view ? { view: diagram.view } : {},
|
|
5235
7094
|
fonts: { ...FONTS },
|
|
5236
7095
|
layout,
|
|
5237
7096
|
timeline,
|
|
5238
|
-
diagram
|
|
7097
|
+
diagram,
|
|
7098
|
+
overlaps: findOverlaps(ink, timeline.stills, traces)
|
|
5239
7099
|
};
|
|
5240
7100
|
}
|
|
5241
7101
|
|
|
@@ -5279,7 +7139,8 @@ function playerCss() {
|
|
|
5279
7139
|
`@container dg-bar (width < ${px(P.narrow)}){.dg-row{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:start;gap:0 ${px(P.gap)}}.dg-say,.dg-txt,.dg-txt>*{display:contents}.dg-btns{grid-area:1/1;margin-bottom:${px(P.gap / 2)}}.dg-btn{width:${px(P.touch)};height:${px(P.touch)}}.dg-no{grid-area:1/2;display:flex;align-items:center;min-height:${px(P.touch)};padding-top:0}.dg-tt{grid-area:2/1/3/3}.dg-tb{grid-area:3/1/4/3}}`,
|
|
5280
7140
|
// 指で触る時は、広い帯でも段を送る釦を指で押せる大きさにする (#3076)。並びは横 1 列のまま変えない。
|
|
5281
7141
|
// 広い帯は本文が 2 行あれば帯の高さが変わらず、本文の無い帯だけが釦の分だけ高くなる
|
|
5282
|
-
`@media (pointer: coarse){.dg-btn{width:${px(P.touch)};height:${px(P.touch)}}}
|
|
7142
|
+
`@media (pointer: coarse){.dg-btn{width:${px(P.touch)};height:${px(P.touch)}}}`,
|
|
7143
|
+
`.dg-spot{fill:none;stroke:var(--t-amber);stroke-width:${px(LOOK.stroke.mark)};stroke-dasharray:${LOOK.mark.dash} ${LOOK.mark.gap};pointer-events:none}`
|
|
5283
7144
|
].join("");
|
|
5284
7145
|
}
|
|
5285
7146
|
function ensureCss(doc) {
|
|
@@ -5290,6 +7151,7 @@ function ensureCss(doc) {
|
|
|
5290
7151
|
doc.head.appendChild(style);
|
|
5291
7152
|
}
|
|
5292
7153
|
var BUTTON_TEXT = { prev: "\u2039", pause: "\u275A\u275A", play: "\u25B6", next: "\u203A" };
|
|
7154
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
5293
7155
|
var pad = (n) => String(n).padStart(2, "0");
|
|
5294
7156
|
var stepNo = (step, count) => `${pad(step + 1)}/${pad(count)}`;
|
|
5295
7157
|
function mountDiagram(host, diagram, options = {}) {
|
|
@@ -5397,6 +7259,26 @@ function mountDiagram(host, diagram, options = {}) {
|
|
|
5397
7259
|
let playing = !reduce;
|
|
5398
7260
|
let at = reduce ? timeline.stills[0] ?? 0 : 0;
|
|
5399
7261
|
let born = Date.now();
|
|
7262
|
+
let marked = [];
|
|
7263
|
+
const drawMarks = () => {
|
|
7264
|
+
if (!svg) return;
|
|
7265
|
+
for (const old of svg.querySelectorAll(".dg-spots")) old.remove();
|
|
7266
|
+
if (marked.length === 0) return;
|
|
7267
|
+
const M = LOOK.mark;
|
|
7268
|
+
const group = doc.createElementNS(SVG_NS, "g");
|
|
7269
|
+
group.setAttribute("class", "dg-spots");
|
|
7270
|
+
for (const r of marked) {
|
|
7271
|
+
const rect = doc.createElementNS(SVG_NS, "rect");
|
|
7272
|
+
rect.setAttribute("class", "dg-spot");
|
|
7273
|
+
rect.setAttribute("x", String(r.x - M.pad));
|
|
7274
|
+
rect.setAttribute("y", String(r.y - M.pad));
|
|
7275
|
+
rect.setAttribute("width", String(r.w + M.pad * 2));
|
|
7276
|
+
rect.setAttribute("height", String(r.h + M.pad * 2));
|
|
7277
|
+
rect.setAttribute("rx", String(M.radius));
|
|
7278
|
+
group.append(rect);
|
|
7279
|
+
}
|
|
7280
|
+
(svg.querySelector('g[clip-path^="url(#dg-vp-"] > g.dg-a') ?? svg).append(group);
|
|
7281
|
+
};
|
|
5400
7282
|
const place = (markup2) => {
|
|
5401
7283
|
let next;
|
|
5402
7284
|
if (markup2 !== void 0) {
|
|
@@ -5417,6 +7299,7 @@ function mountDiagram(host, diagram, options = {}) {
|
|
|
5417
7299
|
else frame.append(next);
|
|
5418
7300
|
svg = next;
|
|
5419
7301
|
born = Date.now();
|
|
7302
|
+
drawMarks();
|
|
5420
7303
|
};
|
|
5421
7304
|
const markup = () => mode === "follow" ? drawSvg(rendered.diagram, rendered.layout, timeline, palette, rendered.theme, { width, ...height === void 0 ? {} : { height }, lang }) : rendered.svg;
|
|
5422
7305
|
const now = () => playing ? (at + (Date.now() - born) / 1e3) % timeline.total : at;
|
|
@@ -5498,6 +7381,14 @@ function mountDiagram(host, diagram, options = {}) {
|
|
|
5498
7381
|
pause: () => {
|
|
5499
7382
|
if (playing) restart(now(), false);
|
|
5500
7383
|
},
|
|
7384
|
+
goTo: (target) => {
|
|
7385
|
+
playing = false;
|
|
7386
|
+
go(target);
|
|
7387
|
+
},
|
|
7388
|
+
mark: (rects) => {
|
|
7389
|
+
marked = rects;
|
|
7390
|
+
drawMarks();
|
|
7391
|
+
},
|
|
5501
7392
|
destroy: () => {
|
|
5502
7393
|
if (timer !== void 0) win?.clearInterval(timer);
|
|
5503
7394
|
observer?.disconnect();
|
|
@@ -5510,6 +7401,6 @@ function mountDiagram(host, diagram, options = {}) {
|
|
|
5510
7401
|
};
|
|
5511
7402
|
}
|
|
5512
7403
|
|
|
5513
|
-
export { DEFAULT_PALETTE, FONTS, FORMAT_VERSION, ICONS, PALETTES, READABLE_PX, chooseView, extractDiagrams, iconSvg, migrateFile, mountDiagram, parseNotation, printNotation, readDiagram, renderDiagram, resolvePalette, validateDiagram };
|
|
7404
|
+
export { DEFAULT_PALETTE, FONTS, FORMAT_VERSION, ICONS, PALETTES, READABLE_PX, chooseView, describeOverlap, extractDiagrams, iconSvg, migrateFile, mountDiagram, parseNotation, printNotation, readDiagram, renderDiagram, resolvePalette, validateDiagram };
|
|
5514
7405
|
//# sourceMappingURL=index.js.map
|
|
5515
7406
|
//# sourceMappingURL=index.js.map
|