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