fumadocs-openapi 10.6.7 → 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.
- package/css/generated/shared.css +2 -5
- package/dist/_virtual/_rolldown/runtime.js +2 -1
- package/dist/i18n.js +3 -2
- package/dist/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +108 -0
- package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/general/create-limiter.js +43 -0
- package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/object/is-object.js +26 -0
- package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/object/prevent-pollution.js +33 -0
- package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/queue/queue.js +106 -0
- package/dist/node_modules/.pnpm/@scalar_helpers@0.4.3/node_modules/@scalar/helpers/dist/string/generate-hash.js +120 -0
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/bundle.js +346 -0
- 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
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js +3 -0
- 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
- 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
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/bundle/value-generator.js +88 -0
- 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
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/escape-json-pointer.js +11 -0
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/get-schemas.js +44 -0
- 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
- 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
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/is-file-path.js +23 -0
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/is-http-url.js +23 -0
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/is-json-object.js +28 -0
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/is-yaml.js +21 -0
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/normalize.js +26 -0
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/resolve-reference-path.js +30 -0
- 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
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/to-relative-path.js +33 -0
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.5/node_modules/@scalar/json-magic/dist/helpers/unescape-json-pointer.js +12 -0
- 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
- 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
- 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
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.4/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +25 -0
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.4/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +15 -0
- package/dist/node_modules/.pnpm/fast-content-type-parse@3.0.0/node_modules/fast-content-type-parse/index.js +115 -0
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +19 -0
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +430 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-collection.js +50 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-doc.js +39 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-node.js +85 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/compose-scalar.js +57 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/composer.js +193 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-block-map.js +82 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +173 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +40 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-end.js +36 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +153 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +204 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/resolve-props.js +105 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-contains-newline.js +27 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +25 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +10 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/compose/util-map-includes.js +10 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/Document.js +277 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/anchors.js +57 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/applyReviver.js +38 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/createNode.js +61 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/doc/directives.js +163 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/errors.js +48 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/index.js +16 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/log.js +6 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Alias.js +91 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Collection.js +117 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Node.js +32 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Pair.js +29 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/YAMLMap.js +106 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +104 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +49 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/identity.js +33 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/nodes/toJS.js +35 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/cst-scalar.js +3 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/cst-visit.js +89 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/cst.js +40 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/lexer.js +517 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/line-counter.js +45 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/parse/parser.js +852 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/public-api.js +44 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/Schema.js +27 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/common/map.js +16 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/common/null.js +13 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/common/seq.js +16 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/core/bool.js +17 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/core/float.js +38 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/core/int.js +37 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/json/schema.js +61 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/tags.js +81 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +44 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +24 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +41 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +70 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +36 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +60 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +56 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +39 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +65 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +79 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +111 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringify.js +105 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +116 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyComment.js +16 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +59 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +19 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyPair.js +95 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyString.js +222 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/visit.js +187 -0
- package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/index.js +16 -0
- package/dist/playground/components/oauth-dialog.js +17 -11
- package/dist/playground/components/result-display.js +3 -2
- package/dist/playground/schema.js +1 -1
- package/dist/scalar/client.js +15 -24
- package/dist/ui/operation/get-example-requests.js +1 -1
- package/dist/ui/operation/response-tabs.js +1 -1
- package/dist/utils/document/process.js +5 -3
- package/dist/utils/schema/sample.js +442 -0
- package/package.json +26 -25
package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isPair, isScalar } from "../../nodes/identity.js";
|
|
2
|
+
import { toJS } from "../../nodes/toJS.js";
|
|
3
|
+
import { YAMLMap } from "../../nodes/YAMLMap.js";
|
|
4
|
+
import { YAMLSeq } from "../../nodes/YAMLSeq.js";
|
|
5
|
+
import { createPairs, resolvePairs } from "./pairs.js";
|
|
6
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js
|
|
7
|
+
var YAMLOMap = class YAMLOMap extends YAMLSeq {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.add = YAMLMap.prototype.add.bind(this);
|
|
11
|
+
this.delete = YAMLMap.prototype.delete.bind(this);
|
|
12
|
+
this.get = YAMLMap.prototype.get.bind(this);
|
|
13
|
+
this.has = YAMLMap.prototype.has.bind(this);
|
|
14
|
+
this.set = YAMLMap.prototype.set.bind(this);
|
|
15
|
+
this.tag = YAMLOMap.tag;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
|
|
19
|
+
* but TypeScript won't allow widening the signature of a child method.
|
|
20
|
+
*/
|
|
21
|
+
toJSON(_, ctx) {
|
|
22
|
+
if (!ctx) return super.toJSON(_);
|
|
23
|
+
const map = /* @__PURE__ */ new Map();
|
|
24
|
+
if (ctx?.onCreate) ctx.onCreate(map);
|
|
25
|
+
for (const pair of this.items) {
|
|
26
|
+
let key, value;
|
|
27
|
+
if (isPair(pair)) {
|
|
28
|
+
key = toJS(pair.key, "", ctx);
|
|
29
|
+
value = toJS(pair.value, key, ctx);
|
|
30
|
+
} else key = toJS(pair, "", ctx);
|
|
31
|
+
if (map.has(key)) throw new Error("Ordered maps must not include duplicate keys");
|
|
32
|
+
map.set(key, value);
|
|
33
|
+
}
|
|
34
|
+
return map;
|
|
35
|
+
}
|
|
36
|
+
static from(schema, iterable, ctx) {
|
|
37
|
+
const pairs = createPairs(schema, iterable, ctx);
|
|
38
|
+
const omap = new this();
|
|
39
|
+
omap.items = pairs.items;
|
|
40
|
+
return omap;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
YAMLOMap.tag = "tag:yaml.org,2002:omap";
|
|
44
|
+
const omap = {
|
|
45
|
+
collection: "seq",
|
|
46
|
+
identify: (value) => value instanceof Map,
|
|
47
|
+
nodeClass: YAMLOMap,
|
|
48
|
+
default: false,
|
|
49
|
+
tag: "tag:yaml.org,2002:omap",
|
|
50
|
+
resolve(seq, onError) {
|
|
51
|
+
const pairs = resolvePairs(seq, onError);
|
|
52
|
+
const seenKeys = [];
|
|
53
|
+
for (const { key } of pairs.items) if (isScalar(key)) if (seenKeys.includes(key.value)) onError(`Ordered maps must not include duplicate keys: ${key.value}`);
|
|
54
|
+
else seenKeys.push(key.value);
|
|
55
|
+
return Object.assign(new YAMLOMap(), pairs);
|
|
56
|
+
},
|
|
57
|
+
createNode: (schema, iterable, ctx) => YAMLOMap.from(schema, iterable, ctx)
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { omap };
|
package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isMap, isPair, isSeq } from "../../nodes/identity.js";
|
|
2
|
+
import { Scalar } from "../../nodes/Scalar.js";
|
|
3
|
+
import { Pair, createPair } from "../../nodes/Pair.js";
|
|
4
|
+
import { YAMLSeq } from "../../nodes/YAMLSeq.js";
|
|
5
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js
|
|
6
|
+
function resolvePairs(seq, onError) {
|
|
7
|
+
if (isSeq(seq)) for (let i = 0; i < seq.items.length; ++i) {
|
|
8
|
+
let item = seq.items[i];
|
|
9
|
+
if (isPair(item)) continue;
|
|
10
|
+
else if (isMap(item)) {
|
|
11
|
+
if (item.items.length > 1) onError("Each pair must have its own sequence indicator");
|
|
12
|
+
const pair = item.items[0] || new Pair(new Scalar(null));
|
|
13
|
+
if (item.commentBefore) pair.key.commentBefore = pair.key.commentBefore ? `${item.commentBefore}\n${pair.key.commentBefore}` : item.commentBefore;
|
|
14
|
+
if (item.comment) {
|
|
15
|
+
const cn = pair.value ?? pair.key;
|
|
16
|
+
cn.comment = cn.comment ? `${item.comment}\n${cn.comment}` : item.comment;
|
|
17
|
+
}
|
|
18
|
+
item = pair;
|
|
19
|
+
}
|
|
20
|
+
seq.items[i] = isPair(item) ? item : new Pair(item);
|
|
21
|
+
}
|
|
22
|
+
else onError("Expected a sequence for this tag");
|
|
23
|
+
return seq;
|
|
24
|
+
}
|
|
25
|
+
function createPairs(schema, iterable, ctx) {
|
|
26
|
+
const { replacer } = ctx;
|
|
27
|
+
const pairs = new YAMLSeq(schema);
|
|
28
|
+
pairs.tag = "tag:yaml.org,2002:pairs";
|
|
29
|
+
let i = 0;
|
|
30
|
+
if (iterable && Symbol.iterator in Object(iterable)) for (let it of iterable) {
|
|
31
|
+
if (typeof replacer === "function") it = replacer.call(iterable, String(i++), it);
|
|
32
|
+
let key, value;
|
|
33
|
+
if (Array.isArray(it)) if (it.length === 2) {
|
|
34
|
+
key = it[0];
|
|
35
|
+
value = it[1];
|
|
36
|
+
} else throw new TypeError(`Expected [key, value] tuple: ${it}`);
|
|
37
|
+
else if (it && it instanceof Object) {
|
|
38
|
+
const keys = Object.keys(it);
|
|
39
|
+
if (keys.length === 1) {
|
|
40
|
+
key = keys[0];
|
|
41
|
+
value = it[key];
|
|
42
|
+
} else throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`);
|
|
43
|
+
} else key = it;
|
|
44
|
+
pairs.items.push(createPair(key, value, ctx));
|
|
45
|
+
}
|
|
46
|
+
return pairs;
|
|
47
|
+
}
|
|
48
|
+
const pairs = {
|
|
49
|
+
collection: "seq",
|
|
50
|
+
default: false,
|
|
51
|
+
tag: "tag:yaml.org,2002:pairs",
|
|
52
|
+
resolve: resolvePairs,
|
|
53
|
+
createNode: createPairs
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { createPairs, pairs, resolvePairs };
|
package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { merge } from "./merge.js";
|
|
2
|
+
import { map } from "../common/map.js";
|
|
3
|
+
import { seq } from "../common/seq.js";
|
|
4
|
+
import { string } from "../common/string.js";
|
|
5
|
+
import { nullTag } from "../common/null.js";
|
|
6
|
+
import { binary } from "./binary.js";
|
|
7
|
+
import { pairs } from "./pairs.js";
|
|
8
|
+
import { omap } from "./omap.js";
|
|
9
|
+
import { falseTag, trueTag } from "./bool.js";
|
|
10
|
+
import { float, floatExp, floatNaN } from "./float.js";
|
|
11
|
+
import { int, intBin, intHex, intOct } from "./int.js";
|
|
12
|
+
import { set } from "./set.js";
|
|
13
|
+
import { floatTime, intTime, timestamp } from "./timestamp.js";
|
|
14
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js
|
|
15
|
+
const schema = [
|
|
16
|
+
map,
|
|
17
|
+
seq,
|
|
18
|
+
string,
|
|
19
|
+
nullTag,
|
|
20
|
+
trueTag,
|
|
21
|
+
falseTag,
|
|
22
|
+
intBin,
|
|
23
|
+
intOct,
|
|
24
|
+
int,
|
|
25
|
+
intHex,
|
|
26
|
+
floatNaN,
|
|
27
|
+
floatExp,
|
|
28
|
+
float,
|
|
29
|
+
binary,
|
|
30
|
+
merge,
|
|
31
|
+
omap,
|
|
32
|
+
pairs,
|
|
33
|
+
set,
|
|
34
|
+
intTime,
|
|
35
|
+
floatTime,
|
|
36
|
+
timestamp
|
|
37
|
+
];
|
|
38
|
+
//#endregion
|
|
39
|
+
export { schema };
|
package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { isMap, isPair, isScalar } from "../../nodes/identity.js";
|
|
2
|
+
import { Pair, createPair } from "../../nodes/Pair.js";
|
|
3
|
+
import { YAMLMap, findPair } from "../../nodes/YAMLMap.js";
|
|
4
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js
|
|
5
|
+
var YAMLSet = class YAMLSet extends YAMLMap {
|
|
6
|
+
constructor(schema) {
|
|
7
|
+
super(schema);
|
|
8
|
+
this.tag = YAMLSet.tag;
|
|
9
|
+
}
|
|
10
|
+
add(key) {
|
|
11
|
+
let pair;
|
|
12
|
+
if (isPair(key)) pair = key;
|
|
13
|
+
else if (key && typeof key === "object" && "key" in key && "value" in key && key.value === null) pair = new Pair(key.key, null);
|
|
14
|
+
else pair = new Pair(key, null);
|
|
15
|
+
if (!findPair(this.items, pair.key)) this.items.push(pair);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* If `keepPair` is `true`, returns the Pair matching `key`.
|
|
19
|
+
* Otherwise, returns the value of that Pair's key.
|
|
20
|
+
*/
|
|
21
|
+
get(key, keepPair) {
|
|
22
|
+
const pair = findPair(this.items, key);
|
|
23
|
+
return !keepPair && isPair(pair) ? isScalar(pair.key) ? pair.key.value : pair.key : pair;
|
|
24
|
+
}
|
|
25
|
+
set(key, value) {
|
|
26
|
+
if (typeof value !== "boolean") throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
|
|
27
|
+
const prev = findPair(this.items, key);
|
|
28
|
+
if (prev && !value) this.items.splice(this.items.indexOf(prev), 1);
|
|
29
|
+
else if (!prev && value) this.items.push(new Pair(key));
|
|
30
|
+
}
|
|
31
|
+
toJSON(_, ctx) {
|
|
32
|
+
return super.toJSON(_, ctx, Set);
|
|
33
|
+
}
|
|
34
|
+
toString(ctx, onComment, onChompKeep) {
|
|
35
|
+
if (!ctx) return JSON.stringify(this);
|
|
36
|
+
if (this.hasAllNullValues(true)) return super.toString(Object.assign({}, ctx, { allNullValues: true }), onComment, onChompKeep);
|
|
37
|
+
else throw new Error("Set items must all have null values");
|
|
38
|
+
}
|
|
39
|
+
static from(schema, iterable, ctx) {
|
|
40
|
+
const { replacer } = ctx;
|
|
41
|
+
const set = new this(schema);
|
|
42
|
+
if (iterable && Symbol.iterator in Object(iterable)) for (let value of iterable) {
|
|
43
|
+
if (typeof replacer === "function") value = replacer.call(iterable, value, value);
|
|
44
|
+
set.items.push(createPair(value, null, ctx));
|
|
45
|
+
}
|
|
46
|
+
return set;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
YAMLSet.tag = "tag:yaml.org,2002:set";
|
|
50
|
+
const set = {
|
|
51
|
+
collection: "map",
|
|
52
|
+
identify: (value) => value instanceof Set,
|
|
53
|
+
nodeClass: YAMLSet,
|
|
54
|
+
default: false,
|
|
55
|
+
tag: "tag:yaml.org,2002:set",
|
|
56
|
+
createNode: (schema, iterable, ctx) => YAMLSet.from(schema, iterable, ctx),
|
|
57
|
+
resolve(map, onError) {
|
|
58
|
+
if (isMap(map)) if (map.hasAllNullValues(true)) return Object.assign(new YAMLSet(), map);
|
|
59
|
+
else onError("Set items must all have null values");
|
|
60
|
+
else onError("Expected a mapping for this tag");
|
|
61
|
+
return map;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { set };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { stringifyNumber } from "../../stringify/stringifyNumber.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js
|
|
3
|
+
/** Internal types handle bigint as number, because TS can't figure it out. */
|
|
4
|
+
function parseSexagesimal(str, asBigInt) {
|
|
5
|
+
const sign = str[0];
|
|
6
|
+
const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
|
|
7
|
+
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
8
|
+
const res = parts.replace(/_/g, "").split(":").reduce((res, p) => res * num(60) + num(p), num(0));
|
|
9
|
+
return sign === "-" ? num(-1) * res : res;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* hhhh:mm:ss.sss
|
|
13
|
+
*
|
|
14
|
+
* Internal types handle bigint as number, because TS can't figure it out.
|
|
15
|
+
*/
|
|
16
|
+
function stringifySexagesimal(node) {
|
|
17
|
+
let { value } = node;
|
|
18
|
+
let num = (n) => n;
|
|
19
|
+
if (typeof value === "bigint") num = (n) => BigInt(n);
|
|
20
|
+
else if (isNaN(value) || !isFinite(value)) return stringifyNumber(node);
|
|
21
|
+
let sign = "";
|
|
22
|
+
if (value < 0) {
|
|
23
|
+
sign = "-";
|
|
24
|
+
value *= num(-1);
|
|
25
|
+
}
|
|
26
|
+
const _60 = num(60);
|
|
27
|
+
const parts = [value % _60];
|
|
28
|
+
if (value < 60) parts.unshift(0);
|
|
29
|
+
else {
|
|
30
|
+
value = (value - parts[0]) / _60;
|
|
31
|
+
parts.unshift(value % _60);
|
|
32
|
+
if (value >= 60) {
|
|
33
|
+
value = (value - parts[0]) / _60;
|
|
34
|
+
parts.unshift(value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return sign + parts.map((n) => String(n).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
|
|
38
|
+
}
|
|
39
|
+
const intTime = {
|
|
40
|
+
identify: (value) => typeof value === "bigint" || Number.isInteger(value),
|
|
41
|
+
default: true,
|
|
42
|
+
tag: "tag:yaml.org,2002:int",
|
|
43
|
+
format: "TIME",
|
|
44
|
+
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
45
|
+
resolve: (str, _onError, { intAsBigInt }) => parseSexagesimal(str, intAsBigInt),
|
|
46
|
+
stringify: stringifySexagesimal
|
|
47
|
+
};
|
|
48
|
+
const floatTime = {
|
|
49
|
+
identify: (value) => typeof value === "number",
|
|
50
|
+
default: true,
|
|
51
|
+
tag: "tag:yaml.org,2002:float",
|
|
52
|
+
format: "TIME",
|
|
53
|
+
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
54
|
+
resolve: (str) => parseSexagesimal(str, false),
|
|
55
|
+
stringify: stringifySexagesimal
|
|
56
|
+
};
|
|
57
|
+
const timestamp = {
|
|
58
|
+
identify: (value) => value instanceof Date,
|
|
59
|
+
default: true,
|
|
60
|
+
tag: "tag:yaml.org,2002:timestamp",
|
|
61
|
+
test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
|
|
62
|
+
resolve(str) {
|
|
63
|
+
const match = str.match(timestamp.test);
|
|
64
|
+
if (!match) throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
65
|
+
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
66
|
+
const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0;
|
|
67
|
+
let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
|
|
68
|
+
const tz = match[8];
|
|
69
|
+
if (tz && tz !== "Z") {
|
|
70
|
+
let d = parseSexagesimal(tz, false);
|
|
71
|
+
if (Math.abs(d) < 30) d *= 60;
|
|
72
|
+
date -= 6e4 * d;
|
|
73
|
+
}
|
|
74
|
+
return new Date(date);
|
|
75
|
+
},
|
|
76
|
+
stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? ""
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { floatTime, intTime, timestamp };
|
package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
|
|
2
|
+
const FOLD_FLOW = "flow";
|
|
3
|
+
const FOLD_BLOCK = "block";
|
|
4
|
+
const FOLD_QUOTED = "quoted";
|
|
5
|
+
/**
|
|
6
|
+
* Tries to keep input at up to `lineWidth` characters, splitting only on spaces
|
|
7
|
+
* not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are
|
|
8
|
+
* terminated with `\n` and started with `indent`.
|
|
9
|
+
*/
|
|
10
|
+
function foldFlowLines(text, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
11
|
+
if (!lineWidth || lineWidth < 0) return text;
|
|
12
|
+
if (lineWidth < minContentWidth) minContentWidth = 0;
|
|
13
|
+
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
14
|
+
if (text.length <= endStep) return text;
|
|
15
|
+
const folds = [];
|
|
16
|
+
const escapedFolds = {};
|
|
17
|
+
let end = lineWidth - indent.length;
|
|
18
|
+
if (typeof indentAtStart === "number") if (indentAtStart > lineWidth - Math.max(2, minContentWidth)) folds.push(0);
|
|
19
|
+
else end = lineWidth - indentAtStart;
|
|
20
|
+
let split = void 0;
|
|
21
|
+
let prev = void 0;
|
|
22
|
+
let overflow = false;
|
|
23
|
+
let i = -1;
|
|
24
|
+
let escStart = -1;
|
|
25
|
+
let escEnd = -1;
|
|
26
|
+
if (mode === "block") {
|
|
27
|
+
i = consumeMoreIndentedLines(text, i, indent.length);
|
|
28
|
+
if (i !== -1) end = i + endStep;
|
|
29
|
+
}
|
|
30
|
+
for (let ch; ch = text[i += 1];) {
|
|
31
|
+
if (mode === "quoted" && ch === "\\") {
|
|
32
|
+
escStart = i;
|
|
33
|
+
switch (text[i + 1]) {
|
|
34
|
+
case "x":
|
|
35
|
+
i += 3;
|
|
36
|
+
break;
|
|
37
|
+
case "u":
|
|
38
|
+
i += 5;
|
|
39
|
+
break;
|
|
40
|
+
case "U":
|
|
41
|
+
i += 9;
|
|
42
|
+
break;
|
|
43
|
+
default: i += 1;
|
|
44
|
+
}
|
|
45
|
+
escEnd = i;
|
|
46
|
+
}
|
|
47
|
+
if (ch === "\n") {
|
|
48
|
+
if (mode === "block") i = consumeMoreIndentedLines(text, i, indent.length);
|
|
49
|
+
end = i + indent.length + endStep;
|
|
50
|
+
split = void 0;
|
|
51
|
+
} else {
|
|
52
|
+
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
53
|
+
const next = text[i + 1];
|
|
54
|
+
if (next && next !== " " && next !== "\n" && next !== " ") split = i;
|
|
55
|
+
}
|
|
56
|
+
if (i >= end) if (split) {
|
|
57
|
+
folds.push(split);
|
|
58
|
+
end = split + endStep;
|
|
59
|
+
split = void 0;
|
|
60
|
+
} else if (mode === "quoted") {
|
|
61
|
+
while (prev === " " || prev === " ") {
|
|
62
|
+
prev = ch;
|
|
63
|
+
ch = text[i += 1];
|
|
64
|
+
overflow = true;
|
|
65
|
+
}
|
|
66
|
+
const j = i > escEnd + 1 ? i - 2 : escStart - 1;
|
|
67
|
+
if (escapedFolds[j]) return text;
|
|
68
|
+
folds.push(j);
|
|
69
|
+
escapedFolds[j] = true;
|
|
70
|
+
end = j + endStep;
|
|
71
|
+
split = void 0;
|
|
72
|
+
} else overflow = true;
|
|
73
|
+
}
|
|
74
|
+
prev = ch;
|
|
75
|
+
}
|
|
76
|
+
if (overflow && onOverflow) onOverflow();
|
|
77
|
+
if (folds.length === 0) return text;
|
|
78
|
+
if (onFold) onFold();
|
|
79
|
+
let res = text.slice(0, folds[0]);
|
|
80
|
+
for (let i = 0; i < folds.length; ++i) {
|
|
81
|
+
const fold = folds[i];
|
|
82
|
+
const end = folds[i + 1] || text.length;
|
|
83
|
+
if (fold === 0) res = `\n${indent}${text.slice(0, end)}`;
|
|
84
|
+
else {
|
|
85
|
+
if (mode === "quoted" && escapedFolds[fold]) res += `${text[fold]}\\`;
|
|
86
|
+
res += `\n${indent}${text.slice(fold + 1, end)}`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return res;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Presumes `i + 1` is at the start of a line
|
|
93
|
+
* @returns index of last newline in more-indented block
|
|
94
|
+
*/
|
|
95
|
+
function consumeMoreIndentedLines(text, i, indent) {
|
|
96
|
+
let end = i;
|
|
97
|
+
let start = i + 1;
|
|
98
|
+
let ch = text[start];
|
|
99
|
+
while (ch === " " || ch === " ") if (i < start + indent) ch = text[++i];
|
|
100
|
+
else {
|
|
101
|
+
do
|
|
102
|
+
ch = text[++i];
|
|
103
|
+
while (ch && ch !== "\n");
|
|
104
|
+
end = i;
|
|
105
|
+
start = i + 1;
|
|
106
|
+
ch = text[start];
|
|
107
|
+
}
|
|
108
|
+
return end;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { FOLD_BLOCK, FOLD_FLOW, FOLD_QUOTED, foldFlowLines };
|
package/dist/node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringify.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { isAlias, isCollection, isNode, isPair, isScalar } from "../nodes/identity.js";
|
|
2
|
+
import { anchorIsValid } from "../doc/anchors.js";
|
|
3
|
+
import { stringifyComment } from "./stringifyComment.js";
|
|
4
|
+
import { stringifyString } from "./stringifyString.js";
|
|
5
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringify.js
|
|
6
|
+
function createStringifyContext(doc, options) {
|
|
7
|
+
const opt = Object.assign({
|
|
8
|
+
blockQuote: true,
|
|
9
|
+
commentString: stringifyComment,
|
|
10
|
+
defaultKeyType: null,
|
|
11
|
+
defaultStringType: "PLAIN",
|
|
12
|
+
directives: null,
|
|
13
|
+
doubleQuotedAsJSON: false,
|
|
14
|
+
doubleQuotedMinMultiLineLength: 40,
|
|
15
|
+
falseStr: "false",
|
|
16
|
+
flowCollectionPadding: true,
|
|
17
|
+
indentSeq: true,
|
|
18
|
+
lineWidth: 80,
|
|
19
|
+
minContentWidth: 20,
|
|
20
|
+
nullStr: "null",
|
|
21
|
+
simpleKeys: false,
|
|
22
|
+
singleQuote: null,
|
|
23
|
+
trailingComma: false,
|
|
24
|
+
trueStr: "true",
|
|
25
|
+
verifyAliasOrder: true
|
|
26
|
+
}, doc.schema.toStringOptions, options);
|
|
27
|
+
let inFlow;
|
|
28
|
+
switch (opt.collectionStyle) {
|
|
29
|
+
case "block":
|
|
30
|
+
inFlow = false;
|
|
31
|
+
break;
|
|
32
|
+
case "flow":
|
|
33
|
+
inFlow = true;
|
|
34
|
+
break;
|
|
35
|
+
default: inFlow = null;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
anchors: /* @__PURE__ */ new Set(),
|
|
39
|
+
doc,
|
|
40
|
+
flowCollectionPadding: opt.flowCollectionPadding ? " " : "",
|
|
41
|
+
indent: "",
|
|
42
|
+
indentStep: typeof opt.indent === "number" ? " ".repeat(opt.indent) : " ",
|
|
43
|
+
inFlow,
|
|
44
|
+
options: opt
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getTagObject(tags, item) {
|
|
48
|
+
if (item.tag) {
|
|
49
|
+
const match = tags.filter((t) => t.tag === item.tag);
|
|
50
|
+
if (match.length > 0) return match.find((t) => t.format === item.format) ?? match[0];
|
|
51
|
+
}
|
|
52
|
+
let tagObj = void 0;
|
|
53
|
+
let obj;
|
|
54
|
+
if (isScalar(item)) {
|
|
55
|
+
obj = item.value;
|
|
56
|
+
let match = tags.filter((t) => t.identify?.(obj));
|
|
57
|
+
if (match.length > 1) {
|
|
58
|
+
const testMatch = match.filter((t) => t.test);
|
|
59
|
+
if (testMatch.length > 0) match = testMatch;
|
|
60
|
+
}
|
|
61
|
+
tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
|
|
62
|
+
} else {
|
|
63
|
+
obj = item;
|
|
64
|
+
tagObj = tags.find((t) => t.nodeClass && obj instanceof t.nodeClass);
|
|
65
|
+
}
|
|
66
|
+
if (!tagObj) {
|
|
67
|
+
const name = obj?.constructor?.name ?? (obj === null ? "null" : typeof obj);
|
|
68
|
+
throw new Error(`Tag not resolved for ${name} value`);
|
|
69
|
+
}
|
|
70
|
+
return tagObj;
|
|
71
|
+
}
|
|
72
|
+
function stringifyProps(node, tagObj, { anchors, doc }) {
|
|
73
|
+
if (!doc.directives) return "";
|
|
74
|
+
const props = [];
|
|
75
|
+
const anchor = (isScalar(node) || isCollection(node)) && node.anchor;
|
|
76
|
+
if (anchor && anchorIsValid(anchor)) {
|
|
77
|
+
anchors.add(anchor);
|
|
78
|
+
props.push(`&${anchor}`);
|
|
79
|
+
}
|
|
80
|
+
const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
|
|
81
|
+
if (tag) props.push(doc.directives.tagString(tag));
|
|
82
|
+
return props.join(" ");
|
|
83
|
+
}
|
|
84
|
+
function stringify(item, ctx, onComment, onChompKeep) {
|
|
85
|
+
if (isPair(item)) return item.toString(ctx, onComment, onChompKeep);
|
|
86
|
+
if (isAlias(item)) {
|
|
87
|
+
if (ctx.doc.directives) return item.toString(ctx);
|
|
88
|
+
if (ctx.resolvedAliases?.has(item)) throw new TypeError(`Cannot stringify circular structure without alias nodes`);
|
|
89
|
+
else {
|
|
90
|
+
if (ctx.resolvedAliases) ctx.resolvedAliases.add(item);
|
|
91
|
+
else ctx.resolvedAliases = new Set([item]);
|
|
92
|
+
item = item.resolve(ctx.doc);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
let tagObj = void 0;
|
|
96
|
+
const node = isNode(item) ? item : ctx.doc.createNode(item, { onTagObj: (o) => tagObj = o });
|
|
97
|
+
tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
|
|
98
|
+
const props = stringifyProps(node, tagObj, ctx);
|
|
99
|
+
if (props.length > 0) ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
100
|
+
const str = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : isScalar(node) ? stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
|
|
101
|
+
if (!props) return str;
|
|
102
|
+
return isScalar(node) || str[0] === "{" || str[0] === "[" ? `${props} ${str}` : `${props}\n${ctx.indent}${str}`;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { createStringifyContext, stringify };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isNode, isPair } from "../nodes/identity.js";
|
|
2
|
+
import { indentComment, lineComment } from "./stringifyComment.js";
|
|
3
|
+
import { stringify } from "./stringify.js";
|
|
4
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyCollection.js
|
|
5
|
+
function stringifyCollection(collection, ctx, options) {
|
|
6
|
+
return (ctx.inFlow ?? collection.flow ? stringifyFlowCollection : stringifyBlockCollection)(collection, ctx, options);
|
|
7
|
+
}
|
|
8
|
+
function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
|
|
9
|
+
const { indent, options: { commentString } } = ctx;
|
|
10
|
+
const itemCtx = Object.assign({}, ctx, {
|
|
11
|
+
indent: itemIndent,
|
|
12
|
+
type: null
|
|
13
|
+
});
|
|
14
|
+
let chompKeep = false;
|
|
15
|
+
const lines = [];
|
|
16
|
+
for (let i = 0; i < items.length; ++i) {
|
|
17
|
+
const item = items[i];
|
|
18
|
+
let comment = null;
|
|
19
|
+
if (isNode(item)) {
|
|
20
|
+
if (!chompKeep && item.spaceBefore) lines.push("");
|
|
21
|
+
addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
|
|
22
|
+
if (item.comment) comment = item.comment;
|
|
23
|
+
} else if (isPair(item)) {
|
|
24
|
+
const ik = isNode(item.key) ? item.key : null;
|
|
25
|
+
if (ik) {
|
|
26
|
+
if (!chompKeep && ik.spaceBefore) lines.push("");
|
|
27
|
+
addCommentBefore(ctx, lines, ik.commentBefore, chompKeep);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
chompKeep = false;
|
|
31
|
+
let str = stringify(item, itemCtx, () => comment = null, () => chompKeep = true);
|
|
32
|
+
if (comment) str += lineComment(str, itemIndent, commentString(comment));
|
|
33
|
+
if (chompKeep && comment) chompKeep = false;
|
|
34
|
+
lines.push(blockItemPrefix + str);
|
|
35
|
+
}
|
|
36
|
+
let str;
|
|
37
|
+
if (lines.length === 0) str = flowChars.start + flowChars.end;
|
|
38
|
+
else {
|
|
39
|
+
str = lines[0];
|
|
40
|
+
for (let i = 1; i < lines.length; ++i) {
|
|
41
|
+
const line = lines[i];
|
|
42
|
+
str += line ? `\n${indent}${line}` : "\n";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (comment) {
|
|
46
|
+
str += "\n" + indentComment(commentString(comment), indent);
|
|
47
|
+
if (onComment) onComment();
|
|
48
|
+
} else if (chompKeep && onChompKeep) onChompKeep();
|
|
49
|
+
return str;
|
|
50
|
+
}
|
|
51
|
+
function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
|
|
52
|
+
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
|
|
53
|
+
itemIndent += indentStep;
|
|
54
|
+
const itemCtx = Object.assign({}, ctx, {
|
|
55
|
+
indent: itemIndent,
|
|
56
|
+
inFlow: true,
|
|
57
|
+
type: null
|
|
58
|
+
});
|
|
59
|
+
let reqNewline = false;
|
|
60
|
+
let linesAtValue = 0;
|
|
61
|
+
const lines = [];
|
|
62
|
+
for (let i = 0; i < items.length; ++i) {
|
|
63
|
+
const item = items[i];
|
|
64
|
+
let comment = null;
|
|
65
|
+
if (isNode(item)) {
|
|
66
|
+
if (item.spaceBefore) lines.push("");
|
|
67
|
+
addCommentBefore(ctx, lines, item.commentBefore, false);
|
|
68
|
+
if (item.comment) comment = item.comment;
|
|
69
|
+
} else if (isPair(item)) {
|
|
70
|
+
const ik = isNode(item.key) ? item.key : null;
|
|
71
|
+
if (ik) {
|
|
72
|
+
if (ik.spaceBefore) lines.push("");
|
|
73
|
+
addCommentBefore(ctx, lines, ik.commentBefore, false);
|
|
74
|
+
if (ik.comment) reqNewline = true;
|
|
75
|
+
}
|
|
76
|
+
const iv = isNode(item.value) ? item.value : null;
|
|
77
|
+
if (iv) {
|
|
78
|
+
if (iv.comment) comment = iv.comment;
|
|
79
|
+
if (iv.commentBefore) reqNewline = true;
|
|
80
|
+
} else if (item.value == null && ik?.comment) comment = ik.comment;
|
|
81
|
+
}
|
|
82
|
+
if (comment) reqNewline = true;
|
|
83
|
+
let str = stringify(item, itemCtx, () => comment = null);
|
|
84
|
+
reqNewline || (reqNewline = lines.length > linesAtValue || str.includes("\n"));
|
|
85
|
+
if (i < items.length - 1) str += ",";
|
|
86
|
+
else if (ctx.options.trailingComma) {
|
|
87
|
+
if (ctx.options.lineWidth > 0) reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str.length + 2) > ctx.options.lineWidth);
|
|
88
|
+
if (reqNewline) str += ",";
|
|
89
|
+
}
|
|
90
|
+
if (comment) str += lineComment(str, itemIndent, commentString(comment));
|
|
91
|
+
lines.push(str);
|
|
92
|
+
linesAtValue = lines.length;
|
|
93
|
+
}
|
|
94
|
+
const { start, end } = flowChars;
|
|
95
|
+
if (lines.length === 0) return start + end;
|
|
96
|
+
else {
|
|
97
|
+
if (!reqNewline) {
|
|
98
|
+
const len = lines.reduce((sum, line) => sum + line.length + 2, 2);
|
|
99
|
+
reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
|
|
100
|
+
}
|
|
101
|
+
if (reqNewline) {
|
|
102
|
+
let str = start;
|
|
103
|
+
for (const line of lines) str += line ? `\n${indentStep}${indent}${line}` : "\n";
|
|
104
|
+
return `${str}\n${indent}${end}`;
|
|
105
|
+
} else return `${start}${fcPadding}${lines.join(" ")}${fcPadding}${end}`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function addCommentBefore({ indent, options: { commentString } }, lines, comment, chompKeep) {
|
|
109
|
+
if (comment && chompKeep) comment = comment.replace(/^\n+/, "");
|
|
110
|
+
if (comment) {
|
|
111
|
+
const ic = indentComment(commentString(comment), indent);
|
|
112
|
+
lines.push(ic.trimStart());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { stringifyCollection };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/yaml@2.8.3/node_modules/yaml/browser/dist/stringify/stringifyComment.js
|
|
2
|
+
/**
|
|
3
|
+
* Stringifies a comment.
|
|
4
|
+
*
|
|
5
|
+
* Empty comment lines are left empty,
|
|
6
|
+
* lines consisting of a single space are replaced by `#`,
|
|
7
|
+
* and all other lines are prefixed with a `#`.
|
|
8
|
+
*/
|
|
9
|
+
const stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#");
|
|
10
|
+
function indentComment(comment, indent) {
|
|
11
|
+
if (/^\n+$/.test(comment)) return comment.substring(1);
|
|
12
|
+
return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
|
13
|
+
}
|
|
14
|
+
const lineComment = (str, indent, comment) => str.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str.endsWith(" ") ? "" : " ") + comment;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { indentComment, lineComment, stringifyComment };
|