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