fumadocs-openapi 10.6.8 → 10.7.0

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 (108) hide show
  1. package/css/generated/shared.css +0 -1
  2. package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/general/create-limiter.js +43 -0
  3. package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/object/is-object.js +26 -0
  4. package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/object/prevent-pollution.js +33 -0
  5. package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/queue/queue.js +106 -0
  6. package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/string/generate-hash.js +120 -0
  7. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/bundle.js +346 -0
  8. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js +73 -0
  9. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js +3 -0
  10. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/plugins/parse-yaml/index.js +1 -0
  11. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js +51 -0
  12. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/value-generator.js +88 -0
  13. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/convert-to-local-ref.js +24 -0
  14. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/escape-json-pointer.js +11 -0
  15. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/get-schemas.js +44 -0
  16. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/get-segments-from-path.js +10 -0
  17. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/get-value-by-path.js +42 -0
  18. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/is-file-path.js +23 -0
  19. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/is-http-url.js +23 -0
  20. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/is-json-object.js +28 -0
  21. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/is-yaml.js +21 -0
  22. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/normalize.js +26 -0
  23. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/resolve-reference-path.js +30 -0
  24. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/set-value-at-path.js +70 -0
  25. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/to-relative-path.js +33 -0
  26. package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/unescape-json-pointer.js +12 -0
  27. package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.4/node_modules/@scalar/openapi-upgrader/dist/2.0-to-3.0/upgrade-from-two-to-three.js +487 -0
  28. package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.4/node_modules/@scalar/openapi-upgrader/dist/3.0-to-3.1/upgrade-from-three-to-three-one.js +95 -0
  29. package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.4/node_modules/@scalar/openapi-upgrader/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +59 -0
  30. package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.4/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +25 -0
  31. package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.4/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +15 -0
  32. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +19 -0
  33. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +430 -0
  34. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-collection.js +50 -0
  35. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-doc.js +39 -0
  36. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-node.js +85 -0
  37. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-scalar.js +57 -0
  38. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/composer.js +193 -0
  39. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-block-map.js +82 -0
  40. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +173 -0
  41. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +40 -0
  42. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-end.js +36 -0
  43. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +153 -0
  44. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +204 -0
  45. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-props.js +105 -0
  46. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-contains-newline.js +27 -0
  47. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +25 -0
  48. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +10 -0
  49. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-map-includes.js +10 -0
  50. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/Document.js +277 -0
  51. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/anchors.js +57 -0
  52. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/applyReviver.js +38 -0
  53. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/createNode.js +61 -0
  54. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/directives.js +163 -0
  55. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/errors.js +48 -0
  56. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/index.js +16 -0
  57. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/log.js +6 -0
  58. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Alias.js +91 -0
  59. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Collection.js +117 -0
  60. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Node.js +32 -0
  61. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Pair.js +29 -0
  62. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
  63. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/YAMLMap.js +106 -0
  64. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +104 -0
  65. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +49 -0
  66. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/identity.js +33 -0
  67. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/toJS.js +35 -0
  68. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/cst-scalar.js +3 -0
  69. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/cst-visit.js +89 -0
  70. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/cst.js +40 -0
  71. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/lexer.js +517 -0
  72. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/line-counter.js +45 -0
  73. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/parser.js +852 -0
  74. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/public-api.js +44 -0
  75. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/Schema.js +27 -0
  76. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/common/map.js +16 -0
  77. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/common/null.js +13 -0
  78. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/common/seq.js +16 -0
  79. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
  80. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/core/bool.js +17 -0
  81. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/core/float.js +38 -0
  82. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/core/int.js +37 -0
  83. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
  84. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/json/schema.js +61 -0
  85. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/tags.js +81 -0
  86. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +44 -0
  87. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +24 -0
  88. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +41 -0
  89. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +70 -0
  90. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +36 -0
  91. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +60 -0
  92. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +56 -0
  93. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
  94. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +65 -0
  95. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +79 -0
  96. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +111 -0
  97. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringify.js +105 -0
  98. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +116 -0
  99. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyComment.js +16 -0
  100. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +59 -0
  101. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +19 -0
  102. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyPair.js +95 -0
  103. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyString.js +222 -0
  104. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/visit.js +187 -0
  105. package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/index.js +16 -0
  106. package/dist/scalar/client.js +1 -1
  107. package/dist/utils/document/process.js +5 -3
  108. package/package.json +16 -16
@@ -0,0 +1,57 @@
1
+ import { SCALAR, isScalar } from "../nodes/identity.js";
2
+ import { Scalar } from "../nodes/Scalar.js";
3
+ import { resolveBlockScalar } from "./resolve-block-scalar.js";
4
+ import { resolveFlowScalar } from "./resolve-flow-scalar.js";
5
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-scalar.js
6
+ function composeScalar(ctx, token, tagToken, onError) {
7
+ const { value, type, comment, range } = token.type === "block-scalar" ? resolveBlockScalar(ctx, token, onError) : resolveFlowScalar(token, ctx.options.strict, onError);
8
+ const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null;
9
+ let tag;
10
+ if (ctx.options.stringKeys && ctx.atKey) tag = ctx.schema[SCALAR];
11
+ else if (tagName) tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
12
+ else if (token.type === "scalar") tag = findScalarTagByTest(ctx, value, token, onError);
13
+ else tag = ctx.schema[SCALAR];
14
+ let scalar;
15
+ try {
16
+ const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
17
+ scalar = isScalar(res) ? res : new Scalar(res);
18
+ } catch (error) {
19
+ const msg = error instanceof Error ? error.message : String(error);
20
+ onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
21
+ scalar = new Scalar(value);
22
+ }
23
+ scalar.range = range;
24
+ scalar.source = value;
25
+ if (type) scalar.type = type;
26
+ if (tagName) scalar.tag = tagName;
27
+ if (tag.format) scalar.format = tag.format;
28
+ if (comment) scalar.comment = comment;
29
+ return scalar;
30
+ }
31
+ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
32
+ if (tagName === "!") return schema[SCALAR];
33
+ const matchWithTest = [];
34
+ for (const tag of schema.tags) if (!tag.collection && tag.tag === tagName) if (tag.default && tag.test) matchWithTest.push(tag);
35
+ else return tag;
36
+ for (const tag of matchWithTest) if (tag.test?.test(value)) return tag;
37
+ const kt = schema.knownTags[tagName];
38
+ if (kt && !kt.collection) {
39
+ schema.tags.push(Object.assign({}, kt, {
40
+ default: false,
41
+ test: void 0
42
+ }));
43
+ return kt;
44
+ }
45
+ onError(tagToken, "TAG_RESOLVE_FAILED", `Unresolved tag: ${tagName}`, tagName !== "tag:yaml.org,2002:str");
46
+ return schema[SCALAR];
47
+ }
48
+ function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
49
+ const tag = schema.tags.find((tag) => (tag.default === true || atKey && tag.default === "key") && tag.test?.test(value)) || schema[SCALAR];
50
+ if (schema.compat) {
51
+ const compat = schema.compat.find((tag) => tag.default && tag.test?.test(value)) ?? schema[SCALAR];
52
+ if (tag.tag !== compat.tag) onError(token, "TAG_RESOLVE_FAILED", `Value may be parsed as either ${directives.tagString(tag.tag)} or ${directives.tagString(compat.tag)}`, true);
53
+ }
54
+ return tag;
55
+ }
56
+ //#endregion
57
+ export { composeScalar };
@@ -0,0 +1,193 @@
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.8.3/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
+ Array.prototype.push.apply(doc.errors, this.errors);
84
+ Array.prototype.push.apply(doc.warnings, this.warnings);
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 };
@@ -0,0 +1,82 @@
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.8.3/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 };
@@ -0,0 +1,173 @@
1
+ import { Scalar } from "../nodes/Scalar.js";
2
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/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
+ default: {
149
+ onError(token, "UNEXPECTED_TOKEN", `Unexpected token in block scalar header: ${token.type}`);
150
+ const ts = token.source;
151
+ if (ts && typeof ts === "string") length += ts.length;
152
+ }
153
+ }
154
+ }
155
+ return {
156
+ mode,
157
+ indent,
158
+ chomp,
159
+ comment,
160
+ length
161
+ };
162
+ }
163
+ /** @returns Array of lines split up as `[indent, content]` */
164
+ function splitLines(source) {
165
+ const split = source.split(/\n( *)/);
166
+ const first = split[0];
167
+ const m = first.match(/^( *)/);
168
+ const lines = [m?.[1] ? [m[1], first.slice(m[1].length)] : ["", first]];
169
+ for (let i = 1; i < split.length; i += 2) lines.push([split[i], split[i + 1]]);
170
+ return lines;
171
+ }
172
+ //#endregion
173
+ export { resolveBlockScalar };
@@ -0,0 +1,40 @@
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.8.3/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 };
@@ -0,0 +1,36 @@
1
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/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 };