@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,1685 @@
1
+ /*!
2
+ * vue-i18n 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 coreBase = require('@intlify/core-base');
11
+ var vue = require('vue');
12
+ var shared = require('@intlify/shared');
13
+
14
+ /**
15
+ * Vue I18n Version
16
+ *
17
+ * @remarks
18
+ * Semver format. Same format as the package.json `version` field.
19
+ *
20
+ * @VueI18nGeneral
21
+ */
22
+ const VERSION = '9.1.7';
23
+
24
+ function createI18nError(code, ...args) {
25
+ return coreBase.createCompileError(code, null, undefined);
26
+ }
27
+
28
+ const TransrateVNodeSymbol = shared.makeSymbol('__transrateVNode');
29
+ const DatetimePartsSymbol = shared.makeSymbol('__datetimeParts');
30
+ const NumberPartsSymbol = shared.makeSymbol('__numberParts');
31
+ shared.makeSymbol('__enableEmitter');
32
+ shared.makeSymbol('__disableEmitter');
33
+ const SetPluralRulesSymbol = shared.makeSymbol('__setPluralRules');
34
+ shared.makeSymbol('__intlifyMeta');
35
+ let composerID = 0;
36
+ function defineCoreMissingHandler(missing) {
37
+ return ((ctx, locale, key, type) => {
38
+ return missing(locale, key, vue.getCurrentInstance() || undefined, type);
39
+ });
40
+ }
41
+ function getLocaleMessages(locale, options) {
42
+ const { messages, __i18n } = options;
43
+ // prettier-ignore
44
+ const ret = shared.isPlainObject(messages)
45
+ ? messages
46
+ : shared.isArray(__i18n)
47
+ ? {}
48
+ : { [locale]: {} };
49
+ // merge locale messages of i18n custom block
50
+ if (shared.isArray(__i18n)) {
51
+ __i18n.forEach(({ locale, resource }) => {
52
+ if (locale) {
53
+ ret[locale] = ret[locale] || {};
54
+ deepCopy(resource, ret[locale]);
55
+ }
56
+ else {
57
+ deepCopy(resource, ret);
58
+ }
59
+ });
60
+ }
61
+ // handle messages for flat json
62
+ if (options.flatJson) {
63
+ for (const key in ret) {
64
+ if (shared.hasOwn(ret, key)) {
65
+ coreBase.handleFlatJson(ret[key]);
66
+ }
67
+ }
68
+ }
69
+ return ret;
70
+ }
71
+ const isNotObjectOrIsArray = (val) => !shared.isObject(val) || shared.isArray(val);
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ function deepCopy(src, des) {
74
+ // src and des should both be objects, and non of then can be a array
75
+ if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) {
76
+ throw createI18nError(20 /* INVALID_VALUE */);
77
+ }
78
+ for (const key in src) {
79
+ if (shared.hasOwn(src, key)) {
80
+ if (isNotObjectOrIsArray(src[key]) || isNotObjectOrIsArray(des[key])) {
81
+ // replace with src[key] when:
82
+ // src[key] or des[key] is not a object, or
83
+ // src[key] or des[key] is a array
84
+ des[key] = src[key];
85
+ }
86
+ else {
87
+ // src[key] and des[key] are both object, merge them
88
+ deepCopy(src[key], des[key]);
89
+ }
90
+ }
91
+ }
92
+ }
93
+ /**
94
+ * Create composer interface factory
95
+ *
96
+ * @internal
97
+ */
98
+ function createComposer(options = {}) {
99
+ const { __root } = options;
100
+ const _isGlobal = __root === undefined;
101
+ let _inheritLocale = shared.isBoolean(options.inheritLocale)
102
+ ? options.inheritLocale
103
+ : true;
104
+ const _locale = vue.ref(
105
+ // prettier-ignore
106
+ __root && _inheritLocale
107
+ ? __root.locale.value
108
+ : shared.isString(options.locale)
109
+ ? options.locale
110
+ : 'en-US');
111
+ const _fallbackLocale = vue.ref(
112
+ // prettier-ignore
113
+ __root && _inheritLocale
114
+ ? __root.fallbackLocale.value
115
+ : shared.isString(options.fallbackLocale) ||
116
+ shared.isArray(options.fallbackLocale) ||
117
+ shared.isPlainObject(options.fallbackLocale) ||
118
+ options.fallbackLocale === false
119
+ ? options.fallbackLocale
120
+ : _locale.value);
121
+ const _messages = vue.ref(getLocaleMessages(_locale.value, options));
122
+ const _datetimeFormats = vue.ref(shared.isPlainObject(options.datetimeFormats)
123
+ ? options.datetimeFormats
124
+ : { [_locale.value]: {} });
125
+ const _numberFormats = vue.ref(shared.isPlainObject(options.numberFormats)
126
+ ? options.numberFormats
127
+ : { [_locale.value]: {} });
128
+ // warning suppress options
129
+ // prettier-ignore
130
+ let _missingWarn = __root
131
+ ? __root.missingWarn
132
+ : shared.isBoolean(options.missingWarn) || shared.isRegExp(options.missingWarn)
133
+ ? options.missingWarn
134
+ : true;
135
+ // prettier-ignore
136
+ let _fallbackWarn = __root
137
+ ? __root.fallbackWarn
138
+ : shared.isBoolean(options.fallbackWarn) || shared.isRegExp(options.fallbackWarn)
139
+ ? options.fallbackWarn
140
+ : true;
141
+ // prettier-ignore
142
+ let _fallbackRoot = __root
143
+ ? __root.fallbackRoot
144
+ : shared.isBoolean(options.fallbackRoot)
145
+ ? options.fallbackRoot
146
+ : true;
147
+ // configure fall back to root
148
+ let _fallbackFormat = !!options.fallbackFormat;
149
+ // runtime missing
150
+ let _missing = shared.isFunction(options.missing) ? options.missing : null;
151
+ let _runtimeMissing = shared.isFunction(options.missing)
152
+ ? defineCoreMissingHandler(options.missing)
153
+ : null;
154
+ // postTranslation handler
155
+ let _postTranslation = shared.isFunction(options.postTranslation)
156
+ ? options.postTranslation
157
+ : null;
158
+ let _warnHtmlMessage = shared.isBoolean(options.warnHtmlMessage)
159
+ ? options.warnHtmlMessage
160
+ : true;
161
+ let _escapeParameter = !!options.escapeParameter;
162
+ // custom linked modifiers
163
+ // prettier-ignore
164
+ const _modifiers = __root
165
+ ? __root.modifiers
166
+ : shared.isPlainObject(options.modifiers)
167
+ ? options.modifiers
168
+ : {};
169
+ // pluralRules
170
+ let _pluralRules = options.pluralRules || (__root && __root.pluralRules);
171
+ // runtime context
172
+ // eslint-disable-next-line prefer-const
173
+ let _context;
174
+ function getCoreContext() {
175
+ return coreBase.createCoreContext({
176
+ version: VERSION,
177
+ locale: _locale.value,
178
+ fallbackLocale: _fallbackLocale.value,
179
+ messages: _messages.value,
180
+ datetimeFormats: _datetimeFormats.value,
181
+ numberFormats: _numberFormats.value,
182
+ modifiers: _modifiers,
183
+ pluralRules: _pluralRules,
184
+ missing: _runtimeMissing === null ? undefined : _runtimeMissing,
185
+ missingWarn: _missingWarn,
186
+ fallbackWarn: _fallbackWarn,
187
+ fallbackFormat: _fallbackFormat,
188
+ unresolving: true,
189
+ postTranslation: _postTranslation === null ? undefined : _postTranslation,
190
+ warnHtmlMessage: _warnHtmlMessage,
191
+ escapeParameter: _escapeParameter,
192
+ __datetimeFormatters: shared.isPlainObject(_context)
193
+ ? _context.__datetimeFormatters
194
+ : undefined,
195
+ __numberFormatters: shared.isPlainObject(_context)
196
+ ? _context.__numberFormatters
197
+ : undefined,
198
+ __v_emitter: shared.isPlainObject(_context)
199
+ ? _context.__v_emitter
200
+ : undefined,
201
+ __meta: { framework: 'vue' }
202
+ });
203
+ }
204
+ _context = getCoreContext();
205
+ coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
206
+ // track reactivity
207
+ function trackReactivityValues() {
208
+ return [
209
+ _locale.value,
210
+ _fallbackLocale.value,
211
+ _messages.value,
212
+ _datetimeFormats.value,
213
+ _numberFormats.value
214
+ ];
215
+ }
216
+ // locale
217
+ const locale = vue.computed({
218
+ get: () => _locale.value,
219
+ set: val => {
220
+ _locale.value = val;
221
+ _context.locale = _locale.value;
222
+ }
223
+ });
224
+ // fallbackLocale
225
+ const fallbackLocale = vue.computed({
226
+ get: () => _fallbackLocale.value,
227
+ set: val => {
228
+ _fallbackLocale.value = val;
229
+ _context.fallbackLocale = _fallbackLocale.value;
230
+ coreBase.updateFallbackLocale(_context, _locale.value, val);
231
+ }
232
+ });
233
+ // messages
234
+ const messages = vue.computed(() => _messages.value);
235
+ // datetimeFormats
236
+ const datetimeFormats = vue.computed(() => _datetimeFormats.value);
237
+ // numberFormats
238
+ const numberFormats = vue.computed(() => _numberFormats.value);
239
+ // getPostTranslationHandler
240
+ function getPostTranslationHandler() {
241
+ return shared.isFunction(_postTranslation) ? _postTranslation : null;
242
+ }
243
+ // setPostTranslationHandler
244
+ function setPostTranslationHandler(handler) {
245
+ _postTranslation = handler;
246
+ _context.postTranslation = handler;
247
+ }
248
+ // getMissingHandler
249
+ function getMissingHandler() {
250
+ return _missing;
251
+ }
252
+ // setMissingHandler
253
+ function setMissingHandler(handler) {
254
+ if (handler !== null) {
255
+ _runtimeMissing = defineCoreMissingHandler(handler);
256
+ }
257
+ _missing = handler;
258
+ _context.missing = _runtimeMissing;
259
+ }
260
+ function wrapWithDeps(fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) {
261
+ trackReactivityValues(); // track reactive dependency
262
+ // NOTE: experimental !!
263
+ let ret;
264
+ {
265
+ ret = fn(_context);
266
+ }
267
+ if (shared.isNumber(ret) && ret === coreBase.NOT_REOSLVED) {
268
+ const [key, arg2] = argumentParser();
269
+ return __root && _fallbackRoot
270
+ ? fallbackSuccess(__root)
271
+ : fallbackFail(key);
272
+ }
273
+ else if (successCondition(ret)) {
274
+ return ret;
275
+ }
276
+ else {
277
+ /* istanbul ignore next */
278
+ throw createI18nError(14 /* UNEXPECTED_RETURN_TYPE */);
279
+ }
280
+ }
281
+ // t
282
+ function t(...args) {
283
+ return wrapWithDeps(context => coreBase.translate(context, ...args), () => coreBase.parseTranslateArgs(...args), 'translate', root => root.t(...args), key => key, val => shared.isString(val));
284
+ }
285
+ // rt
286
+ function rt(...args) {
287
+ const [arg1, arg2, arg3] = args;
288
+ if (arg3 && !shared.isObject(arg3)) {
289
+ throw createI18nError(15 /* INVALID_ARGUMENT */);
290
+ }
291
+ return t(...[arg1, arg2, shared.assign({ resolvedMessage: true }, arg3 || {})]);
292
+ }
293
+ // d
294
+ function d(...args) {
295
+ return wrapWithDeps(context => coreBase.datetime(context, ...args), () => coreBase.parseDateTimeArgs(...args), 'datetime format', root => root.d(...args), () => coreBase.MISSING_RESOLVE_VALUE, val => shared.isString(val));
296
+ }
297
+ // n
298
+ function n(...args) {
299
+ return wrapWithDeps(context => coreBase.number(context, ...args), () => coreBase.parseNumberArgs(...args), 'number format', root => root.n(...args), () => coreBase.MISSING_RESOLVE_VALUE, val => shared.isString(val));
300
+ }
301
+ // for custom processor
302
+ function normalize(values) {
303
+ return values.map(val => shared.isString(val) ? vue.createVNode(vue.Text, null, val, 0) : val);
304
+ }
305
+ const interpolate = (val) => val;
306
+ const processor = {
307
+ normalize,
308
+ interpolate,
309
+ type: 'vnode'
310
+ };
311
+ // transrateVNode, using for `i18n-t` component
312
+ function transrateVNode(...args) {
313
+ return wrapWithDeps(context => {
314
+ let ret;
315
+ const _context = context;
316
+ try {
317
+ _context.processor = processor;
318
+ ret = coreBase.translate(_context, ...args);
319
+ }
320
+ finally {
321
+ _context.processor = null;
322
+ }
323
+ return ret;
324
+ }, () => coreBase.parseTranslateArgs(...args), 'translate',
325
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
326
+ root => root[TransrateVNodeSymbol](...args), key => [vue.createVNode(vue.Text, null, key, 0)], val => shared.isArray(val));
327
+ }
328
+ // numberParts, using for `i18n-n` component
329
+ function numberParts(...args) {
330
+ return wrapWithDeps(context => coreBase.number(context, ...args), () => coreBase.parseNumberArgs(...args), 'number format',
331
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
332
+ root => root[NumberPartsSymbol](...args), () => [], val => shared.isString(val) || shared.isArray(val));
333
+ }
334
+ // datetimeParts, using for `i18n-d` component
335
+ function datetimeParts(...args) {
336
+ return wrapWithDeps(context => coreBase.datetime(context, ...args), () => coreBase.parseDateTimeArgs(...args), 'datetime format',
337
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
338
+ root => root[DatetimePartsSymbol](...args), () => [], val => shared.isString(val) || shared.isArray(val));
339
+ }
340
+ function setPluralRules(rules) {
341
+ _pluralRules = rules;
342
+ _context.pluralRules = _pluralRules;
343
+ }
344
+ // te
345
+ function te(key, locale) {
346
+ const targetLocale = shared.isString(locale) ? locale : _locale.value;
347
+ const message = getLocaleMessage(targetLocale);
348
+ return coreBase.resolveValue(message, key) !== null;
349
+ }
350
+ function resolveMessages(key) {
351
+ let messages = null;
352
+ const locales = coreBase.getLocaleChain(_context, _fallbackLocale.value, _locale.value);
353
+ for (let i = 0; i < locales.length; i++) {
354
+ const targetLocaleMessages = _messages.value[locales[i]] || {};
355
+ const messageValue = coreBase.resolveValue(targetLocaleMessages, key);
356
+ if (messageValue != null) {
357
+ messages = messageValue;
358
+ break;
359
+ }
360
+ }
361
+ return messages;
362
+ }
363
+ // tm
364
+ function tm(key) {
365
+ const messages = resolveMessages(key);
366
+ // prettier-ignore
367
+ return messages != null
368
+ ? messages
369
+ : __root
370
+ ? __root.tm(key) || {}
371
+ : {};
372
+ }
373
+ // getLocaleMessage
374
+ function getLocaleMessage(locale) {
375
+ return (_messages.value[locale] || {});
376
+ }
377
+ // setLocaleMessage
378
+ function setLocaleMessage(locale, message) {
379
+ _messages.value[locale] = message;
380
+ _context.messages = _messages.value;
381
+ }
382
+ // mergeLocaleMessage
383
+ function mergeLocaleMessage(locale, message) {
384
+ _messages.value[locale] = _messages.value[locale] || {};
385
+ deepCopy(message, _messages.value[locale]);
386
+ _context.messages = _messages.value;
387
+ }
388
+ // getDateTimeFormat
389
+ function getDateTimeFormat(locale) {
390
+ return _datetimeFormats.value[locale] || {};
391
+ }
392
+ // setDateTimeFormat
393
+ function setDateTimeFormat(locale, format) {
394
+ _datetimeFormats.value[locale] = format;
395
+ _context.datetimeFormats = _datetimeFormats.value;
396
+ coreBase.clearDateTimeFormat(_context, locale, format);
397
+ }
398
+ // mergeDateTimeFormat
399
+ function mergeDateTimeFormat(locale, format) {
400
+ _datetimeFormats.value[locale] = shared.assign(_datetimeFormats.value[locale] || {}, format);
401
+ _context.datetimeFormats = _datetimeFormats.value;
402
+ coreBase.clearDateTimeFormat(_context, locale, format);
403
+ }
404
+ // getNumberFormat
405
+ function getNumberFormat(locale) {
406
+ return _numberFormats.value[locale] || {};
407
+ }
408
+ // setNumberFormat
409
+ function setNumberFormat(locale, format) {
410
+ _numberFormats.value[locale] = format;
411
+ _context.numberFormats = _numberFormats.value;
412
+ coreBase.clearNumberFormat(_context, locale, format);
413
+ }
414
+ // mergeNumberFormat
415
+ function mergeNumberFormat(locale, format) {
416
+ _numberFormats.value[locale] = shared.assign(_numberFormats.value[locale] || {}, format);
417
+ _context.numberFormats = _numberFormats.value;
418
+ coreBase.clearNumberFormat(_context, locale, format);
419
+ }
420
+ // for debug
421
+ composerID++;
422
+ // watch root locale & fallbackLocale
423
+ if (__root) {
424
+ vue.watch(__root.locale, (val) => {
425
+ if (_inheritLocale) {
426
+ _locale.value = val;
427
+ _context.locale = val;
428
+ coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
429
+ }
430
+ });
431
+ vue.watch(__root.fallbackLocale, (val) => {
432
+ if (_inheritLocale) {
433
+ _fallbackLocale.value = val;
434
+ _context.fallbackLocale = val;
435
+ coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
436
+ }
437
+ });
438
+ }
439
+ // define composition API!
440
+ const composer = {
441
+ id: composerID,
442
+ locale,
443
+ fallbackLocale,
444
+ get inheritLocale() {
445
+ return _inheritLocale;
446
+ },
447
+ set inheritLocale(val) {
448
+ _inheritLocale = val;
449
+ if (val && __root) {
450
+ _locale.value = __root.locale.value;
451
+ _fallbackLocale.value = __root.fallbackLocale.value;
452
+ coreBase.updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
453
+ }
454
+ },
455
+ get availableLocales() {
456
+ return Object.keys(_messages.value).sort();
457
+ },
458
+ messages,
459
+ datetimeFormats,
460
+ numberFormats,
461
+ get modifiers() {
462
+ return _modifiers;
463
+ },
464
+ get pluralRules() {
465
+ return _pluralRules || {};
466
+ },
467
+ get isGlobal() {
468
+ return _isGlobal;
469
+ },
470
+ get missingWarn() {
471
+ return _missingWarn;
472
+ },
473
+ set missingWarn(val) {
474
+ _missingWarn = val;
475
+ _context.missingWarn = _missingWarn;
476
+ },
477
+ get fallbackWarn() {
478
+ return _fallbackWarn;
479
+ },
480
+ set fallbackWarn(val) {
481
+ _fallbackWarn = val;
482
+ _context.fallbackWarn = _fallbackWarn;
483
+ },
484
+ get fallbackRoot() {
485
+ return _fallbackRoot;
486
+ },
487
+ set fallbackRoot(val) {
488
+ _fallbackRoot = val;
489
+ },
490
+ get fallbackFormat() {
491
+ return _fallbackFormat;
492
+ },
493
+ set fallbackFormat(val) {
494
+ _fallbackFormat = val;
495
+ _context.fallbackFormat = _fallbackFormat;
496
+ },
497
+ get warnHtmlMessage() {
498
+ return _warnHtmlMessage;
499
+ },
500
+ set warnHtmlMessage(val) {
501
+ _warnHtmlMessage = val;
502
+ _context.warnHtmlMessage = val;
503
+ },
504
+ get escapeParameter() {
505
+ return _escapeParameter;
506
+ },
507
+ set escapeParameter(val) {
508
+ _escapeParameter = val;
509
+ _context.escapeParameter = val;
510
+ },
511
+ t,
512
+ rt,
513
+ d,
514
+ n,
515
+ te,
516
+ tm,
517
+ getLocaleMessage,
518
+ setLocaleMessage,
519
+ mergeLocaleMessage,
520
+ getDateTimeFormat,
521
+ setDateTimeFormat,
522
+ mergeDateTimeFormat,
523
+ getNumberFormat,
524
+ setNumberFormat,
525
+ mergeNumberFormat,
526
+ getPostTranslationHandler,
527
+ setPostTranslationHandler,
528
+ getMissingHandler,
529
+ setMissingHandler,
530
+ [TransrateVNodeSymbol]: transrateVNode,
531
+ [NumberPartsSymbol]: numberParts,
532
+ [DatetimePartsSymbol]: datetimeParts,
533
+ [SetPluralRulesSymbol]: setPluralRules
534
+ };
535
+ return composer;
536
+ }
537
+
538
+ /**
539
+ * Convert to I18n Composer Options from VueI18n Options
540
+ *
541
+ * @internal
542
+ */
543
+ function convertComposerOptions(options) {
544
+ const locale = shared.isString(options.locale) ? options.locale : 'en-US';
545
+ const fallbackLocale = shared.isString(options.fallbackLocale) ||
546
+ shared.isArray(options.fallbackLocale) ||
547
+ shared.isPlainObject(options.fallbackLocale) ||
548
+ options.fallbackLocale === false
549
+ ? options.fallbackLocale
550
+ : locale;
551
+ const missing = shared.isFunction(options.missing) ? options.missing : undefined;
552
+ const missingWarn = shared.isBoolean(options.silentTranslationWarn) ||
553
+ shared.isRegExp(options.silentTranslationWarn)
554
+ ? !options.silentTranslationWarn
555
+ : true;
556
+ const fallbackWarn = shared.isBoolean(options.silentFallbackWarn) ||
557
+ shared.isRegExp(options.silentFallbackWarn)
558
+ ? !options.silentFallbackWarn
559
+ : true;
560
+ const fallbackRoot = shared.isBoolean(options.fallbackRoot)
561
+ ? options.fallbackRoot
562
+ : true;
563
+ const fallbackFormat = !!options.formatFallbackMessages;
564
+ const modifiers = shared.isPlainObject(options.modifiers) ? options.modifiers : {};
565
+ const pluralizationRules = options.pluralizationRules;
566
+ const postTranslation = shared.isFunction(options.postTranslation)
567
+ ? options.postTranslation
568
+ : undefined;
569
+ const warnHtmlMessage = shared.isString(options.warnHtmlInMessage)
570
+ ? options.warnHtmlInMessage !== 'off'
571
+ : true;
572
+ const escapeParameter = !!options.escapeParameterHtml;
573
+ const inheritLocale = shared.isBoolean(options.sync) ? options.sync : true;
574
+ let messages = options.messages;
575
+ if (shared.isPlainObject(options.sharedMessages)) {
576
+ const sharedMessages = options.sharedMessages;
577
+ const locales = Object.keys(sharedMessages);
578
+ messages = locales.reduce((messages, locale) => {
579
+ const message = messages[locale] || (messages[locale] = {});
580
+ shared.assign(message, sharedMessages[locale]);
581
+ return messages;
582
+ }, (messages || {}));
583
+ }
584
+ const { __i18n, __root } = options;
585
+ const datetimeFormats = options.datetimeFormats;
586
+ const numberFormats = options.numberFormats;
587
+ const flatJson = options.flatJson;
588
+ return {
589
+ locale,
590
+ fallbackLocale,
591
+ messages,
592
+ flatJson,
593
+ datetimeFormats,
594
+ numberFormats,
595
+ missing,
596
+ missingWarn,
597
+ fallbackWarn,
598
+ fallbackRoot,
599
+ fallbackFormat,
600
+ modifiers,
601
+ pluralRules: pluralizationRules,
602
+ postTranslation,
603
+ warnHtmlMessage,
604
+ escapeParameter,
605
+ inheritLocale,
606
+ __i18n,
607
+ __root
608
+ };
609
+ }
610
+ /**
611
+ * create VueI18n interface factory
612
+ *
613
+ * @internal
614
+ */
615
+ function createVueI18n(options = {}) {
616
+ const composer = createComposer(convertComposerOptions(options));
617
+ // defines VueI18n
618
+ const vueI18n = {
619
+ // id
620
+ id: composer.id,
621
+ // locale
622
+ get locale() {
623
+ return composer.locale.value;
624
+ },
625
+ set locale(val) {
626
+ composer.locale.value = val;
627
+ },
628
+ // fallbackLocale
629
+ get fallbackLocale() {
630
+ return composer.fallbackLocale.value;
631
+ },
632
+ set fallbackLocale(val) {
633
+ composer.fallbackLocale.value = val;
634
+ },
635
+ // messages
636
+ get messages() {
637
+ return composer.messages.value;
638
+ },
639
+ // datetimeFormats
640
+ get datetimeFormats() {
641
+ return composer.datetimeFormats.value;
642
+ },
643
+ // numberFormats
644
+ get numberFormats() {
645
+ return composer.numberFormats.value;
646
+ },
647
+ // availableLocales
648
+ get availableLocales() {
649
+ return composer.availableLocales;
650
+ },
651
+ // formatter
652
+ get formatter() {
653
+ // dummy
654
+ return {
655
+ interpolate() {
656
+ return [];
657
+ }
658
+ };
659
+ },
660
+ set formatter(val) {
661
+ },
662
+ // missing
663
+ get missing() {
664
+ return composer.getMissingHandler();
665
+ },
666
+ set missing(handler) {
667
+ composer.setMissingHandler(handler);
668
+ },
669
+ // silentTranslationWarn
670
+ get silentTranslationWarn() {
671
+ return shared.isBoolean(composer.missingWarn)
672
+ ? !composer.missingWarn
673
+ : composer.missingWarn;
674
+ },
675
+ set silentTranslationWarn(val) {
676
+ composer.missingWarn = shared.isBoolean(val) ? !val : val;
677
+ },
678
+ // silentFallbackWarn
679
+ get silentFallbackWarn() {
680
+ return shared.isBoolean(composer.fallbackWarn)
681
+ ? !composer.fallbackWarn
682
+ : composer.fallbackWarn;
683
+ },
684
+ set silentFallbackWarn(val) {
685
+ composer.fallbackWarn = shared.isBoolean(val) ? !val : val;
686
+ },
687
+ // modifiers
688
+ get modifiers() {
689
+ return composer.modifiers;
690
+ },
691
+ // formatFallbackMessages
692
+ get formatFallbackMessages() {
693
+ return composer.fallbackFormat;
694
+ },
695
+ set formatFallbackMessages(val) {
696
+ composer.fallbackFormat = val;
697
+ },
698
+ // postTranslation
699
+ get postTranslation() {
700
+ return composer.getPostTranslationHandler();
701
+ },
702
+ set postTranslation(handler) {
703
+ composer.setPostTranslationHandler(handler);
704
+ },
705
+ // sync
706
+ get sync() {
707
+ return composer.inheritLocale;
708
+ },
709
+ set sync(val) {
710
+ composer.inheritLocale = val;
711
+ },
712
+ // warnInHtmlMessage
713
+ get warnHtmlInMessage() {
714
+ return composer.warnHtmlMessage ? 'warn' : 'off';
715
+ },
716
+ set warnHtmlInMessage(val) {
717
+ composer.warnHtmlMessage = val !== 'off';
718
+ },
719
+ // escapeParameterHtml
720
+ get escapeParameterHtml() {
721
+ return composer.escapeParameter;
722
+ },
723
+ set escapeParameterHtml(val) {
724
+ composer.escapeParameter = val;
725
+ },
726
+ // preserveDirectiveContent
727
+ get preserveDirectiveContent() {
728
+ return true;
729
+ },
730
+ set preserveDirectiveContent(val) {
731
+ },
732
+ // pluralizationRules
733
+ get pluralizationRules() {
734
+ return composer.pluralRules || {};
735
+ },
736
+ // for internal
737
+ __composer: composer,
738
+ // t
739
+ t(...args) {
740
+ const [arg1, arg2, arg3] = args;
741
+ const options = {};
742
+ let list = null;
743
+ let named = null;
744
+ if (!shared.isString(arg1)) {
745
+ throw createI18nError(15 /* INVALID_ARGUMENT */);
746
+ }
747
+ const key = arg1;
748
+ if (shared.isString(arg2)) {
749
+ options.locale = arg2;
750
+ }
751
+ else if (shared.isArray(arg2)) {
752
+ list = arg2;
753
+ }
754
+ else if (shared.isPlainObject(arg2)) {
755
+ named = arg2;
756
+ }
757
+ if (shared.isArray(arg3)) {
758
+ list = arg3;
759
+ }
760
+ else if (shared.isPlainObject(arg3)) {
761
+ named = arg3;
762
+ }
763
+ return composer.t(key, list || named || {}, options);
764
+ },
765
+ rt(...args) {
766
+ return composer.rt(...args);
767
+ },
768
+ // tc
769
+ tc(...args) {
770
+ const [arg1, arg2, arg3] = args;
771
+ const options = { plural: 1 };
772
+ let list = null;
773
+ let named = null;
774
+ if (!shared.isString(arg1)) {
775
+ throw createI18nError(15 /* INVALID_ARGUMENT */);
776
+ }
777
+ const key = arg1;
778
+ if (shared.isString(arg2)) {
779
+ options.locale = arg2;
780
+ }
781
+ else if (shared.isNumber(arg2)) {
782
+ options.plural = arg2;
783
+ }
784
+ else if (shared.isArray(arg2)) {
785
+ list = arg2;
786
+ }
787
+ else if (shared.isPlainObject(arg2)) {
788
+ named = arg2;
789
+ }
790
+ if (shared.isString(arg3)) {
791
+ options.locale = arg3;
792
+ }
793
+ else if (shared.isArray(arg3)) {
794
+ list = arg3;
795
+ }
796
+ else if (shared.isPlainObject(arg3)) {
797
+ named = arg3;
798
+ }
799
+ return composer.t(key, list || named || {}, options);
800
+ },
801
+ // te
802
+ te(key, locale) {
803
+ return composer.te(key, locale);
804
+ },
805
+ // tm
806
+ tm(key) {
807
+ return composer.tm(key);
808
+ },
809
+ // getLocaleMessage
810
+ getLocaleMessage(locale) {
811
+ return composer.getLocaleMessage(locale);
812
+ },
813
+ // setLocaleMessage
814
+ setLocaleMessage(locale, message) {
815
+ composer.setLocaleMessage(locale, message);
816
+ },
817
+ // mergeLocaleMessage
818
+ mergeLocaleMessage(locale, message) {
819
+ composer.mergeLocaleMessage(locale, message);
820
+ },
821
+ // d
822
+ d(...args) {
823
+ return composer.d(...args);
824
+ },
825
+ // getDateTimeFormat
826
+ getDateTimeFormat(locale) {
827
+ return composer.getDateTimeFormat(locale);
828
+ },
829
+ // setDateTimeFormat
830
+ setDateTimeFormat(locale, format) {
831
+ composer.setDateTimeFormat(locale, format);
832
+ },
833
+ // mergeDateTimeFormat
834
+ mergeDateTimeFormat(locale, format) {
835
+ composer.mergeDateTimeFormat(locale, format);
836
+ },
837
+ // n
838
+ n(...args) {
839
+ return composer.n(...args);
840
+ },
841
+ // getNumberFormat
842
+ getNumberFormat(locale) {
843
+ return composer.getNumberFormat(locale);
844
+ },
845
+ // setNumberFormat
846
+ setNumberFormat(locale, format) {
847
+ composer.setNumberFormat(locale, format);
848
+ },
849
+ // mergeNumberFormat
850
+ mergeNumberFormat(locale, format) {
851
+ composer.mergeNumberFormat(locale, format);
852
+ },
853
+ // getChoiceIndex
854
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
855
+ getChoiceIndex(choice, choicesLength) {
856
+ return -1;
857
+ },
858
+ // for internal
859
+ __onComponentInstanceCreated(target) {
860
+ const { componentInstanceCreatedListener } = options;
861
+ if (componentInstanceCreatedListener) {
862
+ componentInstanceCreatedListener(target, vueI18n);
863
+ }
864
+ }
865
+ };
866
+ return vueI18n;
867
+ }
868
+
869
+ const baseFormatProps = {
870
+ tag: {
871
+ type: [String, Object]
872
+ },
873
+ locale: {
874
+ type: String
875
+ },
876
+ scope: {
877
+ type: String,
878
+ validator: (val) => val === 'parent' || val === 'global',
879
+ default: 'parent'
880
+ },
881
+ i18n: {
882
+ type: Object
883
+ }
884
+ };
885
+
886
+ /**
887
+ * Translation Component
888
+ *
889
+ * @remarks
890
+ * See the following items for property about details
891
+ *
892
+ * @VueI18nSee [TranslationProps](component#translationprops)
893
+ * @VueI18nSee [BaseFormatProps](component#baseformatprops)
894
+ * @VueI18nSee [Component Interpolation](../guide/advanced/component)
895
+ *
896
+ * @example
897
+ * ```html
898
+ * <div id="app">
899
+ * <!-- ... -->
900
+ * <i18n path="term" tag="label" for="tos">
901
+ * <a :href="url" target="_blank">{{ $t('tos') }}</a>
902
+ * </i18n>
903
+ * <!-- ... -->
904
+ * </div>
905
+ * ```
906
+ * ```js
907
+ * import { createApp } from 'vue'
908
+ * import { createI18n } from 'vue-i18n'
909
+ *
910
+ * const messages = {
911
+ * en: {
912
+ * tos: 'Term of Service',
913
+ * term: 'I accept xxx {0}.'
914
+ * },
915
+ * ja: {
916
+ * tos: '利用規約',
917
+ * term: '私は xxx の{0}に同意します。'
918
+ * }
919
+ * }
920
+ *
921
+ * const i18n = createI18n({
922
+ * locale: 'en',
923
+ * messages
924
+ * })
925
+ *
926
+ * const app = createApp({
927
+ * data: {
928
+ * url: '/term'
929
+ * }
930
+ * }).use(i18n).mount('#app')
931
+ * ```
932
+ *
933
+ * @VueI18nComponent
934
+ */
935
+ const Translation = {
936
+ /* eslint-disable */
937
+ name: 'i18n-t',
938
+ props: shared.assign({
939
+ keypath: {
940
+ type: String,
941
+ required: true
942
+ },
943
+ plural: {
944
+ type: [Number, String],
945
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
946
+ validator: (val) => shared.isNumber(val) || !isNaN(val)
947
+ }
948
+ }, baseFormatProps),
949
+ /* eslint-enable */
950
+ setup(props, context) {
951
+ const { slots, attrs } = context;
952
+ const i18n = props.i18n ||
953
+ useI18n({ useScope: props.scope });
954
+ const keys = Object.keys(slots).filter(key => key !== '_');
955
+ return () => {
956
+ const options = {};
957
+ if (props.locale) {
958
+ options.locale = props.locale;
959
+ }
960
+ if (props.plural !== undefined) {
961
+ options.plural = shared.isString(props.plural) ? +props.plural : props.plural;
962
+ }
963
+ const arg = getInterpolateArg(context, keys);
964
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
965
+ const children = i18n[TransrateVNodeSymbol](props.keypath, arg, options);
966
+ const assignedAttrs = shared.assign({}, attrs);
967
+ // prettier-ignore
968
+ return shared.isString(props.tag)
969
+ ? vue.h(props.tag, assignedAttrs, children)
970
+ : shared.isObject(props.tag)
971
+ ? vue.h(props.tag, assignedAttrs, children)
972
+ : vue.h(vue.Fragment, assignedAttrs, children);
973
+ };
974
+ }
975
+ };
976
+ function getInterpolateArg({ slots }, keys) {
977
+ if (keys.length === 1 && keys[0] === 'default') {
978
+ // default slot only
979
+ return slots.default ? slots.default() : [];
980
+ }
981
+ else {
982
+ // named slots
983
+ return keys.reduce((arg, key) => {
984
+ const slot = slots[key];
985
+ if (slot) {
986
+ arg[key] = slot();
987
+ }
988
+ return arg;
989
+ }, {});
990
+ }
991
+ }
992
+
993
+ function renderFormatter(props, context, slotKeys, partFormatter) {
994
+ const { slots, attrs } = context;
995
+ return () => {
996
+ const options = { part: true };
997
+ let overrides = {};
998
+ if (props.locale) {
999
+ options.locale = props.locale;
1000
+ }
1001
+ if (shared.isString(props.format)) {
1002
+ options.key = props.format;
1003
+ }
1004
+ else if (shared.isObject(props.format)) {
1005
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1006
+ if (shared.isString(props.format.key)) {
1007
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1008
+ options.key = props.format.key;
1009
+ }
1010
+ // Filter out number format options only
1011
+ overrides = Object.keys(props.format).reduce((options, prop) => {
1012
+ return slotKeys.includes(prop)
1013
+ ? shared.assign({}, options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any
1014
+ : options;
1015
+ }, {});
1016
+ }
1017
+ const parts = partFormatter(...[props.value, options, overrides]);
1018
+ let children = [options.key];
1019
+ if (shared.isArray(parts)) {
1020
+ children = parts.map((part, index) => {
1021
+ const slot = slots[part.type];
1022
+ return slot
1023
+ ? slot({ [part.type]: part.value, index, parts })
1024
+ : [part.value];
1025
+ });
1026
+ }
1027
+ else if (shared.isString(parts)) {
1028
+ children = [parts];
1029
+ }
1030
+ const assignedAttrs = shared.assign({}, attrs);
1031
+ // prettier-ignore
1032
+ return shared.isString(props.tag)
1033
+ ? vue.h(props.tag, assignedAttrs, children)
1034
+ : shared.isObject(props.tag)
1035
+ ? vue.h(props.tag, assignedAttrs, children)
1036
+ : vue.h(vue.Fragment, assignedAttrs, children);
1037
+ };
1038
+ }
1039
+
1040
+ const NUMBER_FORMAT_KEYS = [
1041
+ 'localeMatcher',
1042
+ 'style',
1043
+ 'unit',
1044
+ 'unitDisplay',
1045
+ 'currency',
1046
+ 'currencyDisplay',
1047
+ 'useGrouping',
1048
+ 'numberingSystem',
1049
+ 'minimumIntegerDigits',
1050
+ 'minimumFractionDigits',
1051
+ 'maximumFractionDigits',
1052
+ 'minimumSignificantDigits',
1053
+ 'maximumSignificantDigits',
1054
+ 'notation',
1055
+ 'formatMatcher'
1056
+ ];
1057
+ /**
1058
+ * Number Format Component
1059
+ *
1060
+ * @remarks
1061
+ * See the following items for property about details
1062
+ *
1063
+ * @VueI18nSee [FormattableProps](component#formattableprops)
1064
+ * @VueI18nSee [BaseFormatProps](component#baseformatprops)
1065
+ * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting)
1066
+ *
1067
+ * @VueI18nDanger
1068
+ * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
1069
+ *
1070
+ * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat)
1071
+ *
1072
+ * @VueI18nComponent
1073
+ */
1074
+ const NumberFormat = {
1075
+ /* eslint-disable */
1076
+ name: 'i18n-n',
1077
+ props: shared.assign({
1078
+ value: {
1079
+ type: Number,
1080
+ required: true
1081
+ },
1082
+ format: {
1083
+ type: [String, Object]
1084
+ }
1085
+ }, baseFormatProps),
1086
+ /* eslint-enable */
1087
+ setup(props, context) {
1088
+ const i18n = props.i18n ||
1089
+ useI18n({ useScope: 'parent' });
1090
+ return renderFormatter(props, context, NUMBER_FORMAT_KEYS, (...args) =>
1091
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1092
+ i18n[NumberPartsSymbol](...args));
1093
+ }
1094
+ };
1095
+
1096
+ const DATETIME_FORMAT_KEYS = [
1097
+ 'dateStyle',
1098
+ 'timeStyle',
1099
+ 'fractionalSecondDigits',
1100
+ 'calendar',
1101
+ 'dayPeriod',
1102
+ 'numberingSystem',
1103
+ 'localeMatcher',
1104
+ 'timeZone',
1105
+ 'hour12',
1106
+ 'hourCycle',
1107
+ 'formatMatcher',
1108
+ 'weekday',
1109
+ 'era',
1110
+ 'year',
1111
+ 'month',
1112
+ 'day',
1113
+ 'hour',
1114
+ 'minute',
1115
+ 'second',
1116
+ 'timeZoneName'
1117
+ ];
1118
+ /**
1119
+ * Datetime Format Component
1120
+ *
1121
+ * @remarks
1122
+ * See the following items for property about details
1123
+ *
1124
+ * @VueI18nSee [FormattableProps](component#formattableprops)
1125
+ * @VueI18nSee [BaseFormatProps](component#baseformatprops)
1126
+ * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting)
1127
+ *
1128
+ * @VueI18nDanger
1129
+ * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
1130
+ *
1131
+ * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat)
1132
+ *
1133
+ * @VueI18nComponent
1134
+ */
1135
+ const DatetimeFormat = {
1136
+ /* eslint-disable */
1137
+ name: 'i18n-d',
1138
+ props: shared.assign({
1139
+ value: {
1140
+ type: [Number, Date],
1141
+ required: true
1142
+ },
1143
+ format: {
1144
+ type: [String, Object]
1145
+ }
1146
+ }, baseFormatProps),
1147
+ /* eslint-enable */
1148
+ setup(props, context) {
1149
+ const i18n = props.i18n ||
1150
+ useI18n({ useScope: 'parent' });
1151
+ return renderFormatter(props, context, DATETIME_FORMAT_KEYS, (...args) =>
1152
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1153
+ i18n[DatetimePartsSymbol](...args));
1154
+ }
1155
+ };
1156
+
1157
+ function getComposer$1(i18n, instance) {
1158
+ const i18nInternal = i18n;
1159
+ if (i18n.mode === 'composition') {
1160
+ return (i18nInternal.__getInstance(instance) || i18n.global);
1161
+ }
1162
+ else {
1163
+ const vueI18n = i18nInternal.__getInstance(instance);
1164
+ return vueI18n != null
1165
+ ? vueI18n.__composer
1166
+ : i18n.global.__composer;
1167
+ }
1168
+ }
1169
+ function vTDirective(i18n) {
1170
+ const bind = (el, { instance, value, modifiers }) => {
1171
+ /* istanbul ignore if */
1172
+ if (!instance || !instance.$) {
1173
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
1174
+ }
1175
+ const composer = getComposer$1(i18n, instance.$);
1176
+ const parsedValue = parseValue(value);
1177
+ el.textContent = composer.t(...makeParams(parsedValue));
1178
+ };
1179
+ return {
1180
+ beforeMount: bind,
1181
+ beforeUpdate: bind
1182
+ };
1183
+ }
1184
+ function parseValue(value) {
1185
+ if (shared.isString(value)) {
1186
+ return { path: value };
1187
+ }
1188
+ else if (shared.isPlainObject(value)) {
1189
+ if (!('path' in value)) {
1190
+ throw createI18nError(19 /* REQUIRED_VALUE */, 'path');
1191
+ }
1192
+ return value;
1193
+ }
1194
+ else {
1195
+ throw createI18nError(20 /* INVALID_VALUE */);
1196
+ }
1197
+ }
1198
+ function makeParams(value) {
1199
+ const { path, locale, args, choice, plural } = value;
1200
+ const options = {};
1201
+ const named = args || {};
1202
+ if (shared.isString(locale)) {
1203
+ options.locale = locale;
1204
+ }
1205
+ if (shared.isNumber(choice)) {
1206
+ options.plural = choice;
1207
+ }
1208
+ if (shared.isNumber(plural)) {
1209
+ options.plural = plural;
1210
+ }
1211
+ return [path, named, options];
1212
+ }
1213
+
1214
+ function apply(app, i18n, ...options) {
1215
+ const pluginOptions = shared.isPlainObject(options[0])
1216
+ ? options[0]
1217
+ : {};
1218
+ const useI18nComponentName = !!pluginOptions.useI18nComponentName;
1219
+ const globalInstall = shared.isBoolean(pluginOptions.globalInstall)
1220
+ ? pluginOptions.globalInstall
1221
+ : true;
1222
+ if (globalInstall) {
1223
+ // install components
1224
+ app.component(!useI18nComponentName ? Translation.name : 'i18n', Translation);
1225
+ app.component(NumberFormat.name, NumberFormat);
1226
+ app.component(DatetimeFormat.name, DatetimeFormat);
1227
+ }
1228
+ // install directive
1229
+ app.directive('t', vTDirective(i18n));
1230
+ }
1231
+
1232
+ // supports compatibility for legacy vue-i18n APIs
1233
+ function defineMixin(vuei18n, composer, i18n) {
1234
+ return {
1235
+ beforeCreate() {
1236
+ const instance = vue.getCurrentInstance();
1237
+ /* istanbul ignore if */
1238
+ if (!instance) {
1239
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
1240
+ }
1241
+ const options = this.$options;
1242
+ if (options.i18n) {
1243
+ const optionsI18n = options.i18n;
1244
+ if (options.__i18n) {
1245
+ optionsI18n.__i18n = options.__i18n;
1246
+ }
1247
+ optionsI18n.__root = composer;
1248
+ if (this === this.$root) {
1249
+ this.$i18n = mergeToRoot(vuei18n, optionsI18n);
1250
+ }
1251
+ else {
1252
+ this.$i18n = createVueI18n(optionsI18n);
1253
+ }
1254
+ }
1255
+ else if (options.__i18n) {
1256
+ if (this === this.$root) {
1257
+ this.$i18n = mergeToRoot(vuei18n, options);
1258
+ }
1259
+ else {
1260
+ this.$i18n = createVueI18n({
1261
+ __i18n: options.__i18n,
1262
+ __root: composer
1263
+ });
1264
+ }
1265
+ }
1266
+ else {
1267
+ // set global
1268
+ this.$i18n = vuei18n;
1269
+ }
1270
+ vuei18n.__onComponentInstanceCreated(this.$i18n);
1271
+ i18n.__setInstance(instance, this.$i18n);
1272
+ // defines vue-i18n legacy APIs
1273
+ this.$t = (...args) => this.$i18n.t(...args);
1274
+ this.$rt = (...args) => this.$i18n.rt(...args);
1275
+ this.$tc = (...args) => this.$i18n.tc(...args);
1276
+ this.$te = (key, locale) => this.$i18n.te(key, locale);
1277
+ this.$d = (...args) => this.$i18n.d(...args);
1278
+ this.$n = (...args) => this.$i18n.n(...args);
1279
+ this.$tm = (key) => this.$i18n.tm(key);
1280
+ },
1281
+ mounted() {
1282
+ },
1283
+ beforeUnmount() {
1284
+ const instance = vue.getCurrentInstance();
1285
+ /* istanbul ignore if */
1286
+ if (!instance) {
1287
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
1288
+ }
1289
+ delete this.$t;
1290
+ delete this.$rt;
1291
+ delete this.$tc;
1292
+ delete this.$te;
1293
+ delete this.$d;
1294
+ delete this.$n;
1295
+ delete this.$tm;
1296
+ i18n.__deleteInstance(instance);
1297
+ delete this.$i18n;
1298
+ }
1299
+ };
1300
+ }
1301
+ function mergeToRoot(root, options) {
1302
+ root.locale = options.locale || root.locale;
1303
+ root.fallbackLocale = options.fallbackLocale || root.fallbackLocale;
1304
+ root.missing = options.missing || root.missing;
1305
+ root.silentTranslationWarn =
1306
+ options.silentTranslationWarn || root.silentFallbackWarn;
1307
+ root.silentFallbackWarn =
1308
+ options.silentFallbackWarn || root.silentFallbackWarn;
1309
+ root.formatFallbackMessages =
1310
+ options.formatFallbackMessages || root.formatFallbackMessages;
1311
+ root.postTranslation = options.postTranslation || root.postTranslation;
1312
+ root.warnHtmlInMessage = options.warnHtmlInMessage || root.warnHtmlInMessage;
1313
+ root.escapeParameterHtml =
1314
+ options.escapeParameterHtml || root.escapeParameterHtml;
1315
+ root.sync = options.sync || root.sync;
1316
+ root.__composer[SetPluralRulesSymbol](options.pluralizationRules || root.pluralizationRules);
1317
+ const messages = getLocaleMessages(root.locale, {
1318
+ messages: options.messages,
1319
+ __i18n: options.__i18n
1320
+ });
1321
+ Object.keys(messages).forEach(locale => root.mergeLocaleMessage(locale, messages[locale]));
1322
+ if (options.datetimeFormats) {
1323
+ Object.keys(options.datetimeFormats).forEach(locale => root.mergeDateTimeFormat(locale, options.datetimeFormats[locale]));
1324
+ }
1325
+ if (options.numberFormats) {
1326
+ Object.keys(options.numberFormats).forEach(locale => root.mergeNumberFormat(locale, options.numberFormats[locale]));
1327
+ }
1328
+ return root;
1329
+ }
1330
+
1331
+ /**
1332
+ * Vue I18n factory
1333
+ *
1334
+ * @param options - An options, see the {@link I18nOptions}
1335
+ *
1336
+ * @returns {@link I18n} instance
1337
+ *
1338
+ * @remarks
1339
+ * If you use Legacy API mode, you need toto specify {@link VueI18nOptions} and `legacy: true` option.
1340
+ *
1341
+ * If you use composition API mode, you need to specify {@link ComposerOptions}.
1342
+ *
1343
+ * @VueI18nSee [Getting Started](../guide/)
1344
+ * @VueI18nSee [Composition API](../guide/advanced/composition)
1345
+ *
1346
+ * @example
1347
+ * case: for Legacy API
1348
+ * ```js
1349
+ * import { createApp } from 'vue'
1350
+ * import { createI18n } from 'vue-i18n'
1351
+ *
1352
+ * // call with I18n option
1353
+ * const i18n = createI18n({
1354
+ * locale: 'ja',
1355
+ * messages: {
1356
+ * en: { ... },
1357
+ * ja: { ... }
1358
+ * }
1359
+ * })
1360
+ *
1361
+ * const App = {
1362
+ * // ...
1363
+ * }
1364
+ *
1365
+ * const app = createApp(App)
1366
+ *
1367
+ * // install!
1368
+ * app.use(i18n)
1369
+ * app.mount('#app')
1370
+ * ```
1371
+ *
1372
+ * @example
1373
+ * case: for composition API
1374
+ * ```js
1375
+ * import { createApp } from 'vue'
1376
+ * import { createI18n, useI18n } from 'vue-i18n'
1377
+ *
1378
+ * // call with I18n option
1379
+ * const i18n = createI18n({
1380
+ * legacy: false, // you must specify 'legacy: false' option
1381
+ * locale: 'ja',
1382
+ * messages: {
1383
+ * en: { ... },
1384
+ * ja: { ... }
1385
+ * }
1386
+ * })
1387
+ *
1388
+ * const App = {
1389
+ * setup() {
1390
+ * // ...
1391
+ * const { t } = useI18n({ ... })
1392
+ * return { ... , t }
1393
+ * }
1394
+ * }
1395
+ *
1396
+ * const app = createApp(App)
1397
+ *
1398
+ * // install!
1399
+ * app.use(i18n)
1400
+ * app.mount('#app')
1401
+ * ```
1402
+ *
1403
+ * @VueI18nGeneral
1404
+ */
1405
+ function createI18n(options = {}) {
1406
+ // prettier-ignore
1407
+ const __legacyMode = shared.isBoolean(options.legacy)
1408
+ ? options.legacy
1409
+ : true;
1410
+ const __globalInjection = !!options.globalInjection;
1411
+ const __instances = new Map();
1412
+ // prettier-ignore
1413
+ const __global = __legacyMode
1414
+ ? createVueI18n(options)
1415
+ : createComposer(options);
1416
+ const symbol = shared.makeSymbol('');
1417
+ const i18n = {
1418
+ // mode
1419
+ get mode() {
1420
+ // prettier-ignore
1421
+ return __legacyMode
1422
+ ? 'legacy'
1423
+ : 'composition'
1424
+ ;
1425
+ },
1426
+ // install plugin
1427
+ async install(app, ...options) {
1428
+ // setup global provider
1429
+ app.__VUE_I18N_SYMBOL__ = symbol;
1430
+ app.provide(app.__VUE_I18N_SYMBOL__, i18n);
1431
+ // global method and properties injection for Composition API
1432
+ if (!__legacyMode && __globalInjection) {
1433
+ injectGlobalFields(app, i18n.global);
1434
+ }
1435
+ // install built-in components and directive
1436
+ {
1437
+ apply(app, i18n, ...options);
1438
+ }
1439
+ // setup mixin for Legacy API
1440
+ if (__legacyMode) {
1441
+ app.mixin(defineMixin(__global, __global.__composer, i18n));
1442
+ }
1443
+ },
1444
+ // global accessor
1445
+ get global() {
1446
+ return __global;
1447
+ },
1448
+ // @internal
1449
+ __instances,
1450
+ // @internal
1451
+ __getInstance(component) {
1452
+ return __instances.get(component) || null;
1453
+ },
1454
+ // @internal
1455
+ __setInstance(component, instance) {
1456
+ __instances.set(component, instance);
1457
+ },
1458
+ // @internal
1459
+ __deleteInstance(component) {
1460
+ __instances.delete(component);
1461
+ }
1462
+ };
1463
+ return i18n;
1464
+ }
1465
+ /**
1466
+ * Use Composition API for Vue I18n
1467
+ *
1468
+ * @param options - An options, see {@link UseI18nOptions}
1469
+ *
1470
+ * @returns {@link Composer} instance
1471
+ *
1472
+ * @remarks
1473
+ * This function is mainly used by `setup`.
1474
+ *
1475
+ * If options are specified, Composer instance is created for each component and you can be localized on the component.
1476
+ *
1477
+ * If options are not specified, you can be localized using the global Composer.
1478
+ *
1479
+ * @example
1480
+ * case: Component resource base localization
1481
+ * ```html
1482
+ * <template>
1483
+ * <form>
1484
+ * <label>{{ t('language') }}</label>
1485
+ * <select v-model="locale">
1486
+ * <option value="en">en</option>
1487
+ * <option value="ja">ja</option>
1488
+ * </select>
1489
+ * </form>
1490
+ * <p>message: {{ t('hello') }}</p>
1491
+ * </template>
1492
+ *
1493
+ * <script>
1494
+ * import { useI18n } from 'vue-i18n'
1495
+ *
1496
+ * export default {
1497
+ * setup() {
1498
+ * const { t, locale } = useI18n({
1499
+ * locale: 'ja',
1500
+ * messages: {
1501
+ * en: { ... },
1502
+ * ja: { ... }
1503
+ * }
1504
+ * })
1505
+ * // Something to do ...
1506
+ *
1507
+ * return { ..., t, locale }
1508
+ * }
1509
+ * }
1510
+ * </script>
1511
+ * ```
1512
+ *
1513
+ * @VueI18nComposition
1514
+ */
1515
+ function useI18n(options = {}) {
1516
+ const instance = vue.getCurrentInstance();
1517
+ if (instance == null) {
1518
+ throw createI18nError(16 /* MUST_BE_CALL_SETUP_TOP */);
1519
+ }
1520
+ if (!instance.appContext.app.__VUE_I18N_SYMBOL__) {
1521
+ throw createI18nError(17 /* NOT_INSLALLED */);
1522
+ }
1523
+ const i18n = vue.inject(instance.appContext.app.__VUE_I18N_SYMBOL__);
1524
+ /* istanbul ignore if */
1525
+ if (!i18n) {
1526
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
1527
+ }
1528
+ // prettier-ignore
1529
+ const global = i18n.mode === 'composition'
1530
+ ? i18n.global
1531
+ : i18n.global.__composer;
1532
+ // prettier-ignore
1533
+ const scope = shared.isEmptyObject(options)
1534
+ ? ('__i18n' in instance.type)
1535
+ ? 'local'
1536
+ : 'global'
1537
+ : !options.useScope
1538
+ ? 'local'
1539
+ : options.useScope;
1540
+ if (scope === 'global') {
1541
+ let messages = shared.isObject(options.messages) ? options.messages : {};
1542
+ if ('__i18nGlobal' in instance.type) {
1543
+ messages = getLocaleMessages(global.locale.value, {
1544
+ messages,
1545
+ __i18n: instance.type.__i18nGlobal
1546
+ });
1547
+ }
1548
+ // merge locale messages
1549
+ const locales = Object.keys(messages);
1550
+ if (locales.length) {
1551
+ locales.forEach(locale => {
1552
+ global.mergeLocaleMessage(locale, messages[locale]);
1553
+ });
1554
+ }
1555
+ // merge datetime formats
1556
+ if (shared.isObject(options.datetimeFormats)) {
1557
+ const locales = Object.keys(options.datetimeFormats);
1558
+ if (locales.length) {
1559
+ locales.forEach(locale => {
1560
+ global.mergeDateTimeFormat(locale, options.datetimeFormats[locale]);
1561
+ });
1562
+ }
1563
+ }
1564
+ // merge number formats
1565
+ if (shared.isObject(options.numberFormats)) {
1566
+ const locales = Object.keys(options.numberFormats);
1567
+ if (locales.length) {
1568
+ locales.forEach(locale => {
1569
+ global.mergeNumberFormat(locale, options.numberFormats[locale]);
1570
+ });
1571
+ }
1572
+ }
1573
+ return global;
1574
+ }
1575
+ if (scope === 'parent') {
1576
+ let composer = getComposer(i18n, instance);
1577
+ if (composer == null) {
1578
+ composer = global;
1579
+ }
1580
+ return composer;
1581
+ }
1582
+ // scope 'local' case
1583
+ if (i18n.mode === 'legacy') {
1584
+ throw createI18nError(18 /* NOT_AVAILABLE_IN_LEGACY_MODE */);
1585
+ }
1586
+ const i18nInternal = i18n;
1587
+ let composer = i18nInternal.__getInstance(instance);
1588
+ if (composer == null) {
1589
+ const type = instance.type;
1590
+ const composerOptions = shared.assign({}, options);
1591
+ if (type.__i18n) {
1592
+ composerOptions.__i18n = type.__i18n;
1593
+ }
1594
+ if (global) {
1595
+ composerOptions.__root = global;
1596
+ }
1597
+ composer = createComposer(composerOptions);
1598
+ setupLifeCycle(i18nInternal, instance);
1599
+ i18nInternal.__setInstance(instance, composer);
1600
+ }
1601
+ return composer;
1602
+ }
1603
+ function getComposer(i18n, target) {
1604
+ let composer = null;
1605
+ const root = target.root;
1606
+ let current = target.parent;
1607
+ while (current != null) {
1608
+ const i18nInternal = i18n;
1609
+ if (i18n.mode === 'composition') {
1610
+ composer = i18nInternal.__getInstance(current);
1611
+ }
1612
+ else {
1613
+ const vueI18n = i18nInternal.__getInstance(current);
1614
+ if (vueI18n != null) {
1615
+ composer = vueI18n
1616
+ .__composer;
1617
+ }
1618
+ }
1619
+ if (composer != null) {
1620
+ break;
1621
+ }
1622
+ if (root === current) {
1623
+ break;
1624
+ }
1625
+ current = current.parent;
1626
+ }
1627
+ return composer;
1628
+ }
1629
+ function setupLifeCycle(i18n, target, composer) {
1630
+ vue.onMounted(() => {
1631
+ }, target);
1632
+ vue.onUnmounted(() => {
1633
+ i18n.__deleteInstance(target);
1634
+ }, target);
1635
+ }
1636
+ const globalExportProps = [
1637
+ 'locale',
1638
+ 'fallbackLocale',
1639
+ 'availableLocales'
1640
+ ];
1641
+ const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm'];
1642
+ function injectGlobalFields(app, composer) {
1643
+ const i18n = Object.create(null);
1644
+ globalExportProps.forEach(prop => {
1645
+ const desc = Object.getOwnPropertyDescriptor(composer, prop);
1646
+ if (!desc) {
1647
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
1648
+ }
1649
+ const wrap = vue.isRef(desc.value) // check computed props
1650
+ ? {
1651
+ get() {
1652
+ return desc.value.value;
1653
+ },
1654
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1655
+ set(val) {
1656
+ desc.value.value = val;
1657
+ }
1658
+ }
1659
+ : {
1660
+ get() {
1661
+ return desc.get && desc.get();
1662
+ }
1663
+ };
1664
+ Object.defineProperty(i18n, prop, wrap);
1665
+ });
1666
+ app.config.globalProperties.$i18n = i18n;
1667
+ globalExportMethods.forEach(method => {
1668
+ const desc = Object.getOwnPropertyDescriptor(composer, method);
1669
+ if (!desc || !desc.value) {
1670
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
1671
+ }
1672
+ Object.defineProperty(app.config.globalProperties, `$${method}`, desc);
1673
+ });
1674
+ }
1675
+
1676
+ // register message compiler at vue-i18n
1677
+ coreBase.registerMessageCompiler(coreBase.compileToFunction);
1678
+
1679
+ exports.DatetimeFormat = DatetimeFormat;
1680
+ exports.NumberFormat = NumberFormat;
1681
+ exports.Translation = Translation;
1682
+ exports.VERSION = VERSION;
1683
+ exports.createI18n = createI18n;
1684
+ exports.useI18n = useI18n;
1685
+ exports.vTDirective = vTDirective;