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