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