yaml 1.10.0 → 2.0.0-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 (55) hide show
  1. package/README.md +10 -11
  2. package/browser/dist/Schema-ea978338.js +1211 -0
  3. package/browser/dist/{PlainValue-ff5147c6.js → errors-2634d01a.js} +8 -186
  4. package/browser/dist/index.js +1174 -121
  5. package/browser/dist/parse-cst.js +2 -1904
  6. package/browser/dist/parse-d1ba890f.js +2084 -0
  7. package/browser/dist/{resolveSeq-04825f30.js → stringifyNumber-d8af95b1.js} +197 -1072
  8. package/browser/dist/types.js +3 -4
  9. package/browser/dist/util.js +2 -2
  10. package/browser/index.js +1 -1
  11. package/dist/Document-f89a2614.js +1783 -0
  12. package/dist/Schema-807430ba.js +934 -0
  13. package/dist/{PlainValue-ec8e588e.js → _rollupPluginBabelHelpers-eed30217.js} +0 -167
  14. package/dist/index.js +58 -44
  15. package/dist/parse-3997f544.js +1915 -0
  16. package/dist/parse-cst.js +3 -1742
  17. package/dist/stringifyNumber-dea1120c.js +1286 -0
  18. package/dist/test-events.js +6 -7
  19. package/dist/types.js +16 -17
  20. package/dist/util.js +12 -14
  21. package/index.d.ts +103 -20
  22. package/index.js +1 -1
  23. package/package.json +16 -26
  24. package/types.d.ts +19 -47
  25. package/util.d.ts +2 -12
  26. package/util.js +0 -2
  27. package/util.mjs +0 -3
  28. package/browser/dist/Schema-2bf2c74e.js +0 -679
  29. package/browser/dist/legacy-exports.js +0 -3
  30. package/browser/dist/warnings-0e4b70d3.js +0 -499
  31. package/browser/map.js +0 -2
  32. package/browser/pair.js +0 -2
  33. package/browser/scalar.js +0 -2
  34. package/browser/schema.js +0 -9
  35. package/browser/seq.js +0 -2
  36. package/browser/types/binary.js +0 -8
  37. package/browser/types/omap.js +0 -3
  38. package/browser/types/pairs.js +0 -3
  39. package/browser/types/set.js +0 -3
  40. package/browser/types/timestamp.js +0 -10
  41. package/dist/Document-2cf6b08c.js +0 -757
  42. package/dist/Schema-42e9705c.js +0 -522
  43. package/dist/legacy-exports.js +0 -16
  44. package/dist/resolveSeq-4a68b39b.js +0 -2115
  45. package/dist/warnings-39684f17.js +0 -416
  46. package/map.js +0 -2
  47. package/pair.js +0 -2
  48. package/scalar.js +0 -2
  49. package/schema.js +0 -9
  50. package/seq.js +0 -2
  51. package/types/binary.js +0 -8
  52. package/types/omap.js +0 -3
  53. package/types/pairs.js +0 -3
  54. package/types/set.js +0 -3
  55. package/types/timestamp.js +0 -10
@@ -0,0 +1,2084 @@
1
+ import { l as _inherits, m as _createSuper, b as _classCallCheck, T as Type, a as _createClass, R as Range, N as Node, Y as YAMLSemanticError, n as _get, o as _getPrototypeOf, i as YAMLSyntaxError, C as Char, c as _defineProperty } from './errors-2634d01a.js';
2
+
3
+ var BlankLine = /*#__PURE__*/function (_Node) {
4
+ _inherits(BlankLine, _Node);
5
+
6
+ var _super = _createSuper(BlankLine);
7
+
8
+ function BlankLine() {
9
+ _classCallCheck(this, BlankLine);
10
+
11
+ return _super.call(this, Type.BLANK_LINE);
12
+ }
13
+ /* istanbul ignore next */
14
+
15
+
16
+ _createClass(BlankLine, [{
17
+ key: "parse",
18
+
19
+ /**
20
+ * Parses a blank line from the source
21
+ *
22
+ * @param {ParseContext} context
23
+ * @param {number} start - Index of first \n character
24
+ * @returns {number} - Index of the character after this
25
+ */
26
+ value: function parse(context, start) {
27
+ this.context = context;
28
+ this.range = new Range(start, start + 1);
29
+ return start + 1;
30
+ }
31
+ }, {
32
+ key: "includesTrailingLines",
33
+ get: function get() {
34
+ // This is never called from anywhere, but if it were,
35
+ // this is the value it should return.
36
+ return true;
37
+ }
38
+ }]);
39
+
40
+ return BlankLine;
41
+ }(Node);
42
+
43
+ var CollectionItem = /*#__PURE__*/function (_Node) {
44
+ _inherits(CollectionItem, _Node);
45
+
46
+ var _super = _createSuper(CollectionItem);
47
+
48
+ function CollectionItem(type, props) {
49
+ var _this;
50
+
51
+ _classCallCheck(this, CollectionItem);
52
+
53
+ _this = _super.call(this, type, props);
54
+ _this.node = null;
55
+ return _this;
56
+ }
57
+
58
+ _createClass(CollectionItem, [{
59
+ key: "parse",
60
+
61
+ /**
62
+ * @param {ParseContext} context
63
+ * @param {number} start - Index of first character
64
+ * @returns {number} - Index of the character after this
65
+ */
66
+ value: function parse(context, start) {
67
+ this.context = context;
68
+ var parseNode = context.parseNode,
69
+ src = context.src;
70
+ var atLineStart = context.atLineStart,
71
+ lineStart = context.lineStart;
72
+ if (!atLineStart && this.type === Type.SEQ_ITEM) this.error = new YAMLSemanticError(this, 'Sequence items must not have preceding content on the same line');
73
+ var indent = atLineStart ? start - lineStart : context.indent;
74
+ var offset = Node.endOfWhiteSpace(src, start + 1);
75
+ var ch = src[offset];
76
+ var inlineComment = ch === '#';
77
+ var comments = [];
78
+ var blankLine = null;
79
+
80
+ while (ch === '\n' || ch === '#') {
81
+ if (ch === '#') {
82
+ var _end = Node.endOfLine(src, offset + 1);
83
+
84
+ comments.push(new Range(offset, _end));
85
+ offset = _end;
86
+ } else {
87
+ atLineStart = true;
88
+ lineStart = offset + 1;
89
+ var wsEnd = Node.endOfWhiteSpace(src, lineStart);
90
+
91
+ if (src[wsEnd] === '\n' && comments.length === 0) {
92
+ blankLine = new BlankLine();
93
+ lineStart = blankLine.parse({
94
+ src: src
95
+ }, lineStart);
96
+ }
97
+
98
+ offset = Node.endOfIndent(src, lineStart);
99
+ }
100
+
101
+ ch = src[offset];
102
+ }
103
+
104
+ if (Node.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== Type.SEQ_ITEM)) {
105
+ this.node = parseNode({
106
+ atLineStart: atLineStart,
107
+ inCollection: false,
108
+ indent: indent,
109
+ lineStart: lineStart,
110
+ parent: this
111
+ }, offset);
112
+ } else if (ch && lineStart > start + 1) {
113
+ offset = lineStart - 1;
114
+ }
115
+
116
+ if (this.node) {
117
+ if (blankLine) {
118
+ // Only blank lines preceding non-empty nodes are captured. Note that
119
+ // this means that collection item range start indices do not always
120
+ // increase monotonically. -- eemeli/yaml#126
121
+ var items = context.parent.items || context.parent.contents;
122
+ if (items) items.push(blankLine);
123
+ }
124
+
125
+ if (comments.length) Array.prototype.push.apply(this.props, comments);
126
+ offset = this.node.range.end;
127
+ } else {
128
+ if (inlineComment) {
129
+ var c = comments[0];
130
+ this.props.push(c);
131
+ offset = c.end;
132
+ } else {
133
+ offset = Node.endOfLine(src, start + 1);
134
+ }
135
+ }
136
+
137
+ var end = this.node ? this.node.valueRange.end : offset;
138
+ this.valueRange = new Range(start, end);
139
+ return offset;
140
+ }
141
+ }, {
142
+ key: "setOrigRanges",
143
+ value: function setOrigRanges(cr, offset) {
144
+ offset = _get(_getPrototypeOf(CollectionItem.prototype), "setOrigRanges", this).call(this, cr, offset);
145
+ return this.node ? this.node.setOrigRanges(cr, offset) : offset;
146
+ }
147
+ }, {
148
+ key: "toString",
149
+ value: function toString() {
150
+ var src = this.context.src,
151
+ node = this.node,
152
+ range = this.range,
153
+ value = this.value;
154
+ if (value != null) return value;
155
+ var str = node ? src.slice(range.start, node.range.start) + String(node) : src.slice(range.start, range.end);
156
+ return Node.addStringTerminator(src, range.end, str);
157
+ }
158
+ }, {
159
+ key: "includesTrailingLines",
160
+ get: function get() {
161
+ return !!this.node && this.node.includesTrailingLines;
162
+ }
163
+ }]);
164
+
165
+ return CollectionItem;
166
+ }(Node);
167
+
168
+ var Comment = /*#__PURE__*/function (_Node) {
169
+ _inherits(Comment, _Node);
170
+
171
+ var _super = _createSuper(Comment);
172
+
173
+ function Comment() {
174
+ _classCallCheck(this, Comment);
175
+
176
+ return _super.call(this, Type.COMMENT);
177
+ }
178
+ /**
179
+ * Parses a comment line from the source
180
+ *
181
+ * @param {ParseContext} context
182
+ * @param {number} start - Index of first character
183
+ * @returns {number} - Index of the character after this scalar
184
+ */
185
+
186
+
187
+ _createClass(Comment, [{
188
+ key: "parse",
189
+ value: function parse(context, start) {
190
+ this.context = context;
191
+ var offset = this.parseComment(start);
192
+ this.range = new Range(start, offset);
193
+ return offset;
194
+ }
195
+ }]);
196
+
197
+ return Comment;
198
+ }(Node);
199
+
200
+ function grabCollectionEndComments(node) {
201
+ var cnode = node;
202
+
203
+ while (cnode instanceof CollectionItem) {
204
+ cnode = cnode.node;
205
+ }
206
+
207
+ if (!(cnode instanceof Collection)) return null;
208
+ var len = cnode.items.length;
209
+ var ci = -1;
210
+
211
+ for (var i = len - 1; i >= 0; --i) {
212
+ var n = cnode.items[i];
213
+
214
+ if (n.type === Type.COMMENT) {
215
+ // Keep sufficiently indented comments with preceding node
216
+ var _n$context = n.context,
217
+ indent = _n$context.indent,
218
+ lineStart = _n$context.lineStart;
219
+ if (indent > 0 && n.range.start >= lineStart + indent) break;
220
+ ci = i;
221
+ } else if (n.type === Type.BLANK_LINE) ci = i;else break;
222
+ }
223
+
224
+ if (ci === -1) return null;
225
+ var ca = cnode.items.splice(ci, len - ci);
226
+ var prevEnd = ca[0].range.start;
227
+
228
+ while (true) {
229
+ cnode.range.end = prevEnd;
230
+ if (cnode.valueRange && cnode.valueRange.end > prevEnd) cnode.valueRange.end = prevEnd;
231
+ if (cnode === node) break;
232
+ cnode = cnode.context.parent;
233
+ }
234
+
235
+ return ca;
236
+ }
237
+ var Collection = /*#__PURE__*/function (_Node) {
238
+ _inherits(Collection, _Node);
239
+
240
+ var _super = _createSuper(Collection);
241
+
242
+ _createClass(Collection, null, [{
243
+ key: "nextContentHasIndent",
244
+ value: function nextContentHasIndent(src, offset, indent) {
245
+ var lineStart = Node.endOfLine(src, offset) + 1;
246
+ offset = Node.endOfWhiteSpace(src, lineStart);
247
+ var ch = src[offset];
248
+ if (!ch) return false;
249
+ if (offset >= lineStart + indent) return true;
250
+ if (ch !== '#' && ch !== '\n') return false;
251
+ return Collection.nextContentHasIndent(src, offset, indent);
252
+ }
253
+ }]);
254
+
255
+ function Collection(firstItem) {
256
+ var _this;
257
+
258
+ _classCallCheck(this, Collection);
259
+
260
+ _this = _super.call(this, firstItem.type === Type.SEQ_ITEM ? Type.SEQ : Type.MAP);
261
+
262
+ for (var i = firstItem.props.length - 1; i >= 0; --i) {
263
+ if (firstItem.props[i].start < firstItem.context.lineStart) {
264
+ // props on previous line are assumed by the collection
265
+ _this.props = firstItem.props.slice(0, i + 1);
266
+ firstItem.props = firstItem.props.slice(i + 1);
267
+ var itemRange = firstItem.props[0] || firstItem.valueRange;
268
+ firstItem.range.start = itemRange.start;
269
+ break;
270
+ }
271
+ }
272
+
273
+ _this.items = [firstItem];
274
+ var ec = grabCollectionEndComments(firstItem);
275
+ if (ec) Array.prototype.push.apply(_this.items, ec);
276
+ return _this;
277
+ }
278
+
279
+ _createClass(Collection, [{
280
+ key: "parse",
281
+
282
+ /**
283
+ * @param {ParseContext} context
284
+ * @param {number} start - Index of first character
285
+ * @returns {number} - Index of the character after this
286
+ */
287
+ value: function parse(context, start) {
288
+ this.context = context;
289
+ var parseNode = context.parseNode,
290
+ src = context.src; // It's easier to recalculate lineStart here rather than tracking down the
291
+ // last context from which to read it -- eemeli/yaml#2
292
+
293
+ var lineStart = Node.startOfLine(src, start);
294
+ var firstItem = this.items[0]; // First-item context needs to be correct for later comment handling
295
+ // -- eemeli/yaml#17
296
+
297
+ firstItem.context.parent = this;
298
+ this.valueRange = Range.copy(firstItem.valueRange);
299
+ var indent = firstItem.range.start - firstItem.context.lineStart;
300
+ var offset = start;
301
+ offset = Node.normalizeOffset(src, offset);
302
+ var ch = src[offset];
303
+ var atLineStart = Node.endOfWhiteSpace(src, lineStart) === offset;
304
+ var prevIncludesTrailingLines = false;
305
+
306
+ while (ch) {
307
+ while (ch === '\n' || ch === '#') {
308
+ if (atLineStart && ch === '\n' && !prevIncludesTrailingLines) {
309
+ var blankLine = new BlankLine();
310
+ offset = blankLine.parse({
311
+ src: src
312
+ }, offset);
313
+ this.valueRange.end = offset;
314
+
315
+ if (offset >= src.length) {
316
+ ch = null;
317
+ break;
318
+ }
319
+
320
+ this.items.push(blankLine);
321
+ offset -= 1; // blankLine.parse() consumes terminal newline
322
+ } else if (ch === '#') {
323
+ if (offset < lineStart + indent && !Collection.nextContentHasIndent(src, offset, indent)) {
324
+ return offset;
325
+ }
326
+
327
+ var comment = new Comment();
328
+ offset = comment.parse({
329
+ indent: indent,
330
+ lineStart: lineStart,
331
+ src: src
332
+ }, offset);
333
+ this.items.push(comment);
334
+ this.valueRange.end = offset;
335
+
336
+ if (offset >= src.length) {
337
+ ch = null;
338
+ break;
339
+ }
340
+ }
341
+
342
+ lineStart = offset + 1;
343
+ offset = Node.endOfIndent(src, lineStart);
344
+
345
+ if (Node.atBlank(src, offset)) {
346
+ var wsEnd = Node.endOfWhiteSpace(src, offset);
347
+ var next = src[wsEnd];
348
+
349
+ if (!next || next === '\n' || next === '#') {
350
+ offset = wsEnd;
351
+ }
352
+ }
353
+
354
+ ch = src[offset];
355
+ atLineStart = true;
356
+ }
357
+
358
+ if (!ch) {
359
+ break;
360
+ }
361
+
362
+ if (offset !== lineStart + indent && (atLineStart || ch !== ':')) {
363
+ if (offset < lineStart + indent) {
364
+ if (lineStart > start) offset = lineStart;
365
+ break;
366
+ } else if (!this.error) {
367
+ var msg = 'All collection items must start at the same column';
368
+ this.error = new YAMLSyntaxError(this, msg);
369
+ }
370
+ }
371
+
372
+ if (firstItem.type === Type.SEQ_ITEM) {
373
+ if (ch !== '-') {
374
+ if (lineStart > start) offset = lineStart;
375
+ break;
376
+ }
377
+ } else if (ch === '-' && !this.error) {
378
+ // map key may start with -, as long as it's followed by a non-whitespace char
379
+ var _next = src[offset + 1];
380
+
381
+ if (!_next || _next === '\n' || _next === '\t' || _next === ' ') {
382
+ var _msg = 'A collection cannot be both a mapping and a sequence';
383
+ this.error = new YAMLSyntaxError(this, _msg);
384
+ }
385
+ }
386
+
387
+ var node = parseNode({
388
+ atLineStart: atLineStart,
389
+ inCollection: true,
390
+ indent: indent,
391
+ lineStart: lineStart,
392
+ parent: this
393
+ }, offset);
394
+ if (!node) return offset; // at next document start
395
+
396
+ this.items.push(node);
397
+ this.valueRange.end = node.valueRange.end;
398
+ offset = Node.normalizeOffset(src, node.range.end);
399
+ ch = src[offset];
400
+ atLineStart = false;
401
+ prevIncludesTrailingLines = node.includesTrailingLines; // Need to reset lineStart and atLineStart here if preceding node's range
402
+ // has advanced to check the current line's indentation level
403
+ // -- eemeli/yaml#10 & eemeli/yaml#38
404
+
405
+ if (ch) {
406
+ var ls = offset - 1;
407
+ var prev = src[ls];
408
+
409
+ while (prev === ' ' || prev === '\t') {
410
+ prev = src[--ls];
411
+ }
412
+
413
+ if (prev === '\n') {
414
+ lineStart = ls + 1;
415
+ atLineStart = true;
416
+ }
417
+ }
418
+
419
+ var ec = grabCollectionEndComments(node);
420
+ if (ec) Array.prototype.push.apply(this.items, ec);
421
+ }
422
+
423
+ return offset;
424
+ }
425
+ }, {
426
+ key: "setOrigRanges",
427
+ value: function setOrigRanges(cr, offset) {
428
+ offset = _get(_getPrototypeOf(Collection.prototype), "setOrigRanges", this).call(this, cr, offset);
429
+ this.items.forEach(function (node) {
430
+ offset = node.setOrigRanges(cr, offset);
431
+ });
432
+ return offset;
433
+ }
434
+ }, {
435
+ key: "toString",
436
+ value: function toString() {
437
+ var src = this.context.src,
438
+ items = this.items,
439
+ range = this.range,
440
+ value = this.value;
441
+ if (value != null) return value;
442
+ var str = src.slice(range.start, items[0].range.start) + String(items[0]);
443
+
444
+ for (var i = 1; i < items.length; ++i) {
445
+ var item = items[i];
446
+ var _item$context = item.context,
447
+ atLineStart = _item$context.atLineStart,
448
+ indent = _item$context.indent;
449
+ if (atLineStart) for (var _i = 0; _i < indent; ++_i) {
450
+ str += ' ';
451
+ }
452
+ str += String(item);
453
+ }
454
+
455
+ return Node.addStringTerminator(src, range.end, str);
456
+ }
457
+ }, {
458
+ key: "includesTrailingLines",
459
+ get: function get() {
460
+ return this.items.length > 0;
461
+ }
462
+ }]);
463
+
464
+ return Collection;
465
+ }(Node);
466
+
467
+ var Directive = /*#__PURE__*/function (_Node) {
468
+ _inherits(Directive, _Node);
469
+
470
+ var _super = _createSuper(Directive);
471
+
472
+ function Directive() {
473
+ var _this;
474
+
475
+ _classCallCheck(this, Directive);
476
+
477
+ _this = _super.call(this, Type.DIRECTIVE);
478
+ _this.name = null;
479
+ return _this;
480
+ }
481
+
482
+ _createClass(Directive, [{
483
+ key: "parseName",
484
+ value: function parseName(start) {
485
+ var src = this.context.src;
486
+ var offset = start;
487
+ var ch = src[offset];
488
+
489
+ while (ch && ch !== '\n' && ch !== '\t' && ch !== ' ') {
490
+ ch = src[offset += 1];
491
+ }
492
+
493
+ this.name = src.slice(start, offset);
494
+ return offset;
495
+ }
496
+ }, {
497
+ key: "parseParameters",
498
+ value: function parseParameters(start) {
499
+ var src = this.context.src;
500
+ var offset = start;
501
+ var ch = src[offset];
502
+
503
+ while (ch && ch !== '\n' && ch !== '#') {
504
+ ch = src[offset += 1];
505
+ }
506
+
507
+ this.valueRange = new Range(start, offset);
508
+ return offset;
509
+ }
510
+ }, {
511
+ key: "parse",
512
+ value: function parse(context, start) {
513
+ this.context = context;
514
+ var offset = this.parseName(start + 1);
515
+ offset = this.parseParameters(offset);
516
+ offset = this.parseComment(offset);
517
+ this.range = new Range(start, offset);
518
+ return offset;
519
+ }
520
+ }, {
521
+ key: "parameters",
522
+ get: function get() {
523
+ var raw = this.rawValue;
524
+ return raw ? raw.trim().split(/[ \t]+/) : [];
525
+ }
526
+ }]);
527
+
528
+ return Directive;
529
+ }(Node);
530
+
531
+ var Document = /*#__PURE__*/function (_Node) {
532
+ _inherits(Document, _Node);
533
+
534
+ var _super = _createSuper(Document);
535
+
536
+ _createClass(Document, null, [{
537
+ key: "startCommentOrEndBlankLine",
538
+ value: function startCommentOrEndBlankLine(src, start) {
539
+ var offset = Node.endOfWhiteSpace(src, start);
540
+ var ch = src[offset];
541
+ return ch === '#' || ch === '\n' ? offset : start;
542
+ }
543
+ }]);
544
+
545
+ function Document() {
546
+ var _this;
547
+
548
+ _classCallCheck(this, Document);
549
+
550
+ _this = _super.call(this, Type.DOCUMENT);
551
+ _this.directives = null;
552
+ _this.contents = null;
553
+ _this.directivesEndMarker = null;
554
+ _this.documentEndMarker = null;
555
+ return _this;
556
+ }
557
+
558
+ _createClass(Document, [{
559
+ key: "parseDirectives",
560
+ value: function parseDirectives(start) {
561
+ var src = this.context.src;
562
+ this.directives = [];
563
+ var atLineStart = true;
564
+ var hasDirectives = false;
565
+ var offset = start;
566
+
567
+ while (!Node.atDocumentBoundary(src, offset, Char.DIRECTIVES_END)) {
568
+ offset = Document.startCommentOrEndBlankLine(src, offset);
569
+
570
+ switch (src[offset]) {
571
+ case '\n':
572
+ if (atLineStart) {
573
+ var blankLine = new BlankLine();
574
+ offset = blankLine.parse({
575
+ src: src
576
+ }, offset);
577
+
578
+ if (offset < src.length) {
579
+ this.directives.push(blankLine);
580
+ }
581
+ } else {
582
+ offset += 1;
583
+ atLineStart = true;
584
+ }
585
+
586
+ break;
587
+
588
+ case '#':
589
+ {
590
+ var comment = new Comment();
591
+ offset = comment.parse({
592
+ src: src
593
+ }, offset);
594
+ this.directives.push(comment);
595
+ atLineStart = false;
596
+ }
597
+ break;
598
+
599
+ case '%':
600
+ {
601
+ var directive = new Directive();
602
+ offset = directive.parse({
603
+ parent: this,
604
+ src: src
605
+ }, offset);
606
+ this.directives.push(directive);
607
+ hasDirectives = true;
608
+ atLineStart = false;
609
+ }
610
+ break;
611
+
612
+ default:
613
+ if (hasDirectives) {
614
+ this.error = new YAMLSemanticError(this, 'Missing directives-end indicator line');
615
+ } else if (this.directives.length > 0) {
616
+ this.contents = this.directives;
617
+ this.directives = [];
618
+ }
619
+
620
+ return offset;
621
+ }
622
+ }
623
+
624
+ if (src[offset]) {
625
+ this.directivesEndMarker = new Range(offset, offset + 3);
626
+ return offset + 3;
627
+ }
628
+
629
+ if (hasDirectives) {
630
+ this.error = new YAMLSemanticError(this, 'Missing directives-end indicator line');
631
+ } else if (this.directives.length > 0) {
632
+ this.contents = this.directives;
633
+ this.directives = [];
634
+ }
635
+
636
+ return offset;
637
+ }
638
+ }, {
639
+ key: "parseContents",
640
+ value: function parseContents(start) {
641
+ var _this$context = this.context,
642
+ parseNode = _this$context.parseNode,
643
+ src = _this$context.src;
644
+ if (!this.contents) this.contents = [];
645
+ var lineStart = start;
646
+
647
+ while (src[lineStart - 1] === '-') {
648
+ lineStart -= 1;
649
+ }
650
+
651
+ var offset = Node.endOfWhiteSpace(src, start);
652
+ var atLineStart = lineStart === start;
653
+ this.valueRange = new Range(offset);
654
+
655
+ while (!Node.atDocumentBoundary(src, offset, Char.DOCUMENT_END)) {
656
+ switch (src[offset]) {
657
+ case '\n':
658
+ if (atLineStart) {
659
+ var blankLine = new BlankLine();
660
+ offset = blankLine.parse({
661
+ src: src
662
+ }, offset);
663
+
664
+ if (offset < src.length) {
665
+ this.contents.push(blankLine);
666
+ }
667
+ } else {
668
+ offset += 1;
669
+ atLineStart = true;
670
+ }
671
+
672
+ lineStart = offset;
673
+ break;
674
+
675
+ case '#':
676
+ {
677
+ var comment = new Comment();
678
+ offset = comment.parse({
679
+ src: src
680
+ }, offset);
681
+ this.contents.push(comment);
682
+ atLineStart = false;
683
+ }
684
+ break;
685
+
686
+ default:
687
+ {
688
+ var iEnd = Node.endOfIndent(src, offset);
689
+ var context = {
690
+ atLineStart: atLineStart,
691
+ indent: -1,
692
+ inFlow: false,
693
+ inCollection: false,
694
+ lineStart: lineStart,
695
+ parent: this
696
+ };
697
+ var node = parseNode(context, iEnd);
698
+ if (!node) return this.valueRange.end = iEnd; // at next document start
699
+
700
+ this.contents.push(node);
701
+ offset = node.range.end;
702
+ atLineStart = false;
703
+ var ec = grabCollectionEndComments(node);
704
+ if (ec) Array.prototype.push.apply(this.contents, ec);
705
+ }
706
+ }
707
+
708
+ offset = Document.startCommentOrEndBlankLine(src, offset);
709
+ }
710
+
711
+ this.valueRange.end = offset;
712
+
713
+ if (src[offset]) {
714
+ this.documentEndMarker = new Range(offset, offset + 3);
715
+ offset += 3;
716
+
717
+ if (src[offset]) {
718
+ offset = Node.endOfWhiteSpace(src, offset);
719
+
720
+ if (src[offset] === '#') {
721
+ var _comment = new Comment();
722
+
723
+ offset = _comment.parse({
724
+ src: src
725
+ }, offset);
726
+ this.contents.push(_comment);
727
+ }
728
+
729
+ switch (src[offset]) {
730
+ case '\n':
731
+ offset += 1;
732
+ break;
733
+
734
+ case undefined:
735
+ break;
736
+
737
+ default:
738
+ this.error = new YAMLSyntaxError(this, 'Document end marker line cannot have a non-comment suffix');
739
+ }
740
+ }
741
+ }
742
+
743
+ return offset;
744
+ }
745
+ /**
746
+ * @param {ParseContext} context
747
+ * @param {number} start - Index of first character
748
+ * @returns {number} - Index of the character after this
749
+ */
750
+
751
+ }, {
752
+ key: "parse",
753
+ value: function parse(context, start) {
754
+ context.root = this;
755
+ this.context = context;
756
+ var src = context.src;
757
+ var offset = src.charCodeAt(start) === 0xfeff ? start + 1 : start; // skip BOM
758
+
759
+ offset = this.parseDirectives(offset);
760
+ offset = this.parseContents(offset);
761
+ return offset;
762
+ }
763
+ }, {
764
+ key: "setOrigRanges",
765
+ value: function setOrigRanges(cr, offset) {
766
+ offset = _get(_getPrototypeOf(Document.prototype), "setOrigRanges", this).call(this, cr, offset);
767
+ this.directives.forEach(function (node) {
768
+ offset = node.setOrigRanges(cr, offset);
769
+ });
770
+ if (this.directivesEndMarker) offset = this.directivesEndMarker.setOrigRange(cr, offset);
771
+ this.contents.forEach(function (node) {
772
+ offset = node.setOrigRanges(cr, offset);
773
+ });
774
+ if (this.documentEndMarker) offset = this.documentEndMarker.setOrigRange(cr, offset);
775
+ return offset;
776
+ }
777
+ }, {
778
+ key: "toString",
779
+ value: function toString() {
780
+ var contents = this.contents,
781
+ directives = this.directives,
782
+ value = this.value;
783
+ if (value != null) return value;
784
+ var str = directives.join('');
785
+
786
+ if (contents.length > 0) {
787
+ if (directives.length > 0 || contents[0].type === Type.COMMENT) str += '---\n';
788
+ str += contents.join('');
789
+ }
790
+
791
+ if (str[str.length - 1] !== '\n') str += '\n';
792
+ return str;
793
+ }
794
+ }]);
795
+
796
+ return Document;
797
+ }(Node);
798
+
799
+ var Alias = /*#__PURE__*/function (_Node) {
800
+ _inherits(Alias, _Node);
801
+
802
+ var _super = _createSuper(Alias);
803
+
804
+ function Alias() {
805
+ _classCallCheck(this, Alias);
806
+
807
+ return _super.apply(this, arguments);
808
+ }
809
+
810
+ _createClass(Alias, [{
811
+ key: "parse",
812
+
813
+ /**
814
+ * Parses an *alias from the source
815
+ *
816
+ * @param {ParseContext} context
817
+ * @param {number} start - Index of first character
818
+ * @returns {number} - Index of the character after this scalar
819
+ */
820
+ value: function parse(context, start) {
821
+ this.context = context;
822
+ var src = context.src;
823
+ var offset = Node.endOfIdentifier(src, start + 1);
824
+ this.valueRange = new Range(start + 1, offset);
825
+ offset = Node.endOfWhiteSpace(src, offset);
826
+ offset = this.parseComment(offset);
827
+ return offset;
828
+ }
829
+ }]);
830
+
831
+ return Alias;
832
+ }(Node);
833
+
834
+ var Chomp = {
835
+ CLIP: 'CLIP',
836
+ KEEP: 'KEEP',
837
+ STRIP: 'STRIP'
838
+ };
839
+ var BlockValue = /*#__PURE__*/function (_Node) {
840
+ _inherits(BlockValue, _Node);
841
+
842
+ var _super = _createSuper(BlockValue);
843
+
844
+ function BlockValue(type, props) {
845
+ var _this;
846
+
847
+ _classCallCheck(this, BlockValue);
848
+
849
+ _this = _super.call(this, type, props);
850
+ _this.blockIndent = null;
851
+ _this.chomping = Chomp.CLIP;
852
+ _this.header = null;
853
+ return _this;
854
+ }
855
+
856
+ _createClass(BlockValue, [{
857
+ key: "parseBlockHeader",
858
+ value: function parseBlockHeader(start) {
859
+ var src = this.context.src;
860
+ var offset = start + 1;
861
+ var bi = '';
862
+
863
+ while (true) {
864
+ var ch = src[offset];
865
+
866
+ switch (ch) {
867
+ case '-':
868
+ this.chomping = Chomp.STRIP;
869
+ break;
870
+
871
+ case '+':
872
+ this.chomping = Chomp.KEEP;
873
+ break;
874
+
875
+ case '0':
876
+ case '1':
877
+ case '2':
878
+ case '3':
879
+ case '4':
880
+ case '5':
881
+ case '6':
882
+ case '7':
883
+ case '8':
884
+ case '9':
885
+ bi += ch;
886
+ break;
887
+
888
+ default:
889
+ this.blockIndent = Number(bi) || null;
890
+ this.header = new Range(start, offset);
891
+ return offset;
892
+ }
893
+
894
+ offset += 1;
895
+ }
896
+ }
897
+ }, {
898
+ key: "parseBlockValue",
899
+ value: function parseBlockValue(start) {
900
+ var _this$context = this.context,
901
+ indent = _this$context.indent,
902
+ src = _this$context.src;
903
+ var explicit = !!this.blockIndent;
904
+ var offset = start;
905
+ var valueEnd = start;
906
+ var minBlockIndent = 1;
907
+
908
+ for (var ch = src[offset]; ch === '\n'; ch = src[offset]) {
909
+ offset += 1;
910
+ if (Node.atDocumentBoundary(src, offset)) break;
911
+ var end = Node.endOfBlockIndent(src, indent, offset); // should not include tab?
912
+
913
+ if (end === null) break;
914
+ var _ch = src[end];
915
+ var lineIndent = end - (offset + indent);
916
+
917
+ if (!this.blockIndent) {
918
+ // no explicit block indent, none yet detected
919
+ if (src[end] !== '\n') {
920
+ // first line with non-whitespace content
921
+ if (lineIndent < minBlockIndent) {
922
+ var msg = 'Block scalars with more-indented leading empty lines must use an explicit indentation indicator';
923
+ this.error = new YAMLSemanticError(this, msg);
924
+ }
925
+
926
+ this.blockIndent = lineIndent;
927
+ } else if (lineIndent > minBlockIndent) {
928
+ // empty line with more whitespace
929
+ minBlockIndent = lineIndent;
930
+ }
931
+ } else if (_ch && _ch !== '\n' && lineIndent < this.blockIndent) {
932
+ if (src[end] === '#') break;
933
+
934
+ if (!this.error) {
935
+ var _src = explicit ? 'explicit indentation indicator' : 'first line';
936
+
937
+ var _msg = "Block scalars must not be less indented than their ".concat(_src);
938
+
939
+ this.error = new YAMLSemanticError(this, _msg);
940
+ }
941
+ }
942
+
943
+ if (src[end] === '\n') {
944
+ offset = end;
945
+ } else {
946
+ offset = valueEnd = Node.endOfLine(src, end);
947
+ }
948
+ }
949
+
950
+ if (this.chomping !== Chomp.KEEP) {
951
+ offset = src[valueEnd] ? valueEnd + 1 : valueEnd;
952
+ }
953
+
954
+ this.valueRange = new Range(start + 1, offset);
955
+ return offset;
956
+ }
957
+ /**
958
+ * Parses a block value from the source
959
+ *
960
+ * Accepted forms are:
961
+ * ```
962
+ * BS
963
+ * block
964
+ * lines
965
+ *
966
+ * BS #comment
967
+ * block
968
+ * lines
969
+ * ```
970
+ * where the block style BS matches the regexp `[|>][-+1-9]*` and block lines
971
+ * are empty or have an indent level greater than `indent`.
972
+ *
973
+ * @param {ParseContext} context
974
+ * @param {number} start - Index of first character
975
+ * @returns {number} - Index of the character after this block
976
+ */
977
+
978
+ }, {
979
+ key: "parse",
980
+ value: function parse(context, start) {
981
+ this.context = context;
982
+ var src = context.src;
983
+ var offset = this.parseBlockHeader(start);
984
+ offset = Node.endOfWhiteSpace(src, offset);
985
+ offset = this.parseComment(offset);
986
+ offset = this.parseBlockValue(offset);
987
+ return offset;
988
+ }
989
+ }, {
990
+ key: "setOrigRanges",
991
+ value: function setOrigRanges(cr, offset) {
992
+ offset = _get(_getPrototypeOf(BlockValue.prototype), "setOrigRanges", this).call(this, cr, offset);
993
+ return this.header ? this.header.setOrigRange(cr, offset) : offset;
994
+ }
995
+ }, {
996
+ key: "includesTrailingLines",
997
+ get: function get() {
998
+ return this.chomping === Chomp.KEEP;
999
+ }
1000
+ }, {
1001
+ key: "strValue",
1002
+ get: function get() {
1003
+ if (!this.valueRange || !this.context) return null;
1004
+ var _this$valueRange = this.valueRange,
1005
+ start = _this$valueRange.start,
1006
+ end = _this$valueRange.end;
1007
+ var _this$context2 = this.context,
1008
+ indent = _this$context2.indent,
1009
+ src = _this$context2.src;
1010
+ if (this.valueRange.isEmpty()) return '';
1011
+ var lastNewLine = null;
1012
+ var ch = src[end - 1];
1013
+
1014
+ while (ch === '\n' || ch === '\t' || ch === ' ') {
1015
+ end -= 1;
1016
+
1017
+ if (end <= start) {
1018
+ if (this.chomping === Chomp.KEEP) break;else return ''; // probably never happens
1019
+ }
1020
+
1021
+ if (ch === '\n') lastNewLine = end;
1022
+ ch = src[end - 1];
1023
+ }
1024
+
1025
+ var keepStart = end + 1;
1026
+
1027
+ if (lastNewLine) {
1028
+ if (this.chomping === Chomp.KEEP) {
1029
+ keepStart = lastNewLine;
1030
+ end = this.valueRange.end;
1031
+ } else {
1032
+ end = lastNewLine;
1033
+ }
1034
+ }
1035
+
1036
+ var bi = indent + this.blockIndent;
1037
+ var folded = this.type === Type.BLOCK_FOLDED;
1038
+ var atStart = true;
1039
+ var str = '';
1040
+ var sep = '';
1041
+ var prevMoreIndented = false;
1042
+
1043
+ for (var i = start; i < end; ++i) {
1044
+ for (var j = 0; j < bi; ++j) {
1045
+ if (src[i] !== ' ') break;
1046
+ i += 1;
1047
+ }
1048
+
1049
+ var _ch2 = src[i];
1050
+
1051
+ if (_ch2 === '\n') {
1052
+ if (sep === '\n') str += '\n';else sep = '\n';
1053
+ } else {
1054
+ var lineEnd = Node.endOfLine(src, i);
1055
+ var line = src.slice(i, lineEnd);
1056
+ i = lineEnd;
1057
+
1058
+ if (folded && (_ch2 === ' ' || _ch2 === '\t') && i < keepStart) {
1059
+ if (sep === ' ') sep = '\n';else if (!prevMoreIndented && !atStart && sep === '\n') sep = '\n\n';
1060
+ str += sep + line; //+ ((lineEnd < end && src[lineEnd]) || '')
1061
+
1062
+ sep = lineEnd < end && src[lineEnd] || '';
1063
+ prevMoreIndented = true;
1064
+ } else {
1065
+ str += sep + line;
1066
+ sep = folded && i < keepStart ? ' ' : '\n';
1067
+ prevMoreIndented = false;
1068
+ }
1069
+
1070
+ if (atStart && line !== '') atStart = false;
1071
+ }
1072
+ }
1073
+
1074
+ return this.chomping === Chomp.STRIP ? str : str + '\n';
1075
+ }
1076
+ }]);
1077
+
1078
+ return BlockValue;
1079
+ }(Node);
1080
+
1081
+ var FlowCollection = /*#__PURE__*/function (_Node) {
1082
+ _inherits(FlowCollection, _Node);
1083
+
1084
+ var _super = _createSuper(FlowCollection);
1085
+
1086
+ function FlowCollection(type, props) {
1087
+ var _this;
1088
+
1089
+ _classCallCheck(this, FlowCollection);
1090
+
1091
+ _this = _super.call(this, type, props);
1092
+ _this.items = null;
1093
+ return _this;
1094
+ }
1095
+
1096
+ _createClass(FlowCollection, [{
1097
+ key: "prevNodeIsJsonLike",
1098
+ value: function prevNodeIsJsonLike() {
1099
+ var idx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items.length;
1100
+ var node = this.items[idx - 1];
1101
+ return !!node && (node.jsonLike || node.type === Type.COMMENT && this.prevNodeIsJsonLike(idx - 1));
1102
+ }
1103
+ /**
1104
+ * @param {ParseContext} context
1105
+ * @param {number} start - Index of first character
1106
+ * @returns {number} - Index of the character after this
1107
+ */
1108
+
1109
+ }, {
1110
+ key: "parse",
1111
+ value: function parse(context, start) {
1112
+ this.context = context;
1113
+ var parseNode = context.parseNode,
1114
+ src = context.src;
1115
+ var indent = context.indent,
1116
+ lineStart = context.lineStart;
1117
+ var char = src[start]; // { or [
1118
+
1119
+ this.items = [{
1120
+ char: char,
1121
+ offset: start
1122
+ }];
1123
+ var offset = Node.endOfWhiteSpace(src, start + 1);
1124
+ char = src[offset];
1125
+
1126
+ while (char && char !== ']' && char !== '}') {
1127
+ switch (char) {
1128
+ case '\n':
1129
+ {
1130
+ lineStart = offset + 1;
1131
+ var wsEnd = Node.endOfWhiteSpace(src, lineStart);
1132
+
1133
+ if (src[wsEnd] === '\n') {
1134
+ var blankLine = new BlankLine();
1135
+ lineStart = blankLine.parse({
1136
+ src: src
1137
+ }, lineStart);
1138
+ this.items.push(blankLine);
1139
+ }
1140
+
1141
+ offset = Node.endOfIndent(src, lineStart);
1142
+
1143
+ if (offset <= lineStart + indent) {
1144
+ char = src[offset];
1145
+
1146
+ if (offset < lineStart + indent || char !== ']' && char !== '}') {
1147
+ var msg = 'Insufficient indentation in flow collection';
1148
+ this.error = new YAMLSemanticError(this, msg);
1149
+ }
1150
+ }
1151
+ }
1152
+ break;
1153
+
1154
+ case ',':
1155
+ {
1156
+ this.items.push({
1157
+ char: char,
1158
+ offset: offset
1159
+ });
1160
+ offset += 1;
1161
+ }
1162
+ break;
1163
+
1164
+ case '#':
1165
+ {
1166
+ var comment = new Comment();
1167
+ offset = comment.parse({
1168
+ src: src
1169
+ }, offset);
1170
+ this.items.push(comment);
1171
+ }
1172
+ break;
1173
+
1174
+ case '?':
1175
+ case ':':
1176
+ {
1177
+ var next = src[offset + 1];
1178
+
1179
+ if (next === '\n' || next === '\t' || next === ' ' || next === ',' || // in-flow : after JSON-like key does not need to be followed by whitespace
1180
+ char === ':' && this.prevNodeIsJsonLike()) {
1181
+ this.items.push({
1182
+ char: char,
1183
+ offset: offset
1184
+ });
1185
+ offset += 1;
1186
+ break;
1187
+ }
1188
+ }
1189
+ // fallthrough
1190
+
1191
+ default:
1192
+ {
1193
+ var node = parseNode({
1194
+ atLineStart: false,
1195
+ inCollection: false,
1196
+ inFlow: true,
1197
+ indent: -1,
1198
+ lineStart: lineStart,
1199
+ parent: this
1200
+ }, offset);
1201
+
1202
+ if (!node) {
1203
+ // at next document start
1204
+ this.valueRange = new Range(start, offset);
1205
+ return offset;
1206
+ }
1207
+
1208
+ this.items.push(node);
1209
+ offset = Node.normalizeOffset(src, node.range.end);
1210
+ }
1211
+ }
1212
+
1213
+ offset = Node.endOfWhiteSpace(src, offset);
1214
+ char = src[offset];
1215
+ }
1216
+
1217
+ this.valueRange = new Range(start, offset + 1);
1218
+
1219
+ if (char) {
1220
+ this.items.push({
1221
+ char: char,
1222
+ offset: offset
1223
+ });
1224
+ offset = Node.endOfWhiteSpace(src, offset + 1);
1225
+ offset = this.parseComment(offset);
1226
+ }
1227
+
1228
+ return offset;
1229
+ }
1230
+ }, {
1231
+ key: "setOrigRanges",
1232
+ value: function setOrigRanges(cr, offset) {
1233
+ offset = _get(_getPrototypeOf(FlowCollection.prototype), "setOrigRanges", this).call(this, cr, offset);
1234
+ this.items.forEach(function (node) {
1235
+ if (node instanceof Node) {
1236
+ offset = node.setOrigRanges(cr, offset);
1237
+ } else if (cr.length === 0) {
1238
+ node.origOffset = node.offset;
1239
+ } else {
1240
+ var i = offset;
1241
+
1242
+ while (i < cr.length) {
1243
+ if (cr[i] > node.offset) break;else ++i;
1244
+ }
1245
+
1246
+ node.origOffset = node.offset + i;
1247
+ offset = i;
1248
+ }
1249
+ });
1250
+ return offset;
1251
+ }
1252
+ }, {
1253
+ key: "toString",
1254
+ value: function toString() {
1255
+ var src = this.context.src,
1256
+ items = this.items,
1257
+ range = this.range,
1258
+ value = this.value;
1259
+ if (value != null) return value;
1260
+ var nodes = items.filter(function (item) {
1261
+ return item instanceof Node;
1262
+ });
1263
+ var str = '';
1264
+ var prevEnd = range.start;
1265
+ nodes.forEach(function (node) {
1266
+ var prefix = src.slice(prevEnd, node.range.start);
1267
+ prevEnd = node.range.end;
1268
+ str += prefix + String(node);
1269
+
1270
+ if (str[str.length - 1] === '\n' && src[prevEnd - 1] !== '\n' && src[prevEnd] === '\n') {
1271
+ // Comment range does not include the terminal newline, but its
1272
+ // stringified value does. Without this fix, newlines at comment ends
1273
+ // get duplicated.
1274
+ prevEnd += 1;
1275
+ }
1276
+ });
1277
+ str += src.slice(prevEnd, range.end);
1278
+ return Node.addStringTerminator(src, range.end, str);
1279
+ }
1280
+ }]);
1281
+
1282
+ return FlowCollection;
1283
+ }(Node);
1284
+
1285
+ var PlainValue = /*#__PURE__*/function (_Node) {
1286
+ _inherits(PlainValue, _Node);
1287
+
1288
+ var _super = _createSuper(PlainValue);
1289
+
1290
+ function PlainValue() {
1291
+ _classCallCheck(this, PlainValue);
1292
+
1293
+ return _super.apply(this, arguments);
1294
+ }
1295
+
1296
+ _createClass(PlainValue, [{
1297
+ key: "parseBlockValue",
1298
+ value: function parseBlockValue(start) {
1299
+ var _this$context = this.context,
1300
+ indent = _this$context.indent,
1301
+ inFlow = _this$context.inFlow,
1302
+ src = _this$context.src;
1303
+ var offset = start;
1304
+ var valueEnd = start;
1305
+
1306
+ for (var ch = src[offset]; ch === '\n'; ch = src[offset]) {
1307
+ if (Node.atDocumentBoundary(src, offset + 1)) break;
1308
+ var end = Node.endOfBlockIndent(src, indent, offset + 1);
1309
+ if (end === null || src[end] === '#') break;
1310
+
1311
+ if (src[end] === '\n') {
1312
+ offset = end;
1313
+ } else {
1314
+ valueEnd = PlainValue.endOfLine(src, end, inFlow);
1315
+ offset = valueEnd;
1316
+ }
1317
+ }
1318
+
1319
+ if (this.valueRange.isEmpty()) this.valueRange.start = start;
1320
+ this.valueRange.end = valueEnd;
1321
+ return valueEnd;
1322
+ }
1323
+ /**
1324
+ * Parses a plain value from the source
1325
+ *
1326
+ * Accepted forms are:
1327
+ * ```
1328
+ * #comment
1329
+ *
1330
+ * first line
1331
+ *
1332
+ * first line #comment
1333
+ *
1334
+ * first line
1335
+ * block
1336
+ * lines
1337
+ *
1338
+ * #comment
1339
+ * block
1340
+ * lines
1341
+ * ```
1342
+ * where block lines are empty or have an indent level greater than `indent`.
1343
+ *
1344
+ * @param {ParseContext} context
1345
+ * @param {number} start - Index of first character
1346
+ * @returns {number} - Index of the character after this scalar, may be `\n`
1347
+ */
1348
+
1349
+ }, {
1350
+ key: "parse",
1351
+ value: function parse(context, start) {
1352
+ this.context = context;
1353
+ var inFlow = context.inFlow,
1354
+ src = context.src;
1355
+ var offset = start;
1356
+ var ch = src[offset];
1357
+
1358
+ if (ch && ch !== '#' && ch !== '\n') {
1359
+ offset = PlainValue.endOfLine(src, start, inFlow);
1360
+ }
1361
+
1362
+ this.valueRange = new Range(start, offset);
1363
+ offset = Node.endOfWhiteSpace(src, offset);
1364
+ offset = this.parseComment(offset);
1365
+
1366
+ if (!this.hasComment || this.valueRange.isEmpty()) {
1367
+ offset = this.parseBlockValue(offset);
1368
+ }
1369
+
1370
+ return offset;
1371
+ }
1372
+ }, {
1373
+ key: "strValue",
1374
+ get: function get() {
1375
+ if (!this.valueRange || !this.context) return null;
1376
+ var _this$valueRange = this.valueRange,
1377
+ start = _this$valueRange.start,
1378
+ end = _this$valueRange.end;
1379
+ var src = this.context.src;
1380
+ var ch = src[end - 1];
1381
+
1382
+ while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) {
1383
+ ch = src[--end - 1];
1384
+ }
1385
+
1386
+ var str = '';
1387
+
1388
+ for (var i = start; i < end; ++i) {
1389
+ var _ch = src[i];
1390
+
1391
+ if (_ch === '\n') {
1392
+ var _Node$foldNewline = Node.foldNewline(src, i, -1),
1393
+ fold = _Node$foldNewline.fold,
1394
+ offset = _Node$foldNewline.offset;
1395
+
1396
+ str += fold;
1397
+ i = offset;
1398
+ } else if (_ch === ' ' || _ch === '\t') {
1399
+ // trim trailing whitespace
1400
+ var wsStart = i;
1401
+ var next = src[i + 1];
1402
+
1403
+ while (i < end && (next === ' ' || next === '\t')) {
1404
+ i += 1;
1405
+ next = src[i + 1];
1406
+ }
1407
+
1408
+ if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : _ch;
1409
+ } else {
1410
+ str += _ch;
1411
+ }
1412
+ }
1413
+
1414
+ var ch0 = src[start];
1415
+
1416
+ switch (ch0) {
1417
+ case '\t':
1418
+ {
1419
+ var msg = 'Plain value cannot start with a tab character';
1420
+ var errors = [new YAMLSemanticError(this, msg)];
1421
+ return {
1422
+ errors: errors,
1423
+ str: str
1424
+ };
1425
+ }
1426
+
1427
+ case '@':
1428
+ case '`':
1429
+ {
1430
+ var _msg = "Plain value cannot start with reserved character ".concat(ch0);
1431
+
1432
+ var _errors = [new YAMLSemanticError(this, _msg)];
1433
+ return {
1434
+ errors: _errors,
1435
+ str: str
1436
+ };
1437
+ }
1438
+
1439
+ default:
1440
+ return str;
1441
+ }
1442
+ }
1443
+ }], [{
1444
+ key: "endOfLine",
1445
+ value: function endOfLine(src, start, inFlow) {
1446
+ var ch = src[start];
1447
+ var offset = start;
1448
+
1449
+ while (ch && ch !== '\n') {
1450
+ if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break;
1451
+ var next = src[offset + 1];
1452
+ if (ch === ':' && (!next || next === '\n' || next === '\t' || next === ' ' || inFlow && next === ',')) break;
1453
+ if ((ch === ' ' || ch === '\t') && next === '#') break;
1454
+ offset += 1;
1455
+ ch = next;
1456
+ }
1457
+
1458
+ return offset;
1459
+ }
1460
+ }]);
1461
+
1462
+ return PlainValue;
1463
+ }(Node);
1464
+
1465
+ var QuoteDouble = /*#__PURE__*/function (_Node) {
1466
+ _inherits(QuoteDouble, _Node);
1467
+
1468
+ var _super = _createSuper(QuoteDouble);
1469
+
1470
+ function QuoteDouble() {
1471
+ _classCallCheck(this, QuoteDouble);
1472
+
1473
+ return _super.apply(this, arguments);
1474
+ }
1475
+
1476
+ _createClass(QuoteDouble, [{
1477
+ key: "parseCharCode",
1478
+ value: function parseCharCode(offset, length, errors) {
1479
+ var src = this.context.src;
1480
+ var cc = src.substr(offset, length);
1481
+ var ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
1482
+ var code = ok ? parseInt(cc, 16) : NaN;
1483
+
1484
+ if (isNaN(code)) {
1485
+ errors.push(new YAMLSyntaxError(this, "Invalid escape sequence ".concat(src.substr(offset - 2, length + 2))));
1486
+ return src.substr(offset - 2, length + 2);
1487
+ }
1488
+
1489
+ return String.fromCodePoint(code);
1490
+ }
1491
+ /**
1492
+ * Parses a "double quoted" value from the source
1493
+ *
1494
+ * @param {ParseContext} context
1495
+ * @param {number} start - Index of first character
1496
+ * @returns {number} - Index of the character after this scalar
1497
+ */
1498
+
1499
+ }, {
1500
+ key: "parse",
1501
+ value: function parse(context, start) {
1502
+ this.context = context;
1503
+ var src = context.src;
1504
+ var offset = QuoteDouble.endOfQuote(src, start + 1);
1505
+ this.valueRange = new Range(start, offset);
1506
+ offset = Node.endOfWhiteSpace(src, offset);
1507
+ offset = this.parseComment(offset);
1508
+ return offset;
1509
+ }
1510
+ }, {
1511
+ key: "strValue",
1512
+
1513
+ /**
1514
+ * @returns {string | { str: string, errors: YAMLSyntaxError[] }}
1515
+ */
1516
+ get: function get() {
1517
+ if (!this.valueRange || !this.context) return null;
1518
+ var errors = [];
1519
+ var _this$valueRange = this.valueRange,
1520
+ start = _this$valueRange.start,
1521
+ end = _this$valueRange.end;
1522
+ var _this$context = this.context,
1523
+ indent = _this$context.indent,
1524
+ src = _this$context.src;
1525
+ if (src[end - 1] !== '"') errors.push(new YAMLSyntaxError(this, 'Missing closing "quote')); // Using String#replace is too painful with escaped newlines preceded by
1526
+ // escaped backslashes; also, this should be faster.
1527
+
1528
+ var str = '';
1529
+
1530
+ for (var i = start + 1; i < end - 1; ++i) {
1531
+ var ch = src[i];
1532
+
1533
+ if (ch === '\n') {
1534
+ if (Node.atDocumentBoundary(src, i + 1)) errors.push(new YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values'));
1535
+
1536
+ var _Node$foldNewline = Node.foldNewline(src, i, indent),
1537
+ fold = _Node$foldNewline.fold,
1538
+ offset = _Node$foldNewline.offset,
1539
+ error = _Node$foldNewline.error;
1540
+
1541
+ str += fold;
1542
+ i = offset;
1543
+ if (error) errors.push(new YAMLSemanticError(this, 'Multi-line double-quoted string needs to be sufficiently indented'));
1544
+ } else if (ch === '\\') {
1545
+ i += 1;
1546
+
1547
+ switch (src[i]) {
1548
+ case '0':
1549
+ str += '\0';
1550
+ break;
1551
+ // null character
1552
+
1553
+ case 'a':
1554
+ str += '\x07';
1555
+ break;
1556
+ // bell character
1557
+
1558
+ case 'b':
1559
+ str += '\b';
1560
+ break;
1561
+ // backspace
1562
+
1563
+ case 'e':
1564
+ str += '\x1b';
1565
+ break;
1566
+ // escape character
1567
+
1568
+ case 'f':
1569
+ str += '\f';
1570
+ break;
1571
+ // form feed
1572
+
1573
+ case 'n':
1574
+ str += '\n';
1575
+ break;
1576
+ // line feed
1577
+
1578
+ case 'r':
1579
+ str += '\r';
1580
+ break;
1581
+ // carriage return
1582
+
1583
+ case 't':
1584
+ str += '\t';
1585
+ break;
1586
+ // horizontal tab
1587
+
1588
+ case 'v':
1589
+ str += '\v';
1590
+ break;
1591
+ // vertical tab
1592
+
1593
+ case 'N':
1594
+ str += "\x85";
1595
+ break;
1596
+ // Unicode next line
1597
+
1598
+ case '_':
1599
+ str += "\xA0";
1600
+ break;
1601
+ // Unicode non-breaking space
1602
+
1603
+ case 'L':
1604
+ str += "\u2028";
1605
+ break;
1606
+ // Unicode line separator
1607
+
1608
+ case 'P':
1609
+ str += "\u2029";
1610
+ break;
1611
+ // Unicode paragraph separator
1612
+
1613
+ case ' ':
1614
+ str += ' ';
1615
+ break;
1616
+
1617
+ case '"':
1618
+ str += '"';
1619
+ break;
1620
+
1621
+ case '/':
1622
+ str += '/';
1623
+ break;
1624
+
1625
+ case '\\':
1626
+ str += '\\';
1627
+ break;
1628
+
1629
+ case '\t':
1630
+ str += '\t';
1631
+ break;
1632
+
1633
+ case 'x':
1634
+ str += this.parseCharCode(i + 1, 2, errors);
1635
+ i += 2;
1636
+ break;
1637
+
1638
+ case 'u':
1639
+ str += this.parseCharCode(i + 1, 4, errors);
1640
+ i += 4;
1641
+ break;
1642
+
1643
+ case 'U':
1644
+ str += this.parseCharCode(i + 1, 8, errors);
1645
+ i += 8;
1646
+ break;
1647
+
1648
+ case '\n':
1649
+ // skip escaped newlines, but still trim the following line
1650
+ while (src[i + 1] === ' ' || src[i + 1] === '\t') {
1651
+ i += 1;
1652
+ }
1653
+
1654
+ break;
1655
+
1656
+ default:
1657
+ errors.push(new YAMLSyntaxError(this, "Invalid escape sequence ".concat(src.substr(i - 1, 2))));
1658
+ str += '\\' + src[i];
1659
+ }
1660
+ } else if (ch === ' ' || ch === '\t') {
1661
+ // trim trailing whitespace
1662
+ var wsStart = i;
1663
+ var next = src[i + 1];
1664
+
1665
+ while (next === ' ' || next === '\t') {
1666
+ i += 1;
1667
+ next = src[i + 1];
1668
+ }
1669
+
1670
+ if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
1671
+ } else {
1672
+ str += ch;
1673
+ }
1674
+ }
1675
+
1676
+ return errors.length > 0 ? {
1677
+ errors: errors,
1678
+ str: str
1679
+ } : str;
1680
+ }
1681
+ }], [{
1682
+ key: "endOfQuote",
1683
+ value: function endOfQuote(src, offset) {
1684
+ var ch = src[offset];
1685
+
1686
+ while (ch && ch !== '"') {
1687
+ offset += ch === '\\' ? 2 : 1;
1688
+ ch = src[offset];
1689
+ }
1690
+
1691
+ return offset + 1;
1692
+ }
1693
+ }]);
1694
+
1695
+ return QuoteDouble;
1696
+ }(Node);
1697
+
1698
+ var QuoteSingle = /*#__PURE__*/function (_Node) {
1699
+ _inherits(QuoteSingle, _Node);
1700
+
1701
+ var _super = _createSuper(QuoteSingle);
1702
+
1703
+ function QuoteSingle() {
1704
+ _classCallCheck(this, QuoteSingle);
1705
+
1706
+ return _super.apply(this, arguments);
1707
+ }
1708
+
1709
+ _createClass(QuoteSingle, [{
1710
+ key: "parse",
1711
+
1712
+ /**
1713
+ * Parses a 'single quoted' value from the source
1714
+ *
1715
+ * @param {ParseContext} context
1716
+ * @param {number} start - Index of first character
1717
+ * @returns {number} - Index of the character after this scalar
1718
+ */
1719
+ value: function parse(context, start) {
1720
+ this.context = context;
1721
+ var src = context.src;
1722
+ var offset = QuoteSingle.endOfQuote(src, start + 1);
1723
+ this.valueRange = new Range(start, offset);
1724
+ offset = Node.endOfWhiteSpace(src, offset);
1725
+ offset = this.parseComment(offset);
1726
+ return offset;
1727
+ }
1728
+ }, {
1729
+ key: "strValue",
1730
+
1731
+ /**
1732
+ * @returns {string | { str: string, errors: YAMLSyntaxError[] }}
1733
+ */
1734
+ get: function get() {
1735
+ if (!this.valueRange || !this.context) return null;
1736
+ var errors = [];
1737
+ var _this$valueRange = this.valueRange,
1738
+ start = _this$valueRange.start,
1739
+ end = _this$valueRange.end;
1740
+ var _this$context = this.context,
1741
+ indent = _this$context.indent,
1742
+ src = _this$context.src;
1743
+ if (src[end - 1] !== "'") errors.push(new YAMLSyntaxError(this, "Missing closing 'quote"));
1744
+ var str = '';
1745
+
1746
+ for (var i = start + 1; i < end - 1; ++i) {
1747
+ var ch = src[i];
1748
+
1749
+ if (ch === '\n') {
1750
+ if (Node.atDocumentBoundary(src, i + 1)) errors.push(new YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values'));
1751
+
1752
+ var _Node$foldNewline = Node.foldNewline(src, i, indent),
1753
+ fold = _Node$foldNewline.fold,
1754
+ offset = _Node$foldNewline.offset,
1755
+ error = _Node$foldNewline.error;
1756
+
1757
+ str += fold;
1758
+ i = offset;
1759
+ if (error) errors.push(new YAMLSemanticError(this, 'Multi-line single-quoted string needs to be sufficiently indented'));
1760
+ } else if (ch === "'") {
1761
+ str += ch;
1762
+ i += 1;
1763
+ if (src[i] !== "'") errors.push(new YAMLSyntaxError(this, 'Unescaped single quote? This should not happen.'));
1764
+ } else if (ch === ' ' || ch === '\t') {
1765
+ // trim trailing whitespace
1766
+ var wsStart = i;
1767
+ var next = src[i + 1];
1768
+
1769
+ while (next === ' ' || next === '\t') {
1770
+ i += 1;
1771
+ next = src[i + 1];
1772
+ }
1773
+
1774
+ if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
1775
+ } else {
1776
+ str += ch;
1777
+ }
1778
+ }
1779
+
1780
+ return errors.length > 0 ? {
1781
+ errors: errors,
1782
+ str: str
1783
+ } : str;
1784
+ }
1785
+ }], [{
1786
+ key: "endOfQuote",
1787
+ value: function endOfQuote(src, offset) {
1788
+ var ch = src[offset];
1789
+
1790
+ while (ch) {
1791
+ if (ch === "'") {
1792
+ if (src[offset + 1] !== "'") break;
1793
+ ch = src[offset += 2];
1794
+ } else {
1795
+ ch = src[offset += 1];
1796
+ }
1797
+ }
1798
+
1799
+ return offset + 1;
1800
+ }
1801
+ }]);
1802
+
1803
+ return QuoteSingle;
1804
+ }(Node);
1805
+
1806
+ function createNewNode(type, props) {
1807
+ switch (type) {
1808
+ case Type.ALIAS:
1809
+ return new Alias(type, props);
1810
+
1811
+ case Type.BLOCK_FOLDED:
1812
+ case Type.BLOCK_LITERAL:
1813
+ return new BlockValue(type, props);
1814
+
1815
+ case Type.FLOW_MAP:
1816
+ case Type.FLOW_SEQ:
1817
+ return new FlowCollection(type, props);
1818
+
1819
+ case Type.MAP_KEY:
1820
+ case Type.MAP_VALUE:
1821
+ case Type.SEQ_ITEM:
1822
+ return new CollectionItem(type, props);
1823
+
1824
+ case Type.COMMENT:
1825
+ case Type.PLAIN:
1826
+ return new PlainValue(type, props);
1827
+
1828
+ case Type.QUOTE_DOUBLE:
1829
+ return new QuoteDouble(type, props);
1830
+
1831
+ case Type.QUOTE_SINGLE:
1832
+ return new QuoteSingle(type, props);
1833
+
1834
+ /* istanbul ignore next */
1835
+
1836
+ default:
1837
+ return null;
1838
+ // should never happen
1839
+ }
1840
+ }
1841
+ /**
1842
+ * @param {boolean} atLineStart - Node starts at beginning of line
1843
+ * @param {boolean} inFlow - true if currently in a flow context
1844
+ * @param {boolean} inCollection - true if currently in a collection context
1845
+ * @param {number} indent - Current level of indentation
1846
+ * @param {number} lineStart - Start of the current line
1847
+ * @param {Node} parent - The parent of the node
1848
+ * @param {string} src - Source of the YAML document
1849
+ */
1850
+
1851
+
1852
+ var ParseContext = /*#__PURE__*/function () {
1853
+ _createClass(ParseContext, null, [{
1854
+ key: "parseType",
1855
+ value: function parseType(src, offset, inFlow) {
1856
+ switch (src[offset]) {
1857
+ case '*':
1858
+ return Type.ALIAS;
1859
+
1860
+ case '>':
1861
+ return Type.BLOCK_FOLDED;
1862
+
1863
+ case '|':
1864
+ return Type.BLOCK_LITERAL;
1865
+
1866
+ case '{':
1867
+ return Type.FLOW_MAP;
1868
+
1869
+ case '[':
1870
+ return Type.FLOW_SEQ;
1871
+
1872
+ case '?':
1873
+ return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.MAP_KEY : Type.PLAIN;
1874
+
1875
+ case ':':
1876
+ return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.MAP_VALUE : Type.PLAIN;
1877
+
1878
+ case '-':
1879
+ return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.SEQ_ITEM : Type.PLAIN;
1880
+
1881
+ case '"':
1882
+ return Type.QUOTE_DOUBLE;
1883
+
1884
+ case "'":
1885
+ return Type.QUOTE_SINGLE;
1886
+
1887
+ default:
1888
+ return Type.PLAIN;
1889
+ }
1890
+ }
1891
+ }]);
1892
+
1893
+ function ParseContext() {
1894
+ var _this = this;
1895
+
1896
+ var orig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1897
+
1898
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1899
+ atLineStart = _ref.atLineStart,
1900
+ inCollection = _ref.inCollection,
1901
+ inFlow = _ref.inFlow,
1902
+ indent = _ref.indent,
1903
+ lineStart = _ref.lineStart,
1904
+ parent = _ref.parent;
1905
+
1906
+ _classCallCheck(this, ParseContext);
1907
+
1908
+ _defineProperty(this, "parseNode", function (overlay, start) {
1909
+ if (Node.atDocumentBoundary(_this.src, start)) return null;
1910
+ var context = new ParseContext(_this, overlay);
1911
+
1912
+ var _context$parseProps = context.parseProps(start),
1913
+ props = _context$parseProps.props,
1914
+ type = _context$parseProps.type,
1915
+ valueStart = _context$parseProps.valueStart;
1916
+
1917
+ var node = createNewNode(type, props);
1918
+ var offset = node.parse(context, valueStart);
1919
+ node.range = new Range(start, offset);
1920
+ /* istanbul ignore if */
1921
+
1922
+ if (offset <= start) {
1923
+ // This should never happen, but if it does, let's make sure to at least
1924
+ // step one character forward to avoid a busy loop.
1925
+ node.error = new Error("Node#parse consumed no characters");
1926
+ node.error.parseEnd = offset;
1927
+ node.error.source = node;
1928
+ node.range.end = start + 1;
1929
+ }
1930
+
1931
+ if (context.nodeStartsCollection(node)) {
1932
+ if (!node.error && !context.atLineStart && context.parent.type === Type.DOCUMENT) {
1933
+ node.error = new YAMLSyntaxError(node, 'Block collection must not have preceding content here (e.g. directives-end indicator)');
1934
+ }
1935
+
1936
+ var collection = new Collection(node);
1937
+ offset = collection.parse(new ParseContext(context), offset);
1938
+ collection.range = new Range(start, offset);
1939
+ return collection;
1940
+ }
1941
+
1942
+ return node;
1943
+ });
1944
+
1945
+ this.atLineStart = atLineStart != null ? atLineStart : orig.atLineStart || false;
1946
+ this.inCollection = inCollection != null ? inCollection : orig.inCollection || false;
1947
+ this.inFlow = inFlow != null ? inFlow : orig.inFlow || false;
1948
+ this.indent = indent != null ? indent : orig.indent;
1949
+ this.lineStart = lineStart != null ? lineStart : orig.lineStart;
1950
+ this.parent = parent != null ? parent : orig.parent || {};
1951
+ this.root = orig.root;
1952
+ this.src = orig.src;
1953
+ }
1954
+
1955
+ _createClass(ParseContext, [{
1956
+ key: "nodeStartsCollection",
1957
+ value: function nodeStartsCollection(node) {
1958
+ var inCollection = this.inCollection,
1959
+ inFlow = this.inFlow,
1960
+ src = this.src;
1961
+ if (inCollection || inFlow) return false;
1962
+ if (node instanceof CollectionItem) return true; // check for implicit key
1963
+
1964
+ var offset = node.range.end;
1965
+ if (src[offset] === '\n' || src[offset - 1] === '\n') return false;
1966
+ offset = Node.endOfWhiteSpace(src, offset);
1967
+ return src[offset] === ':';
1968
+ } // Anchor and tag are before type, which determines the node implementation
1969
+ // class; hence this intermediate step.
1970
+
1971
+ }, {
1972
+ key: "parseProps",
1973
+ value: function parseProps(offset) {
1974
+ var inFlow = this.inFlow,
1975
+ parent = this.parent,
1976
+ src = this.src;
1977
+ var props = [];
1978
+ var lineHasProps = false;
1979
+ offset = this.atLineStart ? Node.endOfIndent(src, offset) : Node.endOfWhiteSpace(src, offset);
1980
+ var ch = src[offset];
1981
+
1982
+ while (ch === Char.ANCHOR || ch === Char.COMMENT || ch === Char.TAG || ch === '\n') {
1983
+ if (ch === '\n') {
1984
+ var lineStart = offset + 1;
1985
+ var inEnd = Node.endOfIndent(src, lineStart);
1986
+ var indentDiff = inEnd - (lineStart + this.indent);
1987
+ var noIndicatorAsIndent = parent.type === Type.SEQ_ITEM && parent.context.atLineStart;
1988
+ if (!Node.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break;
1989
+ this.atLineStart = true;
1990
+ this.lineStart = lineStart;
1991
+ lineHasProps = false;
1992
+ offset = inEnd;
1993
+ } else if (ch === Char.COMMENT) {
1994
+ var end = Node.endOfLine(src, offset + 1);
1995
+ props.push(new Range(offset, end));
1996
+ offset = end;
1997
+ } else {
1998
+ var _end = Node.endOfIdentifier(src, offset + 1);
1999
+
2000
+ if (ch === Char.TAG && src[_end] === ',' && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(src.slice(offset + 1, _end + 13))) {
2001
+ // Let's presume we're dealing with a YAML 1.0 domain tag here, rather
2002
+ // than an empty but 'foo.bar' private-tagged node in a flow collection
2003
+ // followed without whitespace by a plain string starting with a year
2004
+ // or date divided by something.
2005
+ _end = Node.endOfIdentifier(src, _end + 5);
2006
+ }
2007
+
2008
+ props.push(new Range(offset, _end));
2009
+ lineHasProps = true;
2010
+ offset = Node.endOfWhiteSpace(src, _end);
2011
+ }
2012
+
2013
+ ch = src[offset];
2014
+ } // '- &a : b' has an anchor on an empty node
2015
+
2016
+
2017
+ if (lineHasProps && ch === ':' && Node.atBlank(src, offset + 1, true)) offset -= 1;
2018
+ var type = ParseContext.parseType(src, offset, inFlow);
2019
+ return {
2020
+ props: props,
2021
+ type: type,
2022
+ valueStart: offset
2023
+ };
2024
+ }
2025
+ /**
2026
+ * Parses a node from the source
2027
+ * @param {ParseContext} overlay
2028
+ * @param {number} start - Index of first non-whitespace character for the node
2029
+ * @returns {?Node} - null if at a document boundary
2030
+ */
2031
+
2032
+ }]);
2033
+
2034
+ return ParseContext;
2035
+ }();
2036
+
2037
+ // Published as 'yaml/parse-cst'
2038
+ function parse(src) {
2039
+ var cr = [];
2040
+
2041
+ if (src.indexOf('\r') !== -1) {
2042
+ src = src.replace(/\r\n?/g, function (match, offset) {
2043
+ if (match.length > 1) cr.push(offset);
2044
+ return '\n';
2045
+ });
2046
+ }
2047
+
2048
+ var documents = [];
2049
+ var offset = 0;
2050
+
2051
+ do {
2052
+ var doc = new Document();
2053
+ var context = new ParseContext({
2054
+ src: src
2055
+ });
2056
+ offset = doc.parse(context, offset);
2057
+ documents.push(doc);
2058
+ } while (offset < src.length);
2059
+
2060
+ documents.setOrigRanges = function () {
2061
+ if (cr.length === 0) return false;
2062
+
2063
+ for (var i = 1; i < cr.length; ++i) {
2064
+ cr[i] -= i;
2065
+ }
2066
+
2067
+ var crOffset = 0;
2068
+
2069
+ for (var _i = 0; _i < documents.length; ++_i) {
2070
+ crOffset = documents[_i].setOrigRanges(cr, crOffset);
2071
+ }
2072
+
2073
+ cr.splice(0, cr.length);
2074
+ return true;
2075
+ };
2076
+
2077
+ documents.toString = function () {
2078
+ return documents.join('...\n');
2079
+ };
2080
+
2081
+ return documents;
2082
+ }
2083
+
2084
+ export { Document as D, PlainValue as P, parse as p };