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,153 @@
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.8.3/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 };
@@ -0,0 +1,204 @@
1
+ import { Scalar } from "../nodes/Scalar.js";
2
+ import { resolveEnd } from "./resolve-end.js";
3
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js
4
+ function resolveFlowScalar(scalar, strict, onError) {
5
+ const { offset, type, source, end } = scalar;
6
+ let _type;
7
+ let value;
8
+ const _onError = (rel, code, msg) => onError(offset + rel, code, msg);
9
+ switch (type) {
10
+ case "scalar":
11
+ _type = Scalar.PLAIN;
12
+ value = plainValue(source, _onError);
13
+ break;
14
+ case "single-quoted-scalar":
15
+ _type = Scalar.QUOTE_SINGLE;
16
+ value = singleQuotedValue(source, _onError);
17
+ break;
18
+ case "double-quoted-scalar":
19
+ _type = Scalar.QUOTE_DOUBLE;
20
+ value = doubleQuotedValue(source, _onError);
21
+ break;
22
+ default:
23
+ onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
24
+ return {
25
+ value: "",
26
+ type: null,
27
+ comment: "",
28
+ range: [
29
+ offset,
30
+ offset + source.length,
31
+ offset + source.length
32
+ ]
33
+ };
34
+ }
35
+ const valueEnd = offset + source.length;
36
+ const re = resolveEnd(end, valueEnd, strict, onError);
37
+ return {
38
+ value,
39
+ type: _type,
40
+ comment: re.comment,
41
+ range: [
42
+ offset,
43
+ valueEnd,
44
+ re.offset
45
+ ]
46
+ };
47
+ }
48
+ function plainValue(source, onError) {
49
+ let badChar = "";
50
+ switch (source[0]) {
51
+ case " ":
52
+ badChar = "a tab character";
53
+ break;
54
+ case ",":
55
+ badChar = "flow indicator character ,";
56
+ break;
57
+ case "%":
58
+ badChar = "directive indicator character %";
59
+ break;
60
+ case "|":
61
+ case ">":
62
+ badChar = `block scalar indicator ${source[0]}`;
63
+ break;
64
+ case "@":
65
+ case "`":
66
+ badChar = `reserved character ${source[0]}`;
67
+ break;
68
+ }
69
+ if (badChar) onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
70
+ return foldLines(source);
71
+ }
72
+ function singleQuotedValue(source, onError) {
73
+ if (source[source.length - 1] !== "'" || source.length === 1) onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
74
+ return foldLines(source.slice(1, -1)).replace(/''/g, "'");
75
+ }
76
+ function foldLines(source) {
77
+ /**
78
+ * The negative lookbehind here and in the `re` RegExp is to
79
+ * prevent causing a polynomial search time in certain cases.
80
+ *
81
+ * The try-catch is for Safari, which doesn't support this yet:
82
+ * https://caniuse.com/js-regexp-lookbehind
83
+ */
84
+ let first, line;
85
+ try {
86
+ first = /* @__PURE__ */ new RegExp("(.*?)(?<![ ])[ ]*\r?\n", "sy");
87
+ line = /* @__PURE__ */ new RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n", "sy");
88
+ } catch {
89
+ first = /(.*?)[ \t]*\r?\n/sy;
90
+ line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
91
+ }
92
+ let match = first.exec(source);
93
+ if (!match) return source;
94
+ let res = match[1];
95
+ let sep = " ";
96
+ let pos = first.lastIndex;
97
+ line.lastIndex = pos;
98
+ while (match = line.exec(source)) {
99
+ if (match[1] === "") if (sep === "\n") res += sep;
100
+ else sep = "\n";
101
+ else {
102
+ res += sep + match[1];
103
+ sep = " ";
104
+ }
105
+ pos = line.lastIndex;
106
+ }
107
+ const last = /[ \t]*(.*)/sy;
108
+ last.lastIndex = pos;
109
+ match = last.exec(source);
110
+ return res + sep + (match?.[1] ?? "");
111
+ }
112
+ function doubleQuotedValue(source, onError) {
113
+ let res = "";
114
+ for (let i = 1; i < source.length - 1; ++i) {
115
+ const ch = source[i];
116
+ if (ch === "\r" && source[i + 1] === "\n") continue;
117
+ if (ch === "\n") {
118
+ const { fold, offset } = foldNewline(source, i);
119
+ res += fold;
120
+ i = offset;
121
+ } else if (ch === "\\") {
122
+ let next = source[++i];
123
+ const cc = escapeCodes[next];
124
+ if (cc) res += cc;
125
+ else if (next === "\n") {
126
+ next = source[i + 1];
127
+ while (next === " " || next === " ") next = source[++i + 1];
128
+ } else if (next === "\r" && source[i + 1] === "\n") {
129
+ next = source[++i + 1];
130
+ while (next === " " || next === " ") next = source[++i + 1];
131
+ } else if (next === "x" || next === "u" || next === "U") {
132
+ const length = {
133
+ x: 2,
134
+ u: 4,
135
+ U: 8
136
+ }[next];
137
+ res += parseCharCode(source, i + 1, length, onError);
138
+ i += length;
139
+ } else {
140
+ const raw = source.substr(i - 1, 2);
141
+ onError(i - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
142
+ res += raw;
143
+ }
144
+ } else if (ch === " " || ch === " ") {
145
+ const wsStart = i;
146
+ let next = source[i + 1];
147
+ while (next === " " || next === " ") next = source[++i + 1];
148
+ if (next !== "\n" && !(next === "\r" && source[i + 2] === "\n")) res += i > wsStart ? source.slice(wsStart, i + 1) : ch;
149
+ } else res += ch;
150
+ }
151
+ if (source[source.length - 1] !== "\"" || source.length === 1) onError(source.length, "MISSING_CHAR", "Missing closing \"quote");
152
+ return res;
153
+ }
154
+ /**
155
+ * Fold a single newline into a space, multiple newlines to N - 1 newlines.
156
+ * Presumes `source[offset] === '\n'`
157
+ */
158
+ function foldNewline(source, offset) {
159
+ let fold = "";
160
+ let ch = source[offset + 1];
161
+ while (ch === " " || ch === " " || ch === "\n" || ch === "\r") {
162
+ if (ch === "\r" && source[offset + 2] !== "\n") break;
163
+ if (ch === "\n") fold += "\n";
164
+ offset += 1;
165
+ ch = source[offset + 1];
166
+ }
167
+ if (!fold) fold = " ";
168
+ return {
169
+ fold,
170
+ offset
171
+ };
172
+ }
173
+ const escapeCodes = {
174
+ "0": "\0",
175
+ a: "\x07",
176
+ b: "\b",
177
+ e: "\x1B",
178
+ f: "\f",
179
+ n: "\n",
180
+ r: "\r",
181
+ t: " ",
182
+ v: "\v",
183
+ N: "…",
184
+ _: "\xA0",
185
+ L: "\u2028",
186
+ P: "\u2029",
187
+ " ": " ",
188
+ "\"": "\"",
189
+ "/": "/",
190
+ "\\": "\\",
191
+ " ": " "
192
+ };
193
+ function parseCharCode(source, offset, length, onError) {
194
+ const cc = source.substr(offset, length);
195
+ const code = cc.length === length && /^[0-9a-fA-F]+$/.test(cc) ? parseInt(cc, 16) : NaN;
196
+ if (isNaN(code)) {
197
+ const raw = source.substr(offset - 2, length + 2);
198
+ onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
199
+ return raw;
200
+ }
201
+ return String.fromCodePoint(code);
202
+ }
203
+ //#endregion
204
+ export { resolveFlowScalar };
@@ -0,0 +1,105 @@
1
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-props.js
2
+ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
3
+ let spaceBefore = false;
4
+ let atNewline = startOnNewline;
5
+ let hasSpace = startOnNewline;
6
+ let comment = "";
7
+ let commentSep = "";
8
+ let hasNewline = false;
9
+ let reqSpace = false;
10
+ let tab = null;
11
+ let anchor = null;
12
+ let tag = null;
13
+ let newlineAfterProp = null;
14
+ let comma = null;
15
+ let found = null;
16
+ let start = null;
17
+ for (const token of tokens) {
18
+ if (reqSpace) {
19
+ if (token.type !== "space" && token.type !== "newline" && token.type !== "comma") onError(token.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space");
20
+ reqSpace = false;
21
+ }
22
+ if (tab) {
23
+ if (atNewline && token.type !== "comment" && token.type !== "newline") onError(tab, "TAB_AS_INDENT", "Tabs are not allowed as indentation");
24
+ tab = null;
25
+ }
26
+ switch (token.type) {
27
+ case "space":
28
+ if (!flow && (indicator !== "doc-start" || next?.type !== "flow-collection") && token.source.includes(" ")) tab = token;
29
+ hasSpace = true;
30
+ break;
31
+ case "comment": {
32
+ if (!hasSpace) onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
33
+ const cb = token.source.substring(1) || " ";
34
+ if (!comment) comment = cb;
35
+ else comment += commentSep + cb;
36
+ commentSep = "";
37
+ atNewline = false;
38
+ break;
39
+ }
40
+ case "newline":
41
+ if (atNewline) {
42
+ if (comment) comment += token.source;
43
+ else if (!found || indicator !== "seq-item-ind") spaceBefore = true;
44
+ } else commentSep += token.source;
45
+ atNewline = true;
46
+ hasNewline = true;
47
+ if (anchor || tag) newlineAfterProp = token;
48
+ hasSpace = true;
49
+ break;
50
+ case "anchor":
51
+ if (anchor) onError(token, "MULTIPLE_ANCHORS", "A node can have at most one anchor");
52
+ if (token.source.endsWith(":")) onError(token.offset + token.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", true);
53
+ anchor = token;
54
+ start ?? (start = token.offset);
55
+ atNewline = false;
56
+ hasSpace = false;
57
+ reqSpace = true;
58
+ break;
59
+ case "tag":
60
+ if (tag) onError(token, "MULTIPLE_TAGS", "A node can have at most one tag");
61
+ tag = token;
62
+ start ?? (start = token.offset);
63
+ atNewline = false;
64
+ hasSpace = false;
65
+ reqSpace = true;
66
+ break;
67
+ case indicator:
68
+ if (anchor || tag) onError(token, "BAD_PROP_ORDER", `Anchors and tags must be after the ${token.source} indicator`);
69
+ if (found) onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.source} in ${flow ?? "collection"}`);
70
+ found = token;
71
+ atNewline = indicator === "seq-item-ind" || indicator === "explicit-key-ind";
72
+ hasSpace = false;
73
+ break;
74
+ case "comma": if (flow) {
75
+ if (comma) onError(token, "UNEXPECTED_TOKEN", `Unexpected , in ${flow}`);
76
+ comma = token;
77
+ atNewline = false;
78
+ hasSpace = false;
79
+ break;
80
+ }
81
+ default:
82
+ onError(token, "UNEXPECTED_TOKEN", `Unexpected ${token.type} token`);
83
+ atNewline = false;
84
+ hasSpace = false;
85
+ }
86
+ }
87
+ const last = tokens[tokens.length - 1];
88
+ const end = last ? last.offset + last.source.length : offset;
89
+ if (reqSpace && next && next.type !== "space" && next.type !== "newline" && next.type !== "comma" && (next.type !== "scalar" || next.source !== "")) onError(next.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space");
90
+ if (tab && (atNewline && tab.indent <= parentIndent || next?.type === "block-map" || next?.type === "block-seq")) onError(tab, "TAB_AS_INDENT", "Tabs are not allowed as indentation");
91
+ return {
92
+ comma,
93
+ found,
94
+ spaceBefore,
95
+ comment,
96
+ hasNewline,
97
+ anchor,
98
+ tag,
99
+ newlineAfterProp,
100
+ end,
101
+ start: start ?? end
102
+ };
103
+ }
104
+ //#endregion
105
+ export { resolveProps };
@@ -0,0 +1,27 @@
1
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-contains-newline.js
2
+ function containsNewline(key) {
3
+ if (!key) return null;
4
+ switch (key.type) {
5
+ case "alias":
6
+ case "scalar":
7
+ case "double-quoted-scalar":
8
+ case "single-quoted-scalar":
9
+ if (key.source.includes("\n")) return true;
10
+ if (key.end) {
11
+ for (const st of key.end) if (st.type === "newline") return true;
12
+ }
13
+ return false;
14
+ case "flow-collection":
15
+ for (const it of key.items) {
16
+ for (const st of it.start) if (st.type === "newline") return true;
17
+ if (it.sep) {
18
+ for (const st of it.sep) if (st.type === "newline") return true;
19
+ }
20
+ if (containsNewline(it.key) || containsNewline(it.value)) return true;
21
+ }
22
+ return false;
23
+ default: return true;
24
+ }
25
+ }
26
+ //#endregion
27
+ export { containsNewline };
@@ -0,0 +1,25 @@
1
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js
2
+ function emptyScalarPosition(offset, before, pos) {
3
+ if (before) {
4
+ pos ?? (pos = before.length);
5
+ for (let i = pos - 1; i >= 0; --i) {
6
+ let st = before[i];
7
+ switch (st.type) {
8
+ case "space":
9
+ case "comment":
10
+ case "newline":
11
+ offset -= st.source.length;
12
+ continue;
13
+ }
14
+ st = before[++i];
15
+ while (st?.type === "space") {
16
+ offset += st.source.length;
17
+ st = before[++i];
18
+ }
19
+ break;
20
+ }
21
+ }
22
+ return offset;
23
+ }
24
+ //#endregion
25
+ export { emptyScalarPosition };
@@ -0,0 +1,10 @@
1
+ import { containsNewline } from "./util-contains-newline.js";
2
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js
3
+ function flowIndentCheck(indent, fc, onError) {
4
+ if (fc?.type === "flow-collection") {
5
+ const end = fc.end[0];
6
+ if (end.indent === indent && (end.source === "]" || end.source === "}") && containsNewline(fc)) onError(end, "BAD_INDENT", "Flow end indicator should be more indented than parent", true);
7
+ }
8
+ }
9
+ //#endregion
10
+ export { flowIndentCheck };
@@ -0,0 +1,10 @@
1
+ import { isScalar } from "../nodes/identity.js";
2
+ //#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-map-includes.js
3
+ function mapIncludes(ctx, items, search) {
4
+ const { uniqueKeys } = ctx.options;
5
+ if (uniqueKeys === false) return false;
6
+ const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b || isScalar(a) && isScalar(b) && a.value === b.value;
7
+ return items.some((pair) => isEqual(pair.key, search));
8
+ }
9
+ //#endregion
10
+ export { mapIncludes };