fumadocs-openapi 10.10.1 → 10.10.3

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 (127) hide show
  1. package/css/generated/shared.css +16 -8
  2. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js +239 -0
  3. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +187 -0
  4. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +136 -0
  5. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js +41 -0
  6. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +124 -0
  7. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js +109 -0
  8. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +30 -0
  9. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js +46 -0
  10. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +36 -0
  11. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js +49 -0
  12. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js +242 -0
  13. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js +247 -0
  14. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js +210 -0
  15. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js +100 -0
  16. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js +41 -0
  17. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +112 -0
  18. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js +8 -0
  19. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +146 -0
  20. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +5 -0
  21. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js +18 -0
  22. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js +11 -0
  23. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js +99 -0
  24. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js +30 -0
  25. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +315 -0
  26. package/dist/ui/schema/client.js +70 -69
  27. package/dist/utils/document/process.js +7 -12
  28. package/package.json +4 -7
  29. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/general/create-limiter.js +0 -43
  30. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/is-object.js +0 -27
  31. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/prevent-pollution.js +0 -33
  32. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/queue/queue.js +0 -106
  33. package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/string/generate-hash.js +0 -120
  34. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/bundle.js +0 -357
  35. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js +0 -73
  36. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js +0 -3
  37. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/parse-yaml/index.js +0 -1
  38. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js +0 -51
  39. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/value-generator.js +0 -102
  40. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/convert-to-local-ref.js +0 -24
  41. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/escape-json-pointer.js +0 -11
  42. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-schemas.js +0 -44
  43. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-segments-from-path.js +0 -10
  44. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-value-by-path.js +0 -42
  45. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-file-path.js +0 -23
  46. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-http-url.js +0 -23
  47. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-json-object.js +0 -28
  48. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-yaml.js +0 -21
  49. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/normalize.js +0 -33
  50. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/resolve-reference-path.js +0 -30
  51. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/set-value-at-path.js +0 -70
  52. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/to-relative-path.js +0 -33
  53. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/unescape-json-pointer.js +0 -12
  54. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +0 -19
  55. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -430
  56. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-collection.js +0 -50
  57. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-doc.js +0 -39
  58. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-node.js +0 -85
  59. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-scalar.js +0 -57
  60. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/composer.js +0 -193
  61. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-map.js +0 -82
  62. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +0 -174
  63. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +0 -40
  64. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-end.js +0 -36
  65. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +0 -153
  66. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +0 -203
  67. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-props.js +0 -105
  68. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-contains-newline.js +0 -27
  69. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +0 -25
  70. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +0 -10
  71. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-map-includes.js +0 -10
  72. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/Document.js +0 -277
  73. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/anchors.js +0 -62
  74. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/applyReviver.js +0 -38
  75. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/createNode.js +0 -61
  76. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/directives.js +0 -163
  77. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/errors.js +0 -48
  78. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/index.js +0 -16
  79. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/log.js +0 -6
  80. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Alias.js +0 -92
  81. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Collection.js +0 -117
  82. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Node.js +0 -32
  83. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Pair.js +0 -29
  84. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Scalar.js +0 -24
  85. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/YAMLMap.js +0 -106
  86. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +0 -104
  87. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +0 -49
  88. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/identity.js +0 -33
  89. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/toJS.js +0 -35
  90. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-scalar.js +0 -3
  91. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-visit.js +0 -89
  92. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst.js +0 -40
  93. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/lexer.js +0 -529
  94. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/line-counter.js +0 -45
  95. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/parser.js +0 -859
  96. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/public-api.js +0 -44
  97. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/Schema.js +0 -27
  98. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/map.js +0 -16
  99. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/null.js +0 -13
  100. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/seq.js +0 -16
  101. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/string.js +0 -14
  102. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/bool.js +0 -17
  103. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/float.js +0 -38
  104. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/int.js +0 -37
  105. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/schema.js +0 -23
  106. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/json/schema.js +0 -61
  107. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/tags.js +0 -81
  108. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +0 -52
  109. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +0 -24
  110. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +0 -41
  111. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +0 -70
  112. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +0 -39
  113. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +0 -60
  114. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +0 -56
  115. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +0 -39
  116. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +0 -65
  117. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +0 -79
  118. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +0 -111
  119. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringify.js +0 -105
  120. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +0 -116
  121. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyComment.js +0 -16
  122. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +0 -59
  123. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +0 -19
  124. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyPair.js +0 -95
  125. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyString.js +0 -222
  126. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/visit.js +0 -187
  127. package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/index.js +0 -16
@@ -1,193 +0,0 @@
1
- import { isCollection, isPair } from "../nodes/identity.js";
2
- import { Directives } from "../doc/directives.js";
3
- import { Document } from "../doc/Document.js";
4
- import { YAMLParseError, YAMLWarning } from "../errors.js";
5
- import { resolveEnd } from "./resolve-end.js";
6
- import { composeDoc } from "./compose-doc.js";
7
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/composer.js
8
- function getErrorPos(src) {
9
- if (typeof src === "number") return [src, src + 1];
10
- if (Array.isArray(src)) return src.length === 2 ? src : [src[0], src[1]];
11
- const { offset, source } = src;
12
- return [offset, offset + (typeof source === "string" ? source.length : 1)];
13
- }
14
- function parsePrelude(prelude) {
15
- let comment = "";
16
- let atComment = false;
17
- let afterEmptyLine = false;
18
- for (let i = 0; i < prelude.length; ++i) {
19
- const source = prelude[i];
20
- switch (source[0]) {
21
- case "#":
22
- comment += (comment === "" ? "" : afterEmptyLine ? "\n\n" : "\n") + (source.substring(1) || " ");
23
- atComment = true;
24
- afterEmptyLine = false;
25
- break;
26
- case "%":
27
- if (prelude[i + 1]?.[0] !== "#") i += 1;
28
- atComment = false;
29
- break;
30
- default:
31
- if (!atComment) afterEmptyLine = true;
32
- atComment = false;
33
- }
34
- }
35
- return {
36
- comment,
37
- afterEmptyLine
38
- };
39
- }
40
- /**
41
- * Compose a stream of CST nodes into a stream of YAML Documents.
42
- *
43
- * ```ts
44
- * import { Composer, Parser } from 'yaml'
45
- *
46
- * const src: string = ...
47
- * const tokens = new Parser().parse(src)
48
- * const docs = new Composer().compose(tokens)
49
- * ```
50
- */
51
- var Composer = class {
52
- constructor(options = {}) {
53
- this.doc = null;
54
- this.atDirectives = false;
55
- this.prelude = [];
56
- this.errors = [];
57
- this.warnings = [];
58
- this.onError = (source, code, message, warning) => {
59
- const pos = getErrorPos(source);
60
- if (warning) this.warnings.push(new YAMLWarning(pos, code, message));
61
- else this.errors.push(new YAMLParseError(pos, code, message));
62
- };
63
- this.directives = new Directives({ version: options.version || "1.2" });
64
- this.options = options;
65
- }
66
- decorate(doc, afterDoc) {
67
- const { comment, afterEmptyLine } = parsePrelude(this.prelude);
68
- if (comment) {
69
- const dc = doc.contents;
70
- if (afterDoc) doc.comment = doc.comment ? `${doc.comment}\n${comment}` : comment;
71
- else if (afterEmptyLine || doc.directives.docStart || !dc) doc.commentBefore = comment;
72
- else if (isCollection(dc) && !dc.flow && dc.items.length > 0) {
73
- let it = dc.items[0];
74
- if (isPair(it)) it = it.key;
75
- const cb = it.commentBefore;
76
- it.commentBefore = cb ? `${comment}\n${cb}` : comment;
77
- } else {
78
- const cb = dc.commentBefore;
79
- dc.commentBefore = cb ? `${comment}\n${cb}` : comment;
80
- }
81
- }
82
- if (afterDoc) {
83
- for (let i = 0; i < this.errors.length; ++i) doc.errors.push(this.errors[i]);
84
- for (let i = 0; i < this.warnings.length; ++i) doc.warnings.push(this.warnings[i]);
85
- } else {
86
- doc.errors = this.errors;
87
- doc.warnings = this.warnings;
88
- }
89
- this.prelude = [];
90
- this.errors = [];
91
- this.warnings = [];
92
- }
93
- /**
94
- * Current stream status information.
95
- *
96
- * Mostly useful at the end of input for an empty stream.
97
- */
98
- streamInfo() {
99
- return {
100
- comment: parsePrelude(this.prelude).comment,
101
- directives: this.directives,
102
- errors: this.errors,
103
- warnings: this.warnings
104
- };
105
- }
106
- /**
107
- * Compose tokens into documents.
108
- *
109
- * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
110
- * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
111
- */
112
- *compose(tokens, forceDoc = false, endOffset = -1) {
113
- for (const token of tokens) yield* this.next(token);
114
- yield* this.end(forceDoc, endOffset);
115
- }
116
- /** Advance the composer by one CST token. */
117
- *next(token) {
118
- switch (token.type) {
119
- case "directive":
120
- this.directives.add(token.source, (offset, message, warning) => {
121
- const pos = getErrorPos(token);
122
- pos[0] += offset;
123
- this.onError(pos, "BAD_DIRECTIVE", message, warning);
124
- });
125
- this.prelude.push(token.source);
126
- this.atDirectives = true;
127
- break;
128
- case "document": {
129
- const doc = composeDoc(this.options, this.directives, token, this.onError);
130
- if (this.atDirectives && !doc.directives.docStart) this.onError(token, "MISSING_CHAR", "Missing directives-end/doc-start indicator line");
131
- this.decorate(doc, false);
132
- if (this.doc) yield this.doc;
133
- this.doc = doc;
134
- this.atDirectives = false;
135
- break;
136
- }
137
- case "byte-order-mark":
138
- case "space": break;
139
- case "comment":
140
- case "newline":
141
- this.prelude.push(token.source);
142
- break;
143
- case "error": {
144
- const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message;
145
- const error = new YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
146
- if (this.atDirectives || !this.doc) this.errors.push(error);
147
- else this.doc.errors.push(error);
148
- break;
149
- }
150
- case "doc-end": {
151
- if (!this.doc) {
152
- this.errors.push(new YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", "Unexpected doc-end without preceding document"));
153
- break;
154
- }
155
- this.doc.directives.docEnd = true;
156
- const end = resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError);
157
- this.decorate(this.doc, true);
158
- if (end.comment) {
159
- const dc = this.doc.comment;
160
- this.doc.comment = dc ? `${dc}\n${end.comment}` : end.comment;
161
- }
162
- this.doc.range[2] = end.offset;
163
- break;
164
- }
165
- default: this.errors.push(new YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", `Unsupported token ${token.type}`));
166
- }
167
- }
168
- /**
169
- * Call at end of input to yield any remaining document.
170
- *
171
- * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
172
- * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
173
- */
174
- *end(forceDoc = false, endOffset = -1) {
175
- if (this.doc) {
176
- this.decorate(this.doc, true);
177
- yield this.doc;
178
- this.doc = null;
179
- } else if (forceDoc) {
180
- const doc = new Document(void 0, Object.assign({ _directives: this.directives }, this.options));
181
- if (this.atDirectives) this.onError(endOffset, "MISSING_CHAR", "Missing directives-end indicator line");
182
- doc.range = [
183
- 0,
184
- endOffset,
185
- endOffset
186
- ];
187
- this.decorate(doc, false);
188
- yield doc;
189
- }
190
- }
191
- };
192
- //#endregion
193
- export { Composer };
@@ -1,82 +0,0 @@
1
- import { Pair } from "../nodes/Pair.js";
2
- import { YAMLMap } from "../nodes/YAMLMap.js";
3
- import { resolveProps } from "./resolve-props.js";
4
- import { containsNewline } from "./util-contains-newline.js";
5
- import { flowIndentCheck } from "./util-flow-indent-check.js";
6
- import { mapIncludes } from "./util-map-includes.js";
7
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-map.js
8
- const startColMsg = "All mapping items must start at the same column";
9
- function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, tag) {
10
- const map = new (tag?.nodeClass ?? YAMLMap)(ctx.schema);
11
- if (ctx.atRoot) ctx.atRoot = false;
12
- let offset = bm.offset;
13
- let commentEnd = null;
14
- for (const collItem of bm.items) {
15
- const { start, key, sep, value } = collItem;
16
- const keyProps = resolveProps(start, {
17
- indicator: "explicit-key-ind",
18
- next: key ?? sep?.[0],
19
- offset,
20
- onError,
21
- parentIndent: bm.indent,
22
- startOnNewline: true
23
- });
24
- const implicitKey = !keyProps.found;
25
- if (implicitKey) {
26
- if (key) {
27
- if (key.type === "block-seq") onError(offset, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key");
28
- else if ("indent" in key && key.indent !== bm.indent) onError(offset, "BAD_INDENT", startColMsg);
29
- }
30
- if (!keyProps.anchor && !keyProps.tag && !sep) {
31
- commentEnd = keyProps.end;
32
- if (keyProps.comment) if (map.comment) map.comment += "\n" + keyProps.comment;
33
- else map.comment = keyProps.comment;
34
- continue;
35
- }
36
- if (keyProps.newlineAfterProp || containsNewline(key)) onError(key ?? start[start.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line");
37
- } else if (keyProps.found?.indent !== bm.indent) onError(offset, "BAD_INDENT", startColMsg);
38
- ctx.atKey = true;
39
- const keyStart = keyProps.end;
40
- const keyNode = key ? composeNode(ctx, key, keyProps, onError) : composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
41
- if (ctx.schema.compat) flowIndentCheck(bm.indent, key, onError);
42
- ctx.atKey = false;
43
- if (mapIncludes(ctx, map.items, keyNode)) onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
44
- const valueProps = resolveProps(sep ?? [], {
45
- indicator: "map-value-ind",
46
- next: value,
47
- offset: keyNode.range[2],
48
- onError,
49
- parentIndent: bm.indent,
50
- startOnNewline: !key || key.type === "block-scalar"
51
- });
52
- offset = valueProps.end;
53
- if (valueProps.found) {
54
- if (implicitKey) {
55
- if (value?.type === "block-map" && !valueProps.hasNewline) onError(offset, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings");
56
- if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024) onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
57
- }
58
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
59
- if (ctx.schema.compat) flowIndentCheck(bm.indent, value, onError);
60
- offset = valueNode.range[2];
61
- const pair = new Pair(keyNode, valueNode);
62
- if (ctx.options.keepSourceTokens) pair.srcToken = collItem;
63
- map.items.push(pair);
64
- } else {
65
- if (implicitKey) onError(keyNode.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values");
66
- if (valueProps.comment) if (keyNode.comment) keyNode.comment += "\n" + valueProps.comment;
67
- else keyNode.comment = valueProps.comment;
68
- const pair = new Pair(keyNode);
69
- if (ctx.options.keepSourceTokens) pair.srcToken = collItem;
70
- map.items.push(pair);
71
- }
72
- }
73
- if (commentEnd && commentEnd < offset) onError(commentEnd, "IMPOSSIBLE", "Map comment with trailing content");
74
- map.range = [
75
- bm.offset,
76
- offset,
77
- commentEnd ?? offset
78
- ];
79
- return map;
80
- }
81
- //#endregion
82
- export { resolveBlockMap };
@@ -1,174 +0,0 @@
1
- import { Scalar } from "../nodes/Scalar.js";
2
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js
3
- function resolveBlockScalar(ctx, scalar, onError) {
4
- const start = scalar.offset;
5
- const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError);
6
- if (!header) return {
7
- value: "",
8
- type: null,
9
- comment: "",
10
- range: [
11
- start,
12
- start,
13
- start
14
- ]
15
- };
16
- const type = header.mode === ">" ? Scalar.BLOCK_FOLDED : Scalar.BLOCK_LITERAL;
17
- const lines = scalar.source ? splitLines(scalar.source) : [];
18
- let chompStart = lines.length;
19
- for (let i = lines.length - 1; i >= 0; --i) {
20
- const content = lines[i][1];
21
- if (content === "" || content === "\r") chompStart = i;
22
- else break;
23
- }
24
- if (chompStart === 0) {
25
- const value = header.chomp === "+" && lines.length > 0 ? "\n".repeat(Math.max(1, lines.length - 1)) : "";
26
- let end = start + header.length;
27
- if (scalar.source) end += scalar.source.length;
28
- return {
29
- value,
30
- type,
31
- comment: header.comment,
32
- range: [
33
- start,
34
- end,
35
- end
36
- ]
37
- };
38
- }
39
- let trimIndent = scalar.indent + header.indent;
40
- let offset = scalar.offset + header.length;
41
- let contentStart = 0;
42
- for (let i = 0; i < chompStart; ++i) {
43
- const [indent, content] = lines[i];
44
- if (content === "" || content === "\r") {
45
- if (header.indent === 0 && indent.length > trimIndent) trimIndent = indent.length;
46
- } else {
47
- if (indent.length < trimIndent) onError(offset + indent.length, "MISSING_CHAR", "Block scalars with more-indented leading empty lines must use an explicit indentation indicator");
48
- if (header.indent === 0) trimIndent = indent.length;
49
- contentStart = i;
50
- if (trimIndent === 0 && !ctx.atRoot) onError(offset, "BAD_INDENT", "Block scalar values in collections must be indented");
51
- break;
52
- }
53
- offset += indent.length + content.length + 1;
54
- }
55
- for (let i = lines.length - 1; i >= chompStart; --i) if (lines[i][0].length > trimIndent) chompStart = i + 1;
56
- let value = "";
57
- let sep = "";
58
- let prevMoreIndented = false;
59
- for (let i = 0; i < contentStart; ++i) value += lines[i][0].slice(trimIndent) + "\n";
60
- for (let i = contentStart; i < chompStart; ++i) {
61
- let [indent, content] = lines[i];
62
- offset += indent.length + content.length + 1;
63
- const crlf = content[content.length - 1] === "\r";
64
- if (crlf) content = content.slice(0, -1);
65
- /* istanbul ignore if already caught in lexer */
66
- if (content && indent.length < trimIndent) {
67
- const message = `Block scalar lines must not be less indented than their ${header.indent ? "explicit indentation indicator" : "first line"}`;
68
- onError(offset - content.length - (crlf ? 2 : 1), "BAD_INDENT", message);
69
- indent = "";
70
- }
71
- if (type === Scalar.BLOCK_LITERAL) {
72
- value += sep + indent.slice(trimIndent) + content;
73
- sep = "\n";
74
- } else if (indent.length > trimIndent || content[0] === " ") {
75
- if (sep === " ") sep = "\n";
76
- else if (!prevMoreIndented && sep === "\n") sep = "\n\n";
77
- value += sep + indent.slice(trimIndent) + content;
78
- sep = "\n";
79
- prevMoreIndented = true;
80
- } else if (content === "") if (sep === "\n") value += "\n";
81
- else sep = "\n";
82
- else {
83
- value += sep + content;
84
- sep = " ";
85
- prevMoreIndented = false;
86
- }
87
- }
88
- switch (header.chomp) {
89
- case "-": break;
90
- case "+":
91
- for (let i = chompStart; i < lines.length; ++i) value += "\n" + lines[i][0].slice(trimIndent);
92
- if (value[value.length - 1] !== "\n") value += "\n";
93
- break;
94
- default: value += "\n";
95
- }
96
- const end = start + header.length + scalar.source.length;
97
- return {
98
- value,
99
- type,
100
- comment: header.comment,
101
- range: [
102
- start,
103
- end,
104
- end
105
- ]
106
- };
107
- }
108
- function parseBlockScalarHeader({ offset, props }, strict, onError) {
109
- /* istanbul ignore if should not happen */
110
- if (props[0].type !== "block-scalar-header") {
111
- onError(props[0], "IMPOSSIBLE", "Block scalar header not found");
112
- return null;
113
- }
114
- const { source } = props[0];
115
- const mode = source[0];
116
- let indent = 0;
117
- let chomp = "";
118
- let error = -1;
119
- for (let i = 1; i < source.length; ++i) {
120
- const ch = source[i];
121
- if (!chomp && (ch === "-" || ch === "+")) chomp = ch;
122
- else {
123
- const n = Number(ch);
124
- if (!indent && n) indent = n;
125
- else if (error === -1) error = offset + i;
126
- }
127
- }
128
- if (error !== -1) onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source}`);
129
- let hasSpace = false;
130
- let comment = "";
131
- let length = source.length;
132
- for (let i = 1; i < props.length; ++i) {
133
- const token = props[i];
134
- switch (token.type) {
135
- case "space": hasSpace = true;
136
- case "newline":
137
- length += token.source.length;
138
- break;
139
- case "comment":
140
- if (strict && !hasSpace) onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
141
- length += token.source.length;
142
- comment = token.source.substring(1);
143
- break;
144
- case "error":
145
- onError(token, "UNEXPECTED_TOKEN", token.message);
146
- length += token.source.length;
147
- break;
148
- /* istanbul ignore next should not happen */
149
- default: {
150
- onError(token, "UNEXPECTED_TOKEN", `Unexpected token in block scalar header: ${token.type}`);
151
- const ts = token.source;
152
- if (ts && typeof ts === "string") length += ts.length;
153
- }
154
- }
155
- }
156
- return {
157
- mode,
158
- indent,
159
- chomp,
160
- comment,
161
- length
162
- };
163
- }
164
- /** @returns Array of lines split up as `[indent, content]` */
165
- function splitLines(source) {
166
- const split = source.split(/\n( *)/);
167
- const first = split[0];
168
- const m = first.match(/^( *)/);
169
- const lines = [m?.[1] ? [m[1], first.slice(m[1].length)] : ["", first]];
170
- for (let i = 1; i < split.length; i += 2) lines.push([split[i], split[i + 1]]);
171
- return lines;
172
- }
173
- //#endregion
174
- export { resolveBlockScalar };
@@ -1,40 +0,0 @@
1
- import { YAMLSeq } from "../nodes/YAMLSeq.js";
2
- import { resolveProps } from "./resolve-props.js";
3
- import { flowIndentCheck } from "./util-flow-indent-check.js";
4
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-seq.js
5
- function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, tag) {
6
- const seq = new (tag?.nodeClass ?? YAMLSeq)(ctx.schema);
7
- if (ctx.atRoot) ctx.atRoot = false;
8
- if (ctx.atKey) ctx.atKey = false;
9
- let offset = bs.offset;
10
- let commentEnd = null;
11
- for (const { start, value } of bs.items) {
12
- const props = resolveProps(start, {
13
- indicator: "seq-item-ind",
14
- next: value,
15
- offset,
16
- onError,
17
- parentIndent: bs.indent,
18
- startOnNewline: true
19
- });
20
- if (!props.found) if (props.anchor || props.tag || value) if (value?.type === "block-seq") onError(props.end, "BAD_INDENT", "All sequence items must start at the same column");
21
- else onError(offset, "MISSING_CHAR", "Sequence item without - indicator");
22
- else {
23
- commentEnd = props.end;
24
- if (props.comment) seq.comment = props.comment;
25
- continue;
26
- }
27
- const node = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, start, null, props, onError);
28
- if (ctx.schema.compat) flowIndentCheck(bs.indent, value, onError);
29
- offset = node.range[2];
30
- seq.items.push(node);
31
- }
32
- seq.range = [
33
- bs.offset,
34
- offset,
35
- commentEnd ?? offset
36
- ];
37
- return seq;
38
- }
39
- //#endregion
40
- export { resolveBlockSeq };
@@ -1,36 +0,0 @@
1
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-end.js
2
- function resolveEnd(end, offset, reqSpace, onError) {
3
- let comment = "";
4
- if (end) {
5
- let hasSpace = false;
6
- let sep = "";
7
- for (const token of end) {
8
- const { source, type } = token;
9
- switch (type) {
10
- case "space":
11
- hasSpace = true;
12
- break;
13
- case "comment": {
14
- if (reqSpace && !hasSpace) onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
15
- const cb = source.substring(1) || " ";
16
- if (!comment) comment = cb;
17
- else comment += sep + cb;
18
- sep = "";
19
- break;
20
- }
21
- case "newline":
22
- if (comment) sep += source;
23
- hasSpace = true;
24
- break;
25
- default: onError(token, "UNEXPECTED_TOKEN", `Unexpected ${type} at node end`);
26
- }
27
- offset += source.length;
28
- }
29
- }
30
- return {
31
- comment,
32
- offset
33
- };
34
- }
35
- //#endregion
36
- export { resolveEnd };
@@ -1,153 +0,0 @@
1
- import { isPair } from "../nodes/identity.js";
2
- import { Pair } from "../nodes/Pair.js";
3
- import { YAMLMap } from "../nodes/YAMLMap.js";
4
- import { YAMLSeq } from "../nodes/YAMLSeq.js";
5
- import { resolveProps } from "./resolve-props.js";
6
- import { containsNewline } from "./util-contains-newline.js";
7
- import { mapIncludes } from "./util-map-includes.js";
8
- import { resolveEnd } from "./resolve-end.js";
9
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js
10
- const blockMsg = "Block collections are not allowed within flow collections";
11
- const isBlock = (token) => token && (token.type === "block-map" || token.type === "block-seq");
12
- function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError, tag) {
13
- const isMap = fc.start.source === "{";
14
- const fcName = isMap ? "flow map" : "flow sequence";
15
- const coll = new (tag?.nodeClass ?? (isMap ? YAMLMap : YAMLSeq))(ctx.schema);
16
- coll.flow = true;
17
- const atRoot = ctx.atRoot;
18
- if (atRoot) ctx.atRoot = false;
19
- if (ctx.atKey) ctx.atKey = false;
20
- let offset = fc.offset + fc.start.source.length;
21
- for (let i = 0; i < fc.items.length; ++i) {
22
- const collItem = fc.items[i];
23
- const { start, key, sep, value } = collItem;
24
- const props = resolveProps(start, {
25
- flow: fcName,
26
- indicator: "explicit-key-ind",
27
- next: key ?? sep?.[0],
28
- offset,
29
- onError,
30
- parentIndent: fc.indent,
31
- startOnNewline: false
32
- });
33
- if (!props.found) {
34
- if (!props.anchor && !props.tag && !sep && !value) {
35
- if (i === 0 && props.comma) onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
36
- else if (i < fc.items.length - 1) onError(props.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${fcName}`);
37
- if (props.comment) if (coll.comment) coll.comment += "\n" + props.comment;
38
- else coll.comment = props.comment;
39
- offset = props.end;
40
- continue;
41
- }
42
- if (!isMap && ctx.options.strict && containsNewline(key)) onError(key, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line");
43
- }
44
- if (i === 0) {
45
- if (props.comma) onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
46
- } else {
47
- if (!props.comma) onError(props.start, "MISSING_CHAR", `Missing , between ${fcName} items`);
48
- if (props.comment) {
49
- let prevItemComment = "";
50
- loop: for (const st of start) switch (st.type) {
51
- case "comma":
52
- case "space": break;
53
- case "comment":
54
- prevItemComment = st.source.substring(1);
55
- break loop;
56
- default: break loop;
57
- }
58
- if (prevItemComment) {
59
- let prev = coll.items[coll.items.length - 1];
60
- if (isPair(prev)) prev = prev.value ?? prev.key;
61
- if (prev.comment) prev.comment += "\n" + prevItemComment;
62
- else prev.comment = prevItemComment;
63
- props.comment = props.comment.substring(prevItemComment.length + 1);
64
- }
65
- }
66
- }
67
- if (!isMap && !sep && !props.found) {
68
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError);
69
- coll.items.push(valueNode);
70
- offset = valueNode.range[2];
71
- if (isBlock(value)) onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
72
- } else {
73
- ctx.atKey = true;
74
- const keyStart = props.end;
75
- const keyNode = key ? composeNode(ctx, key, props, onError) : composeEmptyNode(ctx, keyStart, start, null, props, onError);
76
- if (isBlock(key)) onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
77
- ctx.atKey = false;
78
- const valueProps = resolveProps(sep ?? [], {
79
- flow: fcName,
80
- indicator: "map-value-ind",
81
- next: value,
82
- offset: keyNode.range[2],
83
- onError,
84
- parentIndent: fc.indent,
85
- startOnNewline: false
86
- });
87
- if (valueProps.found) {
88
- if (!isMap && !props.found && ctx.options.strict) {
89
- if (sep) for (const st of sep) {
90
- if (st === valueProps.found) break;
91
- if (st.type === "newline") {
92
- onError(st, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line");
93
- break;
94
- }
95
- }
96
- if (props.start < valueProps.found.offset - 1024) onError(valueProps.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key");
97
- }
98
- } else if (value) if ("source" in value && value.source?.[0] === ":") onError(value, "MISSING_CHAR", `Missing space after : in ${fcName}`);
99
- else onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
100
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError) : null;
101
- if (valueNode) {
102
- if (isBlock(value)) onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
103
- } else if (valueProps.comment) if (keyNode.comment) keyNode.comment += "\n" + valueProps.comment;
104
- else keyNode.comment = valueProps.comment;
105
- const pair = new Pair(keyNode, valueNode);
106
- if (ctx.options.keepSourceTokens) pair.srcToken = collItem;
107
- if (isMap) {
108
- const map = coll;
109
- if (mapIncludes(ctx, map.items, keyNode)) onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
110
- map.items.push(pair);
111
- } else {
112
- const map = new YAMLMap(ctx.schema);
113
- map.flow = true;
114
- map.items.push(pair);
115
- const endRange = (valueNode ?? keyNode).range;
116
- map.range = [
117
- keyNode.range[0],
118
- endRange[1],
119
- endRange[2]
120
- ];
121
- coll.items.push(map);
122
- }
123
- offset = valueNode ? valueNode.range[2] : valueProps.end;
124
- }
125
- }
126
- const expectedEnd = isMap ? "}" : "]";
127
- const [ce, ...ee] = fc.end;
128
- let cePos = offset;
129
- if (ce?.source === expectedEnd) cePos = ce.offset + ce.source.length;
130
- else {
131
- const name = fcName[0].toUpperCase() + fcName.substring(1);
132
- const msg = atRoot ? `${name} must end with a ${expectedEnd}` : `${name} in block collection must be sufficiently indented and end with a ${expectedEnd}`;
133
- onError(offset, atRoot ? "MISSING_CHAR" : "BAD_INDENT", msg);
134
- if (ce && ce.source.length !== 1) ee.unshift(ce);
135
- }
136
- if (ee.length > 0) {
137
- const end = resolveEnd(ee, cePos, ctx.options.strict, onError);
138
- if (end.comment) if (coll.comment) coll.comment += "\n" + end.comment;
139
- else coll.comment = end.comment;
140
- coll.range = [
141
- fc.offset,
142
- cePos,
143
- end.offset
144
- ];
145
- } else coll.range = [
146
- fc.offset,
147
- cePos,
148
- cePos
149
- ];
150
- return coll;
151
- }
152
- //#endregion
153
- export { resolveFlowCollection };