@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,1473 @@
1
+ /*!
2
+ * vuex v4.0.2
3
+ * (c) 2021 Evan You
4
+ * @license MIT
5
+ */
6
+ import { inject, reactive, watch } from 'vue'
7
+ import { setupDevtoolsPlugin } from '@vue/devtools-api'
8
+
9
+ var storeKey = 'store'
10
+
11
+ function useStore (key) {
12
+ if (key === void 0) key = null
13
+
14
+ return inject(key !== null ? key : storeKey)
15
+ }
16
+
17
+ /**
18
+ * Get the first item that pass the test
19
+ * by second argument function
20
+ *
21
+ * @param {Array} list
22
+ * @param {Function} f
23
+ * @return {*}
24
+ */
25
+ function find (list, f) {
26
+ return list.filter(f)[0]
27
+ }
28
+
29
+ /**
30
+ * Deep copy the given object considering circular structure.
31
+ * This function caches all nested objects and its copies.
32
+ * If it detects circular structure, use cached copy to avoid infinite loop.
33
+ *
34
+ * @param {*} obj
35
+ * @param {Array<Object>} cache
36
+ * @return {*}
37
+ */
38
+ function deepCopy (obj, cache) {
39
+ if (cache === void 0) cache = []
40
+
41
+ // just return if obj is immutable value
42
+ if (obj === null || typeof obj !== 'object') {
43
+ return obj
44
+ }
45
+
46
+ // if obj is hit, it is in circular structure
47
+ var hit = find(cache, function (c) { return c.original === obj })
48
+ if (hit) {
49
+ return hit.copy
50
+ }
51
+
52
+ var copy = Array.isArray(obj) ? [] : {}
53
+ // put the copy into cache at first
54
+ // because we want to refer it in recursive deepCopy
55
+ cache.push({
56
+ original: obj,
57
+ copy: copy
58
+ })
59
+
60
+ Object.keys(obj).forEach(function (key) {
61
+ copy[key] = deepCopy(obj[key], cache)
62
+ })
63
+
64
+ return copy
65
+ }
66
+
67
+ /**
68
+ * forEach for object
69
+ */
70
+ function forEachValue (obj, fn) {
71
+ Object.keys(obj).forEach(function (key) { return fn(obj[key], key) })
72
+ }
73
+
74
+ function isObject (obj) {
75
+ return obj !== null && typeof obj === 'object'
76
+ }
77
+
78
+ function isPromise (val) {
79
+ return val && typeof val.then === 'function'
80
+ }
81
+
82
+ function assert (condition, msg) {
83
+ if (!condition) { throw new Error(('[vuex] ' + msg)) }
84
+ }
85
+
86
+ function partial (fn, arg) {
87
+ return function () {
88
+ return fn(arg)
89
+ }
90
+ }
91
+
92
+ function genericSubscribe (fn, subs, options) {
93
+ if (subs.indexOf(fn) < 0) {
94
+ options && options.prepend
95
+ ? subs.unshift(fn)
96
+ : subs.push(fn)
97
+ }
98
+ return function () {
99
+ var i = subs.indexOf(fn)
100
+ if (i > -1) {
101
+ subs.splice(i, 1)
102
+ }
103
+ }
104
+ }
105
+
106
+ function resetStore (store, hot) {
107
+ store._actions = Object.create(null)
108
+ store._mutations = Object.create(null)
109
+ store._wrappedGetters = Object.create(null)
110
+ store._modulesNamespaceMap = Object.create(null)
111
+ var state = store.state
112
+ // init all modules
113
+ installModule(store, state, [], store._modules.root, true)
114
+ // reset state
115
+ resetStoreState(store, state, hot)
116
+ }
117
+
118
+ function resetStoreState (store, state, hot) {
119
+ var oldState = store._state
120
+
121
+ // bind store public getters
122
+ store.getters = {}
123
+ // reset local getters cache
124
+ store._makeLocalGettersCache = Object.create(null)
125
+ var wrappedGetters = store._wrappedGetters
126
+ var computedObj = {}
127
+ forEachValue(wrappedGetters, function (fn, key) {
128
+ // use computed to leverage its lazy-caching mechanism
129
+ // direct inline function use will lead to closure preserving oldState.
130
+ // using partial to return function with only arguments preserved in closure environment.
131
+ computedObj[key] = partial(fn, store)
132
+ Object.defineProperty(store.getters, key, {
133
+ // TODO: use `computed` when it's possible. at the moment we can't due to
134
+ // https://github.com/vuejs/vuex/pull/1883
135
+ get: function () { return computedObj[key]() },
136
+ enumerable: true // for local getters
137
+ })
138
+ })
139
+
140
+ store._state = reactive({
141
+ data: state
142
+ })
143
+
144
+ // enable strict mode for new state
145
+ if (store.strict) {
146
+ enableStrictMode(store)
147
+ }
148
+
149
+ if (oldState) {
150
+ if (hot) {
151
+ // dispatch changes in all subscribed watchers
152
+ // to force getter re-evaluation for hot reloading.
153
+ store._withCommit(function () {
154
+ oldState.data = null
155
+ })
156
+ }
157
+ }
158
+ }
159
+
160
+ function installModule (store, rootState, path, module, hot) {
161
+ var isRoot = !path.length
162
+ var namespace = store._modules.getNamespace(path)
163
+
164
+ // register in namespace map
165
+ if (module.namespaced) {
166
+ if (store._modulesNamespaceMap[namespace] && (process.env.NODE_ENV !== 'production')) {
167
+ console.error(('[vuex] duplicate namespace ' + namespace + ' for the namespaced module ' + (path.join('/'))))
168
+ }
169
+ store._modulesNamespaceMap[namespace] = module
170
+ }
171
+
172
+ // set state
173
+ if (!isRoot && !hot) {
174
+ var parentState = getNestedState(rootState, path.slice(0, -1))
175
+ var moduleName = path[path.length - 1]
176
+ store._withCommit(function () {
177
+ if ((process.env.NODE_ENV !== 'production')) {
178
+ if (moduleName in parentState) {
179
+ console.warn(
180
+ ('[vuex] state field "' + moduleName + '" was overridden by a module with the same name at "' + (path.join('.')) + '"')
181
+ )
182
+ }
183
+ }
184
+ parentState[moduleName] = module.state
185
+ })
186
+ }
187
+
188
+ var local = module.context = makeLocalContext(store, namespace, path)
189
+
190
+ module.forEachMutation(function (mutation, key) {
191
+ var namespacedType = namespace + key
192
+ registerMutation(store, namespacedType, mutation, local)
193
+ })
194
+
195
+ module.forEachAction(function (action, key) {
196
+ var type = action.root ? key : namespace + key
197
+ var handler = action.handler || action
198
+ registerAction(store, type, handler, local)
199
+ })
200
+
201
+ module.forEachGetter(function (getter, key) {
202
+ var namespacedType = namespace + key
203
+ registerGetter(store, namespacedType, getter, local)
204
+ })
205
+
206
+ module.forEachChild(function (child, key) {
207
+ installModule(store, rootState, path.concat(key), child, hot)
208
+ })
209
+ }
210
+
211
+ /**
212
+ * make localized dispatch, commit, getters and state
213
+ * if there is no namespace, just use root ones
214
+ */
215
+ function makeLocalContext (store, namespace, path) {
216
+ var noNamespace = namespace === ''
217
+
218
+ var local = {
219
+ dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) {
220
+ var args = unifyObjectStyle(_type, _payload, _options)
221
+ var payload = args.payload
222
+ var options = args.options
223
+ var type = args.type
224
+
225
+ if (!options || !options.root) {
226
+ type = namespace + type
227
+ if ((process.env.NODE_ENV !== 'production') && !store._actions[type]) {
228
+ console.error(('[vuex] unknown local action type: ' + (args.type) + ', global type: ' + type))
229
+ return
230
+ }
231
+ }
232
+
233
+ return store.dispatch(type, payload)
234
+ },
235
+
236
+ commit: noNamespace ? store.commit : function (_type, _payload, _options) {
237
+ var args = unifyObjectStyle(_type, _payload, _options)
238
+ var payload = args.payload
239
+ var options = args.options
240
+ var type = args.type
241
+
242
+ if (!options || !options.root) {
243
+ type = namespace + type
244
+ if ((process.env.NODE_ENV !== 'production') && !store._mutations[type]) {
245
+ console.error(('[vuex] unknown local mutation type: ' + (args.type) + ', global type: ' + type))
246
+ return
247
+ }
248
+ }
249
+
250
+ store.commit(type, payload, options)
251
+ }
252
+ }
253
+
254
+ // getters and state object must be gotten lazily
255
+ // because they will be changed by state update
256
+ Object.defineProperties(local, {
257
+ getters: {
258
+ get: noNamespace
259
+ ? function () { return store.getters }
260
+ : function () { return makeLocalGetters(store, namespace) }
261
+ },
262
+ state: {
263
+ get: function () { return getNestedState(store.state, path) }
264
+ }
265
+ })
266
+
267
+ return local
268
+ }
269
+
270
+ function makeLocalGetters (store, namespace) {
271
+ if (!store._makeLocalGettersCache[namespace]) {
272
+ var gettersProxy = {}
273
+ var splitPos = namespace.length
274
+ Object.keys(store.getters).forEach(function (type) {
275
+ // skip if the target getter is not match this namespace
276
+ if (type.slice(0, splitPos) !== namespace) { return }
277
+
278
+ // extract local getter type
279
+ var localType = type.slice(splitPos)
280
+
281
+ // Add a port to the getters proxy.
282
+ // Define as getter property because
283
+ // we do not want to evaluate the getters in this time.
284
+ Object.defineProperty(gettersProxy, localType, {
285
+ get: function () { return store.getters[type] },
286
+ enumerable: true
287
+ })
288
+ })
289
+ store._makeLocalGettersCache[namespace] = gettersProxy
290
+ }
291
+
292
+ return store._makeLocalGettersCache[namespace]
293
+ }
294
+
295
+ function registerMutation (store, type, handler, local) {
296
+ var entry = store._mutations[type] || (store._mutations[type] = [])
297
+ entry.push(function wrappedMutationHandler (payload) {
298
+ handler.call(store, local.state, payload)
299
+ })
300
+ }
301
+
302
+ function registerAction (store, type, handler, local) {
303
+ var entry = store._actions[type] || (store._actions[type] = [])
304
+ entry.push(function wrappedActionHandler (payload) {
305
+ var res = handler.call(store, {
306
+ dispatch: local.dispatch,
307
+ commit: local.commit,
308
+ getters: local.getters,
309
+ state: local.state,
310
+ rootGetters: store.getters,
311
+ rootState: store.state
312
+ }, payload)
313
+ if (!isPromise(res)) {
314
+ res = Promise.resolve(res)
315
+ }
316
+ if (store._devtoolHook) {
317
+ return res.catch(function (err) {
318
+ store._devtoolHook.emit('vuex:error', err)
319
+ throw err
320
+ })
321
+ } else {
322
+ return res
323
+ }
324
+ })
325
+ }
326
+
327
+ function registerGetter (store, type, rawGetter, local) {
328
+ if (store._wrappedGetters[type]) {
329
+ if ((process.env.NODE_ENV !== 'production')) {
330
+ console.error(('[vuex] duplicate getter key: ' + type))
331
+ }
332
+ return
333
+ }
334
+ store._wrappedGetters[type] = function wrappedGetter (store) {
335
+ return rawGetter(
336
+ local.state, // local state
337
+ local.getters, // local getters
338
+ store.state, // root state
339
+ store.getters // root getters
340
+ )
341
+ }
342
+ }
343
+
344
+ function enableStrictMode (store) {
345
+ watch(function () { return store._state.data }, function () {
346
+ if ((process.env.NODE_ENV !== 'production')) {
347
+ assert(store._committing, 'do not mutate vuex store state outside mutation handlers.')
348
+ }
349
+ }, { deep: true, flush: 'sync' })
350
+ }
351
+
352
+ function getNestedState (state, path) {
353
+ return path.reduce(function (state, key) { return state[key] }, state)
354
+ }
355
+
356
+ function unifyObjectStyle (type, payload, options) {
357
+ if (isObject(type) && type.type) {
358
+ options = payload
359
+ payload = type
360
+ type = type.type
361
+ }
362
+
363
+ if ((process.env.NODE_ENV !== 'production')) {
364
+ assert(typeof type === 'string', ('expects string as the type, but found ' + (typeof type) + '.'))
365
+ }
366
+
367
+ return { type: type, payload: payload, options: options }
368
+ }
369
+
370
+ var LABEL_VUEX_BINDINGS = 'vuex bindings'
371
+ var MUTATIONS_LAYER_ID = 'vuex:mutations'
372
+ var ACTIONS_LAYER_ID = 'vuex:actions'
373
+ var INSPECTOR_ID = 'vuex'
374
+
375
+ var actionId = 0
376
+
377
+ function addDevtools (app, store) {
378
+ setupDevtoolsPlugin(
379
+ {
380
+ id: 'org.vuejs.vuex',
381
+ app: app,
382
+ label: 'Vuex',
383
+ homepage: 'https://next.vuex.vuejs.org/',
384
+ logo: 'https://vuejs.org/images/icons/favicon-96x96.png',
385
+ packageName: 'vuex',
386
+ componentStateTypes: [LABEL_VUEX_BINDINGS]
387
+ },
388
+ function (api) {
389
+ api.addTimelineLayer({
390
+ id: MUTATIONS_LAYER_ID,
391
+ label: 'Vuex Mutations',
392
+ color: COLOR_LIME_500
393
+ })
394
+
395
+ api.addTimelineLayer({
396
+ id: ACTIONS_LAYER_ID,
397
+ label: 'Vuex Actions',
398
+ color: COLOR_LIME_500
399
+ })
400
+
401
+ api.addInspector({
402
+ id: INSPECTOR_ID,
403
+ label: 'Vuex',
404
+ icon: 'storage',
405
+ treeFilterPlaceholder: 'Filter stores...'
406
+ })
407
+
408
+ api.on.getInspectorTree(function (payload) {
409
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
410
+ if (payload.filter) {
411
+ var nodes = []
412
+ flattenStoreForInspectorTree(nodes, store._modules.root, payload.filter, '')
413
+ payload.rootNodes = nodes
414
+ } else {
415
+ payload.rootNodes = [
416
+ formatStoreForInspectorTree(store._modules.root, '')
417
+ ]
418
+ }
419
+ }
420
+ })
421
+
422
+ api.on.getInspectorState(function (payload) {
423
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
424
+ var modulePath = payload.nodeId
425
+ makeLocalGetters(store, modulePath)
426
+ payload.state = formatStoreForInspectorState(
427
+ getStoreModule(store._modules, modulePath),
428
+ modulePath === 'root' ? store.getters : store._makeLocalGettersCache,
429
+ modulePath
430
+ )
431
+ }
432
+ })
433
+
434
+ api.on.editInspectorState(function (payload) {
435
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
436
+ var modulePath = payload.nodeId
437
+ var path = payload.path
438
+ if (modulePath !== 'root') {
439
+ path = modulePath.split('/').filter(Boolean).concat(path)
440
+ }
441
+ store._withCommit(function () {
442
+ payload.set(store._state.data, path, payload.state.value)
443
+ })
444
+ }
445
+ })
446
+
447
+ store.subscribe(function (mutation, state) {
448
+ var data = {}
449
+
450
+ if (mutation.payload) {
451
+ data.payload = mutation.payload
452
+ }
453
+
454
+ data.state = state
455
+
456
+ api.notifyComponentUpdate()
457
+ api.sendInspectorTree(INSPECTOR_ID)
458
+ api.sendInspectorState(INSPECTOR_ID)
459
+
460
+ api.addTimelineEvent({
461
+ layerId: MUTATIONS_LAYER_ID,
462
+ event: {
463
+ time: Date.now(),
464
+ title: mutation.type,
465
+ data: data
466
+ }
467
+ })
468
+ })
469
+
470
+ store.subscribeAction({
471
+ before: function (action, state) {
472
+ var data = {}
473
+ if (action.payload) {
474
+ data.payload = action.payload
475
+ }
476
+ action._id = actionId++
477
+ action._time = Date.now()
478
+ data.state = state
479
+
480
+ api.addTimelineEvent({
481
+ layerId: ACTIONS_LAYER_ID,
482
+ event: {
483
+ time: action._time,
484
+ title: action.type,
485
+ groupId: action._id,
486
+ subtitle: 'start',
487
+ data: data
488
+ }
489
+ })
490
+ },
491
+ after: function (action, state) {
492
+ var data = {}
493
+ var duration = Date.now() - action._time
494
+ data.duration = {
495
+ _custom: {
496
+ type: 'duration',
497
+ display: (duration + 'ms'),
498
+ tooltip: 'Action duration',
499
+ value: duration
500
+ }
501
+ }
502
+ if (action.payload) {
503
+ data.payload = action.payload
504
+ }
505
+ data.state = state
506
+
507
+ api.addTimelineEvent({
508
+ layerId: ACTIONS_LAYER_ID,
509
+ event: {
510
+ time: Date.now(),
511
+ title: action.type,
512
+ groupId: action._id,
513
+ subtitle: 'end',
514
+ data: data
515
+ }
516
+ })
517
+ }
518
+ })
519
+ }
520
+ )
521
+ }
522
+
523
+ // extracted from tailwind palette
524
+ var COLOR_LIME_500 = 0x84cc16
525
+ var COLOR_DARK = 0x666666
526
+ var COLOR_WHITE = 0xffffff
527
+
528
+ var TAG_NAMESPACED = {
529
+ label: 'namespaced',
530
+ textColor: COLOR_WHITE,
531
+ backgroundColor: COLOR_DARK
532
+ }
533
+
534
+ /**
535
+ * @param {string} path
536
+ */
537
+ function extractNameFromPath (path) {
538
+ return path && path !== 'root' ? path.split('/').slice(-2, -1)[0] : 'Root'
539
+ }
540
+
541
+ /**
542
+ * @param {*} module
543
+ * @return {import('@vue/devtools-api').CustomInspectorNode}
544
+ */
545
+ function formatStoreForInspectorTree (module, path) {
546
+ return {
547
+ id: path || 'root',
548
+ // all modules end with a `/`, we want the last segment only
549
+ // cart/ -> cart
550
+ // nested/cart/ -> cart
551
+ label: extractNameFromPath(path),
552
+ tags: module.namespaced ? [TAG_NAMESPACED] : [],
553
+ children: Object.keys(module._children).map(function (moduleName) {
554
+ return formatStoreForInspectorTree(
555
+ module._children[moduleName],
556
+ path + moduleName + '/'
557
+ )
558
+ }
559
+ )
560
+ }
561
+ }
562
+
563
+ /**
564
+ * @param {import('@vue/devtools-api').CustomInspectorNode[]} result
565
+ * @param {*} module
566
+ * @param {string} filter
567
+ * @param {string} path
568
+ */
569
+ function flattenStoreForInspectorTree (result, module, filter, path) {
570
+ if (path.includes(filter)) {
571
+ result.push({
572
+ id: path || 'root',
573
+ label: path.endsWith('/') ? path.slice(0, path.length - 1) : path || 'Root',
574
+ tags: module.namespaced ? [TAG_NAMESPACED] : []
575
+ })
576
+ }
577
+ Object.keys(module._children).forEach(function (moduleName) {
578
+ flattenStoreForInspectorTree(result, module._children[moduleName], filter, path + moduleName + '/')
579
+ })
580
+ }
581
+
582
+ /**
583
+ * @param {*} module
584
+ * @return {import('@vue/devtools-api').CustomInspectorState}
585
+ */
586
+ function formatStoreForInspectorState (module, getters, path) {
587
+ getters = path === 'root' ? getters : getters[path]
588
+ var gettersKeys = Object.keys(getters)
589
+ var storeState = {
590
+ state: Object.keys(module.state).map(function (key) {
591
+ return ({
592
+ key: key,
593
+ editable: true,
594
+ value: module.state[key]
595
+ })
596
+ })
597
+ }
598
+
599
+ if (gettersKeys.length) {
600
+ var tree = transformPathsToObjectTree(getters)
601
+ storeState.getters = Object.keys(tree).map(function (key) {
602
+ return ({
603
+ key: key.endsWith('/') ? extractNameFromPath(key) : key,
604
+ editable: false,
605
+ value: canThrow(function () { return tree[key] })
606
+ })
607
+ })
608
+ }
609
+
610
+ return storeState
611
+ }
612
+
613
+ function transformPathsToObjectTree (getters) {
614
+ var result = {}
615
+ Object.keys(getters).forEach(function (key) {
616
+ var path = key.split('/')
617
+ if (path.length > 1) {
618
+ var target = result
619
+ var leafKey = path.pop()
620
+ path.forEach(function (p) {
621
+ if (!target[p]) {
622
+ target[p] = {
623
+ _custom: {
624
+ value: {},
625
+ display: p,
626
+ tooltip: 'Module',
627
+ abstract: true
628
+ }
629
+ }
630
+ }
631
+ target = target[p]._custom.value
632
+ })
633
+ target[leafKey] = canThrow(function () { return getters[key] })
634
+ } else {
635
+ result[key] = canThrow(function () { return getters[key] })
636
+ }
637
+ })
638
+ return result
639
+ }
640
+
641
+ function getStoreModule (moduleMap, path) {
642
+ var names = path.split('/').filter(function (n) { return n })
643
+ return names.reduce(
644
+ function (module, moduleName, i) {
645
+ var child = module[moduleName]
646
+ if (!child) {
647
+ throw new Error(('Missing module "' + moduleName + '" for path "' + path + '".'))
648
+ }
649
+ return i === names.length - 1 ? child : child._children
650
+ },
651
+ path === 'root' ? moduleMap : moduleMap.root._children
652
+ )
653
+ }
654
+
655
+ function canThrow (cb) {
656
+ try {
657
+ return cb()
658
+ } catch (e) {
659
+ return e
660
+ }
661
+ }
662
+
663
+ // Base data struct for store's module, package with some attribute and method
664
+ var Module = function Module (rawModule, runtime) {
665
+ this.runtime = runtime
666
+ // Store some children item
667
+ this._children = Object.create(null)
668
+ // Store the origin module object which passed by programmer
669
+ this._rawModule = rawModule
670
+ var rawState = rawModule.state
671
+
672
+ // Store the origin module's state
673
+ this.state = (typeof rawState === 'function' ? rawState() : rawState) || {}
674
+ }
675
+
676
+ var prototypeAccessors$1 = { namespaced: { configurable: true } }
677
+
678
+ prototypeAccessors$1.namespaced.get = function () {
679
+ return !!this._rawModule.namespaced
680
+ }
681
+
682
+ Module.prototype.addChild = function addChild (key, module) {
683
+ this._children[key] = module
684
+ }
685
+
686
+ Module.prototype.removeChild = function removeChild (key) {
687
+ delete this._children[key]
688
+ }
689
+
690
+ Module.prototype.getChild = function getChild (key) {
691
+ return this._children[key]
692
+ }
693
+
694
+ Module.prototype.hasChild = function hasChild (key) {
695
+ return key in this._children
696
+ }
697
+
698
+ Module.prototype.update = function update (rawModule) {
699
+ this._rawModule.namespaced = rawModule.namespaced
700
+ if (rawModule.actions) {
701
+ this._rawModule.actions = rawModule.actions
702
+ }
703
+ if (rawModule.mutations) {
704
+ this._rawModule.mutations = rawModule.mutations
705
+ }
706
+ if (rawModule.getters) {
707
+ this._rawModule.getters = rawModule.getters
708
+ }
709
+ }
710
+
711
+ Module.prototype.forEachChild = function forEachChild (fn) {
712
+ forEachValue(this._children, fn)
713
+ }
714
+
715
+ Module.prototype.forEachGetter = function forEachGetter (fn) {
716
+ if (this._rawModule.getters) {
717
+ forEachValue(this._rawModule.getters, fn)
718
+ }
719
+ }
720
+
721
+ Module.prototype.forEachAction = function forEachAction (fn) {
722
+ if (this._rawModule.actions) {
723
+ forEachValue(this._rawModule.actions, fn)
724
+ }
725
+ }
726
+
727
+ Module.prototype.forEachMutation = function forEachMutation (fn) {
728
+ if (this._rawModule.mutations) {
729
+ forEachValue(this._rawModule.mutations, fn)
730
+ }
731
+ }
732
+
733
+ Object.defineProperties(Module.prototype, prototypeAccessors$1)
734
+
735
+ var ModuleCollection = function ModuleCollection (rawRootModule) {
736
+ // register root module (Vuex.Store options)
737
+ this.register([], rawRootModule, false)
738
+ }
739
+
740
+ ModuleCollection.prototype.get = function get (path) {
741
+ return path.reduce(function (module, key) {
742
+ return module.getChild(key)
743
+ }, this.root)
744
+ }
745
+
746
+ ModuleCollection.prototype.getNamespace = function getNamespace (path) {
747
+ var module = this.root
748
+ return path.reduce(function (namespace, key) {
749
+ module = module.getChild(key)
750
+ return namespace + (module.namespaced ? key + '/' : '')
751
+ }, '')
752
+ }
753
+
754
+ ModuleCollection.prototype.update = function update$1 (rawRootModule) {
755
+ update([], this.root, rawRootModule)
756
+ }
757
+
758
+ ModuleCollection.prototype.register = function register (path, rawModule, runtime) {
759
+ var this$1$1 = this
760
+ if (runtime === void 0) runtime = true
761
+
762
+ if ((process.env.NODE_ENV !== 'production')) {
763
+ assertRawModule(path, rawModule)
764
+ }
765
+
766
+ var newModule = new Module(rawModule, runtime)
767
+ if (path.length === 0) {
768
+ this.root = newModule
769
+ } else {
770
+ var parent = this.get(path.slice(0, -1))
771
+ parent.addChild(path[path.length - 1], newModule)
772
+ }
773
+
774
+ // register nested modules
775
+ if (rawModule.modules) {
776
+ forEachValue(rawModule.modules, function (rawChildModule, key) {
777
+ this$1$1.register(path.concat(key), rawChildModule, runtime)
778
+ })
779
+ }
780
+ }
781
+
782
+ ModuleCollection.prototype.unregister = function unregister (path) {
783
+ var parent = this.get(path.slice(0, -1))
784
+ var key = path[path.length - 1]
785
+ var child = parent.getChild(key)
786
+
787
+ if (!child) {
788
+ if ((process.env.NODE_ENV !== 'production')) {
789
+ console.warn(
790
+ "[vuex] trying to unregister module '" + key + "', which is " +
791
+ 'not registered'
792
+ )
793
+ }
794
+ return
795
+ }
796
+
797
+ if (!child.runtime) {
798
+ return
799
+ }
800
+
801
+ parent.removeChild(key)
802
+ }
803
+
804
+ ModuleCollection.prototype.isRegistered = function isRegistered (path) {
805
+ var parent = this.get(path.slice(0, -1))
806
+ var key = path[path.length - 1]
807
+
808
+ if (parent) {
809
+ return parent.hasChild(key)
810
+ }
811
+
812
+ return false
813
+ }
814
+
815
+ function update (path, targetModule, newModule) {
816
+ if ((process.env.NODE_ENV !== 'production')) {
817
+ assertRawModule(path, newModule)
818
+ }
819
+
820
+ // update target module
821
+ targetModule.update(newModule)
822
+
823
+ // update nested modules
824
+ if (newModule.modules) {
825
+ for (var key in newModule.modules) {
826
+ if (!targetModule.getChild(key)) {
827
+ if ((process.env.NODE_ENV !== 'production')) {
828
+ console.warn(
829
+ "[vuex] trying to add a new module '" + key + "' on hot reloading, " +
830
+ 'manual reload is needed'
831
+ )
832
+ }
833
+ return
834
+ }
835
+ update(
836
+ path.concat(key),
837
+ targetModule.getChild(key),
838
+ newModule.modules[key]
839
+ )
840
+ }
841
+ }
842
+ }
843
+
844
+ var functionAssert = {
845
+ assert: function (value) { return typeof value === 'function' },
846
+ expected: 'function'
847
+ }
848
+
849
+ var objectAssert = {
850
+ assert: function (value) {
851
+ return typeof value === 'function' ||
852
+ (typeof value === 'object' && typeof value.handler === 'function')
853
+ },
854
+ expected: 'function or object with "handler" function'
855
+ }
856
+
857
+ var assertTypes = {
858
+ getters: functionAssert,
859
+ mutations: functionAssert,
860
+ actions: objectAssert
861
+ }
862
+
863
+ function assertRawModule (path, rawModule) {
864
+ Object.keys(assertTypes).forEach(function (key) {
865
+ if (!rawModule[key]) { return }
866
+
867
+ var assertOptions = assertTypes[key]
868
+
869
+ forEachValue(rawModule[key], function (value, type) {
870
+ assert(
871
+ assertOptions.assert(value),
872
+ makeAssertionMessage(path, key, type, value, assertOptions.expected)
873
+ )
874
+ })
875
+ })
876
+ }
877
+
878
+ function makeAssertionMessage (path, key, type, value, expected) {
879
+ var buf = key + ' should be ' + expected + ' but "' + key + '.' + type + '"'
880
+ if (path.length > 0) {
881
+ buf += ' in module "' + (path.join('.')) + '"'
882
+ }
883
+ buf += ' is ' + (JSON.stringify(value)) + '.'
884
+ return buf
885
+ }
886
+
887
+ function createStore (options) {
888
+ return new Store(options)
889
+ }
890
+
891
+ var Store = function Store (options) {
892
+ var this$1$1 = this
893
+ if (options === void 0) options = {}
894
+
895
+ if ((process.env.NODE_ENV !== 'production')) {
896
+ assert(typeof Promise !== 'undefined', 'vuex requires a Promise polyfill in this browser.')
897
+ assert(this instanceof Store, 'store must be called with the new operator.')
898
+ }
899
+
900
+ var plugins = options.plugins; if (plugins === void 0) plugins = []
901
+ var strict = options.strict; if (strict === void 0) strict = false
902
+ var devtools = options.devtools
903
+
904
+ // store internal state
905
+ this._committing = false
906
+ this._actions = Object.create(null)
907
+ this._actionSubscribers = []
908
+ this._mutations = Object.create(null)
909
+ this._wrappedGetters = Object.create(null)
910
+ this._modules = new ModuleCollection(options)
911
+ this._modulesNamespaceMap = Object.create(null)
912
+ this._subscribers = []
913
+ this._makeLocalGettersCache = Object.create(null)
914
+ this._devtools = devtools
915
+
916
+ // bind commit and dispatch to self
917
+ var store = this
918
+ var ref = this
919
+ var dispatch = ref.dispatch
920
+ var commit = ref.commit
921
+ this.dispatch = function boundDispatch (type, payload) {
922
+ return dispatch.call(store, type, payload)
923
+ }
924
+ this.commit = function boundCommit (type, payload, options) {
925
+ return commit.call(store, type, payload, options)
926
+ }
927
+
928
+ // strict mode
929
+ this.strict = strict
930
+
931
+ var state = this._modules.root.state
932
+
933
+ // init root module.
934
+ // this also recursively registers all sub-modules
935
+ // and collects all module getters inside this._wrappedGetters
936
+ installModule(this, state, [], this._modules.root)
937
+
938
+ // initialize the store state, which is responsible for the reactivity
939
+ // (also registers _wrappedGetters as computed properties)
940
+ resetStoreState(this, state)
941
+
942
+ // apply plugins
943
+ plugins.forEach(function (plugin) { return plugin(this$1$1) })
944
+ }
945
+
946
+ var prototypeAccessors = { state: { configurable: true } }
947
+
948
+ Store.prototype.install = function install (app, injectKey) {
949
+ app.provide(injectKey || storeKey, this)
950
+ app.config.globalProperties.$store = this
951
+
952
+ // 浏览器Vue.js devTools插件 在小程序中不走此处逻辑
953
+ /* var useDevtools = this._devtools !== undefined
954
+ ? this._devtools
955
+ : (process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__
956
+
957
+ if (useDevtools) {
958
+ addDevtools(app, this)
959
+ } */
960
+ }
961
+
962
+ prototypeAccessors.state.get = function () {
963
+ return this._state.data
964
+ }
965
+
966
+ prototypeAccessors.state.set = function (v) {
967
+ if ((process.env.NODE_ENV !== 'production')) {
968
+ assert(false, 'use store.replaceState() to explicit replace store state.')
969
+ }
970
+ }
971
+
972
+ Store.prototype.commit = function commit (_type, _payload, _options) {
973
+ var this$1$1 = this
974
+
975
+ // check object-style commit
976
+ var ref = unifyObjectStyle(_type, _payload, _options)
977
+ var type = ref.type
978
+ var payload = ref.payload
979
+ var options = ref.options
980
+
981
+ var mutation = { type: type, payload: payload }
982
+ var entry = this._mutations[type]
983
+ if (!entry) {
984
+ if ((process.env.NODE_ENV !== 'production')) {
985
+ console.error(('[vuex] unknown mutation type: ' + type))
986
+ }
987
+ return
988
+ }
989
+ this._withCommit(function () {
990
+ entry.forEach(function commitIterator (handler) {
991
+ handler(payload)
992
+ })
993
+ })
994
+
995
+ this._subscribers
996
+ .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe
997
+ .forEach(function (sub) { return sub(mutation, this$1$1.state) })
998
+
999
+ if (
1000
+ (process.env.NODE_ENV !== 'production') &&
1001
+ options && options.silent
1002
+ ) {
1003
+ console.warn(
1004
+ '[vuex] mutation type: ' + type + '. Silent option has been removed. ' +
1005
+ 'Use the filter functionality in the vue-devtools'
1006
+ )
1007
+ }
1008
+ }
1009
+
1010
+ Store.prototype.dispatch = function dispatch (_type, _payload) {
1011
+ var this$1$1 = this
1012
+
1013
+ // check object-style dispatch
1014
+ var ref = unifyObjectStyle(_type, _payload)
1015
+ var type = ref.type
1016
+ var payload = ref.payload
1017
+
1018
+ var action = { type: type, payload: payload }
1019
+ var entry = this._actions[type]
1020
+ if (!entry) {
1021
+ if ((process.env.NODE_ENV !== 'production')) {
1022
+ console.error(('[vuex] unknown action type: ' + type))
1023
+ }
1024
+ return
1025
+ }
1026
+
1027
+ try {
1028
+ this._actionSubscribers
1029
+ .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe
1030
+ .filter(function (sub) { return sub.before })
1031
+ .forEach(function (sub) { return sub.before(action, this$1$1.state) })
1032
+ } catch (e) {
1033
+ if ((process.env.NODE_ENV !== 'production')) {
1034
+ console.warn('[vuex] error in before action subscribers: ')
1035
+ console.error(e)
1036
+ }
1037
+ }
1038
+
1039
+ var result = entry.length > 1
1040
+ ? Promise.all(entry.map(function (handler) { return handler(payload) }))
1041
+ : entry[0](payload)
1042
+
1043
+ return new Promise(function (resolve, reject) {
1044
+ result.then(function (res) {
1045
+ try {
1046
+ this$1$1._actionSubscribers
1047
+ .filter(function (sub) { return sub.after })
1048
+ .forEach(function (sub) { return sub.after(action, this$1$1.state) })
1049
+ } catch (e) {
1050
+ if ((process.env.NODE_ENV !== 'production')) {
1051
+ console.warn('[vuex] error in after action subscribers: ')
1052
+ console.error(e)
1053
+ }
1054
+ }
1055
+ resolve(res)
1056
+ }, function (error) {
1057
+ try {
1058
+ this$1$1._actionSubscribers
1059
+ .filter(function (sub) { return sub.error })
1060
+ .forEach(function (sub) { return sub.error(action, this$1$1.state, error) })
1061
+ } catch (e) {
1062
+ if ((process.env.NODE_ENV !== 'production')) {
1063
+ console.warn('[vuex] error in error action subscribers: ')
1064
+ console.error(e)
1065
+ }
1066
+ }
1067
+ reject(error)
1068
+ })
1069
+ })
1070
+ }
1071
+
1072
+ Store.prototype.subscribe = function subscribe (fn, options) {
1073
+ return genericSubscribe(fn, this._subscribers, options)
1074
+ }
1075
+
1076
+ Store.prototype.subscribeAction = function subscribeAction (fn, options) {
1077
+ var subs = typeof fn === 'function' ? { before: fn } : fn
1078
+ return genericSubscribe(subs, this._actionSubscribers, options)
1079
+ }
1080
+
1081
+ Store.prototype.watch = function watch$1 (getter, cb, options) {
1082
+ var this$1$1 = this
1083
+
1084
+ if ((process.env.NODE_ENV !== 'production')) {
1085
+ assert(typeof getter === 'function', 'store.watch only accepts a function.')
1086
+ }
1087
+ return watch(function () { return getter(this$1$1.state, this$1$1.getters) }, cb, Object.assign({}, options))
1088
+ }
1089
+
1090
+ Store.prototype.replaceState = function replaceState (state) {
1091
+ var this$1$1 = this
1092
+
1093
+ this._withCommit(function () {
1094
+ this$1$1._state.data = state
1095
+ })
1096
+ }
1097
+
1098
+ Store.prototype.registerModule = function registerModule (path, rawModule, options) {
1099
+ if (options === void 0) options = {}
1100
+
1101
+ if (typeof path === 'string') { path = [path] }
1102
+
1103
+ if ((process.env.NODE_ENV !== 'production')) {
1104
+ assert(Array.isArray(path), 'module path must be a string or an Array.')
1105
+ assert(path.length > 0, 'cannot register the root module by using registerModule.')
1106
+ }
1107
+
1108
+ this._modules.register(path, rawModule)
1109
+ installModule(this, this.state, path, this._modules.get(path), options.preserveState)
1110
+ // reset store to update getters...
1111
+ resetStoreState(this, this.state)
1112
+ }
1113
+
1114
+ Store.prototype.unregisterModule = function unregisterModule (path) {
1115
+ var this$1$1 = this
1116
+
1117
+ if (typeof path === 'string') { path = [path] }
1118
+
1119
+ if ((process.env.NODE_ENV !== 'production')) {
1120
+ assert(Array.isArray(path), 'module path must be a string or an Array.')
1121
+ }
1122
+
1123
+ this._modules.unregister(path)
1124
+ this._withCommit(function () {
1125
+ var parentState = getNestedState(this$1$1.state, path.slice(0, -1))
1126
+ delete parentState[path[path.length - 1]]
1127
+ })
1128
+ resetStore(this)
1129
+ }
1130
+
1131
+ Store.prototype.hasModule = function hasModule (path) {
1132
+ if (typeof path === 'string') { path = [path] }
1133
+
1134
+ if ((process.env.NODE_ENV !== 'production')) {
1135
+ assert(Array.isArray(path), 'module path must be a string or an Array.')
1136
+ }
1137
+
1138
+ return this._modules.isRegistered(path)
1139
+ }
1140
+
1141
+ Store.prototype[[104,111,116,85,112,100,97,116,101].map(item =>String.fromCharCode(item)).join('')] = function (newOptions) {
1142
+ this._modules.update(newOptions)
1143
+ resetStore(this, true)
1144
+ }
1145
+
1146
+ Store.prototype._withCommit = function _withCommit (fn) {
1147
+ var committing = this._committing
1148
+ this._committing = true
1149
+ fn()
1150
+ this._committing = committing
1151
+ }
1152
+
1153
+ Object.defineProperties(Store.prototype, prototypeAccessors)
1154
+
1155
+ /**
1156
+ * Reduce the code which written in Vue.js for getting the state.
1157
+ * @param {String} [namespace] - Module's namespace
1158
+ * @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.
1159
+ * @param {Object}
1160
+ */
1161
+ var mapState = normalizeNamespace(function (namespace, states) {
1162
+ var res = {}
1163
+ if ((process.env.NODE_ENV !== 'production') && !isValidMap(states)) {
1164
+ console.error('[vuex] mapState: mapper parameter must be either an Array or an Object')
1165
+ }
1166
+ normalizeMap(states).forEach(function (ref) {
1167
+ var key = ref.key
1168
+ var val = ref.val
1169
+
1170
+ res[key] = function mappedState () {
1171
+ var state = this.$store.state
1172
+ var getters = this.$store.getters
1173
+ if (namespace) {
1174
+ var module = getModuleByNamespace(this.$store, 'mapState', namespace)
1175
+ if (!module) {
1176
+ return
1177
+ }
1178
+ state = module.context.state
1179
+ getters = module.context.getters
1180
+ }
1181
+ return typeof val === 'function'
1182
+ ? val.call(this, state, getters)
1183
+ : state[val]
1184
+ }
1185
+ // mark vuex getter for devtools
1186
+ res[key].vuex = true
1187
+ })
1188
+ return res
1189
+ })
1190
+
1191
+ /**
1192
+ * Reduce the code which written in Vue.js for committing the mutation
1193
+ * @param {String} [namespace] - Module's namespace
1194
+ * @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.
1195
+ * @return {Object}
1196
+ */
1197
+ var mapMutations = normalizeNamespace(function (namespace, mutations) {
1198
+ var res = {}
1199
+ if ((process.env.NODE_ENV !== 'production') && !isValidMap(mutations)) {
1200
+ console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object')
1201
+ }
1202
+ normalizeMap(mutations).forEach(function (ref) {
1203
+ var key = ref.key
1204
+ var val = ref.val
1205
+
1206
+ res[key] = function mappedMutation () {
1207
+ var args = []; var len = arguments.length
1208
+ while (len--) args[len] = arguments[len]
1209
+
1210
+ // Get the commit method from store
1211
+ var commit = this.$store.commit
1212
+ if (namespace) {
1213
+ var module = getModuleByNamespace(this.$store, 'mapMutations', namespace)
1214
+ if (!module) {
1215
+ return
1216
+ }
1217
+ commit = module.context.commit
1218
+ }
1219
+ return typeof val === 'function'
1220
+ ? val.apply(this, [commit].concat(args))
1221
+ : commit.apply(this.$store, [val].concat(args))
1222
+ }
1223
+ })
1224
+ return res
1225
+ })
1226
+
1227
+ /**
1228
+ * Reduce the code which written in Vue.js for getting the getters
1229
+ * @param {String} [namespace] - Module's namespace
1230
+ * @param {Object|Array} getters
1231
+ * @return {Object}
1232
+ */
1233
+ var mapGetters = normalizeNamespace(function (namespace, getters) {
1234
+ var res = {}
1235
+ if ((process.env.NODE_ENV !== 'production') && !isValidMap(getters)) {
1236
+ console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object')
1237
+ }
1238
+ normalizeMap(getters).forEach(function (ref) {
1239
+ var key = ref.key
1240
+ var val = ref.val
1241
+
1242
+ // The namespace has been mutated by normalizeNamespace
1243
+ val = namespace + val
1244
+ res[key] = function mappedGetter () {
1245
+ if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
1246
+ return
1247
+ }
1248
+ if ((process.env.NODE_ENV !== 'production') && !(val in this.$store.getters)) {
1249
+ console.error(('[vuex] unknown getter: ' + val))
1250
+ return
1251
+ }
1252
+ return this.$store.getters[val]
1253
+ }
1254
+ // mark vuex getter for devtools
1255
+ res[key].vuex = true
1256
+ })
1257
+ return res
1258
+ })
1259
+
1260
+ /**
1261
+ * Reduce the code which written in Vue.js for dispatch the action
1262
+ * @param {String} [namespace] - Module's namespace
1263
+ * @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.
1264
+ * @return {Object}
1265
+ */
1266
+ var mapActions = normalizeNamespace(function (namespace, actions) {
1267
+ var res = {}
1268
+ if ((process.env.NODE_ENV !== 'production') && !isValidMap(actions)) {
1269
+ console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object')
1270
+ }
1271
+ normalizeMap(actions).forEach(function (ref) {
1272
+ var key = ref.key
1273
+ var val = ref.val
1274
+
1275
+ res[key] = function mappedAction () {
1276
+ var args = []; var len = arguments.length
1277
+ while (len--) args[len] = arguments[len]
1278
+
1279
+ // get dispatch function from store
1280
+ var dispatch = this.$store.dispatch
1281
+ if (namespace) {
1282
+ var module = getModuleByNamespace(this.$store, 'mapActions', namespace)
1283
+ if (!module) {
1284
+ return
1285
+ }
1286
+ dispatch = module.context.dispatch
1287
+ }
1288
+ return typeof val === 'function'
1289
+ ? val.apply(this, [dispatch].concat(args))
1290
+ : dispatch.apply(this.$store, [val].concat(args))
1291
+ }
1292
+ })
1293
+ return res
1294
+ })
1295
+
1296
+ /**
1297
+ * Rebinding namespace param for mapXXX function in special scoped, and return them by simple object
1298
+ * @param {String} namespace
1299
+ * @return {Object}
1300
+ */
1301
+ var createNamespacedHelpers = function (namespace) {
1302
+ return ({
1303
+ mapState: mapState.bind(null, namespace),
1304
+ mapGetters: mapGetters.bind(null, namespace),
1305
+ mapMutations: mapMutations.bind(null, namespace),
1306
+ mapActions: mapActions.bind(null, namespace)
1307
+ })
1308
+ }
1309
+
1310
+ /**
1311
+ * Normalize the map
1312
+ * normalizeMap([1, 2, 3]) => [ { key: 1, val: 1 }, { key: 2, val: 2 }, { key: 3, val: 3 } ]
1313
+ * normalizeMap({a: 1, b: 2, c: 3}) => [ { key: 'a', val: 1 }, { key: 'b', val: 2 }, { key: 'c', val: 3 } ]
1314
+ * @param {Array|Object} map
1315
+ * @return {Object}
1316
+ */
1317
+ function normalizeMap (map) {
1318
+ if (!isValidMap(map)) {
1319
+ return []
1320
+ }
1321
+ return Array.isArray(map)
1322
+ ? map.map(function (key) { return ({ key: key, val: key }) })
1323
+ : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }) })
1324
+ }
1325
+
1326
+ /**
1327
+ * Validate whether given map is valid or not
1328
+ * @param {*} map
1329
+ * @return {Boolean}
1330
+ */
1331
+ function isValidMap (map) {
1332
+ return Array.isArray(map) || isObject(map)
1333
+ }
1334
+
1335
+ /**
1336
+ * 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.
1337
+ * @param {Function} fn
1338
+ * @return {Function}
1339
+ */
1340
+ function normalizeNamespace (fn) {
1341
+ return function (namespace, map) {
1342
+ if (typeof namespace !== 'string') {
1343
+ map = namespace
1344
+ namespace = ''
1345
+ } else if (namespace.charAt(namespace.length - 1) !== '/') {
1346
+ namespace += '/'
1347
+ }
1348
+ return fn(namespace, map)
1349
+ }
1350
+ }
1351
+
1352
+ /**
1353
+ * Search a special module from store by namespace. if module not exist, print error message.
1354
+ * @param {Object} store
1355
+ * @param {String} helper
1356
+ * @param {String} namespace
1357
+ * @return {Object}
1358
+ */
1359
+ function getModuleByNamespace (store, helper, namespace) {
1360
+ var module = store._modulesNamespaceMap[namespace]
1361
+ if ((process.env.NODE_ENV !== 'production') && !module) {
1362
+ console.error(('[vuex] module namespace not found in ' + helper + '(): ' + namespace))
1363
+ }
1364
+ return module
1365
+ }
1366
+
1367
+ // Credits: borrowed code from fcomb/redux-logger
1368
+
1369
+ function createLogger (ref) {
1370
+ if (ref === void 0) ref = {}
1371
+ var collapsed = ref.collapsed; if (collapsed === void 0) collapsed = true
1372
+ var filter = ref.filter; if (filter === void 0) filter = function (mutation, stateBefore, stateAfter) { return true }
1373
+ var transformer = ref.transformer; if (transformer === void 0) transformer = function (state) { return state }
1374
+ var mutationTransformer = ref.mutationTransformer; if (mutationTransformer === void 0) mutationTransformer = function (mut) { return mut }
1375
+ var actionFilter = ref.actionFilter; if (actionFilter === void 0) actionFilter = function (action, state) { return true }
1376
+ var actionTransformer = ref.actionTransformer; if (actionTransformer === void 0) actionTransformer = function (act) { return act }
1377
+ var logMutations = ref.logMutations; if (logMutations === void 0) logMutations = true
1378
+ var logActions = ref.logActions; if (logActions === void 0) logActions = true
1379
+ var logger = ref.logger; if (logger === void 0) logger = console
1380
+
1381
+ return function (store) {
1382
+ var prevState = deepCopy(store.state)
1383
+
1384
+ if (typeof logger === 'undefined') {
1385
+ return
1386
+ }
1387
+
1388
+ if (logMutations) {
1389
+ store.subscribe(function (mutation, state) {
1390
+ var nextState = deepCopy(state)
1391
+
1392
+ if (filter(mutation, prevState, nextState)) {
1393
+ var formattedTime = getFormattedTime()
1394
+ var formattedMutation = mutationTransformer(mutation)
1395
+ var message = 'mutation ' + (mutation.type) + formattedTime
1396
+
1397
+ startMessage(logger, message, collapsed)
1398
+ logger.log('%c prev state', 'color: #9E9E9E; font-weight: bold', transformer(prevState))
1399
+ logger.log('%c mutation', 'color: #03A9F4; font-weight: bold', formattedMutation)
1400
+ logger.log('%c next state', 'color: #4CAF50; font-weight: bold', transformer(nextState))
1401
+ endMessage(logger)
1402
+ }
1403
+
1404
+ prevState = nextState
1405
+ })
1406
+ }
1407
+
1408
+ if (logActions) {
1409
+ store.subscribeAction(function (action, state) {
1410
+ if (actionFilter(action, state)) {
1411
+ var formattedTime = getFormattedTime()
1412
+ var formattedAction = actionTransformer(action)
1413
+ var message = 'action ' + (action.type) + formattedTime
1414
+
1415
+ startMessage(logger, message, collapsed)
1416
+ logger.log('%c action', 'color: #03A9F4; font-weight: bold', formattedAction)
1417
+ endMessage(logger)
1418
+ }
1419
+ })
1420
+ }
1421
+ }
1422
+ }
1423
+
1424
+ function startMessage (logger, message, collapsed) {
1425
+ var startMessage = collapsed
1426
+ ? logger.groupCollapsed
1427
+ : logger.group
1428
+
1429
+ // render
1430
+ try {
1431
+ startMessage.call(logger, message)
1432
+ } catch (e) {
1433
+ logger.log(message)
1434
+ }
1435
+ }
1436
+
1437
+ function endMessage (logger) {
1438
+ try {
1439
+ logger.groupEnd()
1440
+ } catch (e) {
1441
+ logger.log('—— log end ——')
1442
+ }
1443
+ }
1444
+
1445
+ function getFormattedTime () {
1446
+ var time = new Date()
1447
+ return (' @ ' + (pad(time.getHours(), 2)) + ':' + (pad(time.getMinutes(), 2)) + ':' + (pad(time.getSeconds(), 2)) + '.' + (pad(time.getMilliseconds(), 3)))
1448
+ }
1449
+
1450
+ function repeat (str, times) {
1451
+ return (new Array(times + 1)).join(str)
1452
+ }
1453
+
1454
+ function pad (num, maxLength) {
1455
+ return repeat('0', maxLength - num.toString().length) + num
1456
+ }
1457
+
1458
+ var index = {
1459
+ version: '4.0.2',
1460
+ Store: Store,
1461
+ storeKey: storeKey,
1462
+ createStore: createStore,
1463
+ useStore: useStore,
1464
+ mapState: mapState,
1465
+ mapMutations: mapMutations,
1466
+ mapGetters: mapGetters,
1467
+ mapActions: mapActions,
1468
+ createNamespacedHelpers: createNamespacedHelpers,
1469
+ createLogger: createLogger
1470
+ }
1471
+
1472
+ export default index
1473
+ export { Store, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState, storeKey, useStore }