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