shelfware 0.0.1 → 0.1.1

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 (206) hide show
  1. package/.output/nitro.json +15 -0
  2. package/.output/public/_nuxt/6IstVYrV.js +1 -0
  3. package/.output/public/_nuxt/9C5WUlLE.js +36 -0
  4. package/.output/public/_nuxt/BDNMzG2s.js +1 -0
  5. package/.output/public/_nuxt/BW3xJdEx.js +1 -0
  6. package/.output/public/_nuxt/BXXtFil5.js +1 -0
  7. package/.output/public/_nuxt/BZuUK3cr.js +1 -0
  8. package/.output/public/_nuxt/BeLyMmd4.js +1 -0
  9. package/.output/public/_nuxt/C_VgD9ZI.js +3 -0
  10. package/.output/public/_nuxt/DB5Vxbte.js +2 -0
  11. package/.output/public/_nuxt/DMg0j7gv.js +14 -0
  12. package/.output/public/_nuxt/builds/latest.json +1 -0
  13. package/.output/public/_nuxt/builds/meta/e0d2b6a3-3a30-44b7-8c79-a56f66400005.json +1 -0
  14. package/.output/public/_nuxt/entry.b3_DJTEt.css +2 -0
  15. package/.output/public/_nuxt/error-404.CHsn7XF-.css +1 -0
  16. package/.output/public/_nuxt/error-500.Bawx2bLr.css +1 -0
  17. package/.output/server/chunks/_/api-handler.mjs +44 -0
  18. package/.output/server/chunks/_/batch.mjs +27 -0
  19. package/.output/server/chunks/_/catalog.mjs +1115 -0
  20. package/.output/server/chunks/_/detail.mjs +16 -0
  21. package/.output/server/chunks/_/error-500.mjs +19 -0
  22. package/.output/server/chunks/_/quarantine.mjs +159 -0
  23. package/.output/server/chunks/nitro/nitro.mjs +5399 -0
  24. package/.output/server/chunks/routes/api/_..._.mjs +16 -0
  25. package/.output/server/chunks/routes/api/health.get.mjs +13 -0
  26. package/.output/server/chunks/routes/api/skills/_id/file.get.mjs +25 -0
  27. package/.output/server/chunks/routes/api/skills/_id_.get.mjs +25 -0
  28. package/.output/server/chunks/routes/api/skills/_id_.put.mjs +74 -0
  29. package/.output/server/chunks/routes/api/skills/delete.post.mjs +48 -0
  30. package/.output/server/chunks/routes/api/skills/quarantine.post.mjs +26 -0
  31. package/.output/server/chunks/routes/api/skills/restore.post.mjs +26 -0
  32. package/.output/server/chunks/routes/api/skills.get.mjs +41 -0
  33. package/.output/server/chunks/routes/renderer.mjs +341 -0
  34. package/.output/server/chunks/virtual/_virtual_spa-template.mjs +3 -0
  35. package/.output/server/chunks/virtual/precomputed.mjs +3 -0
  36. package/.output/server/index.mjs +9 -0
  37. package/.output/server/node_modules/@babel/parser/lib/index.js +14611 -0
  38. package/.output/server/node_modules/@babel/parser/package.json +50 -0
  39. package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6801 -0
  40. package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
  41. package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +692 -0
  42. package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
  43. package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
  44. package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
  45. package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1903 -0
  46. package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
  47. package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6980 -0
  48. package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
  49. package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1867 -0
  50. package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
  51. package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +904 -0
  52. package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
  53. package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +636 -0
  54. package/.output/server/node_modules/@vue/shared/package.json +47 -0
  55. package/.output/server/node_modules/devalue/index.js +17 -0
  56. package/.output/server/node_modules/devalue/package.json +39 -0
  57. package/.output/server/node_modules/devalue/src/base64.js +60 -0
  58. package/.output/server/node_modules/devalue/src/constants.js +12 -0
  59. package/.output/server/node_modules/devalue/src/operations.js +193 -0
  60. package/.output/server/node_modules/devalue/src/parse.js +274 -0
  61. package/.output/server/node_modules/devalue/src/stringify.js +428 -0
  62. package/.output/server/node_modules/devalue/src/uneval.js +606 -0
  63. package/.output/server/node_modules/devalue/src/utils.js +185 -0
  64. package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
  65. package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
  66. package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
  67. package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
  68. package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
  69. package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
  70. package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
  71. package/.output/server/node_modules/entities/package.json +120 -0
  72. package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
  73. package/.output/server/node_modules/estree-walker/package.json +37 -0
  74. package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
  75. package/.output/server/node_modules/hookable/package.json +53 -0
  76. package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
  77. package/.output/server/node_modules/nostics/dist/index.mjs +187 -0
  78. package/.output/server/node_modules/nostics/package.json +125 -0
  79. package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
  80. package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  81. package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
  82. package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
  83. package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
  84. package/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
  85. package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
  86. package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
  87. package/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
  88. package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
  89. package/.output/server/node_modules/source-map-js/package.json +71 -0
  90. package/.output/server/node_modules/source-map-js/source-map.js +8 -0
  91. package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
  92. package/.output/server/node_modules/ufo/package.json +48 -0
  93. package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
  94. package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
  95. package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
  96. package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
  97. package/.output/server/node_modules/unhead/dist/plugins.mjs +720 -0
  98. package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
  99. package/.output/server/node_modules/unhead/dist/shared/unhead.-hZVKou0.mjs +400 -0
  100. package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
  101. package/.output/server/node_modules/unhead/dist/shared/unhead.BGFxPGPQ.mjs +47 -0
  102. package/.output/server/node_modules/unhead/dist/shared/unhead.BQWSw36o.mjs +192 -0
  103. package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
  104. package/.output/server/node_modules/unhead/dist/shared/unhead.Bjbp1C8D.mjs +224 -0
  105. package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
  106. package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
  107. package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
  108. package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
  109. package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
  110. package/.output/server/node_modules/unhead/dist/shared/unhead.Dssd7L5I.mjs +196 -0
  111. package/.output/server/node_modules/unhead/dist/shared/unhead.jEy9BmRq.mjs +264 -0
  112. package/.output/server/node_modules/unhead/dist/shared/unhead.oZ7pkTV1.mjs +19 -0
  113. package/.output/server/node_modules/unhead/dist/shared/unhead.tQnRaXfX.mjs +240 -0
  114. package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
  115. package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
  116. package/.output/server/node_modules/unhead/dist/stream/server.mjs +445 -0
  117. package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
  118. package/.output/server/node_modules/unhead/package.json +179 -0
  119. package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
  120. package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
  121. package/.output/server/node_modules/vue/index.js +7 -0
  122. package/.output/server/node_modules/vue/index.mjs +1 -0
  123. package/.output/server/node_modules/vue/package.json +112 -0
  124. package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
  125. package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +278 -0
  126. package/.output/server/node_modules/vue-bundle-renderer/package.json +54 -0
  127. package/.output/server/node_modules/yaml/dist/compose/compose-collection.js +90 -0
  128. package/.output/server/node_modules/yaml/dist/compose/compose-doc.js +45 -0
  129. package/.output/server/node_modules/yaml/dist/compose/compose-node.js +112 -0
  130. package/.output/server/node_modules/yaml/dist/compose/compose-scalar.js +88 -0
  131. package/.output/server/node_modules/yaml/dist/compose/composer.js +224 -0
  132. package/.output/server/node_modules/yaml/dist/compose/resolve-block-map.js +117 -0
  133. package/.output/server/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
  134. package/.output/server/node_modules/yaml/dist/compose/resolve-block-seq.js +51 -0
  135. package/.output/server/node_modules/yaml/dist/compose/resolve-end.js +39 -0
  136. package/.output/server/node_modules/yaml/dist/compose/resolve-flow-collection.js +209 -0
  137. package/.output/server/node_modules/yaml/dist/compose/resolve-flow-scalar.js +227 -0
  138. package/.output/server/node_modules/yaml/dist/compose/resolve-props.js +148 -0
  139. package/.output/server/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
  140. package/.output/server/node_modules/yaml/dist/compose/util-empty-scalar-position.js +28 -0
  141. package/.output/server/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
  142. package/.output/server/node_modules/yaml/dist/compose/util-map-includes.js +15 -0
  143. package/.output/server/node_modules/yaml/dist/doc/Document.js +337 -0
  144. package/.output/server/node_modules/yaml/dist/doc/anchors.js +76 -0
  145. package/.output/server/node_modules/yaml/dist/doc/applyReviver.js +57 -0
  146. package/.output/server/node_modules/yaml/dist/doc/createNode.js +90 -0
  147. package/.output/server/node_modules/yaml/dist/doc/directives.js +178 -0
  148. package/.output/server/node_modules/yaml/dist/errors.js +62 -0
  149. package/.output/server/node_modules/yaml/dist/index.js +50 -0
  150. package/.output/server/node_modules/yaml/dist/log.js +19 -0
  151. package/.output/server/node_modules/yaml/dist/nodes/Alias.js +118 -0
  152. package/.output/server/node_modules/yaml/dist/nodes/Collection.js +151 -0
  153. package/.output/server/node_modules/yaml/dist/nodes/Node.js +40 -0
  154. package/.output/server/node_modules/yaml/dist/nodes/Pair.js +39 -0
  155. package/.output/server/node_modules/yaml/dist/nodes/Scalar.js +27 -0
  156. package/.output/server/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
  157. package/.output/server/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
  158. package/.output/server/node_modules/yaml/dist/nodes/addPairToJSMap.js +65 -0
  159. package/.output/server/node_modules/yaml/dist/nodes/identity.js +53 -0
  160. package/.output/server/node_modules/yaml/dist/nodes/toJS.js +39 -0
  161. package/.output/server/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
  162. package/.output/server/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
  163. package/.output/server/node_modules/yaml/dist/parse/cst-visit.js +99 -0
  164. package/.output/server/node_modules/yaml/dist/parse/cst.js +112 -0
  165. package/.output/server/node_modules/yaml/dist/parse/lexer.js +723 -0
  166. package/.output/server/node_modules/yaml/dist/parse/line-counter.js +41 -0
  167. package/.output/server/node_modules/yaml/dist/parse/parser.js +980 -0
  168. package/.output/server/node_modules/yaml/dist/public-api.js +107 -0
  169. package/.output/server/node_modules/yaml/dist/schema/Schema.js +39 -0
  170. package/.output/server/node_modules/yaml/dist/schema/common/map.js +19 -0
  171. package/.output/server/node_modules/yaml/dist/schema/common/null.js +17 -0
  172. package/.output/server/node_modules/yaml/dist/schema/common/seq.js +19 -0
  173. package/.output/server/node_modules/yaml/dist/schema/common/string.js +16 -0
  174. package/.output/server/node_modules/yaml/dist/schema/core/bool.js +21 -0
  175. package/.output/server/node_modules/yaml/dist/schema/core/float.js +47 -0
  176. package/.output/server/node_modules/yaml/dist/schema/core/int.js +42 -0
  177. package/.output/server/node_modules/yaml/dist/schema/core/schema.js +25 -0
  178. package/.output/server/node_modules/yaml/dist/schema/json/schema.js +64 -0
  179. package/.output/server/node_modules/yaml/dist/schema/tags.js +99 -0
  180. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/binary.js +70 -0
  181. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
  182. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
  183. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
  184. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/merge.js +71 -0
  185. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
  186. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
  187. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/schema.js +41 -0
  188. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
  189. package/.output/server/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
  190. package/.output/server/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
  191. package/.output/server/node_modules/yaml/dist/stringify/stringify.js +132 -0
  192. package/.output/server/node_modules/yaml/dist/stringify/stringifyCollection.js +155 -0
  193. package/.output/server/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
  194. package/.output/server/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
  195. package/.output/server/node_modules/yaml/dist/stringify/stringifyNumber.js +27 -0
  196. package/.output/server/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
  197. package/.output/server/node_modules/yaml/dist/stringify/stringifyString.js +338 -0
  198. package/.output/server/node_modules/yaml/dist/visit.js +236 -0
  199. package/.output/server/node_modules/yaml/package.json +97 -0
  200. package/.output/server/package.json +28 -0
  201. package/LICENSE +21 -0
  202. package/README.md +57 -1
  203. package/bin/launch.mjs +216 -0
  204. package/bin/shelfware.mjs +11 -0
  205. package/package.json +64 -5
  206. package/cli.mjs +0 -3
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ const FOLD_FLOW = 'flow';
4
+ const FOLD_BLOCK = 'block';
5
+ const FOLD_QUOTED = 'quoted';
6
+ /**
7
+ * Tries to keep input at up to `lineWidth` characters, splitting only on spaces
8
+ * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are
9
+ * terminated with `\n` and started with `indent`.
10
+ */
11
+ function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
12
+ if (!lineWidth || lineWidth < 0)
13
+ return text;
14
+ if (lineWidth < minContentWidth)
15
+ minContentWidth = 0;
16
+ const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
17
+ if (text.length <= endStep)
18
+ return text;
19
+ const folds = [];
20
+ const escapedFolds = {};
21
+ let end = lineWidth - indent.length;
22
+ if (typeof indentAtStart === 'number') {
23
+ if (indentAtStart > lineWidth - Math.max(2, minContentWidth))
24
+ folds.push(0);
25
+ else
26
+ end = lineWidth - indentAtStart;
27
+ }
28
+ let split = undefined;
29
+ let prev = undefined;
30
+ let overflow = false;
31
+ let i = -1;
32
+ let escStart = -1;
33
+ let escEnd = -1;
34
+ if (mode === FOLD_BLOCK) {
35
+ i = consumeMoreIndentedLines(text, i, indent.length);
36
+ if (i !== -1)
37
+ end = i + endStep;
38
+ }
39
+ for (let ch; (ch = text[(i += 1)]);) {
40
+ if (mode === FOLD_QUOTED && ch === '\\') {
41
+ escStart = i;
42
+ switch (text[i + 1]) {
43
+ case 'x':
44
+ i += 3;
45
+ break;
46
+ case 'u':
47
+ i += 5;
48
+ break;
49
+ case 'U':
50
+ i += 9;
51
+ break;
52
+ default:
53
+ i += 1;
54
+ }
55
+ escEnd = i;
56
+ }
57
+ if (ch === '\n') {
58
+ if (mode === FOLD_BLOCK)
59
+ i = consumeMoreIndentedLines(text, i, indent.length);
60
+ end = i + indent.length + endStep;
61
+ split = undefined;
62
+ }
63
+ else {
64
+ if (ch === ' ' &&
65
+ prev &&
66
+ prev !== ' ' &&
67
+ prev !== '\n' &&
68
+ prev !== '\t') {
69
+ // space surrounded by non-space can be replaced with newline + indent
70
+ const next = text[i + 1];
71
+ if (next && next !== ' ' && next !== '\n' && next !== '\t')
72
+ split = i;
73
+ }
74
+ if (i >= end) {
75
+ if (split) {
76
+ folds.push(split);
77
+ end = split + endStep;
78
+ split = undefined;
79
+ }
80
+ else if (mode === FOLD_QUOTED) {
81
+ // white-space collected at end may stretch past lineWidth
82
+ while (prev === ' ' || prev === '\t') {
83
+ prev = ch;
84
+ ch = text[(i += 1)];
85
+ overflow = true;
86
+ }
87
+ // Account for newline escape, but don't break preceding escape
88
+ const j = i > escEnd + 1 ? i - 2 : escStart - 1;
89
+ // Bail out if lineWidth & minContentWidth are shorter than an escape string
90
+ if (escapedFolds[j])
91
+ return text;
92
+ folds.push(j);
93
+ escapedFolds[j] = true;
94
+ end = j + endStep;
95
+ split = undefined;
96
+ }
97
+ else {
98
+ overflow = true;
99
+ }
100
+ }
101
+ }
102
+ prev = ch;
103
+ }
104
+ if (overflow && onOverflow)
105
+ onOverflow();
106
+ if (folds.length === 0)
107
+ return text;
108
+ if (onFold)
109
+ onFold();
110
+ let res = text.slice(0, folds[0]);
111
+ for (let i = 0; i < folds.length; ++i) {
112
+ const fold = folds[i];
113
+ const end = folds[i + 1] || text.length;
114
+ if (fold === 0)
115
+ res = `\n${indent}${text.slice(0, end)}`;
116
+ else {
117
+ if (mode === FOLD_QUOTED && escapedFolds[fold])
118
+ res += `${text[fold]}\\`;
119
+ res += `\n${indent}${text.slice(fold + 1, end)}`;
120
+ }
121
+ }
122
+ return res;
123
+ }
124
+ /**
125
+ * Presumes `i + 1` is at the start of a line
126
+ * @returns index of last newline in more-indented block
127
+ */
128
+ function consumeMoreIndentedLines(text, i, indent) {
129
+ let end = i;
130
+ let start = i + 1;
131
+ let ch = text[start];
132
+ while (ch === ' ' || ch === '\t') {
133
+ if (i < start + indent) {
134
+ ch = text[++i];
135
+ }
136
+ else {
137
+ do {
138
+ ch = text[++i];
139
+ } while (ch && ch !== '\n');
140
+ end = i;
141
+ start = i + 1;
142
+ ch = text[start];
143
+ }
144
+ }
145
+ return end;
146
+ }
147
+
148
+ exports.FOLD_BLOCK = FOLD_BLOCK;
149
+ exports.FOLD_FLOW = FOLD_FLOW;
150
+ exports.FOLD_QUOTED = FOLD_QUOTED;
151
+ exports.foldFlowLines = foldFlowLines;
@@ -0,0 +1,132 @@
1
+ 'use strict';
2
+
3
+ var anchors = require('../doc/anchors.js');
4
+ var identity = require('../nodes/identity.js');
5
+ var stringifyComment = require('./stringifyComment.js');
6
+ var stringifyString = require('./stringifyString.js');
7
+
8
+ function createStringifyContext(doc, options) {
9
+ const opt = Object.assign({
10
+ blockQuote: true,
11
+ commentString: stringifyComment.stringifyComment,
12
+ defaultKeyType: null,
13
+ defaultStringType: 'PLAIN',
14
+ directives: null,
15
+ doubleQuotedAsJSON: false,
16
+ doubleQuotedMinMultiLineLength: 40,
17
+ falseStr: 'false',
18
+ flowCollectionPadding: true,
19
+ indentSeq: true,
20
+ lineWidth: 80,
21
+ minContentWidth: 20,
22
+ nullStr: 'null',
23
+ simpleKeys: false,
24
+ singleQuote: null,
25
+ trailingComma: false,
26
+ trueStr: 'true',
27
+ verifyAliasOrder: true
28
+ }, doc.schema.toStringOptions, options);
29
+ let inFlow;
30
+ switch (opt.collectionStyle) {
31
+ case 'block':
32
+ inFlow = false;
33
+ break;
34
+ case 'flow':
35
+ inFlow = true;
36
+ break;
37
+ default:
38
+ inFlow = null;
39
+ }
40
+ return {
41
+ anchors: new Set(),
42
+ doc,
43
+ flowCollectionPadding: opt.flowCollectionPadding ? ' ' : '',
44
+ indent: '',
45
+ indentStep: typeof opt.indent === 'number' ? ' '.repeat(opt.indent) : ' ',
46
+ inFlow,
47
+ options: opt
48
+ };
49
+ }
50
+ function getTagObject(tags, item) {
51
+ if (item.tag) {
52
+ const match = tags.filter(t => t.tag === item.tag);
53
+ if (match.length > 0)
54
+ return match.find(t => t.format === item.format) ?? match[0];
55
+ }
56
+ let tagObj = undefined;
57
+ let obj;
58
+ if (identity.isScalar(item)) {
59
+ obj = item.value;
60
+ let match = tags.filter(t => t.identify?.(obj));
61
+ if (match.length > 1) {
62
+ const testMatch = match.filter(t => t.test);
63
+ if (testMatch.length > 0)
64
+ match = testMatch;
65
+ }
66
+ tagObj =
67
+ match.find(t => t.format === item.format) ?? match.find(t => !t.format);
68
+ }
69
+ else {
70
+ obj = item;
71
+ tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
72
+ }
73
+ if (!tagObj) {
74
+ const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
75
+ throw new Error(`Tag not resolved for ${name} value`);
76
+ }
77
+ return tagObj;
78
+ }
79
+ // needs to be called before value stringifier to allow for circular anchor refs
80
+ function stringifyProps(node, tagObj, { anchors: anchors$1, doc }) {
81
+ if (!doc.directives)
82
+ return '';
83
+ const props = [];
84
+ const anchor = (identity.isScalar(node) || identity.isCollection(node)) && node.anchor;
85
+ if (anchor && anchors.anchorIsValid(anchor)) {
86
+ anchors$1.add(anchor);
87
+ props.push(`&${anchor}`);
88
+ }
89
+ const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
90
+ if (tag)
91
+ props.push(doc.directives.tagString(tag));
92
+ return props.join(' ');
93
+ }
94
+ function stringify(item, ctx, onComment, onChompKeep) {
95
+ if (identity.isPair(item))
96
+ return item.toString(ctx, onComment, onChompKeep);
97
+ if (identity.isAlias(item)) {
98
+ if (ctx.doc.directives)
99
+ return item.toString(ctx);
100
+ if (ctx.resolvedAliases?.has(item)) {
101
+ throw new TypeError(`Cannot stringify circular structure without alias nodes`);
102
+ }
103
+ else {
104
+ if (ctx.resolvedAliases)
105
+ ctx.resolvedAliases.add(item);
106
+ else
107
+ ctx.resolvedAliases = new Set([item]);
108
+ item = item.resolve(ctx.doc);
109
+ }
110
+ }
111
+ let tagObj = undefined;
112
+ const node = identity.isNode(item)
113
+ ? item
114
+ : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
115
+ tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
116
+ const props = stringifyProps(node, tagObj, ctx);
117
+ if (props.length > 0)
118
+ ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
119
+ const str = typeof tagObj.stringify === 'function'
120
+ ? tagObj.stringify(node, ctx, onComment, onChompKeep)
121
+ : identity.isScalar(node)
122
+ ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep)
123
+ : node.toString(ctx, onComment, onChompKeep);
124
+ if (!props)
125
+ return str;
126
+ return identity.isScalar(node) || str[0] === '{' || str[0] === '['
127
+ ? `${props} ${str}`
128
+ : `${props}\n${ctx.indent}${str}`;
129
+ }
130
+
131
+ exports.createStringifyContext = createStringifyContext;
132
+ exports.stringify = stringify;
@@ -0,0 +1,155 @@
1
+ 'use strict';
2
+
3
+ var identity = require('../nodes/identity.js');
4
+ var stringify = require('./stringify.js');
5
+ var stringifyComment = require('./stringifyComment.js');
6
+
7
+ function stringifyCollection(collection, ctx, options) {
8
+ const flow = ctx.inFlow ?? collection.flow;
9
+ const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
10
+ return stringify(collection, ctx, options);
11
+ }
12
+ function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
13
+ const { indent, options: { commentString } } = ctx;
14
+ const itemCtx = Object.assign({}, ctx, { indent: itemIndent, type: null });
15
+ let chompKeep = false; // flag for the preceding node's status
16
+ const lines = [];
17
+ for (let i = 0; i < items.length; ++i) {
18
+ const item = items[i];
19
+ let comment = null;
20
+ if (identity.isNode(item)) {
21
+ if (!chompKeep && item.spaceBefore)
22
+ lines.push('');
23
+ addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
24
+ if (item.comment)
25
+ comment = item.comment;
26
+ }
27
+ else if (identity.isPair(item)) {
28
+ const ik = identity.isNode(item.key) ? item.key : null;
29
+ if (ik) {
30
+ if (!chompKeep && ik.spaceBefore)
31
+ lines.push('');
32
+ addCommentBefore(ctx, lines, ik.commentBefore, chompKeep);
33
+ }
34
+ }
35
+ chompKeep = false;
36
+ let str = stringify.stringify(item, itemCtx, () => (comment = null), () => (chompKeep = true));
37
+ if (comment)
38
+ str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
39
+ if (chompKeep && comment)
40
+ chompKeep = false;
41
+ lines.push(blockItemPrefix + str);
42
+ }
43
+ let str;
44
+ if (lines.length === 0) {
45
+ str = flowChars.start + flowChars.end;
46
+ }
47
+ else {
48
+ str = lines[0];
49
+ for (let i = 1; i < lines.length; ++i) {
50
+ const line = lines[i];
51
+ str += line ? `\n${indent}${line}` : '\n';
52
+ }
53
+ }
54
+ if (comment) {
55
+ str += '\n' + stringifyComment.indentComment(commentString(comment), indent);
56
+ if (onComment)
57
+ onComment();
58
+ }
59
+ else if (chompKeep && onChompKeep)
60
+ onChompKeep();
61
+ return str;
62
+ }
63
+ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
64
+ const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
65
+ itemIndent += indentStep;
66
+ const itemCtx = Object.assign({}, ctx, {
67
+ indent: itemIndent,
68
+ inFlow: true,
69
+ type: null
70
+ });
71
+ let reqNewline = false;
72
+ let linesAtValue = 0;
73
+ const lines = [];
74
+ for (let i = 0; i < items.length; ++i) {
75
+ const item = items[i];
76
+ let comment = null;
77
+ if (identity.isNode(item)) {
78
+ if (item.spaceBefore)
79
+ lines.push('');
80
+ addCommentBefore(ctx, lines, item.commentBefore, false);
81
+ if (item.comment)
82
+ comment = item.comment;
83
+ }
84
+ else if (identity.isPair(item)) {
85
+ const ik = identity.isNode(item.key) ? item.key : null;
86
+ if (ik) {
87
+ if (ik.spaceBefore)
88
+ lines.push('');
89
+ addCommentBefore(ctx, lines, ik.commentBefore, false);
90
+ if (ik.comment)
91
+ reqNewline = true;
92
+ }
93
+ const iv = identity.isNode(item.value) ? item.value : null;
94
+ if (iv) {
95
+ if (iv.comment)
96
+ comment = iv.comment;
97
+ if (iv.commentBefore)
98
+ reqNewline = true;
99
+ }
100
+ else if (item.value == null && ik?.comment) {
101
+ comment = ik.comment;
102
+ }
103
+ }
104
+ if (comment)
105
+ reqNewline = true;
106
+ let str = stringify.stringify(item, itemCtx, () => (comment = null));
107
+ reqNewline || (reqNewline = lines.length > linesAtValue || str.includes('\n'));
108
+ if (i < items.length - 1) {
109
+ str += ',';
110
+ }
111
+ else if (ctx.options.trailingComma) {
112
+ if (ctx.options.lineWidth > 0) {
113
+ reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) +
114
+ (str.length + 2) >
115
+ ctx.options.lineWidth);
116
+ }
117
+ if (reqNewline) {
118
+ str += ',';
119
+ }
120
+ }
121
+ if (comment)
122
+ str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
123
+ lines.push(str);
124
+ linesAtValue = lines.length;
125
+ }
126
+ const { start, end } = flowChars;
127
+ if (lines.length === 0) {
128
+ return start + end;
129
+ }
130
+ else {
131
+ if (!reqNewline) {
132
+ const len = lines.reduce((sum, line) => sum + line.length + 2, 2);
133
+ reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
134
+ }
135
+ if (reqNewline) {
136
+ let str = start;
137
+ for (const line of lines)
138
+ str += line ? `\n${indentStep}${indent}${line}` : '\n';
139
+ return `${str}\n${indent}${end}`;
140
+ }
141
+ else {
142
+ return `${start}${fcPadding}${lines.join(' ')}${fcPadding}${end}`;
143
+ }
144
+ }
145
+ }
146
+ function addCommentBefore({ indent, options: { commentString } }, lines, comment, chompKeep) {
147
+ if (comment && chompKeep)
148
+ comment = comment.replace(/^\n+/, '');
149
+ if (comment) {
150
+ const ic = stringifyComment.indentComment(commentString(comment), indent);
151
+ lines.push(ic.trimStart()); // Avoid double indent on first line
152
+ }
153
+ }
154
+
155
+ exports.stringifyCollection = stringifyCollection;
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Stringifies a comment.
5
+ *
6
+ * Empty comment lines are left empty,
7
+ * lines consisting of a single space are replaced by `#`,
8
+ * and all other lines are prefixed with a `#`.
9
+ */
10
+ const stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, '#');
11
+ function indentComment(comment, indent) {
12
+ if (/^\n+$/.test(comment))
13
+ return comment.substring(1);
14
+ return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
15
+ }
16
+ const lineComment = (str, indent, comment) => str.endsWith('\n')
17
+ ? indentComment(comment, indent)
18
+ : comment.includes('\n')
19
+ ? '\n' + indentComment(comment, indent)
20
+ : (str.endsWith(' ') ? '' : ' ') + comment;
21
+
22
+ exports.indentComment = indentComment;
23
+ exports.lineComment = lineComment;
24
+ exports.stringifyComment = stringifyComment;
@@ -0,0 +1,87 @@
1
+ 'use strict';
2
+
3
+ var identity = require('../nodes/identity.js');
4
+ var stringify = require('./stringify.js');
5
+ var stringifyComment = require('./stringifyComment.js');
6
+
7
+ function stringifyDocument(doc, options) {
8
+ const lines = [];
9
+ let hasDirectives = options.directives === true;
10
+ if (options.directives !== false && doc.directives) {
11
+ const dir = doc.directives.toString(doc);
12
+ if (dir) {
13
+ lines.push(dir);
14
+ hasDirectives = true;
15
+ }
16
+ else if (doc.directives.docStart)
17
+ hasDirectives = true;
18
+ }
19
+ if (hasDirectives)
20
+ lines.push('---');
21
+ const ctx = stringify.createStringifyContext(doc, options);
22
+ const { commentString } = ctx.options;
23
+ if (doc.commentBefore) {
24
+ if (lines.length !== 1)
25
+ lines.unshift('');
26
+ const cs = commentString(doc.commentBefore);
27
+ lines.unshift(stringifyComment.indentComment(cs, ''));
28
+ }
29
+ let chompKeep = false;
30
+ let contentComment = null;
31
+ if (doc.contents) {
32
+ if (identity.isNode(doc.contents)) {
33
+ if (doc.contents.spaceBefore && hasDirectives)
34
+ lines.push('');
35
+ if (doc.contents.commentBefore) {
36
+ const cs = commentString(doc.contents.commentBefore);
37
+ lines.push(stringifyComment.indentComment(cs, ''));
38
+ }
39
+ // top-level block scalars need to be indented if followed by a comment
40
+ ctx.forceBlockIndent = !!doc.comment;
41
+ contentComment = doc.contents.comment;
42
+ }
43
+ const onChompKeep = contentComment ? undefined : () => (chompKeep = true);
44
+ let body = stringify.stringify(doc.contents, ctx, () => (contentComment = null), onChompKeep);
45
+ if (contentComment)
46
+ body += stringifyComment.lineComment(body, '', commentString(contentComment));
47
+ if ((body[0] === '|' || body[0] === '>') &&
48
+ lines[lines.length - 1] === '---') {
49
+ // Top-level block scalars with a preceding doc marker ought to use the
50
+ // same line for their header.
51
+ lines[lines.length - 1] = `--- ${body}`;
52
+ }
53
+ else
54
+ lines.push(body);
55
+ }
56
+ else {
57
+ lines.push(stringify.stringify(doc.contents, ctx));
58
+ }
59
+ if (doc.directives?.docEnd) {
60
+ if (doc.comment) {
61
+ const cs = commentString(doc.comment);
62
+ if (cs.includes('\n')) {
63
+ lines.push('...');
64
+ lines.push(stringifyComment.indentComment(cs, ''));
65
+ }
66
+ else {
67
+ lines.push(`... ${cs}`);
68
+ }
69
+ }
70
+ else {
71
+ lines.push('...');
72
+ }
73
+ }
74
+ else {
75
+ let dc = doc.comment;
76
+ if (dc && chompKeep)
77
+ dc = dc.replace(/^\n+/, '');
78
+ if (dc) {
79
+ if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '')
80
+ lines.push('');
81
+ lines.push(stringifyComment.indentComment(commentString(dc), ''));
82
+ }
83
+ }
84
+ return lines.join('\n') + '\n';
85
+ }
86
+
87
+ exports.stringifyDocument = stringifyDocument;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ function stringifyNumber({ format, minFractionDigits, tag, value }) {
4
+ if (typeof value === 'bigint')
5
+ return String(value);
6
+ const num = typeof value === 'number' ? value : Number(value);
7
+ if (!isFinite(num))
8
+ return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf';
9
+ let n = Object.is(value, -0) ? '-0' : JSON.stringify(value);
10
+ if (!format &&
11
+ minFractionDigits &&
12
+ (!tag || tag === 'tag:yaml.org,2002:float') &&
13
+ /^-?\d/.test(n) &&
14
+ !n.includes('e')) {
15
+ let i = n.indexOf('.');
16
+ if (i < 0) {
17
+ i = n.length;
18
+ n += '.';
19
+ }
20
+ let d = minFractionDigits - (n.length - i - 1);
21
+ while (d-- > 0)
22
+ n += '0';
23
+ }
24
+ return n;
25
+ }
26
+
27
+ exports.stringifyNumber = stringifyNumber;