From 70aeba7006dafb1bf3db15d58e0327f015cd981b Mon Sep 17 00:00:00 2001 From: unknown <331404948@qq.com> Date: Tue, 23 Jul 2024 17:29:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=99=E6=80=81=E9=A1=B5=E9=9D=A2=E5=93=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/oneBtn/oneBtn.vue | 12 +- components/privacyRadion/privacyRadion.vue | 2 +- components/searchRow/searchRow.vue | 67 + config/api.js | 29 +- config/site.config.js | 2 +- main.js | 3 + manifest.json | 2 +- node_modules/.bin/vue-demi-fix | 12 + node_modules/.bin/vue-demi-fix.cmd | 17 + node_modules/.bin/vue-demi-fix.ps1 | 28 + node_modules/.bin/vue-demi-switch | 12 + node_modules/.bin/vue-demi-switch.cmd | 17 + node_modules/.bin/vue-demi-switch.ps1 | 28 + node_modules/.package-lock.json | 62 + node_modules/.vite/deps/_metadata.json | 6 +- node_modules/@vue/devtools-api/lib/cjs/api/api.js | 2 + node_modules/@vue/devtools-api/lib/cjs/api/app.js | 2 + .../@vue/devtools-api/lib/cjs/api/component.js | 2 + .../@vue/devtools-api/lib/cjs/api/context.js | 2 + .../@vue/devtools-api/lib/cjs/api/hooks.js | 2 + .../@vue/devtools-api/lib/cjs/api/index.js | 22 + node_modules/@vue/devtools-api/lib/cjs/api/util.js | 2 + node_modules/@vue/devtools-api/lib/cjs/const.js | 5 + node_modules/@vue/devtools-api/lib/cjs/env.js | 17 + node_modules/@vue/devtools-api/lib/cjs/index.js | 45 + node_modules/@vue/devtools-api/lib/cjs/plugin.js | 2 + node_modules/@vue/devtools-api/lib/cjs/proxy.js | 111 + node_modules/@vue/devtools-api/lib/cjs/time.js | 28 + .../@vue/devtools-api/lib/esm/api/api.d.ts | 108 + node_modules/@vue/devtools-api/lib/esm/api/api.js | 1 + .../@vue/devtools-api/lib/esm/api/app.d.ts | 1 + node_modules/@vue/devtools-api/lib/esm/api/app.js | 1 + .../@vue/devtools-api/lib/esm/api/component.d.ts | 78 + .../@vue/devtools-api/lib/esm/api/component.js | 1 + .../@vue/devtools-api/lib/esm/api/context.d.ts | 5 + .../@vue/devtools-api/lib/esm/api/context.js | 1 + .../@vue/devtools-api/lib/esm/api/hooks.d.ts | 180 + .../@vue/devtools-api/lib/esm/api/hooks.js | 1 + .../@vue/devtools-api/lib/esm/api/index.d.ts | 6 + .../@vue/devtools-api/lib/esm/api/index.js | 6 + .../@vue/devtools-api/lib/esm/api/util.d.ts | 4 + node_modules/@vue/devtools-api/lib/esm/api/util.js | 1 + node_modules/@vue/devtools-api/lib/esm/const.d.ts | 2 + node_modules/@vue/devtools-api/lib/esm/const.js | 2 + node_modules/@vue/devtools-api/lib/esm/env.d.ts | 15 + node_modules/@vue/devtools-api/lib/esm/env.js | 12 + node_modules/@vue/devtools-api/lib/esm/index.d.ts | 18 + node_modules/@vue/devtools-api/lib/esm/index.js | 27 + node_modules/@vue/devtools-api/lib/esm/plugin.d.ts | 47 + node_modules/@vue/devtools-api/lib/esm/plugin.js | 1 + node_modules/@vue/devtools-api/lib/esm/proxy.d.ts | 20 + node_modules/@vue/devtools-api/lib/esm/proxy.js | 107 + node_modules/@vue/devtools-api/lib/esm/time.d.ts | 2 + node_modules/@vue/devtools-api/lib/esm/time.js | 23 + node_modules/@vue/devtools-api/package.json | 37 + node_modules/pinia/LICENSE | 21 + node_modules/pinia/README.md | 24 + node_modules/pinia/dist/pinia.cjs | 2020 ++++ node_modules/pinia/dist/pinia.d.ts | 995 ++ node_modules/pinia/dist/pinia.esm-browser.js | 1997 +++ node_modules/pinia/dist/pinia.iife.js | 2181 ++++ node_modules/pinia/dist/pinia.iife.prod.js | 6 + node_modules/pinia/dist/pinia.mjs | 2005 +++ node_modules/pinia/dist/pinia.prod.cjs | 805 ++ node_modules/pinia/index.cjs | 7 + node_modules/pinia/index.js | 7 + node_modules/pinia/package.json | 100 + node_modules/vue-demi/LICENSE | 21 + node_modules/vue-demi/README.md | 229 + node_modules/vue-demi/bin/vue-demi-fix.js | 3 + node_modules/vue-demi/bin/vue-demi-switch.js | 3 + node_modules/vue-demi/lib/index.cjs | 34 + node_modules/vue-demi/lib/index.d.ts | 33 + node_modules/vue-demi/lib/index.iife.js | 119 + node_modules/vue-demi/lib/index.mjs | 49 + node_modules/vue-demi/lib/v2.7/index.cjs | 60 + node_modules/vue-demi/lib/v2.7/index.d.ts | 38 + node_modules/vue-demi/lib/v2.7/index.mjs | 80 + node_modules/vue-demi/lib/v2/index.cjs | 34 + node_modules/vue-demi/lib/v2/index.d.ts | 33 + node_modules/vue-demi/lib/v2/index.mjs | 49 + node_modules/vue-demi/lib/v3/index.cjs | 29 + node_modules/vue-demi/lib/v3/index.d.ts | 22 + node_modules/vue-demi/lib/v3/index.mjs | 34 + node_modules/vue-demi/package.json | 47 + node_modules/vue-demi/scripts/postinstall.js | 19 + node_modules/vue-demi/scripts/switch-cli.js | 18 + node_modules/vue-demi/scripts/utils.js | 62 + node_modules/vue/LICENSE | 21 + node_modules/vue/README.md | 386 + node_modules/vue/dist/README.md | 122 + node_modules/vue/dist/vue.common.dev.js | 12008 ++++++++++++++++++ node_modules/vue/dist/vue.common.js | 5 + node_modules/vue/dist/vue.common.prod.js | 6 + node_modules/vue/dist/vue.esm.browser.js | 12059 +++++++++++++++++++ node_modules/vue/dist/vue.esm.browser.min.js | 6 + node_modules/vue/dist/vue.esm.js | 12042 ++++++++++++++++++ node_modules/vue/dist/vue.js | 12014 ++++++++++++++++++ node_modules/vue/dist/vue.min.js | 6 + node_modules/vue/dist/vue.runtime.common.dev.js | 8467 +++++++++++++ node_modules/vue/dist/vue.runtime.common.js | 5 + node_modules/vue/dist/vue.runtime.common.prod.js | 6 + node_modules/vue/dist/vue.runtime.esm.js | 8495 +++++++++++++ node_modules/vue/dist/vue.runtime.js | 8473 +++++++++++++ node_modules/vue/dist/vue.runtime.min.js | 6 + node_modules/vue/package.json | 150 + node_modules/vue/src/compiler/codeframe.js | 50 + node_modules/vue/src/compiler/codegen/events.js | 190 + node_modules/vue/src/compiler/codegen/index.js | 619 + node_modules/vue/src/compiler/create-compiler.js | 75 + node_modules/vue/src/compiler/directives/bind.js | 11 + node_modules/vue/src/compiler/directives/index.js | 11 + node_modules/vue/src/compiler/directives/model.js | 148 + node_modules/vue/src/compiler/directives/on.js | 10 + node_modules/vue/src/compiler/error-detector.js | 128 + node_modules/vue/src/compiler/helpers.js | 231 + node_modules/vue/src/compiler/index.js | 25 + node_modules/vue/src/compiler/optimizer.js | 128 + .../vue/src/compiler/parser/entity-decoder.js | 11 + .../vue/src/compiler/parser/filter-parser.js | 97 + .../vue/src/compiler/parser/html-parser.js | 306 + node_modules/vue/src/compiler/parser/index.js | 979 ++ .../vue/src/compiler/parser/text-parser.js | 53 + node_modules/vue/src/compiler/to-function.js | 114 + node_modules/vue/src/core/components/index.js | 5 + node_modules/vue/src/core/components/keep-alive.js | 152 + node_modules/vue/src/core/config.js | 130 + node_modules/vue/src/core/global-api/assets.js | 34 + node_modules/vue/src/core/global-api/extend.js | 95 + node_modules/vue/src/core/global-api/index.js | 69 + node_modules/vue/src/core/global-api/mixin.js | 10 + node_modules/vue/src/core/global-api/use.js | 23 + node_modules/vue/src/core/index.js | 26 + node_modules/vue/src/core/instance/events.js | 143 + node_modules/vue/src/core/instance/index.js | 23 + node_modules/vue/src/core/instance/init.js | 128 + node_modules/vue/src/core/instance/inject.js | 73 + node_modules/vue/src/core/instance/lifecycle.js | 351 + node_modules/vue/src/core/instance/proxy.js | 92 + .../instance/render-helpers/bind-dynamic-keys.js | 35 + .../render-helpers/bind-object-listeners.js | 22 + .../instance/render-helpers/bind-object-props.js | 64 + .../core/instance/render-helpers/check-keycodes.js | 35 + .../vue/src/core/instance/render-helpers/index.js | 33 + .../core/instance/render-helpers/render-list.js | 50 + .../core/instance/render-helpers/render-slot.js | 40 + .../core/instance/render-helpers/render-static.js | 60 + .../core/instance/render-helpers/resolve-filter.js | 10 + .../render-helpers/resolve-scoped-slots.js | 27 + .../core/instance/render-helpers/resolve-slots.js | 50 + node_modules/vue/src/core/instance/render.js | 129 + node_modules/vue/src/core/instance/state.js | 370 + node_modules/vue/src/core/observer/array.js | 45 + node_modules/vue/src/core/observer/dep.js | 66 + node_modules/vue/src/core/observer/index.js | 276 + node_modules/vue/src/core/observer/scheduler.js | 190 + node_modules/vue/src/core/observer/traverse.js | 40 + node_modules/vue/src/core/observer/watcher.js | 241 + node_modules/vue/src/core/util/debug.js | 100 + node_modules/vue/src/core/util/env.js | 96 + node_modules/vue/src/core/util/error.js | 83 + node_modules/vue/src/core/util/index.js | 11 + node_modules/vue/src/core/util/lang.js | 46 + node_modules/vue/src/core/util/next-tick.js | 110 + node_modules/vue/src/core/util/options.js | 468 + node_modules/vue/src/core/util/perf.js | 24 + node_modules/vue/src/core/util/props.js | 250 + node_modules/vue/src/core/vdom/create-component.js | 270 + node_modules/vue/src/core/vdom/create-element.js | 166 + .../src/core/vdom/create-functional-component.js | 155 + .../vue/src/core/vdom/helpers/extract-props.js | 75 + .../core/vdom/helpers/get-first-component-child.js | 15 + node_modules/vue/src/core/vdom/helpers/index.js | 9 + .../src/core/vdom/helpers/is-async-placeholder.js | 5 + .../vue/src/core/vdom/helpers/merge-hook.js | 38 + .../src/core/vdom/helpers/normalize-children.js | 89 + .../core/vdom/helpers/normalize-scoped-slots.js | 86 + .../core/vdom/helpers/resolve-async-component.js | 165 + .../vue/src/core/vdom/helpers/update-listeners.js | 95 + .../vue/src/core/vdom/modules/directives.js | 120 + node_modules/vue/src/core/vdom/modules/index.js | 7 + node_modules/vue/src/core/vdom/modules/ref.js | 45 + node_modules/vue/src/core/vdom/patch.js | 803 ++ node_modules/vue/src/core/vdom/vnode.js | 113 + .../src/platforms/web/compiler/directives/html.js | 9 + .../src/platforms/web/compiler/directives/index.js | 9 + .../src/platforms/web/compiler/directives/model.js | 175 + .../src/platforms/web/compiler/directives/text.js | 9 + .../vue/src/platforms/web/compiler/index.js | 8 + .../src/platforms/web/compiler/modules/class.js | 49 + .../src/platforms/web/compiler/modules/index.js | 9 + .../src/platforms/web/compiler/modules/model.js | 94 + .../src/platforms/web/compiler/modules/style.js | 52 + .../vue/src/platforms/web/compiler/options.js | 26 + .../vue/src/platforms/web/compiler/util.js | 24 + .../vue/src/platforms/web/entry-compiler.js | 6 + .../platforms/web/entry-runtime-with-compiler.js | 101 + .../vue/src/platforms/web/entry-runtime.js | 5 + .../platforms/web/entry-server-basic-renderer.js | 13 + .../vue/src/platforms/web/entry-server-renderer.js | 27 + .../vue/src/platforms/web/runtime/class-util.js | 63 + .../src/platforms/web/runtime/components/index.js | 7 + .../web/runtime/components/transition-group.js | 190 + .../platforms/web/runtime/components/transition.js | 198 + .../src/platforms/web/runtime/directives/index.js | 7 + .../src/platforms/web/runtime/directives/model.js | 147 + .../src/platforms/web/runtime/directives/show.js | 60 + .../vue/src/platforms/web/runtime/index.js | 76 + .../vue/src/platforms/web/runtime/modules/attrs.js | 119 + .../vue/src/platforms/web/runtime/modules/class.js | 48 + .../src/platforms/web/runtime/modules/dom-props.js | 116 + .../src/platforms/web/runtime/modules/events.js | 120 + .../vue/src/platforms/web/runtime/modules/index.js | 15 + .../vue/src/platforms/web/runtime/modules/style.js | 93 + .../platforms/web/runtime/modules/transition.js | 343 + .../vue/src/platforms/web/runtime/node-ops.js | 59 + .../vue/src/platforms/web/runtime/patch.js | 12 + .../src/platforms/web/runtime/transition-util.js | 190 + .../vue/src/platforms/web/server/compiler.js | 11 + .../src/platforms/web/server/directives/index.js | 7 + .../src/platforms/web/server/directives/model.js | 44 + .../src/platforms/web/server/directives/show.js | 12 + .../vue/src/platforms/web/server/modules/attrs.js | 67 + .../vue/src/platforms/web/server/modules/class.js | 11 + .../src/platforms/web/server/modules/dom-props.js | 50 + .../vue/src/platforms/web/server/modules/index.js | 11 + .../vue/src/platforms/web/server/modules/style.js | 41 + node_modules/vue/src/platforms/web/server/util.js | 101 + node_modules/vue/src/platforms/web/util/attrs.js | 54 + node_modules/vue/src/platforms/web/util/class.js | 85 + node_modules/vue/src/platforms/web/util/compat.js | 16 + node_modules/vue/src/platforms/web/util/element.js | 77 + node_modules/vue/src/platforms/web/util/index.js | 25 + node_modules/vue/src/platforms/web/util/style.js | 71 + .../platforms/weex/compiler/directives/index.js | 5 + .../platforms/weex/compiler/directives/model.js | 33 + .../vue/src/platforms/weex/compiler/index.js | 52 + .../src/platforms/weex/compiler/modules/append.js | 27 + .../src/platforms/weex/compiler/modules/class.js | 74 + .../src/platforms/weex/compiler/modules/index.js | 13 + .../src/platforms/weex/compiler/modules/props.js | 37 + .../modules/recycle-list/component-root.js | 13 + .../compiler/modules/recycle-list/component.js | 16 + .../weex/compiler/modules/recycle-list/index.js | 60 + .../compiler/modules/recycle-list/recycle-list.js | 50 + .../weex/compiler/modules/recycle-list/text.js | 23 + .../weex/compiler/modules/recycle-list/v-bind.js | 21 + .../weex/compiler/modules/recycle-list/v-for.js | 33 + .../weex/compiler/modules/recycle-list/v-if.js | 63 + .../weex/compiler/modules/recycle-list/v-on.js | 25 + .../weex/compiler/modules/recycle-list/v-once.js | 19 + .../src/platforms/weex/compiler/modules/style.js | 87 + .../vue/src/platforms/weex/entry-compiler.js | 2 + .../vue/src/platforms/weex/entry-framework.js | 187 + .../src/platforms/weex/entry-runtime-factory.js | 6 + .../src/platforms/weex/runtime/components/index.js | 9 + .../platforms/weex/runtime/components/richtext.js | 82 + .../weex/runtime/components/transition-group.js | 148 + .../weex/runtime/components/transition.js | 9 + .../src/platforms/weex/runtime/directives/index.js | 2 + .../vue/src/platforms/weex/runtime/index.js | 42 + .../src/platforms/weex/runtime/modules/attrs.js | 44 + .../src/platforms/weex/runtime/modules/class.js | 76 + .../src/platforms/weex/runtime/modules/events.js | 54 + .../src/platforms/weex/runtime/modules/index.js | 13 + .../src/platforms/weex/runtime/modules/style.js | 84 + .../platforms/weex/runtime/modules/transition.js | 270 + .../vue/src/platforms/weex/runtime/node-ops.js | 91 + .../vue/src/platforms/weex/runtime/patch.js | 16 + .../recycle-list/render-component-template.js | 34 + .../weex/runtime/recycle-list/virtual-component.js | 136 + .../vue/src/platforms/weex/runtime/text-node.js | 9 + .../vue/src/platforms/weex/util/element.js | 52 + node_modules/vue/src/platforms/weex/util/index.js | 40 + node_modules/vue/src/platforms/weex/util/parser.js | 60 + .../bundle-renderer/create-bundle-renderer.js | 151 + .../server/bundle-renderer/create-bundle-runner.js | 150 + .../server/bundle-renderer/source-map-support.js | 45 + .../vue/src/server/create-basic-renderer.js | 37 + node_modules/vue/src/server/create-renderer.js | 152 + .../vue/src/server/optimizing-compiler/codegen.js | 264 + .../vue/src/server/optimizing-compiler/index.js | 20 + .../vue/src/server/optimizing-compiler/modules.js | 124 + .../src/server/optimizing-compiler/optimizer.js | 141 + .../server/optimizing-compiler/runtime-helpers.js | 150 + node_modules/vue/src/server/render-context.js | 130 + node_modules/vue/src/server/render-stream.js | 95 + node_modules/vue/src/server/render.js | 437 + .../template-renderer/create-async-file-mapper.js | 57 + .../vue/src/server/template-renderer/index.js | 277 + .../src/server/template-renderer/parse-template.js | 42 + .../server/template-renderer/template-stream.js | 82 + node_modules/vue/src/server/util.js | 18 + .../vue/src/server/webpack-plugin/client.js | 67 + .../vue/src/server/webpack-plugin/server.js | 69 + node_modules/vue/src/server/webpack-plugin/util.js | 73 + node_modules/vue/src/server/write.js | 50 + node_modules/vue/src/sfc/parser.js | 134 + node_modules/vue/src/shared/constants.js | 22 + node_modules/vue/src/shared/util.js | 343 + node_modules/vue/types/index.d.ts | 39 + node_modules/vue/types/options.d.ts | 207 + node_modules/vue/types/plugin.d.ts | 8 + node_modules/vue/types/umd.d.ts | 48 + node_modules/vue/types/vnode.d.ts | 76 + node_modules/vue/types/vue.d.ts | 132 + package-lock.json | 65 +- package.json | 3 +- pages.json | 50 + pages/subPage/authentication/authentication.vue | 135 + pages/subPage/authentication/comp/select1.vue | 102 + pages/subPage/authentication/comp/select2.vue | 91 + pages/subPage/authentication/comp/select3.vue | 91 + pages/subPage/authentication/selectAddress.vue | 11 + pages/subPage/login/login.vue | 160 +- pages/subPage/login/loginbyPhone.vue | 239 + pages/subPage/login/loginwx.vue | 184 + .../subPage/privacyAgreement/privacyAgreement.vue | 43 + pages/tabbar/index/index.vue | 254 +- pages/tabbar/mine/mine.vue | 6 +- static/images/pozicon.png | Bin 0 -> 2847 bytes static/images/searchIcon.png | Bin 0 -> 2563 bytes store/index.js | 14 + unpackage/dist/dev/mp-weixin/app.js | 7 + unpackage/dist/dev/mp-weixin/app.json | 7 +- unpackage/dist/dev/mp-weixin/common/assets.js | 16 +- unpackage/dist/dev/mp-weixin/common/vendor.js | 175 +- .../dist/dev/mp-weixin/components/oneBtn/oneBtn.js | 19 + .../dev/mp-weixin/components/oneBtn/oneBtn.json | 4 + .../dev/mp-weixin/components/oneBtn/oneBtn.wxml | 1 + .../dev/mp-weixin/components/oneBtn/oneBtn.wxss | 38 + .../components/privacyRadion/privacyRadion.js | 39 + .../components/privacyRadion/privacyRadion.json | 7 + .../components/privacyRadion/privacyRadion.wxml | 1 + .../components/privacyRadion/privacyRadion.wxss | 36 + .../mp-weixin/components/searchRow/searchRow.js | 48 + .../mp-weixin/components/searchRow/searchRow.json | 6 + .../mp-weixin/components/searchRow/searchRow.wxml | 1 + .../mp-weixin/components/searchRow/searchRow.wxss | 51 + unpackage/dist/dev/mp-weixin/config/api.js | 4 + unpackage/dist/dev/mp-weixin/config/site.config.js | 2 +- .../pages/subPage/authentication/authentication.js | 48 + .../subPage/authentication/authentication.json | 9 + .../subPage/authentication/authentication.wxml | 1 + .../subPage/authentication/authentication.wxss | 94 + .../pages/subPage/authentication/comp/select1.js | 37 + .../pages/subPage/authentication/comp/select1.json | 8 + .../pages/subPage/authentication/comp/select1.wxml | 1 + .../pages/subPage/authentication/comp/select1.wxss | 74 + .../pages/subPage/authentication/comp/select2.js | 35 + .../pages/subPage/authentication/comp/select2.json | 8 + .../pages/subPage/authentication/comp/select2.wxml | 1 + .../pages/subPage/authentication/comp/select2.wxss | 74 + .../pages/subPage/authentication/comp/select3.js | 35 + .../pages/subPage/authentication/comp/select3.json | 8 + .../pages/subPage/authentication/comp/select3.wxml | 1 + .../pages/subPage/authentication/comp/select3.wxss | 74 + .../dev/mp-weixin/pages/subPage/login/login.js | 209 +- .../dev/mp-weixin/pages/subPage/login/login.json | 3 +- .../dev/mp-weixin/pages/subPage/login/login.wxml | 2 +- .../dev/mp-weixin/pages/subPage/login/login.wxss | 55 +- .../dev/mp-weixin/pages/subPage/login/loginwx.js | 215 + .../dev/mp-weixin/pages/subPage/login/loginwx.json | 9 + .../dev/mp-weixin/pages/subPage/login/loginwx.wxml | 1 + .../dev/mp-weixin/pages/subPage/login/loginwx.wxss | 99 + .../dist/dev/mp-weixin/pages/tabbar/index/index.js | 86 +- .../dev/mp-weixin/pages/tabbar/index/index.json | 4 +- .../dev/mp-weixin/pages/tabbar/index/index.wxml | 2 +- .../dev/mp-weixin/pages/tabbar/index/index.wxss | 15 + unpackage/dist/dev/mp-weixin/project.config.json | 2 +- .../dist/dev/mp-weixin/project.private.config.json | 3 +- .../dist/dev/mp-weixin/static/images/pozicon.png | Bin 0 -> 2847 bytes .../dev/mp-weixin/static/images/searchIcon.png | Bin 0 -> 2563 bytes .../components/u-checkbox-group/props.js | 83 + .../u-checkbox-group/u-checkbox-group.js | 167 + .../u-checkbox-group/u-checkbox-group.json | 4 + .../u-checkbox-group/u-checkbox-group.wxml | 1 + .../u-checkbox-group/u-checkbox-group.wxss | 51 + .../uview-plus/components/u-checkbox/props.js | 78 + .../uview-plus/components/u-checkbox/u-checkbox.js | 311 + .../components/u-checkbox/u-checkbox.json | 6 + .../components/u-checkbox/u-checkbox.wxml | 1 + .../components/u-checkbox/u-checkbox.wxss | 105 + .../uview-plus/components/u-overlay/props.js | 28 + .../uview-plus/components/u-overlay/u-overlay.js | 146 + .../uview-plus/components/u-overlay/u-overlay.json | 6 + .../uview-plus/components/u-overlay/u-overlay.wxml | 1 + .../uview-plus/components/u-overlay/u-overlay.wxss | 49 + .../uview-plus/components/u-popup/props.js | 83 + .../uview-plus/components/u-popup/u-popup.js | 316 + .../uview-plus/components/u-popup/u-popup.json | 10 + .../uview-plus/components/u-popup/u-popup.wxml | 1 + .../uview-plus/components/u-popup/u-popup.wxss | 100 + .../uview-plus/components/u-safe-bottom/props.js | 12 + .../components/u-safe-bottom/u-safe-bottom.js | 43 + .../components/u-safe-bottom/u-safe-bottom.json | 4 + .../components/u-safe-bottom/u-safe-bottom.wxml | 1 + .../components/u-safe-bottom/u-safe-bottom.wxss | 28 + .../uview-plus/components/u-search/props.js | 136 + .../uview-plus/components/u-search/u-search.js | 260 + .../uview-plus/components/u-search/u-search.json | 6 + .../uview-plus/components/u-search/u-search.wxml | 1 + .../uview-plus/components/u-search/u-search.wxss | 115 + .../uview-plus/components/u-transition/props.js | 28 + .../components/u-transition/transition.js | 62 + .../components/u-transition/u-transition.js | 158 + .../components/u-transition/u-transition.json | 4 + .../components/u-transition/u-transition.wxml | 1 + .../components/u-transition/u-transition.wxss | 137 + .../dev/mp-weixin/uni_modules/uview-plus/index.js | 1 + .../uni_modules/uview-plus/libs/function/index.js | 1 + vite.config.js | 2 +- 412 files changed, 110818 insertions(+), 247 deletions(-) create mode 100644 components/searchRow/searchRow.vue create mode 100644 node_modules/.bin/vue-demi-fix create mode 100644 node_modules/.bin/vue-demi-fix.cmd create mode 100644 node_modules/.bin/vue-demi-fix.ps1 create mode 100644 node_modules/.bin/vue-demi-switch create mode 100644 node_modules/.bin/vue-demi-switch.cmd create mode 100644 node_modules/.bin/vue-demi-switch.ps1 create mode 100644 node_modules/@vue/devtools-api/lib/cjs/api/api.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/api/app.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/api/component.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/api/context.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/api/hooks.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/api/index.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/api/util.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/const.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/env.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/index.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/plugin.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/proxy.js create mode 100644 node_modules/@vue/devtools-api/lib/cjs/time.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/api.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/api.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/app.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/app.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/component.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/component.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/context.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/context.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/hooks.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/index.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/index.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/util.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/api/util.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/const.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/const.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/env.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/env.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/index.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/index.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/plugin.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/plugin.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/proxy.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/proxy.js create mode 100644 node_modules/@vue/devtools-api/lib/esm/time.d.ts create mode 100644 node_modules/@vue/devtools-api/lib/esm/time.js create mode 100644 node_modules/@vue/devtools-api/package.json create mode 100644 node_modules/pinia/LICENSE create mode 100644 node_modules/pinia/README.md create mode 100644 node_modules/pinia/dist/pinia.cjs create mode 100644 node_modules/pinia/dist/pinia.d.ts create mode 100644 node_modules/pinia/dist/pinia.esm-browser.js create mode 100644 node_modules/pinia/dist/pinia.iife.js create mode 100644 node_modules/pinia/dist/pinia.iife.prod.js create mode 100644 node_modules/pinia/dist/pinia.mjs create mode 100644 node_modules/pinia/dist/pinia.prod.cjs create mode 100644 node_modules/pinia/index.cjs create mode 100644 node_modules/pinia/index.js create mode 100644 node_modules/pinia/package.json create mode 100644 node_modules/vue-demi/LICENSE create mode 100644 node_modules/vue-demi/README.md create mode 100644 node_modules/vue-demi/bin/vue-demi-fix.js create mode 100644 node_modules/vue-demi/bin/vue-demi-switch.js create mode 100644 node_modules/vue-demi/lib/index.cjs create mode 100644 node_modules/vue-demi/lib/index.d.ts create mode 100644 node_modules/vue-demi/lib/index.iife.js create mode 100644 node_modules/vue-demi/lib/index.mjs create mode 100644 node_modules/vue-demi/lib/v2.7/index.cjs create mode 100644 node_modules/vue-demi/lib/v2.7/index.d.ts create mode 100644 node_modules/vue-demi/lib/v2.7/index.mjs create mode 100644 node_modules/vue-demi/lib/v2/index.cjs create mode 100644 node_modules/vue-demi/lib/v2/index.d.ts create mode 100644 node_modules/vue-demi/lib/v2/index.mjs create mode 100644 node_modules/vue-demi/lib/v3/index.cjs create mode 100644 node_modules/vue-demi/lib/v3/index.d.ts create mode 100644 node_modules/vue-demi/lib/v3/index.mjs create mode 100644 node_modules/vue-demi/package.json create mode 100644 node_modules/vue-demi/scripts/postinstall.js create mode 100644 node_modules/vue-demi/scripts/switch-cli.js create mode 100644 node_modules/vue-demi/scripts/utils.js create mode 100644 node_modules/vue/LICENSE create mode 100644 node_modules/vue/README.md create mode 100644 node_modules/vue/dist/README.md create mode 100644 node_modules/vue/dist/vue.common.dev.js create mode 100644 node_modules/vue/dist/vue.common.js create mode 100644 node_modules/vue/dist/vue.common.prod.js create mode 100644 node_modules/vue/dist/vue.esm.browser.js create mode 100644 node_modules/vue/dist/vue.esm.browser.min.js create mode 100644 node_modules/vue/dist/vue.esm.js create mode 100644 node_modules/vue/dist/vue.js create mode 100644 node_modules/vue/dist/vue.min.js create mode 100644 node_modules/vue/dist/vue.runtime.common.dev.js create mode 100644 node_modules/vue/dist/vue.runtime.common.js create mode 100644 node_modules/vue/dist/vue.runtime.common.prod.js create mode 100644 node_modules/vue/dist/vue.runtime.esm.js create mode 100644 node_modules/vue/dist/vue.runtime.js create mode 100644 node_modules/vue/dist/vue.runtime.min.js create mode 100644 node_modules/vue/package.json create mode 100644 node_modules/vue/src/compiler/codeframe.js create mode 100644 node_modules/vue/src/compiler/codegen/events.js create mode 100644 node_modules/vue/src/compiler/codegen/index.js create mode 100644 node_modules/vue/src/compiler/create-compiler.js create mode 100644 node_modules/vue/src/compiler/directives/bind.js create mode 100644 node_modules/vue/src/compiler/directives/index.js create mode 100644 node_modules/vue/src/compiler/directives/model.js create mode 100644 node_modules/vue/src/compiler/directives/on.js create mode 100644 node_modules/vue/src/compiler/error-detector.js create mode 100644 node_modules/vue/src/compiler/helpers.js create mode 100644 node_modules/vue/src/compiler/index.js create mode 100644 node_modules/vue/src/compiler/optimizer.js create mode 100644 node_modules/vue/src/compiler/parser/entity-decoder.js create mode 100644 node_modules/vue/src/compiler/parser/filter-parser.js create mode 100644 node_modules/vue/src/compiler/parser/html-parser.js create mode 100644 node_modules/vue/src/compiler/parser/index.js create mode 100644 node_modules/vue/src/compiler/parser/text-parser.js create mode 100644 node_modules/vue/src/compiler/to-function.js create mode 100644 node_modules/vue/src/core/components/index.js create mode 100644 node_modules/vue/src/core/components/keep-alive.js create mode 100644 node_modules/vue/src/core/config.js create mode 100644 node_modules/vue/src/core/global-api/assets.js create mode 100644 node_modules/vue/src/core/global-api/extend.js create mode 100644 node_modules/vue/src/core/global-api/index.js create mode 100644 node_modules/vue/src/core/global-api/mixin.js create mode 100644 node_modules/vue/src/core/global-api/use.js create mode 100644 node_modules/vue/src/core/index.js create mode 100644 node_modules/vue/src/core/instance/events.js create mode 100644 node_modules/vue/src/core/instance/index.js create mode 100644 node_modules/vue/src/core/instance/init.js create mode 100644 node_modules/vue/src/core/instance/inject.js create mode 100644 node_modules/vue/src/core/instance/lifecycle.js create mode 100644 node_modules/vue/src/core/instance/proxy.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/bind-dynamic-keys.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/bind-object-listeners.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/bind-object-props.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/check-keycodes.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/index.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/render-list.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/render-slot.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/render-static.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/resolve-filter.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/resolve-scoped-slots.js create mode 100644 node_modules/vue/src/core/instance/render-helpers/resolve-slots.js create mode 100644 node_modules/vue/src/core/instance/render.js create mode 100644 node_modules/vue/src/core/instance/state.js create mode 100644 node_modules/vue/src/core/observer/array.js create mode 100644 node_modules/vue/src/core/observer/dep.js create mode 100644 node_modules/vue/src/core/observer/index.js create mode 100644 node_modules/vue/src/core/observer/scheduler.js create mode 100644 node_modules/vue/src/core/observer/traverse.js create mode 100644 node_modules/vue/src/core/observer/watcher.js create mode 100644 node_modules/vue/src/core/util/debug.js create mode 100644 node_modules/vue/src/core/util/env.js create mode 100644 node_modules/vue/src/core/util/error.js create mode 100644 node_modules/vue/src/core/util/index.js create mode 100644 node_modules/vue/src/core/util/lang.js create mode 100644 node_modules/vue/src/core/util/next-tick.js create mode 100644 node_modules/vue/src/core/util/options.js create mode 100644 node_modules/vue/src/core/util/perf.js create mode 100644 node_modules/vue/src/core/util/props.js create mode 100644 node_modules/vue/src/core/vdom/create-component.js create mode 100644 node_modules/vue/src/core/vdom/create-element.js create mode 100644 node_modules/vue/src/core/vdom/create-functional-component.js create mode 100644 node_modules/vue/src/core/vdom/helpers/extract-props.js create mode 100644 node_modules/vue/src/core/vdom/helpers/get-first-component-child.js create mode 100644 node_modules/vue/src/core/vdom/helpers/index.js create mode 100644 node_modules/vue/src/core/vdom/helpers/is-async-placeholder.js create mode 100644 node_modules/vue/src/core/vdom/helpers/merge-hook.js create mode 100644 node_modules/vue/src/core/vdom/helpers/normalize-children.js create mode 100644 node_modules/vue/src/core/vdom/helpers/normalize-scoped-slots.js create mode 100644 node_modules/vue/src/core/vdom/helpers/resolve-async-component.js create mode 100644 node_modules/vue/src/core/vdom/helpers/update-listeners.js create mode 100644 node_modules/vue/src/core/vdom/modules/directives.js create mode 100644 node_modules/vue/src/core/vdom/modules/index.js create mode 100644 node_modules/vue/src/core/vdom/modules/ref.js create mode 100644 node_modules/vue/src/core/vdom/patch.js create mode 100644 node_modules/vue/src/core/vdom/vnode.js create mode 100644 node_modules/vue/src/platforms/web/compiler/directives/html.js create mode 100644 node_modules/vue/src/platforms/web/compiler/directives/index.js create mode 100644 node_modules/vue/src/platforms/web/compiler/directives/model.js create mode 100644 node_modules/vue/src/platforms/web/compiler/directives/text.js create mode 100644 node_modules/vue/src/platforms/web/compiler/index.js create mode 100644 node_modules/vue/src/platforms/web/compiler/modules/class.js create mode 100644 node_modules/vue/src/platforms/web/compiler/modules/index.js create mode 100644 node_modules/vue/src/platforms/web/compiler/modules/model.js create mode 100644 node_modules/vue/src/platforms/web/compiler/modules/style.js create mode 100644 node_modules/vue/src/platforms/web/compiler/options.js create mode 100644 node_modules/vue/src/platforms/web/compiler/util.js create mode 100644 node_modules/vue/src/platforms/web/entry-compiler.js create mode 100644 node_modules/vue/src/platforms/web/entry-runtime-with-compiler.js create mode 100644 node_modules/vue/src/platforms/web/entry-runtime.js create mode 100644 node_modules/vue/src/platforms/web/entry-server-basic-renderer.js create mode 100644 node_modules/vue/src/platforms/web/entry-server-renderer.js create mode 100644 node_modules/vue/src/platforms/web/runtime/class-util.js create mode 100644 node_modules/vue/src/platforms/web/runtime/components/index.js create mode 100644 node_modules/vue/src/platforms/web/runtime/components/transition-group.js create mode 100644 node_modules/vue/src/platforms/web/runtime/components/transition.js create mode 100644 node_modules/vue/src/platforms/web/runtime/directives/index.js create mode 100644 node_modules/vue/src/platforms/web/runtime/directives/model.js create mode 100644 node_modules/vue/src/platforms/web/runtime/directives/show.js create mode 100644 node_modules/vue/src/platforms/web/runtime/index.js create mode 100644 node_modules/vue/src/platforms/web/runtime/modules/attrs.js create mode 100644 node_modules/vue/src/platforms/web/runtime/modules/class.js create mode 100644 node_modules/vue/src/platforms/web/runtime/modules/dom-props.js create mode 100644 node_modules/vue/src/platforms/web/runtime/modules/events.js create mode 100644 node_modules/vue/src/platforms/web/runtime/modules/index.js create mode 100644 node_modules/vue/src/platforms/web/runtime/modules/style.js create mode 100644 node_modules/vue/src/platforms/web/runtime/modules/transition.js create mode 100644 node_modules/vue/src/platforms/web/runtime/node-ops.js create mode 100644 node_modules/vue/src/platforms/web/runtime/patch.js create mode 100644 node_modules/vue/src/platforms/web/runtime/transition-util.js create mode 100644 node_modules/vue/src/platforms/web/server/compiler.js create mode 100644 node_modules/vue/src/platforms/web/server/directives/index.js create mode 100644 node_modules/vue/src/platforms/web/server/directives/model.js create mode 100644 node_modules/vue/src/platforms/web/server/directives/show.js create mode 100644 node_modules/vue/src/platforms/web/server/modules/attrs.js create mode 100644 node_modules/vue/src/platforms/web/server/modules/class.js create mode 100644 node_modules/vue/src/platforms/web/server/modules/dom-props.js create mode 100644 node_modules/vue/src/platforms/web/server/modules/index.js create mode 100644 node_modules/vue/src/platforms/web/server/modules/style.js create mode 100644 node_modules/vue/src/platforms/web/server/util.js create mode 100644 node_modules/vue/src/platforms/web/util/attrs.js create mode 100644 node_modules/vue/src/platforms/web/util/class.js create mode 100644 node_modules/vue/src/platforms/web/util/compat.js create mode 100644 node_modules/vue/src/platforms/web/util/element.js create mode 100644 node_modules/vue/src/platforms/web/util/index.js create mode 100644 node_modules/vue/src/platforms/web/util/style.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/directives/index.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/directives/model.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/index.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/append.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/class.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/index.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/props.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/component-root.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/component.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/index.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/recycle-list.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/text.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/v-bind.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/v-for.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/v-if.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/v-on.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/recycle-list/v-once.js create mode 100644 node_modules/vue/src/platforms/weex/compiler/modules/style.js create mode 100644 node_modules/vue/src/platforms/weex/entry-compiler.js create mode 100644 node_modules/vue/src/platforms/weex/entry-framework.js create mode 100644 node_modules/vue/src/platforms/weex/entry-runtime-factory.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/components/index.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/components/richtext.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/components/transition-group.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/components/transition.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/directives/index.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/index.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/modules/attrs.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/modules/class.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/modules/events.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/modules/index.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/modules/style.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/modules/transition.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/node-ops.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/patch.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/recycle-list/render-component-template.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/recycle-list/virtual-component.js create mode 100644 node_modules/vue/src/platforms/weex/runtime/text-node.js create mode 100644 node_modules/vue/src/platforms/weex/util/element.js create mode 100644 node_modules/vue/src/platforms/weex/util/index.js create mode 100644 node_modules/vue/src/platforms/weex/util/parser.js create mode 100644 node_modules/vue/src/server/bundle-renderer/create-bundle-renderer.js create mode 100644 node_modules/vue/src/server/bundle-renderer/create-bundle-runner.js create mode 100644 node_modules/vue/src/server/bundle-renderer/source-map-support.js create mode 100644 node_modules/vue/src/server/create-basic-renderer.js create mode 100644 node_modules/vue/src/server/create-renderer.js create mode 100644 node_modules/vue/src/server/optimizing-compiler/codegen.js create mode 100644 node_modules/vue/src/server/optimizing-compiler/index.js create mode 100644 node_modules/vue/src/server/optimizing-compiler/modules.js create mode 100644 node_modules/vue/src/server/optimizing-compiler/optimizer.js create mode 100644 node_modules/vue/src/server/optimizing-compiler/runtime-helpers.js create mode 100644 node_modules/vue/src/server/render-context.js create mode 100644 node_modules/vue/src/server/render-stream.js create mode 100644 node_modules/vue/src/server/render.js create mode 100644 node_modules/vue/src/server/template-renderer/create-async-file-mapper.js create mode 100644 node_modules/vue/src/server/template-renderer/index.js create mode 100644 node_modules/vue/src/server/template-renderer/parse-template.js create mode 100644 node_modules/vue/src/server/template-renderer/template-stream.js create mode 100644 node_modules/vue/src/server/util.js create mode 100644 node_modules/vue/src/server/webpack-plugin/client.js create mode 100644 node_modules/vue/src/server/webpack-plugin/server.js create mode 100644 node_modules/vue/src/server/webpack-plugin/util.js create mode 100644 node_modules/vue/src/server/write.js create mode 100644 node_modules/vue/src/sfc/parser.js create mode 100644 node_modules/vue/src/shared/constants.js create mode 100644 node_modules/vue/src/shared/util.js create mode 100644 node_modules/vue/types/index.d.ts create mode 100644 node_modules/vue/types/options.d.ts create mode 100644 node_modules/vue/types/plugin.d.ts create mode 100644 node_modules/vue/types/umd.d.ts create mode 100644 node_modules/vue/types/vnode.d.ts create mode 100644 node_modules/vue/types/vue.d.ts create mode 100644 pages/subPage/authentication/authentication.vue create mode 100644 pages/subPage/authentication/comp/select1.vue create mode 100644 pages/subPage/authentication/comp/select2.vue create mode 100644 pages/subPage/authentication/comp/select3.vue create mode 100644 pages/subPage/authentication/selectAddress.vue create mode 100644 pages/subPage/login/loginbyPhone.vue create mode 100644 pages/subPage/login/loginwx.vue create mode 100644 pages/subPage/privacyAgreement/privacyAgreement.vue create mode 100644 static/images/pozicon.png create mode 100644 static/images/searchIcon.png create mode 100644 store/index.js create mode 100644 unpackage/dist/dev/mp-weixin/components/oneBtn/oneBtn.js create mode 100644 unpackage/dist/dev/mp-weixin/components/oneBtn/oneBtn.json create mode 100644 unpackage/dist/dev/mp-weixin/components/oneBtn/oneBtn.wxml create mode 100644 unpackage/dist/dev/mp-weixin/components/oneBtn/oneBtn.wxss create mode 100644 unpackage/dist/dev/mp-weixin/components/privacyRadion/privacyRadion.js create mode 100644 unpackage/dist/dev/mp-weixin/components/privacyRadion/privacyRadion.json create mode 100644 unpackage/dist/dev/mp-weixin/components/privacyRadion/privacyRadion.wxml create mode 100644 unpackage/dist/dev/mp-weixin/components/privacyRadion/privacyRadion.wxss create mode 100644 unpackage/dist/dev/mp-weixin/components/searchRow/searchRow.js create mode 100644 unpackage/dist/dev/mp-weixin/components/searchRow/searchRow.json create mode 100644 unpackage/dist/dev/mp-weixin/components/searchRow/searchRow.wxml create mode 100644 unpackage/dist/dev/mp-weixin/components/searchRow/searchRow.wxss create mode 100644 unpackage/dist/dev/mp-weixin/config/api.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/authentication.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/authentication.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/authentication.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/authentication.wxss create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select1.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select1.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select1.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select1.wxss create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select2.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select2.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select2.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select2.wxss create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select3.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select3.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select3.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/authentication/comp/select3.wxss create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/login/loginwx.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/login/loginwx.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/login/loginwx.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/subPage/login/loginwx.wxss create mode 100644 unpackage/dist/dev/mp-weixin/static/images/pozicon.png create mode 100644 unpackage/dist/dev/mp-weixin/static/images/searchIcon.png create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox-group/props.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox-group/u-checkbox-group.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox-group/u-checkbox-group.json create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox-group/u-checkbox-group.wxml create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox-group/u-checkbox-group.wxss create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox/props.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox/u-checkbox.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox/u-checkbox.json create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox/u-checkbox.wxml create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-checkbox/u-checkbox.wxss create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-overlay/props.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-overlay/u-overlay.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-overlay/u-overlay.json create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-overlay/u-overlay.wxml create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-overlay/u-overlay.wxss create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-popup/props.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-popup/u-popup.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-popup/u-popup.json create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-popup/u-popup.wxml create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-popup/u-popup.wxss create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-safe-bottom/props.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.json create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.wxml create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.wxss create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-search/props.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-search/u-search.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-search/u-search.json create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-search/u-search.wxml create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-search/u-search.wxss create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-transition/props.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-transition/transition.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-transition/u-transition.js create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-transition/u-transition.json create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-transition/u-transition.wxml create mode 100644 unpackage/dist/dev/mp-weixin/uni_modules/uview-plus/components/u-transition/u-transition.wxss diff --git a/components/oneBtn/oneBtn.vue b/components/oneBtn/oneBtn.vue index 3731cc8..8abee8b 100644 --- a/components/oneBtn/oneBtn.vue +++ b/components/oneBtn/oneBtn.vue @@ -1,10 +1,15 @@ @@ -18,5 +23,8 @@ line-height: 80rpx; font-size: 28rpx; color: #fff; + &.hui { + opacity: 0.4; + } } \ No newline at end of file diff --git a/components/privacyRadion/privacyRadion.vue b/components/privacyRadion/privacyRadion.vue index 698e015..1df393a 100644 --- a/components/privacyRadion/privacyRadion.vue +++ b/components/privacyRadion/privacyRadion.vue @@ -18,7 +18,7 @@ this.$emit('changeRadio', val) }, async goPage(type) { - this.$goPage('/pages/userCenter/login/privacyAgreement/privacyAgreement?type='+ type) + this.$goPage('/pages/subPage/privacyAgreement/privacyAgreement?type='+ type) } } diff --git a/components/searchRow/searchRow.vue b/components/searchRow/searchRow.vue new file mode 100644 index 0000000..a2f89d9 --- /dev/null +++ b/components/searchRow/searchRow.vue @@ -0,0 +1,67 @@ + + + + + + diff --git a/config/api.js b/config/api.js index 154d9a2..6299ab2 100644 --- a/config/api.js +++ b/config/api.js @@ -3,20 +3,35 @@ import { http } from '@/uni_modules/uview-plus' +// 登录发验证码 +export const getLoginCode = (data) => http.post('member/auth/send-sms-code', data, { custom: { noToken: true, catch: true,}}) // 微信小程序的一键登录 -export const weixinLogin = (data) => http.post('member/auth/weixin-mini-app-login', data) +export const weixinLogin = (data) => http.post('member/auth/wx_login', data) // 验证码登录 export const loginSMS = (data) => http.post('member/auth/sms-login', data, { custom: { noToken: true }}) -// 登录发验证码 -export const getLoginCode = (data) => http.post('member/auth/send-sms-code', data, { custom: { noToken: true, catch: true,}}) +// 用户协议和隐私协议 +export const getAgreement = (params={}) => http.get('app/student-record/getAgreement', {params}) // 获取个人信息 export const getUserInfo = (data) => http.post('member/user/get', {header: {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}}) // 退出登录 export const logOut = (data={}) => http.post('member/auth/logout', data, {custom: {catch: true, toast: false }}) -// 驾校列表分页 -export const schoolPage = (params) => http.get('business/school/page', {params: params}) - // 新增的接口 - export const getBannerList = (params={}) => http.get('business/video/getBannerList', {params}) + + // 文章列表 + export const getNoticeList = (data) => http.post('article/simple_list', data) + // 首页文章详情 + export const getNoticeDetail = (data) => http.post('article/article_detail', data) + // 我的房子信息 + export const getHouses = (data) => http.post('mime/houses', data) + // 投票列表 + export const votePage = (data) => http.post('article/vote_page', data) + // 我参与的投票 + export const mineVotePage = (data) => http.post('article/mine_vote_page', data) + // 小区下拉选信息 + export const houseTree = (data) => http.post('house/tree', data) + // 根据房间号搜索房子 + export const houseRoom = (data) => http.post('house/room_search', data) + // 绑定房子 + export const houseRoomBind = (data) => http.post('house/bind_room', data) diff --git a/config/site.config.js b/config/site.config.js index 80a5f09..9843267 100644 --- a/config/site.config.js +++ b/config/site.config.js @@ -2,7 +2,7 @@ const VUE_APP_PLATFORM = process.env.VUE_APP_PLATFORM || 'h5'; // localIp = false let obj = { H5_API: VUE_APP_PLATFORM === 'h5' ? '/api' : '',//h5代理 - WX_API: VUE_APP_PLATFORM === 'h5' ? '/' : 'http://www.lyjppt.com/',//非代理地址 不要忘记加/ + WX_API: VUE_APP_PLATFORM === 'h5' ? '/' : 'http://192.168.1.106:8518/',//非代理地址 不要忘记加/ website: 'http://192.168.1.37', httpPrefix: 'app-api/', imgUrl: 'https://jiangxijiakao-1.oss-cn-hangzhou.aliyuncs.com/defaultImages/app/bigImg/', diff --git a/main.js b/main.js index af5046e..a902930 100644 --- a/main.js +++ b/main.js @@ -2,6 +2,7 @@ import App from './App' import uviewPlus from '@/uni_modules/uview-plus' import request from './config/request.js' import { goPage } from '@/utils/utils.js' +import { createPinia } from 'pinia'; // // #ifndef VUE3 // import Vue from 'vue' // import './uni.promisify.adaptor' @@ -18,6 +19,8 @@ import { createSSRApp } from 'vue' export function createApp() { const app = createSSRApp(App) app.config.globalProperties.$goPage = goPage + const pinia = createPinia(); + app.use(pinia); app.use(uviewPlus) request(app) return { diff --git a/manifest.json b/manifest.json index 7384621..6191cc5 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "name" : "questionbankvue3", + "name" : "新疆小程序", "appid" : "__UNI__445D057", "description" : "", "versionName" : "1.0.0", diff --git a/node_modules/.bin/vue-demi-fix b/node_modules/.bin/vue-demi-fix new file mode 100644 index 0000000..dba2771 --- /dev/null +++ b/node_modules/.bin/vue-demi-fix @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../vue-demi/bin/vue-demi-fix.js" "$@" +else + exec node "$basedir/../vue-demi/bin/vue-demi-fix.js" "$@" +fi diff --git a/node_modules/.bin/vue-demi-fix.cmd b/node_modules/.bin/vue-demi-fix.cmd new file mode 100644 index 0000000..cb05986 --- /dev/null +++ b/node_modules/.bin/vue-demi-fix.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\vue-demi\bin\vue-demi-fix.js" %* diff --git a/node_modules/.bin/vue-demi-fix.ps1 b/node_modules/.bin/vue-demi-fix.ps1 new file mode 100644 index 0000000..adecc34 --- /dev/null +++ b/node_modules/.bin/vue-demi-fix.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../vue-demi/bin/vue-demi-fix.js" $args + } else { + & "$basedir/node$exe" "$basedir/../vue-demi/bin/vue-demi-fix.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../vue-demi/bin/vue-demi-fix.js" $args + } else { + & "node$exe" "$basedir/../vue-demi/bin/vue-demi-fix.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.bin/vue-demi-switch b/node_modules/.bin/vue-demi-switch new file mode 100644 index 0000000..458c052 --- /dev/null +++ b/node_modules/.bin/vue-demi-switch @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../vue-demi/bin/vue-demi-switch.js" "$@" +else + exec node "$basedir/../vue-demi/bin/vue-demi-switch.js" "$@" +fi diff --git a/node_modules/.bin/vue-demi-switch.cmd b/node_modules/.bin/vue-demi-switch.cmd new file mode 100644 index 0000000..a685a41 --- /dev/null +++ b/node_modules/.bin/vue-demi-switch.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\vue-demi\bin\vue-demi-switch.js" %* diff --git a/node_modules/.bin/vue-demi-switch.ps1 b/node_modules/.bin/vue-demi-switch.ps1 new file mode 100644 index 0000000..fbb4d69 --- /dev/null +++ b/node_modules/.bin/vue-demi-switch.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../vue-demi/bin/vue-demi-switch.js" $args + } else { + & "$basedir/node$exe" "$basedir/../vue-demi/bin/vue-demi-switch.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../vue-demi/bin/vue-demi-switch.js" $args + } else { + & "node$exe" "$basedir/../vue-demi/bin/vue-demi-switch.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index a9678ff..8c4e2dd 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -4,10 +4,72 @@ "lockfileVersion": 3, "requires": true, "packages": { + "node_modules/@vue/devtools-api": { + "version": "6.6.3", + "resolved": "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.6.3.tgz", + "integrity": "sha512-0MiMsFma/HqA6g3KLKn+AGpL1kgKhFWszC9U29NfpWK5LE7bjeXxySWJrOJ77hBz+TBrBQ7o4QJqbPbqbs8rJw==" + }, "node_modules/js-md5": { "version": "0.8.3", "resolved": "https://registry.npmmirror.com/js-md5/-/js-md5-0.8.3.tgz", "integrity": "sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ==" + }, + "node_modules/pinia": { + "version": "2.1.7", + "resolved": "https://registry.npmmirror.com/pinia/-/pinia-2.1.7.tgz", + "integrity": "sha512-+C2AHFtcFqjPih0zpYuvof37SFxMQ7OEG2zV9jRI12i9BOy3YQVAHwdKtyyc8pDcDyIc33WCIsZaCFWU7WWxGQ==", + "dependencies": { + "@vue/devtools-api": "^6.5.0", + "vue-demi": ">=0.14.5" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "@vue/composition-api": "^1.4.0", + "typescript": ">=4.4.4", + "vue": "^2.6.14 || ^3.3.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/vue": { + "version": "2.6.14", + "resolved": "https://registry.npmmirror.com/vue/-/vue-2.6.14.tgz", + "integrity": "sha512-x2284lgYvjOMj3Za7kqzRcUSxBboHqtgRE2zlos1qWaOye5yUmHn42LB1250NJBLRwEcdrB0JRwyPTEPhfQjiQ==", + "deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.", + "peer": true + }, + "node_modules/vue-demi": { + "version": "0.14.8", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.8.tgz", + "integrity": "sha512-Uuqnk9YE9SsWeReYqK2alDI5YzciATE0r2SkA6iMAtuXvNTMNACJLJEXNXaEy94ECuBe4Sk6RzRU80kjdbIo1Q==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } } } } diff --git a/node_modules/.vite/deps/_metadata.json b/node_modules/.vite/deps/_metadata.json index ce529fa..8b7c04c 100644 --- a/node_modules/.vite/deps/_metadata.json +++ b/node_modules/.vite/deps/_metadata.json @@ -1,11 +1,11 @@ { - "hash": "f7c57611", - "browserHash": "7882e4a1", + "hash": "10f743c3", + "browserHash": "1f78e4e6", "optimized": { "js-md5": { "src": "../../js-md5/src/md5.js", "file": "js-md5.js", - "fileHash": "53a1b02e", + "fileHash": "8ec30bef", "needsInterop": true } }, diff --git a/node_modules/@vue/devtools-api/lib/cjs/api/api.js b/node_modules/@vue/devtools-api/lib/cjs/api/api.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/api/api.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@vue/devtools-api/lib/cjs/api/app.js b/node_modules/@vue/devtools-api/lib/cjs/api/app.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/api/app.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@vue/devtools-api/lib/cjs/api/component.js b/node_modules/@vue/devtools-api/lib/cjs/api/component.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/api/component.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@vue/devtools-api/lib/cjs/api/context.js b/node_modules/@vue/devtools-api/lib/cjs/api/context.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/api/context.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js b/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/api/hooks.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@vue/devtools-api/lib/cjs/api/index.js b/node_modules/@vue/devtools-api/lib/cjs/api/index.js new file mode 100644 index 0000000..22f7589 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/api/index.js @@ -0,0 +1,22 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./api.js"), exports); +__exportStar(require("./app.js"), exports); +__exportStar(require("./component.js"), exports); +__exportStar(require("./context.js"), exports); +__exportStar(require("./hooks.js"), exports); +__exportStar(require("./util.js"), exports); diff --git a/node_modules/@vue/devtools-api/lib/cjs/api/util.js b/node_modules/@vue/devtools-api/lib/cjs/api/util.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/api/util.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@vue/devtools-api/lib/cjs/const.js b/node_modules/@vue/devtools-api/lib/cjs/const.js new file mode 100644 index 0000000..84d408c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/const.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HOOK_PLUGIN_SETTINGS_SET = exports.HOOK_SETUP = void 0; +exports.HOOK_SETUP = 'devtools-plugin:setup'; +exports.HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set'; diff --git a/node_modules/@vue/devtools-api/lib/cjs/env.js b/node_modules/@vue/devtools-api/lib/cjs/env.js new file mode 100644 index 0000000..e6c7ebd --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/env.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isProxyAvailable = exports.getTarget = exports.getDevtoolsGlobalHook = void 0; +function getDevtoolsGlobalHook() { + return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__; +} +exports.getDevtoolsGlobalHook = getDevtoolsGlobalHook; +function getTarget() { + // @ts-expect-error navigator and windows are not available in all environments + return (typeof navigator !== 'undefined' && typeof window !== 'undefined') + ? window + : typeof globalThis !== 'undefined' + ? globalThis + : {}; +} +exports.getTarget = getTarget; +exports.isProxyAvailable = typeof Proxy === 'function'; diff --git a/node_modules/@vue/devtools-api/lib/cjs/index.js b/node_modules/@vue/devtools-api/lib/cjs/index.js new file mode 100644 index 0000000..f8b5fc3 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/index.js @@ -0,0 +1,45 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.setupDevtoolsPlugin = void 0; +const env_js_1 = require("./env.js"); +const const_js_1 = require("./const.js"); +const proxy_js_1 = require("./proxy.js"); +__exportStar(require("./api/index.js"), exports); +__exportStar(require("./plugin.js"), exports); +__exportStar(require("./time.js"), exports); +function setupDevtoolsPlugin(pluginDescriptor, setupFn) { + const descriptor = pluginDescriptor; + const target = (0, env_js_1.getTarget)(); + const hook = (0, env_js_1.getDevtoolsGlobalHook)(); + const enableProxy = env_js_1.isProxyAvailable && descriptor.enableEarlyProxy; + if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) { + hook.emit(const_js_1.HOOK_SETUP, pluginDescriptor, setupFn); + } + else { + const proxy = enableProxy ? new proxy_js_1.ApiProxy(descriptor, hook) : null; + const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []; + list.push({ + pluginDescriptor: descriptor, + setupFn, + proxy, + }); + if (proxy) { + setupFn(proxy.proxiedTarget); + } + } +} +exports.setupDevtoolsPlugin = setupDevtoolsPlugin; diff --git a/node_modules/@vue/devtools-api/lib/cjs/plugin.js b/node_modules/@vue/devtools-api/lib/cjs/plugin.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/plugin.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@vue/devtools-api/lib/cjs/proxy.js b/node_modules/@vue/devtools-api/lib/cjs/proxy.js new file mode 100644 index 0000000..731c9ac --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/proxy.js @@ -0,0 +1,111 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ApiProxy = void 0; +const const_js_1 = require("./const.js"); +const time_js_1 = require("./time.js"); +class ApiProxy { + constructor(plugin, hook) { + this.target = null; + this.targetQueue = []; + this.onQueue = []; + this.plugin = plugin; + this.hook = hook; + const defaultSettings = {}; + if (plugin.settings) { + for (const id in plugin.settings) { + const item = plugin.settings[id]; + defaultSettings[id] = item.defaultValue; + } + } + const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`; + let currentSettings = Object.assign({}, defaultSettings); + try { + const raw = localStorage.getItem(localSettingsSaveId); + const data = JSON.parse(raw); + Object.assign(currentSettings, data); + } + catch (e) { + // noop + } + this.fallbacks = { + getSettings() { + return currentSettings; + }, + setSettings(value) { + try { + localStorage.setItem(localSettingsSaveId, JSON.stringify(value)); + } + catch (e) { + // noop + } + currentSettings = value; + }, + now() { + return (0, time_js_1.now)(); + }, + }; + if (hook) { + hook.on(const_js_1.HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => { + if (pluginId === this.plugin.id) { + this.fallbacks.setSettings(value); + } + }); + } + this.proxiedOn = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target.on[prop]; + } + else { + return (...args) => { + this.onQueue.push({ + method: prop, + args, + }); + }; + } + }, + }); + this.proxiedTarget = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target[prop]; + } + else if (prop === 'on') { + return this.proxiedOn; + } + else if (Object.keys(this.fallbacks).includes(prop)) { + return (...args) => { + this.targetQueue.push({ + method: prop, + args, + resolve: () => { }, + }); + return this.fallbacks[prop](...args); + }; + } + else { + return (...args) => { + return new Promise((resolve) => { + this.targetQueue.push({ + method: prop, + args, + resolve, + }); + }); + }; + } + }, + }); + } + async setRealTarget(target) { + this.target = target; + for (const item of this.onQueue) { + this.target.on[item.method](...item.args); + } + for (const item of this.targetQueue) { + item.resolve(await this.target[item.method](...item.args)); + } + } +} +exports.ApiProxy = ApiProxy; diff --git a/node_modules/@vue/devtools-api/lib/cjs/time.js b/node_modules/@vue/devtools-api/lib/cjs/time.js new file mode 100644 index 0000000..78d7f67 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/cjs/time.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.now = exports.isPerformanceSupported = void 0; +let supported; +let perf; +function isPerformanceSupported() { + var _a; + if (supported !== undefined) { + return supported; + } + if (typeof window !== 'undefined' && window.performance) { + supported = true; + perf = window.performance; + } + else if (typeof globalThis !== 'undefined' && ((_a = globalThis.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) { + supported = true; + perf = globalThis.perf_hooks.performance; + } + else { + supported = false; + } + return supported; +} +exports.isPerformanceSupported = isPerformanceSupported; +function now() { + return isPerformanceSupported() ? perf.now() : Date.now(); +} +exports.now = now; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/api.d.ts b/node_modules/@vue/devtools-api/lib/esm/api/api.d.ts new file mode 100644 index 0000000..2e5494c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/api.d.ts @@ -0,0 +1,108 @@ +import type { ComponentBounds, Hookable } from './hooks.js'; +import type { Context } from './context.js'; +import type { ComponentInstance, ComponentState, StateBase } from './component.js'; +import type { App } from './app.js'; +import type { ID } from './util.js'; +export interface DevtoolsPluginApi { + on: Hookable; + notifyComponentUpdate: (instance?: ComponentInstance) => void; + addTimelineLayer: (options: TimelineLayerOptions) => void; + addTimelineEvent: (options: TimelineEventOptions) => void; + addInspector: (options: CustomInspectorOptions) => void; + sendInspectorTree: (inspectorId: string) => void; + sendInspectorState: (inspectorId: string) => void; + selectInspectorNode: (inspectorId: string, nodeId: string) => void; + getComponentBounds: (instance: ComponentInstance) => Promise; + getComponentName: (instance: ComponentInstance) => Promise; + getComponentInstances: (app: App) => Promise; + highlightElement: (instance: ComponentInstance) => void; + unhighlightElement: () => void; + getSettings: (pluginId?: string) => TSettings; + now: () => number; + /** + * @private + */ + setSettings: (values: TSettings) => void; +} +export interface AppRecord { + id: string; + name: string; + instanceMap: Map; + rootInstance: ComponentInstance; +} +export interface TimelineLayerOptions { + id: string; + label: string; + color: number; + skipScreenshots?: boolean; + groupsOnly?: boolean; + ignoreNoDurationGroups?: boolean; + screenshotOverlayRender?: (event: TimelineEvent & ScreenshotOverlayEvent, ctx: ScreenshotOverlayRenderContext) => ScreenshotOverlayRenderResult | Promise; +} +export interface ScreenshotOverlayEvent { + layerId: string; + renderMeta: any; +} +export interface ScreenshotOverlayRenderContext { + screenshot: ScreenshotData; + events: (TimelineEvent & ScreenshotOverlayEvent)[]; + index: number; +} +export type ScreenshotOverlayRenderResult = HTMLElement | string | false; +export interface ScreenshotData { + time: number; +} +export interface TimelineEventOptions { + layerId: string; + event: TimelineEvent; + all?: boolean; +} +export interface TimelineEvent { + time: number; + data: TData; + logType?: 'default' | 'warning' | 'error'; + meta?: TMeta; + groupId?: ID; + title?: string; + subtitle?: string; +} +export interface TimelineMarkerOptions { + id: string; + time: number; + color: number; + label: string; + all?: boolean; +} +export interface CustomInspectorOptions { + id: string; + label: string; + icon?: string; + treeFilterPlaceholder?: string; + stateFilterPlaceholder?: string; + noSelectionText?: string; + actions?: { + icon: string; + tooltip?: string; + action: () => void | Promise; + }[]; + nodeActions?: { + icon: string; + tooltip?: string; + action: (nodeId: string) => void | Promise; + }[]; +} +export interface CustomInspectorNode { + id: string; + label: string; + children?: CustomInspectorNode[]; + tags?: InspectorNodeTag[]; +} +export interface InspectorNodeTag { + label: string; + textColor: number; + backgroundColor: number; + tooltip?: string; +} +export interface CustomInspectorState { + [key: string]: (StateBase | Omit)[]; +} diff --git a/node_modules/@vue/devtools-api/lib/esm/api/api.js b/node_modules/@vue/devtools-api/lib/esm/api/api.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/api.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/app.d.ts b/node_modules/@vue/devtools-api/lib/esm/api/app.d.ts new file mode 100644 index 0000000..a10f02f --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/app.d.ts @@ -0,0 +1 @@ +export type App = any; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/app.js b/node_modules/@vue/devtools-api/lib/esm/api/app.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/app.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/component.d.ts b/node_modules/@vue/devtools-api/lib/esm/api/component.d.ts new file mode 100644 index 0000000..84fcba7 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/component.d.ts @@ -0,0 +1,78 @@ +import type { InspectorNodeTag } from './api.js'; +import type { ID } from './util.js'; +export type ComponentInstance = any; +export interface ComponentTreeNode { + uid: ID; + id: string; + name: string; + renderKey: string | number; + inactive: boolean; + isFragment: boolean; + hasChildren: boolean; + children: ComponentTreeNode[]; + domOrder?: number[]; + consoleId?: string; + isRouterView?: boolean; + macthedRouteSegment?: string; + tags: InspectorNodeTag[]; + autoOpen: boolean; + meta?: any; +} +export interface InspectedComponentData { + id: string; + name: string; + file: string; + state: ComponentState[]; + functional?: boolean; +} +export interface StateBase { + key: string; + value: any; + editable?: boolean; + objectType?: 'ref' | 'reactive' | 'computed' | 'other'; + raw?: string; +} +export interface ComponentStateBase extends StateBase { + type: string; +} +export interface ComponentPropState extends ComponentStateBase { + meta?: { + type: string; + required: boolean; + /** Vue 1 only */ + mode?: 'default' | 'sync' | 'once'; + }; +} +export type ComponentBuiltinCustomStateTypes = 'function' | 'map' | 'set' | 'reference' | 'component' | 'component-definition' | 'router' | 'store'; +export interface ComponentCustomState extends ComponentStateBase { + value: CustomState; +} +export interface CustomState { + _custom: { + type: ComponentBuiltinCustomStateTypes | string; + objectType?: string; + display?: string; + tooltip?: string; + value?: any; + abstract?: boolean; + file?: string; + uid?: number; + readOnly?: boolean; + /** Configure immediate child fields */ + fields?: { + abstract?: boolean; + }; + id?: any; + actions?: { + icon: string; + tooltip?: string; + action: () => void | Promise; + }[]; + /** internal */ + _reviveId?: number; + }; +} +export type ComponentState = ComponentStateBase | ComponentPropState | ComponentCustomState; +export interface ComponentDevtoolsOptions { + hide?: boolean; +} diff --git a/node_modules/@vue/devtools-api/lib/esm/api/component.js b/node_modules/@vue/devtools-api/lib/esm/api/component.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/component.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/context.d.ts b/node_modules/@vue/devtools-api/lib/esm/api/context.d.ts new file mode 100644 index 0000000..29388f1 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/context.d.ts @@ -0,0 +1,5 @@ +import type { AppRecord } from './api.js'; +export interface Context { + currentTab: string; + currentAppRecord: AppRecord; +} diff --git a/node_modules/@vue/devtools-api/lib/esm/api/context.js b/node_modules/@vue/devtools-api/lib/esm/api/context.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/context.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts b/node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts new file mode 100644 index 0000000..4e5d7cc --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts @@ -0,0 +1,180 @@ +import type { ComponentDevtoolsOptions, ComponentInstance, ComponentTreeNode, InspectedComponentData } from './component.js'; +import type { App } from './app.js'; +import type { CustomInspectorNode, CustomInspectorState, TimelineEvent } from './api.js'; +export declare const enum Hooks { + TRANSFORM_CALL = "transformCall", + GET_APP_RECORD_NAME = "getAppRecordName", + GET_APP_ROOT_INSTANCE = "getAppRootInstance", + REGISTER_APPLICATION = "registerApplication", + WALK_COMPONENT_TREE = "walkComponentTree", + VISIT_COMPONENT_TREE = "visitComponentTree", + WALK_COMPONENT_PARENTS = "walkComponentParents", + INSPECT_COMPONENT = "inspectComponent", + GET_COMPONENT_BOUNDS = "getComponentBounds", + GET_COMPONENT_NAME = "getComponentName", + GET_COMPONENT_INSTANCES = "getComponentInstances", + GET_ELEMENT_COMPONENT = "getElementComponent", + GET_COMPONENT_ROOT_ELEMENTS = "getComponentRootElements", + EDIT_COMPONENT_STATE = "editComponentState", + GET_COMPONENT_DEVTOOLS_OPTIONS = "getAppDevtoolsOptions", + GET_COMPONENT_RENDER_CODE = "getComponentRenderCode", + INSPECT_TIMELINE_EVENT = "inspectTimelineEvent", + TIMELINE_CLEARED = "timelineCleared", + GET_INSPECTOR_TREE = "getInspectorTree", + GET_INSPECTOR_STATE = "getInspectorState", + EDIT_INSPECTOR_STATE = "editInspectorState", + SET_PLUGIN_SETTINGS = "setPluginSettings" +} +export interface ComponentBounds { + left: number; + top: number; + width: number; + height: number; +} +export interface HookPayloads { + [Hooks.TRANSFORM_CALL]: { + callName: string; + inArgs: any[]; + outArgs: any[]; + }; + [Hooks.GET_APP_RECORD_NAME]: { + app: App; + name: string; + }; + [Hooks.GET_APP_ROOT_INSTANCE]: { + app: App; + root: ComponentInstance; + }; + [Hooks.REGISTER_APPLICATION]: { + app: App; + }; + [Hooks.WALK_COMPONENT_TREE]: { + componentInstance: ComponentInstance; + componentTreeData: ComponentTreeNode[]; + maxDepth: number; + filter: string; + recursively: boolean; + }; + [Hooks.VISIT_COMPONENT_TREE]: { + app: App; + componentInstance: ComponentInstance; + treeNode: ComponentTreeNode; + filter: string; + }; + [Hooks.WALK_COMPONENT_PARENTS]: { + componentInstance: ComponentInstance; + parentInstances: ComponentInstance[]; + }; + [Hooks.INSPECT_COMPONENT]: { + app: App; + componentInstance: ComponentInstance; + instanceData: InspectedComponentData; + }; + [Hooks.GET_COMPONENT_BOUNDS]: { + componentInstance: ComponentInstance; + bounds: ComponentBounds; + }; + [Hooks.GET_COMPONENT_NAME]: { + componentInstance: ComponentInstance; + name: string; + }; + [Hooks.GET_COMPONENT_INSTANCES]: { + app: App; + componentInstances: ComponentInstance[]; + }; + [Hooks.GET_ELEMENT_COMPONENT]: { + element: HTMLElement | any; + componentInstance: ComponentInstance; + }; + [Hooks.GET_COMPONENT_ROOT_ELEMENTS]: { + componentInstance: ComponentInstance; + rootElements: (HTMLElement | any)[]; + }; + [Hooks.EDIT_COMPONENT_STATE]: { + app: App; + componentInstance: ComponentInstance; + path: string[]; + type: string; + state: EditStatePayload; + set: (object: any, path?: string | (string[]), value?: any, cb?: (object: any, field: string, value: any) => void) => void; + }; + [Hooks.GET_COMPONENT_DEVTOOLS_OPTIONS]: { + componentInstance: ComponentInstance; + options: ComponentDevtoolsOptions; + }; + [Hooks.GET_COMPONENT_RENDER_CODE]: { + componentInstance: ComponentInstance; + code: string; + }; + [Hooks.INSPECT_TIMELINE_EVENT]: { + app: App; + layerId: string; + event: TimelineEvent; + all?: boolean; + data: any; + }; + [Hooks.TIMELINE_CLEARED]: Record; + [Hooks.GET_INSPECTOR_TREE]: { + app: App; + inspectorId: string; + filter: string; + rootNodes: CustomInspectorNode[]; + }; + [Hooks.GET_INSPECTOR_STATE]: { + app: App; + inspectorId: string; + nodeId: string; + state: CustomInspectorState; + }; + [Hooks.EDIT_INSPECTOR_STATE]: { + app: App; + inspectorId: string; + nodeId: string; + path: string[]; + type: string; + state: EditStatePayload; + set: (object: any, path?: string | (string[]), value?: any, cb?: (object: any, field: string, value: any) => void) => void; + }; + [Hooks.SET_PLUGIN_SETTINGS]: { + app: App; + pluginId: string; + key: string; + newValue: any; + oldValue: any; + settings: any; + }; +} +export type EditStatePayload = { + value: any; + newKey?: string | null; + remove?: undefined | false; +} | { + value?: undefined; + newKey?: undefined; + remove: true; +}; +export type HookHandler = (payload: TPayload, ctx: TContext) => void | Promise; +export interface Hookable { + transformCall: (handler: HookHandler) => any; + getAppRecordName: (handler: HookHandler) => any; + getAppRootInstance: (handler: HookHandler) => any; + registerApplication: (handler: HookHandler) => any; + walkComponentTree: (handler: HookHandler) => any; + visitComponentTree: (handler: HookHandler) => any; + walkComponentParents: (handler: HookHandler) => any; + inspectComponent: (handler: HookHandler) => any; + getComponentBounds: (handler: HookHandler) => any; + getComponentName: (handler: HookHandler) => any; + getComponentInstances: (handler: HookHandler) => any; + getElementComponent: (handler: HookHandler) => any; + getComponentRootElements: (handler: HookHandler) => any; + editComponentState: (handler: HookHandler) => any; + getComponentDevtoolsOptions: (handler: HookHandler) => any; + getComponentRenderCode: (handler: HookHandler) => any; + inspectTimelineEvent: (handler: HookHandler) => any; + timelineCleared: (handler: HookHandler) => any; + getInspectorTree: (handler: HookHandler) => any; + getInspectorState: (handler: HookHandler) => any; + editInspectorState: (handler: HookHandler) => any; + setPluginSettings: (handler: HookHandler) => any; +} diff --git a/node_modules/@vue/devtools-api/lib/esm/api/hooks.js b/node_modules/@vue/devtools-api/lib/esm/api/hooks.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/hooks.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/index.d.ts b/node_modules/@vue/devtools-api/lib/esm/api/index.d.ts new file mode 100644 index 0000000..70d09d2 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/index.d.ts @@ -0,0 +1,6 @@ +export * from './api.js'; +export * from './app.js'; +export * from './component.js'; +export * from './context.js'; +export * from './hooks.js'; +export * from './util.js'; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/index.js b/node_modules/@vue/devtools-api/lib/esm/api/index.js new file mode 100644 index 0000000..70d09d2 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/index.js @@ -0,0 +1,6 @@ +export * from './api.js'; +export * from './app.js'; +export * from './component.js'; +export * from './context.js'; +export * from './hooks.js'; +export * from './util.js'; diff --git a/node_modules/@vue/devtools-api/lib/esm/api/util.d.ts b/node_modules/@vue/devtools-api/lib/esm/api/util.d.ts new file mode 100644 index 0000000..f8ca920 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/util.d.ts @@ -0,0 +1,4 @@ +export type ID = number | string; +export interface WithId { + id: ID; +} diff --git a/node_modules/@vue/devtools-api/lib/esm/api/util.js b/node_modules/@vue/devtools-api/lib/esm/api/util.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/api/util.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/const.d.ts b/node_modules/@vue/devtools-api/lib/esm/const.d.ts new file mode 100644 index 0000000..289b254 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/const.d.ts @@ -0,0 +1,2 @@ +export declare const HOOK_SETUP = "devtools-plugin:setup"; +export declare const HOOK_PLUGIN_SETTINGS_SET = "plugin:settings:set"; diff --git a/node_modules/@vue/devtools-api/lib/esm/const.js b/node_modules/@vue/devtools-api/lib/esm/const.js new file mode 100644 index 0000000..872ea3e --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/const.js @@ -0,0 +1,2 @@ +export const HOOK_SETUP = 'devtools-plugin:setup'; +export const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set'; diff --git a/node_modules/@vue/devtools-api/lib/esm/env.d.ts b/node_modules/@vue/devtools-api/lib/esm/env.d.ts new file mode 100644 index 0000000..045d95f --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/env.d.ts @@ -0,0 +1,15 @@ +import type { ApiProxy } from './proxy.js'; +import type { PluginDescriptor, SetupFunction } from './index.js'; +export interface PluginQueueItem { + pluginDescriptor: PluginDescriptor; + setupFn: SetupFunction; + proxy?: ApiProxy; +} +interface GlobalTarget { + __VUE_DEVTOOLS_PLUGINS__?: PluginQueueItem[]; + __VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__?: boolean; +} +export declare function getDevtoolsGlobalHook(): any; +export declare function getTarget(): GlobalTarget; +export declare const isProxyAvailable: boolean; +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/env.js b/node_modules/@vue/devtools-api/lib/esm/env.js new file mode 100644 index 0000000..a7a74b1 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/env.js @@ -0,0 +1,12 @@ +export function getDevtoolsGlobalHook() { + return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__; +} +export function getTarget() { + // @ts-expect-error navigator and windows are not available in all environments + return (typeof navigator !== 'undefined' && typeof window !== 'undefined') + ? window + : typeof globalThis !== 'undefined' + ? globalThis + : {}; +} +export const isProxyAvailable = typeof Proxy === 'function'; diff --git a/node_modules/@vue/devtools-api/lib/esm/index.d.ts b/node_modules/@vue/devtools-api/lib/esm/index.d.ts new file mode 100644 index 0000000..162518b --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/index.d.ts @@ -0,0 +1,18 @@ +import type { DevtoolsPluginApi } from './api/index.js'; +import type { ExtractSettingsTypes, PluginDescriptor, PluginSettingsItem } from './plugin.js'; +export * from './api/index.js'; +export * from './plugin.js'; +export * from './time.js'; +export { PluginQueueItem } from './env.js'; +type Cast = A extends B ? A : B; +type Narrowable = string | number | bigint | boolean; +type Narrow = Cast; +})>; +type Exact = { + [K in keyof C]: K extends keyof T ? T[K] : never; +}; +export type SetupFunction = (api: DevtoolsPluginApi) => void; +export declare function setupDevtoolsPlugin, TSettings = ExtractSettingsTypes ? S : Record : Record>>(pluginDescriptor: Narrow, setupFn: SetupFunction): void; diff --git a/node_modules/@vue/devtools-api/lib/esm/index.js b/node_modules/@vue/devtools-api/lib/esm/index.js new file mode 100644 index 0000000..c7a50ec --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/index.js @@ -0,0 +1,27 @@ +import { getDevtoolsGlobalHook, getTarget, isProxyAvailable } from './env.js'; +import { HOOK_SETUP } from './const.js'; +import { ApiProxy } from './proxy.js'; +export * from './api/index.js'; +export * from './plugin.js'; +export * from './time.js'; +export function setupDevtoolsPlugin(pluginDescriptor, setupFn) { + const descriptor = pluginDescriptor; + const target = getTarget(); + const hook = getDevtoolsGlobalHook(); + const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy; + if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) { + hook.emit(HOOK_SETUP, pluginDescriptor, setupFn); + } + else { + const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null; + const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []; + list.push({ + pluginDescriptor: descriptor, + setupFn, + proxy, + }); + if (proxy) { + setupFn(proxy.proxiedTarget); + } + } +} diff --git a/node_modules/@vue/devtools-api/lib/esm/plugin.d.ts b/node_modules/@vue/devtools-api/lib/esm/plugin.d.ts new file mode 100644 index 0000000..52322ca --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/plugin.d.ts @@ -0,0 +1,47 @@ +import type { App } from './api/index.js'; +export interface PluginDescriptor { + id: string; + label: string; + app: App; + packageName?: string; + homepage?: string; + componentStateTypes?: string[]; + logo?: string; + disableAppScope?: boolean; + disablePluginScope?: boolean; + /** + * Run the plugin setup and expose the api even if the devtools is not opened yet. + * Useful to record timeline events early. + */ + enableEarlyProxy?: boolean; + settings?: Record; +} +export type PluginSettingsItem = { + label: string; + description?: string; +} & ({ + type: 'boolean'; + defaultValue: boolean; +} | { + type: 'choice'; + defaultValue: string | number; + options: { + value: string | number; + label: string; + }[]; + component?: 'select' | 'button-group'; +} | { + type: 'text'; + defaultValue: string; +}); +type InferSettingsType = [T] extends [{ + type: 'boolean'; +}] ? boolean : [T] extends [{ + type: 'choice'; +}] ? T['options'][number]['value'] : [T] extends [{ + type: 'text'; +}] ? string : unknown; +export type ExtractSettingsTypes> = { + [K in keyof O]: InferSettingsType; +}; +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/plugin.js b/node_modules/@vue/devtools-api/lib/esm/plugin.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/plugin.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/proxy.d.ts b/node_modules/@vue/devtools-api/lib/esm/proxy.d.ts new file mode 100644 index 0000000..38ff867 --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/proxy.d.ts @@ -0,0 +1,20 @@ +import type { Context, DevtoolsPluginApi, Hookable } from './api/index.js'; +import type { PluginDescriptor } from './plugin.js'; +interface QueueItem { + method: string; + args: any[]; + resolve?: (value?: any) => void; +} +export declare class ApiProxy = DevtoolsPluginApi> { + target: TTarget | null; + targetQueue: QueueItem[]; + proxiedTarget: TTarget; + onQueue: QueueItem[]; + proxiedOn: Hookable; + plugin: PluginDescriptor; + hook: any; + fallbacks: Record; + constructor(plugin: PluginDescriptor, hook: any); + setRealTarget(target: TTarget): Promise; +} +export {}; diff --git a/node_modules/@vue/devtools-api/lib/esm/proxy.js b/node_modules/@vue/devtools-api/lib/esm/proxy.js new file mode 100644 index 0000000..3cce0ff --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/proxy.js @@ -0,0 +1,107 @@ +import { HOOK_PLUGIN_SETTINGS_SET } from './const.js'; +import { now } from './time.js'; +export class ApiProxy { + constructor(plugin, hook) { + this.target = null; + this.targetQueue = []; + this.onQueue = []; + this.plugin = plugin; + this.hook = hook; + const defaultSettings = {}; + if (plugin.settings) { + for (const id in plugin.settings) { + const item = plugin.settings[id]; + defaultSettings[id] = item.defaultValue; + } + } + const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`; + let currentSettings = Object.assign({}, defaultSettings); + try { + const raw = localStorage.getItem(localSettingsSaveId); + const data = JSON.parse(raw); + Object.assign(currentSettings, data); + } + catch (e) { + // noop + } + this.fallbacks = { + getSettings() { + return currentSettings; + }, + setSettings(value) { + try { + localStorage.setItem(localSettingsSaveId, JSON.stringify(value)); + } + catch (e) { + // noop + } + currentSettings = value; + }, + now() { + return now(); + }, + }; + if (hook) { + hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => { + if (pluginId === this.plugin.id) { + this.fallbacks.setSettings(value); + } + }); + } + this.proxiedOn = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target.on[prop]; + } + else { + return (...args) => { + this.onQueue.push({ + method: prop, + args, + }); + }; + } + }, + }); + this.proxiedTarget = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target[prop]; + } + else if (prop === 'on') { + return this.proxiedOn; + } + else if (Object.keys(this.fallbacks).includes(prop)) { + return (...args) => { + this.targetQueue.push({ + method: prop, + args, + resolve: () => { }, + }); + return this.fallbacks[prop](...args); + }; + } + else { + return (...args) => { + return new Promise((resolve) => { + this.targetQueue.push({ + method: prop, + args, + resolve, + }); + }); + }; + } + }, + }); + } + async setRealTarget(target) { + this.target = target; + for (const item of this.onQueue) { + this.target.on[item.method](...item.args); + } + for (const item of this.targetQueue) { + item.resolve(await this.target[item.method](...item.args)); + } + } +} diff --git a/node_modules/@vue/devtools-api/lib/esm/time.d.ts b/node_modules/@vue/devtools-api/lib/esm/time.d.ts new file mode 100644 index 0000000..1aebade --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/time.d.ts @@ -0,0 +1,2 @@ +export declare function isPerformanceSupported(): boolean; +export declare function now(): number; diff --git a/node_modules/@vue/devtools-api/lib/esm/time.js b/node_modules/@vue/devtools-api/lib/esm/time.js new file mode 100644 index 0000000..fd15ffe --- /dev/null +++ b/node_modules/@vue/devtools-api/lib/esm/time.js @@ -0,0 +1,23 @@ +let supported; +let perf; +export function isPerformanceSupported() { + var _a; + if (supported !== undefined) { + return supported; + } + if (typeof window !== 'undefined' && window.performance) { + supported = true; + perf = window.performance; + } + else if (typeof globalThis !== 'undefined' && ((_a = globalThis.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) { + supported = true; + perf = globalThis.perf_hooks.performance; + } + else { + supported = false; + } + return supported; +} +export function now() { + return isPerformanceSupported() ? perf.now() : Date.now(); +} diff --git a/node_modules/@vue/devtools-api/package.json b/node_modules/@vue/devtools-api/package.json new file mode 100644 index 0000000..772d566 --- /dev/null +++ b/node_modules/@vue/devtools-api/package.json @@ -0,0 +1,37 @@ +{ + "name": "@vue/devtools-api", + "version": "6.6.3", + "description": "Interact with the Vue devtools from the page", + "author": { + "name": "Guillaume Chau" + }, + "license": "MIT", + "repository": { + "url": "https://github.com/vuejs/vue-devtools.git", + "type": "git", + "directory": "packages/api" + }, + "sideEffects": false, + "main": "lib/cjs/index.js", + "browser": "lib/esm/index.js", + "module": "lib/esm/index.js", + "types": "lib/esm/index.d.ts", + "files": [ + "lib/cjs", + "lib/esm" + ], + "publishConfig": { + "access": "public" + }, + "scripts": { + "build": "rimraf lib && yarn build:esm && yarn build:cjs", + "build:esm": "tsc --module es2015 --outDir lib/esm -d", + "build:cjs": "tsc --module commonjs --outDir lib/cjs", + "build:watch": "yarn tsc --module es2015 --outDir lib/esm -d -w --sourceMap" + }, + "devDependencies": { + "@types/node": "^20.11.16", + "@types/webpack-env": "^1.15.1", + "typescript": "^5.3.3" + } +} \ No newline at end of file diff --git a/node_modules/pinia/LICENSE b/node_modules/pinia/LICENSE new file mode 100644 index 0000000..0c77562 --- /dev/null +++ b/node_modules/pinia/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019-present Eduardo San Martin Morote + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/pinia/README.md b/node_modules/pinia/README.md new file mode 100644 index 0000000..d73d322 --- /dev/null +++ b/node_modules/pinia/README.md @@ -0,0 +1,24 @@ +

+ + Pinia logo + +

+ +# Pinia + +> Intuitive, type safe and flexible Store for Vue + +## 👉 [Demo with Vue 3 on StackBlitz](https://stackblitz.com/github/piniajs/example-vue-3-vite) + +## Help me keep working on this project 💚 + +- [Become a Sponsor on GitHub](https://github.com/sponsors/posva) +- [One-time donation via PayPal](https://paypal.me/posva) + +## Documentation + +To learn more about Pinia, check [its documentation](https://pinia.vuejs.org). + +## License + +[MIT](http://opensource.org/licenses/MIT) diff --git a/node_modules/pinia/dist/pinia.cjs b/node_modules/pinia/dist/pinia.cjs new file mode 100644 index 0000000..3015139 --- /dev/null +++ b/node_modules/pinia/dist/pinia.cjs @@ -0,0 +1,2020 @@ +/*! + * pinia v2.1.7 + * (c) 2023 Eduardo San Martin Morote + * @license MIT + */ +'use strict'; + +var vueDemi = require('vue-demi'); +var devtoolsApi = require('@vue/devtools-api'); + +/** + * setActivePinia must be called to handle SSR at the top of functions like + * `fetch`, `setup`, `serverPrefetch` and others + */ +let activePinia; +/** + * Sets or unsets the active pinia. Used in SSR and internally when calling + * actions and getters + * + * @param pinia - Pinia instance + */ +// @ts-expect-error: cannot constrain the type of the return +const setActivePinia = (pinia) => (activePinia = pinia); +/** + * Get the currently active pinia if there is any. + */ +const getActivePinia = () => (vueDemi.hasInjectionContext() && vueDemi.inject(piniaSymbol)) || activePinia; +const piniaSymbol = ((process.env.NODE_ENV !== 'production') ? Symbol('pinia') : /* istanbul ignore next */ Symbol()); + +function isPlainObject( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +o) { + return (o && + typeof o === 'object' && + Object.prototype.toString.call(o) === '[object Object]' && + typeof o.toJSON !== 'function'); +} +// type DeepReadonly = { readonly [P in keyof T]: DeepReadonly } +// TODO: can we change these to numbers? +/** + * Possible types for SubscriptionCallback + */ +exports.MutationType = void 0; +(function (MutationType) { + /** + * Direct mutation of the state: + * + * - `store.name = 'new name'` + * - `store.$state.name = 'new name'` + * - `store.list.push('new item')` + */ + MutationType["direct"] = "direct"; + /** + * Mutated the state with `$patch` and an object + * + * - `store.$patch({ name: 'newName' })` + */ + MutationType["patchObject"] = "patch object"; + /** + * Mutated the state with `$patch` and a function + * + * - `store.$patch(state => state.name = 'newName')` + */ + MutationType["patchFunction"] = "patch function"; + // maybe reset? for $state = {} and $reset +})(exports.MutationType || (exports.MutationType = {})); + +const IS_CLIENT = typeof window !== 'undefined'; +/** + * Should we add the devtools plugins. + * - only if dev mode or forced through the prod devtools flag + * - not in test + * - only if window exists (could change in the future) + */ +const USE_DEVTOOLS = ((process.env.NODE_ENV !== 'production') || false) && !(process.env.NODE_ENV === 'test') && IS_CLIENT; + +/* + * FileSaver.js A saveAs() FileSaver implementation. + * + * Originally by Eli Grey, adapted as an ESM module by Eduardo San Martin + * Morote. + * + * License : MIT + */ +// The one and only way of getting global scope in all environments +// https://stackoverflow.com/q/3277182/1008999 +const _global = /*#__PURE__*/ (() => typeof window === 'object' && window.window === window + ? window + : typeof self === 'object' && self.self === self + ? self + : typeof global === 'object' && global.global === global + ? global + : typeof globalThis === 'object' + ? globalThis + : { HTMLElement: null })(); +function bom(blob, { autoBom = false } = {}) { + // prepend BOM for UTF-8 XML and text/* types (including HTML) + // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF + if (autoBom && + /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { + return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type }); + } + return blob; +} +function download(url, name, opts) { + const xhr = new XMLHttpRequest(); + xhr.open('GET', url); + xhr.responseType = 'blob'; + xhr.onload = function () { + saveAs(xhr.response, name, opts); + }; + xhr.onerror = function () { + console.error('could not download file'); + }; + xhr.send(); +} +function corsEnabled(url) { + const xhr = new XMLHttpRequest(); + // use sync to avoid popup blocker + xhr.open('HEAD', url, false); + try { + xhr.send(); + } + catch (e) { } + return xhr.status >= 200 && xhr.status <= 299; +} +// `a.click()` doesn't work for all browsers (#465) +function click(node) { + try { + node.dispatchEvent(new MouseEvent('click')); + } + catch (e) { + const evt = document.createEvent('MouseEvents'); + evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null); + node.dispatchEvent(evt); + } +} +const _navigator = + typeof navigator === 'object' ? navigator : { userAgent: '' }; +// Detect WebView inside a native macOS app by ruling out all browsers +// We just need to check for 'Safari' because all other browsers (besides Firefox) include that too +// https://www.whatismybrowser.com/guides/the-latest-user-agent/macos +const isMacOSWebView = /*#__PURE__*/ (() => /Macintosh/.test(_navigator.userAgent) && + /AppleWebKit/.test(_navigator.userAgent) && + !/Safari/.test(_navigator.userAgent))(); +const saveAs = !IS_CLIENT + ? () => { } // noop + : // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program + typeof HTMLAnchorElement !== 'undefined' && + 'download' in HTMLAnchorElement.prototype && + !isMacOSWebView + ? downloadSaveAs + : // Use msSaveOrOpenBlob as a second approach + 'msSaveOrOpenBlob' in _navigator + ? msSaveAs + : // Fallback to using FileReader and a popup + fileSaverSaveAs; +function downloadSaveAs(blob, name = 'download', opts) { + const a = document.createElement('a'); + a.download = name; + a.rel = 'noopener'; // tabnabbing + // TODO: detect chrome extensions & packaged apps + // a.target = '_blank' + if (typeof blob === 'string') { + // Support regular links + a.href = blob; + if (a.origin !== location.origin) { + if (corsEnabled(a.href)) { + download(blob, name, opts); + } + else { + a.target = '_blank'; + click(a); + } + } + else { + click(a); + } + } + else { + // Support blobs + a.href = URL.createObjectURL(blob); + setTimeout(function () { + URL.revokeObjectURL(a.href); + }, 4e4); // 40s + setTimeout(function () { + click(a); + }, 0); + } +} +function msSaveAs(blob, name = 'download', opts) { + if (typeof blob === 'string') { + if (corsEnabled(blob)) { + download(blob, name, opts); + } + else { + const a = document.createElement('a'); + a.href = blob; + a.target = '_blank'; + setTimeout(function () { + click(a); + }); + } + } + else { + // @ts-ignore: works on windows + navigator.msSaveOrOpenBlob(bom(blob, opts), name); + } +} +function fileSaverSaveAs(blob, name, opts, popup) { + // Open a popup immediately do go around popup blocker + // Mostly only available on user interaction and the fileReader is async so... + popup = popup || open('', '_blank'); + if (popup) { + popup.document.title = popup.document.body.innerText = 'downloading...'; + } + if (typeof blob === 'string') + return download(blob, name, opts); + const force = blob.type === 'application/octet-stream'; + const isSafari = /constructor/i.test(String(_global.HTMLElement)) || 'safari' in _global; + const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); + if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && + typeof FileReader !== 'undefined') { + // Safari doesn't allow downloading of blob URLs + const reader = new FileReader(); + reader.onloadend = function () { + let url = reader.result; + if (typeof url !== 'string') { + popup = null; + throw new Error('Wrong reader.result type'); + } + url = isChromeIOS + ? url + : url.replace(/^data:[^;]*;/, 'data:attachment/file;'); + if (popup) { + popup.location.href = url; + } + else { + location.assign(url); + } + popup = null; // reverse-tabnabbing #460 + }; + reader.readAsDataURL(blob); + } + else { + const url = URL.createObjectURL(blob); + if (popup) + popup.location.assign(url); + else + location.href = url; + popup = null; // reverse-tabnabbing #460 + setTimeout(function () { + URL.revokeObjectURL(url); + }, 4e4); // 40s + } +} + +/** + * Shows a toast or console.log + * + * @param message - message to log + * @param type - different color of the tooltip + */ +function toastMessage(message, type) { + const piniaMessage = '🍍 ' + message; + if (typeof __VUE_DEVTOOLS_TOAST__ === 'function') { + // No longer available :( + __VUE_DEVTOOLS_TOAST__(piniaMessage, type); + } + else if (type === 'error') { + console.error(piniaMessage); + } + else if (type === 'warn') { + console.warn(piniaMessage); + } + else { + console.log(piniaMessage); + } +} +function isPinia(o) { + return '_a' in o && 'install' in o; +} + +/** + * This file contain devtools actions, they are not Pinia actions. + */ +// --- +function checkClipboardAccess() { + if (!('clipboard' in navigator)) { + toastMessage(`Your browser doesn't support the Clipboard API`, 'error'); + return true; + } +} +function checkNotFocusedError(error) { + if (error instanceof Error && + error.message.toLowerCase().includes('document is not focused')) { + toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', 'warn'); + return true; + } + return false; +} +async function actionGlobalCopyState(pinia) { + if (checkClipboardAccess()) + return; + try { + await navigator.clipboard.writeText(JSON.stringify(pinia.state.value)); + toastMessage('Global state copied to clipboard.'); + } + catch (error) { + if (checkNotFocusedError(error)) + return; + toastMessage(`Failed to serialize the state. Check the console for more details.`, 'error'); + console.error(error); + } +} +async function actionGlobalPasteState(pinia) { + if (checkClipboardAccess()) + return; + try { + loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText())); + toastMessage('Global state pasted from clipboard.'); + } + catch (error) { + if (checkNotFocusedError(error)) + return; + toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, 'error'); + console.error(error); + } +} +async function actionGlobalSaveState(pinia) { + try { + saveAs(new Blob([JSON.stringify(pinia.state.value)], { + type: 'text/plain;charset=utf-8', + }), 'pinia-state.json'); + } + catch (error) { + toastMessage(`Failed to export the state as JSON. Check the console for more details.`, 'error'); + console.error(error); + } +} +let fileInput; +function getFileOpener() { + if (!fileInput) { + fileInput = document.createElement('input'); + fileInput.type = 'file'; + fileInput.accept = '.json'; + } + function openFile() { + return new Promise((resolve, reject) => { + fileInput.onchange = async () => { + const files = fileInput.files; + if (!files) + return resolve(null); + const file = files.item(0); + if (!file) + return resolve(null); + return resolve({ text: await file.text(), file }); + }; + // @ts-ignore: TODO: changed from 4.3 to 4.4 + fileInput.oncancel = () => resolve(null); + fileInput.onerror = reject; + fileInput.click(); + }); + } + return openFile; +} +async function actionGlobalOpenStateFile(pinia) { + try { + const open = getFileOpener(); + const result = await open(); + if (!result) + return; + const { text, file } = result; + loadStoresState(pinia, JSON.parse(text)); + toastMessage(`Global state imported from "${file.name}".`); + } + catch (error) { + toastMessage(`Failed to import the state from JSON. Check the console for more details.`, 'error'); + console.error(error); + } +} +function loadStoresState(pinia, state) { + for (const key in state) { + const storeState = pinia.state.value[key]; + // store is already instantiated, patch it + if (storeState) { + Object.assign(storeState, state[key]); + } + else { + // store is not instantiated, set the initial state + pinia.state.value[key] = state[key]; + } + } +} + +function formatDisplay(display) { + return { + _custom: { + display, + }, + }; +} +const PINIA_ROOT_LABEL = '🍍 Pinia (root)'; +const PINIA_ROOT_ID = '_root'; +function formatStoreForInspectorTree(store) { + return isPinia(store) + ? { + id: PINIA_ROOT_ID, + label: PINIA_ROOT_LABEL, + } + : { + id: store.$id, + label: store.$id, + }; +} +function formatStoreForInspectorState(store) { + if (isPinia(store)) { + const storeNames = Array.from(store._s.keys()); + const storeMap = store._s; + const state = { + state: storeNames.map((storeId) => ({ + editable: true, + key: storeId, + value: store.state.value[storeId], + })), + getters: storeNames + .filter((id) => storeMap.get(id)._getters) + .map((id) => { + const store = storeMap.get(id); + return { + editable: false, + key: id, + value: store._getters.reduce((getters, key) => { + getters[key] = store[key]; + return getters; + }, {}), + }; + }), + }; + return state; + } + const state = { + state: Object.keys(store.$state).map((key) => ({ + editable: true, + key, + value: store.$state[key], + })), + }; + // avoid adding empty getters + if (store._getters && store._getters.length) { + state.getters = store._getters.map((getterName) => ({ + editable: false, + key: getterName, + value: store[getterName], + })); + } + if (store._customProperties.size) { + state.customProperties = Array.from(store._customProperties).map((key) => ({ + editable: true, + key, + value: store[key], + })); + } + return state; +} +function formatEventData(events) { + if (!events) + return {}; + if (Array.isArray(events)) { + // TODO: handle add and delete for arrays and objects + return events.reduce((data, event) => { + data.keys.push(event.key); + data.operations.push(event.type); + data.oldValue[event.key] = event.oldValue; + data.newValue[event.key] = event.newValue; + return data; + }, { + oldValue: {}, + keys: [], + operations: [], + newValue: {}, + }); + } + else { + return { + operation: formatDisplay(events.type), + key: formatDisplay(events.key), + oldValue: events.oldValue, + newValue: events.newValue, + }; + } +} +function formatMutationType(type) { + switch (type) { + case exports.MutationType.direct: + return 'mutation'; + case exports.MutationType.patchFunction: + return '$patch'; + case exports.MutationType.patchObject: + return '$patch'; + default: + return 'unknown'; + } +} + +// timeline can be paused when directly changing the state +let isTimelineActive = true; +const componentStateTypes = []; +const MUTATIONS_LAYER_ID = 'pinia:mutations'; +const INSPECTOR_ID = 'pinia'; +const { assign: assign$1 } = Object; +/** + * Gets the displayed name of a store in devtools + * + * @param id - id of the store + * @returns a formatted string + */ +const getStoreType = (id) => '🍍 ' + id; +/** + * Add the pinia plugin without any store. Allows displaying a Pinia plugin tab + * as soon as it is added to the application. + * + * @param app - Vue application + * @param pinia - pinia instance + */ +function registerPiniaDevtools(app, pinia) { + devtoolsApi.setupDevtoolsPlugin({ + id: 'dev.esm.pinia', + label: 'Pinia 🍍', + logo: 'https://pinia.vuejs.org/logo.svg', + packageName: 'pinia', + homepage: 'https://pinia.vuejs.org', + componentStateTypes, + app, + }, (api) => { + if (typeof api.now !== 'function') { + toastMessage('You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.'); + } + api.addTimelineLayer({ + id: MUTATIONS_LAYER_ID, + label: `Pinia 🍍`, + color: 0xe5df88, + }); + api.addInspector({ + id: INSPECTOR_ID, + label: 'Pinia 🍍', + icon: 'storage', + treeFilterPlaceholder: 'Search stores', + actions: [ + { + icon: 'content_copy', + action: () => { + actionGlobalCopyState(pinia); + }, + tooltip: 'Serialize and copy the state', + }, + { + icon: 'content_paste', + action: async () => { + await actionGlobalPasteState(pinia); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }, + tooltip: 'Replace the state with the content of your clipboard', + }, + { + icon: 'save', + action: () => { + actionGlobalSaveState(pinia); + }, + tooltip: 'Save the state as a JSON file', + }, + { + icon: 'folder_open', + action: async () => { + await actionGlobalOpenStateFile(pinia); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }, + tooltip: 'Import the state from a JSON file', + }, + ], + nodeActions: [ + { + icon: 'restore', + tooltip: 'Reset the state (with "$reset")', + action: (nodeId) => { + const store = pinia._s.get(nodeId); + if (!store) { + toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, 'warn'); + } + else if (typeof store.$reset !== 'function') { + toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, 'warn'); + } + else { + store.$reset(); + toastMessage(`Store "${nodeId}" reset.`); + } + }, + }, + ], + }); + api.on.inspectComponent((payload, ctx) => { + const proxy = (payload.componentInstance && + payload.componentInstance.proxy); + if (proxy && proxy._pStores) { + const piniaStores = payload.componentInstance.proxy._pStores; + Object.values(piniaStores).forEach((store) => { + payload.instanceData.state.push({ + type: getStoreType(store.$id), + key: 'state', + editable: true, + value: store._isOptionsAPI + ? { + _custom: { + value: vueDemi.toRaw(store.$state), + actions: [ + { + icon: 'restore', + tooltip: 'Reset the state of this store', + action: () => store.$reset(), + }, + ], + }, + } + : // NOTE: workaround to unwrap transferred refs + Object.keys(store.$state).reduce((state, key) => { + state[key] = store.$state[key]; + return state; + }, {}), + }); + if (store._getters && store._getters.length) { + payload.instanceData.state.push({ + type: getStoreType(store.$id), + key: 'getters', + editable: false, + value: store._getters.reduce((getters, key) => { + try { + getters[key] = store[key]; + } + catch (error) { + // @ts-expect-error: we just want to show it in devtools + getters[key] = error; + } + return getters; + }, {}), + }); + } + }); + } + }); + api.on.getInspectorTree((payload) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + let stores = [pinia]; + stores = stores.concat(Array.from(pinia._s.values())); + payload.rootNodes = (payload.filter + ? stores.filter((store) => '$id' in store + ? store.$id + .toLowerCase() + .includes(payload.filter.toLowerCase()) + : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase())) + : stores).map(formatStoreForInspectorTree); + } + }); + api.on.getInspectorState((payload) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + const inspectedStore = payload.nodeId === PINIA_ROOT_ID + ? pinia + : pinia._s.get(payload.nodeId); + if (!inspectedStore) { + // this could be the selected store restored for a different project + // so it's better not to say anything here + return; + } + if (inspectedStore) { + payload.state = formatStoreForInspectorState(inspectedStore); + } + } + }); + api.on.editInspectorState((payload, ctx) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + const inspectedStore = payload.nodeId === PINIA_ROOT_ID + ? pinia + : pinia._s.get(payload.nodeId); + if (!inspectedStore) { + return toastMessage(`store "${payload.nodeId}" not found`, 'error'); + } + const { path } = payload; + if (!isPinia(inspectedStore)) { + // access only the state + if (path.length !== 1 || + !inspectedStore._customProperties.has(path[0]) || + path[0] in inspectedStore.$state) { + path.unshift('$state'); + } + } + else { + // Root access, we can omit the `.value` because the devtools API does it for us + path.unshift('state'); + } + isTimelineActive = false; + payload.set(inspectedStore, path, payload.state.value); + isTimelineActive = true; + } + }); + api.on.editComponentState((payload) => { + if (payload.type.startsWith('🍍')) { + const storeId = payload.type.replace(/^🍍\s*/, ''); + const store = pinia._s.get(storeId); + if (!store) { + return toastMessage(`store "${storeId}" not found`, 'error'); + } + const { path } = payload; + if (path[0] !== 'state') { + return toastMessage(`Invalid path for store "${storeId}":\n${path}\nOnly state can be modified.`); + } + // rewrite the first entry to be able to directly set the state as + // well as any other path + path[0] = '$state'; + isTimelineActive = false; + payload.set(store, path, payload.state.value); + isTimelineActive = true; + } + }); + }); +} +function addStoreToDevtools(app, store) { + if (!componentStateTypes.includes(getStoreType(store.$id))) { + componentStateTypes.push(getStoreType(store.$id)); + } + devtoolsApi.setupDevtoolsPlugin({ + id: 'dev.esm.pinia', + label: 'Pinia 🍍', + logo: 'https://pinia.vuejs.org/logo.svg', + packageName: 'pinia', + homepage: 'https://pinia.vuejs.org', + componentStateTypes, + app, + settings: { + logStoreChanges: { + label: 'Notify about new/deleted stores', + type: 'boolean', + defaultValue: true, + }, + // useEmojis: { + // label: 'Use emojis in messages ⚡️', + // type: 'boolean', + // defaultValue: true, + // }, + }, + }, (api) => { + // gracefully handle errors + const now = typeof api.now === 'function' ? api.now.bind(api) : Date.now; + store.$onAction(({ after, onError, name, args }) => { + const groupId = runningActionId++; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🛫 ' + name, + subtitle: 'start', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + }, + groupId, + }, + }); + after((result) => { + activeAction = undefined; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🛬 ' + name, + subtitle: 'end', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + result, + }, + groupId, + }, + }); + }); + onError((error) => { + activeAction = undefined; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + logType: 'error', + title: '💥 ' + name, + subtitle: 'end', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + error, + }, + groupId, + }, + }); + }); + }, true); + store._customProperties.forEach((name) => { + vueDemi.watch(() => vueDemi.unref(store[name]), (newValue, oldValue) => { + api.notifyComponentUpdate(); + api.sendInspectorState(INSPECTOR_ID); + if (isTimelineActive) { + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: 'Change', + subtitle: name, + data: { + newValue, + oldValue, + }, + groupId: activeAction, + }, + }); + } + }, { deep: true }); + }); + store.$subscribe(({ events, type }, state) => { + api.notifyComponentUpdate(); + api.sendInspectorState(INSPECTOR_ID); + if (!isTimelineActive) + return; + // rootStore.state[store.id] = state + const eventData = { + time: now(), + title: formatMutationType(type), + data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)), + groupId: activeAction, + }; + if (type === exports.MutationType.patchFunction) { + eventData.subtitle = '⤵️'; + } + else if (type === exports.MutationType.patchObject) { + eventData.subtitle = '🧩'; + } + else if (events && !Array.isArray(events)) { + eventData.subtitle = events.type; + } + if (events) { + eventData.data['rawEvent(s)'] = { + _custom: { + display: 'DebuggerEvent', + type: 'object', + tooltip: 'raw DebuggerEvent[]', + value: events, + }, + }; + } + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: eventData, + }); + }, { detached: true, flush: 'sync' }); + const hotUpdate = store._hotUpdate; + store._hotUpdate = vueDemi.markRaw((newStore) => { + hotUpdate(newStore); + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🔥 ' + store.$id, + subtitle: 'HMR update', + data: { + store: formatDisplay(store.$id), + info: formatDisplay(`HMR update`), + }, + }, + }); + // update the devtools too + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }); + const { $dispose } = store; + store.$dispose = () => { + $dispose(); + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + api.getSettings().logStoreChanges && + toastMessage(`Disposed "${store.$id}" store 🗑`); + }; + // trigger an update so it can display new registered stores + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + api.getSettings().logStoreChanges && + toastMessage(`"${store.$id}" store installed 🆕`); + }); +} +let runningActionId = 0; +let activeAction; +/** + * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the + * context of all actions, allowing us to set `runningAction` on each access and effectively associating any state + * mutation to the action. + * + * @param store - store to patch + * @param actionNames - list of actionst to patch + */ +function patchActionForGrouping(store, actionNames, wrapWithProxy) { + // original actions of the store as they are given by pinia. We are going to override them + const actions = actionNames.reduce((storeActions, actionName) => { + // use toRaw to avoid tracking #541 + storeActions[actionName] = vueDemi.toRaw(store)[actionName]; + return storeActions; + }, {}); + for (const actionName in actions) { + store[actionName] = function () { + // the running action id is incremented in a before action hook + const _actionId = runningActionId; + const trackedStore = wrapWithProxy + ? new Proxy(store, { + get(...args) { + activeAction = _actionId; + return Reflect.get(...args); + }, + set(...args) { + activeAction = _actionId; + return Reflect.set(...args); + }, + }) + : store; + // For Setup Stores we need https://github.com/tc39/proposal-async-context + activeAction = _actionId; + const retValue = actions[actionName].apply(trackedStore, arguments); + // this is safer as async actions in Setup Stores would associate mutations done outside of the action + activeAction = undefined; + return retValue; + }; + } +} +/** + * pinia.use(devtoolsPlugin) + */ +function devtoolsPlugin({ app, store, options }) { + // HMR module + if (store.$id.startsWith('__hot:')) { + return; + } + // detect option api vs setup api + store._isOptionsAPI = !!options.state; + patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI); + // Upgrade the HMR to also update the new actions + const originalHotUpdate = store._hotUpdate; + vueDemi.toRaw(store)._hotUpdate = function (newStore) { + originalHotUpdate.apply(this, arguments); + patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI); + }; + addStoreToDevtools(app, + // FIXME: is there a way to allow the assignment from Store to StoreGeneric? + store); +} + +/** + * Creates a Pinia instance to be used by the application + */ +function createPinia() { + const scope = vueDemi.effectScope(true); + // NOTE: here we could check the window object for a state and directly set it + // if there is anything like it with Vue 3 SSR + const state = scope.run(() => vueDemi.ref({})); + let _p = []; + // plugins added before calling app.use(pinia) + let toBeInstalled = []; + const pinia = vueDemi.markRaw({ + install(app) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + if (!vueDemi.isVue2) { + pinia._a = app; + app.provide(piniaSymbol, pinia); + app.config.globalProperties.$pinia = pinia; + /* istanbul ignore else */ + if (USE_DEVTOOLS) { + registerPiniaDevtools(app, pinia); + } + toBeInstalled.forEach((plugin) => _p.push(plugin)); + toBeInstalled = []; + } + }, + use(plugin) { + if (!this._a && !vueDemi.isVue2) { + toBeInstalled.push(plugin); + } + else { + _p.push(plugin); + } + return this; + }, + _p, + // it's actually undefined here + // @ts-expect-error + _a: null, + _e: scope, + _s: new Map(), + state, + }); + // pinia devtools rely on dev only features so they cannot be forced unless + // the dev build of Vue is used. Avoid old browsers like IE11. + if (USE_DEVTOOLS && typeof Proxy !== 'undefined') { + pinia.use(devtoolsPlugin); + } + return pinia; +} + +/** + * Checks if a function is a `StoreDefinition`. + * + * @param fn - object to test + * @returns true if `fn` is a StoreDefinition + */ +const isUseStore = (fn) => { + return typeof fn === 'function' && typeof fn.$id === 'string'; +}; +/** + * Mutates in place `newState` with `oldState` to _hot update_ it. It will + * remove any key not existing in `newState` and recursively merge plain + * objects. + * + * @param newState - new state object to be patched + * @param oldState - old state that should be used to patch newState + * @returns - newState + */ +function patchObject(newState, oldState) { + // no need to go through symbols because they cannot be serialized anyway + for (const key in oldState) { + const subPatch = oldState[key]; + // skip the whole sub tree + if (!(key in newState)) { + continue; + } + const targetValue = newState[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + !vueDemi.isRef(subPatch) && + !vueDemi.isReactive(subPatch)) { + newState[key] = patchObject(targetValue, subPatch); + } + else { + // objects are either a bit more complex (e.g. refs) or primitives, so we + // just set the whole thing + if (vueDemi.isVue2) { + vueDemi.set(newState, key, subPatch); + } + else { + newState[key] = subPatch; + } + } + } + return newState; +} +/** + * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. + * + * @example + * ```js + * const useUser = defineStore(...) + * if (import.meta.hot) { + * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) + * } + * ``` + * + * @param initialUseStore - return of the defineStore to hot update + * @param hot - `import.meta.hot` + */ +function acceptHMRUpdate(initialUseStore, hot) { + // strip as much as possible from iife.prod + if (!(process.env.NODE_ENV !== 'production')) { + return () => { }; + } + return (newModule) => { + const pinia = hot.data.pinia || initialUseStore._pinia; + if (!pinia) { + // this store is still not used + return; + } + // preserve the pinia instance across loads + hot.data.pinia = pinia; + // console.log('got data', newStore) + for (const exportName in newModule) { + const useStore = newModule[exportName]; + // console.log('checking for', exportName) + if (isUseStore(useStore) && pinia._s.has(useStore.$id)) { + // console.log('Accepting update for', useStore.$id) + const id = useStore.$id; + if (id !== initialUseStore.$id) { + console.warn(`The id of the store changed from "${initialUseStore.$id}" to "${id}". Reloading.`); + // return import.meta.hot.invalidate() + return hot.invalidate(); + } + const existingStore = pinia._s.get(id); + if (!existingStore) { + console.log(`[Pinia]: skipping hmr because store doesn't exist yet`); + return; + } + useStore(pinia, existingStore); + } + } + }; +} + +const noop = () => { }; +function addSubscription(subscriptions, callback, detached, onCleanup = noop) { + subscriptions.push(callback); + const removeSubscription = () => { + const idx = subscriptions.indexOf(callback); + if (idx > -1) { + subscriptions.splice(idx, 1); + onCleanup(); + } + }; + if (!detached && vueDemi.getCurrentScope()) { + vueDemi.onScopeDispose(removeSubscription); + } + return removeSubscription; +} +function triggerSubscriptions(subscriptions, ...args) { + subscriptions.slice().forEach((callback) => { + callback(...args); + }); +} + +const fallbackRunWithContext = (fn) => fn(); +function mergeReactiveObjects(target, patchToApply) { + // Handle Map instances + if (target instanceof Map && patchToApply instanceof Map) { + patchToApply.forEach((value, key) => target.set(key, value)); + } + // Handle Set instances + if (target instanceof Set && patchToApply instanceof Set) { + patchToApply.forEach(target.add, target); + } + // no need to go through symbols because they cannot be serialized anyway + for (const key in patchToApply) { + if (!patchToApply.hasOwnProperty(key)) + continue; + const subPatch = patchToApply[key]; + const targetValue = target[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + target.hasOwnProperty(key) && + !vueDemi.isRef(subPatch) && + !vueDemi.isReactive(subPatch)) { + // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might + // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that + // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`. + target[key] = mergeReactiveObjects(targetValue, subPatch); + } + else { + // @ts-expect-error: subPatch is a valid value + target[key] = subPatch; + } + } + return target; +} +const skipHydrateSymbol = (process.env.NODE_ENV !== 'production') + ? Symbol('pinia:skipHydration') + : /* istanbul ignore next */ Symbol(); +const skipHydrateMap = /*#__PURE__*/ new WeakMap(); +/** + * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a + * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. + * + * @param obj - target object + * @returns obj + */ +function skipHydrate(obj) { + return vueDemi.isVue2 + ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work... + /* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj + : Object.defineProperty(obj, skipHydrateSymbol, {}); +} +/** + * Returns whether a value should be hydrated + * + * @param obj - target variable + * @returns true if `obj` should be hydrated + */ +function shouldHydrate(obj) { + return vueDemi.isVue2 + ? /* istanbul ignore next */ !skipHydrateMap.has(obj) + : !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol); +} +const { assign } = Object; +function isComputed(o) { + return !!(vueDemi.isRef(o) && o.effect); +} +function createOptionsStore(id, options, pinia, hot) { + const { state, actions, getters } = options; + const initialState = pinia.state.value[id]; + let store; + function setup() { + if (!initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) { + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value, id, state ? state() : {}); + } + else { + pinia.state.value[id] = state ? state() : {}; + } + } + // avoid creating a state in pinia.state.value + const localState = (process.env.NODE_ENV !== 'production') && hot + ? // use ref() to unwrap refs inside state TODO: check if this is still necessary + vueDemi.toRefs(vueDemi.ref(state ? state() : {}).value) + : vueDemi.toRefs(pinia.state.value[id]); + return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => { + if ((process.env.NODE_ENV !== 'production') && name in localState) { + console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`); + } + computedGetters[name] = vueDemi.markRaw(vueDemi.computed(() => { + setActivePinia(pinia); + // it was created just before + const store = pinia._s.get(id); + // allow cross using stores + /* istanbul ignore next */ + if (vueDemi.isVue2 && !store._r) + return; + // @ts-expect-error + // return getters![name].call(context, context) + // TODO: avoid reading the getter while assigning with a global variable + return getters[name].call(store, store); + })); + return computedGetters; + }, {})); + } + store = createSetupStore(id, setup, options, pinia, hot, true); + return store; +} +function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) { + let scope; + const optionsForPlugin = assign({ actions: {} }, options); + /* istanbul ignore if */ + if ((process.env.NODE_ENV !== 'production') && !pinia._e.active) { + throw new Error('Pinia destroyed'); + } + // watcher options for $subscribe + const $subscribeOptions = { + deep: true, + // flush: 'post', + }; + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production') && !vueDemi.isVue2) { + $subscribeOptions.onTrigger = (event) => { + /* istanbul ignore else */ + if (isListening) { + debuggerEvents = event; + // avoid triggering this while the store is being built and the state is being set in pinia + } + else if (isListening == false && !store._hotUpdating) { + // let patch send all the events together later + /* istanbul ignore else */ + if (Array.isArray(debuggerEvents)) { + debuggerEvents.push(event); + } + else { + console.error('🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.'); + } + } + }; + } + // internal state + let isListening; // set to true at the end + let isSyncListening; // set to true at the end + let subscriptions = []; + let actionSubscriptions = []; + let debuggerEvents; + const initialState = pinia.state.value[$id]; + // avoid setting the state for option stores if it is set + // by the setup + if (!isOptionsStore && !initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) { + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value, $id, {}); + } + else { + pinia.state.value[$id] = {}; + } + } + const hotState = vueDemi.ref({}); + // avoid triggering too many listeners + // https://github.com/vuejs/pinia/issues/1129 + let activeListener; + function $patch(partialStateOrMutator) { + let subscriptionMutation; + isListening = isSyncListening = false; + // reset the debugger events since patches are sync + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + debuggerEvents = []; + } + if (typeof partialStateOrMutator === 'function') { + partialStateOrMutator(pinia.state.value[$id]); + subscriptionMutation = { + type: exports.MutationType.patchFunction, + storeId: $id, + events: debuggerEvents, + }; + } + else { + mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator); + subscriptionMutation = { + type: exports.MutationType.patchObject, + payload: partialStateOrMutator, + storeId: $id, + events: debuggerEvents, + }; + } + const myListenerId = (activeListener = Symbol()); + vueDemi.nextTick().then(() => { + if (activeListener === myListenerId) { + isListening = true; + } + }); + isSyncListening = true; + // because we paused the watcher, we need to manually call the subscriptions + triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]); + } + const $reset = isOptionsStore + ? function $reset() { + const { state } = options; + const newState = state ? state() : {}; + // we use a patch to group all changes into one single subscription + this.$patch(($state) => { + assign($state, newState); + }); + } + : /* istanbul ignore next */ + (process.env.NODE_ENV !== 'production') + ? () => { + throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`); + } + : noop; + function $dispose() { + scope.stop(); + subscriptions = []; + actionSubscriptions = []; + pinia._s.delete($id); + } + /** + * Wraps an action to handle subscriptions. + * + * @param name - name of the action + * @param action - action to wrap + * @returns a wrapped action to handle subscriptions + */ + function wrapAction(name, action) { + return function () { + setActivePinia(pinia); + const args = Array.from(arguments); + const afterCallbackList = []; + const onErrorCallbackList = []; + function after(callback) { + afterCallbackList.push(callback); + } + function onError(callback) { + onErrorCallbackList.push(callback); + } + // @ts-expect-error + triggerSubscriptions(actionSubscriptions, { + args, + name, + store, + after, + onError, + }); + let ret; + try { + ret = action.apply(this && this.$id === $id ? this : store, args); + // handle sync errors + } + catch (error) { + triggerSubscriptions(onErrorCallbackList, error); + throw error; + } + if (ret instanceof Promise) { + return ret + .then((value) => { + triggerSubscriptions(afterCallbackList, value); + return value; + }) + .catch((error) => { + triggerSubscriptions(onErrorCallbackList, error); + return Promise.reject(error); + }); + } + // trigger after callbacks + triggerSubscriptions(afterCallbackList, ret); + return ret; + }; + } + const _hmrPayload = /*#__PURE__*/ vueDemi.markRaw({ + actions: {}, + getters: {}, + state: [], + hotState, + }); + const partialStore = { + _p: pinia, + // _s: scope, + $id, + $onAction: addSubscription.bind(null, actionSubscriptions), + $patch, + $reset, + $subscribe(callback, options = {}) { + const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher()); + const stopWatcher = scope.run(() => vueDemi.watch(() => pinia.state.value[$id], (state) => { + if (options.flush === 'sync' ? isSyncListening : isListening) { + callback({ + storeId: $id, + type: exports.MutationType.direct, + events: debuggerEvents, + }, state); + } + }, assign({}, $subscribeOptions, options))); + return removeSubscription; + }, + $dispose, + }; + /* istanbul ignore if */ + if (vueDemi.isVue2) { + // start as non ready + partialStore._r = false; + } + const store = vueDemi.reactive((process.env.NODE_ENV !== 'production') || USE_DEVTOOLS + ? assign({ + _hmrPayload, + _customProperties: vueDemi.markRaw(new Set()), // devtools custom properties + }, partialStore + // must be added later + // setupStore + ) + : partialStore); + // store the partial store now so the setup of stores can instantiate each other before they are finished without + // creating infinite loops. + pinia._s.set($id, store); + const runWithContext = (pinia._a && pinia._a.runWithContext) || fallbackRunWithContext; + // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped + const setupStore = runWithContext(() => pinia._e.run(() => (scope = vueDemi.effectScope()).run(setup))); + // overwrite existing actions to support $onAction + for (const key in setupStore) { + const prop = setupStore[key]; + if ((vueDemi.isRef(prop) && !isComputed(prop)) || vueDemi.isReactive(prop)) { + // mark it as a piece of state to be serialized + if ((process.env.NODE_ENV !== 'production') && hot) { + vueDemi.set(hotState.value, key, vueDemi.toRef(setupStore, key)); + // createOptionStore directly sets the state in pinia.state.value so we + // can just skip that + } + else if (!isOptionsStore) { + // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created + if (initialState && shouldHydrate(prop)) { + if (vueDemi.isRef(prop)) { + prop.value = initialState[key]; + } + else { + // probably a reactive object, lets recursively assign + // @ts-expect-error: prop is unknown + mergeReactiveObjects(prop, initialState[key]); + } + } + // transfer the ref to the pinia state to keep everything in sync + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value[$id], key, prop); + } + else { + pinia.state.value[$id][key] = prop; + } + } + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + _hmrPayload.state.push(key); + } + // action + } + else if (typeof prop === 'function') { + // @ts-expect-error: we are overriding the function we avoid wrapping if + const actionValue = (process.env.NODE_ENV !== 'production') && hot ? prop : wrapAction(key, prop); + // this a hot module replacement store because the hotUpdate method needs + // to do it with the right context + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(setupStore, key, actionValue); + } + else { + // @ts-expect-error + setupStore[key] = actionValue; + } + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + _hmrPayload.actions[key] = prop; + } + // list actions so they can be used in plugins + // @ts-expect-error + optionsForPlugin.actions[key] = prop; + } + else if ((process.env.NODE_ENV !== 'production')) { + // add getters for devtools + if (isComputed(prop)) { + _hmrPayload.getters[key] = isOptionsStore + ? // @ts-expect-error + options.getters[key] + : prop; + if (IS_CLIENT) { + const getters = setupStore._getters || + // @ts-expect-error: same + (setupStore._getters = vueDemi.markRaw([])); + getters.push(key); + } + } + } + } + // add the state, getters, and action properties + /* istanbul ignore if */ + if (vueDemi.isVue2) { + Object.keys(setupStore).forEach((key) => { + vueDemi.set(store, key, setupStore[key]); + }); + } + else { + assign(store, setupStore); + // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object. + // Make `storeToRefs()` work with `reactive()` #799 + assign(vueDemi.toRaw(store), setupStore); + } + // use this instead of a computed with setter to be able to create it anywhere + // without linking the computed lifespan to wherever the store is first + // created. + Object.defineProperty(store, '$state', { + get: () => ((process.env.NODE_ENV !== 'production') && hot ? hotState.value : pinia.state.value[$id]), + set: (state) => { + /* istanbul ignore if */ + if ((process.env.NODE_ENV !== 'production') && hot) { + throw new Error('cannot set hotState'); + } + $patch(($state) => { + assign($state, state); + }); + }, + }); + // add the hotUpdate before plugins to allow them to override it + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + store._hotUpdate = vueDemi.markRaw((newStore) => { + store._hotUpdating = true; + newStore._hmrPayload.state.forEach((stateKey) => { + if (stateKey in store.$state) { + const newStateTarget = newStore.$state[stateKey]; + const oldStateSource = store.$state[stateKey]; + if (typeof newStateTarget === 'object' && + isPlainObject(newStateTarget) && + isPlainObject(oldStateSource)) { + patchObject(newStateTarget, oldStateSource); + } + else { + // transfer the ref + newStore.$state[stateKey] = oldStateSource; + } + } + // patch direct access properties to allow store.stateProperty to work as + // store.$state.stateProperty + vueDemi.set(store, stateKey, vueDemi.toRef(newStore.$state, stateKey)); + }); + // remove deleted state properties + Object.keys(store.$state).forEach((stateKey) => { + if (!(stateKey in newStore.$state)) { + vueDemi.del(store, stateKey); + } + }); + // avoid devtools logging this as a mutation + isListening = false; + isSyncListening = false; + pinia.state.value[$id] = vueDemi.toRef(newStore._hmrPayload, 'hotState'); + isSyncListening = true; + vueDemi.nextTick().then(() => { + isListening = true; + }); + for (const actionName in newStore._hmrPayload.actions) { + const action = newStore[actionName]; + vueDemi.set(store, actionName, wrapAction(actionName, action)); + } + // TODO: does this work in both setup and option store? + for (const getterName in newStore._hmrPayload.getters) { + const getter = newStore._hmrPayload.getters[getterName]; + const getterValue = isOptionsStore + ? // special handling of options api + vueDemi.computed(() => { + setActivePinia(pinia); + return getter.call(store, store); + }) + : getter; + vueDemi.set(store, getterName, getterValue); + } + // remove deleted getters + Object.keys(store._hmrPayload.getters).forEach((key) => { + if (!(key in newStore._hmrPayload.getters)) { + vueDemi.del(store, key); + } + }); + // remove old actions + Object.keys(store._hmrPayload.actions).forEach((key) => { + if (!(key in newStore._hmrPayload.actions)) { + vueDemi.del(store, key); + } + }); + // update the values used in devtools and to allow deleting new properties later on + store._hmrPayload = newStore._hmrPayload; + store._getters = newStore._getters; + store._hotUpdating = false; + }); + } + if (USE_DEVTOOLS) { + const nonEnumerable = { + writable: true, + configurable: true, + // avoid warning on devtools trying to display this property + enumerable: false, + }; + ['_p', '_hmrPayload', '_getters', '_customProperties'].forEach((p) => { + Object.defineProperty(store, p, assign({ value: store[p] }, nonEnumerable)); + }); + } + /* istanbul ignore if */ + if (vueDemi.isVue2) { + // mark the store as ready before plugins + store._r = true; + } + // apply all plugins + pinia._p.forEach((extender) => { + /* istanbul ignore else */ + if (USE_DEVTOOLS) { + const extensions = scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + })); + Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key)); + assign(store, extensions); + } + else { + assign(store, scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + }))); + } + }); + if ((process.env.NODE_ENV !== 'production') && + store.$state && + typeof store.$state === 'object' && + typeof store.$state.constructor === 'function' && + !store.$state.constructor.toString().includes('[native code]')) { + console.warn(`[🍍]: The "state" must be a plain object. It cannot be\n` + + `\tstate: () => new MyClass()\n` + + `Found in store "${store.$id}".`); + } + // only apply hydrate to option stores with an initial state in pinia + if (initialState && + isOptionsStore && + options.hydrate) { + options.hydrate(store.$state, initialState); + } + isListening = true; + isSyncListening = true; + return store; +} +function defineStore( +// TODO: add proper types from above +idOrOptions, setup, setupOptions) { + let id; + let options; + const isSetupStore = typeof setup === 'function'; + if (typeof idOrOptions === 'string') { + id = idOrOptions; + // the option store setup will contain the actual options in this case + options = isSetupStore ? setupOptions : setup; + } + else { + options = idOrOptions; + id = idOrOptions.id; + if ((process.env.NODE_ENV !== 'production') && typeof id !== 'string') { + throw new Error(`[🍍]: "defineStore()" must be passed a store id as its first argument.`); + } + } + function useStore(pinia, hot) { + const hasContext = vueDemi.hasInjectionContext(); + pinia = + // in test mode, ignore the argument provided as we can always retrieve a + // pinia instance with getActivePinia() + ((process.env.NODE_ENV === 'test') && activePinia && activePinia._testing ? null : pinia) || + (hasContext ? vueDemi.inject(piniaSymbol, null) : null); + if (pinia) + setActivePinia(pinia); + if ((process.env.NODE_ENV !== 'production') && !activePinia) { + throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?\n` + + `See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.\n` + + `This will fail in production.`); + } + pinia = activePinia; + if (!pinia._s.has(id)) { + // creating the store registers it in `pinia._s` + if (isSetupStore) { + createSetupStore(id, setup, options, pinia); + } + else { + createOptionsStore(id, options, pinia); + } + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + // @ts-expect-error: not the right inferred type + useStore._pinia = pinia; + } + } + const store = pinia._s.get(id); + if ((process.env.NODE_ENV !== 'production') && hot) { + const hotId = '__hot:' + id; + const newStore = isSetupStore + ? createSetupStore(hotId, setup, options, pinia, true) + : createOptionsStore(hotId, assign({}, options), pinia, true); + hot._hotUpdate(newStore); + // cleanup the state properties and the store from the cache + delete pinia.state.value[hotId]; + pinia._s.delete(hotId); + } + if ((process.env.NODE_ENV !== 'production') && IS_CLIENT) { + const currentInstance = vueDemi.getCurrentInstance(); + // save stores in instances to access them devtools + if (currentInstance && + currentInstance.proxy && + // avoid adding stores that are just built for hot module replacement + !hot) { + const vm = currentInstance.proxy; + const cache = '_pStores' in vm ? vm._pStores : (vm._pStores = {}); + cache[id] = store; + } + } + // StoreGeneric cannot be casted towards Store + return store; + } + useStore.$id = id; + return useStore; +} + +let mapStoreSuffix = 'Store'; +/** + * Changes the suffix added by `mapStores()`. Can be set to an empty string. + * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization + * interface if you are using TypeScript. + * + * @param suffix - new suffix + */ +function setMapStoreSuffix(suffix // could be 'Store' but that would be annoying for JS +) { + mapStoreSuffix = suffix; +} +/** + * Allows using stores without the composition API (`setup()`) by generating an + * object to be spread in the `computed` field of a component. It accepts a list + * of store definitions. + * + * @example + * ```js + * export default { + * computed: { + * // other computed properties + * ...mapStores(useUserStore, useCartStore) + * }, + * + * created() { + * this.userStore // store with id "user" + * this.cartStore // store with id "cart" + * } + * } + * ``` + * + * @param stores - list of stores to map to an object + */ +function mapStores(...stores) { + if ((process.env.NODE_ENV !== 'production') && Array.isArray(stores[0])) { + console.warn(`[🍍]: Directly pass all stores to "mapStores()" without putting them in an array:\n` + + `Replace\n` + + `\tmapStores([useAuthStore, useCartStore])\n` + + `with\n` + + `\tmapStores(useAuthStore, useCartStore)\n` + + `This will fail in production if not fixed.`); + stores = stores[0]; + } + return stores.reduce((reduced, useStore) => { + // @ts-expect-error: $id is added by defineStore + reduced[useStore.$id + mapStoreSuffix] = function () { + return useStore(this.$pinia); + }; + return reduced; + }, {}); +} +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + reduced[key] = function () { + return useStore(this.$pinia)[key]; + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function () { + const store = useStore(this.$pinia); + const storeKey = keysOrMapper[key]; + // for some reason TS is unable to infer the type of storeKey to be a + // function + return typeof storeKey === 'function' + ? storeKey.call(this, store) + : store[storeKey]; + }; + return reduced; + }, {}); +} +/** + * Alias for `mapState()`. You should use `mapState()` instead. + * @deprecated use `mapState()` instead. + */ +const mapGetters = mapState; +/** + * Allows directly using actions from your store without using the composition + * API (`setup()`) by generating an object to be spread in the `methods` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapActions(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[key](...args); + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[keysOrMapper[key]](...args); + }; + return reduced; + }, {}); +} +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapWritableState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[key]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[key] = value); + }, + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[keysOrMapper[key]]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[keysOrMapper[key]] = value); + }, + }; + return reduced; + }, {}); +} + +/** + * Creates an object of references with all the state, getters, and plugin-added + * state properties of the store. Similar to `toRefs()` but specifically + * designed for Pinia stores so methods and non reactive properties are + * completely ignored. + * + * @param store - store to extract the refs from + */ +function storeToRefs(store) { + // See https://github.com/vuejs/pinia/issues/852 + // It's easier to just use toRefs() even if it includes more stuff + if (vueDemi.isVue2) { + // @ts-expect-error: toRefs include methods and others + return vueDemi.toRefs(store); + } + else { + store = vueDemi.toRaw(store); + const refs = {}; + for (const key in store) { + const value = store[key]; + if (vueDemi.isRef(value) || vueDemi.isReactive(value)) { + // @ts-expect-error: the key is state or getter + refs[key] = + // --- + vueDemi.toRef(store, key); + } + } + return refs; + } +} + +/** + * Vue 2 Plugin that must be installed for pinia to work. Note **you don't need + * this plugin if you are using Nuxt.js**. Use the `buildModule` instead: + * https://pinia.vuejs.org/ssr/nuxt.html. + * + * @example + * ```js + * import Vue from 'vue' + * import { PiniaVuePlugin, createPinia } from 'pinia' + * + * Vue.use(PiniaVuePlugin) + * const pinia = createPinia() + * + * new Vue({ + * el: '#app', + * // ... + * pinia, + * }) + * ``` + * + * @param _Vue - `Vue` imported from 'vue'. + */ +const PiniaVuePlugin = function (_Vue) { + // Equivalent of + // app.config.globalProperties.$pinia = pinia + _Vue.mixin({ + beforeCreate() { + const options = this.$options; + if (options.pinia) { + const pinia = options.pinia; + // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/main/src/apis/inject.ts#L31 + /* istanbul ignore else */ + if (!this._provided) { + const provideCache = {}; + Object.defineProperty(this, '_provided', { + get: () => provideCache, + set: (v) => Object.assign(provideCache, v), + }); + } + this._provided[piniaSymbol] = pinia; + // propagate the pinia instance in an SSR friendly way + // avoid adding it to nuxt twice + /* istanbul ignore else */ + if (!this.$pinia) { + this.$pinia = pinia; + } + pinia._a = this; + if (IS_CLIENT) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + } + if (USE_DEVTOOLS) { + registerPiniaDevtools(pinia._a, pinia); + } + } + else if (!this.$pinia && options.parent && options.parent.$pinia) { + this.$pinia = options.parent.$pinia; + } + }, + destroyed() { + delete this._pStores; + }, + }); +}; + +exports.PiniaVuePlugin = PiniaVuePlugin; +exports.acceptHMRUpdate = acceptHMRUpdate; +exports.createPinia = createPinia; +exports.defineStore = defineStore; +exports.getActivePinia = getActivePinia; +exports.mapActions = mapActions; +exports.mapGetters = mapGetters; +exports.mapState = mapState; +exports.mapStores = mapStores; +exports.mapWritableState = mapWritableState; +exports.setActivePinia = setActivePinia; +exports.setMapStoreSuffix = setMapStoreSuffix; +exports.skipHydrate = skipHydrate; +exports.storeToRefs = storeToRefs; diff --git a/node_modules/pinia/dist/pinia.d.ts b/node_modules/pinia/dist/pinia.d.ts new file mode 100644 index 0000000..841defa --- /dev/null +++ b/node_modules/pinia/dist/pinia.d.ts @@ -0,0 +1,995 @@ +import { App } from 'vue-demi'; +import { ComputedRef } from 'vue-demi'; +import type { DebuggerEvent } from 'vue-demi'; +import { EffectScope } from 'vue-demi'; +import type { Plugin as Plugin_2 } from 'vue-demi'; +import { Ref } from 'vue-demi'; +import { ToRef } from 'vue-demi'; +import { ToRefs } from 'vue-demi'; +import { UnwrapRef } from 'vue-demi'; +import type { WatchOptions } from 'vue-demi'; + +/** + * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. + * + * @example + * ```js + * const useUser = defineStore(...) + * if (import.meta.hot) { + * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) + * } + * ``` + * + * @param initialUseStore - return of the defineStore to hot update + * @param hot - `import.meta.hot` + */ +export declare function acceptHMRUpdate = _GettersTree, A = _ActionsTree>(initialUseStore: StoreDefinition, hot: any): (newModule: any) => any; + +/** + * Type of an object of Actions. For internal usage only. + * For internal use **only** + */ +export declare type _ActionsTree = Record; + +export declare type _Awaited = T extends null | undefined ? T : T extends object & { + then(onfulfilled: infer F): any; +} ? F extends (value: infer V, ...args: any) => any ? _Awaited : never : T; + +/** + * Creates a Pinia instance to be used by the application + */ +export declare function createPinia(): Pinia; + +/** + * Recursive `Partial`. Used by {@link Store['$patch']}. + * + * For internal use **only** + */ +export declare type _DeepPartial = { + [K in keyof T]?: _DeepPartial; +}; + +/** + * Options parameter of `defineStore()` for setup stores. Can be extended to + * augment stores with the plugin API. @see {@link DefineStoreOptionsBase}. + */ +export declare interface DefineSetupStoreOptions extends DefineStoreOptionsBase> { + /** + * Extracted actions. Added by useStore(). SHOULD NOT be added by the user when + * creating the store. Can be used in plugins to get the list of actions in a + * store defined with a setup function. Note this is always defined + */ + actions?: A; +} + +/** + * Creates a `useStore` function that retrieves the store instance + * + * @param id - id of the store (must be unique) + * @param options - options to define the store + */ +export declare function defineStore = {}, A = {}>(id: Id, options: Omit, 'id'>): StoreDefinition; + +/** + * Creates a `useStore` function that retrieves the store instance + * + * @param options - options to define the store + */ +export declare function defineStore = {}, A = {}>(options: DefineStoreOptions): StoreDefinition; + +/** + * Creates a `useStore` function that retrieves the store instance + * + * @param id - id of the store (must be unique) + * @param storeSetup - function that defines the store + * @param options - extra options + */ +export declare function defineStore(id: Id, storeSetup: () => SS, options?: DefineSetupStoreOptions, _ExtractGettersFromSetupStore, _ExtractActionsFromSetupStore>): StoreDefinition, _ExtractGettersFromSetupStore, _ExtractActionsFromSetupStore>; + +/** + * Options parameter of `defineStore()` for option stores. Can be extended to + * augment stores with the plugin API. @see {@link DefineStoreOptionsBase}. + */ +export declare interface DefineStoreOptions extends DefineStoreOptionsBase> { + /** + * Unique string key to identify the store across the application. + */ + id: Id; + /** + * Function to create a fresh state. **Must be an arrow function** to ensure + * correct typings! + */ + state?: () => S; + /** + * Optional object of getters. + */ + getters?: G & ThisType & _StoreWithGetters & PiniaCustomProperties> & _GettersTree; + /** + * Optional object of actions. + */ + actions?: A & ThisType & _StoreWithState & _StoreWithGetters & PiniaCustomProperties>; + /** + * Allows hydrating the store during SSR when complex state (like client side only refs) are used in the store + * definition and copying the value from `pinia.state` isn't enough. + * + * @example + * If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on + * Server and Client, you need to manually hydrate them. e.g., a custom ref that is stored in the local + * storage: + * + * ```ts + * const useStore = defineStore('main', { + * state: () => ({ + * n: useLocalStorage('key', 0) + * }), + * hydrate(storeState, initialState) { + * // @ts-expect-error: https://github.com/microsoft/TypeScript/issues/43826 + * storeState.n = useLocalStorage('key', 0) + * } + * }) + * ``` + * + * @param storeState - the current state in the store + * @param initialState - initialState + */ + hydrate?(storeState: UnwrapRef, initialState: UnwrapRef): void; +} + +/** + * Options passed to `defineStore()` that are common between option and setup + * stores. Extend this interface if you want to add custom options to both kinds + * of stores. + */ +export declare interface DefineStoreOptionsBase { +} + +/** + * Available `options` when creating a pinia plugin. + */ +export declare interface DefineStoreOptionsInPlugin extends Omit, 'id' | 'actions'> { + /** + * Extracted object of actions. Added by useStore() when the store is built + * using the setup API, otherwise uses the one passed to `defineStore()`. + * Defaults to an empty object if no actions are defined. + */ + actions: A; +} + +/** + * For internal use **only** + */ +export declare type _ExtractActionsFromSetupStore = SS extends undefined | void ? {} : _ExtractActionsFromSetupStore_Keys extends keyof SS ? Pick> : never; + +/** + * Type that enables refactoring through IDE. + * For internal use **only** + */ +export declare type _ExtractActionsFromSetupStore_Keys = keyof { + [K in keyof SS as SS[K] extends _Method ? K : never]: any; +}; + +/** + * For internal use **only** + */ +export declare type _ExtractGettersFromSetupStore = SS extends undefined | void ? {} : _ExtractGettersFromSetupStore_Keys extends keyof SS ? Pick> : never; + +/** + * Type that enables refactoring through IDE. + * For internal use **only** + */ +export declare type _ExtractGettersFromSetupStore_Keys = keyof { + [K in keyof SS as SS[K] extends ComputedRef ? K : never]: any; +}; + +/** + * For internal use **only** + */ +export declare type _ExtractStateFromSetupStore = SS extends undefined | void ? {} : _ExtractStateFromSetupStore_Keys extends keyof SS ? _UnwrapAll>> : never; + +/** + * Type that enables refactoring through IDE. + * For internal use **only** + */ +export declare type _ExtractStateFromSetupStore_Keys = keyof { + [K in keyof SS as SS[K] extends _Method | ComputedRef ? never : K]: any; +}; + +/** + * Get the currently active pinia if there is any. + */ +export declare const getActivePinia: () => Pinia | undefined; + +/** + * Type of an object of Getters that infers the argument. For internal usage only. + * For internal use **only** + */ +export declare type _GettersTree = Record & UnwrapRef>) => any) | (() => any)>; + +/** + * Allows directly using actions from your store without using the composition + * API (`setup()`) by generating an object to be spread in the `methods` field + * of a component. The values of the object are the actions while the keys are + * the names of the resulting methods. + * + * @example + * ```js + * export default { + * methods: { + * // other methods properties + * // useCounterStore has two actions named `increment` and `setCount` + * ...mapActions(useCounterStore, { moar: 'increment', setIt: 'setCount' }) + * }, + * + * created() { + * this.moar() + * this.setIt(2) + * } + * } + * ``` + * + * @param useStore - store to map from + * @param keyMapper - object to define new names for the actions + */ +export declare function mapActions, A, KeyMapper extends Record>(useStore: StoreDefinition, keyMapper: KeyMapper): _MapActionsObjectReturn; + +/** + * Allows directly using actions from your store without using the composition + * API (`setup()`) by generating an object to be spread in the `methods` field + * of a component. + * + * @example + * ```js + * export default { + * methods: { + * // other methods properties + * ...mapActions(useCounterStore, ['increment', 'setCount']) + * }, + * + * created() { + * this.increment() + * this.setCount(2) // pass arguments as usual + * } + * } + * ``` + * + * @param useStore - store to map from + * @param keys - array of action names to map + */ +export declare function mapActions, A>(useStore: StoreDefinition, keys: Array): _MapActionsReturn; + +/** + * For internal use **only** + */ +export declare type _MapActionsObjectReturn> = { + [key in keyof T]: A[T[key]]; +}; + +/** + * For internal use **only** + */ +export declare type _MapActionsReturn = { + [key in keyof A]: A[key]; +}; + +/** + * Alias for `mapState()`. You should use `mapState()` instead. + * @deprecated use `mapState()` instead. + */ +export declare const mapGetters: typeof mapState; + +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. The values of the object are the state properties/getters + * while the keys are the names of the resulting computed properties. + * Optionally, you can also pass a custom function that will receive the store + * as its first argument. Note that while it has access to the component + * instance via `this`, it won't be typed. + * + * @example + * ```js + * export default { + * computed: { + * // other computed properties + * // useCounterStore has a state property named `count` and a getter `double` + * ...mapState(useCounterStore, { + * n: 'count', + * triple: store => store.n * 3, + * // note we can't use an arrow function if we want to use `this` + * custom(store) { + * return this.someComponentValue + store.n + * }, + * doubleN: 'double' + * }) + * }, + * + * created() { + * this.n // 2 + * this.doubleN // 4 + * } + * } + * ``` + * + * @param useStore - store to map from + * @param keyMapper - object of state properties or getters + */ +export declare function mapState, A, KeyMapper extends Record) => any)>>(useStore: StoreDefinition, keyMapper: KeyMapper): _MapStateObjectReturn; + +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @example + * ```js + * export default { + * computed: { + * // other computed properties + * ...mapState(useCounterStore, ['count', 'double']) + * }, + * + * created() { + * this.count // 2 + * this.double // 4 + * } + * } + * ``` + * + * @param useStore - store to map from + * @param keys - array of state properties or getters + */ +export declare function mapState, A, Keys extends keyof S | keyof G>(useStore: StoreDefinition, keys: readonly Keys[]): _MapStateReturn; + +/** + * For internal use **only** + */ +export declare type _MapStateObjectReturn, A, T extends Record) => any)> = {}> = { + [key in keyof T]: () => T[key] extends (store: any) => infer R ? R : T[key] extends keyof Store ? Store[T[key]] : never; +}; + +/** + * For internal use **only** + */ +export declare type _MapStateReturn, Keys extends keyof S | keyof G = keyof S | keyof G> = { + [key in Keys]: () => Store[key]; +}; + +/** + * Allows using stores without the composition API (`setup()`) by generating an + * object to be spread in the `computed` field of a component. It accepts a list + * of store definitions. + * + * @example + * ```js + * export default { + * computed: { + * // other computed properties + * ...mapStores(useUserStore, useCartStore) + * }, + * + * created() { + * this.userStore // store with id "user" + * this.cartStore // store with id "cart" + * } + * } + * ``` + * + * @param stores - list of stores to map to an object + */ +export declare function mapStores(...stores: [...Stores]): _Spread; + +/** + * Interface to allow customizing map helpers. Extend this interface with the + * following properties: + * + * - `suffix`: string. Affects the suffix of `mapStores()`, defaults to `Store`. + */ +export declare interface MapStoresCustomization { +} + +/** + * Same as `mapState()` but creates computed setters as well so the state can be + * modified. Differently from `mapState()`, only `state` properties can be + * added. + * + * @param useStore - store to map from + * @param keyMapper - object of state properties + */ +export declare function mapWritableState, A, KeyMapper extends Record>(useStore: StoreDefinition, keyMapper: KeyMapper): _MapWritableStateObjectReturn; + +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keys - array of state properties + */ +export declare function mapWritableState, A, Keys extends keyof S>(useStore: StoreDefinition, keys: readonly Keys[]): { + [K in Keys]: { + get: () => S[K]; + set: (value: S[K]) => any; + }; +}; + +/** + * For internal use **only** + */ +export declare type _MapWritableStateObjectReturn> = { + [key in keyof T]: { + get: () => S[T[key]]; + set: (value: S[T[key]]) => any; + }; +}; + +/** + * For internal use **only** + */ +export declare type _MapWritableStateReturn = { + [key in keyof S]: { + get: () => S[key]; + set: (value: S[key]) => any; + }; +}; + +/** + * Generic type for a function that can infer arguments and return type + * + * For internal use **only** + */ +export declare type _Method = (...args: any[]) => any; + +/** + * Possible types for SubscriptionCallback + */ +export declare enum MutationType { + /** + * Direct mutation of the state: + * + * - `store.name = 'new name'` + * - `store.$state.name = 'new name'` + * - `store.list.push('new item')` + */ + direct = "direct", + /** + * Mutated the state with `$patch` and an object + * + * - `store.$patch({ name: 'newName' })` + */ + patchObject = "patch object", + /** + * Mutated the state with `$patch` and a function + * + * - `store.$patch(state => state.name = 'newName')` + */ + patchFunction = "patch function" +} + +/** + * Every application must own its own pinia to be able to create stores + */ +export declare interface Pinia { + install: (app: App) => void; + /** + * root state + */ + state: Ref>; + /** + * Adds a store plugin to extend every store + * + * @param plugin - store plugin to add + */ + use(plugin: PiniaPlugin): Pinia; + /* Excluded from this release type: _p */ + /* Excluded from this release type: _a */ + /* Excluded from this release type: _e */ + /* Excluded from this release type: _s */ + /* Excluded from this release type: _testing */ +} + +/** + * Interface to be extended by the user when they add properties through plugins. + */ +export declare interface PiniaCustomProperties, A = _ActionsTree> { +} + +/** + * Properties that are added to every `store.$state` by `pinia.use()`. + */ +export declare interface PiniaCustomStateProperties { +} + +/** + * Plugin to extend every store. + */ +export declare interface PiniaPlugin { + /** + * Plugin to extend every store. Returns an object to extend the store or + * nothing. + * + * @param context - Context + */ + (context: PiniaPluginContext): Partial | void; +} + +/** + * Context argument passed to Pinia plugins. + */ +export declare interface PiniaPluginContext, A = _ActionsTree> { + /** + * pinia instance. + */ + pinia: Pinia; + /** + * Current app created with `Vue.createApp()`. + */ + app: App; + /** + * Current store being extended. + */ + store: Store; + /** + * Initial options defining the store when calling `defineStore()`. + */ + options: DefineStoreOptionsInPlugin; +} + +/** + * Plugin to extend every store. + * @deprecated use PiniaPlugin instead + */ +export declare type PiniaStorePlugin = PiniaPlugin; + +/** + * Vue 2 Plugin that must be installed for pinia to work. Note **you don't need + * this plugin if you are using Nuxt.js**. Use the `buildModule` instead: + * https://pinia.vuejs.org/ssr/nuxt.html. + * + * @example + * ```js + * import Vue from 'vue' + * import { PiniaVuePlugin, createPinia } from 'pinia' + * + * Vue.use(PiniaVuePlugin) + * const pinia = createPinia() + * + * new Vue({ + * el: '#app', + * // ... + * pinia, + * }) + * ``` + * + * @param _Vue - `Vue` imported from 'vue'. + */ +export declare const PiniaVuePlugin: Plugin_2; + +declare interface _SetActivePinia { + (pinia: Pinia): Pinia; + (pinia: undefined): undefined; + (pinia: Pinia | undefined): Pinia | undefined; +} + +/** + * Sets or unsets the active pinia. Used in SSR and internally when calling + * actions and getters + * + * @param pinia - Pinia instance + */ +export declare const setActivePinia: _SetActivePinia; + +/** + * Changes the suffix added by `mapStores()`. Can be set to an empty string. + * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization + * interface if you are using TypeScript. + * + * @param suffix - new suffix + */ +export declare function setMapStoreSuffix(suffix: MapStoresCustomization extends Record<'suffix', infer Suffix> ? Suffix : string): void; + +/** + * Return type of `defineStore()` with a setup function. + * - `Id` is a string literal of the store's name + * - `SS` is the return type of the setup function + * @see {@link StoreDefinition} + */ +export declare interface SetupStoreDefinition extends StoreDefinition, _ExtractGettersFromSetupStore, _ExtractActionsFromSetupStore> { +} + +/** + * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a + * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. + * + * @param obj - target object + * @returns obj + */ +export declare function skipHydrate(obj: T): T; + +/** + * For internal use **only**. + */ +export declare type _Spread = A extends [infer L, ...infer R] ? _StoreObject & _Spread : unknown; + +/** + * Generic state of a Store + */ +export declare type StateTree = Record; + +/** + * Store type to build a store. + */ +export declare type Store = _StoreWithState & UnwrapRef & _StoreWithGetters & (_ActionsTree extends A ? {} : A) & PiniaCustomProperties & PiniaCustomStateProperties; + +/** + * Extract the actions of a store type. Works with both a Setup Store or an + * Options Store. + */ +export declare type StoreActions = SS extends Store, infer A> ? A : _ExtractActionsFromSetupStore; + +/** + * Return type of `defineStore()`. Function that allows instantiating a store. + */ +export declare interface StoreDefinition, A = _ActionsTree> { + /** + * Returns a store, creates it if necessary. + * + * @param pinia - Pinia instance to retrieve the store + * @param hot - dev only hot module replacement + */ + (pinia?: Pinia | null | undefined, hot?: StoreGeneric): Store; + /** + * Id of the store. Used by map helpers. + */ + $id: Id; + /* Excluded from this release type: _pinia */ +} + +/** + * Generic and type-unsafe version of Store. Doesn't fail on access with + * strings, making it much easier to write generic functions that do not care + * about the kind of store that is passed. + */ +export declare type StoreGeneric = Store, _ActionsTree>; + +/** + * Extract the getters of a store type. Works with both a Setup Store or an + * Options Store. + */ +export declare type StoreGetters = SS extends Store ? _StoreWithGetters : _ExtractGettersFromSetupStore; + +/** + * For internal use **only**. + */ +export declare type _StoreObject = S extends StoreDefinition ? { + [Id in `${Ids}${MapStoresCustomization extends Record<'suffix', infer Suffix> ? Suffix : 'Store'}`]: () => Store ? Suffix : 'Store'}` ? RealId : string, State, Getters, Actions>; +} : {}; + +/** + * Argument of `store.$onAction()` + */ +export declare type StoreOnActionListener = (context: StoreOnActionListenerContext) => void; + +/** + * Context object passed to callbacks of `store.$onAction(context => {})` + * TODO: should have only the Id, the Store and Actions to generate the proper object + */ +export declare type StoreOnActionListenerContext = _ActionsTree extends A ? _StoreOnActionListenerContext : { + [Name in keyof A]: Name extends string ? _StoreOnActionListenerContext, Name, A> : never; +}[keyof A]; + +/** + * Actual type for {@link StoreOnActionListenerContext}. Exists for refactoring + * purposes. For internal use only. + * For internal use **only** + */ +export declare interface _StoreOnActionListenerContext { + /** + * Name of the action + */ + name: ActionName; + /** + * Store that is invoking the action + */ + store: Store; + /** + * Parameters passed to the action + */ + args: A extends Record ? Parameters : unknown[]; + /** + * Sets up a hook once the action is finished. It receives the return value + * of the action, if it's a Promise, it will be unwrapped. + */ + after: (callback: A extends Record ? (resolvedReturn: _Awaited>) => void : () => void) => void; + /** + * Sets up a hook if the action fails. Return `false` to catch the error and + * stop it from propagating. + */ + onError: (callback: (error: unknown) => void) => void; +} + +/** + * Properties of a store. + */ +export declare interface StoreProperties { + /** + * Unique identifier of the store + */ + $id: Id; + /* Excluded from this release type: _p */ + /* Excluded from this release type: _getters */ + /* Excluded from this release type: _isOptionsAPI */ + /** + * Used by devtools plugin to retrieve properties added with plugins. Removed + * in production. Can be used by the user to add property keys of the store + * that should be displayed in devtools. + */ + _customProperties: Set; + /* Excluded from this release type: _hotUpdate */ + /* Excluded from this release type: _hotUpdating */ + /* Excluded from this release type: _hmrPayload */ +} + +/** + * Extract the state of a store type. Works with both a Setup Store or an + * Options Store. Note this unwraps refs. + */ +export declare type StoreState = SS extends Store, _ActionsTree> ? UnwrapRef : _ExtractStateFromSetupStore; + +/** + * Extracts the return type for `storeToRefs`. + * Will convert any `getters` into `ComputedRef`. + */ +declare type StoreToRefs = ToRefs & PiniaCustomStateProperties>> & ToComputedRefs>; + +/** + * Creates an object of references with all the state, getters, and plugin-added + * state properties of the store. Similar to `toRefs()` but specifically + * designed for Pinia stores so methods and non reactive properties are + * completely ignored. + * + * @param store - store to extract the refs from + */ +export declare function storeToRefs(store: SS): StoreToRefs; + +/** + * Store augmented for actions. For internal usage only. + * For internal use **only** + */ +export declare type _StoreWithActions = { + [k in keyof A]: A[k] extends (...args: infer P) => infer R ? (...args: P) => R : never; +}; + +/** + * Store augmented with getters. For internal usage only. + * For internal use **only** + */ +export declare type _StoreWithGetters = { + readonly [k in keyof G]: G[k] extends (...args: any[]) => infer R ? R : UnwrapRef; +}; + +/** + * Base store with state and functions. Should not be used directly. + */ +export declare interface _StoreWithState extends StoreProperties { + /** + * State of the Store. Setting it will internally call `$patch()` to update the state. + */ + $state: UnwrapRef & PiniaCustomStateProperties; + /** + * Applies a state patch to current state. Allows passing nested values + * + * @param partialState - patch to apply to the state + */ + $patch(partialState: _DeepPartial>): void; + /** + * Group multiple changes into one function. Useful when mutating objects like + * Sets or arrays and applying an object patch isn't practical, e.g. appending + * to an array. The function passed to `$patch()` **must be synchronous**. + * + * @param stateMutator - function that mutates `state`, cannot be asynchronous + */ + $patch) => any>(stateMutator: ReturnType extends Promise ? never : F): void; + /** + * Resets the store to its initial state by building a new state object. + * TODO: make this options only + */ + $reset(): void; + /** + * Setups a callback to be called whenever the state changes. It also returns a function to remove the callback. Note + * that when calling `store.$subscribe()` inside of a component, it will be automatically cleaned up when the + * component gets unmounted unless `detached` is set to true. + * + * @param callback - callback passed to the watcher + * @param options - `watch` options + `detached` to detach the subscription from the context (usually a component) + * this is called from. Note that the `flush` option does not affect calls to `store.$patch()`. + * @returns function that removes the watcher + */ + $subscribe(callback: SubscriptionCallback, options?: { + detached?: boolean; + } & WatchOptions): () => void; + /** + * Setups a callback to be called every time an action is about to get + * invoked. The callback receives an object with all the relevant information + * of the invoked action: + * - `store`: the store it is invoked on + * - `name`: The name of the action + * - `args`: The parameters passed to the action + * + * On top of these, it receives two functions that allow setting up a callback + * once the action finishes or when it fails. + * + * It also returns a function to remove the callback. Note than when calling + * `store.$onAction()` inside of a component, it will be automatically cleaned + * up when the component gets unmounted unless `detached` is set to true. + * + * @example + * + *```js + *store.$onAction(({ after, onError }) => { + * // Here you could share variables between all of the hooks as well as + * // setting up watchers and clean them up + * after((resolvedValue) => { + * // can be used to cleanup side effects + * . // `resolvedValue` is the value returned by the action, if it's a + * . // Promise, it will be the resolved value instead of the Promise + * }) + * onError((error) => { + * // can be used to pass up errors + * }) + *}) + *``` + * + * @param callback - callback called before every action + * @param detached - detach the subscription from the context this is called from + * @returns function that removes the watcher + */ + $onAction(callback: StoreOnActionListener, detached?: boolean): () => void; + /** + * Stops the associated effect scope of the store and remove it from the store + * registry. Plugins can override this method to cleanup any added effects. + * e.g. devtools plugin stops displaying disposed stores from devtools. + * Note this doesn't delete the state of the store, you have to do it manually with + * `delete pinia.state.value[store.$id]` if you want to. If you don't and the + * store is used again, it will reuse the previous state. + */ + $dispose(): void; + /* Excluded from this release type: _r */ +} + +/** + * Callback of a subscription + */ +export declare type SubscriptionCallback = ( +/** + * Object with information relative to the store mutation that triggered the + * subscription. + */ +mutation: SubscriptionCallbackMutation, +/** + * State of the store when the subscription is triggered. Same as + * `store.$state`. + */ +state: UnwrapRef) => void; + +/** + * Context object passed to a subscription callback. + */ +export declare type SubscriptionCallbackMutation = SubscriptionCallbackMutationDirect | SubscriptionCallbackMutationPatchObject | SubscriptionCallbackMutationPatchFunction; + +/** + * Base type for the context passed to a subscription callback. Internal type. + */ +export declare interface _SubscriptionCallbackMutationBase { + /** + * Type of the mutation. + */ + type: MutationType; + /** + * `id` of the store doing the mutation. + */ + storeId: string; + /** + * 🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from + * https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in + * devtools and plugins **during development only**. + */ + events?: DebuggerEvent[] | DebuggerEvent; +} + +/** + * Context passed to a subscription callback when directly mutating the state of + * a store with `store.someState = newValue` or `store.$state.someState = + * newValue`. + */ +export declare interface SubscriptionCallbackMutationDirect extends _SubscriptionCallbackMutationBase { + type: MutationType.direct; + events: DebuggerEvent; +} + +/** + * Context passed to a subscription callback when `store.$patch()` is called + * with a function. + */ +export declare interface SubscriptionCallbackMutationPatchFunction extends _SubscriptionCallbackMutationBase { + type: MutationType.patchFunction; + events: DebuggerEvent[]; +} + +/** + * Context passed to a subscription callback when `store.$patch()` is called + * with an object. + */ +export declare interface SubscriptionCallbackMutationPatchObject extends _SubscriptionCallbackMutationBase { + type: MutationType.patchObject; + events: DebuggerEvent[]; + /** + * Object passed to `store.$patch()`. + */ + payload: _DeepPartial; +} + +declare type ToComputedRefs = { + [K in keyof T]: ToRef extends Ref ? ComputedRef : ToRef; +}; + +/** + * Type that enables refactoring through IDE. + * For internal use **only** + */ +export declare type _UnwrapAll = { + [K in keyof SS]: UnwrapRef; +}; + +export { } + +// Extensions of Vue types to be appended manually +// https://github.com/microsoft/rushstack/issues/2090 +// https://github.com/microsoft/rushstack/issues/1709 + +// @ts-ignore: works on Vue 2, fails in Vue 3 +declare module 'vue/types/vue' { + interface Vue { + /** + * Currently installed pinia instance. + */ + $pinia: Pinia + + /** + * Cache of stores instantiated by the current instance. Used by map + * helpers. Used internally by Pinia. + * + * @internal + */ + _pStores?: Record + } +} + +// @ts-ignore: works on Vue 2, fails in Vue 3 +declare module 'vue/types/options' { + interface ComponentOptions { + /** + * Pinia instance to install in your application. Should be passed to the + * root Vue. + */ + pinia?: Pinia + } +} + +// TODO: figure out why it cannot be 'vue' +// @ts-ignore: works on Vue 3, fails in Vue 2 +declare module '@vue/runtime-core' { + export interface ComponentCustomProperties { + /** + * Access to the application's Pinia + */ + $pinia: Pinia + + /** + * Cache of stores instantiated by the current instance. Used by devtools to + * list currently used stores. Used internally by Pinia. + * + * @internal + */ + _pStores?: Record + } +} diff --git a/node_modules/pinia/dist/pinia.esm-browser.js b/node_modules/pinia/dist/pinia.esm-browser.js new file mode 100644 index 0000000..f8fcf11 --- /dev/null +++ b/node_modules/pinia/dist/pinia.esm-browser.js @@ -0,0 +1,1997 @@ +/*! + * pinia v2.1.7 + * (c) 2023 Eduardo San Martin Morote + * @license MIT + */ +import { hasInjectionContext, inject, toRaw, watch, unref, markRaw, effectScope, ref, isVue2, isRef, isReactive, set, getCurrentScope, onScopeDispose, getCurrentInstance, reactive, toRef, del, nextTick, computed, toRefs } from 'vue-demi'; +import { setupDevtoolsPlugin } from '@vue/devtools-api'; + +/** + * setActivePinia must be called to handle SSR at the top of functions like + * `fetch`, `setup`, `serverPrefetch` and others + */ +let activePinia; +/** + * Sets or unsets the active pinia. Used in SSR and internally when calling + * actions and getters + * + * @param pinia - Pinia instance + */ +// @ts-expect-error: cannot constrain the type of the return +const setActivePinia = (pinia) => (activePinia = pinia); +/** + * Get the currently active pinia if there is any. + */ +const getActivePinia = () => (hasInjectionContext() && inject(piniaSymbol)) || activePinia; +const piniaSymbol = (Symbol('pinia') ); + +function isPlainObject( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +o) { + return (o && + typeof o === 'object' && + Object.prototype.toString.call(o) === '[object Object]' && + typeof o.toJSON !== 'function'); +} +// type DeepReadonly = { readonly [P in keyof T]: DeepReadonly } +// TODO: can we change these to numbers? +/** + * Possible types for SubscriptionCallback + */ +var MutationType; +(function (MutationType) { + /** + * Direct mutation of the state: + * + * - `store.name = 'new name'` + * - `store.$state.name = 'new name'` + * - `store.list.push('new item')` + */ + MutationType["direct"] = "direct"; + /** + * Mutated the state with `$patch` and an object + * + * - `store.$patch({ name: 'newName' })` + */ + MutationType["patchObject"] = "patch object"; + /** + * Mutated the state with `$patch` and a function + * + * - `store.$patch(state => state.name = 'newName')` + */ + MutationType["patchFunction"] = "patch function"; + // maybe reset? for $state = {} and $reset +})(MutationType || (MutationType = {})); + +const IS_CLIENT = typeof window !== 'undefined'; +/** + * Should we add the devtools plugins. + * - only if dev mode or forced through the prod devtools flag + * - not in test + * - only if window exists (could change in the future) + */ +const USE_DEVTOOLS = IS_CLIENT; + +/* + * FileSaver.js A saveAs() FileSaver implementation. + * + * Originally by Eli Grey, adapted as an ESM module by Eduardo San Martin + * Morote. + * + * License : MIT + */ +// The one and only way of getting global scope in all environments +// https://stackoverflow.com/q/3277182/1008999 +const _global = /*#__PURE__*/ (() => typeof window === 'object' && window.window === window + ? window + : typeof self === 'object' && self.self === self + ? self + : typeof global === 'object' && global.global === global + ? global + : typeof globalThis === 'object' + ? globalThis + : { HTMLElement: null })(); +function bom(blob, { autoBom = false } = {}) { + // prepend BOM for UTF-8 XML and text/* types (including HTML) + // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF + if (autoBom && + /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { + return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type }); + } + return blob; +} +function download(url, name, opts) { + const xhr = new XMLHttpRequest(); + xhr.open('GET', url); + xhr.responseType = 'blob'; + xhr.onload = function () { + saveAs(xhr.response, name, opts); + }; + xhr.onerror = function () { + console.error('could not download file'); + }; + xhr.send(); +} +function corsEnabled(url) { + const xhr = new XMLHttpRequest(); + // use sync to avoid popup blocker + xhr.open('HEAD', url, false); + try { + xhr.send(); + } + catch (e) { } + return xhr.status >= 200 && xhr.status <= 299; +} +// `a.click()` doesn't work for all browsers (#465) +function click(node) { + try { + node.dispatchEvent(new MouseEvent('click')); + } + catch (e) { + const evt = document.createEvent('MouseEvents'); + evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null); + node.dispatchEvent(evt); + } +} +const _navigator = + typeof navigator === 'object' ? navigator : { userAgent: '' }; +// Detect WebView inside a native macOS app by ruling out all browsers +// We just need to check for 'Safari' because all other browsers (besides Firefox) include that too +// https://www.whatismybrowser.com/guides/the-latest-user-agent/macos +const isMacOSWebView = /*#__PURE__*/ (() => /Macintosh/.test(_navigator.userAgent) && + /AppleWebKit/.test(_navigator.userAgent) && + !/Safari/.test(_navigator.userAgent))(); +const saveAs = !IS_CLIENT + ? () => { } // noop + : // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program + typeof HTMLAnchorElement !== 'undefined' && + 'download' in HTMLAnchorElement.prototype && + !isMacOSWebView + ? downloadSaveAs + : // Use msSaveOrOpenBlob as a second approach + 'msSaveOrOpenBlob' in _navigator + ? msSaveAs + : // Fallback to using FileReader and a popup + fileSaverSaveAs; +function downloadSaveAs(blob, name = 'download', opts) { + const a = document.createElement('a'); + a.download = name; + a.rel = 'noopener'; // tabnabbing + // TODO: detect chrome extensions & packaged apps + // a.target = '_blank' + if (typeof blob === 'string') { + // Support regular links + a.href = blob; + if (a.origin !== location.origin) { + if (corsEnabled(a.href)) { + download(blob, name, opts); + } + else { + a.target = '_blank'; + click(a); + } + } + else { + click(a); + } + } + else { + // Support blobs + a.href = URL.createObjectURL(blob); + setTimeout(function () { + URL.revokeObjectURL(a.href); + }, 4e4); // 40s + setTimeout(function () { + click(a); + }, 0); + } +} +function msSaveAs(blob, name = 'download', opts) { + if (typeof blob === 'string') { + if (corsEnabled(blob)) { + download(blob, name, opts); + } + else { + const a = document.createElement('a'); + a.href = blob; + a.target = '_blank'; + setTimeout(function () { + click(a); + }); + } + } + else { + // @ts-ignore: works on windows + navigator.msSaveOrOpenBlob(bom(blob, opts), name); + } +} +function fileSaverSaveAs(blob, name, opts, popup) { + // Open a popup immediately do go around popup blocker + // Mostly only available on user interaction and the fileReader is async so... + popup = popup || open('', '_blank'); + if (popup) { + popup.document.title = popup.document.body.innerText = 'downloading...'; + } + if (typeof blob === 'string') + return download(blob, name, opts); + const force = blob.type === 'application/octet-stream'; + const isSafari = /constructor/i.test(String(_global.HTMLElement)) || 'safari' in _global; + const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); + if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && + typeof FileReader !== 'undefined') { + // Safari doesn't allow downloading of blob URLs + const reader = new FileReader(); + reader.onloadend = function () { + let url = reader.result; + if (typeof url !== 'string') { + popup = null; + throw new Error('Wrong reader.result type'); + } + url = isChromeIOS + ? url + : url.replace(/^data:[^;]*;/, 'data:attachment/file;'); + if (popup) { + popup.location.href = url; + } + else { + location.assign(url); + } + popup = null; // reverse-tabnabbing #460 + }; + reader.readAsDataURL(blob); + } + else { + const url = URL.createObjectURL(blob); + if (popup) + popup.location.assign(url); + else + location.href = url; + popup = null; // reverse-tabnabbing #460 + setTimeout(function () { + URL.revokeObjectURL(url); + }, 4e4); // 40s + } +} + +/** + * Shows a toast or console.log + * + * @param message - message to log + * @param type - different color of the tooltip + */ +function toastMessage(message, type) { + const piniaMessage = '🍍 ' + message; + if (typeof __VUE_DEVTOOLS_TOAST__ === 'function') { + // No longer available :( + __VUE_DEVTOOLS_TOAST__(piniaMessage, type); + } + else if (type === 'error') { + console.error(piniaMessage); + } + else if (type === 'warn') { + console.warn(piniaMessage); + } + else { + console.log(piniaMessage); + } +} +function isPinia(o) { + return '_a' in o && 'install' in o; +} + +/** + * This file contain devtools actions, they are not Pinia actions. + */ +// --- +function checkClipboardAccess() { + if (!('clipboard' in navigator)) { + toastMessage(`Your browser doesn't support the Clipboard API`, 'error'); + return true; + } +} +function checkNotFocusedError(error) { + if (error instanceof Error && + error.message.toLowerCase().includes('document is not focused')) { + toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', 'warn'); + return true; + } + return false; +} +async function actionGlobalCopyState(pinia) { + if (checkClipboardAccess()) + return; + try { + await navigator.clipboard.writeText(JSON.stringify(pinia.state.value)); + toastMessage('Global state copied to clipboard.'); + } + catch (error) { + if (checkNotFocusedError(error)) + return; + toastMessage(`Failed to serialize the state. Check the console for more details.`, 'error'); + console.error(error); + } +} +async function actionGlobalPasteState(pinia) { + if (checkClipboardAccess()) + return; + try { + loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText())); + toastMessage('Global state pasted from clipboard.'); + } + catch (error) { + if (checkNotFocusedError(error)) + return; + toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, 'error'); + console.error(error); + } +} +async function actionGlobalSaveState(pinia) { + try { + saveAs(new Blob([JSON.stringify(pinia.state.value)], { + type: 'text/plain;charset=utf-8', + }), 'pinia-state.json'); + } + catch (error) { + toastMessage(`Failed to export the state as JSON. Check the console for more details.`, 'error'); + console.error(error); + } +} +let fileInput; +function getFileOpener() { + if (!fileInput) { + fileInput = document.createElement('input'); + fileInput.type = 'file'; + fileInput.accept = '.json'; + } + function openFile() { + return new Promise((resolve, reject) => { + fileInput.onchange = async () => { + const files = fileInput.files; + if (!files) + return resolve(null); + const file = files.item(0); + if (!file) + return resolve(null); + return resolve({ text: await file.text(), file }); + }; + // @ts-ignore: TODO: changed from 4.3 to 4.4 + fileInput.oncancel = () => resolve(null); + fileInput.onerror = reject; + fileInput.click(); + }); + } + return openFile; +} +async function actionGlobalOpenStateFile(pinia) { + try { + const open = getFileOpener(); + const result = await open(); + if (!result) + return; + const { text, file } = result; + loadStoresState(pinia, JSON.parse(text)); + toastMessage(`Global state imported from "${file.name}".`); + } + catch (error) { + toastMessage(`Failed to import the state from JSON. Check the console for more details.`, 'error'); + console.error(error); + } +} +function loadStoresState(pinia, state) { + for (const key in state) { + const storeState = pinia.state.value[key]; + // store is already instantiated, patch it + if (storeState) { + Object.assign(storeState, state[key]); + } + else { + // store is not instantiated, set the initial state + pinia.state.value[key] = state[key]; + } + } +} + +function formatDisplay(display) { + return { + _custom: { + display, + }, + }; +} +const PINIA_ROOT_LABEL = '🍍 Pinia (root)'; +const PINIA_ROOT_ID = '_root'; +function formatStoreForInspectorTree(store) { + return isPinia(store) + ? { + id: PINIA_ROOT_ID, + label: PINIA_ROOT_LABEL, + } + : { + id: store.$id, + label: store.$id, + }; +} +function formatStoreForInspectorState(store) { + if (isPinia(store)) { + const storeNames = Array.from(store._s.keys()); + const storeMap = store._s; + const state = { + state: storeNames.map((storeId) => ({ + editable: true, + key: storeId, + value: store.state.value[storeId], + })), + getters: storeNames + .filter((id) => storeMap.get(id)._getters) + .map((id) => { + const store = storeMap.get(id); + return { + editable: false, + key: id, + value: store._getters.reduce((getters, key) => { + getters[key] = store[key]; + return getters; + }, {}), + }; + }), + }; + return state; + } + const state = { + state: Object.keys(store.$state).map((key) => ({ + editable: true, + key, + value: store.$state[key], + })), + }; + // avoid adding empty getters + if (store._getters && store._getters.length) { + state.getters = store._getters.map((getterName) => ({ + editable: false, + key: getterName, + value: store[getterName], + })); + } + if (store._customProperties.size) { + state.customProperties = Array.from(store._customProperties).map((key) => ({ + editable: true, + key, + value: store[key], + })); + } + return state; +} +function formatEventData(events) { + if (!events) + return {}; + if (Array.isArray(events)) { + // TODO: handle add and delete for arrays and objects + return events.reduce((data, event) => { + data.keys.push(event.key); + data.operations.push(event.type); + data.oldValue[event.key] = event.oldValue; + data.newValue[event.key] = event.newValue; + return data; + }, { + oldValue: {}, + keys: [], + operations: [], + newValue: {}, + }); + } + else { + return { + operation: formatDisplay(events.type), + key: formatDisplay(events.key), + oldValue: events.oldValue, + newValue: events.newValue, + }; + } +} +function formatMutationType(type) { + switch (type) { + case MutationType.direct: + return 'mutation'; + case MutationType.patchFunction: + return '$patch'; + case MutationType.patchObject: + return '$patch'; + default: + return 'unknown'; + } +} + +// timeline can be paused when directly changing the state +let isTimelineActive = true; +const componentStateTypes = []; +const MUTATIONS_LAYER_ID = 'pinia:mutations'; +const INSPECTOR_ID = 'pinia'; +const { assign: assign$1 } = Object; +/** + * Gets the displayed name of a store in devtools + * + * @param id - id of the store + * @returns a formatted string + */ +const getStoreType = (id) => '🍍 ' + id; +/** + * Add the pinia plugin without any store. Allows displaying a Pinia plugin tab + * as soon as it is added to the application. + * + * @param app - Vue application + * @param pinia - pinia instance + */ +function registerPiniaDevtools(app, pinia) { + setupDevtoolsPlugin({ + id: 'dev.esm.pinia', + label: 'Pinia 🍍', + logo: 'https://pinia.vuejs.org/logo.svg', + packageName: 'pinia', + homepage: 'https://pinia.vuejs.org', + componentStateTypes, + app, + }, (api) => { + if (typeof api.now !== 'function') { + toastMessage('You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.'); + } + api.addTimelineLayer({ + id: MUTATIONS_LAYER_ID, + label: `Pinia 🍍`, + color: 0xe5df88, + }); + api.addInspector({ + id: INSPECTOR_ID, + label: 'Pinia 🍍', + icon: 'storage', + treeFilterPlaceholder: 'Search stores', + actions: [ + { + icon: 'content_copy', + action: () => { + actionGlobalCopyState(pinia); + }, + tooltip: 'Serialize and copy the state', + }, + { + icon: 'content_paste', + action: async () => { + await actionGlobalPasteState(pinia); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }, + tooltip: 'Replace the state with the content of your clipboard', + }, + { + icon: 'save', + action: () => { + actionGlobalSaveState(pinia); + }, + tooltip: 'Save the state as a JSON file', + }, + { + icon: 'folder_open', + action: async () => { + await actionGlobalOpenStateFile(pinia); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }, + tooltip: 'Import the state from a JSON file', + }, + ], + nodeActions: [ + { + icon: 'restore', + tooltip: 'Reset the state (with "$reset")', + action: (nodeId) => { + const store = pinia._s.get(nodeId); + if (!store) { + toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, 'warn'); + } + else if (typeof store.$reset !== 'function') { + toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, 'warn'); + } + else { + store.$reset(); + toastMessage(`Store "${nodeId}" reset.`); + } + }, + }, + ], + }); + api.on.inspectComponent((payload, ctx) => { + const proxy = (payload.componentInstance && + payload.componentInstance.proxy); + if (proxy && proxy._pStores) { + const piniaStores = payload.componentInstance.proxy._pStores; + Object.values(piniaStores).forEach((store) => { + payload.instanceData.state.push({ + type: getStoreType(store.$id), + key: 'state', + editable: true, + value: store._isOptionsAPI + ? { + _custom: { + value: toRaw(store.$state), + actions: [ + { + icon: 'restore', + tooltip: 'Reset the state of this store', + action: () => store.$reset(), + }, + ], + }, + } + : // NOTE: workaround to unwrap transferred refs + Object.keys(store.$state).reduce((state, key) => { + state[key] = store.$state[key]; + return state; + }, {}), + }); + if (store._getters && store._getters.length) { + payload.instanceData.state.push({ + type: getStoreType(store.$id), + key: 'getters', + editable: false, + value: store._getters.reduce((getters, key) => { + try { + getters[key] = store[key]; + } + catch (error) { + // @ts-expect-error: we just want to show it in devtools + getters[key] = error; + } + return getters; + }, {}), + }); + } + }); + } + }); + api.on.getInspectorTree((payload) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + let stores = [pinia]; + stores = stores.concat(Array.from(pinia._s.values())); + payload.rootNodes = (payload.filter + ? stores.filter((store) => '$id' in store + ? store.$id + .toLowerCase() + .includes(payload.filter.toLowerCase()) + : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase())) + : stores).map(formatStoreForInspectorTree); + } + }); + api.on.getInspectorState((payload) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + const inspectedStore = payload.nodeId === PINIA_ROOT_ID + ? pinia + : pinia._s.get(payload.nodeId); + if (!inspectedStore) { + // this could be the selected store restored for a different project + // so it's better not to say anything here + return; + } + if (inspectedStore) { + payload.state = formatStoreForInspectorState(inspectedStore); + } + } + }); + api.on.editInspectorState((payload, ctx) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + const inspectedStore = payload.nodeId === PINIA_ROOT_ID + ? pinia + : pinia._s.get(payload.nodeId); + if (!inspectedStore) { + return toastMessage(`store "${payload.nodeId}" not found`, 'error'); + } + const { path } = payload; + if (!isPinia(inspectedStore)) { + // access only the state + if (path.length !== 1 || + !inspectedStore._customProperties.has(path[0]) || + path[0] in inspectedStore.$state) { + path.unshift('$state'); + } + } + else { + // Root access, we can omit the `.value` because the devtools API does it for us + path.unshift('state'); + } + isTimelineActive = false; + payload.set(inspectedStore, path, payload.state.value); + isTimelineActive = true; + } + }); + api.on.editComponentState((payload) => { + if (payload.type.startsWith('🍍')) { + const storeId = payload.type.replace(/^🍍\s*/, ''); + const store = pinia._s.get(storeId); + if (!store) { + return toastMessage(`store "${storeId}" not found`, 'error'); + } + const { path } = payload; + if (path[0] !== 'state') { + return toastMessage(`Invalid path for store "${storeId}":\n${path}\nOnly state can be modified.`); + } + // rewrite the first entry to be able to directly set the state as + // well as any other path + path[0] = '$state'; + isTimelineActive = false; + payload.set(store, path, payload.state.value); + isTimelineActive = true; + } + }); + }); +} +function addStoreToDevtools(app, store) { + if (!componentStateTypes.includes(getStoreType(store.$id))) { + componentStateTypes.push(getStoreType(store.$id)); + } + setupDevtoolsPlugin({ + id: 'dev.esm.pinia', + label: 'Pinia 🍍', + logo: 'https://pinia.vuejs.org/logo.svg', + packageName: 'pinia', + homepage: 'https://pinia.vuejs.org', + componentStateTypes, + app, + settings: { + logStoreChanges: { + label: 'Notify about new/deleted stores', + type: 'boolean', + defaultValue: true, + }, + // useEmojis: { + // label: 'Use emojis in messages ⚡️', + // type: 'boolean', + // defaultValue: true, + // }, + }, + }, (api) => { + // gracefully handle errors + const now = typeof api.now === 'function' ? api.now.bind(api) : Date.now; + store.$onAction(({ after, onError, name, args }) => { + const groupId = runningActionId++; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🛫 ' + name, + subtitle: 'start', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + }, + groupId, + }, + }); + after((result) => { + activeAction = undefined; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🛬 ' + name, + subtitle: 'end', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + result, + }, + groupId, + }, + }); + }); + onError((error) => { + activeAction = undefined; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + logType: 'error', + title: '💥 ' + name, + subtitle: 'end', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + error, + }, + groupId, + }, + }); + }); + }, true); + store._customProperties.forEach((name) => { + watch(() => unref(store[name]), (newValue, oldValue) => { + api.notifyComponentUpdate(); + api.sendInspectorState(INSPECTOR_ID); + if (isTimelineActive) { + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: 'Change', + subtitle: name, + data: { + newValue, + oldValue, + }, + groupId: activeAction, + }, + }); + } + }, { deep: true }); + }); + store.$subscribe(({ events, type }, state) => { + api.notifyComponentUpdate(); + api.sendInspectorState(INSPECTOR_ID); + if (!isTimelineActive) + return; + // rootStore.state[store.id] = state + const eventData = { + time: now(), + title: formatMutationType(type), + data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)), + groupId: activeAction, + }; + if (type === MutationType.patchFunction) { + eventData.subtitle = '⤵️'; + } + else if (type === MutationType.patchObject) { + eventData.subtitle = '🧩'; + } + else if (events && !Array.isArray(events)) { + eventData.subtitle = events.type; + } + if (events) { + eventData.data['rawEvent(s)'] = { + _custom: { + display: 'DebuggerEvent', + type: 'object', + tooltip: 'raw DebuggerEvent[]', + value: events, + }, + }; + } + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: eventData, + }); + }, { detached: true, flush: 'sync' }); + const hotUpdate = store._hotUpdate; + store._hotUpdate = markRaw((newStore) => { + hotUpdate(newStore); + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🔥 ' + store.$id, + subtitle: 'HMR update', + data: { + store: formatDisplay(store.$id), + info: formatDisplay(`HMR update`), + }, + }, + }); + // update the devtools too + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }); + const { $dispose } = store; + store.$dispose = () => { + $dispose(); + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + api.getSettings().logStoreChanges && + toastMessage(`Disposed "${store.$id}" store 🗑`); + }; + // trigger an update so it can display new registered stores + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + api.getSettings().logStoreChanges && + toastMessage(`"${store.$id}" store installed 🆕`); + }); +} +let runningActionId = 0; +let activeAction; +/** + * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the + * context of all actions, allowing us to set `runningAction` on each access and effectively associating any state + * mutation to the action. + * + * @param store - store to patch + * @param actionNames - list of actionst to patch + */ +function patchActionForGrouping(store, actionNames, wrapWithProxy) { + // original actions of the store as they are given by pinia. We are going to override them + const actions = actionNames.reduce((storeActions, actionName) => { + // use toRaw to avoid tracking #541 + storeActions[actionName] = toRaw(store)[actionName]; + return storeActions; + }, {}); + for (const actionName in actions) { + store[actionName] = function () { + // the running action id is incremented in a before action hook + const _actionId = runningActionId; + const trackedStore = wrapWithProxy + ? new Proxy(store, { + get(...args) { + activeAction = _actionId; + return Reflect.get(...args); + }, + set(...args) { + activeAction = _actionId; + return Reflect.set(...args); + }, + }) + : store; + // For Setup Stores we need https://github.com/tc39/proposal-async-context + activeAction = _actionId; + const retValue = actions[actionName].apply(trackedStore, arguments); + // this is safer as async actions in Setup Stores would associate mutations done outside of the action + activeAction = undefined; + return retValue; + }; + } +} +/** + * pinia.use(devtoolsPlugin) + */ +function devtoolsPlugin({ app, store, options }) { + // HMR module + if (store.$id.startsWith('__hot:')) { + return; + } + // detect option api vs setup api + store._isOptionsAPI = !!options.state; + patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI); + // Upgrade the HMR to also update the new actions + const originalHotUpdate = store._hotUpdate; + toRaw(store)._hotUpdate = function (newStore) { + originalHotUpdate.apply(this, arguments); + patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI); + }; + addStoreToDevtools(app, + // FIXME: is there a way to allow the assignment from Store to StoreGeneric? + store); +} + +/** + * Creates a Pinia instance to be used by the application + */ +function createPinia() { + const scope = effectScope(true); + // NOTE: here we could check the window object for a state and directly set it + // if there is anything like it with Vue 3 SSR + const state = scope.run(() => ref({})); + let _p = []; + // plugins added before calling app.use(pinia) + let toBeInstalled = []; + const pinia = markRaw({ + install(app) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + if (!isVue2) { + pinia._a = app; + app.provide(piniaSymbol, pinia); + app.config.globalProperties.$pinia = pinia; + /* istanbul ignore else */ + if (USE_DEVTOOLS) { + registerPiniaDevtools(app, pinia); + } + toBeInstalled.forEach((plugin) => _p.push(plugin)); + toBeInstalled = []; + } + }, + use(plugin) { + if (!this._a && !isVue2) { + toBeInstalled.push(plugin); + } + else { + _p.push(plugin); + } + return this; + }, + _p, + // it's actually undefined here + // @ts-expect-error + _a: null, + _e: scope, + _s: new Map(), + state, + }); + // pinia devtools rely on dev only features so they cannot be forced unless + // the dev build of Vue is used. Avoid old browsers like IE11. + if (USE_DEVTOOLS && typeof Proxy !== 'undefined') { + pinia.use(devtoolsPlugin); + } + return pinia; +} + +/** + * Checks if a function is a `StoreDefinition`. + * + * @param fn - object to test + * @returns true if `fn` is a StoreDefinition + */ +const isUseStore = (fn) => { + return typeof fn === 'function' && typeof fn.$id === 'string'; +}; +/** + * Mutates in place `newState` with `oldState` to _hot update_ it. It will + * remove any key not existing in `newState` and recursively merge plain + * objects. + * + * @param newState - new state object to be patched + * @param oldState - old state that should be used to patch newState + * @returns - newState + */ +function patchObject(newState, oldState) { + // no need to go through symbols because they cannot be serialized anyway + for (const key in oldState) { + const subPatch = oldState[key]; + // skip the whole sub tree + if (!(key in newState)) { + continue; + } + const targetValue = newState[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + !isRef(subPatch) && + !isReactive(subPatch)) { + newState[key] = patchObject(targetValue, subPatch); + } + else { + // objects are either a bit more complex (e.g. refs) or primitives, so we + // just set the whole thing + if (isVue2) { + set(newState, key, subPatch); + } + else { + newState[key] = subPatch; + } + } + } + return newState; +} +/** + * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. + * + * @example + * ```js + * const useUser = defineStore(...) + * if (import.meta.hot) { + * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) + * } + * ``` + * + * @param initialUseStore - return of the defineStore to hot update + * @param hot - `import.meta.hot` + */ +function acceptHMRUpdate(initialUseStore, hot) { + return (newModule) => { + const pinia = hot.data.pinia || initialUseStore._pinia; + if (!pinia) { + // this store is still not used + return; + } + // preserve the pinia instance across loads + hot.data.pinia = pinia; + // console.log('got data', newStore) + for (const exportName in newModule) { + const useStore = newModule[exportName]; + // console.log('checking for', exportName) + if (isUseStore(useStore) && pinia._s.has(useStore.$id)) { + // console.log('Accepting update for', useStore.$id) + const id = useStore.$id; + if (id !== initialUseStore.$id) { + console.warn(`The id of the store changed from "${initialUseStore.$id}" to "${id}". Reloading.`); + // return import.meta.hot.invalidate() + return hot.invalidate(); + } + const existingStore = pinia._s.get(id); + if (!existingStore) { + console.log(`[Pinia]: skipping hmr because store doesn't exist yet`); + return; + } + useStore(pinia, existingStore); + } + } + }; +} + +const noop = () => { }; +function addSubscription(subscriptions, callback, detached, onCleanup = noop) { + subscriptions.push(callback); + const removeSubscription = () => { + const idx = subscriptions.indexOf(callback); + if (idx > -1) { + subscriptions.splice(idx, 1); + onCleanup(); + } + }; + if (!detached && getCurrentScope()) { + onScopeDispose(removeSubscription); + } + return removeSubscription; +} +function triggerSubscriptions(subscriptions, ...args) { + subscriptions.slice().forEach((callback) => { + callback(...args); + }); +} + +const fallbackRunWithContext = (fn) => fn(); +function mergeReactiveObjects(target, patchToApply) { + // Handle Map instances + if (target instanceof Map && patchToApply instanceof Map) { + patchToApply.forEach((value, key) => target.set(key, value)); + } + // Handle Set instances + if (target instanceof Set && patchToApply instanceof Set) { + patchToApply.forEach(target.add, target); + } + // no need to go through symbols because they cannot be serialized anyway + for (const key in patchToApply) { + if (!patchToApply.hasOwnProperty(key)) + continue; + const subPatch = patchToApply[key]; + const targetValue = target[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + target.hasOwnProperty(key) && + !isRef(subPatch) && + !isReactive(subPatch)) { + // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might + // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that + // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`. + target[key] = mergeReactiveObjects(targetValue, subPatch); + } + else { + // @ts-expect-error: subPatch is a valid value + target[key] = subPatch; + } + } + return target; +} +const skipHydrateSymbol = Symbol('pinia:skipHydration') + ; +const skipHydrateMap = /*#__PURE__*/ new WeakMap(); +/** + * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a + * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. + * + * @param obj - target object + * @returns obj + */ +function skipHydrate(obj) { + return isVue2 + ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work... + /* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj + : Object.defineProperty(obj, skipHydrateSymbol, {}); +} +/** + * Returns whether a value should be hydrated + * + * @param obj - target variable + * @returns true if `obj` should be hydrated + */ +function shouldHydrate(obj) { + return isVue2 + ? /* istanbul ignore next */ !skipHydrateMap.has(obj) + : !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol); +} +const { assign } = Object; +function isComputed(o) { + return !!(isRef(o) && o.effect); +} +function createOptionsStore(id, options, pinia, hot) { + const { state, actions, getters } = options; + const initialState = pinia.state.value[id]; + let store; + function setup() { + if (!initialState && (!hot)) { + /* istanbul ignore if */ + if (isVue2) { + set(pinia.state.value, id, state ? state() : {}); + } + else { + pinia.state.value[id] = state ? state() : {}; + } + } + // avoid creating a state in pinia.state.value + const localState = hot + ? // use ref() to unwrap refs inside state TODO: check if this is still necessary + toRefs(ref(state ? state() : {}).value) + : toRefs(pinia.state.value[id]); + return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => { + if (name in localState) { + console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`); + } + computedGetters[name] = markRaw(computed(() => { + setActivePinia(pinia); + // it was created just before + const store = pinia._s.get(id); + // allow cross using stores + /* istanbul ignore next */ + if (isVue2 && !store._r) + return; + // @ts-expect-error + // return getters![name].call(context, context) + // TODO: avoid reading the getter while assigning with a global variable + return getters[name].call(store, store); + })); + return computedGetters; + }, {})); + } + store = createSetupStore(id, setup, options, pinia, hot, true); + return store; +} +function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) { + let scope; + const optionsForPlugin = assign({ actions: {} }, options); + /* istanbul ignore if */ + if (!pinia._e.active) { + throw new Error('Pinia destroyed'); + } + // watcher options for $subscribe + const $subscribeOptions = { + deep: true, + // flush: 'post', + }; + /* istanbul ignore else */ + if (!isVue2) { + $subscribeOptions.onTrigger = (event) => { + /* istanbul ignore else */ + if (isListening) { + debuggerEvents = event; + // avoid triggering this while the store is being built and the state is being set in pinia + } + else if (isListening == false && !store._hotUpdating) { + // let patch send all the events together later + /* istanbul ignore else */ + if (Array.isArray(debuggerEvents)) { + debuggerEvents.push(event); + } + else { + console.error('🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.'); + } + } + }; + } + // internal state + let isListening; // set to true at the end + let isSyncListening; // set to true at the end + let subscriptions = []; + let actionSubscriptions = []; + let debuggerEvents; + const initialState = pinia.state.value[$id]; + // avoid setting the state for option stores if it is set + // by the setup + if (!isOptionsStore && !initialState && (!hot)) { + /* istanbul ignore if */ + if (isVue2) { + set(pinia.state.value, $id, {}); + } + else { + pinia.state.value[$id] = {}; + } + } + const hotState = ref({}); + // avoid triggering too many listeners + // https://github.com/vuejs/pinia/issues/1129 + let activeListener; + function $patch(partialStateOrMutator) { + let subscriptionMutation; + isListening = isSyncListening = false; + // reset the debugger events since patches are sync + /* istanbul ignore else */ + { + debuggerEvents = []; + } + if (typeof partialStateOrMutator === 'function') { + partialStateOrMutator(pinia.state.value[$id]); + subscriptionMutation = { + type: MutationType.patchFunction, + storeId: $id, + events: debuggerEvents, + }; + } + else { + mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator); + subscriptionMutation = { + type: MutationType.patchObject, + payload: partialStateOrMutator, + storeId: $id, + events: debuggerEvents, + }; + } + const myListenerId = (activeListener = Symbol()); + nextTick().then(() => { + if (activeListener === myListenerId) { + isListening = true; + } + }); + isSyncListening = true; + // because we paused the watcher, we need to manually call the subscriptions + triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]); + } + const $reset = isOptionsStore + ? function $reset() { + const { state } = options; + const newState = state ? state() : {}; + // we use a patch to group all changes into one single subscription + this.$patch(($state) => { + assign($state, newState); + }); + } + : /* istanbul ignore next */ + () => { + throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`); + } + ; + function $dispose() { + scope.stop(); + subscriptions = []; + actionSubscriptions = []; + pinia._s.delete($id); + } + /** + * Wraps an action to handle subscriptions. + * + * @param name - name of the action + * @param action - action to wrap + * @returns a wrapped action to handle subscriptions + */ + function wrapAction(name, action) { + return function () { + setActivePinia(pinia); + const args = Array.from(arguments); + const afterCallbackList = []; + const onErrorCallbackList = []; + function after(callback) { + afterCallbackList.push(callback); + } + function onError(callback) { + onErrorCallbackList.push(callback); + } + // @ts-expect-error + triggerSubscriptions(actionSubscriptions, { + args, + name, + store, + after, + onError, + }); + let ret; + try { + ret = action.apply(this && this.$id === $id ? this : store, args); + // handle sync errors + } + catch (error) { + triggerSubscriptions(onErrorCallbackList, error); + throw error; + } + if (ret instanceof Promise) { + return ret + .then((value) => { + triggerSubscriptions(afterCallbackList, value); + return value; + }) + .catch((error) => { + triggerSubscriptions(onErrorCallbackList, error); + return Promise.reject(error); + }); + } + // trigger after callbacks + triggerSubscriptions(afterCallbackList, ret); + return ret; + }; + } + const _hmrPayload = /*#__PURE__*/ markRaw({ + actions: {}, + getters: {}, + state: [], + hotState, + }); + const partialStore = { + _p: pinia, + // _s: scope, + $id, + $onAction: addSubscription.bind(null, actionSubscriptions), + $patch, + $reset, + $subscribe(callback, options = {}) { + const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher()); + const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => { + if (options.flush === 'sync' ? isSyncListening : isListening) { + callback({ + storeId: $id, + type: MutationType.direct, + events: debuggerEvents, + }, state); + } + }, assign({}, $subscribeOptions, options))); + return removeSubscription; + }, + $dispose, + }; + /* istanbul ignore if */ + if (isVue2) { + // start as non ready + partialStore._r = false; + } + const store = reactive(assign({ + _hmrPayload, + _customProperties: markRaw(new Set()), // devtools custom properties + }, partialStore + // must be added later + // setupStore + ) + ); + // store the partial store now so the setup of stores can instantiate each other before they are finished without + // creating infinite loops. + pinia._s.set($id, store); + const runWithContext = (pinia._a && pinia._a.runWithContext) || fallbackRunWithContext; + // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped + const setupStore = runWithContext(() => pinia._e.run(() => (scope = effectScope()).run(setup))); + // overwrite existing actions to support $onAction + for (const key in setupStore) { + const prop = setupStore[key]; + if ((isRef(prop) && !isComputed(prop)) || isReactive(prop)) { + // mark it as a piece of state to be serialized + if (hot) { + set(hotState.value, key, toRef(setupStore, key)); + // createOptionStore directly sets the state in pinia.state.value so we + // can just skip that + } + else if (!isOptionsStore) { + // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created + if (initialState && shouldHydrate(prop)) { + if (isRef(prop)) { + prop.value = initialState[key]; + } + else { + // probably a reactive object, lets recursively assign + // @ts-expect-error: prop is unknown + mergeReactiveObjects(prop, initialState[key]); + } + } + // transfer the ref to the pinia state to keep everything in sync + /* istanbul ignore if */ + if (isVue2) { + set(pinia.state.value[$id], key, prop); + } + else { + pinia.state.value[$id][key] = prop; + } + } + /* istanbul ignore else */ + { + _hmrPayload.state.push(key); + } + // action + } + else if (typeof prop === 'function') { + // @ts-expect-error: we are overriding the function we avoid wrapping if + const actionValue = hot ? prop : wrapAction(key, prop); + // this a hot module replacement store because the hotUpdate method needs + // to do it with the right context + /* istanbul ignore if */ + if (isVue2) { + set(setupStore, key, actionValue); + } + else { + // @ts-expect-error + setupStore[key] = actionValue; + } + /* istanbul ignore else */ + { + _hmrPayload.actions[key] = prop; + } + // list actions so they can be used in plugins + // @ts-expect-error + optionsForPlugin.actions[key] = prop; + } + else { + // add getters for devtools + if (isComputed(prop)) { + _hmrPayload.getters[key] = isOptionsStore + ? // @ts-expect-error + options.getters[key] + : prop; + if (IS_CLIENT) { + const getters = setupStore._getters || + // @ts-expect-error: same + (setupStore._getters = markRaw([])); + getters.push(key); + } + } + } + } + // add the state, getters, and action properties + /* istanbul ignore if */ + if (isVue2) { + Object.keys(setupStore).forEach((key) => { + set(store, key, setupStore[key]); + }); + } + else { + assign(store, setupStore); + // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object. + // Make `storeToRefs()` work with `reactive()` #799 + assign(toRaw(store), setupStore); + } + // use this instead of a computed with setter to be able to create it anywhere + // without linking the computed lifespan to wherever the store is first + // created. + Object.defineProperty(store, '$state', { + get: () => (hot ? hotState.value : pinia.state.value[$id]), + set: (state) => { + /* istanbul ignore if */ + if (hot) { + throw new Error('cannot set hotState'); + } + $patch(($state) => { + assign($state, state); + }); + }, + }); + // add the hotUpdate before plugins to allow them to override it + /* istanbul ignore else */ + { + store._hotUpdate = markRaw((newStore) => { + store._hotUpdating = true; + newStore._hmrPayload.state.forEach((stateKey) => { + if (stateKey in store.$state) { + const newStateTarget = newStore.$state[stateKey]; + const oldStateSource = store.$state[stateKey]; + if (typeof newStateTarget === 'object' && + isPlainObject(newStateTarget) && + isPlainObject(oldStateSource)) { + patchObject(newStateTarget, oldStateSource); + } + else { + // transfer the ref + newStore.$state[stateKey] = oldStateSource; + } + } + // patch direct access properties to allow store.stateProperty to work as + // store.$state.stateProperty + set(store, stateKey, toRef(newStore.$state, stateKey)); + }); + // remove deleted state properties + Object.keys(store.$state).forEach((stateKey) => { + if (!(stateKey in newStore.$state)) { + del(store, stateKey); + } + }); + // avoid devtools logging this as a mutation + isListening = false; + isSyncListening = false; + pinia.state.value[$id] = toRef(newStore._hmrPayload, 'hotState'); + isSyncListening = true; + nextTick().then(() => { + isListening = true; + }); + for (const actionName in newStore._hmrPayload.actions) { + const action = newStore[actionName]; + set(store, actionName, wrapAction(actionName, action)); + } + // TODO: does this work in both setup and option store? + for (const getterName in newStore._hmrPayload.getters) { + const getter = newStore._hmrPayload.getters[getterName]; + const getterValue = isOptionsStore + ? // special handling of options api + computed(() => { + setActivePinia(pinia); + return getter.call(store, store); + }) + : getter; + set(store, getterName, getterValue); + } + // remove deleted getters + Object.keys(store._hmrPayload.getters).forEach((key) => { + if (!(key in newStore._hmrPayload.getters)) { + del(store, key); + } + }); + // remove old actions + Object.keys(store._hmrPayload.actions).forEach((key) => { + if (!(key in newStore._hmrPayload.actions)) { + del(store, key); + } + }); + // update the values used in devtools and to allow deleting new properties later on + store._hmrPayload = newStore._hmrPayload; + store._getters = newStore._getters; + store._hotUpdating = false; + }); + } + if (USE_DEVTOOLS) { + const nonEnumerable = { + writable: true, + configurable: true, + // avoid warning on devtools trying to display this property + enumerable: false, + }; + ['_p', '_hmrPayload', '_getters', '_customProperties'].forEach((p) => { + Object.defineProperty(store, p, assign({ value: store[p] }, nonEnumerable)); + }); + } + /* istanbul ignore if */ + if (isVue2) { + // mark the store as ready before plugins + store._r = true; + } + // apply all plugins + pinia._p.forEach((extender) => { + /* istanbul ignore else */ + if (USE_DEVTOOLS) { + const extensions = scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + })); + Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key)); + assign(store, extensions); + } + else { + assign(store, scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + }))); + } + }); + if (store.$state && + typeof store.$state === 'object' && + typeof store.$state.constructor === 'function' && + !store.$state.constructor.toString().includes('[native code]')) { + console.warn(`[🍍]: The "state" must be a plain object. It cannot be\n` + + `\tstate: () => new MyClass()\n` + + `Found in store "${store.$id}".`); + } + // only apply hydrate to option stores with an initial state in pinia + if (initialState && + isOptionsStore && + options.hydrate) { + options.hydrate(store.$state, initialState); + } + isListening = true; + isSyncListening = true; + return store; +} +function defineStore( +// TODO: add proper types from above +idOrOptions, setup, setupOptions) { + let id; + let options; + const isSetupStore = typeof setup === 'function'; + if (typeof idOrOptions === 'string') { + id = idOrOptions; + // the option store setup will contain the actual options in this case + options = isSetupStore ? setupOptions : setup; + } + else { + options = idOrOptions; + id = idOrOptions.id; + if (typeof id !== 'string') { + throw new Error(`[🍍]: "defineStore()" must be passed a store id as its first argument.`); + } + } + function useStore(pinia, hot) { + const hasContext = hasInjectionContext(); + pinia = + // in test mode, ignore the argument provided as we can always retrieve a + // pinia instance with getActivePinia() + (pinia) || + (hasContext ? inject(piniaSymbol, null) : null); + if (pinia) + setActivePinia(pinia); + if (!activePinia) { + throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?\n` + + `See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.\n` + + `This will fail in production.`); + } + pinia = activePinia; + if (!pinia._s.has(id)) { + // creating the store registers it in `pinia._s` + if (isSetupStore) { + createSetupStore(id, setup, options, pinia); + } + else { + createOptionsStore(id, options, pinia); + } + /* istanbul ignore else */ + { + // @ts-expect-error: not the right inferred type + useStore._pinia = pinia; + } + } + const store = pinia._s.get(id); + if (hot) { + const hotId = '__hot:' + id; + const newStore = isSetupStore + ? createSetupStore(hotId, setup, options, pinia, true) + : createOptionsStore(hotId, assign({}, options), pinia, true); + hot._hotUpdate(newStore); + // cleanup the state properties and the store from the cache + delete pinia.state.value[hotId]; + pinia._s.delete(hotId); + } + if (IS_CLIENT) { + const currentInstance = getCurrentInstance(); + // save stores in instances to access them devtools + if (currentInstance && + currentInstance.proxy && + // avoid adding stores that are just built for hot module replacement + !hot) { + const vm = currentInstance.proxy; + const cache = '_pStores' in vm ? vm._pStores : (vm._pStores = {}); + cache[id] = store; + } + } + // StoreGeneric cannot be casted towards Store + return store; + } + useStore.$id = id; + return useStore; +} + +let mapStoreSuffix = 'Store'; +/** + * Changes the suffix added by `mapStores()`. Can be set to an empty string. + * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization + * interface if you are using TypeScript. + * + * @param suffix - new suffix + */ +function setMapStoreSuffix(suffix // could be 'Store' but that would be annoying for JS +) { + mapStoreSuffix = suffix; +} +/** + * Allows using stores without the composition API (`setup()`) by generating an + * object to be spread in the `computed` field of a component. It accepts a list + * of store definitions. + * + * @example + * ```js + * export default { + * computed: { + * // other computed properties + * ...mapStores(useUserStore, useCartStore) + * }, + * + * created() { + * this.userStore // store with id "user" + * this.cartStore // store with id "cart" + * } + * } + * ``` + * + * @param stores - list of stores to map to an object + */ +function mapStores(...stores) { + if (Array.isArray(stores[0])) { + console.warn(`[🍍]: Directly pass all stores to "mapStores()" without putting them in an array:\n` + + `Replace\n` + + `\tmapStores([useAuthStore, useCartStore])\n` + + `with\n` + + `\tmapStores(useAuthStore, useCartStore)\n` + + `This will fail in production if not fixed.`); + stores = stores[0]; + } + return stores.reduce((reduced, useStore) => { + // @ts-expect-error: $id is added by defineStore + reduced[useStore.$id + mapStoreSuffix] = function () { + return useStore(this.$pinia); + }; + return reduced; + }, {}); +} +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + reduced[key] = function () { + return useStore(this.$pinia)[key]; + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function () { + const store = useStore(this.$pinia); + const storeKey = keysOrMapper[key]; + // for some reason TS is unable to infer the type of storeKey to be a + // function + return typeof storeKey === 'function' + ? storeKey.call(this, store) + : store[storeKey]; + }; + return reduced; + }, {}); +} +/** + * Alias for `mapState()`. You should use `mapState()` instead. + * @deprecated use `mapState()` instead. + */ +const mapGetters = mapState; +/** + * Allows directly using actions from your store without using the composition + * API (`setup()`) by generating an object to be spread in the `methods` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapActions(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[key](...args); + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[keysOrMapper[key]](...args); + }; + return reduced; + }, {}); +} +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapWritableState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[key]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[key] = value); + }, + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[keysOrMapper[key]]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[keysOrMapper[key]] = value); + }, + }; + return reduced; + }, {}); +} + +/** + * Creates an object of references with all the state, getters, and plugin-added + * state properties of the store. Similar to `toRefs()` but specifically + * designed for Pinia stores so methods and non reactive properties are + * completely ignored. + * + * @param store - store to extract the refs from + */ +function storeToRefs(store) { + // See https://github.com/vuejs/pinia/issues/852 + // It's easier to just use toRefs() even if it includes more stuff + if (isVue2) { + // @ts-expect-error: toRefs include methods and others + return toRefs(store); + } + else { + store = toRaw(store); + const refs = {}; + for (const key in store) { + const value = store[key]; + if (isRef(value) || isReactive(value)) { + // @ts-expect-error: the key is state or getter + refs[key] = + // --- + toRef(store, key); + } + } + return refs; + } +} + +/** + * Vue 2 Plugin that must be installed for pinia to work. Note **you don't need + * this plugin if you are using Nuxt.js**. Use the `buildModule` instead: + * https://pinia.vuejs.org/ssr/nuxt.html. + * + * @example + * ```js + * import Vue from 'vue' + * import { PiniaVuePlugin, createPinia } from 'pinia' + * + * Vue.use(PiniaVuePlugin) + * const pinia = createPinia() + * + * new Vue({ + * el: '#app', + * // ... + * pinia, + * }) + * ``` + * + * @param _Vue - `Vue` imported from 'vue'. + */ +const PiniaVuePlugin = function (_Vue) { + // Equivalent of + // app.config.globalProperties.$pinia = pinia + _Vue.mixin({ + beforeCreate() { + const options = this.$options; + if (options.pinia) { + const pinia = options.pinia; + // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/main/src/apis/inject.ts#L31 + /* istanbul ignore else */ + if (!this._provided) { + const provideCache = {}; + Object.defineProperty(this, '_provided', { + get: () => provideCache, + set: (v) => Object.assign(provideCache, v), + }); + } + this._provided[piniaSymbol] = pinia; + // propagate the pinia instance in an SSR friendly way + // avoid adding it to nuxt twice + /* istanbul ignore else */ + if (!this.$pinia) { + this.$pinia = pinia; + } + pinia._a = this; + if (IS_CLIENT) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + } + if (USE_DEVTOOLS) { + registerPiniaDevtools(pinia._a, pinia); + } + } + else if (!this.$pinia && options.parent && options.parent.$pinia) { + this.$pinia = options.parent.$pinia; + } + }, + destroyed() { + delete this._pStores; + }, + }); +}; + +export { MutationType, PiniaVuePlugin, acceptHMRUpdate, createPinia, defineStore, getActivePinia, mapActions, mapGetters, mapState, mapStores, mapWritableState, setActivePinia, setMapStoreSuffix, skipHydrate, storeToRefs }; diff --git a/node_modules/pinia/dist/pinia.iife.js b/node_modules/pinia/dist/pinia.iife.js new file mode 100644 index 0000000..4d36fa6 --- /dev/null +++ b/node_modules/pinia/dist/pinia.iife.js @@ -0,0 +1,2181 @@ +/*! + * pinia v2.1.7 + * (c) 2023 Eduardo San Martin Morote + * @license MIT + */ +var Pinia = (function (exports, vueDemi) { + 'use strict'; + + /** + * setActivePinia must be called to handle SSR at the top of functions like + * `fetch`, `setup`, `serverPrefetch` and others + */ + let activePinia; + /** + * Sets or unsets the active pinia. Used in SSR and internally when calling + * actions and getters + * + * @param pinia - Pinia instance + */ + // @ts-expect-error: cannot constrain the type of the return + const setActivePinia = (pinia) => (activePinia = pinia); + /** + * Get the currently active pinia if there is any. + */ + const getActivePinia = () => (vueDemi.hasInjectionContext() && vueDemi.inject(piniaSymbol)) || activePinia; + const piniaSymbol = (Symbol('pinia') ); + + function getDevtoolsGlobalHook() { + return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__; + } + function getTarget() { + // @ts-ignore + return (typeof navigator !== 'undefined' && typeof window !== 'undefined') + ? window + : typeof global !== 'undefined' + ? global + : {}; + } + const isProxyAvailable = typeof Proxy === 'function'; + + const HOOK_SETUP = 'devtools-plugin:setup'; + const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set'; + + let supported; + let perf; + function isPerformanceSupported() { + var _a; + if (supported !== undefined) { + return supported; + } + if (typeof window !== 'undefined' && window.performance) { + supported = true; + perf = window.performance; + } + else if (typeof global !== 'undefined' && ((_a = global.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) { + supported = true; + perf = global.perf_hooks.performance; + } + else { + supported = false; + } + return supported; + } + function now() { + return isPerformanceSupported() ? perf.now() : Date.now(); + } + + class ApiProxy { + constructor(plugin, hook) { + this.target = null; + this.targetQueue = []; + this.onQueue = []; + this.plugin = plugin; + this.hook = hook; + const defaultSettings = {}; + if (plugin.settings) { + for (const id in plugin.settings) { + const item = plugin.settings[id]; + defaultSettings[id] = item.defaultValue; + } + } + const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`; + let currentSettings = Object.assign({}, defaultSettings); + try { + const raw = localStorage.getItem(localSettingsSaveId); + const data = JSON.parse(raw); + Object.assign(currentSettings, data); + } + catch (e) { + // noop + } + this.fallbacks = { + getSettings() { + return currentSettings; + }, + setSettings(value) { + try { + localStorage.setItem(localSettingsSaveId, JSON.stringify(value)); + } + catch (e) { + // noop + } + currentSettings = value; + }, + now() { + return now(); + }, + }; + if (hook) { + hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => { + if (pluginId === this.plugin.id) { + this.fallbacks.setSettings(value); + } + }); + } + this.proxiedOn = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target.on[prop]; + } + else { + return (...args) => { + this.onQueue.push({ + method: prop, + args, + }); + }; + } + }, + }); + this.proxiedTarget = new Proxy({}, { + get: (_target, prop) => { + if (this.target) { + return this.target[prop]; + } + else if (prop === 'on') { + return this.proxiedOn; + } + else if (Object.keys(this.fallbacks).includes(prop)) { + return (...args) => { + this.targetQueue.push({ + method: prop, + args, + resolve: () => { }, + }); + return this.fallbacks[prop](...args); + }; + } + else { + return (...args) => { + return new Promise(resolve => { + this.targetQueue.push({ + method: prop, + args, + resolve, + }); + }); + }; + } + }, + }); + } + async setRealTarget(target) { + this.target = target; + for (const item of this.onQueue) { + this.target.on[item.method](...item.args); + } + for (const item of this.targetQueue) { + item.resolve(await this.target[item.method](...item.args)); + } + } + } + + function setupDevtoolsPlugin(pluginDescriptor, setupFn) { + const descriptor = pluginDescriptor; + const target = getTarget(); + const hook = getDevtoolsGlobalHook(); + const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy; + if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) { + hook.emit(HOOK_SETUP, pluginDescriptor, setupFn); + } + else { + const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null; + const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []; + list.push({ + pluginDescriptor: descriptor, + setupFn, + proxy, + }); + if (proxy) + setupFn(proxy.proxiedTarget); + } + } + + function isPlainObject( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + o) { + return (o && + typeof o === 'object' && + Object.prototype.toString.call(o) === '[object Object]' && + typeof o.toJSON !== 'function'); + } + // type DeepReadonly = { readonly [P in keyof T]: DeepReadonly } + // TODO: can we change these to numbers? + /** + * Possible types for SubscriptionCallback + */ + exports.MutationType = void 0; + (function (MutationType) { + /** + * Direct mutation of the state: + * + * - `store.name = 'new name'` + * - `store.$state.name = 'new name'` + * - `store.list.push('new item')` + */ + MutationType["direct"] = "direct"; + /** + * Mutated the state with `$patch` and an object + * + * - `store.$patch({ name: 'newName' })` + */ + MutationType["patchObject"] = "patch object"; + /** + * Mutated the state with `$patch` and a function + * + * - `store.$patch(state => state.name = 'newName')` + */ + MutationType["patchFunction"] = "patch function"; + // maybe reset? for $state = {} and $reset + })(exports.MutationType || (exports.MutationType = {})); + + const IS_CLIENT = typeof window !== 'undefined'; + /** + * Should we add the devtools plugins. + * - only if dev mode or forced through the prod devtools flag + * - not in test + * - only if window exists (could change in the future) + */ + const USE_DEVTOOLS = IS_CLIENT; + + /* + * FileSaver.js A saveAs() FileSaver implementation. + * + * Originally by Eli Grey, adapted as an ESM module by Eduardo San Martin + * Morote. + * + * License : MIT + */ + // The one and only way of getting global scope in all environments + // https://stackoverflow.com/q/3277182/1008999 + const _global = /*#__PURE__*/ (() => typeof window === 'object' && window.window === window + ? window + : typeof self === 'object' && self.self === self + ? self + : typeof global === 'object' && global.global === global + ? global + : typeof globalThis === 'object' + ? globalThis + : { HTMLElement: null })(); + function bom(blob, { autoBom = false } = {}) { + // prepend BOM for UTF-8 XML and text/* types (including HTML) + // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF + if (autoBom && + /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { + return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type }); + } + return blob; + } + function download(url, name, opts) { + const xhr = new XMLHttpRequest(); + xhr.open('GET', url); + xhr.responseType = 'blob'; + xhr.onload = function () { + saveAs(xhr.response, name, opts); + }; + xhr.onerror = function () { + console.error('could not download file'); + }; + xhr.send(); + } + function corsEnabled(url) { + const xhr = new XMLHttpRequest(); + // use sync to avoid popup blocker + xhr.open('HEAD', url, false); + try { + xhr.send(); + } + catch (e) { } + return xhr.status >= 200 && xhr.status <= 299; + } + // `a.click()` doesn't work for all browsers (#465) + function click(node) { + try { + node.dispatchEvent(new MouseEvent('click')); + } + catch (e) { + const evt = document.createEvent('MouseEvents'); + evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null); + node.dispatchEvent(evt); + } + } + const _navigator = + typeof navigator === 'object' ? navigator : { userAgent: '' }; + // Detect WebView inside a native macOS app by ruling out all browsers + // We just need to check for 'Safari' because all other browsers (besides Firefox) include that too + // https://www.whatismybrowser.com/guides/the-latest-user-agent/macos + const isMacOSWebView = /*#__PURE__*/ (() => /Macintosh/.test(_navigator.userAgent) && + /AppleWebKit/.test(_navigator.userAgent) && + !/Safari/.test(_navigator.userAgent))(); + const saveAs = !IS_CLIENT + ? () => { } // noop + : // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program + typeof HTMLAnchorElement !== 'undefined' && + 'download' in HTMLAnchorElement.prototype && + !isMacOSWebView + ? downloadSaveAs + : // Use msSaveOrOpenBlob as a second approach + 'msSaveOrOpenBlob' in _navigator + ? msSaveAs + : // Fallback to using FileReader and a popup + fileSaverSaveAs; + function downloadSaveAs(blob, name = 'download', opts) { + const a = document.createElement('a'); + a.download = name; + a.rel = 'noopener'; // tabnabbing + // TODO: detect chrome extensions & packaged apps + // a.target = '_blank' + if (typeof blob === 'string') { + // Support regular links + a.href = blob; + if (a.origin !== location.origin) { + if (corsEnabled(a.href)) { + download(blob, name, opts); + } + else { + a.target = '_blank'; + click(a); + } + } + else { + click(a); + } + } + else { + // Support blobs + a.href = URL.createObjectURL(blob); + setTimeout(function () { + URL.revokeObjectURL(a.href); + }, 4e4); // 40s + setTimeout(function () { + click(a); + }, 0); + } + } + function msSaveAs(blob, name = 'download', opts) { + if (typeof blob === 'string') { + if (corsEnabled(blob)) { + download(blob, name, opts); + } + else { + const a = document.createElement('a'); + a.href = blob; + a.target = '_blank'; + setTimeout(function () { + click(a); + }); + } + } + else { + // @ts-ignore: works on windows + navigator.msSaveOrOpenBlob(bom(blob, opts), name); + } + } + function fileSaverSaveAs(blob, name, opts, popup) { + // Open a popup immediately do go around popup blocker + // Mostly only available on user interaction and the fileReader is async so... + popup = popup || open('', '_blank'); + if (popup) { + popup.document.title = popup.document.body.innerText = 'downloading...'; + } + if (typeof blob === 'string') + return download(blob, name, opts); + const force = blob.type === 'application/octet-stream'; + const isSafari = /constructor/i.test(String(_global.HTMLElement)) || 'safari' in _global; + const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); + if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && + typeof FileReader !== 'undefined') { + // Safari doesn't allow downloading of blob URLs + const reader = new FileReader(); + reader.onloadend = function () { + let url = reader.result; + if (typeof url !== 'string') { + popup = null; + throw new Error('Wrong reader.result type'); + } + url = isChromeIOS + ? url + : url.replace(/^data:[^;]*;/, 'data:attachment/file;'); + if (popup) { + popup.location.href = url; + } + else { + location.assign(url); + } + popup = null; // reverse-tabnabbing #460 + }; + reader.readAsDataURL(blob); + } + else { + const url = URL.createObjectURL(blob); + if (popup) + popup.location.assign(url); + else + location.href = url; + popup = null; // reverse-tabnabbing #460 + setTimeout(function () { + URL.revokeObjectURL(url); + }, 4e4); // 40s + } + } + + /** + * Shows a toast or console.log + * + * @param message - message to log + * @param type - different color of the tooltip + */ + function toastMessage(message, type) { + const piniaMessage = '🍍 ' + message; + if (typeof __VUE_DEVTOOLS_TOAST__ === 'function') { + // No longer available :( + __VUE_DEVTOOLS_TOAST__(piniaMessage, type); + } + else if (type === 'error') { + console.error(piniaMessage); + } + else if (type === 'warn') { + console.warn(piniaMessage); + } + else { + console.log(piniaMessage); + } + } + function isPinia(o) { + return '_a' in o && 'install' in o; + } + + /** + * This file contain devtools actions, they are not Pinia actions. + */ + // --- + function checkClipboardAccess() { + if (!('clipboard' in navigator)) { + toastMessage(`Your browser doesn't support the Clipboard API`, 'error'); + return true; + } + } + function checkNotFocusedError(error) { + if (error instanceof Error && + error.message.toLowerCase().includes('document is not focused')) { + toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', 'warn'); + return true; + } + return false; + } + async function actionGlobalCopyState(pinia) { + if (checkClipboardAccess()) + return; + try { + await navigator.clipboard.writeText(JSON.stringify(pinia.state.value)); + toastMessage('Global state copied to clipboard.'); + } + catch (error) { + if (checkNotFocusedError(error)) + return; + toastMessage(`Failed to serialize the state. Check the console for more details.`, 'error'); + console.error(error); + } + } + async function actionGlobalPasteState(pinia) { + if (checkClipboardAccess()) + return; + try { + loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText())); + toastMessage('Global state pasted from clipboard.'); + } + catch (error) { + if (checkNotFocusedError(error)) + return; + toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, 'error'); + console.error(error); + } + } + async function actionGlobalSaveState(pinia) { + try { + saveAs(new Blob([JSON.stringify(pinia.state.value)], { + type: 'text/plain;charset=utf-8', + }), 'pinia-state.json'); + } + catch (error) { + toastMessage(`Failed to export the state as JSON. Check the console for more details.`, 'error'); + console.error(error); + } + } + let fileInput; + function getFileOpener() { + if (!fileInput) { + fileInput = document.createElement('input'); + fileInput.type = 'file'; + fileInput.accept = '.json'; + } + function openFile() { + return new Promise((resolve, reject) => { + fileInput.onchange = async () => { + const files = fileInput.files; + if (!files) + return resolve(null); + const file = files.item(0); + if (!file) + return resolve(null); + return resolve({ text: await file.text(), file }); + }; + // @ts-ignore: TODO: changed from 4.3 to 4.4 + fileInput.oncancel = () => resolve(null); + fileInput.onerror = reject; + fileInput.click(); + }); + } + return openFile; + } + async function actionGlobalOpenStateFile(pinia) { + try { + const open = getFileOpener(); + const result = await open(); + if (!result) + return; + const { text, file } = result; + loadStoresState(pinia, JSON.parse(text)); + toastMessage(`Global state imported from "${file.name}".`); + } + catch (error) { + toastMessage(`Failed to import the state from JSON. Check the console for more details.`, 'error'); + console.error(error); + } + } + function loadStoresState(pinia, state) { + for (const key in state) { + const storeState = pinia.state.value[key]; + // store is already instantiated, patch it + if (storeState) { + Object.assign(storeState, state[key]); + } + else { + // store is not instantiated, set the initial state + pinia.state.value[key] = state[key]; + } + } + } + + function formatDisplay(display) { + return { + _custom: { + display, + }, + }; + } + const PINIA_ROOT_LABEL = '🍍 Pinia (root)'; + const PINIA_ROOT_ID = '_root'; + function formatStoreForInspectorTree(store) { + return isPinia(store) + ? { + id: PINIA_ROOT_ID, + label: PINIA_ROOT_LABEL, + } + : { + id: store.$id, + label: store.$id, + }; + } + function formatStoreForInspectorState(store) { + if (isPinia(store)) { + const storeNames = Array.from(store._s.keys()); + const storeMap = store._s; + const state = { + state: storeNames.map((storeId) => ({ + editable: true, + key: storeId, + value: store.state.value[storeId], + })), + getters: storeNames + .filter((id) => storeMap.get(id)._getters) + .map((id) => { + const store = storeMap.get(id); + return { + editable: false, + key: id, + value: store._getters.reduce((getters, key) => { + getters[key] = store[key]; + return getters; + }, {}), + }; + }), + }; + return state; + } + const state = { + state: Object.keys(store.$state).map((key) => ({ + editable: true, + key, + value: store.$state[key], + })), + }; + // avoid adding empty getters + if (store._getters && store._getters.length) { + state.getters = store._getters.map((getterName) => ({ + editable: false, + key: getterName, + value: store[getterName], + })); + } + if (store._customProperties.size) { + state.customProperties = Array.from(store._customProperties).map((key) => ({ + editable: true, + key, + value: store[key], + })); + } + return state; + } + function formatEventData(events) { + if (!events) + return {}; + if (Array.isArray(events)) { + // TODO: handle add and delete for arrays and objects + return events.reduce((data, event) => { + data.keys.push(event.key); + data.operations.push(event.type); + data.oldValue[event.key] = event.oldValue; + data.newValue[event.key] = event.newValue; + return data; + }, { + oldValue: {}, + keys: [], + operations: [], + newValue: {}, + }); + } + else { + return { + operation: formatDisplay(events.type), + key: formatDisplay(events.key), + oldValue: events.oldValue, + newValue: events.newValue, + }; + } + } + function formatMutationType(type) { + switch (type) { + case exports.MutationType.direct: + return 'mutation'; + case exports.MutationType.patchFunction: + return '$patch'; + case exports.MutationType.patchObject: + return '$patch'; + default: + return 'unknown'; + } + } + + // timeline can be paused when directly changing the state + let isTimelineActive = true; + const componentStateTypes = []; + const MUTATIONS_LAYER_ID = 'pinia:mutations'; + const INSPECTOR_ID = 'pinia'; + const { assign: assign$1 } = Object; + /** + * Gets the displayed name of a store in devtools + * + * @param id - id of the store + * @returns a formatted string + */ + const getStoreType = (id) => '🍍 ' + id; + /** + * Add the pinia plugin without any store. Allows displaying a Pinia plugin tab + * as soon as it is added to the application. + * + * @param app - Vue application + * @param pinia - pinia instance + */ + function registerPiniaDevtools(app, pinia) { + setupDevtoolsPlugin({ + id: 'dev.esm.pinia', + label: 'Pinia 🍍', + logo: 'https://pinia.vuejs.org/logo.svg', + packageName: 'pinia', + homepage: 'https://pinia.vuejs.org', + componentStateTypes, + app, + }, (api) => { + if (typeof api.now !== 'function') { + toastMessage('You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.'); + } + api.addTimelineLayer({ + id: MUTATIONS_LAYER_ID, + label: `Pinia 🍍`, + color: 0xe5df88, + }); + api.addInspector({ + id: INSPECTOR_ID, + label: 'Pinia 🍍', + icon: 'storage', + treeFilterPlaceholder: 'Search stores', + actions: [ + { + icon: 'content_copy', + action: () => { + actionGlobalCopyState(pinia); + }, + tooltip: 'Serialize and copy the state', + }, + { + icon: 'content_paste', + action: async () => { + await actionGlobalPasteState(pinia); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }, + tooltip: 'Replace the state with the content of your clipboard', + }, + { + icon: 'save', + action: () => { + actionGlobalSaveState(pinia); + }, + tooltip: 'Save the state as a JSON file', + }, + { + icon: 'folder_open', + action: async () => { + await actionGlobalOpenStateFile(pinia); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }, + tooltip: 'Import the state from a JSON file', + }, + ], + nodeActions: [ + { + icon: 'restore', + tooltip: 'Reset the state (with "$reset")', + action: (nodeId) => { + const store = pinia._s.get(nodeId); + if (!store) { + toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, 'warn'); + } + else if (typeof store.$reset !== 'function') { + toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, 'warn'); + } + else { + store.$reset(); + toastMessage(`Store "${nodeId}" reset.`); + } + }, + }, + ], + }); + api.on.inspectComponent((payload, ctx) => { + const proxy = (payload.componentInstance && + payload.componentInstance.proxy); + if (proxy && proxy._pStores) { + const piniaStores = payload.componentInstance.proxy._pStores; + Object.values(piniaStores).forEach((store) => { + payload.instanceData.state.push({ + type: getStoreType(store.$id), + key: 'state', + editable: true, + value: store._isOptionsAPI + ? { + _custom: { + value: vueDemi.toRaw(store.$state), + actions: [ + { + icon: 'restore', + tooltip: 'Reset the state of this store', + action: () => store.$reset(), + }, + ], + }, + } + : // NOTE: workaround to unwrap transferred refs + Object.keys(store.$state).reduce((state, key) => { + state[key] = store.$state[key]; + return state; + }, {}), + }); + if (store._getters && store._getters.length) { + payload.instanceData.state.push({ + type: getStoreType(store.$id), + key: 'getters', + editable: false, + value: store._getters.reduce((getters, key) => { + try { + getters[key] = store[key]; + } + catch (error) { + // @ts-expect-error: we just want to show it in devtools + getters[key] = error; + } + return getters; + }, {}), + }); + } + }); + } + }); + api.on.getInspectorTree((payload) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + let stores = [pinia]; + stores = stores.concat(Array.from(pinia._s.values())); + payload.rootNodes = (payload.filter + ? stores.filter((store) => '$id' in store + ? store.$id + .toLowerCase() + .includes(payload.filter.toLowerCase()) + : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase())) + : stores).map(formatStoreForInspectorTree); + } + }); + api.on.getInspectorState((payload) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + const inspectedStore = payload.nodeId === PINIA_ROOT_ID + ? pinia + : pinia._s.get(payload.nodeId); + if (!inspectedStore) { + // this could be the selected store restored for a different project + // so it's better not to say anything here + return; + } + if (inspectedStore) { + payload.state = formatStoreForInspectorState(inspectedStore); + } + } + }); + api.on.editInspectorState((payload, ctx) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + const inspectedStore = payload.nodeId === PINIA_ROOT_ID + ? pinia + : pinia._s.get(payload.nodeId); + if (!inspectedStore) { + return toastMessage(`store "${payload.nodeId}" not found`, 'error'); + } + const { path } = payload; + if (!isPinia(inspectedStore)) { + // access only the state + if (path.length !== 1 || + !inspectedStore._customProperties.has(path[0]) || + path[0] in inspectedStore.$state) { + path.unshift('$state'); + } + } + else { + // Root access, we can omit the `.value` because the devtools API does it for us + path.unshift('state'); + } + isTimelineActive = false; + payload.set(inspectedStore, path, payload.state.value); + isTimelineActive = true; + } + }); + api.on.editComponentState((payload) => { + if (payload.type.startsWith('🍍')) { + const storeId = payload.type.replace(/^🍍\s*/, ''); + const store = pinia._s.get(storeId); + if (!store) { + return toastMessage(`store "${storeId}" not found`, 'error'); + } + const { path } = payload; + if (path[0] !== 'state') { + return toastMessage(`Invalid path for store "${storeId}":\n${path}\nOnly state can be modified.`); + } + // rewrite the first entry to be able to directly set the state as + // well as any other path + path[0] = '$state'; + isTimelineActive = false; + payload.set(store, path, payload.state.value); + isTimelineActive = true; + } + }); + }); + } + function addStoreToDevtools(app, store) { + if (!componentStateTypes.includes(getStoreType(store.$id))) { + componentStateTypes.push(getStoreType(store.$id)); + } + setupDevtoolsPlugin({ + id: 'dev.esm.pinia', + label: 'Pinia 🍍', + logo: 'https://pinia.vuejs.org/logo.svg', + packageName: 'pinia', + homepage: 'https://pinia.vuejs.org', + componentStateTypes, + app, + settings: { + logStoreChanges: { + label: 'Notify about new/deleted stores', + type: 'boolean', + defaultValue: true, + }, + // useEmojis: { + // label: 'Use emojis in messages ⚡️', + // type: 'boolean', + // defaultValue: true, + // }, + }, + }, (api) => { + // gracefully handle errors + const now = typeof api.now === 'function' ? api.now.bind(api) : Date.now; + store.$onAction(({ after, onError, name, args }) => { + const groupId = runningActionId++; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🛫 ' + name, + subtitle: 'start', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + }, + groupId, + }, + }); + after((result) => { + activeAction = undefined; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🛬 ' + name, + subtitle: 'end', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + result, + }, + groupId, + }, + }); + }); + onError((error) => { + activeAction = undefined; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + logType: 'error', + title: '💥 ' + name, + subtitle: 'end', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + error, + }, + groupId, + }, + }); + }); + }, true); + store._customProperties.forEach((name) => { + vueDemi.watch(() => vueDemi.unref(store[name]), (newValue, oldValue) => { + api.notifyComponentUpdate(); + api.sendInspectorState(INSPECTOR_ID); + if (isTimelineActive) { + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: 'Change', + subtitle: name, + data: { + newValue, + oldValue, + }, + groupId: activeAction, + }, + }); + } + }, { deep: true }); + }); + store.$subscribe(({ events, type }, state) => { + api.notifyComponentUpdate(); + api.sendInspectorState(INSPECTOR_ID); + if (!isTimelineActive) + return; + // rootStore.state[store.id] = state + const eventData = { + time: now(), + title: formatMutationType(type), + data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)), + groupId: activeAction, + }; + if (type === exports.MutationType.patchFunction) { + eventData.subtitle = '⤵️'; + } + else if (type === exports.MutationType.patchObject) { + eventData.subtitle = '🧩'; + } + else if (events && !Array.isArray(events)) { + eventData.subtitle = events.type; + } + if (events) { + eventData.data['rawEvent(s)'] = { + _custom: { + display: 'DebuggerEvent', + type: 'object', + tooltip: 'raw DebuggerEvent[]', + value: events, + }, + }; + } + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: eventData, + }); + }, { detached: true, flush: 'sync' }); + const hotUpdate = store._hotUpdate; + store._hotUpdate = vueDemi.markRaw((newStore) => { + hotUpdate(newStore); + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🔥 ' + store.$id, + subtitle: 'HMR update', + data: { + store: formatDisplay(store.$id), + info: formatDisplay(`HMR update`), + }, + }, + }); + // update the devtools too + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }); + const { $dispose } = store; + store.$dispose = () => { + $dispose(); + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + api.getSettings().logStoreChanges && + toastMessage(`Disposed "${store.$id}" store 🗑`); + }; + // trigger an update so it can display new registered stores + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + api.getSettings().logStoreChanges && + toastMessage(`"${store.$id}" store installed 🆕`); + }); + } + let runningActionId = 0; + let activeAction; + /** + * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the + * context of all actions, allowing us to set `runningAction` on each access and effectively associating any state + * mutation to the action. + * + * @param store - store to patch + * @param actionNames - list of actionst to patch + */ + function patchActionForGrouping(store, actionNames, wrapWithProxy) { + // original actions of the store as they are given by pinia. We are going to override them + const actions = actionNames.reduce((storeActions, actionName) => { + // use toRaw to avoid tracking #541 + storeActions[actionName] = vueDemi.toRaw(store)[actionName]; + return storeActions; + }, {}); + for (const actionName in actions) { + store[actionName] = function () { + // the running action id is incremented in a before action hook + const _actionId = runningActionId; + const trackedStore = wrapWithProxy + ? new Proxy(store, { + get(...args) { + activeAction = _actionId; + return Reflect.get(...args); + }, + set(...args) { + activeAction = _actionId; + return Reflect.set(...args); + }, + }) + : store; + // For Setup Stores we need https://github.com/tc39/proposal-async-context + activeAction = _actionId; + const retValue = actions[actionName].apply(trackedStore, arguments); + // this is safer as async actions in Setup Stores would associate mutations done outside of the action + activeAction = undefined; + return retValue; + }; + } + } + /** + * pinia.use(devtoolsPlugin) + */ + function devtoolsPlugin({ app, store, options }) { + // HMR module + if (store.$id.startsWith('__hot:')) { + return; + } + // detect option api vs setup api + store._isOptionsAPI = !!options.state; + patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI); + // Upgrade the HMR to also update the new actions + const originalHotUpdate = store._hotUpdate; + vueDemi.toRaw(store)._hotUpdate = function (newStore) { + originalHotUpdate.apply(this, arguments); + patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI); + }; + addStoreToDevtools(app, + // FIXME: is there a way to allow the assignment from Store to StoreGeneric? + store); + } + + /** + * Creates a Pinia instance to be used by the application + */ + function createPinia() { + const scope = vueDemi.effectScope(true); + // NOTE: here we could check the window object for a state and directly set it + // if there is anything like it with Vue 3 SSR + const state = scope.run(() => vueDemi.ref({})); + let _p = []; + // plugins added before calling app.use(pinia) + let toBeInstalled = []; + const pinia = vueDemi.markRaw({ + install(app) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + if (!vueDemi.isVue2) { + pinia._a = app; + app.provide(piniaSymbol, pinia); + app.config.globalProperties.$pinia = pinia; + /* istanbul ignore else */ + if (USE_DEVTOOLS) { + registerPiniaDevtools(app, pinia); + } + toBeInstalled.forEach((plugin) => _p.push(plugin)); + toBeInstalled = []; + } + }, + use(plugin) { + if (!this._a && !vueDemi.isVue2) { + toBeInstalled.push(plugin); + } + else { + _p.push(plugin); + } + return this; + }, + _p, + // it's actually undefined here + // @ts-expect-error + _a: null, + _e: scope, + _s: new Map(), + state, + }); + // pinia devtools rely on dev only features so they cannot be forced unless + // the dev build of Vue is used. Avoid old browsers like IE11. + if (USE_DEVTOOLS && typeof Proxy !== 'undefined') { + pinia.use(devtoolsPlugin); + } + return pinia; + } + + /** + * Checks if a function is a `StoreDefinition`. + * + * @param fn - object to test + * @returns true if `fn` is a StoreDefinition + */ + const isUseStore = (fn) => { + return typeof fn === 'function' && typeof fn.$id === 'string'; + }; + /** + * Mutates in place `newState` with `oldState` to _hot update_ it. It will + * remove any key not existing in `newState` and recursively merge plain + * objects. + * + * @param newState - new state object to be patched + * @param oldState - old state that should be used to patch newState + * @returns - newState + */ + function patchObject(newState, oldState) { + // no need to go through symbols because they cannot be serialized anyway + for (const key in oldState) { + const subPatch = oldState[key]; + // skip the whole sub tree + if (!(key in newState)) { + continue; + } + const targetValue = newState[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + !vueDemi.isRef(subPatch) && + !vueDemi.isReactive(subPatch)) { + newState[key] = patchObject(targetValue, subPatch); + } + else { + // objects are either a bit more complex (e.g. refs) or primitives, so we + // just set the whole thing + if (vueDemi.isVue2) { + vueDemi.set(newState, key, subPatch); + } + else { + newState[key] = subPatch; + } + } + } + return newState; + } + /** + * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. + * + * @example + * ```js + * const useUser = defineStore(...) + * if (import.meta.hot) { + * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) + * } + * ``` + * + * @param initialUseStore - return of the defineStore to hot update + * @param hot - `import.meta.hot` + */ + function acceptHMRUpdate(initialUseStore, hot) { + return (newModule) => { + const pinia = hot.data.pinia || initialUseStore._pinia; + if (!pinia) { + // this store is still not used + return; + } + // preserve the pinia instance across loads + hot.data.pinia = pinia; + // console.log('got data', newStore) + for (const exportName in newModule) { + const useStore = newModule[exportName]; + // console.log('checking for', exportName) + if (isUseStore(useStore) && pinia._s.has(useStore.$id)) { + // console.log('Accepting update for', useStore.$id) + const id = useStore.$id; + if (id !== initialUseStore.$id) { + console.warn(`The id of the store changed from "${initialUseStore.$id}" to "${id}". Reloading.`); + // return import.meta.hot.invalidate() + return hot.invalidate(); + } + const existingStore = pinia._s.get(id); + if (!existingStore) { + console.log(`[Pinia]: skipping hmr because store doesn't exist yet`); + return; + } + useStore(pinia, existingStore); + } + } + }; + } + + const noop = () => { }; + function addSubscription(subscriptions, callback, detached, onCleanup = noop) { + subscriptions.push(callback); + const removeSubscription = () => { + const idx = subscriptions.indexOf(callback); + if (idx > -1) { + subscriptions.splice(idx, 1); + onCleanup(); + } + }; + if (!detached && vueDemi.getCurrentScope()) { + vueDemi.onScopeDispose(removeSubscription); + } + return removeSubscription; + } + function triggerSubscriptions(subscriptions, ...args) { + subscriptions.slice().forEach((callback) => { + callback(...args); + }); + } + + const fallbackRunWithContext = (fn) => fn(); + function mergeReactiveObjects(target, patchToApply) { + // Handle Map instances + if (target instanceof Map && patchToApply instanceof Map) { + patchToApply.forEach((value, key) => target.set(key, value)); + } + // Handle Set instances + if (target instanceof Set && patchToApply instanceof Set) { + patchToApply.forEach(target.add, target); + } + // no need to go through symbols because they cannot be serialized anyway + for (const key in patchToApply) { + if (!patchToApply.hasOwnProperty(key)) + continue; + const subPatch = patchToApply[key]; + const targetValue = target[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + target.hasOwnProperty(key) && + !vueDemi.isRef(subPatch) && + !vueDemi.isReactive(subPatch)) { + // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might + // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that + // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`. + target[key] = mergeReactiveObjects(targetValue, subPatch); + } + else { + // @ts-expect-error: subPatch is a valid value + target[key] = subPatch; + } + } + return target; + } + const skipHydrateSymbol = Symbol('pinia:skipHydration') + ; + const skipHydrateMap = /*#__PURE__*/ new WeakMap(); + /** + * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a + * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. + * + * @param obj - target object + * @returns obj + */ + function skipHydrate(obj) { + return vueDemi.isVue2 + ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work... + /* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj + : Object.defineProperty(obj, skipHydrateSymbol, {}); + } + /** + * Returns whether a value should be hydrated + * + * @param obj - target variable + * @returns true if `obj` should be hydrated + */ + function shouldHydrate(obj) { + return vueDemi.isVue2 + ? /* istanbul ignore next */ !skipHydrateMap.has(obj) + : !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol); + } + const { assign } = Object; + function isComputed(o) { + return !!(vueDemi.isRef(o) && o.effect); + } + function createOptionsStore(id, options, pinia, hot) { + const { state, actions, getters } = options; + const initialState = pinia.state.value[id]; + let store; + function setup() { + if (!initialState && (!hot)) { + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value, id, state ? state() : {}); + } + else { + pinia.state.value[id] = state ? state() : {}; + } + } + // avoid creating a state in pinia.state.value + const localState = hot + ? // use ref() to unwrap refs inside state TODO: check if this is still necessary + vueDemi.toRefs(vueDemi.ref(state ? state() : {}).value) + : vueDemi.toRefs(pinia.state.value[id]); + return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => { + if (name in localState) { + console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`); + } + computedGetters[name] = vueDemi.markRaw(vueDemi.computed(() => { + setActivePinia(pinia); + // it was created just before + const store = pinia._s.get(id); + // allow cross using stores + /* istanbul ignore next */ + if (vueDemi.isVue2 && !store._r) + return; + // @ts-expect-error + // return getters![name].call(context, context) + // TODO: avoid reading the getter while assigning with a global variable + return getters[name].call(store, store); + })); + return computedGetters; + }, {})); + } + store = createSetupStore(id, setup, options, pinia, hot, true); + return store; + } + function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) { + let scope; + const optionsForPlugin = assign({ actions: {} }, options); + /* istanbul ignore if */ + if (!pinia._e.active) { + throw new Error('Pinia destroyed'); + } + // watcher options for $subscribe + const $subscribeOptions = { + deep: true, + // flush: 'post', + }; + /* istanbul ignore else */ + if (!vueDemi.isVue2) { + $subscribeOptions.onTrigger = (event) => { + /* istanbul ignore else */ + if (isListening) { + debuggerEvents = event; + // avoid triggering this while the store is being built and the state is being set in pinia + } + else if (isListening == false && !store._hotUpdating) { + // let patch send all the events together later + /* istanbul ignore else */ + if (Array.isArray(debuggerEvents)) { + debuggerEvents.push(event); + } + else { + console.error('🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.'); + } + } + }; + } + // internal state + let isListening; // set to true at the end + let isSyncListening; // set to true at the end + let subscriptions = []; + let actionSubscriptions = []; + let debuggerEvents; + const initialState = pinia.state.value[$id]; + // avoid setting the state for option stores if it is set + // by the setup + if (!isOptionsStore && !initialState && (!hot)) { + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value, $id, {}); + } + else { + pinia.state.value[$id] = {}; + } + } + const hotState = vueDemi.ref({}); + // avoid triggering too many listeners + // https://github.com/vuejs/pinia/issues/1129 + let activeListener; + function $patch(partialStateOrMutator) { + let subscriptionMutation; + isListening = isSyncListening = false; + // reset the debugger events since patches are sync + /* istanbul ignore else */ + { + debuggerEvents = []; + } + if (typeof partialStateOrMutator === 'function') { + partialStateOrMutator(pinia.state.value[$id]); + subscriptionMutation = { + type: exports.MutationType.patchFunction, + storeId: $id, + events: debuggerEvents, + }; + } + else { + mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator); + subscriptionMutation = { + type: exports.MutationType.patchObject, + payload: partialStateOrMutator, + storeId: $id, + events: debuggerEvents, + }; + } + const myListenerId = (activeListener = Symbol()); + vueDemi.nextTick().then(() => { + if (activeListener === myListenerId) { + isListening = true; + } + }); + isSyncListening = true; + // because we paused the watcher, we need to manually call the subscriptions + triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]); + } + const $reset = isOptionsStore + ? function $reset() { + const { state } = options; + const newState = state ? state() : {}; + // we use a patch to group all changes into one single subscription + this.$patch(($state) => { + assign($state, newState); + }); + } + : /* istanbul ignore next */ + () => { + throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`); + } + ; + function $dispose() { + scope.stop(); + subscriptions = []; + actionSubscriptions = []; + pinia._s.delete($id); + } + /** + * Wraps an action to handle subscriptions. + * + * @param name - name of the action + * @param action - action to wrap + * @returns a wrapped action to handle subscriptions + */ + function wrapAction(name, action) { + return function () { + setActivePinia(pinia); + const args = Array.from(arguments); + const afterCallbackList = []; + const onErrorCallbackList = []; + function after(callback) { + afterCallbackList.push(callback); + } + function onError(callback) { + onErrorCallbackList.push(callback); + } + // @ts-expect-error + triggerSubscriptions(actionSubscriptions, { + args, + name, + store, + after, + onError, + }); + let ret; + try { + ret = action.apply(this && this.$id === $id ? this : store, args); + // handle sync errors + } + catch (error) { + triggerSubscriptions(onErrorCallbackList, error); + throw error; + } + if (ret instanceof Promise) { + return ret + .then((value) => { + triggerSubscriptions(afterCallbackList, value); + return value; + }) + .catch((error) => { + triggerSubscriptions(onErrorCallbackList, error); + return Promise.reject(error); + }); + } + // trigger after callbacks + triggerSubscriptions(afterCallbackList, ret); + return ret; + }; + } + const _hmrPayload = /*#__PURE__*/ vueDemi.markRaw({ + actions: {}, + getters: {}, + state: [], + hotState, + }); + const partialStore = { + _p: pinia, + // _s: scope, + $id, + $onAction: addSubscription.bind(null, actionSubscriptions), + $patch, + $reset, + $subscribe(callback, options = {}) { + const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher()); + const stopWatcher = scope.run(() => vueDemi.watch(() => pinia.state.value[$id], (state) => { + if (options.flush === 'sync' ? isSyncListening : isListening) { + callback({ + storeId: $id, + type: exports.MutationType.direct, + events: debuggerEvents, + }, state); + } + }, assign({}, $subscribeOptions, options))); + return removeSubscription; + }, + $dispose, + }; + /* istanbul ignore if */ + if (vueDemi.isVue2) { + // start as non ready + partialStore._r = false; + } + const store = vueDemi.reactive(assign({ + _hmrPayload, + _customProperties: vueDemi.markRaw(new Set()), // devtools custom properties + }, partialStore + // must be added later + // setupStore + ) + ); + // store the partial store now so the setup of stores can instantiate each other before they are finished without + // creating infinite loops. + pinia._s.set($id, store); + const runWithContext = (pinia._a && pinia._a.runWithContext) || fallbackRunWithContext; + // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped + const setupStore = runWithContext(() => pinia._e.run(() => (scope = vueDemi.effectScope()).run(setup))); + // overwrite existing actions to support $onAction + for (const key in setupStore) { + const prop = setupStore[key]; + if ((vueDemi.isRef(prop) && !isComputed(prop)) || vueDemi.isReactive(prop)) { + // mark it as a piece of state to be serialized + if (hot) { + vueDemi.set(hotState.value, key, vueDemi.toRef(setupStore, key)); + // createOptionStore directly sets the state in pinia.state.value so we + // can just skip that + } + else if (!isOptionsStore) { + // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created + if (initialState && shouldHydrate(prop)) { + if (vueDemi.isRef(prop)) { + prop.value = initialState[key]; + } + else { + // probably a reactive object, lets recursively assign + // @ts-expect-error: prop is unknown + mergeReactiveObjects(prop, initialState[key]); + } + } + // transfer the ref to the pinia state to keep everything in sync + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value[$id], key, prop); + } + else { + pinia.state.value[$id][key] = prop; + } + } + /* istanbul ignore else */ + { + _hmrPayload.state.push(key); + } + // action + } + else if (typeof prop === 'function') { + // @ts-expect-error: we are overriding the function we avoid wrapping if + const actionValue = hot ? prop : wrapAction(key, prop); + // this a hot module replacement store because the hotUpdate method needs + // to do it with the right context + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(setupStore, key, actionValue); + } + else { + // @ts-expect-error + setupStore[key] = actionValue; + } + /* istanbul ignore else */ + { + _hmrPayload.actions[key] = prop; + } + // list actions so they can be used in plugins + // @ts-expect-error + optionsForPlugin.actions[key] = prop; + } + else { + // add getters for devtools + if (isComputed(prop)) { + _hmrPayload.getters[key] = isOptionsStore + ? // @ts-expect-error + options.getters[key] + : prop; + if (IS_CLIENT) { + const getters = setupStore._getters || + // @ts-expect-error: same + (setupStore._getters = vueDemi.markRaw([])); + getters.push(key); + } + } + } + } + // add the state, getters, and action properties + /* istanbul ignore if */ + if (vueDemi.isVue2) { + Object.keys(setupStore).forEach((key) => { + vueDemi.set(store, key, setupStore[key]); + }); + } + else { + assign(store, setupStore); + // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object. + // Make `storeToRefs()` work with `reactive()` #799 + assign(vueDemi.toRaw(store), setupStore); + } + // use this instead of a computed with setter to be able to create it anywhere + // without linking the computed lifespan to wherever the store is first + // created. + Object.defineProperty(store, '$state', { + get: () => (hot ? hotState.value : pinia.state.value[$id]), + set: (state) => { + /* istanbul ignore if */ + if (hot) { + throw new Error('cannot set hotState'); + } + $patch(($state) => { + assign($state, state); + }); + }, + }); + // add the hotUpdate before plugins to allow them to override it + /* istanbul ignore else */ + { + store._hotUpdate = vueDemi.markRaw((newStore) => { + store._hotUpdating = true; + newStore._hmrPayload.state.forEach((stateKey) => { + if (stateKey in store.$state) { + const newStateTarget = newStore.$state[stateKey]; + const oldStateSource = store.$state[stateKey]; + if (typeof newStateTarget === 'object' && + isPlainObject(newStateTarget) && + isPlainObject(oldStateSource)) { + patchObject(newStateTarget, oldStateSource); + } + else { + // transfer the ref + newStore.$state[stateKey] = oldStateSource; + } + } + // patch direct access properties to allow store.stateProperty to work as + // store.$state.stateProperty + vueDemi.set(store, stateKey, vueDemi.toRef(newStore.$state, stateKey)); + }); + // remove deleted state properties + Object.keys(store.$state).forEach((stateKey) => { + if (!(stateKey in newStore.$state)) { + vueDemi.del(store, stateKey); + } + }); + // avoid devtools logging this as a mutation + isListening = false; + isSyncListening = false; + pinia.state.value[$id] = vueDemi.toRef(newStore._hmrPayload, 'hotState'); + isSyncListening = true; + vueDemi.nextTick().then(() => { + isListening = true; + }); + for (const actionName in newStore._hmrPayload.actions) { + const action = newStore[actionName]; + vueDemi.set(store, actionName, wrapAction(actionName, action)); + } + // TODO: does this work in both setup and option store? + for (const getterName in newStore._hmrPayload.getters) { + const getter = newStore._hmrPayload.getters[getterName]; + const getterValue = isOptionsStore + ? // special handling of options api + vueDemi.computed(() => { + setActivePinia(pinia); + return getter.call(store, store); + }) + : getter; + vueDemi.set(store, getterName, getterValue); + } + // remove deleted getters + Object.keys(store._hmrPayload.getters).forEach((key) => { + if (!(key in newStore._hmrPayload.getters)) { + vueDemi.del(store, key); + } + }); + // remove old actions + Object.keys(store._hmrPayload.actions).forEach((key) => { + if (!(key in newStore._hmrPayload.actions)) { + vueDemi.del(store, key); + } + }); + // update the values used in devtools and to allow deleting new properties later on + store._hmrPayload = newStore._hmrPayload; + store._getters = newStore._getters; + store._hotUpdating = false; + }); + } + if (USE_DEVTOOLS) { + const nonEnumerable = { + writable: true, + configurable: true, + // avoid warning on devtools trying to display this property + enumerable: false, + }; + ['_p', '_hmrPayload', '_getters', '_customProperties'].forEach((p) => { + Object.defineProperty(store, p, assign({ value: store[p] }, nonEnumerable)); + }); + } + /* istanbul ignore if */ + if (vueDemi.isVue2) { + // mark the store as ready before plugins + store._r = true; + } + // apply all plugins + pinia._p.forEach((extender) => { + /* istanbul ignore else */ + if (USE_DEVTOOLS) { + const extensions = scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + })); + Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key)); + assign(store, extensions); + } + else { + assign(store, scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + }))); + } + }); + if (store.$state && + typeof store.$state === 'object' && + typeof store.$state.constructor === 'function' && + !store.$state.constructor.toString().includes('[native code]')) { + console.warn(`[🍍]: The "state" must be a plain object. It cannot be\n` + + `\tstate: () => new MyClass()\n` + + `Found in store "${store.$id}".`); + } + // only apply hydrate to option stores with an initial state in pinia + if (initialState && + isOptionsStore && + options.hydrate) { + options.hydrate(store.$state, initialState); + } + isListening = true; + isSyncListening = true; + return store; + } + function defineStore( + // TODO: add proper types from above + idOrOptions, setup, setupOptions) { + let id; + let options; + const isSetupStore = typeof setup === 'function'; + if (typeof idOrOptions === 'string') { + id = idOrOptions; + // the option store setup will contain the actual options in this case + options = isSetupStore ? setupOptions : setup; + } + else { + options = idOrOptions; + id = idOrOptions.id; + if (typeof id !== 'string') { + throw new Error(`[🍍]: "defineStore()" must be passed a store id as its first argument.`); + } + } + function useStore(pinia, hot) { + const hasContext = vueDemi.hasInjectionContext(); + pinia = + // in test mode, ignore the argument provided as we can always retrieve a + // pinia instance with getActivePinia() + (pinia) || + (hasContext ? vueDemi.inject(piniaSymbol, null) : null); + if (pinia) + setActivePinia(pinia); + if (!activePinia) { + throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?\n` + + `See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.\n` + + `This will fail in production.`); + } + pinia = activePinia; + if (!pinia._s.has(id)) { + // creating the store registers it in `pinia._s` + if (isSetupStore) { + createSetupStore(id, setup, options, pinia); + } + else { + createOptionsStore(id, options, pinia); + } + /* istanbul ignore else */ + { + // @ts-expect-error: not the right inferred type + useStore._pinia = pinia; + } + } + const store = pinia._s.get(id); + if (hot) { + const hotId = '__hot:' + id; + const newStore = isSetupStore + ? createSetupStore(hotId, setup, options, pinia, true) + : createOptionsStore(hotId, assign({}, options), pinia, true); + hot._hotUpdate(newStore); + // cleanup the state properties and the store from the cache + delete pinia.state.value[hotId]; + pinia._s.delete(hotId); + } + if (IS_CLIENT) { + const currentInstance = vueDemi.getCurrentInstance(); + // save stores in instances to access them devtools + if (currentInstance && + currentInstance.proxy && + // avoid adding stores that are just built for hot module replacement + !hot) { + const vm = currentInstance.proxy; + const cache = '_pStores' in vm ? vm._pStores : (vm._pStores = {}); + cache[id] = store; + } + } + // StoreGeneric cannot be casted towards Store + return store; + } + useStore.$id = id; + return useStore; + } + + let mapStoreSuffix = 'Store'; + /** + * Changes the suffix added by `mapStores()`. Can be set to an empty string. + * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization + * interface if you are using TypeScript. + * + * @param suffix - new suffix + */ + function setMapStoreSuffix(suffix // could be 'Store' but that would be annoying for JS + ) { + mapStoreSuffix = suffix; + } + /** + * Allows using stores without the composition API (`setup()`) by generating an + * object to be spread in the `computed` field of a component. It accepts a list + * of store definitions. + * + * @example + * ```js + * export default { + * computed: { + * // other computed properties + * ...mapStores(useUserStore, useCartStore) + * }, + * + * created() { + * this.userStore // store with id "user" + * this.cartStore // store with id "cart" + * } + * } + * ``` + * + * @param stores - list of stores to map to an object + */ + function mapStores(...stores) { + if (Array.isArray(stores[0])) { + console.warn(`[🍍]: Directly pass all stores to "mapStores()" without putting them in an array:\n` + + `Replace\n` + + `\tmapStores([useAuthStore, useCartStore])\n` + + `with\n` + + `\tmapStores(useAuthStore, useCartStore)\n` + + `This will fail in production if not fixed.`); + stores = stores[0]; + } + return stores.reduce((reduced, useStore) => { + // @ts-expect-error: $id is added by defineStore + reduced[useStore.$id + mapStoreSuffix] = function () { + return useStore(this.$pinia); + }; + return reduced; + }, {}); + } + /** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ + function mapState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + reduced[key] = function () { + return useStore(this.$pinia)[key]; + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function () { + const store = useStore(this.$pinia); + const storeKey = keysOrMapper[key]; + // for some reason TS is unable to infer the type of storeKey to be a + // function + return typeof storeKey === 'function' + ? storeKey.call(this, store) + : store[storeKey]; + }; + return reduced; + }, {}); + } + /** + * Alias for `mapState()`. You should use `mapState()` instead. + * @deprecated use `mapState()` instead. + */ + const mapGetters = mapState; + /** + * Allows directly using actions from your store without using the composition + * API (`setup()`) by generating an object to be spread in the `methods` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ + function mapActions(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[key](...args); + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[keysOrMapper[key]](...args); + }; + return reduced; + }, {}); + } + /** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ + function mapWritableState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[key]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[key] = value); + }, + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[keysOrMapper[key]]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[keysOrMapper[key]] = value); + }, + }; + return reduced; + }, {}); + } + + /** + * Creates an object of references with all the state, getters, and plugin-added + * state properties of the store. Similar to `toRefs()` but specifically + * designed for Pinia stores so methods and non reactive properties are + * completely ignored. + * + * @param store - store to extract the refs from + */ + function storeToRefs(store) { + // See https://github.com/vuejs/pinia/issues/852 + // It's easier to just use toRefs() even if it includes more stuff + if (vueDemi.isVue2) { + // @ts-expect-error: toRefs include methods and others + return vueDemi.toRefs(store); + } + else { + store = vueDemi.toRaw(store); + const refs = {}; + for (const key in store) { + const value = store[key]; + if (vueDemi.isRef(value) || vueDemi.isReactive(value)) { + // @ts-expect-error: the key is state or getter + refs[key] = + // --- + vueDemi.toRef(store, key); + } + } + return refs; + } + } + + /** + * Vue 2 Plugin that must be installed for pinia to work. Note **you don't need + * this plugin if you are using Nuxt.js**. Use the `buildModule` instead: + * https://pinia.vuejs.org/ssr/nuxt.html. + * + * @example + * ```js + * import Vue from 'vue' + * import { PiniaVuePlugin, createPinia } from 'pinia' + * + * Vue.use(PiniaVuePlugin) + * const pinia = createPinia() + * + * new Vue({ + * el: '#app', + * // ... + * pinia, + * }) + * ``` + * + * @param _Vue - `Vue` imported from 'vue'. + */ + const PiniaVuePlugin = function (_Vue) { + // Equivalent of + // app.config.globalProperties.$pinia = pinia + _Vue.mixin({ + beforeCreate() { + const options = this.$options; + if (options.pinia) { + const pinia = options.pinia; + // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/main/src/apis/inject.ts#L31 + /* istanbul ignore else */ + if (!this._provided) { + const provideCache = {}; + Object.defineProperty(this, '_provided', { + get: () => provideCache, + set: (v) => Object.assign(provideCache, v), + }); + } + this._provided[piniaSymbol] = pinia; + // propagate the pinia instance in an SSR friendly way + // avoid adding it to nuxt twice + /* istanbul ignore else */ + if (!this.$pinia) { + this.$pinia = pinia; + } + pinia._a = this; + if (IS_CLIENT) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + } + if (USE_DEVTOOLS) { + registerPiniaDevtools(pinia._a, pinia); + } + } + else if (!this.$pinia && options.parent && options.parent.$pinia) { + this.$pinia = options.parent.$pinia; + } + }, + destroyed() { + delete this._pStores; + }, + }); + }; + + exports.PiniaVuePlugin = PiniaVuePlugin; + exports.acceptHMRUpdate = acceptHMRUpdate; + exports.createPinia = createPinia; + exports.defineStore = defineStore; + exports.getActivePinia = getActivePinia; + exports.mapActions = mapActions; + exports.mapGetters = mapGetters; + exports.mapState = mapState; + exports.mapStores = mapStores; + exports.mapWritableState = mapWritableState; + exports.setActivePinia = setActivePinia; + exports.setMapStoreSuffix = setMapStoreSuffix; + exports.skipHydrate = skipHydrate; + exports.storeToRefs = storeToRefs; + + return exports; + +})({}, VueDemi); diff --git a/node_modules/pinia/dist/pinia.iife.prod.js b/node_modules/pinia/dist/pinia.iife.prod.js new file mode 100644 index 0000000..eed2971 --- /dev/null +++ b/node_modules/pinia/dist/pinia.iife.prod.js @@ -0,0 +1,6 @@ +/*! + * pinia v2.1.7 + * (c) 2023 Eduardo San Martin Morote + * @license MIT + */ +var Pinia=function(t,e){"use strict";let n;const i=t=>n=t,s=Symbol();function o(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}var r;t.MutationType=void 0,(r=t.MutationType||(t.MutationType={})).direct="direct",r.patchObject="patch object",r.patchFunction="patch function";const c="undefined"!=typeof window;const a=()=>{};function u(t,n,i,s=a){t.push(n);const o=()=>{const e=t.indexOf(n);e>-1&&(t.splice(e,1),s())};return!i&&e.getCurrentScope()&&e.onScopeDispose(o),o}function p(t,...e){t.slice().forEach((t=>{t(...e)}))}const f=t=>t();function h(t,n){t instanceof Map&&n instanceof Map&&n.forEach(((e,n)=>t.set(n,e))),t instanceof Set&&n instanceof Set&&n.forEach(t.add,t);for(const i in n){if(!n.hasOwnProperty(i))continue;const s=n[i],r=t[i];t[i]=o(r)&&o(s)&&t.hasOwnProperty(i)&&!e.isRef(s)&&!e.isReactive(s)?h(r,s):s}return t}const l=Symbol(),d=new WeakMap;const{assign:y}=Object;function v(n,s,r={},c,v,$){let b;const _=y({actions:{}},r),j={deep:!0};let O,S,g,m=[],R=[];const P=c.state.value[n];let V;function w(i){let s;O=S=!1,"function"==typeof i?(i(c.state.value[n]),s={type:t.MutationType.patchFunction,storeId:n,events:g}):(h(c.state.value[n],i),s={type:t.MutationType.patchObject,payload:i,storeId:n,events:g});const o=V=Symbol();e.nextTick().then((()=>{V===o&&(O=!0)})),S=!0,p(m,s,c.state.value[n])}$||P||(e.isVue2?e.set(c.state.value,n,{}):c.state.value[n]={}),e.ref({});const M=$?function(){const{state:t}=r,e=t?t():{};this.$patch((t=>{y(t,e)}))}:a;function A(t,e){return function(){i(c);const s=Array.from(arguments),o=[],r=[];let a;p(R,{args:s,name:t,store:T,after:function(t){o.push(t)},onError:function(t){r.push(t)}});try{a=e.apply(this&&this.$id===n?this:T,s)}catch(t){throw p(r,t),t}return a instanceof Promise?a.then((t=>(p(o,t),t))).catch((t=>(p(r,t),Promise.reject(t)))):(p(o,a),a)}}const k={_p:c,$id:n,$onAction:u.bind(null,R),$patch:w,$reset:M,$subscribe(i,s={}){const o=u(m,i,s.detached,(()=>r())),r=b.run((()=>e.watch((()=>c.state.value[n]),(e=>{("sync"===s.flush?S:O)&&i({storeId:n,type:t.MutationType.direct,events:g},e)}),y({},j,s))));return o},$dispose:function(){b.stop(),m=[],R=[],c._s.delete(n)}};e.isVue2&&(k._r=!1);const T=e.reactive(k);c._s.set(n,T);const x=(c._a&&c._a.runWithContext||f)((()=>c._e.run((()=>(b=e.effectScope()).run(s)))));for(const t in x){const i=x[t];if(e.isRef(i)&&(!e.isRef(C=i)||!C.effect)||e.isReactive(i))$||(!P||(E=i,e.isVue2?d.has(E):o(E)&&E.hasOwnProperty(l))||(e.isRef(i)?i.value=P[t]:h(i,P[t])),e.isVue2?e.set(c.state.value[n],t,i):c.state.value[n][t]=i);else if("function"==typeof i){const n=A(t,i);e.isVue2?e.set(x,t,n):x[t]=n,_.actions[t]=i}}var E,C;return e.isVue2?Object.keys(x).forEach((t=>{e.set(T,t,x[t])})):(y(T,x),y(e.toRaw(T),x)),Object.defineProperty(T,"$state",{get:()=>c.state.value[n],set:t=>{w((e=>{y(e,t)}))}}),e.isVue2&&(T._r=!0),c._p.forEach((t=>{y(T,b.run((()=>t({store:T,app:c._a,pinia:c,options:_}))))})),P&&$&&r.hydrate&&r.hydrate(T.$state,P),O=!0,S=!0,T}let $="Store";function b(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(){return t(this.$pinia)[n]},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]=function(){const n=t(this.$pinia),s=e[i];return"function"==typeof s?s.call(this,n):n[s]},n)),{})}const _=b;return t.PiniaVuePlugin=function(t){t.mixin({beforeCreate(){const t=this.$options;if(t.pinia){const e=t.pinia;if(!this._provided){const t={};Object.defineProperty(this,"_provided",{get:()=>t,set:e=>Object.assign(t,e)})}this._provided[s]=e,this.$pinia||(this.$pinia=e),e._a=this,c&&i(e)}else!this.$pinia&&t.parent&&t.parent.$pinia&&(this.$pinia=t.parent.$pinia)},destroyed(){delete this._pStores}})},t.acceptHMRUpdate=function(t,e){return()=>{}},t.createPinia=function(){const t=e.effectScope(!0),n=t.run((()=>e.ref({})));let o=[],r=[];const c=e.markRaw({install(t){i(c),e.isVue2||(c._a=t,t.provide(s,c),t.config.globalProperties.$pinia=c,r.forEach((t=>o.push(t))),r=[])},use(t){return this._a||e.isVue2?o.push(t):r.push(t),this},_p:o,_a:null,_e:t,_s:new Map,state:n});return c},t.defineStore=function(t,o,r){let c,a;const u="function"==typeof o;function p(t,r){const p=e.hasInjectionContext();(t=t||(p?e.inject(s,null):null))&&i(t),(t=n)._s.has(c)||(u?v(c,o,a,t):function(t,n,s,o){const{state:r,actions:c,getters:a}=n,u=s.state.value[t];let p;p=v(t,(function(){u||(e.isVue2?e.set(s.state.value,t,r?r():{}):s.state.value[t]=r?r():{});const n=e.toRefs(s.state.value[t]);return y(n,c,Object.keys(a||{}).reduce(((n,o)=>(n[o]=e.markRaw(e.computed((()=>{i(s);const n=s._s.get(t);if(!e.isVue2||n._r)return a[o].call(n,n)}))),n)),{}))}),n,s,0,!0)}(c,a,t));return t._s.get(c)}return"string"==typeof t?(c=t,a=u?r:o):(a=t,c=t.id),p.$id=c,p},t.getActivePinia=()=>e.hasInjectionContext()&&e.inject(s)||n,t.mapActions=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(...e){return t(this.$pinia)[n](...e)},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]=function(...n){return t(this.$pinia)[e[i]](...n)},n)),{})},t.mapGetters=_,t.mapState=b,t.mapStores=function(...t){return t.reduce(((t,e)=>(t[e.$id+$]=function(){return e(this.$pinia)},t)),{})},t.mapWritableState=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]={get(){return t(this.$pinia)[n]},set(e){return t(this.$pinia)[n]=e}},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]={get(){return t(this.$pinia)[e[i]]},set(n){return t(this.$pinia)[e[i]]=n}},n)),{})},t.setActivePinia=i,t.setMapStoreSuffix=function(t){$=t},t.skipHydrate=function(t){return e.isVue2?d.set(t,1)&&t:Object.defineProperty(t,l,{})},t.storeToRefs=function(t){if(e.isVue2)return e.toRefs(t);{t=e.toRaw(t);const n={};for(const i in t){const s=t[i];(e.isRef(s)||e.isReactive(s))&&(n[i]=e.toRef(t,i))}return n}},t}({},VueDemi); diff --git a/node_modules/pinia/dist/pinia.mjs b/node_modules/pinia/dist/pinia.mjs new file mode 100644 index 0000000..b0095a4 --- /dev/null +++ b/node_modules/pinia/dist/pinia.mjs @@ -0,0 +1,2005 @@ +/*! + * pinia v2.1.7 + * (c) 2023 Eduardo San Martin Morote + * @license MIT + */ +import { hasInjectionContext, inject, toRaw, watch, unref, markRaw, effectScope, ref, isVue2, isRef, isReactive, set, getCurrentScope, onScopeDispose, getCurrentInstance, reactive, toRef, del, nextTick, computed, toRefs } from 'vue-demi'; +import { setupDevtoolsPlugin } from '@vue/devtools-api'; + +/** + * setActivePinia must be called to handle SSR at the top of functions like + * `fetch`, `setup`, `serverPrefetch` and others + */ +let activePinia; +/** + * Sets or unsets the active pinia. Used in SSR and internally when calling + * actions and getters + * + * @param pinia - Pinia instance + */ +// @ts-expect-error: cannot constrain the type of the return +const setActivePinia = (pinia) => (activePinia = pinia); +/** + * Get the currently active pinia if there is any. + */ +const getActivePinia = () => (hasInjectionContext() && inject(piniaSymbol)) || activePinia; +const piniaSymbol = ((process.env.NODE_ENV !== 'production') ? Symbol('pinia') : /* istanbul ignore next */ Symbol()); + +function isPlainObject( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +o) { + return (o && + typeof o === 'object' && + Object.prototype.toString.call(o) === '[object Object]' && + typeof o.toJSON !== 'function'); +} +// type DeepReadonly = { readonly [P in keyof T]: DeepReadonly } +// TODO: can we change these to numbers? +/** + * Possible types for SubscriptionCallback + */ +var MutationType; +(function (MutationType) { + /** + * Direct mutation of the state: + * + * - `store.name = 'new name'` + * - `store.$state.name = 'new name'` + * - `store.list.push('new item')` + */ + MutationType["direct"] = "direct"; + /** + * Mutated the state with `$patch` and an object + * + * - `store.$patch({ name: 'newName' })` + */ + MutationType["patchObject"] = "patch object"; + /** + * Mutated the state with `$patch` and a function + * + * - `store.$patch(state => state.name = 'newName')` + */ + MutationType["patchFunction"] = "patch function"; + // maybe reset? for $state = {} and $reset +})(MutationType || (MutationType = {})); + +const IS_CLIENT = typeof window !== 'undefined'; +/** + * Should we add the devtools plugins. + * - only if dev mode or forced through the prod devtools flag + * - not in test + * - only if window exists (could change in the future) + */ +const USE_DEVTOOLS = ((process.env.NODE_ENV !== 'production') || (typeof __VUE_PROD_DEVTOOLS__ !== 'undefined' && __VUE_PROD_DEVTOOLS__)) && !(process.env.NODE_ENV === 'test') && IS_CLIENT; + +/* + * FileSaver.js A saveAs() FileSaver implementation. + * + * Originally by Eli Grey, adapted as an ESM module by Eduardo San Martin + * Morote. + * + * License : MIT + */ +// The one and only way of getting global scope in all environments +// https://stackoverflow.com/q/3277182/1008999 +const _global = /*#__PURE__*/ (() => typeof window === 'object' && window.window === window + ? window + : typeof self === 'object' && self.self === self + ? self + : typeof global === 'object' && global.global === global + ? global + : typeof globalThis === 'object' + ? globalThis + : { HTMLElement: null })(); +function bom(blob, { autoBom = false } = {}) { + // prepend BOM for UTF-8 XML and text/* types (including HTML) + // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF + if (autoBom && + /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { + return new Blob([String.fromCharCode(0xfeff), blob], { type: blob.type }); + } + return blob; +} +function download(url, name, opts) { + const xhr = new XMLHttpRequest(); + xhr.open('GET', url); + xhr.responseType = 'blob'; + xhr.onload = function () { + saveAs(xhr.response, name, opts); + }; + xhr.onerror = function () { + console.error('could not download file'); + }; + xhr.send(); +} +function corsEnabled(url) { + const xhr = new XMLHttpRequest(); + // use sync to avoid popup blocker + xhr.open('HEAD', url, false); + try { + xhr.send(); + } + catch (e) { } + return xhr.status >= 200 && xhr.status <= 299; +} +// `a.click()` doesn't work for all browsers (#465) +function click(node) { + try { + node.dispatchEvent(new MouseEvent('click')); + } + catch (e) { + const evt = document.createEvent('MouseEvents'); + evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null); + node.dispatchEvent(evt); + } +} +const _navigator = + typeof navigator === 'object' ? navigator : { userAgent: '' }; +// Detect WebView inside a native macOS app by ruling out all browsers +// We just need to check for 'Safari' because all other browsers (besides Firefox) include that too +// https://www.whatismybrowser.com/guides/the-latest-user-agent/macos +const isMacOSWebView = /*#__PURE__*/ (() => /Macintosh/.test(_navigator.userAgent) && + /AppleWebKit/.test(_navigator.userAgent) && + !/Safari/.test(_navigator.userAgent))(); +const saveAs = !IS_CLIENT + ? () => { } // noop + : // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program + typeof HTMLAnchorElement !== 'undefined' && + 'download' in HTMLAnchorElement.prototype && + !isMacOSWebView + ? downloadSaveAs + : // Use msSaveOrOpenBlob as a second approach + 'msSaveOrOpenBlob' in _navigator + ? msSaveAs + : // Fallback to using FileReader and a popup + fileSaverSaveAs; +function downloadSaveAs(blob, name = 'download', opts) { + const a = document.createElement('a'); + a.download = name; + a.rel = 'noopener'; // tabnabbing + // TODO: detect chrome extensions & packaged apps + // a.target = '_blank' + if (typeof blob === 'string') { + // Support regular links + a.href = blob; + if (a.origin !== location.origin) { + if (corsEnabled(a.href)) { + download(blob, name, opts); + } + else { + a.target = '_blank'; + click(a); + } + } + else { + click(a); + } + } + else { + // Support blobs + a.href = URL.createObjectURL(blob); + setTimeout(function () { + URL.revokeObjectURL(a.href); + }, 4e4); // 40s + setTimeout(function () { + click(a); + }, 0); + } +} +function msSaveAs(blob, name = 'download', opts) { + if (typeof blob === 'string') { + if (corsEnabled(blob)) { + download(blob, name, opts); + } + else { + const a = document.createElement('a'); + a.href = blob; + a.target = '_blank'; + setTimeout(function () { + click(a); + }); + } + } + else { + // @ts-ignore: works on windows + navigator.msSaveOrOpenBlob(bom(blob, opts), name); + } +} +function fileSaverSaveAs(blob, name, opts, popup) { + // Open a popup immediately do go around popup blocker + // Mostly only available on user interaction and the fileReader is async so... + popup = popup || open('', '_blank'); + if (popup) { + popup.document.title = popup.document.body.innerText = 'downloading...'; + } + if (typeof blob === 'string') + return download(blob, name, opts); + const force = blob.type === 'application/octet-stream'; + const isSafari = /constructor/i.test(String(_global.HTMLElement)) || 'safari' in _global; + const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); + if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && + typeof FileReader !== 'undefined') { + // Safari doesn't allow downloading of blob URLs + const reader = new FileReader(); + reader.onloadend = function () { + let url = reader.result; + if (typeof url !== 'string') { + popup = null; + throw new Error('Wrong reader.result type'); + } + url = isChromeIOS + ? url + : url.replace(/^data:[^;]*;/, 'data:attachment/file;'); + if (popup) { + popup.location.href = url; + } + else { + location.assign(url); + } + popup = null; // reverse-tabnabbing #460 + }; + reader.readAsDataURL(blob); + } + else { + const url = URL.createObjectURL(blob); + if (popup) + popup.location.assign(url); + else + location.href = url; + popup = null; // reverse-tabnabbing #460 + setTimeout(function () { + URL.revokeObjectURL(url); + }, 4e4); // 40s + } +} + +/** + * Shows a toast or console.log + * + * @param message - message to log + * @param type - different color of the tooltip + */ +function toastMessage(message, type) { + const piniaMessage = '🍍 ' + message; + if (typeof __VUE_DEVTOOLS_TOAST__ === 'function') { + // No longer available :( + __VUE_DEVTOOLS_TOAST__(piniaMessage, type); + } + else if (type === 'error') { + console.error(piniaMessage); + } + else if (type === 'warn') { + console.warn(piniaMessage); + } + else { + console.log(piniaMessage); + } +} +function isPinia(o) { + return '_a' in o && 'install' in o; +} + +/** + * This file contain devtools actions, they are not Pinia actions. + */ +// --- +function checkClipboardAccess() { + if (!('clipboard' in navigator)) { + toastMessage(`Your browser doesn't support the Clipboard API`, 'error'); + return true; + } +} +function checkNotFocusedError(error) { + if (error instanceof Error && + error.message.toLowerCase().includes('document is not focused')) { + toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', 'warn'); + return true; + } + return false; +} +async function actionGlobalCopyState(pinia) { + if (checkClipboardAccess()) + return; + try { + await navigator.clipboard.writeText(JSON.stringify(pinia.state.value)); + toastMessage('Global state copied to clipboard.'); + } + catch (error) { + if (checkNotFocusedError(error)) + return; + toastMessage(`Failed to serialize the state. Check the console for more details.`, 'error'); + console.error(error); + } +} +async function actionGlobalPasteState(pinia) { + if (checkClipboardAccess()) + return; + try { + loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText())); + toastMessage('Global state pasted from clipboard.'); + } + catch (error) { + if (checkNotFocusedError(error)) + return; + toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, 'error'); + console.error(error); + } +} +async function actionGlobalSaveState(pinia) { + try { + saveAs(new Blob([JSON.stringify(pinia.state.value)], { + type: 'text/plain;charset=utf-8', + }), 'pinia-state.json'); + } + catch (error) { + toastMessage(`Failed to export the state as JSON. Check the console for more details.`, 'error'); + console.error(error); + } +} +let fileInput; +function getFileOpener() { + if (!fileInput) { + fileInput = document.createElement('input'); + fileInput.type = 'file'; + fileInput.accept = '.json'; + } + function openFile() { + return new Promise((resolve, reject) => { + fileInput.onchange = async () => { + const files = fileInput.files; + if (!files) + return resolve(null); + const file = files.item(0); + if (!file) + return resolve(null); + return resolve({ text: await file.text(), file }); + }; + // @ts-ignore: TODO: changed from 4.3 to 4.4 + fileInput.oncancel = () => resolve(null); + fileInput.onerror = reject; + fileInput.click(); + }); + } + return openFile; +} +async function actionGlobalOpenStateFile(pinia) { + try { + const open = getFileOpener(); + const result = await open(); + if (!result) + return; + const { text, file } = result; + loadStoresState(pinia, JSON.parse(text)); + toastMessage(`Global state imported from "${file.name}".`); + } + catch (error) { + toastMessage(`Failed to import the state from JSON. Check the console for more details.`, 'error'); + console.error(error); + } +} +function loadStoresState(pinia, state) { + for (const key in state) { + const storeState = pinia.state.value[key]; + // store is already instantiated, patch it + if (storeState) { + Object.assign(storeState, state[key]); + } + else { + // store is not instantiated, set the initial state + pinia.state.value[key] = state[key]; + } + } +} + +function formatDisplay(display) { + return { + _custom: { + display, + }, + }; +} +const PINIA_ROOT_LABEL = '🍍 Pinia (root)'; +const PINIA_ROOT_ID = '_root'; +function formatStoreForInspectorTree(store) { + return isPinia(store) + ? { + id: PINIA_ROOT_ID, + label: PINIA_ROOT_LABEL, + } + : { + id: store.$id, + label: store.$id, + }; +} +function formatStoreForInspectorState(store) { + if (isPinia(store)) { + const storeNames = Array.from(store._s.keys()); + const storeMap = store._s; + const state = { + state: storeNames.map((storeId) => ({ + editable: true, + key: storeId, + value: store.state.value[storeId], + })), + getters: storeNames + .filter((id) => storeMap.get(id)._getters) + .map((id) => { + const store = storeMap.get(id); + return { + editable: false, + key: id, + value: store._getters.reduce((getters, key) => { + getters[key] = store[key]; + return getters; + }, {}), + }; + }), + }; + return state; + } + const state = { + state: Object.keys(store.$state).map((key) => ({ + editable: true, + key, + value: store.$state[key], + })), + }; + // avoid adding empty getters + if (store._getters && store._getters.length) { + state.getters = store._getters.map((getterName) => ({ + editable: false, + key: getterName, + value: store[getterName], + })); + } + if (store._customProperties.size) { + state.customProperties = Array.from(store._customProperties).map((key) => ({ + editable: true, + key, + value: store[key], + })); + } + return state; +} +function formatEventData(events) { + if (!events) + return {}; + if (Array.isArray(events)) { + // TODO: handle add and delete for arrays and objects + return events.reduce((data, event) => { + data.keys.push(event.key); + data.operations.push(event.type); + data.oldValue[event.key] = event.oldValue; + data.newValue[event.key] = event.newValue; + return data; + }, { + oldValue: {}, + keys: [], + operations: [], + newValue: {}, + }); + } + else { + return { + operation: formatDisplay(events.type), + key: formatDisplay(events.key), + oldValue: events.oldValue, + newValue: events.newValue, + }; + } +} +function formatMutationType(type) { + switch (type) { + case MutationType.direct: + return 'mutation'; + case MutationType.patchFunction: + return '$patch'; + case MutationType.patchObject: + return '$patch'; + default: + return 'unknown'; + } +} + +// timeline can be paused when directly changing the state +let isTimelineActive = true; +const componentStateTypes = []; +const MUTATIONS_LAYER_ID = 'pinia:mutations'; +const INSPECTOR_ID = 'pinia'; +const { assign: assign$1 } = Object; +/** + * Gets the displayed name of a store in devtools + * + * @param id - id of the store + * @returns a formatted string + */ +const getStoreType = (id) => '🍍 ' + id; +/** + * Add the pinia plugin without any store. Allows displaying a Pinia plugin tab + * as soon as it is added to the application. + * + * @param app - Vue application + * @param pinia - pinia instance + */ +function registerPiniaDevtools(app, pinia) { + setupDevtoolsPlugin({ + id: 'dev.esm.pinia', + label: 'Pinia 🍍', + logo: 'https://pinia.vuejs.org/logo.svg', + packageName: 'pinia', + homepage: 'https://pinia.vuejs.org', + componentStateTypes, + app, + }, (api) => { + if (typeof api.now !== 'function') { + toastMessage('You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.'); + } + api.addTimelineLayer({ + id: MUTATIONS_LAYER_ID, + label: `Pinia 🍍`, + color: 0xe5df88, + }); + api.addInspector({ + id: INSPECTOR_ID, + label: 'Pinia 🍍', + icon: 'storage', + treeFilterPlaceholder: 'Search stores', + actions: [ + { + icon: 'content_copy', + action: () => { + actionGlobalCopyState(pinia); + }, + tooltip: 'Serialize and copy the state', + }, + { + icon: 'content_paste', + action: async () => { + await actionGlobalPasteState(pinia); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }, + tooltip: 'Replace the state with the content of your clipboard', + }, + { + icon: 'save', + action: () => { + actionGlobalSaveState(pinia); + }, + tooltip: 'Save the state as a JSON file', + }, + { + icon: 'folder_open', + action: async () => { + await actionGlobalOpenStateFile(pinia); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }, + tooltip: 'Import the state from a JSON file', + }, + ], + nodeActions: [ + { + icon: 'restore', + tooltip: 'Reset the state (with "$reset")', + action: (nodeId) => { + const store = pinia._s.get(nodeId); + if (!store) { + toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, 'warn'); + } + else if (typeof store.$reset !== 'function') { + toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, 'warn'); + } + else { + store.$reset(); + toastMessage(`Store "${nodeId}" reset.`); + } + }, + }, + ], + }); + api.on.inspectComponent((payload, ctx) => { + const proxy = (payload.componentInstance && + payload.componentInstance.proxy); + if (proxy && proxy._pStores) { + const piniaStores = payload.componentInstance.proxy._pStores; + Object.values(piniaStores).forEach((store) => { + payload.instanceData.state.push({ + type: getStoreType(store.$id), + key: 'state', + editable: true, + value: store._isOptionsAPI + ? { + _custom: { + value: toRaw(store.$state), + actions: [ + { + icon: 'restore', + tooltip: 'Reset the state of this store', + action: () => store.$reset(), + }, + ], + }, + } + : // NOTE: workaround to unwrap transferred refs + Object.keys(store.$state).reduce((state, key) => { + state[key] = store.$state[key]; + return state; + }, {}), + }); + if (store._getters && store._getters.length) { + payload.instanceData.state.push({ + type: getStoreType(store.$id), + key: 'getters', + editable: false, + value: store._getters.reduce((getters, key) => { + try { + getters[key] = store[key]; + } + catch (error) { + // @ts-expect-error: we just want to show it in devtools + getters[key] = error; + } + return getters; + }, {}), + }); + } + }); + } + }); + api.on.getInspectorTree((payload) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + let stores = [pinia]; + stores = stores.concat(Array.from(pinia._s.values())); + payload.rootNodes = (payload.filter + ? stores.filter((store) => '$id' in store + ? store.$id + .toLowerCase() + .includes(payload.filter.toLowerCase()) + : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase())) + : stores).map(formatStoreForInspectorTree); + } + }); + api.on.getInspectorState((payload) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + const inspectedStore = payload.nodeId === PINIA_ROOT_ID + ? pinia + : pinia._s.get(payload.nodeId); + if (!inspectedStore) { + // this could be the selected store restored for a different project + // so it's better not to say anything here + return; + } + if (inspectedStore) { + payload.state = formatStoreForInspectorState(inspectedStore); + } + } + }); + api.on.editInspectorState((payload, ctx) => { + if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { + const inspectedStore = payload.nodeId === PINIA_ROOT_ID + ? pinia + : pinia._s.get(payload.nodeId); + if (!inspectedStore) { + return toastMessage(`store "${payload.nodeId}" not found`, 'error'); + } + const { path } = payload; + if (!isPinia(inspectedStore)) { + // access only the state + if (path.length !== 1 || + !inspectedStore._customProperties.has(path[0]) || + path[0] in inspectedStore.$state) { + path.unshift('$state'); + } + } + else { + // Root access, we can omit the `.value` because the devtools API does it for us + path.unshift('state'); + } + isTimelineActive = false; + payload.set(inspectedStore, path, payload.state.value); + isTimelineActive = true; + } + }); + api.on.editComponentState((payload) => { + if (payload.type.startsWith('🍍')) { + const storeId = payload.type.replace(/^🍍\s*/, ''); + const store = pinia._s.get(storeId); + if (!store) { + return toastMessage(`store "${storeId}" not found`, 'error'); + } + const { path } = payload; + if (path[0] !== 'state') { + return toastMessage(`Invalid path for store "${storeId}":\n${path}\nOnly state can be modified.`); + } + // rewrite the first entry to be able to directly set the state as + // well as any other path + path[0] = '$state'; + isTimelineActive = false; + payload.set(store, path, payload.state.value); + isTimelineActive = true; + } + }); + }); +} +function addStoreToDevtools(app, store) { + if (!componentStateTypes.includes(getStoreType(store.$id))) { + componentStateTypes.push(getStoreType(store.$id)); + } + setupDevtoolsPlugin({ + id: 'dev.esm.pinia', + label: 'Pinia 🍍', + logo: 'https://pinia.vuejs.org/logo.svg', + packageName: 'pinia', + homepage: 'https://pinia.vuejs.org', + componentStateTypes, + app, + settings: { + logStoreChanges: { + label: 'Notify about new/deleted stores', + type: 'boolean', + defaultValue: true, + }, + // useEmojis: { + // label: 'Use emojis in messages ⚡️', + // type: 'boolean', + // defaultValue: true, + // }, + }, + }, (api) => { + // gracefully handle errors + const now = typeof api.now === 'function' ? api.now.bind(api) : Date.now; + store.$onAction(({ after, onError, name, args }) => { + const groupId = runningActionId++; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🛫 ' + name, + subtitle: 'start', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + }, + groupId, + }, + }); + after((result) => { + activeAction = undefined; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🛬 ' + name, + subtitle: 'end', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + result, + }, + groupId, + }, + }); + }); + onError((error) => { + activeAction = undefined; + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + logType: 'error', + title: '💥 ' + name, + subtitle: 'end', + data: { + store: formatDisplay(store.$id), + action: formatDisplay(name), + args, + error, + }, + groupId, + }, + }); + }); + }, true); + store._customProperties.forEach((name) => { + watch(() => unref(store[name]), (newValue, oldValue) => { + api.notifyComponentUpdate(); + api.sendInspectorState(INSPECTOR_ID); + if (isTimelineActive) { + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: 'Change', + subtitle: name, + data: { + newValue, + oldValue, + }, + groupId: activeAction, + }, + }); + } + }, { deep: true }); + }); + store.$subscribe(({ events, type }, state) => { + api.notifyComponentUpdate(); + api.sendInspectorState(INSPECTOR_ID); + if (!isTimelineActive) + return; + // rootStore.state[store.id] = state + const eventData = { + time: now(), + title: formatMutationType(type), + data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)), + groupId: activeAction, + }; + if (type === MutationType.patchFunction) { + eventData.subtitle = '⤵️'; + } + else if (type === MutationType.patchObject) { + eventData.subtitle = '🧩'; + } + else if (events && !Array.isArray(events)) { + eventData.subtitle = events.type; + } + if (events) { + eventData.data['rawEvent(s)'] = { + _custom: { + display: 'DebuggerEvent', + type: 'object', + tooltip: 'raw DebuggerEvent[]', + value: events, + }, + }; + } + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: eventData, + }); + }, { detached: true, flush: 'sync' }); + const hotUpdate = store._hotUpdate; + store._hotUpdate = markRaw((newStore) => { + hotUpdate(newStore); + api.addTimelineEvent({ + layerId: MUTATIONS_LAYER_ID, + event: { + time: now(), + title: '🔥 ' + store.$id, + subtitle: 'HMR update', + data: { + store: formatDisplay(store.$id), + info: formatDisplay(`HMR update`), + }, + }, + }); + // update the devtools too + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + }); + const { $dispose } = store; + store.$dispose = () => { + $dispose(); + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + api.getSettings().logStoreChanges && + toastMessage(`Disposed "${store.$id}" store 🗑`); + }; + // trigger an update so it can display new registered stores + api.notifyComponentUpdate(); + api.sendInspectorTree(INSPECTOR_ID); + api.sendInspectorState(INSPECTOR_ID); + api.getSettings().logStoreChanges && + toastMessage(`"${store.$id}" store installed 🆕`); + }); +} +let runningActionId = 0; +let activeAction; +/** + * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the + * context of all actions, allowing us to set `runningAction` on each access and effectively associating any state + * mutation to the action. + * + * @param store - store to patch + * @param actionNames - list of actionst to patch + */ +function patchActionForGrouping(store, actionNames, wrapWithProxy) { + // original actions of the store as they are given by pinia. We are going to override them + const actions = actionNames.reduce((storeActions, actionName) => { + // use toRaw to avoid tracking #541 + storeActions[actionName] = toRaw(store)[actionName]; + return storeActions; + }, {}); + for (const actionName in actions) { + store[actionName] = function () { + // the running action id is incremented in a before action hook + const _actionId = runningActionId; + const trackedStore = wrapWithProxy + ? new Proxy(store, { + get(...args) { + activeAction = _actionId; + return Reflect.get(...args); + }, + set(...args) { + activeAction = _actionId; + return Reflect.set(...args); + }, + }) + : store; + // For Setup Stores we need https://github.com/tc39/proposal-async-context + activeAction = _actionId; + const retValue = actions[actionName].apply(trackedStore, arguments); + // this is safer as async actions in Setup Stores would associate mutations done outside of the action + activeAction = undefined; + return retValue; + }; + } +} +/** + * pinia.use(devtoolsPlugin) + */ +function devtoolsPlugin({ app, store, options }) { + // HMR module + if (store.$id.startsWith('__hot:')) { + return; + } + // detect option api vs setup api + store._isOptionsAPI = !!options.state; + patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI); + // Upgrade the HMR to also update the new actions + const originalHotUpdate = store._hotUpdate; + toRaw(store)._hotUpdate = function (newStore) { + originalHotUpdate.apply(this, arguments); + patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI); + }; + addStoreToDevtools(app, + // FIXME: is there a way to allow the assignment from Store to StoreGeneric? + store); +} + +/** + * Creates a Pinia instance to be used by the application + */ +function createPinia() { + const scope = effectScope(true); + // NOTE: here we could check the window object for a state and directly set it + // if there is anything like it with Vue 3 SSR + const state = scope.run(() => ref({})); + let _p = []; + // plugins added before calling app.use(pinia) + let toBeInstalled = []; + const pinia = markRaw({ + install(app) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + if (!isVue2) { + pinia._a = app; + app.provide(piniaSymbol, pinia); + app.config.globalProperties.$pinia = pinia; + /* istanbul ignore else */ + if (USE_DEVTOOLS) { + registerPiniaDevtools(app, pinia); + } + toBeInstalled.forEach((plugin) => _p.push(plugin)); + toBeInstalled = []; + } + }, + use(plugin) { + if (!this._a && !isVue2) { + toBeInstalled.push(plugin); + } + else { + _p.push(plugin); + } + return this; + }, + _p, + // it's actually undefined here + // @ts-expect-error + _a: null, + _e: scope, + _s: new Map(), + state, + }); + // pinia devtools rely on dev only features so they cannot be forced unless + // the dev build of Vue is used. Avoid old browsers like IE11. + if (USE_DEVTOOLS && typeof Proxy !== 'undefined') { + pinia.use(devtoolsPlugin); + } + return pinia; +} + +/** + * Checks if a function is a `StoreDefinition`. + * + * @param fn - object to test + * @returns true if `fn` is a StoreDefinition + */ +const isUseStore = (fn) => { + return typeof fn === 'function' && typeof fn.$id === 'string'; +}; +/** + * Mutates in place `newState` with `oldState` to _hot update_ it. It will + * remove any key not existing in `newState` and recursively merge plain + * objects. + * + * @param newState - new state object to be patched + * @param oldState - old state that should be used to patch newState + * @returns - newState + */ +function patchObject(newState, oldState) { + // no need to go through symbols because they cannot be serialized anyway + for (const key in oldState) { + const subPatch = oldState[key]; + // skip the whole sub tree + if (!(key in newState)) { + continue; + } + const targetValue = newState[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + !isRef(subPatch) && + !isReactive(subPatch)) { + newState[key] = patchObject(targetValue, subPatch); + } + else { + // objects are either a bit more complex (e.g. refs) or primitives, so we + // just set the whole thing + if (isVue2) { + set(newState, key, subPatch); + } + else { + newState[key] = subPatch; + } + } + } + return newState; +} +/** + * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. + * + * @example + * ```js + * const useUser = defineStore(...) + * if (import.meta.hot) { + * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) + * } + * ``` + * + * @param initialUseStore - return of the defineStore to hot update + * @param hot - `import.meta.hot` + */ +function acceptHMRUpdate(initialUseStore, hot) { + // strip as much as possible from iife.prod + if (!(process.env.NODE_ENV !== 'production')) { + return () => { }; + } + return (newModule) => { + const pinia = hot.data.pinia || initialUseStore._pinia; + if (!pinia) { + // this store is still not used + return; + } + // preserve the pinia instance across loads + hot.data.pinia = pinia; + // console.log('got data', newStore) + for (const exportName in newModule) { + const useStore = newModule[exportName]; + // console.log('checking for', exportName) + if (isUseStore(useStore) && pinia._s.has(useStore.$id)) { + // console.log('Accepting update for', useStore.$id) + const id = useStore.$id; + if (id !== initialUseStore.$id) { + console.warn(`The id of the store changed from "${initialUseStore.$id}" to "${id}". Reloading.`); + // return import.meta.hot.invalidate() + return hot.invalidate(); + } + const existingStore = pinia._s.get(id); + if (!existingStore) { + console.log(`[Pinia]: skipping hmr because store doesn't exist yet`); + return; + } + useStore(pinia, existingStore); + } + } + }; +} + +const noop = () => { }; +function addSubscription(subscriptions, callback, detached, onCleanup = noop) { + subscriptions.push(callback); + const removeSubscription = () => { + const idx = subscriptions.indexOf(callback); + if (idx > -1) { + subscriptions.splice(idx, 1); + onCleanup(); + } + }; + if (!detached && getCurrentScope()) { + onScopeDispose(removeSubscription); + } + return removeSubscription; +} +function triggerSubscriptions(subscriptions, ...args) { + subscriptions.slice().forEach((callback) => { + callback(...args); + }); +} + +const fallbackRunWithContext = (fn) => fn(); +function mergeReactiveObjects(target, patchToApply) { + // Handle Map instances + if (target instanceof Map && patchToApply instanceof Map) { + patchToApply.forEach((value, key) => target.set(key, value)); + } + // Handle Set instances + if (target instanceof Set && patchToApply instanceof Set) { + patchToApply.forEach(target.add, target); + } + // no need to go through symbols because they cannot be serialized anyway + for (const key in patchToApply) { + if (!patchToApply.hasOwnProperty(key)) + continue; + const subPatch = patchToApply[key]; + const targetValue = target[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + target.hasOwnProperty(key) && + !isRef(subPatch) && + !isReactive(subPatch)) { + // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might + // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that + // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`. + target[key] = mergeReactiveObjects(targetValue, subPatch); + } + else { + // @ts-expect-error: subPatch is a valid value + target[key] = subPatch; + } + } + return target; +} +const skipHydrateSymbol = (process.env.NODE_ENV !== 'production') + ? Symbol('pinia:skipHydration') + : /* istanbul ignore next */ Symbol(); +const skipHydrateMap = /*#__PURE__*/ new WeakMap(); +/** + * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a + * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. + * + * @param obj - target object + * @returns obj + */ +function skipHydrate(obj) { + return isVue2 + ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work... + /* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj + : Object.defineProperty(obj, skipHydrateSymbol, {}); +} +/** + * Returns whether a value should be hydrated + * + * @param obj - target variable + * @returns true if `obj` should be hydrated + */ +function shouldHydrate(obj) { + return isVue2 + ? /* istanbul ignore next */ !skipHydrateMap.has(obj) + : !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol); +} +const { assign } = Object; +function isComputed(o) { + return !!(isRef(o) && o.effect); +} +function createOptionsStore(id, options, pinia, hot) { + const { state, actions, getters } = options; + const initialState = pinia.state.value[id]; + let store; + function setup() { + if (!initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) { + /* istanbul ignore if */ + if (isVue2) { + set(pinia.state.value, id, state ? state() : {}); + } + else { + pinia.state.value[id] = state ? state() : {}; + } + } + // avoid creating a state in pinia.state.value + const localState = (process.env.NODE_ENV !== 'production') && hot + ? // use ref() to unwrap refs inside state TODO: check if this is still necessary + toRefs(ref(state ? state() : {}).value) + : toRefs(pinia.state.value[id]); + return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => { + if ((process.env.NODE_ENV !== 'production') && name in localState) { + console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`); + } + computedGetters[name] = markRaw(computed(() => { + setActivePinia(pinia); + // it was created just before + const store = pinia._s.get(id); + // allow cross using stores + /* istanbul ignore next */ + if (isVue2 && !store._r) + return; + // @ts-expect-error + // return getters![name].call(context, context) + // TODO: avoid reading the getter while assigning with a global variable + return getters[name].call(store, store); + })); + return computedGetters; + }, {})); + } + store = createSetupStore(id, setup, options, pinia, hot, true); + return store; +} +function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) { + let scope; + const optionsForPlugin = assign({ actions: {} }, options); + /* istanbul ignore if */ + if ((process.env.NODE_ENV !== 'production') && !pinia._e.active) { + throw new Error('Pinia destroyed'); + } + // watcher options for $subscribe + const $subscribeOptions = { + deep: true, + // flush: 'post', + }; + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production') && !isVue2) { + $subscribeOptions.onTrigger = (event) => { + /* istanbul ignore else */ + if (isListening) { + debuggerEvents = event; + // avoid triggering this while the store is being built and the state is being set in pinia + } + else if (isListening == false && !store._hotUpdating) { + // let patch send all the events together later + /* istanbul ignore else */ + if (Array.isArray(debuggerEvents)) { + debuggerEvents.push(event); + } + else { + console.error('🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.'); + } + } + }; + } + // internal state + let isListening; // set to true at the end + let isSyncListening; // set to true at the end + let subscriptions = []; + let actionSubscriptions = []; + let debuggerEvents; + const initialState = pinia.state.value[$id]; + // avoid setting the state for option stores if it is set + // by the setup + if (!isOptionsStore && !initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) { + /* istanbul ignore if */ + if (isVue2) { + set(pinia.state.value, $id, {}); + } + else { + pinia.state.value[$id] = {}; + } + } + const hotState = ref({}); + // avoid triggering too many listeners + // https://github.com/vuejs/pinia/issues/1129 + let activeListener; + function $patch(partialStateOrMutator) { + let subscriptionMutation; + isListening = isSyncListening = false; + // reset the debugger events since patches are sync + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + debuggerEvents = []; + } + if (typeof partialStateOrMutator === 'function') { + partialStateOrMutator(pinia.state.value[$id]); + subscriptionMutation = { + type: MutationType.patchFunction, + storeId: $id, + events: debuggerEvents, + }; + } + else { + mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator); + subscriptionMutation = { + type: MutationType.patchObject, + payload: partialStateOrMutator, + storeId: $id, + events: debuggerEvents, + }; + } + const myListenerId = (activeListener = Symbol()); + nextTick().then(() => { + if (activeListener === myListenerId) { + isListening = true; + } + }); + isSyncListening = true; + // because we paused the watcher, we need to manually call the subscriptions + triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]); + } + const $reset = isOptionsStore + ? function $reset() { + const { state } = options; + const newState = state ? state() : {}; + // we use a patch to group all changes into one single subscription + this.$patch(($state) => { + assign($state, newState); + }); + } + : /* istanbul ignore next */ + (process.env.NODE_ENV !== 'production') + ? () => { + throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`); + } + : noop; + function $dispose() { + scope.stop(); + subscriptions = []; + actionSubscriptions = []; + pinia._s.delete($id); + } + /** + * Wraps an action to handle subscriptions. + * + * @param name - name of the action + * @param action - action to wrap + * @returns a wrapped action to handle subscriptions + */ + function wrapAction(name, action) { + return function () { + setActivePinia(pinia); + const args = Array.from(arguments); + const afterCallbackList = []; + const onErrorCallbackList = []; + function after(callback) { + afterCallbackList.push(callback); + } + function onError(callback) { + onErrorCallbackList.push(callback); + } + // @ts-expect-error + triggerSubscriptions(actionSubscriptions, { + args, + name, + store, + after, + onError, + }); + let ret; + try { + ret = action.apply(this && this.$id === $id ? this : store, args); + // handle sync errors + } + catch (error) { + triggerSubscriptions(onErrorCallbackList, error); + throw error; + } + if (ret instanceof Promise) { + return ret + .then((value) => { + triggerSubscriptions(afterCallbackList, value); + return value; + }) + .catch((error) => { + triggerSubscriptions(onErrorCallbackList, error); + return Promise.reject(error); + }); + } + // trigger after callbacks + triggerSubscriptions(afterCallbackList, ret); + return ret; + }; + } + const _hmrPayload = /*#__PURE__*/ markRaw({ + actions: {}, + getters: {}, + state: [], + hotState, + }); + const partialStore = { + _p: pinia, + // _s: scope, + $id, + $onAction: addSubscription.bind(null, actionSubscriptions), + $patch, + $reset, + $subscribe(callback, options = {}) { + const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher()); + const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => { + if (options.flush === 'sync' ? isSyncListening : isListening) { + callback({ + storeId: $id, + type: MutationType.direct, + events: debuggerEvents, + }, state); + } + }, assign({}, $subscribeOptions, options))); + return removeSubscription; + }, + $dispose, + }; + /* istanbul ignore if */ + if (isVue2) { + // start as non ready + partialStore._r = false; + } + const store = reactive((process.env.NODE_ENV !== 'production') || USE_DEVTOOLS + ? assign({ + _hmrPayload, + _customProperties: markRaw(new Set()), // devtools custom properties + }, partialStore + // must be added later + // setupStore + ) + : partialStore); + // store the partial store now so the setup of stores can instantiate each other before they are finished without + // creating infinite loops. + pinia._s.set($id, store); + const runWithContext = (pinia._a && pinia._a.runWithContext) || fallbackRunWithContext; + // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped + const setupStore = runWithContext(() => pinia._e.run(() => (scope = effectScope()).run(setup))); + // overwrite existing actions to support $onAction + for (const key in setupStore) { + const prop = setupStore[key]; + if ((isRef(prop) && !isComputed(prop)) || isReactive(prop)) { + // mark it as a piece of state to be serialized + if ((process.env.NODE_ENV !== 'production') && hot) { + set(hotState.value, key, toRef(setupStore, key)); + // createOptionStore directly sets the state in pinia.state.value so we + // can just skip that + } + else if (!isOptionsStore) { + // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created + if (initialState && shouldHydrate(prop)) { + if (isRef(prop)) { + prop.value = initialState[key]; + } + else { + // probably a reactive object, lets recursively assign + // @ts-expect-error: prop is unknown + mergeReactiveObjects(prop, initialState[key]); + } + } + // transfer the ref to the pinia state to keep everything in sync + /* istanbul ignore if */ + if (isVue2) { + set(pinia.state.value[$id], key, prop); + } + else { + pinia.state.value[$id][key] = prop; + } + } + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + _hmrPayload.state.push(key); + } + // action + } + else if (typeof prop === 'function') { + // @ts-expect-error: we are overriding the function we avoid wrapping if + const actionValue = (process.env.NODE_ENV !== 'production') && hot ? prop : wrapAction(key, prop); + // this a hot module replacement store because the hotUpdate method needs + // to do it with the right context + /* istanbul ignore if */ + if (isVue2) { + set(setupStore, key, actionValue); + } + else { + // @ts-expect-error + setupStore[key] = actionValue; + } + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + _hmrPayload.actions[key] = prop; + } + // list actions so they can be used in plugins + // @ts-expect-error + optionsForPlugin.actions[key] = prop; + } + else if ((process.env.NODE_ENV !== 'production')) { + // add getters for devtools + if (isComputed(prop)) { + _hmrPayload.getters[key] = isOptionsStore + ? // @ts-expect-error + options.getters[key] + : prop; + if (IS_CLIENT) { + const getters = setupStore._getters || + // @ts-expect-error: same + (setupStore._getters = markRaw([])); + getters.push(key); + } + } + } + } + // add the state, getters, and action properties + /* istanbul ignore if */ + if (isVue2) { + Object.keys(setupStore).forEach((key) => { + set(store, key, setupStore[key]); + }); + } + else { + assign(store, setupStore); + // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object. + // Make `storeToRefs()` work with `reactive()` #799 + assign(toRaw(store), setupStore); + } + // use this instead of a computed with setter to be able to create it anywhere + // without linking the computed lifespan to wherever the store is first + // created. + Object.defineProperty(store, '$state', { + get: () => ((process.env.NODE_ENV !== 'production') && hot ? hotState.value : pinia.state.value[$id]), + set: (state) => { + /* istanbul ignore if */ + if ((process.env.NODE_ENV !== 'production') && hot) { + throw new Error('cannot set hotState'); + } + $patch(($state) => { + assign($state, state); + }); + }, + }); + // add the hotUpdate before plugins to allow them to override it + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + store._hotUpdate = markRaw((newStore) => { + store._hotUpdating = true; + newStore._hmrPayload.state.forEach((stateKey) => { + if (stateKey in store.$state) { + const newStateTarget = newStore.$state[stateKey]; + const oldStateSource = store.$state[stateKey]; + if (typeof newStateTarget === 'object' && + isPlainObject(newStateTarget) && + isPlainObject(oldStateSource)) { + patchObject(newStateTarget, oldStateSource); + } + else { + // transfer the ref + newStore.$state[stateKey] = oldStateSource; + } + } + // patch direct access properties to allow store.stateProperty to work as + // store.$state.stateProperty + set(store, stateKey, toRef(newStore.$state, stateKey)); + }); + // remove deleted state properties + Object.keys(store.$state).forEach((stateKey) => { + if (!(stateKey in newStore.$state)) { + del(store, stateKey); + } + }); + // avoid devtools logging this as a mutation + isListening = false; + isSyncListening = false; + pinia.state.value[$id] = toRef(newStore._hmrPayload, 'hotState'); + isSyncListening = true; + nextTick().then(() => { + isListening = true; + }); + for (const actionName in newStore._hmrPayload.actions) { + const action = newStore[actionName]; + set(store, actionName, wrapAction(actionName, action)); + } + // TODO: does this work in both setup and option store? + for (const getterName in newStore._hmrPayload.getters) { + const getter = newStore._hmrPayload.getters[getterName]; + const getterValue = isOptionsStore + ? // special handling of options api + computed(() => { + setActivePinia(pinia); + return getter.call(store, store); + }) + : getter; + set(store, getterName, getterValue); + } + // remove deleted getters + Object.keys(store._hmrPayload.getters).forEach((key) => { + if (!(key in newStore._hmrPayload.getters)) { + del(store, key); + } + }); + // remove old actions + Object.keys(store._hmrPayload.actions).forEach((key) => { + if (!(key in newStore._hmrPayload.actions)) { + del(store, key); + } + }); + // update the values used in devtools and to allow deleting new properties later on + store._hmrPayload = newStore._hmrPayload; + store._getters = newStore._getters; + store._hotUpdating = false; + }); + } + if (USE_DEVTOOLS) { + const nonEnumerable = { + writable: true, + configurable: true, + // avoid warning on devtools trying to display this property + enumerable: false, + }; + ['_p', '_hmrPayload', '_getters', '_customProperties'].forEach((p) => { + Object.defineProperty(store, p, assign({ value: store[p] }, nonEnumerable)); + }); + } + /* istanbul ignore if */ + if (isVue2) { + // mark the store as ready before plugins + store._r = true; + } + // apply all plugins + pinia._p.forEach((extender) => { + /* istanbul ignore else */ + if (USE_DEVTOOLS) { + const extensions = scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + })); + Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key)); + assign(store, extensions); + } + else { + assign(store, scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + }))); + } + }); + if ((process.env.NODE_ENV !== 'production') && + store.$state && + typeof store.$state === 'object' && + typeof store.$state.constructor === 'function' && + !store.$state.constructor.toString().includes('[native code]')) { + console.warn(`[🍍]: The "state" must be a plain object. It cannot be\n` + + `\tstate: () => new MyClass()\n` + + `Found in store "${store.$id}".`); + } + // only apply hydrate to option stores with an initial state in pinia + if (initialState && + isOptionsStore && + options.hydrate) { + options.hydrate(store.$state, initialState); + } + isListening = true; + isSyncListening = true; + return store; +} +function defineStore( +// TODO: add proper types from above +idOrOptions, setup, setupOptions) { + let id; + let options; + const isSetupStore = typeof setup === 'function'; + if (typeof idOrOptions === 'string') { + id = idOrOptions; + // the option store setup will contain the actual options in this case + options = isSetupStore ? setupOptions : setup; + } + else { + options = idOrOptions; + id = idOrOptions.id; + if ((process.env.NODE_ENV !== 'production') && typeof id !== 'string') { + throw new Error(`[🍍]: "defineStore()" must be passed a store id as its first argument.`); + } + } + function useStore(pinia, hot) { + const hasContext = hasInjectionContext(); + pinia = + // in test mode, ignore the argument provided as we can always retrieve a + // pinia instance with getActivePinia() + ((process.env.NODE_ENV === 'test') && activePinia && activePinia._testing ? null : pinia) || + (hasContext ? inject(piniaSymbol, null) : null); + if (pinia) + setActivePinia(pinia); + if ((process.env.NODE_ENV !== 'production') && !activePinia) { + throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?\n` + + `See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.\n` + + `This will fail in production.`); + } + pinia = activePinia; + if (!pinia._s.has(id)) { + // creating the store registers it in `pinia._s` + if (isSetupStore) { + createSetupStore(id, setup, options, pinia); + } + else { + createOptionsStore(id, options, pinia); + } + /* istanbul ignore else */ + if ((process.env.NODE_ENV !== 'production')) { + // @ts-expect-error: not the right inferred type + useStore._pinia = pinia; + } + } + const store = pinia._s.get(id); + if ((process.env.NODE_ENV !== 'production') && hot) { + const hotId = '__hot:' + id; + const newStore = isSetupStore + ? createSetupStore(hotId, setup, options, pinia, true) + : createOptionsStore(hotId, assign({}, options), pinia, true); + hot._hotUpdate(newStore); + // cleanup the state properties and the store from the cache + delete pinia.state.value[hotId]; + pinia._s.delete(hotId); + } + if ((process.env.NODE_ENV !== 'production') && IS_CLIENT) { + const currentInstance = getCurrentInstance(); + // save stores in instances to access them devtools + if (currentInstance && + currentInstance.proxy && + // avoid adding stores that are just built for hot module replacement + !hot) { + const vm = currentInstance.proxy; + const cache = '_pStores' in vm ? vm._pStores : (vm._pStores = {}); + cache[id] = store; + } + } + // StoreGeneric cannot be casted towards Store + return store; + } + useStore.$id = id; + return useStore; +} + +let mapStoreSuffix = 'Store'; +/** + * Changes the suffix added by `mapStores()`. Can be set to an empty string. + * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization + * interface if you are using TypeScript. + * + * @param suffix - new suffix + */ +function setMapStoreSuffix(suffix // could be 'Store' but that would be annoying for JS +) { + mapStoreSuffix = suffix; +} +/** + * Allows using stores without the composition API (`setup()`) by generating an + * object to be spread in the `computed` field of a component. It accepts a list + * of store definitions. + * + * @example + * ```js + * export default { + * computed: { + * // other computed properties + * ...mapStores(useUserStore, useCartStore) + * }, + * + * created() { + * this.userStore // store with id "user" + * this.cartStore // store with id "cart" + * } + * } + * ``` + * + * @param stores - list of stores to map to an object + */ +function mapStores(...stores) { + if ((process.env.NODE_ENV !== 'production') && Array.isArray(stores[0])) { + console.warn(`[🍍]: Directly pass all stores to "mapStores()" without putting them in an array:\n` + + `Replace\n` + + `\tmapStores([useAuthStore, useCartStore])\n` + + `with\n` + + `\tmapStores(useAuthStore, useCartStore)\n` + + `This will fail in production if not fixed.`); + stores = stores[0]; + } + return stores.reduce((reduced, useStore) => { + // @ts-expect-error: $id is added by defineStore + reduced[useStore.$id + mapStoreSuffix] = function () { + return useStore(this.$pinia); + }; + return reduced; + }, {}); +} +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + reduced[key] = function () { + return useStore(this.$pinia)[key]; + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function () { + const store = useStore(this.$pinia); + const storeKey = keysOrMapper[key]; + // for some reason TS is unable to infer the type of storeKey to be a + // function + return typeof storeKey === 'function' + ? storeKey.call(this, store) + : store[storeKey]; + }; + return reduced; + }, {}); +} +/** + * Alias for `mapState()`. You should use `mapState()` instead. + * @deprecated use `mapState()` instead. + */ +const mapGetters = mapState; +/** + * Allows directly using actions from your store without using the composition + * API (`setup()`) by generating an object to be spread in the `methods` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapActions(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[key](...args); + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[keysOrMapper[key]](...args); + }; + return reduced; + }, {}); +} +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapWritableState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[key]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[key] = value); + }, + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[keysOrMapper[key]]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[keysOrMapper[key]] = value); + }, + }; + return reduced; + }, {}); +} + +/** + * Creates an object of references with all the state, getters, and plugin-added + * state properties of the store. Similar to `toRefs()` but specifically + * designed for Pinia stores so methods and non reactive properties are + * completely ignored. + * + * @param store - store to extract the refs from + */ +function storeToRefs(store) { + // See https://github.com/vuejs/pinia/issues/852 + // It's easier to just use toRefs() even if it includes more stuff + if (isVue2) { + // @ts-expect-error: toRefs include methods and others + return toRefs(store); + } + else { + store = toRaw(store); + const refs = {}; + for (const key in store) { + const value = store[key]; + if (isRef(value) || isReactive(value)) { + // @ts-expect-error: the key is state or getter + refs[key] = + // --- + toRef(store, key); + } + } + return refs; + } +} + +/** + * Vue 2 Plugin that must be installed for pinia to work. Note **you don't need + * this plugin if you are using Nuxt.js**. Use the `buildModule` instead: + * https://pinia.vuejs.org/ssr/nuxt.html. + * + * @example + * ```js + * import Vue from 'vue' + * import { PiniaVuePlugin, createPinia } from 'pinia' + * + * Vue.use(PiniaVuePlugin) + * const pinia = createPinia() + * + * new Vue({ + * el: '#app', + * // ... + * pinia, + * }) + * ``` + * + * @param _Vue - `Vue` imported from 'vue'. + */ +const PiniaVuePlugin = function (_Vue) { + // Equivalent of + // app.config.globalProperties.$pinia = pinia + _Vue.mixin({ + beforeCreate() { + const options = this.$options; + if (options.pinia) { + const pinia = options.pinia; + // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/main/src/apis/inject.ts#L31 + /* istanbul ignore else */ + if (!this._provided) { + const provideCache = {}; + Object.defineProperty(this, '_provided', { + get: () => provideCache, + set: (v) => Object.assign(provideCache, v), + }); + } + this._provided[piniaSymbol] = pinia; + // propagate the pinia instance in an SSR friendly way + // avoid adding it to nuxt twice + /* istanbul ignore else */ + if (!this.$pinia) { + this.$pinia = pinia; + } + pinia._a = this; + if (IS_CLIENT) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + } + if (USE_DEVTOOLS) { + registerPiniaDevtools(pinia._a, pinia); + } + } + else if (!this.$pinia && options.parent && options.parent.$pinia) { + this.$pinia = options.parent.$pinia; + } + }, + destroyed() { + delete this._pStores; + }, + }); +}; + +export { MutationType, PiniaVuePlugin, acceptHMRUpdate, createPinia, defineStore, getActivePinia, mapActions, mapGetters, mapState, mapStores, mapWritableState, setActivePinia, setMapStoreSuffix, skipHydrate, storeToRefs }; diff --git a/node_modules/pinia/dist/pinia.prod.cjs b/node_modules/pinia/dist/pinia.prod.cjs new file mode 100644 index 0000000..ca9679a --- /dev/null +++ b/node_modules/pinia/dist/pinia.prod.cjs @@ -0,0 +1,805 @@ +/*! + * pinia v2.1.7 + * (c) 2023 Eduardo San Martin Morote + * @license MIT + */ +'use strict'; + +var vueDemi = require('vue-demi'); + +/** + * setActivePinia must be called to handle SSR at the top of functions like + * `fetch`, `setup`, `serverPrefetch` and others + */ +let activePinia; +/** + * Sets or unsets the active pinia. Used in SSR and internally when calling + * actions and getters + * + * @param pinia - Pinia instance + */ +// @ts-expect-error: cannot constrain the type of the return +const setActivePinia = (pinia) => (activePinia = pinia); +/** + * Get the currently active pinia if there is any. + */ +const getActivePinia = () => (vueDemi.hasInjectionContext() && vueDemi.inject(piniaSymbol)) || activePinia; +const piniaSymbol = (/* istanbul ignore next */ Symbol()); + +function isPlainObject( +// eslint-disable-next-line @typescript-eslint/no-explicit-any +o) { + return (o && + typeof o === 'object' && + Object.prototype.toString.call(o) === '[object Object]' && + typeof o.toJSON !== 'function'); +} +// type DeepReadonly = { readonly [P in keyof T]: DeepReadonly } +// TODO: can we change these to numbers? +/** + * Possible types for SubscriptionCallback + */ +exports.MutationType = void 0; +(function (MutationType) { + /** + * Direct mutation of the state: + * + * - `store.name = 'new name'` + * - `store.$state.name = 'new name'` + * - `store.list.push('new item')` + */ + MutationType["direct"] = "direct"; + /** + * Mutated the state with `$patch` and an object + * + * - `store.$patch({ name: 'newName' })` + */ + MutationType["patchObject"] = "patch object"; + /** + * Mutated the state with `$patch` and a function + * + * - `store.$patch(state => state.name = 'newName')` + */ + MutationType["patchFunction"] = "patch function"; + // maybe reset? for $state = {} and $reset +})(exports.MutationType || (exports.MutationType = {})); + +const IS_CLIENT = typeof window !== 'undefined'; + +/** + * Creates a Pinia instance to be used by the application + */ +function createPinia() { + const scope = vueDemi.effectScope(true); + // NOTE: here we could check the window object for a state and directly set it + // if there is anything like it with Vue 3 SSR + const state = scope.run(() => vueDemi.ref({})); + let _p = []; + // plugins added before calling app.use(pinia) + let toBeInstalled = []; + const pinia = vueDemi.markRaw({ + install(app) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + if (!vueDemi.isVue2) { + pinia._a = app; + app.provide(piniaSymbol, pinia); + app.config.globalProperties.$pinia = pinia; + toBeInstalled.forEach((plugin) => _p.push(plugin)); + toBeInstalled = []; + } + }, + use(plugin) { + if (!this._a && !vueDemi.isVue2) { + toBeInstalled.push(plugin); + } + else { + _p.push(plugin); + } + return this; + }, + _p, + // it's actually undefined here + // @ts-expect-error + _a: null, + _e: scope, + _s: new Map(), + state, + }); + return pinia; +} + +/** + * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. + * + * @example + * ```js + * const useUser = defineStore(...) + * if (import.meta.hot) { + * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) + * } + * ``` + * + * @param initialUseStore - return of the defineStore to hot update + * @param hot - `import.meta.hot` + */ +function acceptHMRUpdate(initialUseStore, hot) { + // strip as much as possible from iife.prod + { + return () => { }; + } +} + +const noop = () => { }; +function addSubscription(subscriptions, callback, detached, onCleanup = noop) { + subscriptions.push(callback); + const removeSubscription = () => { + const idx = subscriptions.indexOf(callback); + if (idx > -1) { + subscriptions.splice(idx, 1); + onCleanup(); + } + }; + if (!detached && vueDemi.getCurrentScope()) { + vueDemi.onScopeDispose(removeSubscription); + } + return removeSubscription; +} +function triggerSubscriptions(subscriptions, ...args) { + subscriptions.slice().forEach((callback) => { + callback(...args); + }); +} + +const fallbackRunWithContext = (fn) => fn(); +function mergeReactiveObjects(target, patchToApply) { + // Handle Map instances + if (target instanceof Map && patchToApply instanceof Map) { + patchToApply.forEach((value, key) => target.set(key, value)); + } + // Handle Set instances + if (target instanceof Set && patchToApply instanceof Set) { + patchToApply.forEach(target.add, target); + } + // no need to go through symbols because they cannot be serialized anyway + for (const key in patchToApply) { + if (!patchToApply.hasOwnProperty(key)) + continue; + const subPatch = patchToApply[key]; + const targetValue = target[key]; + if (isPlainObject(targetValue) && + isPlainObject(subPatch) && + target.hasOwnProperty(key) && + !vueDemi.isRef(subPatch) && + !vueDemi.isReactive(subPatch)) { + // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might + // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that + // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`. + target[key] = mergeReactiveObjects(targetValue, subPatch); + } + else { + // @ts-expect-error: subPatch is a valid value + target[key] = subPatch; + } + } + return target; +} +const skipHydrateSymbol = /* istanbul ignore next */ Symbol(); +const skipHydrateMap = /*#__PURE__*/ new WeakMap(); +/** + * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a + * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. + * + * @param obj - target object + * @returns obj + */ +function skipHydrate(obj) { + return vueDemi.isVue2 + ? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work... + /* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj + : Object.defineProperty(obj, skipHydrateSymbol, {}); +} +/** + * Returns whether a value should be hydrated + * + * @param obj - target variable + * @returns true if `obj` should be hydrated + */ +function shouldHydrate(obj) { + return vueDemi.isVue2 + ? /* istanbul ignore next */ !skipHydrateMap.has(obj) + : !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol); +} +const { assign } = Object; +function isComputed(o) { + return !!(vueDemi.isRef(o) && o.effect); +} +function createOptionsStore(id, options, pinia, hot) { + const { state, actions, getters } = options; + const initialState = pinia.state.value[id]; + let store; + function setup() { + if (!initialState && (!false )) { + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value, id, state ? state() : {}); + } + else { + pinia.state.value[id] = state ? state() : {}; + } + } + // avoid creating a state in pinia.state.value + const localState = vueDemi.toRefs(pinia.state.value[id]); + return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => { + computedGetters[name] = vueDemi.markRaw(vueDemi.computed(() => { + setActivePinia(pinia); + // it was created just before + const store = pinia._s.get(id); + // allow cross using stores + /* istanbul ignore next */ + if (vueDemi.isVue2 && !store._r) + return; + // @ts-expect-error + // return getters![name].call(context, context) + // TODO: avoid reading the getter while assigning with a global variable + return getters[name].call(store, store); + })); + return computedGetters; + }, {})); + } + store = createSetupStore(id, setup, options, pinia, hot, true); + return store; +} +function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) { + let scope; + const optionsForPlugin = assign({ actions: {} }, options); + // watcher options for $subscribe + const $subscribeOptions = { + deep: true, + // flush: 'post', + }; + // internal state + let isListening; // set to true at the end + let isSyncListening; // set to true at the end + let subscriptions = []; + let actionSubscriptions = []; + let debuggerEvents; + const initialState = pinia.state.value[$id]; + // avoid setting the state for option stores if it is set + // by the setup + if (!isOptionsStore && !initialState && (!false )) { + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value, $id, {}); + } + else { + pinia.state.value[$id] = {}; + } + } + vueDemi.ref({}); + // avoid triggering too many listeners + // https://github.com/vuejs/pinia/issues/1129 + let activeListener; + function $patch(partialStateOrMutator) { + let subscriptionMutation; + isListening = isSyncListening = false; + if (typeof partialStateOrMutator === 'function') { + partialStateOrMutator(pinia.state.value[$id]); + subscriptionMutation = { + type: exports.MutationType.patchFunction, + storeId: $id, + events: debuggerEvents, + }; + } + else { + mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator); + subscriptionMutation = { + type: exports.MutationType.patchObject, + payload: partialStateOrMutator, + storeId: $id, + events: debuggerEvents, + }; + } + const myListenerId = (activeListener = Symbol()); + vueDemi.nextTick().then(() => { + if (activeListener === myListenerId) { + isListening = true; + } + }); + isSyncListening = true; + // because we paused the watcher, we need to manually call the subscriptions + triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]); + } + const $reset = isOptionsStore + ? function $reset() { + const { state } = options; + const newState = state ? state() : {}; + // we use a patch to group all changes into one single subscription + this.$patch(($state) => { + assign($state, newState); + }); + } + : /* istanbul ignore next */ + noop; + function $dispose() { + scope.stop(); + subscriptions = []; + actionSubscriptions = []; + pinia._s.delete($id); + } + /** + * Wraps an action to handle subscriptions. + * + * @param name - name of the action + * @param action - action to wrap + * @returns a wrapped action to handle subscriptions + */ + function wrapAction(name, action) { + return function () { + setActivePinia(pinia); + const args = Array.from(arguments); + const afterCallbackList = []; + const onErrorCallbackList = []; + function after(callback) { + afterCallbackList.push(callback); + } + function onError(callback) { + onErrorCallbackList.push(callback); + } + // @ts-expect-error + triggerSubscriptions(actionSubscriptions, { + args, + name, + store, + after, + onError, + }); + let ret; + try { + ret = action.apply(this && this.$id === $id ? this : store, args); + // handle sync errors + } + catch (error) { + triggerSubscriptions(onErrorCallbackList, error); + throw error; + } + if (ret instanceof Promise) { + return ret + .then((value) => { + triggerSubscriptions(afterCallbackList, value); + return value; + }) + .catch((error) => { + triggerSubscriptions(onErrorCallbackList, error); + return Promise.reject(error); + }); + } + // trigger after callbacks + triggerSubscriptions(afterCallbackList, ret); + return ret; + }; + } + const partialStore = { + _p: pinia, + // _s: scope, + $id, + $onAction: addSubscription.bind(null, actionSubscriptions), + $patch, + $reset, + $subscribe(callback, options = {}) { + const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher()); + const stopWatcher = scope.run(() => vueDemi.watch(() => pinia.state.value[$id], (state) => { + if (options.flush === 'sync' ? isSyncListening : isListening) { + callback({ + storeId: $id, + type: exports.MutationType.direct, + events: debuggerEvents, + }, state); + } + }, assign({}, $subscribeOptions, options))); + return removeSubscription; + }, + $dispose, + }; + /* istanbul ignore if */ + if (vueDemi.isVue2) { + // start as non ready + partialStore._r = false; + } + const store = vueDemi.reactive(partialStore); + // store the partial store now so the setup of stores can instantiate each other before they are finished without + // creating infinite loops. + pinia._s.set($id, store); + const runWithContext = (pinia._a && pinia._a.runWithContext) || fallbackRunWithContext; + // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped + const setupStore = runWithContext(() => pinia._e.run(() => (scope = vueDemi.effectScope()).run(setup))); + // overwrite existing actions to support $onAction + for (const key in setupStore) { + const prop = setupStore[key]; + if ((vueDemi.isRef(prop) && !isComputed(prop)) || vueDemi.isReactive(prop)) { + // mark it as a piece of state to be serialized + if (!isOptionsStore) { + // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created + if (initialState && shouldHydrate(prop)) { + if (vueDemi.isRef(prop)) { + prop.value = initialState[key]; + } + else { + // probably a reactive object, lets recursively assign + // @ts-expect-error: prop is unknown + mergeReactiveObjects(prop, initialState[key]); + } + } + // transfer the ref to the pinia state to keep everything in sync + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(pinia.state.value[$id], key, prop); + } + else { + pinia.state.value[$id][key] = prop; + } + } + // action + } + else if (typeof prop === 'function') { + // @ts-expect-error: we are overriding the function we avoid wrapping if + const actionValue = wrapAction(key, prop); + // this a hot module replacement store because the hotUpdate method needs + // to do it with the right context + /* istanbul ignore if */ + if (vueDemi.isVue2) { + vueDemi.set(setupStore, key, actionValue); + } + else { + // @ts-expect-error + setupStore[key] = actionValue; + } + // list actions so they can be used in plugins + // @ts-expect-error + optionsForPlugin.actions[key] = prop; + } + else ; + } + // add the state, getters, and action properties + /* istanbul ignore if */ + if (vueDemi.isVue2) { + Object.keys(setupStore).forEach((key) => { + vueDemi.set(store, key, setupStore[key]); + }); + } + else { + assign(store, setupStore); + // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object. + // Make `storeToRefs()` work with `reactive()` #799 + assign(vueDemi.toRaw(store), setupStore); + } + // use this instead of a computed with setter to be able to create it anywhere + // without linking the computed lifespan to wherever the store is first + // created. + Object.defineProperty(store, '$state', { + get: () => (pinia.state.value[$id]), + set: (state) => { + $patch(($state) => { + assign($state, state); + }); + }, + }); + /* istanbul ignore if */ + if (vueDemi.isVue2) { + // mark the store as ready before plugins + store._r = true; + } + // apply all plugins + pinia._p.forEach((extender) => { + /* istanbul ignore else */ + { + assign(store, scope.run(() => extender({ + store, + app: pinia._a, + pinia, + options: optionsForPlugin, + }))); + } + }); + // only apply hydrate to option stores with an initial state in pinia + if (initialState && + isOptionsStore && + options.hydrate) { + options.hydrate(store.$state, initialState); + } + isListening = true; + isSyncListening = true; + return store; +} +function defineStore( +// TODO: add proper types from above +idOrOptions, setup, setupOptions) { + let id; + let options; + const isSetupStore = typeof setup === 'function'; + if (typeof idOrOptions === 'string') { + id = idOrOptions; + // the option store setup will contain the actual options in this case + options = isSetupStore ? setupOptions : setup; + } + else { + options = idOrOptions; + id = idOrOptions.id; + } + function useStore(pinia, hot) { + const hasContext = vueDemi.hasInjectionContext(); + pinia = + // in test mode, ignore the argument provided as we can always retrieve a + // pinia instance with getActivePinia() + ((process.env.NODE_ENV === 'test') && activePinia && activePinia._testing ? null : pinia) || + (hasContext ? vueDemi.inject(piniaSymbol, null) : null); + if (pinia) + setActivePinia(pinia); + pinia = activePinia; + if (!pinia._s.has(id)) { + // creating the store registers it in `pinia._s` + if (isSetupStore) { + createSetupStore(id, setup, options, pinia); + } + else { + createOptionsStore(id, options, pinia); + } + } + const store = pinia._s.get(id); + // StoreGeneric cannot be casted towards Store + return store; + } + useStore.$id = id; + return useStore; +} + +let mapStoreSuffix = 'Store'; +/** + * Changes the suffix added by `mapStores()`. Can be set to an empty string. + * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization + * interface if you are using TypeScript. + * + * @param suffix - new suffix + */ +function setMapStoreSuffix(suffix // could be 'Store' but that would be annoying for JS +) { + mapStoreSuffix = suffix; +} +/** + * Allows using stores without the composition API (`setup()`) by generating an + * object to be spread in the `computed` field of a component. It accepts a list + * of store definitions. + * + * @example + * ```js + * export default { + * computed: { + * // other computed properties + * ...mapStores(useUserStore, useCartStore) + * }, + * + * created() { + * this.userStore // store with id "user" + * this.cartStore // store with id "cart" + * } + * } + * ``` + * + * @param stores - list of stores to map to an object + */ +function mapStores(...stores) { + return stores.reduce((reduced, useStore) => { + // @ts-expect-error: $id is added by defineStore + reduced[useStore.$id + mapStoreSuffix] = function () { + return useStore(this.$pinia); + }; + return reduced; + }, {}); +} +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + reduced[key] = function () { + return useStore(this.$pinia)[key]; + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function () { + const store = useStore(this.$pinia); + const storeKey = keysOrMapper[key]; + // for some reason TS is unable to infer the type of storeKey to be a + // function + return typeof storeKey === 'function' + ? storeKey.call(this, store) + : store[storeKey]; + }; + return reduced; + }, {}); +} +/** + * Alias for `mapState()`. You should use `mapState()` instead. + * @deprecated use `mapState()` instead. + */ +const mapGetters = mapState; +/** + * Allows directly using actions from your store without using the composition + * API (`setup()`) by generating an object to be spread in the `methods` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapActions(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[key](...args); + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-expect-error + reduced[key] = function (...args) { + return useStore(this.$pinia)[keysOrMapper[key]](...args); + }; + return reduced; + }, {}); +} +/** + * Allows using state and getters from one store without using the composition + * API (`setup()`) by generating an object to be spread in the `computed` field + * of a component. + * + * @param useStore - store to map from + * @param keysOrMapper - array or object + */ +function mapWritableState(useStore, keysOrMapper) { + return Array.isArray(keysOrMapper) + ? keysOrMapper.reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[key]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[key] = value); + }, + }; + return reduced; + }, {}) + : Object.keys(keysOrMapper).reduce((reduced, key) => { + // @ts-ignore + reduced[key] = { + get() { + return useStore(this.$pinia)[keysOrMapper[key]]; + }, + set(value) { + // it's easier to type it here as any + return (useStore(this.$pinia)[keysOrMapper[key]] = value); + }, + }; + return reduced; + }, {}); +} + +/** + * Creates an object of references with all the state, getters, and plugin-added + * state properties of the store. Similar to `toRefs()` but specifically + * designed for Pinia stores so methods and non reactive properties are + * completely ignored. + * + * @param store - store to extract the refs from + */ +function storeToRefs(store) { + // See https://github.com/vuejs/pinia/issues/852 + // It's easier to just use toRefs() even if it includes more stuff + if (vueDemi.isVue2) { + // @ts-expect-error: toRefs include methods and others + return vueDemi.toRefs(store); + } + else { + store = vueDemi.toRaw(store); + const refs = {}; + for (const key in store) { + const value = store[key]; + if (vueDemi.isRef(value) || vueDemi.isReactive(value)) { + // @ts-expect-error: the key is state or getter + refs[key] = + // --- + vueDemi.toRef(store, key); + } + } + return refs; + } +} + +/** + * Vue 2 Plugin that must be installed for pinia to work. Note **you don't need + * this plugin if you are using Nuxt.js**. Use the `buildModule` instead: + * https://pinia.vuejs.org/ssr/nuxt.html. + * + * @example + * ```js + * import Vue from 'vue' + * import { PiniaVuePlugin, createPinia } from 'pinia' + * + * Vue.use(PiniaVuePlugin) + * const pinia = createPinia() + * + * new Vue({ + * el: '#app', + * // ... + * pinia, + * }) + * ``` + * + * @param _Vue - `Vue` imported from 'vue'. + */ +const PiniaVuePlugin = function (_Vue) { + // Equivalent of + // app.config.globalProperties.$pinia = pinia + _Vue.mixin({ + beforeCreate() { + const options = this.$options; + if (options.pinia) { + const pinia = options.pinia; + // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/main/src/apis/inject.ts#L31 + /* istanbul ignore else */ + if (!this._provided) { + const provideCache = {}; + Object.defineProperty(this, '_provided', { + get: () => provideCache, + set: (v) => Object.assign(provideCache, v), + }); + } + this._provided[piniaSymbol] = pinia; + // propagate the pinia instance in an SSR friendly way + // avoid adding it to nuxt twice + /* istanbul ignore else */ + if (!this.$pinia) { + this.$pinia = pinia; + } + pinia._a = this; + if (IS_CLIENT) { + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia); + } + } + else if (!this.$pinia && options.parent && options.parent.$pinia) { + this.$pinia = options.parent.$pinia; + } + }, + destroyed() { + delete this._pStores; + }, + }); +}; + +exports.PiniaVuePlugin = PiniaVuePlugin; +exports.acceptHMRUpdate = acceptHMRUpdate; +exports.createPinia = createPinia; +exports.defineStore = defineStore; +exports.getActivePinia = getActivePinia; +exports.mapActions = mapActions; +exports.mapGetters = mapGetters; +exports.mapState = mapState; +exports.mapStores = mapStores; +exports.mapWritableState = mapWritableState; +exports.setActivePinia = setActivePinia; +exports.setMapStoreSuffix = setMapStoreSuffix; +exports.skipHydrate = skipHydrate; +exports.storeToRefs = storeToRefs; diff --git a/node_modules/pinia/index.cjs b/node_modules/pinia/index.cjs new file mode 100644 index 0000000..9fc1f5c --- /dev/null +++ b/node_modules/pinia/index.cjs @@ -0,0 +1,7 @@ +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./dist/pinia.prod.cjs') +} else { + module.exports = require('./dist/pinia.cjs') +} diff --git a/node_modules/pinia/index.js b/node_modules/pinia/index.js new file mode 100644 index 0000000..9fc1f5c --- /dev/null +++ b/node_modules/pinia/index.js @@ -0,0 +1,7 @@ +'use strict' + +if (process.env.NODE_ENV === 'production') { + module.exports = require('./dist/pinia.prod.cjs') +} else { + module.exports = require('./dist/pinia.cjs') +} diff --git a/node_modules/pinia/package.json b/node_modules/pinia/package.json new file mode 100644 index 0000000..4568c40 --- /dev/null +++ b/node_modules/pinia/package.json @@ -0,0 +1,100 @@ +{ + "name": "pinia", + "version": "2.1.7", + "description": "Intuitive, type safe and flexible Store for Vue", + "main": "index.js", + "module": "dist/pinia.mjs", + "unpkg": "dist/pinia.iife.js", + "jsdelivr": "dist/pinia.iife.js", + "types": "dist/pinia.d.ts", + "exports": { + ".": { + "types": "./dist/pinia.d.ts", + "node": { + "import": { + "production": "./dist/pinia.prod.cjs", + "development": "./dist/pinia.mjs", + "default": "./dist/pinia.mjs" + }, + "require": { + "production": "./dist/pinia.prod.cjs", + "development": "./dist/pinia.cjs", + "default": "./index.js" + } + }, + "import": "./dist/pinia.mjs", + "require": "./index.js" + }, + "./package.json": "./package.json", + "./dist/*": "./dist/*" + }, + "sideEffects": false, + "author": { + "name": "Eduardo San Martin Morote", + "email": "posva13@gmail.com" + }, + "funding": "https://github.com/sponsors/posva", + "files": [ + "dist/*.js", + "dist/*.mjs", + "dist/*.cjs", + "dist/pinia.d.ts", + "index.js", + "index.cjs", + "LICENSE", + "README.md" + ], + "keywords": [ + "vue", + "vuex", + "store", + "pinia", + "piña", + "pigna", + "composition", + "api", + "setup", + "typed", + "typescript", + "ts", + "type", + "safe" + ], + "license": "MIT", + "devDependencies": { + "@microsoft/api-extractor": "7.34.4", + "@vue/test-utils": "^2.4.0" + }, + "dependencies": { + "@vue/devtools-api": "^6.5.0", + "vue-demi": ">=0.14.5" + }, + "peerDependencies": { + "@vue/composition-api": "^1.4.0", + "typescript": ">=4.4.4", + "vue": "^2.6.14 || ^3.3.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "@vue/composition-api": { + "optional": true + } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/vuejs/pinia.git" + }, + "bugs": { + "url": "https://github.com/vuejs/pinia/issues" + }, + "homepage": "https://github.com/vuejs/pinia#readme", + "scripts": { + "build": "rimraf dist && rollup -c ../../rollup.config.mjs --environment TARGET:pinia", + "build:dts": "api-extractor run --local --verbose && tail -n +3 ./src/globalExtensions.ts >> dist/pinia.d.ts", + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . -l pinia -r 1", + "test:dts": "tsc -p ./test-dts/tsconfig.json", + "test": "yarn run build && yarn run build:dts && yarn test:dts" + } +} \ No newline at end of file diff --git a/node_modules/vue-demi/LICENSE b/node_modules/vue-demi/LICENSE new file mode 100644 index 0000000..894ffaf --- /dev/null +++ b/node_modules/vue-demi/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020-present, Anthony Fu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/vue-demi/README.md b/node_modules/vue-demi/README.md new file mode 100644 index 0000000..f941590 --- /dev/null +++ b/node_modules/vue-demi/README.md @@ -0,0 +1,229 @@ + + +

+Vue Demi (half in French) is a developing utility
allows you to write Universal Vue Libraries for Vue 2 & 3
+See more details in this blog post +

+ +
+ +
+ +## Strategies + +- `<=2.6`: exports from `vue` + `@vue/composition-api` with plugin auto installing. +- `2.7`: exports from `vue` (Composition API is built-in in Vue 2.7). +- `>=3.0`: exports from `vue`, with polyfill of Vue 2's `set` and `del` API. + +## Usage + +Install this as your plugin's dependency: + +```bash +npm i vue-demi +# or +yarn add vue-demi +# or +pnpm i vue-demi +``` + +Add `vue` and `@vue/composition-api` to your plugin's peer dependencies to specify what versions you support. + +```jsonc +{ + "dependencies": { + "vue-demi": "latest" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^2.0.0 || >=3.0.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + }, + "devDependencies": { + "vue": "^3.0.0" // or "^2.6.0" base on your preferred working environment + }, +} +``` + +Import everything related to Vue from it, it will redirect to `vue@2` + `@vue/composition-api` or `vue@3` based on users' environments. + +```ts +import { ref, reactive, defineComponent } from 'vue-demi' +``` + +Publish your plugin and all is done! + +> When using with [Vite](https://vitejs.dev), you will need to opt-out the pre-bundling to get `vue-demi` work properly by +> ```js +> // vite.config.js +> export default defineConfig({ +> optimizeDeps: { +> exclude: ['vue-demi'] +> } +> }) +> ``` + +### Extra APIs + +`Vue Demi` provides extra APIs to help distinguish users' environments and to do some version-specific logic. + +### `isVue2` `isVue3` + +```ts +import { isVue2, isVue3 } from 'vue-demi' + +if (isVue2) { + // Vue 2 only +} else { + // Vue 3 only +} +``` + +### `Vue2` + +To avoid bringing in all the tree-shakable modules, we provide a `Vue2` export to support access to Vue 2's global API. (See [#41](https://github.com/vueuse/vue-demi/issues/41).) + +```ts +import { Vue2 } from 'vue-demi' + +if (Vue2) { + Vue2.config.ignoredElements.push('x-foo') +} +``` + +### `install()` + +Composition API in Vue 2 is provided as a plugin and needs to be installed on the Vue instance before using. Normally, `vue-demi` will try to install it automatically. For some usages where you might need to ensure the plugin gets installed correctly, the `install()` API is exposed to as a safe version of `Vue.use(CompositionAPI)`. `install()` in the Vue 3 environment will be an empty function (no-op). + +```ts +import { install } from 'vue-demi' + +install() +``` + +## CLI + +### Manually Switch Versions + +To explicitly switch the redirecting version, you can use these commands in your project's root. + +```bash +npx vue-demi-switch 2 +# or +npx vue-demi-switch 3 +``` + +### Package Aliasing + +If you would like to import `vue` under an alias, you can use the following command + +```bash +npx vue-demi-switch 2 vue2 +# or +npx vue-demi-switch 3 vue3 +``` + +Then `vue-demi` will redirect APIs from the alias name you specified, for example: + +```ts +import * as Vue from 'vue3' + +var isVue2 = false +var isVue3 = true +var Vue2 = undefined + +export * from 'vue3' +export { + Vue, + Vue2, + isVue2, + isVue3, +} +``` + +### Auto Fix + +If the `postinstall` hook doesn't get triggered or you have updated the Vue version, try to run the following command to resolve the redirecting. + +```bash +npx vue-demi-fix +``` + +### Isomorphic Testings + +You can support testing for both versions by adding npm alias in your dev dependencies. For example: + +```json +{ + "scripts": { + "test:2": "vue-demi-switch 2 vue2 && jest", + "test:3": "vue-demi-switch 3 && jest", + }, + "devDependencies": { + "vue": "^3.0.0", + "vue2": "npm:vue@2" + }, +} +``` + +or + +```json +{ + "scripts": { + "test:2": "vue-demi-switch 2 && jest", + "test:3": "vue-demi-switch 3 vue3 && jest", + }, + "devDependencies": { + "vue": "^2.6.0", + "vue3": "npm:vue@3" + }, +} +``` + +## Examples + +See [examples](./examples). + +## Who is using this? + +- [VueUse](https://github.com/vueuse/vueuse) - Collection of Composition API utils +- [@vue/apollo-composable](https://github.com/vuejs/vue-apollo/tree/v4/packages/vue-apollo-composable) - Apollo GraphQL functions for Vue Composition API +- [vuelidate](https://github.com/vuelidate/vuelidate) - Simple, lightweight model-based validation +- [vue-composition-test-utils](https://github.com/ariesjia/vue-composition-test-utils) - Simple vue composition api unit test utilities +- [vue-use-stripe](https://github.com/frandiox/vue-use-stripe) - Stripe Elements wrapper for Vue.js +- [@opd/g2plot-vue](https://github.com/open-data-plan/g2plot-vue) - G2plot for vue +- [vue-echarts](https://github.com/ecomfe/vue-echarts) - Vue.js component for Apache ECharts. +- [fluent-vue](https://github.com/Demivan/fluent-vue) - Vue.js integration for [Fluent.js](https://github.com/projectfluent/fluent.js) - JavaScript implementation of [Project Fluent](https://projectfluent.org) +- [vue-datatable-url-sync](https://github.com/socotecio/vue-datatable-url-sync) - Synchronize datatable options and filters with the url to keep user preference even after refresh or navigation +- [vue-insta-stories](https://github.com/UnevenSoftware/vue-insta-stories) - Instagram stories in your vue projects. +- [vue-tiny-validate](https://github.com/FrontLabsOfficial/vue-tiny-validate) - Tiny Vue Validate Composition +- [v-perfect-signature](https://github.com/wobsoriano/v-perfect-signature) - Pressure-sensitive signature drawing for Vue 2 and 3 +- [vue-winbox](https://github.com/wobsoriano/vue-winbox) - A wrapper component for WinBox.js that adds the ability to mount Vue components. +- [vue-word-highlighter](https://github.com/kawamataryo/vue-word-highlighter) - The word highlighter library for Vue 2 and Vue 3 +- [vue-chart-3](https://github.com/victorgarciaesgi/vue-chart-3) - Vue.js component for Chart.js +- [json-editor-vue](https://github.com/cloydlau/json-editor-vue) - JSON editor & viewer for Vue 2 and 3. +- [kidar-echarts](https://github.com/kidarjs/kidar-echarts) - A simpler echarts component for Vue 2 and 3. +- [vue3-sketch-ruler](https://github.com/kakajun/vue3-sketch-ruler) - The zoom operation used for page presentation for Vue 2 and 3( Replace render function with template ) +- [vue-rough-notation](https://github.com/Leecason/vue-rough-notation) - RoughNotation wrapper component for Vue 2 and 3. +- [vue-request](https://github.com/AttoJS/vue-request) - Vue composition API for data fetching, supports SWR, polling, error retry, cache request, pagination, etc. +- [vue3-lazyload](https://github.com/murongg/vue3-lazyload) - A vue3.x image lazyload plugin. +- [vue-codemirror6](https://github.com/logue/vue-codemirror6) - CodeMirror6 component for Vue2 and 3. +- [@tanstack/vue-query](https://github.com/TanStack/query) - TanStack Query for Vue. +> open a PR to add your library ;) + +## Underhood + +See [the blog post](https://antfu.me/posts/make-libraries-working-with-vue-2-and-3/#-introducing-vue-demi). + +## License + +MIT License © 2020 [Anthony Fu](https://github.com/antfu) diff --git a/node_modules/vue-demi/bin/vue-demi-fix.js b/node_modules/vue-demi/bin/vue-demi-fix.js new file mode 100644 index 0000000..684a621 --- /dev/null +++ b/node_modules/vue-demi/bin/vue-demi-fix.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +'use strict' +require('../scripts/postinstall') diff --git a/node_modules/vue-demi/bin/vue-demi-switch.js b/node_modules/vue-demi/bin/vue-demi-switch.js new file mode 100644 index 0000000..360eada --- /dev/null +++ b/node_modules/vue-demi/bin/vue-demi-switch.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +'use strict' +require('../scripts/switch-cli') diff --git a/node_modules/vue-demi/lib/index.cjs b/node_modules/vue-demi/lib/index.cjs new file mode 100644 index 0000000..c3d298e --- /dev/null +++ b/node_modules/vue-demi/lib/index.cjs @@ -0,0 +1,34 @@ +var Vue = require('vue') +var VueCompositionAPI = require('@vue/composition-api') + +function install(_vue) { + var vueLib = _vue || Vue + if (vueLib && 'default' in vueLib) { + vueLib = vueLib.default + } + + if (vueLib && !vueLib['__composition_api_installed__']) { + if (VueCompositionAPI && 'default' in VueCompositionAPI) + vueLib.use(VueCompositionAPI.default) + else if (VueCompositionAPI) + vueLib.use(VueCompositionAPI) + } +} + +install(Vue) + +Object.keys(VueCompositionAPI).forEach(function(key) { + exports[key] = VueCompositionAPI[key] +}) + +exports.Vue = Vue +exports.Vue2 = Vue +exports.isVue2 = true +exports.isVue3 = false +exports.install = install +exports.version = Vue.version + +// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance() +exports.hasInjectionContext = function () { + return !!VueCompositionAPI.getCurrentInstance() +} diff --git a/node_modules/vue-demi/lib/index.d.ts b/node_modules/vue-demi/lib/index.d.ts new file mode 100644 index 0000000..bbdcbc5 --- /dev/null +++ b/node_modules/vue-demi/lib/index.d.ts @@ -0,0 +1,33 @@ +import Vue from 'vue' +import type { PluginFunction, PluginObject } from 'vue' +declare const isVue2: boolean +declare const isVue3: boolean +declare const Vue2: typeof Vue | undefined +declare const version: string +declare const install: (vue?: typeof Vue) => void +/** + * @deprecated To avoid bringing in all the tree-shakable modules, this API has been deprecated. Use `Vue2` or named exports instead. + * Refer to https://github.com/vueuse/vue-demi/issues/41 + */ +declare const V: typeof Vue + +/** + * DebuggerEvent is a Vue 3 development only feature. This type cannot exist in Vue 2. + */ +export declare type DebuggerEvent = never + +// accept no generic because Vue 3 doesn't accept any +// https://github.com/vuejs/vue-next/pull/2758/ +export declare type Plugin = PluginObject | PluginFunction +export type { VNode } from 'vue' +export * from '@vue/composition-api' +export { + V as Vue, + Vue2, + isVue2, + isVue3, + version, + install, +} + +export declare function hasInjectionContext(): boolean diff --git a/node_modules/vue-demi/lib/index.iife.js b/node_modules/vue-demi/lib/index.iife.js new file mode 100644 index 0000000..796c91f --- /dev/null +++ b/node_modules/vue-demi/lib/index.iife.js @@ -0,0 +1,119 @@ +var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) { + if (VueDemi.install) { + return VueDemi + } + if (!Vue) { + console.error('[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.') + return VueDemi + } + + // Vue 2.7 + if (Vue.version.slice(0, 4) === '2.7.') { + for (var key in Vue) { + VueDemi[key] = Vue[key] + } + VueDemi.isVue2 = true + VueDemi.isVue3 = false + VueDemi.install = function () {} + VueDemi.Vue = Vue + VueDemi.Vue2 = Vue + VueDemi.version = Vue.version + VueDemi.warn = Vue.util.warn + VueDemi.hasInjectionContext = function() { + return !!VueDemi.getCurrentInstance() + } + function createApp(rootComponent, rootProps) { + var vm + var provide = {} + var app = { + config: Vue.config, + use: Vue.use.bind(Vue), + mixin: Vue.mixin.bind(Vue), + component: Vue.component.bind(Vue), + provide: function (key, value) { + provide[key] = value + return this + }, + directive: function (name, dir) { + if (dir) { + Vue.directive(name, dir) + return app + } else { + return Vue.directive(name) + } + }, + mount: function (el, hydrating) { + if (!vm) { + vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) })) + vm.$mount(el, hydrating) + return vm + } else { + return vm + } + }, + unmount: function () { + if (vm) { + vm.$destroy() + vm = undefined + } + }, + } + return app + } + VueDemi.createApp = createApp + } + // Vue 2.6.x + else if (Vue.version.slice(0, 2) === '2.') { + if (VueCompositionAPI) { + for (var key in VueCompositionAPI) { + VueDemi[key] = VueCompositionAPI[key] + } + VueDemi.isVue2 = true + VueDemi.isVue3 = false + VueDemi.install = function () {} + VueDemi.Vue = Vue + VueDemi.Vue2 = Vue + VueDemi.version = Vue.version + VueDemi.hasInjectionContext = function() { + return !!VueDemi.getCurrentInstance() + } + } else { + console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.') + } + } + // Vue 3 + else if (Vue.version.slice(0, 2) === '3.') { + for (var key in Vue) { + VueDemi[key] = Vue[key] + } + VueDemi.isVue2 = false + VueDemi.isVue3 = true + VueDemi.install = function () {} + VueDemi.Vue = Vue + VueDemi.Vue2 = undefined + VueDemi.version = Vue.version + VueDemi.set = function (target, key, val) { + if (Array.isArray(target)) { + target.length = Math.max(target.length, key) + target.splice(key, 1, val) + return val + } + target[key] = val + return val + } + VueDemi.del = function (target, key) { + if (Array.isArray(target)) { + target.splice(key, 1) + return + } + delete target[key] + } + } else { + console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.') + } + return VueDemi +})( + ((globalThis || self).VueDemi = (globalThis || self).VueDemi || (typeof VueDemi !== 'undefined' ? VueDemi : {})), + (globalThis || self).Vue || (typeof Vue !== 'undefined' ? Vue : undefined), + (globalThis || self).VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined) +); diff --git a/node_modules/vue-demi/lib/index.mjs b/node_modules/vue-demi/lib/index.mjs new file mode 100644 index 0000000..2c18122 --- /dev/null +++ b/node_modules/vue-demi/lib/index.mjs @@ -0,0 +1,49 @@ +import Vue from 'vue' +import VueCompositionAPI, { getCurrentInstance } from '@vue/composition-api/dist/vue-composition-api.mjs' + +function install(_vue) { + _vue = _vue || Vue + if (_vue && !_vue['__composition_api_installed__']) + _vue.use(VueCompositionAPI) +} + +install(Vue) + +var isVue2 = true +var isVue3 = false +var Vue2 = Vue +var version = Vue.version + +/**VCA-EXPORTS**/ +export * from '@vue/composition-api/dist/vue-composition-api.mjs' +/**VCA-EXPORTS**/ + +export { + Vue, + Vue2, + isVue2, + isVue3, + version, + install, +} + + +// Vue 3 components mock +function createMockComponent(name) { + return { + setup() { + throw new Error('[vue-demi] ' + name + ' is not supported in Vue 2. It\'s provided to avoid compiler errors.') + } + } +} +export var Fragment = /*#__PURE__*/ createMockComponent('Fragment') +export var Transition = /*#__PURE__*/ createMockComponent('Transition') +export var TransitionGroup = /*#__PURE__*/ createMockComponent('TransitionGroup') +export var Teleport = /*#__PURE__*/ createMockComponent('Teleport') +export var Suspense = /*#__PURE__*/ createMockComponent('Suspense') +export var KeepAlive = /*#__PURE__*/ createMockComponent('KeepAlive') + +// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance() +export function hasInjectionContext() { + return !!getCurrentInstance() +} diff --git a/node_modules/vue-demi/lib/v2.7/index.cjs b/node_modules/vue-demi/lib/v2.7/index.cjs new file mode 100644 index 0000000..8fa3b68 --- /dev/null +++ b/node_modules/vue-demi/lib/v2.7/index.cjs @@ -0,0 +1,60 @@ +var VueModule = require('vue') + +// get the real Vue https://github.com/vueuse/vue-demi/issues/192 +var Vue = VueModule.default || VueModule + +exports.Vue = Vue +exports.Vue2 = Vue +exports.isVue2 = true +exports.isVue3 = false +exports.install = function () {} +exports.warn = Vue.util.warn + +// createApp polyfill +exports.createApp = function (rootComponent, rootProps) { + var vm + var provide = {} + var app = { + config: Vue.config, + use: Vue.use.bind(Vue), + mixin: Vue.mixin.bind(Vue), + component: Vue.component.bind(Vue), + provide: function (key, value) { + provide[key] = value + return this + }, + directive: function (name, dir) { + if (dir) { + Vue.directive(name, dir) + return app + } else { + return Vue.directive(name) + } + }, + mount: function (el, hydrating) { + if (!vm) { + vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) })) + vm.$mount(el, hydrating) + return vm + } else { + return vm + } + }, + unmount: function () { + if (vm) { + vm.$destroy() + vm = undefined + } + }, + } + return app +} + +Object.keys(VueModule).forEach(function (key) { + exports[key] = VueModule[key] +}) + +// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance() +exports.hasInjectionContext = function() { + return !!VueModule.getCurrentInstance() +} \ No newline at end of file diff --git a/node_modules/vue-demi/lib/v2.7/index.d.ts b/node_modules/vue-demi/lib/v2.7/index.d.ts new file mode 100644 index 0000000..827c7b2 --- /dev/null +++ b/node_modules/vue-demi/lib/v2.7/index.d.ts @@ -0,0 +1,38 @@ +import Vue from 'vue' +import type { PluginFunction, PluginObject, VueConstructor, Directive, InjectionKey, Component } from 'vue' + +declare const isVue2: boolean +declare const isVue3: boolean +declare const Vue2: typeof Vue | undefined +declare const version: string +declare const install: (vue?: typeof Vue) => void +export declare function warn(msg: string, vm?: Component | null): void +/** + * @deprecated To avoid bringing in all the tree-shakable modules, this API has been deprecated. Use `Vue2` or named exports instead. + * Refer to https://github.com/vueuse/vue-demi/issues/41 + */ +declare const V: typeof Vue + +// accept no generic because Vue 3 doesn't accept any +// https://github.com/vuejs/vue-next/pull/2758/ +export declare type Plugin = PluginObject | PluginFunction +export type { VNode } from 'vue' +export * from 'vue' +export { V as Vue, Vue2, isVue2, isVue3, version, install } + +// #region createApp polyfill +export interface App { + config: VueConstructor['config'] + use: VueConstructor['use'] + mixin: VueConstructor['mixin'] + component: VueConstructor['component'] + directive(name: string): Directive | undefined + directive(name: string, directive: Directive): this + provide(key: InjectionKey | string, value: T): this + mount: Vue['$mount'] + unmount: Vue['$destroy'] +} +export declare function createApp(rootComponent: any, rootProps?: any): App +// #endregion + +export declare function hasInjectionContext(): boolean diff --git a/node_modules/vue-demi/lib/v2.7/index.mjs b/node_modules/vue-demi/lib/v2.7/index.mjs new file mode 100644 index 0000000..e575059 --- /dev/null +++ b/node_modules/vue-demi/lib/v2.7/index.mjs @@ -0,0 +1,80 @@ +import Vue from 'vue' +import { getCurrentInstance } from 'vue' + +var isVue2 = true +var isVue3 = false +var Vue2 = Vue +var warn = Vue.util.warn + +function install() {} + +// createApp polyfill +export function createApp(rootComponent, rootProps) { + var vm + var provide = {} + var app = { + config: Vue.config, + use: Vue.use.bind(Vue), + mixin: Vue.mixin.bind(Vue), + component: Vue.component.bind(Vue), + provide: function (key, value) { + provide[key] = value + return this + }, + directive: function (name, dir) { + if (dir) { + Vue.directive(name, dir) + return app + } else { + return Vue.directive(name) + } + }, + mount: function (el, hydrating) { + if (!vm) { + vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) })) + vm.$mount(el, hydrating) + return vm + } else { + return vm + } + }, + unmount: function () { + if (vm) { + vm.$destroy() + vm = undefined + } + }, + } + return app +} + +export { + Vue, + Vue2, + isVue2, + isVue3, + install, + warn +} + +// Vue 3 components mock +function createMockComponent(name) { + return { + setup() { + throw new Error('[vue-demi] ' + name + ' is not supported in Vue 2. It\'s provided to avoid compiler errors.') + } + } +} +export var Fragment = /*#__PURE__*/ createMockComponent('Fragment') +export var Transition = /*#__PURE__*/ createMockComponent('Transition') +export var TransitionGroup = /*#__PURE__*/ createMockComponent('TransitionGroup') +export var Teleport = /*#__PURE__*/ createMockComponent('Teleport') +export var Suspense = /*#__PURE__*/ createMockComponent('Suspense') +export var KeepAlive = /*#__PURE__*/ createMockComponent('KeepAlive') + +export * from 'vue' + +// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance() +export function hasInjectionContext() { + return !!getCurrentInstance() +} diff --git a/node_modules/vue-demi/lib/v2/index.cjs b/node_modules/vue-demi/lib/v2/index.cjs new file mode 100644 index 0000000..c3d298e --- /dev/null +++ b/node_modules/vue-demi/lib/v2/index.cjs @@ -0,0 +1,34 @@ +var Vue = require('vue') +var VueCompositionAPI = require('@vue/composition-api') + +function install(_vue) { + var vueLib = _vue || Vue + if (vueLib && 'default' in vueLib) { + vueLib = vueLib.default + } + + if (vueLib && !vueLib['__composition_api_installed__']) { + if (VueCompositionAPI && 'default' in VueCompositionAPI) + vueLib.use(VueCompositionAPI.default) + else if (VueCompositionAPI) + vueLib.use(VueCompositionAPI) + } +} + +install(Vue) + +Object.keys(VueCompositionAPI).forEach(function(key) { + exports[key] = VueCompositionAPI[key] +}) + +exports.Vue = Vue +exports.Vue2 = Vue +exports.isVue2 = true +exports.isVue3 = false +exports.install = install +exports.version = Vue.version + +// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance() +exports.hasInjectionContext = function () { + return !!VueCompositionAPI.getCurrentInstance() +} diff --git a/node_modules/vue-demi/lib/v2/index.d.ts b/node_modules/vue-demi/lib/v2/index.d.ts new file mode 100644 index 0000000..bbdcbc5 --- /dev/null +++ b/node_modules/vue-demi/lib/v2/index.d.ts @@ -0,0 +1,33 @@ +import Vue from 'vue' +import type { PluginFunction, PluginObject } from 'vue' +declare const isVue2: boolean +declare const isVue3: boolean +declare const Vue2: typeof Vue | undefined +declare const version: string +declare const install: (vue?: typeof Vue) => void +/** + * @deprecated To avoid bringing in all the tree-shakable modules, this API has been deprecated. Use `Vue2` or named exports instead. + * Refer to https://github.com/vueuse/vue-demi/issues/41 + */ +declare const V: typeof Vue + +/** + * DebuggerEvent is a Vue 3 development only feature. This type cannot exist in Vue 2. + */ +export declare type DebuggerEvent = never + +// accept no generic because Vue 3 doesn't accept any +// https://github.com/vuejs/vue-next/pull/2758/ +export declare type Plugin = PluginObject | PluginFunction +export type { VNode } from 'vue' +export * from '@vue/composition-api' +export { + V as Vue, + Vue2, + isVue2, + isVue3, + version, + install, +} + +export declare function hasInjectionContext(): boolean diff --git a/node_modules/vue-demi/lib/v2/index.mjs b/node_modules/vue-demi/lib/v2/index.mjs new file mode 100644 index 0000000..2c18122 --- /dev/null +++ b/node_modules/vue-demi/lib/v2/index.mjs @@ -0,0 +1,49 @@ +import Vue from 'vue' +import VueCompositionAPI, { getCurrentInstance } from '@vue/composition-api/dist/vue-composition-api.mjs' + +function install(_vue) { + _vue = _vue || Vue + if (_vue && !_vue['__composition_api_installed__']) + _vue.use(VueCompositionAPI) +} + +install(Vue) + +var isVue2 = true +var isVue3 = false +var Vue2 = Vue +var version = Vue.version + +/**VCA-EXPORTS**/ +export * from '@vue/composition-api/dist/vue-composition-api.mjs' +/**VCA-EXPORTS**/ + +export { + Vue, + Vue2, + isVue2, + isVue3, + version, + install, +} + + +// Vue 3 components mock +function createMockComponent(name) { + return { + setup() { + throw new Error('[vue-demi] ' + name + ' is not supported in Vue 2. It\'s provided to avoid compiler errors.') + } + } +} +export var Fragment = /*#__PURE__*/ createMockComponent('Fragment') +export var Transition = /*#__PURE__*/ createMockComponent('Transition') +export var TransitionGroup = /*#__PURE__*/ createMockComponent('TransitionGroup') +export var Teleport = /*#__PURE__*/ createMockComponent('Teleport') +export var Suspense = /*#__PURE__*/ createMockComponent('Suspense') +export var KeepAlive = /*#__PURE__*/ createMockComponent('KeepAlive') + +// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance() +export function hasInjectionContext() { + return !!getCurrentInstance() +} diff --git a/node_modules/vue-demi/lib/v3/index.cjs b/node_modules/vue-demi/lib/v3/index.cjs new file mode 100644 index 0000000..8197f90 --- /dev/null +++ b/node_modules/vue-demi/lib/v3/index.cjs @@ -0,0 +1,29 @@ +var Vue = require('vue') + +Object.keys(Vue).forEach(function(key) { + exports[key] = Vue[key] +}) + +exports.set = function(target, key, val) { + if (Array.isArray(target)) { + target.length = Math.max(target.length, key) + target.splice(key, 1, val) + return val + } + target[key] = val + return val +} + +exports.del = function(target, key) { + if (Array.isArray(target)) { + target.splice(key, 1) + return + } + delete target[key] +} + +exports.Vue = Vue +exports.Vue2 = undefined +exports.isVue2 = false +exports.isVue3 = true +exports.install = function(){} diff --git a/node_modules/vue-demi/lib/v3/index.d.ts b/node_modules/vue-demi/lib/v3/index.d.ts new file mode 100644 index 0000000..897b4c5 --- /dev/null +++ b/node_modules/vue-demi/lib/v3/index.d.ts @@ -0,0 +1,22 @@ +import * as Vue from 'vue' +declare const isVue2: boolean +declare const isVue3: boolean +declare const Vue2: any +declare const install: (vue?: any) => void +/** + * @deprecated To avoid bringing in all the tree-shakable modules, this API has been deprecated. Use `Vue2` or named exports instead. + * Refer to https://github.com/vueuse/vue-demi/issues/41 + */ +declare const V: typeof Vue + +export function set(target: any, key: any, val: T): T +export function del(target: any, key: any): void + +export * from 'vue' +export { + V as Vue, + Vue2, + isVue2, + isVue3, + install, +} diff --git a/node_modules/vue-demi/lib/v3/index.mjs b/node_modules/vue-demi/lib/v3/index.mjs new file mode 100644 index 0000000..be3a96d --- /dev/null +++ b/node_modules/vue-demi/lib/v3/index.mjs @@ -0,0 +1,34 @@ +import * as Vue from 'vue' + +var isVue2 = false +var isVue3 = true +var Vue2 = undefined + +function install() {} + +export function set(target, key, val) { + if (Array.isArray(target)) { + target.length = Math.max(target.length, key) + target.splice(key, 1, val) + return val + } + target[key] = val + return val +} + +export function del(target, key) { + if (Array.isArray(target)) { + target.splice(key, 1) + return + } + delete target[key] +} + +export * from 'vue' +export { + Vue, + Vue2, + isVue2, + isVue3, + install, +} diff --git a/node_modules/vue-demi/package.json b/node_modules/vue-demi/package.json new file mode 100644 index 0000000..97fb870 --- /dev/null +++ b/node_modules/vue-demi/package.json @@ -0,0 +1,47 @@ +{ + "name": "vue-demi", + "version": "0.14.8", + "engines": { + "node": ">=12" + }, + "repository": "https://github.com/antfu/vue-demi.git", + "funding": "https://github.com/sponsors/antfu", + "license": "MIT", + "author": "Anthony Fu ", + "main": "lib/index.cjs", + "jsdelivr": "lib/index.iife.js", + "unpkg": "lib/index.iife.js", + "module": "lib/index.mjs", + "types": "lib/index.d.ts", + "exports": { + ".": { + "types": "./lib/index.d.ts", + "require": "./lib/index.cjs", + "import": "./lib/index.mjs", + "browser": "./lib/index.mjs" + }, + "./*": "./*" + }, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "files": [ + "lib", + "bin", + "scripts" + ], + "scripts": { + "postinstall": "node -e \"try{require('./scripts/postinstall.js')}catch(e){}\"", + "release": "npx bumpp --tag --commit --push && npm publish" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } +} diff --git a/node_modules/vue-demi/scripts/postinstall.js b/node_modules/vue-demi/scripts/postinstall.js new file mode 100644 index 0000000..7baf14e --- /dev/null +++ b/node_modules/vue-demi/scripts/postinstall.js @@ -0,0 +1,19 @@ +const { switchVersion, loadModule } = require('./utils') + +const Vue = loadModule('vue') + +if (!Vue || typeof Vue.version !== 'string') { + console.warn('[vue-demi] Vue is not found. Please run "npm install vue" to install.') +} +else if (Vue.version.startsWith('2.7.')) { + switchVersion(2.7) +} +else if (Vue.version.startsWith('2.')) { + switchVersion(2) +} +else if (Vue.version.startsWith('3.')) { + switchVersion(3) +} +else { + console.warn(`[vue-demi] Vue version v${Vue.version} is not supported.`) +} diff --git a/node_modules/vue-demi/scripts/switch-cli.js b/node_modules/vue-demi/scripts/switch-cli.js new file mode 100644 index 0000000..3c104ca --- /dev/null +++ b/node_modules/vue-demi/scripts/switch-cli.js @@ -0,0 +1,18 @@ +const { switchVersion } = require('./utils') + +const version = process.argv[2] +const vueEntry = process.argv[3] || 'vue' + +if (version === '2.7') { + switchVersion(2.7, vueEntry) + console.log(`[vue-demi] Switched for Vue 2.7 (entry: "${vueEntry}")`) +} else if (version === '2') { + switchVersion(2, vueEntry) + console.log(`[vue-demi] Switched for Vue 2 (entry: "${vueEntry}")`) +} else if (version === '3') { + switchVersion(3, vueEntry) + console.log(`[vue-demi] Switched for Vue 3 (entry: "${vueEntry}")`) +} else { + console.warn(`[vue-demi] expecting version "2" or "2.7" or "3" but got "${version}"`) + process.exit(1) +} diff --git a/node_modules/vue-demi/scripts/utils.js b/node_modules/vue-demi/scripts/utils.js new file mode 100644 index 0000000..eff99f0 --- /dev/null +++ b/node_modules/vue-demi/scripts/utils.js @@ -0,0 +1,62 @@ +const fs = require('fs') +const path = require('path') + +const dir = path.resolve(__dirname, '..', 'lib') + +function loadModule(name) { + try { + return require(name) + } catch (e) { + return undefined + } +} + +function copy(name, version, vue) { + vue = vue || 'vue' + const src = path.join(dir, `v${version}`, name) + const dest = path.join(dir, name) + let content = fs.readFileSync(src, 'utf-8') + content = content.replace(/'vue'/g, `'${vue}'`) + // unlink for pnpm, #92 + try { + fs.unlinkSync(dest) + } catch (error) { } + fs.writeFileSync(dest, content, 'utf-8') +} + +function updateVue2API() { + const ignoreList = ['version', 'default'] + const VCA = loadModule('@vue/composition-api') + if (!VCA) { + console.warn('[vue-demi] Composition API plugin is not found. Please run "npm install @vue/composition-api" to install.') + return + } + + const exports = Object.keys(VCA).filter(i => !ignoreList.includes(i)) + + const esmPath = path.join(dir, 'index.mjs') + let content = fs.readFileSync(esmPath, 'utf-8') + + content = content.replace( + /\/\*\*VCA-EXPORTS\*\*\/[\s\S]+\/\*\*VCA-EXPORTS\*\*\//m, +`/**VCA-EXPORTS**/ +export { ${exports.join(', ')} } from '@vue/composition-api/dist/vue-composition-api.mjs' +/**VCA-EXPORTS**/` + ) + + fs.writeFileSync(esmPath, content, 'utf-8') + +} + +function switchVersion(version, vue) { + copy('index.cjs', version, vue) + copy('index.mjs', version, vue) + copy('index.d.ts', version, vue) + + if (version === 2) + updateVue2API() +} + + +module.exports.loadModule = loadModule +module.exports.switchVersion = switchVersion diff --git a/node_modules/vue/LICENSE b/node_modules/vue/LICENSE new file mode 100644 index 0000000..b65dd9e --- /dev/null +++ b/node_modules/vue/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-present, Yuxi (Evan) You + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/vue/README.md b/node_modules/vue/README.md new file mode 100644 index 0000000..862d58f --- /dev/null +++ b/node_modules/vue/README.md @@ -0,0 +1,386 @@ +

Vue logo

+ +

+ Build Status + Coverage Status + Downloads + Version + License + Chat +
+ Build Status +

+ +

Supporting Vue.js

+ +Vue.js is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome [backers](https://github.com/vuejs/vue/blob/dev/BACKERS.md). If you'd like to join them, please consider: + +- [Become a backer or sponsor on Patreon](https://www.patreon.com/evanyou). +- [Become a backer or sponsor on Open Collective](https://opencollective.com/vuejs). +- [One-time donation via PayPal or crypto-currencies](https://vuejs.org/support-vuejs/#One-time-Donations). + +#### What's the difference between Patreon and OpenCollective? + +Funds donated via Patreon go directly to support Evan You's full-time work on Vue.js. Funds donated via OpenCollective are managed with transparent expenses and will be used for compensating work and expenses for core team members or sponsoring community events. Your name/logo will receive proper recognition and exposure by donating on either platform. + +

Special Sponsors

+ + +

+ + + +

+ + + +

Platinum Sponsors

+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + +

Platinum Sponsors (China)

+ + + + + + +
+ + + +
+ + +

Gold Sponsors

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + +

Sponsors via Open Collective

+ +

Platinum

+ + + + +

Gold

+ + + + + + + + + + + + +--- + +## Introduction + +Vue (pronounced `/vjuː/`, like view) is a **progressive framework** for building user interfaces. It is designed from the ground up to be incrementally adoptable, and can easily scale between a library and a framework depending on different use cases. It consists of an approachable core library that focuses on the view layer only, and an ecosystem of supporting libraries that helps you tackle complexity in large Single-Page Applications. + +#### Browser Compatibility + +Vue.js supports all browsers that are [ES5-compliant](https://kangax.github.io/compat-table/es5/) (IE8 and below are not supported). + +## Ecosystem + +| Project | Status | Description | +|---------|--------|-------------| +| [vue-router] | [![vue-router-status]][vue-router-package] | Single-page application routing | +| [vuex] | [![vuex-status]][vuex-package] | Large-scale state management | +| [vue-cli] | [![vue-cli-status]][vue-cli-package] | Project scaffolding | +| [vue-loader] | [![vue-loader-status]][vue-loader-package] | Single File Component (`*.vue` file) loader for webpack | +| [vue-server-renderer] | [![vue-server-renderer-status]][vue-server-renderer-package] | Server-side rendering support | +| [vue-class-component] | [![vue-class-component-status]][vue-class-component-package] | TypeScript decorator for a class-based API | +| [vue-rx] | [![vue-rx-status]][vue-rx-package] | RxJS integration | +| [vue-devtools] | [![vue-devtools-status]][vue-devtools-package] | Browser DevTools extension | + +[vue-router]: https://github.com/vuejs/vue-router +[vuex]: https://github.com/vuejs/vuex +[vue-cli]: https://github.com/vuejs/vue-cli +[vue-loader]: https://github.com/vuejs/vue-loader +[vue-server-renderer]: https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer +[vue-class-component]: https://github.com/vuejs/vue-class-component +[vue-rx]: https://github.com/vuejs/vue-rx +[vue-devtools]: https://github.com/vuejs/vue-devtools + +[vue-router-status]: https://img.shields.io/npm/v/vue-router.svg +[vuex-status]: https://img.shields.io/npm/v/vuex.svg +[vue-cli-status]: https://img.shields.io/npm/v/@vue/cli.svg +[vue-loader-status]: https://img.shields.io/npm/v/vue-loader.svg +[vue-server-renderer-status]: https://img.shields.io/npm/v/vue-server-renderer.svg +[vue-class-component-status]: https://img.shields.io/npm/v/vue-class-component.svg +[vue-rx-status]: https://img.shields.io/npm/v/vue-rx.svg +[vue-devtools-status]: https://img.shields.io/chrome-web-store/v/nhdogjmejiglipccpnnnanhbledajbpd.svg + +[vue-router-package]: https://npmjs.com/package/vue-router +[vuex-package]: https://npmjs.com/package/vuex +[vue-cli-package]: https://npmjs.com/package/@vue/cli +[vue-loader-package]: https://npmjs.com/package/vue-loader +[vue-server-renderer-package]: https://npmjs.com/package/vue-server-renderer +[vue-class-component-package]: https://npmjs.com/package/vue-class-component +[vue-rx-package]: https://npmjs.com/package/vue-rx +[vue-devtools-package]: https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd + +## Documentation + +To check out [live examples](https://vuejs.org/v2/examples/) and docs, visit [vuejs.org](https://vuejs.org). + +## Questions + +For questions and support please use [the official forum](https://forum.vuejs.org) or [community chat](https://chat.vuejs.org/). The issue list of this repo is **exclusively** for bug reports and feature requests. + +## Issues + +Please make sure to read the [Issue Reporting Checklist](https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#issue-reporting-guidelines) before opening an issue. Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](https://github.com/vuejs/vue/releases). + +## Stay In Touch + +- [Twitter](https://twitter.com/vuejs) +- [Blog](https://medium.com/the-vue-point) +- [Job Board](https://vuejobs.com/?ref=vuejs) + +## Contribution + +Please make sure to read the [Contributing Guide](https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md) before making a pull request. If you have a Vue-related project/component/tool, add it with a pull request to [this curated list](https://github.com/vuejs/awesome-vue)! + +Thank you to all the people who already contributed to Vue! + + + + +## License + +[MIT](https://opensource.org/licenses/MIT) + +Copyright (c) 2013-present, Yuxi (Evan) You diff --git a/node_modules/vue/dist/README.md b/node_modules/vue/dist/README.md new file mode 100644 index 0000000..19386ec --- /dev/null +++ b/node_modules/vue/dist/README.md @@ -0,0 +1,122 @@ +## Explanation of Build Files + +| | UMD | CommonJS | ES Module | +| --- | --- | --- | --- | +| **Full** | vue.js | vue.common.js | vue.esm.js | +| **Runtime-only** | vue.runtime.js | vue.runtime.common.js | vue.runtime.esm.js | +| **Full (production)** | vue.min.js | | | +| **Runtime-only (production)** | vue.runtime.min.js | | | + +### Terms + +- **Full**: builds that contain both the compiler and the runtime. + +- **Compiler**: code that is responsible for compiling template strings into JavaScript render functions. + +- **Runtime**: code that is responsible for creating Vue instances, rendering and patching virtual DOM, etc. Basically everything minus the compiler. + +- **[UMD](https://github.com/umdjs/umd)**: UMD builds can be used directly in the browser via a `` + : '' + } + + renderScripts (context: Object): string { + if (this.clientManifest) { + const initial = this.preloadFiles.filter(({ file }) => isJS(file)) + const async = (this.getUsedAsyncFiles(context) || []).filter(({ file }) => isJS(file)) + const needed = [initial[0]].concat(async, initial.slice(1)) + return needed.map(({ file }) => { + return `` + }).join('') + } else { + return '' + } + } + + getUsedAsyncFiles (context: Object): ?Array { + if (!context._mappedFiles && context._registeredComponents && this.mapFiles) { + const registered = Array.from(context._registeredComponents) + context._mappedFiles = this.mapFiles(registered).map(normalizeFile) + } + return context._mappedFiles + } + + // create a transform stream + createStream (context: ?Object): TemplateStream { + if (!this.parsedTemplate) { + throw new Error('createStream cannot be called without a template.') + } + return new TemplateStream(this, this.parsedTemplate, context || {}) + } +} + +function normalizeFile (file: string): Resource { + const withoutQuery = file.replace(/\?.*/, '') + const extension = path.extname(withoutQuery).slice(1) + return { + file, + extension, + fileWithoutQuery: withoutQuery, + asType: getPreloadType(extension) + } +} + +function getPreloadType (ext: string): string { + if (ext === 'js') { + return 'script' + } else if (ext === 'css') { + return 'style' + } else if (/jpe?g|png|svg|gif|webp|ico/.test(ext)) { + return 'image' + } else if (/woff2?|ttf|otf|eot/.test(ext)) { + return 'font' + } else { + // not exhausting all possibilities here, but above covers common cases + return '' + } +} diff --git a/node_modules/vue/src/server/template-renderer/parse-template.js b/node_modules/vue/src/server/template-renderer/parse-template.js new file mode 100644 index 0000000..1ccfe89 --- /dev/null +++ b/node_modules/vue/src/server/template-renderer/parse-template.js @@ -0,0 +1,42 @@ +/* @flow */ + +const compile = require('lodash.template') +const compileOptions = { + escape: /{{([^{][\s\S]+?[^}])}}/g, + interpolate: /{{{([\s\S]+?)}}}/g +} + +export type ParsedTemplate = { + head: (data: any) => string; + neck: (data: any) => string; + tail: (data: any) => string; +}; + +export function parseTemplate ( + template: string, + contentPlaceholder?: string = '' +): ParsedTemplate { + if (typeof template === 'object') { + return template + } + + let i = template.indexOf('') + const j = template.indexOf(contentPlaceholder) + + if (j < 0) { + throw new Error(`Content placeholder not found in template.`) + } + + if (i < 0) { + i = template.indexOf('') + if (i < 0) { + i = j + } + } + + return { + head: compile(template.slice(0, i), compileOptions), + neck: compile(template.slice(i, j), compileOptions), + tail: compile(template.slice(j + contentPlaceholder.length), compileOptions) + } +} diff --git a/node_modules/vue/src/server/template-renderer/template-stream.js b/node_modules/vue/src/server/template-renderer/template-stream.js new file mode 100644 index 0000000..ed4db78 --- /dev/null +++ b/node_modules/vue/src/server/template-renderer/template-stream.js @@ -0,0 +1,82 @@ +/* @flow */ + +const Transform = require('stream').Transform +import type TemplateRenderer from './index' +import type { ParsedTemplate } from './parse-template' + +export default class TemplateStream extends Transform { + started: boolean; + renderer: TemplateRenderer; + template: ParsedTemplate; + context: Object; + inject: boolean; + + constructor ( + renderer: TemplateRenderer, + template: ParsedTemplate, + context: Object + ) { + super() + this.started = false + this.renderer = renderer + this.template = template + this.context = context || {} + this.inject = renderer.inject + } + + _transform (data: Buffer | string, encoding: string, done: Function) { + if (!this.started) { + this.emit('beforeStart') + this.start() + } + this.push(data) + done() + } + + start () { + this.started = true + this.push(this.template.head(this.context)) + + if (this.inject) { + // inline server-rendered head meta information + if (this.context.head) { + this.push(this.context.head) + } + + // inline preload/prefetch directives for initial/async chunks + const links = this.renderer.renderResourceHints(this.context) + if (links) { + this.push(links) + } + + // CSS files and inline server-rendered CSS collected by vue-style-loader + const styles = this.renderer.renderStyles(this.context) + if (styles) { + this.push(styles) + } + } + + this.push(this.template.neck(this.context)) + } + + _flush (done: Function) { + this.emit('beforeEnd') + + if (this.inject) { + // inline initial store state + const state = this.renderer.renderState(this.context) + if (state) { + this.push(state) + } + + // embed scripts needed + const scripts = this.renderer.renderScripts(this.context) + if (scripts) { + this.push(scripts) + } + } + + this.push(this.template.tail(this.context)) + done() + } +} diff --git a/node_modules/vue/src/server/util.js b/node_modules/vue/src/server/util.js new file mode 100644 index 0000000..908f8c9 --- /dev/null +++ b/node_modules/vue/src/server/util.js @@ -0,0 +1,18 @@ +/* @flow */ + +export const isJS = (file: string): boolean => /\.js(\?[^.]+)?$/.test(file) + +export const isCSS = (file: string): boolean => /\.css(\?[^.]+)?$/.test(file) + +export function createPromiseCallback () { + let resolve, reject + const promise: Promise = new Promise((_resolve, _reject) => { + resolve = _resolve + reject = _reject + }) + const cb = (err: Error, res?: string) => { + if (err) return reject(err) + resolve(res || '') + } + return { promise, cb } +} diff --git a/node_modules/vue/src/server/webpack-plugin/client.js b/node_modules/vue/src/server/webpack-plugin/client.js new file mode 100644 index 0000000..ec7b875 --- /dev/null +++ b/node_modules/vue/src/server/webpack-plugin/client.js @@ -0,0 +1,67 @@ +const hash = require('hash-sum') +const uniq = require('lodash.uniq') +import { isJS, isCSS, getAssetName, onEmit, stripModuleIdHash } from './util' + +export default class VueSSRClientPlugin { + constructor (options = {}) { + this.options = Object.assign({ + filename: 'vue-ssr-client-manifest.json' + }, options) + } + + apply (compiler) { + const stage = 'PROCESS_ASSETS_STAGE_ADDITIONAL' + onEmit(compiler, 'vue-client-plugin', stage, (compilation, cb) => { + const stats = compilation.getStats().toJson() + + const allFiles = uniq(stats.assets + .map(a => a.name)) + + const initialFiles = uniq(Object.keys(stats.entrypoints) + .map(name => stats.entrypoints[name].assets) + .reduce((assets, all) => all.concat(assets), []) + .map(getAssetName) + .filter((file) => isJS(file) || isCSS(file))) + + const asyncFiles = allFiles + .filter((file) => isJS(file) || isCSS(file)) + .filter(file => initialFiles.indexOf(file) < 0) + + const manifest = { + publicPath: stats.publicPath, + all: allFiles, + initial: initialFiles, + async: asyncFiles, + modules: { /* [identifier: string]: Array */ } + } + + const assetModules = stats.modules.filter(m => m.assets.length) + const fileToIndex = asset => manifest.all.indexOf(getAssetName(asset)) + stats.modules.forEach(m => { + // ignore modules duplicated in multiple chunks + if (m.chunks.length === 1) { + const cid = m.chunks[0] + const chunk = stats.chunks.find(c => c.id === cid) + if (!chunk || !chunk.files) { + return + } + const id = stripModuleIdHash(m.identifier) + const files = manifest.modules[hash(id)] = chunk.files.map(fileToIndex) + // find all asset modules associated with the same chunk + assetModules.forEach(m => { + if (m.chunks.some(id => id === cid)) { + files.push.apply(files, m.assets.map(fileToIndex)) + } + }) + } + }) + + const json = JSON.stringify(manifest, null, 2) + compilation.assets[this.options.filename] = { + source: () => json, + size: () => json.length + } + cb() + }) + } +} diff --git a/node_modules/vue/src/server/webpack-plugin/server.js b/node_modules/vue/src/server/webpack-plugin/server.js new file mode 100644 index 0000000..02fab24 --- /dev/null +++ b/node_modules/vue/src/server/webpack-plugin/server.js @@ -0,0 +1,69 @@ +import { validate, isJS, getAssetName, onEmit } from './util' + +export default class VueSSRServerPlugin { + constructor (options = {}) { + this.options = Object.assign({ + filename: 'vue-ssr-server-bundle.json' + }, options) + } + + apply (compiler) { + validate(compiler) + + const stage = 'PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER' + onEmit(compiler, 'vue-server-plugin', stage, (compilation, cb) => { + const stats = compilation.getStats().toJson() + const entryName = Object.keys(stats.entrypoints)[0] + const entryInfo = stats.entrypoints[entryName] + + if (!entryInfo) { + // #5553 + return cb() + } + + const entryAssets = entryInfo.assets + .map(getAssetName) + .filter(isJS) + + if (entryAssets.length > 1) { + throw new Error( + `Server-side bundle should have one single entry file. ` + + `Avoid using CommonsChunkPlugin in the server config.` + ) + } + + const entry = entryAssets[0] + if (!entry || typeof entry !== 'string') { + throw new Error( + `Entry "${entryName}" not found. Did you specify the correct entry option?` + ) + } + + const bundle = { + entry, + files: {}, + maps: {} + } + + Object.keys(compilation.assets).forEach(name => { + if (isJS(name)) { + bundle.files[name] = compilation.assets[name].source() + } else if (name.match(/\.js\.map$/)) { + bundle.maps[name.replace(/\.map$/, '')] = JSON.parse(compilation.assets[name].source()) + } + // do not emit anything else for server + delete compilation.assets[name] + }) + + const json = JSON.stringify(bundle, null, 2) + const filename = this.options.filename + + compilation.assets[filename] = { + source: () => json, + size: () => json.length + } + + cb() + }) + } +} diff --git a/node_modules/vue/src/server/webpack-plugin/util.js b/node_modules/vue/src/server/webpack-plugin/util.js new file mode 100644 index 0000000..844671b --- /dev/null +++ b/node_modules/vue/src/server/webpack-plugin/util.js @@ -0,0 +1,73 @@ +const { red, yellow } = require('chalk') +const webpack = require('webpack') + +const prefix = `[vue-server-renderer-webpack-plugin]` +const warn = exports.warn = msg => console.error(red(`${prefix} ${msg}\n`)) +const tip = exports.tip = msg => console.log(yellow(`${prefix} ${msg}\n`)) + +const isWebpack5 = !!(webpack.version && webpack.version[0] > 4) + +export const validate = compiler => { + if (compiler.options.target !== 'node') { + warn('webpack config `target` should be "node".') + } + + if (compiler.options.output) { + if (compiler.options.output.library) { + // Webpack >= 5.0.0 + if (compiler.options.output.library.type !== 'commonjs2') { + warn('webpack config `output.library.type` should be "commonjs2".') + } + } else if (compiler.options.output.libraryTarget !== 'commonjs2') { + // Webpack < 5.0.0 + warn('webpack config `output.libraryTarget` should be "commonjs2".') + } + } + + if (!compiler.options.externals) { + tip( + 'It is recommended to externalize dependencies in the server build for ' + + 'better build performance.' + ) + } +} + +export const onEmit = (compiler, name, stageName, hook) => { + if (isWebpack5) { + // Webpack >= 5.0.0 + compiler.hooks.compilation.tap(name, compilation => { + if (compilation.compiler !== compiler) { + // Ignore child compilers + return + } + const stage = webpack.Compilation[stageName] + compilation.hooks.processAssets.tapAsync({ name, stage }, (assets, cb) => { + hook(compilation, cb) + }) + }) + } else if (compiler.hooks) { + // Webpack >= 4.0.0 + compiler.hooks.emit.tapAsync(name, hook) + } else { + // Webpack < 4.0.0 + compiler.plugin('emit', hook) + } +} + +export const stripModuleIdHash = id => { + if (isWebpack5) { + // Webpack >= 5.0.0 + return id.replace(/\|\w+$/, '') + } + // Webpack < 5.0.0 + return id.replace(/\s\w+$/, '') +} + +export const getAssetName = asset => { + if (typeof asset === 'string') { + return asset + } + return asset.name +} + +export { isJS, isCSS } from '../util' diff --git a/node_modules/vue/src/server/write.js b/node_modules/vue/src/server/write.js new file mode 100644 index 0000000..27a5e8a --- /dev/null +++ b/node_modules/vue/src/server/write.js @@ -0,0 +1,50 @@ +/* @flow */ + +const MAX_STACK_DEPTH = 800 +const noop = _ => _ + +const defer = typeof process !== 'undefined' && process.nextTick + ? process.nextTick + : typeof Promise !== 'undefined' + ? fn => Promise.resolve().then(fn) + : typeof setTimeout !== 'undefined' + ? setTimeout + : noop + +if (defer === noop) { + throw new Error( + 'Your JavaScript runtime does not support any asynchronous primitives ' + + 'that are required by vue-server-renderer. Please use a polyfill for ' + + 'either Promise or setTimeout.' + ) +} + +export function createWriteFunction ( + write: (text: string, next: Function) => boolean, + onError: Function +): Function { + let stackDepth = 0 + const cachedWrite = (text, next) => { + if (text && cachedWrite.caching) { + cachedWrite.cacheBuffer[cachedWrite.cacheBuffer.length - 1] += text + } + const waitForNext = write(text, next) + if (waitForNext !== true) { + if (stackDepth >= MAX_STACK_DEPTH) { + defer(() => { + try { next() } catch (e) { + onError(e) + } + }) + } else { + stackDepth++ + next() + stackDepth-- + } + } + } + cachedWrite.caching = false + cachedWrite.cacheBuffer = [] + cachedWrite.componentBuffer = [] + return cachedWrite +} diff --git a/node_modules/vue/src/sfc/parser.js b/node_modules/vue/src/sfc/parser.js new file mode 100644 index 0000000..59c5fc3 --- /dev/null +++ b/node_modules/vue/src/sfc/parser.js @@ -0,0 +1,134 @@ +/* @flow */ + +import deindent from 'de-indent' +import { parseHTML } from 'compiler/parser/html-parser' +import { makeMap } from 'shared/util' + +const splitRE = /\r?\n/g +const replaceRE = /./g +const isSpecialTag = makeMap('script,style,template', true) + +/** + * Parse a single-file component (*.vue) file into an SFC Descriptor Object. + */ +export function parseComponent ( + content: string, + options?: Object = {} +): SFCDescriptor { + const sfc: SFCDescriptor = { + template: null, + script: null, + styles: [], + customBlocks: [], + errors: [] + } + let depth = 0 + let currentBlock: ?SFCBlock = null + + let warn = msg => { + sfc.errors.push(msg) + } + + if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) { + warn = (msg, range) => { + const data: WarningMessage = { msg } + if (range.start != null) { + data.start = range.start + } + if (range.end != null) { + data.end = range.end + } + sfc.errors.push(data) + } + } + + function start ( + tag: string, + attrs: Array, + unary: boolean, + start: number, + end: number + ) { + if (depth === 0) { + currentBlock = { + type: tag, + content: '', + start: end, + attrs: attrs.reduce((cumulated, { name, value }) => { + cumulated[name] = value || true + return cumulated + }, {}) + } + if (isSpecialTag(tag)) { + checkAttrs(currentBlock, attrs) + if (tag === 'style') { + sfc.styles.push(currentBlock) + } else { + sfc[tag] = currentBlock + } + } else { // custom blocks + sfc.customBlocks.push(currentBlock) + } + } + if (!unary) { + depth++ + } + } + + function checkAttrs (block: SFCBlock, attrs: Array) { + for (let i = 0; i < attrs.length; i++) { + const attr = attrs[i] + if (attr.name === 'lang') { + block.lang = attr.value + } + if (attr.name === 'scoped') { + block.scoped = true + } + if (attr.name === 'module') { + block.module = attr.value || true + } + if (attr.name === 'src') { + block.src = attr.value + } + } + } + + function end (tag: string, start: number) { + if (depth === 1 && currentBlock) { + currentBlock.end = start + let text = content.slice(currentBlock.start, currentBlock.end) + if (options.deindent !== false) { + text = deindent(text) + } + // pad content so that linters and pre-processors can output correct + // line numbers in errors and warnings + if (currentBlock.type !== 'template' && options.pad) { + text = padContent(currentBlock, options.pad) + text + } + currentBlock.content = text + currentBlock = null + } + depth-- + } + + function padContent (block: SFCBlock, pad: true | "line" | "space") { + if (pad === 'space') { + return content.slice(0, block.start).replace(replaceRE, ' ') + } else { + const offset = content.slice(0, block.start).split(splitRE).length + const padChar = block.type === 'script' && !block.lang + ? '//\n' + : '\n' + return Array(offset).join(padChar) + } + } + + parseHTML(content, { + warn, + start, + end, + outputSourceRange: options.outputSourceRange + }) + + return sfc +} diff --git a/node_modules/vue/src/shared/constants.js b/node_modules/vue/src/shared/constants.js new file mode 100644 index 0000000..a8b15e0 --- /dev/null +++ b/node_modules/vue/src/shared/constants.js @@ -0,0 +1,22 @@ +export const SSR_ATTR = 'data-server-rendered' + +export const ASSET_TYPES = [ + 'component', + 'directive', + 'filter' +] + +export const LIFECYCLE_HOOKS = [ + 'beforeCreate', + 'created', + 'beforeMount', + 'mounted', + 'beforeUpdate', + 'updated', + 'beforeDestroy', + 'destroyed', + 'activated', + 'deactivated', + 'errorCaptured', + 'serverPrefetch' +] diff --git a/node_modules/vue/src/shared/util.js b/node_modules/vue/src/shared/util.js new file mode 100644 index 0000000..9f240c7 --- /dev/null +++ b/node_modules/vue/src/shared/util.js @@ -0,0 +1,343 @@ +/* @flow */ + +export const emptyObject = Object.freeze({}) + +// These helpers produce better VM code in JS engines due to their +// explicitness and function inlining. +export function isUndef (v: any): boolean %checks { + return v === undefined || v === null +} + +export function isDef (v: any): boolean %checks { + return v !== undefined && v !== null +} + +export function isTrue (v: any): boolean %checks { + return v === true +} + +export function isFalse (v: any): boolean %checks { + return v === false +} + +/** + * Check if value is primitive. + */ +export function isPrimitive (value: any): boolean %checks { + return ( + typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean' + ) +} + +/** + * Quick object check - this is primarily used to tell + * Objects from primitive values when we know the value + * is a JSON-compliant type. + */ +export function isObject (obj: mixed): boolean %checks { + return obj !== null && typeof obj === 'object' +} + +/** + * Get the raw type string of a value, e.g., [object Object]. + */ +const _toString = Object.prototype.toString + +export function toRawType (value: any): string { + return _toString.call(value).slice(8, -1) +} + +/** + * Strict object type check. Only returns true + * for plain JavaScript objects. + */ +export function isPlainObject (obj: any): boolean { + return _toString.call(obj) === '[object Object]' +} + +export function isRegExp (v: any): boolean { + return _toString.call(v) === '[object RegExp]' +} + +/** + * Check if val is a valid array index. + */ +export function isValidArrayIndex (val: any): boolean { + const n = parseFloat(String(val)) + return n >= 0 && Math.floor(n) === n && isFinite(val) +} + +export function isPromise (val: any): boolean { + return ( + isDef(val) && + typeof val.then === 'function' && + typeof val.catch === 'function' + ) +} + +/** + * Convert a value to a string that is actually rendered. + */ +export function toString (val: any): string { + return val == null + ? '' + : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString) + ? JSON.stringify(val, null, 2) + : String(val) +} + +/** + * Convert an input value to a number for persistence. + * If the conversion fails, return original string. + */ +export function toNumber (val: string): number | string { + const n = parseFloat(val) + return isNaN(n) ? val : n +} + +/** + * Make a map and return a function for checking if a key + * is in that map. + */ +export function makeMap ( + str: string, + expectsLowerCase?: boolean +): (key: string) => true | void { + const map = Object.create(null) + const list: Array = str.split(',') + for (let i = 0; i < list.length; i++) { + map[list[i]] = true + } + return expectsLowerCase + ? val => map[val.toLowerCase()] + : val => map[val] +} + +/** + * Check if a tag is a built-in tag. + */ +export const isBuiltInTag = makeMap('slot,component', true) + +/** + * Check if an attribute is a reserved attribute. + */ +export const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is') + +/** + * Remove an item from an array. + */ +export function remove (arr: Array, item: any): Array | void { + if (arr.length) { + const index = arr.indexOf(item) + if (index > -1) { + return arr.splice(index, 1) + } + } +} + +/** + * Check whether an object has the property. + */ +const hasOwnProperty = Object.prototype.hasOwnProperty +export function hasOwn (obj: Object | Array<*>, key: string): boolean { + return hasOwnProperty.call(obj, key) +} + +/** + * Create a cached version of a pure function. + */ +export function cached (fn: F): F { + const cache = Object.create(null) + return (function cachedFn (str: string) { + const hit = cache[str] + return hit || (cache[str] = fn(str)) + }: any) +} + +/** + * Camelize a hyphen-delimited string. + */ +const camelizeRE = /-(\w)/g +export const camelize = cached((str: string): string => { + return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') +}) + +/** + * Capitalize a string. + */ +export const capitalize = cached((str: string): string => { + return str.charAt(0).toUpperCase() + str.slice(1) +}) + +/** + * Hyphenate a camelCase string. + */ +const hyphenateRE = /\B([A-Z])/g +export const hyphenate = cached((str: string): string => { + return str.replace(hyphenateRE, '-$1').toLowerCase() +}) + +/** + * Simple bind polyfill for environments that do not support it, + * e.g., PhantomJS 1.x. Technically, we don't need this anymore + * since native bind is now performant enough in most browsers. + * But removing it would mean breaking code that was able to run in + * PhantomJS 1.x, so this must be kept for backward compatibility. + */ + +/* istanbul ignore next */ +function polyfillBind (fn: Function, ctx: Object): Function { + function boundFn (a) { + const l = arguments.length + return l + ? l > 1 + ? fn.apply(ctx, arguments) + : fn.call(ctx, a) + : fn.call(ctx) + } + + boundFn._length = fn.length + return boundFn +} + +function nativeBind (fn: Function, ctx: Object): Function { + return fn.bind(ctx) +} + +export const bind = Function.prototype.bind + ? nativeBind + : polyfillBind + +/** + * Convert an Array-like object to a real Array. + */ +export function toArray (list: any, start?: number): Array { + start = start || 0 + let i = list.length - start + const ret: Array = new Array(i) + while (i--) { + ret[i] = list[i + start] + } + return ret +} + +/** + * Mix properties into target object. + */ +export function extend (to: Object, _from: ?Object): Object { + for (const key in _from) { + to[key] = _from[key] + } + return to +} + +/** + * Merge an Array of Objects into a single Object. + */ +export function toObject (arr: Array): Object { + const res = {} + for (let i = 0; i < arr.length; i++) { + if (arr[i]) { + extend(res, arr[i]) + } + } + return res +} + +/* eslint-disable no-unused-vars */ + +/** + * Perform no operation. + * Stubbing args to make Flow happy without leaving useless transpiled code + * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/). + */ +export function noop (a?: any, b?: any, c?: any) {} + +/** + * Always return false. + */ +export const no = (a?: any, b?: any, c?: any) => false + +/* eslint-enable no-unused-vars */ + +/** + * Return the same value. + */ +export const identity = (_: any) => _ + +/** + * Generate a string containing static keys from compiler modules. + */ +export function genStaticKeys (modules: Array): string { + return modules.reduce((keys, m) => { + return keys.concat(m.staticKeys || []) + }, []).join(',') +} + +/** + * Check if two values are loosely equal - that is, + * if they are plain objects, do they have the same shape? + */ +export function looseEqual (a: any, b: any): boolean { + if (a === b) return true + const isObjectA = isObject(a) + const isObjectB = isObject(b) + if (isObjectA && isObjectB) { + try { + const isArrayA = Array.isArray(a) + const isArrayB = Array.isArray(b) + if (isArrayA && isArrayB) { + return a.length === b.length && a.every((e, i) => { + return looseEqual(e, b[i]) + }) + } else if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime() + } else if (!isArrayA && !isArrayB) { + const keysA = Object.keys(a) + const keysB = Object.keys(b) + return keysA.length === keysB.length && keysA.every(key => { + return looseEqual(a[key], b[key]) + }) + } else { + /* istanbul ignore next */ + return false + } + } catch (e) { + /* istanbul ignore next */ + return false + } + } else if (!isObjectA && !isObjectB) { + return String(a) === String(b) + } else { + return false + } +} + +/** + * Return the first index at which a loosely equal value can be + * found in the array (if value is a plain object, the array must + * contain an object of the same shape), or -1 if it is not present. + */ +export function looseIndexOf (arr: Array, val: mixed): number { + for (let i = 0; i < arr.length; i++) { + if (looseEqual(arr[i], val)) return i + } + return -1 +} + +/** + * Ensure a function is called only once. + */ +export function once (fn: Function): Function { + let called = false + return function () { + if (!called) { + called = true + fn.apply(this, arguments) + } + } +} diff --git a/node_modules/vue/types/index.d.ts b/node_modules/vue/types/index.d.ts new file mode 100644 index 0000000..58ceb20 --- /dev/null +++ b/node_modules/vue/types/index.d.ts @@ -0,0 +1,39 @@ +import { Vue } from "./vue"; +import "./umd"; + +export default Vue; + +export { + CreateElement, + VueConstructor +} from "./vue"; + +export { + Component, + AsyncComponent, + ComponentOptions, + FunctionalComponentOptions, + RenderContext, + PropType, + PropOptions, + ComputedOptions, + WatchHandler, + WatchOptions, + WatchOptionsWithHandler, + DirectiveFunction, + DirectiveOptions +} from "./options"; + +export { + PluginFunction, + PluginObject +} from "./plugin"; + +export { + VNodeChildren, + VNodeChildrenArrayContents, + VNode, + VNodeComponentOptions, + VNodeData, + VNodeDirective +} from "./vnode"; diff --git a/node_modules/vue/types/options.d.ts b/node_modules/vue/types/options.d.ts new file mode 100644 index 0000000..ff26605 --- /dev/null +++ b/node_modules/vue/types/options.d.ts @@ -0,0 +1,207 @@ +import { Vue, CreateElement, CombinedVueInstance } from "./vue"; +import { VNode, VNodeData, VNodeDirective, NormalizedScopedSlot } from "./vnode"; + +type Constructor = { + new (...args: any[]): any; +} + +// we don't support infer props in async component +// N.B. ComponentOptions is contravariant, the default generic should be bottom type +export type Component, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = + | typeof Vue + | FunctionalComponentOptions + | ComponentOptions + +type EsModule = T | { default: T } + +type ImportedComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> + = EsModule> + +export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> + = AsyncComponentPromise + | AsyncComponentFactory + +export type AsyncComponentPromise, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = ( + resolve: (component: Component) => void, + reject: (reason?: any) => void +) => Promise> | void; + +export type AsyncComponentFactory, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = () => { + component: Promise>; + loading?: ImportedComponent; + error?: ImportedComponent; + delay?: number; + timeout?: number; +} + +/** + * When the `Computed` type parameter on `ComponentOptions` is inferred, + * it should have a property with the return type of every get-accessor. + * Since there isn't a way to query for the return type of a function, we allow TypeScript + * to infer from the shape of `Accessors` and work backwards. + */ +export type Accessors = { + [K in keyof T]: (() => T[K]) | ComputedOptions +} + +type DataDef = Data | ((this: Readonly & V) => Data) +/** + * This type should be used when an array of strings is used for a component's `props` value. + */ +export type ThisTypedComponentOptionsWithArrayProps = + object & + ComponentOptions, V>, Methods, Computed, PropNames[], Record> & + ThisType>>>; + +/** + * This type should be used when an object mapped to `PropOptions` is used for a component's `props` value. + */ +export type ThisTypedComponentOptionsWithRecordProps = + object & + ComponentOptions, Methods, Computed, RecordPropsDefinition, Props> & + ThisType>>; + +type DefaultData = object | ((this: V) => object); +type DefaultProps = Record; +type DefaultMethods = { [key: string]: (this: V, ...args: any[]) => any }; +type DefaultComputed = { [key: string]: any }; +export interface ComponentOptions< + V extends Vue, + Data=DefaultData, + Methods=DefaultMethods, + Computed=DefaultComputed, + PropsDef=PropsDefinition, + Props=DefaultProps> { + data?: Data; + props?: PropsDef; + propsData?: object; + computed?: Accessors; + methods?: Methods; + watch?: Record | WatchHandler>; + + el?: Element | string; + template?: string; + // hack is for functional component type inference, should not be used in user code + render?(createElement: CreateElement, hack: RenderContext): VNode; + renderError?(createElement: CreateElement, err: Error): VNode; + staticRenderFns?: ((createElement: CreateElement) => VNode)[]; + + beforeCreate?(this: V): void; + created?(): void; + beforeDestroy?(): void; + destroyed?(): void; + beforeMount?(): void; + mounted?(): void; + beforeUpdate?(): void; + updated?(): void; + activated?(): void; + deactivated?(): void; + errorCaptured?(err: Error, vm: Vue, info: string): boolean | void; + serverPrefetch?(this: V): Promise; + + directives?: { [key: string]: DirectiveFunction | DirectiveOptions }; + components?: { [key: string]: Component | AsyncComponent }; + transitions?: { [key: string]: object }; + filters?: { [key: string]: Function }; + + provide?: object | (() => object); + inject?: InjectOptions; + + model?: { + prop?: string; + event?: string; + }; + + parent?: Vue; + mixins?: (ComponentOptions | typeof Vue)[]; + name?: string; + // TODO: support properly inferred 'extends' + extends?: ComponentOptions | typeof Vue; + delimiters?: [string, string]; + comments?: boolean; + inheritAttrs?: boolean; +} + +export interface FunctionalComponentOptions> { + name?: string; + props?: PropDefs; + model?: { + prop?: string; + event?: string; + }; + inject?: InjectOptions; + functional: boolean; + render?(this: undefined, createElement: CreateElement, context: RenderContext): VNode | VNode[]; +} + +export interface RenderContext { + props: Props; + children: VNode[]; + slots(): any; + data: VNodeData; + parent: Vue; + listeners: { [key: string]: Function | Function[] }; + scopedSlots: { [key: string]: NormalizedScopedSlot }; + injections: any +} + +export type Prop = { (): T } | { new(...args: never[]): T & object } | { new(...args: string[]): Function } + +export type PropType = Prop | Prop[]; + +export type PropValidator = PropOptions | PropType; + +export interface PropOptions { + type?: PropType; + required?: boolean; + default?: T | null | undefined | (() => T | null | undefined); + validator?(value: T): boolean; +} + +export type RecordPropsDefinition = { + [K in keyof T]: PropValidator +} +export type ArrayPropsDefinition = (keyof T)[]; +export type PropsDefinition = ArrayPropsDefinition | RecordPropsDefinition; + +export interface ComputedOptions { + get?(): T; + set?(value: T): void; + cache?: boolean; +} + +export type WatchHandler = string | ((val: T, oldVal: T) => void); + +export interface WatchOptions { + deep?: boolean; + immediate?: boolean; +} + +export interface WatchOptionsWithHandler extends WatchOptions { + handler: WatchHandler; +} + +export interface DirectiveBinding extends Readonly { + readonly modifiers: { [key: string]: boolean }; +} + +export type DirectiveFunction = ( + el: HTMLElement, + binding: DirectiveBinding, + vnode: VNode, + oldVnode: VNode +) => void; + +export interface DirectiveOptions { + bind?: DirectiveFunction; + inserted?: DirectiveFunction; + update?: DirectiveFunction; + componentUpdated?: DirectiveFunction; + unbind?: DirectiveFunction; +} + +export type InjectKey = string | symbol; + +export type InjectOptions = { + [key: string]: InjectKey | { from?: InjectKey, default?: any } +} | string[]; diff --git a/node_modules/vue/types/plugin.d.ts b/node_modules/vue/types/plugin.d.ts new file mode 100644 index 0000000..5741f86 --- /dev/null +++ b/node_modules/vue/types/plugin.d.ts @@ -0,0 +1,8 @@ +import { Vue as _Vue } from "./vue"; + +export type PluginFunction = (Vue: typeof _Vue, options?: T) => void; + +export interface PluginObject { + install: PluginFunction; + [key: string]: any; +} diff --git a/node_modules/vue/types/umd.d.ts b/node_modules/vue/types/umd.d.ts new file mode 100644 index 0000000..d1dc8d1 --- /dev/null +++ b/node_modules/vue/types/umd.d.ts @@ -0,0 +1,48 @@ +import * as V from "./index"; +import { + DefaultData, + DefaultProps, + DefaultMethods, + DefaultComputed, + PropsDefinition +} from "./options"; + +// Expose some types for backward compatibility... +declare namespace Vue { + // vue.d.ts + export type CreateElement = V.CreateElement; + export type VueConstructor = V.VueConstructor; + + // options.d.ts + export type Component, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = V.Component; + export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = V.AsyncComponent; + export type ComponentOptions, Methods=DefaultMethods, Computed=DefaultComputed, PropsDef=PropsDefinition, Props=DefaultProps> = V.ComponentOptions; + export type FunctionalComponentOptions> = V.FunctionalComponentOptions; + export type RenderContext = V.RenderContext; + export type PropType = V.PropType; + export type PropOptions = V.PropOptions; + export type ComputedOptions = V.ComputedOptions; + export type WatchHandler = V.WatchHandler; + export type WatchOptions = V.WatchOptions; + export type WatchOptionsWithHandler = V.WatchOptionsWithHandler; + export type DirectiveFunction = V.DirectiveFunction; + export type DirectiveOptions = V.DirectiveOptions; + + // plugin.d.ts + export type PluginFunction = V.PluginFunction; + export type PluginObject = V.PluginObject; + + // vnode.d.ts + export type VNodeChildren = V.VNodeChildren; + export type VNodeChildrenArrayContents = V.VNodeChildrenArrayContents; + export type VNode = V.VNode; + export type VNodeComponentOptions = V.VNodeComponentOptions; + export type VNodeData = V.VNodeData; + export type VNodeDirective = V.VNodeDirective; +} + +declare class Vue extends V.default {} + +export = Vue; + +export as namespace Vue; diff --git a/node_modules/vue/types/vnode.d.ts b/node_modules/vue/types/vnode.d.ts new file mode 100644 index 0000000..997980c --- /dev/null +++ b/node_modules/vue/types/vnode.d.ts @@ -0,0 +1,76 @@ +import { Vue } from "./vue"; + +export type ScopedSlot = (props: any) => ScopedSlotReturnValue; +type ScopedSlotReturnValue = VNode | string | boolean | null | undefined | ScopedSlotReturnArray; +interface ScopedSlotReturnArray extends Array {} + +// Scoped slots are guaranteed to return Array of VNodes starting in 2.6 +export type NormalizedScopedSlot = (props: any) => ScopedSlotChildren; +export type ScopedSlotChildren = VNode[] | undefined; + +// Relaxed type compatible with $createElement +export type VNodeChildren = VNodeChildrenArrayContents | [ScopedSlot] | string | boolean | null | undefined; +export interface VNodeChildrenArrayContents extends Array {} + +export interface VNode { + tag?: string; + data?: VNodeData; + children?: VNode[]; + text?: string; + elm?: Node; + ns?: string; + context?: Vue; + key?: string | number | symbol | boolean; + componentOptions?: VNodeComponentOptions; + componentInstance?: Vue; + parent?: VNode; + raw?: boolean; + isStatic?: boolean; + isRootInsert: boolean; + isComment: boolean; +} + +export interface VNodeComponentOptions { + Ctor: typeof Vue; + propsData?: object; + listeners?: object; + children?: VNode[]; + tag?: string; +} + +export interface VNodeData { + key?: string | number; + slot?: string; + scopedSlots?: { [key: string]: ScopedSlot | undefined }; + ref?: string; + refInFor?: boolean; + tag?: string; + staticClass?: string; + class?: any; + staticStyle?: { [key: string]: any }; + style?: string | object[] | object; + props?: { [key: string]: any }; + attrs?: { [key: string]: any }; + domProps?: { [key: string]: any }; + hook?: { [key: string]: Function }; + on?: { [key: string]: Function | Function[] }; + nativeOn?: { [key: string]: Function | Function[] }; + transition?: object; + show?: boolean; + inlineTemplate?: { + render: Function; + staticRenderFns: Function[]; + }; + directives?: VNodeDirective[]; + keepAlive?: boolean; +} + +export interface VNodeDirective { + name: string; + value?: any; + oldValue?: any; + expression?: string; + arg?: string; + oldArg?: string; + modifiers?: { [key: string]: boolean }; +} diff --git a/node_modules/vue/types/vue.d.ts b/node_modules/vue/types/vue.d.ts new file mode 100644 index 0000000..7adb5a5 --- /dev/null +++ b/node_modules/vue/types/vue.d.ts @@ -0,0 +1,132 @@ +import { + Component, + AsyncComponent, + ComponentOptions, + FunctionalComponentOptions, + WatchOptionsWithHandler, + WatchHandler, + DirectiveOptions, + DirectiveFunction, + RecordPropsDefinition, + ThisTypedComponentOptionsWithArrayProps, + ThisTypedComponentOptionsWithRecordProps, + WatchOptions, +} from "./options"; +import { VNode, VNodeData, VNodeChildren, NormalizedScopedSlot } from "./vnode"; +import { PluginFunction, PluginObject } from "./plugin"; + +export interface CreateElement { + (tag?: string | Component | AsyncComponent | (() => Component), children?: VNodeChildren): VNode; + (tag?: string | Component | AsyncComponent | (() => Component), data?: VNodeData, children?: VNodeChildren): VNode; +} + +export interface Vue { + readonly $el: Element; + readonly $options: ComponentOptions; + readonly $parent: Vue; + readonly $root: Vue; + readonly $children: Vue[]; + readonly $refs: { [key: string]: Vue | Element | (Vue | Element)[] | undefined }; + readonly $slots: { [key: string]: VNode[] | undefined }; + readonly $scopedSlots: { [key: string]: NormalizedScopedSlot | undefined }; + readonly $isServer: boolean; + readonly $data: Record; + readonly $props: Record; + readonly $ssrContext: any; + readonly $vnode: VNode; + readonly $attrs: Record; + readonly $listeners: Record; + + $mount(elementOrSelector?: Element | string, hydrating?: boolean): this; + $forceUpdate(): void; + $destroy(): void; + $set: typeof Vue.set; + $delete: typeof Vue.delete; + $watch( + expOrFn: string, + callback: (this: this, n: any, o: any) => void, + options?: WatchOptions + ): (() => void); + $watch( + expOrFn: (this: this) => T, + callback: (this: this, n: T, o: T) => void, + options?: WatchOptions + ): (() => void); + $on(event: string | string[], callback: Function): this; + $once(event: string | string[], callback: Function): this; + $off(event?: string | string[], callback?: Function): this; + $emit(event: string, ...args: any[]): this; + $nextTick(callback: (this: this) => void): void; + $nextTick(): Promise; + $createElement: CreateElement; +} + +export type CombinedVueInstance = Data & Methods & Computed & Props & Instance; +export type ExtendedVue = VueConstructor & Vue>; + +export interface VueConfiguration { + silent: boolean; + optionMergeStrategies: any; + devtools: boolean; + productionTip: boolean; + performance: boolean; + errorHandler(err: Error, vm: Vue, info: string): void; + warnHandler(msg: string, vm: Vue, trace: string): void; + ignoredElements: (string | RegExp)[]; + keyCodes: { [key: string]: number | number[] }; + async: boolean; +} + +export interface VueConstructor { + new (options?: ThisTypedComponentOptionsWithArrayProps): CombinedVueInstance>; + // ideally, the return type should just contain Props, not Record. But TS requires to have Base constructors with the same return type. + new (options?: ThisTypedComponentOptionsWithRecordProps): CombinedVueInstance>; + new (options?: ComponentOptions): CombinedVueInstance>; + + extend(options?: ThisTypedComponentOptionsWithArrayProps): ExtendedVue>; + extend(options?: ThisTypedComponentOptionsWithRecordProps): ExtendedVue; + extend(definition: FunctionalComponentOptions, PropNames[]>): ExtendedVue>; + extend(definition: FunctionalComponentOptions>): ExtendedVue; + extend(options?: ComponentOptions): ExtendedVue; + + nextTick(callback: (this: T) => void, context?: T): void; + nextTick(): Promise + set(object: object, key: string | number, value: T): T; + set(array: T[], key: number, value: T): T; + delete(object: object, key: string | number): void; + delete(array: T[], key: number): void; + + directive( + id: string, + definition?: DirectiveOptions | DirectiveFunction + ): DirectiveOptions; + filter(id: string, definition?: Function): Function; + + component(id: string): VueConstructor; + component(id: string, constructor: VC): VC; + component(id: string, definition: AsyncComponent): ExtendedVue; + component(id: string, definition?: ThisTypedComponentOptionsWithArrayProps): ExtendedVue>; + component(id: string, definition?: ThisTypedComponentOptionsWithRecordProps): ExtendedVue; + component(id: string, definition: FunctionalComponentOptions, PropNames[]>): ExtendedVue>; + component(id: string, definition: FunctionalComponentOptions>): ExtendedVue; + component(id: string, definition?: ComponentOptions): ExtendedVue; + + use(plugin: PluginObject | PluginFunction, options?: T): VueConstructor; + use(plugin: PluginObject | PluginFunction, ...options: any[]): VueConstructor; + mixin(mixin: VueConstructor | ComponentOptions): VueConstructor; + compile(template: string): { + render(createElement: typeof Vue.prototype.$createElement): VNode; + staticRenderFns: (() => VNode)[]; + }; + + observable(obj: T): T; + + util: { + warn(msg: string, vm?: InstanceType): void; + }; + + config: VueConfiguration; + version: string; +} + +export const Vue: VueConstructor; diff --git a/package-lock.json b/package-lock.json index 29b32fe..9210db5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,13 +9,76 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "js-md5": "^0.8.3" + "js-md5": "^0.8.3", + "pinia": "^2.1.7" } }, + "node_modules/@vue/devtools-api": { + "version": "6.6.3", + "resolved": "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.6.3.tgz", + "integrity": "sha512-0MiMsFma/HqA6g3KLKn+AGpL1kgKhFWszC9U29NfpWK5LE7bjeXxySWJrOJ77hBz+TBrBQ7o4QJqbPbqbs8rJw==" + }, "node_modules/js-md5": { "version": "0.8.3", "resolved": "https://registry.npmmirror.com/js-md5/-/js-md5-0.8.3.tgz", "integrity": "sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ==" + }, + "node_modules/pinia": { + "version": "2.1.7", + "resolved": "https://registry.npmmirror.com/pinia/-/pinia-2.1.7.tgz", + "integrity": "sha512-+C2AHFtcFqjPih0zpYuvof37SFxMQ7OEG2zV9jRI12i9BOy3YQVAHwdKtyyc8pDcDyIc33WCIsZaCFWU7WWxGQ==", + "dependencies": { + "@vue/devtools-api": "^6.5.0", + "vue-demi": ">=0.14.5" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "@vue/composition-api": "^1.4.0", + "typescript": ">=4.4.4", + "vue": "^2.6.14 || ^3.3.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/vue": { + "version": "2.6.14", + "resolved": "https://registry.npmmirror.com/vue/-/vue-2.6.14.tgz", + "integrity": "sha512-x2284lgYvjOMj3Za7kqzRcUSxBboHqtgRE2zlos1qWaOye5yUmHn42LB1250NJBLRwEcdrB0JRwyPTEPhfQjiQ==", + "deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.", + "peer": true + }, + "node_modules/vue-demi": { + "version": "0.14.8", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.8.tgz", + "integrity": "sha512-Uuqnk9YE9SsWeReYqK2alDI5YzciATE0r2SkA6iMAtuXvNTMNACJLJEXNXaEy94ECuBe4Sk6RzRU80kjdbIo1Q==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } } } } diff --git a/package.json b/package.json index ec6b7ff..e394467 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "", "license": "ISC", "dependencies": { - "js-md5": "^0.8.3" + "js-md5": "^0.8.3", + "pinia": "^2.1.7" } } diff --git a/pages.json b/pages.json index 83a0197..71e4273 100644 --- a/pages.json +++ b/pages.json @@ -34,7 +34,57 @@ "enablePullDownRefresh": false, "backgroundTextStyle": "dark" } + }, + { + "path": "login/loginwx", + "style": { + "navigationBarTitleText": "登录", + "enablePullDownRefresh": false, + "backgroundTextStyle": "dark" + } + }, + { + "path": "authentication/authentication", + "style": { + "navigationBarTitleText": "业主认证", + "enablePullDownRefresh": false, + "backgroundTextStyle": "dark" + } + }, + { + "path": "authentication/comp/select1", + "style": { + "navigationBarTitleText": "业主认证", + "enablePullDownRefresh": false, + "backgroundTextStyle": "dark" + } + }, + { + "path": "authentication/comp/select2", + "style": { + "navigationBarTitleText": "业主认证", + "enablePullDownRefresh": false, + "backgroundTextStyle": "dark" + } + }, + { + "path": "authentication/comp/select3", + "style": { + "navigationBarTitleText": "业主认证", + "enablePullDownRefresh": false, + "backgroundTextStyle": "dark" + } + }, + { + "path": "privacyAgreement/privacyAgreement", + "style": { + "navigationBarTitleText": "业主认证", + "enablePullDownRefresh": false, + "backgroundTextStyle": "dark" + } } + + ] } ], diff --git a/pages/subPage/authentication/authentication.vue b/pages/subPage/authentication/authentication.vue new file mode 100644 index 0000000..6066ec9 --- /dev/null +++ b/pages/subPage/authentication/authentication.vue @@ -0,0 +1,135 @@ + + + + + \ No newline at end of file diff --git a/pages/subPage/authentication/comp/select1.vue b/pages/subPage/authentication/comp/select1.vue new file mode 100644 index 0000000..1350243 --- /dev/null +++ b/pages/subPage/authentication/comp/select1.vue @@ -0,0 +1,102 @@ + + + + + \ No newline at end of file diff --git a/pages/subPage/authentication/comp/select2.vue b/pages/subPage/authentication/comp/select2.vue new file mode 100644 index 0000000..bee114e --- /dev/null +++ b/pages/subPage/authentication/comp/select2.vue @@ -0,0 +1,91 @@ + + + + + \ No newline at end of file diff --git a/pages/subPage/authentication/comp/select3.vue b/pages/subPage/authentication/comp/select3.vue new file mode 100644 index 0000000..3f86fda --- /dev/null +++ b/pages/subPage/authentication/comp/select3.vue @@ -0,0 +1,91 @@ + + + + + \ No newline at end of file diff --git a/pages/subPage/authentication/selectAddress.vue b/pages/subPage/authentication/selectAddress.vue new file mode 100644 index 0000000..5d82c0d --- /dev/null +++ b/pages/subPage/authentication/selectAddress.vue @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/pages/subPage/login/login.vue b/pages/subPage/login/login.vue index c43260b..99b3ea9 100644 --- a/pages/subPage/login/login.vue +++ b/pages/subPage/login/login.vue @@ -8,47 +8,90 @@ 事务通 - - - +86 - - - - - - - - - - 发送验证码 - - - - + + + + + + - - - - 其它登录方式 - - - - 快捷登录 + + @@ -67,16 +110,32 @@ justify-content: center; font-size: 22rpx; color: #9C9C9C; + position: fixed; + bottom: 80rpx; + left: 0; + width: 100%; .lineTxt { position: relative; &::before { content: ''; position: absolute; - width: 256rpx; - height: 1px; + width: 240rpx; + height: 1rpx; top: 50%; - left: 0; + background: #e6e6e6; + right: 150rpx; + transform: translateY(50%); + z-index: 99; + } + &::after { + content: ''; + position: absolute; + width: 240rpx; + height: 1rpx; + top: 50%; + background: #e6e6e6; + left: 150rpx; transform: translateY(50%); z-index: 99; } @@ -99,7 +158,7 @@ flex-direction: column; align-items: center; justify-content: center; - padding-top: 50rpx; + padding-top: 150rpx; .logo { width: 160rpx; height: 160rpx; @@ -111,38 +170,15 @@ font-weight: 700; } } - - .from { - margin-top: 20rpx; - .formItem { - height: 108rpx; - border-bottom: 1px solid #EFEFEF; - .prefix { - font-size: 28rpx; - color: #333; - width: 120rpx; - text-align: center; - } - - .line { - width: 1px; - height: 40rpx; - background: #EFEFEF; - margin-right: 30rpx; - } - - .inputBox { - flex: 1; - width: 0; - } - - .sedCode { - font-size: 28rpx; - color: $themC; - } - } - .oneBtn { - margin-top: 40rpx; + .oneBtnBox { + margin-top: 40rpx; + position: relative; + .cotact { + position: absolute; + left: 0; + right: 0; + top: 0; + opacity: 0; } } } diff --git a/pages/subPage/login/loginbyPhone.vue b/pages/subPage/login/loginbyPhone.vue new file mode 100644 index 0000000..88f5c6e --- /dev/null +++ b/pages/subPage/login/loginbyPhone.vue @@ -0,0 +1,239 @@ + + + + + \ No newline at end of file diff --git a/pages/subPage/login/loginwx.vue b/pages/subPage/login/loginwx.vue new file mode 100644 index 0000000..8933170 --- /dev/null +++ b/pages/subPage/login/loginwx.vue @@ -0,0 +1,184 @@ + + + + + \ No newline at end of file diff --git a/pages/subPage/privacyAgreement/privacyAgreement.vue b/pages/subPage/privacyAgreement/privacyAgreement.vue new file mode 100644 index 0000000..e3da231 --- /dev/null +++ b/pages/subPage/privacyAgreement/privacyAgreement.vue @@ -0,0 +1,43 @@ + + + + + \ No newline at end of file diff --git a/pages/tabbar/index/index.vue b/pages/tabbar/index/index.vue index 2740cda..1cc4195 100644 --- a/pages/tabbar/index/index.vue +++ b/pages/tabbar/index/index.vue @@ -1,7 +1,9 @@

+ +
+
npm +