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