@mcpc-tech/plugin-markdown-loader 0.0.10 → 0.0.12
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/index.cjs +197 -162
- package/index.mjs +197 -162
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import { createRequire } from 'node:module';
|
|
3
2
|
const require = createRequire(import.meta.url);
|
|
4
3
|
|
|
@@ -843,12 +842,29 @@ function writeFoldedLines(count) {
|
|
|
843
842
|
if (count > 1) return "\n".repeat(count - 1);
|
|
844
843
|
return "";
|
|
845
844
|
}
|
|
845
|
+
var Scanner = class {
|
|
846
|
+
source;
|
|
847
|
+
#length;
|
|
848
|
+
position = 0;
|
|
849
|
+
constructor(source) {
|
|
850
|
+
source += "\0";
|
|
851
|
+
this.source = source;
|
|
852
|
+
this.#length = source.length;
|
|
853
|
+
}
|
|
854
|
+
peek(offset = 0) {
|
|
855
|
+
return this.source.charCodeAt(this.position + offset);
|
|
856
|
+
}
|
|
857
|
+
next() {
|
|
858
|
+
this.position += 1;
|
|
859
|
+
}
|
|
860
|
+
eof() {
|
|
861
|
+
return this.position >= this.#length - 1;
|
|
862
|
+
}
|
|
863
|
+
};
|
|
846
864
|
var LoaderState = class {
|
|
847
|
-
|
|
848
|
-
length;
|
|
865
|
+
#scanner;
|
|
849
866
|
lineIndent = 0;
|
|
850
867
|
lineStart = 0;
|
|
851
|
-
position = 0;
|
|
852
868
|
line = 0;
|
|
853
869
|
onWarning;
|
|
854
870
|
allowDuplicateKeys;
|
|
@@ -858,44 +874,40 @@ var LoaderState = class {
|
|
|
858
874
|
tagMap = /* @__PURE__ */ new Map();
|
|
859
875
|
anchorMap = /* @__PURE__ */ new Map();
|
|
860
876
|
constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false }) {
|
|
861
|
-
this
|
|
877
|
+
this.#scanner = new Scanner(input);
|
|
862
878
|
this.onWarning = onWarning;
|
|
863
879
|
this.allowDuplicateKeys = allowDuplicateKeys;
|
|
864
880
|
this.implicitTypes = schema.implicitTypes;
|
|
865
881
|
this.typeMap = schema.typeMap;
|
|
866
|
-
this.length = input.length;
|
|
867
882
|
this.readIndent();
|
|
868
883
|
}
|
|
869
884
|
skipWhitespaces() {
|
|
870
|
-
let ch = this.peek();
|
|
885
|
+
let ch = this.#scanner.peek();
|
|
871
886
|
while (isWhiteSpace(ch)) {
|
|
872
|
-
|
|
887
|
+
this.#scanner.next();
|
|
888
|
+
ch = this.#scanner.peek();
|
|
873
889
|
}
|
|
874
890
|
}
|
|
875
891
|
skipComment() {
|
|
876
|
-
let ch = this.peek();
|
|
892
|
+
let ch = this.#scanner.peek();
|
|
877
893
|
if (ch !== SHARP) return;
|
|
878
|
-
|
|
894
|
+
this.#scanner.next();
|
|
895
|
+
ch = this.#scanner.peek();
|
|
879
896
|
while (ch !== 0 && !isEOL(ch)) {
|
|
880
|
-
|
|
897
|
+
this.#scanner.next();
|
|
898
|
+
ch = this.#scanner.peek();
|
|
881
899
|
}
|
|
882
900
|
}
|
|
883
901
|
readIndent() {
|
|
884
|
-
let
|
|
885
|
-
while (
|
|
902
|
+
let ch = this.#scanner.peek();
|
|
903
|
+
while (ch === SPACE) {
|
|
886
904
|
this.lineIndent += 1;
|
|
887
|
-
|
|
905
|
+
this.#scanner.next();
|
|
906
|
+
ch = this.#scanner.peek();
|
|
888
907
|
}
|
|
889
908
|
}
|
|
890
|
-
peek(offset = 0) {
|
|
891
|
-
return this.input.charCodeAt(this.position + offset);
|
|
892
|
-
}
|
|
893
|
-
next() {
|
|
894
|
-
this.position += 1;
|
|
895
|
-
return this.peek();
|
|
896
|
-
}
|
|
897
909
|
#createError(message) {
|
|
898
|
-
const mark = markToString(this.
|
|
910
|
+
const mark = markToString(this.#scanner.source, this.#scanner.position, this.line, this.#scanner.position - this.lineStart);
|
|
899
911
|
return new SyntaxError(`${message} ${mark}`);
|
|
900
912
|
}
|
|
901
913
|
dispatchWarning(message) {
|
|
@@ -940,7 +952,7 @@ var LoaderState = class {
|
|
|
940
952
|
}
|
|
941
953
|
captureSegment(start, end, checkJson) {
|
|
942
954
|
if (start < end) {
|
|
943
|
-
const result = this.
|
|
955
|
+
const result = this.#scanner.source.slice(start, end);
|
|
944
956
|
if (checkJson) {
|
|
945
957
|
for (let position = 0; position < result.length; position++) {
|
|
946
958
|
const character = result.charCodeAt(position);
|
|
@@ -958,21 +970,21 @@ var LoaderState = class {
|
|
|
958
970
|
let detected = false;
|
|
959
971
|
const result = [];
|
|
960
972
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
961
|
-
let ch = this.peek();
|
|
973
|
+
let ch = this.#scanner.peek();
|
|
962
974
|
while (ch !== 0) {
|
|
963
975
|
if (ch !== MINUS) {
|
|
964
976
|
break;
|
|
965
977
|
}
|
|
966
|
-
const following = this.peek(1);
|
|
978
|
+
const following = this.#scanner.peek(1);
|
|
967
979
|
if (!isWhiteSpaceOrEOL(following)) {
|
|
968
980
|
break;
|
|
969
981
|
}
|
|
970
982
|
detected = true;
|
|
971
|
-
this.
|
|
983
|
+
this.#scanner.next();
|
|
972
984
|
if (this.skipSeparationSpace(true, -1)) {
|
|
973
985
|
if (this.lineIndent <= nodeIndent) {
|
|
974
986
|
result.push(null);
|
|
975
|
-
ch = this.peek();
|
|
987
|
+
ch = this.#scanner.peek();
|
|
976
988
|
continue;
|
|
977
989
|
}
|
|
978
990
|
}
|
|
@@ -985,7 +997,7 @@ var LoaderState = class {
|
|
|
985
997
|
});
|
|
986
998
|
if (newState) result.push(newState.result);
|
|
987
999
|
this.skipSeparationSpace(true, -1);
|
|
988
|
-
ch = this.peek();
|
|
1000
|
+
ch = this.#scanner.peek();
|
|
989
1001
|
if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) {
|
|
990
1002
|
throw this.#createError("Cannot read block sequence: bad indentation of a sequence entry");
|
|
991
1003
|
} else if (this.lineIndent < nodeIndent) {
|
|
@@ -1041,7 +1053,7 @@ var LoaderState = class {
|
|
|
1041
1053
|
} else {
|
|
1042
1054
|
if (!this.allowDuplicateKeys && !overridableKeys.has(keyNode) && Object.hasOwn(result, keyNode)) {
|
|
1043
1055
|
this.line = startLine || this.line;
|
|
1044
|
-
this.position = startPos || this.position;
|
|
1056
|
+
this.#scanner.position = startPos || this.#scanner.position;
|
|
1045
1057
|
throw this.#createError("Cannot store mapping pair: duplicated key");
|
|
1046
1058
|
}
|
|
1047
1059
|
Object.defineProperty(result, keyNode, {
|
|
@@ -1055,37 +1067,37 @@ var LoaderState = class {
|
|
|
1055
1067
|
return result;
|
|
1056
1068
|
}
|
|
1057
1069
|
readLineBreak() {
|
|
1058
|
-
const ch = this.peek();
|
|
1070
|
+
const ch = this.#scanner.peek();
|
|
1059
1071
|
if (ch === LINE_FEED) {
|
|
1060
|
-
this.
|
|
1072
|
+
this.#scanner.next();
|
|
1061
1073
|
} else if (ch === CARRIAGE_RETURN) {
|
|
1062
|
-
this.
|
|
1063
|
-
if (this.peek() === LINE_FEED) {
|
|
1064
|
-
this.
|
|
1074
|
+
this.#scanner.next();
|
|
1075
|
+
if (this.#scanner.peek() === LINE_FEED) {
|
|
1076
|
+
this.#scanner.next();
|
|
1065
1077
|
}
|
|
1066
1078
|
} else {
|
|
1067
1079
|
throw this.#createError("Cannot read line: line break not found");
|
|
1068
1080
|
}
|
|
1069
1081
|
this.line += 1;
|
|
1070
|
-
this.lineStart = this.position;
|
|
1082
|
+
this.lineStart = this.#scanner.position;
|
|
1071
1083
|
}
|
|
1072
1084
|
skipSeparationSpace(allowComments, checkIndent) {
|
|
1073
1085
|
let lineBreaks = 0;
|
|
1074
|
-
let ch = this.peek();
|
|
1086
|
+
let ch = this.#scanner.peek();
|
|
1075
1087
|
while (ch !== 0) {
|
|
1076
1088
|
this.skipWhitespaces();
|
|
1077
|
-
ch = this.peek();
|
|
1089
|
+
ch = this.#scanner.peek();
|
|
1078
1090
|
if (allowComments) {
|
|
1079
1091
|
this.skipComment();
|
|
1080
|
-
ch = this.peek();
|
|
1092
|
+
ch = this.#scanner.peek();
|
|
1081
1093
|
}
|
|
1082
1094
|
if (isEOL(ch)) {
|
|
1083
1095
|
this.readLineBreak();
|
|
1084
|
-
ch = this.peek();
|
|
1096
|
+
ch = this.#scanner.peek();
|
|
1085
1097
|
lineBreaks++;
|
|
1086
1098
|
this.lineIndent = 0;
|
|
1087
1099
|
this.readIndent();
|
|
1088
|
-
ch = this.peek();
|
|
1100
|
+
ch = this.#scanner.peek();
|
|
1089
1101
|
} else {
|
|
1090
1102
|
break;
|
|
1091
1103
|
}
|
|
@@ -1096,9 +1108,9 @@ var LoaderState = class {
|
|
|
1096
1108
|
return lineBreaks;
|
|
1097
1109
|
}
|
|
1098
1110
|
testDocumentSeparator() {
|
|
1099
|
-
let ch = this.peek();
|
|
1100
|
-
if ((ch === MINUS || ch === DOT) && ch === this.peek(1) && ch === this.peek(2)) {
|
|
1101
|
-
ch = this.peek(3);
|
|
1111
|
+
let ch = this.#scanner.peek();
|
|
1112
|
+
if ((ch === MINUS || ch === DOT) && ch === this.#scanner.peek(1) && ch === this.#scanner.peek(2)) {
|
|
1113
|
+
ch = this.#scanner.peek(3);
|
|
1102
1114
|
if (ch === 0 || isWhiteSpaceOrEOL(ch)) {
|
|
1103
1115
|
return true;
|
|
1104
1116
|
}
|
|
@@ -1106,34 +1118,34 @@ var LoaderState = class {
|
|
|
1106
1118
|
return false;
|
|
1107
1119
|
}
|
|
1108
1120
|
readPlainScalar(tag, anchor, nodeIndent, withinFlowCollection) {
|
|
1109
|
-
let ch = this.peek();
|
|
1121
|
+
let ch = this.#scanner.peek();
|
|
1110
1122
|
if (isWhiteSpaceOrEOL(ch) || isFlowIndicator(ch) || ch === SHARP || ch === AMPERSAND || ch === ASTERISK || ch === EXCLAMATION || ch === VERTICAL_LINE || ch === GREATER_THAN || ch === SINGLE_QUOTE || ch === DOUBLE_QUOTE || ch === PERCENT || ch === COMMERCIAL_AT || ch === GRAVE_ACCENT) {
|
|
1111
1123
|
return;
|
|
1112
1124
|
}
|
|
1113
1125
|
let following;
|
|
1114
1126
|
if (ch === QUESTION || ch === MINUS) {
|
|
1115
|
-
following = this.peek(1);
|
|
1127
|
+
following = this.#scanner.peek(1);
|
|
1116
1128
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
1117
1129
|
return;
|
|
1118
1130
|
}
|
|
1119
1131
|
}
|
|
1120
1132
|
let result = "";
|
|
1121
|
-
let captureEnd = this.position;
|
|
1122
|
-
let captureStart = this.position;
|
|
1133
|
+
let captureEnd = this.#scanner.position;
|
|
1134
|
+
let captureStart = this.#scanner.position;
|
|
1123
1135
|
let hasPendingContent = false;
|
|
1124
1136
|
let line = 0;
|
|
1125
1137
|
while (ch !== 0) {
|
|
1126
1138
|
if (ch === COLON) {
|
|
1127
|
-
following = this.peek(1);
|
|
1139
|
+
following = this.#scanner.peek(1);
|
|
1128
1140
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
1129
1141
|
break;
|
|
1130
1142
|
}
|
|
1131
1143
|
} else if (ch === SHARP) {
|
|
1132
|
-
const preceding = this.peek(-1);
|
|
1144
|
+
const preceding = this.#scanner.peek(-1);
|
|
1133
1145
|
if (isWhiteSpaceOrEOL(preceding)) {
|
|
1134
1146
|
break;
|
|
1135
1147
|
}
|
|
1136
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
1148
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
1137
1149
|
break;
|
|
1138
1150
|
} else if (isEOL(ch)) {
|
|
1139
1151
|
line = this.line;
|
|
@@ -1142,10 +1154,10 @@ var LoaderState = class {
|
|
|
1142
1154
|
this.skipSeparationSpace(false, -1);
|
|
1143
1155
|
if (this.lineIndent >= nodeIndent) {
|
|
1144
1156
|
hasPendingContent = true;
|
|
1145
|
-
ch = this.peek();
|
|
1157
|
+
ch = this.#scanner.peek();
|
|
1146
1158
|
continue;
|
|
1147
1159
|
} else {
|
|
1148
|
-
this.position = captureEnd;
|
|
1160
|
+
this.#scanner.position = captureEnd;
|
|
1149
1161
|
this.line = line;
|
|
1150
1162
|
this.lineStart = lineStart;
|
|
1151
1163
|
this.lineIndent = lineIndent;
|
|
@@ -1156,13 +1168,14 @@ var LoaderState = class {
|
|
|
1156
1168
|
const segment2 = this.captureSegment(captureStart, captureEnd, false);
|
|
1157
1169
|
if (segment2) result += segment2;
|
|
1158
1170
|
result += writeFoldedLines(this.line - line);
|
|
1159
|
-
captureStart = captureEnd = this.position;
|
|
1171
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
1160
1172
|
hasPendingContent = false;
|
|
1161
1173
|
}
|
|
1162
1174
|
if (!isWhiteSpace(ch)) {
|
|
1163
|
-
captureEnd = this.position + 1;
|
|
1175
|
+
captureEnd = this.#scanner.position + 1;
|
|
1164
1176
|
}
|
|
1165
|
-
|
|
1177
|
+
this.#scanner.next();
|
|
1178
|
+
ch = this.#scanner.peek();
|
|
1166
1179
|
}
|
|
1167
1180
|
const segment = this.captureSegment(captureStart, captureEnd, false);
|
|
1168
1181
|
if (segment) result += segment;
|
|
@@ -1175,22 +1188,23 @@ var LoaderState = class {
|
|
|
1175
1188
|
};
|
|
1176
1189
|
}
|
|
1177
1190
|
readSingleQuotedScalar(tag, anchor, nodeIndent) {
|
|
1178
|
-
let ch = this.peek();
|
|
1191
|
+
let ch = this.#scanner.peek();
|
|
1179
1192
|
if (ch !== SINGLE_QUOTE) return;
|
|
1180
1193
|
let result = "";
|
|
1181
|
-
this.
|
|
1182
|
-
let captureStart = this.position;
|
|
1183
|
-
let captureEnd = this.position;
|
|
1184
|
-
ch = this.peek();
|
|
1194
|
+
this.#scanner.next();
|
|
1195
|
+
let captureStart = this.#scanner.position;
|
|
1196
|
+
let captureEnd = this.#scanner.position;
|
|
1197
|
+
ch = this.#scanner.peek();
|
|
1185
1198
|
while (ch !== 0) {
|
|
1186
1199
|
if (ch === SINGLE_QUOTE) {
|
|
1187
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
1200
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
1188
1201
|
if (segment) result += segment;
|
|
1189
|
-
|
|
1202
|
+
this.#scanner.next();
|
|
1203
|
+
ch = this.#scanner.peek();
|
|
1190
1204
|
if (ch === SINGLE_QUOTE) {
|
|
1191
|
-
captureStart = this.position;
|
|
1192
|
-
this.
|
|
1193
|
-
captureEnd = this.position;
|
|
1205
|
+
captureStart = this.#scanner.position;
|
|
1206
|
+
this.#scanner.next();
|
|
1207
|
+
captureEnd = this.#scanner.position;
|
|
1194
1208
|
} else {
|
|
1195
1209
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1196
1210
|
return {
|
|
@@ -1204,31 +1218,31 @@ var LoaderState = class {
|
|
|
1204
1218
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
1205
1219
|
if (segment) result += segment;
|
|
1206
1220
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
1207
|
-
captureStart = captureEnd = this.position;
|
|
1208
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
1221
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
1222
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
1209
1223
|
throw this.#createError("Unexpected end of the document within a single quoted scalar");
|
|
1210
1224
|
} else {
|
|
1211
|
-
this.
|
|
1212
|
-
captureEnd = this.position;
|
|
1225
|
+
this.#scanner.next();
|
|
1226
|
+
captureEnd = this.#scanner.position;
|
|
1213
1227
|
}
|
|
1214
|
-
ch = this.peek();
|
|
1228
|
+
ch = this.#scanner.peek();
|
|
1215
1229
|
}
|
|
1216
1230
|
throw this.#createError("Unexpected end of the stream within a single quoted scalar");
|
|
1217
1231
|
}
|
|
1218
1232
|
readDoubleQuotedScalar(tag, anchor, nodeIndent) {
|
|
1219
|
-
let ch = this.peek();
|
|
1233
|
+
let ch = this.#scanner.peek();
|
|
1220
1234
|
if (ch !== DOUBLE_QUOTE) return;
|
|
1221
1235
|
let result = "";
|
|
1222
|
-
this.
|
|
1223
|
-
let captureEnd = this.position;
|
|
1224
|
-
let captureStart = this.position;
|
|
1236
|
+
this.#scanner.next();
|
|
1237
|
+
let captureEnd = this.#scanner.position;
|
|
1238
|
+
let captureStart = this.#scanner.position;
|
|
1225
1239
|
let tmp;
|
|
1226
|
-
ch = this.peek();
|
|
1240
|
+
ch = this.#scanner.peek();
|
|
1227
1241
|
while (ch !== 0) {
|
|
1228
1242
|
if (ch === DOUBLE_QUOTE) {
|
|
1229
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
1243
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
1230
1244
|
if (segment) result += segment;
|
|
1231
|
-
this.
|
|
1245
|
+
this.#scanner.next();
|
|
1232
1246
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1233
1247
|
return {
|
|
1234
1248
|
tag,
|
|
@@ -1238,19 +1252,21 @@ var LoaderState = class {
|
|
|
1238
1252
|
};
|
|
1239
1253
|
}
|
|
1240
1254
|
if (ch === BACKSLASH) {
|
|
1241
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
1255
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
1242
1256
|
if (segment) result += segment;
|
|
1243
|
-
|
|
1257
|
+
this.#scanner.next();
|
|
1258
|
+
ch = this.#scanner.peek();
|
|
1244
1259
|
if (isEOL(ch)) {
|
|
1245
1260
|
this.skipSeparationSpace(false, nodeIndent);
|
|
1246
1261
|
} else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) {
|
|
1247
1262
|
result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
|
|
1248
|
-
this.
|
|
1263
|
+
this.#scanner.next();
|
|
1249
1264
|
} else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) {
|
|
1250
1265
|
let hexLength = tmp;
|
|
1251
1266
|
let hexResult = 0;
|
|
1252
1267
|
for (; hexLength > 0; hexLength--) {
|
|
1253
|
-
|
|
1268
|
+
this.#scanner.next();
|
|
1269
|
+
ch = this.#scanner.peek();
|
|
1254
1270
|
if ((tmp = hexCharCodeToNumber(ch)) >= 0) {
|
|
1255
1271
|
hexResult = (hexResult << 4) + tmp;
|
|
1256
1272
|
} else {
|
|
@@ -1258,28 +1274,28 @@ var LoaderState = class {
|
|
|
1258
1274
|
}
|
|
1259
1275
|
}
|
|
1260
1276
|
result += codepointToChar(hexResult);
|
|
1261
|
-
this.
|
|
1277
|
+
this.#scanner.next();
|
|
1262
1278
|
} else {
|
|
1263
1279
|
throw this.#createError("Cannot read double quoted scalar: unknown escape sequence");
|
|
1264
1280
|
}
|
|
1265
|
-
captureStart = captureEnd = this.position;
|
|
1281
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
1266
1282
|
} else if (isEOL(ch)) {
|
|
1267
1283
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
1268
1284
|
if (segment) result += segment;
|
|
1269
1285
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
1270
|
-
captureStart = captureEnd = this.position;
|
|
1271
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
1286
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
1287
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
1272
1288
|
throw this.#createError("Unexpected end of the document within a double quoted scalar");
|
|
1273
1289
|
} else {
|
|
1274
|
-
this.
|
|
1275
|
-
captureEnd = this.position;
|
|
1290
|
+
this.#scanner.next();
|
|
1291
|
+
captureEnd = this.#scanner.position;
|
|
1276
1292
|
}
|
|
1277
|
-
ch = this.peek();
|
|
1293
|
+
ch = this.#scanner.peek();
|
|
1278
1294
|
}
|
|
1279
1295
|
throw this.#createError("Unexpected end of the stream within a double quoted scalar");
|
|
1280
1296
|
}
|
|
1281
1297
|
readFlowCollection(tag, anchor, nodeIndent) {
|
|
1282
|
-
let ch = this.peek();
|
|
1298
|
+
let ch = this.#scanner.peek();
|
|
1283
1299
|
let terminator;
|
|
1284
1300
|
let isMapping = true;
|
|
1285
1301
|
let result = {};
|
|
@@ -1293,7 +1309,8 @@ var LoaderState = class {
|
|
|
1293
1309
|
return;
|
|
1294
1310
|
}
|
|
1295
1311
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1296
|
-
|
|
1312
|
+
this.#scanner.next();
|
|
1313
|
+
ch = this.#scanner.peek();
|
|
1297
1314
|
let readNext = true;
|
|
1298
1315
|
let valueNode = null;
|
|
1299
1316
|
let keyNode = null;
|
|
@@ -1305,9 +1322,9 @@ var LoaderState = class {
|
|
|
1305
1322
|
const overridableKeys = /* @__PURE__ */ new Set();
|
|
1306
1323
|
while (ch !== 0) {
|
|
1307
1324
|
this.skipSeparationSpace(true, nodeIndent);
|
|
1308
|
-
ch = this.peek();
|
|
1325
|
+
ch = this.#scanner.peek();
|
|
1309
1326
|
if (ch === terminator) {
|
|
1310
|
-
this.
|
|
1327
|
+
this.#scanner.next();
|
|
1311
1328
|
const kind = isMapping ? "mapping" : "sequence";
|
|
1312
1329
|
return {
|
|
1313
1330
|
tag,
|
|
@@ -1322,10 +1339,10 @@ var LoaderState = class {
|
|
|
1322
1339
|
keyTag = keyNode = valueNode = null;
|
|
1323
1340
|
isPair = isExplicitPair = false;
|
|
1324
1341
|
if (ch === QUESTION) {
|
|
1325
|
-
following = this.peek(1);
|
|
1342
|
+
following = this.#scanner.peek(1);
|
|
1326
1343
|
if (isWhiteSpaceOrEOL(following)) {
|
|
1327
1344
|
isPair = isExplicitPair = true;
|
|
1328
|
-
this.
|
|
1345
|
+
this.#scanner.next();
|
|
1329
1346
|
this.skipSeparationSpace(true, nodeIndent);
|
|
1330
1347
|
}
|
|
1331
1348
|
}
|
|
@@ -1341,10 +1358,11 @@ var LoaderState = class {
|
|
|
1341
1358
|
keyNode = newState.result;
|
|
1342
1359
|
}
|
|
1343
1360
|
this.skipSeparationSpace(true, nodeIndent);
|
|
1344
|
-
ch = this.peek();
|
|
1361
|
+
ch = this.#scanner.peek();
|
|
1345
1362
|
if ((isExplicitPair || this.line === line) && ch === COLON) {
|
|
1346
1363
|
isPair = true;
|
|
1347
|
-
|
|
1364
|
+
this.#scanner.next();
|
|
1365
|
+
ch = this.#scanner.peek();
|
|
1348
1366
|
this.skipSeparationSpace(true, nodeIndent);
|
|
1349
1367
|
const newState2 = this.composeNode({
|
|
1350
1368
|
parentIndent: nodeIndent,
|
|
@@ -1362,10 +1380,11 @@ var LoaderState = class {
|
|
|
1362
1380
|
result.push(keyNode);
|
|
1363
1381
|
}
|
|
1364
1382
|
this.skipSeparationSpace(true, nodeIndent);
|
|
1365
|
-
ch = this.peek();
|
|
1383
|
+
ch = this.#scanner.peek();
|
|
1366
1384
|
if (ch === COMMA) {
|
|
1367
1385
|
readNext = true;
|
|
1368
|
-
|
|
1386
|
+
this.#scanner.next();
|
|
1387
|
+
ch = this.#scanner.peek();
|
|
1369
1388
|
} else {
|
|
1370
1389
|
readNext = false;
|
|
1371
1390
|
}
|
|
@@ -1381,7 +1400,7 @@ var LoaderState = class {
|
|
|
1381
1400
|
let textIndent = nodeIndent;
|
|
1382
1401
|
let emptyLines = 0;
|
|
1383
1402
|
let atMoreIndented = false;
|
|
1384
|
-
let ch = this.peek();
|
|
1403
|
+
let ch = this.#scanner.peek();
|
|
1385
1404
|
let folding = false;
|
|
1386
1405
|
if (ch === VERTICAL_LINE) {
|
|
1387
1406
|
folding = false;
|
|
@@ -1393,7 +1412,8 @@ var LoaderState = class {
|
|
|
1393
1412
|
let result = "";
|
|
1394
1413
|
let tmp = 0;
|
|
1395
1414
|
while (ch !== 0) {
|
|
1396
|
-
|
|
1415
|
+
this.#scanner.next();
|
|
1416
|
+
ch = this.#scanner.peek();
|
|
1397
1417
|
if (ch === PLUS || ch === MINUS) {
|
|
1398
1418
|
if (CHOMPING_CLIP === chomping) {
|
|
1399
1419
|
chomping = ch === PLUS ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
@@ -1416,15 +1436,16 @@ var LoaderState = class {
|
|
|
1416
1436
|
if (isWhiteSpace(ch)) {
|
|
1417
1437
|
this.skipWhitespaces();
|
|
1418
1438
|
this.skipComment();
|
|
1419
|
-
ch = this.peek();
|
|
1439
|
+
ch = this.#scanner.peek();
|
|
1420
1440
|
}
|
|
1421
1441
|
while (ch !== 0) {
|
|
1422
1442
|
this.readLineBreak();
|
|
1423
1443
|
this.lineIndent = 0;
|
|
1424
|
-
ch = this.peek();
|
|
1444
|
+
ch = this.#scanner.peek();
|
|
1425
1445
|
while ((!detectedIndent || this.lineIndent < textIndent) && ch === SPACE) {
|
|
1426
1446
|
this.lineIndent++;
|
|
1427
|
-
|
|
1447
|
+
this.#scanner.next();
|
|
1448
|
+
ch = this.#scanner.peek();
|
|
1428
1449
|
}
|
|
1429
1450
|
if (!detectedIndent && this.lineIndent > textIndent) {
|
|
1430
1451
|
textIndent = this.lineIndent;
|
|
@@ -1463,11 +1484,12 @@ var LoaderState = class {
|
|
|
1463
1484
|
didReadContent = true;
|
|
1464
1485
|
detectedIndent = true;
|
|
1465
1486
|
emptyLines = 0;
|
|
1466
|
-
const captureStart = this.position;
|
|
1487
|
+
const captureStart = this.#scanner.position;
|
|
1467
1488
|
while (!isEOL(ch) && ch !== 0) {
|
|
1468
|
-
|
|
1489
|
+
this.#scanner.next();
|
|
1490
|
+
ch = this.#scanner.peek();
|
|
1469
1491
|
}
|
|
1470
|
-
const segment = this.captureSegment(captureStart, this.position, false);
|
|
1492
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, false);
|
|
1471
1493
|
if (segment) result += segment;
|
|
1472
1494
|
}
|
|
1473
1495
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
@@ -1490,11 +1512,11 @@ var LoaderState = class {
|
|
|
1490
1512
|
let atExplicitKey = false;
|
|
1491
1513
|
let detected = false;
|
|
1492
1514
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
1493
|
-
let ch = this.peek();
|
|
1515
|
+
let ch = this.#scanner.peek();
|
|
1494
1516
|
while (ch !== 0) {
|
|
1495
|
-
const following = this.peek(1);
|
|
1517
|
+
const following = this.#scanner.peek(1);
|
|
1496
1518
|
line = this.line;
|
|
1497
|
-
pos = this.position;
|
|
1519
|
+
pos = this.#scanner.position;
|
|
1498
1520
|
if ((ch === QUESTION || ch === COLON) && isWhiteSpaceOrEOL(following)) {
|
|
1499
1521
|
if (ch === QUESTION) {
|
|
1500
1522
|
if (atExplicitKey) {
|
|
@@ -1512,7 +1534,7 @@ var LoaderState = class {
|
|
|
1512
1534
|
} else {
|
|
1513
1535
|
throw this.#createError("Cannot read block as explicit mapping pair is incomplete: a key node is missed or followed by a non-tabulated empty line");
|
|
1514
1536
|
}
|
|
1515
|
-
this.
|
|
1537
|
+
this.#scanner.next();
|
|
1516
1538
|
ch = following;
|
|
1517
1539
|
} else {
|
|
1518
1540
|
const newState = this.composeNode({
|
|
@@ -1523,11 +1545,12 @@ var LoaderState = class {
|
|
|
1523
1545
|
});
|
|
1524
1546
|
if (!newState) break;
|
|
1525
1547
|
if (this.line === line) {
|
|
1526
|
-
ch = this.peek();
|
|
1548
|
+
ch = this.#scanner.peek();
|
|
1527
1549
|
this.skipWhitespaces();
|
|
1528
|
-
ch = this.peek();
|
|
1550
|
+
ch = this.#scanner.peek();
|
|
1529
1551
|
if (ch === COLON) {
|
|
1530
|
-
|
|
1552
|
+
this.#scanner.next();
|
|
1553
|
+
ch = this.#scanner.peek();
|
|
1531
1554
|
if (!isWhiteSpaceOrEOL(ch)) {
|
|
1532
1555
|
throw this.#createError("Cannot read block: a whitespace character is expected after the key-value separator within a block mapping");
|
|
1533
1556
|
}
|
|
@@ -1584,7 +1607,7 @@ var LoaderState = class {
|
|
|
1584
1607
|
keyTag = keyNode = valueNode = null;
|
|
1585
1608
|
}
|
|
1586
1609
|
this.skipSeparationSpace(true, -1);
|
|
1587
|
-
ch = this.peek();
|
|
1610
|
+
ch = this.#scanner.peek();
|
|
1588
1611
|
}
|
|
1589
1612
|
if (this.lineIndent > nodeIndent && ch !== 0) {
|
|
1590
1613
|
throw this.#createError("Cannot read block: bad indentation of a mapping entry");
|
|
@@ -1607,30 +1630,35 @@ var LoaderState = class {
|
|
|
1607
1630
|
let isNamed = false;
|
|
1608
1631
|
let tagHandle = "";
|
|
1609
1632
|
let tagName;
|
|
1610
|
-
let ch = this.peek();
|
|
1633
|
+
let ch = this.#scanner.peek();
|
|
1611
1634
|
if (ch !== EXCLAMATION) return;
|
|
1612
1635
|
if (tag !== null) {
|
|
1613
1636
|
throw this.#createError("Cannot read tag property: duplication of a tag property");
|
|
1614
1637
|
}
|
|
1615
|
-
|
|
1638
|
+
this.#scanner.next();
|
|
1639
|
+
ch = this.#scanner.peek();
|
|
1616
1640
|
if (ch === SMALLER_THAN) {
|
|
1617
1641
|
isVerbatim = true;
|
|
1618
|
-
|
|
1642
|
+
this.#scanner.next();
|
|
1643
|
+
ch = this.#scanner.peek();
|
|
1619
1644
|
} else if (ch === EXCLAMATION) {
|
|
1620
1645
|
isNamed = true;
|
|
1621
1646
|
tagHandle = "!!";
|
|
1622
|
-
|
|
1647
|
+
this.#scanner.next();
|
|
1648
|
+
ch = this.#scanner.peek();
|
|
1623
1649
|
} else {
|
|
1624
1650
|
tagHandle = "!";
|
|
1625
1651
|
}
|
|
1626
|
-
let position = this.position;
|
|
1652
|
+
let position = this.#scanner.position;
|
|
1627
1653
|
if (isVerbatim) {
|
|
1628
1654
|
do {
|
|
1629
|
-
|
|
1655
|
+
this.#scanner.next();
|
|
1656
|
+
ch = this.#scanner.peek();
|
|
1630
1657
|
} while (ch !== 0 && ch !== GREATER_THAN);
|
|
1631
|
-
if (this.
|
|
1632
|
-
tagName = this.
|
|
1633
|
-
|
|
1658
|
+
if (!this.#scanner.eof()) {
|
|
1659
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
1660
|
+
this.#scanner.next();
|
|
1661
|
+
ch = this.#scanner.peek();
|
|
1634
1662
|
} else {
|
|
1635
1663
|
throw this.#createError("Cannot read tag property: unexpected end of stream");
|
|
1636
1664
|
}
|
|
@@ -1638,19 +1666,20 @@ var LoaderState = class {
|
|
|
1638
1666
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
1639
1667
|
if (ch === EXCLAMATION) {
|
|
1640
1668
|
if (!isNamed) {
|
|
1641
|
-
tagHandle = this.
|
|
1669
|
+
tagHandle = this.#scanner.source.slice(position - 1, this.#scanner.position + 1);
|
|
1642
1670
|
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1643
1671
|
throw this.#createError("Cannot read tag property: named tag handle contains invalid characters");
|
|
1644
1672
|
}
|
|
1645
1673
|
isNamed = true;
|
|
1646
|
-
position = this.position + 1;
|
|
1674
|
+
position = this.#scanner.position + 1;
|
|
1647
1675
|
} else {
|
|
1648
1676
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain an exclamation mark");
|
|
1649
1677
|
}
|
|
1650
1678
|
}
|
|
1651
|
-
|
|
1679
|
+
this.#scanner.next();
|
|
1680
|
+
ch = this.#scanner.peek();
|
|
1652
1681
|
}
|
|
1653
|
-
tagName = this.
|
|
1682
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
1654
1683
|
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1655
1684
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain flow indicator characters");
|
|
1656
1685
|
}
|
|
@@ -1670,32 +1699,36 @@ var LoaderState = class {
|
|
|
1670
1699
|
throw this.#createError(`Cannot read tag property: undeclared tag handle "${tagHandle}"`);
|
|
1671
1700
|
}
|
|
1672
1701
|
readAnchorProperty(anchor) {
|
|
1673
|
-
let ch = this.peek();
|
|
1702
|
+
let ch = this.#scanner.peek();
|
|
1674
1703
|
if (ch !== AMPERSAND) return;
|
|
1675
1704
|
if (anchor !== null) {
|
|
1676
1705
|
throw this.#createError("Cannot read anchor property: duplicate anchor property");
|
|
1677
1706
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1707
|
+
this.#scanner.next();
|
|
1708
|
+
ch = this.#scanner.peek();
|
|
1709
|
+
const position = this.#scanner.position;
|
|
1680
1710
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
1681
|
-
|
|
1711
|
+
this.#scanner.next();
|
|
1712
|
+
ch = this.#scanner.peek();
|
|
1682
1713
|
}
|
|
1683
|
-
if (this.position === position) {
|
|
1714
|
+
if (this.#scanner.position === position) {
|
|
1684
1715
|
throw this.#createError("Cannot read anchor property: name of an anchor node must contain at least one character");
|
|
1685
1716
|
}
|
|
1686
|
-
return this.
|
|
1717
|
+
return this.#scanner.source.slice(position, this.#scanner.position);
|
|
1687
1718
|
}
|
|
1688
1719
|
readAlias() {
|
|
1689
|
-
if (this.peek() !== ASTERISK) return;
|
|
1690
|
-
|
|
1691
|
-
|
|
1720
|
+
if (this.#scanner.peek() !== ASTERISK) return;
|
|
1721
|
+
this.#scanner.next();
|
|
1722
|
+
let ch = this.#scanner.peek();
|
|
1723
|
+
const position = this.#scanner.position;
|
|
1692
1724
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
1693
|
-
|
|
1725
|
+
this.#scanner.next();
|
|
1726
|
+
ch = this.#scanner.peek();
|
|
1694
1727
|
}
|
|
1695
|
-
if (this.position === position) {
|
|
1728
|
+
if (this.#scanner.position === position) {
|
|
1696
1729
|
throw this.#createError("Cannot read alias: alias name must contain at least one character");
|
|
1697
1730
|
}
|
|
1698
|
-
const alias = this.
|
|
1731
|
+
const alias = this.#scanner.source.slice(position, this.#scanner.position);
|
|
1699
1732
|
if (!this.anchorMap.has(alias)) {
|
|
1700
1733
|
throw this.#createError(`Cannot read alias: unidentified alias "${alias}"`);
|
|
1701
1734
|
}
|
|
@@ -1778,7 +1811,7 @@ var LoaderState = class {
|
|
|
1778
1811
|
const cond = CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext;
|
|
1779
1812
|
const flowIndent = cond ? parentIndent : parentIndent + 1;
|
|
1780
1813
|
if (allowBlockCollections) {
|
|
1781
|
-
const blockIndent = this.position - this.lineStart;
|
|
1814
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
1782
1815
|
const blockSequenceState = this.readBlockSequence(tag, anchor, blockIndent);
|
|
1783
1816
|
if (blockSequenceState) return this.resolveTag(blockSequenceState);
|
|
1784
1817
|
const blockMappingState = this.readBlockMapping(tag, anchor, blockIndent, flowIndent);
|
|
@@ -1812,7 +1845,7 @@ var LoaderState = class {
|
|
|
1812
1845
|
return this.resolveTag(plainScalarState);
|
|
1813
1846
|
}
|
|
1814
1847
|
} else if (indentStatus === 0 && CONTEXT_BLOCK_OUT === nodeContext && allowBlockCollections) {
|
|
1815
|
-
const blockIndent = this.position - this.lineStart;
|
|
1848
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
1816
1849
|
const newState2 = this.readBlockSequence(tag, anchor, blockIndent);
|
|
1817
1850
|
if (newState2) return this.resolveTag(newState2);
|
|
1818
1851
|
}
|
|
@@ -1827,20 +1860,22 @@ var LoaderState = class {
|
|
|
1827
1860
|
readDirectives() {
|
|
1828
1861
|
let hasDirectives = false;
|
|
1829
1862
|
let version = null;
|
|
1830
|
-
let ch = this.peek();
|
|
1863
|
+
let ch = this.#scanner.peek();
|
|
1831
1864
|
while (ch !== 0) {
|
|
1832
1865
|
this.skipSeparationSpace(true, -1);
|
|
1833
|
-
ch = this.peek();
|
|
1866
|
+
ch = this.#scanner.peek();
|
|
1834
1867
|
if (this.lineIndent > 0 || ch !== PERCENT) {
|
|
1835
1868
|
break;
|
|
1836
1869
|
}
|
|
1837
1870
|
hasDirectives = true;
|
|
1838
|
-
|
|
1839
|
-
|
|
1871
|
+
this.#scanner.next();
|
|
1872
|
+
ch = this.#scanner.peek();
|
|
1873
|
+
let position = this.#scanner.position;
|
|
1840
1874
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
1841
|
-
|
|
1875
|
+
this.#scanner.next();
|
|
1876
|
+
ch = this.#scanner.peek();
|
|
1842
1877
|
}
|
|
1843
|
-
const directiveName = this.
|
|
1878
|
+
const directiveName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
1844
1879
|
const directiveArgs = [];
|
|
1845
1880
|
if (directiveName.length < 1) {
|
|
1846
1881
|
throw this.#createError("Cannot read document: directive name length must be greater than zero");
|
|
@@ -1848,13 +1883,14 @@ var LoaderState = class {
|
|
|
1848
1883
|
while (ch !== 0) {
|
|
1849
1884
|
this.skipWhitespaces();
|
|
1850
1885
|
this.skipComment();
|
|
1851
|
-
ch = this.peek();
|
|
1886
|
+
ch = this.#scanner.peek();
|
|
1852
1887
|
if (isEOL(ch)) break;
|
|
1853
|
-
position = this.position;
|
|
1888
|
+
position = this.#scanner.position;
|
|
1854
1889
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
1855
|
-
|
|
1890
|
+
this.#scanner.next();
|
|
1891
|
+
ch = this.#scanner.peek();
|
|
1856
1892
|
}
|
|
1857
|
-
directiveArgs.push(this.
|
|
1893
|
+
directiveArgs.push(this.#scanner.source.slice(position, this.#scanner.position));
|
|
1858
1894
|
}
|
|
1859
1895
|
if (ch !== 0) this.readLineBreak();
|
|
1860
1896
|
switch (directiveName) {
|
|
@@ -1871,20 +1907,20 @@ var LoaderState = class {
|
|
|
1871
1907
|
this.dispatchWarning(`unknown document directive "${directiveName}"`);
|
|
1872
1908
|
break;
|
|
1873
1909
|
}
|
|
1874
|
-
ch = this.peek();
|
|
1910
|
+
ch = this.#scanner.peek();
|
|
1875
1911
|
}
|
|
1876
1912
|
return hasDirectives;
|
|
1877
1913
|
}
|
|
1878
1914
|
readDocument() {
|
|
1879
|
-
const documentStart = this.position;
|
|
1915
|
+
const documentStart = this.#scanner.position;
|
|
1880
1916
|
this.checkLineBreaks = false;
|
|
1881
1917
|
this.tagMap = /* @__PURE__ */ new Map();
|
|
1882
1918
|
this.anchorMap = /* @__PURE__ */ new Map();
|
|
1883
1919
|
const hasDirectives = this.readDirectives();
|
|
1884
1920
|
this.skipSeparationSpace(true, -1);
|
|
1885
1921
|
let result = null;
|
|
1886
|
-
if (this.lineIndent === 0 && this.peek() === MINUS && this.peek(1) === MINUS && this.peek(2) === MINUS) {
|
|
1887
|
-
this.position += 3;
|
|
1922
|
+
if (this.lineIndent === 0 && this.#scanner.peek() === MINUS && this.#scanner.peek(1) === MINUS && this.#scanner.peek(2) === MINUS) {
|
|
1923
|
+
this.#scanner.position += 3;
|
|
1888
1924
|
this.skipSeparationSpace(true, -1);
|
|
1889
1925
|
} else if (hasDirectives) {
|
|
1890
1926
|
throw this.#createError("Cannot read document: directives end mark is expected");
|
|
@@ -1897,21 +1933,21 @@ var LoaderState = class {
|
|
|
1897
1933
|
});
|
|
1898
1934
|
if (newState) result = newState.result;
|
|
1899
1935
|
this.skipSeparationSpace(true, -1);
|
|
1900
|
-
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.
|
|
1936
|
+
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.#scanner.source.slice(documentStart, this.#scanner.position))) {
|
|
1901
1937
|
this.dispatchWarning("non-ASCII line breaks are interpreted as content");
|
|
1902
1938
|
}
|
|
1903
|
-
if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
1904
|
-
if (this.peek() === DOT) {
|
|
1905
|
-
this.position += 3;
|
|
1939
|
+
if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
1940
|
+
if (this.#scanner.peek() === DOT) {
|
|
1941
|
+
this.#scanner.position += 3;
|
|
1906
1942
|
this.skipSeparationSpace(true, -1);
|
|
1907
1943
|
}
|
|
1908
|
-
} else if (this.
|
|
1944
|
+
} else if (!this.#scanner.eof()) {
|
|
1909
1945
|
throw this.#createError("Cannot read document: end of the stream or a document separator is expected");
|
|
1910
1946
|
}
|
|
1911
1947
|
return result;
|
|
1912
1948
|
}
|
|
1913
1949
|
*readDocuments() {
|
|
1914
|
-
while (this.
|
|
1950
|
+
while (!this.#scanner.eof()) {
|
|
1915
1951
|
yield this.readDocument();
|
|
1916
1952
|
}
|
|
1917
1953
|
}
|
|
@@ -1924,7 +1960,6 @@ function sanitizeInput(input) {
|
|
|
1924
1960
|
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
1925
1961
|
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
1926
1962
|
}
|
|
1927
|
-
input += "\0";
|
|
1928
1963
|
return input;
|
|
1929
1964
|
}
|
|
1930
1965
|
function parse(content, options = {}) {
|