cdk8s-operator 0.1.407 → 0.1.409

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 (29) hide show
  1. package/.jsii +4 -4
  2. package/lib/operator.js +3 -3
  3. package/lib/server.js +1 -1
  4. package/node_modules/yaml/browser/dist/PlainValue-183afbad.js +751 -0
  5. package/node_modules/yaml/browser/dist/Schema-9530c078.js +467 -0
  6. package/node_modules/yaml/browser/dist/index.js +436 -746
  7. package/node_modules/yaml/browser/dist/legacy-exports.js +3 -3
  8. package/node_modules/yaml/browser/dist/parse-cst.js +1290 -1689
  9. package/node_modules/yaml/browser/dist/resolveSeq-67caf78a.js +1835 -0
  10. package/node_modules/yaml/browser/dist/types.js +4 -4
  11. package/node_modules/yaml/browser/dist/util.js +2 -2
  12. package/node_modules/yaml/browser/dist/warnings-5e4358fe.js +348 -0
  13. package/node_modules/yaml/dist/{Document-9b4560a1.js → Document-a8d0fbf9.js} +11 -131
  14. package/node_modules/yaml/dist/{PlainValue-ec8e588e.js → PlainValue-516d5bc2.js} +35 -146
  15. package/node_modules/yaml/dist/{Schema-88e323a7.js → Schema-bcc6c2d7.js} +10 -66
  16. package/node_modules/yaml/dist/index.js +5 -17
  17. package/node_modules/yaml/dist/legacy-exports.js +3 -3
  18. package/node_modules/yaml/dist/parse-cst.js +45 -291
  19. package/node_modules/yaml/dist/{resolveSeq-d03cb037.js → resolveSeq-95613e94.js} +44 -346
  20. package/node_modules/yaml/dist/test-events.js +28 -44
  21. package/node_modules/yaml/dist/types.js +4 -4
  22. package/node_modules/yaml/dist/util.js +2 -2
  23. package/node_modules/yaml/dist/{warnings-1000a372.js → warnings-793925ce.js} +16 -73
  24. package/node_modules/yaml/package.json +2 -3
  25. package/package.json +6 -6
  26. package/node_modules/yaml/browser/dist/PlainValue-b8036b75.js +0 -1275
  27. package/node_modules/yaml/browser/dist/Schema-e94716c8.js +0 -682
  28. package/node_modules/yaml/browser/dist/resolveSeq-492ab440.js +0 -2419
  29. package/node_modules/yaml/browser/dist/warnings-df54cb69.js +0 -499
@@ -1,1275 +0,0 @@
1
- function _typeof(obj) {
2
- "@babel/helpers - typeof";
3
-
4
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
5
- _typeof = function (obj) {
6
- return typeof obj;
7
- };
8
- } else {
9
- _typeof = function (obj) {
10
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
11
- };
12
- }
13
-
14
- return _typeof(obj);
15
- }
16
-
17
- function _classCallCheck(instance, Constructor) {
18
- if (!(instance instanceof Constructor)) {
19
- throw new TypeError("Cannot call a class as a function");
20
- }
21
- }
22
-
23
- function _defineProperties(target, props) {
24
- for (var i = 0; i < props.length; i++) {
25
- var descriptor = props[i];
26
- descriptor.enumerable = descriptor.enumerable || false;
27
- descriptor.configurable = true;
28
- if ("value" in descriptor) descriptor.writable = true;
29
- Object.defineProperty(target, descriptor.key, descriptor);
30
- }
31
- }
32
-
33
- function _createClass(Constructor, protoProps, staticProps) {
34
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
35
- if (staticProps) _defineProperties(Constructor, staticProps);
36
- return Constructor;
37
- }
38
-
39
- function _defineProperty(obj, key, value) {
40
- if (key in obj) {
41
- Object.defineProperty(obj, key, {
42
- value: value,
43
- enumerable: true,
44
- configurable: true,
45
- writable: true
46
- });
47
- } else {
48
- obj[key] = value;
49
- }
50
-
51
- return obj;
52
- }
53
-
54
- function _inherits(subClass, superClass) {
55
- if (typeof superClass !== "function" && superClass !== null) {
56
- throw new TypeError("Super expression must either be null or a function");
57
- }
58
-
59
- subClass.prototype = Object.create(superClass && superClass.prototype, {
60
- constructor: {
61
- value: subClass,
62
- writable: true,
63
- configurable: true
64
- }
65
- });
66
- if (superClass) _setPrototypeOf(subClass, superClass);
67
- }
68
-
69
- function _getPrototypeOf(o) {
70
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
71
- return o.__proto__ || Object.getPrototypeOf(o);
72
- };
73
- return _getPrototypeOf(o);
74
- }
75
-
76
- function _setPrototypeOf(o, p) {
77
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
78
- o.__proto__ = p;
79
- return o;
80
- };
81
-
82
- return _setPrototypeOf(o, p);
83
- }
84
-
85
- function _isNativeReflectConstruct() {
86
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
87
- if (Reflect.construct.sham) return false;
88
- if (typeof Proxy === "function") return true;
89
-
90
- try {
91
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
92
- return true;
93
- } catch (e) {
94
- return false;
95
- }
96
- }
97
-
98
- function _construct(Parent, args, Class) {
99
- if (_isNativeReflectConstruct()) {
100
- _construct = Reflect.construct;
101
- } else {
102
- _construct = function _construct(Parent, args, Class) {
103
- var a = [null];
104
- a.push.apply(a, args);
105
- var Constructor = Function.bind.apply(Parent, a);
106
- var instance = new Constructor();
107
- if (Class) _setPrototypeOf(instance, Class.prototype);
108
- return instance;
109
- };
110
- }
111
-
112
- return _construct.apply(null, arguments);
113
- }
114
-
115
- function _isNativeFunction(fn) {
116
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
117
- }
118
-
119
- function _wrapNativeSuper(Class) {
120
- var _cache = typeof Map === "function" ? new Map() : undefined;
121
-
122
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
123
- if (Class === null || !_isNativeFunction(Class)) return Class;
124
-
125
- if (typeof Class !== "function") {
126
- throw new TypeError("Super expression must either be null or a function");
127
- }
128
-
129
- if (typeof _cache !== "undefined") {
130
- if (_cache.has(Class)) return _cache.get(Class);
131
-
132
- _cache.set(Class, Wrapper);
133
- }
134
-
135
- function Wrapper() {
136
- return _construct(Class, arguments, _getPrototypeOf(this).constructor);
137
- }
138
-
139
- Wrapper.prototype = Object.create(Class.prototype, {
140
- constructor: {
141
- value: Wrapper,
142
- enumerable: false,
143
- writable: true,
144
- configurable: true
145
- }
146
- });
147
- return _setPrototypeOf(Wrapper, Class);
148
- };
149
-
150
- return _wrapNativeSuper(Class);
151
- }
152
-
153
- function _assertThisInitialized(self) {
154
- if (self === void 0) {
155
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
156
- }
157
-
158
- return self;
159
- }
160
-
161
- function _possibleConstructorReturn(self, call) {
162
- if (call && (typeof call === "object" || typeof call === "function")) {
163
- return call;
164
- }
165
-
166
- return _assertThisInitialized(self);
167
- }
168
-
169
- function _createSuper(Derived) {
170
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
171
-
172
- return function _createSuperInternal() {
173
- var Super = _getPrototypeOf(Derived),
174
- result;
175
-
176
- if (hasNativeReflectConstruct) {
177
- var NewTarget = _getPrototypeOf(this).constructor;
178
-
179
- result = Reflect.construct(Super, arguments, NewTarget);
180
- } else {
181
- result = Super.apply(this, arguments);
182
- }
183
-
184
- return _possibleConstructorReturn(this, result);
185
- };
186
- }
187
-
188
- function _superPropBase(object, property) {
189
- while (!Object.prototype.hasOwnProperty.call(object, property)) {
190
- object = _getPrototypeOf(object);
191
- if (object === null) break;
192
- }
193
-
194
- return object;
195
- }
196
-
197
- function _get(target, property, receiver) {
198
- if (typeof Reflect !== "undefined" && Reflect.get) {
199
- _get = Reflect.get;
200
- } else {
201
- _get = function _get(target, property, receiver) {
202
- var base = _superPropBase(target, property);
203
-
204
- if (!base) return;
205
- var desc = Object.getOwnPropertyDescriptor(base, property);
206
-
207
- if (desc.get) {
208
- return desc.get.call(receiver);
209
- }
210
-
211
- return desc.value;
212
- };
213
- }
214
-
215
- return _get(target, property, receiver || target);
216
- }
217
-
218
- function _slicedToArray(arr, i) {
219
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
220
- }
221
-
222
- function _toArray(arr) {
223
- return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
224
- }
225
-
226
- function _arrayWithHoles(arr) {
227
- if (Array.isArray(arr)) return arr;
228
- }
229
-
230
- function _iterableToArray(iter) {
231
- if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
232
- }
233
-
234
- function _iterableToArrayLimit(arr, i) {
235
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
236
- var _arr = [];
237
- var _n = true;
238
- var _d = false;
239
- var _e = undefined;
240
-
241
- try {
242
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
243
- _arr.push(_s.value);
244
-
245
- if (i && _arr.length === i) break;
246
- }
247
- } catch (err) {
248
- _d = true;
249
- _e = err;
250
- } finally {
251
- try {
252
- if (!_n && _i["return"] != null) _i["return"]();
253
- } finally {
254
- if (_d) throw _e;
255
- }
256
- }
257
-
258
- return _arr;
259
- }
260
-
261
- function _unsupportedIterableToArray(o, minLen) {
262
- if (!o) return;
263
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
264
- var n = Object.prototype.toString.call(o).slice(8, -1);
265
- if (n === "Object" && o.constructor) n = o.constructor.name;
266
- if (n === "Map" || n === "Set") return Array.from(o);
267
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
268
- }
269
-
270
- function _arrayLikeToArray(arr, len) {
271
- if (len == null || len > arr.length) len = arr.length;
272
-
273
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
274
-
275
- return arr2;
276
- }
277
-
278
- function _nonIterableRest() {
279
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
280
- }
281
-
282
- function _createForOfIteratorHelper(o, allowArrayLike) {
283
- var it;
284
-
285
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
286
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
287
- if (it) o = it;
288
- var i = 0;
289
-
290
- var F = function () {};
291
-
292
- return {
293
- s: F,
294
- n: function () {
295
- if (i >= o.length) return {
296
- done: true
297
- };
298
- return {
299
- done: false,
300
- value: o[i++]
301
- };
302
- },
303
- e: function (e) {
304
- throw e;
305
- },
306
- f: F
307
- };
308
- }
309
-
310
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
311
- }
312
-
313
- var normalCompletion = true,
314
- didErr = false,
315
- err;
316
- return {
317
- s: function () {
318
- it = o[Symbol.iterator]();
319
- },
320
- n: function () {
321
- var step = it.next();
322
- normalCompletion = step.done;
323
- return step;
324
- },
325
- e: function (e) {
326
- didErr = true;
327
- err = e;
328
- },
329
- f: function () {
330
- try {
331
- if (!normalCompletion && it.return != null) it.return();
332
- } finally {
333
- if (didErr) throw err;
334
- }
335
- }
336
- };
337
- }
338
-
339
- var Char = {
340
- ANCHOR: '&',
341
- COMMENT: '#',
342
- TAG: '!',
343
- DIRECTIVES_END: '-',
344
- DOCUMENT_END: '.'
345
- };
346
- var Type = {
347
- ALIAS: 'ALIAS',
348
- BLANK_LINE: 'BLANK_LINE',
349
- BLOCK_FOLDED: 'BLOCK_FOLDED',
350
- BLOCK_LITERAL: 'BLOCK_LITERAL',
351
- COMMENT: 'COMMENT',
352
- DIRECTIVE: 'DIRECTIVE',
353
- DOCUMENT: 'DOCUMENT',
354
- FLOW_MAP: 'FLOW_MAP',
355
- FLOW_SEQ: 'FLOW_SEQ',
356
- MAP: 'MAP',
357
- MAP_KEY: 'MAP_KEY',
358
- MAP_VALUE: 'MAP_VALUE',
359
- PLAIN: 'PLAIN',
360
- QUOTE_DOUBLE: 'QUOTE_DOUBLE',
361
- QUOTE_SINGLE: 'QUOTE_SINGLE',
362
- SEQ: 'SEQ',
363
- SEQ_ITEM: 'SEQ_ITEM'
364
- };
365
- var defaultTagPrefix = 'tag:yaml.org,2002:';
366
- var defaultTags = {
367
- MAP: 'tag:yaml.org,2002:map',
368
- SEQ: 'tag:yaml.org,2002:seq',
369
- STR: 'tag:yaml.org,2002:str'
370
- };
371
-
372
- function findLineStarts(src) {
373
- var ls = [0];
374
- var offset = src.indexOf('\n');
375
-
376
- while (offset !== -1) {
377
- offset += 1;
378
- ls.push(offset);
379
- offset = src.indexOf('\n', offset);
380
- }
381
-
382
- return ls;
383
- }
384
-
385
- function getSrcInfo(cst) {
386
- var lineStarts, src;
387
-
388
- if (typeof cst === 'string') {
389
- lineStarts = findLineStarts(cst);
390
- src = cst;
391
- } else {
392
- if (Array.isArray(cst)) cst = cst[0];
393
-
394
- if (cst && cst.context) {
395
- if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src);
396
- lineStarts = cst.lineStarts;
397
- src = cst.context.src;
398
- }
399
- }
400
-
401
- return {
402
- lineStarts: lineStarts,
403
- src: src
404
- };
405
- }
406
- /**
407
- * @typedef {Object} LinePos - One-indexed position in the source
408
- * @property {number} line
409
- * @property {number} col
410
- */
411
-
412
- /**
413
- * Determine the line/col position matching a character offset.
414
- *
415
- * Accepts a source string or a CST document as the second parameter. With
416
- * the latter, starting indices for lines are cached in the document as
417
- * `lineStarts: number[]`.
418
- *
419
- * Returns a one-indexed `{ line, col }` location if found, or
420
- * `undefined` otherwise.
421
- *
422
- * @param {number} offset
423
- * @param {string|Document|Document[]} cst
424
- * @returns {?LinePos}
425
- */
426
-
427
-
428
- function getLinePos(offset, cst) {
429
- if (typeof offset !== 'number' || offset < 0) return null;
430
-
431
- var _getSrcInfo = getSrcInfo(cst),
432
- lineStarts = _getSrcInfo.lineStarts,
433
- src = _getSrcInfo.src;
434
-
435
- if (!lineStarts || !src || offset > src.length) return null;
436
-
437
- for (var i = 0; i < lineStarts.length; ++i) {
438
- var start = lineStarts[i];
439
-
440
- if (offset < start) {
441
- return {
442
- line: i,
443
- col: offset - lineStarts[i - 1] + 1
444
- };
445
- }
446
-
447
- if (offset === start) return {
448
- line: i + 1,
449
- col: 1
450
- };
451
- }
452
-
453
- var line = lineStarts.length;
454
- return {
455
- line: line,
456
- col: offset - lineStarts[line - 1] + 1
457
- };
458
- }
459
- /**
460
- * Get a specified line from the source.
461
- *
462
- * Accepts a source string or a CST document as the second parameter. With
463
- * the latter, starting indices for lines are cached in the document as
464
- * `lineStarts: number[]`.
465
- *
466
- * Returns the line as a string if found, or `null` otherwise.
467
- *
468
- * @param {number} line One-indexed line number
469
- * @param {string|Document|Document[]} cst
470
- * @returns {?string}
471
- */
472
-
473
- function getLine(line, cst) {
474
- var _getSrcInfo2 = getSrcInfo(cst),
475
- lineStarts = _getSrcInfo2.lineStarts,
476
- src = _getSrcInfo2.src;
477
-
478
- if (!lineStarts || !(line >= 1) || line > lineStarts.length) return null;
479
- var start = lineStarts[line - 1];
480
- var end = lineStarts[line]; // undefined for last line; that's ok for slice()
481
-
482
- while (end && end > start && src[end - 1] === '\n') {
483
- --end;
484
- }
485
-
486
- return src.slice(start, end);
487
- }
488
- /**
489
- * Pretty-print the starting line from the source indicated by the range `pos`
490
- *
491
- * Trims output to `maxWidth` chars while keeping the starting column visible,
492
- * using `…` at either end to indicate dropped characters.
493
- *
494
- * Returns a two-line string (or `null`) with `\n` as separator; the second line
495
- * will hold appropriately indented `^` marks indicating the column range.
496
- *
497
- * @param {Object} pos
498
- * @param {LinePos} pos.start
499
- * @param {LinePos} [pos.end]
500
- * @param {string|Document|Document[]*} cst
501
- * @param {number} [maxWidth=80]
502
- * @returns {?string}
503
- */
504
-
505
- function getPrettyContext(_ref, cst) {
506
- var start = _ref.start,
507
- end = _ref.end;
508
- var maxWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 80;
509
- var src = getLine(start.line, cst);
510
- if (!src) return null;
511
- var col = start.col;
512
-
513
- if (src.length > maxWidth) {
514
- if (col <= maxWidth - 10) {
515
- src = src.substr(0, maxWidth - 1) + '…';
516
- } else {
517
- var halfWidth = Math.round(maxWidth / 2);
518
- if (src.length > col + halfWidth) src = src.substr(0, col + halfWidth - 1) + '…';
519
- col -= src.length - maxWidth;
520
- src = '…' + src.substr(1 - maxWidth);
521
- }
522
- }
523
-
524
- var errLen = 1;
525
- var errEnd = '';
526
-
527
- if (end) {
528
- if (end.line === start.line && col + (end.col - start.col) <= maxWidth + 1) {
529
- errLen = end.col - start.col;
530
- } else {
531
- errLen = Math.min(src.length + 1, maxWidth) - col;
532
- errEnd = '…';
533
- }
534
- }
535
-
536
- var offset = col > 1 ? ' '.repeat(col - 1) : '';
537
- var err = '^'.repeat(errLen);
538
- return "".concat(src, "\n").concat(offset).concat(err).concat(errEnd);
539
- }
540
-
541
- var Range = /*#__PURE__*/function () {
542
- function Range(start, end) {
543
- _classCallCheck(this, Range);
544
-
545
- this.start = start;
546
- this.end = end || start;
547
- }
548
-
549
- _createClass(Range, [{
550
- key: "isEmpty",
551
- value: function isEmpty() {
552
- return typeof this.start !== 'number' || !this.end || this.end <= this.start;
553
- }
554
- /**
555
- * Set `origStart` and `origEnd` to point to the original source range for
556
- * this node, which may differ due to dropped CR characters.
557
- *
558
- * @param {number[]} cr - Positions of dropped CR characters
559
- * @param {number} offset - Starting index of `cr` from the last call
560
- * @returns {number} - The next offset, matching the one found for `origStart`
561
- */
562
-
563
- }, {
564
- key: "setOrigRange",
565
- value: function setOrigRange(cr, offset) {
566
- var start = this.start,
567
- end = this.end;
568
-
569
- if (cr.length === 0 || end <= cr[0]) {
570
- this.origStart = start;
571
- this.origEnd = end;
572
- return offset;
573
- }
574
-
575
- var i = offset;
576
-
577
- while (i < cr.length) {
578
- if (cr[i] > start) break;else ++i;
579
- }
580
-
581
- this.origStart = start + i;
582
- var nextOffset = i;
583
-
584
- while (i < cr.length) {
585
- // if end was at \n, it should now be at \r
586
- if (cr[i] >= end) break;else ++i;
587
- }
588
-
589
- this.origEnd = end + i;
590
- return nextOffset;
591
- }
592
- }], [{
593
- key: "copy",
594
- value: function copy(orig) {
595
- return new Range(orig.start, orig.end);
596
- }
597
- }]);
598
-
599
- return Range;
600
- }();
601
-
602
- /** Root class of all nodes */
603
-
604
- var Node = /*#__PURE__*/function () {
605
- function Node(type, props, context) {
606
- _classCallCheck(this, Node);
607
-
608
- Object.defineProperty(this, 'context', {
609
- value: context || null,
610
- writable: true
611
- });
612
- this.error = null;
613
- this.range = null;
614
- this.valueRange = null;
615
- this.props = props || [];
616
- this.type = type;
617
- this.value = null;
618
- }
619
-
620
- _createClass(Node, [{
621
- key: "getPropValue",
622
- value: function getPropValue(idx, key, skipKey) {
623
- if (!this.context) return null;
624
- var src = this.context.src;
625
- var prop = this.props[idx];
626
- return prop && src[prop.start] === key ? src.slice(prop.start + (skipKey ? 1 : 0), prop.end) : null;
627
- }
628
- }, {
629
- key: "anchor",
630
- get: function get() {
631
- for (var i = 0; i < this.props.length; ++i) {
632
- var anchor = this.getPropValue(i, Char.ANCHOR, true);
633
- if (anchor != null) return anchor;
634
- }
635
-
636
- return null;
637
- }
638
- }, {
639
- key: "comment",
640
- get: function get() {
641
- var comments = [];
642
-
643
- for (var i = 0; i < this.props.length; ++i) {
644
- var comment = this.getPropValue(i, Char.COMMENT, true);
645
- if (comment != null) comments.push(comment);
646
- }
647
-
648
- return comments.length > 0 ? comments.join('\n') : null;
649
- }
650
- }, {
651
- key: "commentHasRequiredWhitespace",
652
- value: function commentHasRequiredWhitespace(start) {
653
- var src = this.context.src;
654
- if (this.header && start === this.header.end) return false;
655
- if (!this.valueRange) return false;
656
- var end = this.valueRange.end;
657
- return start !== end || Node.atBlank(src, end - 1);
658
- }
659
- }, {
660
- key: "hasComment",
661
- get: function get() {
662
- if (this.context) {
663
- var src = this.context.src;
664
-
665
- for (var i = 0; i < this.props.length; ++i) {
666
- if (src[this.props[i].start] === Char.COMMENT) return true;
667
- }
668
- }
669
-
670
- return false;
671
- }
672
- }, {
673
- key: "hasProps",
674
- get: function get() {
675
- if (this.context) {
676
- var src = this.context.src;
677
-
678
- for (var i = 0; i < this.props.length; ++i) {
679
- if (src[this.props[i].start] !== Char.COMMENT) return true;
680
- }
681
- }
682
-
683
- return false;
684
- }
685
- }, {
686
- key: "includesTrailingLines",
687
- get: function get() {
688
- return false;
689
- }
690
- }, {
691
- key: "jsonLike",
692
- get: function get() {
693
- var jsonLikeTypes = [Type.FLOW_MAP, Type.FLOW_SEQ, Type.QUOTE_DOUBLE, Type.QUOTE_SINGLE];
694
- return jsonLikeTypes.indexOf(this.type) !== -1;
695
- }
696
- }, {
697
- key: "rangeAsLinePos",
698
- get: function get() {
699
- if (!this.range || !this.context) return undefined;
700
- var start = getLinePos(this.range.start, this.context.root);
701
- if (!start) return undefined;
702
- var end = getLinePos(this.range.end, this.context.root);
703
- return {
704
- start: start,
705
- end: end
706
- };
707
- }
708
- }, {
709
- key: "rawValue",
710
- get: function get() {
711
- if (!this.valueRange || !this.context) return null;
712
- var _this$valueRange = this.valueRange,
713
- start = _this$valueRange.start,
714
- end = _this$valueRange.end;
715
- return this.context.src.slice(start, end);
716
- }
717
- }, {
718
- key: "tag",
719
- get: function get() {
720
- for (var i = 0; i < this.props.length; ++i) {
721
- var tag = this.getPropValue(i, Char.TAG, false);
722
-
723
- if (tag != null) {
724
- if (tag[1] === '<') {
725
- return {
726
- verbatim: tag.slice(2, -1)
727
- };
728
- } else {
729
- // eslint-disable-next-line no-unused-vars
730
- var _tag$match = tag.match(/^(.*!)([^!]*)$/),
731
- _tag$match2 = _slicedToArray(_tag$match, 3);
732
- _tag$match2[0];
733
- var handle = _tag$match2[1],
734
- suffix = _tag$match2[2];
735
-
736
- return {
737
- handle: handle,
738
- suffix: suffix
739
- };
740
- }
741
- }
742
- }
743
-
744
- return null;
745
- }
746
- }, {
747
- key: "valueRangeContainsNewline",
748
- get: function get() {
749
- if (!this.valueRange || !this.context) return false;
750
- var _this$valueRange2 = this.valueRange,
751
- start = _this$valueRange2.start,
752
- end = _this$valueRange2.end;
753
- var src = this.context.src;
754
-
755
- for (var i = start; i < end; ++i) {
756
- if (src[i] === '\n') return true;
757
- }
758
-
759
- return false;
760
- }
761
- }, {
762
- key: "parseComment",
763
- value: function parseComment(start) {
764
- var src = this.context.src;
765
-
766
- if (src[start] === Char.COMMENT) {
767
- var end = Node.endOfLine(src, start + 1);
768
- var commentRange = new Range(start, end);
769
- this.props.push(commentRange);
770
- return end;
771
- }
772
-
773
- return start;
774
- }
775
- /**
776
- * Populates the `origStart` and `origEnd` values of all ranges for this
777
- * node. Extended by child classes to handle descendant nodes.
778
- *
779
- * @param {number[]} cr - Positions of dropped CR characters
780
- * @param {number} offset - Starting index of `cr` from the last call
781
- * @returns {number} - The next offset, matching the one found for `origStart`
782
- */
783
-
784
- }, {
785
- key: "setOrigRanges",
786
- value: function setOrigRanges(cr, offset) {
787
- if (this.range) offset = this.range.setOrigRange(cr, offset);
788
- if (this.valueRange) this.valueRange.setOrigRange(cr, offset);
789
- this.props.forEach(function (prop) {
790
- return prop.setOrigRange(cr, offset);
791
- });
792
- return offset;
793
- }
794
- }, {
795
- key: "toString",
796
- value: function toString() {
797
- var src = this.context.src,
798
- range = this.range,
799
- value = this.value;
800
- if (value != null) return value;
801
- var str = src.slice(range.start, range.end);
802
- return Node.addStringTerminator(src, range.end, str);
803
- }
804
- }], [{
805
- key: "addStringTerminator",
806
- value: function addStringTerminator(src, offset, str) {
807
- if (str[str.length - 1] === '\n') return str;
808
- var next = Node.endOfWhiteSpace(src, offset);
809
- return next >= src.length || src[next] === '\n' ? str + '\n' : str;
810
- } // ^(---|...)
811
-
812
- }, {
813
- key: "atDocumentBoundary",
814
- value: function atDocumentBoundary(src, offset, sep) {
815
- var ch0 = src[offset];
816
- if (!ch0) return true;
817
- var prev = src[offset - 1];
818
- if (prev && prev !== '\n') return false;
819
-
820
- if (sep) {
821
- if (ch0 !== sep) return false;
822
- } else {
823
- if (ch0 !== Char.DIRECTIVES_END && ch0 !== Char.DOCUMENT_END) return false;
824
- }
825
-
826
- var ch1 = src[offset + 1];
827
- var ch2 = src[offset + 2];
828
- if (ch1 !== ch0 || ch2 !== ch0) return false;
829
- var ch3 = src[offset + 3];
830
- return !ch3 || ch3 === '\n' || ch3 === '\t' || ch3 === ' ';
831
- }
832
- }, {
833
- key: "endOfIdentifier",
834
- value: function endOfIdentifier(src, offset) {
835
- var ch = src[offset];
836
- var isVerbatim = ch === '<';
837
- var notOk = isVerbatim ? ['\n', '\t', ' ', '>'] : ['\n', '\t', ' ', '[', ']', '{', '}', ','];
838
-
839
- while (ch && notOk.indexOf(ch) === -1) {
840
- ch = src[offset += 1];
841
- }
842
-
843
- if (isVerbatim && ch === '>') offset += 1;
844
- return offset;
845
- }
846
- }, {
847
- key: "endOfIndent",
848
- value: function endOfIndent(src, offset) {
849
- var ch = src[offset];
850
-
851
- while (ch === ' ') {
852
- ch = src[offset += 1];
853
- }
854
-
855
- return offset;
856
- }
857
- }, {
858
- key: "endOfLine",
859
- value: function endOfLine(src, offset) {
860
- var ch = src[offset];
861
-
862
- while (ch && ch !== '\n') {
863
- ch = src[offset += 1];
864
- }
865
-
866
- return offset;
867
- }
868
- }, {
869
- key: "endOfWhiteSpace",
870
- value: function endOfWhiteSpace(src, offset) {
871
- var ch = src[offset];
872
-
873
- while (ch === '\t' || ch === ' ') {
874
- ch = src[offset += 1];
875
- }
876
-
877
- return offset;
878
- }
879
- }, {
880
- key: "startOfLine",
881
- value: function startOfLine(src, offset) {
882
- var ch = src[offset - 1];
883
- if (ch === '\n') return offset;
884
-
885
- while (ch && ch !== '\n') {
886
- ch = src[offset -= 1];
887
- }
888
-
889
- return offset + 1;
890
- }
891
- /**
892
- * End of indentation, or null if the line's indent level is not more
893
- * than `indent`
894
- *
895
- * @param {string} src
896
- * @param {number} indent
897
- * @param {number} lineStart
898
- * @returns {?number}
899
- */
900
-
901
- }, {
902
- key: "endOfBlockIndent",
903
- value: function endOfBlockIndent(src, indent, lineStart) {
904
- var inEnd = Node.endOfIndent(src, lineStart);
905
-
906
- if (inEnd > lineStart + indent) {
907
- return inEnd;
908
- } else {
909
- var wsEnd = Node.endOfWhiteSpace(src, inEnd);
910
- var ch = src[wsEnd];
911
- if (!ch || ch === '\n') return wsEnd;
912
- }
913
-
914
- return null;
915
- }
916
- }, {
917
- key: "atBlank",
918
- value: function atBlank(src, offset, endAsBlank) {
919
- var ch = src[offset];
920
- return ch === '\n' || ch === '\t' || ch === ' ' || endAsBlank && !ch;
921
- }
922
- }, {
923
- key: "nextNodeIsIndented",
924
- value: function nextNodeIsIndented(ch, indentDiff, indicatorAsIndent) {
925
- if (!ch || indentDiff < 0) return false;
926
- if (indentDiff > 0) return true;
927
- return indicatorAsIndent && ch === '-';
928
- } // should be at line or string end, or at next non-whitespace char
929
-
930
- }, {
931
- key: "normalizeOffset",
932
- value: function normalizeOffset(src, offset) {
933
- var ch = src[offset];
934
- return !ch ? offset : ch !== '\n' && src[offset - 1] === '\n' ? offset - 1 : Node.endOfWhiteSpace(src, offset);
935
- } // fold single newline into space, multiple newlines to N - 1 newlines
936
- // presumes src[offset] === '\n'
937
-
938
- }, {
939
- key: "foldNewline",
940
- value: function foldNewline(src, offset, indent) {
941
- var inCount = 0;
942
- var error = false;
943
- var fold = '';
944
- var ch = src[offset + 1];
945
-
946
- while (ch === ' ' || ch === '\t' || ch === '\n') {
947
- switch (ch) {
948
- case '\n':
949
- inCount = 0;
950
- offset += 1;
951
- fold += '\n';
952
- break;
953
-
954
- case '\t':
955
- if (inCount <= indent) error = true;
956
- offset = Node.endOfWhiteSpace(src, offset + 2) - 1;
957
- break;
958
-
959
- case ' ':
960
- inCount += 1;
961
- offset += 1;
962
- break;
963
- }
964
-
965
- ch = src[offset + 1];
966
- }
967
-
968
- if (!fold) fold = ' ';
969
- if (ch && inCount <= indent) error = true;
970
- return {
971
- fold: fold,
972
- offset: offset,
973
- error: error
974
- };
975
- }
976
- }]);
977
-
978
- return Node;
979
- }();
980
-
981
- var YAMLError = /*#__PURE__*/function (_Error) {
982
- _inherits(YAMLError, _Error);
983
-
984
- var _super = _createSuper(YAMLError);
985
-
986
- function YAMLError(name, source, message) {
987
- var _this;
988
-
989
- _classCallCheck(this, YAMLError);
990
-
991
- if (!message || !(source instanceof Node)) throw new Error("Invalid arguments for new ".concat(name));
992
- _this = _super.call(this);
993
- _this.name = name;
994
- _this.message = message;
995
- _this.source = source;
996
- return _this;
997
- }
998
-
999
- _createClass(YAMLError, [{
1000
- key: "makePretty",
1001
- value: function makePretty() {
1002
- if (!this.source) return;
1003
- this.nodeType = this.source.type;
1004
- var cst = this.source.context && this.source.context.root;
1005
-
1006
- if (typeof this.offset === 'number') {
1007
- this.range = new Range(this.offset, this.offset + 1);
1008
- var start = cst && getLinePos(this.offset, cst);
1009
-
1010
- if (start) {
1011
- var end = {
1012
- line: start.line,
1013
- col: start.col + 1
1014
- };
1015
- this.linePos = {
1016
- start: start,
1017
- end: end
1018
- };
1019
- }
1020
-
1021
- delete this.offset;
1022
- } else {
1023
- this.range = this.source.range;
1024
- this.linePos = this.source.rangeAsLinePos;
1025
- }
1026
-
1027
- if (this.linePos) {
1028
- var _this$linePos$start = this.linePos.start,
1029
- line = _this$linePos$start.line,
1030
- col = _this$linePos$start.col;
1031
- this.message += " at line ".concat(line, ", column ").concat(col);
1032
- var ctx = cst && getPrettyContext(this.linePos, cst);
1033
- if (ctx) this.message += ":\n\n".concat(ctx, "\n");
1034
- }
1035
-
1036
- delete this.source;
1037
- }
1038
- }]);
1039
-
1040
- return YAMLError;
1041
- }( /*#__PURE__*/_wrapNativeSuper(Error));
1042
- var YAMLReferenceError = /*#__PURE__*/function (_YAMLError) {
1043
- _inherits(YAMLReferenceError, _YAMLError);
1044
-
1045
- var _super2 = _createSuper(YAMLReferenceError);
1046
-
1047
- function YAMLReferenceError(source, message) {
1048
- _classCallCheck(this, YAMLReferenceError);
1049
-
1050
- return _super2.call(this, 'YAMLReferenceError', source, message);
1051
- }
1052
-
1053
- return YAMLReferenceError;
1054
- }(YAMLError);
1055
- var YAMLSemanticError = /*#__PURE__*/function (_YAMLError2) {
1056
- _inherits(YAMLSemanticError, _YAMLError2);
1057
-
1058
- var _super3 = _createSuper(YAMLSemanticError);
1059
-
1060
- function YAMLSemanticError(source, message) {
1061
- _classCallCheck(this, YAMLSemanticError);
1062
-
1063
- return _super3.call(this, 'YAMLSemanticError', source, message);
1064
- }
1065
-
1066
- return YAMLSemanticError;
1067
- }(YAMLError);
1068
- var YAMLSyntaxError = /*#__PURE__*/function (_YAMLError3) {
1069
- _inherits(YAMLSyntaxError, _YAMLError3);
1070
-
1071
- var _super4 = _createSuper(YAMLSyntaxError);
1072
-
1073
- function YAMLSyntaxError(source, message) {
1074
- _classCallCheck(this, YAMLSyntaxError);
1075
-
1076
- return _super4.call(this, 'YAMLSyntaxError', source, message);
1077
- }
1078
-
1079
- return YAMLSyntaxError;
1080
- }(YAMLError);
1081
- var YAMLWarning = /*#__PURE__*/function (_YAMLError4) {
1082
- _inherits(YAMLWarning, _YAMLError4);
1083
-
1084
- var _super5 = _createSuper(YAMLWarning);
1085
-
1086
- function YAMLWarning(source, message) {
1087
- _classCallCheck(this, YAMLWarning);
1088
-
1089
- return _super5.call(this, 'YAMLWarning', source, message);
1090
- }
1091
-
1092
- return YAMLWarning;
1093
- }(YAMLError);
1094
-
1095
- var PlainValue = /*#__PURE__*/function (_Node) {
1096
- _inherits(PlainValue, _Node);
1097
-
1098
- var _super = _createSuper(PlainValue);
1099
-
1100
- function PlainValue() {
1101
- _classCallCheck(this, PlainValue);
1102
-
1103
- return _super.apply(this, arguments);
1104
- }
1105
-
1106
- _createClass(PlainValue, [{
1107
- key: "strValue",
1108
- get: function get() {
1109
- if (!this.valueRange || !this.context) return null;
1110
- var _this$valueRange = this.valueRange,
1111
- start = _this$valueRange.start,
1112
- end = _this$valueRange.end;
1113
- var src = this.context.src;
1114
- var ch = src[end - 1];
1115
-
1116
- while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) {
1117
- ch = src[--end - 1];
1118
- }
1119
-
1120
- var str = '';
1121
-
1122
- for (var i = start; i < end; ++i) {
1123
- var _ch = src[i];
1124
-
1125
- if (_ch === '\n') {
1126
- var _Node$foldNewline = Node.foldNewline(src, i, -1),
1127
- fold = _Node$foldNewline.fold,
1128
- offset = _Node$foldNewline.offset;
1129
-
1130
- str += fold;
1131
- i = offset;
1132
- } else if (_ch === ' ' || _ch === '\t') {
1133
- // trim trailing whitespace
1134
- var wsStart = i;
1135
- var next = src[i + 1];
1136
-
1137
- while (i < end && (next === ' ' || next === '\t')) {
1138
- i += 1;
1139
- next = src[i + 1];
1140
- }
1141
-
1142
- if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : _ch;
1143
- } else {
1144
- str += _ch;
1145
- }
1146
- }
1147
-
1148
- var ch0 = src[start];
1149
-
1150
- switch (ch0) {
1151
- case '\t':
1152
- {
1153
- var msg = 'Plain value cannot start with a tab character';
1154
- var errors = [new YAMLSemanticError(this, msg)];
1155
- return {
1156
- errors: errors,
1157
- str: str
1158
- };
1159
- }
1160
-
1161
- case '@':
1162
- case '`':
1163
- {
1164
- var _msg = "Plain value cannot start with reserved character ".concat(ch0);
1165
-
1166
- var _errors = [new YAMLSemanticError(this, _msg)];
1167
- return {
1168
- errors: _errors,
1169
- str: str
1170
- };
1171
- }
1172
-
1173
- default:
1174
- return str;
1175
- }
1176
- }
1177
- }, {
1178
- key: "parseBlockValue",
1179
- value: function parseBlockValue(start) {
1180
- var _this$context = this.context,
1181
- indent = _this$context.indent,
1182
- inFlow = _this$context.inFlow,
1183
- src = _this$context.src;
1184
- var offset = start;
1185
- var valueEnd = start;
1186
-
1187
- for (var ch = src[offset]; ch === '\n'; ch = src[offset]) {
1188
- if (Node.atDocumentBoundary(src, offset + 1)) break;
1189
- var end = Node.endOfBlockIndent(src, indent, offset + 1);
1190
- if (end === null || src[end] === '#') break;
1191
-
1192
- if (src[end] === '\n') {
1193
- offset = end;
1194
- } else {
1195
- valueEnd = PlainValue.endOfLine(src, end, inFlow);
1196
- offset = valueEnd;
1197
- }
1198
- }
1199
-
1200
- if (this.valueRange.isEmpty()) this.valueRange.start = start;
1201
- this.valueRange.end = valueEnd;
1202
- return valueEnd;
1203
- }
1204
- /**
1205
- * Parses a plain value from the source
1206
- *
1207
- * Accepted forms are:
1208
- * ```
1209
- * #comment
1210
- *
1211
- * first line
1212
- *
1213
- * first line #comment
1214
- *
1215
- * first line
1216
- * block
1217
- * lines
1218
- *
1219
- * #comment
1220
- * block
1221
- * lines
1222
- * ```
1223
- * where block lines are empty or have an indent level greater than `indent`.
1224
- *
1225
- * @param {ParseContext} context
1226
- * @param {number} start - Index of first character
1227
- * @returns {number} - Index of the character after this scalar, may be `\n`
1228
- */
1229
-
1230
- }, {
1231
- key: "parse",
1232
- value: function parse(context, start) {
1233
- this.context = context;
1234
- var inFlow = context.inFlow,
1235
- src = context.src;
1236
- var offset = start;
1237
- var ch = src[offset];
1238
-
1239
- if (ch && ch !== '#' && ch !== '\n') {
1240
- offset = PlainValue.endOfLine(src, start, inFlow);
1241
- }
1242
-
1243
- this.valueRange = new Range(start, offset);
1244
- offset = Node.endOfWhiteSpace(src, offset);
1245
- offset = this.parseComment(offset);
1246
-
1247
- if (!this.hasComment || this.valueRange.isEmpty()) {
1248
- offset = this.parseBlockValue(offset);
1249
- }
1250
-
1251
- return offset;
1252
- }
1253
- }], [{
1254
- key: "endOfLine",
1255
- value: function endOfLine(src, start, inFlow) {
1256
- var ch = src[start];
1257
- var offset = start;
1258
-
1259
- while (ch && ch !== '\n') {
1260
- if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break;
1261
- var next = src[offset + 1];
1262
- if (ch === ':' && (!next || next === '\n' || next === '\t' || next === ' ' || inFlow && next === ',')) break;
1263
- if ((ch === ' ' || ch === '\t') && next === '#') break;
1264
- offset += 1;
1265
- ch = next;
1266
- }
1267
-
1268
- return offset;
1269
- }
1270
- }]);
1271
-
1272
- return PlainValue;
1273
- }(Node);
1274
-
1275
- export { Char as C, Node as N, PlainValue as P, Range as R, Type as T, YAMLSyntaxError as Y, _createForOfIteratorHelper as _, _typeof as a, _createClass as b, _classCallCheck as c, defaultTagPrefix as d, _defineProperty as e, YAMLWarning as f, YAMLSemanticError as g, _slicedToArray as h, YAMLError as i, _inherits as j, _createSuper as k, _get as l, _getPrototypeOf as m, defaultTags as n, YAMLReferenceError as o, _assertThisInitialized as p, _toArray as q, _possibleConstructorReturn as r };