@digipair/skill-yaml 0.55.0 → 0.55.1

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.
Files changed (3) hide show
  1. package/index.cjs.js +1271 -1
  2. package/index.esm.js +1271 -1
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -93,6 +93,68 @@ YAMLException$1.prototype.toString = function toString(compact) {
93
93
  return this.name + ": " + formatError(this, compact);
94
94
  };
95
95
  var exception = YAMLException$1;
96
+ // get snippet for a single line, respecting maxLength
97
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
98
+ var head = "";
99
+ var tail = "";
100
+ var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
101
+ if (position - lineStart > maxHalfLength) {
102
+ head = " ... ";
103
+ lineStart = position - maxHalfLength + head.length;
104
+ }
105
+ if (lineEnd - position > maxHalfLength) {
106
+ tail = " ...";
107
+ lineEnd = position + maxHalfLength - tail.length;
108
+ }
109
+ return {
110
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
111
+ pos: position - lineStart + head.length // relative position
112
+ };
113
+ }
114
+ function padStart(string, max) {
115
+ return common.repeat(" ", max - string.length) + string;
116
+ }
117
+ function makeSnippet(mark, options) {
118
+ options = Object.create(options || null);
119
+ if (!mark.buffer) return null;
120
+ if (!options.maxLength) options.maxLength = 79;
121
+ if (typeof options.indent !== "number") options.indent = 1;
122
+ if (typeof options.linesBefore !== "number") options.linesBefore = 3;
123
+ if (typeof options.linesAfter !== "number") options.linesAfter = 2;
124
+ var re = /\r?\n|\r|\0/g;
125
+ var lineStarts = [
126
+ 0
127
+ ];
128
+ var lineEnds = [];
129
+ var match;
130
+ var foundLineNo = -1;
131
+ while(match = re.exec(mark.buffer)){
132
+ lineEnds.push(match.index);
133
+ lineStarts.push(match.index + match[0].length);
134
+ if (mark.position <= match.index && foundLineNo < 0) {
135
+ foundLineNo = lineStarts.length - 2;
136
+ }
137
+ }
138
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
139
+ var result = "", i, line;
140
+ var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
141
+ var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
142
+ for(i = 1; i <= options.linesBefore; i++){
143
+ if (foundLineNo - i < 0) break;
144
+ line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
145
+ result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
146
+ }
147
+ line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
148
+ result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
149
+ result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^" + "\n";
150
+ for(i = 1; i <= options.linesAfter; i++){
151
+ if (foundLineNo + i >= lineEnds.length) break;
152
+ line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
153
+ result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
154
+ }
155
+ return result.replace(/\n$/, "");
156
+ }
157
+ var snippet = makeSnippet;
96
158
  var TYPE_CONSTRUCTOR_OPTIONS = [
97
159
  "kind",
98
160
  "multi",
@@ -792,15 +854,1222 @@ var _default = core.extend({
792
854
  set
793
855
  ]
794
856
  });
857
+ /*eslint-disable max-len,no-use-before-define*/ var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
858
+ var CONTEXT_FLOW_IN = 1;
859
+ var CONTEXT_FLOW_OUT = 2;
860
+ var CONTEXT_BLOCK_IN = 3;
861
+ var CONTEXT_BLOCK_OUT = 4;
862
+ var CHOMPING_CLIP = 1;
863
+ var CHOMPING_STRIP = 2;
864
+ var CHOMPING_KEEP = 3;
865
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
866
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
867
+ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
868
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
869
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
870
+ function _class(obj) {
871
+ return Object.prototype.toString.call(obj);
872
+ }
873
+ function is_EOL(c) {
874
+ return c === 0x0A /* LF */ || c === 0x0D /* CR */ ;
875
+ }
876
+ function is_WHITE_SPACE(c) {
877
+ return c === 0x09 /* Tab */ || c === 0x20 /* Space */ ;
878
+ }
879
+ function is_WS_OR_EOL(c) {
880
+ return c === 0x09 /* Tab */ || c === 0x20 /* Space */ || c === 0x0A /* LF */ || c === 0x0D /* CR */ ;
881
+ }
882
+ function is_FLOW_INDICATOR(c) {
883
+ return c === 0x2C /* , */ || c === 0x5B /* [ */ || c === 0x5D /* ] */ || c === 0x7B /* { */ || c === 0x7D /* } */ ;
884
+ }
885
+ function fromHexCode(c) {
886
+ var lc;
887
+ if (0x30 /* 0 */ <= c && c <= 0x39 /* 9 */ ) {
888
+ return c - 0x30;
889
+ }
890
+ /*eslint-disable no-bitwise*/ lc = c | 0x20;
891
+ if (0x61 /* a */ <= lc && lc <= 0x66 /* f */ ) {
892
+ return lc - 0x61 + 10;
893
+ }
894
+ return -1;
895
+ }
896
+ function escapedHexLen(c) {
897
+ if (c === 0x78 /* x */ ) {
898
+ return 2;
899
+ }
900
+ if (c === 0x75 /* u */ ) {
901
+ return 4;
902
+ }
903
+ if (c === 0x55 /* U */ ) {
904
+ return 8;
905
+ }
906
+ return 0;
907
+ }
908
+ function fromDecimalCode(c) {
909
+ if (0x30 /* 0 */ <= c && c <= 0x39 /* 9 */ ) {
910
+ return c - 0x30;
911
+ }
912
+ return -1;
913
+ }
795
914
  function simpleEscapeSequence(c) {
796
915
  /* eslint-disable indent */ return c === 0x30 /* 0 */ ? "\0" : c === 0x61 /* a */ ? "\x07" : c === 0x62 /* b */ ? "\b" : c === 0x74 /* t */ ? " " : c === 0x09 /* Tab */ ? " " : c === 0x6E /* n */ ? "\n" : c === 0x76 /* v */ ? "\v" : c === 0x66 /* f */ ? "\f" : c === 0x72 /* r */ ? "\r" : c === 0x65 /* e */ ? "\x1b" : c === 0x20 /* Space */ ? " " : c === 0x22 /* " */ ? '"' : c === 0x2F /* / */ ? "/" : c === 0x5C /* \ */ ? "\\" : c === 0x4E /* N */ ? "\x85" : c === 0x5F /* _ */ ? "\xa0" : c === 0x4C /* L */ ? "\u2028" : c === 0x50 /* P */ ? "\u2029" : "";
797
916
  }
917
+ function charFromCodepoint(c) {
918
+ if (c <= 0xFFFF) {
919
+ return String.fromCharCode(c);
920
+ }
921
+ // Encode UTF-16 surrogate pair
922
+ // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
923
+ return String.fromCharCode((c - 0x010000 >> 10) + 0xD800, (c - 0x010000 & 0x03FF) + 0xDC00);
924
+ }
798
925
  var simpleEscapeCheck = new Array(256); // integer, for fast access
799
926
  var simpleEscapeMap = new Array(256);
800
927
  for(var i = 0; i < 256; i++){
801
928
  simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
802
929
  simpleEscapeMap[i] = simpleEscapeSequence(i);
803
930
  }
931
+ function State$1(input, options) {
932
+ this.input = input;
933
+ this.filename = options["filename"] || null;
934
+ this.schema = options["schema"] || _default;
935
+ this.onWarning = options["onWarning"] || null;
936
+ // (Hidden) Remove? makes the loader to expect YAML 1.1 documents
937
+ // if such documents have no explicit %YAML directive
938
+ this.legacy = options["legacy"] || false;
939
+ this.json = options["json"] || false;
940
+ this.listener = options["listener"] || null;
941
+ this.implicitTypes = this.schema.compiledImplicit;
942
+ this.typeMap = this.schema.compiledTypeMap;
943
+ this.length = input.length;
944
+ this.position = 0;
945
+ this.line = 0;
946
+ this.lineStart = 0;
947
+ this.lineIndent = 0;
948
+ // position of first leading tab in the current line,
949
+ // used to make sure there are no tabs in the indentation
950
+ this.firstTabInLine = -1;
951
+ this.documents = [];
952
+ /*
953
+ this.version;
954
+ this.checkLineBreaks;
955
+ this.tagMap;
956
+ this.anchorMap;
957
+ this.tag;
958
+ this.anchor;
959
+ this.kind;
960
+ this.result;*/ }
961
+ function generateError(state, message) {
962
+ var mark = {
963
+ name: state.filename,
964
+ buffer: state.input.slice(0, -1),
965
+ position: state.position,
966
+ line: state.line,
967
+ column: state.position - state.lineStart
968
+ };
969
+ mark.snippet = snippet(mark);
970
+ return new exception(message, mark);
971
+ }
972
+ function throwError(state, message) {
973
+ throw generateError(state, message);
974
+ }
975
+ function throwWarning(state, message) {
976
+ if (state.onWarning) {
977
+ state.onWarning.call(null, generateError(state, message));
978
+ }
979
+ }
980
+ var directiveHandlers = {
981
+ YAML: function handleYamlDirective(state, name, args) {
982
+ var match, major, minor;
983
+ if (state.version !== null) {
984
+ throwError(state, "duplication of %YAML directive");
985
+ }
986
+ if (args.length !== 1) {
987
+ throwError(state, "YAML directive accepts exactly one argument");
988
+ }
989
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
990
+ if (match === null) {
991
+ throwError(state, "ill-formed argument of the YAML directive");
992
+ }
993
+ major = parseInt(match[1], 10);
994
+ minor = parseInt(match[2], 10);
995
+ if (major !== 1) {
996
+ throwError(state, "unacceptable YAML version of the document");
997
+ }
998
+ state.version = args[0];
999
+ state.checkLineBreaks = minor < 2;
1000
+ if (minor !== 1 && minor !== 2) {
1001
+ throwWarning(state, "unsupported YAML version of the document");
1002
+ }
1003
+ },
1004
+ TAG: function handleTagDirective(state, name, args) {
1005
+ var handle, prefix;
1006
+ if (args.length !== 2) {
1007
+ throwError(state, "TAG directive accepts exactly two arguments");
1008
+ }
1009
+ handle = args[0];
1010
+ prefix = args[1];
1011
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
1012
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1013
+ }
1014
+ if (_hasOwnProperty$1.call(state.tagMap, handle)) {
1015
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1016
+ }
1017
+ if (!PATTERN_TAG_URI.test(prefix)) {
1018
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1019
+ }
1020
+ try {
1021
+ prefix = decodeURIComponent(prefix);
1022
+ } catch (err) {
1023
+ throwError(state, "tag prefix is malformed: " + prefix);
1024
+ }
1025
+ state.tagMap[handle] = prefix;
1026
+ }
1027
+ };
1028
+ function captureSegment(state, start, end, checkJson) {
1029
+ var _position, _length, _character, _result;
1030
+ if (start < end) {
1031
+ _result = state.input.slice(start, end);
1032
+ if (checkJson) {
1033
+ for(_position = 0, _length = _result.length; _position < _length; _position += 1){
1034
+ _character = _result.charCodeAt(_position);
1035
+ if (!(_character === 0x09 || 0x20 <= _character && _character <= 0x10FFFF)) {
1036
+ throwError(state, "expected valid JSON character");
1037
+ }
1038
+ }
1039
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1040
+ throwError(state, "the stream contains non-printable characters");
1041
+ }
1042
+ state.result += _result;
1043
+ }
1044
+ }
1045
+ function mergeMappings(state, destination, source, overridableKeys) {
1046
+ var sourceKeys, key, index, quantity;
1047
+ if (!common.isObject(source)) {
1048
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1049
+ }
1050
+ sourceKeys = Object.keys(source);
1051
+ for(index = 0, quantity = sourceKeys.length; index < quantity; index += 1){
1052
+ key = sourceKeys[index];
1053
+ if (!_hasOwnProperty$1.call(destination, key)) {
1054
+ destination[key] = source[key];
1055
+ overridableKeys[key] = true;
1056
+ }
1057
+ }
1058
+ }
1059
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1060
+ var index, quantity;
1061
+ // The output is a plain object here, so keys can only be strings.
1062
+ // We need to convert keyNode to a string, but doing so can hang the process
1063
+ // (deeply nested arrays that explode exponentially using aliases).
1064
+ if (Array.isArray(keyNode)) {
1065
+ keyNode = Array.prototype.slice.call(keyNode);
1066
+ for(index = 0, quantity = keyNode.length; index < quantity; index += 1){
1067
+ if (Array.isArray(keyNode[index])) {
1068
+ throwError(state, "nested arrays are not supported inside keys");
1069
+ }
1070
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1071
+ keyNode[index] = "[object Object]";
1072
+ }
1073
+ }
1074
+ }
1075
+ // Avoid code execution in load() via toString property
1076
+ // (still use its own toString for arrays, timestamps,
1077
+ // and whatever user schema extensions happen to have @@toStringTag)
1078
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1079
+ keyNode = "[object Object]";
1080
+ }
1081
+ keyNode = String(keyNode);
1082
+ if (_result === null) {
1083
+ _result = {};
1084
+ }
1085
+ if (keyTag === "tag:yaml.org,2002:merge") {
1086
+ if (Array.isArray(valueNode)) {
1087
+ for(index = 0, quantity = valueNode.length; index < quantity; index += 1){
1088
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
1089
+ }
1090
+ } else {
1091
+ mergeMappings(state, _result, valueNode, overridableKeys);
1092
+ }
1093
+ } else {
1094
+ if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
1095
+ state.line = startLine || state.line;
1096
+ state.lineStart = startLineStart || state.lineStart;
1097
+ state.position = startPos || state.position;
1098
+ throwError(state, "duplicated mapping key");
1099
+ }
1100
+ // used for this specific key only because Object.defineProperty is slow
1101
+ if (keyNode === "__proto__") {
1102
+ Object.defineProperty(_result, keyNode, {
1103
+ configurable: true,
1104
+ enumerable: true,
1105
+ writable: true,
1106
+ value: valueNode
1107
+ });
1108
+ } else {
1109
+ _result[keyNode] = valueNode;
1110
+ }
1111
+ delete overridableKeys[keyNode];
1112
+ }
1113
+ return _result;
1114
+ }
1115
+ function readLineBreak(state) {
1116
+ var ch;
1117
+ ch = state.input.charCodeAt(state.position);
1118
+ if (ch === 0x0A /* LF */ ) {
1119
+ state.position++;
1120
+ } else if (ch === 0x0D /* CR */ ) {
1121
+ state.position++;
1122
+ if (state.input.charCodeAt(state.position) === 0x0A /* LF */ ) {
1123
+ state.position++;
1124
+ }
1125
+ } else {
1126
+ throwError(state, "a line break is expected");
1127
+ }
1128
+ state.line += 1;
1129
+ state.lineStart = state.position;
1130
+ state.firstTabInLine = -1;
1131
+ }
1132
+ function skipSeparationSpace(state, allowComments, checkIndent) {
1133
+ var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1134
+ while(ch !== 0){
1135
+ while(is_WHITE_SPACE(ch)){
1136
+ if (ch === 0x09 /* Tab */ && state.firstTabInLine === -1) {
1137
+ state.firstTabInLine = state.position;
1138
+ }
1139
+ ch = state.input.charCodeAt(++state.position);
1140
+ }
1141
+ if (allowComments && ch === 0x23 /* # */ ) {
1142
+ do {
1143
+ ch = state.input.charCodeAt(++state.position);
1144
+ }while (ch !== 0x0A /* LF */ && ch !== 0x0D /* CR */ && ch !== 0);
1145
+ }
1146
+ if (is_EOL(ch)) {
1147
+ readLineBreak(state);
1148
+ ch = state.input.charCodeAt(state.position);
1149
+ lineBreaks++;
1150
+ state.lineIndent = 0;
1151
+ while(ch === 0x20 /* Space */ ){
1152
+ state.lineIndent++;
1153
+ ch = state.input.charCodeAt(++state.position);
1154
+ }
1155
+ } else {
1156
+ break;
1157
+ }
1158
+ }
1159
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1160
+ throwWarning(state, "deficient indentation");
1161
+ }
1162
+ return lineBreaks;
1163
+ }
1164
+ function testDocumentSeparator(state) {
1165
+ var _position = state.position, ch;
1166
+ ch = state.input.charCodeAt(_position);
1167
+ // Condition state.position === state.lineStart is tested
1168
+ // in parent on each call, for efficiency. No needs to test here again.
1169
+ if ((ch === 0x2D /* - */ || ch === 0x2E /* . */ ) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1170
+ _position += 3;
1171
+ ch = state.input.charCodeAt(_position);
1172
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
1173
+ return true;
1174
+ }
1175
+ }
1176
+ return false;
1177
+ }
1178
+ function writeFoldedLines(state, count) {
1179
+ if (count === 1) {
1180
+ state.result += " ";
1181
+ } else if (count > 1) {
1182
+ state.result += common.repeat("\n", count - 1);
1183
+ }
1184
+ }
1185
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1186
+ var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1187
+ ch = state.input.charCodeAt(state.position);
1188
+ if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 0x23 /* # */ || ch === 0x26 /* & */ || ch === 0x2A /* * */ || ch === 0x21 /* ! */ || ch === 0x7C /* | */ || ch === 0x3E /* > */ || ch === 0x27 /* ' */ || ch === 0x22 /* " */ || ch === 0x25 /* % */ || ch === 0x40 /* @ */ || ch === 0x60 /* ` */ ) {
1189
+ return false;
1190
+ }
1191
+ if (ch === 0x3F /* ? */ || ch === 0x2D /* - */ ) {
1192
+ following = state.input.charCodeAt(state.position + 1);
1193
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1194
+ return false;
1195
+ }
1196
+ }
1197
+ state.kind = "scalar";
1198
+ state.result = "";
1199
+ captureStart = captureEnd = state.position;
1200
+ hasPendingContent = false;
1201
+ while(ch !== 0){
1202
+ if (ch === 0x3A /* : */ ) {
1203
+ following = state.input.charCodeAt(state.position + 1);
1204
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1205
+ break;
1206
+ }
1207
+ } else if (ch === 0x23 /* # */ ) {
1208
+ preceding = state.input.charCodeAt(state.position - 1);
1209
+ if (is_WS_OR_EOL(preceding)) {
1210
+ break;
1211
+ }
1212
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1213
+ break;
1214
+ } else if (is_EOL(ch)) {
1215
+ _line = state.line;
1216
+ _lineStart = state.lineStart;
1217
+ _lineIndent = state.lineIndent;
1218
+ skipSeparationSpace(state, false, -1);
1219
+ if (state.lineIndent >= nodeIndent) {
1220
+ hasPendingContent = true;
1221
+ ch = state.input.charCodeAt(state.position);
1222
+ continue;
1223
+ } else {
1224
+ state.position = captureEnd;
1225
+ state.line = _line;
1226
+ state.lineStart = _lineStart;
1227
+ state.lineIndent = _lineIndent;
1228
+ break;
1229
+ }
1230
+ }
1231
+ if (hasPendingContent) {
1232
+ captureSegment(state, captureStart, captureEnd, false);
1233
+ writeFoldedLines(state, state.line - _line);
1234
+ captureStart = captureEnd = state.position;
1235
+ hasPendingContent = false;
1236
+ }
1237
+ if (!is_WHITE_SPACE(ch)) {
1238
+ captureEnd = state.position + 1;
1239
+ }
1240
+ ch = state.input.charCodeAt(++state.position);
1241
+ }
1242
+ captureSegment(state, captureStart, captureEnd, false);
1243
+ if (state.result) {
1244
+ return true;
1245
+ }
1246
+ state.kind = _kind;
1247
+ state.result = _result;
1248
+ return false;
1249
+ }
1250
+ function readSingleQuotedScalar(state, nodeIndent) {
1251
+ var ch, captureStart, captureEnd;
1252
+ ch = state.input.charCodeAt(state.position);
1253
+ if (ch !== 0x27 /* ' */ ) {
1254
+ return false;
1255
+ }
1256
+ state.kind = "scalar";
1257
+ state.result = "";
1258
+ state.position++;
1259
+ captureStart = captureEnd = state.position;
1260
+ while((ch = state.input.charCodeAt(state.position)) !== 0){
1261
+ if (ch === 0x27 /* ' */ ) {
1262
+ captureSegment(state, captureStart, state.position, true);
1263
+ ch = state.input.charCodeAt(++state.position);
1264
+ if (ch === 0x27 /* ' */ ) {
1265
+ captureStart = state.position;
1266
+ state.position++;
1267
+ captureEnd = state.position;
1268
+ } else {
1269
+ return true;
1270
+ }
1271
+ } else if (is_EOL(ch)) {
1272
+ captureSegment(state, captureStart, captureEnd, true);
1273
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1274
+ captureStart = captureEnd = state.position;
1275
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1276
+ throwError(state, "unexpected end of the document within a single quoted scalar");
1277
+ } else {
1278
+ state.position++;
1279
+ captureEnd = state.position;
1280
+ }
1281
+ }
1282
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
1283
+ }
1284
+ function readDoubleQuotedScalar(state, nodeIndent) {
1285
+ var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1286
+ ch = state.input.charCodeAt(state.position);
1287
+ if (ch !== 0x22 /* " */ ) {
1288
+ return false;
1289
+ }
1290
+ state.kind = "scalar";
1291
+ state.result = "";
1292
+ state.position++;
1293
+ captureStart = captureEnd = state.position;
1294
+ while((ch = state.input.charCodeAt(state.position)) !== 0){
1295
+ if (ch === 0x22 /* " */ ) {
1296
+ captureSegment(state, captureStart, state.position, true);
1297
+ state.position++;
1298
+ return true;
1299
+ } else if (ch === 0x5C /* \ */ ) {
1300
+ captureSegment(state, captureStart, state.position, true);
1301
+ ch = state.input.charCodeAt(++state.position);
1302
+ if (is_EOL(ch)) {
1303
+ skipSeparationSpace(state, false, nodeIndent);
1304
+ // TODO: rework to inline fn with no type cast?
1305
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
1306
+ state.result += simpleEscapeMap[ch];
1307
+ state.position++;
1308
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
1309
+ hexLength = tmp;
1310
+ hexResult = 0;
1311
+ for(; hexLength > 0; hexLength--){
1312
+ ch = state.input.charCodeAt(++state.position);
1313
+ if ((tmp = fromHexCode(ch)) >= 0) {
1314
+ hexResult = (hexResult << 4) + tmp;
1315
+ } else {
1316
+ throwError(state, "expected hexadecimal character");
1317
+ }
1318
+ }
1319
+ state.result += charFromCodepoint(hexResult);
1320
+ state.position++;
1321
+ } else {
1322
+ throwError(state, "unknown escape sequence");
1323
+ }
1324
+ captureStart = captureEnd = state.position;
1325
+ } else if (is_EOL(ch)) {
1326
+ captureSegment(state, captureStart, captureEnd, true);
1327
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1328
+ captureStart = captureEnd = state.position;
1329
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1330
+ throwError(state, "unexpected end of the document within a double quoted scalar");
1331
+ } else {
1332
+ state.position++;
1333
+ captureEnd = state.position;
1334
+ }
1335
+ }
1336
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
1337
+ }
1338
+ function readFlowCollection(state, nodeIndent) {
1339
+ var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch;
1340
+ ch = state.input.charCodeAt(state.position);
1341
+ if (ch === 0x5B /* [ */ ) {
1342
+ terminator = 0x5D; /* ] */
1343
+ isMapping = false;
1344
+ _result = [];
1345
+ } else if (ch === 0x7B /* { */ ) {
1346
+ terminator = 0x7D; /* } */
1347
+ isMapping = true;
1348
+ _result = {};
1349
+ } else {
1350
+ return false;
1351
+ }
1352
+ if (state.anchor !== null) {
1353
+ state.anchorMap[state.anchor] = _result;
1354
+ }
1355
+ ch = state.input.charCodeAt(++state.position);
1356
+ while(ch !== 0){
1357
+ skipSeparationSpace(state, true, nodeIndent);
1358
+ ch = state.input.charCodeAt(state.position);
1359
+ if (ch === terminator) {
1360
+ state.position++;
1361
+ state.tag = _tag;
1362
+ state.anchor = _anchor;
1363
+ state.kind = isMapping ? "mapping" : "sequence";
1364
+ state.result = _result;
1365
+ return true;
1366
+ } else if (!readNext) {
1367
+ throwError(state, "missed comma between flow collection entries");
1368
+ } else if (ch === 0x2C /* , */ ) {
1369
+ // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4
1370
+ throwError(state, "expected the node content, but found ','");
1371
+ }
1372
+ keyTag = keyNode = valueNode = null;
1373
+ isPair = isExplicitPair = false;
1374
+ if (ch === 0x3F /* ? */ ) {
1375
+ following = state.input.charCodeAt(state.position + 1);
1376
+ if (is_WS_OR_EOL(following)) {
1377
+ isPair = isExplicitPair = true;
1378
+ state.position++;
1379
+ skipSeparationSpace(state, true, nodeIndent);
1380
+ }
1381
+ }
1382
+ _line = state.line; // Save the current line.
1383
+ _lineStart = state.lineStart;
1384
+ _pos = state.position;
1385
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1386
+ keyTag = state.tag;
1387
+ keyNode = state.result;
1388
+ skipSeparationSpace(state, true, nodeIndent);
1389
+ ch = state.input.charCodeAt(state.position);
1390
+ if ((isExplicitPair || state.line === _line) && ch === 0x3A /* : */ ) {
1391
+ isPair = true;
1392
+ ch = state.input.charCodeAt(++state.position);
1393
+ skipSeparationSpace(state, true, nodeIndent);
1394
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1395
+ valueNode = state.result;
1396
+ }
1397
+ if (isMapping) {
1398
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
1399
+ } else if (isPair) {
1400
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
1401
+ } else {
1402
+ _result.push(keyNode);
1403
+ }
1404
+ skipSeparationSpace(state, true, nodeIndent);
1405
+ ch = state.input.charCodeAt(state.position);
1406
+ if (ch === 0x2C /* , */ ) {
1407
+ readNext = true;
1408
+ ch = state.input.charCodeAt(++state.position);
1409
+ } else {
1410
+ readNext = false;
1411
+ }
1412
+ }
1413
+ throwError(state, "unexpected end of the stream within a flow collection");
1414
+ }
1415
+ function readBlockScalar(state, nodeIndent) {
1416
+ var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
1417
+ ch = state.input.charCodeAt(state.position);
1418
+ if (ch === 0x7C /* | */ ) {
1419
+ folding = false;
1420
+ } else if (ch === 0x3E /* > */ ) {
1421
+ folding = true;
1422
+ } else {
1423
+ return false;
1424
+ }
1425
+ state.kind = "scalar";
1426
+ state.result = "";
1427
+ while(ch !== 0){
1428
+ ch = state.input.charCodeAt(++state.position);
1429
+ if (ch === 0x2B /* + */ || ch === 0x2D /* - */ ) {
1430
+ if (CHOMPING_CLIP === chomping) {
1431
+ chomping = ch === 0x2B /* + */ ? CHOMPING_KEEP : CHOMPING_STRIP;
1432
+ } else {
1433
+ throwError(state, "repeat of a chomping mode identifier");
1434
+ }
1435
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1436
+ if (tmp === 0) {
1437
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
1438
+ } else if (!detectedIndent) {
1439
+ textIndent = nodeIndent + tmp - 1;
1440
+ detectedIndent = true;
1441
+ } else {
1442
+ throwError(state, "repeat of an indentation width identifier");
1443
+ }
1444
+ } else {
1445
+ break;
1446
+ }
1447
+ }
1448
+ if (is_WHITE_SPACE(ch)) {
1449
+ do {
1450
+ ch = state.input.charCodeAt(++state.position);
1451
+ }while (is_WHITE_SPACE(ch));
1452
+ if (ch === 0x23 /* # */ ) {
1453
+ do {
1454
+ ch = state.input.charCodeAt(++state.position);
1455
+ }while (!is_EOL(ch) && ch !== 0);
1456
+ }
1457
+ }
1458
+ while(ch !== 0){
1459
+ readLineBreak(state);
1460
+ state.lineIndent = 0;
1461
+ ch = state.input.charCodeAt(state.position);
1462
+ while((!detectedIndent || state.lineIndent < textIndent) && ch === 0x20 /* Space */ ){
1463
+ state.lineIndent++;
1464
+ ch = state.input.charCodeAt(++state.position);
1465
+ }
1466
+ if (!detectedIndent && state.lineIndent > textIndent) {
1467
+ textIndent = state.lineIndent;
1468
+ }
1469
+ if (is_EOL(ch)) {
1470
+ emptyLines++;
1471
+ continue;
1472
+ }
1473
+ // End of the scalar.
1474
+ if (state.lineIndent < textIndent) {
1475
+ // Perform the chomping.
1476
+ if (chomping === CHOMPING_KEEP) {
1477
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1478
+ } else if (chomping === CHOMPING_CLIP) {
1479
+ if (didReadContent) {
1480
+ state.result += "\n";
1481
+ }
1482
+ }
1483
+ break;
1484
+ }
1485
+ // Folded style: use fancy rules to handle line breaks.
1486
+ if (folding) {
1487
+ // Lines starting with white space characters (more-indented lines) are not folded.
1488
+ if (is_WHITE_SPACE(ch)) {
1489
+ atMoreIndented = true;
1490
+ // except for the first content line (cf. Example 8.1)
1491
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1492
+ // End of more-indented block.
1493
+ } else if (atMoreIndented) {
1494
+ atMoreIndented = false;
1495
+ state.result += common.repeat("\n", emptyLines + 1);
1496
+ // Just one line break - perceive as the same line.
1497
+ } else if (emptyLines === 0) {
1498
+ if (didReadContent) {
1499
+ state.result += " ";
1500
+ }
1501
+ // Several line breaks - perceive as different lines.
1502
+ } else {
1503
+ state.result += common.repeat("\n", emptyLines);
1504
+ }
1505
+ // Literal style: just add exact number of line breaks between content lines.
1506
+ } else {
1507
+ // Keep all line breaks except the header line break.
1508
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
1509
+ }
1510
+ didReadContent = true;
1511
+ detectedIndent = true;
1512
+ emptyLines = 0;
1513
+ captureStart = state.position;
1514
+ while(!is_EOL(ch) && ch !== 0){
1515
+ ch = state.input.charCodeAt(++state.position);
1516
+ }
1517
+ captureSegment(state, captureStart, state.position, false);
1518
+ }
1519
+ return true;
1520
+ }
1521
+ function readBlockSequence(state, nodeIndent) {
1522
+ var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
1523
+ // there is a leading tab before this token, so it can't be a block sequence/mapping;
1524
+ // it can still be flow sequence/mapping or a scalar
1525
+ if (state.firstTabInLine !== -1) return false;
1526
+ if (state.anchor !== null) {
1527
+ state.anchorMap[state.anchor] = _result;
1528
+ }
1529
+ ch = state.input.charCodeAt(state.position);
1530
+ while(ch !== 0){
1531
+ if (state.firstTabInLine !== -1) {
1532
+ state.position = state.firstTabInLine;
1533
+ throwError(state, "tab characters must not be used in indentation");
1534
+ }
1535
+ if (ch !== 0x2D /* - */ ) {
1536
+ break;
1537
+ }
1538
+ following = state.input.charCodeAt(state.position + 1);
1539
+ if (!is_WS_OR_EOL(following)) {
1540
+ break;
1541
+ }
1542
+ detected = true;
1543
+ state.position++;
1544
+ if (skipSeparationSpace(state, true, -1)) {
1545
+ if (state.lineIndent <= nodeIndent) {
1546
+ _result.push(null);
1547
+ ch = state.input.charCodeAt(state.position);
1548
+ continue;
1549
+ }
1550
+ }
1551
+ _line = state.line;
1552
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1553
+ _result.push(state.result);
1554
+ skipSeparationSpace(state, true, -1);
1555
+ ch = state.input.charCodeAt(state.position);
1556
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1557
+ throwError(state, "bad indentation of a sequence entry");
1558
+ } else if (state.lineIndent < nodeIndent) {
1559
+ break;
1560
+ }
1561
+ }
1562
+ if (detected) {
1563
+ state.tag = _tag;
1564
+ state.anchor = _anchor;
1565
+ state.kind = "sequence";
1566
+ state.result = _result;
1567
+ return true;
1568
+ }
1569
+ return false;
1570
+ }
1571
+ function readBlockMapping(state, nodeIndent, flowIndent) {
1572
+ var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
1573
+ // there is a leading tab before this token, so it can't be a block sequence/mapping;
1574
+ // it can still be flow sequence/mapping or a scalar
1575
+ if (state.firstTabInLine !== -1) return false;
1576
+ if (state.anchor !== null) {
1577
+ state.anchorMap[state.anchor] = _result;
1578
+ }
1579
+ ch = state.input.charCodeAt(state.position);
1580
+ while(ch !== 0){
1581
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
1582
+ state.position = state.firstTabInLine;
1583
+ throwError(state, "tab characters must not be used in indentation");
1584
+ }
1585
+ following = state.input.charCodeAt(state.position + 1);
1586
+ _line = state.line; // Save the current line.
1587
+ //
1588
+ // Explicit notation case. There are two separate blocks:
1589
+ // first for the key (denoted by "?") and second for the value (denoted by ":")
1590
+ //
1591
+ if ((ch === 0x3F /* ? */ || ch === 0x3A /* : */ ) && is_WS_OR_EOL(following)) {
1592
+ if (ch === 0x3F /* ? */ ) {
1593
+ if (atExplicitKey) {
1594
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1595
+ keyTag = keyNode = valueNode = null;
1596
+ }
1597
+ detected = true;
1598
+ atExplicitKey = true;
1599
+ allowCompact = true;
1600
+ } else if (atExplicitKey) {
1601
+ // i.e. 0x3A/* : */ === character after the explicit key.
1602
+ atExplicitKey = false;
1603
+ allowCompact = true;
1604
+ } else {
1605
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
1606
+ }
1607
+ state.position += 1;
1608
+ ch = following;
1609
+ //
1610
+ // Implicit notation case. Flow-style node as the key first, then ":", and the value.
1611
+ //
1612
+ } else {
1613
+ _keyLine = state.line;
1614
+ _keyLineStart = state.lineStart;
1615
+ _keyPos = state.position;
1616
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1617
+ break;
1618
+ }
1619
+ if (state.line === _line) {
1620
+ ch = state.input.charCodeAt(state.position);
1621
+ while(is_WHITE_SPACE(ch)){
1622
+ ch = state.input.charCodeAt(++state.position);
1623
+ }
1624
+ if (ch === 0x3A /* : */ ) {
1625
+ ch = state.input.charCodeAt(++state.position);
1626
+ if (!is_WS_OR_EOL(ch)) {
1627
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
1628
+ }
1629
+ if (atExplicitKey) {
1630
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1631
+ keyTag = keyNode = valueNode = null;
1632
+ }
1633
+ detected = true;
1634
+ atExplicitKey = false;
1635
+ allowCompact = false;
1636
+ keyTag = state.tag;
1637
+ keyNode = state.result;
1638
+ } else if (detected) {
1639
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
1640
+ } else {
1641
+ state.tag = _tag;
1642
+ state.anchor = _anchor;
1643
+ return true; // Keep the result of `composeNode`.
1644
+ }
1645
+ } else if (detected) {
1646
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
1647
+ } else {
1648
+ state.tag = _tag;
1649
+ state.anchor = _anchor;
1650
+ return true; // Keep the result of `composeNode`.
1651
+ }
1652
+ }
1653
+ //
1654
+ // Common reading code for both explicit and implicit notations.
1655
+ //
1656
+ if (state.line === _line || state.lineIndent > nodeIndent) {
1657
+ if (atExplicitKey) {
1658
+ _keyLine = state.line;
1659
+ _keyLineStart = state.lineStart;
1660
+ _keyPos = state.position;
1661
+ }
1662
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1663
+ if (atExplicitKey) {
1664
+ keyNode = state.result;
1665
+ } else {
1666
+ valueNode = state.result;
1667
+ }
1668
+ }
1669
+ if (!atExplicitKey) {
1670
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
1671
+ keyTag = keyNode = valueNode = null;
1672
+ }
1673
+ skipSeparationSpace(state, true, -1);
1674
+ ch = state.input.charCodeAt(state.position);
1675
+ }
1676
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
1677
+ throwError(state, "bad indentation of a mapping entry");
1678
+ } else if (state.lineIndent < nodeIndent) {
1679
+ break;
1680
+ }
1681
+ }
1682
+ //
1683
+ // Epilogue.
1684
+ //
1685
+ // Special case: last mapping's node contains only the key in explicit notation.
1686
+ if (atExplicitKey) {
1687
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
1688
+ }
1689
+ // Expose the resulting mapping.
1690
+ if (detected) {
1691
+ state.tag = _tag;
1692
+ state.anchor = _anchor;
1693
+ state.kind = "mapping";
1694
+ state.result = _result;
1695
+ }
1696
+ return detected;
1697
+ }
1698
+ function readTagProperty(state) {
1699
+ var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
1700
+ ch = state.input.charCodeAt(state.position);
1701
+ if (ch !== 0x21 /* ! */ ) return false;
1702
+ if (state.tag !== null) {
1703
+ throwError(state, "duplication of a tag property");
1704
+ }
1705
+ ch = state.input.charCodeAt(++state.position);
1706
+ if (ch === 0x3C /* < */ ) {
1707
+ isVerbatim = true;
1708
+ ch = state.input.charCodeAt(++state.position);
1709
+ } else if (ch === 0x21 /* ! */ ) {
1710
+ isNamed = true;
1711
+ tagHandle = "!!";
1712
+ ch = state.input.charCodeAt(++state.position);
1713
+ } else {
1714
+ tagHandle = "!";
1715
+ }
1716
+ _position = state.position;
1717
+ if (isVerbatim) {
1718
+ do {
1719
+ ch = state.input.charCodeAt(++state.position);
1720
+ }while (ch !== 0 && ch !== 0x3E /* > */ );
1721
+ if (state.position < state.length) {
1722
+ tagName = state.input.slice(_position, state.position);
1723
+ ch = state.input.charCodeAt(++state.position);
1724
+ } else {
1725
+ throwError(state, "unexpected end of the stream within a verbatim tag");
1726
+ }
1727
+ } else {
1728
+ while(ch !== 0 && !is_WS_OR_EOL(ch)){
1729
+ if (ch === 0x21 /* ! */ ) {
1730
+ if (!isNamed) {
1731
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
1732
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1733
+ throwError(state, "named tag handle cannot contain such characters");
1734
+ }
1735
+ isNamed = true;
1736
+ _position = state.position + 1;
1737
+ } else {
1738
+ throwError(state, "tag suffix cannot contain exclamation marks");
1739
+ }
1740
+ }
1741
+ ch = state.input.charCodeAt(++state.position);
1742
+ }
1743
+ tagName = state.input.slice(_position, state.position);
1744
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1745
+ throwError(state, "tag suffix cannot contain flow indicator characters");
1746
+ }
1747
+ }
1748
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1749
+ throwError(state, "tag name cannot contain such characters: " + tagName);
1750
+ }
1751
+ try {
1752
+ tagName = decodeURIComponent(tagName);
1753
+ } catch (err) {
1754
+ throwError(state, "tag name is malformed: " + tagName);
1755
+ }
1756
+ if (isVerbatim) {
1757
+ state.tag = tagName;
1758
+ } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
1759
+ state.tag = state.tagMap[tagHandle] + tagName;
1760
+ } else if (tagHandle === "!") {
1761
+ state.tag = "!" + tagName;
1762
+ } else if (tagHandle === "!!") {
1763
+ state.tag = "tag:yaml.org,2002:" + tagName;
1764
+ } else {
1765
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1766
+ }
1767
+ return true;
1768
+ }
1769
+ function readAnchorProperty(state) {
1770
+ var _position, ch;
1771
+ ch = state.input.charCodeAt(state.position);
1772
+ if (ch !== 0x26 /* & */ ) return false;
1773
+ if (state.anchor !== null) {
1774
+ throwError(state, "duplication of an anchor property");
1775
+ }
1776
+ ch = state.input.charCodeAt(++state.position);
1777
+ _position = state.position;
1778
+ while(ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)){
1779
+ ch = state.input.charCodeAt(++state.position);
1780
+ }
1781
+ if (state.position === _position) {
1782
+ throwError(state, "name of an anchor node must contain at least one character");
1783
+ }
1784
+ state.anchor = state.input.slice(_position, state.position);
1785
+ return true;
1786
+ }
1787
+ function readAlias(state) {
1788
+ var _position, alias, ch;
1789
+ ch = state.input.charCodeAt(state.position);
1790
+ if (ch !== 0x2A /* * */ ) return false;
1791
+ ch = state.input.charCodeAt(++state.position);
1792
+ _position = state.position;
1793
+ while(ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)){
1794
+ ch = state.input.charCodeAt(++state.position);
1795
+ }
1796
+ if (state.position === _position) {
1797
+ throwError(state, "name of an alias node must contain at least one character");
1798
+ }
1799
+ alias = state.input.slice(_position, state.position);
1800
+ if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
1801
+ throwError(state, 'unidentified alias "' + alias + '"');
1802
+ }
1803
+ state.result = state.anchorMap[alias];
1804
+ skipSeparationSpace(state, true, -1);
1805
+ return true;
1806
+ }
1807
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1808
+ var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type, flowIndent, blockIndent;
1809
+ if (state.listener !== null) {
1810
+ state.listener("open", state);
1811
+ }
1812
+ state.tag = null;
1813
+ state.anchor = null;
1814
+ state.kind = null;
1815
+ state.result = null;
1816
+ allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
1817
+ if (allowToSeek) {
1818
+ if (skipSeparationSpace(state, true, -1)) {
1819
+ atNewLine = true;
1820
+ if (state.lineIndent > parentIndent) {
1821
+ indentStatus = 1;
1822
+ } else if (state.lineIndent === parentIndent) {
1823
+ indentStatus = 0;
1824
+ } else if (state.lineIndent < parentIndent) {
1825
+ indentStatus = -1;
1826
+ }
1827
+ }
1828
+ }
1829
+ if (indentStatus === 1) {
1830
+ while(readTagProperty(state) || readAnchorProperty(state)){
1831
+ if (skipSeparationSpace(state, true, -1)) {
1832
+ atNewLine = true;
1833
+ allowBlockCollections = allowBlockStyles;
1834
+ if (state.lineIndent > parentIndent) {
1835
+ indentStatus = 1;
1836
+ } else if (state.lineIndent === parentIndent) {
1837
+ indentStatus = 0;
1838
+ } else if (state.lineIndent < parentIndent) {
1839
+ indentStatus = -1;
1840
+ }
1841
+ } else {
1842
+ allowBlockCollections = false;
1843
+ }
1844
+ }
1845
+ }
1846
+ if (allowBlockCollections) {
1847
+ allowBlockCollections = atNewLine || allowCompact;
1848
+ }
1849
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1850
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
1851
+ flowIndent = parentIndent;
1852
+ } else {
1853
+ flowIndent = parentIndent + 1;
1854
+ }
1855
+ blockIndent = state.position - state.lineStart;
1856
+ if (indentStatus === 1) {
1857
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
1858
+ hasContent = true;
1859
+ } else {
1860
+ if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
1861
+ hasContent = true;
1862
+ } else if (readAlias(state)) {
1863
+ hasContent = true;
1864
+ if (state.tag !== null || state.anchor !== null) {
1865
+ throwError(state, "alias node should not have any properties");
1866
+ }
1867
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1868
+ hasContent = true;
1869
+ if (state.tag === null) {
1870
+ state.tag = "?";
1871
+ }
1872
+ }
1873
+ if (state.anchor !== null) {
1874
+ state.anchorMap[state.anchor] = state.result;
1875
+ }
1876
+ }
1877
+ } else if (indentStatus === 0) {
1878
+ // Special case: block sequences are allowed to have same indentation level as the parent.
1879
+ // http://www.yaml.org/spec/1.2/spec.html#id2799784
1880
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
1881
+ }
1882
+ }
1883
+ if (state.tag === null) {
1884
+ if (state.anchor !== null) {
1885
+ state.anchorMap[state.anchor] = state.result;
1886
+ }
1887
+ } else if (state.tag === "?") {
1888
+ // Implicit resolving is not allowed for non-scalar types, and '?'
1889
+ // non-specific tag is only automatically assigned to plain scalars.
1890
+ //
1891
+ // We only need to check kind conformity in case user explicitly assigns '?'
1892
+ // tag, for example like this: "!<?> [0]"
1893
+ //
1894
+ if (state.result !== null && state.kind !== "scalar") {
1895
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
1896
+ }
1897
+ for(typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1){
1898
+ type = state.implicitTypes[typeIndex];
1899
+ if (type.resolve(state.result)) {
1900
+ state.result = type.construct(state.result);
1901
+ state.tag = type.tag;
1902
+ if (state.anchor !== null) {
1903
+ state.anchorMap[state.anchor] = state.result;
1904
+ }
1905
+ break;
1906
+ }
1907
+ }
1908
+ } else if (state.tag !== "!") {
1909
+ if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
1910
+ type = state.typeMap[state.kind || "fallback"][state.tag];
1911
+ } else {
1912
+ // looking for multi type
1913
+ type = null;
1914
+ typeList = state.typeMap.multi[state.kind || "fallback"];
1915
+ for(typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1){
1916
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
1917
+ type = typeList[typeIndex];
1918
+ break;
1919
+ }
1920
+ }
1921
+ }
1922
+ if (!type) {
1923
+ throwError(state, "unknown tag !<" + state.tag + ">");
1924
+ }
1925
+ if (state.result !== null && type.kind !== state.kind) {
1926
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
1927
+ }
1928
+ if (!type.resolve(state.result, state.tag)) {
1929
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
1930
+ } else {
1931
+ state.result = type.construct(state.result, state.tag);
1932
+ if (state.anchor !== null) {
1933
+ state.anchorMap[state.anchor] = state.result;
1934
+ }
1935
+ }
1936
+ }
1937
+ if (state.listener !== null) {
1938
+ state.listener("close", state);
1939
+ }
1940
+ return state.tag !== null || state.anchor !== null || hasContent;
1941
+ }
1942
+ function readDocument(state) {
1943
+ var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
1944
+ state.version = null;
1945
+ state.checkLineBreaks = state.legacy;
1946
+ state.tagMap = Object.create(null);
1947
+ state.anchorMap = Object.create(null);
1948
+ while((ch = state.input.charCodeAt(state.position)) !== 0){
1949
+ skipSeparationSpace(state, true, -1);
1950
+ ch = state.input.charCodeAt(state.position);
1951
+ if (state.lineIndent > 0 || ch !== 0x25 /* % */ ) {
1952
+ break;
1953
+ }
1954
+ hasDirectives = true;
1955
+ ch = state.input.charCodeAt(++state.position);
1956
+ _position = state.position;
1957
+ while(ch !== 0 && !is_WS_OR_EOL(ch)){
1958
+ ch = state.input.charCodeAt(++state.position);
1959
+ }
1960
+ directiveName = state.input.slice(_position, state.position);
1961
+ directiveArgs = [];
1962
+ if (directiveName.length < 1) {
1963
+ throwError(state, "directive name must not be less than one character in length");
1964
+ }
1965
+ while(ch !== 0){
1966
+ while(is_WHITE_SPACE(ch)){
1967
+ ch = state.input.charCodeAt(++state.position);
1968
+ }
1969
+ if (ch === 0x23 /* # */ ) {
1970
+ do {
1971
+ ch = state.input.charCodeAt(++state.position);
1972
+ }while (ch !== 0 && !is_EOL(ch));
1973
+ break;
1974
+ }
1975
+ if (is_EOL(ch)) break;
1976
+ _position = state.position;
1977
+ while(ch !== 0 && !is_WS_OR_EOL(ch)){
1978
+ ch = state.input.charCodeAt(++state.position);
1979
+ }
1980
+ directiveArgs.push(state.input.slice(_position, state.position));
1981
+ }
1982
+ if (ch !== 0) readLineBreak(state);
1983
+ if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
1984
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
1985
+ } else {
1986
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
1987
+ }
1988
+ }
1989
+ skipSeparationSpace(state, true, -1);
1990
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 0x2D /* - */ && state.input.charCodeAt(state.position + 1) === 0x2D /* - */ && state.input.charCodeAt(state.position + 2) === 0x2D /* - */ ) {
1991
+ state.position += 3;
1992
+ skipSeparationSpace(state, true, -1);
1993
+ } else if (hasDirectives) {
1994
+ throwError(state, "directives end mark is expected");
1995
+ }
1996
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
1997
+ skipSeparationSpace(state, true, -1);
1998
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
1999
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
2000
+ }
2001
+ state.documents.push(state.result);
2002
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
2003
+ if (state.input.charCodeAt(state.position) === 0x2E /* . */ ) {
2004
+ state.position += 3;
2005
+ skipSeparationSpace(state, true, -1);
2006
+ }
2007
+ return;
2008
+ }
2009
+ if (state.position < state.length - 1) {
2010
+ throwError(state, "end of the stream or a document separator is expected");
2011
+ } else {
2012
+ return;
2013
+ }
2014
+ }
2015
+ function loadDocuments(input, options) {
2016
+ input = String(input);
2017
+ options = options || {};
2018
+ if (input.length !== 0) {
2019
+ // Add tailing `\n` if not exists
2020
+ if (input.charCodeAt(input.length - 1) !== 0x0A /* LF */ && input.charCodeAt(input.length - 1) !== 0x0D /* CR */ ) {
2021
+ input += "\n";
2022
+ }
2023
+ // Strip BOM
2024
+ if (input.charCodeAt(0) === 0xFEFF) {
2025
+ input = input.slice(1);
2026
+ }
2027
+ }
2028
+ var state = new State$1(input, options);
2029
+ var nullpos = input.indexOf("\0");
2030
+ if (nullpos !== -1) {
2031
+ state.position = nullpos;
2032
+ throwError(state, "null byte is not allowed in input");
2033
+ }
2034
+ // Use 0 as string terminator. That significantly simplifies bounds check.
2035
+ state.input += "\0";
2036
+ while(state.input.charCodeAt(state.position) === 0x20 /* Space */ ){
2037
+ state.lineIndent += 1;
2038
+ state.position += 1;
2039
+ }
2040
+ while(state.position < state.length - 1){
2041
+ readDocument(state);
2042
+ }
2043
+ return state.documents;
2044
+ }
2045
+ function loadAll$1(input, iterator, options) {
2046
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2047
+ options = iterator;
2048
+ iterator = null;
2049
+ }
2050
+ var documents = loadDocuments(input, options);
2051
+ if (typeof iterator !== "function") {
2052
+ return documents;
2053
+ }
2054
+ for(var index = 0, length = documents.length; index < length; index += 1){
2055
+ iterator(documents[index]);
2056
+ }
2057
+ }
2058
+ function load$1(input, options) {
2059
+ var documents = loadDocuments(input, options);
2060
+ if (documents.length === 0) {
2061
+ /*eslint-disable no-undefined*/ return undefined;
2062
+ } else if (documents.length === 1) {
2063
+ return documents[0];
2064
+ }
2065
+ throw new exception("expected a single document in the stream, but found more");
2066
+ }
2067
+ var loadAll_1 = loadAll$1;
2068
+ var load_1 = load$1;
2069
+ var loader = {
2070
+ loadAll: loadAll_1,
2071
+ load: load_1
2072
+ };
804
2073
  /*eslint-disable no-use-before-define*/ var _toString = Object.prototype.toString;
805
2074
  var _hasOwnProperty = Object.prototype.hasOwnProperty;
806
2075
  var CHAR_BOM = 0xFEFF;
@@ -1523,12 +2792,13 @@ var dump_1 = dump$1;
1523
2792
  var dumper = {
1524
2793
  dump: dump_1
1525
2794
  };
2795
+ var load$2 = loader.load;
1526
2796
  var dump$2 = dumper.dump;
1527
2797
 
1528
2798
  let YamlService = class YamlService {
1529
2799
  async load(params, _pinsSettingsList, context) {
1530
2800
  const { yaml, options = {} } = params;
1531
- return yaml.load(yaml, options);
2801
+ return load$2(yaml, options);
1532
2802
  }
1533
2803
  async dump(params, _pinsSettingsList, context) {
1534
2804
  const { data, options = {} } = params;