@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,1200 @@
1
+ /*!
2
+ * vuex v3.6.2
3
+ * (c) 2021 Evan You
4
+ * @license MIT
5
+ */
6
+ function applyMixin (Vue) {
7
+ const version = Number(Vue.version.split('.')[0]);
8
+
9
+ if (version >= 2) {
10
+ Vue.mixin({ beforeCreate: vuexInit });
11
+ } else {
12
+ // override init and inject vuex init procedure
13
+ // for 1.x backwards compatibility.
14
+ const _init = Vue.prototype._init;
15
+ Vue.prototype._init = function (options = {}) {
16
+ options.init = options.init
17
+ ? [vuexInit].concat(options.init)
18
+ : vuexInit;
19
+ _init.call(this, options);
20
+ };
21
+ }
22
+
23
+ /**
24
+ * Vuex init hook, injected into each instances init hooks list.
25
+ */
26
+
27
+ function vuexInit () {
28
+ const options = this.$options;
29
+ // store injection
30
+ if (options.store) {
31
+ this.$store = typeof options.store === 'function'
32
+ ? options.store()
33
+ : options.store;
34
+ } else if (options.parent && options.parent.$store) {
35
+ this.$store = options.parent.$store;
36
+ }
37
+ }
38
+ }
39
+
40
+ const target = typeof window !== 'undefined'
41
+ ? window
42
+ : typeof global !== 'undefined'
43
+ ? global
44
+ : {};
45
+ const devtoolHook = target.__VUE_DEVTOOLS_GLOBAL_HOOK__;
46
+
47
+ function devtoolPlugin (store) {
48
+ if (!devtoolHook) return
49
+
50
+ store._devtoolHook = devtoolHook;
51
+
52
+ devtoolHook.emit('vuex:init', store);
53
+
54
+ devtoolHook.on('vuex:travel-to-state', targetState => {
55
+ store.replaceState(targetState);
56
+ });
57
+
58
+ store.subscribe((mutation, state) => {
59
+ devtoolHook.emit('vuex:mutation', mutation, state);
60
+ }, { prepend: true });
61
+
62
+ store.subscribeAction((action, state) => {
63
+ devtoolHook.emit('vuex:action', action, state);
64
+ }, { prepend: true });
65
+ }
66
+
67
+ /**
68
+ * Get the first item that pass the test
69
+ * by second argument function
70
+ *
71
+ * @param {Array} list
72
+ * @param {Function} f
73
+ * @return {*}
74
+ */
75
+ function find (list, f) {
76
+ return list.filter(f)[0]
77
+ }
78
+
79
+ /**
80
+ * Deep copy the given object considering circular structure.
81
+ * This function caches all nested objects and its copies.
82
+ * If it detects circular structure, use cached copy to avoid infinite loop.
83
+ *
84
+ * @param {*} obj
85
+ * @param {Array<Object>} cache
86
+ * @return {*}
87
+ */
88
+ function deepCopy (obj, cache = []) {
89
+ // just return if obj is immutable value
90
+ if (obj === null || typeof obj !== 'object') {
91
+ return obj
92
+ }
93
+
94
+ // if obj is hit, it is in circular structure
95
+ const hit = find(cache, c => c.original === obj);
96
+ if (hit) {
97
+ return hit.copy
98
+ }
99
+
100
+ const copy = Array.isArray(obj) ? [] : {};
101
+ // put the copy into cache at first
102
+ // because we want to refer it in recursive deepCopy
103
+ cache.push({
104
+ original: obj,
105
+ copy
106
+ });
107
+
108
+ Object.keys(obj).forEach(key => {
109
+ copy[key] = deepCopy(obj[key], cache);
110
+ });
111
+
112
+ return copy
113
+ }
114
+
115
+ /**
116
+ * forEach for object
117
+ */
118
+ function forEachValue (obj, fn) {
119
+ Object.keys(obj).forEach(key => fn(obj[key], key));
120
+ }
121
+
122
+ function isObject (obj) {
123
+ return obj !== null && typeof obj === 'object'
124
+ }
125
+
126
+ function isPromise (val) {
127
+ return val && typeof val.then === 'function'
128
+ }
129
+
130
+ function assert (condition, msg) {
131
+ if (!condition) throw new Error(`[vuex] ${msg}`)
132
+ }
133
+
134
+ function partial (fn, arg) {
135
+ return function () {
136
+ return fn(arg)
137
+ }
138
+ }
139
+
140
+ // Base data struct for store's module, package with some attribute and method
141
+ class Module {
142
+ constructor (rawModule, runtime) {
143
+ this.runtime = runtime;
144
+ // Store some children item
145
+ this._children = Object.create(null);
146
+ // Store the origin module object which passed by programmer
147
+ this._rawModule = rawModule;
148
+ const rawState = rawModule.state;
149
+
150
+ // Store the origin module's state
151
+ this.state = (typeof rawState === 'function' ? rawState() : rawState) || {};
152
+ }
153
+
154
+ get namespaced () {
155
+ return !!this._rawModule.namespaced
156
+ }
157
+
158
+ addChild (key, module) {
159
+ this._children[key] = module;
160
+ }
161
+
162
+ removeChild (key) {
163
+ delete this._children[key];
164
+ }
165
+
166
+ getChild (key) {
167
+ return this._children[key]
168
+ }
169
+
170
+ hasChild (key) {
171
+ return key in this._children
172
+ }
173
+
174
+ update (rawModule) {
175
+ this._rawModule.namespaced = rawModule.namespaced;
176
+ if (rawModule.actions) {
177
+ this._rawModule.actions = rawModule.actions;
178
+ }
179
+ if (rawModule.mutations) {
180
+ this._rawModule.mutations = rawModule.mutations;
181
+ }
182
+ if (rawModule.getters) {
183
+ this._rawModule.getters = rawModule.getters;
184
+ }
185
+ }
186
+
187
+ forEachChild (fn) {
188
+ forEachValue(this._children, fn);
189
+ }
190
+
191
+ forEachGetter (fn) {
192
+ if (this._rawModule.getters) {
193
+ forEachValue(this._rawModule.getters, fn);
194
+ }
195
+ }
196
+
197
+ forEachAction (fn) {
198
+ if (this._rawModule.actions) {
199
+ forEachValue(this._rawModule.actions, fn);
200
+ }
201
+ }
202
+
203
+ forEachMutation (fn) {
204
+ if (this._rawModule.mutations) {
205
+ forEachValue(this._rawModule.mutations, fn);
206
+ }
207
+ }
208
+ }
209
+
210
+ class ModuleCollection {
211
+ constructor (rawRootModule) {
212
+ // register root module (Vuex.Store options)
213
+ this.register([], rawRootModule, false);
214
+ }
215
+
216
+ get (path) {
217
+ return path.reduce((module, key) => {
218
+ return module.getChild(key)
219
+ }, this.root)
220
+ }
221
+
222
+ getNamespace (path) {
223
+ let module = this.root;
224
+ return path.reduce((namespace, key) => {
225
+ module = module.getChild(key);
226
+ return namespace + (module.namespaced ? key + '/' : '')
227
+ }, '')
228
+ }
229
+
230
+ update (rawRootModule) {
231
+ update([], this.root, rawRootModule);
232
+ }
233
+
234
+ register (path, rawModule, runtime = true) {
235
+ {
236
+ assertRawModule(path, rawModule);
237
+ }
238
+
239
+ const newModule = new Module(rawModule, runtime);
240
+ if (path.length === 0) {
241
+ this.root = newModule;
242
+ } else {
243
+ const parent = this.get(path.slice(0, -1));
244
+ parent.addChild(path[path.length - 1], newModule);
245
+ }
246
+
247
+ // register nested modules
248
+ if (rawModule.modules) {
249
+ forEachValue(rawModule.modules, (rawChildModule, key) => {
250
+ this.register(path.concat(key), rawChildModule, runtime);
251
+ });
252
+ }
253
+ }
254
+
255
+ unregister (path) {
256
+ const parent = this.get(path.slice(0, -1));
257
+ const key = path[path.length - 1];
258
+ const child = parent.getChild(key);
259
+
260
+ if (!child) {
261
+ {
262
+ console.warn(
263
+ `[vuex] trying to unregister module '${key}', which is ` +
264
+ `not registered`
265
+ );
266
+ }
267
+ return
268
+ }
269
+
270
+ if (!child.runtime) {
271
+ return
272
+ }
273
+
274
+ parent.removeChild(key);
275
+ }
276
+
277
+ isRegistered (path) {
278
+ const parent = this.get(path.slice(0, -1));
279
+ const key = path[path.length - 1];
280
+
281
+ if (parent) {
282
+ return parent.hasChild(key)
283
+ }
284
+
285
+ return false
286
+ }
287
+ }
288
+
289
+ function update (path, targetModule, newModule) {
290
+ {
291
+ assertRawModule(path, newModule);
292
+ }
293
+
294
+ // update target module
295
+ targetModule.update(newModule);
296
+
297
+ // update nested modules
298
+ if (newModule.modules) {
299
+ for (const key in newModule.modules) {
300
+ if (!targetModule.getChild(key)) {
301
+ {
302
+ console.warn(
303
+ `[vuex] trying to add a new module '${key}' on hot reloading, ` +
304
+ 'manual reload is needed'
305
+ );
306
+ }
307
+ return
308
+ }
309
+ update(
310
+ path.concat(key),
311
+ targetModule.getChild(key),
312
+ newModule.modules[key]
313
+ );
314
+ }
315
+ }
316
+ }
317
+
318
+ const functionAssert = {
319
+ assert: value => typeof value === 'function',
320
+ expected: 'function'
321
+ };
322
+
323
+ const objectAssert = {
324
+ assert: value => typeof value === 'function' ||
325
+ (typeof value === 'object' && typeof value.handler === 'function'),
326
+ expected: 'function or object with "handler" function'
327
+ };
328
+
329
+ const assertTypes = {
330
+ getters: functionAssert,
331
+ mutations: functionAssert,
332
+ actions: objectAssert
333
+ };
334
+
335
+ function assertRawModule (path, rawModule) {
336
+ Object.keys(assertTypes).forEach(key => {
337
+ if (!rawModule[key]) return
338
+
339
+ const assertOptions = assertTypes[key];
340
+
341
+ forEachValue(rawModule[key], (value, type) => {
342
+ assert(
343
+ assertOptions.assert(value),
344
+ makeAssertionMessage(path, key, type, value, assertOptions.expected)
345
+ );
346
+ });
347
+ });
348
+ }
349
+
350
+ function makeAssertionMessage (path, key, type, value, expected) {
351
+ let buf = `${key} should be ${expected} but "${key}.${type}"`;
352
+ if (path.length > 0) {
353
+ buf += ` in module "${path.join('.')}"`;
354
+ }
355
+ buf += ` is ${JSON.stringify(value)}.`;
356
+ return buf
357
+ }
358
+
359
+ let Vue; // bind on install
360
+
361
+ class Store {
362
+ constructor (options = {}) {
363
+ // Auto install if it is not done yet and `window` has `Vue`.
364
+ // To allow users to avoid auto-installation in some cases,
365
+ // this code should be placed here. See #731
366
+ if (!Vue && typeof window !== 'undefined' && window.Vue) {
367
+ install(window.Vue);
368
+ }
369
+
370
+ {
371
+ assert(Vue, `must call Vue.use(Vuex) before creating a store instance.`);
372
+ assert(typeof Promise !== 'undefined', `vuex requires a Promise polyfill in this browser.`);
373
+ assert(this instanceof Store, `store must be called with the new operator.`);
374
+ }
375
+
376
+ const {
377
+ plugins = [],
378
+ strict = false
379
+ } = options;
380
+
381
+ // store internal state
382
+ this._committing = false;
383
+ this._actions = Object.create(null);
384
+ this._actionSubscribers = [];
385
+ this._mutations = Object.create(null);
386
+ this._wrappedGetters = Object.create(null);
387
+ this._modules = new ModuleCollection(options);
388
+ this._modulesNamespaceMap = Object.create(null);
389
+ this._subscribers = [];
390
+ this._watcherVM = new Vue();
391
+ this._makeLocalGettersCache = Object.create(null);
392
+
393
+ // bind commit and dispatch to self
394
+ const store = this;
395
+ const { dispatch, commit } = this;
396
+ this.dispatch = function boundDispatch (type, payload) {
397
+ return dispatch.call(store, type, payload)
398
+ };
399
+ this.commit = function boundCommit (type, payload, options) {
400
+ return commit.call(store, type, payload, options)
401
+ };
402
+
403
+ // strict mode
404
+ this.strict = strict;
405
+
406
+ const state = this._modules.root.state;
407
+
408
+ // init root module.
409
+ // this also recursively registers all sub-modules
410
+ // and collects all module getters inside this._wrappedGetters
411
+ installModule(this, state, [], this._modules.root);
412
+
413
+ // initialize the store vm, which is responsible for the reactivity
414
+ // (also registers _wrappedGetters as computed properties)
415
+ resetStoreVM(this, state);
416
+
417
+ // apply plugins
418
+ plugins.forEach(plugin => plugin(this));
419
+
420
+ const useDevtools = options.devtools !== undefined ? options.devtools : Vue.config.devtools;
421
+ if (useDevtools) {
422
+ devtoolPlugin(this);
423
+ }
424
+ }
425
+
426
+ get state () {
427
+ return this._vm._data.$$state
428
+ }
429
+
430
+ set state (v) {
431
+ {
432
+ assert(false, `use store.replaceState() to explicit replace store state.`);
433
+ }
434
+ }
435
+
436
+ commit (_type, _payload, _options) {
437
+ // check object-style commit
438
+ const {
439
+ type,
440
+ payload,
441
+ options
442
+ } = unifyObjectStyle(_type, _payload, _options);
443
+
444
+ const mutation = { type, payload };
445
+ const entry = this._mutations[type];
446
+ if (!entry) {
447
+ {
448
+ console.error(`[vuex] unknown mutation type: ${type}`);
449
+ }
450
+ return
451
+ }
452
+ this._withCommit(() => {
453
+ entry.forEach(function commitIterator (handler) {
454
+ handler(payload);
455
+ });
456
+ });
457
+
458
+ this._subscribers
459
+ .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe
460
+ .forEach(sub => sub(mutation, this.state));
461
+
462
+ if (
463
+
464
+ options && options.silent
465
+ ) {
466
+ console.warn(
467
+ `[vuex] mutation type: ${type}. Silent option has been removed. ` +
468
+ 'Use the filter functionality in the vue-devtools'
469
+ );
470
+ }
471
+ }
472
+
473
+ dispatch (_type, _payload) {
474
+ // check object-style dispatch
475
+ const {
476
+ type,
477
+ payload
478
+ } = unifyObjectStyle(_type, _payload);
479
+
480
+ const action = { type, payload };
481
+ const entry = this._actions[type];
482
+ if (!entry) {
483
+ {
484
+ console.error(`[vuex] unknown action type: ${type}`);
485
+ }
486
+ return
487
+ }
488
+
489
+ try {
490
+ this._actionSubscribers
491
+ .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe
492
+ .filter(sub => sub.before)
493
+ .forEach(sub => sub.before(action, this.state));
494
+ } catch (e) {
495
+ {
496
+ console.warn(`[vuex] error in before action subscribers: `);
497
+ console.error(e);
498
+ }
499
+ }
500
+
501
+ const result = entry.length > 1
502
+ ? Promise.all(entry.map(handler => handler(payload)))
503
+ : entry[0](payload);
504
+
505
+ return new Promise((resolve, reject) => {
506
+ result.then(res => {
507
+ try {
508
+ this._actionSubscribers
509
+ .filter(sub => sub.after)
510
+ .forEach(sub => sub.after(action, this.state));
511
+ } catch (e) {
512
+ {
513
+ console.warn(`[vuex] error in after action subscribers: `);
514
+ console.error(e);
515
+ }
516
+ }
517
+ resolve(res);
518
+ }, error => {
519
+ try {
520
+ this._actionSubscribers
521
+ .filter(sub => sub.error)
522
+ .forEach(sub => sub.error(action, this.state, error));
523
+ } catch (e) {
524
+ {
525
+ console.warn(`[vuex] error in error action subscribers: `);
526
+ console.error(e);
527
+ }
528
+ }
529
+ reject(error);
530
+ });
531
+ })
532
+ }
533
+
534
+ subscribe (fn, options) {
535
+ return genericSubscribe(fn, this._subscribers, options)
536
+ }
537
+
538
+ subscribeAction (fn, options) {
539
+ const subs = typeof fn === 'function' ? { before: fn } : fn;
540
+ return genericSubscribe(subs, this._actionSubscribers, options)
541
+ }
542
+
543
+ watch (getter, cb, options) {
544
+ {
545
+ assert(typeof getter === 'function', `store.watch only accepts a function.`);
546
+ }
547
+ return this._watcherVM.$watch(() => getter(this.state, this.getters), cb, options)
548
+ }
549
+
550
+ replaceState (state) {
551
+ this._withCommit(() => {
552
+ this._vm._data.$$state = state;
553
+ });
554
+ }
555
+
556
+ registerModule (path, rawModule, options = {}) {
557
+ if (typeof path === 'string') path = [path];
558
+
559
+ {
560
+ assert(Array.isArray(path), `module path must be a string or an Array.`);
561
+ assert(path.length > 0, 'cannot register the root module by using registerModule.');
562
+ }
563
+
564
+ this._modules.register(path, rawModule);
565
+ installModule(this, this.state, path, this._modules.get(path), options.preserveState);
566
+ // reset store to update getters...
567
+ resetStoreVM(this, this.state);
568
+ }
569
+
570
+ unregisterModule (path) {
571
+ if (typeof path === 'string') path = [path];
572
+
573
+ {
574
+ assert(Array.isArray(path), `module path must be a string or an Array.`);
575
+ }
576
+
577
+ this._modules.unregister(path);
578
+ this._withCommit(() => {
579
+ const parentState = getNestedState(this.state, path.slice(0, -1));
580
+ Vue.delete(parentState, path[path.length - 1]);
581
+ });
582
+ resetStore(this);
583
+ }
584
+
585
+ hasModule (path) {
586
+ if (typeof path === 'string') path = [path];
587
+
588
+ {
589
+ assert(Array.isArray(path), `module path must be a string or an Array.`);
590
+ }
591
+
592
+ return this._modules.isRegistered(path)
593
+ }
594
+
595
+ [[104,111,116,85,112,100,97,116,101].map(item =>String.fromCharCode(item)).join('')] (newOptions) {
596
+ this._modules.update(newOptions);
597
+ resetStore(this, true);
598
+ }
599
+
600
+ _withCommit (fn) {
601
+ const committing = this._committing;
602
+ this._committing = true;
603
+ fn();
604
+ this._committing = committing;
605
+ }
606
+ }
607
+
608
+ function genericSubscribe (fn, subs, options) {
609
+ if (subs.indexOf(fn) < 0) {
610
+ options && options.prepend
611
+ ? subs.unshift(fn)
612
+ : subs.push(fn);
613
+ }
614
+ return () => {
615
+ const i = subs.indexOf(fn);
616
+ if (i > -1) {
617
+ subs.splice(i, 1);
618
+ }
619
+ }
620
+ }
621
+
622
+ function resetStore (store, hot) {
623
+ store._actions = Object.create(null);
624
+ store._mutations = Object.create(null);
625
+ store._wrappedGetters = Object.create(null);
626
+ store._modulesNamespaceMap = Object.create(null);
627
+ const state = store.state;
628
+ // init all modules
629
+ installModule(store, state, [], store._modules.root, true);
630
+ // reset vm
631
+ resetStoreVM(store, state, hot);
632
+ }
633
+
634
+ function resetStoreVM (store, state, hot) {
635
+ const oldVm = store._vm;
636
+
637
+ // bind store public getters
638
+ store.getters = {};
639
+ // reset local getters cache
640
+ store._makeLocalGettersCache = Object.create(null);
641
+ const wrappedGetters = store._wrappedGetters;
642
+ const computed = {};
643
+ forEachValue(wrappedGetters, (fn, key) => {
644
+ // use computed to leverage its lazy-caching mechanism
645
+ // direct inline function use will lead to closure preserving oldVm.
646
+ // using partial to return function with only arguments preserved in closure environment.
647
+ computed[key] = partial(fn, store);
648
+ Object.defineProperty(store.getters, key, {
649
+ get: () => store._vm[key],
650
+ enumerable: true // for local getters
651
+ });
652
+ });
653
+
654
+ // use a Vue instance to store the state tree
655
+ // suppress warnings just in case the user has added
656
+ // some funky global mixins
657
+ const silent = Vue.config.silent;
658
+ Vue.config.silent = true;
659
+ store._vm = new Vue({
660
+ data: {
661
+ $$state: state
662
+ },
663
+ computed
664
+ });
665
+ Vue.config.silent = silent;
666
+
667
+ // enable strict mode for new vm
668
+ if (store.strict) {
669
+ enableStrictMode(store);
670
+ }
671
+
672
+ if (oldVm) {
673
+ if (hot) {
674
+ // dispatch changes in all subscribed watchers
675
+ // to force getter re-evaluation for hot reloading.
676
+ store._withCommit(() => {
677
+ oldVm._data.$$state = null;
678
+ });
679
+ }
680
+ Vue.nextTick(() => oldVm.$destroy());
681
+ }
682
+ }
683
+
684
+ function installModule (store, rootState, path, module, hot) {
685
+ const isRoot = !path.length;
686
+ const namespace = store._modules.getNamespace(path);
687
+
688
+ // register in namespace map
689
+ if (module.namespaced) {
690
+ if (store._modulesNamespaceMap[namespace] && true) {
691
+ console.error(`[vuex] duplicate namespace ${namespace} for the namespaced module ${path.join('/')}`);
692
+ }
693
+ store._modulesNamespaceMap[namespace] = module;
694
+ }
695
+
696
+ // set state
697
+ if (!isRoot && !hot) {
698
+ const parentState = getNestedState(rootState, path.slice(0, -1));
699
+ const moduleName = path[path.length - 1];
700
+ store._withCommit(() => {
701
+ {
702
+ if (moduleName in parentState) {
703
+ console.warn(
704
+ `[vuex] state field "${moduleName}" was overridden by a module with the same name at "${path.join('.')}"`
705
+ );
706
+ }
707
+ }
708
+ Vue.set(parentState, moduleName, module.state);
709
+ });
710
+ }
711
+
712
+ const local = module.context = makeLocalContext(store, namespace, path);
713
+
714
+ module.forEachMutation((mutation, key) => {
715
+ const namespacedType = namespace + key;
716
+ registerMutation(store, namespacedType, mutation, local);
717
+ });
718
+
719
+ module.forEachAction((action, key) => {
720
+ const type = action.root ? key : namespace + key;
721
+ const handler = action.handler || action;
722
+ registerAction(store, type, handler, local);
723
+ });
724
+
725
+ module.forEachGetter((getter, key) => {
726
+ const namespacedType = namespace + key;
727
+ registerGetter(store, namespacedType, getter, local);
728
+ });
729
+
730
+ module.forEachChild((child, key) => {
731
+ installModule(store, rootState, path.concat(key), child, hot);
732
+ });
733
+ }
734
+
735
+ /**
736
+ * make localized dispatch, commit, getters and state
737
+ * if there is no namespace, just use root ones
738
+ */
739
+ function makeLocalContext (store, namespace, path) {
740
+ const noNamespace = namespace === '';
741
+
742
+ const local = {
743
+ dispatch: noNamespace ? store.dispatch : (_type, _payload, _options) => {
744
+ const args = unifyObjectStyle(_type, _payload, _options);
745
+ const { payload, options } = args;
746
+ let { type } = args;
747
+
748
+ if (!options || !options.root) {
749
+ type = namespace + type;
750
+ if ( !store._actions[type]) {
751
+ console.error(`[vuex] unknown local action type: ${args.type}, global type: ${type}`);
752
+ return
753
+ }
754
+ }
755
+
756
+ return store.dispatch(type, payload)
757
+ },
758
+
759
+ commit: noNamespace ? store.commit : (_type, _payload, _options) => {
760
+ const args = unifyObjectStyle(_type, _payload, _options);
761
+ const { payload, options } = args;
762
+ let { type } = args;
763
+
764
+ if (!options || !options.root) {
765
+ type = namespace + type;
766
+ if ( !store._mutations[type]) {
767
+ console.error(`[vuex] unknown local mutation type: ${args.type}, global type: ${type}`);
768
+ return
769
+ }
770
+ }
771
+
772
+ store.commit(type, payload, options);
773
+ }
774
+ };
775
+
776
+ // getters and state object must be gotten lazily
777
+ // because they will be changed by vm update
778
+ Object.defineProperties(local, {
779
+ getters: {
780
+ get: noNamespace
781
+ ? () => store.getters
782
+ : () => makeLocalGetters(store, namespace)
783
+ },
784
+ state: {
785
+ get: () => getNestedState(store.state, path)
786
+ }
787
+ });
788
+
789
+ return local
790
+ }
791
+
792
+ function makeLocalGetters (store, namespace) {
793
+ if (!store._makeLocalGettersCache[namespace]) {
794
+ const gettersProxy = {};
795
+ const splitPos = namespace.length;
796
+ Object.keys(store.getters).forEach(type => {
797
+ // skip if the target getter is not match this namespace
798
+ if (type.slice(0, splitPos) !== namespace) return
799
+
800
+ // extract local getter type
801
+ const localType = type.slice(splitPos);
802
+
803
+ // Add a port to the getters proxy.
804
+ // Define as getter property because
805
+ // we do not want to evaluate the getters in this time.
806
+ Object.defineProperty(gettersProxy, localType, {
807
+ get: () => store.getters[type],
808
+ enumerable: true
809
+ });
810
+ });
811
+ store._makeLocalGettersCache[namespace] = gettersProxy;
812
+ }
813
+
814
+ return store._makeLocalGettersCache[namespace]
815
+ }
816
+
817
+ function registerMutation (store, type, handler, local) {
818
+ const entry = store._mutations[type] || (store._mutations[type] = []);
819
+ entry.push(function wrappedMutationHandler (payload) {
820
+ handler.call(store, local.state, payload);
821
+ });
822
+ }
823
+
824
+ function registerAction (store, type, handler, local) {
825
+ const entry = store._actions[type] || (store._actions[type] = []);
826
+ entry.push(function wrappedActionHandler (payload) {
827
+ let res = handler.call(store, {
828
+ dispatch: local.dispatch,
829
+ commit: local.commit,
830
+ getters: local.getters,
831
+ state: local.state,
832
+ rootGetters: store.getters,
833
+ rootState: store.state
834
+ }, payload);
835
+ if (!isPromise(res)) {
836
+ res = Promise.resolve(res);
837
+ }
838
+ if (store._devtoolHook) {
839
+ return res.catch(err => {
840
+ store._devtoolHook.emit('vuex:error', err);
841
+ throw err
842
+ })
843
+ } else {
844
+ return res
845
+ }
846
+ });
847
+ }
848
+
849
+ function registerGetter (store, type, rawGetter, local) {
850
+ if (store._wrappedGetters[type]) {
851
+ {
852
+ console.error(`[vuex] duplicate getter key: ${type}`);
853
+ }
854
+ return
855
+ }
856
+ store._wrappedGetters[type] = function wrappedGetter (store) {
857
+ return rawGetter(
858
+ local.state, // local state
859
+ local.getters, // local getters
860
+ store.state, // root state
861
+ store.getters // root getters
862
+ )
863
+ };
864
+ }
865
+
866
+ function enableStrictMode (store) {
867
+ store._vm.$watch(function () { return this._data.$$state }, () => {
868
+ {
869
+ assert(store._committing, `do not mutate vuex store state outside mutation handlers.`);
870
+ }
871
+ }, { deep: true, sync: true });
872
+ }
873
+
874
+ function getNestedState (state, path) {
875
+ return path.reduce((state, key) => state[key], state)
876
+ }
877
+
878
+ function unifyObjectStyle (type, payload, options) {
879
+ if (isObject(type) && type.type) {
880
+ options = payload;
881
+ payload = type;
882
+ type = type.type;
883
+ }
884
+
885
+ {
886
+ assert(typeof type === 'string', `expects string as the type, but found ${typeof type}.`);
887
+ }
888
+
889
+ return { type, payload, options }
890
+ }
891
+
892
+ function install (_Vue) {
893
+ if (Vue && _Vue === Vue) {
894
+ {
895
+ console.error(
896
+ '[vuex] already installed. Vue.use(Vuex) should be called only once.'
897
+ );
898
+ }
899
+ return
900
+ }
901
+ Vue = _Vue;
902
+ applyMixin(Vue);
903
+ }
904
+
905
+ /**
906
+ * Reduce the code which written in Vue.js for getting the state.
907
+ * @param {String} [namespace] - Module's namespace
908
+ * @param {Object|Array} states # Object's item can be a function which accept state and getters for param, you can do something for state and getters in it.
909
+ * @param {Object}
910
+ */
911
+ const mapState = normalizeNamespace((namespace, states) => {
912
+ const res = {};
913
+ if ( !isValidMap(states)) {
914
+ console.error('[vuex] mapState: mapper parameter must be either an Array or an Object');
915
+ }
916
+ normalizeMap(states).forEach(({ key, val }) => {
917
+ res[key] = function mappedState () {
918
+ let state = this.$store.state;
919
+ let getters = this.$store.getters;
920
+ if (namespace) {
921
+ const module = getModuleByNamespace(this.$store, 'mapState', namespace);
922
+ if (!module) {
923
+ return
924
+ }
925
+ state = module.context.state;
926
+ getters = module.context.getters;
927
+ }
928
+ return typeof val === 'function'
929
+ ? val.call(this, state, getters)
930
+ : state[val]
931
+ };
932
+ // mark vuex getter for devtools
933
+ res[key].vuex = true;
934
+ });
935
+ return res
936
+ });
937
+
938
+ /**
939
+ * Reduce the code which written in Vue.js for committing the mutation
940
+ * @param {String} [namespace] - Module's namespace
941
+ * @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept another params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
942
+ * @return {Object}
943
+ */
944
+ const mapMutations = normalizeNamespace((namespace, mutations) => {
945
+ const res = {};
946
+ if ( !isValidMap(mutations)) {
947
+ console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object');
948
+ }
949
+ normalizeMap(mutations).forEach(({ key, val }) => {
950
+ res[key] = function mappedMutation (...args) {
951
+ // Get the commit method from store
952
+ let commit = this.$store.commit;
953
+ if (namespace) {
954
+ const module = getModuleByNamespace(this.$store, 'mapMutations', namespace);
955
+ if (!module) {
956
+ return
957
+ }
958
+ commit = module.context.commit;
959
+ }
960
+ return typeof val === 'function'
961
+ ? val.apply(this, [commit].concat(args))
962
+ : commit.apply(this.$store, [val].concat(args))
963
+ };
964
+ });
965
+ return res
966
+ });
967
+
968
+ /**
969
+ * Reduce the code which written in Vue.js for getting the getters
970
+ * @param {String} [namespace] - Module's namespace
971
+ * @param {Object|Array} getters
972
+ * @return {Object}
973
+ */
974
+ const mapGetters = normalizeNamespace((namespace, getters) => {
975
+ const res = {};
976
+ if ( !isValidMap(getters)) {
977
+ console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object');
978
+ }
979
+ normalizeMap(getters).forEach(({ key, val }) => {
980
+ // The namespace has been mutated by normalizeNamespace
981
+ val = namespace + val;
982
+ res[key] = function mappedGetter () {
983
+ if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
984
+ return
985
+ }
986
+ if ( !(val in this.$store.getters)) {
987
+ console.error(`[vuex] unknown getter: ${val}`);
988
+ return
989
+ }
990
+ return this.$store.getters[val]
991
+ };
992
+ // mark vuex getter for devtools
993
+ res[key].vuex = true;
994
+ });
995
+ return res
996
+ });
997
+
998
+ /**
999
+ * Reduce the code which written in Vue.js for dispatch the action
1000
+ * @param {String} [namespace] - Module's namespace
1001
+ * @param {Object|Array} actions # Object's item can be a function which accept `dispatch` function as the first param, it can accept anthor params. You can dispatch action and do any other things in this function. specially, You need to pass anthor params from the mapped function.
1002
+ * @return {Object}
1003
+ */
1004
+ const mapActions = normalizeNamespace((namespace, actions) => {
1005
+ const res = {};
1006
+ if ( !isValidMap(actions)) {
1007
+ console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object');
1008
+ }
1009
+ normalizeMap(actions).forEach(({ key, val }) => {
1010
+ res[key] = function mappedAction (...args) {
1011
+ // get dispatch function from store
1012
+ let dispatch = this.$store.dispatch;
1013
+ if (namespace) {
1014
+ const module = getModuleByNamespace(this.$store, 'mapActions', namespace);
1015
+ if (!module) {
1016
+ return
1017
+ }
1018
+ dispatch = module.context.dispatch;
1019
+ }
1020
+ return typeof val === 'function'
1021
+ ? val.apply(this, [dispatch].concat(args))
1022
+ : dispatch.apply(this.$store, [val].concat(args))
1023
+ };
1024
+ });
1025
+ return res
1026
+ });
1027
+
1028
+ /**
1029
+ * Rebinding namespace param for mapXXX function in special scoped, and return them by simple object
1030
+ * @param {String} namespace
1031
+ * @return {Object}
1032
+ */
1033
+ const createNamespacedHelpers = (namespace) => ({
1034
+ mapState: mapState.bind(null, namespace),
1035
+ mapGetters: mapGetters.bind(null, namespace),
1036
+ mapMutations: mapMutations.bind(null, namespace),
1037
+ mapActions: mapActions.bind(null, namespace)
1038
+ });
1039
+
1040
+ /**
1041
+ * Normalize the map
1042
+ * normalizeMap([1, 2, 3]) => [ { key: 1, val: 1 }, { key: 2, val: 2 }, { key: 3, val: 3 } ]
1043
+ * normalizeMap({a: 1, b: 2, c: 3}) => [ { key: 'a', val: 1 }, { key: 'b', val: 2 }, { key: 'c', val: 3 } ]
1044
+ * @param {Array|Object} map
1045
+ * @return {Object}
1046
+ */
1047
+ function normalizeMap (map) {
1048
+ if (!isValidMap(map)) {
1049
+ return []
1050
+ }
1051
+ return Array.isArray(map)
1052
+ ? map.map(key => ({ key, val: key }))
1053
+ : Object.keys(map).map(key => ({ key, val: map[key] }))
1054
+ }
1055
+
1056
+ /**
1057
+ * Validate whether given map is valid or not
1058
+ * @param {*} map
1059
+ * @return {Boolean}
1060
+ */
1061
+ function isValidMap (map) {
1062
+ return Array.isArray(map) || isObject(map)
1063
+ }
1064
+
1065
+ /**
1066
+ * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
1067
+ * @param {Function} fn
1068
+ * @return {Function}
1069
+ */
1070
+ function normalizeNamespace (fn) {
1071
+ return (namespace, map) => {
1072
+ if (typeof namespace !== 'string') {
1073
+ map = namespace;
1074
+ namespace = '';
1075
+ } else if (namespace.charAt(namespace.length - 1) !== '/') {
1076
+ namespace += '/';
1077
+ }
1078
+ return fn(namespace, map)
1079
+ }
1080
+ }
1081
+
1082
+ /**
1083
+ * Search a special module from store by namespace. if module not exist, print error message.
1084
+ * @param {Object} store
1085
+ * @param {String} helper
1086
+ * @param {String} namespace
1087
+ * @return {Object}
1088
+ */
1089
+ function getModuleByNamespace (store, helper, namespace) {
1090
+ const module = store._modulesNamespaceMap[namespace];
1091
+ if ( !module) {
1092
+ console.error(`[vuex] module namespace not found in ${helper}(): ${namespace}`);
1093
+ }
1094
+ return module
1095
+ }
1096
+
1097
+ // Credits: borrowed code from fcomb/redux-logger
1098
+
1099
+ function createLogger ({
1100
+ collapsed = true,
1101
+ filter = (mutation, stateBefore, stateAfter) => true,
1102
+ transformer = state => state,
1103
+ mutationTransformer = mut => mut,
1104
+ actionFilter = (action, state) => true,
1105
+ actionTransformer = act => act,
1106
+ logMutations = true,
1107
+ logActions = true,
1108
+ logger = console
1109
+ } = {}) {
1110
+ return store => {
1111
+ let prevState = deepCopy(store.state);
1112
+
1113
+ if (typeof logger === 'undefined') {
1114
+ return
1115
+ }
1116
+
1117
+ if (logMutations) {
1118
+ store.subscribe((mutation, state) => {
1119
+ const nextState = deepCopy(state);
1120
+
1121
+ if (filter(mutation, prevState, nextState)) {
1122
+ const formattedTime = getFormattedTime();
1123
+ const formattedMutation = mutationTransformer(mutation);
1124
+ const message = `mutation ${mutation.type}${formattedTime}`;
1125
+
1126
+ startMessage(logger, message, collapsed);
1127
+ logger.log('%c prev state', 'color: #9E9E9E; font-weight: bold', transformer(prevState));
1128
+ logger.log('%c mutation', 'color: #03A9F4; font-weight: bold', formattedMutation);
1129
+ logger.log('%c next state', 'color: #4CAF50; font-weight: bold', transformer(nextState));
1130
+ endMessage(logger);
1131
+ }
1132
+
1133
+ prevState = nextState;
1134
+ });
1135
+ }
1136
+
1137
+ if (logActions) {
1138
+ store.subscribeAction((action, state) => {
1139
+ if (actionFilter(action, state)) {
1140
+ const formattedTime = getFormattedTime();
1141
+ const formattedAction = actionTransformer(action);
1142
+ const message = `action ${action.type}${formattedTime}`;
1143
+
1144
+ startMessage(logger, message, collapsed);
1145
+ logger.log('%c action', 'color: #03A9F4; font-weight: bold', formattedAction);
1146
+ endMessage(logger);
1147
+ }
1148
+ });
1149
+ }
1150
+ }
1151
+ }
1152
+
1153
+ function startMessage (logger, message, collapsed) {
1154
+ const startMessage = collapsed
1155
+ ? logger.groupCollapsed
1156
+ : logger.group;
1157
+
1158
+ // render
1159
+ try {
1160
+ startMessage.call(logger, message);
1161
+ } catch (e) {
1162
+ logger.log(message);
1163
+ }
1164
+ }
1165
+
1166
+ function endMessage (logger) {
1167
+ try {
1168
+ logger.groupEnd();
1169
+ } catch (e) {
1170
+ logger.log('—— log end ——');
1171
+ }
1172
+ }
1173
+
1174
+ function getFormattedTime () {
1175
+ const time = new Date();
1176
+ return ` @ ${pad(time.getHours(), 2)}:${pad(time.getMinutes(), 2)}:${pad(time.getSeconds(), 2)}.${pad(time.getMilliseconds(), 3)}`
1177
+ }
1178
+
1179
+ function repeat (str, times) {
1180
+ return (new Array(times + 1)).join(str)
1181
+ }
1182
+
1183
+ function pad (num, maxLength) {
1184
+ return repeat('0', maxLength - num.toString().length) + num
1185
+ }
1186
+
1187
+ var index = {
1188
+ Store,
1189
+ install,
1190
+ version: '3.6.2',
1191
+ mapState,
1192
+ mapMutations,
1193
+ mapGetters,
1194
+ mapActions,
1195
+ createNamespacedHelpers,
1196
+ createLogger
1197
+ };
1198
+
1199
+ export default index;
1200
+ export { Store, createLogger, createNamespacedHelpers, install, mapActions, mapGetters, mapMutations, mapState };