cdk8s-operator 0.1.407 → 0.1.408
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +3 -3
- package/lib/operator.js +1 -1
- package/lib/server.js +1 -1
- package/node_modules/yaml/browser/dist/PlainValue-183afbad.js +751 -0
- package/node_modules/yaml/browser/dist/Schema-9530c078.js +467 -0
- package/node_modules/yaml/browser/dist/index.js +436 -746
- package/node_modules/yaml/browser/dist/legacy-exports.js +3 -3
- package/node_modules/yaml/browser/dist/parse-cst.js +1290 -1689
- package/node_modules/yaml/browser/dist/resolveSeq-67caf78a.js +1835 -0
- package/node_modules/yaml/browser/dist/types.js +4 -4
- package/node_modules/yaml/browser/dist/util.js +2 -2
- package/node_modules/yaml/browser/dist/warnings-5e4358fe.js +348 -0
- package/node_modules/yaml/dist/{Document-9b4560a1.js → Document-a8d0fbf9.js} +11 -131
- package/node_modules/yaml/dist/{PlainValue-ec8e588e.js → PlainValue-516d5bc2.js} +35 -146
- package/node_modules/yaml/dist/{Schema-88e323a7.js → Schema-bcc6c2d7.js} +10 -66
- package/node_modules/yaml/dist/index.js +5 -17
- package/node_modules/yaml/dist/legacy-exports.js +3 -3
- package/node_modules/yaml/dist/parse-cst.js +45 -291
- package/node_modules/yaml/dist/{resolveSeq-d03cb037.js → resolveSeq-95613e94.js} +44 -346
- package/node_modules/yaml/dist/test-events.js +28 -44
- package/node_modules/yaml/dist/types.js +4 -4
- package/node_modules/yaml/dist/util.js +2 -2
- package/node_modules/yaml/dist/{warnings-1000a372.js → warnings-793925ce.js} +16 -73
- package/node_modules/yaml/package.json +2 -3
- package/package.json +2 -2
- package/node_modules/yaml/browser/dist/PlainValue-b8036b75.js +0 -1275
- package/node_modules/yaml/browser/dist/Schema-e94716c8.js +0 -682
- package/node_modules/yaml/browser/dist/resolveSeq-492ab440.js +0 -2419
- package/node_modules/yaml/browser/dist/warnings-df54cb69.js +0 -499
|
@@ -36,37 +36,32 @@ const defaultTags = {
|
|
|
36
36
|
function findLineStarts(src) {
|
|
37
37
|
const ls = [0];
|
|
38
38
|
let offset = src.indexOf('\n');
|
|
39
|
-
|
|
40
39
|
while (offset !== -1) {
|
|
41
40
|
offset += 1;
|
|
42
41
|
ls.push(offset);
|
|
43
42
|
offset = src.indexOf('\n', offset);
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
return ls;
|
|
47
45
|
}
|
|
48
|
-
|
|
49
46
|
function getSrcInfo(cst) {
|
|
50
47
|
let lineStarts, src;
|
|
51
|
-
|
|
52
48
|
if (typeof cst === 'string') {
|
|
53
49
|
lineStarts = findLineStarts(cst);
|
|
54
50
|
src = cst;
|
|
55
51
|
} else {
|
|
56
52
|
if (Array.isArray(cst)) cst = cst[0];
|
|
57
|
-
|
|
58
53
|
if (cst && cst.context) {
|
|
59
54
|
if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src);
|
|
60
55
|
lineStarts = cst.lineStarts;
|
|
61
56
|
src = cst.context.src;
|
|
62
57
|
}
|
|
63
58
|
}
|
|
64
|
-
|
|
65
59
|
return {
|
|
66
60
|
lineStarts,
|
|
67
61
|
src
|
|
68
62
|
};
|
|
69
63
|
}
|
|
64
|
+
|
|
70
65
|
/**
|
|
71
66
|
* @typedef {Object} LinePos - One-indexed position in the source
|
|
72
67
|
* @property {number} line
|
|
@@ -87,8 +82,6 @@ function getSrcInfo(cst) {
|
|
|
87
82
|
* @param {string|Document|Document[]} cst
|
|
88
83
|
* @returns {?LinePos}
|
|
89
84
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
85
|
function getLinePos(offset, cst) {
|
|
93
86
|
if (typeof offset !== 'number' || offset < 0) return null;
|
|
94
87
|
const {
|
|
@@ -96,29 +89,26 @@ function getLinePos(offset, cst) {
|
|
|
96
89
|
src
|
|
97
90
|
} = getSrcInfo(cst);
|
|
98
91
|
if (!lineStarts || !src || offset > src.length) return null;
|
|
99
|
-
|
|
100
92
|
for (let i = 0; i < lineStarts.length; ++i) {
|
|
101
93
|
const start = lineStarts[i];
|
|
102
|
-
|
|
103
94
|
if (offset < start) {
|
|
104
95
|
return {
|
|
105
96
|
line: i,
|
|
106
97
|
col: offset - lineStarts[i - 1] + 1
|
|
107
98
|
};
|
|
108
99
|
}
|
|
109
|
-
|
|
110
100
|
if (offset === start) return {
|
|
111
101
|
line: i + 1,
|
|
112
102
|
col: 1
|
|
113
103
|
};
|
|
114
104
|
}
|
|
115
|
-
|
|
116
105
|
const line = lineStarts.length;
|
|
117
106
|
return {
|
|
118
107
|
line,
|
|
119
108
|
col: offset - lineStarts[line - 1] + 1
|
|
120
109
|
};
|
|
121
110
|
}
|
|
111
|
+
|
|
122
112
|
/**
|
|
123
113
|
* Get a specified line from the source.
|
|
124
114
|
*
|
|
@@ -132,7 +122,6 @@ function getLinePos(offset, cst) {
|
|
|
132
122
|
* @param {string|Document|Document[]} cst
|
|
133
123
|
* @returns {?string}
|
|
134
124
|
*/
|
|
135
|
-
|
|
136
125
|
function getLine(line, cst) {
|
|
137
126
|
const {
|
|
138
127
|
lineStarts,
|
|
@@ -141,11 +130,10 @@ function getLine(line, cst) {
|
|
|
141
130
|
if (!lineStarts || !(line >= 1) || line > lineStarts.length) return null;
|
|
142
131
|
const start = lineStarts[line - 1];
|
|
143
132
|
let end = lineStarts[line]; // undefined for last line; that's ok for slice()
|
|
144
|
-
|
|
145
133
|
while (end && end > start && src[end - 1] === '\n') --end;
|
|
146
|
-
|
|
147
134
|
return src.slice(start, end);
|
|
148
135
|
}
|
|
136
|
+
|
|
149
137
|
/**
|
|
150
138
|
* Pretty-print the starting line from the source indicated by the range `pos`
|
|
151
139
|
*
|
|
@@ -162,7 +150,6 @@ function getLine(line, cst) {
|
|
|
162
150
|
* @param {number} [maxWidth=80]
|
|
163
151
|
* @returns {?string}
|
|
164
152
|
*/
|
|
165
|
-
|
|
166
153
|
function getPrettyContext({
|
|
167
154
|
start,
|
|
168
155
|
end
|
|
@@ -172,7 +159,6 @@ function getPrettyContext({
|
|
|
172
159
|
let {
|
|
173
160
|
col
|
|
174
161
|
} = start;
|
|
175
|
-
|
|
176
162
|
if (src.length > maxWidth) {
|
|
177
163
|
if (col <= maxWidth - 10) {
|
|
178
164
|
src = src.substr(0, maxWidth - 1) + '…';
|
|
@@ -183,10 +169,8 @@ function getPrettyContext({
|
|
|
183
169
|
src = '…' + src.substr(1 - maxWidth);
|
|
184
170
|
}
|
|
185
171
|
}
|
|
186
|
-
|
|
187
172
|
let errLen = 1;
|
|
188
173
|
let errEnd = '';
|
|
189
|
-
|
|
190
174
|
if (end) {
|
|
191
175
|
if (end.line === start.line && col + (end.col - start.col) <= maxWidth + 1) {
|
|
192
176
|
errLen = end.col - start.col;
|
|
@@ -195,7 +179,6 @@ function getPrettyContext({
|
|
|
195
179
|
errEnd = '…';
|
|
196
180
|
}
|
|
197
181
|
}
|
|
198
|
-
|
|
199
182
|
const offset = col > 1 ? ' '.repeat(col - 1) : '';
|
|
200
183
|
const err = '^'.repeat(errLen);
|
|
201
184
|
return `${src}\n${offset}${err}${errEnd}`;
|
|
@@ -205,15 +188,14 @@ class Range {
|
|
|
205
188
|
static copy(orig) {
|
|
206
189
|
return new Range(orig.start, orig.end);
|
|
207
190
|
}
|
|
208
|
-
|
|
209
191
|
constructor(start, end) {
|
|
210
192
|
this.start = start;
|
|
211
193
|
this.end = end || start;
|
|
212
194
|
}
|
|
213
|
-
|
|
214
195
|
isEmpty() {
|
|
215
196
|
return typeof this.start !== 'number' || !this.end || this.end <= this.start;
|
|
216
197
|
}
|
|
198
|
+
|
|
217
199
|
/**
|
|
218
200
|
* Set `origStart` and `origEnd` to point to the original source range for
|
|
219
201
|
* this node, which may differ due to dropped CR characters.
|
|
@@ -222,112 +204,86 @@ class Range {
|
|
|
222
204
|
* @param {number} offset - Starting index of `cr` from the last call
|
|
223
205
|
* @returns {number} - The next offset, matching the one found for `origStart`
|
|
224
206
|
*/
|
|
225
|
-
|
|
226
|
-
|
|
227
207
|
setOrigRange(cr, offset) {
|
|
228
208
|
const {
|
|
229
209
|
start,
|
|
230
210
|
end
|
|
231
211
|
} = this;
|
|
232
|
-
|
|
233
212
|
if (cr.length === 0 || end <= cr[0]) {
|
|
234
213
|
this.origStart = start;
|
|
235
214
|
this.origEnd = end;
|
|
236
215
|
return offset;
|
|
237
216
|
}
|
|
238
|
-
|
|
239
217
|
let i = offset;
|
|
240
|
-
|
|
241
218
|
while (i < cr.length) {
|
|
242
219
|
if (cr[i] > start) break;else ++i;
|
|
243
220
|
}
|
|
244
|
-
|
|
245
221
|
this.origStart = start + i;
|
|
246
222
|
const nextOffset = i;
|
|
247
|
-
|
|
248
223
|
while (i < cr.length) {
|
|
249
224
|
// if end was at \n, it should now be at \r
|
|
250
225
|
if (cr[i] >= end) break;else ++i;
|
|
251
226
|
}
|
|
252
|
-
|
|
253
227
|
this.origEnd = end + i;
|
|
254
228
|
return nextOffset;
|
|
255
229
|
}
|
|
256
|
-
|
|
257
230
|
}
|
|
258
231
|
|
|
259
232
|
/** Root class of all nodes */
|
|
260
|
-
|
|
261
233
|
class Node {
|
|
262
234
|
static addStringTerminator(src, offset, str) {
|
|
263
235
|
if (str[str.length - 1] === '\n') return str;
|
|
264
236
|
const next = Node.endOfWhiteSpace(src, offset);
|
|
265
237
|
return next >= src.length || src[next] === '\n' ? str + '\n' : str;
|
|
266
|
-
}
|
|
267
|
-
|
|
238
|
+
}
|
|
268
239
|
|
|
240
|
+
// ^(---|...)
|
|
269
241
|
static atDocumentBoundary(src, offset, sep) {
|
|
270
242
|
const ch0 = src[offset];
|
|
271
243
|
if (!ch0) return true;
|
|
272
244
|
const prev = src[offset - 1];
|
|
273
245
|
if (prev && prev !== '\n') return false;
|
|
274
|
-
|
|
275
246
|
if (sep) {
|
|
276
247
|
if (ch0 !== sep) return false;
|
|
277
248
|
} else {
|
|
278
249
|
if (ch0 !== Char.DIRECTIVES_END && ch0 !== Char.DOCUMENT_END) return false;
|
|
279
250
|
}
|
|
280
|
-
|
|
281
251
|
const ch1 = src[offset + 1];
|
|
282
252
|
const ch2 = src[offset + 2];
|
|
283
253
|
if (ch1 !== ch0 || ch2 !== ch0) return false;
|
|
284
254
|
const ch3 = src[offset + 3];
|
|
285
255
|
return !ch3 || ch3 === '\n' || ch3 === '\t' || ch3 === ' ';
|
|
286
256
|
}
|
|
287
|
-
|
|
288
257
|
static endOfIdentifier(src, offset) {
|
|
289
258
|
let ch = src[offset];
|
|
290
259
|
const isVerbatim = ch === '<';
|
|
291
260
|
const notOk = isVerbatim ? ['\n', '\t', ' ', '>'] : ['\n', '\t', ' ', '[', ']', '{', '}', ','];
|
|
292
|
-
|
|
293
261
|
while (ch && notOk.indexOf(ch) === -1) ch = src[offset += 1];
|
|
294
|
-
|
|
295
262
|
if (isVerbatim && ch === '>') offset += 1;
|
|
296
263
|
return offset;
|
|
297
264
|
}
|
|
298
|
-
|
|
299
265
|
static endOfIndent(src, offset) {
|
|
300
266
|
let ch = src[offset];
|
|
301
|
-
|
|
302
267
|
while (ch === ' ') ch = src[offset += 1];
|
|
303
|
-
|
|
304
268
|
return offset;
|
|
305
269
|
}
|
|
306
|
-
|
|
307
270
|
static endOfLine(src, offset) {
|
|
308
271
|
let ch = src[offset];
|
|
309
|
-
|
|
310
272
|
while (ch && ch !== '\n') ch = src[offset += 1];
|
|
311
|
-
|
|
312
273
|
return offset;
|
|
313
274
|
}
|
|
314
|
-
|
|
315
275
|
static endOfWhiteSpace(src, offset) {
|
|
316
276
|
let ch = src[offset];
|
|
317
|
-
|
|
318
277
|
while (ch === '\t' || ch === ' ') ch = src[offset += 1];
|
|
319
|
-
|
|
320
278
|
return offset;
|
|
321
279
|
}
|
|
322
|
-
|
|
323
280
|
static startOfLine(src, offset) {
|
|
324
281
|
let ch = src[offset - 1];
|
|
325
282
|
if (ch === '\n') return offset;
|
|
326
|
-
|
|
327
283
|
while (ch && ch !== '\n') ch = src[offset -= 1];
|
|
328
|
-
|
|
329
284
|
return offset + 1;
|
|
330
285
|
}
|
|
286
|
+
|
|
331
287
|
/**
|
|
332
288
|
* End of indentation, or null if the line's indent level is not more
|
|
333
289
|
* than `indent`
|
|
@@ -337,11 +293,8 @@ class Node {
|
|
|
337
293
|
* @param {number} lineStart
|
|
338
294
|
* @returns {?number}
|
|
339
295
|
*/
|
|
340
|
-
|
|
341
|
-
|
|
342
296
|
static endOfBlockIndent(src, indent, lineStart) {
|
|
343
297
|
const inEnd = Node.endOfIndent(src, lineStart);
|
|
344
|
-
|
|
345
298
|
if (inEnd > lineStart + indent) {
|
|
346
299
|
return inEnd;
|
|
347
300
|
} else {
|
|
@@ -349,35 +302,31 @@ class Node {
|
|
|
349
302
|
const ch = src[wsEnd];
|
|
350
303
|
if (!ch || ch === '\n') return wsEnd;
|
|
351
304
|
}
|
|
352
|
-
|
|
353
305
|
return null;
|
|
354
306
|
}
|
|
355
|
-
|
|
356
307
|
static atBlank(src, offset, endAsBlank) {
|
|
357
308
|
const ch = src[offset];
|
|
358
309
|
return ch === '\n' || ch === '\t' || ch === ' ' || endAsBlank && !ch;
|
|
359
310
|
}
|
|
360
|
-
|
|
361
311
|
static nextNodeIsIndented(ch, indentDiff, indicatorAsIndent) {
|
|
362
312
|
if (!ch || indentDiff < 0) return false;
|
|
363
313
|
if (indentDiff > 0) return true;
|
|
364
314
|
return indicatorAsIndent && ch === '-';
|
|
365
|
-
}
|
|
366
|
-
|
|
315
|
+
}
|
|
367
316
|
|
|
317
|
+
// should be at line or string end, or at next non-whitespace char
|
|
368
318
|
static normalizeOffset(src, offset) {
|
|
369
319
|
const ch = src[offset];
|
|
370
320
|
return !ch ? offset : ch !== '\n' && src[offset - 1] === '\n' ? offset - 1 : Node.endOfWhiteSpace(src, offset);
|
|
371
|
-
}
|
|
372
|
-
// presumes src[offset] === '\n'
|
|
373
|
-
|
|
321
|
+
}
|
|
374
322
|
|
|
323
|
+
// fold single newline into space, multiple newlines to N - 1 newlines
|
|
324
|
+
// presumes src[offset] === '\n'
|
|
375
325
|
static foldNewline(src, offset, indent) {
|
|
376
326
|
let inCount = 0;
|
|
377
327
|
let error = false;
|
|
378
328
|
let fold = '';
|
|
379
329
|
let ch = src[offset + 1];
|
|
380
|
-
|
|
381
330
|
while (ch === ' ' || ch === '\t' || ch === '\n') {
|
|
382
331
|
switch (ch) {
|
|
383
332
|
case '\n':
|
|
@@ -385,21 +334,17 @@ class Node {
|
|
|
385
334
|
offset += 1;
|
|
386
335
|
fold += '\n';
|
|
387
336
|
break;
|
|
388
|
-
|
|
389
337
|
case '\t':
|
|
390
338
|
if (inCount <= indent) error = true;
|
|
391
339
|
offset = Node.endOfWhiteSpace(src, offset + 2) - 1;
|
|
392
340
|
break;
|
|
393
|
-
|
|
394
341
|
case ' ':
|
|
395
342
|
inCount += 1;
|
|
396
343
|
offset += 1;
|
|
397
344
|
break;
|
|
398
345
|
}
|
|
399
|
-
|
|
400
346
|
ch = src[offset + 1];
|
|
401
347
|
}
|
|
402
|
-
|
|
403
348
|
if (!fold) fold = ' ';
|
|
404
349
|
if (ch && inCount <= indent) error = true;
|
|
405
350
|
return {
|
|
@@ -408,7 +353,6 @@ class Node {
|
|
|
408
353
|
error
|
|
409
354
|
};
|
|
410
355
|
}
|
|
411
|
-
|
|
412
356
|
constructor(type, props, context) {
|
|
413
357
|
Object.defineProperty(this, 'context', {
|
|
414
358
|
value: context || null,
|
|
@@ -421,7 +365,6 @@ class Node {
|
|
|
421
365
|
this.type = type;
|
|
422
366
|
this.value = null;
|
|
423
367
|
}
|
|
424
|
-
|
|
425
368
|
getPropValue(idx, key, skipKey) {
|
|
426
369
|
if (!this.context) return null;
|
|
427
370
|
const {
|
|
@@ -430,27 +373,21 @@ class Node {
|
|
|
430
373
|
const prop = this.props[idx];
|
|
431
374
|
return prop && src[prop.start] === key ? src.slice(prop.start + (skipKey ? 1 : 0), prop.end) : null;
|
|
432
375
|
}
|
|
433
|
-
|
|
434
376
|
get anchor() {
|
|
435
377
|
for (let i = 0; i < this.props.length; ++i) {
|
|
436
378
|
const anchor = this.getPropValue(i, Char.ANCHOR, true);
|
|
437
379
|
if (anchor != null) return anchor;
|
|
438
380
|
}
|
|
439
|
-
|
|
440
381
|
return null;
|
|
441
382
|
}
|
|
442
|
-
|
|
443
383
|
get comment() {
|
|
444
384
|
const comments = [];
|
|
445
|
-
|
|
446
385
|
for (let i = 0; i < this.props.length; ++i) {
|
|
447
386
|
const comment = this.getPropValue(i, Char.COMMENT, true);
|
|
448
387
|
if (comment != null) comments.push(comment);
|
|
449
388
|
}
|
|
450
|
-
|
|
451
389
|
return comments.length > 0 ? comments.join('\n') : null;
|
|
452
390
|
}
|
|
453
|
-
|
|
454
391
|
commentHasRequiredWhitespace(start) {
|
|
455
392
|
const {
|
|
456
393
|
src
|
|
@@ -462,44 +399,35 @@ class Node {
|
|
|
462
399
|
} = this.valueRange;
|
|
463
400
|
return start !== end || Node.atBlank(src, end - 1);
|
|
464
401
|
}
|
|
465
|
-
|
|
466
402
|
get hasComment() {
|
|
467
403
|
if (this.context) {
|
|
468
404
|
const {
|
|
469
405
|
src
|
|
470
406
|
} = this.context;
|
|
471
|
-
|
|
472
407
|
for (let i = 0; i < this.props.length; ++i) {
|
|
473
408
|
if (src[this.props[i].start] === Char.COMMENT) return true;
|
|
474
409
|
}
|
|
475
410
|
}
|
|
476
|
-
|
|
477
411
|
return false;
|
|
478
412
|
}
|
|
479
|
-
|
|
480
413
|
get hasProps() {
|
|
481
414
|
if (this.context) {
|
|
482
415
|
const {
|
|
483
416
|
src
|
|
484
417
|
} = this.context;
|
|
485
|
-
|
|
486
418
|
for (let i = 0; i < this.props.length; ++i) {
|
|
487
419
|
if (src[this.props[i].start] !== Char.COMMENT) return true;
|
|
488
420
|
}
|
|
489
421
|
}
|
|
490
|
-
|
|
491
422
|
return false;
|
|
492
423
|
}
|
|
493
|
-
|
|
494
424
|
get includesTrailingLines() {
|
|
495
425
|
return false;
|
|
496
426
|
}
|
|
497
|
-
|
|
498
427
|
get jsonLike() {
|
|
499
428
|
const jsonLikeTypes = [Type.FLOW_MAP, Type.FLOW_SEQ, Type.QUOTE_DOUBLE, Type.QUOTE_SINGLE];
|
|
500
429
|
return jsonLikeTypes.indexOf(this.type) !== -1;
|
|
501
430
|
}
|
|
502
|
-
|
|
503
431
|
get rangeAsLinePos() {
|
|
504
432
|
if (!this.range || !this.context) return undefined;
|
|
505
433
|
const start = getLinePos(this.range.start, this.context.root);
|
|
@@ -510,7 +438,6 @@ class Node {
|
|
|
510
438
|
end
|
|
511
439
|
};
|
|
512
440
|
}
|
|
513
|
-
|
|
514
441
|
get rawValue() {
|
|
515
442
|
if (!this.valueRange || !this.context) return null;
|
|
516
443
|
const {
|
|
@@ -519,11 +446,9 @@ class Node {
|
|
|
519
446
|
} = this.valueRange;
|
|
520
447
|
return this.context.src.slice(start, end);
|
|
521
448
|
}
|
|
522
|
-
|
|
523
449
|
get tag() {
|
|
524
450
|
for (let i = 0; i < this.props.length; ++i) {
|
|
525
451
|
const tag = this.getPropValue(i, Char.TAG, false);
|
|
526
|
-
|
|
527
452
|
if (tag != null) {
|
|
528
453
|
if (tag[1] === '<') {
|
|
529
454
|
return {
|
|
@@ -539,10 +464,8 @@ class Node {
|
|
|
539
464
|
}
|
|
540
465
|
}
|
|
541
466
|
}
|
|
542
|
-
|
|
543
467
|
return null;
|
|
544
468
|
}
|
|
545
|
-
|
|
546
469
|
get valueRangeContainsNewline() {
|
|
547
470
|
if (!this.valueRange || !this.context) return false;
|
|
548
471
|
const {
|
|
@@ -552,28 +475,24 @@ class Node {
|
|
|
552
475
|
const {
|
|
553
476
|
src
|
|
554
477
|
} = this.context;
|
|
555
|
-
|
|
556
478
|
for (let i = start; i < end; ++i) {
|
|
557
479
|
if (src[i] === '\n') return true;
|
|
558
480
|
}
|
|
559
|
-
|
|
560
481
|
return false;
|
|
561
482
|
}
|
|
562
|
-
|
|
563
483
|
parseComment(start) {
|
|
564
484
|
const {
|
|
565
485
|
src
|
|
566
486
|
} = this.context;
|
|
567
|
-
|
|
568
487
|
if (src[start] === Char.COMMENT) {
|
|
569
488
|
const end = Node.endOfLine(src, start + 1);
|
|
570
489
|
const commentRange = new Range(start, end);
|
|
571
490
|
this.props.push(commentRange);
|
|
572
491
|
return end;
|
|
573
492
|
}
|
|
574
|
-
|
|
575
493
|
return start;
|
|
576
494
|
}
|
|
495
|
+
|
|
577
496
|
/**
|
|
578
497
|
* Populates the `origStart` and `origEnd` values of all ranges for this
|
|
579
498
|
* node. Extended by child classes to handle descendant nodes.
|
|
@@ -582,15 +501,12 @@ class Node {
|
|
|
582
501
|
* @param {number} offset - Starting index of `cr` from the last call
|
|
583
502
|
* @returns {number} - The next offset, matching the one found for `origStart`
|
|
584
503
|
*/
|
|
585
|
-
|
|
586
|
-
|
|
587
504
|
setOrigRanges(cr, offset) {
|
|
588
505
|
if (this.range) offset = this.range.setOrigRange(cr, offset);
|
|
589
506
|
if (this.valueRange) this.valueRange.setOrigRange(cr, offset);
|
|
590
507
|
this.props.forEach(prop => prop.setOrigRange(cr, offset));
|
|
591
508
|
return offset;
|
|
592
509
|
}
|
|
593
|
-
|
|
594
510
|
toString() {
|
|
595
511
|
const {
|
|
596
512
|
context: {
|
|
@@ -603,7 +519,6 @@ class Node {
|
|
|
603
519
|
const str = src.slice(range.start, range.end);
|
|
604
520
|
return Node.addStringTerminator(src, range.end, str);
|
|
605
521
|
}
|
|
606
|
-
|
|
607
522
|
}
|
|
608
523
|
|
|
609
524
|
class YAMLError extends Error {
|
|
@@ -614,16 +529,13 @@ class YAMLError extends Error {
|
|
|
614
529
|
this.message = message;
|
|
615
530
|
this.source = source;
|
|
616
531
|
}
|
|
617
|
-
|
|
618
532
|
makePretty() {
|
|
619
533
|
if (!this.source) return;
|
|
620
534
|
this.nodeType = this.source.type;
|
|
621
535
|
const cst = this.source.context && this.source.context.root;
|
|
622
|
-
|
|
623
536
|
if (typeof this.offset === 'number') {
|
|
624
537
|
this.range = new Range(this.offset, this.offset + 1);
|
|
625
538
|
const start = cst && getLinePos(this.offset, cst);
|
|
626
|
-
|
|
627
539
|
if (start) {
|
|
628
540
|
const end = {
|
|
629
541
|
line: start.line,
|
|
@@ -634,13 +546,11 @@ class YAMLError extends Error {
|
|
|
634
546
|
end
|
|
635
547
|
};
|
|
636
548
|
}
|
|
637
|
-
|
|
638
549
|
delete this.offset;
|
|
639
550
|
} else {
|
|
640
551
|
this.range = this.source.range;
|
|
641
552
|
this.linePos = this.source.rangeAsLinePos;
|
|
642
553
|
}
|
|
643
|
-
|
|
644
554
|
if (this.linePos) {
|
|
645
555
|
const {
|
|
646
556
|
line,
|
|
@@ -650,56 +560,57 @@ class YAMLError extends Error {
|
|
|
650
560
|
const ctx = cst && getPrettyContext(this.linePos, cst);
|
|
651
561
|
if (ctx) this.message += `:\n\n${ctx}\n`;
|
|
652
562
|
}
|
|
653
|
-
|
|
654
563
|
delete this.source;
|
|
655
564
|
}
|
|
656
|
-
|
|
657
565
|
}
|
|
658
566
|
class YAMLReferenceError extends YAMLError {
|
|
659
567
|
constructor(source, message) {
|
|
660
568
|
super('YAMLReferenceError', source, message);
|
|
661
569
|
}
|
|
662
|
-
|
|
663
570
|
}
|
|
664
571
|
class YAMLSemanticError extends YAMLError {
|
|
665
572
|
constructor(source, message) {
|
|
666
573
|
super('YAMLSemanticError', source, message);
|
|
667
574
|
}
|
|
668
|
-
|
|
669
575
|
}
|
|
670
576
|
class YAMLSyntaxError extends YAMLError {
|
|
671
577
|
constructor(source, message) {
|
|
672
578
|
super('YAMLSyntaxError', source, message);
|
|
673
579
|
}
|
|
674
|
-
|
|
675
580
|
}
|
|
676
581
|
class YAMLWarning extends YAMLError {
|
|
677
582
|
constructor(source, message) {
|
|
678
583
|
super('YAMLWarning', source, message);
|
|
679
584
|
}
|
|
680
|
-
|
|
681
585
|
}
|
|
682
586
|
|
|
683
|
-
function _defineProperty(
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
587
|
+
function _defineProperty(e, r, t) {
|
|
588
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
589
|
+
value: t,
|
|
590
|
+
enumerable: !0,
|
|
591
|
+
configurable: !0,
|
|
592
|
+
writable: !0
|
|
593
|
+
}) : e[r] = t, e;
|
|
594
|
+
}
|
|
595
|
+
function _toPrimitive(t, r) {
|
|
596
|
+
if ("object" != typeof t || !t) return t;
|
|
597
|
+
var e = t[Symbol.toPrimitive];
|
|
598
|
+
if (void 0 !== e) {
|
|
599
|
+
var i = e.call(t, r || "default");
|
|
600
|
+
if ("object" != typeof i) return i;
|
|
601
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
602
|
+
}
|
|
603
|
+
return ("string" === r ? String : Number)(t);
|
|
604
|
+
}
|
|
605
|
+
function _toPropertyKey(t) {
|
|
606
|
+
var i = _toPrimitive(t, "string");
|
|
607
|
+
return "symbol" == typeof i ? i : i + "";
|
|
696
608
|
}
|
|
697
609
|
|
|
698
610
|
class PlainValue extends Node {
|
|
699
611
|
static endOfLine(src, start, inFlow) {
|
|
700
612
|
let ch = src[start];
|
|
701
613
|
let offset = start;
|
|
702
|
-
|
|
703
614
|
while (ch && ch !== '\n') {
|
|
704
615
|
if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break;
|
|
705
616
|
const next = src[offset + 1];
|
|
@@ -708,10 +619,8 @@ class PlainValue extends Node {
|
|
|
708
619
|
offset += 1;
|
|
709
620
|
ch = next;
|
|
710
621
|
}
|
|
711
|
-
|
|
712
622
|
return offset;
|
|
713
623
|
}
|
|
714
|
-
|
|
715
624
|
get strValue() {
|
|
716
625
|
if (!this.valueRange || !this.context) return null;
|
|
717
626
|
let {
|
|
@@ -722,14 +631,10 @@ class PlainValue extends Node {
|
|
|
722
631
|
src
|
|
723
632
|
} = this.context;
|
|
724
633
|
let ch = src[end - 1];
|
|
725
|
-
|
|
726
634
|
while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) ch = src[--end - 1];
|
|
727
|
-
|
|
728
635
|
let str = '';
|
|
729
|
-
|
|
730
636
|
for (let i = start; i < end; ++i) {
|
|
731
637
|
const ch = src[i];
|
|
732
|
-
|
|
733
638
|
if (ch === '\n') {
|
|
734
639
|
const {
|
|
735
640
|
fold,
|
|
@@ -741,20 +646,16 @@ class PlainValue extends Node {
|
|
|
741
646
|
// trim trailing whitespace
|
|
742
647
|
const wsStart = i;
|
|
743
648
|
let next = src[i + 1];
|
|
744
|
-
|
|
745
649
|
while (i < end && (next === ' ' || next === '\t')) {
|
|
746
650
|
i += 1;
|
|
747
651
|
next = src[i + 1];
|
|
748
652
|
}
|
|
749
|
-
|
|
750
653
|
if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
|
|
751
654
|
} else {
|
|
752
655
|
str += ch;
|
|
753
656
|
}
|
|
754
657
|
}
|
|
755
|
-
|
|
756
658
|
const ch0 = src[start];
|
|
757
|
-
|
|
758
659
|
switch (ch0) {
|
|
759
660
|
case '\t':
|
|
760
661
|
{
|
|
@@ -765,7 +666,6 @@ class PlainValue extends Node {
|
|
|
765
666
|
str
|
|
766
667
|
};
|
|
767
668
|
}
|
|
768
|
-
|
|
769
669
|
case '@':
|
|
770
670
|
case '`':
|
|
771
671
|
{
|
|
@@ -776,12 +676,10 @@ class PlainValue extends Node {
|
|
|
776
676
|
str
|
|
777
677
|
};
|
|
778
678
|
}
|
|
779
|
-
|
|
780
679
|
default:
|
|
781
680
|
return str;
|
|
782
681
|
}
|
|
783
682
|
}
|
|
784
|
-
|
|
785
683
|
parseBlockValue(start) {
|
|
786
684
|
const {
|
|
787
685
|
indent,
|
|
@@ -790,12 +688,10 @@ class PlainValue extends Node {
|
|
|
790
688
|
} = this.context;
|
|
791
689
|
let offset = start;
|
|
792
690
|
let valueEnd = start;
|
|
793
|
-
|
|
794
691
|
for (let ch = src[offset]; ch === '\n'; ch = src[offset]) {
|
|
795
692
|
if (Node.atDocumentBoundary(src, offset + 1)) break;
|
|
796
693
|
const end = Node.endOfBlockIndent(src, indent, offset + 1);
|
|
797
694
|
if (end === null || src[end] === '#') break;
|
|
798
|
-
|
|
799
695
|
if (src[end] === '\n') {
|
|
800
696
|
offset = end;
|
|
801
697
|
} else {
|
|
@@ -803,11 +699,11 @@ class PlainValue extends Node {
|
|
|
803
699
|
offset = valueEnd;
|
|
804
700
|
}
|
|
805
701
|
}
|
|
806
|
-
|
|
807
702
|
if (this.valueRange.isEmpty()) this.valueRange.start = start;
|
|
808
703
|
this.valueRange.end = valueEnd;
|
|
809
704
|
return valueEnd;
|
|
810
705
|
}
|
|
706
|
+
|
|
811
707
|
/**
|
|
812
708
|
* Parses a plain value from the source
|
|
813
709
|
*
|
|
@@ -833,8 +729,6 @@ class PlainValue extends Node {
|
|
|
833
729
|
* @param {number} start - Index of first character
|
|
834
730
|
* @returns {number} - Index of the character after this scalar, may be `\n`
|
|
835
731
|
*/
|
|
836
|
-
|
|
837
|
-
|
|
838
732
|
parse(context, start) {
|
|
839
733
|
this.context = context;
|
|
840
734
|
const {
|
|
@@ -843,22 +737,17 @@ class PlainValue extends Node {
|
|
|
843
737
|
} = context;
|
|
844
738
|
let offset = start;
|
|
845
739
|
const ch = src[offset];
|
|
846
|
-
|
|
847
740
|
if (ch && ch !== '#' && ch !== '\n') {
|
|
848
741
|
offset = PlainValue.endOfLine(src, start, inFlow);
|
|
849
742
|
}
|
|
850
|
-
|
|
851
743
|
this.valueRange = new Range(start, offset);
|
|
852
744
|
offset = Node.endOfWhiteSpace(src, offset);
|
|
853
745
|
offset = this.parseComment(offset);
|
|
854
|
-
|
|
855
746
|
if (!this.hasComment || this.valueRange.isEmpty()) {
|
|
856
747
|
offset = this.parseBlockValue(offset);
|
|
857
748
|
}
|
|
858
|
-
|
|
859
749
|
return offset;
|
|
860
750
|
}
|
|
861
|
-
|
|
862
751
|
}
|
|
863
752
|
|
|
864
753
|
exports.Char = Char;
|