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.
Files changed (29) hide show
  1. package/.jsii +3 -3
  2. package/lib/operator.js +1 -1
  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 +2 -2
  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,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var PlainValue = require('./PlainValue-ec8e588e.js');
4
- var resolveSeq = require('./resolveSeq-d03cb037.js');
5
- var Schema = require('./Schema-88e323a7.js');
3
+ var PlainValue = require('./PlainValue-516d5bc2.js');
4
+ var resolveSeq = require('./resolveSeq-95613e94.js');
5
+ var Schema = require('./Schema-bcc6c2d7.js');
6
6
 
7
7
  const defaultOptions = {
8
8
  anchorPrefix: 'a',
@@ -23,43 +23,33 @@ const scalarOptions = {
23
23
  get binary() {
24
24
  return resolveSeq.binaryOptions;
25
25
  },
26
-
27
26
  set binary(opt) {
28
27
  Object.assign(resolveSeq.binaryOptions, opt);
29
28
  },
30
-
31
29
  get bool() {
32
30
  return resolveSeq.boolOptions;
33
31
  },
34
-
35
32
  set bool(opt) {
36
33
  Object.assign(resolveSeq.boolOptions, opt);
37
34
  },
38
-
39
35
  get int() {
40
36
  return resolveSeq.intOptions;
41
37
  },
42
-
43
38
  set int(opt) {
44
39
  Object.assign(resolveSeq.intOptions, opt);
45
40
  },
46
-
47
41
  get null() {
48
42
  return resolveSeq.nullOptions;
49
43
  },
50
-
51
44
  set null(opt) {
52
45
  Object.assign(resolveSeq.nullOptions, opt);
53
46
  },
54
-
55
47
  get str() {
56
48
  return resolveSeq.strOptions;
57
49
  },
58
-
59
50
  set str(opt) {
60
51
  Object.assign(resolveSeq.strOptions, opt);
61
52
  }
62
-
63
53
  };
64
54
  const documentOptions = {
65
55
  '1.0': {
@@ -104,14 +94,11 @@ function stringifyTag(doc, tag) {
104
94
  const vocab = tag.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/);
105
95
  return vocab ? `!${vocab[1]}/${vocab[2]}` : `!${tag.replace(/^tag:/, '')}`;
106
96
  }
107
-
108
97
  let p = doc.tagPrefixes.find(p => tag.indexOf(p.prefix) === 0);
109
-
110
98
  if (!p) {
111
99
  const dtp = doc.getDefaults().tagPrefixes;
112
100
  p = dtp && dtp.find(p => tag.indexOf(p.prefix) === 0);
113
101
  }
114
-
115
102
  if (!p) return tag[0] === '!' ? tag : `!<${tag}>`;
116
103
  const suffix = tag.substr(p.prefix.length).replace(/[!,[\]{}]/g, ch => ({
117
104
  '!': '%21',
@@ -126,61 +113,51 @@ function stringifyTag(doc, tag) {
126
113
 
127
114
  function getTagObject(tags, item) {
128
115
  if (item instanceof resolveSeq.Alias) return resolveSeq.Alias;
129
-
130
116
  if (item.tag) {
131
117
  const match = tags.filter(t => t.tag === item.tag);
132
118
  if (match.length > 0) return match.find(t => t.format === item.format) || match[0];
133
119
  }
134
-
135
120
  let tagObj, obj;
136
-
137
121
  if (item instanceof resolveSeq.Scalar) {
138
- obj = item.value; // TODO: deprecate/remove class check
139
-
122
+ obj = item.value;
123
+ // TODO: deprecate/remove class check
140
124
  const match = tags.filter(t => t.identify && t.identify(obj) || t.class && obj instanceof t.class);
141
125
  tagObj = match.find(t => t.format === item.format) || match.find(t => !t.format);
142
126
  } else {
143
127
  obj = item;
144
128
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
145
129
  }
146
-
147
130
  if (!tagObj) {
148
131
  const name = obj && obj.constructor ? obj.constructor.name : typeof obj;
149
132
  throw new Error(`Tag not resolved for ${name} value`);
150
133
  }
151
-
152
134
  return tagObj;
153
- } // needs to be called before value stringifier to allow for circular anchor refs
154
-
135
+ }
155
136
 
137
+ // needs to be called before value stringifier to allow for circular anchor refs
156
138
  function stringifyProps(node, tagObj, {
157
139
  anchors,
158
140
  doc
159
141
  }) {
160
142
  const props = [];
161
143
  const anchor = doc.anchors.getName(node);
162
-
163
144
  if (anchor) {
164
145
  anchors[anchor] = node;
165
146
  props.push(`&${anchor}`);
166
147
  }
167
-
168
148
  if (node.tag) {
169
149
  props.push(stringifyTag(doc, node.tag));
170
150
  } else if (!tagObj.default) {
171
151
  props.push(stringifyTag(doc, tagObj.tag));
172
152
  }
173
-
174
153
  return props.join(' ');
175
154
  }
176
-
177
155
  function stringify(item, ctx, onComment, onChompKeep) {
178
156
  const {
179
157
  anchors,
180
158
  schema
181
159
  } = ctx.doc;
182
160
  let tagObj;
183
-
184
161
  if (!(item instanceof resolveSeq.Node)) {
185
162
  const createCtx = {
186
163
  aliasNodes: [],
@@ -188,18 +165,15 @@ function stringify(item, ctx, onComment, onChompKeep) {
188
165
  prevObjects: new Map()
189
166
  };
190
167
  item = schema.createNode(item, true, null, createCtx);
191
-
192
168
  for (const alias of createCtx.aliasNodes) {
193
169
  alias.source = alias.source.node;
194
170
  let name = anchors.getName(alias.source);
195
-
196
171
  if (!name) {
197
172
  name = anchors.newName();
198
173
  anchors.map[name] = alias.source;
199
174
  }
200
175
  }
201
176
  }
202
-
203
177
  if (item instanceof resolveSeq.Pair) return item.toString(ctx, onComment, onChompKeep);
204
178
  if (!tagObj) tagObj = getTagObject(schema.tags, item);
205
179
  const props = stringifyProps(item, tagObj, ctx);
@@ -213,18 +187,14 @@ class Anchors {
213
187
  static validAnchorNode(node) {
214
188
  return node instanceof resolveSeq.Scalar || node instanceof resolveSeq.YAMLSeq || node instanceof resolveSeq.YAMLMap;
215
189
  }
216
-
217
190
  constructor(prefix) {
218
191
  PlainValue._defineProperty(this, "map", Object.create(null));
219
-
220
192
  this.prefix = prefix;
221
193
  }
222
-
223
194
  createAlias(node, name) {
224
195
  this.setAnchor(node, name);
225
196
  return new resolveSeq.Alias(node);
226
197
  }
227
-
228
198
  createMergePair(...sources) {
229
199
  const merge = new resolveSeq.Merge();
230
200
  merge.value.items = sources.map(s => {
@@ -233,38 +203,32 @@ class Anchors {
233
203
  } else if (s instanceof resolveSeq.YAMLMap) {
234
204
  return this.createAlias(s);
235
205
  }
236
-
237
206
  throw new Error('Merge sources must be Map nodes or their Aliases');
238
207
  });
239
208
  return merge;
240
209
  }
241
-
242
210
  getName(node) {
243
211
  const {
244
212
  map
245
213
  } = this;
246
214
  return Object.keys(map).find(a => map[a] === node);
247
215
  }
248
-
249
216
  getNames() {
250
217
  return Object.keys(this.map);
251
218
  }
252
-
253
219
  getNode(name) {
254
220
  return this.map[name];
255
221
  }
256
-
257
222
  newName(prefix) {
258
223
  if (!prefix) prefix = this.prefix;
259
224
  const names = Object.keys(this.map);
260
-
261
225
  for (let i = 1; true; ++i) {
262
226
  const name = `${prefix}${i}`;
263
227
  if (!names.includes(name)) return name;
264
228
  }
265
- } // During parsing, map & aliases contain CST nodes
266
-
229
+ }
267
230
 
231
+ // During parsing, map & aliases contain CST nodes
268
232
  resolveNodes() {
269
233
  const {
270
234
  map,
@@ -273,28 +237,22 @@ class Anchors {
273
237
  Object.keys(map).forEach(a => {
274
238
  map[a] = map[a].resolved;
275
239
  });
276
-
277
240
  _cstAliases.forEach(a => {
278
241
  a.source = a.source.resolved;
279
242
  });
280
-
281
243
  delete this._cstAliases;
282
244
  }
283
-
284
245
  setAnchor(node, name) {
285
246
  if (node != null && !Anchors.validAnchorNode(node)) {
286
247
  throw new Error('Anchors may only be set for Scalar, Seq and Map nodes');
287
248
  }
288
-
289
249
  if (name && /[\x00-\x19\s,[\]{}]/.test(name)) {
290
250
  throw new Error('Anchor names must not contain whitespace or control characters');
291
251
  }
292
-
293
252
  const {
294
253
  map
295
254
  } = this;
296
255
  const prev = node && Object.keys(map).find(a => map[a] === node);
297
-
298
256
  if (prev) {
299
257
  if (!name) {
300
258
  return prev;
@@ -307,13 +265,10 @@ class Anchors {
307
265
  if (!node) return null;
308
266
  name = this.newName();
309
267
  }
310
-
311
268
  map[name] = node;
312
269
  }
313
-
314
270
  return name;
315
271
  }
316
-
317
272
  }
318
273
 
319
274
  const visit = (node, tags) => {
@@ -321,7 +276,6 @@ const visit = (node, tags) => {
321
276
  const {
322
277
  tag
323
278
  } = node;
324
-
325
279
  if (node instanceof resolveSeq.Collection) {
326
280
  if (tag) tags[tag] = true;
327
281
  node.items.forEach(n => visit(n, tags));
@@ -332,10 +286,8 @@ const visit = (node, tags) => {
332
286
  if (tag) tags[tag] = true;
333
287
  }
334
288
  }
335
-
336
289
  return tags;
337
290
  };
338
-
339
291
  const listTagNames = node => Object.keys(visit(node, {}));
340
292
 
341
293
  function parseContents(doc, contents) {
@@ -345,7 +297,6 @@ function parseContents(doc, contents) {
345
297
  };
346
298
  let body = undefined;
347
299
  let spaceBefore = false;
348
-
349
300
  for (const node of contents) {
350
301
  if (node.valueRange) {
351
302
  if (body !== undefined) {
@@ -353,21 +304,17 @@ function parseContents(doc, contents) {
353
304
  doc.errors.push(new PlainValue.YAMLSyntaxError(node, msg));
354
305
  break;
355
306
  }
356
-
357
307
  const res = resolveSeq.resolveNode(doc, node);
358
-
359
308
  if (spaceBefore) {
360
309
  res.spaceBefore = true;
361
310
  spaceBefore = false;
362
311
  }
363
-
364
312
  body = res;
365
313
  } else if (node.comment !== null) {
366
314
  const cc = body === undefined ? comments.before : comments.after;
367
315
  cc.push(node.comment);
368
316
  } else if (node.type === PlainValue.Type.BLANK_LINE) {
369
317
  spaceBefore = true;
370
-
371
318
  if (body === undefined && comments.before.length > 0 && !doc.commentBefore) {
372
319
  // space-separated comments at start are parsed as document comments
373
320
  doc.commentBefore = comments.before.join('\n');
@@ -375,19 +322,15 @@ function parseContents(doc, contents) {
375
322
  }
376
323
  }
377
324
  }
378
-
379
325
  doc.contents = body || null;
380
-
381
326
  if (!body) {
382
327
  doc.comment = comments.before.concat(comments.after).join('\n') || null;
383
328
  } else {
384
329
  const cb = comments.before.join('\n');
385
-
386
330
  if (cb) {
387
331
  const cbNode = body instanceof resolveSeq.Collection && body.items[0] ? body.items[0] : body;
388
332
  cbNode.commentBefore = cbNode.commentBefore ? `${cb}\n${cbNode.commentBefore}` : cb;
389
333
  }
390
-
391
334
  doc.comment = comments.after.join('\n') || null;
392
335
  }
393
336
  }
@@ -396,51 +339,41 @@ function resolveTagDirective({
396
339
  tagPrefixes
397
340
  }, directive) {
398
341
  const [handle, prefix] = directive.parameters;
399
-
400
342
  if (!handle || !prefix) {
401
343
  const msg = 'Insufficient parameters given for %TAG directive';
402
344
  throw new PlainValue.YAMLSemanticError(directive, msg);
403
345
  }
404
-
405
346
  if (tagPrefixes.some(p => p.handle === handle)) {
406
347
  const msg = 'The %TAG directive must only be given at most once per handle in the same document.';
407
348
  throw new PlainValue.YAMLSemanticError(directive, msg);
408
349
  }
409
-
410
350
  return {
411
351
  handle,
412
352
  prefix
413
353
  };
414
354
  }
415
-
416
355
  function resolveYamlDirective(doc, directive) {
417
356
  let [version] = directive.parameters;
418
357
  if (directive.name === 'YAML:1.0') version = '1.0';
419
-
420
358
  if (!version) {
421
359
  const msg = 'Insufficient parameters given for %YAML directive';
422
360
  throw new PlainValue.YAMLSemanticError(directive, msg);
423
361
  }
424
-
425
362
  if (!documentOptions[version]) {
426
363
  const v0 = doc.version || doc.options.version;
427
364
  const msg = `Document will be parsed as YAML ${v0} rather than YAML ${version}`;
428
365
  doc.warnings.push(new PlainValue.YAMLWarning(directive, msg));
429
366
  }
430
-
431
367
  return version;
432
368
  }
433
-
434
369
  function parseDirectives(doc, directives, prevDoc) {
435
370
  const directiveComments = [];
436
371
  let hasDirectives = false;
437
-
438
372
  for (const directive of directives) {
439
373
  const {
440
374
  comment,
441
375
  name
442
376
  } = directive;
443
-
444
377
  switch (name) {
445
378
  case 'TAG':
446
379
  try {
@@ -448,37 +381,29 @@ function parseDirectives(doc, directives, prevDoc) {
448
381
  } catch (error) {
449
382
  doc.errors.push(error);
450
383
  }
451
-
452
384
  hasDirectives = true;
453
385
  break;
454
-
455
386
  case 'YAML':
456
387
  case 'YAML:1.0':
457
388
  if (doc.version) {
458
389
  const msg = 'The %YAML directive must only be given at most once per document.';
459
390
  doc.errors.push(new PlainValue.YAMLSemanticError(directive, msg));
460
391
  }
461
-
462
392
  try {
463
393
  doc.version = resolveYamlDirective(doc, directive);
464
394
  } catch (error) {
465
395
  doc.errors.push(error);
466
396
  }
467
-
468
397
  hasDirectives = true;
469
398
  break;
470
-
471
399
  default:
472
400
  if (name) {
473
401
  const msg = `YAML only supports %TAG and %YAML directives, and not %${name}`;
474
402
  doc.warnings.push(new PlainValue.YAMLWarning(directive, msg));
475
403
  }
476
-
477
404
  }
478
-
479
405
  if (comment) directiveComments.push(comment);
480
406
  }
481
-
482
407
  if (prevDoc && !hasDirectives && '1.1' === (doc.version || prevDoc.version || doc.options.version)) {
483
408
  const copyTagPrefix = ({
484
409
  handle,
@@ -487,11 +412,9 @@ function parseDirectives(doc, directives, prevDoc) {
487
412
  handle,
488
413
  prefix
489
414
  });
490
-
491
415
  doc.tagPrefixes = prevDoc.tagPrefixes.map(copyTagPrefix);
492
416
  doc.version = prevDoc.version;
493
417
  }
494
-
495
418
  doc.commentBefore = directiveComments.join('\n') || null;
496
419
  }
497
420
 
@@ -499,7 +422,6 @@ function assertCollection(contents) {
499
422
  if (contents instanceof resolveSeq.Collection) return true;
500
423
  throw new Error('Expected a YAML collection as document contents');
501
424
  }
502
-
503
425
  class Document {
504
426
  constructor(options) {
505
427
  this.anchors = new Anchors(options.anchorPrefix);
@@ -514,83 +436,67 @@ class Document {
514
436
  this.version = null;
515
437
  this.warnings = [];
516
438
  }
517
-
518
439
  add(value) {
519
440
  assertCollection(this.contents);
520
441
  return this.contents.add(value);
521
442
  }
522
-
523
443
  addIn(path, value) {
524
444
  assertCollection(this.contents);
525
445
  this.contents.addIn(path, value);
526
446
  }
527
-
528
447
  delete(key) {
529
448
  assertCollection(this.contents);
530
449
  return this.contents.delete(key);
531
450
  }
532
-
533
451
  deleteIn(path) {
534
452
  if (resolveSeq.isEmptyPath(path)) {
535
453
  if (this.contents == null) return false;
536
454
  this.contents = null;
537
455
  return true;
538
456
  }
539
-
540
457
  assertCollection(this.contents);
541
458
  return this.contents.deleteIn(path);
542
459
  }
543
-
544
460
  getDefaults() {
545
461
  return Document.defaults[this.version] || Document.defaults[this.options.version] || {};
546
462
  }
547
-
548
463
  get(key, keepScalar) {
549
464
  return this.contents instanceof resolveSeq.Collection ? this.contents.get(key, keepScalar) : undefined;
550
465
  }
551
-
552
466
  getIn(path, keepScalar) {
553
467
  if (resolveSeq.isEmptyPath(path)) return !keepScalar && this.contents instanceof resolveSeq.Scalar ? this.contents.value : this.contents;
554
468
  return this.contents instanceof resolveSeq.Collection ? this.contents.getIn(path, keepScalar) : undefined;
555
469
  }
556
-
557
470
  has(key) {
558
471
  return this.contents instanceof resolveSeq.Collection ? this.contents.has(key) : false;
559
472
  }
560
-
561
473
  hasIn(path) {
562
474
  if (resolveSeq.isEmptyPath(path)) return this.contents !== undefined;
563
475
  return this.contents instanceof resolveSeq.Collection ? this.contents.hasIn(path) : false;
564
476
  }
565
-
566
477
  set(key, value) {
567
478
  assertCollection(this.contents);
568
479
  this.contents.set(key, value);
569
480
  }
570
-
571
481
  setIn(path, value) {
572
482
  if (resolveSeq.isEmptyPath(path)) this.contents = value;else {
573
483
  assertCollection(this.contents);
574
484
  this.contents.setIn(path, value);
575
485
  }
576
486
  }
577
-
578
487
  setSchema(id, customTags) {
579
488
  if (!id && !customTags && this.schema) return;
580
489
  if (typeof id === 'number') id = id.toFixed(1);
581
-
582
490
  if (id === '1.0' || id === '1.1' || id === '1.2') {
583
491
  if (this.version) this.version = id;else this.options.version = id;
584
492
  delete this.options.schema;
585
493
  } else if (id && typeof id === 'string') {
586
494
  this.options.schema = id;
587
495
  }
588
-
589
496
  if (Array.isArray(customTags)) this.options.customTags = customTags;
590
497
  const opt = Object.assign({}, this.getDefaults(), this.options);
591
498
  this.schema = new Schema.Schema(opt);
592
499
  }
593
-
594
500
  parse(node, prevDoc) {
595
501
  if (this.options.keepCstNodes) this.cstNode = node;
596
502
  if (this.options.keepNodeTypes) this.type = 'DOCUMENT';
@@ -601,12 +507,10 @@ class Document {
601
507
  error,
602
508
  valueRange
603
509
  } = node;
604
-
605
510
  if (error) {
606
511
  if (!error.source) error.source = this;
607
512
  this.errors.push(error);
608
513
  }
609
-
610
514
  parseDirectives(this, directives, prevDoc);
611
515
  if (directivesEndMarker) this.directivesEndMarker = true;
612
516
  this.range = valueRange ? [valueRange.start, valueRange.end] : null;
@@ -614,23 +518,17 @@ class Document {
614
518
  this.anchors._cstAliases = [];
615
519
  parseContents(this, contents);
616
520
  this.anchors.resolveNodes();
617
-
618
521
  if (this.options.prettyErrors) {
619
522
  for (const error of this.errors) if (error instanceof PlainValue.YAMLError) error.makePretty();
620
-
621
523
  for (const warn of this.warnings) if (warn instanceof PlainValue.YAMLError) warn.makePretty();
622
524
  }
623
-
624
525
  return this;
625
526
  }
626
-
627
527
  listNonDefaultTags() {
628
528
  return listTagNames(this.contents).filter(t => t.indexOf(Schema.Schema.defaultPrefix) !== 0);
629
529
  }
630
-
631
530
  setTagPrefix(handle, prefix) {
632
531
  if (handle[0] !== '!' || handle[handle.length - 1] !== '!') throw new Error('Handle must start and end with !');
633
-
634
532
  if (prefix) {
635
533
  const prev = this.tagPrefixes.find(p => p.handle === handle);
636
534
  if (prev) prev.prefix = prefix;else this.tagPrefixes.push({
@@ -641,7 +539,6 @@ class Document {
641
539
  this.tagPrefixes = this.tagPrefixes.filter(p => p.handle !== handle);
642
540
  }
643
541
  }
644
-
645
542
  toJSON(arg, onAnchor) {
646
543
  const {
647
544
  keepBlobsInJSON,
@@ -656,7 +553,6 @@ class Document {
656
553
  mapAsMap: keep && !!mapAsMap,
657
554
  maxAliasCount,
658
555
  stringify // Requiring directly in Pair would create circular dependencies
659
-
660
556
  };
661
557
  const anchorNames = Object.keys(this.anchors.map);
662
558
  if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(name => [this.anchors.map[name], {
@@ -671,31 +567,24 @@ class Document {
671
567
  } of ctx.anchors.values()) onAnchor(res, count);
672
568
  return res;
673
569
  }
674
-
675
570
  toString() {
676
571
  if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified');
677
572
  const indentSize = this.options.indent;
678
-
679
573
  if (!Number.isInteger(indentSize) || indentSize <= 0) {
680
574
  const s = JSON.stringify(indentSize);
681
575
  throw new Error(`"indent" option must be a positive integer, not ${s}`);
682
576
  }
683
-
684
577
  this.setSchema();
685
578
  const lines = [];
686
579
  let hasDirectives = false;
687
-
688
580
  if (this.version) {
689
581
  let vd = '%YAML 1.2';
690
-
691
582
  if (this.schema.name === 'yaml-1.1') {
692
583
  if (this.version === '1.0') vd = '%YAML:1.0';else if (this.version === '1.1') vd = '%YAML 1.1';
693
584
  }
694
-
695
585
  lines.push(vd);
696
586
  hasDirectives = true;
697
587
  }
698
-
699
588
  const tagNames = this.listNonDefaultTags();
700
589
  this.tagPrefixes.forEach(({
701
590
  handle,
@@ -707,49 +596,40 @@ class Document {
707
596
  }
708
597
  });
709
598
  if (hasDirectives || this.directivesEndMarker) lines.push('---');
710
-
711
599
  if (this.commentBefore) {
712
600
  if (hasDirectives || !this.directivesEndMarker) lines.unshift('');
713
601
  lines.unshift(this.commentBefore.replace(/^/gm, '#'));
714
602
  }
715
-
716
603
  const ctx = {
717
604
  anchors: Object.create(null),
718
605
  doc: this,
719
606
  indent: '',
720
607
  indentStep: ' '.repeat(indentSize),
721
608
  stringify // Requiring directly in nodes would create circular dependencies
722
-
723
609
  };
724
610
  let chompKeep = false;
725
611
  let contentComment = null;
726
-
727
612
  if (this.contents) {
728
613
  if (this.contents instanceof resolveSeq.Node) {
729
614
  if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
730
- if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
731
-
615
+ if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#'));
616
+ // top-level block scalars need to be indented if followed by a comment
732
617
  ctx.forceBlockIndent = !!this.comment;
733
618
  contentComment = this.contents.comment;
734
619
  }
735
-
736
620
  const onChompKeep = contentComment ? null : () => chompKeep = true;
737
621
  const body = stringify(this.contents, ctx, () => contentComment = null, onChompKeep);
738
622
  lines.push(resolveSeq.addComment(body, '', contentComment));
739
623
  } else if (this.contents !== undefined) {
740
624
  lines.push(stringify(this.contents, ctx));
741
625
  }
742
-
743
626
  if (this.comment) {
744
627
  if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '') lines.push('');
745
628
  lines.push(this.comment.replace(/^/gm, '#'));
746
629
  }
747
-
748
630
  return lines.join('\n') + '\n';
749
631
  }
750
-
751
632
  }
752
-
753
633
  PlainValue._defineProperty(Document, "defaults", documentOptions);
754
634
 
755
635
  exports.Document = Document;