shelfware 0.0.1 → 0.1.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/.output/nitro.json +15 -0
- package/.output/public/_nuxt/6IstVYrV.js +1 -0
- package/.output/public/_nuxt/9C5WUlLE.js +36 -0
- package/.output/public/_nuxt/BDNMzG2s.js +1 -0
- package/.output/public/_nuxt/BW3xJdEx.js +1 -0
- package/.output/public/_nuxt/BXXtFil5.js +1 -0
- package/.output/public/_nuxt/BZuUK3cr.js +1 -0
- package/.output/public/_nuxt/BeLyMmd4.js +1 -0
- package/.output/public/_nuxt/C_VgD9ZI.js +3 -0
- package/.output/public/_nuxt/DB5Vxbte.js +2 -0
- package/.output/public/_nuxt/DMg0j7gv.js +14 -0
- package/.output/public/_nuxt/builds/latest.json +1 -0
- package/.output/public/_nuxt/builds/meta/4c307968-4837-497b-a570-d6ee336accc4.json +1 -0
- package/.output/public/_nuxt/entry.b3_DJTEt.css +2 -0
- package/.output/public/_nuxt/error-404.CHsn7XF-.css +1 -0
- package/.output/public/_nuxt/error-500.Bawx2bLr.css +1 -0
- package/.output/server/chunks/_/api-handler.mjs +44 -0
- package/.output/server/chunks/_/batch.mjs +27 -0
- package/.output/server/chunks/_/catalog.mjs +1115 -0
- package/.output/server/chunks/_/detail.mjs +16 -0
- package/.output/server/chunks/_/error-500.mjs +19 -0
- package/.output/server/chunks/_/quarantine.mjs +159 -0
- package/.output/server/chunks/nitro/nitro.mjs +5399 -0
- package/.output/server/chunks/routes/api/_..._.mjs +16 -0
- package/.output/server/chunks/routes/api/health.get.mjs +13 -0
- package/.output/server/chunks/routes/api/skills/_id/file.get.mjs +25 -0
- package/.output/server/chunks/routes/api/skills/_id_.get.mjs +25 -0
- package/.output/server/chunks/routes/api/skills/_id_.put.mjs +74 -0
- package/.output/server/chunks/routes/api/skills/delete.post.mjs +48 -0
- package/.output/server/chunks/routes/api/skills/quarantine.post.mjs +26 -0
- package/.output/server/chunks/routes/api/skills/restore.post.mjs +26 -0
- package/.output/server/chunks/routes/api/skills.get.mjs +41 -0
- package/.output/server/chunks/routes/renderer.mjs +341 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs +3 -0
- package/.output/server/chunks/virtual/precomputed.mjs +3 -0
- package/.output/server/index.mjs +9 -0
- package/.output/server/node_modules/@babel/parser/lib/index.js +14611 -0
- package/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6801 -0
- package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +692 -0
- package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
- package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1903 -0
- package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6980 -0
- package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1867 -0
- package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +904 -0
- package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
- package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +636 -0
- package/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/.output/server/node_modules/devalue/index.js +17 -0
- package/.output/server/node_modules/devalue/package.json +39 -0
- package/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/.output/server/node_modules/devalue/src/operations.js +193 -0
- package/.output/server/node_modules/devalue/src/parse.js +274 -0
- package/.output/server/node_modules/devalue/src/stringify.js +428 -0
- package/.output/server/node_modules/devalue/src/uneval.js +606 -0
- package/.output/server/node_modules/devalue/src/utils.js +185 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/.output/server/node_modules/entities/package.json +120 -0
- package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/.output/server/node_modules/estree-walker/package.json +37 -0
- package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/.output/server/node_modules/hookable/package.json +53 -0
- package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
- package/.output/server/node_modules/nostics/dist/index.mjs +187 -0
- package/.output/server/node_modules/nostics/package.json +125 -0
- package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/.output/server/node_modules/source-map-js/package.json +71 -0
- package/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/.output/server/node_modules/ufo/package.json +48 -0
- package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
- package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
- package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
- package/.output/server/node_modules/unhead/dist/plugins.mjs +720 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.-hZVKou0.mjs +400 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BGFxPGPQ.mjs +47 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BQWSw36o.mjs +192 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bjbp1C8D.mjs +224 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Dssd7L5I.mjs +196 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.jEy9BmRq.mjs +264 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.oZ7pkTV1.mjs +19 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.tQnRaXfX.mjs +240 -0
- package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
- package/.output/server/node_modules/unhead/dist/stream/server.mjs +445 -0
- package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
- package/.output/server/node_modules/unhead/package.json +179 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/.output/server/node_modules/vue/index.js +7 -0
- package/.output/server/node_modules/vue/index.mjs +1 -0
- package/.output/server/node_modules/vue/package.json +112 -0
- package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +278 -0
- package/.output/server/node_modules/vue-bundle-renderer/package.json +54 -0
- package/.output/server/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/.output/server/node_modules/yaml/dist/compose/compose-doc.js +45 -0
- package/.output/server/node_modules/yaml/dist/compose/compose-node.js +112 -0
- package/.output/server/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
- package/.output/server/node_modules/yaml/dist/compose/composer.js +224 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
- package/.output/server/node_modules/yaml/dist/compose/resolve-props.js +148 -0
- package/.output/server/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/.output/server/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
- package/.output/server/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/.output/server/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
- package/.output/server/node_modules/yaml/dist/doc/Document.js +337 -0
- package/.output/server/node_modules/yaml/dist/doc/anchors.js +76 -0
- package/.output/server/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/.output/server/node_modules/yaml/dist/doc/createNode.js +90 -0
- package/.output/server/node_modules/yaml/dist/doc/directives.js +178 -0
- package/.output/server/node_modules/yaml/dist/errors.js +62 -0
- package/.output/server/node_modules/yaml/dist/index.js +50 -0
- package/.output/server/node_modules/yaml/dist/log.js +19 -0
- package/.output/server/node_modules/yaml/dist/nodes/Alias.js +118 -0
- package/.output/server/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/.output/server/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/.output/server/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/.output/server/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/.output/server/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/.output/server/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/.output/server/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
- package/.output/server/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/.output/server/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/.output/server/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/.output/server/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/.output/server/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/.output/server/node_modules/yaml/dist/parse/cst.js +112 -0
- package/.output/server/node_modules/yaml/dist/parse/lexer.js +723 -0
- package/.output/server/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/.output/server/node_modules/yaml/dist/parse/parser.js +980 -0
- package/.output/server/node_modules/yaml/dist/public-api.js +107 -0
- package/.output/server/node_modules/yaml/dist/schema/Schema.js +39 -0
- package/.output/server/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/.output/server/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/.output/server/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/.output/server/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/.output/server/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/.output/server/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/.output/server/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/.output/server/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/.output/server/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/.output/server/node_modules/yaml/dist/schema/tags.js +99 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/.output/server/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringify.js +132 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/.output/server/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
- package/.output/server/node_modules/yaml/dist/visit.js +236 -0
- package/.output/server/node_modules/yaml/package.json +97 -0
- package/.output/server/package.json +28 -0
- package/LICENSE +21 -0
- package/README.md +57 -1
- package/bin/launch.mjs +158 -0
- package/bin/shelfware.mjs +6 -0
- package/package.json +64 -5
- package/cli.mjs +0 -3
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var identity = require('../nodes/identity.js');
|
|
4
|
+
var Scalar = require('../nodes/Scalar.js');
|
|
5
|
+
var stringify = require('./stringify.js');
|
|
6
|
+
var stringifyComment = require('./stringifyComment.js');
|
|
7
|
+
|
|
8
|
+
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
9
|
+
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
10
|
+
let keyComment = (identity.isNode(key) && key.comment) || null;
|
|
11
|
+
if (simpleKeys) {
|
|
12
|
+
if (keyComment) {
|
|
13
|
+
throw new Error('With simple keys, key nodes cannot have comments');
|
|
14
|
+
}
|
|
15
|
+
if (identity.isCollection(key) || (!identity.isNode(key) && typeof key === 'object')) {
|
|
16
|
+
const msg = 'With simple keys, collection cannot be used as a key value';
|
|
17
|
+
throw new Error(msg);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
let explicitKey = !simpleKeys &&
|
|
21
|
+
(!key ||
|
|
22
|
+
(keyComment && value == null && !ctx.inFlow) ||
|
|
23
|
+
identity.isCollection(key) ||
|
|
24
|
+
(identity.isScalar(key)
|
|
25
|
+
? key.type === Scalar.Scalar.BLOCK_FOLDED || key.type === Scalar.Scalar.BLOCK_LITERAL
|
|
26
|
+
: typeof key === 'object'));
|
|
27
|
+
ctx = Object.assign({}, ctx, {
|
|
28
|
+
allNullValues: false,
|
|
29
|
+
implicitKey: !explicitKey && (simpleKeys || !allNullValues),
|
|
30
|
+
indent: indent + indentStep
|
|
31
|
+
});
|
|
32
|
+
let keyCommentDone = false;
|
|
33
|
+
let chompKeep = false;
|
|
34
|
+
let str = stringify.stringify(key, ctx, () => (keyCommentDone = true), () => (chompKeep = true));
|
|
35
|
+
if (!explicitKey && !ctx.inFlow && str.length > 1024) {
|
|
36
|
+
if (simpleKeys)
|
|
37
|
+
throw new Error('With simple keys, single line scalar must not span more than 1024 characters');
|
|
38
|
+
explicitKey = true;
|
|
39
|
+
}
|
|
40
|
+
if (ctx.inFlow) {
|
|
41
|
+
if (allNullValues || value == null) {
|
|
42
|
+
if (keyCommentDone && onComment)
|
|
43
|
+
onComment();
|
|
44
|
+
return str === '' ? '?' : explicitKey ? `? ${str}` : str;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if ((allNullValues && !simpleKeys) || (value == null && explicitKey)) {
|
|
48
|
+
str = `? ${str}`;
|
|
49
|
+
if (keyComment && !keyCommentDone) {
|
|
50
|
+
str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment));
|
|
51
|
+
}
|
|
52
|
+
else if (chompKeep && onChompKeep)
|
|
53
|
+
onChompKeep();
|
|
54
|
+
return str;
|
|
55
|
+
}
|
|
56
|
+
if (keyCommentDone)
|
|
57
|
+
keyComment = null;
|
|
58
|
+
if (explicitKey) {
|
|
59
|
+
if (keyComment)
|
|
60
|
+
str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment));
|
|
61
|
+
str = `? ${str}\n${indent}:`;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
str = `${str}:`;
|
|
65
|
+
if (keyComment)
|
|
66
|
+
str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment));
|
|
67
|
+
}
|
|
68
|
+
let vsb, vcb, valueComment;
|
|
69
|
+
if (identity.isNode(value)) {
|
|
70
|
+
vsb = !!value.spaceBefore;
|
|
71
|
+
vcb = value.commentBefore;
|
|
72
|
+
valueComment = value.comment;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
vsb = false;
|
|
76
|
+
vcb = null;
|
|
77
|
+
valueComment = null;
|
|
78
|
+
if (value && typeof value === 'object')
|
|
79
|
+
value = doc.createNode(value);
|
|
80
|
+
}
|
|
81
|
+
ctx.implicitKey = false;
|
|
82
|
+
if (!explicitKey && !keyComment && identity.isScalar(value))
|
|
83
|
+
ctx.indentAtStart = str.length + 1;
|
|
84
|
+
chompKeep = false;
|
|
85
|
+
if (!indentSeq &&
|
|
86
|
+
indentStep.length >= 2 &&
|
|
87
|
+
!ctx.inFlow &&
|
|
88
|
+
!explicitKey &&
|
|
89
|
+
identity.isSeq(value) &&
|
|
90
|
+
!value.flow &&
|
|
91
|
+
!value.tag &&
|
|
92
|
+
!value.anchor) {
|
|
93
|
+
// If indentSeq === false, consider '- ' as part of indentation where possible
|
|
94
|
+
ctx.indent = ctx.indent.substring(2);
|
|
95
|
+
}
|
|
96
|
+
let valueCommentDone = false;
|
|
97
|
+
const valueStr = stringify.stringify(value, ctx, () => (valueCommentDone = true), () => (chompKeep = true));
|
|
98
|
+
let ws = ' ';
|
|
99
|
+
if (keyComment || vsb || vcb) {
|
|
100
|
+
ws = vsb ? '\n' : '';
|
|
101
|
+
if (vcb) {
|
|
102
|
+
const cs = commentString(vcb);
|
|
103
|
+
ws += `\n${stringifyComment.indentComment(cs, ctx.indent)}`;
|
|
104
|
+
}
|
|
105
|
+
if (valueStr === '' && !ctx.inFlow) {
|
|
106
|
+
if (ws === '\n' && valueComment)
|
|
107
|
+
ws = '\n\n';
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
ws += `\n${ctx.indent}`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (!explicitKey && identity.isCollection(value)) {
|
|
114
|
+
const vs0 = valueStr[0];
|
|
115
|
+
const nl0 = valueStr.indexOf('\n');
|
|
116
|
+
const hasNewline = nl0 !== -1;
|
|
117
|
+
const flow = ctx.inFlow ?? value.flow ?? value.items.length === 0;
|
|
118
|
+
if (hasNewline || !flow) {
|
|
119
|
+
let hasPropsLine = false;
|
|
120
|
+
if (hasNewline && (vs0 === '&' || vs0 === '!')) {
|
|
121
|
+
let sp0 = valueStr.indexOf(' ');
|
|
122
|
+
if (vs0 === '&' &&
|
|
123
|
+
sp0 !== -1 &&
|
|
124
|
+
sp0 < nl0 &&
|
|
125
|
+
valueStr[sp0 + 1] === '!') {
|
|
126
|
+
sp0 = valueStr.indexOf(' ', sp0 + 1);
|
|
127
|
+
}
|
|
128
|
+
if (sp0 === -1 || nl0 < sp0)
|
|
129
|
+
hasPropsLine = true;
|
|
130
|
+
}
|
|
131
|
+
if (!hasPropsLine)
|
|
132
|
+
ws = `\n${ctx.indent}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else if (valueStr === '' || valueStr[0] === '\n') {
|
|
136
|
+
ws = '';
|
|
137
|
+
}
|
|
138
|
+
str += ws + valueStr;
|
|
139
|
+
if (ctx.inFlow) {
|
|
140
|
+
if (valueCommentDone && onComment)
|
|
141
|
+
onComment();
|
|
142
|
+
}
|
|
143
|
+
else if (valueComment && !valueCommentDone) {
|
|
144
|
+
str += stringifyComment.lineComment(str, ctx.indent, commentString(valueComment));
|
|
145
|
+
}
|
|
146
|
+
else if (chompKeep && onChompKeep) {
|
|
147
|
+
onChompKeep();
|
|
148
|
+
}
|
|
149
|
+
return str;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
exports.stringifyPair = stringifyPair;
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Scalar = require('../nodes/Scalar.js');
|
|
4
|
+
var foldFlowLines = require('./foldFlowLines.js');
|
|
5
|
+
|
|
6
|
+
const getFoldOptions = (ctx, isBlock) => ({
|
|
7
|
+
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
8
|
+
lineWidth: ctx.options.lineWidth,
|
|
9
|
+
minContentWidth: ctx.options.minContentWidth
|
|
10
|
+
});
|
|
11
|
+
// Also checks for lines starting with %, as parsing the output as YAML 1.1 will
|
|
12
|
+
// presume that's starting a new document.
|
|
13
|
+
const containsDocumentMarker = (str) => /^(%|---|\.\.\.)/m.test(str);
|
|
14
|
+
function lineLengthOverLimit(str, lineWidth, indentLength) {
|
|
15
|
+
if (!lineWidth || lineWidth < 0)
|
|
16
|
+
return false;
|
|
17
|
+
const limit = lineWidth - indentLength;
|
|
18
|
+
const strLen = str.length;
|
|
19
|
+
if (strLen <= limit)
|
|
20
|
+
return false;
|
|
21
|
+
for (let i = 0, start = 0; i < strLen; ++i) {
|
|
22
|
+
if (str[i] === '\n') {
|
|
23
|
+
if (i - start > limit)
|
|
24
|
+
return true;
|
|
25
|
+
start = i + 1;
|
|
26
|
+
if (strLen - start <= limit)
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
function doubleQuotedString(value, ctx) {
|
|
33
|
+
const json = JSON.stringify(value);
|
|
34
|
+
if (ctx.options.doubleQuotedAsJSON)
|
|
35
|
+
return json;
|
|
36
|
+
const { implicitKey } = ctx;
|
|
37
|
+
const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
|
|
38
|
+
const indent = ctx.indent || (containsDocumentMarker(value) ? ' ' : '');
|
|
39
|
+
let str = '';
|
|
40
|
+
let start = 0;
|
|
41
|
+
for (let i = 0, ch = json[i]; ch; ch = json[++i]) {
|
|
42
|
+
if (ch === ' ' && json[i + 1] === '\\' && json[i + 2] === 'n') {
|
|
43
|
+
// space before newline needs to be escaped to not be folded
|
|
44
|
+
str += json.slice(start, i) + '\\ ';
|
|
45
|
+
i += 1;
|
|
46
|
+
start = i;
|
|
47
|
+
ch = '\\';
|
|
48
|
+
}
|
|
49
|
+
if (ch === '\\')
|
|
50
|
+
switch (json[i + 1]) {
|
|
51
|
+
case 'u':
|
|
52
|
+
{
|
|
53
|
+
str += json.slice(start, i);
|
|
54
|
+
const code = json.substr(i + 2, 4);
|
|
55
|
+
switch (code) {
|
|
56
|
+
case '0000':
|
|
57
|
+
str += '\\0';
|
|
58
|
+
break;
|
|
59
|
+
case '0007':
|
|
60
|
+
str += '\\a';
|
|
61
|
+
break;
|
|
62
|
+
case '000b':
|
|
63
|
+
str += '\\v';
|
|
64
|
+
break;
|
|
65
|
+
case '001b':
|
|
66
|
+
str += '\\e';
|
|
67
|
+
break;
|
|
68
|
+
case '0085':
|
|
69
|
+
str += '\\N';
|
|
70
|
+
break;
|
|
71
|
+
case '00a0':
|
|
72
|
+
str += '\\_';
|
|
73
|
+
break;
|
|
74
|
+
case '2028':
|
|
75
|
+
str += '\\L';
|
|
76
|
+
break;
|
|
77
|
+
case '2029':
|
|
78
|
+
str += '\\P';
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
if (code.substr(0, 2) === '00')
|
|
82
|
+
str += '\\x' + code.substr(2);
|
|
83
|
+
else
|
|
84
|
+
str += json.substr(i, 6);
|
|
85
|
+
}
|
|
86
|
+
i += 5;
|
|
87
|
+
start = i + 1;
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case 'n':
|
|
91
|
+
if (implicitKey ||
|
|
92
|
+
json[i + 2] === '"' ||
|
|
93
|
+
json.length < minMultiLineLength) {
|
|
94
|
+
i += 1;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// folding will eat first newline
|
|
98
|
+
str += json.slice(start, i) + '\n\n';
|
|
99
|
+
while (json[i + 2] === '\\' &&
|
|
100
|
+
json[i + 3] === 'n' &&
|
|
101
|
+
json[i + 4] !== '"') {
|
|
102
|
+
str += '\n';
|
|
103
|
+
i += 2;
|
|
104
|
+
}
|
|
105
|
+
str += indent;
|
|
106
|
+
// space after newline needs to be escaped to not be folded
|
|
107
|
+
if (json[i + 2] === ' ')
|
|
108
|
+
str += '\\';
|
|
109
|
+
i += 1;
|
|
110
|
+
start = i + 1;
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
i += 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
str = start ? str + json.slice(start) : json;
|
|
118
|
+
return implicitKey
|
|
119
|
+
? str
|
|
120
|
+
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
121
|
+
}
|
|
122
|
+
function singleQuotedString(value, ctx) {
|
|
123
|
+
if (ctx.options.singleQuote === false ||
|
|
124
|
+
(ctx.implicitKey && value.includes('\n')) ||
|
|
125
|
+
/[ \t]\n|\n[ \t]/.test(value) // single quoted string can't have leading or trailing whitespace around newline
|
|
126
|
+
)
|
|
127
|
+
return doubleQuotedString(value, ctx);
|
|
128
|
+
const indent = ctx.indent || (containsDocumentMarker(value) ? ' ' : '');
|
|
129
|
+
const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
|
|
130
|
+
return ctx.implicitKey
|
|
131
|
+
? res
|
|
132
|
+
: foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
|
|
133
|
+
}
|
|
134
|
+
function quotedString(value, ctx) {
|
|
135
|
+
const { singleQuote } = ctx.options;
|
|
136
|
+
let qs;
|
|
137
|
+
if (singleQuote === false)
|
|
138
|
+
qs = doubleQuotedString;
|
|
139
|
+
else {
|
|
140
|
+
const hasDouble = value.includes('"');
|
|
141
|
+
const hasSingle = value.includes("'");
|
|
142
|
+
if (hasDouble && !hasSingle)
|
|
143
|
+
qs = singleQuotedString;
|
|
144
|
+
else if (hasSingle && !hasDouble)
|
|
145
|
+
qs = doubleQuotedString;
|
|
146
|
+
else
|
|
147
|
+
qs = singleQuote ? singleQuotedString : doubleQuotedString;
|
|
148
|
+
}
|
|
149
|
+
return qs(value, ctx);
|
|
150
|
+
}
|
|
151
|
+
// The negative lookbehind avoids a polynomial search,
|
|
152
|
+
// but isn't supported yet on Safari: https://caniuse.com/js-regexp-lookbehind
|
|
153
|
+
let blockEndNewlines;
|
|
154
|
+
try {
|
|
155
|
+
blockEndNewlines = new RegExp('(^|(?<!\n))\n+(?!\n|$)', 'g');
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
blockEndNewlines = /\n+(?!\n|$)/g;
|
|
159
|
+
}
|
|
160
|
+
function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
161
|
+
const { blockQuote, commentString, lineWidth } = ctx.options;
|
|
162
|
+
// 1. Block can't end in whitespace unless the last line is non-empty.
|
|
163
|
+
// 2. Strings consisting of only whitespace are best rendered explicitly.
|
|
164
|
+
if (!blockQuote || /\n[\t ]+$/.test(value)) {
|
|
165
|
+
return quotedString(value, ctx);
|
|
166
|
+
}
|
|
167
|
+
const indent = ctx.indent ||
|
|
168
|
+
(ctx.forceBlockIndent || containsDocumentMarker(value) ? ' ' : '');
|
|
169
|
+
const literal = blockQuote === 'literal'
|
|
170
|
+
? true
|
|
171
|
+
: blockQuote === 'folded' || type === Scalar.Scalar.BLOCK_FOLDED
|
|
172
|
+
? false
|
|
173
|
+
: type === Scalar.Scalar.BLOCK_LITERAL
|
|
174
|
+
? true
|
|
175
|
+
: !lineLengthOverLimit(value, lineWidth, indent.length);
|
|
176
|
+
if (!value)
|
|
177
|
+
return literal ? '|\n' : '>\n';
|
|
178
|
+
// determine chomping from whitespace at value end
|
|
179
|
+
let chomp;
|
|
180
|
+
let endStart;
|
|
181
|
+
for (endStart = value.length; endStart > 0; --endStart) {
|
|
182
|
+
const ch = value[endStart - 1];
|
|
183
|
+
if (ch !== '\n' && ch !== '\t' && ch !== ' ')
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
let end = value.substring(endStart);
|
|
187
|
+
const endNlPos = end.indexOf('\n');
|
|
188
|
+
if (endNlPos === -1) {
|
|
189
|
+
chomp = '-'; // strip
|
|
190
|
+
}
|
|
191
|
+
else if (value === end || endNlPos !== end.length - 1) {
|
|
192
|
+
chomp = '+'; // keep
|
|
193
|
+
if (onChompKeep)
|
|
194
|
+
onChompKeep();
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
chomp = ''; // clip
|
|
198
|
+
}
|
|
199
|
+
if (end) {
|
|
200
|
+
value = value.slice(0, -end.length);
|
|
201
|
+
if (end[end.length - 1] === '\n')
|
|
202
|
+
end = end.slice(0, -1);
|
|
203
|
+
end = end.replace(blockEndNewlines, `$&${indent}`);
|
|
204
|
+
}
|
|
205
|
+
// determine indent indicator from whitespace at value start
|
|
206
|
+
let startWithSpace = false;
|
|
207
|
+
let startEnd;
|
|
208
|
+
let startNlPos = -1;
|
|
209
|
+
for (startEnd = 0; startEnd < value.length; ++startEnd) {
|
|
210
|
+
const ch = value[startEnd];
|
|
211
|
+
if (ch === ' ')
|
|
212
|
+
startWithSpace = true;
|
|
213
|
+
else if (ch === '\n')
|
|
214
|
+
startNlPos = startEnd;
|
|
215
|
+
else
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
let start = value.substring(0, startNlPos < startEnd ? startNlPos + 1 : startEnd);
|
|
219
|
+
if (start) {
|
|
220
|
+
value = value.substring(start.length);
|
|
221
|
+
start = start.replace(/\n+/g, `$&${indent}`);
|
|
222
|
+
}
|
|
223
|
+
const indentSize = indent ? '2' : '1'; // root is at -1
|
|
224
|
+
// Leading | or > is added later
|
|
225
|
+
let header = (startWithSpace ? indentSize : '') + chomp;
|
|
226
|
+
if (comment) {
|
|
227
|
+
header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
|
|
228
|
+
if (onComment)
|
|
229
|
+
onComment();
|
|
230
|
+
}
|
|
231
|
+
if (!literal) {
|
|
232
|
+
const foldedValue = value
|
|
233
|
+
.replace(/\n+/g, '\n$&')
|
|
234
|
+
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
235
|
+
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
236
|
+
.replace(/\n+/g, `$&${indent}`);
|
|
237
|
+
let literalFallback = false;
|
|
238
|
+
const foldOptions = getFoldOptions(ctx, true);
|
|
239
|
+
if (blockQuote !== 'folded' && type !== Scalar.Scalar.BLOCK_FOLDED) {
|
|
240
|
+
foldOptions.onOverflow = () => {
|
|
241
|
+
literalFallback = true;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const body = foldFlowLines.foldFlowLines(`${start}${foldedValue}${end}`, indent, foldFlowLines.FOLD_BLOCK, foldOptions);
|
|
245
|
+
if (!literalFallback)
|
|
246
|
+
return `>${header}\n${indent}${body}`;
|
|
247
|
+
}
|
|
248
|
+
value = value.replace(/\n+/g, `$&${indent}`);
|
|
249
|
+
return `|${header}\n${indent}${start}${value}${end}`;
|
|
250
|
+
}
|
|
251
|
+
function plainString(item, ctx, onComment, onChompKeep) {
|
|
252
|
+
const { type, value } = item;
|
|
253
|
+
const { actualString, implicitKey, indent, indentStep, inFlow } = ctx;
|
|
254
|
+
if ((implicitKey && value.includes('\n')) ||
|
|
255
|
+
(inFlow && /[[\]{},]/.test(value))) {
|
|
256
|
+
return quotedString(value, ctx);
|
|
257
|
+
}
|
|
258
|
+
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
|
|
259
|
+
// not allowed:
|
|
260
|
+
// - '-' or '?'
|
|
261
|
+
// - start with an indicator character (except [?:-]) or /[?-] /
|
|
262
|
+
// - '\n ', ': ' or ' \n' anywhere
|
|
263
|
+
// - '#' not preceded by a non-space char
|
|
264
|
+
// - end with ' ' or ':'
|
|
265
|
+
return implicitKey || inFlow || !value.includes('\n')
|
|
266
|
+
? quotedString(value, ctx)
|
|
267
|
+
: blockString(item, ctx, onComment, onChompKeep);
|
|
268
|
+
}
|
|
269
|
+
if (!implicitKey &&
|
|
270
|
+
!inFlow &&
|
|
271
|
+
type !== Scalar.Scalar.PLAIN &&
|
|
272
|
+
value.includes('\n')) {
|
|
273
|
+
// Where allowed & type not set explicitly, prefer block style for multiline strings
|
|
274
|
+
return blockString(item, ctx, onComment, onChompKeep);
|
|
275
|
+
}
|
|
276
|
+
if (containsDocumentMarker(value)) {
|
|
277
|
+
if (indent === '') {
|
|
278
|
+
ctx.forceBlockIndent = true;
|
|
279
|
+
return blockString(item, ctx, onComment, onChompKeep);
|
|
280
|
+
}
|
|
281
|
+
else if (implicitKey && indent === indentStep) {
|
|
282
|
+
return quotedString(value, ctx);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const str = value.replace(/\n+/g, `$&\n${indent}`);
|
|
286
|
+
// Verify that output will be parsed as a string, as e.g. plain numbers and
|
|
287
|
+
// booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
|
|
288
|
+
// and others in v1.1.
|
|
289
|
+
if (actualString) {
|
|
290
|
+
const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && tag.test?.test(str);
|
|
291
|
+
const { compat, tags } = ctx.doc.schema;
|
|
292
|
+
if (tags.some(test) || compat?.some(test))
|
|
293
|
+
return quotedString(value, ctx);
|
|
294
|
+
}
|
|
295
|
+
return implicitKey
|
|
296
|
+
? str
|
|
297
|
+
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
|
|
298
|
+
}
|
|
299
|
+
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
300
|
+
const { implicitKey, inFlow } = ctx;
|
|
301
|
+
const ss = typeof item.value === 'string'
|
|
302
|
+
? item
|
|
303
|
+
: Object.assign({}, item, { value: String(item.value) });
|
|
304
|
+
let { type } = item;
|
|
305
|
+
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
|
|
306
|
+
// force double quotes on control characters & unpaired surrogates
|
|
307
|
+
if (/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(ss.value))
|
|
308
|
+
type = Scalar.Scalar.QUOTE_DOUBLE;
|
|
309
|
+
}
|
|
310
|
+
const _stringify = (_type) => {
|
|
311
|
+
switch (_type) {
|
|
312
|
+
case Scalar.Scalar.BLOCK_FOLDED:
|
|
313
|
+
case Scalar.Scalar.BLOCK_LITERAL:
|
|
314
|
+
return implicitKey || inFlow
|
|
315
|
+
? quotedString(ss.value, ctx) // blocks are not valid inside flow containers
|
|
316
|
+
: blockString(ss, ctx, onComment, onChompKeep);
|
|
317
|
+
case Scalar.Scalar.QUOTE_DOUBLE:
|
|
318
|
+
return doubleQuotedString(ss.value, ctx);
|
|
319
|
+
case Scalar.Scalar.QUOTE_SINGLE:
|
|
320
|
+
return singleQuotedString(ss.value, ctx);
|
|
321
|
+
case Scalar.Scalar.PLAIN:
|
|
322
|
+
return plainString(ss, ctx, onComment, onChompKeep);
|
|
323
|
+
default:
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
let res = _stringify(type);
|
|
328
|
+
if (res === null) {
|
|
329
|
+
const { defaultKeyType, defaultStringType } = ctx.options;
|
|
330
|
+
const t = (implicitKey && defaultKeyType) || defaultStringType;
|
|
331
|
+
res = _stringify(t);
|
|
332
|
+
if (res === null)
|
|
333
|
+
throw new Error(`Unsupported default string type ${t}`);
|
|
334
|
+
}
|
|
335
|
+
return res;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
exports.stringifyString = stringifyString;
|