dimcode-darwin-x64 0.0.79-beta.0 → 0.1.0-alpha.11

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 (254) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +2 -0
  3. package/bin/dimcode +2 -2
  4. package/licenses/grok-build/LICENSE +204 -0
  5. package/licenses/grok-build/NOTICE +14 -0
  6. package/licenses/grok-build/xai-ratatui-inline/NOTICE +15 -0
  7. package/licenses/grok-build/xai-ratatui-textarea/NOTICE +8 -0
  8. package/package.json +12 -3
  9. package/release-manifest.json +19 -0
  10. package/bin/node_modules/skills/bin/cli.mjs +0 -14
  11. package/bin/node_modules/skills/dist/_chunks/libs/@clack/core.mjs +0 -767
  12. package/bin/node_modules/skills/dist/_chunks/libs/@clack/prompts.mjs +0 -334
  13. package/bin/node_modules/skills/dist/_chunks/libs/@kwsites/file-exists.mjs +0 -562
  14. package/bin/node_modules/skills/dist/_chunks/libs/@kwsites/promise-deferred.mjs +0 -37
  15. package/bin/node_modules/skills/dist/_chunks/libs/@vercel/detect-agent.mjs +0 -138
  16. package/bin/node_modules/skills/dist/_chunks/libs/simple-git.mjs +0 -3584
  17. package/bin/node_modules/skills/dist/_chunks/libs/xdg-basedir.mjs +0 -14
  18. package/bin/node_modules/skills/dist/_chunks/rolldown-runtime.mjs +0 -24
  19. package/bin/node_modules/skills/dist/cli.d.mts +0 -1
  20. package/bin/node_modules/skills/dist/cli.mjs +0 -6199
  21. package/bin/node_modules/skills/package.json +0 -143
  22. package/bin/node_modules/yaml/LICENSE +0 -13
  23. package/bin/node_modules/yaml/README.md +0 -172
  24. package/bin/node_modules/yaml/bin.mjs +0 -11
  25. package/bin/node_modules/yaml/browser/dist/compose/compose-collection.js +0 -88
  26. package/bin/node_modules/yaml/browser/dist/compose/compose-doc.js +0 -43
  27. package/bin/node_modules/yaml/browser/dist/compose/compose-node.js +0 -109
  28. package/bin/node_modules/yaml/browser/dist/compose/compose-scalar.js +0 -86
  29. package/bin/node_modules/yaml/browser/dist/compose/composer.js +0 -219
  30. package/bin/node_modules/yaml/browser/dist/compose/resolve-block-map.js +0 -115
  31. package/bin/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +0 -198
  32. package/bin/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +0 -49
  33. package/bin/node_modules/yaml/browser/dist/compose/resolve-end.js +0 -37
  34. package/bin/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +0 -207
  35. package/bin/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +0 -225
  36. package/bin/node_modules/yaml/browser/dist/compose/resolve-props.js +0 -146
  37. package/bin/node_modules/yaml/browser/dist/compose/util-contains-newline.js +0 -34
  38. package/bin/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +0 -26
  39. package/bin/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +0 -15
  40. package/bin/node_modules/yaml/browser/dist/compose/util-map-includes.js +0 -13
  41. package/bin/node_modules/yaml/browser/dist/doc/Document.js +0 -335
  42. package/bin/node_modules/yaml/browser/dist/doc/anchors.js +0 -71
  43. package/bin/node_modules/yaml/browser/dist/doc/applyReviver.js +0 -55
  44. package/bin/node_modules/yaml/browser/dist/doc/createNode.js +0 -88
  45. package/bin/node_modules/yaml/browser/dist/doc/directives.js +0 -176
  46. package/bin/node_modules/yaml/browser/dist/errors.js +0 -57
  47. package/bin/node_modules/yaml/browser/dist/index.js +0 -17
  48. package/bin/node_modules/yaml/browser/dist/log.js +0 -11
  49. package/bin/node_modules/yaml/browser/dist/nodes/Alias.js +0 -116
  50. package/bin/node_modules/yaml/browser/dist/nodes/Collection.js +0 -147
  51. package/bin/node_modules/yaml/browser/dist/nodes/Node.js +0 -38
  52. package/bin/node_modules/yaml/browser/dist/nodes/Pair.js +0 -36
  53. package/bin/node_modules/yaml/browser/dist/nodes/Scalar.js +0 -24
  54. package/bin/node_modules/yaml/browser/dist/nodes/YAMLMap.js +0 -144
  55. package/bin/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +0 -113
  56. package/bin/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +0 -63
  57. package/bin/node_modules/yaml/browser/dist/nodes/identity.js +0 -36
  58. package/bin/node_modules/yaml/browser/dist/nodes/toJS.js +0 -37
  59. package/bin/node_modules/yaml/browser/dist/parse/cst-scalar.js +0 -214
  60. package/bin/node_modules/yaml/browser/dist/parse/cst-stringify.js +0 -61
  61. package/bin/node_modules/yaml/browser/dist/parse/cst-visit.js +0 -97
  62. package/bin/node_modules/yaml/browser/dist/parse/cst.js +0 -98
  63. package/bin/node_modules/yaml/browser/dist/parse/lexer.js +0 -721
  64. package/bin/node_modules/yaml/browser/dist/parse/line-counter.js +0 -39
  65. package/bin/node_modules/yaml/browser/dist/parse/parser.js +0 -975
  66. package/bin/node_modules/yaml/browser/dist/public-api.js +0 -102
  67. package/bin/node_modules/yaml/browser/dist/schema/Schema.js +0 -37
  68. package/bin/node_modules/yaml/browser/dist/schema/common/map.js +0 -17
  69. package/bin/node_modules/yaml/browser/dist/schema/common/null.js +0 -15
  70. package/bin/node_modules/yaml/browser/dist/schema/common/seq.js +0 -17
  71. package/bin/node_modules/yaml/browser/dist/schema/common/string.js +0 -14
  72. package/bin/node_modules/yaml/browser/dist/schema/core/bool.js +0 -19
  73. package/bin/node_modules/yaml/browser/dist/schema/core/float.js +0 -43
  74. package/bin/node_modules/yaml/browser/dist/schema/core/int.js +0 -38
  75. package/bin/node_modules/yaml/browser/dist/schema/core/schema.js +0 -23
  76. package/bin/node_modules/yaml/browser/dist/schema/json/schema.js +0 -62
  77. package/bin/node_modules/yaml/browser/dist/schema/tags.js +0 -96
  78. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +0 -58
  79. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +0 -26
  80. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +0 -46
  81. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +0 -71
  82. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +0 -67
  83. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +0 -74
  84. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +0 -78
  85. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +0 -39
  86. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +0 -93
  87. package/bin/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +0 -101
  88. package/bin/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +0 -146
  89. package/bin/node_modules/yaml/browser/dist/stringify/stringify.js +0 -129
  90. package/bin/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +0 -153
  91. package/bin/node_modules/yaml/browser/dist/stringify/stringifyComment.js +0 -20
  92. package/bin/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +0 -85
  93. package/bin/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +0 -25
  94. package/bin/node_modules/yaml/browser/dist/stringify/stringifyPair.js +0 -150
  95. package/bin/node_modules/yaml/browser/dist/stringify/stringifyString.js +0 -336
  96. package/bin/node_modules/yaml/browser/dist/util.js +0 -11
  97. package/bin/node_modules/yaml/browser/dist/visit.js +0 -233
  98. package/bin/node_modules/yaml/browser/index.js +0 -5
  99. package/bin/node_modules/yaml/browser/package.json +0 -3
  100. package/bin/node_modules/yaml/dist/cli.d.ts +0 -8
  101. package/bin/node_modules/yaml/dist/cli.mjs +0 -201
  102. package/bin/node_modules/yaml/dist/compose/compose-collection.d.ts +0 -11
  103. package/bin/node_modules/yaml/dist/compose/compose-collection.js +0 -90
  104. package/bin/node_modules/yaml/dist/compose/compose-doc.d.ts +0 -7
  105. package/bin/node_modules/yaml/dist/compose/compose-doc.js +0 -45
  106. package/bin/node_modules/yaml/dist/compose/compose-node.d.ts +0 -29
  107. package/bin/node_modules/yaml/dist/compose/compose-node.js +0 -112
  108. package/bin/node_modules/yaml/dist/compose/compose-scalar.d.ts +0 -5
  109. package/bin/node_modules/yaml/dist/compose/compose-scalar.js +0 -88
  110. package/bin/node_modules/yaml/dist/compose/composer.d.ts +0 -63
  111. package/bin/node_modules/yaml/dist/compose/composer.js +0 -224
  112. package/bin/node_modules/yaml/dist/compose/resolve-block-map.d.ts +0 -6
  113. package/bin/node_modules/yaml/dist/compose/resolve-block-map.js +0 -117
  114. package/bin/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +0 -11
  115. package/bin/node_modules/yaml/dist/compose/resolve-block-scalar.js +0 -200
  116. package/bin/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +0 -6
  117. package/bin/node_modules/yaml/dist/compose/resolve-block-seq.js +0 -51
  118. package/bin/node_modules/yaml/dist/compose/resolve-end.d.ts +0 -6
  119. package/bin/node_modules/yaml/dist/compose/resolve-end.js +0 -39
  120. package/bin/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +0 -7
  121. package/bin/node_modules/yaml/dist/compose/resolve-flow-collection.js +0 -209
  122. package/bin/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +0 -10
  123. package/bin/node_modules/yaml/dist/compose/resolve-flow-scalar.js +0 -227
  124. package/bin/node_modules/yaml/dist/compose/resolve-props.d.ts +0 -23
  125. package/bin/node_modules/yaml/dist/compose/resolve-props.js +0 -148
  126. package/bin/node_modules/yaml/dist/compose/util-contains-newline.d.ts +0 -2
  127. package/bin/node_modules/yaml/dist/compose/util-contains-newline.js +0 -36
  128. package/bin/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +0 -2
  129. package/bin/node_modules/yaml/dist/compose/util-empty-scalar-position.js +0 -28
  130. package/bin/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +0 -3
  131. package/bin/node_modules/yaml/dist/compose/util-flow-indent-check.js +0 -17
  132. package/bin/node_modules/yaml/dist/compose/util-map-includes.d.ts +0 -4
  133. package/bin/node_modules/yaml/dist/compose/util-map-includes.js +0 -15
  134. package/bin/node_modules/yaml/dist/doc/Document.d.ts +0 -141
  135. package/bin/node_modules/yaml/dist/doc/Document.js +0 -337
  136. package/bin/node_modules/yaml/dist/doc/anchors.d.ts +0 -24
  137. package/bin/node_modules/yaml/dist/doc/anchors.js +0 -76
  138. package/bin/node_modules/yaml/dist/doc/applyReviver.d.ts +0 -9
  139. package/bin/node_modules/yaml/dist/doc/applyReviver.js +0 -57
  140. package/bin/node_modules/yaml/dist/doc/createNode.d.ts +0 -17
  141. package/bin/node_modules/yaml/dist/doc/createNode.js +0 -90
  142. package/bin/node_modules/yaml/dist/doc/directives.d.ts +0 -49
  143. package/bin/node_modules/yaml/dist/doc/directives.js +0 -178
  144. package/bin/node_modules/yaml/dist/errors.d.ts +0 -21
  145. package/bin/node_modules/yaml/dist/errors.js +0 -62
  146. package/bin/node_modules/yaml/dist/index.d.ts +0 -25
  147. package/bin/node_modules/yaml/dist/index.js +0 -50
  148. package/bin/node_modules/yaml/dist/log.d.ts +0 -3
  149. package/bin/node_modules/yaml/dist/log.js +0 -19
  150. package/bin/node_modules/yaml/dist/nodes/Alias.d.ts +0 -29
  151. package/bin/node_modules/yaml/dist/nodes/Alias.js +0 -118
  152. package/bin/node_modules/yaml/dist/nodes/Collection.d.ts +0 -73
  153. package/bin/node_modules/yaml/dist/nodes/Collection.js +0 -151
  154. package/bin/node_modules/yaml/dist/nodes/Node.d.ts +0 -53
  155. package/bin/node_modules/yaml/dist/nodes/Node.js +0 -40
  156. package/bin/node_modules/yaml/dist/nodes/Pair.d.ts +0 -22
  157. package/bin/node_modules/yaml/dist/nodes/Pair.js +0 -39
  158. package/bin/node_modules/yaml/dist/nodes/Scalar.d.ts +0 -47
  159. package/bin/node_modules/yaml/dist/nodes/Scalar.js +0 -27
  160. package/bin/node_modules/yaml/dist/nodes/YAMLMap.d.ts +0 -53
  161. package/bin/node_modules/yaml/dist/nodes/YAMLMap.js +0 -147
  162. package/bin/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +0 -60
  163. package/bin/node_modules/yaml/dist/nodes/YAMLSeq.js +0 -115
  164. package/bin/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +0 -4
  165. package/bin/node_modules/yaml/dist/nodes/addPairToJSMap.js +0 -65
  166. package/bin/node_modules/yaml/dist/nodes/identity.d.ts +0 -23
  167. package/bin/node_modules/yaml/dist/nodes/identity.js +0 -53
  168. package/bin/node_modules/yaml/dist/nodes/toJS.d.ts +0 -29
  169. package/bin/node_modules/yaml/dist/nodes/toJS.js +0 -39
  170. package/bin/node_modules/yaml/dist/options.d.ts +0 -350
  171. package/bin/node_modules/yaml/dist/parse/cst-scalar.d.ts +0 -64
  172. package/bin/node_modules/yaml/dist/parse/cst-scalar.js +0 -218
  173. package/bin/node_modules/yaml/dist/parse/cst-stringify.d.ts +0 -8
  174. package/bin/node_modules/yaml/dist/parse/cst-stringify.js +0 -63
  175. package/bin/node_modules/yaml/dist/parse/cst-visit.d.ts +0 -39
  176. package/bin/node_modules/yaml/dist/parse/cst-visit.js +0 -99
  177. package/bin/node_modules/yaml/dist/parse/cst.d.ts +0 -109
  178. package/bin/node_modules/yaml/dist/parse/cst.js +0 -112
  179. package/bin/node_modules/yaml/dist/parse/lexer.d.ts +0 -87
  180. package/bin/node_modules/yaml/dist/parse/lexer.js +0 -723
  181. package/bin/node_modules/yaml/dist/parse/line-counter.d.ts +0 -22
  182. package/bin/node_modules/yaml/dist/parse/line-counter.js +0 -41
  183. package/bin/node_modules/yaml/dist/parse/parser.d.ts +0 -84
  184. package/bin/node_modules/yaml/dist/parse/parser.js +0 -980
  185. package/bin/node_modules/yaml/dist/public-api.d.ts +0 -44
  186. package/bin/node_modules/yaml/dist/public-api.js +0 -107
  187. package/bin/node_modules/yaml/dist/schema/Schema.d.ts +0 -17
  188. package/bin/node_modules/yaml/dist/schema/Schema.js +0 -39
  189. package/bin/node_modules/yaml/dist/schema/common/map.d.ts +0 -2
  190. package/bin/node_modules/yaml/dist/schema/common/map.js +0 -19
  191. package/bin/node_modules/yaml/dist/schema/common/null.d.ts +0 -4
  192. package/bin/node_modules/yaml/dist/schema/common/null.js +0 -17
  193. package/bin/node_modules/yaml/dist/schema/common/seq.d.ts +0 -2
  194. package/bin/node_modules/yaml/dist/schema/common/seq.js +0 -19
  195. package/bin/node_modules/yaml/dist/schema/common/string.d.ts +0 -2
  196. package/bin/node_modules/yaml/dist/schema/common/string.js +0 -16
  197. package/bin/node_modules/yaml/dist/schema/core/bool.d.ts +0 -4
  198. package/bin/node_modules/yaml/dist/schema/core/bool.js +0 -21
  199. package/bin/node_modules/yaml/dist/schema/core/float.d.ts +0 -4
  200. package/bin/node_modules/yaml/dist/schema/core/float.js +0 -47
  201. package/bin/node_modules/yaml/dist/schema/core/int.d.ts +0 -4
  202. package/bin/node_modules/yaml/dist/schema/core/int.js +0 -42
  203. package/bin/node_modules/yaml/dist/schema/core/schema.d.ts +0 -1
  204. package/bin/node_modules/yaml/dist/schema/core/schema.js +0 -25
  205. package/bin/node_modules/yaml/dist/schema/json/schema.d.ts +0 -2
  206. package/bin/node_modules/yaml/dist/schema/json/schema.js +0 -64
  207. package/bin/node_modules/yaml/dist/schema/json-schema.d.ts +0 -69
  208. package/bin/node_modules/yaml/dist/schema/tags.d.ts +0 -48
  209. package/bin/node_modules/yaml/dist/schema/tags.js +0 -99
  210. package/bin/node_modules/yaml/dist/schema/types.d.ts +0 -92
  211. package/bin/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +0 -2
  212. package/bin/node_modules/yaml/dist/schema/yaml-1.1/binary.js +0 -70
  213. package/bin/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +0 -7
  214. package/bin/node_modules/yaml/dist/schema/yaml-1.1/bool.js +0 -29
  215. package/bin/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +0 -4
  216. package/bin/node_modules/yaml/dist/schema/yaml-1.1/float.js +0 -50
  217. package/bin/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +0 -5
  218. package/bin/node_modules/yaml/dist/schema/yaml-1.1/int.js +0 -76
  219. package/bin/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +0 -9
  220. package/bin/node_modules/yaml/dist/schema/yaml-1.1/merge.js +0 -71
  221. package/bin/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +0 -22
  222. package/bin/node_modules/yaml/dist/schema/yaml-1.1/omap.js +0 -77
  223. package/bin/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +0 -10
  224. package/bin/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +0 -82
  225. package/bin/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +0 -1
  226. package/bin/node_modules/yaml/dist/schema/yaml-1.1/schema.js +0 -41
  227. package/bin/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +0 -28
  228. package/bin/node_modules/yaml/dist/schema/yaml-1.1/set.js +0 -96
  229. package/bin/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +0 -6
  230. package/bin/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +0 -105
  231. package/bin/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +0 -34
  232. package/bin/node_modules/yaml/dist/stringify/foldFlowLines.js +0 -151
  233. package/bin/node_modules/yaml/dist/stringify/stringify.d.ts +0 -21
  234. package/bin/node_modules/yaml/dist/stringify/stringify.js +0 -132
  235. package/bin/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +0 -17
  236. package/bin/node_modules/yaml/dist/stringify/stringifyCollection.js +0 -155
  237. package/bin/node_modules/yaml/dist/stringify/stringifyComment.d.ts +0 -10
  238. package/bin/node_modules/yaml/dist/stringify/stringifyComment.js +0 -24
  239. package/bin/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +0 -4
  240. package/bin/node_modules/yaml/dist/stringify/stringifyDocument.js +0 -87
  241. package/bin/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +0 -2
  242. package/bin/node_modules/yaml/dist/stringify/stringifyNumber.js +0 -27
  243. package/bin/node_modules/yaml/dist/stringify/stringifyPair.d.ts +0 -3
  244. package/bin/node_modules/yaml/dist/stringify/stringifyPair.js +0 -152
  245. package/bin/node_modules/yaml/dist/stringify/stringifyString.d.ts +0 -9
  246. package/bin/node_modules/yaml/dist/stringify/stringifyString.js +0 -338
  247. package/bin/node_modules/yaml/dist/test-events.d.ts +0 -4
  248. package/bin/node_modules/yaml/dist/test-events.js +0 -134
  249. package/bin/node_modules/yaml/dist/util.d.ts +0 -16
  250. package/bin/node_modules/yaml/dist/util.js +0 -28
  251. package/bin/node_modules/yaml/dist/visit.d.ts +0 -102
  252. package/bin/node_modules/yaml/dist/visit.js +0 -236
  253. package/bin/node_modules/yaml/package.json +0 -97
  254. package/bin/node_modules/yaml/util.js +0 -2
@@ -1,97 +0,0 @@
1
- const BREAK = Symbol('break visit');
2
- const SKIP = Symbol('skip children');
3
- const REMOVE = Symbol('remove item');
4
- /**
5
- * Apply a visitor to a CST document or item.
6
- *
7
- * Walks through the tree (depth-first) starting from the root, calling a
8
- * `visitor` function with two arguments when entering each item:
9
- * - `item`: The current item, which included the following members:
10
- * - `start: SourceToken[]` – Source tokens before the key or value,
11
- * possibly including its anchor or tag.
12
- * - `key?: Token | null` – Set for pair values. May then be `null`, if
13
- * the key before the `:` separator is empty.
14
- * - `sep?: SourceToken[]` – Source tokens between the key and the value,
15
- * which should include the `:` map value indicator if `value` is set.
16
- * - `value?: Token` – The value of a sequence item, or of a map pair.
17
- * - `path`: The steps from the root to the current node, as an array of
18
- * `['key' | 'value', number]` tuples.
19
- *
20
- * The return value of the visitor may be used to control the traversal:
21
- * - `undefined` (default): Do nothing and continue
22
- * - `visit.SKIP`: Do not visit the children of this token, continue with
23
- * next sibling
24
- * - `visit.BREAK`: Terminate traversal completely
25
- * - `visit.REMOVE`: Remove the current item, then continue with the next one
26
- * - `number`: Set the index of the next step. This is useful especially if
27
- * the index of the current token has changed.
28
- * - `function`: Define the next visitor for this item. After the original
29
- * visitor is called on item entry, next visitors are called after handling
30
- * a non-empty `key` and when exiting the item.
31
- */
32
- function visit(cst, visitor) {
33
- if ('type' in cst && cst.type === 'document')
34
- cst = { start: cst.start, value: cst.value };
35
- _visit(Object.freeze([]), cst, visitor);
36
- }
37
- // Without the `as symbol` casts, TS declares these in the `visit`
38
- // namespace using `var`, but then complains about that because
39
- // `unique symbol` must be `const`.
40
- /** Terminate visit traversal completely */
41
- visit.BREAK = BREAK;
42
- /** Do not visit the children of the current item */
43
- visit.SKIP = SKIP;
44
- /** Remove the current item */
45
- visit.REMOVE = REMOVE;
46
- /** Find the item at `path` from `cst` as the root */
47
- visit.itemAtPath = (cst, path) => {
48
- let item = cst;
49
- for (const [field, index] of path) {
50
- const tok = item?.[field];
51
- if (tok && 'items' in tok) {
52
- item = tok.items[index];
53
- }
54
- else
55
- return undefined;
56
- }
57
- return item;
58
- };
59
- /**
60
- * Get the immediate parent collection of the item at `path` from `cst` as the root.
61
- *
62
- * Throws an error if the collection is not found, which should never happen if the item itself exists.
63
- */
64
- visit.parentCollection = (cst, path) => {
65
- const parent = visit.itemAtPath(cst, path.slice(0, -1));
66
- const field = path[path.length - 1][0];
67
- const coll = parent?.[field];
68
- if (coll && 'items' in coll)
69
- return coll;
70
- throw new Error('Parent collection not found');
71
- };
72
- function _visit(path, item, visitor) {
73
- let ctrl = visitor(item, path);
74
- if (typeof ctrl === 'symbol')
75
- return ctrl;
76
- for (const field of ['key', 'value']) {
77
- const token = item[field];
78
- if (token && 'items' in token) {
79
- for (let i = 0; i < token.items.length; ++i) {
80
- const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
81
- if (typeof ci === 'number')
82
- i = ci - 1;
83
- else if (ci === BREAK)
84
- return BREAK;
85
- else if (ci === REMOVE) {
86
- token.items.splice(i, 1);
87
- i -= 1;
88
- }
89
- }
90
- if (typeof ctrl === 'function' && field === 'key')
91
- ctrl = ctrl(item, path);
92
- }
93
- }
94
- return typeof ctrl === 'function' ? ctrl(item, path) : ctrl;
95
- }
96
-
97
- export { visit };
@@ -1,98 +0,0 @@
1
- export { createScalarToken, resolveAsScalar, setScalarValue } from './cst-scalar.js';
2
- export { stringify } from './cst-stringify.js';
3
- export { visit } from './cst-visit.js';
4
-
5
- /** The byte order mark */
6
- const BOM = '\u{FEFF}';
7
- /** Start of doc-mode */
8
- const DOCUMENT = '\x02'; // C0: Start of Text
9
- /** Unexpected end of flow-mode */
10
- const FLOW_END = '\x18'; // C0: Cancel
11
- /** Next token is a scalar value */
12
- const SCALAR = '\x1f'; // C0: Unit Separator
13
- /** @returns `true` if `token` is a flow or block collection */
14
- const isCollection = (token) => !!token && 'items' in token;
15
- /** @returns `true` if `token` is a flow or block scalar; not an alias */
16
- const isScalar = (token) => !!token &&
17
- (token.type === 'scalar' ||
18
- token.type === 'single-quoted-scalar' ||
19
- token.type === 'double-quoted-scalar' ||
20
- token.type === 'block-scalar');
21
- /* istanbul ignore next */
22
- /** Get a printable representation of a lexer token */
23
- function prettyToken(token) {
24
- switch (token) {
25
- case BOM:
26
- return '<BOM>';
27
- case DOCUMENT:
28
- return '<DOC>';
29
- case FLOW_END:
30
- return '<FLOW_END>';
31
- case SCALAR:
32
- return '<SCALAR>';
33
- default:
34
- return JSON.stringify(token);
35
- }
36
- }
37
- /** Identify the type of a lexer token. May return `null` for unknown tokens. */
38
- function tokenType(source) {
39
- switch (source) {
40
- case BOM:
41
- return 'byte-order-mark';
42
- case DOCUMENT:
43
- return 'doc-mode';
44
- case FLOW_END:
45
- return 'flow-error-end';
46
- case SCALAR:
47
- return 'scalar';
48
- case '---':
49
- return 'doc-start';
50
- case '...':
51
- return 'doc-end';
52
- case '':
53
- case '\n':
54
- case '\r\n':
55
- return 'newline';
56
- case '-':
57
- return 'seq-item-ind';
58
- case '?':
59
- return 'explicit-key-ind';
60
- case ':':
61
- return 'map-value-ind';
62
- case '{':
63
- return 'flow-map-start';
64
- case '}':
65
- return 'flow-map-end';
66
- case '[':
67
- return 'flow-seq-start';
68
- case ']':
69
- return 'flow-seq-end';
70
- case ',':
71
- return 'comma';
72
- }
73
- switch (source[0]) {
74
- case ' ':
75
- case '\t':
76
- return 'space';
77
- case '#':
78
- return 'comment';
79
- case '%':
80
- return 'directive-line';
81
- case '*':
82
- return 'alias';
83
- case '&':
84
- return 'anchor';
85
- case '!':
86
- return 'tag';
87
- case "'":
88
- return 'single-quoted-scalar';
89
- case '"':
90
- return 'double-quoted-scalar';
91
- case '|':
92
- case '>':
93
- return 'block-scalar-header';
94
- }
95
- return null;
96
- }
97
-
98
- export { BOM, DOCUMENT, FLOW_END, SCALAR, isCollection, isScalar, prettyToken, tokenType };