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,859 +0,0 @@
1
- import { tokenType } from "./cst.js";
2
- import { Lexer } from "./lexer.js";
3
- //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/parser.js
4
- function includesToken(list, type) {
5
- for (let i = 0; i < list.length; ++i) if (list[i].type === type) return true;
6
- return false;
7
- }
8
- function findNonEmptyIndex(list) {
9
- for (let i = 0; i < list.length; ++i) switch (list[i].type) {
10
- case "space":
11
- case "comment":
12
- case "newline": break;
13
- default: return i;
14
- }
15
- return -1;
16
- }
17
- function isFlowToken(token) {
18
- switch (token?.type) {
19
- case "alias":
20
- case "scalar":
21
- case "single-quoted-scalar":
22
- case "double-quoted-scalar":
23
- case "flow-collection": return true;
24
- default: return false;
25
- }
26
- }
27
- function getPrevProps(parent) {
28
- switch (parent.type) {
29
- case "document": return parent.start;
30
- case "block-map": {
31
- const it = parent.items[parent.items.length - 1];
32
- return it.sep ?? it.start;
33
- }
34
- case "block-seq": return parent.items[parent.items.length - 1].start;
35
- /* istanbul ignore next should not happen */
36
- default: return [];
37
- }
38
- }
39
- /** Note: May modify input array */
40
- function getFirstKeyStartProps(prev) {
41
- if (prev.length === 0) return [];
42
- let i = prev.length;
43
- loop: while (--i >= 0) switch (prev[i].type) {
44
- case "doc-start":
45
- case "explicit-key-ind":
46
- case "map-value-ind":
47
- case "seq-item-ind":
48
- case "newline": break loop;
49
- }
50
- while (prev[++i]?.type === "space");
51
- return prev.splice(i, prev.length);
52
- }
53
- function arrayPushArray(target, source) {
54
- if (source.length < 1e5) Array.prototype.push.apply(target, source);
55
- else for (let i = 0; i < source.length; ++i) target.push(source[i]);
56
- }
57
- function fixFlowSeqItems(fc) {
58
- if (fc.start.type === "flow-seq-start") {
59
- for (const it of fc.items) if (it.sep && !it.value && !includesToken(it.start, "explicit-key-ind") && !includesToken(it.sep, "map-value-ind")) {
60
- if (it.key) it.value = it.key;
61
- delete it.key;
62
- if (isFlowToken(it.value)) if (it.value.end) arrayPushArray(it.value.end, it.sep);
63
- else it.value.end = it.sep;
64
- else arrayPushArray(it.start, it.sep);
65
- delete it.sep;
66
- }
67
- }
68
- }
69
- /**
70
- * A YAML concrete syntax tree (CST) parser
71
- *
72
- * ```ts
73
- * const src: string = ...
74
- * for (const token of new Parser().parse(src)) {
75
- * // token: Token
76
- * }
77
- * ```
78
- *
79
- * To use the parser with a user-provided lexer:
80
- *
81
- * ```ts
82
- * function* parse(source: string, lexer: Lexer) {
83
- * const parser = new Parser()
84
- * for (const lexeme of lexer.lex(source))
85
- * yield* parser.next(lexeme)
86
- * yield* parser.end()
87
- * }
88
- *
89
- * const src: string = ...
90
- * const lexer = new Lexer()
91
- * for (const token of parse(src, lexer)) {
92
- * // token: Token
93
- * }
94
- * ```
95
- */
96
- var Parser = class {
97
- /**
98
- * @param onNewLine - If defined, called separately with the start position of
99
- * each new line (in `parse()`, including the start of input).
100
- */
101
- constructor(onNewLine) {
102
- /** If true, space and sequence indicators count as indentation */
103
- this.atNewLine = true;
104
- /** If true, next token is a scalar value */
105
- this.atScalar = false;
106
- /** Current indentation level */
107
- this.indent = 0;
108
- /** Current offset since the start of parsing */
109
- this.offset = 0;
110
- /** On the same line with a block map key */
111
- this.onKeyLine = false;
112
- /** Top indicates the node that's currently being built */
113
- this.stack = [];
114
- /** The source of the current token, set in parse() */
115
- this.source = "";
116
- /** The type of the current token, set in parse() */
117
- this.type = "";
118
- this.lexer = new Lexer();
119
- this.onNewLine = onNewLine;
120
- }
121
- /**
122
- * Parse `source` as a YAML stream.
123
- * If `incomplete`, a part of the last line may be left as a buffer for the next call.
124
- *
125
- * Errors are not thrown, but yielded as `{ type: 'error', message }` tokens.
126
- *
127
- * @returns A generator of tokens representing each directive, document, and other structure.
128
- */
129
- *parse(source, incomplete = false) {
130
- if (this.onNewLine && this.offset === 0) this.onNewLine(0);
131
- for (const lexeme of this.lexer.lex(source, incomplete)) yield* this.next(lexeme);
132
- if (!incomplete) yield* this.end();
133
- }
134
- /**
135
- * Advance the parser by the `source` of one lexical token.
136
- */
137
- *next(source) {
138
- this.source = source;
139
- if (this.atScalar) {
140
- this.atScalar = false;
141
- yield* this.step();
142
- this.offset += source.length;
143
- return;
144
- }
145
- const type = tokenType(source);
146
- if (!type) {
147
- const message = `Not a YAML token: ${source}`;
148
- yield* this.pop({
149
- type: "error",
150
- offset: this.offset,
151
- message,
152
- source
153
- });
154
- this.offset += source.length;
155
- } else if (type === "scalar") {
156
- this.atNewLine = false;
157
- this.atScalar = true;
158
- this.type = "scalar";
159
- } else {
160
- this.type = type;
161
- yield* this.step();
162
- switch (type) {
163
- case "newline":
164
- this.atNewLine = true;
165
- this.indent = 0;
166
- if (this.onNewLine) this.onNewLine(this.offset + source.length);
167
- break;
168
- case "space":
169
- if (this.atNewLine && source[0] === " ") this.indent += source.length;
170
- break;
171
- case "explicit-key-ind":
172
- case "map-value-ind":
173
- case "seq-item-ind":
174
- if (this.atNewLine) this.indent += source.length;
175
- break;
176
- case "doc-mode":
177
- case "flow-error-end": return;
178
- default: this.atNewLine = false;
179
- }
180
- this.offset += source.length;
181
- }
182
- }
183
- /** Call at end of input to push out any remaining constructions */
184
- *end() {
185
- while (this.stack.length > 0) yield* this.pop();
186
- }
187
- get sourceToken() {
188
- return {
189
- type: this.type,
190
- offset: this.offset,
191
- indent: this.indent,
192
- source: this.source
193
- };
194
- }
195
- *step() {
196
- const top = this.peek(1);
197
- if (this.type === "doc-end" && top?.type !== "doc-end") {
198
- while (this.stack.length > 0) yield* this.pop();
199
- this.stack.push({
200
- type: "doc-end",
201
- offset: this.offset,
202
- source: this.source
203
- });
204
- return;
205
- }
206
- if (!top) return yield* this.stream();
207
- switch (top.type) {
208
- case "document": return yield* this.document(top);
209
- case "alias":
210
- case "scalar":
211
- case "single-quoted-scalar":
212
- case "double-quoted-scalar": return yield* this.scalar(top);
213
- case "block-scalar": return yield* this.blockScalar(top);
214
- case "block-map": return yield* this.blockMap(top);
215
- case "block-seq": return yield* this.blockSequence(top);
216
- case "flow-collection": return yield* this.flowCollection(top);
217
- case "doc-end": return yield* this.documentEnd(top);
218
- }
219
- /* istanbul ignore next should not happen */
220
- yield* this.pop();
221
- }
222
- peek(n) {
223
- return this.stack[this.stack.length - n];
224
- }
225
- *pop(error) {
226
- const token = error ?? this.stack.pop();
227
- /* istanbul ignore if should not happen */
228
- if (!token) yield {
229
- type: "error",
230
- offset: this.offset,
231
- source: "",
232
- message: "Tried to pop an empty stack"
233
- };
234
- else if (this.stack.length === 0) yield token;
235
- else {
236
- const top = this.peek(1);
237
- if (token.type === "block-scalar") token.indent = "indent" in top ? top.indent : 0;
238
- else if (token.type === "flow-collection" && top.type === "document") token.indent = 0;
239
- if (token.type === "flow-collection") fixFlowSeqItems(token);
240
- switch (top.type) {
241
- case "document":
242
- top.value = token;
243
- break;
244
- case "block-scalar":
245
- top.props.push(token);
246
- break;
247
- case "block-map": {
248
- const it = top.items[top.items.length - 1];
249
- if (it.value) {
250
- top.items.push({
251
- start: [],
252
- key: token,
253
- sep: []
254
- });
255
- this.onKeyLine = true;
256
- return;
257
- } else if (it.sep) it.value = token;
258
- else {
259
- Object.assign(it, {
260
- key: token,
261
- sep: []
262
- });
263
- this.onKeyLine = !it.explicitKey;
264
- return;
265
- }
266
- break;
267
- }
268
- case "block-seq": {
269
- const it = top.items[top.items.length - 1];
270
- if (it.value) top.items.push({
271
- start: [],
272
- value: token
273
- });
274
- else it.value = token;
275
- break;
276
- }
277
- case "flow-collection": {
278
- const it = top.items[top.items.length - 1];
279
- if (!it || it.value) top.items.push({
280
- start: [],
281
- key: token,
282
- sep: []
283
- });
284
- else if (it.sep) it.value = token;
285
- else Object.assign(it, {
286
- key: token,
287
- sep: []
288
- });
289
- return;
290
- }
291
- /* istanbul ignore next should not happen */
292
- default:
293
- yield* this.pop();
294
- yield* this.pop(token);
295
- }
296
- if ((top.type === "document" || top.type === "block-map" || top.type === "block-seq") && (token.type === "block-map" || token.type === "block-seq")) {
297
- const last = token.items[token.items.length - 1];
298
- if (last && !last.sep && !last.value && last.start.length > 0 && findNonEmptyIndex(last.start) === -1 && (token.indent === 0 || last.start.every((st) => st.type !== "comment" || st.indent < token.indent))) {
299
- if (top.type === "document") top.end = last.start;
300
- else top.items.push({ start: last.start });
301
- token.items.splice(-1, 1);
302
- }
303
- }
304
- }
305
- }
306
- *stream() {
307
- switch (this.type) {
308
- case "directive-line":
309
- yield {
310
- type: "directive",
311
- offset: this.offset,
312
- source: this.source
313
- };
314
- return;
315
- case "byte-order-mark":
316
- case "space":
317
- case "comment":
318
- case "newline":
319
- yield this.sourceToken;
320
- return;
321
- case "doc-mode":
322
- case "doc-start": {
323
- const doc = {
324
- type: "document",
325
- offset: this.offset,
326
- start: []
327
- };
328
- if (this.type === "doc-start") doc.start.push(this.sourceToken);
329
- this.stack.push(doc);
330
- return;
331
- }
332
- }
333
- yield {
334
- type: "error",
335
- offset: this.offset,
336
- message: `Unexpected ${this.type} token in YAML stream`,
337
- source: this.source
338
- };
339
- }
340
- *document(doc) {
341
- if (doc.value) return yield* this.lineEnd(doc);
342
- switch (this.type) {
343
- case "doc-start":
344
- if (findNonEmptyIndex(doc.start) !== -1) {
345
- yield* this.pop();
346
- yield* this.step();
347
- } else doc.start.push(this.sourceToken);
348
- return;
349
- case "anchor":
350
- case "tag":
351
- case "space":
352
- case "comment":
353
- case "newline":
354
- doc.start.push(this.sourceToken);
355
- return;
356
- }
357
- const bv = this.startBlockValue(doc);
358
- if (bv) this.stack.push(bv);
359
- else yield {
360
- type: "error",
361
- offset: this.offset,
362
- message: `Unexpected ${this.type} token in YAML document`,
363
- source: this.source
364
- };
365
- }
366
- *scalar(scalar) {
367
- if (this.type === "map-value-ind") {
368
- const start = getFirstKeyStartProps(getPrevProps(this.peek(2)));
369
- let sep;
370
- if (scalar.end) {
371
- sep = scalar.end;
372
- sep.push(this.sourceToken);
373
- delete scalar.end;
374
- } else sep = [this.sourceToken];
375
- const map = {
376
- type: "block-map",
377
- offset: scalar.offset,
378
- indent: scalar.indent,
379
- items: [{
380
- start,
381
- key: scalar,
382
- sep
383
- }]
384
- };
385
- this.onKeyLine = true;
386
- this.stack[this.stack.length - 1] = map;
387
- } else yield* this.lineEnd(scalar);
388
- }
389
- *blockScalar(scalar) {
390
- switch (this.type) {
391
- case "space":
392
- case "comment":
393
- case "newline":
394
- scalar.props.push(this.sourceToken);
395
- return;
396
- case "scalar":
397
- scalar.source = this.source;
398
- this.atNewLine = true;
399
- this.indent = 0;
400
- if (this.onNewLine) {
401
- let nl = this.source.indexOf("\n") + 1;
402
- while (nl !== 0) {
403
- this.onNewLine(this.offset + nl);
404
- nl = this.source.indexOf("\n", nl) + 1;
405
- }
406
- }
407
- yield* this.pop();
408
- break;
409
- /* istanbul ignore next should not happen */
410
- default:
411
- yield* this.pop();
412
- yield* this.step();
413
- }
414
- }
415
- *blockMap(map) {
416
- const it = map.items[map.items.length - 1];
417
- switch (this.type) {
418
- case "newline":
419
- this.onKeyLine = false;
420
- if (it.value) {
421
- const end = "end" in it.value ? it.value.end : void 0;
422
- if ((Array.isArray(end) ? end[end.length - 1] : void 0)?.type === "comment") end?.push(this.sourceToken);
423
- else map.items.push({ start: [this.sourceToken] });
424
- } else if (it.sep) it.sep.push(this.sourceToken);
425
- else it.start.push(this.sourceToken);
426
- return;
427
- case "space":
428
- case "comment":
429
- if (it.value) map.items.push({ start: [this.sourceToken] });
430
- else if (it.sep) it.sep.push(this.sourceToken);
431
- else {
432
- if (this.atIndentedComment(it.start, map.indent)) {
433
- const end = map.items[map.items.length - 2]?.value?.end;
434
- if (Array.isArray(end)) {
435
- arrayPushArray(end, it.start);
436
- end.push(this.sourceToken);
437
- map.items.pop();
438
- return;
439
- }
440
- }
441
- it.start.push(this.sourceToken);
442
- }
443
- return;
444
- }
445
- if (this.indent >= map.indent) {
446
- const atMapIndent = !this.onKeyLine && this.indent === map.indent;
447
- const atNextItem = atMapIndent && (it.sep || it.explicitKey) && this.type !== "seq-item-ind";
448
- let start = [];
449
- if (atNextItem && it.sep && !it.value) {
450
- const nl = [];
451
- for (let i = 0; i < it.sep.length; ++i) {
452
- const st = it.sep[i];
453
- switch (st.type) {
454
- case "newline":
455
- nl.push(i);
456
- break;
457
- case "space": break;
458
- case "comment":
459
- if (st.indent > map.indent) nl.length = 0;
460
- break;
461
- default: nl.length = 0;
462
- }
463
- }
464
- if (nl.length >= 2) start = it.sep.splice(nl[1]);
465
- }
466
- switch (this.type) {
467
- case "anchor":
468
- case "tag":
469
- if (atNextItem || it.value) {
470
- start.push(this.sourceToken);
471
- map.items.push({ start });
472
- this.onKeyLine = true;
473
- } else if (it.sep) it.sep.push(this.sourceToken);
474
- else it.start.push(this.sourceToken);
475
- return;
476
- case "explicit-key-ind":
477
- if (!it.sep && !it.explicitKey) {
478
- it.start.push(this.sourceToken);
479
- it.explicitKey = true;
480
- } else if (atNextItem || it.value) {
481
- start.push(this.sourceToken);
482
- map.items.push({
483
- start,
484
- explicitKey: true
485
- });
486
- } else this.stack.push({
487
- type: "block-map",
488
- offset: this.offset,
489
- indent: this.indent,
490
- items: [{
491
- start: [this.sourceToken],
492
- explicitKey: true
493
- }]
494
- });
495
- this.onKeyLine = true;
496
- return;
497
- case "map-value-ind":
498
- if (it.explicitKey) if (!it.sep) if (includesToken(it.start, "newline")) Object.assign(it, {
499
- key: null,
500
- sep: [this.sourceToken]
501
- });
502
- else {
503
- const start = getFirstKeyStartProps(it.start);
504
- this.stack.push({
505
- type: "block-map",
506
- offset: this.offset,
507
- indent: this.indent,
508
- items: [{
509
- start,
510
- key: null,
511
- sep: [this.sourceToken]
512
- }]
513
- });
514
- }
515
- else if (it.value) map.items.push({
516
- start: [],
517
- key: null,
518
- sep: [this.sourceToken]
519
- });
520
- else if (includesToken(it.sep, "map-value-ind")) this.stack.push({
521
- type: "block-map",
522
- offset: this.offset,
523
- indent: this.indent,
524
- items: [{
525
- start,
526
- key: null,
527
- sep: [this.sourceToken]
528
- }]
529
- });
530
- else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
531
- const start = getFirstKeyStartProps(it.start);
532
- const key = it.key;
533
- const sep = it.sep;
534
- sep.push(this.sourceToken);
535
- delete it.key;
536
- delete it.sep;
537
- this.stack.push({
538
- type: "block-map",
539
- offset: this.offset,
540
- indent: this.indent,
541
- items: [{
542
- start,
543
- key,
544
- sep
545
- }]
546
- });
547
- } else if (start.length > 0) it.sep = it.sep.concat(start, this.sourceToken);
548
- else it.sep.push(this.sourceToken);
549
- else if (!it.sep) Object.assign(it, {
550
- key: null,
551
- sep: [this.sourceToken]
552
- });
553
- else if (it.value || atNextItem) map.items.push({
554
- start,
555
- key: null,
556
- sep: [this.sourceToken]
557
- });
558
- else if (includesToken(it.sep, "map-value-ind")) this.stack.push({
559
- type: "block-map",
560
- offset: this.offset,
561
- indent: this.indent,
562
- items: [{
563
- start: [],
564
- key: null,
565
- sep: [this.sourceToken]
566
- }]
567
- });
568
- else it.sep.push(this.sourceToken);
569
- this.onKeyLine = true;
570
- return;
571
- case "alias":
572
- case "scalar":
573
- case "single-quoted-scalar":
574
- case "double-quoted-scalar": {
575
- const fs = this.flowScalar(this.type);
576
- if (atNextItem || it.value) {
577
- map.items.push({
578
- start,
579
- key: fs,
580
- sep: []
581
- });
582
- this.onKeyLine = true;
583
- } else if (it.sep) this.stack.push(fs);
584
- else {
585
- Object.assign(it, {
586
- key: fs,
587
- sep: []
588
- });
589
- this.onKeyLine = true;
590
- }
591
- return;
592
- }
593
- default: {
594
- const bv = this.startBlockValue(map);
595
- if (bv) {
596
- if (bv.type === "block-seq") {
597
- if (!it.explicitKey && it.sep && !includesToken(it.sep, "newline")) {
598
- yield* this.pop({
599
- type: "error",
600
- offset: this.offset,
601
- message: "Unexpected block-seq-ind on same line with key",
602
- source: this.source
603
- });
604
- return;
605
- }
606
- } else if (atMapIndent) map.items.push({ start });
607
- this.stack.push(bv);
608
- return;
609
- }
610
- }
611
- }
612
- }
613
- yield* this.pop();
614
- yield* this.step();
615
- }
616
- *blockSequence(seq) {
617
- const it = seq.items[seq.items.length - 1];
618
- switch (this.type) {
619
- case "newline":
620
- if (it.value) {
621
- const end = "end" in it.value ? it.value.end : void 0;
622
- if ((Array.isArray(end) ? end[end.length - 1] : void 0)?.type === "comment") end?.push(this.sourceToken);
623
- else seq.items.push({ start: [this.sourceToken] });
624
- } else it.start.push(this.sourceToken);
625
- return;
626
- case "space":
627
- case "comment":
628
- if (it.value) seq.items.push({ start: [this.sourceToken] });
629
- else {
630
- if (this.atIndentedComment(it.start, seq.indent)) {
631
- const end = seq.items[seq.items.length - 2]?.value?.end;
632
- if (Array.isArray(end)) {
633
- arrayPushArray(end, it.start);
634
- end.push(this.sourceToken);
635
- seq.items.pop();
636
- return;
637
- }
638
- }
639
- it.start.push(this.sourceToken);
640
- }
641
- return;
642
- case "anchor":
643
- case "tag":
644
- if (it.value || this.indent <= seq.indent) break;
645
- it.start.push(this.sourceToken);
646
- return;
647
- case "seq-item-ind":
648
- if (this.indent !== seq.indent) break;
649
- if (it.value || includesToken(it.start, "seq-item-ind")) seq.items.push({ start: [this.sourceToken] });
650
- else it.start.push(this.sourceToken);
651
- return;
652
- }
653
- if (this.indent > seq.indent) {
654
- const bv = this.startBlockValue(seq);
655
- if (bv) {
656
- this.stack.push(bv);
657
- return;
658
- }
659
- }
660
- yield* this.pop();
661
- yield* this.step();
662
- }
663
- *flowCollection(fc) {
664
- const it = fc.items[fc.items.length - 1];
665
- if (this.type === "flow-error-end") {
666
- let top;
667
- do {
668
- yield* this.pop();
669
- top = this.peek(1);
670
- } while (top?.type === "flow-collection");
671
- } else if (fc.end.length === 0) {
672
- switch (this.type) {
673
- case "comma":
674
- case "explicit-key-ind":
675
- if (!it || it.sep) fc.items.push({ start: [this.sourceToken] });
676
- else it.start.push(this.sourceToken);
677
- return;
678
- case "map-value-ind":
679
- if (!it || it.value) fc.items.push({
680
- start: [],
681
- key: null,
682
- sep: [this.sourceToken]
683
- });
684
- else if (it.sep) it.sep.push(this.sourceToken);
685
- else Object.assign(it, {
686
- key: null,
687
- sep: [this.sourceToken]
688
- });
689
- return;
690
- case "space":
691
- case "comment":
692
- case "newline":
693
- case "anchor":
694
- case "tag":
695
- if (!it || it.value) fc.items.push({ start: [this.sourceToken] });
696
- else if (it.sep) it.sep.push(this.sourceToken);
697
- else it.start.push(this.sourceToken);
698
- return;
699
- case "alias":
700
- case "scalar":
701
- case "single-quoted-scalar":
702
- case "double-quoted-scalar": {
703
- const fs = this.flowScalar(this.type);
704
- if (!it || it.value) fc.items.push({
705
- start: [],
706
- key: fs,
707
- sep: []
708
- });
709
- else if (it.sep) this.stack.push(fs);
710
- else Object.assign(it, {
711
- key: fs,
712
- sep: []
713
- });
714
- return;
715
- }
716
- case "flow-map-end":
717
- case "flow-seq-end":
718
- fc.end.push(this.sourceToken);
719
- return;
720
- }
721
- const bv = this.startBlockValue(fc);
722
- /* istanbul ignore else should not happen */
723
- if (bv) this.stack.push(bv);
724
- else {
725
- yield* this.pop();
726
- yield* this.step();
727
- }
728
- } else {
729
- const parent = this.peek(2);
730
- if (parent.type === "block-map" && (this.type === "map-value-ind" && parent.indent === fc.indent || this.type === "newline" && !parent.items[parent.items.length - 1].sep)) {
731
- yield* this.pop();
732
- yield* this.step();
733
- } else if (this.type === "map-value-ind" && parent.type !== "flow-collection") {
734
- const start = getFirstKeyStartProps(getPrevProps(parent));
735
- fixFlowSeqItems(fc);
736
- const sep = fc.end.splice(1, fc.end.length);
737
- sep.push(this.sourceToken);
738
- const map = {
739
- type: "block-map",
740
- offset: fc.offset,
741
- indent: fc.indent,
742
- items: [{
743
- start,
744
- key: fc,
745
- sep
746
- }]
747
- };
748
- this.onKeyLine = true;
749
- this.stack[this.stack.length - 1] = map;
750
- } else yield* this.lineEnd(fc);
751
- }
752
- }
753
- flowScalar(type) {
754
- if (this.onNewLine) {
755
- let nl = this.source.indexOf("\n") + 1;
756
- while (nl !== 0) {
757
- this.onNewLine(this.offset + nl);
758
- nl = this.source.indexOf("\n", nl) + 1;
759
- }
760
- }
761
- return {
762
- type,
763
- offset: this.offset,
764
- indent: this.indent,
765
- source: this.source
766
- };
767
- }
768
- startBlockValue(parent) {
769
- switch (this.type) {
770
- case "alias":
771
- case "scalar":
772
- case "single-quoted-scalar":
773
- case "double-quoted-scalar": return this.flowScalar(this.type);
774
- case "block-scalar-header": return {
775
- type: "block-scalar",
776
- offset: this.offset,
777
- indent: this.indent,
778
- props: [this.sourceToken],
779
- source: ""
780
- };
781
- case "flow-map-start":
782
- case "flow-seq-start": return {
783
- type: "flow-collection",
784
- offset: this.offset,
785
- indent: this.indent,
786
- start: this.sourceToken,
787
- items: [],
788
- end: []
789
- };
790
- case "seq-item-ind": return {
791
- type: "block-seq",
792
- offset: this.offset,
793
- indent: this.indent,
794
- items: [{ start: [this.sourceToken] }]
795
- };
796
- case "explicit-key-ind": {
797
- this.onKeyLine = true;
798
- const start = getFirstKeyStartProps(getPrevProps(parent));
799
- start.push(this.sourceToken);
800
- return {
801
- type: "block-map",
802
- offset: this.offset,
803
- indent: this.indent,
804
- items: [{
805
- start,
806
- explicitKey: true
807
- }]
808
- };
809
- }
810
- case "map-value-ind": {
811
- this.onKeyLine = true;
812
- const start = getFirstKeyStartProps(getPrevProps(parent));
813
- return {
814
- type: "block-map",
815
- offset: this.offset,
816
- indent: this.indent,
817
- items: [{
818
- start,
819
- key: null,
820
- sep: [this.sourceToken]
821
- }]
822
- };
823
- }
824
- }
825
- return null;
826
- }
827
- atIndentedComment(start, indent) {
828
- if (this.type !== "comment") return false;
829
- if (this.indent <= indent) return false;
830
- return start.every((st) => st.type === "newline" || st.type === "space");
831
- }
832
- *documentEnd(docEnd) {
833
- if (this.type !== "doc-mode") {
834
- if (docEnd.end) docEnd.end.push(this.sourceToken);
835
- else docEnd.end = [this.sourceToken];
836
- if (this.type === "newline") yield* this.pop();
837
- }
838
- }
839
- *lineEnd(token) {
840
- switch (this.type) {
841
- case "comma":
842
- case "doc-start":
843
- case "doc-end":
844
- case "flow-seq-end":
845
- case "flow-map-end":
846
- case "map-value-ind":
847
- yield* this.pop();
848
- yield* this.step();
849
- break;
850
- case "newline": this.onKeyLine = false;
851
- default:
852
- if (token.end) token.end.push(this.sourceToken);
853
- else token.end = [this.sourceToken];
854
- if (this.type === "newline") yield* this.pop();
855
- }
856
- }
857
- };
858
- //#endregion
859
- export { Parser };