diagram-contracts 0.2.5 → 0.2.7
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/dist/cli.mjs +171 -94
- package/dist/diagram-contracts.browser.mjs +533 -220
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +130 -61
- package/package.json +1 -1
|
@@ -513,7 +513,6 @@ function tokenize(source) {
|
|
|
513
513
|
|
|
514
514
|
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
515
515
|
var NOT_RESOLVED = /* @__PURE__ */ Symbol("NOT_RESOLVED");
|
|
516
|
-
var MERGE_KEY = /* @__PURE__ */ Symbol("MERGE_KEY");
|
|
517
516
|
function defineScalarTag(tagName, options) {
|
|
518
517
|
return {
|
|
519
518
|
tagName,
|
|
@@ -522,9 +521,9 @@ function defineScalarTag(tagName, options) {
|
|
|
522
521
|
matchByTagPrefix: options.matchByTagPrefix ?? false,
|
|
523
522
|
implicitFirstChars: options.implicitFirstChars ?? null,
|
|
524
523
|
resolve: options.resolve,
|
|
525
|
-
identify: options.identify
|
|
524
|
+
identify: options.identify,
|
|
526
525
|
represent: options.represent ?? ((data) => String(data)),
|
|
527
|
-
representTagName: options.representTagName ??
|
|
526
|
+
representTagName: options.representTagName ?? (() => tagName)
|
|
528
527
|
};
|
|
529
528
|
}
|
|
530
529
|
function defineSequenceTag(tagName, options) {
|
|
@@ -538,9 +537,9 @@ function defineSequenceTag(tagName, options) {
|
|
|
538
537
|
addItem: options.addItem,
|
|
539
538
|
finalize: options.finalize ?? ((carrier) => carrier),
|
|
540
539
|
carrierIsResult,
|
|
541
|
-
identify: options.identify
|
|
540
|
+
identify: options.identify,
|
|
542
541
|
represent: options.represent ?? ((data) => data),
|
|
543
|
-
representTagName: options.representTagName ??
|
|
542
|
+
representTagName: options.representTagName ?? (() => tagName)
|
|
544
543
|
};
|
|
545
544
|
}
|
|
546
545
|
function defineMappingTag(tagName, options) {
|
|
@@ -557,9 +556,9 @@ function defineMappingTag(tagName, options) {
|
|
|
557
556
|
get: options.get,
|
|
558
557
|
finalize: options.finalize ?? ((carrier) => carrier),
|
|
559
558
|
carrierIsResult,
|
|
560
|
-
identify: options.identify
|
|
559
|
+
identify: options.identify,
|
|
561
560
|
represent: options.represent ?? ((data) => data),
|
|
562
|
-
representTagName: options.representTagName ??
|
|
561
|
+
representTagName: options.representTagName ?? (() => tagName)
|
|
563
562
|
};
|
|
564
563
|
}
|
|
565
564
|
var strTag = defineScalarTag("tag:yaml.org,2002:str", {
|
|
@@ -908,9 +907,10 @@ var mergeTag = defineScalarTag("tag:yaml.org,2002:merge", {
|
|
|
908
907
|
implicit: true,
|
|
909
908
|
implicitFirstChars: ["<"],
|
|
910
909
|
resolve: (source, isExplicit) => {
|
|
911
|
-
if (source === "<<" || isExplicit && source === "") return
|
|
910
|
+
if (source === "<<" || isExplicit && source === "") return "<<";
|
|
912
911
|
return NOT_RESOLVED;
|
|
913
|
-
}
|
|
912
|
+
},
|
|
913
|
+
identify: () => false
|
|
914
914
|
});
|
|
915
915
|
var BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
916
916
|
function resolveYamlBinary(source) {
|
|
@@ -933,6 +933,11 @@ var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
|
|
|
933
933
|
});
|
|
934
934
|
var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
935
935
|
var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
|
|
936
|
+
function makeUtcDate(year, month, day, hour = 0, minute = 0, second = 0, fraction = 0) {
|
|
937
|
+
const date5 = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
938
|
+
date5.setUTCFullYear(year, month, day);
|
|
939
|
+
return date5;
|
|
940
|
+
}
|
|
936
941
|
function resolveYamlTimestamp(source) {
|
|
937
942
|
let match = YAML_DATE_REGEXP.exec(source);
|
|
938
943
|
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
|
|
@@ -941,7 +946,7 @@ function resolveYamlTimestamp(source) {
|
|
|
941
946
|
const month = +match[2] - 1;
|
|
942
947
|
const day = +match[3];
|
|
943
948
|
if (!match[4]) {
|
|
944
|
-
const date6 =
|
|
949
|
+
const date6 = makeUtcDate(year, month, day);
|
|
945
950
|
if (date6.getUTCFullYear() !== year || date6.getUTCMonth() !== month || date6.getUTCDate() !== day) return NOT_RESOLVED;
|
|
946
951
|
return date6;
|
|
947
952
|
}
|
|
@@ -955,7 +960,7 @@ function resolveYamlTimestamp(source) {
|
|
|
955
960
|
while (value.length < 3) value += "0";
|
|
956
961
|
fraction = +value;
|
|
957
962
|
}
|
|
958
|
-
const date5 =
|
|
963
|
+
const date5 = makeUtcDate(year, month, day, hour, minute, second, fraction);
|
|
959
964
|
if (date5.getUTCFullYear() !== year || date5.getUTCMonth() !== month || date5.getUTCDate() !== day) return NOT_RESOLVED;
|
|
960
965
|
if (match[9]) {
|
|
961
966
|
const offsetHour = +match[10];
|
|
@@ -1010,7 +1015,8 @@ var omapTag = defineSequenceTag("tag:yaml.org,2002:omap", {
|
|
|
1010
1015
|
carrier.list.push(item);
|
|
1011
1016
|
return "";
|
|
1012
1017
|
},
|
|
1013
|
-
finalize: (carrier) => carrier.list
|
|
1018
|
+
finalize: (carrier) => carrier.list,
|
|
1019
|
+
identify: () => false
|
|
1014
1020
|
});
|
|
1015
1021
|
var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
|
|
1016
1022
|
create: () => [],
|
|
@@ -1026,7 +1032,8 @@ var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
|
|
|
1026
1032
|
if (keys.length !== 1) return "cannot resolve a pairs item";
|
|
1027
1033
|
container.push([keys[0], object2[keys[0]]]);
|
|
1028
1034
|
return "";
|
|
1029
|
-
}
|
|
1035
|
+
},
|
|
1036
|
+
identify: () => false
|
|
1030
1037
|
});
|
|
1031
1038
|
var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
1032
1039
|
create: () => ({}),
|
|
@@ -1053,7 +1060,11 @@ var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
|
1053
1060
|
return Object.prototype.hasOwnProperty.call(container, String(key));
|
|
1054
1061
|
},
|
|
1055
1062
|
keys: (container) => Object.keys(container),
|
|
1056
|
-
get: (container, key) =>
|
|
1063
|
+
get: (container, key) => {
|
|
1064
|
+
const normalizedKey = String(key);
|
|
1065
|
+
if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
|
|
1066
|
+
return container[normalizedKey];
|
|
1067
|
+
}
|
|
1057
1068
|
});
|
|
1058
1069
|
var setTag = defineMappingTag("tag:yaml.org,2002:set", {
|
|
1059
1070
|
create: () => /* @__PURE__ */ new Set(),
|
|
@@ -1074,9 +1085,9 @@ var setTag = defineMappingTag("tag:yaml.org,2002:set", {
|
|
|
1074
1085
|
});
|
|
1075
1086
|
function createTagDefinitionMap() {
|
|
1076
1087
|
return {
|
|
1077
|
-
scalar:
|
|
1078
|
-
sequence:
|
|
1079
|
-
mapping:
|
|
1088
|
+
scalar: /* @__PURE__ */ Object.create(null),
|
|
1089
|
+
sequence: /* @__PURE__ */ Object.create(null),
|
|
1090
|
+
mapping: /* @__PURE__ */ Object.create(null)
|
|
1080
1091
|
};
|
|
1081
1092
|
}
|
|
1082
1093
|
function createTagDefinitionListMap() {
|
|
@@ -1103,11 +1114,35 @@ function compileTags(tags) {
|
|
|
1103
1114
|
}
|
|
1104
1115
|
var Schema = class Schema2 {
|
|
1105
1116
|
tags;
|
|
1117
|
+
/** @internal */
|
|
1106
1118
|
implicitScalarTags;
|
|
1119
|
+
/**
|
|
1120
|
+
* Dispatch implicit scalar resolvers by `source.charAt(0)`. Each bucket holds
|
|
1121
|
+
* the resolvers that may match that key, in schema order; a key absent from
|
|
1122
|
+
* the map uses
|
|
1123
|
+
* {@link Schema.implicitScalarAnyFirstChar}
|
|
1124
|
+
* (resolvers that declared no first-char constraint, so they apply to any
|
|
1125
|
+
* first character).
|
|
1126
|
+
*/
|
|
1107
1127
|
implicitScalarByFirstChar;
|
|
1108
1128
|
implicitScalarAnyFirstChar;
|
|
1129
|
+
/**
|
|
1130
|
+
* The default scalar tag (`!!str`), resolved once so the composer's fallback
|
|
1131
|
+
* for unresolved plain scalars avoids a keyed lookup per scalar.
|
|
1132
|
+
*
|
|
1133
|
+
* @internal
|
|
1134
|
+
*/
|
|
1109
1135
|
defaultScalarTag;
|
|
1136
|
+
/**
|
|
1137
|
+
* The default container tags (`!!seq` / `!!map`), used by the dumper: when a
|
|
1138
|
+
* value is identified by its default tag, the tag is implicit and not
|
|
1139
|
+
* printed. Undefined if the schema does not define them (then such values
|
|
1140
|
+
* can't be dumped).
|
|
1141
|
+
*
|
|
1142
|
+
* @internal
|
|
1143
|
+
*/
|
|
1110
1144
|
defaultSequenceTag;
|
|
1145
|
+
/** @internal */
|
|
1111
1146
|
defaultMappingTag;
|
|
1112
1147
|
exact;
|
|
1113
1148
|
prefix;
|
|
@@ -1153,6 +1188,52 @@ var Schema = class Schema2 {
|
|
|
1153
1188
|
this.exact = exact;
|
|
1154
1189
|
this.prefix = prefix;
|
|
1155
1190
|
}
|
|
1191
|
+
/** @internal */
|
|
1192
|
+
lookupScalarTag(tagName) {
|
|
1193
|
+
const exactTag = this.exact.scalar[tagName];
|
|
1194
|
+
if (exactTag) return exactTag;
|
|
1195
|
+
for (const tag of this.prefix.scalar) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1196
|
+
}
|
|
1197
|
+
/** @internal */
|
|
1198
|
+
lookupSequenceTag(tagName) {
|
|
1199
|
+
const exactTag = this.exact.sequence[tagName];
|
|
1200
|
+
if (exactTag) return exactTag;
|
|
1201
|
+
for (const tag of this.prefix.sequence) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1202
|
+
}
|
|
1203
|
+
/** @internal */
|
|
1204
|
+
lookupMappingTag(tagName) {
|
|
1205
|
+
const exactTag = this.exact.mapping[tagName];
|
|
1206
|
+
if (exactTag) return exactTag;
|
|
1207
|
+
for (const tag of this.prefix.mapping) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1208
|
+
}
|
|
1209
|
+
/** @internal */
|
|
1210
|
+
resolveImplicitScalarTag(source) {
|
|
1211
|
+
const candidates = this.implicitScalarByFirstChar.get(source.charAt(0)) ?? this.implicitScalarAnyFirstChar;
|
|
1212
|
+
for (const tag2 of candidates) {
|
|
1213
|
+
const value = tag2.resolve(source, false, tag2.tagName);
|
|
1214
|
+
if (value !== NOT_RESOLVED) return {
|
|
1215
|
+
value,
|
|
1216
|
+
tag: tag2
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
const tag = this.defaultScalarTag;
|
|
1220
|
+
return {
|
|
1221
|
+
value: tag.resolve(source, false, tag.tagName),
|
|
1222
|
+
tag
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Creates a new schema with the specified tags added. If a tag already
|
|
1227
|
+
* exists, it is replaced by the specified tag.
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
*
|
|
1231
|
+
* ```javascript
|
|
1232
|
+
* import { CORE_SCHEMA, mergeTag, realMapTag } from 'js-yaml'
|
|
1233
|
+
*
|
|
1234
|
+
* const schema = CORE_SCHEMA.withTags(mergeTag, realMapTag)
|
|
1235
|
+
* ```
|
|
1236
|
+
*/
|
|
1156
1237
|
withTags(...tags) {
|
|
1157
1238
|
let flatTags = [];
|
|
1158
1239
|
for (const tag of tags) flatTags = flatTags.concat(tag);
|
|
@@ -1191,6 +1272,19 @@ var YAML11_SCHEMA = new Schema([
|
|
|
1191
1272
|
pairsTag,
|
|
1192
1273
|
setTag
|
|
1193
1274
|
]);
|
|
1275
|
+
var DUMP_SCHEMA = YAML11_SCHEMA.withTags({
|
|
1276
|
+
...intYaml11Tag,
|
|
1277
|
+
resolve: (source, isExplicit, tagName) => {
|
|
1278
|
+
const result = intYaml11Tag.resolve(source, isExplicit, tagName);
|
|
1279
|
+
return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
1280
|
+
}
|
|
1281
|
+
}, {
|
|
1282
|
+
...floatYaml11Tag,
|
|
1283
|
+
resolve: (source, isExplicit, tagName) => {
|
|
1284
|
+
const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
|
|
1285
|
+
return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1194
1288
|
var realMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
1195
1289
|
create: () => /* @__PURE__ */ new Map(),
|
|
1196
1290
|
addPair: (container, key, value) => {
|
|
@@ -1246,7 +1340,11 @@ var legacyMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
|
1246
1340
|
return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
|
|
1247
1341
|
},
|
|
1248
1342
|
keys: (container) => Object.keys(container),
|
|
1249
|
-
get: (container, key) =>
|
|
1343
|
+
get: (container, key) => {
|
|
1344
|
+
const normalizedKey = String(key);
|
|
1345
|
+
if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
|
|
1346
|
+
return container[normalizedKey];
|
|
1347
|
+
}
|
|
1250
1348
|
});
|
|
1251
1349
|
var DEFAULT_SNIPPET_OPTIONS = {
|
|
1252
1350
|
maxLength: 79,
|
|
@@ -1323,9 +1421,13 @@ function formatError(exception, compact) {
|
|
|
1323
1421
|
${exception.mark.snippet}`;
|
|
1324
1422
|
return `${exception.reason} ${where}`;
|
|
1325
1423
|
}
|
|
1326
|
-
var YAMLException = class extends Error {
|
|
1424
|
+
var YAMLException = class YAMLException2 extends Error {
|
|
1327
1425
|
reason;
|
|
1328
1426
|
mark;
|
|
1427
|
+
/**
|
|
1428
|
+
* Optional `mark` contains source snippet data. Usually, use
|
|
1429
|
+
* {@link YAMLException.throwAt} instead of passing it directly.
|
|
1430
|
+
*/
|
|
1329
1431
|
constructor(reason, mark) {
|
|
1330
1432
|
super();
|
|
1331
1433
|
this.name = "YAMLException";
|
|
@@ -1334,34 +1436,65 @@ var YAMLException = class extends Error {
|
|
|
1334
1436
|
this.message = formatError(this, false);
|
|
1335
1437
|
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
1336
1438
|
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Returns the formatted error, omitting the source snippet in compact mode.
|
|
1441
|
+
*/
|
|
1337
1442
|
toString(compact) {
|
|
1338
1443
|
return `${this.name}: ${formatError(this, compact)}`;
|
|
1339
1444
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1445
|
+
/**
|
|
1446
|
+
* Builds a YAMLException with a source snippet and throws it. `source` is
|
|
1447
|
+
* the raw input text; `position` is an offset into it.
|
|
1448
|
+
*/
|
|
1449
|
+
static throwAt(source, position, message, filename = "") {
|
|
1450
|
+
let line = 0;
|
|
1451
|
+
let lineStart = 0;
|
|
1452
|
+
for (let index = 0; index < position; index++) {
|
|
1453
|
+
const ch = source.charCodeAt(index);
|
|
1454
|
+
if (ch === 10) {
|
|
1455
|
+
line++;
|
|
1456
|
+
lineStart = index + 1;
|
|
1457
|
+
} else if (ch === 13) {
|
|
1458
|
+
line++;
|
|
1459
|
+
if (source.charCodeAt(index + 1) === 10) index++;
|
|
1460
|
+
lineStart = index + 1;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
const mark = {
|
|
1464
|
+
name: filename,
|
|
1465
|
+
buffer: source,
|
|
1466
|
+
position,
|
|
1467
|
+
line,
|
|
1468
|
+
column: position - lineStart
|
|
1469
|
+
};
|
|
1470
|
+
mark.snippet = makeSnippet(mark);
|
|
1471
|
+
throw new YAMLException2(message, mark);
|
|
1354
1472
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1473
|
+
};
|
|
1474
|
+
var EVENT_ID = {
|
|
1475
|
+
DOCUMENT: 1,
|
|
1476
|
+
SEQUENCE: 2,
|
|
1477
|
+
MAPPING: 3,
|
|
1478
|
+
SCALAR: 4,
|
|
1479
|
+
ALIAS: 5,
|
|
1480
|
+
POP: 6
|
|
1481
|
+
};
|
|
1482
|
+
var SCALAR_STYLE = {
|
|
1483
|
+
PLAIN: 1,
|
|
1484
|
+
SINGLE_QUOTED: 2,
|
|
1485
|
+
DOUBLE_QUOTED: 3,
|
|
1486
|
+
LITERAL_BLOCK: 4,
|
|
1487
|
+
FOLDED_BLOCK: 5
|
|
1488
|
+
};
|
|
1489
|
+
var COLLECTION_STYLE = {
|
|
1490
|
+
BLOCK: 1,
|
|
1491
|
+
FLOW: 2
|
|
1492
|
+
};
|
|
1493
|
+
var CHOMPING_MODE = {
|
|
1494
|
+
CLIP: 1,
|
|
1495
|
+
STRIP: 2,
|
|
1496
|
+
KEEP: 3
|
|
1497
|
+
};
|
|
1365
1498
|
var NO_RANGE$3 = -1;
|
|
1366
1499
|
function simpleEscapeSequence(c) {
|
|
1367
1500
|
switch (c) {
|
|
@@ -1559,8 +1692,8 @@ function getBlockValue(input, start, end, indent, chomping, folded) {
|
|
|
1559
1692
|
didReadContent = true;
|
|
1560
1693
|
emptyLines = 0;
|
|
1561
1694
|
}
|
|
1562
|
-
if (chomping ===
|
|
1563
|
-
else if (chomping !==
|
|
1695
|
+
if (chomping === CHOMPING_MODE.KEEP) result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1696
|
+
else if (chomping !== CHOMPING_MODE.STRIP) {
|
|
1564
1697
|
if (didReadContent) result += "\n";
|
|
1565
1698
|
}
|
|
1566
1699
|
return result;
|
|
@@ -1570,22 +1703,22 @@ function getScalarValue(input, scalar) {
|
|
|
1570
1703
|
const { valueStart, valueEnd } = scalar;
|
|
1571
1704
|
if (scalar.fast) return input.slice(valueStart, valueEnd);
|
|
1572
1705
|
switch (scalar.style) {
|
|
1573
|
-
case
|
|
1706
|
+
case SCALAR_STYLE.SINGLE_QUOTED:
|
|
1574
1707
|
return getSingleQuotedValue(input, valueStart, valueEnd);
|
|
1575
|
-
case
|
|
1708
|
+
case SCALAR_STYLE.DOUBLE_QUOTED:
|
|
1576
1709
|
return getDoubleQuotedValue(input, valueStart, valueEnd);
|
|
1577
|
-
case
|
|
1710
|
+
case SCALAR_STYLE.LITERAL_BLOCK:
|
|
1578
1711
|
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, false);
|
|
1579
|
-
case
|
|
1712
|
+
case SCALAR_STYLE.FOLDED_BLOCK:
|
|
1580
1713
|
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, true);
|
|
1581
1714
|
default:
|
|
1582
1715
|
return getPlainValue(input, valueStart, valueEnd);
|
|
1583
1716
|
}
|
|
1584
1717
|
}
|
|
1585
|
-
var DEFAULT_TAG_HANDLERS = {
|
|
1718
|
+
var DEFAULT_TAG_HANDLERS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1586
1719
|
"!": "!",
|
|
1587
1720
|
"!!": "tag:yaml.org,2002:"
|
|
1588
|
-
};
|
|
1721
|
+
});
|
|
1589
1722
|
function tagNameFull(rawTag, tagHandlers) {
|
|
1590
1723
|
if (rawTag.startsWith("!<") && rawTag.endsWith(">")) return decodeURIComponent(rawTag.slice(2, -1));
|
|
1591
1724
|
const handleEnd = rawTag.indexOf("!", 1);
|
|
@@ -1594,6 +1727,7 @@ function tagNameFull(rawTag, tagHandlers) {
|
|
|
1594
1727
|
return decodeURIComponent(prefix) + decodeURIComponent(rawTag.slice(handle.length));
|
|
1595
1728
|
}
|
|
1596
1729
|
var NO_RANGE$2 = -1;
|
|
1730
|
+
var MERGE_TAG_NAME = "tag:yaml.org,2002:merge";
|
|
1597
1731
|
var DEFAULT_CONSTRUCTOR_OPTIONS = {
|
|
1598
1732
|
filename: "",
|
|
1599
1733
|
schema: CORE_SCHEMA,
|
|
@@ -1609,26 +1743,16 @@ function eventPosition$1(event) {
|
|
|
1609
1743
|
return 0;
|
|
1610
1744
|
}
|
|
1611
1745
|
function throwError$1(state, message) {
|
|
1612
|
-
|
|
1746
|
+
YAMLException.throwAt(state.source, state.position, message, state.filename);
|
|
1613
1747
|
}
|
|
1614
1748
|
function finalizeCollection(state, position, tag, carrier) {
|
|
1615
1749
|
try {
|
|
1616
1750
|
return tag.finalize(carrier);
|
|
1617
1751
|
} catch (error51) {
|
|
1618
1752
|
if (error51 instanceof YAMLException) throw error51;
|
|
1619
|
-
|
|
1753
|
+
YAMLException.throwAt(state.source, position, error51 instanceof Error ? error51.message : String(error51), state.filename);
|
|
1620
1754
|
}
|
|
1621
1755
|
}
|
|
1622
|
-
function lookupTag(exact, prefix, tagName) {
|
|
1623
|
-
const exactTag = exact[tagName];
|
|
1624
|
-
if (exactTag) return exactTag;
|
|
1625
|
-
for (const tag of prefix) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1626
|
-
}
|
|
1627
|
-
function findExplicitTag(state, exact, prefix, tagName, nodeKind) {
|
|
1628
|
-
const tag = lookupTag(exact, prefix, tagName);
|
|
1629
|
-
if (tag) return tag;
|
|
1630
|
-
throwError$1(state, `unknown ${nodeKind} tag !<${tagName}>`);
|
|
1631
|
-
}
|
|
1632
1756
|
function constructScalar(state, event) {
|
|
1633
1757
|
const source = getScalarValue(state.source, event);
|
|
1634
1758
|
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
@@ -1639,7 +1763,7 @@ function constructScalar(state, event) {
|
|
|
1639
1763
|
tag: strTag2
|
|
1640
1764
|
};
|
|
1641
1765
|
const tagName = tagNameFull(rawTag, state.tagHandlers);
|
|
1642
|
-
const scalarTag =
|
|
1766
|
+
const scalarTag = state.schema.lookupScalarTag(tagName);
|
|
1643
1767
|
if (scalarTag) {
|
|
1644
1768
|
const result = scalarTag.resolve(source, true, tagName);
|
|
1645
1769
|
if (result === NOT_RESOLVED) throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
@@ -1648,7 +1772,7 @@ function constructScalar(state, event) {
|
|
|
1648
1772
|
tag: scalarTag
|
|
1649
1773
|
};
|
|
1650
1774
|
}
|
|
1651
|
-
const collectionTagDef =
|
|
1775
|
+
const collectionTagDef = state.schema.lookupMappingTag(tagName) ?? state.schema.lookupSequenceTag(tagName);
|
|
1652
1776
|
if (collectionTagDef) {
|
|
1653
1777
|
if (source !== "") throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
1654
1778
|
const carrier = collectionTagDef.create(tagName);
|
|
@@ -1659,50 +1783,49 @@ function constructScalar(state, event) {
|
|
|
1659
1783
|
}
|
|
1660
1784
|
throwError$1(state, `unknown scalar tag !<${tagName}>`);
|
|
1661
1785
|
}
|
|
1662
|
-
if (event.style ===
|
|
1663
|
-
const candidates = state.schema.implicitScalarByFirstChar.get(source.charAt(0)) ?? state.schema.implicitScalarAnyFirstChar;
|
|
1664
|
-
for (const tag of candidates) {
|
|
1665
|
-
const result = tag.resolve(source, false, tag.tagName);
|
|
1666
|
-
if (result !== NOT_RESOLVED) return {
|
|
1667
|
-
value: result,
|
|
1668
|
-
tag
|
|
1669
|
-
};
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1786
|
+
if (event.style === SCALAR_STYLE.PLAIN) return state.schema.resolveImplicitScalarTag(source);
|
|
1672
1787
|
return {
|
|
1673
1788
|
value: strTag2.resolve(source, false, strTag2.tagName),
|
|
1674
1789
|
tag: strTag2
|
|
1675
1790
|
};
|
|
1676
1791
|
}
|
|
1677
|
-
function
|
|
1792
|
+
function collectionTagName(state, event, defaultTagName) {
|
|
1678
1793
|
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1679
|
-
|
|
1680
|
-
return {
|
|
1681
|
-
tagName,
|
|
1682
|
-
tag: findExplicitTag(state, exact, prefix, tagName, nodeKind)
|
|
1683
|
-
};
|
|
1794
|
+
return rawTag === "" || rawTag === "!" ? defaultTagName : tagNameFull(rawTag, state.tagHandlers);
|
|
1684
1795
|
}
|
|
1685
1796
|
function isMappingTag(tag) {
|
|
1686
1797
|
return tag.nodeKind === "mapping";
|
|
1687
1798
|
}
|
|
1799
|
+
function chargeMergeWork(state) {
|
|
1800
|
+
state.totalMergeKeys++;
|
|
1801
|
+
if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) throwError$1(state, `merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys})`);
|
|
1802
|
+
}
|
|
1688
1803
|
function mergeKeys(state, frame, source, sourceTag) {
|
|
1804
|
+
chargeMergeWork(state);
|
|
1689
1805
|
for (const sourceKey of sourceTag.keys(source)) {
|
|
1690
|
-
|
|
1806
|
+
chargeMergeWork(state);
|
|
1691
1807
|
if (frame.tag.has(frame.value, sourceKey)) continue;
|
|
1692
1808
|
const err = frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
|
|
1693
1809
|
if (err) throwError$1(state, err);
|
|
1694
|
-
|
|
1810
|
+
frame.overridable ??= /* @__PURE__ */ new Set();
|
|
1811
|
+
frame.overridable.add(sourceKey);
|
|
1695
1812
|
}
|
|
1696
1813
|
}
|
|
1697
1814
|
function mergeSource(state, frame, source, sourceTag) {
|
|
1698
1815
|
state.position = frame.keyPosition;
|
|
1699
1816
|
if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
|
|
1700
|
-
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source))
|
|
1701
|
-
|
|
1817
|
+
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source)) {
|
|
1818
|
+
if (source.length > 100) throwError$1(state, "abnormal merge sequence size");
|
|
1819
|
+
for (const element of source) {
|
|
1820
|
+
const elementTag = state.nodeTags.get(element);
|
|
1821
|
+
if (!elementTag) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1822
|
+
mergeKeys(state, frame, element, elementTag);
|
|
1823
|
+
}
|
|
1824
|
+
} else throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1702
1825
|
}
|
|
1703
1826
|
function addMappingValue(state, frame, key, value, tag) {
|
|
1704
1827
|
state.position = frame.keyPosition;
|
|
1705
|
-
if (
|
|
1828
|
+
if (frame.keyIsMerge) {
|
|
1706
1829
|
mergeSource(state, frame, value, tag);
|
|
1707
1830
|
return;
|
|
1708
1831
|
}
|
|
@@ -1717,9 +1840,7 @@ function addValue(state, value, tag) {
|
|
|
1717
1840
|
frame.value = value;
|
|
1718
1841
|
frame.hasValue = true;
|
|
1719
1842
|
} else if (frame.kind === "sequence") {
|
|
1720
|
-
if (
|
|
1721
|
-
if (!isMappingTag(tag)) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1722
|
-
}
|
|
1843
|
+
if (isMappingTag(tag)) state.nodeTags.set(value, tag);
|
|
1723
1844
|
const err = frame.tag.addItem(frame.value, value, frame.index++);
|
|
1724
1845
|
if (err) throwError$1(state, err);
|
|
1725
1846
|
} else if (frame.hasKey) {
|
|
@@ -1731,6 +1852,7 @@ function addValue(state, value, tag) {
|
|
|
1731
1852
|
frame.key = value;
|
|
1732
1853
|
frame.keyPosition = state.position;
|
|
1733
1854
|
frame.hasKey = true;
|
|
1855
|
+
frame.keyIsMerge = tag.tagName === MERGE_TAG_NAME;
|
|
1734
1856
|
}
|
|
1735
1857
|
}
|
|
1736
1858
|
function storeAnchor(state, event, value, tag, isValueFinal) {
|
|
@@ -1755,6 +1877,7 @@ function constructFromEvents(events, options) {
|
|
|
1755
1877
|
position: 0,
|
|
1756
1878
|
frames: [],
|
|
1757
1879
|
anchors: /* @__PURE__ */ new Map(),
|
|
1880
|
+
nodeTags: /* @__PURE__ */ new Map(),
|
|
1758
1881
|
tagHandlers: /* @__PURE__ */ Object.create(null),
|
|
1759
1882
|
totalMergeKeys: 0,
|
|
1760
1883
|
aliasCount: 0
|
|
@@ -1763,8 +1886,9 @@ function constructFromEvents(events, options) {
|
|
|
1763
1886
|
const event = state.events[state.eventIndex++];
|
|
1764
1887
|
state.position = eventPosition$1(event);
|
|
1765
1888
|
switch (event.type) {
|
|
1766
|
-
case
|
|
1889
|
+
case EVENT_ID.DOCUMENT:
|
|
1767
1890
|
state.anchors = /* @__PURE__ */ new Map();
|
|
1891
|
+
state.nodeTags = /* @__PURE__ */ new Map();
|
|
1768
1892
|
state.aliasCount = 0;
|
|
1769
1893
|
state.tagHandlers = /* @__PURE__ */ Object.create(null);
|
|
1770
1894
|
for (const directive of event.directives) if (directive.kind === "tag") state.tagHandlers[directive.handle] = directive.prefix;
|
|
@@ -1775,47 +1899,49 @@ function constructFromEvents(events, options) {
|
|
|
1775
1899
|
hasValue: false
|
|
1776
1900
|
});
|
|
1777
1901
|
break;
|
|
1778
|
-
case
|
|
1902
|
+
case EVENT_ID.SCALAR: {
|
|
1779
1903
|
const { value, tag } = constructScalar(state, event);
|
|
1780
1904
|
storeAnchor(state, event, value, tag, true);
|
|
1781
1905
|
addValue(state, value, tag);
|
|
1782
1906
|
break;
|
|
1783
1907
|
}
|
|
1784
|
-
case
|
|
1785
|
-
const
|
|
1786
|
-
const
|
|
1787
|
-
|
|
1788
|
-
const
|
|
1789
|
-
const
|
|
1908
|
+
case EVENT_ID.SEQUENCE: {
|
|
1909
|
+
const tagName = collectionTagName(state, event, "tag:yaml.org,2002:seq");
|
|
1910
|
+
const tag = state.schema.lookupSequenceTag(tagName);
|
|
1911
|
+
if (!tag) throwError$1(state, `unknown sequence tag !<${tagName}>`);
|
|
1912
|
+
const value = tag.create(tagName);
|
|
1913
|
+
const anchor = storeAnchor(state, event, value, tag, tag.carrierIsResult);
|
|
1790
1914
|
state.frames.push({
|
|
1791
1915
|
kind: "sequence",
|
|
1792
1916
|
position: state.position,
|
|
1793
1917
|
value,
|
|
1794
|
-
tag
|
|
1918
|
+
tag,
|
|
1795
1919
|
anchor,
|
|
1796
|
-
index: 0
|
|
1797
|
-
merge: merge2
|
|
1920
|
+
index: 0
|
|
1798
1921
|
});
|
|
1799
1922
|
break;
|
|
1800
1923
|
}
|
|
1801
|
-
case
|
|
1802
|
-
const
|
|
1803
|
-
const
|
|
1804
|
-
|
|
1924
|
+
case EVENT_ID.MAPPING: {
|
|
1925
|
+
const tagName = collectionTagName(state, event, "tag:yaml.org,2002:map");
|
|
1926
|
+
const tag = state.schema.lookupMappingTag(tagName);
|
|
1927
|
+
if (!tag) throwError$1(state, `unknown mapping tag !<${tagName}>`);
|
|
1928
|
+
const value = tag.create(tagName);
|
|
1929
|
+
const anchor = storeAnchor(state, event, value, tag, tag.carrierIsResult);
|
|
1805
1930
|
state.frames.push({
|
|
1806
1931
|
kind: "mapping",
|
|
1807
1932
|
position: state.position,
|
|
1808
1933
|
value,
|
|
1809
|
-
tag
|
|
1934
|
+
tag,
|
|
1810
1935
|
anchor,
|
|
1811
1936
|
key: void 0,
|
|
1812
1937
|
keyPosition: state.position,
|
|
1813
1938
|
hasKey: false,
|
|
1939
|
+
keyIsMerge: false,
|
|
1814
1940
|
overridable: null
|
|
1815
1941
|
});
|
|
1816
1942
|
break;
|
|
1817
1943
|
}
|
|
1818
|
-
case
|
|
1944
|
+
case EVENT_ID.ALIAS: {
|
|
1819
1945
|
if (state.maxAliases !== -1 && ++state.aliasCount > state.maxAliases) throwError$1(state, `aliases exceeded maxAliases (${state.maxAliases})`);
|
|
1820
1946
|
const name = state.source.slice(event.anchorStart, event.anchorEnd);
|
|
1821
1947
|
const anchor = state.anchors.get(name);
|
|
@@ -1824,8 +1950,12 @@ function constructFromEvents(events, options) {
|
|
|
1824
1950
|
addValue(state, anchor.value, anchor.tag);
|
|
1825
1951
|
break;
|
|
1826
1952
|
}
|
|
1827
|
-
case
|
|
1953
|
+
case EVENT_ID.POP: {
|
|
1828
1954
|
const frame = state.frames.pop();
|
|
1955
|
+
if (frame.kind === "mapping" && frame.hasKey) {
|
|
1956
|
+
state.position = frame.keyPosition;
|
|
1957
|
+
throwError$1(state, "incomplete mapping pair in event stream");
|
|
1958
|
+
}
|
|
1829
1959
|
if (frame.kind === "document") state.documents.push(frame.value);
|
|
1830
1960
|
else {
|
|
1831
1961
|
const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
|
|
@@ -1861,7 +1991,7 @@ var DEFAULT_PARSER_OPTIONS = {
|
|
|
1861
1991
|
};
|
|
1862
1992
|
function addDocumentEvent(state, explicitStart, explicitEnd) {
|
|
1863
1993
|
state.events.push({
|
|
1864
|
-
type:
|
|
1994
|
+
type: EVENT_ID.DOCUMENT,
|
|
1865
1995
|
explicitStart,
|
|
1866
1996
|
explicitEnd,
|
|
1867
1997
|
directives: state.directives
|
|
@@ -1869,7 +1999,7 @@ function addDocumentEvent(state, explicitStart, explicitEnd) {
|
|
|
1869
1999
|
}
|
|
1870
2000
|
function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
1871
2001
|
state.events.push({
|
|
1872
|
-
type:
|
|
2002
|
+
type: EVENT_ID.SEQUENCE,
|
|
1873
2003
|
start,
|
|
1874
2004
|
anchorStart,
|
|
1875
2005
|
anchorEnd,
|
|
@@ -1880,7 +2010,7 @@ function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd
|
|
|
1880
2010
|
}
|
|
1881
2011
|
function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
1882
2012
|
state.events.push({
|
|
1883
|
-
type:
|
|
2013
|
+
type: EVENT_ID.MAPPING,
|
|
1884
2014
|
start,
|
|
1885
2015
|
anchorStart,
|
|
1886
2016
|
anchorEnd,
|
|
@@ -1891,18 +2021,18 @@ function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd,
|
|
|
1891
2021
|
}
|
|
1892
2022
|
function insertFlowPairMappingEvent(state, snapshot) {
|
|
1893
2023
|
state.events.splice(snapshot.eventsLength, 0, {
|
|
1894
|
-
type:
|
|
2024
|
+
type: EVENT_ID.MAPPING,
|
|
1895
2025
|
start: snapshot.position,
|
|
1896
2026
|
anchorStart: NO_RANGE$1,
|
|
1897
2027
|
anchorEnd: NO_RANGE$1,
|
|
1898
2028
|
tagStart: NO_RANGE$1,
|
|
1899
2029
|
tagEnd: NO_RANGE$1,
|
|
1900
|
-
style:
|
|
2030
|
+
style: COLLECTION_STYLE.FLOW
|
|
1901
2031
|
});
|
|
1902
2032
|
}
|
|
1903
|
-
function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping =
|
|
2033
|
+
function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping = CHOMPING_MODE.CLIP, indent = -1, fast = false) {
|
|
1904
2034
|
state.events.push({
|
|
1905
|
-
type:
|
|
2035
|
+
type: EVENT_ID.SCALAR,
|
|
1906
2036
|
valueStart,
|
|
1907
2037
|
valueEnd,
|
|
1908
2038
|
anchorStart,
|
|
@@ -1917,16 +2047,16 @@ function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tag
|
|
|
1917
2047
|
}
|
|
1918
2048
|
function addAliasEvent(state, anchorStart, anchorEnd) {
|
|
1919
2049
|
state.events.push({
|
|
1920
|
-
type:
|
|
2050
|
+
type: EVENT_ID.ALIAS,
|
|
1921
2051
|
anchorStart,
|
|
1922
2052
|
anchorEnd
|
|
1923
2053
|
});
|
|
1924
2054
|
}
|
|
1925
2055
|
function addPopEvent(state) {
|
|
1926
|
-
state.events.push({ type:
|
|
2056
|
+
state.events.push({ type: EVENT_ID.POP });
|
|
1927
2057
|
}
|
|
1928
2058
|
function addEmptyScalarEvent(state) {
|
|
1929
|
-
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1,
|
|
2059
|
+
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, SCALAR_STYLE.PLAIN);
|
|
1930
2060
|
}
|
|
1931
2061
|
function emptyProperties() {
|
|
1932
2062
|
return {
|
|
@@ -1955,7 +2085,7 @@ function restoreState(state, snapshot) {
|
|
|
1955
2085
|
state.events.length = snapshot.eventsLength;
|
|
1956
2086
|
}
|
|
1957
2087
|
function throwError(state, message) {
|
|
1958
|
-
|
|
2088
|
+
YAMLException.throwAt(state.input.slice(0, state.length), state.position, message, state.filename);
|
|
1959
2089
|
}
|
|
1960
2090
|
function isEol(c) {
|
|
1961
2091
|
return c === 10 || c === 13;
|
|
@@ -2034,6 +2164,24 @@ function testDocumentSeparator(state, position = state.position) {
|
|
|
2034
2164
|
}
|
|
2035
2165
|
return false;
|
|
2036
2166
|
}
|
|
2167
|
+
function skipByteOrderMark(state) {
|
|
2168
|
+
if (state.position === state.lineStart && state.input.charCodeAt(state.position) === 65279) {
|
|
2169
|
+
state.position++;
|
|
2170
|
+
state.lineStart = state.position;
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
function testDocumentBoundary(state) {
|
|
2174
|
+
if (state.position !== state.lineStart) return false;
|
|
2175
|
+
if (testDocumentSeparator(state)) return true;
|
|
2176
|
+
if (state.input.charCodeAt(state.position) !== 65279) return false;
|
|
2177
|
+
const snapshot = snapshotState(state);
|
|
2178
|
+
skipByteOrderMark(state);
|
|
2179
|
+
skipSeparationSpace(state, true);
|
|
2180
|
+
const ch = state.input.charCodeAt(state.position);
|
|
2181
|
+
const result = state.position === state.lineStart && (ch === 37 || ch === 45 && testDocumentSeparator(state));
|
|
2182
|
+
restoreState(state, snapshot);
|
|
2183
|
+
return result;
|
|
2184
|
+
}
|
|
2037
2185
|
function skipUntilLineEnd(state) {
|
|
2038
2186
|
let ch = state.input.charCodeAt(state.position);
|
|
2039
2187
|
while (ch !== 0 && !isEol(ch)) ch = state.input.charCodeAt(++state.position);
|
|
@@ -2123,7 +2271,7 @@ function readSingleQuotedScalar(state, nodeIndent, props) {
|
|
|
2123
2271
|
}
|
|
2124
2272
|
const end = state.position;
|
|
2125
2273
|
state.position++;
|
|
2126
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2274
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.SINGLE_QUOTED, CHOMPING_MODE.CLIP, -1, simple);
|
|
2127
2275
|
return true;
|
|
2128
2276
|
}
|
|
2129
2277
|
if (isEol(ch)) {
|
|
@@ -2145,7 +2293,7 @@ function readDoubleQuotedScalar(state, nodeIndent, props) {
|
|
|
2145
2293
|
if (ch === 34) {
|
|
2146
2294
|
const end = state.position;
|
|
2147
2295
|
state.position++;
|
|
2148
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2296
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.DOUBLE_QUOTED, CHOMPING_MODE.CLIP, -1, simple);
|
|
2149
2297
|
return true;
|
|
2150
2298
|
}
|
|
2151
2299
|
if (ch === 92) {
|
|
@@ -2173,18 +2321,18 @@ function readDoubleQuotedScalar(state, nodeIndent, props) {
|
|
|
2173
2321
|
}
|
|
2174
2322
|
function readBlockScalar(state, parentIndent, props) {
|
|
2175
2323
|
const ch = state.input.charCodeAt(state.position);
|
|
2176
|
-
let chomping =
|
|
2324
|
+
let chomping = CHOMPING_MODE.CLIP;
|
|
2177
2325
|
let indent = -1;
|
|
2178
2326
|
let detectedIndent = false;
|
|
2179
2327
|
if (ch !== 124 && ch !== 62) return false;
|
|
2180
|
-
const style = ch === 124 ?
|
|
2328
|
+
const style = ch === 124 ? SCALAR_STYLE.LITERAL_BLOCK : SCALAR_STYLE.FOLDED_BLOCK;
|
|
2181
2329
|
state.position++;
|
|
2182
2330
|
while (state.input.charCodeAt(state.position) !== 0) {
|
|
2183
2331
|
const current = state.input.charCodeAt(state.position);
|
|
2184
2332
|
const digit = fromDecimalCode(current);
|
|
2185
2333
|
if (current === 43 || current === 45) {
|
|
2186
|
-
if (chomping !==
|
|
2187
|
-
chomping = current === 43 ?
|
|
2334
|
+
if (chomping !== CHOMPING_MODE.CLIP) throwError(state, "repeat of a chomping mode identifier");
|
|
2335
|
+
chomping = current === 43 ? CHOMPING_MODE.KEEP : CHOMPING_MODE.STRIP;
|
|
2188
2336
|
state.position++;
|
|
2189
2337
|
} else if (digit >= 0) {
|
|
2190
2338
|
if (digit === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
@@ -2217,7 +2365,7 @@ function readBlockScalar(state, parentIndent, props) {
|
|
|
2217
2365
|
} else if (column > 0) valueEnd = linePosition + column;
|
|
2218
2366
|
break;
|
|
2219
2367
|
}
|
|
2220
|
-
if (
|
|
2368
|
+
if (testDocumentBoundary(state)) break;
|
|
2221
2369
|
if (!detectedIndent && contentIndent === -1 && isEol(first)) maxLeadingIndent = Math.max(maxLeadingIndent, column);
|
|
2222
2370
|
if (!detectedIndent && contentIndent === -1 && !isEol(first)) {
|
|
2223
2371
|
if (first === 9 && column < parentIndent) {
|
|
@@ -2270,7 +2418,7 @@ function readPlainScalar(state, nodeIndent, nodeContext, props) {
|
|
|
2270
2418
|
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
2271
2419
|
let multiline = false;
|
|
2272
2420
|
while (ch !== 0) {
|
|
2273
|
-
if (
|
|
2421
|
+
if (testDocumentBoundary(state)) break;
|
|
2274
2422
|
if (ch === 58) {
|
|
2275
2423
|
const following = state.input.charCodeAt(state.position + 1);
|
|
2276
2424
|
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) break;
|
|
@@ -2299,7 +2447,7 @@ function readPlainScalar(state, nodeIndent, nodeContext, props) {
|
|
|
2299
2447
|
}
|
|
2300
2448
|
if (end === start) return false;
|
|
2301
2449
|
checkPrintable(state, start, end);
|
|
2302
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2450
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.PLAIN, CHOMPING_MODE.CLIP, -1, !multiline);
|
|
2303
2451
|
return true;
|
|
2304
2452
|
}
|
|
2305
2453
|
function skipFlowSeparationSpace(state, nodeIndent) {
|
|
@@ -2314,8 +2462,8 @@ function readFlowCollection(state, nodeIndent, props) {
|
|
|
2314
2462
|
let readNext = true;
|
|
2315
2463
|
if (ch !== 91 && ch !== 123) return false;
|
|
2316
2464
|
const terminator = isMapping ? 125 : 93;
|
|
2317
|
-
if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2318
|
-
else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2465
|
+
if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.FLOW);
|
|
2466
|
+
else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.FLOW);
|
|
2319
2467
|
state.position++;
|
|
2320
2468
|
while (state.input.charCodeAt(state.position) !== 0) {
|
|
2321
2469
|
skipFlowSeparationSpace(state, nodeIndent);
|
|
@@ -2369,7 +2517,7 @@ function readFlowCollection(state, nodeIndent, props) {
|
|
|
2369
2517
|
}
|
|
2370
2518
|
function readBlockSequence(state, nodeIndent, props) {
|
|
2371
2519
|
if (state.firstTabInLine !== -1 || state.input.charCodeAt(state.position) !== 45 || !isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) return false;
|
|
2372
|
-
addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2520
|
+
addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
|
|
2373
2521
|
while (state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) {
|
|
2374
2522
|
if (state.firstTabInLine !== -1) {
|
|
2375
2523
|
state.position = state.firstTabInLine;
|
|
@@ -2405,7 +2553,7 @@ function readBlockMapping(state, nodeIndent, flowIndent, props) {
|
|
|
2405
2553
|
const entryLine = state.line;
|
|
2406
2554
|
if ((ch === 63 || ch === 58) && isWsOrEolOrEnd(following)) {
|
|
2407
2555
|
if (!mappingOpened) {
|
|
2408
|
-
addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2556
|
+
addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
|
|
2409
2557
|
mappingOpened = true;
|
|
2410
2558
|
}
|
|
2411
2559
|
if (ch === 63) {
|
|
@@ -2435,7 +2583,7 @@ function readBlockMapping(state, nodeIndent, flowIndent, props) {
|
|
|
2435
2583
|
if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
2436
2584
|
if (!mappingOpened) {
|
|
2437
2585
|
restoreState(state, beforeKey);
|
|
2438
|
-
addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2586
|
+
addMappingEvent(state, beforeKey.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
|
|
2439
2587
|
mappingOpened = true;
|
|
2440
2588
|
parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true);
|
|
2441
2589
|
ch = state.input.charCodeAt(state.position);
|
|
@@ -2496,10 +2644,6 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
|
|
|
2496
2644
|
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
2497
2645
|
else indentStatus = -1;
|
|
2498
2646
|
}
|
|
2499
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2500
|
-
state.depth--;
|
|
2501
|
-
return false;
|
|
2502
|
-
}
|
|
2503
2647
|
if (indentStatus === 1) while (true) {
|
|
2504
2648
|
const ch = state.input.charCodeAt(state.position);
|
|
2505
2649
|
const propertyState = snapshotState(state);
|
|
@@ -2507,7 +2651,7 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
|
|
|
2507
2651
|
if (atNewLine && allowBlockStyles && (props.tagStart !== NO_RANGE$1 || props.anchorStart !== NO_RANGE$1) && (ch === 33 || ch === 38)) {
|
|
2508
2652
|
const fallbackState = snapshotState(state);
|
|
2509
2653
|
const flowIndent = parentIndent + 1;
|
|
2510
|
-
if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && state.events[fallbackState.eventsLength]?.type ===
|
|
2654
|
+
if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && state.events[fallbackState.eventsLength]?.type === EVENT_ID.MAPPING) {
|
|
2511
2655
|
state.depth--;
|
|
2512
2656
|
return true;
|
|
2513
2657
|
}
|
|
@@ -2535,7 +2679,7 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
|
|
|
2535
2679
|
const fallbackState = snapshotState(state);
|
|
2536
2680
|
const propertyIndent = propertyStart.position - propertyStart.lineStart;
|
|
2537
2681
|
restoreState(state, propertyStart);
|
|
2538
|
-
if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && state.events[fallbackState.eventsLength]?.type ===
|
|
2682
|
+
if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && state.events[fallbackState.eventsLength]?.type === EVENT_ID.MAPPING) hasContent = true;
|
|
2539
2683
|
else restoreState(state, fallbackState);
|
|
2540
2684
|
}
|
|
2541
2685
|
if (!hasContent && (allowBlockScalars && readBlockScalar(state, flowIndent, props) || readSingleQuotedScalar(state, flowIndent, props) || readDoubleQuotedScalar(state, flowIndent, props) || readAlias(state, props) || readPlainScalar(state, flowIndent, nodeContext, props))) hasContent = true;
|
|
@@ -2544,7 +2688,7 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
|
|
|
2544
2688
|
}
|
|
2545
2689
|
allowBlockScalars = allowBlockScalars && !hasContent;
|
|
2546
2690
|
if (!hasContent && (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1 || allowBlockScalars)) {
|
|
2547
|
-
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2691
|
+
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.PLAIN);
|
|
2548
2692
|
hasContent = true;
|
|
2549
2693
|
}
|
|
2550
2694
|
state.depth--;
|
|
@@ -2629,9 +2773,9 @@ function readDocument(state) {
|
|
|
2629
2773
|
}
|
|
2630
2774
|
}
|
|
2631
2775
|
const documentEvent = state.events[documentEventIndex];
|
|
2632
|
-
if (documentEvent?.type ===
|
|
2776
|
+
if (documentEvent?.type === EVENT_ID.DOCUMENT) documentEvent.explicitEnd = explicitEnd;
|
|
2633
2777
|
addPopEvent(state);
|
|
2634
|
-
if (!explicitEnd && state.position < state.length && !(state
|
|
2778
|
+
if (!explicitEnd && state.position < state.length && !testDocumentBoundary(state)) throwError(state, "end of the stream or a document separator is expected");
|
|
2635
2779
|
}
|
|
2636
2780
|
function parseEvents(input, options) {
|
|
2637
2781
|
const length = input.length;
|
|
@@ -2651,9 +2795,9 @@ function parseEvents(input, options) {
|
|
|
2651
2795
|
events: []
|
|
2652
2796
|
};
|
|
2653
2797
|
const nullpos = input.indexOf("\0");
|
|
2654
|
-
if (nullpos !== -1)
|
|
2655
|
-
if (state.input.charCodeAt(state.position) === 65279) state.position++;
|
|
2798
|
+
if (nullpos !== -1) YAMLException.throwAt(input, nullpos, "null byte is not allowed in input", state.filename);
|
|
2656
2799
|
while (state.position < state.length) {
|
|
2800
|
+
skipByteOrderMark(state);
|
|
2657
2801
|
skipSeparationSpace(state, true);
|
|
2658
2802
|
if (state.position >= state.length) break;
|
|
2659
2803
|
const documentStart = state.position;
|
|
@@ -2686,27 +2830,109 @@ function load(input, options) {
|
|
|
2686
2830
|
if (documents.length === 1) return documents[0];
|
|
2687
2831
|
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2688
2832
|
}
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2833
|
+
function hasBit(mask, bit) {
|
|
2834
|
+
return (mask & 1 << bit) !== 0;
|
|
2835
|
+
}
|
|
2836
|
+
var DEFAULT_SCALAR_STYLE_RULES = {
|
|
2837
|
+
applyQuoteFlowKeysOption,
|
|
2838
|
+
doubleQuoteForInvisibles,
|
|
2839
|
+
doubleQuoteWhitespaceOnly,
|
|
2840
|
+
applyForceQuotesOption,
|
|
2841
|
+
tryLongOrMultilineAsBlock,
|
|
2842
|
+
quoteInvalidPlain,
|
|
2843
|
+
fallbackToDoubleQuoted
|
|
2844
|
+
};
|
|
2845
|
+
function _preferredQuotedStyle(layout2) {
|
|
2846
|
+
if (layout2.presenterOptions.quoteStyle === "single" && hasBit(layout2.allowedStylesMask, SCALAR_STYLE.SINGLE_QUOTED)) return SCALAR_STYLE.SINGLE_QUOTED;
|
|
2847
|
+
return SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2848
|
+
}
|
|
2849
|
+
function applyQuoteFlowKeysOption(layout2) {
|
|
2850
|
+
if (!layout2.presenterOptions.quoteFlowKeys) return;
|
|
2851
|
+
if (!layout2.isKey || !layout2.flowOnly || layout2.style !== SCALAR_STYLE.PLAIN) return;
|
|
2852
|
+
layout2.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2853
|
+
}
|
|
2854
|
+
function doubleQuoteForInvisibles(layout2) {
|
|
2855
|
+
if (layout2.style === SCALAR_STYLE.PLAIN && /[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(layout2.node.value)) layout2.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2856
|
+
}
|
|
2857
|
+
function doubleQuoteWhitespaceOnly(layout2) {
|
|
2858
|
+
if (layout2.style === SCALAR_STYLE.PLAIN && /^\s+$/.test(layout2.node.value)) layout2.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2859
|
+
}
|
|
2860
|
+
function applyForceQuotesOption(layout2) {
|
|
2861
|
+
if (!layout2.presenterOptions.forceQuotes) return;
|
|
2862
|
+
if (layout2.isKey || layout2.style !== SCALAR_STYLE.PLAIN) return;
|
|
2863
|
+
if (layout2.node.tag !== layout2.presenterOptions.schema.defaultScalarTag.tagName) return;
|
|
2864
|
+
layout2.style = layout2.node.value.includes("\n") ? SCALAR_STYLE.DOUBLE_QUOTED : _preferredQuotedStyle(layout2);
|
|
2865
|
+
}
|
|
2866
|
+
function tryLongOrMultilineAsBlock(layout2) {
|
|
2867
|
+
if (layout2.style !== SCALAR_STYLE.PLAIN || layout2.isKey) return;
|
|
2868
|
+
const value = layout2.node.value;
|
|
2869
|
+
const multiline = value.indexOf("\n") !== -1;
|
|
2870
|
+
if (!hasBit(layout2.allowedStylesMask, SCALAR_STYLE.LITERAL_BLOCK)) {
|
|
2871
|
+
if (multiline) layout2.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2872
|
+
return;
|
|
2873
|
+
}
|
|
2874
|
+
const w = layout2.presenterOptions.lineWidth;
|
|
2875
|
+
if (w === -1) {
|
|
2876
|
+
if (multiline) layout2.style = SCALAR_STYLE.LITERAL_BLOCK;
|
|
2877
|
+
return;
|
|
2878
|
+
}
|
|
2879
|
+
const availableWidth = Math.max(Math.min(w, 40), w - layout2.shiftOfContent);
|
|
2880
|
+
let position = 0;
|
|
2881
|
+
let shouldFold = false;
|
|
2882
|
+
while (position <= value.length) {
|
|
2883
|
+
let lineEnd = value.length;
|
|
2884
|
+
const nextLineBreak = value.indexOf("\n", position);
|
|
2885
|
+
if (nextLineBreak !== -1) lineEnd = nextLineBreak;
|
|
2886
|
+
const line = value.slice(position, lineEnd);
|
|
2887
|
+
if (line.length > availableWidth && line[0] !== " " && / [^ \t]/.test(line)) shouldFold = true;
|
|
2888
|
+
if (nextLineBreak === -1) break;
|
|
2889
|
+
position = nextLineBreak + 1;
|
|
2890
|
+
}
|
|
2891
|
+
if (shouldFold) layout2.style = SCALAR_STYLE.FOLDED_BLOCK;
|
|
2892
|
+
else if (multiline) layout2.style = SCALAR_STYLE.LITERAL_BLOCK;
|
|
2893
|
+
}
|
|
2894
|
+
function quoteInvalidPlain(layout2) {
|
|
2895
|
+
if (layout2.style === SCALAR_STYLE.PLAIN && !hasBit(layout2.allowedStylesMask, SCALAR_STYLE.PLAIN)) layout2.style = _preferredQuotedStyle(layout2);
|
|
2896
|
+
}
|
|
2897
|
+
function fallbackToDoubleQuoted(layout2) {
|
|
2898
|
+
if (!hasBit(layout2.allowedStylesMask, layout2.style)) layout2.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2899
|
+
}
|
|
2900
|
+
var SRC_C_PRINTABLE = "[\\x09\\x0A\\x0D\\x20-\\x7E\\x85\\xA0-\\uD7FF\\uE000-\\uFFFD\\u{10000}-\\u{10FFFF}]";
|
|
2901
|
+
var SRC_B_CHAR = "[\\n\\r]";
|
|
2902
|
+
var SRC_C_BYTE_ORDER_MARK = "\\uFEFF";
|
|
2903
|
+
var SRC_S_WHITE = "[ \\t]";
|
|
2904
|
+
var SRC_NB_CHAR = `(?:(?!(?:${SRC_B_CHAR}|${SRC_C_BYTE_ORDER_MARK}))${SRC_C_PRINTABLE})`;
|
|
2905
|
+
var SRC_NS_CHAR = `(?:(?!${SRC_S_WHITE})${SRC_NB_CHAR})`;
|
|
2906
|
+
var SRC_NB_JSON = "[\\x09\\x20-\\uD7FF\\uE000-\\uFFFF\\u{10000}-\\u{10FFFF}]";
|
|
2907
|
+
var SRC_C_INDICATOR = "[-?:,\\[\\]{}#&*!|>'\"%@`]";
|
|
2908
|
+
var SRC_C_FLOW_INDICATOR = "[,\\[\\]{}]";
|
|
2909
|
+
var SRC_NS_PLAIN_SAFE_FLOW_OUT = SRC_NS_CHAR;
|
|
2910
|
+
var SRC_NS_PLAIN_SAFE_FLOW_IN = `(?:(?!${SRC_C_FLOW_INDICATOR})${SRC_NS_CHAR})`;
|
|
2911
|
+
var SRC_NS_PLAIN_FIRST_FLOW_OUT = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))`;
|
|
2912
|
+
var SRC_NS_PLAIN_FIRST_FLOW_IN = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))`;
|
|
2913
|
+
var SRC_NS_PLAIN_CHAR_FLOW_OUT = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_OUT})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))#*`;
|
|
2914
|
+
var SRC_NS_PLAIN_CHAR_FLOW_IN = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_IN})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))#*`;
|
|
2915
|
+
var SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_OUT})*`;
|
|
2916
|
+
var SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_IN})*`;
|
|
2917
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_OUT = `${SRC_NS_PLAIN_FIRST_FLOW_OUT}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
|
|
2918
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_IN = `${SRC_NS_PLAIN_FIRST_FLOW_IN}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
|
|
2919
|
+
var SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_OUT;
|
|
2920
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_IN;
|
|
2921
|
+
var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_OUT}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
|
|
2922
|
+
var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_IN}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
|
|
2923
|
+
var SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT = `${SRC_NS_PLAIN_ONE_LINE_FLOW_OUT}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT})*`;
|
|
2924
|
+
var SRC_NS_PLAIN_MULTI_LINE_FLOW_IN = `${SRC_NS_PLAIN_ONE_LINE_FLOW_IN}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN})*`;
|
|
2925
|
+
var NS_PLAIN_FLOW_OUT = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT})$`, "u");
|
|
2926
|
+
var NS_PLAIN_FLOW_IN = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_IN})$`, "u");
|
|
2927
|
+
var NS_PLAIN_BLOCK_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY})$`, "u");
|
|
2928
|
+
var NS_PLAIN_FLOW_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_FLOW_KEY})$`, "u");
|
|
2929
|
+
var NB_SINGLE_ONE_LINE = new RegExp(`^(?:${SRC_NB_JSON})*$`, "u");
|
|
2930
|
+
var NB_SINGLE_MULTI_LINE = new RegExp(`^(?:${SRC_NB_JSON}|\\n)*$`, "u");
|
|
2931
|
+
var BLOCK_SCALAR_CONTENT = new RegExp(`^(?:${SRC_NB_CHAR}|\\n)*$`, "u");
|
|
2705
2932
|
var DEFAULT_PRESENTER_OPTIONS = {
|
|
2706
2933
|
indent: 2,
|
|
2707
2934
|
seqNoIndent: false,
|
|
2708
2935
|
seqInlineFirst: true,
|
|
2709
|
-
sortKeys: false,
|
|
2710
2936
|
lineWidth: 80,
|
|
2711
2937
|
flowBracketPadding: false,
|
|
2712
2938
|
flowSkipCommaSpace: false,
|
|
@@ -2714,30 +2940,35 @@ var DEFAULT_PRESENTER_OPTIONS = {
|
|
|
2714
2940
|
quoteFlowKeys: false,
|
|
2715
2941
|
quoteStyle: "single",
|
|
2716
2942
|
forceQuotes: false,
|
|
2943
|
+
scalarStyleRules: Object.keys(DEFAULT_SCALAR_STYLE_RULES).map((name) => Reflect.get(DEFAULT_SCALAR_STYLE_RULES, name)),
|
|
2717
2944
|
tagBeforeAnchor: false
|
|
2718
2945
|
};
|
|
2719
|
-
var DEFAULT_DUMP_SCHEMA = YAML11_SCHEMA.withTags({
|
|
2720
|
-
...intYaml11Tag,
|
|
2721
|
-
resolve: (source, isExplicit, tagName) => {
|
|
2722
|
-
const result = intYaml11Tag.resolve(source, isExplicit, tagName);
|
|
2723
|
-
return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
2724
|
-
}
|
|
2725
|
-
}, {
|
|
2726
|
-
...floatYaml11Tag,
|
|
2727
|
-
resolve: (source, isExplicit, tagName) => {
|
|
2728
|
-
const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
|
|
2729
|
-
return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
2730
|
-
}
|
|
2731
|
-
});
|
|
2732
2946
|
var DEFAULT_DUMP_OPTIONS = {
|
|
2733
2947
|
...DEFAULT_PRESENTER_OPTIONS,
|
|
2734
|
-
schema:
|
|
2948
|
+
schema: DUMP_SCHEMA,
|
|
2735
2949
|
skipInvalid: false,
|
|
2736
2950
|
noRefs: false,
|
|
2737
2951
|
flowLevel: -1,
|
|
2952
|
+
sortKeys: false,
|
|
2738
2953
|
transform: () => {
|
|
2739
2954
|
}
|
|
2740
2955
|
};
|
|
2956
|
+
var EVENT_DOCUMENT = EVENT_ID.DOCUMENT;
|
|
2957
|
+
var EVENT_SEQUENCE = EVENT_ID.SEQUENCE;
|
|
2958
|
+
var EVENT_MAPPING = EVENT_ID.MAPPING;
|
|
2959
|
+
var EVENT_SCALAR = EVENT_ID.SCALAR;
|
|
2960
|
+
var EVENT_ALIAS = EVENT_ID.ALIAS;
|
|
2961
|
+
var EVENT_POP = EVENT_ID.POP;
|
|
2962
|
+
var SCALAR_STYLE_PLAIN = SCALAR_STYLE.PLAIN;
|
|
2963
|
+
var SCALAR_STYLE_SINGLE_QUOTED = SCALAR_STYLE.SINGLE_QUOTED;
|
|
2964
|
+
var SCALAR_STYLE_DOUBLE_QUOTED = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
2965
|
+
var SCALAR_STYLE_LITERAL_BLOCK = SCALAR_STYLE.LITERAL_BLOCK;
|
|
2966
|
+
var SCALAR_STYLE_FOLDED_BLOCK = SCALAR_STYLE.FOLDED_BLOCK;
|
|
2967
|
+
var COLLECTION_STYLE_BLOCK = COLLECTION_STYLE.BLOCK;
|
|
2968
|
+
var COLLECTION_STYLE_FLOW = COLLECTION_STYLE.FLOW;
|
|
2969
|
+
var CHOMPING_CLIP = CHOMPING_MODE.CLIP;
|
|
2970
|
+
var CHOMPING_STRIP = CHOMPING_MODE.STRIP;
|
|
2971
|
+
var CHOMPING_KEEP = CHOMPING_MODE.KEEP;
|
|
2741
2972
|
|
|
2742
2973
|
// src/graph/graph-helpers.ts
|
|
2743
2974
|
function num(v) {
|
|
@@ -5191,7 +5422,14 @@ function deepCloneAndSubstitute(node, paramValues, compiledChildren, diagnostics
|
|
|
5191
5422
|
function expandComponent(def, paramValues, compiledChildren, diagnostics, extraProps, id, idIsParam) {
|
|
5192
5423
|
const expanded = deepCloneAndSubstitute(def.template, paramValues, compiledChildren, diagnostics, def.name);
|
|
5193
5424
|
Object.assign(expanded.props, extraProps);
|
|
5194
|
-
if (
|
|
5425
|
+
if (!idIsParam) {
|
|
5426
|
+
if (typeof id === "string" && id !== "") {
|
|
5427
|
+
expanded.id = id;
|
|
5428
|
+
delete expanded.props["__idParam"];
|
|
5429
|
+
} else if (isParamRef(id) || isTemplateRef(id) || isExprRef(id)) {
|
|
5430
|
+
expanded.props["__idParam"] = id;
|
|
5431
|
+
}
|
|
5432
|
+
}
|
|
5195
5433
|
return expanded;
|
|
5196
5434
|
}
|
|
5197
5435
|
function componentDefFromJSON(json2) {
|
|
@@ -5294,12 +5532,22 @@ function buildResolvedProps(bind, def, target, diagnostics) {
|
|
|
5294
5532
|
continue;
|
|
5295
5533
|
}
|
|
5296
5534
|
const value = resolvePropValue(prop, target, bind.component, bind.line, diagnostics);
|
|
5535
|
+
if (prop.param === "id") {
|
|
5536
|
+
if (value !== void 0 && value !== target.id) {
|
|
5537
|
+
diagnostics.push({
|
|
5538
|
+
level: "error",
|
|
5539
|
+
message: `bind <${bind.component}>: the 'id' param cannot be mapped to ${JSON.stringify(value)} \u2014 it is always the node id ('${target.id}').`,
|
|
5540
|
+
path: `line:${bind.line}`
|
|
5541
|
+
});
|
|
5542
|
+
}
|
|
5543
|
+
continue;
|
|
5544
|
+
}
|
|
5297
5545
|
if (value !== void 0) {
|
|
5298
5546
|
resolved[prop.param] = value;
|
|
5299
5547
|
mapped.add(prop.param);
|
|
5300
5548
|
}
|
|
5301
5549
|
}
|
|
5302
|
-
if (def.paramNames.has("id")
|
|
5550
|
+
if (def.paramNames.has("id")) {
|
|
5303
5551
|
resolved.id = target.id;
|
|
5304
5552
|
}
|
|
5305
5553
|
if (def.paramNames.has("label") && !mapped.has("label")) {
|
|
@@ -20684,6 +20932,14 @@ var ELEMENT_CATALOG = {
|
|
|
20684
20932
|
"box",
|
|
20685
20933
|
"group",
|
|
20686
20934
|
"table",
|
|
20935
|
+
"row",
|
|
20936
|
+
"cell",
|
|
20937
|
+
"divider",
|
|
20938
|
+
"text",
|
|
20939
|
+
"label",
|
|
20940
|
+
"image",
|
|
20941
|
+
"icon",
|
|
20942
|
+
"svgAsset",
|
|
20687
20943
|
"connector",
|
|
20688
20944
|
"alignConstraint",
|
|
20689
20945
|
"equalizeWidth",
|
|
@@ -20969,7 +21225,7 @@ var ELEMENT_CATALOG = {
|
|
|
20969
21225
|
"opacity",
|
|
20970
21226
|
"variant"
|
|
20971
21227
|
],
|
|
20972
|
-
children: { kind: "list", items: ["label"] },
|
|
21228
|
+
children: { kind: "list", items: ["label", "text"] },
|
|
20973
21229
|
notes: "Child Labels are annotation text rendered at the connector midpoint. Label.textPosition is reserved (planned, not implemented)"
|
|
20974
21230
|
},
|
|
20975
21231
|
// ── constraint ────────────────────────────────────────────────────────
|
|
@@ -21014,6 +21270,10 @@ var ELEMENT_CATALOG = {
|
|
|
21014
21270
|
notes: "targets array order is source order. axis: vertical = top-to-bottom, horizontal = left-to-right"
|
|
21015
21271
|
}
|
|
21016
21272
|
};
|
|
21273
|
+
function hasOwnRect(kind) {
|
|
21274
|
+
const category = ELEMENT_CATALOG[kind].category;
|
|
21275
|
+
return category !== "connector" && category !== "constraint";
|
|
21276
|
+
}
|
|
21017
21277
|
|
|
21018
21278
|
// src/ir/index.ts
|
|
21019
21279
|
var IrNodeSchema = external_exports.lazy(
|
|
@@ -21102,32 +21362,39 @@ function kindToPascal(kind) {
|
|
|
21102
21362
|
function normalize(ir, options) {
|
|
21103
21363
|
const diagnostics = [];
|
|
21104
21364
|
const result = structuredClone(ir);
|
|
21105
|
-
const
|
|
21106
|
-
|
|
21107
|
-
|
|
21365
|
+
const explicitIds = /* @__PURE__ */ new Map();
|
|
21366
|
+
collectIds(result, explicitIds, "root");
|
|
21367
|
+
assignAutoIds(result, /* @__PURE__ */ new Map(), explicitIds);
|
|
21368
|
+
const idLocations = /* @__PURE__ */ new Map();
|
|
21369
|
+
collectIds(result, idLocations, "root");
|
|
21370
|
+
checkDuplicateIds(idLocations, diagnostics);
|
|
21371
|
+
validateChildren(result, diagnostics, "root");
|
|
21108
21372
|
applyThemeAndVariants(result, options.theme);
|
|
21109
21373
|
resolveAllTokens(result, options.tokens, diagnostics, "root");
|
|
21110
21374
|
validateEnumProps(result, diagnostics, "root");
|
|
21111
21375
|
validateRangeProps(result, diagnostics, "root");
|
|
21112
21376
|
const geometryRegistry = buildGeometryRegistry(result, diagnostics);
|
|
21113
|
-
|
|
21377
|
+
const referable = /* @__PURE__ */ new Map();
|
|
21378
|
+
collectReferable(result, true, referable);
|
|
21379
|
+
resolveGeometryReferences(result, geometryRegistry, referable, diagnostics);
|
|
21114
21380
|
return { ir: result, diagnostics, geometryRegistry };
|
|
21115
21381
|
}
|
|
21116
|
-
function assignAutoIds(node, counters) {
|
|
21382
|
+
function assignAutoIds(node, counters, explicitIds) {
|
|
21117
21383
|
if (!node.id) {
|
|
21118
|
-
|
|
21384
|
+
let count = counters.get(node.kind) ?? 0;
|
|
21385
|
+
do {
|
|
21386
|
+
count += 1;
|
|
21387
|
+
} while (explicitIds.has(`${node.kind}_${count}`));
|
|
21119
21388
|
counters.set(node.kind, count);
|
|
21120
21389
|
node.id = `${node.kind}_${count}`;
|
|
21121
21390
|
}
|
|
21122
21391
|
if (node.children) {
|
|
21123
21392
|
for (const child of node.children) {
|
|
21124
|
-
assignAutoIds(child, counters);
|
|
21393
|
+
assignAutoIds(child, counters, explicitIds);
|
|
21125
21394
|
}
|
|
21126
21395
|
}
|
|
21127
21396
|
}
|
|
21128
|
-
function checkDuplicateIds(
|
|
21129
|
-
const idLocations = /* @__PURE__ */ new Map();
|
|
21130
|
-
collectIds(root, idLocations, "root");
|
|
21397
|
+
function checkDuplicateIds(idLocations, diagnostics) {
|
|
21131
21398
|
for (const [id, paths] of idLocations) {
|
|
21132
21399
|
if (paths.length > 1) {
|
|
21133
21400
|
diagnostics.push({
|
|
@@ -21153,6 +21420,24 @@ function collectIds(node, idLocations, path) {
|
|
|
21153
21420
|
}
|
|
21154
21421
|
}
|
|
21155
21422
|
}
|
|
21423
|
+
function validateChildren(node, diagnostics, path) {
|
|
21424
|
+
if (!node.children) return;
|
|
21425
|
+
const allowed = ELEMENT_CATALOG[node.kind].children;
|
|
21426
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
21427
|
+
const child = node.children[i];
|
|
21428
|
+
const childPath = `${path}.children[${i}]`;
|
|
21429
|
+
const ok = allowed.kind === "any" || allowed.kind === "list" && allowed.items.includes(child.kind);
|
|
21430
|
+
if (!ok) {
|
|
21431
|
+
const expected = allowed.kind === "list" ? `allowed children: ${allowed.items.join(", ")}` : allowed.kind === "text" ? "it takes text content only" : "it takes no children";
|
|
21432
|
+
diagnostics.push({
|
|
21433
|
+
level: "error",
|
|
21434
|
+
message: `${kindToPascal(child.kind)} '${child.id}' cannot be placed inside ${kindToPascal(node.kind)} '${node.id}' \u2014 ${expected}`,
|
|
21435
|
+
path: childPath
|
|
21436
|
+
});
|
|
21437
|
+
}
|
|
21438
|
+
validateChildren(child, diagnostics, childPath);
|
|
21439
|
+
}
|
|
21440
|
+
}
|
|
21156
21441
|
function applyThemeAndVariants(node, theme) {
|
|
21157
21442
|
const pascalKind = kindToPascal(node.kind);
|
|
21158
21443
|
const explicitKeys = new Set(Object.keys(node.props));
|
|
@@ -21312,6 +21597,13 @@ function collectGeometryProps(node, registry2, diagnostics) {
|
|
|
21312
21597
|
}
|
|
21313
21598
|
}
|
|
21314
21599
|
}
|
|
21600
|
+
function collectReferable(node, parentHasRect, out) {
|
|
21601
|
+
const ownRect = parentHasRect && hasOwnRect(node.kind);
|
|
21602
|
+
if (node.id) out.set(node.id, ownRect);
|
|
21603
|
+
if (node.children) {
|
|
21604
|
+
for (const child of node.children) collectReferable(child, ownRect, out);
|
|
21605
|
+
}
|
|
21606
|
+
}
|
|
21315
21607
|
function parseGeometryRef(ref) {
|
|
21316
21608
|
const colonIdx = ref.indexOf(":");
|
|
21317
21609
|
if (colonIdx === -1) return { nodeId: ref };
|
|
@@ -21330,20 +21622,33 @@ function resolveWithRole(nodeId, role, registry2) {
|
|
|
21330
21622
|
}
|
|
21331
21623
|
return current;
|
|
21332
21624
|
}
|
|
21333
|
-
function
|
|
21334
|
-
const { nodeId, role } = parseGeometryRef(ref);
|
|
21335
|
-
const effectiveRole = role ?? implicitRole;
|
|
21336
|
-
if (!effectiveRole) return nodeId;
|
|
21337
|
-
return resolveWithRole(nodeId, effectiveRole, registry2);
|
|
21338
|
-
}
|
|
21339
|
-
function resolveGeometryReferences(node, registry2, diagnostics) {
|
|
21625
|
+
function resolveGeometryReferences(node, registry2, referable, diagnostics) {
|
|
21340
21626
|
const kind = node.kind;
|
|
21627
|
+
const report = (prop, message) => {
|
|
21628
|
+
diagnostics.push({
|
|
21629
|
+
level: "error",
|
|
21630
|
+
message: `${kindToPascal(kind)} '${node.id}': ${message}`,
|
|
21631
|
+
path: `${node.id}.props.${prop}`
|
|
21632
|
+
});
|
|
21633
|
+
};
|
|
21634
|
+
const resolveRef2 = (ref, implicitRole, prop) => {
|
|
21635
|
+
const { nodeId, role } = parseGeometryRef(ref);
|
|
21636
|
+
const effectiveRole = role ?? implicitRole;
|
|
21637
|
+
const resolved = effectiveRole ? resolveWithRole(nodeId, effectiveRole, registry2) : nodeId;
|
|
21638
|
+
const ownRect = referable.get(resolved);
|
|
21639
|
+
if (ownRect === void 0) {
|
|
21640
|
+
report(prop, `${prop} "${ref}" refers to an element that does not exist ('${resolved}')`);
|
|
21641
|
+
} else if (!ownRect) {
|
|
21642
|
+
report(prop, `${prop} "${ref}" refers to an element without a rectangle of its own ('${resolved}' \u2014 a connector, a connector's label or a constraint)`);
|
|
21643
|
+
}
|
|
21644
|
+
return resolved;
|
|
21645
|
+
};
|
|
21341
21646
|
if (kind === "alignConstraint") {
|
|
21342
21647
|
const targets = node.props.targets;
|
|
21343
21648
|
if (targets) {
|
|
21344
21649
|
const alignRefs = {};
|
|
21345
21650
|
for (const t of targets) {
|
|
21346
|
-
const resolved =
|
|
21651
|
+
const resolved = resolveRef2(t, "align", "targets");
|
|
21347
21652
|
if (resolved !== t) alignRefs[t] = resolved;
|
|
21348
21653
|
}
|
|
21349
21654
|
if (Object.keys(alignRefs).length > 0) {
|
|
@@ -21352,39 +21657,41 @@ function resolveGeometryReferences(node, registry2, diagnostics) {
|
|
|
21352
21657
|
}
|
|
21353
21658
|
const anchor = node.props.anchor;
|
|
21354
21659
|
if (anchor) {
|
|
21355
|
-
const resolved =
|
|
21660
|
+
const resolved = resolveRef2(anchor, "align", "anchor");
|
|
21356
21661
|
if (resolved !== anchor) {
|
|
21357
21662
|
node.props.alignRefs = { ...node.props.alignRefs ?? {}, [anchor]: resolved };
|
|
21358
21663
|
}
|
|
21359
21664
|
}
|
|
21665
|
+
const mover = node.props.mover;
|
|
21666
|
+
if (mover) {
|
|
21667
|
+
resolveRef2(mover, void 0, "mover");
|
|
21668
|
+
}
|
|
21360
21669
|
}
|
|
21361
21670
|
if (kind === "connector") {
|
|
21362
|
-
const from
|
|
21363
|
-
|
|
21364
|
-
|
|
21365
|
-
|
|
21366
|
-
|
|
21367
|
-
|
|
21368
|
-
|
|
21671
|
+
for (const prop of ["from", "to"]) {
|
|
21672
|
+
const ref = node.props[prop];
|
|
21673
|
+
if (ref) {
|
|
21674
|
+
node.props[prop] = resolveRef2(ref, "connect", prop);
|
|
21675
|
+
} else {
|
|
21676
|
+
report(prop, `'${prop}' is required \u2014 a connector runs between two elements`);
|
|
21677
|
+
}
|
|
21369
21678
|
}
|
|
21370
21679
|
}
|
|
21371
21680
|
if (kind === "equalizeWidth" || kind === "equalizeHeight" || kind === "minGap" || kind === "keepInsideConstraint" || kind === "orderConstraint") {
|
|
21372
21681
|
const targets = node.props.targets;
|
|
21373
21682
|
if (targets) {
|
|
21374
|
-
node.props.targets = targets.map(
|
|
21375
|
-
(t) => resolveGeometryRef(t, void 0, registry2)
|
|
21376
|
-
);
|
|
21683
|
+
node.props.targets = targets.map((t) => resolveRef2(t, void 0, "targets"));
|
|
21377
21684
|
}
|
|
21378
21685
|
}
|
|
21379
21686
|
if (node.children) {
|
|
21380
21687
|
for (const child of node.children) {
|
|
21381
|
-
resolveGeometryReferences(child, registry2, diagnostics);
|
|
21688
|
+
resolveGeometryReferences(child, registry2, referable, diagnostics);
|
|
21382
21689
|
}
|
|
21383
21690
|
}
|
|
21384
21691
|
}
|
|
21385
21692
|
|
|
21386
21693
|
// src/artifact/index.ts
|
|
21387
|
-
var CONNECTOR_LABEL_KINDS =
|
|
21694
|
+
var CONNECTOR_LABEL_KINDS = new Set(ELEMENT_CATALOG.connector.children.items);
|
|
21388
21695
|
function isConnectorLabelKind(kind) {
|
|
21389
21696
|
return CONNECTOR_LABEL_KINDS.has(kind);
|
|
21390
21697
|
}
|
|
@@ -21913,7 +22220,11 @@ function buildResolvedNode(graph, ir, parentWorldX, parentWorldY, diagnostics) {
|
|
|
21913
22220
|
const children = [];
|
|
21914
22221
|
for (const child of ir.children) {
|
|
21915
22222
|
const childNode = buildResolvedNode(graph, child, worldRect.x, worldRect.y, diagnostics);
|
|
21916
|
-
if (childNode)
|
|
22223
|
+
if (!childNode) continue;
|
|
22224
|
+
if (kind === "row" && childNode.kind === "cell" && styles.fill != null && childNode.styles.fill == null) {
|
|
22225
|
+
childNode.styles.fill = styles.fill;
|
|
22226
|
+
}
|
|
22227
|
+
children.push(childNode);
|
|
21917
22228
|
}
|
|
21918
22229
|
if (children.length > 0) {
|
|
21919
22230
|
resolved.children = children;
|
|
@@ -21929,10 +22240,10 @@ var CONNECTOR_DEFAULTS = {
|
|
|
21929
22240
|
};
|
|
21930
22241
|
function fixConnectorPaths(nodes, _graph, ir) {
|
|
21931
22242
|
const worldRectMap = /* @__PURE__ */ new Map();
|
|
21932
|
-
|
|
22243
|
+
const connectors = [];
|
|
22244
|
+
collectWorldRects(nodes, worldRectMap, connectors);
|
|
21933
22245
|
const connectorInfos = [];
|
|
21934
|
-
for (const node of
|
|
21935
|
-
if (node.kind !== "connector") continue;
|
|
22246
|
+
for (const node of connectors) {
|
|
21936
22247
|
const irNode = findIrNode(ir, node.id);
|
|
21937
22248
|
if (!irNode) continue;
|
|
21938
22249
|
const fromId = irNode.props.from;
|
|
@@ -22212,11 +22523,12 @@ function edgePoint(rect, edge, t) {
|
|
|
22212
22523
|
return { x: rect.x + rect.width, y: rect.y + rect.height * t };
|
|
22213
22524
|
}
|
|
22214
22525
|
}
|
|
22215
|
-
function collectWorldRects(nodes, map2) {
|
|
22526
|
+
function collectWorldRects(nodes, map2, connectors) {
|
|
22216
22527
|
for (const node of nodes) {
|
|
22217
22528
|
map2.set(node.id, node.worldRect);
|
|
22529
|
+
if (node.kind === "connector") connectors.push(node);
|
|
22218
22530
|
if (node.children) {
|
|
22219
|
-
collectWorldRects(node.children, map2);
|
|
22531
|
+
collectWorldRects(node.children, map2, connectors);
|
|
22220
22532
|
}
|
|
22221
22533
|
}
|
|
22222
22534
|
}
|
|
@@ -22273,10 +22585,14 @@ function getDynamicMarkerDefs() {
|
|
|
22273
22585
|
if (dynamicMarkerRegistry.size === 0) return "";
|
|
22274
22586
|
return Array.from(dynamicMarkerRegistry.values()).join("\n");
|
|
22275
22587
|
}
|
|
22588
|
+
function colorKey(color) {
|
|
22589
|
+
if (/^#[0-9a-fA-F]+$/.test(color)) return color.slice(1);
|
|
22590
|
+
if (/^[0-9a-zA-Z]+$/.test(color) && /[g-zG-Z]/.test(color)) return color;
|
|
22591
|
+
return "_" + color.replace(/[^a-zA-Z0-9]/g, (c) => `_${c.charCodeAt(0).toString(16)}_`);
|
|
22592
|
+
}
|
|
22276
22593
|
function ensureColoredMarker(arrowType, arrowSize, color) {
|
|
22277
|
-
const colorKey = color.replace(/[^a-zA-Z0-9]/g, "");
|
|
22278
22594
|
const sizeKey = arrowSize === 1 ? "" : `-s${arrowSize}`;
|
|
22279
|
-
const id = `marker-${arrowType}-${colorKey}${sizeKey}`;
|
|
22595
|
+
const id = `marker-${arrowType}-${colorKey(color)}${sizeKey}`;
|
|
22280
22596
|
if (!dynamicMarkerRegistry.has(id)) {
|
|
22281
22597
|
const template = MARKER_TEMPLATES.find((t) => t.type === arrowType);
|
|
22282
22598
|
if (template) {
|
|
@@ -22449,9 +22765,6 @@ function renderNode(node) {
|
|
|
22449
22765
|
}
|
|
22450
22766
|
if (node.children) {
|
|
22451
22767
|
for (const child of node.children) {
|
|
22452
|
-
if (node.kind === "row" && child.kind === "cell" && node.styles.fill != null && child.styles.fill == null) {
|
|
22453
|
-
child.styles.fill = node.styles.fill;
|
|
22454
|
-
}
|
|
22455
22768
|
const childSvg = renderNode(child);
|
|
22456
22769
|
if (childSvg) parts.push(childSvg);
|
|
22457
22770
|
}
|
|
@@ -23224,5 +23537,5 @@ export {
|
|
|
23224
23537
|
/*! Bundled license information:
|
|
23225
23538
|
|
|
23226
23539
|
js-yaml/dist/js-yaml.mjs:
|
|
23227
|
-
(*! js-yaml 5.
|
|
23540
|
+
(*! js-yaml 5.4.2 https://github.com/nodeca/js-yaml @license MIT *)
|
|
23228
23541
|
*/
|