projen 0.53.8 → 0.53.11

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 (158) hide show
  1. package/.jsii +27 -9
  2. package/changelog.md +1 -1
  3. package/docs/api/API.md +2 -0
  4. package/lib/awscdk/auto-discover.js +4 -4
  5. package/lib/awscdk/awscdk-app-java.js +3 -3
  6. package/lib/awscdk/awscdk-app-py.js +11 -9
  7. package/lib/awscdk/awscdk-app-ts.js +4 -4
  8. package/lib/awscdk/awscdk-construct.js +2 -2
  9. package/lib/awscdk/awscdk-deps-java.js +1 -1
  10. package/lib/awscdk/awscdk-deps-js.js +1 -1
  11. package/lib/awscdk/awscdk-deps.js +1 -1
  12. package/lib/awscdk/cdk-config.js +1 -1
  13. package/lib/awscdk/cdk-tasks.js +1 -1
  14. package/lib/awscdk/integration-test.js +1 -1
  15. package/lib/awscdk/lambda-extension.js +1 -1
  16. package/lib/awscdk/lambda-function.js +2 -2
  17. package/lib/build/build-workflow.js +1 -1
  18. package/lib/cdk/auto-discover-base.js +2 -2
  19. package/lib/cdk/construct-lib.js +1 -1
  20. package/lib/cdk/integration-test-base.js +1 -1
  21. package/lib/cdk/jsii-docgen.js +1 -1
  22. package/lib/cdk/jsii-project.js +1 -1
  23. package/lib/cdk8s/auto-discover.js +2 -2
  24. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  25. package/lib/cdk8s/cdk8s-construct.js +1 -1
  26. package/lib/cdk8s/integration-test.js +1 -1
  27. package/lib/cdktf/cdktf-construct.js +1 -1
  28. package/lib/component.js +1 -1
  29. package/lib/dependencies.js +1 -1
  30. package/lib/dev-env.js +1 -1
  31. package/lib/docker-compose.js +2 -2
  32. package/lib/file.js +1 -1
  33. package/lib/gitattributes.js +1 -1
  34. package/lib/github/auto-approve.js +1 -1
  35. package/lib/github/auto-merge.js +1 -1
  36. package/lib/github/dependabot.js +1 -1
  37. package/lib/github/github-project.js +1 -1
  38. package/lib/github/github.js +1 -1
  39. package/lib/github/mergify.js +1 -1
  40. package/lib/github/pr-template.js +1 -1
  41. package/lib/github/pull-request-lint.js +1 -1
  42. package/lib/github/stale.js +1 -1
  43. package/lib/github/task-workflow.js +1 -1
  44. package/lib/github/workflows.js +1 -1
  45. package/lib/gitlab/configuration.js +1 -1
  46. package/lib/gitlab/gitlab-configuration.js +1 -1
  47. package/lib/gitlab/nested-configuration.js +1 -1
  48. package/lib/gitpod.js +1 -1
  49. package/lib/ignore-file.js +1 -1
  50. package/lib/ini.js +1 -1
  51. package/lib/java/java-project.js +1 -1
  52. package/lib/java/junit.js +1 -1
  53. package/lib/java/maven-compile.js +1 -1
  54. package/lib/java/maven-packaging.js +1 -1
  55. package/lib/java/maven-sample.js +1 -1
  56. package/lib/java/pom.js +1 -1
  57. package/lib/java/projenrc.js +1 -1
  58. package/lib/javascript/bundler.js +1 -1
  59. package/lib/javascript/eslint.js +1 -1
  60. package/lib/javascript/jest.js +1 -1
  61. package/lib/javascript/node-package.js +1 -1
  62. package/lib/javascript/node-project.js +1 -1
  63. package/lib/javascript/npm-config.js +1 -1
  64. package/lib/javascript/prettier.js +1 -1
  65. package/lib/javascript/projenrc.js +1 -1
  66. package/lib/javascript/typescript-config.js +1 -1
  67. package/lib/javascript/upgrade-dependencies.js +2 -2
  68. package/lib/json.js +1 -1
  69. package/lib/license.js +1 -1
  70. package/lib/logger.js +1 -1
  71. package/lib/makefile.js +1 -1
  72. package/lib/object-file.js +1 -1
  73. package/lib/project-build.js +1 -1
  74. package/lib/project.js +1 -1
  75. package/lib/projects.js +1 -1
  76. package/lib/projenrc-json.js +1 -1
  77. package/lib/python/pip.js +1 -1
  78. package/lib/python/poetry.js +2 -2
  79. package/lib/python/projenrc.js +1 -1
  80. package/lib/python/pytest-sample.js +1 -1
  81. package/lib/python/pytest.js +1 -1
  82. package/lib/python/python-project.js +1 -1
  83. package/lib/python/python-sample.js +1 -1
  84. package/lib/python/requirements-file.js +1 -1
  85. package/lib/python/setuppy.js +1 -1
  86. package/lib/python/setuptools.js +1 -1
  87. package/lib/python/venv.js +1 -1
  88. package/lib/readme.js +1 -1
  89. package/lib/release/publisher.js +1 -1
  90. package/lib/release/release-trigger.js +1 -1
  91. package/lib/release/release.js +1 -1
  92. package/lib/sample-file.js +2 -2
  93. package/lib/semver.js +1 -1
  94. package/lib/source-code.d.ts +6 -0
  95. package/lib/source-code.js +6 -4
  96. package/lib/task-runtime.js +1 -1
  97. package/lib/task.js +1 -1
  98. package/lib/tasks.js +1 -1
  99. package/lib/testing.js +1 -1
  100. package/lib/textfile.js +1 -1
  101. package/lib/toml.js +1 -1
  102. package/lib/typescript/projenrc.js +1 -1
  103. package/lib/typescript/typescript-typedoc.js +1 -1
  104. package/lib/typescript/typescript.js +3 -3
  105. package/lib/version.js +1 -1
  106. package/lib/vscode/devcontainer.js +1 -1
  107. package/lib/vscode/launch-config.js +1 -1
  108. package/lib/vscode/vscode.js +1 -1
  109. package/lib/web/next.js +3 -3
  110. package/lib/web/postcss.js +1 -1
  111. package/lib/web/react.js +4 -4
  112. package/lib/web/tailwind.js +1 -1
  113. package/lib/xmlfile.js +1 -1
  114. package/lib/yaml.js +1 -1
  115. package/node_modules/xmlbuilder2/node_modules/@types/node/README.md +1 -1
  116. package/node_modules/xmlbuilder2/node_modules/@types/node/fs.d.ts +48 -14
  117. package/node_modules/xmlbuilder2/node_modules/@types/node/package.json +2 -2
  118. package/node_modules/yaml/browser/dist/compose/compose-doc.js +1 -1
  119. package/node_modules/yaml/browser/dist/compose/compose-node.js +13 -4
  120. package/node_modules/yaml/browser/dist/compose/composer.js +5 -7
  121. package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +9 -2
  122. package/node_modules/yaml/browser/dist/compose/resolve-props.js +2 -0
  123. package/node_modules/yaml/browser/dist/doc/Document.js +9 -2
  124. package/node_modules/yaml/browser/dist/doc/directives.js +7 -4
  125. package/node_modules/yaml/browser/dist/index.js +1 -2
  126. package/node_modules/yaml/browser/dist/parse/lexer.js +16 -7
  127. package/node_modules/yaml/browser/dist/parse/parser.js +64 -30
  128. package/node_modules/yaml/browser/dist/schema/common/null.js +3 -1
  129. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +26 -8
  130. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +1 -1
  131. package/node_modules/yaml/browser/dist/visit.js +150 -62
  132. package/node_modules/yaml/dist/compose/compose-doc.js +1 -1
  133. package/node_modules/yaml/dist/compose/compose-node.js +13 -4
  134. package/node_modules/yaml/dist/compose/composer.d.ts +1 -1
  135. package/node_modules/yaml/dist/compose/composer.js +7 -9
  136. package/node_modules/yaml/dist/compose/resolve-block-scalar.js +9 -2
  137. package/node_modules/yaml/dist/compose/resolve-props.js +2 -0
  138. package/node_modules/yaml/dist/doc/Document.d.ts +1 -1
  139. package/node_modules/yaml/dist/doc/Document.js +16 -9
  140. package/node_modules/yaml/dist/doc/directives.d.ts +3 -1
  141. package/node_modules/yaml/dist/doc/directives.js +7 -4
  142. package/node_modules/yaml/dist/index.d.ts +2 -2
  143. package/node_modules/yaml/dist/index.js +1 -2
  144. package/node_modules/yaml/dist/options.d.ts +0 -8
  145. package/node_modules/yaml/dist/parse/lexer.js +16 -7
  146. package/node_modules/yaml/dist/parse/parser.js +64 -30
  147. package/node_modules/yaml/dist/schema/common/null.js +3 -1
  148. package/node_modules/yaml/dist/stringify/stringifyDocument.js +26 -8
  149. package/node_modules/yaml/dist/stringify/stringifyPair.js +1 -1
  150. package/node_modules/yaml/dist/test-events.js +8 -9
  151. package/node_modules/yaml/dist/visit.d.ts +49 -10
  152. package/node_modules/yaml/dist/visit.js +149 -60
  153. package/node_modules/yaml/package.json +3 -3
  154. package/package.json +3 -3
  155. package/releasetag.txt +1 -1
  156. package/version.txt +1 -1
  157. package/node_modules/yaml/browser/dist/options.js +0 -18
  158. package/node_modules/yaml/dist/options.js +0 -20
@@ -5,7 +5,6 @@ var Collection = require('../nodes/Collection.js');
5
5
  var Node = require('../nodes/Node.js');
6
6
  var Pair = require('../nodes/Pair.js');
7
7
  var toJS = require('../nodes/toJS.js');
8
- var options = require('../options.js');
9
8
  var Schema = require('../schema/Schema.js');
10
9
  var stringify = require('../stringify/stringify.js');
11
10
  var stringifyDocument = require('../stringify/stringifyDocument.js');
@@ -15,7 +14,7 @@ var createNode = require('./createNode.js');
15
14
  var directives = require('./directives.js');
16
15
 
17
16
  class Document {
18
- constructor(value, replacer, options$1) {
17
+ constructor(value, replacer, options) {
19
18
  /** A comment before this Document */
20
19
  this.commentBefore = null;
21
20
  /** A comment immediately after this Document */
@@ -29,25 +28,33 @@ class Document {
29
28
  if (typeof replacer === 'function' || Array.isArray(replacer)) {
30
29
  _replacer = replacer;
31
30
  }
32
- else if (options$1 === undefined && replacer) {
33
- options$1 = replacer;
31
+ else if (options === undefined && replacer) {
32
+ options = replacer;
34
33
  replacer = undefined;
35
34
  }
36
- const opt = Object.assign({}, options.defaultOptions, options$1);
35
+ const opt = Object.assign({
36
+ intAsBigInt: false,
37
+ keepSourceTokens: false,
38
+ logLevel: 'warn',
39
+ prettyErrors: true,
40
+ strict: true,
41
+ uniqueKeys: true,
42
+ version: '1.2'
43
+ }, options);
37
44
  this.options = opt;
38
45
  let { version } = opt;
39
- if (options$1 === null || options$1 === void 0 ? void 0 : options$1.directives) {
40
- this.directives = options$1.directives.atDocument();
46
+ if (options === null || options === void 0 ? void 0 : options.directives) {
47
+ this.directives = options.directives.atDocument();
41
48
  if (this.directives.yaml.explicit)
42
49
  version = this.directives.yaml.version;
43
50
  }
44
51
  else
45
52
  this.directives = new directives.Directives({ version });
46
- this.setSchema(version, options$1);
53
+ this.setSchema(version, options);
47
54
  if (value === undefined)
48
55
  this.contents = null;
49
56
  else {
50
- this.contents = this.createNode(value, _replacer, options$1);
57
+ this.contents = this.createNode(value, _replacer, options);
51
58
  }
52
59
  }
53
60
  /**
@@ -11,7 +11,9 @@ export declare class Directives {
11
11
  * The directives-end/doc-start marker `---`. If `null`, a marker may still be
12
12
  * included in the document's stringified representation.
13
13
  */
14
- marker: true | null;
14
+ docStart: true | null;
15
+ /** The doc-end marker `...`. */
16
+ docEnd: boolean;
15
17
  /**
16
18
  * Used when parsing YAML 1.1, where:
17
19
  * > If the document specifies no directives, it is parsed using the same
@@ -18,13 +18,15 @@ class Directives {
18
18
  * The directives-end/doc-start marker `---`. If `null`, a marker may still be
19
19
  * included in the document's stringified representation.
20
20
  */
21
- this.marker = null;
21
+ this.docStart = null;
22
+ /** The doc-end marker `...`. */
23
+ this.docEnd = false;
22
24
  this.yaml = Object.assign({}, Directives.defaultYaml, yaml);
23
25
  this.tags = Object.assign({}, Directives.defaultTags, tags);
24
26
  }
25
27
  clone() {
26
28
  const copy = new Directives(this.yaml, this.tags);
27
- copy.marker = this.marker;
29
+ copy.docStart = this.docStart;
28
30
  return copy;
29
31
  }
30
32
  /**
@@ -73,7 +75,7 @@ class Directives {
73
75
  }
74
76
  case '%YAML': {
75
77
  this.yaml.explicit = true;
76
- if (parts.length < 1) {
78
+ if (parts.length !== 1) {
77
79
  onError(0, '%YAML directive should contain exactly one part');
78
80
  return false;
79
81
  }
@@ -83,7 +85,8 @@ class Directives {
83
85
  return true;
84
86
  }
85
87
  else {
86
- onError(6, `Unsupported YAML version ${version}`, true);
88
+ const isValid = /^\d+\.\d+$/.test(version);
89
+ onError(6, `Unsupported YAML version ${version}`, isValid);
87
90
  return false;
88
91
  }
89
92
  }
@@ -8,7 +8,7 @@ export { Pair } from './nodes/Pair.js';
8
8
  export { Scalar } from './nodes/Scalar.js';
9
9
  export { YAMLMap } from './nodes/YAMLMap.js';
10
10
  export { YAMLSeq } from './nodes/YAMLSeq.js';
11
- export { CreateNodeOptions, defaultOptions, DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, ToStringOptions } from './options.js';
11
+ export type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, ToStringOptions } from './options.js';
12
12
  export * as CST from './parse/cst.js';
13
13
  export { Lexer } from './parse/lexer.js';
14
14
  export { LineCounter } from './parse/line-counter.js';
@@ -16,4 +16,4 @@ export { Parser } from './parse/parser.js';
16
16
  export { EmptyStream, parse, parseAllDocuments, parseDocument, stringify } from './public-api.js';
17
17
  export type { TagId, Tags } from './schema/tags';
18
18
  export type { CollectionTag, ScalarTag } from './schema/types';
19
- export { visit, visitor, visitorFn } from './visit.js';
19
+ export { asyncVisitor, asyncVisitorFn, visit, visitAsync, visitor, visitorFn } from './visit.js';
@@ -10,7 +10,6 @@ var Pair = require('./nodes/Pair.js');
10
10
  var Scalar = require('./nodes/Scalar.js');
11
11
  var YAMLMap = require('./nodes/YAMLMap.js');
12
12
  var YAMLSeq = require('./nodes/YAMLSeq.js');
13
- var options = require('./options.js');
14
13
  var cst = require('./parse/cst.js');
15
14
  var lexer = require('./parse/lexer.js');
16
15
  var lineCounter = require('./parse/line-counter.js');
@@ -39,7 +38,6 @@ exports.Pair = Pair.Pair;
39
38
  exports.Scalar = Scalar.Scalar;
40
39
  exports.YAMLMap = YAMLMap.YAMLMap;
41
40
  exports.YAMLSeq = YAMLSeq.YAMLSeq;
42
- exports.defaultOptions = options.defaultOptions;
43
41
  exports.CST = cst;
44
42
  exports.Lexer = lexer.Lexer;
45
43
  exports.LineCounter = lineCounter.LineCounter;
@@ -49,3 +47,4 @@ exports.parseAllDocuments = publicApi.parseAllDocuments;
49
47
  exports.parseDocument = publicApi.parseDocument;
50
48
  exports.stringify = publicApi.stringify;
51
49
  exports.visit = visit.visit;
50
+ exports.visitAsync = visit.visitAsync;
@@ -328,11 +328,3 @@ export declare type ToStringOptions = {
328
328
  */
329
329
  verifyAliasOrder?: boolean;
330
330
  };
331
- /**
332
- * `yaml` defines document-specific options in three places: as an argument of
333
- * parse, create and stringify calls, in the values of `YAML.defaultOptions`,
334
- * and in the version-dependent `YAML.Document.defaults` object. Values set in
335
- * `YAML.defaultOptions` override version-dependent defaults, and argument
336
- * options override both.
337
- */
338
- export declare const defaultOptions: Required<Omit<ParseOptions, 'lineCounter'> & Omit<DocumentOptions, 'directives'>>;
@@ -359,9 +359,14 @@ class Lexer {
359
359
  let indent = -1;
360
360
  do {
361
361
  nl = yield* this.pushNewline();
362
- sp = yield* this.pushSpaces(true);
363
- if (nl > 0)
362
+ if (nl > 0) {
363
+ sp = yield* this.pushSpaces(false);
364
364
  this.indentValue = indent = sp;
365
+ }
366
+ else {
367
+ sp = 0;
368
+ }
369
+ sp += yield* this.pushSpaces(true);
365
370
  } while (nl + sp > 0);
366
371
  const line = this.getLine();
367
372
  if (line === null)
@@ -535,9 +540,10 @@ class Lexer {
535
540
  let ch = this.buffer[i];
536
541
  if (ch === '\r')
537
542
  ch = this.buffer[--i];
543
+ const lastChar = i; // Drop the line if last char not more indented
538
544
  while (ch === ' ' || ch === '\t')
539
545
  ch = this.buffer[--i];
540
- if (ch === '\n' && i >= this.pos)
546
+ if (ch === '\n' && i >= this.pos && i + 1 + indent > lastChar)
541
547
  nl = i;
542
548
  else
543
549
  break;
@@ -620,11 +626,13 @@ class Lexer {
620
626
  return ((yield* this.pushUntil(isNotAnchorChar)) +
621
627
  (yield* this.pushSpaces(true)) +
622
628
  (yield* this.pushIndicators()));
623
- case ':':
624
- case '?': // this is an error outside flow collections
625
629
  case '-': // this is an error
626
- if (isEmpty(this.charAt(1))) {
627
- if (this.flowLevel === 0)
630
+ case '?': // this is an error outside flow collections
631
+ case ':': {
632
+ const inFlow = this.flowLevel > 0;
633
+ const ch1 = this.charAt(1);
634
+ if (isEmpty(ch1) || (inFlow && invalidFlowScalarChars.includes(ch1))) {
635
+ if (!inFlow)
628
636
  this.indentNext = this.indentValue + 1;
629
637
  else if (this.flowKey)
630
638
  this.flowKey = false;
@@ -632,6 +640,7 @@ class Lexer {
632
640
  (yield* this.pushSpaces(true)) +
633
641
  (yield* this.pushIndicators()));
634
642
  }
643
+ }
635
644
  }
636
645
  return 0;
637
646
  }
@@ -545,36 +545,70 @@ class Parser {
545
545
  this.onKeyLine = true;
546
546
  return;
547
547
  case 'map-value-ind':
548
- if (!it.sep)
549
- Object.assign(it, { key: null, sep: [this.sourceToken] });
550
- else if (it.value ||
551
- (atNextItem && !includesToken(it.start, 'explicit-key-ind')))
552
- map.items.push({ start: [], key: null, sep: [this.sourceToken] });
553
- else if (includesToken(it.sep, 'map-value-ind'))
554
- this.stack.push({
555
- type: 'block-map',
556
- offset: this.offset,
557
- indent: this.indent,
558
- items: [{ start: [], key: null, sep: [this.sourceToken] }]
559
- });
560
- else if (includesToken(it.start, 'explicit-key-ind') &&
561
- isFlowToken(it.key) &&
562
- !includesToken(it.sep, 'newline')) {
563
- const start = getFirstKeyStartProps(it.start);
564
- const key = it.key;
565
- const sep = it.sep;
566
- sep.push(this.sourceToken);
567
- // @ts-ignore type guard is wrong here
568
- delete it.key, delete it.sep;
569
- this.stack.push({
570
- type: 'block-map',
571
- offset: this.offset,
572
- indent: this.indent,
573
- items: [{ start, key, sep }]
574
- });
548
+ if (includesToken(it.start, 'explicit-key-ind')) {
549
+ if (!it.sep) {
550
+ if (includesToken(it.start, 'newline')) {
551
+ Object.assign(it, { key: null, sep: [this.sourceToken] });
552
+ }
553
+ else {
554
+ const start = getFirstKeyStartProps(it.start);
555
+ this.stack.push({
556
+ type: 'block-map',
557
+ offset: this.offset,
558
+ indent: this.indent,
559
+ items: [{ start, key: null, sep: [this.sourceToken] }]
560
+ });
561
+ }
562
+ }
563
+ else if (it.value) {
564
+ map.items.push({ start: [], key: null, sep: [this.sourceToken] });
565
+ }
566
+ else if (includesToken(it.sep, 'map-value-ind')) {
567
+ this.stack.push({
568
+ type: 'block-map',
569
+ offset: this.offset,
570
+ indent: this.indent,
571
+ items: [{ start: [], key: null, sep: [this.sourceToken] }]
572
+ });
573
+ }
574
+ else if (isFlowToken(it.key) &&
575
+ !includesToken(it.sep, 'newline')) {
576
+ const start = getFirstKeyStartProps(it.start);
577
+ const key = it.key;
578
+ const sep = it.sep;
579
+ sep.push(this.sourceToken);
580
+ // @ts-expect-error type guard is wrong here
581
+ delete it.key, delete it.sep;
582
+ this.stack.push({
583
+ type: 'block-map',
584
+ offset: this.offset,
585
+ indent: this.indent,
586
+ items: [{ start, key, sep }]
587
+ });
588
+ }
589
+ else {
590
+ it.sep.push(this.sourceToken);
591
+ }
592
+ }
593
+ else {
594
+ if (!it.sep) {
595
+ Object.assign(it, { key: null, sep: [this.sourceToken] });
596
+ }
597
+ else if (it.value || atNextItem) {
598
+ map.items.push({ start: [], key: null, sep: [this.sourceToken] });
599
+ }
600
+ else if (includesToken(it.sep, 'map-value-ind')) {
601
+ this.stack.push({
602
+ type: 'block-map',
603
+ offset: this.offset,
604
+ indent: this.indent,
605
+ items: [{ start: [], key: null, sep: [this.sourceToken] }]
606
+ });
607
+ }
608
+ else {
609
+ it.sep.push(this.sourceToken);
610
+ }
575
611
  }
576
- else
577
- it.sep.push(this.sourceToken);
578
612
  this.onKeyLine = true;
579
613
  return;
580
614
  case 'alias':
@@ -738,7 +772,7 @@ class Parser {
738
772
  else {
739
773
  const parent = this.peek(2);
740
774
  if (parent.type === 'block-map' &&
741
- (this.type === 'map-value-ind' ||
775
+ ((this.type === 'map-value-ind' && parent.indent === fc.indent) ||
742
776
  (this.type === 'newline' &&
743
777
  !parent.items[parent.items.length - 1].sep))) {
744
778
  yield* this.pop();
@@ -9,7 +9,9 @@ const nullTag = {
9
9
  tag: 'tag:yaml.org,2002:null',
10
10
  test: /^(?:~|[Nn]ull|NULL)?$/,
11
11
  resolve: () => new Scalar.Scalar(null),
12
- stringify: ({ source }, ctx) => source && nullTag.test.test(source) ? source : ctx.options.nullStr
12
+ stringify: ({ source }, ctx) => typeof source === 'string' && nullTag.test.test(source)
13
+ ? source
14
+ : ctx.options.nullStr
13
15
  };
14
16
 
15
17
  exports.nullTag = nullTag;
@@ -5,6 +5,7 @@ var stringify = require('./stringify.js');
5
5
  var stringifyComment = require('./stringifyComment.js');
6
6
 
7
7
  function stringifyDocument(doc, options) {
8
+ var _a;
8
9
  const lines = [];
9
10
  let hasDirectives = options.directives === true;
10
11
  if (options.directives !== false && doc.directives) {
@@ -13,7 +14,7 @@ function stringifyDocument(doc, options) {
13
14
  lines.push(dir);
14
15
  hasDirectives = true;
15
16
  }
16
- else if (doc.directives.marker)
17
+ else if (doc.directives.docStart)
17
18
  hasDirectives = true;
18
19
  }
19
20
  if (hasDirectives)
@@ -56,13 +57,30 @@ function stringifyDocument(doc, options) {
56
57
  else {
57
58
  lines.push(stringify.stringify(doc.contents, ctx));
58
59
  }
59
- let dc = doc.comment;
60
- if (dc && chompKeep)
61
- dc = dc.replace(/^\n+/, '');
62
- if (dc) {
63
- if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '')
64
- lines.push('');
65
- lines.push(stringifyComment.indentComment(commentString(dc), ''));
60
+ if ((_a = doc.directives) === null || _a === void 0 ? void 0 : _a.docEnd) {
61
+ if (doc.comment) {
62
+ const cs = commentString(doc.comment);
63
+ if (cs.includes('\n')) {
64
+ lines.push('...');
65
+ lines.push(stringifyComment.indentComment(cs, ''));
66
+ }
67
+ else {
68
+ lines.push(`... ${cs}`);
69
+ }
70
+ }
71
+ else {
72
+ lines.push('...');
73
+ }
74
+ }
75
+ else {
76
+ let dc = doc.comment;
77
+ if (dc && chompKeep)
78
+ dc = dc.replace(/^\n+/, '');
79
+ if (dc) {
80
+ if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '')
81
+ lines.push('');
82
+ lines.push(stringifyComment.indentComment(commentString(dc), ''));
83
+ }
66
84
  }
67
85
  return lines.join('\n') + '\n';
68
86
  }
@@ -41,7 +41,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
41
41
  if (allNullValues || value == null) {
42
42
  if (keyCommentDone && onComment)
43
43
  onComment();
44
- return explicitKey ? `? ${str}` : str;
44
+ return str === '' ? '?' : explicitKey ? `? ${str}` : str;
45
45
  }
46
46
  }
47
47
  else if ((allNullValues && !simpleKeys) || (value == null && explicitKey)) {
@@ -36,24 +36,23 @@ function testEvents(src) {
36
36
  let root = doc.contents;
37
37
  if (Array.isArray(root))
38
38
  root = root[0];
39
- // eslint-disable-next-line no-sparse-arrays
40
- const [rootStart, , rootEnd] = doc.range || [0, , 0];
39
+ const [rootStart] = doc.range || [0];
41
40
  const error = doc.errors[0];
42
41
  if (error && (!error.pos || error.pos[0] < rootStart))
43
42
  throw new Error();
44
43
  let docStart = '+DOC';
45
- if (doc.directives.marker)
44
+ if (doc.directives.docStart)
46
45
  docStart += ' ---';
47
- else if (doc.contents && doc.contents.range[2] === doc.contents.range[0])
46
+ else if (doc.contents &&
47
+ doc.contents.range[2] === doc.contents.range[0] &&
48
+ !doc.contents.anchor &&
49
+ !doc.contents.tag)
48
50
  continue;
49
51
  events.push(docStart);
50
52
  addEvents(events, doc, (_a = error === null || error === void 0 ? void 0 : error.pos[0]) !== null && _a !== void 0 ? _a : -1, root);
51
53
  let docEnd = '-DOC';
52
- if (rootEnd) {
53
- const post = src.slice(rootStart, rootEnd);
54
- if (/^\.\.\.($|\s)/m.test(post))
55
- docEnd += ' ...';
56
- }
54
+ if (doc.directives.docEnd)
55
+ docEnd += ' ...';
57
56
  events.push(docEnd);
58
57
  }
59
58
  }
@@ -16,6 +16,17 @@ export declare type visitor = visitorFn<unknown> | {
16
16
  Seq?: visitorFn<YAMLSeq>;
17
17
  Value?: visitorFn<Scalar | YAMLMap | YAMLSeq>;
18
18
  };
19
+ export declare type asyncVisitorFn<T> = (key: number | 'key' | 'value' | null, node: T, path: readonly (Document | Node | Pair)[]) => void | symbol | number | Node | Pair | Promise<void | symbol | number | Node | Pair>;
20
+ export declare type asyncVisitor = asyncVisitorFn<unknown> | {
21
+ Alias?: asyncVisitorFn<Alias>;
22
+ Collection?: asyncVisitorFn<YAMLMap | YAMLSeq>;
23
+ Map?: asyncVisitorFn<YAMLMap>;
24
+ Node?: asyncVisitorFn<Alias | Scalar | YAMLMap | YAMLSeq>;
25
+ Pair?: asyncVisitorFn<Pair>;
26
+ Scalar?: asyncVisitorFn<Scalar>;
27
+ Seq?: asyncVisitorFn<YAMLSeq>;
28
+ Value?: asyncVisitorFn<Scalar | YAMLMap | YAMLSeq>;
29
+ };
19
30
  /**
20
31
  * Apply a visitor to an AST node or document.
21
32
  *
@@ -46,18 +57,46 @@ export declare type visitor = visitorFn<unknown> | {
46
57
  * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
47
58
  * specific defined one will be used for each node.
48
59
  */
49
- export declare function visit(node: Node | Document | null, visitor: visitorFn<unknown> | {
50
- Alias?: visitorFn<Alias>;
51
- Collection?: visitorFn<YAMLMap | YAMLSeq>;
52
- Map?: visitorFn<YAMLMap>;
53
- Node?: visitorFn<Alias | Scalar | YAMLMap | YAMLSeq>;
54
- Pair?: visitorFn<Pair>;
55
- Scalar?: visitorFn<Scalar>;
56
- Seq?: visitorFn<YAMLSeq>;
57
- Value?: visitorFn<Scalar | YAMLMap | YAMLSeq>;
58
- }): void;
60
+ export declare function visit(node: Node | Document | null, visitor: visitor): void;
59
61
  export declare namespace visit {
60
62
  var BREAK: symbol;
61
63
  var SKIP: symbol;
62
64
  var REMOVE: symbol;
63
65
  }
66
+ /**
67
+ * Apply an async visitor to an AST node or document.
68
+ *
69
+ * Walks through the tree (depth-first) starting from `node`, calling a
70
+ * `visitor` function with three arguments:
71
+ * - `key`: For sequence values and map `Pair`, the node's index in the
72
+ * collection. Within a `Pair`, `'key'` or `'value'`, correspondingly.
73
+ * `null` for the root node.
74
+ * - `node`: The current node.
75
+ * - `path`: The ancestry of the current node.
76
+ *
77
+ * The return value of the visitor may be used to control the traversal:
78
+ * - `Promise`: Must resolve to one of the following values
79
+ * - `undefined` (default): Do nothing and continue
80
+ * - `visit.SKIP`: Do not visit the children of this node, continue with next
81
+ * sibling
82
+ * - `visit.BREAK`: Terminate traversal completely
83
+ * - `visit.REMOVE`: Remove the current node, then continue with the next one
84
+ * - `Node`: Replace the current node, then continue by visiting it
85
+ * - `number`: While iterating the items of a sequence or map, set the index
86
+ * of the next step. This is useful especially if the index of the current
87
+ * node has changed.
88
+ *
89
+ * If `visitor` is a single function, it will be called with all values
90
+ * encountered in the tree, including e.g. `null` values. Alternatively,
91
+ * separate visitor functions may be defined for each `Map`, `Pair`, `Seq`,
92
+ * `Alias` and `Scalar` node. To define the same visitor function for more than
93
+ * one node type, use the `Collection` (map and seq), `Value` (map, seq & scalar)
94
+ * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
95
+ * specific defined one will be used for each node.
96
+ */
97
+ export declare function visitAsync(node: Node | Document | null, visitor: asyncVisitor): Promise<void>;
98
+ export declare namespace visitAsync {
99
+ var BREAK: symbol;
100
+ var SKIP: symbol;
101
+ var REMOVE: symbol;
102
+ }