@bolt-foundry/gambit-core 0.8.0 → 0.8.3

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 (207) hide show
  1. package/README.md +28 -32
  2. package/cards/context.card.md +5 -5
  3. package/cards/generate-test-input.card.md +12 -0
  4. package/esm/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/_utils.d.ts.map +1 -1
  5. package/esm/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/_utils.js +1 -1
  6. package/esm/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/deep_merge.d.ts.map +1 -1
  7. package/esm/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/deep_merge.js +1 -1
  8. package/esm/deps/jsr.io/@std/front-matter/1.0.9/yaml.js +1 -1
  9. package/esm/deps/jsr.io/@std/toml/1.0.11/_parser.js +1 -1
  10. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_chars.d.ts.map +1 -1
  11. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_chars.js +1 -1
  12. package/{script/deps/jsr.io/@std/yaml/1.0.10 → esm/deps/jsr.io/@std/yaml/1.0.11}/_loader_state.d.ts +21 -18
  13. package/esm/deps/jsr.io/@std/yaml/1.0.11/_loader_state.d.ts.map +1 -0
  14. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_loader_state.js +250 -273
  15. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_schema.d.ts.map +1 -1
  16. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_schema.js +1 -1
  17. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/binary.d.ts.map +1 -1
  18. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/bool.d.ts.map +1 -1
  19. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/bool.js +1 -1
  20. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/float.d.ts.map +1 -1
  21. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/float.js +1 -1
  22. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/int.d.ts.map +1 -1
  23. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/int.js +1 -1
  24. package/{script/deps/jsr.io/@std/yaml/1.0.10 → esm/deps/jsr.io/@std/yaml/1.0.11}/_type/map.d.ts.map +1 -1
  25. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/map.js +1 -1
  26. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/merge.d.ts.map +1 -1
  27. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/merge.js +1 -1
  28. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/nil.d.ts.map +1 -1
  29. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/nil.js +1 -1
  30. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/omap.d.ts.map +1 -1
  31. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/omap.js +1 -1
  32. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/pairs.d.ts.map +1 -1
  33. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/pairs.js +1 -1
  34. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/regexp.d.ts.map +1 -1
  35. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/regexp.js +1 -1
  36. package/{script/deps/jsr.io/@std/yaml/1.0.10 → esm/deps/jsr.io/@std/yaml/1.0.11}/_type/seq.d.ts.map +1 -1
  37. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/seq.js +1 -1
  38. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/set.d.ts.map +1 -1
  39. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/set.js +1 -1
  40. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/str.d.ts.map +1 -1
  41. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/str.js +1 -1
  42. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/timestamp.d.ts.map +1 -1
  43. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/timestamp.js +1 -1
  44. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/undefined.d.ts.map +1 -1
  45. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/undefined.js +1 -1
  46. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type.d.ts.map +1 -1
  47. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type.js +1 -1
  48. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_utils.d.ts.map +1 -1
  49. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_utils.js +1 -1
  50. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/parse.d.ts.map +1 -1
  51. package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/parse.js +1 -1
  52. package/esm/mod.d.ts +11 -33
  53. package/esm/mod.d.ts.map +1 -1
  54. package/esm/mod.js +7 -3
  55. package/esm/src/constants.d.ts +4 -0
  56. package/esm/src/constants.d.ts.map +1 -1
  57. package/esm/src/constants.js +5 -0
  58. package/esm/src/definitions.d.ts +5 -1
  59. package/esm/src/definitions.d.ts.map +1 -1
  60. package/esm/src/loader.d.ts.map +1 -1
  61. package/esm/src/loader.js +61 -2
  62. package/esm/src/markdown.d.ts.map +1 -1
  63. package/esm/src/markdown.js +55 -12
  64. package/esm/src/render.d.ts.map +1 -1
  65. package/esm/src/render.js +22 -8
  66. package/esm/src/runtime.d.ts +1 -0
  67. package/esm/src/runtime.d.ts.map +1 -1
  68. package/esm/src/runtime.js +327 -172
  69. package/esm/src/state.d.ts +5 -4
  70. package/esm/src/state.d.ts.map +1 -1
  71. package/esm/src/state.js +48 -2
  72. package/esm/src/types.d.ts +156 -281
  73. package/esm/src/types.d.ts.map +1 -1
  74. package/esm/src/types.js +102 -1
  75. package/package.json +1 -1
  76. package/schemas/graders/grader_output.ts +7 -0
  77. package/script/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/_utils.d.ts.map +1 -1
  78. package/script/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/_utils.js +1 -1
  79. package/script/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/deep_merge.d.ts.map +1 -1
  80. package/script/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/deep_merge.js +1 -1
  81. package/script/deps/jsr.io/@std/front-matter/1.0.9/yaml.js +1 -1
  82. package/script/deps/jsr.io/@std/toml/1.0.11/_parser.js +1 -1
  83. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_chars.d.ts.map +1 -1
  84. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_chars.js +1 -1
  85. package/{esm/deps/jsr.io/@std/yaml/1.0.10 → script/deps/jsr.io/@std/yaml/1.0.11}/_loader_state.d.ts +21 -18
  86. package/script/deps/jsr.io/@std/yaml/1.0.11/_loader_state.d.ts.map +1 -0
  87. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_loader_state.js +250 -273
  88. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_schema.d.ts.map +1 -1
  89. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_schema.js +1 -1
  90. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/binary.d.ts.map +1 -1
  91. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/bool.d.ts.map +1 -1
  92. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/bool.js +1 -1
  93. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/float.d.ts.map +1 -1
  94. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/float.js +1 -1
  95. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/int.d.ts.map +1 -1
  96. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/int.js +1 -1
  97. package/{esm/deps/jsr.io/@std/yaml/1.0.10 → script/deps/jsr.io/@std/yaml/1.0.11}/_type/map.d.ts.map +1 -1
  98. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/map.js +1 -1
  99. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/merge.d.ts.map +1 -1
  100. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/merge.js +1 -1
  101. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/nil.d.ts.map +1 -1
  102. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/nil.js +1 -1
  103. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/omap.d.ts.map +1 -1
  104. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/omap.js +1 -1
  105. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/pairs.d.ts.map +1 -1
  106. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/pairs.js +1 -1
  107. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/regexp.d.ts.map +1 -1
  108. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/regexp.js +1 -1
  109. package/{esm/deps/jsr.io/@std/yaml/1.0.10 → script/deps/jsr.io/@std/yaml/1.0.11}/_type/seq.d.ts.map +1 -1
  110. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/seq.js +1 -1
  111. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/set.d.ts.map +1 -1
  112. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/set.js +1 -1
  113. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/str.d.ts.map +1 -1
  114. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/str.js +1 -1
  115. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/timestamp.d.ts.map +1 -1
  116. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/timestamp.js +1 -1
  117. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/undefined.d.ts.map +1 -1
  118. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/undefined.js +1 -1
  119. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type.d.ts.map +1 -1
  120. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type.js +1 -1
  121. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_utils.d.ts.map +1 -1
  122. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_utils.js +1 -1
  123. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/parse.d.ts.map +1 -1
  124. package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/parse.js +1 -1
  125. package/script/mod.d.ts +11 -33
  126. package/script/mod.d.ts.map +1 -1
  127. package/script/mod.js +14 -6
  128. package/script/src/constants.d.ts +4 -0
  129. package/script/src/constants.d.ts.map +1 -1
  130. package/script/src/constants.js +6 -1
  131. package/script/src/definitions.d.ts +5 -1
  132. package/script/src/definitions.d.ts.map +1 -1
  133. package/script/src/loader.d.ts.map +1 -1
  134. package/script/src/loader.js +61 -2
  135. package/script/src/markdown.d.ts.map +1 -1
  136. package/script/src/markdown.js +54 -11
  137. package/script/src/render.d.ts.map +1 -1
  138. package/script/src/render.js +22 -8
  139. package/script/src/runtime.d.ts +1 -0
  140. package/script/src/runtime.d.ts.map +1 -1
  141. package/script/src/runtime.js +326 -171
  142. package/script/src/state.d.ts +5 -4
  143. package/script/src/state.d.ts.map +1 -1
  144. package/script/src/state.js +48 -2
  145. package/script/src/types.d.ts +156 -281
  146. package/script/src/types.d.ts.map +1 -1
  147. package/script/src/types.js +103 -0
  148. package/esm/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts.map +0 -1
  149. package/esm/src/openai_compat.d.ts +0 -63
  150. package/esm/src/openai_compat.d.ts.map +0 -1
  151. package/esm/src/openai_compat.js +0 -339
  152. package/esm/src/openresponses.d.ts +0 -6
  153. package/esm/src/openresponses.d.ts.map +0 -1
  154. package/esm/src/openresponses.js +0 -75
  155. package/script/deps/jsr.io/@std/yaml/1.0.10/_loader_state.d.ts.map +0 -1
  156. package/script/src/openai_compat.d.ts +0 -63
  157. package/script/src/openai_compat.d.ts.map +0 -1
  158. package/script/src/openai_compat.js +0 -343
  159. package/script/src/openresponses.d.ts +0 -6
  160. package/script/src/openresponses.d.ts.map +0 -1
  161. package/script/src/openresponses.js +0 -81
  162. /package/esm/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/_utils.d.ts +0 -0
  163. /package/esm/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/deep_merge.d.ts +0 -0
  164. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_chars.d.ts +0 -0
  165. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_schema.d.ts +0 -0
  166. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/binary.d.ts +0 -0
  167. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/binary.js +0 -0
  168. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/bool.d.ts +0 -0
  169. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/float.d.ts +0 -0
  170. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/int.d.ts +0 -0
  171. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/map.d.ts +0 -0
  172. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/merge.d.ts +0 -0
  173. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/nil.d.ts +0 -0
  174. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/omap.d.ts +0 -0
  175. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/pairs.d.ts +0 -0
  176. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/regexp.d.ts +0 -0
  177. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/seq.d.ts +0 -0
  178. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/set.d.ts +0 -0
  179. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/str.d.ts +0 -0
  180. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/timestamp.d.ts +0 -0
  181. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/undefined.d.ts +0 -0
  182. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type.d.ts +0 -0
  183. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_utils.d.ts +0 -0
  184. /package/esm/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/parse.d.ts +0 -0
  185. /package/script/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/_utils.d.ts +0 -0
  186. /package/script/deps/jsr.io/@std/collections/{1.1.3 → 1.1.4}/deep_merge.d.ts +0 -0
  187. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_chars.d.ts +0 -0
  188. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_schema.d.ts +0 -0
  189. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/binary.d.ts +0 -0
  190. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/binary.js +0 -0
  191. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/bool.d.ts +0 -0
  192. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/float.d.ts +0 -0
  193. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/int.d.ts +0 -0
  194. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/map.d.ts +0 -0
  195. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/merge.d.ts +0 -0
  196. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/nil.d.ts +0 -0
  197. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/omap.d.ts +0 -0
  198. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/pairs.d.ts +0 -0
  199. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/regexp.d.ts +0 -0
  200. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/seq.d.ts +0 -0
  201. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/set.d.ts +0 -0
  202. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/str.d.ts +0 -0
  203. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/timestamp.d.ts +0 -0
  204. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type/undefined.d.ts +0 -0
  205. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_type.d.ts +0 -0
  206. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/_utils.d.ts +0 -0
  207. /package/script/deps/jsr.io/@std/yaml/{1.0.10 → 1.0.11}/parse.d.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  // Ported from js-yaml v3.13.1:
2
2
  // https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
3
3
  // Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
4
- // Copyright 2018-2025 the Deno authors. MIT license.
4
+ // Copyright 2018-2026 the Deno authors. MIT license.
5
5
  var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
6
6
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
7
7
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -123,6 +123,20 @@ function markToString(buffer, position, line, column) {
123
123
  where += `:\n${snippet}`;
124
124
  return where;
125
125
  }
126
+ function getIndentStatus(lineIndent, parentIndent) {
127
+ if (lineIndent > parentIndent)
128
+ return 1;
129
+ if (lineIndent < parentIndent)
130
+ return -1;
131
+ return 0;
132
+ }
133
+ function writeFoldedLines(count) {
134
+ if (count === 1)
135
+ return " ";
136
+ if (count > 1)
137
+ return "\n".repeat(count - 1);
138
+ return "";
139
+ }
126
140
  export class LoaderState {
127
141
  constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false, }) {
128
142
  _LoaderState_instances.add(this);
@@ -204,30 +218,6 @@ export class LoaderState {
204
218
  writable: true,
205
219
  value: new Map()
206
220
  });
207
- Object.defineProperty(this, "tag", {
208
- enumerable: true,
209
- configurable: true,
210
- writable: true,
211
- value: void 0
212
- });
213
- Object.defineProperty(this, "anchor", {
214
- enumerable: true,
215
- configurable: true,
216
- writable: true,
217
- value: void 0
218
- });
219
- Object.defineProperty(this, "kind", {
220
- enumerable: true,
221
- configurable: true,
222
- writable: true,
223
- value: void 0
224
- });
225
- Object.defineProperty(this, "result", {
226
- enumerable: true,
227
- configurable: true,
228
- writable: true,
229
- value: ""
230
- });
231
221
  this.input = input;
232
222
  this.onWarning = onWarning;
233
223
  this.allowDuplicateKeys = allowDuplicateKeys;
@@ -320,17 +310,14 @@ export class LoaderState {
320
310
  else if (PATTERN_NON_PRINTABLE.test(result)) {
321
311
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Stream contains non-printable characters");
322
312
  }
323
- this.result += result;
313
+ return result;
324
314
  }
325
315
  }
326
- readBlockSequence(nodeIndent) {
316
+ readBlockSequence(tag, anchor, nodeIndent) {
327
317
  let detected = false;
328
- const tag = this.tag;
329
- const anchor = this.anchor;
330
318
  const result = [];
331
- if (this.anchor !== null && typeof this.anchor !== "undefined") {
332
- this.anchorMap.set(this.anchor, result);
333
- }
319
+ if (anchor !== null)
320
+ this.anchorMap.set(anchor, result);
334
321
  let ch = this.peek();
335
322
  while (ch !== 0) {
336
323
  if (ch !== MINUS) {
@@ -350,13 +337,14 @@ export class LoaderState {
350
337
  }
351
338
  }
352
339
  const line = this.line;
353
- this.composeNode({
340
+ const newState = this.composeNode({
354
341
  parentIndent: nodeIndent,
355
342
  nodeContext: CONTEXT_BLOCK_IN,
356
343
  allowToSeek: false,
357
344
  allowCompact: true,
358
345
  });
359
- result.push(this.result);
346
+ if (newState)
347
+ result.push(newState.result);
360
348
  this.skipSeparationSpace(true, -1);
361
349
  ch = this.peek();
362
350
  if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) {
@@ -366,14 +354,8 @@ export class LoaderState {
366
354
  break;
367
355
  }
368
356
  }
369
- if (detected) {
370
- this.tag = tag;
371
- this.anchor = anchor;
372
- this.kind = "sequence";
373
- this.result = result;
374
- return true;
375
- }
376
- return false;
357
+ if (detected)
358
+ return { tag, anchor, kind: "sequence", result };
377
359
  }
378
360
  mergeMappings(destination, source, overridableKeys) {
379
361
  if (!isObject(source)) {
@@ -501,17 +483,7 @@ export class LoaderState {
501
483
  }
502
484
  return false;
503
485
  }
504
- writeFoldedLines(count) {
505
- if (count === 1) {
506
- this.result += " ";
507
- }
508
- else if (count > 1) {
509
- this.result += "\n".repeat(count - 1);
510
- }
511
- }
512
- readPlainScalar(nodeIndent, withinFlowCollection) {
513
- const kind = this.kind;
514
- const result = this.result;
486
+ readPlainScalar(tag, anchor, nodeIndent, withinFlowCollection) {
515
487
  let ch = this.peek();
516
488
  if (isWhiteSpaceOrEOL(ch) ||
517
489
  isFlowIndicator(ch) ||
@@ -526,18 +498,17 @@ export class LoaderState {
526
498
  ch === PERCENT ||
527
499
  ch === COMMERCIAL_AT ||
528
500
  ch === GRAVE_ACCENT) {
529
- return false;
501
+ return;
530
502
  }
531
503
  let following;
532
504
  if (ch === QUESTION || ch === MINUS) {
533
505
  following = this.peek(1);
534
506
  if (isWhiteSpaceOrEOL(following) ||
535
507
  (withinFlowCollection && isFlowIndicator(following))) {
536
- return false;
508
+ return;
537
509
  }
538
510
  }
539
- this.kind = "scalar";
540
- this.result = "";
511
+ let result = "";
541
512
  let captureEnd = this.position;
542
513
  let captureStart = this.position;
543
514
  let hasPendingContent = false;
@@ -579,8 +550,10 @@ export class LoaderState {
579
550
  }
580
551
  }
581
552
  if (hasPendingContent) {
582
- this.captureSegment(captureStart, captureEnd, false);
583
- this.writeFoldedLines(this.line - line);
553
+ const segment = this.captureSegment(captureStart, captureEnd, false);
554
+ if (segment)
555
+ result += segment;
556
+ result += writeFoldedLines(this.line - line);
584
557
  captureStart = captureEnd = this.position;
585
558
  hasPendingContent = false;
586
559
  }
@@ -589,28 +562,28 @@ export class LoaderState {
589
562
  }
590
563
  ch = this.next();
591
564
  }
592
- this.captureSegment(captureStart, captureEnd, false);
593
- if (this.result) {
594
- return true;
595
- }
596
- this.kind = kind;
597
- this.result = result;
598
- return false;
565
+ const segment = this.captureSegment(captureStart, captureEnd, false);
566
+ if (segment)
567
+ result += segment;
568
+ if (anchor !== null)
569
+ this.anchorMap.set(anchor, result);
570
+ if (result)
571
+ return { tag, anchor, kind: "scalar", result };
599
572
  }
600
- readSingleQuotedScalar(nodeIndent) {
573
+ readSingleQuotedScalar(tag, anchor, nodeIndent) {
601
574
  let ch = this.peek();
602
- if (ch !== SINGLE_QUOTE) {
603
- return false;
604
- }
605
- this.kind = "scalar";
606
- this.result = "";
575
+ if (ch !== SINGLE_QUOTE)
576
+ return;
577
+ let result = "";
607
578
  this.position++;
608
579
  let captureStart = this.position;
609
580
  let captureEnd = this.position;
610
581
  ch = this.peek();
611
582
  while (ch !== 0) {
612
583
  if (ch === SINGLE_QUOTE) {
613
- this.captureSegment(captureStart, this.position, true);
584
+ const segment = this.captureSegment(captureStart, this.position, true);
585
+ if (segment)
586
+ result += segment;
614
587
  ch = this.next();
615
588
  if (ch === SINGLE_QUOTE) {
616
589
  captureStart = this.position;
@@ -618,12 +591,16 @@ export class LoaderState {
618
591
  captureEnd = this.position;
619
592
  }
620
593
  else {
621
- return true;
594
+ if (anchor !== null)
595
+ this.anchorMap.set(anchor, result);
596
+ return { tag, anchor, kind: "scalar", result };
622
597
  }
623
598
  }
624
599
  else if (isEOL(ch)) {
625
- this.captureSegment(captureStart, captureEnd, true);
626
- this.writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
600
+ const segment = this.captureSegment(captureStart, captureEnd, true);
601
+ if (segment)
602
+ result += segment;
603
+ result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
627
604
  captureStart = captureEnd = this.position;
628
605
  }
629
606
  else if (this.position === this.lineStart &&
@@ -638,13 +615,11 @@ export class LoaderState {
638
615
  }
639
616
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Unexpected end of the stream within a single quoted scalar");
640
617
  }
641
- readDoubleQuotedScalar(nodeIndent) {
618
+ readDoubleQuotedScalar(tag, anchor, nodeIndent) {
642
619
  let ch = this.peek();
643
- if (ch !== DOUBLE_QUOTE) {
644
- return false;
645
- }
646
- this.kind = "scalar";
647
- this.result = "";
620
+ if (ch !== DOUBLE_QUOTE)
621
+ return;
622
+ let result = "";
648
623
  this.position++;
649
624
  let captureEnd = this.position;
650
625
  let captureStart = this.position;
@@ -652,18 +627,24 @@ export class LoaderState {
652
627
  ch = this.peek();
653
628
  while (ch !== 0) {
654
629
  if (ch === DOUBLE_QUOTE) {
655
- this.captureSegment(captureStart, this.position, true);
630
+ const segment = this.captureSegment(captureStart, this.position, true);
631
+ if (segment)
632
+ result += segment;
656
633
  this.position++;
657
- return true;
634
+ if (anchor !== null)
635
+ this.anchorMap.set(anchor, result);
636
+ return { tag, anchor, kind: "scalar", result };
658
637
  }
659
638
  if (ch === BACKSLASH) {
660
- this.captureSegment(captureStart, this.position, true);
639
+ const segment = this.captureSegment(captureStart, this.position, true);
640
+ if (segment)
641
+ result += segment;
661
642
  ch = this.next();
662
643
  if (isEOL(ch)) {
663
644
  this.skipSeparationSpace(false, nodeIndent);
664
645
  }
665
646
  else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) {
666
- this.result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
647
+ result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
667
648
  this.position++;
668
649
  }
669
650
  else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) {
@@ -678,7 +659,7 @@ export class LoaderState {
678
659
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read double quoted scalar: expected hexadecimal character");
679
660
  }
680
661
  }
681
- this.result += codepointToChar(hexResult);
662
+ result += codepointToChar(hexResult);
682
663
  this.position++;
683
664
  }
684
665
  else {
@@ -687,8 +668,10 @@ export class LoaderState {
687
668
  captureStart = captureEnd = this.position;
688
669
  }
689
670
  else if (isEOL(ch)) {
690
- this.captureSegment(captureStart, captureEnd, true);
691
- this.writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
671
+ const segment = this.captureSegment(captureStart, captureEnd, true);
672
+ if (segment)
673
+ result += segment;
674
+ result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
692
675
  captureStart = captureEnd = this.position;
693
676
  }
694
677
  else if (this.position === this.lineStart &&
@@ -703,7 +686,7 @@ export class LoaderState {
703
686
  }
704
687
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Unexpected end of the stream within a double quoted scalar");
705
688
  }
706
- readFlowCollection(nodeIndent) {
689
+ readFlowCollection(tag, anchor, nodeIndent) {
707
690
  let ch = this.peek();
708
691
  let terminator;
709
692
  let isMapping = true;
@@ -717,14 +700,11 @@ export class LoaderState {
717
700
  terminator = RIGHT_CURLY_BRACKET;
718
701
  }
719
702
  else {
720
- return false;
721
- }
722
- if (this.anchor !== null && typeof this.anchor !== "undefined") {
723
- this.anchorMap.set(this.anchor, result);
703
+ return;
724
704
  }
705
+ if (anchor !== null)
706
+ this.anchorMap.set(anchor, result);
725
707
  ch = this.next();
726
- const tag = this.tag;
727
- const anchor = this.anchor;
728
708
  let readNext = true;
729
709
  let valueNode = null;
730
710
  let keyNode = null;
@@ -739,11 +719,8 @@ export class LoaderState {
739
719
  ch = this.peek();
740
720
  if (ch === terminator) {
741
721
  this.position++;
742
- this.tag = tag;
743
- this.anchor = anchor;
744
- this.kind = isMapping ? "mapping" : "sequence";
745
- this.result = result;
746
- return true;
722
+ const kind = isMapping ? "mapping" : "sequence";
723
+ return { tag, anchor, kind, result };
747
724
  }
748
725
  if (!readNext) {
749
726
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read flow collection: missing comma between flow collection entries");
@@ -759,27 +736,30 @@ export class LoaderState {
759
736
  }
760
737
  }
761
738
  line = this.line;
762
- this.composeNode({
739
+ const newState = this.composeNode({
763
740
  parentIndent: nodeIndent,
764
741
  nodeContext: CONTEXT_FLOW_IN,
765
742
  allowToSeek: false,
766
743
  allowCompact: true,
767
744
  });
768
- keyTag = this.tag || null;
769
- keyNode = this.result;
745
+ if (newState) {
746
+ keyTag = newState.tag || null;
747
+ keyNode = newState.result;
748
+ }
770
749
  this.skipSeparationSpace(true, nodeIndent);
771
750
  ch = this.peek();
772
751
  if ((isExplicitPair || this.line === line) && ch === COLON) {
773
752
  isPair = true;
774
753
  ch = this.next();
775
754
  this.skipSeparationSpace(true, nodeIndent);
776
- this.composeNode({
755
+ const newState = this.composeNode({
777
756
  parentIndent: nodeIndent,
778
757
  nodeContext: CONTEXT_FLOW_IN,
779
758
  allowToSeek: false,
780
759
  allowCompact: true,
781
760
  });
782
- valueNode = this.result;
761
+ if (newState)
762
+ valueNode = newState.result;
783
763
  }
784
764
  if (isMapping) {
785
765
  this.storeMappingPair(result, overridableKeys, keyTag, keyNode, valueNode);
@@ -804,7 +784,7 @@ export class LoaderState {
804
784
  }
805
785
  // Handles block scaler styles: e.g. '|', '>', '|-' and '>-'.
806
786
  // https://yaml.org/spec/1.2.2/#81-block-scalar-styles
807
- readBlockScalar(nodeIndent) {
787
+ readBlockScalar(tag, anchor, nodeIndent) {
808
788
  let chomping = CHOMPING_CLIP;
809
789
  let didReadContent = false;
810
790
  let detectedIndent = false;
@@ -820,10 +800,9 @@ export class LoaderState {
820
800
  folding = true;
821
801
  }
822
802
  else {
823
- return false;
803
+ return;
824
804
  }
825
- this.kind = "scalar";
826
- this.result = "";
805
+ let result = "";
827
806
  let tmp = 0;
828
807
  while (ch !== 0) {
829
808
  ch = this.next();
@@ -876,12 +855,12 @@ export class LoaderState {
876
855
  if (this.lineIndent < textIndent) {
877
856
  // Perform the chomping.
878
857
  if (chomping === CHOMPING_KEEP) {
879
- this.result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
858
+ result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
880
859
  }
881
860
  else if (chomping === CHOMPING_CLIP) {
882
861
  if (didReadContent) {
883
862
  // i.e. only if the scalar is not empty.
884
- this.result += "\n";
863
+ result += "\n";
885
864
  }
886
865
  }
887
866
  // Break this `while` cycle and go to the function's epilogue.
@@ -893,29 +872,29 @@ export class LoaderState {
893
872
  if (isWhiteSpace(ch)) {
894
873
  atMoreIndented = true;
895
874
  // except for the first content line (cf. Example 8.1)
896
- this.result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
875
+ result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
897
876
  // End of more-indented block.
898
877
  }
899
878
  else if (atMoreIndented) {
900
879
  atMoreIndented = false;
901
- this.result += "\n".repeat(emptyLines + 1);
880
+ result += "\n".repeat(emptyLines + 1);
902
881
  // Just one line break - perceive as the same line.
903
882
  }
904
883
  else if (emptyLines === 0) {
905
884
  if (didReadContent) {
906
885
  // i.e. only if we have already read some scalar content.
907
- this.result += " ";
886
+ result += " ";
908
887
  }
909
888
  // Several line breaks - perceive as different lines.
910
889
  }
911
890
  else {
912
- this.result += "\n".repeat(emptyLines);
891
+ result += "\n".repeat(emptyLines);
913
892
  }
914
893
  // Literal style: just add exact number of line breaks between content lines.
915
894
  }
916
895
  else {
917
896
  // Keep all line breaks except the header line break.
918
- this.result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
897
+ result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
919
898
  }
920
899
  didReadContent = true;
921
900
  detectedIndent = true;
@@ -924,13 +903,15 @@ export class LoaderState {
924
903
  while (!isEOL(ch) && ch !== 0) {
925
904
  ch = this.next();
926
905
  }
927
- this.captureSegment(captureStart, this.position, false);
906
+ const segment = this.captureSegment(captureStart, this.position, false);
907
+ if (segment)
908
+ result += segment;
928
909
  }
929
- return true;
910
+ if (anchor !== null)
911
+ this.anchorMap.set(anchor, result);
912
+ return { tag, anchor, kind: "scalar", result };
930
913
  }
931
- readBlockMapping(nodeIndent, flowIndent) {
932
- const tag = this.tag;
933
- const anchor = this.anchor;
914
+ readBlockMapping(tag, anchor, nodeIndent, flowIndent) {
934
915
  const result = {};
935
916
  const overridableKeys = new Set();
936
917
  let allowCompact = false;
@@ -941,9 +922,8 @@ export class LoaderState {
941
922
  let valueNode = null;
942
923
  let atExplicitKey = false;
943
924
  let detected = false;
944
- if (this.anchor !== null && typeof this.anchor !== "undefined") {
945
- this.anchorMap.set(this.anchor, result);
946
- }
925
+ if (anchor !== null)
926
+ this.anchorMap.set(anchor, result);
947
927
  let ch = this.peek();
948
928
  while (ch !== 0) {
949
929
  const following = this.peek(1);
@@ -979,12 +959,15 @@ export class LoaderState {
979
959
  // Implicit notation case. Flow-style node as the key first, then ":", and the value.
980
960
  //
981
961
  }
982
- else if (this.composeNode({
983
- parentIndent: flowIndent,
984
- nodeContext: CONTEXT_FLOW_OUT,
985
- allowToSeek: false,
986
- allowCompact: true,
987
- })) {
962
+ else {
963
+ const newState = this.composeNode({
964
+ parentIndent: flowIndent,
965
+ nodeContext: CONTEXT_FLOW_OUT,
966
+ allowToSeek: false,
967
+ allowCompact: true,
968
+ });
969
+ if (!newState)
970
+ break; // Reading is done. Go to the epilogue.
988
971
  if (this.line === line) {
989
972
  ch = this.peek();
990
973
  this.skipWhitespaces();
@@ -1003,45 +986,41 @@ export class LoaderState {
1003
986
  detected = true;
1004
987
  atExplicitKey = false;
1005
988
  allowCompact = false;
1006
- keyTag = this.tag;
1007
- keyNode = this.result;
989
+ keyTag = newState.tag;
990
+ keyNode = newState.result;
1008
991
  }
1009
992
  else if (detected) {
1010
993
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read an implicit mapping pair: missing colon");
1011
994
  }
1012
995
  else {
1013
- this.tag = tag;
1014
- this.anchor = anchor;
1015
- return true; // Keep the result of `composeNode`.
996
+ const { kind, result } = newState;
997
+ return { tag, anchor, kind, result }; // Keep the result of `composeNode`.
1016
998
  }
1017
999
  }
1018
1000
  else if (detected) {
1019
1001
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read a block mapping entry: a multiline key may not be an implicit key");
1020
1002
  }
1021
1003
  else {
1022
- this.tag = tag;
1023
- this.anchor = anchor;
1024
- return true; // Keep the result of `composeNode`.
1004
+ const { kind, result } = newState;
1005
+ return { tag, anchor, kind, result }; // Keep the result of `composeNode`.
1025
1006
  }
1026
1007
  }
1027
- else {
1028
- break; // Reading is done. Go to the epilogue.
1029
- }
1030
1008
  //
1031
1009
  // Common reading code for both explicit and implicit notations.
1032
1010
  //
1033
1011
  if (this.line === line || this.lineIndent > nodeIndent) {
1034
- if (this.composeNode({
1012
+ const newState = this.composeNode({
1035
1013
  parentIndent: nodeIndent,
1036
1014
  nodeContext: CONTEXT_BLOCK_OUT,
1037
1015
  allowToSeek: true,
1038
1016
  allowCompact,
1039
- })) {
1017
+ });
1018
+ if (newState) {
1040
1019
  if (atExplicitKey) {
1041
- keyNode = this.result;
1020
+ keyNode = newState.result;
1042
1021
  }
1043
1022
  else {
1044
- valueNode = this.result;
1023
+ valueNode = newState.result;
1045
1024
  }
1046
1025
  }
1047
1026
  if (!atExplicitKey) {
@@ -1066,23 +1045,18 @@ export class LoaderState {
1066
1045
  this.storeMappingPair(result, overridableKeys, keyTag, keyNode, null);
1067
1046
  }
1068
1047
  // Expose the resulting mapping.
1069
- if (detected) {
1070
- this.tag = tag;
1071
- this.anchor = anchor;
1072
- this.kind = "mapping";
1073
- this.result = result;
1074
- }
1075
- return detected;
1048
+ if (detected)
1049
+ return { tag, anchor, kind: "mapping", result };
1076
1050
  }
1077
- readTagProperty() {
1051
+ readTagProperty(tag) {
1078
1052
  let isVerbatim = false;
1079
1053
  let isNamed = false;
1080
1054
  let tagHandle = "";
1081
1055
  let tagName;
1082
1056
  let ch = this.peek();
1083
1057
  if (ch !== EXCLAMATION)
1084
- return false;
1085
- if (this.tag !== null) {
1058
+ return;
1059
+ if (tag !== null) {
1086
1060
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read tag property: duplication of a tag property");
1087
1061
  }
1088
1062
  ch = this.next();
@@ -1137,27 +1111,24 @@ export class LoaderState {
1137
1111
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Cannot read tag property: invalid characters in tag name "${tagName}"`);
1138
1112
  }
1139
1113
  if (isVerbatim) {
1140
- this.tag = tagName;
1114
+ return tagName;
1141
1115
  }
1142
1116
  else if (this.tagMap.has(tagHandle)) {
1143
- this.tag = this.tagMap.get(tagHandle) + tagName;
1117
+ return this.tagMap.get(tagHandle) + tagName;
1144
1118
  }
1145
1119
  else if (tagHandle === "!") {
1146
- this.tag = `!${tagName}`;
1120
+ return `!${tagName}`;
1147
1121
  }
1148
1122
  else if (tagHandle === "!!") {
1149
- this.tag = `tag:yaml.org,2002:${tagName}`;
1150
- }
1151
- else {
1152
- throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Cannot read tag property: undeclared tag handle "${tagHandle}"`);
1123
+ return `tag:yaml.org,2002:${tagName}`;
1153
1124
  }
1154
- return true;
1125
+ throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Cannot read tag property: undeclared tag handle "${tagHandle}"`);
1155
1126
  }
1156
- readAnchorProperty() {
1127
+ readAnchorProperty(anchor) {
1157
1128
  let ch = this.peek();
1158
1129
  if (ch !== AMPERSAND)
1159
- return false;
1160
- if (this.anchor !== null) {
1130
+ return;
1131
+ if (anchor !== null) {
1161
1132
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read anchor property: duplicate anchor property");
1162
1133
  }
1163
1134
  ch = this.next();
@@ -1168,12 +1139,11 @@ export class LoaderState {
1168
1139
  if (this.position === position) {
1169
1140
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read anchor property: name of an anchor node must contain at least one character");
1170
1141
  }
1171
- this.anchor = this.input.slice(position, this.position);
1172
- return true;
1142
+ return this.input.slice(position, this.position);
1173
1143
  }
1174
1144
  readAlias() {
1175
1145
  if (this.peek() !== ASTERISK)
1176
- return false;
1146
+ return;
1177
1147
  let ch = this.next();
1178
1148
  const position = this.position;
1179
1149
  while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
@@ -1186,19 +1156,56 @@ export class LoaderState {
1186
1156
  if (!this.anchorMap.has(alias)) {
1187
1157
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Cannot read alias: unidentified alias "${alias}"`);
1188
1158
  }
1189
- this.result = this.anchorMap.get(alias);
1190
1159
  this.skipSeparationSpace(true, -1);
1191
- return true;
1160
+ return this.anchorMap.get(alias);
1161
+ }
1162
+ resolveTag(state) {
1163
+ switch (state.tag) {
1164
+ case null:
1165
+ case "!":
1166
+ return state;
1167
+ case "?": {
1168
+ for (const type of this.implicitTypes) {
1169
+ // Implicit resolving is not allowed for non-scalar types, and '?'
1170
+ // non-specific tag is only assigned to plain scalars. So, it isn't
1171
+ // needed to check for 'kind' conformity.
1172
+ if (!type.resolve(state.result))
1173
+ continue;
1174
+ // `state.result` updated in resolver if matched
1175
+ const result = type.construct(state.result);
1176
+ state.result = result;
1177
+ state.tag = type.tag;
1178
+ const { anchor } = state;
1179
+ if (anchor !== null)
1180
+ this.anchorMap.set(anchor, result);
1181
+ return state;
1182
+ }
1183
+ return state;
1184
+ }
1185
+ }
1186
+ const kind = state.kind ?? "fallback";
1187
+ const map = this.typeMap[kind];
1188
+ const type = map.get(state.tag);
1189
+ if (!type) {
1190
+ throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Cannot resolve unknown tag !<${state.tag}>`);
1191
+ }
1192
+ if (state.result !== null && type.kind !== state.kind) {
1193
+ throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Unacceptable node kind for !<${state.tag}> tag: it should be "${type.kind}", not "${state.kind}"`);
1194
+ }
1195
+ if (!type.resolve(state.result)) {
1196
+ // `state.result` updated in resolver if matched
1197
+ throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Cannot resolve a node with !<${state.tag}> explicit tag`);
1198
+ }
1199
+ const result = type.construct(state.result);
1200
+ state.result = result;
1201
+ const { anchor } = state;
1202
+ if (anchor !== null)
1203
+ this.anchorMap.set(anchor, result);
1204
+ return state;
1192
1205
  }
1193
1206
  composeNode({ parentIndent, nodeContext, allowToSeek, allowCompact }) {
1194
1207
  let indentStatus = 1; // 1: this>parent, 0: this=parent, -1: this<parent
1195
1208
  let atNewLine = false;
1196
- let hasContent = false;
1197
- let type;
1198
- this.tag = null;
1199
- this.anchor = null;
1200
- this.kind = null;
1201
- this.result = null;
1202
1209
  const allowBlockScalars = CONTEXT_BLOCK_OUT === nodeContext ||
1203
1210
  CONTEXT_BLOCK_IN === nodeContext;
1204
1211
  let allowBlockCollections = allowBlockScalars;
@@ -1206,31 +1213,27 @@ export class LoaderState {
1206
1213
  if (allowToSeek) {
1207
1214
  if (this.skipSeparationSpace(true, -1)) {
1208
1215
  atNewLine = true;
1209
- if (this.lineIndent > parentIndent) {
1210
- indentStatus = 1;
1211
- }
1212
- else if (this.lineIndent === parentIndent) {
1213
- indentStatus = 0;
1214
- }
1215
- else if (this.lineIndent < parentIndent) {
1216
- indentStatus = -1;
1217
- }
1216
+ indentStatus = getIndentStatus(this.lineIndent, parentIndent);
1218
1217
  }
1219
1218
  }
1219
+ let tag = null;
1220
+ let anchor = null;
1220
1221
  if (indentStatus === 1) {
1221
- while (this.readTagProperty() || this.readAnchorProperty()) {
1222
+ while (true) {
1223
+ const newTag = this.readTagProperty(tag);
1224
+ if (newTag) {
1225
+ tag = newTag;
1226
+ }
1227
+ else {
1228
+ const newAnchor = this.readAnchorProperty(anchor);
1229
+ if (!newAnchor)
1230
+ break;
1231
+ anchor = newAnchor;
1232
+ }
1222
1233
  if (this.skipSeparationSpace(true, -1)) {
1223
1234
  atNewLine = true;
1224
1235
  allowBlockCollections = allowBlockStyles;
1225
- if (this.lineIndent > parentIndent) {
1226
- indentStatus = 1;
1227
- }
1228
- else if (this.lineIndent === parentIndent) {
1229
- indentStatus = 0;
1230
- }
1231
- else if (this.lineIndent < parentIndent) {
1232
- indentStatus = -1;
1233
- }
1236
+ indentStatus = getIndentStatus(this.lineIndent, parentIndent);
1234
1237
  }
1235
1238
  else {
1236
1239
  allowBlockCollections = false;
@@ -1240,88 +1243,59 @@ export class LoaderState {
1240
1243
  if (allowBlockCollections) {
1241
1244
  allowBlockCollections = atNewLine || allowCompact;
1242
1245
  }
1243
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1246
+ if (indentStatus === 1) {
1244
1247
  const cond = CONTEXT_FLOW_IN === nodeContext ||
1245
1248
  CONTEXT_FLOW_OUT === nodeContext;
1246
1249
  const flowIndent = cond ? parentIndent : parentIndent + 1;
1247
- const blockIndent = this.position - this.lineStart;
1248
- if (indentStatus === 1) {
1249
- if ((allowBlockCollections &&
1250
- (this.readBlockSequence(blockIndent) ||
1251
- this.readBlockMapping(blockIndent, flowIndent))) ||
1252
- this.readFlowCollection(flowIndent)) {
1253
- hasContent = true;
1254
- }
1255
- else {
1256
- if ((allowBlockScalars && this.readBlockScalar(flowIndent)) ||
1257
- this.readSingleQuotedScalar(flowIndent) ||
1258
- this.readDoubleQuotedScalar(flowIndent)) {
1259
- hasContent = true;
1260
- }
1261
- else if (this.readAlias()) {
1262
- hasContent = true;
1263
- if (this.tag !== null || this.anchor !== null) {
1264
- throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot compose node: alias node should not have any properties");
1265
- }
1266
- }
1267
- else if (this.readPlainScalar(flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1268
- hasContent = true;
1269
- if (this.tag === null) {
1270
- this.tag = "?";
1271
- }
1272
- }
1273
- if (this.anchor !== null) {
1274
- this.anchorMap.set(this.anchor, this.result);
1275
- }
1250
+ if (allowBlockCollections) {
1251
+ const blockIndent = this.position - this.lineStart;
1252
+ const blockSequenceState = this.readBlockSequence(tag, anchor, blockIndent);
1253
+ if (blockSequenceState)
1254
+ return this.resolveTag(blockSequenceState);
1255
+ const blockMappingState = this.readBlockMapping(tag, anchor, blockIndent, flowIndent);
1256
+ if (blockMappingState)
1257
+ return this.resolveTag(blockMappingState);
1258
+ }
1259
+ const flowCollectionState = this.readFlowCollection(tag, anchor, flowIndent);
1260
+ if (flowCollectionState)
1261
+ return this.resolveTag(flowCollectionState);
1262
+ if (allowBlockScalars) {
1263
+ const blockScalarState = this.readBlockScalar(tag, anchor, flowIndent);
1264
+ if (blockScalarState)
1265
+ return this.resolveTag(blockScalarState);
1266
+ }
1267
+ const singleQuoteState = this.readSingleQuotedScalar(tag, anchor, flowIndent);
1268
+ if (singleQuoteState)
1269
+ return this.resolveTag(singleQuoteState);
1270
+ const doubleQuoteState = this.readDoubleQuotedScalar(tag, anchor, flowIndent);
1271
+ if (doubleQuoteState)
1272
+ return this.resolveTag(doubleQuoteState);
1273
+ const alias = this.readAlias();
1274
+ if (alias) {
1275
+ if (tag !== null || anchor !== null) {
1276
+ throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot compose node: alias node should not have any properties");
1276
1277
  }
1278
+ return this.resolveTag({ tag, anchor, kind: null, result: alias });
1277
1279
  }
1278
- else if (indentStatus === 0) {
1279
- // Special case: block sequences are allowed to have same indentation level as the parent.
1280
- // http://www.yaml.org/spec/1.2/spec.html#id2799784
1281
- hasContent = allowBlockCollections &&
1282
- this.readBlockSequence(blockIndent);
1280
+ const plainScalarState = this.readPlainScalar(tag, anchor, flowIndent, CONTEXT_FLOW_IN === nodeContext);
1281
+ if (plainScalarState) {
1282
+ plainScalarState.tag ??= "?";
1283
+ return this.resolveTag(plainScalarState);
1283
1284
  }
1284
1285
  }
1285
- if (this.tag !== null && this.tag !== "!") {
1286
- if (this.tag === "?") {
1287
- for (let typeIndex = 0; typeIndex < this.implicitTypes.length; typeIndex++) {
1288
- type = this.implicitTypes[typeIndex];
1289
- // Implicit resolving is not allowed for non-scalar types, and '?'
1290
- // non-specific tag is only assigned to plain scalars. So, it isn't
1291
- // needed to check for 'kind' conformity.
1292
- if (type.resolve(this.result)) {
1293
- // `state.result` updated in resolver if matched
1294
- this.result = type.construct(this.result);
1295
- this.tag = type.tag;
1296
- if (this.anchor !== null) {
1297
- this.anchorMap.set(this.anchor, this.result);
1298
- }
1299
- break;
1300
- }
1301
- }
1302
- }
1303
- else if (this.typeMap[this.kind ?? "fallback"].has(this.tag)) {
1304
- const map = this.typeMap[this.kind ?? "fallback"];
1305
- type = map.get(this.tag);
1306
- if (this.result !== null && type.kind !== this.kind) {
1307
- throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Unacceptable node kind for !<${this.tag}> tag: it should be "${type.kind}", not "${this.kind}"`);
1308
- }
1309
- if (!type.resolve(this.result)) {
1310
- // `state.result` updated in resolver if matched
1311
- throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Cannot resolve a node with !<${this.tag}> explicit tag`);
1312
- }
1313
- else {
1314
- this.result = type.construct(this.result);
1315
- if (this.anchor !== null) {
1316
- this.anchorMap.set(this.anchor, this.result);
1317
- }
1318
- }
1319
- }
1320
- else {
1321
- throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, `Cannot resolve unknown tag !<${this.tag}>`);
1322
- }
1286
+ else if (indentStatus === 0 &&
1287
+ CONTEXT_BLOCK_OUT === nodeContext &&
1288
+ allowBlockCollections) {
1289
+ // Special case: block sequences are allowed to have same indentation level as the parent.
1290
+ // http://www.yaml.org/spec/1.2/spec.html#id2799784
1291
+ const blockIndent = this.position - this.lineStart;
1292
+ const newState = this.readBlockSequence(tag, anchor, blockIndent);
1293
+ if (newState)
1294
+ return this.resolveTag(newState);
1323
1295
  }
1324
- return this.tag !== null || this.anchor !== null || hasContent;
1296
+ const newState = this.resolveTag({ tag, anchor, kind: null, result: null });
1297
+ if (newState.tag !== null || newState.anchor !== null)
1298
+ return newState;
1325
1299
  }
1326
1300
  readDirectives() {
1327
1301
  let hasDirectives = false;
@@ -1383,6 +1357,7 @@ export class LoaderState {
1383
1357
  this.anchorMap = new Map();
1384
1358
  const hasDirectives = this.readDirectives();
1385
1359
  this.skipSeparationSpace(true, -1);
1360
+ let result = null;
1386
1361
  if (this.lineIndent === 0 &&
1387
1362
  this.peek() === MINUS &&
1388
1363
  this.peek(1) === MINUS &&
@@ -1393,12 +1368,14 @@ export class LoaderState {
1393
1368
  else if (hasDirectives) {
1394
1369
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read document: directives end mark is expected");
1395
1370
  }
1396
- this.composeNode({
1371
+ const newState = this.composeNode({
1397
1372
  parentIndent: this.lineIndent - 1,
1398
1373
  nodeContext: CONTEXT_BLOCK_OUT,
1399
1374
  allowToSeek: false,
1400
1375
  allowCompact: true,
1401
1376
  });
1377
+ if (newState)
1378
+ result = newState.result;
1402
1379
  this.skipSeparationSpace(true, -1);
1403
1380
  if (this.checkLineBreaks &&
1404
1381
  PATTERN_NON_ASCII_LINE_BREAKS.test(this.input.slice(documentStart, this.position))) {
@@ -1413,7 +1390,7 @@ export class LoaderState {
1413
1390
  else if (this.position < this.length - 1) {
1414
1391
  throw __classPrivateFieldGet(this, _LoaderState_instances, "m", _LoaderState_createError).call(this, "Cannot read document: end of the stream or a document separator is expected");
1415
1392
  }
1416
- return this.result;
1393
+ return result;
1417
1394
  }
1418
1395
  *readDocuments() {
1419
1396
  while (this.position < this.length - 1) {