@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,3724 @@
1
+ /*!
2
+ * vue-i18n v9.1.7
3
+ * (c) 2021 kazuya kawaguchi
4
+ * Released under the MIT License.
5
+ */
6
+ import { ref, getCurrentInstance, computed, watch, createVNode, Text, h, Fragment, inject, onMounted, onUnmounted, isRef } from 'vue';
7
+
8
+ /**
9
+ * Original Utilities
10
+ * written by kazuya kawaguchi
11
+ */
12
+ const inBrowser = typeof window !== 'undefined';
13
+ let mark;
14
+ let measure;
15
+ {
16
+ const perf = inBrowser && window.performance;
17
+ if (perf &&
18
+ perf.mark &&
19
+ perf.measure &&
20
+ perf.clearMarks &&
21
+ perf.clearMeasures) {
22
+ mark = (tag) => perf.mark(tag);
23
+ measure = (name, startTag, endTag) => {
24
+ perf.measure(name, startTag, endTag);
25
+ perf.clearMarks(startTag);
26
+ perf.clearMarks(endTag);
27
+ };
28
+ }
29
+ }
30
+ const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g;
31
+ /* eslint-disable */
32
+ function format(message, ...args) {
33
+ if (args.length === 1 && isObject(args[0])) {
34
+ args = args[0];
35
+ }
36
+ if (!args || !args.hasOwnProperty) {
37
+ args = {};
38
+ }
39
+ return message.replace(RE_ARGS, (match, identifier) => {
40
+ return args.hasOwnProperty(identifier) ? args[identifier] : '';
41
+ });
42
+ }
43
+ const hasSymbol = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
44
+ const makeSymbol = (name) => hasSymbol ? Symbol(name) : name;
45
+ const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source });
46
+ const friendlyJSONstringify = (json) => JSON.stringify(json)
47
+ .replace(/\u2028/g, '\\u2028')
48
+ .replace(/\u2029/g, '\\u2029')
49
+ .replace(/\u0027/g, '\\u0027');
50
+ const isNumber = (val) => typeof val === 'number' && isFinite(val);
51
+ const isDate = (val) => toTypeString(val) === '[object Date]';
52
+ const isRegExp = (val) => toTypeString(val) === '[object RegExp]';
53
+ const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0;
54
+ function warn(msg, err) {
55
+ if (typeof console !== 'undefined') {
56
+ console.warn(`[intlify] ` + msg);
57
+ /* istanbul ignore if */
58
+ if (err) {
59
+ console.warn(err.stack);
60
+ }
61
+ }
62
+ }
63
+ const assign = Object.assign;
64
+ let _globalThis;
65
+ const getGlobalThis = () => {
66
+ // prettier-ignore
67
+ return (_globalThis ||
68
+ (_globalThis =
69
+ typeof globalThis !== 'undefined'
70
+ ? globalThis
71
+ : typeof self !== 'undefined'
72
+ ? self
73
+ : typeof window !== 'undefined'
74
+ ? window
75
+ : typeof global !== 'undefined'
76
+ ? global
77
+ : {}));
78
+ };
79
+ function escapeHtml(rawText) {
80
+ return rawText
81
+ .replace(/</g, '&lt;')
82
+ .replace(/>/g, '&gt;')
83
+ .replace(/"/g, '&quot;')
84
+ .replace(/'/g, '&apos;');
85
+ }
86
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
87
+ function hasOwn(obj, key) {
88
+ return hasOwnProperty.call(obj, key);
89
+ }
90
+ /* eslint-enable */
91
+ /**
92
+ * Useful Utilities By Evan you
93
+ * Modified by kazuya kawaguchi
94
+ * MIT License
95
+ * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts
96
+ * https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts
97
+ */
98
+ const isArray = Array.isArray;
99
+ const isFunction = (val) => typeof val === 'function';
100
+ const isString = (val) => typeof val === 'string';
101
+ const isBoolean = (val) => typeof val === 'boolean';
102
+ const isObject = (val) => // eslint-disable-line
103
+ val !== null && typeof val === 'object';
104
+ const objectToString = Object.prototype.toString;
105
+ const toTypeString = (value) => objectToString.call(value);
106
+ const isPlainObject = (val) => toTypeString(val) === '[object Object]';
107
+ // for converting list and named values to displayed strings.
108
+ const toDisplayString = (val) => {
109
+ return val == null
110
+ ? ''
111
+ : isArray(val) || (isPlainObject(val) && val.toString === objectToString)
112
+ ? JSON.stringify(val, null, 2)
113
+ : String(val);
114
+ };
115
+ const RANGE = 2;
116
+ function generateCodeFrame(source, start = 0, end = source.length) {
117
+ const lines = source.split(/\r?\n/);
118
+ let count = 0;
119
+ const res = [];
120
+ for (let i = 0; i < lines.length; i++) {
121
+ count += lines[i].length + 1;
122
+ if (count >= start) {
123
+ for (let j = i - RANGE; j <= i + RANGE || end > count; j++) {
124
+ if (j < 0 || j >= lines.length)
125
+ continue;
126
+ const line = j + 1;
127
+ res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`);
128
+ const lineLength = lines[j].length;
129
+ if (j === i) {
130
+ // push underline
131
+ const pad = start - (count - lineLength) + 1;
132
+ const length = Math.max(1, end > count ? lineLength - pad : end - start);
133
+ res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
134
+ }
135
+ else if (j > i) {
136
+ if (end > count) {
137
+ const length = Math.max(Math.min(end - count, lineLength), 1);
138
+ res.push(` | ` + '^'.repeat(length));
139
+ }
140
+ count += lineLength + 1;
141
+ }
142
+ }
143
+ break;
144
+ }
145
+ }
146
+ return res.join('\n');
147
+ }
148
+
149
+ /**
150
+ * Event emitter, forked from the below:
151
+ * - original repository url: https://github.com/developit/mitt
152
+ * - code url: https://github.com/developit/mitt/blob/master/src/index.ts
153
+ * - author: Jason Miller (https://github.com/developit)
154
+ * - license: MIT
155
+ */
156
+ /**
157
+ * Create a event emitter
158
+ *
159
+ * @returns An event emitter
160
+ */
161
+ function createEmitter() {
162
+ const events = new Map();
163
+ const emitter = {
164
+ events,
165
+ on(event, handler) {
166
+ const handlers = events.get(event);
167
+ const added = handlers && handlers.push(handler);
168
+ if (!added) {
169
+ events.set(event, [handler]);
170
+ }
171
+ },
172
+ off(event, handler) {
173
+ const handlers = events.get(event);
174
+ if (handlers) {
175
+ handlers.splice(handlers.indexOf(handler) >>> 0, 1);
176
+ }
177
+ },
178
+ emit(event, payload) {
179
+ (events.get(event) || [])
180
+ .slice()
181
+ .map(handler => handler(payload));
182
+ (events.get('*') || [])
183
+ .slice()
184
+ .map(handler => handler(event, payload));
185
+ }
186
+ };
187
+ return emitter;
188
+ }
189
+
190
+ const pathStateMachine = [];
191
+ pathStateMachine[0 /* BEFORE_PATH */] = {
192
+ ["w" /* WORKSPACE */]: [0 /* BEFORE_PATH */],
193
+ ["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */],
194
+ ["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */],
195
+ ["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */]
196
+ };
197
+ pathStateMachine[1 /* IN_PATH */] = {
198
+ ["w" /* WORKSPACE */]: [1 /* IN_PATH */],
199
+ ["." /* DOT */]: [2 /* BEFORE_IDENT */],
200
+ ["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */],
201
+ ["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */]
202
+ };
203
+ pathStateMachine[2 /* BEFORE_IDENT */] = {
204
+ ["w" /* WORKSPACE */]: [2 /* BEFORE_IDENT */],
205
+ ["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */],
206
+ ["0" /* ZERO */]: [3 /* IN_IDENT */, 0 /* APPEND */]
207
+ };
208
+ pathStateMachine[3 /* IN_IDENT */] = {
209
+ ["i" /* IDENT */]: [3 /* IN_IDENT */, 0 /* APPEND */],
210
+ ["0" /* ZERO */]: [3 /* IN_IDENT */, 0 /* APPEND */],
211
+ ["w" /* WORKSPACE */]: [1 /* IN_PATH */, 1 /* PUSH */],
212
+ ["." /* DOT */]: [2 /* BEFORE_IDENT */, 1 /* PUSH */],
213
+ ["[" /* LEFT_BRACKET */]: [4 /* IN_SUB_PATH */, 1 /* PUSH */],
214
+ ["o" /* END_OF_FAIL */]: [7 /* AFTER_PATH */, 1 /* PUSH */]
215
+ };
216
+ pathStateMachine[4 /* IN_SUB_PATH */] = {
217
+ ["'" /* SINGLE_QUOTE */]: [5 /* IN_SINGLE_QUOTE */, 0 /* APPEND */],
218
+ ["\"" /* DOUBLE_QUOTE */]: [6 /* IN_DOUBLE_QUOTE */, 0 /* APPEND */],
219
+ ["[" /* LEFT_BRACKET */]: [
220
+ 4 /* IN_SUB_PATH */,
221
+ 2 /* INC_SUB_PATH_DEPTH */
222
+ ],
223
+ ["]" /* RIGHT_BRACKET */]: [1 /* IN_PATH */, 3 /* PUSH_SUB_PATH */],
224
+ ["o" /* END_OF_FAIL */]: 8 /* ERROR */,
225
+ ["l" /* ELSE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */]
226
+ };
227
+ pathStateMachine[5 /* IN_SINGLE_QUOTE */] = {
228
+ ["'" /* SINGLE_QUOTE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */],
229
+ ["o" /* END_OF_FAIL */]: 8 /* ERROR */,
230
+ ["l" /* ELSE */]: [5 /* IN_SINGLE_QUOTE */, 0 /* APPEND */]
231
+ };
232
+ pathStateMachine[6 /* IN_DOUBLE_QUOTE */] = {
233
+ ["\"" /* DOUBLE_QUOTE */]: [4 /* IN_SUB_PATH */, 0 /* APPEND */],
234
+ ["o" /* END_OF_FAIL */]: 8 /* ERROR */,
235
+ ["l" /* ELSE */]: [6 /* IN_DOUBLE_QUOTE */, 0 /* APPEND */]
236
+ };
237
+ /**
238
+ * Check if an expression is a literal value.
239
+ */
240
+ const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
241
+ function isLiteral(exp) {
242
+ return literalValueRE.test(exp);
243
+ }
244
+ /**
245
+ * Strip quotes from a string
246
+ */
247
+ function stripQuotes(str) {
248
+ const a = str.charCodeAt(0);
249
+ const b = str.charCodeAt(str.length - 1);
250
+ return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str;
251
+ }
252
+ /**
253
+ * Determine the type of a character in a keypath.
254
+ */
255
+ function getPathCharType(ch) {
256
+ if (ch === undefined || ch === null) {
257
+ return "o" /* END_OF_FAIL */;
258
+ }
259
+ const code = ch.charCodeAt(0);
260
+ switch (code) {
261
+ case 0x5b: // [
262
+ case 0x5d: // ]
263
+ case 0x2e: // .
264
+ case 0x22: // "
265
+ case 0x27: // '
266
+ return ch;
267
+ case 0x5f: // _
268
+ case 0x24: // $
269
+ case 0x2d: // -
270
+ return "i" /* IDENT */;
271
+ case 0x09: // Tab (HT)
272
+ case 0x0a: // Newline (LF)
273
+ case 0x0d: // Return (CR)
274
+ case 0xa0: // No-break space (NBSP)
275
+ case 0xfeff: // Byte Order Mark (BOM)
276
+ case 0x2028: // Line Separator (LS)
277
+ case 0x2029: // Paragraph Separator (PS)
278
+ return "w" /* WORKSPACE */;
279
+ }
280
+ return "i" /* IDENT */;
281
+ }
282
+ /**
283
+ * Format a subPath, return its plain form if it is
284
+ * a literal string or number. Otherwise prepend the
285
+ * dynamic indicator (*).
286
+ */
287
+ function formatSubPath(path) {
288
+ const trimmed = path.trim();
289
+ // invalid leading 0
290
+ if (path.charAt(0) === '0' && isNaN(parseInt(path))) {
291
+ return false;
292
+ }
293
+ return isLiteral(trimmed)
294
+ ? stripQuotes(trimmed)
295
+ : "*" /* ASTARISK */ + trimmed;
296
+ }
297
+ /**
298
+ * Parse a string path into an array of segments
299
+ */
300
+ function parse(path) {
301
+ const keys = [];
302
+ let index = -1;
303
+ let mode = 0 /* BEFORE_PATH */;
304
+ let subPathDepth = 0;
305
+ let c;
306
+ let key; // eslint-disable-line
307
+ let newChar;
308
+ let type;
309
+ let transition;
310
+ let action;
311
+ let typeMap;
312
+ const actions = [];
313
+ actions[0 /* APPEND */] = () => {
314
+ if (key === undefined) {
315
+ key = newChar;
316
+ }
317
+ else {
318
+ key += newChar;
319
+ }
320
+ };
321
+ actions[1 /* PUSH */] = () => {
322
+ if (key !== undefined) {
323
+ keys.push(key);
324
+ key = undefined;
325
+ }
326
+ };
327
+ actions[2 /* INC_SUB_PATH_DEPTH */] = () => {
328
+ actions[0 /* APPEND */]();
329
+ subPathDepth++;
330
+ };
331
+ actions[3 /* PUSH_SUB_PATH */] = () => {
332
+ if (subPathDepth > 0) {
333
+ subPathDepth--;
334
+ mode = 4 /* IN_SUB_PATH */;
335
+ actions[0 /* APPEND */]();
336
+ }
337
+ else {
338
+ subPathDepth = 0;
339
+ if (key === undefined) {
340
+ return false;
341
+ }
342
+ key = formatSubPath(key);
343
+ if (key === false) {
344
+ return false;
345
+ }
346
+ else {
347
+ actions[1 /* PUSH */]();
348
+ }
349
+ }
350
+ };
351
+ function maybeUnescapeQuote() {
352
+ const nextChar = path[index + 1];
353
+ if ((mode === 5 /* IN_SINGLE_QUOTE */ &&
354
+ nextChar === "'" /* SINGLE_QUOTE */) ||
355
+ (mode === 6 /* IN_DOUBLE_QUOTE */ &&
356
+ nextChar === "\"" /* DOUBLE_QUOTE */)) {
357
+ index++;
358
+ newChar = '\\' + nextChar;
359
+ actions[0 /* APPEND */]();
360
+ return true;
361
+ }
362
+ }
363
+ while (mode !== null) {
364
+ index++;
365
+ c = path[index];
366
+ if (c === '\\' && maybeUnescapeQuote()) {
367
+ continue;
368
+ }
369
+ type = getPathCharType(c);
370
+ typeMap = pathStateMachine[mode];
371
+ transition = typeMap[type] || typeMap["l" /* ELSE */] || 8 /* ERROR */;
372
+ // check parse error
373
+ if (transition === 8 /* ERROR */) {
374
+ return;
375
+ }
376
+ mode = transition[0];
377
+ if (transition[1] !== undefined) {
378
+ action = actions[transition[1]];
379
+ if (action) {
380
+ newChar = c;
381
+ if (action() === false) {
382
+ return;
383
+ }
384
+ }
385
+ }
386
+ // check parse finish
387
+ if (mode === 7 /* AFTER_PATH */) {
388
+ return keys;
389
+ }
390
+ }
391
+ }
392
+ // path token cache
393
+ const cache = new Map();
394
+ function resolveValue(obj, path) {
395
+ // check object
396
+ if (!isObject(obj)) {
397
+ return null;
398
+ }
399
+ // parse path
400
+ let hit = cache.get(path);
401
+ if (!hit) {
402
+ hit = parse(path);
403
+ if (hit) {
404
+ cache.set(path, hit);
405
+ }
406
+ }
407
+ // check hit
408
+ if (!hit) {
409
+ return null;
410
+ }
411
+ // resolve path value
412
+ const len = hit.length;
413
+ let last = obj;
414
+ let i = 0;
415
+ while (i < len) {
416
+ const val = last[hit[i]];
417
+ if (val === undefined) {
418
+ return null;
419
+ }
420
+ last = val;
421
+ i++;
422
+ }
423
+ return last;
424
+ }
425
+ /**
426
+ * Transform flat json in obj to normal json in obj
427
+ */
428
+ function handleFlatJson(obj) {
429
+ // check obj
430
+ if (!isObject(obj)) {
431
+ return obj;
432
+ }
433
+ for (const key in obj) {
434
+ // check key
435
+ if (!hasOwn(obj, key)) {
436
+ continue;
437
+ }
438
+ // handle for normal json
439
+ if (!key.includes("." /* DOT */)) {
440
+ // recursive process value if value is also a object
441
+ if (isObject(obj[key])) {
442
+ handleFlatJson(obj[key]);
443
+ }
444
+ }
445
+ // handle for flat json, transform to normal json
446
+ else {
447
+ // go to the last object
448
+ const subKeys = key.split("." /* DOT */);
449
+ const lastIndex = subKeys.length - 1;
450
+ let currentObj = obj;
451
+ for (let i = 0; i < lastIndex; i++) {
452
+ if (!(subKeys[i] in currentObj)) {
453
+ currentObj[subKeys[i]] = {};
454
+ }
455
+ currentObj = currentObj[subKeys[i]];
456
+ }
457
+ // update last object value, delete old property
458
+ currentObj[subKeys[lastIndex]] = obj[key];
459
+ delete obj[key];
460
+ // recursive process value if value is also a object
461
+ if (isObject(currentObj[subKeys[lastIndex]])) {
462
+ handleFlatJson(currentObj[subKeys[lastIndex]]);
463
+ }
464
+ }
465
+ }
466
+ return obj;
467
+ }
468
+
469
+ const DEFAULT_MODIFIER = (str) => str;
470
+ const DEFAULT_MESSAGE = (ctx) => ''; // eslint-disable-line
471
+ const DEFAULT_MESSAGE_DATA_TYPE = 'text';
472
+ const DEFAULT_NORMALIZE = (values) => values.length === 0 ? '' : values.join('');
473
+ const DEFAULT_INTERPOLATE = toDisplayString;
474
+ function pluralDefault(choice, choicesLength) {
475
+ choice = Math.abs(choice);
476
+ if (choicesLength === 2) {
477
+ // prettier-ignore
478
+ return choice
479
+ ? choice > 1
480
+ ? 1
481
+ : 0
482
+ : 1;
483
+ }
484
+ return choice ? Math.min(choice, 2) : 0;
485
+ }
486
+ function getPluralIndex(options) {
487
+ // prettier-ignore
488
+ const index = isNumber(options.pluralIndex)
489
+ ? options.pluralIndex
490
+ : -1;
491
+ // prettier-ignore
492
+ return options.named && (isNumber(options.named.count) || isNumber(options.named.n))
493
+ ? isNumber(options.named.count)
494
+ ? options.named.count
495
+ : isNumber(options.named.n)
496
+ ? options.named.n
497
+ : index
498
+ : index;
499
+ }
500
+ function normalizeNamed(pluralIndex, props) {
501
+ if (!props.count) {
502
+ props.count = pluralIndex;
503
+ }
504
+ if (!props.n) {
505
+ props.n = pluralIndex;
506
+ }
507
+ }
508
+ function createMessageContext(options = {}) {
509
+ const locale = options.locale;
510
+ const pluralIndex = getPluralIndex(options);
511
+ const pluralRule = isObject(options.pluralRules) &&
512
+ isString(locale) &&
513
+ isFunction(options.pluralRules[locale])
514
+ ? options.pluralRules[locale]
515
+ : pluralDefault;
516
+ const orgPluralRule = isObject(options.pluralRules) &&
517
+ isString(locale) &&
518
+ isFunction(options.pluralRules[locale])
519
+ ? pluralDefault
520
+ : undefined;
521
+ const plural = (messages) => messages[pluralRule(pluralIndex, messages.length, orgPluralRule)];
522
+ const _list = options.list || [];
523
+ const list = (index) => _list[index];
524
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
525
+ const _named = options.named || {};
526
+ isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named);
527
+ const named = (key) => _named[key];
528
+ // TODO: need to design resolve message function?
529
+ function message(key) {
530
+ // prettier-ignore
531
+ const msg = isFunction(options.messages)
532
+ ? options.messages(key)
533
+ : isObject(options.messages)
534
+ ? options.messages[key]
535
+ : false;
536
+ return !msg
537
+ ? options.parent
538
+ ? options.parent.message(key) // resolve from parent messages
539
+ : DEFAULT_MESSAGE
540
+ : msg;
541
+ }
542
+ const _modifier = (name) => options.modifiers
543
+ ? options.modifiers[name]
544
+ : DEFAULT_MODIFIER;
545
+ const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize)
546
+ ? options.processor.normalize
547
+ : DEFAULT_NORMALIZE;
548
+ const interpolate = isPlainObject(options.processor) &&
549
+ isFunction(options.processor.interpolate)
550
+ ? options.processor.interpolate
551
+ : DEFAULT_INTERPOLATE;
552
+ const type = isPlainObject(options.processor) && isString(options.processor.type)
553
+ ? options.processor.type
554
+ : DEFAULT_MESSAGE_DATA_TYPE;
555
+ const ctx = {
556
+ ["list" /* LIST */]: list,
557
+ ["named" /* NAMED */]: named,
558
+ ["plural" /* PLURAL */]: plural,
559
+ ["linked" /* LINKED */]: (key, modifier) => {
560
+ // TODO: should check `key`
561
+ const msg = message(key)(ctx);
562
+ return isString(modifier) ? _modifier(modifier)(msg) : msg;
563
+ },
564
+ ["message" /* MESSAGE */]: message,
565
+ ["type" /* TYPE */]: type,
566
+ ["interpolate" /* INTERPOLATE */]: interpolate,
567
+ ["normalize" /* NORMALIZE */]: normalize
568
+ };
569
+ return ctx;
570
+ }
571
+
572
+ /** @internal */
573
+ const errorMessages$2 = {
574
+ // tokenizer error messages
575
+ [0 /* EXPECTED_TOKEN */]: `Expected token: '{0}'`,
576
+ [1 /* INVALID_TOKEN_IN_PLACEHOLDER */]: `Invalid token in placeholder: '{0}'`,
577
+ [2 /* UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER */]: `Unterminated single quote in placeholder`,
578
+ [3 /* UNKNOWN_ESCAPE_SEQUENCE */]: `Unknown escape sequence: \\{0}`,
579
+ [4 /* INVALID_UNICODE_ESCAPE_SEQUENCE */]: `Invalid unicode escape sequence: {0}`,
580
+ [5 /* UNBALANCED_CLOSING_BRACE */]: `Unbalanced closing brace`,
581
+ [6 /* UNTERMINATED_CLOSING_BRACE */]: `Unterminated closing brace`,
582
+ [7 /* EMPTY_PLACEHOLDER */]: `Empty placeholder`,
583
+ [8 /* NOT_ALLOW_NEST_PLACEHOLDER */]: `Not allowed nest placeholder`,
584
+ [9 /* INVALID_LINKED_FORMAT */]: `Invalid linked format`,
585
+ // parser error messages
586
+ [10 /* MUST_HAVE_MESSAGES_IN_PLURAL */]: `Plural must have messages`,
587
+ [11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */]: `Unexpected empty linked modifier`,
588
+ [12 /* UNEXPECTED_EMPTY_LINKED_KEY */]: `Unexpected empty linked key`,
589
+ [13 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'`
590
+ };
591
+ function createCompileError(code, loc, options = {}) {
592
+ const { domain, messages, args } = options;
593
+ const msg = format((messages || errorMessages$2)[code] || '', ...(args || []))
594
+ ;
595
+ const error = new SyntaxError(String(msg));
596
+ error.code = code;
597
+ if (loc) {
598
+ error.location = loc;
599
+ }
600
+ error.domain = domain;
601
+ return error;
602
+ }
603
+
604
+ const IntlifyDevToolsHooks = {
605
+ I18nInit: 'i18n:init',
606
+ FunctionTranslate: 'function:translate'
607
+ };
608
+
609
+ let devtools = null;
610
+ function setDevToolsHook(hook) {
611
+ devtools = hook;
612
+ }
613
+ function initI18nDevTools(i18n, version, meta) {
614
+ // TODO: queue if devtools is undefined
615
+ devtools &&
616
+ devtools.emit(IntlifyDevToolsHooks.I18nInit, {
617
+ timestamp: Date.now(),
618
+ i18n,
619
+ version,
620
+ meta
621
+ });
622
+ }
623
+ const translateDevTools = /* #__PURE__*/ createDevToolsHook(IntlifyDevToolsHooks.FunctionTranslate);
624
+ function createDevToolsHook(hook) {
625
+ return (payloads) => devtools && devtools.emit(hook, payloads);
626
+ }
627
+
628
+ /** @internal */
629
+ const warnMessages$1 = {
630
+ [0 /* NOT_FOUND_KEY */]: `Not found '{key}' key in '{locale}' locale messages.`,
631
+ [1 /* FALLBACK_TO_TRANSLATE */]: `Fall back to translate '{key}' key with '{target}' locale.`,
632
+ [2 /* CANNOT_FORMAT_NUMBER */]: `Cannot format a number value due to not supported Intl.NumberFormat.`,
633
+ [3 /* FALLBACK_TO_NUMBER_FORMAT */]: `Fall back to number format '{key}' key with '{target}' locale.`,
634
+ [4 /* CANNOT_FORMAT_DATE */]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`,
635
+ [5 /* FALLBACK_TO_DATE_FORMAT */]: `Fall back to datetime format '{key}' key with '{target}' locale.`
636
+ };
637
+ function getWarnMessage$1(code, ...args) {
638
+ return format(warnMessages$1[code], ...args);
639
+ }
640
+
641
+ /**
642
+ * Intlify core-base version
643
+ * @internal
644
+ */
645
+ const VERSION$1 = '9.1.7';
646
+ const NOT_REOSLVED = -1;
647
+ const MISSING_RESOLVE_VALUE = '';
648
+ function getDefaultLinkedModifiers() {
649
+ return {
650
+ upper: (val) => (isString(val) ? val.toUpperCase() : val),
651
+ lower: (val) => (isString(val) ? val.toLowerCase() : val),
652
+ // prettier-ignore
653
+ capitalize: (val) => (isString(val)
654
+ ? `${val.charAt(0).toLocaleUpperCase()}${val.substr(1)}`
655
+ : val)
656
+ };
657
+ }
658
+ let _compiler;
659
+ // Additional Meta for Intlify DevTools
660
+ let _additionalMeta = null;
661
+ const setAdditionalMeta = /* #__PURE__*/ (meta) => {
662
+ _additionalMeta = meta;
663
+ };
664
+ const getAdditionalMeta = /* #__PURE__*/ () => _additionalMeta;
665
+ // ID for CoreContext
666
+ let _cid = 0;
667
+ function createCoreContext(options = {}) {
668
+ // setup options
669
+ const version = isString(options.version) ? options.version : VERSION$1;
670
+ const locale = isString(options.locale) ? options.locale : 'en-US';
671
+ const fallbackLocale = isArray(options.fallbackLocale) ||
672
+ isPlainObject(options.fallbackLocale) ||
673
+ isString(options.fallbackLocale) ||
674
+ options.fallbackLocale === false
675
+ ? options.fallbackLocale
676
+ : locale;
677
+ const messages = isPlainObject(options.messages)
678
+ ? options.messages
679
+ : { [locale]: {} };
680
+ const datetimeFormats = isPlainObject(options.datetimeFormats)
681
+ ? options.datetimeFormats
682
+ : { [locale]: {} };
683
+ const numberFormats = isPlainObject(options.numberFormats)
684
+ ? options.numberFormats
685
+ : { [locale]: {} };
686
+ const modifiers = assign({}, options.modifiers || {}, getDefaultLinkedModifiers());
687
+ const pluralRules = options.pluralRules || {};
688
+ const missing = isFunction(options.missing) ? options.missing : null;
689
+ const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn)
690
+ ? options.missingWarn
691
+ : true;
692
+ const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn)
693
+ ? options.fallbackWarn
694
+ : true;
695
+ const fallbackFormat = !!options.fallbackFormat;
696
+ const unresolving = !!options.unresolving;
697
+ const postTranslation = isFunction(options.postTranslation)
698
+ ? options.postTranslation
699
+ : null;
700
+ const processor = isPlainObject(options.processor) ? options.processor : null;
701
+ const warnHtmlMessage = isBoolean(options.warnHtmlMessage)
702
+ ? options.warnHtmlMessage
703
+ : true;
704
+ const escapeParameter = !!options.escapeParameter;
705
+ const messageCompiler = isFunction(options.messageCompiler)
706
+ ? options.messageCompiler
707
+ : _compiler;
708
+ const onWarn = isFunction(options.onWarn) ? options.onWarn : warn;
709
+ // setup internal options
710
+ const internalOptions = options;
711
+ const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters)
712
+ ? internalOptions.__datetimeFormatters
713
+ : new Map();
714
+ const __numberFormatters = isObject(internalOptions.__numberFormatters)
715
+ ? internalOptions.__numberFormatters
716
+ : new Map();
717
+ const __meta = isObject(internalOptions.__meta) ? internalOptions.__meta : {};
718
+ _cid++;
719
+ const context = {
720
+ version,
721
+ cid: _cid,
722
+ locale,
723
+ fallbackLocale,
724
+ messages,
725
+ datetimeFormats,
726
+ numberFormats,
727
+ modifiers,
728
+ pluralRules,
729
+ missing,
730
+ missingWarn,
731
+ fallbackWarn,
732
+ fallbackFormat,
733
+ unresolving,
734
+ postTranslation,
735
+ processor,
736
+ warnHtmlMessage,
737
+ escapeParameter,
738
+ messageCompiler,
739
+ onWarn,
740
+ __datetimeFormatters,
741
+ __numberFormatters,
742
+ __meta
743
+ };
744
+ // for vue-devtools timeline event
745
+ {
746
+ context.__v_emitter =
747
+ internalOptions.__v_emitter != null
748
+ ? internalOptions.__v_emitter
749
+ : undefined;
750
+ }
751
+ // NOTE: experimental !!
752
+ {
753
+ initI18nDevTools(context, version, __meta);
754
+ }
755
+ return context;
756
+ }
757
+ /** @internal */
758
+ function isTranslateFallbackWarn(fallback, key) {
759
+ return fallback instanceof RegExp ? fallback.test(key) : fallback;
760
+ }
761
+ /** @internal */
762
+ function isTranslateMissingWarn(missing, key) {
763
+ return missing instanceof RegExp ? missing.test(key) : missing;
764
+ }
765
+ /** @internal */
766
+ function handleMissing(context, key, locale, missingWarn, type) {
767
+ const { missing, onWarn } = context;
768
+ // for vue-devtools timeline event
769
+ {
770
+ const emitter = context.__v_emitter;
771
+ if (emitter) {
772
+ emitter.emit("missing" /* MISSING */, {
773
+ locale,
774
+ key,
775
+ type,
776
+ groupId: `${type}:${key}`
777
+ });
778
+ }
779
+ }
780
+ if (missing !== null) {
781
+ const ret = missing(context, locale, key, type);
782
+ return isString(ret) ? ret : key;
783
+ }
784
+ else {
785
+ if (isTranslateMissingWarn(missingWarn, key)) {
786
+ onWarn(getWarnMessage$1(0 /* NOT_FOUND_KEY */, { key, locale }));
787
+ }
788
+ return key;
789
+ }
790
+ }
791
+ /** @internal */
792
+ function getLocaleChain(ctx, fallback, start) {
793
+ const context = ctx;
794
+ if (!context.__localeChainCache) {
795
+ context.__localeChainCache = new Map();
796
+ }
797
+ let chain = context.__localeChainCache.get(start);
798
+ if (!chain) {
799
+ chain = [];
800
+ // first block defined by start
801
+ let block = [start];
802
+ // while any intervening block found
803
+ while (isArray(block)) {
804
+ block = appendBlockToChain(chain, block, fallback);
805
+ }
806
+ // prettier-ignore
807
+ // last block defined by default
808
+ const defaults = isArray(fallback)
809
+ ? fallback
810
+ : isPlainObject(fallback)
811
+ ? fallback['default']
812
+ ? fallback['default']
813
+ : null
814
+ : fallback;
815
+ // convert defaults to array
816
+ block = isString(defaults) ? [defaults] : defaults;
817
+ if (isArray(block)) {
818
+ appendBlockToChain(chain, block, false);
819
+ }
820
+ context.__localeChainCache.set(start, chain);
821
+ }
822
+ return chain;
823
+ }
824
+ function appendBlockToChain(chain, block, blocks) {
825
+ let follow = true;
826
+ for (let i = 0; i < block.length && isBoolean(follow); i++) {
827
+ const locale = block[i];
828
+ if (isString(locale)) {
829
+ follow = appendLocaleToChain(chain, block[i], blocks);
830
+ }
831
+ }
832
+ return follow;
833
+ }
834
+ function appendLocaleToChain(chain, locale, blocks) {
835
+ let follow;
836
+ const tokens = locale.split('-');
837
+ do {
838
+ const target = tokens.join('-');
839
+ follow = appendItemToChain(chain, target, blocks);
840
+ tokens.splice(-1, 1);
841
+ } while (tokens.length && follow === true);
842
+ return follow;
843
+ }
844
+ function appendItemToChain(chain, target, blocks) {
845
+ let follow = false;
846
+ if (!chain.includes(target)) {
847
+ follow = true;
848
+ if (target) {
849
+ follow = target[target.length - 1] !== '!';
850
+ const locale = target.replace(/!/g, '');
851
+ chain.push(locale);
852
+ if ((isArray(blocks) || isPlainObject(blocks)) &&
853
+ blocks[locale] // eslint-disable-line @typescript-eslint/no-explicit-any
854
+ ) {
855
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
856
+ follow = blocks[locale];
857
+ }
858
+ }
859
+ }
860
+ return follow;
861
+ }
862
+ /** @internal */
863
+ function updateFallbackLocale(ctx, locale, fallback) {
864
+ const context = ctx;
865
+ context.__localeChainCache = new Map();
866
+ getLocaleChain(ctx, fallback, locale);
867
+ }
868
+
869
+ function createCoreError(code) {
870
+ return createCompileError(code, null, { messages: errorMessages$1 } );
871
+ }
872
+ /** @internal */
873
+ const errorMessages$1 = {
874
+ [14 /* INVALID_ARGUMENT */]: 'Invalid arguments',
875
+ [15 /* INVALID_DATE_ARGUMENT */]: 'The date provided is an invalid Date object.' +
876
+ 'Make sure your Date represents a valid date.',
877
+ [16 /* INVALID_ISO_DATE_ARGUMENT */]: 'The argument provided is not a valid ISO date string'
878
+ };
879
+
880
+ const NOOP_MESSAGE_FUNCTION = () => '';
881
+ const isMessageFunction = (val) => isFunction(val);
882
+ // implementation of `translate` function
883
+ function translate(context, ...args) {
884
+ const { fallbackFormat, postTranslation, unresolving, fallbackLocale, messages } = context;
885
+ const [key, options] = parseTranslateArgs(...args);
886
+ const missingWarn = isBoolean(options.missingWarn)
887
+ ? options.missingWarn
888
+ : context.missingWarn;
889
+ const fallbackWarn = isBoolean(options.fallbackWarn)
890
+ ? options.fallbackWarn
891
+ : context.fallbackWarn;
892
+ const escapeParameter = isBoolean(options.escapeParameter)
893
+ ? options.escapeParameter
894
+ : context.escapeParameter;
895
+ const resolvedMessage = !!options.resolvedMessage;
896
+ // prettier-ignore
897
+ const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option
898
+ ? !isBoolean(options.default)
899
+ ? options.default
900
+ : key
901
+ : fallbackFormat // default by `fallbackFormat` option
902
+ ? key
903
+ : '';
904
+ const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== '';
905
+ const locale = isString(options.locale) ? options.locale : context.locale;
906
+ // escape params
907
+ escapeParameter && escapeParams(options);
908
+ // resolve message format
909
+ // eslint-disable-next-line prefer-const
910
+ let [format, targetLocale, message] = !resolvedMessage
911
+ ? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn)
912
+ : [
913
+ key,
914
+ locale,
915
+ messages[locale] || {}
916
+ ];
917
+ // if you use default message, set it as message format!
918
+ let cacheBaseKey = key;
919
+ if (!resolvedMessage &&
920
+ !(isString(format) || isMessageFunction(format))) {
921
+ if (enableDefaultMsg) {
922
+ format = defaultMsgOrKey;
923
+ cacheBaseKey = format;
924
+ }
925
+ }
926
+ // checking message format and target locale
927
+ if (!resolvedMessage &&
928
+ (!(isString(format) || isMessageFunction(format)) ||
929
+ !isString(targetLocale))) {
930
+ return unresolving ? NOT_REOSLVED : key;
931
+ }
932
+ if (isString(format) && context.messageCompiler == null) {
933
+ warn(`The message format compilation is not supported in this build. ` +
934
+ `Because message compiler isn't included. ` +
935
+ `You need to pre-compilation all message format. ` +
936
+ `So translate function return '${key}'.`);
937
+ return key;
938
+ }
939
+ // setup compile error detecting
940
+ let occurred = false;
941
+ const errorDetector = () => {
942
+ occurred = true;
943
+ };
944
+ // compile message format
945
+ const msg = !isMessageFunction(format)
946
+ ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector)
947
+ : format;
948
+ // if occurred compile error, return the message format
949
+ if (occurred) {
950
+ return format;
951
+ }
952
+ // evaluate message with context
953
+ const ctxOptions = getMessageContextOptions(context, targetLocale, message, options);
954
+ const msgContext = createMessageContext(ctxOptions);
955
+ const messaged = evaluateMessage(context, msg, msgContext);
956
+ // if use post translation option, proceed it with handler
957
+ const ret = postTranslation ? postTranslation(messaged) : messaged;
958
+ // NOTE: experimental !!
959
+ {
960
+ // prettier-ignore
961
+ const payloads = {
962
+ timestamp: Date.now(),
963
+ key: isString(key)
964
+ ? key
965
+ : isMessageFunction(format)
966
+ ? format.key
967
+ : '',
968
+ locale: targetLocale || (isMessageFunction(format)
969
+ ? format.locale
970
+ : ''),
971
+ format: isString(format)
972
+ ? format
973
+ : isMessageFunction(format)
974
+ ? format.source
975
+ : '',
976
+ message: ret
977
+ };
978
+ payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {});
979
+ translateDevTools(payloads);
980
+ }
981
+ return ret;
982
+ }
983
+ function escapeParams(options) {
984
+ if (isArray(options.list)) {
985
+ options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item);
986
+ }
987
+ else if (isObject(options.named)) {
988
+ Object.keys(options.named).forEach(key => {
989
+ if (isString(options.named[key])) {
990
+ options.named[key] = escapeHtml(options.named[key]);
991
+ }
992
+ });
993
+ }
994
+ }
995
+ function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
996
+ const { messages, onWarn } = context;
997
+ const locales = getLocaleChain(context, fallbackLocale, locale);
998
+ let message = {};
999
+ let targetLocale;
1000
+ let format = null;
1001
+ let from = locale;
1002
+ let to = null;
1003
+ const type = 'translate';
1004
+ for (let i = 0; i < locales.length; i++) {
1005
+ targetLocale = to = locales[i];
1006
+ if (locale !== targetLocale &&
1007
+ isTranslateFallbackWarn(fallbackWarn, key)) {
1008
+ onWarn(getWarnMessage$1(1 /* FALLBACK_TO_TRANSLATE */, {
1009
+ key,
1010
+ target: targetLocale
1011
+ }));
1012
+ }
1013
+ // for vue-devtools timeline event
1014
+ if (locale !== targetLocale) {
1015
+ const emitter = context.__v_emitter;
1016
+ if (emitter) {
1017
+ emitter.emit("fallback" /* FALBACK */, {
1018
+ type,
1019
+ key,
1020
+ from,
1021
+ to,
1022
+ groupId: `${type}:${key}`
1023
+ });
1024
+ }
1025
+ }
1026
+ message =
1027
+ messages[targetLocale] || {};
1028
+ // for vue-devtools timeline event
1029
+ let start = null;
1030
+ let startTag;
1031
+ let endTag;
1032
+ if (inBrowser) {
1033
+ start = window.performance.now();
1034
+ startTag = 'intlify-message-resolve-start';
1035
+ endTag = 'intlify-message-resolve-end';
1036
+ mark && mark(startTag);
1037
+ }
1038
+ if ((format = resolveValue(message, key)) === null) {
1039
+ // if null, resolve with object key path
1040
+ format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any
1041
+ }
1042
+ // for vue-devtools timeline event
1043
+ if (inBrowser) {
1044
+ const end = window.performance.now();
1045
+ const emitter = context.__v_emitter;
1046
+ if (emitter && start && format) {
1047
+ emitter.emit("message-resolve" /* MESSAGE_RESOLVE */, {
1048
+ type: "message-resolve" /* MESSAGE_RESOLVE */,
1049
+ key,
1050
+ message: format,
1051
+ time: end - start,
1052
+ groupId: `${type}:${key}`
1053
+ });
1054
+ }
1055
+ if (startTag && endTag && mark && measure) {
1056
+ mark(endTag);
1057
+ measure('intlify message resolve', startTag, endTag);
1058
+ }
1059
+ }
1060
+ if (isString(format) || isFunction(format))
1061
+ break;
1062
+ const missingRet = handleMissing(context, key, targetLocale, missingWarn, type);
1063
+ if (missingRet !== key) {
1064
+ format = missingRet;
1065
+ }
1066
+ from = to;
1067
+ }
1068
+ return [format, targetLocale, message];
1069
+ }
1070
+ function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, errorDetector) {
1071
+ const { messageCompiler, warnHtmlMessage } = context;
1072
+ if (isMessageFunction(format)) {
1073
+ const msg = format;
1074
+ msg.locale = msg.locale || targetLocale;
1075
+ msg.key = msg.key || key;
1076
+ return msg;
1077
+ }
1078
+ // for vue-devtools timeline event
1079
+ let start = null;
1080
+ let startTag;
1081
+ let endTag;
1082
+ if (inBrowser) {
1083
+ start = window.performance.now();
1084
+ startTag = 'intlify-message-compilation-start';
1085
+ endTag = 'intlify-message-compilation-end';
1086
+ mark && mark(startTag);
1087
+ }
1088
+ const msg = messageCompiler(format, getCompileOptions(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, errorDetector));
1089
+ // for vue-devtools timeline event
1090
+ if (inBrowser) {
1091
+ const end = window.performance.now();
1092
+ const emitter = context.__v_emitter;
1093
+ if (emitter && start) {
1094
+ emitter.emit("message-compilation" /* MESSAGE_COMPILATION */, {
1095
+ type: "message-compilation" /* MESSAGE_COMPILATION */,
1096
+ message: format,
1097
+ time: end - start,
1098
+ groupId: `${'translate'}:${key}`
1099
+ });
1100
+ }
1101
+ if (startTag && endTag && mark && measure) {
1102
+ mark(endTag);
1103
+ measure('intlify message compilation', startTag, endTag);
1104
+ }
1105
+ }
1106
+ msg.locale = targetLocale;
1107
+ msg.key = key;
1108
+ msg.source = format;
1109
+ return msg;
1110
+ }
1111
+ function evaluateMessage(context, msg, msgCtx) {
1112
+ // for vue-devtools timeline event
1113
+ let start = null;
1114
+ let startTag;
1115
+ let endTag;
1116
+ if (inBrowser) {
1117
+ start = window.performance.now();
1118
+ startTag = 'intlify-message-evaluation-start';
1119
+ endTag = 'intlify-message-evaluation-end';
1120
+ mark && mark(startTag);
1121
+ }
1122
+ const messaged = msg(msgCtx);
1123
+ // for vue-devtools timeline event
1124
+ if (inBrowser) {
1125
+ const end = window.performance.now();
1126
+ const emitter = context.__v_emitter;
1127
+ if (emitter && start) {
1128
+ emitter.emit("message-evaluation" /* MESSAGE_EVALUATION */, {
1129
+ type: "message-evaluation" /* MESSAGE_EVALUATION */,
1130
+ value: messaged,
1131
+ time: end - start,
1132
+ groupId: `${'translate'}:${msg.key}`
1133
+ });
1134
+ }
1135
+ if (startTag && endTag && mark && measure) {
1136
+ mark(endTag);
1137
+ measure('intlify message evaluation', startTag, endTag);
1138
+ }
1139
+ }
1140
+ return messaged;
1141
+ }
1142
+ /** @internal */
1143
+ function parseTranslateArgs(...args) {
1144
+ const [arg1, arg2, arg3] = args;
1145
+ const options = {};
1146
+ if (!isString(arg1) && !isNumber(arg1) && !isMessageFunction(arg1)) {
1147
+ throw createCoreError(14 /* INVALID_ARGUMENT */);
1148
+ }
1149
+ // prettier-ignore
1150
+ const key = isNumber(arg1)
1151
+ ? String(arg1)
1152
+ : isMessageFunction(arg1)
1153
+ ? arg1
1154
+ : arg1;
1155
+ if (isNumber(arg2)) {
1156
+ options.plural = arg2;
1157
+ }
1158
+ else if (isString(arg2)) {
1159
+ options.default = arg2;
1160
+ }
1161
+ else if (isPlainObject(arg2) && !isEmptyObject(arg2)) {
1162
+ options.named = arg2;
1163
+ }
1164
+ else if (isArray(arg2)) {
1165
+ options.list = arg2;
1166
+ }
1167
+ if (isNumber(arg3)) {
1168
+ options.plural = arg3;
1169
+ }
1170
+ else if (isString(arg3)) {
1171
+ options.default = arg3;
1172
+ }
1173
+ else if (isPlainObject(arg3)) {
1174
+ assign(options, arg3);
1175
+ }
1176
+ return [key, options];
1177
+ }
1178
+ function getCompileOptions(context, locale, key, source, warnHtmlMessage, errorDetector) {
1179
+ return {
1180
+ warnHtmlMessage,
1181
+ onError: (err) => {
1182
+ errorDetector && errorDetector(err);
1183
+ {
1184
+ const message = `Message compilation error: ${err.message}`;
1185
+ const codeFrame = err.location &&
1186
+ generateCodeFrame(source, err.location.start.offset, err.location.end.offset);
1187
+ const emitter = context
1188
+ .__v_emitter;
1189
+ if (emitter) {
1190
+ emitter.emit("compile-error" /* COMPILE_ERROR */, {
1191
+ message: source,
1192
+ error: err.message,
1193
+ start: err.location && err.location.start.offset,
1194
+ end: err.location && err.location.end.offset,
1195
+ groupId: `${'translate'}:${key}`
1196
+ });
1197
+ }
1198
+ console.error(codeFrame ? `${message}\n${codeFrame}` : message);
1199
+ }
1200
+ },
1201
+ onCacheKey: (source) => generateFormatCacheKey(locale, key, source)
1202
+ };
1203
+ }
1204
+ function getMessageContextOptions(context, locale, message, options) {
1205
+ const { modifiers, pluralRules } = context;
1206
+ const resolveMessage = (key) => {
1207
+ const val = resolveValue(message, key);
1208
+ if (isString(val)) {
1209
+ let occurred = false;
1210
+ const errorDetector = () => {
1211
+ occurred = true;
1212
+ };
1213
+ const msg = compileMessageFormat(context, key, locale, val, key, errorDetector);
1214
+ return !occurred
1215
+ ? msg
1216
+ : NOOP_MESSAGE_FUNCTION;
1217
+ }
1218
+ else if (isMessageFunction(val)) {
1219
+ return val;
1220
+ }
1221
+ else {
1222
+ // TODO: should be implemented warning message
1223
+ return NOOP_MESSAGE_FUNCTION;
1224
+ }
1225
+ };
1226
+ const ctxOptions = {
1227
+ locale,
1228
+ modifiers,
1229
+ pluralRules,
1230
+ messages: resolveMessage
1231
+ };
1232
+ if (context.processor) {
1233
+ ctxOptions.processor = context.processor;
1234
+ }
1235
+ if (options.list) {
1236
+ ctxOptions.list = options.list;
1237
+ }
1238
+ if (options.named) {
1239
+ ctxOptions.named = options.named;
1240
+ }
1241
+ if (isNumber(options.plural)) {
1242
+ ctxOptions.pluralIndex = options.plural;
1243
+ }
1244
+ return ctxOptions;
1245
+ }
1246
+
1247
+ const intlDefined = typeof Intl !== 'undefined';
1248
+ const Availabilities = {
1249
+ dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined',
1250
+ numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined'
1251
+ };
1252
+
1253
+ // implementation of `datetime` function
1254
+ function datetime(context, ...args) {
1255
+ const { datetimeFormats, unresolving, fallbackLocale, onWarn } = context;
1256
+ const { __datetimeFormatters } = context;
1257
+ if (!Availabilities.dateTimeFormat) {
1258
+ onWarn(getWarnMessage$1(4 /* CANNOT_FORMAT_DATE */));
1259
+ return MISSING_RESOLVE_VALUE;
1260
+ }
1261
+ const [key, value, options, overrides] = parseDateTimeArgs(...args);
1262
+ const missingWarn = isBoolean(options.missingWarn)
1263
+ ? options.missingWarn
1264
+ : context.missingWarn;
1265
+ const fallbackWarn = isBoolean(options.fallbackWarn)
1266
+ ? options.fallbackWarn
1267
+ : context.fallbackWarn;
1268
+ const part = !!options.part;
1269
+ const locale = isString(options.locale) ? options.locale : context.locale;
1270
+ const locales = getLocaleChain(context, fallbackLocale, locale);
1271
+ if (!isString(key) || key === '') {
1272
+ return new Intl.DateTimeFormat(locale).format(value);
1273
+ }
1274
+ // resolve format
1275
+ let datetimeFormat = {};
1276
+ let targetLocale;
1277
+ let format = null;
1278
+ let from = locale;
1279
+ let to = null;
1280
+ const type = 'datetime format';
1281
+ for (let i = 0; i < locales.length; i++) {
1282
+ targetLocale = to = locales[i];
1283
+ if (locale !== targetLocale &&
1284
+ isTranslateFallbackWarn(fallbackWarn, key)) {
1285
+ onWarn(getWarnMessage$1(5 /* FALLBACK_TO_DATE_FORMAT */, {
1286
+ key,
1287
+ target: targetLocale
1288
+ }));
1289
+ }
1290
+ // for vue-devtools timeline event
1291
+ if (locale !== targetLocale) {
1292
+ const emitter = context.__v_emitter;
1293
+ if (emitter) {
1294
+ emitter.emit("fallback" /* FALBACK */, {
1295
+ type,
1296
+ key,
1297
+ from,
1298
+ to,
1299
+ groupId: `${type}:${key}`
1300
+ });
1301
+ }
1302
+ }
1303
+ datetimeFormat =
1304
+ datetimeFormats[targetLocale] || {};
1305
+ format = datetimeFormat[key];
1306
+ if (isPlainObject(format))
1307
+ break;
1308
+ handleMissing(context, key, targetLocale, missingWarn, type);
1309
+ from = to;
1310
+ }
1311
+ // checking format and target locale
1312
+ if (!isPlainObject(format) || !isString(targetLocale)) {
1313
+ return unresolving ? NOT_REOSLVED : key;
1314
+ }
1315
+ let id = `${targetLocale}__${key}`;
1316
+ if (!isEmptyObject(overrides)) {
1317
+ id = `${id}__${JSON.stringify(overrides)}`;
1318
+ }
1319
+ let formatter = __datetimeFormatters.get(id);
1320
+ if (!formatter) {
1321
+ formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides));
1322
+ __datetimeFormatters.set(id, formatter);
1323
+ }
1324
+ return !part ? formatter.format(value) : formatter.formatToParts(value);
1325
+ }
1326
+ /** @internal */
1327
+ function parseDateTimeArgs(...args) {
1328
+ const [arg1, arg2, arg3, arg4] = args;
1329
+ let options = {};
1330
+ let overrides = {};
1331
+ let value;
1332
+ if (isString(arg1)) {
1333
+ // Only allow ISO strings - other date formats are often supported,
1334
+ // but may cause different results in different browsers.
1335
+ if (!/\d{4}-\d{2}-\d{2}(T.*)?/.test(arg1)) {
1336
+ throw createCoreError(16 /* INVALID_ISO_DATE_ARGUMENT */);
1337
+ }
1338
+ value = new Date(arg1);
1339
+ try {
1340
+ // This will fail if the date is not valid
1341
+ value.toISOString();
1342
+ }
1343
+ catch (e) {
1344
+ throw createCoreError(16 /* INVALID_ISO_DATE_ARGUMENT */);
1345
+ }
1346
+ }
1347
+ else if (isDate(arg1)) {
1348
+ if (isNaN(arg1.getTime())) {
1349
+ throw createCoreError(15 /* INVALID_DATE_ARGUMENT */);
1350
+ }
1351
+ value = arg1;
1352
+ }
1353
+ else if (isNumber(arg1)) {
1354
+ value = arg1;
1355
+ }
1356
+ else {
1357
+ throw createCoreError(14 /* INVALID_ARGUMENT */);
1358
+ }
1359
+ if (isString(arg2)) {
1360
+ options.key = arg2;
1361
+ }
1362
+ else if (isPlainObject(arg2)) {
1363
+ options = arg2;
1364
+ }
1365
+ if (isString(arg3)) {
1366
+ options.locale = arg3;
1367
+ }
1368
+ else if (isPlainObject(arg3)) {
1369
+ overrides = arg3;
1370
+ }
1371
+ if (isPlainObject(arg4)) {
1372
+ overrides = arg4;
1373
+ }
1374
+ return [options.key || '', value, options, overrides];
1375
+ }
1376
+ /** @internal */
1377
+ function clearDateTimeFormat(ctx, locale, format) {
1378
+ const context = ctx;
1379
+ for (const key in format) {
1380
+ const id = `${locale}__${key}`;
1381
+ if (!context.__datetimeFormatters.has(id)) {
1382
+ continue;
1383
+ }
1384
+ context.__datetimeFormatters.delete(id);
1385
+ }
1386
+ }
1387
+
1388
+ // implementation of `number` function
1389
+ function number(context, ...args) {
1390
+ const { numberFormats, unresolving, fallbackLocale, onWarn } = context;
1391
+ const { __numberFormatters } = context;
1392
+ if (!Availabilities.numberFormat) {
1393
+ onWarn(getWarnMessage$1(2 /* CANNOT_FORMAT_NUMBER */));
1394
+ return MISSING_RESOLVE_VALUE;
1395
+ }
1396
+ const [key, value, options, overrides] = parseNumberArgs(...args);
1397
+ const missingWarn = isBoolean(options.missingWarn)
1398
+ ? options.missingWarn
1399
+ : context.missingWarn;
1400
+ const fallbackWarn = isBoolean(options.fallbackWarn)
1401
+ ? options.fallbackWarn
1402
+ : context.fallbackWarn;
1403
+ const part = !!options.part;
1404
+ const locale = isString(options.locale) ? options.locale : context.locale;
1405
+ const locales = getLocaleChain(context, fallbackLocale, locale);
1406
+ if (!isString(key) || key === '') {
1407
+ return new Intl.NumberFormat(locale).format(value);
1408
+ }
1409
+ // resolve format
1410
+ let numberFormat = {};
1411
+ let targetLocale;
1412
+ let format = null;
1413
+ let from = locale;
1414
+ let to = null;
1415
+ const type = 'number format';
1416
+ for (let i = 0; i < locales.length; i++) {
1417
+ targetLocale = to = locales[i];
1418
+ if (locale !== targetLocale &&
1419
+ isTranslateFallbackWarn(fallbackWarn, key)) {
1420
+ onWarn(getWarnMessage$1(3 /* FALLBACK_TO_NUMBER_FORMAT */, {
1421
+ key,
1422
+ target: targetLocale
1423
+ }));
1424
+ }
1425
+ // for vue-devtools timeline event
1426
+ if (locale !== targetLocale) {
1427
+ const emitter = context.__v_emitter;
1428
+ if (emitter) {
1429
+ emitter.emit("fallback" /* FALBACK */, {
1430
+ type,
1431
+ key,
1432
+ from,
1433
+ to,
1434
+ groupId: `${type}:${key}`
1435
+ });
1436
+ }
1437
+ }
1438
+ numberFormat =
1439
+ numberFormats[targetLocale] || {};
1440
+ format = numberFormat[key];
1441
+ if (isPlainObject(format))
1442
+ break;
1443
+ handleMissing(context, key, targetLocale, missingWarn, type);
1444
+ from = to;
1445
+ }
1446
+ // checking format and target locale
1447
+ if (!isPlainObject(format) || !isString(targetLocale)) {
1448
+ return unresolving ? NOT_REOSLVED : key;
1449
+ }
1450
+ let id = `${targetLocale}__${key}`;
1451
+ if (!isEmptyObject(overrides)) {
1452
+ id = `${id}__${JSON.stringify(overrides)}`;
1453
+ }
1454
+ let formatter = __numberFormatters.get(id);
1455
+ if (!formatter) {
1456
+ formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides));
1457
+ __numberFormatters.set(id, formatter);
1458
+ }
1459
+ return !part ? formatter.format(value) : formatter.formatToParts(value);
1460
+ }
1461
+ /** @internal */
1462
+ function parseNumberArgs(...args) {
1463
+ const [arg1, arg2, arg3, arg4] = args;
1464
+ let options = {};
1465
+ let overrides = {};
1466
+ if (!isNumber(arg1)) {
1467
+ throw createCoreError(14 /* INVALID_ARGUMENT */);
1468
+ }
1469
+ const value = arg1;
1470
+ if (isString(arg2)) {
1471
+ options.key = arg2;
1472
+ }
1473
+ else if (isPlainObject(arg2)) {
1474
+ options = arg2;
1475
+ }
1476
+ if (isString(arg3)) {
1477
+ options.locale = arg3;
1478
+ }
1479
+ else if (isPlainObject(arg3)) {
1480
+ overrides = arg3;
1481
+ }
1482
+ if (isPlainObject(arg4)) {
1483
+ overrides = arg4;
1484
+ }
1485
+ return [options.key || '', value, options, overrides];
1486
+ }
1487
+ /** @internal */
1488
+ function clearNumberFormat(ctx, locale, format) {
1489
+ const context = ctx;
1490
+ for (const key in format) {
1491
+ const id = `${locale}__${key}`;
1492
+ if (!context.__numberFormatters.has(id)) {
1493
+ continue;
1494
+ }
1495
+ context.__numberFormatters.delete(id);
1496
+ }
1497
+ }
1498
+
1499
+ /**
1500
+ * Vue I18n Version
1501
+ *
1502
+ * @remarks
1503
+ * Semver format. Same format as the package.json `version` field.
1504
+ *
1505
+ * @VueI18nGeneral
1506
+ */
1507
+ const VERSION = '9.1.7';
1508
+ /**
1509
+ * This is only called development env
1510
+ * istanbul-ignore-next
1511
+ */
1512
+ function initDev() {
1513
+ {
1514
+ {
1515
+ console.info(`You are running a development build of vue-i18n.\n` +
1516
+ `Make sure to use the production build (*.prod.js) when deploying for production.`);
1517
+ }
1518
+ }
1519
+ }
1520
+
1521
+ const warnMessages = {
1522
+ [6 /* FALLBACK_TO_ROOT */]: `Fall back to {type} '{key}' with root locale.`,
1523
+ [7 /* NOT_SUPPORTED_PRESERVE */]: `Not supported 'preserve'.`,
1524
+ [8 /* NOT_SUPPORTED_FORMATTER */]: `Not supported 'formatter'.`,
1525
+ [9 /* NOT_SUPPORTED_PRESERVE_DIRECTIVE */]: `Not supported 'preserveDirectiveContent'.`,
1526
+ [10 /* NOT_SUPPORTED_GET_CHOICE_INDEX */]: `Not supported 'getChoiceIndex'.`,
1527
+ [11 /* COMPONENT_NAME_LEGACY_COMPATIBLE */]: `Component name legacy compatible: '{name}' -> 'i18n'`,
1528
+ [12 /* NOT_FOUND_PARENT_SCOPE */]: `Not found parent scope. use the global scope.`
1529
+ };
1530
+ function getWarnMessage(code, ...args) {
1531
+ return format(warnMessages[code], ...args);
1532
+ }
1533
+
1534
+ function createI18nError(code, ...args) {
1535
+ return createCompileError(code, null, { messages: errorMessages, args } );
1536
+ }
1537
+ const errorMessages = {
1538
+ [14 /* UNEXPECTED_RETURN_TYPE */]: 'Unexpected return type in composer',
1539
+ [15 /* INVALID_ARGUMENT */]: 'Invalid argument',
1540
+ [16 /* MUST_BE_CALL_SETUP_TOP */]: 'Must be called at the top of a `setup` function',
1541
+ [17 /* NOT_INSLALLED */]: 'Need to install with `app.use` function',
1542
+ [22 /* UNEXPECTED_ERROR */]: 'Unexpected error',
1543
+ [18 /* NOT_AVAILABLE_IN_LEGACY_MODE */]: 'Not available in legacy mode',
1544
+ [19 /* REQUIRED_VALUE */]: `Required in value: {0}`,
1545
+ [20 /* INVALID_VALUE */]: `Invalid value`,
1546
+ [21 /* CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN */]: `Cannot setup vue-devtools plugin`
1547
+ };
1548
+
1549
+ const DEVTOOLS_META = '__INTLIFY_META__';
1550
+ const TransrateVNodeSymbol = makeSymbol('__transrateVNode');
1551
+ const DatetimePartsSymbol = makeSymbol('__datetimeParts');
1552
+ const NumberPartsSymbol = makeSymbol('__numberParts');
1553
+ const EnableEmitter = makeSymbol('__enableEmitter');
1554
+ const DisableEmitter = makeSymbol('__disableEmitter');
1555
+ const SetPluralRulesSymbol = makeSymbol('__setPluralRules');
1556
+ let composerID = 0;
1557
+ function defineCoreMissingHandler(missing) {
1558
+ return ((ctx, locale, key, type) => {
1559
+ return missing(locale, key, getCurrentInstance() || undefined, type);
1560
+ });
1561
+ }
1562
+ function getLocaleMessages(locale, options) {
1563
+ const { messages, __i18n } = options;
1564
+ // prettier-ignore
1565
+ const ret = isPlainObject(messages)
1566
+ ? messages
1567
+ : isArray(__i18n)
1568
+ ? {}
1569
+ : { [locale]: {} };
1570
+ // merge locale messages of i18n custom block
1571
+ if (isArray(__i18n)) {
1572
+ __i18n.forEach(({ locale, resource }) => {
1573
+ if (locale) {
1574
+ ret[locale] = ret[locale] || {};
1575
+ deepCopy(resource, ret[locale]);
1576
+ }
1577
+ else {
1578
+ deepCopy(resource, ret);
1579
+ }
1580
+ });
1581
+ }
1582
+ // handle messages for flat json
1583
+ if (options.flatJson) {
1584
+ for (const key in ret) {
1585
+ if (hasOwn(ret, key)) {
1586
+ handleFlatJson(ret[key]);
1587
+ }
1588
+ }
1589
+ }
1590
+ return ret;
1591
+ }
1592
+ const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val);
1593
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1594
+ function deepCopy(src, des) {
1595
+ // src and des should both be objects, and non of then can be a array
1596
+ if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) {
1597
+ throw createI18nError(20 /* INVALID_VALUE */);
1598
+ }
1599
+ for (const key in src) {
1600
+ if (hasOwn(src, key)) {
1601
+ if (isNotObjectOrIsArray(src[key]) || isNotObjectOrIsArray(des[key])) {
1602
+ // replace with src[key] when:
1603
+ // src[key] or des[key] is not a object, or
1604
+ // src[key] or des[key] is a array
1605
+ des[key] = src[key];
1606
+ }
1607
+ else {
1608
+ // src[key] and des[key] are both object, merge them
1609
+ deepCopy(src[key], des[key]);
1610
+ }
1611
+ }
1612
+ }
1613
+ }
1614
+ // for Intlify DevTools
1615
+ const getMetaInfo = /* #__PURE__*/ () => {
1616
+ const instance = getCurrentInstance();
1617
+ return instance && instance.type[DEVTOOLS_META] // eslint-disable-line @typescript-eslint/no-explicit-any
1618
+ ? { [DEVTOOLS_META]: instance.type[DEVTOOLS_META] } // eslint-disable-line @typescript-eslint/no-explicit-any
1619
+ : null;
1620
+ };
1621
+ /**
1622
+ * Create composer interface factory
1623
+ *
1624
+ * @internal
1625
+ */
1626
+ function createComposer(options = {}) {
1627
+ const { __root } = options;
1628
+ const _isGlobal = __root === undefined;
1629
+ let _inheritLocale = isBoolean(options.inheritLocale)
1630
+ ? options.inheritLocale
1631
+ : true;
1632
+ const _locale = ref(
1633
+ // prettier-ignore
1634
+ __root && _inheritLocale
1635
+ ? __root.locale.value
1636
+ : isString(options.locale)
1637
+ ? options.locale
1638
+ : 'en-US');
1639
+ const _fallbackLocale = ref(
1640
+ // prettier-ignore
1641
+ __root && _inheritLocale
1642
+ ? __root.fallbackLocale.value
1643
+ : isString(options.fallbackLocale) ||
1644
+ isArray(options.fallbackLocale) ||
1645
+ isPlainObject(options.fallbackLocale) ||
1646
+ options.fallbackLocale === false
1647
+ ? options.fallbackLocale
1648
+ : _locale.value);
1649
+ const _messages = ref(getLocaleMessages(_locale.value, options));
1650
+ const _datetimeFormats = ref(isPlainObject(options.datetimeFormats)
1651
+ ? options.datetimeFormats
1652
+ : { [_locale.value]: {} });
1653
+ const _numberFormats = ref(isPlainObject(options.numberFormats)
1654
+ ? options.numberFormats
1655
+ : { [_locale.value]: {} });
1656
+ // warning suppress options
1657
+ // prettier-ignore
1658
+ let _missingWarn = __root
1659
+ ? __root.missingWarn
1660
+ : isBoolean(options.missingWarn) || isRegExp(options.missingWarn)
1661
+ ? options.missingWarn
1662
+ : true;
1663
+ // prettier-ignore
1664
+ let _fallbackWarn = __root
1665
+ ? __root.fallbackWarn
1666
+ : isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn)
1667
+ ? options.fallbackWarn
1668
+ : true;
1669
+ // prettier-ignore
1670
+ let _fallbackRoot = __root
1671
+ ? __root.fallbackRoot
1672
+ : isBoolean(options.fallbackRoot)
1673
+ ? options.fallbackRoot
1674
+ : true;
1675
+ // configure fall back to root
1676
+ let _fallbackFormat = !!options.fallbackFormat;
1677
+ // runtime missing
1678
+ let _missing = isFunction(options.missing) ? options.missing : null;
1679
+ let _runtimeMissing = isFunction(options.missing)
1680
+ ? defineCoreMissingHandler(options.missing)
1681
+ : null;
1682
+ // postTranslation handler
1683
+ let _postTranslation = isFunction(options.postTranslation)
1684
+ ? options.postTranslation
1685
+ : null;
1686
+ let _warnHtmlMessage = isBoolean(options.warnHtmlMessage)
1687
+ ? options.warnHtmlMessage
1688
+ : true;
1689
+ let _escapeParameter = !!options.escapeParameter;
1690
+ // custom linked modifiers
1691
+ // prettier-ignore
1692
+ const _modifiers = __root
1693
+ ? __root.modifiers
1694
+ : isPlainObject(options.modifiers)
1695
+ ? options.modifiers
1696
+ : {};
1697
+ // pluralRules
1698
+ let _pluralRules = options.pluralRules || (__root && __root.pluralRules);
1699
+ // runtime context
1700
+ // eslint-disable-next-line prefer-const
1701
+ let _context;
1702
+ function getCoreContext() {
1703
+ return createCoreContext({
1704
+ version: VERSION,
1705
+ locale: _locale.value,
1706
+ fallbackLocale: _fallbackLocale.value,
1707
+ messages: _messages.value,
1708
+ datetimeFormats: _datetimeFormats.value,
1709
+ numberFormats: _numberFormats.value,
1710
+ modifiers: _modifiers,
1711
+ pluralRules: _pluralRules,
1712
+ missing: _runtimeMissing === null ? undefined : _runtimeMissing,
1713
+ missingWarn: _missingWarn,
1714
+ fallbackWarn: _fallbackWarn,
1715
+ fallbackFormat: _fallbackFormat,
1716
+ unresolving: true,
1717
+ postTranslation: _postTranslation === null ? undefined : _postTranslation,
1718
+ warnHtmlMessage: _warnHtmlMessage,
1719
+ escapeParameter: _escapeParameter,
1720
+ __datetimeFormatters: isPlainObject(_context)
1721
+ ? _context.__datetimeFormatters
1722
+ : undefined,
1723
+ __numberFormatters: isPlainObject(_context)
1724
+ ? _context.__numberFormatters
1725
+ : undefined,
1726
+ __v_emitter: isPlainObject(_context)
1727
+ ? _context.__v_emitter
1728
+ : undefined,
1729
+ __meta: { framework: 'vue' }
1730
+ });
1731
+ }
1732
+ _context = getCoreContext();
1733
+ updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
1734
+ // track reactivity
1735
+ function trackReactivityValues() {
1736
+ return [
1737
+ _locale.value,
1738
+ _fallbackLocale.value,
1739
+ _messages.value,
1740
+ _datetimeFormats.value,
1741
+ _numberFormats.value
1742
+ ];
1743
+ }
1744
+ // locale
1745
+ const locale = computed({
1746
+ get: () => _locale.value,
1747
+ set: val => {
1748
+ _locale.value = val;
1749
+ _context.locale = _locale.value;
1750
+ }
1751
+ });
1752
+ // fallbackLocale
1753
+ const fallbackLocale = computed({
1754
+ get: () => _fallbackLocale.value,
1755
+ set: val => {
1756
+ _fallbackLocale.value = val;
1757
+ _context.fallbackLocale = _fallbackLocale.value;
1758
+ updateFallbackLocale(_context, _locale.value, val);
1759
+ }
1760
+ });
1761
+ // messages
1762
+ const messages = computed(() => _messages.value);
1763
+ // datetimeFormats
1764
+ const datetimeFormats = computed(() => _datetimeFormats.value);
1765
+ // numberFormats
1766
+ const numberFormats = computed(() => _numberFormats.value);
1767
+ // getPostTranslationHandler
1768
+ function getPostTranslationHandler() {
1769
+ return isFunction(_postTranslation) ? _postTranslation : null;
1770
+ }
1771
+ // setPostTranslationHandler
1772
+ function setPostTranslationHandler(handler) {
1773
+ _postTranslation = handler;
1774
+ _context.postTranslation = handler;
1775
+ }
1776
+ // getMissingHandler
1777
+ function getMissingHandler() {
1778
+ return _missing;
1779
+ }
1780
+ // setMissingHandler
1781
+ function setMissingHandler(handler) {
1782
+ if (handler !== null) {
1783
+ _runtimeMissing = defineCoreMissingHandler(handler);
1784
+ }
1785
+ _missing = handler;
1786
+ _context.missing = _runtimeMissing;
1787
+ }
1788
+ function isResolvedTranslateMessage(type, arg // eslint-disable-line @typescript-eslint/no-explicit-any
1789
+ ) {
1790
+ return type !== 'translate' || !!arg.resolvedMessage === false;
1791
+ }
1792
+ function wrapWithDeps(fn, argumentParser, warnType, fallbackSuccess, fallbackFail, successCondition) {
1793
+ trackReactivityValues(); // track reactive dependency
1794
+ // NOTE: experimental !!
1795
+ let ret;
1796
+ {
1797
+ try {
1798
+ setAdditionalMeta(getMetaInfo());
1799
+ ret = fn(_context);
1800
+ }
1801
+ finally {
1802
+ setAdditionalMeta(null);
1803
+ }
1804
+ }
1805
+ if (isNumber(ret) && ret === NOT_REOSLVED) {
1806
+ const [key, arg2] = argumentParser();
1807
+ if (__root &&
1808
+ isString(key) &&
1809
+ isResolvedTranslateMessage(warnType, arg2)) {
1810
+ if (_fallbackRoot &&
1811
+ (isTranslateFallbackWarn(_fallbackWarn, key) ||
1812
+ isTranslateMissingWarn(_missingWarn, key))) {
1813
+ warn(getWarnMessage(6 /* FALLBACK_TO_ROOT */, {
1814
+ key,
1815
+ type: warnType
1816
+ }));
1817
+ }
1818
+ // for vue-devtools timeline event
1819
+ {
1820
+ const { __v_emitter: emitter } = _context;
1821
+ if (emitter && _fallbackRoot) {
1822
+ emitter.emit("fallback" /* FALBACK */, {
1823
+ type: warnType,
1824
+ key,
1825
+ to: 'global',
1826
+ groupId: `${warnType}:${key}`
1827
+ });
1828
+ }
1829
+ }
1830
+ }
1831
+ return __root && _fallbackRoot
1832
+ ? fallbackSuccess(__root)
1833
+ : fallbackFail(key);
1834
+ }
1835
+ else if (successCondition(ret)) {
1836
+ return ret;
1837
+ }
1838
+ else {
1839
+ /* istanbul ignore next */
1840
+ throw createI18nError(14 /* UNEXPECTED_RETURN_TYPE */);
1841
+ }
1842
+ }
1843
+ // t
1844
+ function t(...args) {
1845
+ return wrapWithDeps(context => translate(context, ...args), () => parseTranslateArgs(...args), 'translate', root => root.t(...args), key => key, val => isString(val));
1846
+ }
1847
+ // rt
1848
+ function rt(...args) {
1849
+ const [arg1, arg2, arg3] = args;
1850
+ if (arg3 && !isObject(arg3)) {
1851
+ throw createI18nError(15 /* INVALID_ARGUMENT */);
1852
+ }
1853
+ return t(...[arg1, arg2, assign({ resolvedMessage: true }, arg3 || {})]);
1854
+ }
1855
+ // d
1856
+ function d(...args) {
1857
+ return wrapWithDeps(context => datetime(context, ...args), () => parseDateTimeArgs(...args), 'datetime format', root => root.d(...args), () => MISSING_RESOLVE_VALUE, val => isString(val));
1858
+ }
1859
+ // n
1860
+ function n(...args) {
1861
+ return wrapWithDeps(context => number(context, ...args), () => parseNumberArgs(...args), 'number format', root => root.n(...args), () => MISSING_RESOLVE_VALUE, val => isString(val));
1862
+ }
1863
+ // for custom processor
1864
+ function normalize(values) {
1865
+ return values.map(val => isString(val) ? createVNode(Text, null, val, 0) : val);
1866
+ }
1867
+ const interpolate = (val) => val;
1868
+ const processor = {
1869
+ normalize,
1870
+ interpolate,
1871
+ type: 'vnode'
1872
+ };
1873
+ // transrateVNode, using for `i18n-t` component
1874
+ function transrateVNode(...args) {
1875
+ return wrapWithDeps(context => {
1876
+ let ret;
1877
+ const _context = context;
1878
+ try {
1879
+ _context.processor = processor;
1880
+ ret = translate(_context, ...args);
1881
+ }
1882
+ finally {
1883
+ _context.processor = null;
1884
+ }
1885
+ return ret;
1886
+ }, () => parseTranslateArgs(...args), 'translate',
1887
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1888
+ root => root[TransrateVNodeSymbol](...args), key => [createVNode(Text, null, key, 0)], val => isArray(val));
1889
+ }
1890
+ // numberParts, using for `i18n-n` component
1891
+ function numberParts(...args) {
1892
+ return wrapWithDeps(context => number(context, ...args), () => parseNumberArgs(...args), 'number format',
1893
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1894
+ root => root[NumberPartsSymbol](...args), () => [], val => isString(val) || isArray(val));
1895
+ }
1896
+ // datetimeParts, using for `i18n-d` component
1897
+ function datetimeParts(...args) {
1898
+ return wrapWithDeps(context => datetime(context, ...args), () => parseDateTimeArgs(...args), 'datetime format',
1899
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1900
+ root => root[DatetimePartsSymbol](...args), () => [], val => isString(val) || isArray(val));
1901
+ }
1902
+ function setPluralRules(rules) {
1903
+ _pluralRules = rules;
1904
+ _context.pluralRules = _pluralRules;
1905
+ }
1906
+ // te
1907
+ function te(key, locale) {
1908
+ const targetLocale = isString(locale) ? locale : _locale.value;
1909
+ const message = getLocaleMessage(targetLocale);
1910
+ return resolveValue(message, key) !== null;
1911
+ }
1912
+ function resolveMessages(key) {
1913
+ let messages = null;
1914
+ const locales = getLocaleChain(_context, _fallbackLocale.value, _locale.value);
1915
+ for (let i = 0; i < locales.length; i++) {
1916
+ const targetLocaleMessages = _messages.value[locales[i]] || {};
1917
+ const messageValue = resolveValue(targetLocaleMessages, key);
1918
+ if (messageValue != null) {
1919
+ messages = messageValue;
1920
+ break;
1921
+ }
1922
+ }
1923
+ return messages;
1924
+ }
1925
+ // tm
1926
+ function tm(key) {
1927
+ const messages = resolveMessages(key);
1928
+ // prettier-ignore
1929
+ return messages != null
1930
+ ? messages
1931
+ : __root
1932
+ ? __root.tm(key) || {}
1933
+ : {};
1934
+ }
1935
+ // getLocaleMessage
1936
+ function getLocaleMessage(locale) {
1937
+ return (_messages.value[locale] || {});
1938
+ }
1939
+ // setLocaleMessage
1940
+ function setLocaleMessage(locale, message) {
1941
+ _messages.value[locale] = message;
1942
+ _context.messages = _messages.value;
1943
+ }
1944
+ // mergeLocaleMessage
1945
+ function mergeLocaleMessage(locale, message) {
1946
+ _messages.value[locale] = _messages.value[locale] || {};
1947
+ deepCopy(message, _messages.value[locale]);
1948
+ _context.messages = _messages.value;
1949
+ }
1950
+ // getDateTimeFormat
1951
+ function getDateTimeFormat(locale) {
1952
+ return _datetimeFormats.value[locale] || {};
1953
+ }
1954
+ // setDateTimeFormat
1955
+ function setDateTimeFormat(locale, format) {
1956
+ _datetimeFormats.value[locale] = format;
1957
+ _context.datetimeFormats = _datetimeFormats.value;
1958
+ clearDateTimeFormat(_context, locale, format);
1959
+ }
1960
+ // mergeDateTimeFormat
1961
+ function mergeDateTimeFormat(locale, format) {
1962
+ _datetimeFormats.value[locale] = assign(_datetimeFormats.value[locale] || {}, format);
1963
+ _context.datetimeFormats = _datetimeFormats.value;
1964
+ clearDateTimeFormat(_context, locale, format);
1965
+ }
1966
+ // getNumberFormat
1967
+ function getNumberFormat(locale) {
1968
+ return _numberFormats.value[locale] || {};
1969
+ }
1970
+ // setNumberFormat
1971
+ function setNumberFormat(locale, format) {
1972
+ _numberFormats.value[locale] = format;
1973
+ _context.numberFormats = _numberFormats.value;
1974
+ clearNumberFormat(_context, locale, format);
1975
+ }
1976
+ // mergeNumberFormat
1977
+ function mergeNumberFormat(locale, format) {
1978
+ _numberFormats.value[locale] = assign(_numberFormats.value[locale] || {}, format);
1979
+ _context.numberFormats = _numberFormats.value;
1980
+ clearNumberFormat(_context, locale, format);
1981
+ }
1982
+ // for debug
1983
+ composerID++;
1984
+ // watch root locale & fallbackLocale
1985
+ if (__root) {
1986
+ watch(__root.locale, (val) => {
1987
+ if (_inheritLocale) {
1988
+ _locale.value = val;
1989
+ _context.locale = val;
1990
+ updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
1991
+ }
1992
+ });
1993
+ watch(__root.fallbackLocale, (val) => {
1994
+ if (_inheritLocale) {
1995
+ _fallbackLocale.value = val;
1996
+ _context.fallbackLocale = val;
1997
+ updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
1998
+ }
1999
+ });
2000
+ }
2001
+ // define composition API!
2002
+ const composer = {
2003
+ id: composerID,
2004
+ locale,
2005
+ fallbackLocale,
2006
+ get inheritLocale() {
2007
+ return _inheritLocale;
2008
+ },
2009
+ set inheritLocale(val) {
2010
+ _inheritLocale = val;
2011
+ if (val && __root) {
2012
+ _locale.value = __root.locale.value;
2013
+ _fallbackLocale.value = __root.fallbackLocale.value;
2014
+ updateFallbackLocale(_context, _locale.value, _fallbackLocale.value);
2015
+ }
2016
+ },
2017
+ get availableLocales() {
2018
+ return Object.keys(_messages.value).sort();
2019
+ },
2020
+ messages,
2021
+ datetimeFormats,
2022
+ numberFormats,
2023
+ get modifiers() {
2024
+ return _modifiers;
2025
+ },
2026
+ get pluralRules() {
2027
+ return _pluralRules || {};
2028
+ },
2029
+ get isGlobal() {
2030
+ return _isGlobal;
2031
+ },
2032
+ get missingWarn() {
2033
+ return _missingWarn;
2034
+ },
2035
+ set missingWarn(val) {
2036
+ _missingWarn = val;
2037
+ _context.missingWarn = _missingWarn;
2038
+ },
2039
+ get fallbackWarn() {
2040
+ return _fallbackWarn;
2041
+ },
2042
+ set fallbackWarn(val) {
2043
+ _fallbackWarn = val;
2044
+ _context.fallbackWarn = _fallbackWarn;
2045
+ },
2046
+ get fallbackRoot() {
2047
+ return _fallbackRoot;
2048
+ },
2049
+ set fallbackRoot(val) {
2050
+ _fallbackRoot = val;
2051
+ },
2052
+ get fallbackFormat() {
2053
+ return _fallbackFormat;
2054
+ },
2055
+ set fallbackFormat(val) {
2056
+ _fallbackFormat = val;
2057
+ _context.fallbackFormat = _fallbackFormat;
2058
+ },
2059
+ get warnHtmlMessage() {
2060
+ return _warnHtmlMessage;
2061
+ },
2062
+ set warnHtmlMessage(val) {
2063
+ _warnHtmlMessage = val;
2064
+ _context.warnHtmlMessage = val;
2065
+ },
2066
+ get escapeParameter() {
2067
+ return _escapeParameter;
2068
+ },
2069
+ set escapeParameter(val) {
2070
+ _escapeParameter = val;
2071
+ _context.escapeParameter = val;
2072
+ },
2073
+ t,
2074
+ rt,
2075
+ d,
2076
+ n,
2077
+ te,
2078
+ tm,
2079
+ getLocaleMessage,
2080
+ setLocaleMessage,
2081
+ mergeLocaleMessage,
2082
+ getDateTimeFormat,
2083
+ setDateTimeFormat,
2084
+ mergeDateTimeFormat,
2085
+ getNumberFormat,
2086
+ setNumberFormat,
2087
+ mergeNumberFormat,
2088
+ getPostTranslationHandler,
2089
+ setPostTranslationHandler,
2090
+ getMissingHandler,
2091
+ setMissingHandler,
2092
+ [TransrateVNodeSymbol]: transrateVNode,
2093
+ [NumberPartsSymbol]: numberParts,
2094
+ [DatetimePartsSymbol]: datetimeParts,
2095
+ [SetPluralRulesSymbol]: setPluralRules
2096
+ };
2097
+ // for vue-devtools timeline event
2098
+ {
2099
+ composer[EnableEmitter] = (emitter) => {
2100
+ _context.__v_emitter = emitter;
2101
+ };
2102
+ composer[DisableEmitter] = () => {
2103
+ _context.__v_emitter = undefined;
2104
+ };
2105
+ }
2106
+ return composer;
2107
+ }
2108
+
2109
+ /**
2110
+ * Convert to I18n Composer Options from VueI18n Options
2111
+ *
2112
+ * @internal
2113
+ */
2114
+ function convertComposerOptions(options) {
2115
+ const locale = isString(options.locale) ? options.locale : 'en-US';
2116
+ const fallbackLocale = isString(options.fallbackLocale) ||
2117
+ isArray(options.fallbackLocale) ||
2118
+ isPlainObject(options.fallbackLocale) ||
2119
+ options.fallbackLocale === false
2120
+ ? options.fallbackLocale
2121
+ : locale;
2122
+ const missing = isFunction(options.missing) ? options.missing : undefined;
2123
+ const missingWarn = isBoolean(options.silentTranslationWarn) ||
2124
+ isRegExp(options.silentTranslationWarn)
2125
+ ? !options.silentTranslationWarn
2126
+ : true;
2127
+ const fallbackWarn = isBoolean(options.silentFallbackWarn) ||
2128
+ isRegExp(options.silentFallbackWarn)
2129
+ ? !options.silentFallbackWarn
2130
+ : true;
2131
+ const fallbackRoot = isBoolean(options.fallbackRoot)
2132
+ ? options.fallbackRoot
2133
+ : true;
2134
+ const fallbackFormat = !!options.formatFallbackMessages;
2135
+ const modifiers = isPlainObject(options.modifiers) ? options.modifiers : {};
2136
+ const pluralizationRules = options.pluralizationRules;
2137
+ const postTranslation = isFunction(options.postTranslation)
2138
+ ? options.postTranslation
2139
+ : undefined;
2140
+ const warnHtmlMessage = isString(options.warnHtmlInMessage)
2141
+ ? options.warnHtmlInMessage !== 'off'
2142
+ : true;
2143
+ const escapeParameter = !!options.escapeParameterHtml;
2144
+ const inheritLocale = isBoolean(options.sync) ? options.sync : true;
2145
+ if (options.formatter) {
2146
+ warn(getWarnMessage(8 /* NOT_SUPPORTED_FORMATTER */));
2147
+ }
2148
+ if (options.preserveDirectiveContent) {
2149
+ warn(getWarnMessage(9 /* NOT_SUPPORTED_PRESERVE_DIRECTIVE */));
2150
+ }
2151
+ let messages = options.messages;
2152
+ if (isPlainObject(options.sharedMessages)) {
2153
+ const sharedMessages = options.sharedMessages;
2154
+ const locales = Object.keys(sharedMessages);
2155
+ messages = locales.reduce((messages, locale) => {
2156
+ const message = messages[locale] || (messages[locale] = {});
2157
+ assign(message, sharedMessages[locale]);
2158
+ return messages;
2159
+ }, (messages || {}));
2160
+ }
2161
+ const { __i18n, __root } = options;
2162
+ const datetimeFormats = options.datetimeFormats;
2163
+ const numberFormats = options.numberFormats;
2164
+ const flatJson = options.flatJson;
2165
+ return {
2166
+ locale,
2167
+ fallbackLocale,
2168
+ messages,
2169
+ flatJson,
2170
+ datetimeFormats,
2171
+ numberFormats,
2172
+ missing,
2173
+ missingWarn,
2174
+ fallbackWarn,
2175
+ fallbackRoot,
2176
+ fallbackFormat,
2177
+ modifiers,
2178
+ pluralRules: pluralizationRules,
2179
+ postTranslation,
2180
+ warnHtmlMessage,
2181
+ escapeParameter,
2182
+ inheritLocale,
2183
+ __i18n,
2184
+ __root
2185
+ };
2186
+ }
2187
+ /**
2188
+ * create VueI18n interface factory
2189
+ *
2190
+ * @internal
2191
+ */
2192
+ function createVueI18n(options = {}) {
2193
+ const composer = createComposer(convertComposerOptions(options));
2194
+ // defines VueI18n
2195
+ const vueI18n = {
2196
+ // id
2197
+ id: composer.id,
2198
+ // locale
2199
+ get locale() {
2200
+ return composer.locale.value;
2201
+ },
2202
+ set locale(val) {
2203
+ composer.locale.value = val;
2204
+ },
2205
+ // fallbackLocale
2206
+ get fallbackLocale() {
2207
+ return composer.fallbackLocale.value;
2208
+ },
2209
+ set fallbackLocale(val) {
2210
+ composer.fallbackLocale.value = val;
2211
+ },
2212
+ // messages
2213
+ get messages() {
2214
+ return composer.messages.value;
2215
+ },
2216
+ // datetimeFormats
2217
+ get datetimeFormats() {
2218
+ return composer.datetimeFormats.value;
2219
+ },
2220
+ // numberFormats
2221
+ get numberFormats() {
2222
+ return composer.numberFormats.value;
2223
+ },
2224
+ // availableLocales
2225
+ get availableLocales() {
2226
+ return composer.availableLocales;
2227
+ },
2228
+ // formatter
2229
+ get formatter() {
2230
+ warn(getWarnMessage(8 /* NOT_SUPPORTED_FORMATTER */));
2231
+ // dummy
2232
+ return {
2233
+ interpolate() {
2234
+ return [];
2235
+ }
2236
+ };
2237
+ },
2238
+ set formatter(val) {
2239
+ warn(getWarnMessage(8 /* NOT_SUPPORTED_FORMATTER */));
2240
+ },
2241
+ // missing
2242
+ get missing() {
2243
+ return composer.getMissingHandler();
2244
+ },
2245
+ set missing(handler) {
2246
+ composer.setMissingHandler(handler);
2247
+ },
2248
+ // silentTranslationWarn
2249
+ get silentTranslationWarn() {
2250
+ return isBoolean(composer.missingWarn)
2251
+ ? !composer.missingWarn
2252
+ : composer.missingWarn;
2253
+ },
2254
+ set silentTranslationWarn(val) {
2255
+ composer.missingWarn = isBoolean(val) ? !val : val;
2256
+ },
2257
+ // silentFallbackWarn
2258
+ get silentFallbackWarn() {
2259
+ return isBoolean(composer.fallbackWarn)
2260
+ ? !composer.fallbackWarn
2261
+ : composer.fallbackWarn;
2262
+ },
2263
+ set silentFallbackWarn(val) {
2264
+ composer.fallbackWarn = isBoolean(val) ? !val : val;
2265
+ },
2266
+ // modifiers
2267
+ get modifiers() {
2268
+ return composer.modifiers;
2269
+ },
2270
+ // formatFallbackMessages
2271
+ get formatFallbackMessages() {
2272
+ return composer.fallbackFormat;
2273
+ },
2274
+ set formatFallbackMessages(val) {
2275
+ composer.fallbackFormat = val;
2276
+ },
2277
+ // postTranslation
2278
+ get postTranslation() {
2279
+ return composer.getPostTranslationHandler();
2280
+ },
2281
+ set postTranslation(handler) {
2282
+ composer.setPostTranslationHandler(handler);
2283
+ },
2284
+ // sync
2285
+ get sync() {
2286
+ return composer.inheritLocale;
2287
+ },
2288
+ set sync(val) {
2289
+ composer.inheritLocale = val;
2290
+ },
2291
+ // warnInHtmlMessage
2292
+ get warnHtmlInMessage() {
2293
+ return composer.warnHtmlMessage ? 'warn' : 'off';
2294
+ },
2295
+ set warnHtmlInMessage(val) {
2296
+ composer.warnHtmlMessage = val !== 'off';
2297
+ },
2298
+ // escapeParameterHtml
2299
+ get escapeParameterHtml() {
2300
+ return composer.escapeParameter;
2301
+ },
2302
+ set escapeParameterHtml(val) {
2303
+ composer.escapeParameter = val;
2304
+ },
2305
+ // preserveDirectiveContent
2306
+ get preserveDirectiveContent() {
2307
+ warn(getWarnMessage(9 /* NOT_SUPPORTED_PRESERVE_DIRECTIVE */));
2308
+ return true;
2309
+ },
2310
+ set preserveDirectiveContent(val) {
2311
+ warn(getWarnMessage(9 /* NOT_SUPPORTED_PRESERVE_DIRECTIVE */));
2312
+ },
2313
+ // pluralizationRules
2314
+ get pluralizationRules() {
2315
+ return composer.pluralRules || {};
2316
+ },
2317
+ // for internal
2318
+ __composer: composer,
2319
+ // t
2320
+ t(...args) {
2321
+ const [arg1, arg2, arg3] = args;
2322
+ const options = {};
2323
+ let list = null;
2324
+ let named = null;
2325
+ if (!isString(arg1)) {
2326
+ throw createI18nError(15 /* INVALID_ARGUMENT */);
2327
+ }
2328
+ const key = arg1;
2329
+ if (isString(arg2)) {
2330
+ options.locale = arg2;
2331
+ }
2332
+ else if (isArray(arg2)) {
2333
+ list = arg2;
2334
+ }
2335
+ else if (isPlainObject(arg2)) {
2336
+ named = arg2;
2337
+ }
2338
+ if (isArray(arg3)) {
2339
+ list = arg3;
2340
+ }
2341
+ else if (isPlainObject(arg3)) {
2342
+ named = arg3;
2343
+ }
2344
+ return composer.t(key, list || named || {}, options);
2345
+ },
2346
+ rt(...args) {
2347
+ return composer.rt(...args);
2348
+ },
2349
+ // tc
2350
+ tc(...args) {
2351
+ const [arg1, arg2, arg3] = args;
2352
+ const options = { plural: 1 };
2353
+ let list = null;
2354
+ let named = null;
2355
+ if (!isString(arg1)) {
2356
+ throw createI18nError(15 /* INVALID_ARGUMENT */);
2357
+ }
2358
+ const key = arg1;
2359
+ if (isString(arg2)) {
2360
+ options.locale = arg2;
2361
+ }
2362
+ else if (isNumber(arg2)) {
2363
+ options.plural = arg2;
2364
+ }
2365
+ else if (isArray(arg2)) {
2366
+ list = arg2;
2367
+ }
2368
+ else if (isPlainObject(arg2)) {
2369
+ named = arg2;
2370
+ }
2371
+ if (isString(arg3)) {
2372
+ options.locale = arg3;
2373
+ }
2374
+ else if (isArray(arg3)) {
2375
+ list = arg3;
2376
+ }
2377
+ else if (isPlainObject(arg3)) {
2378
+ named = arg3;
2379
+ }
2380
+ return composer.t(key, list || named || {}, options);
2381
+ },
2382
+ // te
2383
+ te(key, locale) {
2384
+ return composer.te(key, locale);
2385
+ },
2386
+ // tm
2387
+ tm(key) {
2388
+ return composer.tm(key);
2389
+ },
2390
+ // getLocaleMessage
2391
+ getLocaleMessage(locale) {
2392
+ return composer.getLocaleMessage(locale);
2393
+ },
2394
+ // setLocaleMessage
2395
+ setLocaleMessage(locale, message) {
2396
+ composer.setLocaleMessage(locale, message);
2397
+ },
2398
+ // mergeLocaleMessage
2399
+ mergeLocaleMessage(locale, message) {
2400
+ composer.mergeLocaleMessage(locale, message);
2401
+ },
2402
+ // d
2403
+ d(...args) {
2404
+ return composer.d(...args);
2405
+ },
2406
+ // getDateTimeFormat
2407
+ getDateTimeFormat(locale) {
2408
+ return composer.getDateTimeFormat(locale);
2409
+ },
2410
+ // setDateTimeFormat
2411
+ setDateTimeFormat(locale, format) {
2412
+ composer.setDateTimeFormat(locale, format);
2413
+ },
2414
+ // mergeDateTimeFormat
2415
+ mergeDateTimeFormat(locale, format) {
2416
+ composer.mergeDateTimeFormat(locale, format);
2417
+ },
2418
+ // n
2419
+ n(...args) {
2420
+ return composer.n(...args);
2421
+ },
2422
+ // getNumberFormat
2423
+ getNumberFormat(locale) {
2424
+ return composer.getNumberFormat(locale);
2425
+ },
2426
+ // setNumberFormat
2427
+ setNumberFormat(locale, format) {
2428
+ composer.setNumberFormat(locale, format);
2429
+ },
2430
+ // mergeNumberFormat
2431
+ mergeNumberFormat(locale, format) {
2432
+ composer.mergeNumberFormat(locale, format);
2433
+ },
2434
+ // getChoiceIndex
2435
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2436
+ getChoiceIndex(choice, choicesLength) {
2437
+ warn(getWarnMessage(10 /* NOT_SUPPORTED_GET_CHOICE_INDEX */));
2438
+ return -1;
2439
+ },
2440
+ // for internal
2441
+ __onComponentInstanceCreated(target) {
2442
+ const { componentInstanceCreatedListener } = options;
2443
+ if (componentInstanceCreatedListener) {
2444
+ componentInstanceCreatedListener(target, vueI18n);
2445
+ }
2446
+ }
2447
+ };
2448
+ // for vue-devtools timeline event
2449
+ {
2450
+ vueI18n.__enableEmitter = (emitter) => {
2451
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2452
+ const __composer = composer;
2453
+ __composer[EnableEmitter] && __composer[EnableEmitter](emitter);
2454
+ };
2455
+ vueI18n.__disableEmitter = () => {
2456
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2457
+ const __composer = composer;
2458
+ __composer[DisableEmitter] && __composer[DisableEmitter]();
2459
+ };
2460
+ }
2461
+ return vueI18n;
2462
+ }
2463
+
2464
+ const baseFormatProps = {
2465
+ tag: {
2466
+ type: [String, Object]
2467
+ },
2468
+ locale: {
2469
+ type: String
2470
+ },
2471
+ scope: {
2472
+ type: String,
2473
+ validator: (val) => val === 'parent' || val === 'global',
2474
+ default: 'parent'
2475
+ },
2476
+ i18n: {
2477
+ type: Object
2478
+ }
2479
+ };
2480
+
2481
+ /**
2482
+ * Translation Component
2483
+ *
2484
+ * @remarks
2485
+ * See the following items for property about details
2486
+ *
2487
+ * @VueI18nSee [TranslationProps](component#translationprops)
2488
+ * @VueI18nSee [BaseFormatProps](component#baseformatprops)
2489
+ * @VueI18nSee [Component Interpolation](../guide/advanced/component)
2490
+ *
2491
+ * @example
2492
+ * ```html
2493
+ * <div id="app">
2494
+ * <!-- ... -->
2495
+ * <i18n path="term" tag="label" for="tos">
2496
+ * <a :href="url" target="_blank">{{ $t('tos') }}</a>
2497
+ * </i18n>
2498
+ * <!-- ... -->
2499
+ * </div>
2500
+ * ```
2501
+ * ```js
2502
+ * import { createApp } from 'vue'
2503
+ * import { createI18n } from 'vue-i18n'
2504
+ *
2505
+ * const messages = {
2506
+ * en: {
2507
+ * tos: 'Term of Service',
2508
+ * term: 'I accept xxx {0}.'
2509
+ * },
2510
+ * ja: {
2511
+ * tos: '利用規約',
2512
+ * term: '私は xxx の{0}に同意します。'
2513
+ * }
2514
+ * }
2515
+ *
2516
+ * const i18n = createI18n({
2517
+ * locale: 'en',
2518
+ * messages
2519
+ * })
2520
+ *
2521
+ * const app = createApp({
2522
+ * data: {
2523
+ * url: '/term'
2524
+ * }
2525
+ * }).use(i18n).mount('#app')
2526
+ * ```
2527
+ *
2528
+ * @VueI18nComponent
2529
+ */
2530
+ const Translation = {
2531
+ /* eslint-disable */
2532
+ name: 'i18n-t',
2533
+ props: assign({
2534
+ keypath: {
2535
+ type: String,
2536
+ required: true
2537
+ },
2538
+ plural: {
2539
+ type: [Number, String],
2540
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2541
+ validator: (val) => isNumber(val) || !isNaN(val)
2542
+ }
2543
+ }, baseFormatProps),
2544
+ /* eslint-enable */
2545
+ setup(props, context) {
2546
+ const { slots, attrs } = context;
2547
+ const i18n = props.i18n ||
2548
+ useI18n({ useScope: props.scope });
2549
+ const keys = Object.keys(slots).filter(key => key !== '_');
2550
+ return () => {
2551
+ const options = {};
2552
+ if (props.locale) {
2553
+ options.locale = props.locale;
2554
+ }
2555
+ if (props.plural !== undefined) {
2556
+ options.plural = isString(props.plural) ? +props.plural : props.plural;
2557
+ }
2558
+ const arg = getInterpolateArg(context, keys);
2559
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2560
+ const children = i18n[TransrateVNodeSymbol](props.keypath, arg, options);
2561
+ const assignedAttrs = assign({}, attrs);
2562
+ // prettier-ignore
2563
+ return isString(props.tag)
2564
+ ? h(props.tag, assignedAttrs, children)
2565
+ : isObject(props.tag)
2566
+ ? h(props.tag, assignedAttrs, children)
2567
+ : h(Fragment, assignedAttrs, children);
2568
+ };
2569
+ }
2570
+ };
2571
+ function getInterpolateArg({ slots }, keys) {
2572
+ if (keys.length === 1 && keys[0] === 'default') {
2573
+ // default slot only
2574
+ return slots.default ? slots.default() : [];
2575
+ }
2576
+ else {
2577
+ // named slots
2578
+ return keys.reduce((arg, key) => {
2579
+ const slot = slots[key];
2580
+ if (slot) {
2581
+ arg[key] = slot();
2582
+ }
2583
+ return arg;
2584
+ }, {});
2585
+ }
2586
+ }
2587
+
2588
+ function renderFormatter(props, context, slotKeys, partFormatter) {
2589
+ const { slots, attrs } = context;
2590
+ return () => {
2591
+ const options = { part: true };
2592
+ let overrides = {};
2593
+ if (props.locale) {
2594
+ options.locale = props.locale;
2595
+ }
2596
+ if (isString(props.format)) {
2597
+ options.key = props.format;
2598
+ }
2599
+ else if (isObject(props.format)) {
2600
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2601
+ if (isString(props.format.key)) {
2602
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2603
+ options.key = props.format.key;
2604
+ }
2605
+ // Filter out number format options only
2606
+ overrides = Object.keys(props.format).reduce((options, prop) => {
2607
+ return slotKeys.includes(prop)
2608
+ ? assign({}, options, { [prop]: props.format[prop] }) // eslint-disable-line @typescript-eslint/no-explicit-any
2609
+ : options;
2610
+ }, {});
2611
+ }
2612
+ const parts = partFormatter(...[props.value, options, overrides]);
2613
+ let children = [options.key];
2614
+ if (isArray(parts)) {
2615
+ children = parts.map((part, index) => {
2616
+ const slot = slots[part.type];
2617
+ return slot
2618
+ ? slot({ [part.type]: part.value, index, parts })
2619
+ : [part.value];
2620
+ });
2621
+ }
2622
+ else if (isString(parts)) {
2623
+ children = [parts];
2624
+ }
2625
+ const assignedAttrs = assign({}, attrs);
2626
+ // prettier-ignore
2627
+ return isString(props.tag)
2628
+ ? h(props.tag, assignedAttrs, children)
2629
+ : isObject(props.tag)
2630
+ ? h(props.tag, assignedAttrs, children)
2631
+ : h(Fragment, assignedAttrs, children);
2632
+ };
2633
+ }
2634
+
2635
+ const NUMBER_FORMAT_KEYS = [
2636
+ 'localeMatcher',
2637
+ 'style',
2638
+ 'unit',
2639
+ 'unitDisplay',
2640
+ 'currency',
2641
+ 'currencyDisplay',
2642
+ 'useGrouping',
2643
+ 'numberingSystem',
2644
+ 'minimumIntegerDigits',
2645
+ 'minimumFractionDigits',
2646
+ 'maximumFractionDigits',
2647
+ 'minimumSignificantDigits',
2648
+ 'maximumSignificantDigits',
2649
+ 'notation',
2650
+ 'formatMatcher'
2651
+ ];
2652
+ /**
2653
+ * Number Format Component
2654
+ *
2655
+ * @remarks
2656
+ * See the following items for property about details
2657
+ *
2658
+ * @VueI18nSee [FormattableProps](component#formattableprops)
2659
+ * @VueI18nSee [BaseFormatProps](component#baseformatprops)
2660
+ * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting)
2661
+ *
2662
+ * @VueI18nDanger
2663
+ * 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)
2664
+ *
2665
+ * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat)
2666
+ *
2667
+ * @VueI18nComponent
2668
+ */
2669
+ const NumberFormat = {
2670
+ /* eslint-disable */
2671
+ name: 'i18n-n',
2672
+ props: assign({
2673
+ value: {
2674
+ type: Number,
2675
+ required: true
2676
+ },
2677
+ format: {
2678
+ type: [String, Object]
2679
+ }
2680
+ }, baseFormatProps),
2681
+ /* eslint-enable */
2682
+ setup(props, context) {
2683
+ const i18n = props.i18n ||
2684
+ useI18n({ useScope: 'parent' });
2685
+ return renderFormatter(props, context, NUMBER_FORMAT_KEYS, (...args) =>
2686
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2687
+ i18n[NumberPartsSymbol](...args));
2688
+ }
2689
+ };
2690
+
2691
+ const DATETIME_FORMAT_KEYS = [
2692
+ 'dateStyle',
2693
+ 'timeStyle',
2694
+ 'fractionalSecondDigits',
2695
+ 'calendar',
2696
+ 'dayPeriod',
2697
+ 'numberingSystem',
2698
+ 'localeMatcher',
2699
+ 'timeZone',
2700
+ 'hour12',
2701
+ 'hourCycle',
2702
+ 'formatMatcher',
2703
+ 'weekday',
2704
+ 'era',
2705
+ 'year',
2706
+ 'month',
2707
+ 'day',
2708
+ 'hour',
2709
+ 'minute',
2710
+ 'second',
2711
+ 'timeZoneName'
2712
+ ];
2713
+ /**
2714
+ * Datetime Format Component
2715
+ *
2716
+ * @remarks
2717
+ * See the following items for property about details
2718
+ *
2719
+ * @VueI18nSee [FormattableProps](component#formattableprops)
2720
+ * @VueI18nSee [BaseFormatProps](component#baseformatprops)
2721
+ * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting)
2722
+ *
2723
+ * @VueI18nDanger
2724
+ * 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)
2725
+ *
2726
+ * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat)
2727
+ *
2728
+ * @VueI18nComponent
2729
+ */
2730
+ const DatetimeFormat = {
2731
+ /* eslint-disable */
2732
+ name: 'i18n-d',
2733
+ props: assign({
2734
+ value: {
2735
+ type: [Number, Date],
2736
+ required: true
2737
+ },
2738
+ format: {
2739
+ type: [String, Object]
2740
+ }
2741
+ }, baseFormatProps),
2742
+ /* eslint-enable */
2743
+ setup(props, context) {
2744
+ const i18n = props.i18n ||
2745
+ useI18n({ useScope: 'parent' });
2746
+ return renderFormatter(props, context, DATETIME_FORMAT_KEYS, (...args) =>
2747
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2748
+ i18n[DatetimePartsSymbol](...args));
2749
+ }
2750
+ };
2751
+
2752
+ function getComposer$2(i18n, instance) {
2753
+ const i18nInternal = i18n;
2754
+ if (i18n.mode === 'composition') {
2755
+ return (i18nInternal.__getInstance(instance) || i18n.global);
2756
+ }
2757
+ else {
2758
+ const vueI18n = i18nInternal.__getInstance(instance);
2759
+ return vueI18n != null
2760
+ ? vueI18n.__composer
2761
+ : i18n.global.__composer;
2762
+ }
2763
+ }
2764
+ function vTDirective(i18n) {
2765
+ const bind = (el, { instance, value, modifiers }) => {
2766
+ /* istanbul ignore if */
2767
+ if (!instance || !instance.$) {
2768
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
2769
+ }
2770
+ const composer = getComposer$2(i18n, instance.$);
2771
+ if (modifiers.preserve) {
2772
+ warn(getWarnMessage(7 /* NOT_SUPPORTED_PRESERVE */));
2773
+ }
2774
+ const parsedValue = parseValue(value);
2775
+ el.textContent = composer.t(...makeParams(parsedValue));
2776
+ };
2777
+ return {
2778
+ beforeMount: bind,
2779
+ beforeUpdate: bind
2780
+ };
2781
+ }
2782
+ function parseValue(value) {
2783
+ if (isString(value)) {
2784
+ return { path: value };
2785
+ }
2786
+ else if (isPlainObject(value)) {
2787
+ if (!('path' in value)) {
2788
+ throw createI18nError(19 /* REQUIRED_VALUE */, 'path');
2789
+ }
2790
+ return value;
2791
+ }
2792
+ else {
2793
+ throw createI18nError(20 /* INVALID_VALUE */);
2794
+ }
2795
+ }
2796
+ function makeParams(value) {
2797
+ const { path, locale, args, choice, plural } = value;
2798
+ const options = {};
2799
+ const named = args || {};
2800
+ if (isString(locale)) {
2801
+ options.locale = locale;
2802
+ }
2803
+ if (isNumber(choice)) {
2804
+ options.plural = choice;
2805
+ }
2806
+ if (isNumber(plural)) {
2807
+ options.plural = plural;
2808
+ }
2809
+ return [path, named, options];
2810
+ }
2811
+
2812
+ function apply(app, i18n, ...options) {
2813
+ const pluginOptions = isPlainObject(options[0])
2814
+ ? options[0]
2815
+ : {};
2816
+ const useI18nComponentName = !!pluginOptions.useI18nComponentName;
2817
+ const globalInstall = isBoolean(pluginOptions.globalInstall)
2818
+ ? pluginOptions.globalInstall
2819
+ : true;
2820
+ if (globalInstall && useI18nComponentName) {
2821
+ warn(getWarnMessage(11 /* COMPONENT_NAME_LEGACY_COMPATIBLE */, {
2822
+ name: Translation.name
2823
+ }));
2824
+ }
2825
+ if (globalInstall) {
2826
+ // install components
2827
+ app.component(!useI18nComponentName ? Translation.name : 'i18n', Translation);
2828
+ app.component(NumberFormat.name, NumberFormat);
2829
+ app.component(DatetimeFormat.name, DatetimeFormat);
2830
+ }
2831
+ // install directive
2832
+ app.directive('t', vTDirective(i18n));
2833
+ }
2834
+
2835
+ var global$1 = (typeof global !== "undefined" ? global :
2836
+ typeof self !== "undefined" ? self :
2837
+ typeof window !== "undefined" ? window : {});
2838
+
2839
+ function getDevtoolsGlobalHook() {
2840
+ return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
2841
+ }
2842
+ function getTarget() {
2843
+ // @ts-ignore
2844
+ return typeof navigator !== 'undefined'
2845
+ ? window
2846
+ : typeof global$1 !== 'undefined'
2847
+ ? global$1
2848
+ : {};
2849
+ }
2850
+
2851
+ const HOOK_SETUP = 'devtools-plugin:setup';
2852
+
2853
+ function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
2854
+ const hook = getDevtoolsGlobalHook();
2855
+ if (hook) {
2856
+ hook.emit(HOOK_SETUP, pluginDescriptor, setupFn);
2857
+ }
2858
+ else {
2859
+ const target = getTarget();
2860
+ const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
2861
+ list.push({
2862
+ pluginDescriptor,
2863
+ setupFn
2864
+ });
2865
+ }
2866
+ }
2867
+
2868
+ const VueDevToolsLabels = {
2869
+ ["vue-devtools-plugin-vue-i18n" /* PLUGIN */]: 'Vue I18n devtools',
2870
+ ["vue-i18n-resource-inspector" /* CUSTOM_INSPECTOR */]: 'I18n Resources',
2871
+ ["vue-i18n-timeline" /* TIMELINE */]: 'Vue I18n'
2872
+ };
2873
+ const VueDevToolsPlaceholders = {
2874
+ ["vue-i18n-resource-inspector" /* CUSTOM_INSPECTOR */]: 'Search for scopes ...'
2875
+ };
2876
+ const VueDevToolsTimelineColors = {
2877
+ ["vue-i18n-timeline" /* TIMELINE */]: 0xffcd19
2878
+ };
2879
+
2880
+ const VUE_I18N_COMPONENT_TYPES = 'vue-i18n: composer properties';
2881
+ let devtoolsApi;
2882
+ async function enableDevTools(app, i18n) {
2883
+ return new Promise((resolve, reject) => {
2884
+ try {
2885
+ setupDevtoolsPlugin({
2886
+ id: "vue-devtools-plugin-vue-i18n" /* PLUGIN */,
2887
+ label: VueDevToolsLabels["vue-devtools-plugin-vue-i18n" /* PLUGIN */],
2888
+ packageName: 'vue-i18n',
2889
+ homepage: 'https://vue-i18n.intlify.dev',
2890
+ logo: 'https://vue-i18n.intlify.dev/vue-i18n-devtools-logo.png',
2891
+ componentStateTypes: [VUE_I18N_COMPONENT_TYPES],
2892
+ app
2893
+ }, api => {
2894
+ devtoolsApi = api;
2895
+ api.on.visitComponentTree(({ componentInstance, treeNode }) => {
2896
+ updateComponentTreeTags(componentInstance, treeNode, i18n);
2897
+ });
2898
+ api.on.inspectComponent(({ componentInstance, instanceData }) => {
2899
+ if (componentInstance.vnode.el.__VUE_I18N__ && instanceData) {
2900
+ if (i18n.mode === 'legacy') {
2901
+ // ignore global scope on legacy mode
2902
+ if (componentInstance.vnode.el.__VUE_I18N__ !==
2903
+ i18n.global.__composer) {
2904
+ inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__);
2905
+ }
2906
+ }
2907
+ else {
2908
+ inspectComposer(instanceData, componentInstance.vnode.el.__VUE_I18N__);
2909
+ }
2910
+ }
2911
+ });
2912
+ api.addInspector({
2913
+ id: "vue-i18n-resource-inspector" /* CUSTOM_INSPECTOR */,
2914
+ label: VueDevToolsLabels["vue-i18n-resource-inspector" /* CUSTOM_INSPECTOR */],
2915
+ icon: 'language',
2916
+ treeFilterPlaceholder: VueDevToolsPlaceholders["vue-i18n-resource-inspector" /* CUSTOM_INSPECTOR */]
2917
+ });
2918
+ api.on.getInspectorTree(payload => {
2919
+ if (payload.app === app &&
2920
+ payload.inspectorId === "vue-i18n-resource-inspector" /* CUSTOM_INSPECTOR */) {
2921
+ registerScope(payload, i18n);
2922
+ }
2923
+ });
2924
+ api.on.getInspectorState(payload => {
2925
+ if (payload.app === app &&
2926
+ payload.inspectorId === "vue-i18n-resource-inspector" /* CUSTOM_INSPECTOR */) {
2927
+ inspectScope(payload, i18n);
2928
+ }
2929
+ });
2930
+ api.on.editInspectorState(payload => {
2931
+ if (payload.app === app &&
2932
+ payload.inspectorId === "vue-i18n-resource-inspector" /* CUSTOM_INSPECTOR */) {
2933
+ editScope(payload, i18n);
2934
+ }
2935
+ });
2936
+ api.addTimelineLayer({
2937
+ id: "vue-i18n-timeline" /* TIMELINE */,
2938
+ label: VueDevToolsLabels["vue-i18n-timeline" /* TIMELINE */],
2939
+ color: VueDevToolsTimelineColors["vue-i18n-timeline" /* TIMELINE */]
2940
+ });
2941
+ resolve(true);
2942
+ });
2943
+ }
2944
+ catch (e) {
2945
+ console.error(e);
2946
+ reject(false);
2947
+ }
2948
+ });
2949
+ }
2950
+ function updateComponentTreeTags(instance, // eslint-disable-line @typescript-eslint/no-explicit-any
2951
+ treeNode, i18n) {
2952
+ // prettier-ignore
2953
+ const global = i18n.mode === 'composition'
2954
+ ? i18n.global
2955
+ : i18n.global.__composer;
2956
+ if (instance && instance.vnode.el.__VUE_I18N__) {
2957
+ // add custom tags local scope only
2958
+ if (instance.vnode.el.__VUE_I18N__ !== global) {
2959
+ const label = instance.type.name || instance.type.displayName || instance.type.__file;
2960
+ const tag = {
2961
+ label: `i18n (${label} Scope)`,
2962
+ textColor: 0x000000,
2963
+ backgroundColor: 0xffcd19
2964
+ };
2965
+ treeNode.tags.push(tag);
2966
+ }
2967
+ }
2968
+ }
2969
+ function inspectComposer(instanceData, composer) {
2970
+ const type = VUE_I18N_COMPONENT_TYPES;
2971
+ instanceData.state.push({
2972
+ type,
2973
+ key: 'locale',
2974
+ editable: true,
2975
+ value: composer.locale.value
2976
+ });
2977
+ instanceData.state.push({
2978
+ type,
2979
+ key: 'availableLocales',
2980
+ editable: false,
2981
+ value: composer.availableLocales
2982
+ });
2983
+ instanceData.state.push({
2984
+ type,
2985
+ key: 'fallbackLocale',
2986
+ editable: true,
2987
+ value: composer.fallbackLocale.value
2988
+ });
2989
+ instanceData.state.push({
2990
+ type,
2991
+ key: 'inheritLocale',
2992
+ editable: true,
2993
+ value: composer.inheritLocale
2994
+ });
2995
+ instanceData.state.push({
2996
+ type,
2997
+ key: 'messages',
2998
+ editable: false,
2999
+ value: getLocaleMessageValue(composer.messages.value)
3000
+ });
3001
+ instanceData.state.push({
3002
+ type,
3003
+ key: 'datetimeFormats',
3004
+ editable: false,
3005
+ value: composer.datetimeFormats.value
3006
+ });
3007
+ instanceData.state.push({
3008
+ type,
3009
+ key: 'numberFormats',
3010
+ editable: false,
3011
+ value: composer.numberFormats.value
3012
+ });
3013
+ }
3014
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3015
+ function getLocaleMessageValue(messages) {
3016
+ const value = {};
3017
+ Object.keys(messages).forEach((key) => {
3018
+ const v = messages[key];
3019
+ if (isFunction(v) && 'source' in v) {
3020
+ value[key] = getMessageFunctionDetails(v);
3021
+ }
3022
+ else if (isObject(v)) {
3023
+ value[key] = getLocaleMessageValue(v);
3024
+ }
3025
+ else {
3026
+ value[key] = v;
3027
+ }
3028
+ });
3029
+ return value;
3030
+ }
3031
+ const ESC = {
3032
+ '<': '&lt;',
3033
+ '>': '&gt;',
3034
+ '"': '&quot;',
3035
+ '&': '&amp;'
3036
+ };
3037
+ function escape(s) {
3038
+ return s.replace(/[<>"&]/g, escapeChar);
3039
+ }
3040
+ function escapeChar(a) {
3041
+ return ESC[a] || a;
3042
+ }
3043
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3044
+ function getMessageFunctionDetails(func) {
3045
+ const argString = func.source ? `("${escape(func.source)}")` : `(?)`;
3046
+ return {
3047
+ _custom: {
3048
+ type: 'function',
3049
+ display: `<span>ƒ</span> ${argString}`
3050
+ }
3051
+ };
3052
+ }
3053
+ function registerScope(payload, i18n) {
3054
+ payload.rootNodes.push({
3055
+ id: 'global',
3056
+ label: 'Global Scope'
3057
+ });
3058
+ // prettier-ignore
3059
+ const global = i18n.mode === 'composition'
3060
+ ? i18n.global
3061
+ : i18n.global.__composer;
3062
+ for (const [keyInstance, instance] of i18n.__instances) {
3063
+ // prettier-ignore
3064
+ const composer = i18n.mode === 'composition'
3065
+ ? instance
3066
+ : instance.__composer;
3067
+ if (global === composer) {
3068
+ continue;
3069
+ }
3070
+ const label = keyInstance.type.name ||
3071
+ keyInstance.type.displayName ||
3072
+ keyInstance.type.__file;
3073
+ payload.rootNodes.push({
3074
+ id: composer.id.toString(),
3075
+ label: `${label} Scope`
3076
+ });
3077
+ }
3078
+ }
3079
+ function getComposer$1(nodeId, i18n) {
3080
+ if (nodeId === 'global') {
3081
+ return i18n.mode === 'composition'
3082
+ ? i18n.global
3083
+ : i18n.global.__composer;
3084
+ }
3085
+ else {
3086
+ const instance = Array.from(i18n.__instances.values()).find(item => item.id.toString() === nodeId);
3087
+ if (instance) {
3088
+ return i18n.mode === 'composition'
3089
+ ? instance
3090
+ : instance.__composer;
3091
+ }
3092
+ else {
3093
+ return null;
3094
+ }
3095
+ }
3096
+ }
3097
+ function inspectScope(payload, i18n) {
3098
+ const composer = getComposer$1(payload.nodeId, i18n);
3099
+ if (composer) {
3100
+ payload.state = makeScopeInspectState(composer);
3101
+ }
3102
+ }
3103
+ function makeScopeInspectState(composer) {
3104
+ const state = {};
3105
+ const localeType = 'Locale related info';
3106
+ const localeStates = [
3107
+ {
3108
+ type: localeType,
3109
+ key: 'locale',
3110
+ editable: true,
3111
+ value: composer.locale.value
3112
+ },
3113
+ {
3114
+ type: localeType,
3115
+ key: 'fallbackLocale',
3116
+ editable: true,
3117
+ value: composer.fallbackLocale.value
3118
+ },
3119
+ {
3120
+ type: localeType,
3121
+ key: 'availableLocales',
3122
+ editable: false,
3123
+ value: composer.availableLocales
3124
+ },
3125
+ {
3126
+ type: localeType,
3127
+ key: 'inheritLocale',
3128
+ editable: true,
3129
+ value: composer.inheritLocale
3130
+ }
3131
+ ];
3132
+ state[localeType] = localeStates;
3133
+ const localeMessagesType = 'Locale messages info';
3134
+ const localeMessagesStates = [
3135
+ {
3136
+ type: localeMessagesType,
3137
+ key: 'messages',
3138
+ editable: false,
3139
+ value: getLocaleMessageValue(composer.messages.value)
3140
+ }
3141
+ ];
3142
+ state[localeMessagesType] = localeMessagesStates;
3143
+ const datetimeFormatsType = 'Datetime formats info';
3144
+ const datetimeFormatsStates = [
3145
+ {
3146
+ type: datetimeFormatsType,
3147
+ key: 'datetimeFormats',
3148
+ editable: false,
3149
+ value: composer.datetimeFormats.value
3150
+ }
3151
+ ];
3152
+ state[datetimeFormatsType] = datetimeFormatsStates;
3153
+ const numberFormatsType = 'Datetime formats info';
3154
+ const numberFormatsStates = [
3155
+ {
3156
+ type: numberFormatsType,
3157
+ key: 'numberFormats',
3158
+ editable: false,
3159
+ value: composer.numberFormats.value
3160
+ }
3161
+ ];
3162
+ state[numberFormatsType] = numberFormatsStates;
3163
+ return state;
3164
+ }
3165
+ function addTimelineEvent(event, payload) {
3166
+ if (devtoolsApi) {
3167
+ let groupId;
3168
+ if (payload && 'groupId' in payload) {
3169
+ groupId = payload.groupId;
3170
+ delete payload.groupId;
3171
+ }
3172
+ devtoolsApi.addTimelineEvent({
3173
+ layerId: "vue-i18n-timeline" /* TIMELINE */,
3174
+ event: {
3175
+ title: event,
3176
+ groupId,
3177
+ time: Date.now(),
3178
+ meta: {},
3179
+ data: payload || {},
3180
+ logType: event === "compile-error" /* COMPILE_ERROR */
3181
+ ? 'error'
3182
+ : event === "fallback" /* FALBACK */ ||
3183
+ event === "missing" /* MISSING */
3184
+ ? 'warning'
3185
+ : 'default'
3186
+ }
3187
+ });
3188
+ }
3189
+ }
3190
+ function editScope(payload, i18n) {
3191
+ const composer = getComposer$1(payload.nodeId, i18n);
3192
+ if (composer) {
3193
+ const [field] = payload.path;
3194
+ if (field === 'locale' && isString(payload.state.value)) {
3195
+ composer.locale.value = payload.state.value;
3196
+ }
3197
+ else if (field === 'fallbackLocale' &&
3198
+ (isString(payload.state.value) ||
3199
+ isArray(payload.state.value) ||
3200
+ isObject(payload.state.value))) {
3201
+ composer.fallbackLocale.value = payload.state.value;
3202
+ }
3203
+ else if (field === 'inheritLocale' && isBoolean(payload.state.value)) {
3204
+ composer.inheritLocale = payload.state.value;
3205
+ }
3206
+ }
3207
+ }
3208
+
3209
+ // supports compatibility for legacy vue-i18n APIs
3210
+ function defineMixin(vuei18n, composer, i18n) {
3211
+ return {
3212
+ beforeCreate() {
3213
+ const instance = getCurrentInstance();
3214
+ /* istanbul ignore if */
3215
+ if (!instance) {
3216
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
3217
+ }
3218
+ const options = this.$options;
3219
+ if (options.i18n) {
3220
+ const optionsI18n = options.i18n;
3221
+ if (options.__i18n) {
3222
+ optionsI18n.__i18n = options.__i18n;
3223
+ }
3224
+ optionsI18n.__root = composer;
3225
+ if (this === this.$root) {
3226
+ this.$i18n = mergeToRoot(vuei18n, optionsI18n);
3227
+ }
3228
+ else {
3229
+ this.$i18n = createVueI18n(optionsI18n);
3230
+ }
3231
+ }
3232
+ else if (options.__i18n) {
3233
+ if (this === this.$root) {
3234
+ this.$i18n = mergeToRoot(vuei18n, options);
3235
+ }
3236
+ else {
3237
+ this.$i18n = createVueI18n({
3238
+ __i18n: options.__i18n,
3239
+ __root: composer
3240
+ });
3241
+ }
3242
+ }
3243
+ else {
3244
+ // set global
3245
+ this.$i18n = vuei18n;
3246
+ }
3247
+ vuei18n.__onComponentInstanceCreated(this.$i18n);
3248
+ i18n.__setInstance(instance, this.$i18n);
3249
+ // defines vue-i18n legacy APIs
3250
+ this.$t = (...args) => this.$i18n.t(...args);
3251
+ this.$rt = (...args) => this.$i18n.rt(...args);
3252
+ this.$tc = (...args) => this.$i18n.tc(...args);
3253
+ this.$te = (key, locale) => this.$i18n.te(key, locale);
3254
+ this.$d = (...args) => this.$i18n.d(...args);
3255
+ this.$n = (...args) => this.$i18n.n(...args);
3256
+ this.$tm = (key) => this.$i18n.tm(key);
3257
+ },
3258
+ mounted() {
3259
+ /* istanbul ignore if */
3260
+ {
3261
+ this.$el.__VUE_I18N__ = this.$i18n.__composer;
3262
+ const emitter = (this.__v_emitter = createEmitter());
3263
+ const _vueI18n = this.$i18n;
3264
+ _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter);
3265
+ emitter.on('*', addTimelineEvent);
3266
+ }
3267
+ },
3268
+ beforeUnmount() {
3269
+ const instance = getCurrentInstance();
3270
+ /* istanbul ignore if */
3271
+ if (!instance) {
3272
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
3273
+ }
3274
+ /* istanbul ignore if */
3275
+ {
3276
+ if (this.__v_emitter) {
3277
+ this.__v_emitter.off('*', addTimelineEvent);
3278
+ delete this.__v_emitter;
3279
+ }
3280
+ const _vueI18n = this.$i18n;
3281
+ _vueI18n.__disableEmitter && _vueI18n.__disableEmitter();
3282
+ delete this.$el.__VUE_I18N__;
3283
+ }
3284
+ delete this.$t;
3285
+ delete this.$rt;
3286
+ delete this.$tc;
3287
+ delete this.$te;
3288
+ delete this.$d;
3289
+ delete this.$n;
3290
+ delete this.$tm;
3291
+ i18n.__deleteInstance(instance);
3292
+ delete this.$i18n;
3293
+ }
3294
+ };
3295
+ }
3296
+ function mergeToRoot(root, options) {
3297
+ root.locale = options.locale || root.locale;
3298
+ root.fallbackLocale = options.fallbackLocale || root.fallbackLocale;
3299
+ root.missing = options.missing || root.missing;
3300
+ root.silentTranslationWarn =
3301
+ options.silentTranslationWarn || root.silentFallbackWarn;
3302
+ root.silentFallbackWarn =
3303
+ options.silentFallbackWarn || root.silentFallbackWarn;
3304
+ root.formatFallbackMessages =
3305
+ options.formatFallbackMessages || root.formatFallbackMessages;
3306
+ root.postTranslation = options.postTranslation || root.postTranslation;
3307
+ root.warnHtmlInMessage = options.warnHtmlInMessage || root.warnHtmlInMessage;
3308
+ root.escapeParameterHtml =
3309
+ options.escapeParameterHtml || root.escapeParameterHtml;
3310
+ root.sync = options.sync || root.sync;
3311
+ root.__composer[SetPluralRulesSymbol](options.pluralizationRules || root.pluralizationRules);
3312
+ const messages = getLocaleMessages(root.locale, {
3313
+ messages: options.messages,
3314
+ __i18n: options.__i18n
3315
+ });
3316
+ Object.keys(messages).forEach(locale => root.mergeLocaleMessage(locale, messages[locale]));
3317
+ if (options.datetimeFormats) {
3318
+ Object.keys(options.datetimeFormats).forEach(locale => root.mergeDateTimeFormat(locale, options.datetimeFormats[locale]));
3319
+ }
3320
+ if (options.numberFormats) {
3321
+ Object.keys(options.numberFormats).forEach(locale => root.mergeNumberFormat(locale, options.numberFormats[locale]));
3322
+ }
3323
+ return root;
3324
+ }
3325
+
3326
+ /**
3327
+ * Vue I18n factory
3328
+ *
3329
+ * @param options - An options, see the {@link I18nOptions}
3330
+ *
3331
+ * @returns {@link I18n} instance
3332
+ *
3333
+ * @remarks
3334
+ * If you use Legacy API mode, you need toto specify {@link VueI18nOptions} and `legacy: true` option.
3335
+ *
3336
+ * If you use composition API mode, you need to specify {@link ComposerOptions}.
3337
+ *
3338
+ * @VueI18nSee [Getting Started](../guide/)
3339
+ * @VueI18nSee [Composition API](../guide/advanced/composition)
3340
+ *
3341
+ * @example
3342
+ * case: for Legacy API
3343
+ * ```js
3344
+ * import { createApp } from 'vue'
3345
+ * import { createI18n } from 'vue-i18n'
3346
+ *
3347
+ * // call with I18n option
3348
+ * const i18n = createI18n({
3349
+ * locale: 'ja',
3350
+ * messages: {
3351
+ * en: { ... },
3352
+ * ja: { ... }
3353
+ * }
3354
+ * })
3355
+ *
3356
+ * const App = {
3357
+ * // ...
3358
+ * }
3359
+ *
3360
+ * const app = createApp(App)
3361
+ *
3362
+ * // install!
3363
+ * app.use(i18n)
3364
+ * app.mount('#app')
3365
+ * ```
3366
+ *
3367
+ * @example
3368
+ * case: for composition API
3369
+ * ```js
3370
+ * import { createApp } from 'vue'
3371
+ * import { createI18n, useI18n } from 'vue-i18n'
3372
+ *
3373
+ * // call with I18n option
3374
+ * const i18n = createI18n({
3375
+ * legacy: false, // you must specify 'legacy: false' option
3376
+ * locale: 'ja',
3377
+ * messages: {
3378
+ * en: { ... },
3379
+ * ja: { ... }
3380
+ * }
3381
+ * })
3382
+ *
3383
+ * const App = {
3384
+ * setup() {
3385
+ * // ...
3386
+ * const { t } = useI18n({ ... })
3387
+ * return { ... , t }
3388
+ * }
3389
+ * }
3390
+ *
3391
+ * const app = createApp(App)
3392
+ *
3393
+ * // install!
3394
+ * app.use(i18n)
3395
+ * app.mount('#app')
3396
+ * ```
3397
+ *
3398
+ * @VueI18nGeneral
3399
+ */
3400
+ function createI18n(options = {}) {
3401
+ // prettier-ignore
3402
+ const __legacyMode = isBoolean(options.legacy)
3403
+ ? options.legacy
3404
+ : true;
3405
+ const __globalInjection = !!options.globalInjection;
3406
+ const __instances = new Map();
3407
+ // prettier-ignore
3408
+ const __global = __legacyMode
3409
+ ? createVueI18n(options)
3410
+ : createComposer(options);
3411
+ const symbol = makeSymbol('vue-i18n' );
3412
+ const i18n = {
3413
+ // mode
3414
+ get mode() {
3415
+ // prettier-ignore
3416
+ return __legacyMode
3417
+ ? 'legacy'
3418
+ : 'composition'
3419
+ ;
3420
+ },
3421
+ // install plugin
3422
+ async install(app, ...options) {
3423
+ {
3424
+ app.__VUE_I18N__ = i18n;
3425
+ }
3426
+ // setup global provider
3427
+ app.__VUE_I18N_SYMBOL__ = symbol;
3428
+ app.provide(app.__VUE_I18N_SYMBOL__, i18n);
3429
+ // global method and properties injection for Composition API
3430
+ if (!__legacyMode && __globalInjection) {
3431
+ injectGlobalFields(app, i18n.global);
3432
+ }
3433
+ // install built-in components and directive
3434
+ {
3435
+ apply(app, i18n, ...options);
3436
+ }
3437
+ // setup mixin for Legacy API
3438
+ if (__legacyMode) {
3439
+ app.mixin(defineMixin(__global, __global.__composer, i18n));
3440
+ }
3441
+ // setup vue-devtools plugin
3442
+ {
3443
+ const ret = await enableDevTools(app, i18n);
3444
+ if (!ret) {
3445
+ throw createI18nError(21 /* CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN */);
3446
+ }
3447
+ const emitter = createEmitter();
3448
+ if (__legacyMode) {
3449
+ const _vueI18n = __global;
3450
+ _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter);
3451
+ }
3452
+ else {
3453
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3454
+ const _composer = __global;
3455
+ _composer[EnableEmitter] && _composer[EnableEmitter](emitter);
3456
+ }
3457
+ emitter.on('*', addTimelineEvent);
3458
+ }
3459
+ },
3460
+ // global accessor
3461
+ get global() {
3462
+ return __global;
3463
+ },
3464
+ // @internal
3465
+ __instances,
3466
+ // @internal
3467
+ __getInstance(component) {
3468
+ return __instances.get(component) || null;
3469
+ },
3470
+ // @internal
3471
+ __setInstance(component, instance) {
3472
+ __instances.set(component, instance);
3473
+ },
3474
+ // @internal
3475
+ __deleteInstance(component) {
3476
+ __instances.delete(component);
3477
+ }
3478
+ };
3479
+ return i18n;
3480
+ }
3481
+ /**
3482
+ * Use Composition API for Vue I18n
3483
+ *
3484
+ * @param options - An options, see {@link UseI18nOptions}
3485
+ *
3486
+ * @returns {@link Composer} instance
3487
+ *
3488
+ * @remarks
3489
+ * This function is mainly used by `setup`.
3490
+ *
3491
+ * If options are specified, Composer instance is created for each component and you can be localized on the component.
3492
+ *
3493
+ * If options are not specified, you can be localized using the global Composer.
3494
+ *
3495
+ * @example
3496
+ * case: Component resource base localization
3497
+ * ```html
3498
+ * <template>
3499
+ * <form>
3500
+ * <label>{{ t('language') }}</label>
3501
+ * <select v-model="locale">
3502
+ * <option value="en">en</option>
3503
+ * <option value="ja">ja</option>
3504
+ * </select>
3505
+ * </form>
3506
+ * <p>message: {{ t('hello') }}</p>
3507
+ * </template>
3508
+ *
3509
+ * <script>
3510
+ * import { useI18n } from 'vue-i18n'
3511
+ *
3512
+ * export default {
3513
+ * setup() {
3514
+ * const { t, locale } = useI18n({
3515
+ * locale: 'ja',
3516
+ * messages: {
3517
+ * en: { ... },
3518
+ * ja: { ... }
3519
+ * }
3520
+ * })
3521
+ * // Something to do ...
3522
+ *
3523
+ * return { ..., t, locale }
3524
+ * }
3525
+ * }
3526
+ * </script>
3527
+ * ```
3528
+ *
3529
+ * @VueI18nComposition
3530
+ */
3531
+ function useI18n(options = {}) {
3532
+ const instance = getCurrentInstance();
3533
+ if (instance == null) {
3534
+ throw createI18nError(16 /* MUST_BE_CALL_SETUP_TOP */);
3535
+ }
3536
+ if (!instance.appContext.app.__VUE_I18N_SYMBOL__) {
3537
+ throw createI18nError(17 /* NOT_INSLALLED */);
3538
+ }
3539
+ const i18n = inject(instance.appContext.app.__VUE_I18N_SYMBOL__);
3540
+ /* istanbul ignore if */
3541
+ if (!i18n) {
3542
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
3543
+ }
3544
+ // prettier-ignore
3545
+ const global = i18n.mode === 'composition'
3546
+ ? i18n.global
3547
+ : i18n.global.__composer;
3548
+ // prettier-ignore
3549
+ const scope = isEmptyObject(options)
3550
+ ? ('__i18n' in instance.type)
3551
+ ? 'local'
3552
+ : 'global'
3553
+ : !options.useScope
3554
+ ? 'local'
3555
+ : options.useScope;
3556
+ if (scope === 'global') {
3557
+ let messages = isObject(options.messages) ? options.messages : {};
3558
+ if ('__i18nGlobal' in instance.type) {
3559
+ messages = getLocaleMessages(global.locale.value, {
3560
+ messages,
3561
+ __i18n: instance.type.__i18nGlobal
3562
+ });
3563
+ }
3564
+ // merge locale messages
3565
+ const locales = Object.keys(messages);
3566
+ if (locales.length) {
3567
+ locales.forEach(locale => {
3568
+ global.mergeLocaleMessage(locale, messages[locale]);
3569
+ });
3570
+ }
3571
+ // merge datetime formats
3572
+ if (isObject(options.datetimeFormats)) {
3573
+ const locales = Object.keys(options.datetimeFormats);
3574
+ if (locales.length) {
3575
+ locales.forEach(locale => {
3576
+ global.mergeDateTimeFormat(locale, options.datetimeFormats[locale]);
3577
+ });
3578
+ }
3579
+ }
3580
+ // merge number formats
3581
+ if (isObject(options.numberFormats)) {
3582
+ const locales = Object.keys(options.numberFormats);
3583
+ if (locales.length) {
3584
+ locales.forEach(locale => {
3585
+ global.mergeNumberFormat(locale, options.numberFormats[locale]);
3586
+ });
3587
+ }
3588
+ }
3589
+ return global;
3590
+ }
3591
+ if (scope === 'parent') {
3592
+ let composer = getComposer(i18n, instance);
3593
+ if (composer == null) {
3594
+ {
3595
+ warn(getWarnMessage(12 /* NOT_FOUND_PARENT_SCOPE */));
3596
+ }
3597
+ composer = global;
3598
+ }
3599
+ return composer;
3600
+ }
3601
+ // scope 'local' case
3602
+ if (i18n.mode === 'legacy') {
3603
+ throw createI18nError(18 /* NOT_AVAILABLE_IN_LEGACY_MODE */);
3604
+ }
3605
+ const i18nInternal = i18n;
3606
+ let composer = i18nInternal.__getInstance(instance);
3607
+ if (composer == null) {
3608
+ const type = instance.type;
3609
+ const composerOptions = assign({}, options);
3610
+ if (type.__i18n) {
3611
+ composerOptions.__i18n = type.__i18n;
3612
+ }
3613
+ if (global) {
3614
+ composerOptions.__root = global;
3615
+ }
3616
+ composer = createComposer(composerOptions);
3617
+ setupLifeCycle(i18nInternal, instance, composer);
3618
+ i18nInternal.__setInstance(instance, composer);
3619
+ }
3620
+ return composer;
3621
+ }
3622
+ function getComposer(i18n, target) {
3623
+ let composer = null;
3624
+ const root = target.root;
3625
+ let current = target.parent;
3626
+ while (current != null) {
3627
+ const i18nInternal = i18n;
3628
+ if (i18n.mode === 'composition') {
3629
+ composer = i18nInternal.__getInstance(current);
3630
+ }
3631
+ else {
3632
+ const vueI18n = i18nInternal.__getInstance(current);
3633
+ if (vueI18n != null) {
3634
+ composer = vueI18n
3635
+ .__composer;
3636
+ }
3637
+ }
3638
+ if (composer != null) {
3639
+ break;
3640
+ }
3641
+ if (root === current) {
3642
+ break;
3643
+ }
3644
+ current = current.parent;
3645
+ }
3646
+ return composer;
3647
+ }
3648
+ function setupLifeCycle(i18n, target, composer) {
3649
+ let emitter = null;
3650
+ onMounted(() => {
3651
+ // inject composer instance to DOM for intlify-devtools
3652
+ if (target.vnode.el) {
3653
+ target.vnode.el.__VUE_I18N__ = composer;
3654
+ emitter = createEmitter();
3655
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3656
+ const _composer = composer;
3657
+ _composer[EnableEmitter] && _composer[EnableEmitter](emitter);
3658
+ emitter.on('*', addTimelineEvent);
3659
+ }
3660
+ }, target);
3661
+ onUnmounted(() => {
3662
+ // remove composer instance from DOM for intlify-devtools
3663
+ if (target.vnode.el &&
3664
+ target.vnode.el.__VUE_I18N__) {
3665
+ emitter && emitter.off('*', addTimelineEvent);
3666
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3667
+ const _composer = composer;
3668
+ _composer[DisableEmitter] && _composer[DisableEmitter]();
3669
+ delete target.vnode.el.__VUE_I18N__;
3670
+ }
3671
+ i18n.__deleteInstance(target);
3672
+ }, target);
3673
+ }
3674
+ const globalExportProps = [
3675
+ 'locale',
3676
+ 'fallbackLocale',
3677
+ 'availableLocales'
3678
+ ];
3679
+ const globalExportMethods = ['t', 'rt', 'd', 'n', 'tm'];
3680
+ function injectGlobalFields(app, composer) {
3681
+ const i18n = Object.create(null);
3682
+ globalExportProps.forEach(prop => {
3683
+ const desc = Object.getOwnPropertyDescriptor(composer, prop);
3684
+ if (!desc) {
3685
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
3686
+ }
3687
+ const wrap = isRef(desc.value) // check computed props
3688
+ ? {
3689
+ get() {
3690
+ return desc.value.value;
3691
+ },
3692
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3693
+ set(val) {
3694
+ desc.value.value = val;
3695
+ }
3696
+ }
3697
+ : {
3698
+ get() {
3699
+ return desc.get && desc.get();
3700
+ }
3701
+ };
3702
+ Object.defineProperty(i18n, prop, wrap);
3703
+ });
3704
+ app.config.globalProperties.$i18n = i18n;
3705
+ globalExportMethods.forEach(method => {
3706
+ const desc = Object.getOwnPropertyDescriptor(composer, method);
3707
+ if (!desc || !desc.value) {
3708
+ throw createI18nError(22 /* UNEXPECTED_ERROR */);
3709
+ }
3710
+ Object.defineProperty(app.config.globalProperties, `$${method}`, desc);
3711
+ });
3712
+ }
3713
+
3714
+ // NOTE: experimental !!
3715
+ {
3716
+ const target = getGlobalThis();
3717
+ target.__INTLIFY__ = true;
3718
+ setDevToolsHook(target.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__);
3719
+ }
3720
+ {
3721
+ initDev();
3722
+ }
3723
+
3724
+ export { DatetimeFormat, NumberFormat, Translation, VERSION, createI18n, useI18n, vTDirective };