@dcloudio/vue-cli-plugin-uni 2.0.0 → 2.0.1-32920211122002

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 (269) hide show
  1. package/commands/build.js +64 -33
  2. package/commands/serve.js +12 -17
  3. package/generator.js +6 -2
  4. package/index.js +5 -3
  5. package/lib/chain-webpack.js +8 -1
  6. package/lib/check-update.js +56 -0
  7. package/lib/commands/custom.js +7 -4
  8. package/lib/commands/invoke.js +5 -4
  9. package/lib/configure-webpack.js +35 -5
  10. package/lib/copy-webpack-options.js +60 -20
  11. package/lib/env.js +99 -51
  12. package/lib/error-reporting.js +9 -3
  13. package/lib/mp/index.js +31 -16
  14. package/lib/options.js +6 -3
  15. package/lib/util.js +5 -6
  16. package/package.json +3 -3
  17. package/packages/@vue/component-compiler-utils/MODIFY.md +5 -0
  18. package/packages/@vue/component-compiler-utils/dist/compileStyle.js +11 -0
  19. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/API.md +873 -0
  20. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/CHANGELOG.md +466 -0
  21. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/LICENSE-MIT +22 -0
  22. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/README.md +49 -0
  23. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/index.js +26 -0
  24. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/parser.js +1088 -0
  25. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/processor.js +185 -0
  26. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/attribute.js +468 -0
  27. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/className.js +67 -0
  28. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/combinator.js +35 -0
  29. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/comment.js +35 -0
  30. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/constructors.js +91 -0
  31. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/container.js +392 -0
  32. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/guards.js +54 -0
  33. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/id.js +39 -0
  34. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/index.js +39 -0
  35. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/namespace.js +98 -0
  36. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/nesting.js +36 -0
  37. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/node.js +216 -0
  38. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/pseudo.js +40 -0
  39. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/root.js +60 -0
  40. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/selector.js +35 -0
  41. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/string.js +35 -0
  42. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/tag.js +35 -0
  43. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/types.js +15 -0
  44. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/selectors/universal.js +36 -0
  45. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/sortAscending.js +10 -0
  46. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/tokenTypes.js +39 -0
  47. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/tokenize.js +271 -0
  48. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/ensureObject.js +20 -0
  49. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/getProp.js +22 -0
  50. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/index.js +41 -0
  51. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/stripComments.js +21 -0
  52. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/dist/util/unesc.js +18 -0
  53. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/package.json +76 -0
  54. package/packages/@vue/component-compiler-utils/node_modules/postcss-selector-parser/postcss-selector-parser.d.ts +499 -0
  55. package/packages/@vue/devtools-api/lib/cjs/api/api.d.ts +90 -0
  56. package/packages/@vue/devtools-api/lib/cjs/api/api.js +2 -0
  57. package/packages/@vue/devtools-api/lib/cjs/api/app.d.ts +1 -0
  58. package/packages/@vue/devtools-api/lib/cjs/api/app.js +2 -0
  59. package/packages/@vue/devtools-api/lib/cjs/api/component.d.ts +76 -0
  60. package/packages/@vue/devtools-api/lib/cjs/api/component.js +2 -0
  61. package/packages/@vue/devtools-api/lib/cjs/api/context.d.ts +5 -0
  62. package/packages/@vue/devtools-api/lib/cjs/api/context.js +2 -0
  63. package/packages/@vue/devtools-api/lib/cjs/api/hooks.d.ts +169 -0
  64. package/packages/@vue/devtools-api/lib/cjs/api/hooks.js +2 -0
  65. package/packages/@vue/devtools-api/lib/cjs/api/index.d.ts +6 -0
  66. package/packages/@vue/devtools-api/lib/cjs/api/index.js +18 -0
  67. package/packages/@vue/devtools-api/lib/cjs/api/util.d.ts +4 -0
  68. package/packages/@vue/devtools-api/lib/cjs/api/util.js +2 -0
  69. package/packages/@vue/devtools-api/lib/cjs/const.d.ts +1 -0
  70. package/packages/@vue/devtools-api/lib/cjs/const.js +4 -0
  71. package/packages/@vue/devtools-api/lib/cjs/env.d.ts +10 -0
  72. package/packages/@vue/devtools-api/lib/cjs/env.js +16 -0
  73. package/packages/@vue/devtools-api/lib/cjs/index.d.ts +14 -0
  74. package/packages/@vue/devtools-api/lib/cjs/index.js +31 -0
  75. package/packages/@vue/devtools-api/lib/esm/api/api.js +0 -0
  76. package/packages/@vue/devtools-api/lib/esm/api/app.js +0 -0
  77. package/packages/@vue/devtools-api/lib/esm/api/component.js +0 -0
  78. package/packages/@vue/devtools-api/lib/esm/api/context.js +0 -0
  79. package/packages/@vue/devtools-api/lib/esm/api/hooks.js +0 -0
  80. package/packages/@vue/devtools-api/lib/esm/api/index.js +6 -0
  81. package/packages/@vue/devtools-api/lib/esm/api/util.js +0 -0
  82. package/packages/@vue/devtools-api/lib/esm/const.js +1 -0
  83. package/packages/@vue/devtools-api/lib/esm/env.js +11 -0
  84. package/packages/@vue/devtools-api/lib/esm/index.js +17 -0
  85. package/packages/@vue/devtools-api/package.json +38 -0
  86. package/packages/app-vue-style-loader/lib/addStylesClient.js +1 -1
  87. package/packages/h5-vue-style-loader/lib/addStylesClient.js +1 -1
  88. package/packages/mp-vue/dist/mp.runtime.esm.js +3 -2
  89. package/packages/mp-vue/package.json +1 -0
  90. package/packages/uni-app/LICENSE +202 -0
  91. package/packages/uni-app/dist/uni-app.cjs.js +165 -0
  92. package/packages/uni-app/dist/uni-app.d.ts +61 -0
  93. package/packages/uni-app/dist/uni-app.es.js +108 -0
  94. package/packages/uni-app/package.json +22 -0
  95. package/packages/uni-cloud/dist/index.js +1 -1
  96. package/packages/uni-stat/dist/uni-stat.cjs.js +961 -0
  97. package/packages/uni-stat/dist/uni-stat.es.js +959 -0
  98. package/packages/uni-stat/lib/uni.plugin.js +68 -0
  99. package/packages/uni-stat/package.json +25 -0
  100. package/packages/vue3/node_modules/.yarn-integrity +27 -0
  101. package/packages/vue3/node_modules/@intlify/core-base/LICENSE +20 -0
  102. package/packages/vue3/node_modules/@intlify/core-base/README.md +7 -0
  103. package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.cjs.js +989 -0
  104. package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.cjs.prod.js +735 -0
  105. package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.d.ts +576 -0
  106. package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.esm-browser.js +2771 -0
  107. package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.esm-browser.prod.js +6 -0
  108. package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.esm-bundler.js +965 -0
  109. package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.global.js +2814 -0
  110. package/packages/vue3/node_modules/@intlify/core-base/dist/core-base.global.prod.js +6 -0
  111. package/packages/vue3/node_modules/@intlify/core-base/index.js +7 -0
  112. package/packages/vue3/node_modules/@intlify/core-base/package.json +59 -0
  113. package/packages/vue3/node_modules/@intlify/devtools-if/LICENSE +20 -0
  114. package/packages/vue3/node_modules/@intlify/devtools-if/README.md +13 -0
  115. package/packages/vue3/node_modules/@intlify/devtools-if/dist/devtools-if.cjs.js +15 -0
  116. package/packages/vue3/node_modules/@intlify/devtools-if/dist/devtools-if.cjs.prod.js +15 -0
  117. package/packages/vue3/node_modules/@intlify/devtools-if/dist/devtools-if.d.ts +43 -0
  118. package/packages/vue3/node_modules/@intlify/devtools-if/dist/devtools-if.esm-bundler.js +11 -0
  119. package/packages/vue3/node_modules/@intlify/devtools-if/index.js +7 -0
  120. package/packages/vue3/node_modules/@intlify/devtools-if/package.json +49 -0
  121. package/packages/vue3/node_modules/@intlify/message-compiler/LICENSE +20 -0
  122. package/packages/vue3/node_modules/@intlify/message-compiler/README.md +7 -0
  123. package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js +1400 -0
  124. package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.prod.js +1395 -0
  125. package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.d.ts +197 -0
  126. package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.js +1348 -0
  127. package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.esm-browser.prod.js +6 -0
  128. package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.esm-bundler.js +1329 -0
  129. package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.global.js +1365 -0
  130. package/packages/vue3/node_modules/@intlify/message-compiler/dist/message-compiler.global.prod.js +6 -0
  131. package/packages/vue3/node_modules/@intlify/message-compiler/index.js +7 -0
  132. package/packages/vue3/node_modules/@intlify/message-compiler/package.json +56 -0
  133. package/packages/vue3/node_modules/@intlify/message-resolver/LICENSE +20 -0
  134. package/packages/vue3/node_modules/@intlify/message-resolver/README.md +7 -0
  135. package/packages/vue3/node_modules/@intlify/message-resolver/dist/message-resolver.cjs.js +302 -0
  136. package/packages/vue3/node_modules/@intlify/message-resolver/dist/message-resolver.cjs.prod.js +302 -0
  137. package/packages/vue3/node_modules/@intlify/message-resolver/dist/message-resolver.d.ts +21 -0
  138. package/packages/vue3/node_modules/@intlify/message-resolver/dist/message-resolver.esm-bundler.js +297 -0
  139. package/packages/vue3/node_modules/@intlify/message-resolver/index.js +7 -0
  140. package/packages/vue3/node_modules/@intlify/message-resolver/package.json +46 -0
  141. package/packages/vue3/node_modules/@intlify/runtime/LICENSE +20 -0
  142. package/packages/vue3/node_modules/@intlify/runtime/README.md +7 -0
  143. package/packages/vue3/node_modules/@intlify/runtime/dist/runtime.cjs.js +116 -0
  144. package/packages/vue3/node_modules/@intlify/runtime/dist/runtime.cjs.prod.js +116 -0
  145. package/packages/vue3/node_modules/@intlify/runtime/dist/runtime.d.ts +95 -0
  146. package/packages/vue3/node_modules/@intlify/runtime/dist/runtime.esm-bundler.js +111 -0
  147. package/packages/vue3/node_modules/@intlify/runtime/index.js +7 -0
  148. package/packages/vue3/node_modules/@intlify/runtime/package.json +51 -0
  149. package/packages/vue3/node_modules/@intlify/shared/LICENSE +20 -0
  150. package/packages/vue3/node_modules/@intlify/shared/README.md +18 -0
  151. package/packages/vue3/node_modules/@intlify/shared/dist/shared.cjs.js +222 -0
  152. package/packages/vue3/node_modules/@intlify/shared/dist/shared.cjs.prod.js +209 -0
  153. package/packages/vue3/node_modules/@intlify/shared/dist/shared.d.ts +145 -0
  154. package/packages/vue3/node_modules/@intlify/shared/dist/shared.esm-bundler.js +192 -0
  155. package/packages/vue3/node_modules/@intlify/shared/index.js +7 -0
  156. package/packages/vue3/node_modules/@intlify/shared/package.json +46 -0
  157. package/packages/vue3/node_modules/@intlify/vue-devtools/LICENSE +20 -0
  158. package/packages/vue3/node_modules/@intlify/vue-devtools/README.md +7 -0
  159. package/packages/vue3/node_modules/@intlify/vue-devtools/dist/vue-devtools.cjs.js +24 -0
  160. package/packages/vue3/node_modules/@intlify/vue-devtools/dist/vue-devtools.cjs.prod.js +24 -0
  161. package/packages/vue3/node_modules/@intlify/vue-devtools/dist/vue-devtools.d.ts +81 -0
  162. package/packages/vue3/node_modules/@intlify/vue-devtools/dist/vue-devtools.esm-bundler.js +18 -0
  163. package/packages/vue3/node_modules/@intlify/vue-devtools/index.js +7 -0
  164. package/packages/vue3/node_modules/@intlify/vue-devtools/package.json +51 -0
  165. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/api.d.ts +90 -0
  166. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/api.js +2 -0
  167. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/app.d.ts +1 -0
  168. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/app.js +2 -0
  169. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/component.d.ts +76 -0
  170. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/component.js +2 -0
  171. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/context.d.ts +5 -0
  172. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/context.js +2 -0
  173. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/hooks.d.ts +169 -0
  174. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js +2 -0
  175. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/index.d.ts +6 -0
  176. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/index.js +18 -0
  177. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/util.d.ts +4 -0
  178. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/api/util.js +2 -0
  179. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/const.d.ts +1 -0
  180. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/const.js +4 -0
  181. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/env.d.ts +10 -0
  182. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/env.js +16 -0
  183. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/index.d.ts +14 -0
  184. package/packages/vue3/node_modules/@vue/devtools-api/lib/cjs/index.js +31 -0
  185. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/api.js +0 -0
  186. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/app.js +0 -0
  187. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/component.js +0 -0
  188. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/context.js +0 -0
  189. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/hooks.js +0 -0
  190. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/index.js +6 -0
  191. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/api/util.js +0 -0
  192. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/const.js +1 -0
  193. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/env.js +11 -0
  194. package/packages/vue3/node_modules/@vue/devtools-api/lib/esm/index.js +17 -0
  195. package/packages/vue3/node_modules/@vue/devtools-api/package.json +38 -0
  196. package/packages/vue3/node_modules/source-map/CHANGELOG.md +301 -0
  197. package/packages/vue3/node_modules/source-map/LICENSE +28 -0
  198. package/packages/vue3/node_modules/source-map/README.md +742 -0
  199. package/packages/vue3/node_modules/source-map/dist/source-map.debug.js +3234 -0
  200. package/packages/vue3/node_modules/source-map/dist/source-map.js +3233 -0
  201. package/packages/vue3/node_modules/source-map/dist/source-map.min.js +2 -0
  202. package/packages/vue3/node_modules/source-map/dist/source-map.min.js.map +1 -0
  203. package/packages/vue3/node_modules/source-map/lib/array-set.js +121 -0
  204. package/packages/vue3/node_modules/source-map/lib/base64-vlq.js +140 -0
  205. package/packages/vue3/node_modules/source-map/lib/base64.js +67 -0
  206. package/packages/vue3/node_modules/source-map/lib/binary-search.js +111 -0
  207. package/packages/vue3/node_modules/source-map/lib/mapping-list.js +79 -0
  208. package/packages/vue3/node_modules/source-map/lib/quick-sort.js +114 -0
  209. package/packages/vue3/node_modules/source-map/lib/source-map-consumer.js +1145 -0
  210. package/packages/vue3/node_modules/source-map/lib/source-map-generator.js +425 -0
  211. package/packages/vue3/node_modules/source-map/lib/source-node.js +413 -0
  212. package/packages/vue3/node_modules/source-map/lib/util.js +488 -0
  213. package/packages/vue3/node_modules/source-map/package.json +73 -0
  214. package/packages/vue3/node_modules/source-map/source-map.d.ts +98 -0
  215. package/packages/vue3/node_modules/source-map/source-map.js +8 -0
  216. package/packages/vue3/node_modules/vue-i18n/LICENSE +20 -0
  217. package/packages/vue3/node_modules/vue-i18n/README.md +74 -0
  218. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.cjs.js +1801 -0
  219. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.cjs.prod.js +1685 -0
  220. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.d.ts +3302 -0
  221. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.esm-browser.js +5052 -0
  222. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.esm-browser.prod.js +6 -0
  223. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.esm-bundler.js +2226 -0
  224. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.global.js +5065 -0
  225. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.global.prod.js +6 -0
  226. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.js +3724 -0
  227. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-browser.prod.js +6 -0
  228. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-bundler.js +2224 -0
  229. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.global.js +3737 -0
  230. package/packages/vue3/node_modules/vue-i18n/dist/vue-i18n.runtime.global.prod.js +6 -0
  231. package/packages/vue3/node_modules/vue-i18n/index.js +7 -0
  232. package/packages/vue3/node_modules/vue-i18n/package.json +69 -0
  233. package/packages/vue3/node_modules/vue-i18n/vetur/attributes.json +62 -0
  234. package/packages/vue3/node_modules/vue-i18n/vetur/tags.json +14 -0
  235. package/packages/vue3/package.json +15 -0
  236. package/packages/vue3/yarn.lock +79 -0
  237. package/packages/vuex/CHANGELOG.md +604 -0
  238. package/packages/vuex/LICENSE +21 -0
  239. package/packages/vuex/README.md +55 -0
  240. package/packages/vuex/dist/vuex.cjs.js +1474 -0
  241. package/packages/vuex/dist/vuex.esm-browser.js +1472 -0
  242. package/packages/vuex/dist/vuex.esm-browser.prod.js +1307 -0
  243. package/packages/vuex/dist/vuex.esm-bundler.js +1473 -0
  244. package/packages/vuex/dist/vuex.global.js +1499 -0
  245. package/packages/vuex/dist/vuex.global.prod.js +6 -0
  246. package/packages/vuex/dist/vuex.mjs +32 -0
  247. package/packages/vuex/package.json +99 -0
  248. package/packages/vuex/types/helpers.d.ts +86 -0
  249. package/packages/vuex/types/index.d.ts +167 -0
  250. package/packages/vuex/types/logger.d.ts +20 -0
  251. package/packages/vuex/types/vue.d.ts +12 -0
  252. package/packages/vuex3/CHANGELOG.md +356 -0
  253. package/packages/vuex3/LICENSE +21 -0
  254. package/packages/vuex3/README.md +59 -0
  255. package/packages/vuex3/dist/logger.js +155 -0
  256. package/packages/vuex3/dist/vuex.common.js +1244 -0
  257. package/packages/vuex3/dist/vuex.esm.browser.js +1200 -0
  258. package/packages/vuex3/dist/vuex.esm.browser.min.js +6 -0
  259. package/packages/vuex3/dist/vuex.esm.js +1243 -0
  260. package/packages/vuex3/dist/vuex.js +1250 -0
  261. package/packages/vuex3/dist/vuex.min.js +6 -0
  262. package/packages/vuex3/dist/vuex.mjs +26 -0
  263. package/packages/vuex3/package.json +96 -0
  264. package/packages/vuex3/types/helpers.d.ts +86 -0
  265. package/packages/vuex3/types/index.d.ts +164 -0
  266. package/packages/vuex3/types/logger.d.ts +20 -0
  267. package/packages/vuex3/types/vue.d.ts +18 -0
  268. package/packages/webpack-uni-app-loader/plugin/index.js +8 -2
  269. package/packages/webpack-uni-app-loader/view/main.js +12 -0
@@ -0,0 +1,1329 @@
1
+ /*!
2
+ * @intlify/message-compiler v9.1.7
3
+ * (c) 2021 kazuya kawaguchi
4
+ * Released under the MIT License.
5
+ */
6
+ import { format, assign, isString } from '@intlify/shared';
7
+
8
+ /** @internal */
9
+ const errorMessages = {
10
+ // tokenizer error messages
11
+ [0 /* EXPECTED_TOKEN */]: `Expected token: '{0}'`,
12
+ [1 /* INVALID_TOKEN_IN_PLACEHOLDER */]: `Invalid token in placeholder: '{0}'`,
13
+ [2 /* UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER */]: `Unterminated single quote in placeholder`,
14
+ [3 /* UNKNOWN_ESCAPE_SEQUENCE */]: `Unknown escape sequence: \\{0}`,
15
+ [4 /* INVALID_UNICODE_ESCAPE_SEQUENCE */]: `Invalid unicode escape sequence: {0}`,
16
+ [5 /* UNBALANCED_CLOSING_BRACE */]: `Unbalanced closing brace`,
17
+ [6 /* UNTERMINATED_CLOSING_BRACE */]: `Unterminated closing brace`,
18
+ [7 /* EMPTY_PLACEHOLDER */]: `Empty placeholder`,
19
+ [8 /* NOT_ALLOW_NEST_PLACEHOLDER */]: `Not allowed nest placeholder`,
20
+ [9 /* INVALID_LINKED_FORMAT */]: `Invalid linked format`,
21
+ // parser error messages
22
+ [10 /* MUST_HAVE_MESSAGES_IN_PLURAL */]: `Plural must have messages`,
23
+ [11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */]: `Unexpected empty linked modifier`,
24
+ [12 /* UNEXPECTED_EMPTY_LINKED_KEY */]: `Unexpected empty linked key`,
25
+ [13 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'`
26
+ };
27
+ function createCompileError(code, loc, options = {}) {
28
+ const { domain, messages, args } = options;
29
+ const msg = (process.env.NODE_ENV !== 'production')
30
+ ? format((messages || errorMessages)[code] || '', ...(args || []))
31
+ : code;
32
+ const error = new SyntaxError(String(msg));
33
+ error.code = code;
34
+ if (loc) {
35
+ error.location = loc;
36
+ }
37
+ error.domain = domain;
38
+ return error;
39
+ }
40
+ /** @internal */
41
+ function defaultOnError(error) {
42
+ throw error;
43
+ }
44
+
45
+ const LocationStub = {
46
+ start: { line: 1, column: 1, offset: 0 },
47
+ end: { line: 1, column: 1, offset: 0 }
48
+ };
49
+ function createPosition(line, column, offset) {
50
+ return { line, column, offset };
51
+ }
52
+ function createLocation(start, end, source) {
53
+ const loc = { start, end };
54
+ if (source != null) {
55
+ loc.source = source;
56
+ }
57
+ return loc;
58
+ }
59
+
60
+ const CHAR_SP = ' ';
61
+ const CHAR_CR = '\r';
62
+ const CHAR_LF = '\n';
63
+ const CHAR_LS = String.fromCharCode(0x2028);
64
+ const CHAR_PS = String.fromCharCode(0x2029);
65
+ function createScanner(str) {
66
+ const _buf = str;
67
+ let _index = 0;
68
+ let _line = 1;
69
+ let _column = 1;
70
+ let _peekOffset = 0;
71
+ const isCRLF = (index) => _buf[index] === CHAR_CR && _buf[index + 1] === CHAR_LF;
72
+ const isLF = (index) => _buf[index] === CHAR_LF;
73
+ const isPS = (index) => _buf[index] === CHAR_PS;
74
+ const isLS = (index) => _buf[index] === CHAR_LS;
75
+ const isLineEnd = (index) => isCRLF(index) || isLF(index) || isPS(index) || isLS(index);
76
+ const index = () => _index;
77
+ const line = () => _line;
78
+ const column = () => _column;
79
+ const peekOffset = () => _peekOffset;
80
+ const charAt = (offset) => isCRLF(offset) || isPS(offset) || isLS(offset) ? CHAR_LF : _buf[offset];
81
+ const currentChar = () => charAt(_index);
82
+ const currentPeek = () => charAt(_index + _peekOffset);
83
+ function next() {
84
+ _peekOffset = 0;
85
+ if (isLineEnd(_index)) {
86
+ _line++;
87
+ _column = 0;
88
+ }
89
+ if (isCRLF(_index)) {
90
+ _index++;
91
+ }
92
+ _index++;
93
+ _column++;
94
+ return _buf[_index];
95
+ }
96
+ function peek() {
97
+ if (isCRLF(_index + _peekOffset)) {
98
+ _peekOffset++;
99
+ }
100
+ _peekOffset++;
101
+ return _buf[_index + _peekOffset];
102
+ }
103
+ function reset() {
104
+ _index = 0;
105
+ _line = 1;
106
+ _column = 1;
107
+ _peekOffset = 0;
108
+ }
109
+ function resetPeek(offset = 0) {
110
+ _peekOffset = offset;
111
+ }
112
+ function skipToPeek() {
113
+ const target = _index + _peekOffset;
114
+ // eslint-disable-next-line no-unmodified-loop-condition
115
+ while (target !== _index) {
116
+ next();
117
+ }
118
+ _peekOffset = 0;
119
+ }
120
+ return {
121
+ index,
122
+ line,
123
+ column,
124
+ peekOffset,
125
+ charAt,
126
+ currentChar,
127
+ currentPeek,
128
+ next,
129
+ peek,
130
+ reset,
131
+ resetPeek,
132
+ skipToPeek
133
+ };
134
+ }
135
+
136
+ const EOF = undefined;
137
+ const LITERAL_DELIMITER = "'";
138
+ const ERROR_DOMAIN$1 = 'tokenizer';
139
+ function createTokenizer(source, options = {}) {
140
+ const location = options.location !== false;
141
+ const _scnr = createScanner(source);
142
+ const currentOffset = () => _scnr.index();
143
+ const currentPosition = () => createPosition(_scnr.line(), _scnr.column(), _scnr.index());
144
+ const _initLoc = currentPosition();
145
+ const _initOffset = currentOffset();
146
+ const _context = {
147
+ currentType: 14 /* EOF */,
148
+ offset: _initOffset,
149
+ startLoc: _initLoc,
150
+ endLoc: _initLoc,
151
+ lastType: 14 /* EOF */,
152
+ lastOffset: _initOffset,
153
+ lastStartLoc: _initLoc,
154
+ lastEndLoc: _initLoc,
155
+ braceNest: 0,
156
+ inLinked: false,
157
+ text: ''
158
+ };
159
+ const context = () => _context;
160
+ const { onError } = options;
161
+ function emitError(code, pos, offset, ...args) {
162
+ const ctx = context();
163
+ pos.column += offset;
164
+ pos.offset += offset;
165
+ if (onError) {
166
+ const loc = createLocation(ctx.startLoc, pos);
167
+ const err = createCompileError(code, loc, {
168
+ domain: ERROR_DOMAIN$1,
169
+ args
170
+ });
171
+ onError(err);
172
+ }
173
+ }
174
+ function getToken(context, type, value) {
175
+ context.endLoc = currentPosition();
176
+ context.currentType = type;
177
+ const token = { type };
178
+ if (location) {
179
+ token.loc = createLocation(context.startLoc, context.endLoc);
180
+ }
181
+ if (value != null) {
182
+ token.value = value;
183
+ }
184
+ return token;
185
+ }
186
+ const getEndToken = (context) => getToken(context, 14 /* EOF */);
187
+ function eat(scnr, ch) {
188
+ if (scnr.currentChar() === ch) {
189
+ scnr.next();
190
+ return ch;
191
+ }
192
+ else {
193
+ emitError(0 /* EXPECTED_TOKEN */, currentPosition(), 0, ch);
194
+ return '';
195
+ }
196
+ }
197
+ function peekSpaces(scnr) {
198
+ let buf = '';
199
+ while (scnr.currentPeek() === CHAR_SP || scnr.currentPeek() === CHAR_LF) {
200
+ buf += scnr.currentPeek();
201
+ scnr.peek();
202
+ }
203
+ return buf;
204
+ }
205
+ function skipSpaces(scnr) {
206
+ const buf = peekSpaces(scnr);
207
+ scnr.skipToPeek();
208
+ return buf;
209
+ }
210
+ function isIdentifierStart(ch) {
211
+ if (ch === EOF) {
212
+ return false;
213
+ }
214
+ const cc = ch.charCodeAt(0);
215
+ return ((cc >= 97 && cc <= 122) || // a-z
216
+ (cc >= 65 && cc <= 90) || // A-Z
217
+ cc === 95 // _
218
+ );
219
+ }
220
+ function isNumberStart(ch) {
221
+ if (ch === EOF) {
222
+ return false;
223
+ }
224
+ const cc = ch.charCodeAt(0);
225
+ return cc >= 48 && cc <= 57; // 0-9
226
+ }
227
+ function isNamedIdentifierStart(scnr, context) {
228
+ const { currentType } = context;
229
+ if (currentType !== 2 /* BraceLeft */) {
230
+ return false;
231
+ }
232
+ peekSpaces(scnr);
233
+ const ret = isIdentifierStart(scnr.currentPeek());
234
+ scnr.resetPeek();
235
+ return ret;
236
+ }
237
+ function isListIdentifierStart(scnr, context) {
238
+ const { currentType } = context;
239
+ if (currentType !== 2 /* BraceLeft */) {
240
+ return false;
241
+ }
242
+ peekSpaces(scnr);
243
+ const ch = scnr.currentPeek() === '-' ? scnr.peek() : scnr.currentPeek();
244
+ const ret = isNumberStart(ch);
245
+ scnr.resetPeek();
246
+ return ret;
247
+ }
248
+ function isLiteralStart(scnr, context) {
249
+ const { currentType } = context;
250
+ if (currentType !== 2 /* BraceLeft */) {
251
+ return false;
252
+ }
253
+ peekSpaces(scnr);
254
+ const ret = scnr.currentPeek() === LITERAL_DELIMITER;
255
+ scnr.resetPeek();
256
+ return ret;
257
+ }
258
+ function isLinkedDotStart(scnr, context) {
259
+ const { currentType } = context;
260
+ if (currentType !== 8 /* LinkedAlias */) {
261
+ return false;
262
+ }
263
+ peekSpaces(scnr);
264
+ const ret = scnr.currentPeek() === "." /* LinkedDot */;
265
+ scnr.resetPeek();
266
+ return ret;
267
+ }
268
+ function isLinkedModifierStart(scnr, context) {
269
+ const { currentType } = context;
270
+ if (currentType !== 9 /* LinkedDot */) {
271
+ return false;
272
+ }
273
+ peekSpaces(scnr);
274
+ const ret = isIdentifierStart(scnr.currentPeek());
275
+ scnr.resetPeek();
276
+ return ret;
277
+ }
278
+ function isLinkedDelimiterStart(scnr, context) {
279
+ const { currentType } = context;
280
+ if (!(currentType === 8 /* LinkedAlias */ ||
281
+ currentType === 12 /* LinkedModifier */)) {
282
+ return false;
283
+ }
284
+ peekSpaces(scnr);
285
+ const ret = scnr.currentPeek() === ":" /* LinkedDelimiter */;
286
+ scnr.resetPeek();
287
+ return ret;
288
+ }
289
+ function isLinkedReferStart(scnr, context) {
290
+ const { currentType } = context;
291
+ if (currentType !== 10 /* LinkedDelimiter */) {
292
+ return false;
293
+ }
294
+ const fn = () => {
295
+ const ch = scnr.currentPeek();
296
+ if (ch === "{" /* BraceLeft */) {
297
+ return isIdentifierStart(scnr.peek());
298
+ }
299
+ else if (ch === "@" /* LinkedAlias */ ||
300
+ ch === "%" /* Modulo */ ||
301
+ ch === "|" /* Pipe */ ||
302
+ ch === ":" /* LinkedDelimiter */ ||
303
+ ch === "." /* LinkedDot */ ||
304
+ ch === CHAR_SP ||
305
+ !ch) {
306
+ return false;
307
+ }
308
+ else if (ch === CHAR_LF) {
309
+ scnr.peek();
310
+ return fn();
311
+ }
312
+ else {
313
+ // other characters
314
+ return isIdentifierStart(ch);
315
+ }
316
+ };
317
+ const ret = fn();
318
+ scnr.resetPeek();
319
+ return ret;
320
+ }
321
+ function isPluralStart(scnr) {
322
+ peekSpaces(scnr);
323
+ const ret = scnr.currentPeek() === "|" /* Pipe */;
324
+ scnr.resetPeek();
325
+ return ret;
326
+ }
327
+ function isTextStart(scnr, reset = true) {
328
+ const fn = (hasSpace = false, prev = '', detectModulo = false) => {
329
+ const ch = scnr.currentPeek();
330
+ if (ch === "{" /* BraceLeft */) {
331
+ return prev === "%" /* Modulo */ ? false : hasSpace;
332
+ }
333
+ else if (ch === "@" /* LinkedAlias */ || !ch) {
334
+ return prev === "%" /* Modulo */ ? true : hasSpace;
335
+ }
336
+ else if (ch === "%" /* Modulo */) {
337
+ scnr.peek();
338
+ return fn(hasSpace, "%" /* Modulo */, true);
339
+ }
340
+ else if (ch === "|" /* Pipe */) {
341
+ return prev === "%" /* Modulo */ || detectModulo
342
+ ? true
343
+ : !(prev === CHAR_SP || prev === CHAR_LF);
344
+ }
345
+ else if (ch === CHAR_SP) {
346
+ scnr.peek();
347
+ return fn(true, CHAR_SP, detectModulo);
348
+ }
349
+ else if (ch === CHAR_LF) {
350
+ scnr.peek();
351
+ return fn(true, CHAR_LF, detectModulo);
352
+ }
353
+ else {
354
+ return true;
355
+ }
356
+ };
357
+ const ret = fn();
358
+ reset && scnr.resetPeek();
359
+ return ret;
360
+ }
361
+ function takeChar(scnr, fn) {
362
+ const ch = scnr.currentChar();
363
+ if (ch === EOF) {
364
+ return EOF;
365
+ }
366
+ if (fn(ch)) {
367
+ scnr.next();
368
+ return ch;
369
+ }
370
+ return null;
371
+ }
372
+ function takeIdentifierChar(scnr) {
373
+ const closure = (ch) => {
374
+ const cc = ch.charCodeAt(0);
375
+ return ((cc >= 97 && cc <= 122) || // a-z
376
+ (cc >= 65 && cc <= 90) || // A-Z
377
+ (cc >= 48 && cc <= 57) || // 0-9
378
+ cc === 95 || // _
379
+ cc === 36 // $
380
+ );
381
+ };
382
+ return takeChar(scnr, closure);
383
+ }
384
+ function takeDigit(scnr) {
385
+ const closure = (ch) => {
386
+ const cc = ch.charCodeAt(0);
387
+ return cc >= 48 && cc <= 57; // 0-9
388
+ };
389
+ return takeChar(scnr, closure);
390
+ }
391
+ function takeHexDigit(scnr) {
392
+ const closure = (ch) => {
393
+ const cc = ch.charCodeAt(0);
394
+ return ((cc >= 48 && cc <= 57) || // 0-9
395
+ (cc >= 65 && cc <= 70) || // A-F
396
+ (cc >= 97 && cc <= 102)); // a-f
397
+ };
398
+ return takeChar(scnr, closure);
399
+ }
400
+ function getDigits(scnr) {
401
+ let ch = '';
402
+ let num = '';
403
+ while ((ch = takeDigit(scnr))) {
404
+ num += ch;
405
+ }
406
+ return num;
407
+ }
408
+ function readText(scnr) {
409
+ const fn = (buf) => {
410
+ const ch = scnr.currentChar();
411
+ if (ch === "{" /* BraceLeft */ ||
412
+ ch === "}" /* BraceRight */ ||
413
+ ch === "@" /* LinkedAlias */ ||
414
+ !ch) {
415
+ return buf;
416
+ }
417
+ else if (ch === "%" /* Modulo */) {
418
+ if (isTextStart(scnr)) {
419
+ buf += ch;
420
+ scnr.next();
421
+ return fn(buf);
422
+ }
423
+ else {
424
+ return buf;
425
+ }
426
+ }
427
+ else if (ch === "|" /* Pipe */) {
428
+ return buf;
429
+ }
430
+ else if (ch === CHAR_SP || ch === CHAR_LF) {
431
+ if (isTextStart(scnr)) {
432
+ buf += ch;
433
+ scnr.next();
434
+ return fn(buf);
435
+ }
436
+ else if (isPluralStart(scnr)) {
437
+ return buf;
438
+ }
439
+ else {
440
+ buf += ch;
441
+ scnr.next();
442
+ return fn(buf);
443
+ }
444
+ }
445
+ else {
446
+ buf += ch;
447
+ scnr.next();
448
+ return fn(buf);
449
+ }
450
+ };
451
+ return fn('');
452
+ }
453
+ function readNamedIdentifier(scnr) {
454
+ skipSpaces(scnr);
455
+ let ch = '';
456
+ let name = '';
457
+ while ((ch = takeIdentifierChar(scnr))) {
458
+ name += ch;
459
+ }
460
+ if (scnr.currentChar() === EOF) {
461
+ emitError(6 /* UNTERMINATED_CLOSING_BRACE */, currentPosition(), 0);
462
+ }
463
+ return name;
464
+ }
465
+ function readListIdentifier(scnr) {
466
+ skipSpaces(scnr);
467
+ let value = '';
468
+ if (scnr.currentChar() === '-') {
469
+ scnr.next();
470
+ value += `-${getDigits(scnr)}`;
471
+ }
472
+ else {
473
+ value += getDigits(scnr);
474
+ }
475
+ if (scnr.currentChar() === EOF) {
476
+ emitError(6 /* UNTERMINATED_CLOSING_BRACE */, currentPosition(), 0);
477
+ }
478
+ return value;
479
+ }
480
+ function readLiteral(scnr) {
481
+ skipSpaces(scnr);
482
+ eat(scnr, `\'`);
483
+ let ch = '';
484
+ let literal = '';
485
+ const fn = (x) => x !== LITERAL_DELIMITER && x !== CHAR_LF;
486
+ while ((ch = takeChar(scnr, fn))) {
487
+ if (ch === '\\') {
488
+ literal += readEscapeSequence(scnr);
489
+ }
490
+ else {
491
+ literal += ch;
492
+ }
493
+ }
494
+ const current = scnr.currentChar();
495
+ if (current === CHAR_LF || current === EOF) {
496
+ emitError(2 /* UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER */, currentPosition(), 0);
497
+ // TODO: Is it correct really?
498
+ if (current === CHAR_LF) {
499
+ scnr.next();
500
+ eat(scnr, `\'`);
501
+ }
502
+ return literal;
503
+ }
504
+ eat(scnr, `\'`);
505
+ return literal;
506
+ }
507
+ function readEscapeSequence(scnr) {
508
+ const ch = scnr.currentChar();
509
+ switch (ch) {
510
+ case '\\':
511
+ case `\'`:
512
+ scnr.next();
513
+ return `\\${ch}`;
514
+ case 'u':
515
+ return readUnicodeEscapeSequence(scnr, ch, 4);
516
+ case 'U':
517
+ return readUnicodeEscapeSequence(scnr, ch, 6);
518
+ default:
519
+ emitError(3 /* UNKNOWN_ESCAPE_SEQUENCE */, currentPosition(), 0, ch);
520
+ return '';
521
+ }
522
+ }
523
+ function readUnicodeEscapeSequence(scnr, unicode, digits) {
524
+ eat(scnr, unicode);
525
+ let sequence = '';
526
+ for (let i = 0; i < digits; i++) {
527
+ const ch = takeHexDigit(scnr);
528
+ if (!ch) {
529
+ emitError(4 /* INVALID_UNICODE_ESCAPE_SEQUENCE */, currentPosition(), 0, `\\${unicode}${sequence}${scnr.currentChar()}`);
530
+ break;
531
+ }
532
+ sequence += ch;
533
+ }
534
+ return `\\${unicode}${sequence}`;
535
+ }
536
+ function readInvalidIdentifier(scnr) {
537
+ skipSpaces(scnr);
538
+ let ch = '';
539
+ let identifiers = '';
540
+ const closure = (ch) => ch !== "{" /* BraceLeft */ &&
541
+ ch !== "}" /* BraceRight */ &&
542
+ ch !== CHAR_SP &&
543
+ ch !== CHAR_LF;
544
+ while ((ch = takeChar(scnr, closure))) {
545
+ identifiers += ch;
546
+ }
547
+ return identifiers;
548
+ }
549
+ function readLinkedModifier(scnr) {
550
+ let ch = '';
551
+ let name = '';
552
+ while ((ch = takeIdentifierChar(scnr))) {
553
+ name += ch;
554
+ }
555
+ return name;
556
+ }
557
+ function readLinkedRefer(scnr) {
558
+ const fn = (detect = false, buf) => {
559
+ const ch = scnr.currentChar();
560
+ if (ch === "{" /* BraceLeft */ ||
561
+ ch === "%" /* Modulo */ ||
562
+ ch === "@" /* LinkedAlias */ ||
563
+ ch === "|" /* Pipe */ ||
564
+ !ch) {
565
+ return buf;
566
+ }
567
+ else if (ch === CHAR_SP) {
568
+ return buf;
569
+ }
570
+ else if (ch === CHAR_LF) {
571
+ buf += ch;
572
+ scnr.next();
573
+ return fn(detect, buf);
574
+ }
575
+ else {
576
+ buf += ch;
577
+ scnr.next();
578
+ return fn(true, buf);
579
+ }
580
+ };
581
+ return fn(false, '');
582
+ }
583
+ function readPlural(scnr) {
584
+ skipSpaces(scnr);
585
+ const plural = eat(scnr, "|" /* Pipe */);
586
+ skipSpaces(scnr);
587
+ return plural;
588
+ }
589
+ // TODO: We need refactoring of token parsing ...
590
+ function readTokenInPlaceholder(scnr, context) {
591
+ let token = null;
592
+ const ch = scnr.currentChar();
593
+ switch (ch) {
594
+ case "{" /* BraceLeft */:
595
+ if (context.braceNest >= 1) {
596
+ emitError(8 /* NOT_ALLOW_NEST_PLACEHOLDER */, currentPosition(), 0);
597
+ }
598
+ scnr.next();
599
+ token = getToken(context, 2 /* BraceLeft */, "{" /* BraceLeft */);
600
+ skipSpaces(scnr);
601
+ context.braceNest++;
602
+ return token;
603
+ case "}" /* BraceRight */:
604
+ if (context.braceNest > 0 &&
605
+ context.currentType === 2 /* BraceLeft */) {
606
+ emitError(7 /* EMPTY_PLACEHOLDER */, currentPosition(), 0);
607
+ }
608
+ scnr.next();
609
+ token = getToken(context, 3 /* BraceRight */, "}" /* BraceRight */);
610
+ context.braceNest--;
611
+ context.braceNest > 0 && skipSpaces(scnr);
612
+ if (context.inLinked && context.braceNest === 0) {
613
+ context.inLinked = false;
614
+ }
615
+ return token;
616
+ case "@" /* LinkedAlias */:
617
+ if (context.braceNest > 0) {
618
+ emitError(6 /* UNTERMINATED_CLOSING_BRACE */, currentPosition(), 0);
619
+ }
620
+ token = readTokenInLinked(scnr, context) || getEndToken(context);
621
+ context.braceNest = 0;
622
+ return token;
623
+ default:
624
+ let validNamedIdentifier = true;
625
+ let validListIdentifier = true;
626
+ let validLiteral = true;
627
+ if (isPluralStart(scnr)) {
628
+ if (context.braceNest > 0) {
629
+ emitError(6 /* UNTERMINATED_CLOSING_BRACE */, currentPosition(), 0);
630
+ }
631
+ token = getToken(context, 1 /* Pipe */, readPlural(scnr));
632
+ // reset
633
+ context.braceNest = 0;
634
+ context.inLinked = false;
635
+ return token;
636
+ }
637
+ if (context.braceNest > 0 &&
638
+ (context.currentType === 5 /* Named */ ||
639
+ context.currentType === 6 /* List */ ||
640
+ context.currentType === 7 /* Literal */)) {
641
+ emitError(6 /* UNTERMINATED_CLOSING_BRACE */, currentPosition(), 0);
642
+ context.braceNest = 0;
643
+ return readToken(scnr, context);
644
+ }
645
+ if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) {
646
+ token = getToken(context, 5 /* Named */, readNamedIdentifier(scnr));
647
+ skipSpaces(scnr);
648
+ return token;
649
+ }
650
+ if ((validListIdentifier = isListIdentifierStart(scnr, context))) {
651
+ token = getToken(context, 6 /* List */, readListIdentifier(scnr));
652
+ skipSpaces(scnr);
653
+ return token;
654
+ }
655
+ if ((validLiteral = isLiteralStart(scnr, context))) {
656
+ token = getToken(context, 7 /* Literal */, readLiteral(scnr));
657
+ skipSpaces(scnr);
658
+ return token;
659
+ }
660
+ if (!validNamedIdentifier && !validListIdentifier && !validLiteral) {
661
+ // TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ...
662
+ token = getToken(context, 13 /* InvalidPlace */, readInvalidIdentifier(scnr));
663
+ emitError(1 /* INVALID_TOKEN_IN_PLACEHOLDER */, currentPosition(), 0, token.value);
664
+ skipSpaces(scnr);
665
+ return token;
666
+ }
667
+ break;
668
+ }
669
+ return token;
670
+ }
671
+ // TODO: We need refactoring of token parsing ...
672
+ function readTokenInLinked(scnr, context) {
673
+ const { currentType } = context;
674
+ let token = null;
675
+ const ch = scnr.currentChar();
676
+ if ((currentType === 8 /* LinkedAlias */ ||
677
+ currentType === 9 /* LinkedDot */ ||
678
+ currentType === 12 /* LinkedModifier */ ||
679
+ currentType === 10 /* LinkedDelimiter */) &&
680
+ (ch === CHAR_LF || ch === CHAR_SP)) {
681
+ emitError(9 /* INVALID_LINKED_FORMAT */, currentPosition(), 0);
682
+ }
683
+ switch (ch) {
684
+ case "@" /* LinkedAlias */:
685
+ scnr.next();
686
+ token = getToken(context, 8 /* LinkedAlias */, "@" /* LinkedAlias */);
687
+ context.inLinked = true;
688
+ return token;
689
+ case "." /* LinkedDot */:
690
+ skipSpaces(scnr);
691
+ scnr.next();
692
+ return getToken(context, 9 /* LinkedDot */, "." /* LinkedDot */);
693
+ case ":" /* LinkedDelimiter */:
694
+ skipSpaces(scnr);
695
+ scnr.next();
696
+ return getToken(context, 10 /* LinkedDelimiter */, ":" /* LinkedDelimiter */);
697
+ default:
698
+ if (isPluralStart(scnr)) {
699
+ token = getToken(context, 1 /* Pipe */, readPlural(scnr));
700
+ // reset
701
+ context.braceNest = 0;
702
+ context.inLinked = false;
703
+ return token;
704
+ }
705
+ if (isLinkedDotStart(scnr, context) ||
706
+ isLinkedDelimiterStart(scnr, context)) {
707
+ skipSpaces(scnr);
708
+ return readTokenInLinked(scnr, context);
709
+ }
710
+ if (isLinkedModifierStart(scnr, context)) {
711
+ skipSpaces(scnr);
712
+ return getToken(context, 12 /* LinkedModifier */, readLinkedModifier(scnr));
713
+ }
714
+ if (isLinkedReferStart(scnr, context)) {
715
+ skipSpaces(scnr);
716
+ if (ch === "{" /* BraceLeft */) {
717
+ // scan the placeholder
718
+ return readTokenInPlaceholder(scnr, context) || token;
719
+ }
720
+ else {
721
+ return getToken(context, 11 /* LinkedKey */, readLinkedRefer(scnr));
722
+ }
723
+ }
724
+ if (currentType === 8 /* LinkedAlias */) {
725
+ emitError(9 /* INVALID_LINKED_FORMAT */, currentPosition(), 0);
726
+ }
727
+ context.braceNest = 0;
728
+ context.inLinked = false;
729
+ return readToken(scnr, context);
730
+ }
731
+ }
732
+ // TODO: We need refactoring of token parsing ...
733
+ function readToken(scnr, context) {
734
+ let token = { type: 14 /* EOF */ };
735
+ if (context.braceNest > 0) {
736
+ return readTokenInPlaceholder(scnr, context) || getEndToken(context);
737
+ }
738
+ if (context.inLinked) {
739
+ return readTokenInLinked(scnr, context) || getEndToken(context);
740
+ }
741
+ const ch = scnr.currentChar();
742
+ switch (ch) {
743
+ case "{" /* BraceLeft */:
744
+ return readTokenInPlaceholder(scnr, context) || getEndToken(context);
745
+ case "}" /* BraceRight */:
746
+ emitError(5 /* UNBALANCED_CLOSING_BRACE */, currentPosition(), 0);
747
+ scnr.next();
748
+ return getToken(context, 3 /* BraceRight */, "}" /* BraceRight */);
749
+ case "@" /* LinkedAlias */:
750
+ return readTokenInLinked(scnr, context) || getEndToken(context);
751
+ default:
752
+ if (isPluralStart(scnr)) {
753
+ token = getToken(context, 1 /* Pipe */, readPlural(scnr));
754
+ // reset
755
+ context.braceNest = 0;
756
+ context.inLinked = false;
757
+ return token;
758
+ }
759
+ if (isTextStart(scnr)) {
760
+ return getToken(context, 0 /* Text */, readText(scnr));
761
+ }
762
+ if (ch === "%" /* Modulo */) {
763
+ scnr.next();
764
+ return getToken(context, 4 /* Modulo */, "%" /* Modulo */);
765
+ }
766
+ break;
767
+ }
768
+ return token;
769
+ }
770
+ function nextToken() {
771
+ const { currentType, offset, startLoc, endLoc } = _context;
772
+ _context.lastType = currentType;
773
+ _context.lastOffset = offset;
774
+ _context.lastStartLoc = startLoc;
775
+ _context.lastEndLoc = endLoc;
776
+ _context.offset = currentOffset();
777
+ _context.startLoc = currentPosition();
778
+ if (_scnr.currentChar() === EOF) {
779
+ return getToken(_context, 14 /* EOF */);
780
+ }
781
+ return readToken(_scnr, _context);
782
+ }
783
+ return {
784
+ nextToken,
785
+ currentOffset,
786
+ currentPosition,
787
+ context
788
+ };
789
+ }
790
+
791
+ const ERROR_DOMAIN = 'parser';
792
+ // Backslash backslash, backslash quote, uHHHH, UHHHHHH.
793
+ const KNOWN_ESCAPES = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;
794
+ function fromEscapeSequence(match, codePoint4, codePoint6) {
795
+ switch (match) {
796
+ case `\\\\`:
797
+ return `\\`;
798
+ case `\\\'`:
799
+ return `\'`;
800
+ default: {
801
+ const codePoint = parseInt(codePoint4 || codePoint6, 16);
802
+ if (codePoint <= 0xd7ff || codePoint >= 0xe000) {
803
+ return String.fromCodePoint(codePoint);
804
+ }
805
+ // invalid ...
806
+ // Replace them with U+FFFD REPLACEMENT CHARACTER.
807
+ return '�';
808
+ }
809
+ }
810
+ }
811
+ function createParser(options = {}) {
812
+ const location = options.location !== false;
813
+ const { onError } = options;
814
+ function emitError(tokenzer, code, start, offset, ...args) {
815
+ const end = tokenzer.currentPosition();
816
+ end.offset += offset;
817
+ end.column += offset;
818
+ if (onError) {
819
+ const loc = createLocation(start, end);
820
+ const err = createCompileError(code, loc, {
821
+ domain: ERROR_DOMAIN,
822
+ args
823
+ });
824
+ onError(err);
825
+ }
826
+ }
827
+ function startNode(type, offset, loc) {
828
+ const node = {
829
+ type,
830
+ start: offset,
831
+ end: offset
832
+ };
833
+ if (location) {
834
+ node.loc = { start: loc, end: loc };
835
+ }
836
+ return node;
837
+ }
838
+ function endNode(node, offset, pos, type) {
839
+ node.end = offset;
840
+ if (type) {
841
+ node.type = type;
842
+ }
843
+ if (location && node.loc) {
844
+ node.loc.end = pos;
845
+ }
846
+ }
847
+ function parseText(tokenizer, value) {
848
+ const context = tokenizer.context();
849
+ const node = startNode(3 /* Text */, context.offset, context.startLoc);
850
+ node.value = value;
851
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
852
+ return node;
853
+ }
854
+ function parseList(tokenizer, index) {
855
+ const context = tokenizer.context();
856
+ const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
857
+ const node = startNode(5 /* List */, offset, loc);
858
+ node.index = parseInt(index, 10);
859
+ tokenizer.nextToken(); // skip brach right
860
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
861
+ return node;
862
+ }
863
+ function parseNamed(tokenizer, key) {
864
+ const context = tokenizer.context();
865
+ const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
866
+ const node = startNode(4 /* Named */, offset, loc);
867
+ node.key = key;
868
+ tokenizer.nextToken(); // skip brach right
869
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
870
+ return node;
871
+ }
872
+ function parseLiteral(tokenizer, value) {
873
+ const context = tokenizer.context();
874
+ const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
875
+ const node = startNode(9 /* Literal */, offset, loc);
876
+ node.value = value.replace(KNOWN_ESCAPES, fromEscapeSequence);
877
+ tokenizer.nextToken(); // skip brach right
878
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
879
+ return node;
880
+ }
881
+ function parseLinkedModifier(tokenizer) {
882
+ const token = tokenizer.nextToken();
883
+ const context = tokenizer.context();
884
+ const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc
885
+ const node = startNode(8 /* LinkedModifier */, offset, loc);
886
+ if (token.type !== 12 /* LinkedModifier */) {
887
+ // empty modifier
888
+ emitError(tokenizer, 11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */, context.lastStartLoc, 0);
889
+ node.value = '';
890
+ endNode(node, offset, loc);
891
+ return {
892
+ nextConsumeToken: token,
893
+ node
894
+ };
895
+ }
896
+ // check token
897
+ if (token.value == null) {
898
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
899
+ }
900
+ node.value = token.value || '';
901
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
902
+ return {
903
+ node
904
+ };
905
+ }
906
+ function parseLinkedKey(tokenizer, value) {
907
+ const context = tokenizer.context();
908
+ const node = startNode(7 /* LinkedKey */, context.offset, context.startLoc);
909
+ node.value = value;
910
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
911
+ return node;
912
+ }
913
+ function parseLinked(tokenizer) {
914
+ const context = tokenizer.context();
915
+ const linkedNode = startNode(6 /* Linked */, context.offset, context.startLoc);
916
+ let token = tokenizer.nextToken();
917
+ if (token.type === 9 /* LinkedDot */) {
918
+ const parsed = parseLinkedModifier(tokenizer);
919
+ linkedNode.modifier = parsed.node;
920
+ token = parsed.nextConsumeToken || tokenizer.nextToken();
921
+ }
922
+ // asset check token
923
+ if (token.type !== 10 /* LinkedDelimiter */) {
924
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
925
+ }
926
+ token = tokenizer.nextToken();
927
+ // skip brace left
928
+ if (token.type === 2 /* BraceLeft */) {
929
+ token = tokenizer.nextToken();
930
+ }
931
+ switch (token.type) {
932
+ case 11 /* LinkedKey */:
933
+ if (token.value == null) {
934
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
935
+ }
936
+ linkedNode.key = parseLinkedKey(tokenizer, token.value || '');
937
+ break;
938
+ case 5 /* Named */:
939
+ if (token.value == null) {
940
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
941
+ }
942
+ linkedNode.key = parseNamed(tokenizer, token.value || '');
943
+ break;
944
+ case 6 /* List */:
945
+ if (token.value == null) {
946
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
947
+ }
948
+ linkedNode.key = parseList(tokenizer, token.value || '');
949
+ break;
950
+ case 7 /* Literal */:
951
+ if (token.value == null) {
952
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
953
+ }
954
+ linkedNode.key = parseLiteral(tokenizer, token.value || '');
955
+ break;
956
+ default:
957
+ // empty key
958
+ emitError(tokenizer, 12 /* UNEXPECTED_EMPTY_LINKED_KEY */, context.lastStartLoc, 0);
959
+ const nextContext = tokenizer.context();
960
+ const emptyLinkedKeyNode = startNode(7 /* LinkedKey */, nextContext.offset, nextContext.startLoc);
961
+ emptyLinkedKeyNode.value = '';
962
+ endNode(emptyLinkedKeyNode, nextContext.offset, nextContext.startLoc);
963
+ linkedNode.key = emptyLinkedKeyNode;
964
+ endNode(linkedNode, nextContext.offset, nextContext.startLoc);
965
+ return {
966
+ nextConsumeToken: token,
967
+ node: linkedNode
968
+ };
969
+ }
970
+ endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition());
971
+ return {
972
+ node: linkedNode
973
+ };
974
+ }
975
+ function parseMessage(tokenizer) {
976
+ const context = tokenizer.context();
977
+ const startOffset = context.currentType === 1 /* Pipe */
978
+ ? tokenizer.currentOffset()
979
+ : context.offset;
980
+ const startLoc = context.currentType === 1 /* Pipe */
981
+ ? context.endLoc
982
+ : context.startLoc;
983
+ const node = startNode(2 /* Message */, startOffset, startLoc);
984
+ node.items = [];
985
+ let nextToken = null;
986
+ do {
987
+ const token = nextToken || tokenizer.nextToken();
988
+ nextToken = null;
989
+ switch (token.type) {
990
+ case 0 /* Text */:
991
+ if (token.value == null) {
992
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
993
+ }
994
+ node.items.push(parseText(tokenizer, token.value || ''));
995
+ break;
996
+ case 6 /* List */:
997
+ if (token.value == null) {
998
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
999
+ }
1000
+ node.items.push(parseList(tokenizer, token.value || ''));
1001
+ break;
1002
+ case 5 /* Named */:
1003
+ if (token.value == null) {
1004
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
1005
+ }
1006
+ node.items.push(parseNamed(tokenizer, token.value || ''));
1007
+ break;
1008
+ case 7 /* Literal */:
1009
+ if (token.value == null) {
1010
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token));
1011
+ }
1012
+ node.items.push(parseLiteral(tokenizer, token.value || ''));
1013
+ break;
1014
+ case 8 /* LinkedAlias */:
1015
+ const parsed = parseLinked(tokenizer);
1016
+ node.items.push(parsed.node);
1017
+ nextToken = parsed.nextConsumeToken || null;
1018
+ break;
1019
+ }
1020
+ } while (context.currentType !== 14 /* EOF */ &&
1021
+ context.currentType !== 1 /* Pipe */);
1022
+ // adjust message node loc
1023
+ const endOffset = context.currentType === 1 /* Pipe */
1024
+ ? context.lastOffset
1025
+ : tokenizer.currentOffset();
1026
+ const endLoc = context.currentType === 1 /* Pipe */
1027
+ ? context.lastEndLoc
1028
+ : tokenizer.currentPosition();
1029
+ endNode(node, endOffset, endLoc);
1030
+ return node;
1031
+ }
1032
+ function parsePlural(tokenizer, offset, loc, msgNode) {
1033
+ const context = tokenizer.context();
1034
+ let hasEmptyMessage = msgNode.items.length === 0;
1035
+ const node = startNode(1 /* Plural */, offset, loc);
1036
+ node.cases = [];
1037
+ node.cases.push(msgNode);
1038
+ do {
1039
+ const msg = parseMessage(tokenizer);
1040
+ if (!hasEmptyMessage) {
1041
+ hasEmptyMessage = msg.items.length === 0;
1042
+ }
1043
+ node.cases.push(msg);
1044
+ } while (context.currentType !== 14 /* EOF */);
1045
+ if (hasEmptyMessage) {
1046
+ emitError(tokenizer, 10 /* MUST_HAVE_MESSAGES_IN_PLURAL */, loc, 0);
1047
+ }
1048
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
1049
+ return node;
1050
+ }
1051
+ function parseResource(tokenizer) {
1052
+ const context = tokenizer.context();
1053
+ const { offset, startLoc } = context;
1054
+ const msgNode = parseMessage(tokenizer);
1055
+ if (context.currentType === 14 /* EOF */) {
1056
+ return msgNode;
1057
+ }
1058
+ else {
1059
+ return parsePlural(tokenizer, offset, startLoc, msgNode);
1060
+ }
1061
+ }
1062
+ function parse(source) {
1063
+ const tokenizer = createTokenizer(source, assign({}, options));
1064
+ const context = tokenizer.context();
1065
+ const node = startNode(0 /* Resource */, context.offset, context.startLoc);
1066
+ if (location && node.loc) {
1067
+ node.loc.source = source;
1068
+ }
1069
+ node.body = parseResource(tokenizer);
1070
+ // assert whether achieved to EOF
1071
+ if (context.currentType !== 14 /* EOF */) {
1072
+ emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, source[context.offset] || '');
1073
+ }
1074
+ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
1075
+ return node;
1076
+ }
1077
+ return { parse };
1078
+ }
1079
+ function getTokenCaption(token) {
1080
+ if (token.type === 14 /* EOF */) {
1081
+ return 'EOF';
1082
+ }
1083
+ const name = (token.value || '').replace(/\r?\n/gu, '\\n');
1084
+ return name.length > 10 ? name.slice(0, 9) + '…' : name;
1085
+ }
1086
+
1087
+ function createTransformer(ast, options = {} // eslint-disable-line
1088
+ ) {
1089
+ const _context = {
1090
+ ast,
1091
+ helpers: new Set()
1092
+ };
1093
+ const context = () => _context;
1094
+ const helper = (name) => {
1095
+ _context.helpers.add(name);
1096
+ return name;
1097
+ };
1098
+ return { context, helper };
1099
+ }
1100
+ function traverseNodes(nodes, transformer) {
1101
+ for (let i = 0; i < nodes.length; i++) {
1102
+ traverseNode(nodes[i], transformer);
1103
+ }
1104
+ }
1105
+ function traverseNode(node, transformer) {
1106
+ // TODO: if we need pre-hook of transform, should be implemented to here
1107
+ switch (node.type) {
1108
+ case 1 /* Plural */:
1109
+ traverseNodes(node.cases, transformer);
1110
+ transformer.helper("plural" /* PLURAL */);
1111
+ break;
1112
+ case 2 /* Message */:
1113
+ traverseNodes(node.items, transformer);
1114
+ break;
1115
+ case 6 /* Linked */:
1116
+ const linked = node;
1117
+ traverseNode(linked.key, transformer);
1118
+ transformer.helper("linked" /* LINKED */);
1119
+ break;
1120
+ case 5 /* List */:
1121
+ transformer.helper("interpolate" /* INTERPOLATE */);
1122
+ transformer.helper("list" /* LIST */);
1123
+ break;
1124
+ case 4 /* Named */:
1125
+ transformer.helper("interpolate" /* INTERPOLATE */);
1126
+ transformer.helper("named" /* NAMED */);
1127
+ break;
1128
+ }
1129
+ // TODO: if we need post-hook of transform, should be implemented to here
1130
+ }
1131
+ // transform AST
1132
+ function transform(ast, options = {} // eslint-disable-line
1133
+ ) {
1134
+ const transformer = createTransformer(ast);
1135
+ transformer.helper("normalize" /* NORMALIZE */);
1136
+ // traverse
1137
+ ast.body && traverseNode(ast.body, transformer);
1138
+ // set meta information
1139
+ const context = transformer.context();
1140
+ ast.helpers = Array.from(context.helpers);
1141
+ }
1142
+
1143
+ function createCodeGenerator(ast, options) {
1144
+ const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options;
1145
+ const _context = {
1146
+ source: ast.loc.source,
1147
+ filename,
1148
+ code: '',
1149
+ column: 1,
1150
+ line: 1,
1151
+ offset: 0,
1152
+ map: undefined,
1153
+ breakLineCode,
1154
+ needIndent: _needIndent,
1155
+ indentLevel: 0
1156
+ };
1157
+ const context = () => _context;
1158
+ function push(code, node) {
1159
+ _context.code += code;
1160
+ }
1161
+ function _newline(n, withBreakLine = true) {
1162
+ const _breakLineCode = withBreakLine ? breakLineCode : '';
1163
+ push(_needIndent ? _breakLineCode + ` `.repeat(n) : _breakLineCode);
1164
+ }
1165
+ function indent(withNewLine = true) {
1166
+ const level = ++_context.indentLevel;
1167
+ withNewLine && _newline(level);
1168
+ }
1169
+ function deindent(withNewLine = true) {
1170
+ const level = --_context.indentLevel;
1171
+ withNewLine && _newline(level);
1172
+ }
1173
+ function newline() {
1174
+ _newline(_context.indentLevel);
1175
+ }
1176
+ const helper = (key) => `_${key}`;
1177
+ const needIndent = () => _context.needIndent;
1178
+ return {
1179
+ context,
1180
+ push,
1181
+ indent,
1182
+ deindent,
1183
+ newline,
1184
+ helper,
1185
+ needIndent
1186
+ };
1187
+ }
1188
+ function generateLinkedNode(generator, node) {
1189
+ const { helper } = generator;
1190
+ generator.push(`${helper("linked" /* LINKED */)}(`);
1191
+ generateNode(generator, node.key);
1192
+ if (node.modifier) {
1193
+ generator.push(`, `);
1194
+ generateNode(generator, node.modifier);
1195
+ }
1196
+ generator.push(`)`);
1197
+ }
1198
+ function generateMessageNode(generator, node) {
1199
+ const { helper, needIndent } = generator;
1200
+ generator.push(`${helper("normalize" /* NORMALIZE */)}([`);
1201
+ generator.indent(needIndent());
1202
+ const length = node.items.length;
1203
+ for (let i = 0; i < length; i++) {
1204
+ generateNode(generator, node.items[i]);
1205
+ if (i === length - 1) {
1206
+ break;
1207
+ }
1208
+ generator.push(', ');
1209
+ }
1210
+ generator.deindent(needIndent());
1211
+ generator.push('])');
1212
+ }
1213
+ function generatePluralNode(generator, node) {
1214
+ const { helper, needIndent } = generator;
1215
+ if (node.cases.length > 1) {
1216
+ generator.push(`${helper("plural" /* PLURAL */)}([`);
1217
+ generator.indent(needIndent());
1218
+ const length = node.cases.length;
1219
+ for (let i = 0; i < length; i++) {
1220
+ generateNode(generator, node.cases[i]);
1221
+ if (i === length - 1) {
1222
+ break;
1223
+ }
1224
+ generator.push(', ');
1225
+ }
1226
+ generator.deindent(needIndent());
1227
+ generator.push(`])`);
1228
+ }
1229
+ }
1230
+ function generateResource(generator, node) {
1231
+ if (node.body) {
1232
+ generateNode(generator, node.body);
1233
+ }
1234
+ else {
1235
+ generator.push('null');
1236
+ }
1237
+ }
1238
+ function generateNode(generator, node) {
1239
+ const { helper } = generator;
1240
+ switch (node.type) {
1241
+ case 0 /* Resource */:
1242
+ generateResource(generator, node);
1243
+ break;
1244
+ case 1 /* Plural */:
1245
+ generatePluralNode(generator, node);
1246
+ break;
1247
+ case 2 /* Message */:
1248
+ generateMessageNode(generator, node);
1249
+ break;
1250
+ case 6 /* Linked */:
1251
+ generateLinkedNode(generator, node);
1252
+ break;
1253
+ case 8 /* LinkedModifier */:
1254
+ generator.push(JSON.stringify(node.value), node);
1255
+ break;
1256
+ case 7 /* LinkedKey */:
1257
+ generator.push(JSON.stringify(node.value), node);
1258
+ break;
1259
+ case 5 /* List */:
1260
+ generator.push(`${helper("interpolate" /* INTERPOLATE */)}(${helper("list" /* LIST */)}(${node.index}))`, node);
1261
+ break;
1262
+ case 4 /* Named */:
1263
+ generator.push(`${helper("interpolate" /* INTERPOLATE */)}(${helper("named" /* NAMED */)}(${JSON.stringify(node.key)}))`, node);
1264
+ break;
1265
+ case 9 /* Literal */:
1266
+ generator.push(JSON.stringify(node.value), node);
1267
+ break;
1268
+ case 3 /* Text */:
1269
+ generator.push(JSON.stringify(node.value), node);
1270
+ break;
1271
+ default:
1272
+ if ((process.env.NODE_ENV !== 'production')) {
1273
+ throw new Error(`unhandled codegen node type: ${node.type}`);
1274
+ }
1275
+ }
1276
+ }
1277
+ // generate code from AST
1278
+ const generate = (ast, options = {} // eslint-disable-line
1279
+ ) => {
1280
+ const mode = isString(options.mode) ? options.mode : 'normal';
1281
+ const filename = isString(options.filename)
1282
+ ? options.filename
1283
+ : 'message.intl';
1284
+ const sourceMap = !!options.sourceMap;
1285
+ // prettier-ignore
1286
+ const breakLineCode = options.breakLineCode != null
1287
+ ? options.breakLineCode
1288
+ : mode === 'arrow'
1289
+ ? ';'
1290
+ : '\n';
1291
+ const needIndent = options.needIndent ? options.needIndent : mode !== 'arrow';
1292
+ const helpers = ast.helpers || [];
1293
+ const generator = createCodeGenerator(ast, {
1294
+ mode,
1295
+ filename,
1296
+ sourceMap,
1297
+ breakLineCode,
1298
+ needIndent
1299
+ });
1300
+ generator.push(mode === 'normal' ? `function __msg__ (ctx) {` : `(ctx) => {`);
1301
+ generator.indent(needIndent);
1302
+ if (helpers.length > 0) {
1303
+ generator.push(`const { ${helpers.map(s => `${s}: _${s}`).join(', ')} } = ctx`);
1304
+ generator.newline();
1305
+ }
1306
+ generator.push(`return `);
1307
+ generateNode(generator, ast);
1308
+ generator.deindent(needIndent);
1309
+ generator.push(`}`);
1310
+ const { code, map } = generator.context();
1311
+ return {
1312
+ ast,
1313
+ code,
1314
+ map: map ? map.toJSON() : undefined // eslint-disable-line @typescript-eslint/no-explicit-any
1315
+ };
1316
+ };
1317
+
1318
+ function baseCompile(source, options = {}) {
1319
+ const assignedOptions = assign({}, options);
1320
+ // parse source codes
1321
+ const parser = createParser(assignedOptions);
1322
+ const ast = parser.parse(source);
1323
+ // transform ASTs
1324
+ transform(ast, assignedOptions);
1325
+ // generate javascript codes
1326
+ return generate(ast, assignedOptions);
1327
+ }
1328
+
1329
+ export { ERROR_DOMAIN, LocationStub, baseCompile, createCompileError, createLocation, createParser, createPosition, defaultOnError, errorMessages };