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