@emulsify/cli 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/README.md +131 -12
  2. package/dist/handlers/componentInstall.js +65 -4
  3. package/dist/index.js +2 -0
  4. package/dist/node_modules/.package-lock.json +6 -216
  5. package/dist/node_modules/@types/node/README.md +1 -1
  6. package/dist/node_modules/@types/node/http2.d.ts +1 -0
  7. package/dist/node_modules/@types/node/package.json +2 -2
  8. package/dist/package-lock.json +61 -42
  9. package/dist/package.json +5 -6
  10. package/dist/schemas/emulsifyProjectConfig.json +80 -0
  11. package/dist/util/fs/executeScript.js +10 -4
  12. package/dist/util/fs/loadJsonFile.js +14 -4
  13. package/dist/util/fs/safeResolveWithin.js +22 -0
  14. package/dist/util/getRepositoryLatestTag.js +96 -13
  15. package/dist/util/project/buildComponentDependencyList.js +35 -10
  16. package/dist/util/project/generateComponent.js +52 -23
  17. package/dist/util/project/getEmulsifyConfig.js +35 -1
  18. package/dist/util/project/installComponentFromCache.js +3 -2
  19. package/dist/util/project/installGeneralAssetsFromCache.js +4 -2
  20. package/dist/util/system/getAvailableSystems.js +0 -5
  21. package/package.json +5 -6
  22. package/dist/node_modules/@babel/code-frame/LICENSE +0 -22
  23. package/dist/node_modules/@babel/code-frame/README.md +0 -19
  24. package/dist/node_modules/@babel/code-frame/lib/index.js +0 -217
  25. package/dist/node_modules/@babel/code-frame/lib/index.js.map +0 -1
  26. package/dist/node_modules/@babel/code-frame/package.json +0 -32
  27. package/dist/node_modules/@babel/helper-validator-identifier/LICENSE +0 -22
  28. package/dist/node_modules/@babel/helper-validator-identifier/README.md +0 -19
  29. package/dist/node_modules/@babel/helper-validator-identifier/lib/identifier.js +0 -70
  30. package/dist/node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +0 -1
  31. package/dist/node_modules/@babel/helper-validator-identifier/lib/index.js +0 -57
  32. package/dist/node_modules/@babel/helper-validator-identifier/lib/index.js.map +0 -1
  33. package/dist/node_modules/@babel/helper-validator-identifier/lib/keyword.js +0 -35
  34. package/dist/node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +0 -1
  35. package/dist/node_modules/@babel/helper-validator-identifier/package.json +0 -31
  36. package/dist/node_modules/@types/progress/LICENSE +0 -21
  37. package/dist/node_modules/@types/progress/README.md +0 -15
  38. package/dist/node_modules/@types/progress/index.d.ts +0 -143
  39. package/dist/node_modules/@types/progress/package.json +0 -27
  40. package/dist/node_modules/argparse/CHANGELOG.md +0 -216
  41. package/dist/node_modules/argparse/LICENSE +0 -254
  42. package/dist/node_modules/argparse/README.md +0 -84
  43. package/dist/node_modules/argparse/argparse.js +0 -3707
  44. package/dist/node_modules/argparse/lib/sub.js +0 -67
  45. package/dist/node_modules/argparse/lib/textwrap.js +0 -440
  46. package/dist/node_modules/argparse/package.json +0 -31
  47. package/dist/node_modules/callsites/index.d.ts +0 -96
  48. package/dist/node_modules/callsites/index.js +0 -13
  49. package/dist/node_modules/callsites/license +0 -9
  50. package/dist/node_modules/callsites/package.json +0 -39
  51. package/dist/node_modules/callsites/readme.md +0 -48
  52. package/dist/node_modules/cosmiconfig/LICENSE +0 -22
  53. package/dist/node_modules/cosmiconfig/README.md +0 -782
  54. package/dist/node_modules/cosmiconfig/dist/Explorer.d.ts +0 -2
  55. package/dist/node_modules/cosmiconfig/dist/Explorer.js +0 -174
  56. package/dist/node_modules/cosmiconfig/dist/ExplorerBase.d.ts +0 -2
  57. package/dist/node_modules/cosmiconfig/dist/ExplorerBase.js +0 -126
  58. package/dist/node_modules/cosmiconfig/dist/ExplorerSync.d.ts +0 -2
  59. package/dist/node_modules/cosmiconfig/dist/ExplorerSync.js +0 -188
  60. package/dist/node_modules/cosmiconfig/dist/defaults.d.ts +0 -25
  61. package/dist/node_modules/cosmiconfig/dist/defaults.js +0 -105
  62. package/dist/node_modules/cosmiconfig/dist/index.d.ts +0 -6
  63. package/dist/node_modules/cosmiconfig/dist/index.js +0 -148
  64. package/dist/node_modules/cosmiconfig/dist/loaders.d.ts +0 -8
  65. package/dist/node_modules/cosmiconfig/dist/loaders.js +0 -150
  66. package/dist/node_modules/cosmiconfig/dist/merge.d.ts +0 -9
  67. package/dist/node_modules/cosmiconfig/dist/merge.js +0 -44
  68. package/dist/node_modules/cosmiconfig/dist/types.d.ts +0 -98
  69. package/dist/node_modules/cosmiconfig/dist/types.js +0 -3
  70. package/dist/node_modules/cosmiconfig/dist/util.d.ts +0 -2
  71. package/dist/node_modules/cosmiconfig/dist/util.js +0 -108
  72. package/dist/node_modules/cosmiconfig/package.json +0 -103
  73. package/dist/node_modules/env-paths/index.d.ts +0 -101
  74. package/dist/node_modules/env-paths/index.js +0 -74
  75. package/dist/node_modules/env-paths/license +0 -9
  76. package/dist/node_modules/env-paths/package.json +0 -45
  77. package/dist/node_modules/env-paths/readme.md +0 -115
  78. package/dist/node_modules/error-ex/LICENSE +0 -21
  79. package/dist/node_modules/error-ex/README.md +0 -144
  80. package/dist/node_modules/error-ex/index.js +0 -141
  81. package/dist/node_modules/error-ex/package.json +0 -46
  82. package/dist/node_modules/import-fresh/index.d.ts +0 -30
  83. package/dist/node_modules/import-fresh/index.js +0 -34
  84. package/dist/node_modules/import-fresh/license +0 -9
  85. package/dist/node_modules/import-fresh/node_modules/resolve-from/index.js +0 -47
  86. package/dist/node_modules/import-fresh/node_modules/resolve-from/license +0 -9
  87. package/dist/node_modules/import-fresh/node_modules/resolve-from/package.json +0 -34
  88. package/dist/node_modules/import-fresh/node_modules/resolve-from/readme.md +0 -72
  89. package/dist/node_modules/import-fresh/package.json +0 -48
  90. package/dist/node_modules/import-fresh/readme.md +0 -54
  91. package/dist/node_modules/is-arrayish/.editorconfig +0 -18
  92. package/dist/node_modules/is-arrayish/.istanbul.yml +0 -4
  93. package/dist/node_modules/is-arrayish/.travis.yml +0 -17
  94. package/dist/node_modules/is-arrayish/LICENSE +0 -21
  95. package/dist/node_modules/is-arrayish/README.md +0 -16
  96. package/dist/node_modules/is-arrayish/index.js +0 -10
  97. package/dist/node_modules/is-arrayish/package.json +0 -34
  98. package/dist/node_modules/js-tokens/CHANGELOG.md +0 -151
  99. package/dist/node_modules/js-tokens/LICENSE +0 -21
  100. package/dist/node_modules/js-tokens/README.md +0 -240
  101. package/dist/node_modules/js-tokens/index.js +0 -23
  102. package/dist/node_modules/js-tokens/package.json +0 -30
  103. package/dist/node_modules/js-yaml/LICENSE +0 -21
  104. package/dist/node_modules/js-yaml/README.md +0 -231
  105. package/dist/node_modules/js-yaml/bin/js-yaml.js +0 -117
  106. package/dist/node_modules/js-yaml/dist/js-yaml.js +0 -2404
  107. package/dist/node_modules/js-yaml/dist/js-yaml.js.map +0 -1
  108. package/dist/node_modules/js-yaml/dist/js-yaml.min.js +0 -33
  109. package/dist/node_modules/js-yaml/dist/js-yaml.min.js.map +0 -1
  110. package/dist/node_modules/js-yaml/dist/js-yaml.mjs +0 -2382
  111. package/dist/node_modules/js-yaml/dist/js-yaml.mjs.map +0 -1
  112. package/dist/node_modules/js-yaml/index.js +0 -44
  113. package/dist/node_modules/js-yaml/lib/common.js +0 -50
  114. package/dist/node_modules/js-yaml/lib/dumper.js +0 -937
  115. package/dist/node_modules/js-yaml/lib/exception.js +0 -51
  116. package/dist/node_modules/js-yaml/lib/index_vite_proxy.tmp.mjs +0 -37
  117. package/dist/node_modules/js-yaml/lib/loader.js +0 -1794
  118. package/dist/node_modules/js-yaml/lib/schema/core.js +0 -9
  119. package/dist/node_modules/js-yaml/lib/schema/default.js +0 -20
  120. package/dist/node_modules/js-yaml/lib/schema/failsafe.js +0 -14
  121. package/dist/node_modules/js-yaml/lib/schema/json.js +0 -17
  122. package/dist/node_modules/js-yaml/lib/schema.js +0 -109
  123. package/dist/node_modules/js-yaml/lib/snippet.js +0 -96
  124. package/dist/node_modules/js-yaml/lib/type/binary.js +0 -122
  125. package/dist/node_modules/js-yaml/lib/type/bool.js +0 -35
  126. package/dist/node_modules/js-yaml/lib/type/float.js +0 -99
  127. package/dist/node_modules/js-yaml/lib/type/int.js +0 -142
  128. package/dist/node_modules/js-yaml/lib/type/map.js +0 -8
  129. package/dist/node_modules/js-yaml/lib/type/merge.js +0 -12
  130. package/dist/node_modules/js-yaml/lib/type/null.js +0 -35
  131. package/dist/node_modules/js-yaml/lib/type/omap.js +0 -45
  132. package/dist/node_modules/js-yaml/lib/type/pairs.js +0 -50
  133. package/dist/node_modules/js-yaml/lib/type/seq.js +0 -8
  134. package/dist/node_modules/js-yaml/lib/type/set.js +0 -29
  135. package/dist/node_modules/js-yaml/lib/type/str.js +0 -8
  136. package/dist/node_modules/js-yaml/lib/type/timestamp.js +0 -88
  137. package/dist/node_modules/js-yaml/lib/type.js +0 -66
  138. package/dist/node_modules/js-yaml/package.json +0 -77
  139. package/dist/node_modules/json-parse-even-better-errors/CHANGELOG.md +0 -50
  140. package/dist/node_modules/json-parse-even-better-errors/LICENSE.md +0 -25
  141. package/dist/node_modules/json-parse-even-better-errors/README.md +0 -96
  142. package/dist/node_modules/json-parse-even-better-errors/index.js +0 -121
  143. package/dist/node_modules/json-parse-even-better-errors/package.json +0 -33
  144. package/dist/node_modules/lines-and-columns/LICENSE +0 -21
  145. package/dist/node_modules/lines-and-columns/README.md +0 -33
  146. package/dist/node_modules/lines-and-columns/build/index.d.ts +0 -13
  147. package/dist/node_modules/lines-and-columns/build/index.js +0 -62
  148. package/dist/node_modules/lines-and-columns/package.json +0 -49
  149. package/dist/node_modules/parent-module/index.js +0 -37
  150. package/dist/node_modules/parent-module/license +0 -9
  151. package/dist/node_modules/parent-module/package.json +0 -46
  152. package/dist/node_modules/parent-module/readme.md +0 -67
  153. package/dist/node_modules/parse-json/index.js +0 -54
  154. package/dist/node_modules/parse-json/license +0 -9
  155. package/dist/node_modules/parse-json/package.json +0 -45
  156. package/dist/node_modules/parse-json/readme.md +0 -119
  157. package/dist/node_modules/picocolors/LICENSE +0 -15
  158. package/dist/node_modules/picocolors/README.md +0 -21
  159. package/dist/node_modules/picocolors/package.json +0 -25
  160. package/dist/node_modules/picocolors/picocolors.browser.js +0 -4
  161. package/dist/node_modules/picocolors/picocolors.d.ts +0 -5
  162. package/dist/node_modules/picocolors/picocolors.js +0 -75
  163. package/dist/node_modules/picocolors/types.d.ts +0 -51
  164. package/dist/node_modules/typescript/LICENSE.txt +0 -55
  165. package/dist/node_modules/typescript/README.md +0 -50
  166. package/dist/node_modules/typescript/SECURITY.md +0 -39
  167. package/dist/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
  168. package/dist/node_modules/typescript/bin/tsc +0 -2
  169. package/dist/node_modules/typescript/bin/tsserver +0 -2
  170. package/dist/node_modules/typescript/lib/_tsc.js +0 -134465
  171. package/dist/node_modules/typescript/lib/_tsserver.js +0 -659
  172. package/dist/node_modules/typescript/lib/_typingsInstaller.js +0 -222
  173. package/dist/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2129
  174. package/dist/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2125
  175. package/dist/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2129
  176. package/dist/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2129
  177. package/dist/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2125
  178. package/dist/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2129
  179. package/dist/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2129
  180. package/dist/node_modules/typescript/lib/lib.d.ts +0 -20
  181. package/dist/node_modules/typescript/lib/lib.decorators.d.ts +0 -382
  182. package/dist/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -20
  183. package/dist/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -18
  184. package/dist/node_modules/typescript/lib/lib.dom.d.ts +0 -45125
  185. package/dist/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -18
  186. package/dist/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -150
  187. package/dist/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -595
  188. package/dist/node_modules/typescript/lib/lib.es2015.d.ts +0 -26
  189. package/dist/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -75
  190. package/dist/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -603
  191. package/dist/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -79
  192. package/dist/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -126
  193. package/dist/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -142
  194. package/dist/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -44
  195. package/dist/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -324
  196. package/dist/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -114
  197. package/dist/node_modules/typescript/lib/lib.es2016.d.ts +0 -19
  198. package/dist/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -21
  199. package/dist/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -29
  200. package/dist/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -19
  201. package/dist/node_modules/typescript/lib/lib.es2017.d.ts +0 -24
  202. package/dist/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -29
  203. package/dist/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -21
  204. package/dist/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -42
  205. package/dist/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -47
  206. package/dist/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -133
  207. package/dist/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -43
  208. package/dist/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -51
  209. package/dist/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -75
  210. package/dist/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -51
  211. package/dist/node_modules/typescript/lib/lib.es2018.d.ts +0 -22
  212. package/dist/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -22
  213. package/dist/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -81
  214. package/dist/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -28
  215. package/dist/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -35
  216. package/dist/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -77
  217. package/dist/node_modules/typescript/lib/lib.es2019.d.ts +0 -22
  218. package/dist/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -22
  219. package/dist/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -21
  220. package/dist/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -31
  221. package/dist/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -35
  222. package/dist/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -22
  223. package/dist/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -763
  224. package/dist/node_modules/typescript/lib/lib.es2020.d.ts +0 -25
  225. package/dist/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -40
  226. package/dist/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -22
  227. package/dist/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -472
  228. package/dist/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -26
  229. package/dist/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -45
  230. package/dist/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -97
  231. package/dist/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -42
  232. package/dist/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -39
  233. package/dist/node_modules/typescript/lib/lib.es2021.d.ts +0 -21
  234. package/dist/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -22
  235. package/dist/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -164
  236. package/dist/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -46
  237. package/dist/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -31
  238. package/dist/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -76
  239. package/dist/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -119
  240. package/dist/node_modules/typescript/lib/lib.es2022.d.ts +0 -23
  241. package/dist/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -73
  242. package/dist/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -22
  243. package/dist/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -143
  244. package/dist/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -24
  245. package/dist/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -37
  246. package/dist/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -23
  247. package/dist/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -922
  248. package/dist/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -19
  249. package/dist/node_modules/typescript/lib/lib.es2023.d.ts +0 -20
  250. package/dist/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -22
  251. package/dist/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -62
  252. package/dist/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -63
  253. package/dist/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -27
  254. package/dist/node_modules/typescript/lib/lib.es2024.d.ts +0 -24
  255. package/dist/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -22
  256. package/dist/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -27
  257. package/dist/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -33
  258. package/dist/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -23
  259. package/dist/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -66
  260. package/dist/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -27
  261. package/dist/node_modules/typescript/lib/lib.es2025.collection.d.ts +0 -94
  262. package/dist/node_modules/typescript/lib/lib.es2025.d.ts +0 -23
  263. package/dist/node_modules/typescript/lib/lib.es2025.float16.d.ts +0 -443
  264. package/dist/node_modules/typescript/lib/lib.es2025.full.d.ts +0 -22
  265. package/dist/node_modules/typescript/lib/lib.es2025.intl.d.ts +0 -200
  266. package/dist/node_modules/typescript/lib/lib.es2025.iterator.d.ts +0 -146
  267. package/dist/node_modules/typescript/lib/lib.es2025.promise.d.ts +0 -32
  268. package/dist/node_modules/typescript/lib/lib.es2025.regexp.d.ts +0 -30
  269. package/dist/node_modules/typescript/lib/lib.es5.d.ts +0 -4599
  270. package/dist/node_modules/typescript/lib/lib.es6.d.ts +0 -21
  271. package/dist/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -33
  272. package/dist/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -47
  273. package/dist/node_modules/typescript/lib/lib.esnext.d.ts +0 -27
  274. package/dist/node_modules/typescript/lib/lib.esnext.date.d.ts +0 -21
  275. package/dist/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -26
  276. package/dist/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -191
  277. package/dist/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -22
  278. package/dist/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -22
  279. package/dist/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -107
  280. package/dist/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -23
  281. package/dist/node_modules/typescript/lib/lib.esnext.temporal.d.ts +0 -485
  282. package/dist/node_modules/typescript/lib/lib.esnext.typedarrays.d.ts +0 -90
  283. package/dist/node_modules/typescript/lib/lib.scripthost.d.ts +0 -320
  284. package/dist/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -18
  285. package/dist/node_modules/typescript/lib/lib.webworker.d.ts +0 -15606
  286. package/dist/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -21
  287. package/dist/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -18
  288. package/dist/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2129
  289. package/dist/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2129
  290. package/dist/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2125
  291. package/dist/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2129
  292. package/dist/node_modules/typescript/lib/tsc.js +0 -8
  293. package/dist/node_modules/typescript/lib/tsserver.js +0 -8
  294. package/dist/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
  295. package/dist/node_modules/typescript/lib/tsserverlibrary.js +0 -21
  296. package/dist/node_modules/typescript/lib/typesMap.json +0 -497
  297. package/dist/node_modules/typescript/lib/typescript.d.ts +0 -11448
  298. package/dist/node_modules/typescript/lib/typescript.js +0 -201039
  299. package/dist/node_modules/typescript/lib/typingsInstaller.js +0 -8
  300. package/dist/node_modules/typescript/lib/watchGuard.js +0 -53
  301. package/dist/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2129
  302. package/dist/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2125
  303. package/dist/node_modules/typescript/package.json +0 -118
@@ -1,1794 +0,0 @@
1
- 'use strict'
2
-
3
- const common = require('./common')
4
- const YAMLException = require('./exception')
5
- const makeSnippet = require('./snippet')
6
- const DEFAULT_SCHEMA = require('./schema/default')
7
-
8
- const _hasOwnProperty = Object.prototype.hasOwnProperty
9
-
10
- const CONTEXT_FLOW_IN = 1
11
- const CONTEXT_FLOW_OUT = 2
12
- const CONTEXT_BLOCK_IN = 3
13
- const CONTEXT_BLOCK_OUT = 4
14
-
15
- const CHOMPING_CLIP = 1
16
- const CHOMPING_STRIP = 2
17
- const CHOMPING_KEEP = 3
18
-
19
- // eslint-disable-next-line no-control-regex
20
- const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/
21
- const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/
22
- // eslint-disable-next-line no-useless-escape
23
- const PATTERN_FLOW_INDICATORS = /[,\[\]{}]/
24
- // eslint-disable-next-line no-useless-escape
25
- const PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/
26
- // eslint-disable-next-line no-useless-escape
27
- const PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i
28
-
29
- function _class (obj) { return Object.prototype.toString.call(obj) }
30
-
31
- function isEol (c) {
32
- return (c === 0x0A/* LF */) || (c === 0x0D/* CR */)
33
- }
34
-
35
- function isWhiteSpace (c) {
36
- return (c === 0x09/* Tab */) || (c === 0x20/* Space */)
37
- }
38
-
39
- function isWsOrEol (c) {
40
- return (c === 0x09/* Tab */) ||
41
- (c === 0x20/* Space */) ||
42
- (c === 0x0A/* LF */) ||
43
- (c === 0x0D/* CR */)
44
- }
45
-
46
- function isFlowIndicator (c) {
47
- return c === 0x2C/* , */ ||
48
- c === 0x5B/* [ */ ||
49
- c === 0x5D/* ] */ ||
50
- c === 0x7B/* { */ ||
51
- c === 0x7D/* } */
52
- }
53
-
54
- function fromHexCode (c) {
55
- if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) {
56
- return c - 0x30
57
- }
58
-
59
- const lc = c | 0x20
60
-
61
- if ((lc >= 0x61/* a */) && (lc <= 0x66/* f */)) {
62
- return lc - 0x61 + 10
63
- }
64
-
65
- return -1
66
- }
67
-
68
- function escapedHexLen (c) {
69
- if (c === 0x78/* x */) { return 2 }
70
- if (c === 0x75/* u */) { return 4 }
71
- if (c === 0x55/* U */) { return 8 }
72
- return 0
73
- }
74
-
75
- function fromDecimalCode (c) {
76
- if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) {
77
- return c - 0x30
78
- }
79
-
80
- return -1
81
- }
82
-
83
- function simpleEscapeSequence (c) {
84
- switch (c) {
85
- case 0x30/* 0 */: return '\x00'
86
- case 0x61/* a */: return '\x07'
87
- case 0x62/* b */: return '\x08'
88
- case 0x74/* t */: return '\x09'
89
- case 0x09/* Tab */: return '\x09'
90
- case 0x6E/* n */: return '\x0A'
91
- case 0x76/* v */: return '\x0B'
92
- case 0x66/* f */: return '\x0C'
93
- case 0x72/* r */: return '\x0D'
94
- case 0x65/* e */: return '\x1B'
95
- case 0x20/* Space */: return ' '
96
- case 0x22/* " */: return '\x22'
97
- case 0x2F/* / */: return '/'
98
- case 0x5C/* \ */: return '\x5C'
99
- case 0x4E/* N */: return '\x85'
100
- case 0x5F/* _ */: return '\xA0'
101
- case 0x4C/* L */: return '\u2028'
102
- case 0x50/* P */: return '\u2029'
103
- default: return ''
104
- }
105
- }
106
-
107
- function charFromCodepoint (c) {
108
- if (c <= 0xFFFF) {
109
- return String.fromCharCode(c)
110
- }
111
- // Encode UTF-16 surrogate pair
112
- // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
113
- return String.fromCharCode(
114
- ((c - 0x010000) >> 10) + 0xD800,
115
- ((c - 0x010000) & 0x03FF) + 0xDC00
116
- )
117
- }
118
-
119
- // set a property of a literal object, while protecting against prototype pollution,
120
- // see https://github.com/nodeca/js-yaml/issues/164 for more details
121
- function setProperty (object, key, value) {
122
- // used for this specific key only because Object.defineProperty is slow
123
- if (key === '__proto__') {
124
- Object.defineProperty(object, key, {
125
- configurable: true,
126
- enumerable: true,
127
- writable: true,
128
- value: value
129
- })
130
- } else {
131
- object[key] = value
132
- }
133
- }
134
-
135
- const simpleEscapeCheck = new Array(256) // integer, for fast access
136
- const simpleEscapeMap = new Array(256)
137
- for (let i = 0; i < 256; i++) {
138
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0
139
- simpleEscapeMap[i] = simpleEscapeSequence(i)
140
- }
141
-
142
- function State (input, options) {
143
- this.input = input
144
-
145
- this.filename = options['filename'] || null
146
- this.schema = options['schema'] || DEFAULT_SCHEMA
147
- this.onWarning = options['onWarning'] || null
148
- // (Hidden) Remove? makes the loader to expect YAML 1.1 documents
149
- // if such documents have no explicit %YAML directive
150
- this.legacy = options['legacy'] || false
151
-
152
- this.json = options['json'] || false
153
- this.listener = options['listener'] || null
154
- this.maxDepth = typeof options['maxDepth'] === 'number' ? options['maxDepth'] : 100
155
- this.maxMergeSeqLength = typeof options['maxMergeSeqLength'] === 'number' ? options['maxMergeSeqLength'] : 20
156
-
157
- this.implicitTypes = this.schema.compiledImplicit
158
- this.typeMap = this.schema.compiledTypeMap
159
-
160
- this.length = input.length
161
- this.position = 0
162
- this.line = 0
163
- this.lineStart = 0
164
- this.lineIndent = 0
165
- this.depth = 0
166
-
167
- // position of first leading tab in the current line,
168
- // used to make sure there are no tabs in the indentation
169
- this.firstTabInLine = -1
170
-
171
- this.documents = []
172
- this.anchorMapTransactions = []
173
-
174
- /*
175
- this.version;
176
- this.checkLineBreaks;
177
- this.tagMap;
178
- this.anchorMap;
179
- this.tag;
180
- this.anchor;
181
- this.kind;
182
- this.result; */
183
- }
184
-
185
- function generateError (state, message) {
186
- const mark = {
187
- name: state.filename,
188
- buffer: state.input.slice(0, -1), // omit trailing \0
189
- position: state.position,
190
- line: state.line,
191
- column: state.position - state.lineStart
192
- }
193
-
194
- mark.snippet = makeSnippet(mark)
195
-
196
- return new YAMLException(message, mark)
197
- }
198
-
199
- function throwError (state, message) {
200
- throw generateError(state, message)
201
- }
202
-
203
- function throwWarning (state, message) {
204
- if (state.onWarning) {
205
- state.onWarning.call(null, generateError(state, message))
206
- }
207
- }
208
-
209
- function storeAnchor (state, name, value) {
210
- const transactions = state.anchorMapTransactions
211
-
212
- if (transactions.length !== 0) {
213
- const transaction = transactions[transactions.length - 1]
214
-
215
- if (!_hasOwnProperty.call(transaction, name)) {
216
- transaction[name] = {
217
- existed: _hasOwnProperty.call(state.anchorMap, name),
218
- value: state.anchorMap[name]
219
- }
220
- }
221
- }
222
-
223
- state.anchorMap[name] = value
224
- }
225
-
226
- function beginAnchorTransaction (state) {
227
- state.anchorMapTransactions.push(Object.create(null))
228
- }
229
-
230
- function commitAnchorTransaction (state) {
231
- const transaction = state.anchorMapTransactions.pop()
232
- const transactions = state.anchorMapTransactions
233
-
234
- if (transactions.length === 0) return
235
-
236
- const parent = transactions[transactions.length - 1]
237
- const names = Object.keys(transaction)
238
-
239
- for (let index = 0, length = names.length; index < length; index += 1) {
240
- const name = names[index]
241
-
242
- if (!_hasOwnProperty.call(parent, name)) {
243
- parent[name] = transaction[name]
244
- }
245
- }
246
- }
247
-
248
- function rollbackAnchorTransaction (state) {
249
- const transaction = state.anchorMapTransactions.pop()
250
- const names = Object.keys(transaction)
251
-
252
- for (let index = names.length - 1; index >= 0; index -= 1) {
253
- const entry = transaction[names[index]]
254
-
255
- if (entry.existed) {
256
- state.anchorMap[names[index]] = entry.value
257
- } else {
258
- delete state.anchorMap[names[index]]
259
- }
260
- }
261
- }
262
-
263
- function snapshotState (state) {
264
- return {
265
- position: state.position,
266
- line: state.line,
267
- lineStart: state.lineStart,
268
- lineIndent: state.lineIndent,
269
- firstTabInLine: state.firstTabInLine,
270
- tag: state.tag,
271
- anchor: state.anchor,
272
- kind: state.kind,
273
- result: state.result
274
- }
275
- }
276
-
277
- function restoreState (state, snapshot) {
278
- state.position = snapshot.position
279
- state.line = snapshot.line
280
- state.lineStart = snapshot.lineStart
281
- state.lineIndent = snapshot.lineIndent
282
- state.firstTabInLine = snapshot.firstTabInLine
283
- state.tag = snapshot.tag
284
- state.anchor = snapshot.anchor
285
- state.kind = snapshot.kind
286
- state.result = snapshot.result
287
- }
288
-
289
- const directiveHandlers = {
290
-
291
- YAML: function handleYamlDirective (state, name, args) {
292
- if (state.version !== null) {
293
- throwError(state, 'duplication of %YAML directive')
294
- }
295
-
296
- if (args.length !== 1) {
297
- throwError(state, 'YAML directive accepts exactly one argument')
298
- }
299
-
300
- const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0])
301
-
302
- if (match === null) {
303
- throwError(state, 'ill-formed argument of the YAML directive')
304
- }
305
-
306
- const major = parseInt(match[1], 10)
307
- const minor = parseInt(match[2], 10)
308
-
309
- if (major !== 1) {
310
- throwError(state, 'unacceptable YAML version of the document')
311
- }
312
-
313
- state.version = args[0]
314
- state.checkLineBreaks = (minor < 2)
315
-
316
- if (minor !== 1 && minor !== 2) {
317
- throwWarning(state, 'unsupported YAML version of the document')
318
- }
319
- },
320
-
321
- TAG: function handleTagDirective (state, name, args) {
322
- let prefix
323
-
324
- if (args.length !== 2) {
325
- throwError(state, 'TAG directive accepts exactly two arguments')
326
- }
327
-
328
- const handle = args[0]
329
- prefix = args[1]
330
-
331
- if (!PATTERN_TAG_HANDLE.test(handle)) {
332
- throwError(state, 'ill-formed tag handle (first argument) of the TAG directive')
333
- }
334
-
335
- if (_hasOwnProperty.call(state.tagMap, handle)) {
336
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle')
337
- }
338
-
339
- if (!PATTERN_TAG_URI.test(prefix)) {
340
- throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive')
341
- }
342
-
343
- try {
344
- prefix = decodeURIComponent(prefix)
345
- } catch (err) {
346
- throwError(state, 'tag prefix is malformed: ' + prefix)
347
- }
348
-
349
- state.tagMap[handle] = prefix
350
- }
351
- }
352
-
353
- function captureSegment (state, start, end, checkJson) {
354
- if (start < end) {
355
- const _result = state.input.slice(start, end)
356
-
357
- if (checkJson) {
358
- for (let _position = 0, _length = _result.length; _position < _length; _position += 1) {
359
- const _character = _result.charCodeAt(_position)
360
- if (!(_character === 0x09 ||
361
- (_character >= 0x20 && _character <= 0x10FFFF))) {
362
- throwError(state, 'expected valid JSON character')
363
- }
364
- }
365
- } else if (PATTERN_NON_PRINTABLE.test(_result)) {
366
- throwError(state, 'the stream contains non-printable characters')
367
- }
368
-
369
- state.result += _result
370
- }
371
- }
372
-
373
- function mergeMappings (state, destination, source, overridableKeys) {
374
- if (!common.isObject(source)) {
375
- throwError(state, 'cannot merge mappings; the provided source object is unacceptable')
376
- }
377
-
378
- const sourceKeys = Object.keys(source)
379
-
380
- for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
381
- const key = sourceKeys[index]
382
-
383
- if (!_hasOwnProperty.call(destination, key)) {
384
- setProperty(destination, key, source[key])
385
- overridableKeys[key] = true
386
- }
387
- }
388
- }
389
-
390
- function storeMappingPair (state, _result, overridableKeys, keyTag, keyNode, valueNode,
391
- startLine, startLineStart, startPos) {
392
- // The output is a plain object here, so keys can only be strings.
393
- // We need to convert keyNode to a string, but doing so can hang the process
394
- // (deeply nested arrays that explode exponentially using aliases).
395
- if (Array.isArray(keyNode)) {
396
- keyNode = Array.prototype.slice.call(keyNode)
397
-
398
- for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) {
399
- if (Array.isArray(keyNode[index])) {
400
- throwError(state, 'nested arrays are not supported inside keys')
401
- }
402
-
403
- if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
404
- keyNode[index] = '[object Object]'
405
- }
406
- }
407
- }
408
-
409
- // Avoid code execution in load() via toString property
410
- // (still use its own toString for arrays, timestamps,
411
- // and whatever user schema extensions happen to have @@toStringTag)
412
- if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
413
- keyNode = '[object Object]'
414
- }
415
-
416
- keyNode = String(keyNode)
417
-
418
- if (_result === null) {
419
- _result = {}
420
- }
421
-
422
- if (keyTag === 'tag:yaml.org,2002:merge') {
423
- if (Array.isArray(valueNode)) {
424
- if (valueNode.length > state.maxMergeSeqLength) {
425
- throwError(state, 'merge sequence length exceeded maxMergeSeqLength (' + state.maxMergeSeqLength + ')')
426
- }
427
- const seen = new Set()
428
- for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
429
- const src = valueNode[index]
430
- // Existing keys are not overridden on merge, so dedupe sources to
431
- // avoid redundant work on repeated aliases.
432
- if (seen.has(src)) continue
433
- seen.add(src)
434
- mergeMappings(state, _result, src, overridableKeys)
435
- }
436
- } else {
437
- mergeMappings(state, _result, valueNode, overridableKeys)
438
- }
439
- } else {
440
- if (!state.json &&
441
- !_hasOwnProperty.call(overridableKeys, keyNode) &&
442
- _hasOwnProperty.call(_result, keyNode)) {
443
- state.line = startLine || state.line
444
- state.lineStart = startLineStart || state.lineStart
445
- state.position = startPos || state.position
446
- throwError(state, 'duplicated mapping key')
447
- }
448
-
449
- setProperty(_result, keyNode, valueNode)
450
- delete overridableKeys[keyNode]
451
- }
452
-
453
- return _result
454
- }
455
-
456
- function readLineBreak (state) {
457
- const ch = state.input.charCodeAt(state.position)
458
-
459
- if (ch === 0x0A/* LF */) {
460
- state.position++
461
- } else if (ch === 0x0D/* CR */) {
462
- state.position++
463
- if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
464
- state.position++
465
- }
466
- } else {
467
- throwError(state, 'a line break is expected')
468
- }
469
-
470
- state.line += 1
471
- state.lineStart = state.position
472
- state.firstTabInLine = -1
473
- }
474
-
475
- function skipSeparationSpace (state, allowComments, checkIndent) {
476
- let lineBreaks = 0
477
- let ch = state.input.charCodeAt(state.position)
478
-
479
- while (ch !== 0) {
480
- while (isWhiteSpace(ch)) {
481
- if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) {
482
- state.firstTabInLine = state.position
483
- }
484
- ch = state.input.charCodeAt(++state.position)
485
- }
486
-
487
- if (allowComments && ch === 0x23/* # */) {
488
- do {
489
- ch = state.input.charCodeAt(++state.position)
490
- } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0)
491
- }
492
-
493
- if (isEol(ch)) {
494
- readLineBreak(state)
495
-
496
- ch = state.input.charCodeAt(state.position)
497
- lineBreaks++
498
- state.lineIndent = 0
499
-
500
- while (ch === 0x20/* Space */) {
501
- state.lineIndent++
502
- ch = state.input.charCodeAt(++state.position)
503
- }
504
- } else {
505
- break
506
- }
507
- }
508
-
509
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
510
- throwWarning(state, 'deficient indentation')
511
- }
512
-
513
- return lineBreaks
514
- }
515
-
516
- function testDocumentSeparator (state) {
517
- let _position = state.position
518
- let ch = state.input.charCodeAt(_position)
519
-
520
- // Condition state.position === state.lineStart is tested
521
- // in parent on each call, for efficiency. No needs to test here again.
522
- if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
523
- ch === state.input.charCodeAt(_position + 1) &&
524
- ch === state.input.charCodeAt(_position + 2)) {
525
- _position += 3
526
-
527
- ch = state.input.charCodeAt(_position)
528
-
529
- if (ch === 0 || isWsOrEol(ch)) {
530
- return true
531
- }
532
- }
533
-
534
- return false
535
- }
536
-
537
- function writeFoldedLines (state, count) {
538
- if (count === 1) {
539
- state.result += ' '
540
- } else if (count > 1) {
541
- state.result += common.repeat('\n', count - 1)
542
- }
543
- }
544
-
545
- function readPlainScalar (state, nodeIndent, withinFlowCollection) {
546
- let captureStart
547
- let captureEnd
548
- let hasPendingContent
549
- let _line
550
- let _lineStart
551
- let _lineIndent
552
- const _kind = state.kind
553
- const _result = state.result
554
-
555
- let ch = state.input.charCodeAt(state.position)
556
-
557
- if (isWsOrEol(ch) ||
558
- isFlowIndicator(ch) ||
559
- ch === 0x23/* # */ ||
560
- ch === 0x26/* & */ ||
561
- ch === 0x2A/* * */ ||
562
- ch === 0x21/* ! */ ||
563
- ch === 0x7C/* | */ ||
564
- ch === 0x3E/* > */ ||
565
- ch === 0x27/* ' */ ||
566
- ch === 0x22/* " */ ||
567
- ch === 0x25/* % */ ||
568
- ch === 0x40/* @ */ ||
569
- ch === 0x60/* ` */) {
570
- return false
571
- }
572
-
573
- if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
574
- const following = state.input.charCodeAt(state.position + 1)
575
-
576
- if (isWsOrEol(following) ||
577
- (withinFlowCollection && isFlowIndicator(following))) {
578
- return false
579
- }
580
- }
581
-
582
- state.kind = 'scalar'
583
- state.result = ''
584
- captureStart = captureEnd = state.position
585
- hasPendingContent = false
586
-
587
- while (ch !== 0) {
588
- if (ch === 0x3A/* : */) {
589
- const following = state.input.charCodeAt(state.position + 1)
590
-
591
- if (isWsOrEol(following) ||
592
- (withinFlowCollection && isFlowIndicator(following))) {
593
- break
594
- }
595
- } else if (ch === 0x23/* # */) {
596
- const preceding = state.input.charCodeAt(state.position - 1)
597
-
598
- if (isWsOrEol(preceding)) {
599
- break
600
- }
601
- } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
602
- (withinFlowCollection && isFlowIndicator(ch))) {
603
- break
604
- } else if (isEol(ch)) {
605
- _line = state.line
606
- _lineStart = state.lineStart
607
- _lineIndent = state.lineIndent
608
- skipSeparationSpace(state, false, -1)
609
-
610
- if (state.lineIndent >= nodeIndent) {
611
- hasPendingContent = true
612
- ch = state.input.charCodeAt(state.position)
613
- continue
614
- } else {
615
- state.position = captureEnd
616
- state.line = _line
617
- state.lineStart = _lineStart
618
- state.lineIndent = _lineIndent
619
- break
620
- }
621
- }
622
-
623
- if (hasPendingContent) {
624
- captureSegment(state, captureStart, captureEnd, false)
625
- writeFoldedLines(state, state.line - _line)
626
- captureStart = captureEnd = state.position
627
- hasPendingContent = false
628
- }
629
-
630
- if (!isWhiteSpace(ch)) {
631
- captureEnd = state.position + 1
632
- }
633
-
634
- ch = state.input.charCodeAt(++state.position)
635
- }
636
-
637
- captureSegment(state, captureStart, captureEnd, false)
638
-
639
- if (state.result) {
640
- return true
641
- }
642
-
643
- state.kind = _kind
644
- state.result = _result
645
- return false
646
- }
647
-
648
- function readSingleQuotedScalar (state, nodeIndent) {
649
- let captureStart
650
- let captureEnd
651
-
652
- let ch = state.input.charCodeAt(state.position)
653
-
654
- if (ch !== 0x27/* ' */) {
655
- return false
656
- }
657
-
658
- state.kind = 'scalar'
659
- state.result = ''
660
- state.position++
661
- captureStart = captureEnd = state.position
662
-
663
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
664
- if (ch === 0x27/* ' */) {
665
- captureSegment(state, captureStart, state.position, true)
666
- ch = state.input.charCodeAt(++state.position)
667
-
668
- if (ch === 0x27/* ' */) {
669
- captureStart = state.position
670
- state.position++
671
- captureEnd = state.position
672
- } else {
673
- return true
674
- }
675
- } else if (isEol(ch)) {
676
- captureSegment(state, captureStart, captureEnd, true)
677
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent))
678
- captureStart = captureEnd = state.position
679
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
680
- throwError(state, 'unexpected end of the document within a single quoted scalar')
681
- } else {
682
- state.position++
683
- if (!isWhiteSpace(ch)) {
684
- captureEnd = state.position
685
- }
686
- }
687
- }
688
-
689
- throwError(state, 'unexpected end of the stream within a single quoted scalar')
690
- }
691
-
692
- function readDoubleQuotedScalar (state, nodeIndent) {
693
- let captureStart
694
- let captureEnd
695
- let tmp
696
-
697
- let ch = state.input.charCodeAt(state.position)
698
-
699
- if (ch !== 0x22/* " */) {
700
- return false
701
- }
702
-
703
- state.kind = 'scalar'
704
- state.result = ''
705
- state.position++
706
- captureStart = captureEnd = state.position
707
-
708
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
709
- if (ch === 0x22/* " */) {
710
- captureSegment(state, captureStart, state.position, true)
711
- state.position++
712
- return true
713
- } else if (ch === 0x5C/* \ */) {
714
- captureSegment(state, captureStart, state.position, true)
715
- ch = state.input.charCodeAt(++state.position)
716
-
717
- if (isEol(ch)) {
718
- skipSeparationSpace(state, false, nodeIndent)
719
-
720
- // TODO: rework to inline fn with no type cast?
721
- } else if (ch < 256 && simpleEscapeCheck[ch]) {
722
- state.result += simpleEscapeMap[ch]
723
- state.position++
724
- } else if ((tmp = escapedHexLen(ch)) > 0) {
725
- let hexLength = tmp
726
- let hexResult = 0
727
-
728
- for (; hexLength > 0; hexLength--) {
729
- ch = state.input.charCodeAt(++state.position)
730
-
731
- if ((tmp = fromHexCode(ch)) >= 0) {
732
- hexResult = (hexResult << 4) + tmp
733
- } else {
734
- throwError(state, 'expected hexadecimal character')
735
- }
736
- }
737
-
738
- state.result += charFromCodepoint(hexResult)
739
-
740
- state.position++
741
- } else {
742
- throwError(state, 'unknown escape sequence')
743
- }
744
-
745
- captureStart = captureEnd = state.position
746
- } else if (isEol(ch)) {
747
- captureSegment(state, captureStart, captureEnd, true)
748
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent))
749
- captureStart = captureEnd = state.position
750
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
751
- throwError(state, 'unexpected end of the document within a double quoted scalar')
752
- } else {
753
- state.position++
754
- if (!isWhiteSpace(ch)) {
755
- captureEnd = state.position
756
- }
757
- }
758
- }
759
-
760
- throwError(state, 'unexpected end of the stream within a double quoted scalar')
761
- }
762
-
763
- function readFlowCollection (state, nodeIndent) {
764
- let readNext = true
765
- let _line
766
- let _lineStart
767
- let _pos
768
- const _tag = state.tag
769
- let _result
770
- const _anchor = state.anchor
771
- let terminator
772
- let isPair
773
- let isExplicitPair
774
- let isMapping
775
- const overridableKeys = Object.create(null)
776
- let keyNode
777
- let keyTag
778
- let valueNode
779
-
780
- let ch = state.input.charCodeAt(state.position)
781
-
782
- if (ch === 0x5B/* [ */) {
783
- terminator = 0x5D/* ] */
784
- isMapping = false
785
- _result = []
786
- } else if (ch === 0x7B/* { */) {
787
- terminator = 0x7D/* } */
788
- isMapping = true
789
- _result = {}
790
- } else {
791
- return false
792
- }
793
-
794
- if (state.anchor !== null) {
795
- storeAnchor(state, state.anchor, _result)
796
- }
797
-
798
- ch = state.input.charCodeAt(++state.position)
799
-
800
- while (ch !== 0) {
801
- skipSeparationSpace(state, true, nodeIndent)
802
-
803
- ch = state.input.charCodeAt(state.position)
804
-
805
- if (ch === terminator) {
806
- state.position++
807
- state.tag = _tag
808
- state.anchor = _anchor
809
- state.kind = isMapping ? 'mapping' : 'sequence'
810
- state.result = _result
811
- return true
812
- } else if (!readNext) {
813
- throwError(state, 'missed comma between flow collection entries')
814
- } else if (ch === 0x2C/* , */) {
815
- // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4
816
- throwError(state, "expected the node content, but found ','")
817
- }
818
-
819
- keyTag = keyNode = valueNode = null
820
- isPair = isExplicitPair = false
821
-
822
- if (ch === 0x3F/* ? */) {
823
- const following = state.input.charCodeAt(state.position + 1)
824
-
825
- if (isWsOrEol(following)) {
826
- isPair = isExplicitPair = true
827
- state.position++
828
- skipSeparationSpace(state, true, nodeIndent)
829
- }
830
- }
831
-
832
- _line = state.line // Save the current line.
833
- _lineStart = state.lineStart
834
- _pos = state.position
835
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)
836
- keyTag = state.tag
837
- keyNode = state.result
838
- skipSeparationSpace(state, true, nodeIndent)
839
-
840
- ch = state.input.charCodeAt(state.position)
841
-
842
- if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
843
- isPair = true
844
- ch = state.input.charCodeAt(++state.position)
845
- skipSeparationSpace(state, true, nodeIndent)
846
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)
847
- valueNode = state.result
848
- }
849
-
850
- if (isMapping) {
851
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)
852
- } else if (isPair) {
853
- _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos))
854
- } else {
855
- _result.push(keyNode)
856
- }
857
-
858
- skipSeparationSpace(state, true, nodeIndent)
859
-
860
- ch = state.input.charCodeAt(state.position)
861
-
862
- if (ch === 0x2C/* , */) {
863
- readNext = true
864
- ch = state.input.charCodeAt(++state.position)
865
- } else {
866
- readNext = false
867
- }
868
- }
869
-
870
- throwError(state, 'unexpected end of the stream within a flow collection')
871
- }
872
-
873
- function readBlockScalar (state, nodeIndent) {
874
- let folding
875
- let chomping = CHOMPING_CLIP
876
- let didReadContent = false
877
- let detectedIndent = false
878
- let textIndent = nodeIndent
879
- let emptyLines = 0
880
- let atMoreIndented = false
881
- let tmp
882
-
883
- let ch = state.input.charCodeAt(state.position)
884
-
885
- if (ch === 0x7C/* | */) {
886
- folding = false
887
- } else if (ch === 0x3E/* > */) {
888
- folding = true
889
- } else {
890
- return false
891
- }
892
-
893
- state.kind = 'scalar'
894
- state.result = ''
895
-
896
- while (ch !== 0) {
897
- ch = state.input.charCodeAt(++state.position)
898
-
899
- if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
900
- if (CHOMPING_CLIP === chomping) {
901
- chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP
902
- } else {
903
- throwError(state, 'repeat of a chomping mode identifier')
904
- }
905
- } else if ((tmp = fromDecimalCode(ch)) >= 0) {
906
- if (tmp === 0) {
907
- throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one')
908
- } else if (!detectedIndent) {
909
- textIndent = nodeIndent + tmp - 1
910
- detectedIndent = true
911
- } else {
912
- throwError(state, 'repeat of an indentation width identifier')
913
- }
914
- } else {
915
- break
916
- }
917
- }
918
-
919
- if (isWhiteSpace(ch)) {
920
- do { ch = state.input.charCodeAt(++state.position) }
921
- while (isWhiteSpace(ch))
922
-
923
- if (ch === 0x23/* # */) {
924
- do { ch = state.input.charCodeAt(++state.position) }
925
- while (!isEol(ch) && (ch !== 0))
926
- }
927
- }
928
-
929
- while (ch !== 0) {
930
- readLineBreak(state)
931
- state.lineIndent = 0
932
-
933
- ch = state.input.charCodeAt(state.position)
934
-
935
- // eslint-disable-next-line no-unmodified-loop-condition
936
- while ((!detectedIndent || state.lineIndent < textIndent) &&
937
- (ch === 0x20/* Space */)) {
938
- state.lineIndent++
939
- ch = state.input.charCodeAt(++state.position)
940
- }
941
-
942
- if (!detectedIndent && state.lineIndent > textIndent) {
943
- textIndent = state.lineIndent
944
- }
945
-
946
- if (isEol(ch)) {
947
- emptyLines++
948
- continue
949
- }
950
-
951
- if (!detectedIndent && textIndent === 0) {
952
- throwError(state, 'missing indentation for block scalar')
953
- }
954
-
955
- // End of the scalar.
956
- if (state.lineIndent < textIndent) {
957
- // Perform the chomping.
958
- if (chomping === CHOMPING_KEEP) {
959
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines)
960
- } else if (chomping === CHOMPING_CLIP) {
961
- if (didReadContent) { // i.e. only if the scalar is not empty.
962
- state.result += '\n'
963
- }
964
- }
965
-
966
- // Break this `while` cycle and go to the funciton's epilogue.
967
- break
968
- }
969
-
970
- // Folded style: use fancy rules to handle line breaks.
971
- if (folding) {
972
- // Lines starting with white space characters (more-indented lines) are not folded.
973
- if (isWhiteSpace(ch)) {
974
- atMoreIndented = true
975
- // except for the first content line (cf. Example 8.1)
976
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines)
977
-
978
- // End of more-indented block.
979
- } else if (atMoreIndented) {
980
- atMoreIndented = false
981
- state.result += common.repeat('\n', emptyLines + 1)
982
-
983
- // Just one line break - perceive as the same line.
984
- } else if (emptyLines === 0) {
985
- if (didReadContent) { // i.e. only if we have already read some scalar content.
986
- state.result += ' '
987
- }
988
-
989
- // Several line breaks - perceive as different lines.
990
- } else {
991
- state.result += common.repeat('\n', emptyLines)
992
- }
993
-
994
- // Literal style: just add exact number of line breaks between content lines.
995
- } else {
996
- // Keep all line breaks except the header line break.
997
- state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines)
998
- }
999
-
1000
- didReadContent = true
1001
- detectedIndent = true
1002
- emptyLines = 0
1003
- const captureStart = state.position
1004
-
1005
- while (!isEol(ch) && (ch !== 0)) {
1006
- ch = state.input.charCodeAt(++state.position)
1007
- }
1008
-
1009
- captureSegment(state, captureStart, state.position, false)
1010
- }
1011
-
1012
- return true
1013
- }
1014
-
1015
- function readBlockSequence (state, nodeIndent) {
1016
- const _tag = state.tag
1017
- const _anchor = state.anchor
1018
- const _result = []
1019
- let detected = false
1020
-
1021
- // there is a leading tab before this token, so it can't be a block sequence/mapping;
1022
- // it can still be flow sequence/mapping or a scalar
1023
- if (state.firstTabInLine !== -1) return false
1024
-
1025
- if (state.anchor !== null) {
1026
- storeAnchor(state, state.anchor, _result)
1027
- }
1028
-
1029
- let ch = state.input.charCodeAt(state.position)
1030
-
1031
- while (ch !== 0) {
1032
- if (state.firstTabInLine !== -1) {
1033
- state.position = state.firstTabInLine
1034
- throwError(state, 'tab characters must not be used in indentation')
1035
- }
1036
-
1037
- if (ch !== 0x2D/* - */) {
1038
- break
1039
- }
1040
-
1041
- const following = state.input.charCodeAt(state.position + 1)
1042
-
1043
- if (!isWsOrEol(following)) {
1044
- break
1045
- }
1046
-
1047
- detected = true
1048
- state.position++
1049
-
1050
- if (skipSeparationSpace(state, true, -1)) {
1051
- if (state.lineIndent <= nodeIndent) {
1052
- _result.push(null)
1053
- ch = state.input.charCodeAt(state.position)
1054
- continue
1055
- }
1056
- }
1057
-
1058
- const _line = state.line
1059
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true)
1060
- _result.push(state.result)
1061
- skipSeparationSpace(state, true, -1)
1062
-
1063
- ch = state.input.charCodeAt(state.position)
1064
-
1065
- if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
1066
- throwError(state, 'bad indentation of a sequence entry')
1067
- } else if (state.lineIndent < nodeIndent) {
1068
- break
1069
- }
1070
- }
1071
-
1072
- if (detected) {
1073
- state.tag = _tag
1074
- state.anchor = _anchor
1075
- state.kind = 'sequence'
1076
- state.result = _result
1077
- return true
1078
- }
1079
- return false
1080
- }
1081
-
1082
- function readBlockMapping (state, nodeIndent, flowIndent) {
1083
- let allowCompact
1084
- let _keyLine
1085
- let _keyLineStart
1086
- let _keyPos
1087
- const _tag = state.tag
1088
- const _anchor = state.anchor
1089
- const _result = {}
1090
- const overridableKeys = Object.create(null)
1091
- let keyTag = null
1092
- let keyNode = null
1093
- let valueNode = null
1094
- let atExplicitKey = false
1095
- let detected = false
1096
-
1097
- // there is a leading tab before this token, so it can't be a block sequence/mapping;
1098
- // it can still be flow sequence/mapping or a scalar
1099
- if (state.firstTabInLine !== -1) return false
1100
-
1101
- if (state.anchor !== null) {
1102
- storeAnchor(state, state.anchor, _result)
1103
- }
1104
-
1105
- let ch = state.input.charCodeAt(state.position)
1106
-
1107
- while (ch !== 0) {
1108
- if (!atExplicitKey && state.firstTabInLine !== -1) {
1109
- state.position = state.firstTabInLine
1110
- throwError(state, 'tab characters must not be used in indentation')
1111
- }
1112
-
1113
- const following = state.input.charCodeAt(state.position + 1)
1114
- const _line = state.line // Save the current line.
1115
-
1116
- //
1117
- // Explicit notation case. There are two separate blocks:
1118
- // first for the key (denoted by "?") and second for the value (denoted by ":")
1119
- //
1120
- if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && isWsOrEol(following)) {
1121
- if (ch === 0x3F/* ? */) {
1122
- if (atExplicitKey) {
1123
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos)
1124
- keyTag = keyNode = valueNode = null
1125
- }
1126
-
1127
- detected = true
1128
- atExplicitKey = true
1129
- allowCompact = true
1130
- } else if (atExplicitKey) {
1131
- // i.e. 0x3A/* : */ === character after the explicit key.
1132
- atExplicitKey = false
1133
- allowCompact = true
1134
- } else {
1135
- throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line')
1136
- }
1137
-
1138
- state.position += 1
1139
- ch = following
1140
-
1141
- //
1142
- // Implicit notation case. Flow-style node as the key first, then ":", and the value.
1143
- //
1144
- } else {
1145
- _keyLine = state.line
1146
- _keyLineStart = state.lineStart
1147
- _keyPos = state.position
1148
-
1149
- if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1150
- // Neither implicit nor explicit notation.
1151
- // Reading is done. Go to the epilogue.
1152
- break
1153
- }
1154
-
1155
- if (state.line === _line) {
1156
- ch = state.input.charCodeAt(state.position)
1157
-
1158
- while (isWhiteSpace(ch)) {
1159
- ch = state.input.charCodeAt(++state.position)
1160
- }
1161
-
1162
- if (ch === 0x3A/* : */) {
1163
- ch = state.input.charCodeAt(++state.position)
1164
-
1165
- if (!isWsOrEol(ch)) {
1166
- throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping')
1167
- }
1168
-
1169
- if (atExplicitKey) {
1170
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos)
1171
- keyTag = keyNode = valueNode = null
1172
- }
1173
-
1174
- detected = true
1175
- atExplicitKey = false
1176
- allowCompact = false
1177
- keyTag = state.tag
1178
- keyNode = state.result
1179
- } else if (detected) {
1180
- throwError(state, 'can not read an implicit mapping pair; a colon is missed')
1181
- } else {
1182
- state.tag = _tag
1183
- state.anchor = _anchor
1184
- return true // Keep the result of `composeNode`.
1185
- }
1186
- } else if (detected) {
1187
- throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key')
1188
- } else {
1189
- state.tag = _tag
1190
- state.anchor = _anchor
1191
- return true // Keep the result of `composeNode`.
1192
- }
1193
- }
1194
-
1195
- //
1196
- // Common reading code for both explicit and implicit notations.
1197
- //
1198
- if (state.line === _line || state.lineIndent > nodeIndent) {
1199
- if (atExplicitKey) {
1200
- _keyLine = state.line
1201
- _keyLineStart = state.lineStart
1202
- _keyPos = state.position
1203
- }
1204
-
1205
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1206
- if (atExplicitKey) {
1207
- keyNode = state.result
1208
- } else {
1209
- valueNode = state.result
1210
- }
1211
- }
1212
-
1213
- if (!atExplicitKey) {
1214
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos)
1215
- keyTag = keyNode = valueNode = null
1216
- }
1217
-
1218
- skipSeparationSpace(state, true, -1)
1219
- ch = state.input.charCodeAt(state.position)
1220
- }
1221
-
1222
- if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
1223
- throwError(state, 'bad indentation of a mapping entry')
1224
- } else if (state.lineIndent < nodeIndent) {
1225
- break
1226
- }
1227
- }
1228
-
1229
- //
1230
- // Epilogue.
1231
- //
1232
-
1233
- // Special case: last mapping's node contains only the key in explicit notation.
1234
- if (atExplicitKey) {
1235
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos)
1236
- }
1237
-
1238
- // Expose the resulting mapping.
1239
- if (detected) {
1240
- state.tag = _tag
1241
- state.anchor = _anchor
1242
- state.kind = 'mapping'
1243
- state.result = _result
1244
- }
1245
-
1246
- return detected
1247
- }
1248
-
1249
- function readTagProperty (state) {
1250
- let isVerbatim = false
1251
- let isNamed = false
1252
- let tagHandle
1253
- let tagName
1254
-
1255
- let ch = state.input.charCodeAt(state.position)
1256
-
1257
- if (ch !== 0x21/* ! */) return false
1258
-
1259
- if (state.tag !== null) {
1260
- throwError(state, 'duplication of a tag property')
1261
- }
1262
-
1263
- ch = state.input.charCodeAt(++state.position)
1264
-
1265
- if (ch === 0x3C/* < */) {
1266
- isVerbatim = true
1267
- ch = state.input.charCodeAt(++state.position)
1268
- } else if (ch === 0x21/* ! */) {
1269
- isNamed = true
1270
- tagHandle = '!!'
1271
- ch = state.input.charCodeAt(++state.position)
1272
- } else {
1273
- tagHandle = '!'
1274
- }
1275
-
1276
- let _position = state.position
1277
-
1278
- if (isVerbatim) {
1279
- do { ch = state.input.charCodeAt(++state.position) }
1280
- while (ch !== 0 && ch !== 0x3E/* > */)
1281
-
1282
- if (state.position < state.length) {
1283
- tagName = state.input.slice(_position, state.position)
1284
- ch = state.input.charCodeAt(++state.position)
1285
- } else {
1286
- throwError(state, 'unexpected end of the stream within a verbatim tag')
1287
- }
1288
- } else {
1289
- while (ch !== 0 && !isWsOrEol(ch)) {
1290
- if (ch === 0x21/* ! */) {
1291
- if (!isNamed) {
1292
- tagHandle = state.input.slice(_position - 1, state.position + 1)
1293
-
1294
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1295
- throwError(state, 'named tag handle cannot contain such characters')
1296
- }
1297
-
1298
- isNamed = true
1299
- _position = state.position + 1
1300
- } else {
1301
- throwError(state, 'tag suffix cannot contain exclamation marks')
1302
- }
1303
- }
1304
-
1305
- ch = state.input.charCodeAt(++state.position)
1306
- }
1307
-
1308
- tagName = state.input.slice(_position, state.position)
1309
-
1310
- if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1311
- throwError(state, 'tag suffix cannot contain flow indicator characters')
1312
- }
1313
- }
1314
-
1315
- if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1316
- throwError(state, 'tag name cannot contain such characters: ' + tagName)
1317
- }
1318
-
1319
- try {
1320
- tagName = decodeURIComponent(tagName)
1321
- } catch (err) {
1322
- throwError(state, 'tag name is malformed: ' + tagName)
1323
- }
1324
-
1325
- if (isVerbatim) {
1326
- state.tag = tagName
1327
- } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
1328
- state.tag = state.tagMap[tagHandle] + tagName
1329
- } else if (tagHandle === '!') {
1330
- state.tag = '!' + tagName
1331
- } else if (tagHandle === '!!') {
1332
- state.tag = 'tag:yaml.org,2002:' + tagName
1333
- } else {
1334
- throwError(state, 'undeclared tag handle "' + tagHandle + '"')
1335
- }
1336
-
1337
- return true
1338
- }
1339
-
1340
- function readAnchorProperty (state) {
1341
- let ch = state.input.charCodeAt(state.position)
1342
-
1343
- if (ch !== 0x26/* & */) return false
1344
-
1345
- if (state.anchor !== null) {
1346
- throwError(state, 'duplication of an anchor property')
1347
- }
1348
-
1349
- ch = state.input.charCodeAt(++state.position)
1350
- const _position = state.position
1351
-
1352
- while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) {
1353
- ch = state.input.charCodeAt(++state.position)
1354
- }
1355
-
1356
- if (state.position === _position) {
1357
- throwError(state, 'name of an anchor node must contain at least one character')
1358
- }
1359
-
1360
- state.anchor = state.input.slice(_position, state.position)
1361
- return true
1362
- }
1363
-
1364
- function readAlias (state) {
1365
- let ch = state.input.charCodeAt(state.position)
1366
-
1367
- if (ch !== 0x2A/* * */) return false
1368
-
1369
- ch = state.input.charCodeAt(++state.position)
1370
- const _position = state.position
1371
-
1372
- while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) {
1373
- ch = state.input.charCodeAt(++state.position)
1374
- }
1375
-
1376
- if (state.position === _position) {
1377
- throwError(state, 'name of an alias node must contain at least one character')
1378
- }
1379
-
1380
- const alias = state.input.slice(_position, state.position)
1381
-
1382
- if (!_hasOwnProperty.call(state.anchorMap, alias)) {
1383
- throwError(state, 'unidentified alias "' + alias + '"')
1384
- }
1385
-
1386
- state.result = state.anchorMap[alias]
1387
- skipSeparationSpace(state, true, -1)
1388
- return true
1389
- }
1390
-
1391
- function tryReadBlockMappingFromProperty (state, propertyStart, nodeIndent, flowIndent) {
1392
- const fallbackState = snapshotState(state)
1393
-
1394
- beginAnchorTransaction(state)
1395
- restoreState(state, propertyStart)
1396
-
1397
- // Re-read the leading properties as part of the first implicit key, not as
1398
- // properties of the current node.
1399
- state.tag = null
1400
- state.anchor = null
1401
- state.kind = null
1402
- state.result = null
1403
-
1404
- if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === 'mapping') {
1405
- commitAnchorTransaction(state)
1406
- return true
1407
- }
1408
-
1409
- rollbackAnchorTransaction(state)
1410
- restoreState(state, fallbackState)
1411
- return false
1412
- }
1413
-
1414
- function composeNode (state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1415
- let allowBlockScalars
1416
- let allowBlockCollections
1417
- let indentStatus = 1 // 1: this>parent, 0: this=parent, -1: this<parent
1418
- let atNewLine = false
1419
- let hasContent = false
1420
- let propertyStart = null
1421
- let type
1422
- let flowIndent
1423
- let blockIndent
1424
-
1425
- if (state.depth >= state.maxDepth) {
1426
- throwError(state, 'nesting exceeded maxDepth (' + state.maxDepth + ')')
1427
- }
1428
-
1429
- state.depth += 1
1430
-
1431
- if (state.listener !== null) {
1432
- state.listener('open', state)
1433
- }
1434
-
1435
- state.tag = null
1436
- state.anchor = null
1437
- state.kind = null
1438
- state.result = null
1439
-
1440
- const allowBlockStyles = allowBlockScalars = allowBlockCollections =
1441
- CONTEXT_BLOCK_OUT === nodeContext ||
1442
- CONTEXT_BLOCK_IN === nodeContext
1443
-
1444
- if (allowToSeek) {
1445
- if (skipSeparationSpace(state, true, -1)) {
1446
- atNewLine = true
1447
-
1448
- if (state.lineIndent > parentIndent) {
1449
- indentStatus = 1
1450
- } else if (state.lineIndent === parentIndent) {
1451
- indentStatus = 0
1452
- } else if (state.lineIndent < parentIndent) {
1453
- indentStatus = -1
1454
- }
1455
- }
1456
- }
1457
-
1458
- if (indentStatus === 1) {
1459
- while (true) {
1460
- const ch = state.input.charCodeAt(state.position)
1461
- const propertyState = snapshotState(state)
1462
-
1463
- // A duplicate property token after a line break can be the first key of
1464
- // a nested block mapping, e.g. `!!map\n !!str key: value`.
1465
- if (atNewLine &&
1466
- ((ch === 0x21/* ! */ && state.tag !== null) ||
1467
- (ch === 0x26/* & */ && state.anchor !== null))) {
1468
- break
1469
- }
1470
-
1471
- if (!readTagProperty(state) && !readAnchorProperty(state)) {
1472
- break
1473
- }
1474
-
1475
- if (propertyStart === null) {
1476
- propertyStart = propertyState
1477
- }
1478
-
1479
- if (skipSeparationSpace(state, true, -1)) {
1480
- atNewLine = true
1481
- allowBlockCollections = allowBlockStyles
1482
-
1483
- if (state.lineIndent > parentIndent) {
1484
- indentStatus = 1
1485
- } else if (state.lineIndent === parentIndent) {
1486
- indentStatus = 0
1487
- } else if (state.lineIndent < parentIndent) {
1488
- indentStatus = -1
1489
- }
1490
- } else {
1491
- allowBlockCollections = false
1492
- }
1493
- }
1494
- }
1495
-
1496
- if (allowBlockCollections) {
1497
- allowBlockCollections = atNewLine || allowCompact
1498
- }
1499
-
1500
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1501
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
1502
- flowIndent = parentIndent
1503
- } else {
1504
- flowIndent = parentIndent + 1
1505
- }
1506
-
1507
- blockIndent = state.position - state.lineStart
1508
-
1509
- if (indentStatus === 1) {
1510
- if ((allowBlockCollections &&
1511
- (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent))) ||
1512
- readFlowCollection(state, flowIndent)) {
1513
- hasContent = true
1514
- } else {
1515
- const ch = state.input.charCodeAt(state.position)
1516
-
1517
- if (propertyStart !== null && allowBlockStyles && !allowBlockCollections &&
1518
- ch !== 0x7C/* | */ && ch !== 0x3E/* > */ &&
1519
- tryReadBlockMappingFromProperty(
1520
- state,
1521
- propertyStart,
1522
- propertyStart.position - propertyStart.lineStart,
1523
- flowIndent
1524
- )) {
1525
- hasContent = true
1526
- } else if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
1527
- readSingleQuotedScalar(state, flowIndent) ||
1528
- readDoubleQuotedScalar(state, flowIndent)) {
1529
- hasContent = true
1530
- } else if (readAlias(state)) {
1531
- hasContent = true
1532
-
1533
- if (state.tag !== null || state.anchor !== null) {
1534
- throwError(state, 'alias node should not have any properties')
1535
- }
1536
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1537
- hasContent = true
1538
-
1539
- if (state.tag === null) {
1540
- state.tag = '?'
1541
- }
1542
- }
1543
-
1544
- if (state.anchor !== null) {
1545
- storeAnchor(state, state.anchor, state.result)
1546
- }
1547
- }
1548
- } else if (indentStatus === 0) {
1549
- // Special case: block sequences are allowed to have same indentation level as the parent.
1550
- // http://www.yaml.org/spec/1.2/spec.html#id2799784
1551
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent)
1552
- }
1553
- }
1554
-
1555
- if (state.tag === null) {
1556
- if (state.anchor !== null) {
1557
- storeAnchor(state, state.anchor, state.result)
1558
- }
1559
- } else if (state.tag === '?') {
1560
- // Implicit resolving is not allowed for non-scalar types, and '?'
1561
- // non-specific tag is only automatically assigned to plain scalars.
1562
- //
1563
- // We only need to check kind conformity in case user explicitly assigns '?'
1564
- // tag, for example like this: "!<?> [0]"
1565
- //
1566
- if (state.result !== null && state.kind !== 'scalar') {
1567
- throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"')
1568
- }
1569
-
1570
- for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
1571
- type = state.implicitTypes[typeIndex]
1572
-
1573
- if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
1574
- state.result = type.construct(state.result)
1575
- state.tag = type.tag
1576
- if (state.anchor !== null) {
1577
- storeAnchor(state, state.anchor, state.result)
1578
- }
1579
- break
1580
- }
1581
- }
1582
- } else if (state.tag !== '!') {
1583
- if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
1584
- type = state.typeMap[state.kind || 'fallback'][state.tag]
1585
- } else {
1586
- // looking for multi type
1587
- type = null
1588
- const typeList = state.typeMap.multi[state.kind || 'fallback']
1589
-
1590
- for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
1591
- if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
1592
- type = typeList[typeIndex]
1593
- break
1594
- }
1595
- }
1596
- }
1597
-
1598
- if (!type) {
1599
- throwError(state, 'unknown tag !<' + state.tag + '>')
1600
- }
1601
-
1602
- if (state.result !== null && type.kind !== state.kind) {
1603
- throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"')
1604
- }
1605
-
1606
- if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched
1607
- throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag')
1608
- } else {
1609
- state.result = type.construct(state.result, state.tag)
1610
- if (state.anchor !== null) {
1611
- storeAnchor(state, state.anchor, state.result)
1612
- }
1613
- }
1614
- }
1615
-
1616
- if (state.listener !== null) {
1617
- state.listener('close', state)
1618
- }
1619
-
1620
- state.depth -= 1
1621
- return state.tag !== null || state.anchor !== null || hasContent
1622
- }
1623
-
1624
- function readDocument (state) {
1625
- const documentStart = state.position
1626
- let hasDirectives = false
1627
- let ch
1628
-
1629
- state.version = null
1630
- state.checkLineBreaks = state.legacy
1631
- state.tagMap = Object.create(null)
1632
- state.anchorMap = Object.create(null)
1633
-
1634
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1635
- skipSeparationSpace(state, true, -1)
1636
-
1637
- ch = state.input.charCodeAt(state.position)
1638
-
1639
- if (state.lineIndent > 0 || ch !== 0x25/* % */) {
1640
- break
1641
- }
1642
-
1643
- hasDirectives = true
1644
- ch = state.input.charCodeAt(++state.position)
1645
- let _position = state.position
1646
-
1647
- while (ch !== 0 && !isWsOrEol(ch)) {
1648
- ch = state.input.charCodeAt(++state.position)
1649
- }
1650
-
1651
- const directiveName = state.input.slice(_position, state.position)
1652
- const directiveArgs = []
1653
-
1654
- if (directiveName.length < 1) {
1655
- throwError(state, 'directive name must not be less than one character in length')
1656
- }
1657
-
1658
- while (ch !== 0) {
1659
- while (isWhiteSpace(ch)) {
1660
- ch = state.input.charCodeAt(++state.position)
1661
- }
1662
-
1663
- if (ch === 0x23/* # */) {
1664
- do { ch = state.input.charCodeAt(++state.position) }
1665
- while (ch !== 0 && !isEol(ch))
1666
- break
1667
- }
1668
-
1669
- if (isEol(ch)) break
1670
-
1671
- _position = state.position
1672
-
1673
- while (ch !== 0 && !isWsOrEol(ch)) {
1674
- ch = state.input.charCodeAt(++state.position)
1675
- }
1676
-
1677
- directiveArgs.push(state.input.slice(_position, state.position))
1678
- }
1679
-
1680
- if (ch !== 0) readLineBreak(state)
1681
-
1682
- if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
1683
- directiveHandlers[directiveName](state, directiveName, directiveArgs)
1684
- } else {
1685
- throwWarning(state, 'unknown document directive "' + directiveName + '"')
1686
- }
1687
- }
1688
-
1689
- skipSeparationSpace(state, true, -1)
1690
-
1691
- if (state.lineIndent === 0 &&
1692
- state.input.charCodeAt(state.position) === 0x2D/* - */ &&
1693
- state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
1694
- state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
1695
- state.position += 3
1696
- skipSeparationSpace(state, true, -1)
1697
- } else if (hasDirectives) {
1698
- throwError(state, 'directives end mark is expected')
1699
- }
1700
-
1701
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true)
1702
- skipSeparationSpace(state, true, -1)
1703
-
1704
- if (state.checkLineBreaks &&
1705
- PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
1706
- throwWarning(state, 'non-ASCII line breaks are interpreted as content')
1707
- }
1708
-
1709
- state.documents.push(state.result)
1710
-
1711
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
1712
- if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
1713
- state.position += 3
1714
- skipSeparationSpace(state, true, -1)
1715
- }
1716
- return
1717
- }
1718
-
1719
- if (state.position < (state.length - 1)) {
1720
- throwError(state, 'end of the stream or a document separator is expected')
1721
- }
1722
- }
1723
-
1724
- function loadDocuments (input, options) {
1725
- input = String(input)
1726
- options = options || {}
1727
-
1728
- if (input.length !== 0) {
1729
- // Add tailing `\n` if not exists
1730
- if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
1731
- input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
1732
- input += '\n'
1733
- }
1734
-
1735
- // Strip BOM
1736
- if (input.charCodeAt(0) === 0xFEFF) {
1737
- input = input.slice(1)
1738
- }
1739
- }
1740
-
1741
- const state = new State(input, options)
1742
-
1743
- const nullpos = input.indexOf('\0')
1744
-
1745
- if (nullpos !== -1) {
1746
- state.position = nullpos
1747
- throwError(state, 'null byte is not allowed in input')
1748
- }
1749
-
1750
- // Use 0 as string terminator. That significantly simplifies bounds check.
1751
- state.input += '\0'
1752
-
1753
- while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
1754
- state.lineIndent += 1
1755
- state.position += 1
1756
- }
1757
-
1758
- while (state.position < (state.length - 1)) {
1759
- readDocument(state)
1760
- }
1761
-
1762
- return state.documents
1763
- }
1764
-
1765
- function loadAll (input, iterator, options) {
1766
- if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
1767
- options = iterator
1768
- iterator = null
1769
- }
1770
-
1771
- const documents = loadDocuments(input, options)
1772
-
1773
- if (typeof iterator !== 'function') {
1774
- return documents
1775
- }
1776
-
1777
- for (let index = 0, length = documents.length; index < length; index += 1) {
1778
- iterator(documents[index])
1779
- }
1780
- }
1781
-
1782
- function load (input, options) {
1783
- const documents = loadDocuments(input, options)
1784
-
1785
- if (documents.length === 0) {
1786
- return undefined
1787
- } else if (documents.length === 1) {
1788
- return documents[0]
1789
- }
1790
- throw new YAMLException('expected a single document in the stream, but found more')
1791
- }
1792
-
1793
- module.exports.loadAll = loadAll
1794
- module.exports.load = load