@poveste/vendors 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/dist/client/b-floating-vue.d.ts +3 -0
- package/dist/client/b-floating-vue.js +3377 -0
- package/dist/client/b-iconify.d.ts +1 -0
- package/dist/client/b-iconify.js +1883 -0
- package/dist/client/b-pinia.d.ts +1 -0
- package/dist/client/b-pinia.js +2069 -0
- package/dist/client/b-scroll.d.ts +2 -0
- package/dist/client/b-scroll.js +7 -0
- package/dist/client/b-vue-router.d.ts +1 -0
- package/dist/client/b-vue-router.js +2773 -0
- package/dist/client/b-vue-use.d.ts +1 -0
- package/dist/client/b-vue-use.js +9626 -0
- package/dist/client/b-vue.d.ts +1 -0
- package/dist/client/b-vue.js +1 -0
- package/dist/client/index.js +169 -0
- package/dist/client/node_modules/@babel/helper-string-parser/package.json +31 -0
- package/dist/client/node_modules/@babel/helper-validator-identifier/package.json +31 -0
- package/dist/client/node_modules/@babel/parser/package.json +50 -0
- package/dist/client/node_modules/@babel/parser/typings/babel-parser.d.ts +262 -0
- package/dist/client/node_modules/@babel/types/lib/index-legacy.d.ts +2796 -0
- package/dist/client/node_modules/@babel/types/lib/index.d.ts +3616 -0
- package/dist/client/node_modules/@babel/types/package.json +39 -0
- package/dist/client/node_modules/@floating-ui/core/dist/floating-ui.core.d.mts +535 -0
- package/dist/client/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +535 -0
- package/dist/client/node_modules/@floating-ui/core/package.json +63 -0
- package/dist/client/node_modules/@floating-ui/dom/index.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/package.json +74 -0
- package/dist/client/node_modules/@floating-ui/dom/src/autoUpdate.d.ts +31 -0
- package/dist/client/node_modules/@floating-ui/dom/src/index.d.ts +11 -0
- package/dist/client/node_modules/@floating-ui/dom/src/platform.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/types.d.ts +128 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/convertOffsetParentRelativeRectToViewportRelativeRect.d.ts +6 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getBoundingClientRect.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingRect.d.ts +12 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getComputedStyle.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getCssDimensions.d.ts +4 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDimensions.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDocumentElement.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getDocumentRect.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getNearestOverflowAncestor.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getNodeName.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getNodeScroll.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getOffsetParent.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts +3 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getParentNode.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getRectRelativeToOffsetParent.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getScale.d.ts +7 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getViewportRect.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/getWindowScrollBarX.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/is.d.ts +17 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/math.d.ts +3 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/unwrapElement.d.ts +2 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/userAgent.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/dom/src/utils/window.d.ts +1 -0
- package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.mts +105 -0
- package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.ts +105 -0
- package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.mts +47 -0
- package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.ts +47 -0
- package/dist/client/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.d.ts +47 -0
- package/dist/client/node_modules/@floating-ui/utils/dom/package.json +6 -0
- package/dist/client/node_modules/@floating-ui/utils/package.json +70 -0
- package/dist/client/node_modules/@iconify/types/package.json +23 -0
- package/dist/client/node_modules/@iconify/types/provider.d.ts +44 -0
- package/dist/client/node_modules/@iconify/types/types.d.ts +272 -0
- package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +475 -0
- package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +114 -0
- package/dist/client/node_modules/@iconify/vue/offline/package.json +14 -0
- package/dist/client/node_modules/@iconify/vue/package.json +65 -0
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/package.json +63 -0
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts +50 -0
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts +9 -0
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/strings.d.mts +16 -0
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts +7 -0
- package/dist/client/node_modules/@types/web-bluetooth/index.d.ts +265 -0
- package/dist/client/node_modules/@types/web-bluetooth/package.json +46 -0
- package/dist/client/node_modules/@vue/compiler-core/dist/compiler-core.d.ts +1100 -0
- package/dist/client/node_modules/@vue/compiler-core/package.json +58 -0
- package/dist/client/node_modules/@vue/compiler-dom/dist/compiler-dom.d.ts +45 -0
- package/dist/client/node_modules/@vue/compiler-dom/package.json +57 -0
- package/dist/client/node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts +485 -0
- package/dist/client/node_modules/@vue/compiler-sfc/package.json +67 -0
- package/dist/client/node_modules/@vue/compiler-ssr/dist/compiler-ssr.d.ts +4 -0
- package/dist/client/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/api.d.ts +108 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/app.d.ts +1 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/component.d.ts +78 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/context.d.ts +5 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts +180 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/index.d.ts +6 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/util.d.ts +4 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/const.d.ts +2 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/env.d.ts +15 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/index.d.ts +18 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/plugin.d.ts +47 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/proxy.d.ts +20 -0
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/time.d.ts +2 -0
- package/dist/client/node_modules/@vue/devtools-api/package.json +37 -0
- package/dist/client/node_modules/@vue/reactivity/dist/reactivity.d.ts +753 -0
- package/dist/client/node_modules/@vue/reactivity/package.json +55 -0
- package/dist/client/node_modules/@vue/runtime-core/dist/runtime-core.d.ts +1839 -0
- package/dist/client/node_modules/@vue/runtime-core/package.json +52 -0
- package/dist/client/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +1430 -0
- package/dist/client/node_modules/@vue/runtime-dom/package.json +60 -0
- package/dist/client/node_modules/@vue/server-renderer/dist/server-renderer.d.ts +65 -0
- package/dist/client/node_modules/@vue/server-renderer/package.json +55 -0
- package/dist/client/node_modules/@vue/shared/dist/shared.d.ts +334 -0
- package/dist/client/node_modules/@vue/shared/package.json +47 -0
- package/dist/client/node_modules/@vueuse/core/index.d.mts +6221 -0
- package/dist/client/node_modules/@vueuse/core/index.d.ts +6221 -0
- package/dist/client/node_modules/@vueuse/core/metadata.d.mts +1 -0
- package/dist/client/node_modules/@vueuse/core/metadata.d.ts +1 -0
- package/dist/client/node_modules/@vueuse/core/package.json +57 -0
- package/dist/client/node_modules/@vueuse/metadata/index.d.mts +78 -0
- package/dist/client/node_modules/@vueuse/metadata/index.d.ts +78 -0
- package/dist/client/node_modules/@vueuse/metadata/package.json +46 -0
- package/dist/client/node_modules/@vueuse/shared/index.d.mts +1260 -0
- package/dist/client/node_modules/@vueuse/shared/index.d.ts +1260 -0
- package/dist/client/node_modules/@vueuse/shared/package.json +49 -0
- package/dist/client/node_modules/compute-scroll-into-view/dist/index.d.ts +75 -0
- package/dist/client/node_modules/compute-scroll-into-view/package.json +82 -0
- package/dist/client/node_modules/csstype/index.d.ts +22569 -0
- package/dist/client/node_modules/csstype/package.json +70 -0
- package/dist/client/node_modules/entities/decode.d.ts +3 -0
- package/dist/client/node_modules/entities/dist/commonjs/decode-codepoint.d.ts +19 -0
- package/dist/client/node_modules/entities/dist/commonjs/decode.d.ts +205 -0
- package/dist/client/node_modules/entities/dist/commonjs/encode.d.ts +22 -0
- package/dist/client/node_modules/entities/dist/commonjs/escape.d.ts +46 -0
- package/dist/client/node_modules/entities/dist/commonjs/generated/decode-data-html.d.ts +2 -0
- package/dist/client/node_modules/entities/dist/commonjs/generated/decode-data-xml.d.ts +2 -0
- package/dist/client/node_modules/entities/dist/commonjs/generated/encode-html.d.ts +3 -0
- package/dist/client/node_modules/entities/dist/commonjs/index.d.ts +96 -0
- package/dist/client/node_modules/entities/dist/commonjs/internal/bin-trie-flags.d.ts +17 -0
- package/dist/client/node_modules/entities/dist/commonjs/internal/decode-shared.d.ts +2 -0
- package/dist/client/node_modules/entities/dist/commonjs/internal/encode-shared.d.ts +32 -0
- package/dist/client/node_modules/entities/dist/commonjs/package.json +3 -0
- package/dist/client/node_modules/entities/dist/esm/decode-codepoint.d.ts +19 -0
- package/dist/client/node_modules/entities/dist/esm/decode.d.ts +205 -0
- package/dist/client/node_modules/entities/dist/esm/encode.d.ts +22 -0
- package/dist/client/node_modules/entities/dist/esm/escape.d.ts +46 -0
- package/dist/client/node_modules/entities/dist/esm/generated/decode-data-html.d.ts +2 -0
- package/dist/client/node_modules/entities/dist/esm/generated/decode-data-xml.d.ts +2 -0
- package/dist/client/node_modules/entities/dist/esm/generated/encode-html.d.ts +3 -0
- package/dist/client/node_modules/entities/dist/esm/index.d.ts +96 -0
- package/dist/client/node_modules/entities/dist/esm/internal/bin-trie-flags.d.ts +17 -0
- package/dist/client/node_modules/entities/dist/esm/internal/decode-shared.d.ts +2 -0
- package/dist/client/node_modules/entities/dist/esm/internal/encode-shared.d.ts +32 -0
- package/dist/client/node_modules/entities/dist/esm/package.json +3 -0
- package/dist/client/node_modules/entities/escape.d.ts +3 -0
- package/dist/client/node_modules/entities/package.json +120 -0
- package/dist/client/node_modules/estree-walker/dist/esm/package.json +1 -0
- package/dist/client/node_modules/estree-walker/package.json +37 -0
- package/dist/client/node_modules/estree-walker/src/package.json +1 -0
- package/dist/client/node_modules/estree-walker/types/async.d.ts +53 -0
- package/dist/client/node_modules/estree-walker/types/index.d.ts +56 -0
- package/dist/client/node_modules/estree-walker/types/sync.d.ts +53 -0
- package/dist/client/node_modules/estree-walker/types/walker.d.ts +37 -0
- package/dist/client/node_modules/floating-vue/dist/components/Dropdown.d.ts +398 -0
- package/dist/client/node_modules/floating-vue/dist/components/Menu.d.ts +398 -0
- package/dist/client/node_modules/floating-vue/dist/components/Popper.d.ts +495 -0
- package/dist/client/node_modules/floating-vue/dist/components/Popper.vue.d.ts +474 -0
- package/dist/client/node_modules/floating-vue/dist/components/PopperContent.vue.d.ts +37 -0
- package/dist/client/node_modules/floating-vue/dist/components/PopperMethods.d.ts +9 -0
- package/dist/client/node_modules/floating-vue/dist/components/PopperWrapper.vue.d.ts +414 -0
- package/dist/client/node_modules/floating-vue/dist/components/ThemeClass.d.ts +6 -0
- package/dist/client/node_modules/floating-vue/dist/components/Tooltip.d.ts +398 -0
- package/dist/client/node_modules/floating-vue/dist/components/TooltipDirective.vue.d.ts +67 -0
- package/dist/client/node_modules/floating-vue/dist/config.d.ts +11 -0
- package/dist/client/node_modules/floating-vue/dist/directives/v-close-popper.d.ts +13 -0
- package/dist/client/node_modules/floating-vue/dist/directives/v-tooltip.d.ts +27 -0
- package/dist/client/node_modules/floating-vue/dist/directives/v-tooltip.spec.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/dist/index.d.ts +2239 -0
- package/dist/client/node_modules/floating-vue/dist/util/assign-deep.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/dist/util/env.d.ts +2 -0
- package/dist/client/node_modules/floating-vue/dist/util/events.d.ts +14 -0
- package/dist/client/node_modules/floating-vue/dist/util/frame.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/dist/util/lang.d.ts +1 -0
- package/dist/client/node_modules/floating-vue/dist/util/popper.d.ts +3 -0
- package/dist/client/node_modules/floating-vue/package.json +80 -0
- package/dist/client/node_modules/magic-string/dist/magic-string.cjs.d.ts +289 -0
- package/dist/client/node_modules/magic-string/dist/magic-string.es.d.mts +289 -0
- package/dist/client/node_modules/magic-string/package.json +67 -0
- package/dist/client/node_modules/nanoid/async/index.d.ts +56 -0
- package/dist/client/node_modules/nanoid/async/package.json +12 -0
- package/dist/client/node_modules/nanoid/index.d.ts +91 -0
- package/dist/client/node_modules/nanoid/non-secure/index.d.ts +33 -0
- package/dist/client/node_modules/nanoid/non-secure/package.json +6 -0
- package/dist/client/node_modules/nanoid/package.json +89 -0
- package/dist/client/node_modules/nanoid/url-alphabet/package.json +6 -0
- package/dist/client/node_modules/picocolors/package.json +25 -0
- package/dist/client/node_modules/picocolors/picocolors.d.ts +5 -0
- package/dist/client/node_modules/picocolors/types.d.ts +51 -0
- package/dist/client/node_modules/pinia/dist/pinia.d.ts +1074 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/index.d.ts +22 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2/index.d.ts +33 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2.7/index.d.ts +38 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v3/index.d.ts +22 -0
- package/dist/client/node_modules/pinia/node_modules/vue-demi/package.json +47 -0
- package/dist/client/node_modules/pinia/package.json +96 -0
- package/dist/client/node_modules/postcss/lib/at-rule.d.ts +139 -0
- package/dist/client/node_modules/postcss/lib/comment.d.ts +67 -0
- package/dist/client/node_modules/postcss/lib/container.d.ts +478 -0
- package/dist/client/node_modules/postcss/lib/css-syntax-error.d.ts +247 -0
- package/dist/client/node_modules/postcss/lib/declaration.d.ts +150 -0
- package/dist/client/node_modules/postcss/lib/document.d.ts +68 -0
- package/dist/client/node_modules/postcss/lib/fromJSON.d.ts +9 -0
- package/dist/client/node_modules/postcss/lib/input.d.ts +226 -0
- package/dist/client/node_modules/postcss/lib/lazy-result.d.ts +189 -0
- package/dist/client/node_modules/postcss/lib/list.d.ts +60 -0
- package/dist/client/node_modules/postcss/lib/no-work-result.d.ts +45 -0
- package/dist/client/node_modules/postcss/lib/node.d.ts +555 -0
- package/dist/client/node_modules/postcss/lib/parse.d.ts +9 -0
- package/dist/client/node_modules/postcss/lib/postcss.d.mts +66 -0
- package/dist/client/node_modules/postcss/lib/postcss.d.ts +464 -0
- package/dist/client/node_modules/postcss/lib/previous-map.d.ts +80 -0
- package/dist/client/node_modules/postcss/lib/processor.d.ts +114 -0
- package/dist/client/node_modules/postcss/lib/result.d.ts +204 -0
- package/dist/client/node_modules/postcss/lib/root.d.ts +86 -0
- package/dist/client/node_modules/postcss/lib/rule.d.ts +126 -0
- package/dist/client/node_modules/postcss/lib/stringifier.d.ts +45 -0
- package/dist/client/node_modules/postcss/lib/stringify.d.ts +9 -0
- package/dist/client/node_modules/postcss/lib/warning.d.ts +146 -0
- package/dist/client/node_modules/postcss/package.json +88 -0
- package/dist/client/node_modules/scroll-into-view-if-needed/dist/index.d.ts +79 -0
- package/dist/client/node_modules/scroll-into-view-if-needed/package.json +80 -0
- package/dist/client/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
- package/dist/client/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
- package/dist/client/node_modules/source-map-js/lib/source-node.d.ts +1 -0
- package/dist/client/node_modules/source-map-js/package.json +71 -0
- package/dist/client/node_modules/source-map-js/source-map.d.ts +104 -0
- package/dist/client/node_modules/vue/compiler-sfc/index.d.mts +1 -0
- package/dist/client/node_modules/vue/compiler-sfc/index.d.ts +1 -0
- package/dist/client/node_modules/vue/compiler-sfc/package.json +4 -0
- package/dist/client/node_modules/vue/dist/vue.d.mts +7 -0
- package/dist/client/node_modules/vue/dist/vue.d.ts +7 -0
- package/dist/client/node_modules/vue/jsx-runtime/index.d.ts +25 -0
- package/dist/client/node_modules/vue/jsx-runtime/package.json +5 -0
- package/dist/client/node_modules/vue/jsx.d.ts +22 -0
- package/dist/client/node_modules/vue/package.json +112 -0
- package/dist/client/node_modules/vue/server-renderer/index.d.mts +1 -0
- package/dist/client/node_modules/vue/server-renderer/index.d.ts +1 -0
- package/dist/client/node_modules/vue/server-renderer/package.json +4 -0
- package/dist/client/node_modules/vue-resize/package.json +77 -0
- package/dist/client/node_modules/vue-router/dist/experimental/index.d.mts +38 -0
- package/dist/client/node_modules/vue-router/dist/router-CWoNjPRp.d.mts +1973 -0
- package/dist/client/node_modules/vue-router/dist/vue-router.d.mts +361 -0
- package/dist/client/node_modules/vue-router/package.json +153 -0
- package/dist/client/node_modules/vue-router/vue-router-auto-resolver.d.mts +22 -0
- package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.ts +4 -0
- package/dist/client/node_modules/vue-router/vue-router-auto.d.ts +1 -0
- package/dist/client/vue.runtime.esm-bundler.js +13167 -0
- package/entries.js +9 -0
- package/floating-vue.d.ts +4 -0
- package/iconify.d.ts +4 -0
- package/package.json +50 -0
- package/pinia.d.ts +4 -0
- package/rollup.config.mjs +119 -0
- package/scroll.d.ts +4 -0
- package/src/client/b-floating-vue.ts +5 -0
- package/src/client/b-iconify.ts +1 -0
- package/src/client/b-pinia.ts +1 -0
- package/src/client/b-scroll.ts +4 -0
- package/src/client/b-vue-router.ts +1 -0
- package/src/client/b-vue-use.ts +1 -0
- package/src/client/b-vue.ts +1 -0
- package/tsconfig.json +34 -0
- package/vue-router.d.ts +4 -0
- package/vue-use.d.ts +4 -0
- package/vue.d.ts +4 -0
|
@@ -0,0 +1,1074 @@
|
|
|
1
|
+
import { App } from 'vue-demi';
|
|
2
|
+
import { ComputedRef } from 'vue-demi';
|
|
3
|
+
import type { DebuggerEvent } from 'vue-demi';
|
|
4
|
+
import { EffectScope } from 'vue-demi';
|
|
5
|
+
import type { Plugin as Plugin_2 } from 'vue-demi';
|
|
6
|
+
import { Ref } from 'vue-demi';
|
|
7
|
+
import { ToRef } from 'vue-demi';
|
|
8
|
+
import { ToRefs } from 'vue-demi';
|
|
9
|
+
import { UnwrapRef } from 'vue-demi';
|
|
10
|
+
import type { WatchOptions } from 'vue-demi';
|
|
11
|
+
import { WritableComputedRef } from 'vue-demi';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates an _accept_ function to pass to `import.meta.hot` in Vite applications.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```js
|
|
18
|
+
* const useUser = defineStore(...)
|
|
19
|
+
* if (import.meta.hot) {
|
|
20
|
+
* import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot))
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param initialUseStore - return of the defineStore to hot update
|
|
25
|
+
* @param hot - `import.meta.hot`
|
|
26
|
+
*/
|
|
27
|
+
export declare function acceptHMRUpdate<Id extends string = string, S extends StateTree = StateTree, G extends _GettersTree<S> = _GettersTree<S>, A = _ActionsTree>(initialUseStore: StoreDefinition<Id, S, G, A>, hot: any): (newModule: any) => any;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Type of an object of Actions. For internal usage only.
|
|
31
|
+
* For internal use **only**
|
|
32
|
+
*/
|
|
33
|
+
export declare type _ActionsTree = Record<string, _Method>;
|
|
34
|
+
|
|
35
|
+
export declare type _Awaited<T> = T extends null | undefined ? T : T extends object & {
|
|
36
|
+
then(onfulfilled: infer F): any;
|
|
37
|
+
} ? F extends (value: infer V, ...args: any) => any ? _Awaited<V> : never : T;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Pinia instance to be used by the application
|
|
41
|
+
*/
|
|
42
|
+
export declare function createPinia(): Pinia;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Recursive `Partial<T>`. Used by {@link Store['$patch']}.
|
|
46
|
+
*
|
|
47
|
+
* For internal use **only**
|
|
48
|
+
*/
|
|
49
|
+
export declare type _DeepPartial<T> = {
|
|
50
|
+
[K in keyof T]?: _DeepPartial<T[K]>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Options parameter of `defineStore()` for setup stores. Can be extended to
|
|
55
|
+
* augment stores with the plugin API. @see {@link DefineStoreOptionsBase}.
|
|
56
|
+
*/
|
|
57
|
+
export declare interface DefineSetupStoreOptions<Id extends string, S extends StateTree, G, A> extends DefineStoreOptionsBase<S, Store<Id, S, G, A>> {
|
|
58
|
+
/**
|
|
59
|
+
* Extracted actions. Added by useStore(). SHOULD NOT be added by the user when
|
|
60
|
+
* creating the store. Can be used in plugins to get the list of actions in a
|
|
61
|
+
* store defined with a setup function. Note this is always defined
|
|
62
|
+
*/
|
|
63
|
+
actions?: A;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Creates a `useStore` function that retrieves the store instance
|
|
68
|
+
*
|
|
69
|
+
* @param id - id of the store (must be unique)
|
|
70
|
+
* @param options - options to define the store
|
|
71
|
+
*/
|
|
72
|
+
export declare function defineStore<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(id: Id, options: Omit<DefineStoreOptions<Id, S, G, A>, 'id'>): StoreDefinition<Id, S, G, A>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a `useStore` function that retrieves the store instance
|
|
76
|
+
*
|
|
77
|
+
* @param options - options to define the store
|
|
78
|
+
*
|
|
79
|
+
* @deprecated use `defineStore(id, options)` instead
|
|
80
|
+
*/
|
|
81
|
+
export declare function defineStore<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(options: DefineStoreOptions<Id, S, G, A>): StoreDefinition<Id, S, G, A>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Creates a `useStore` function that retrieves the store instance
|
|
85
|
+
*
|
|
86
|
+
* @param id - id of the store (must be unique)
|
|
87
|
+
* @param storeSetup - function that defines the store
|
|
88
|
+
* @param options - extra options
|
|
89
|
+
*/
|
|
90
|
+
export declare function defineStore<Id extends string, SS>(id: Id, storeSetup: (helpers: SetupStoreHelpers) => SS, options?: DefineSetupStoreOptions<Id, _ExtractStateFromSetupStore<SS>, _ExtractGettersFromSetupStore<SS>, _ExtractActionsFromSetupStore<SS>>): StoreDefinition<Id, _ExtractStateFromSetupStore<SS>, _ExtractGettersFromSetupStore<SS>, _ExtractActionsFromSetupStore<SS>>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Options parameter of `defineStore()` for option stores. Can be extended to
|
|
94
|
+
* augment stores with the plugin API. @see {@link DefineStoreOptionsBase}.
|
|
95
|
+
*/
|
|
96
|
+
export declare interface DefineStoreOptions<Id extends string, S extends StateTree, G, A> extends DefineStoreOptionsBase<S, Store<Id, S, G, A>> {
|
|
97
|
+
/**
|
|
98
|
+
* Unique string key to identify the store across the application.
|
|
99
|
+
*/
|
|
100
|
+
id: Id;
|
|
101
|
+
/**
|
|
102
|
+
* Function to create a fresh state. **Must be an arrow function** to ensure
|
|
103
|
+
* correct typings!
|
|
104
|
+
*/
|
|
105
|
+
state?: () => S;
|
|
106
|
+
/**
|
|
107
|
+
* Optional object of getters.
|
|
108
|
+
*/
|
|
109
|
+
getters?: G & ThisType<UnwrapRef<S> & _StoreWithGetters<G> & PiniaCustomProperties> & _GettersTree<S>;
|
|
110
|
+
/**
|
|
111
|
+
* Optional object of actions.
|
|
112
|
+
*/
|
|
113
|
+
actions?: A & ThisType<A & UnwrapRef<S> & _StoreWithState<Id, S, G, A> & _StoreWithGetters<G> & PiniaCustomProperties>;
|
|
114
|
+
/**
|
|
115
|
+
* Allows hydrating the store during SSR when complex state (like client side only refs) are used in the store
|
|
116
|
+
* definition and copying the value from `pinia.state` isn't enough.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on
|
|
120
|
+
* Server and Client, you need to manually hydrate them. e.g., a custom ref that is stored in the local
|
|
121
|
+
* storage:
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* const useStore = defineStore('main', {
|
|
125
|
+
* state: () => ({
|
|
126
|
+
* n: useLocalStorage('key', 0)
|
|
127
|
+
* }),
|
|
128
|
+
* hydrate(storeState, initialState) {
|
|
129
|
+
* // @ts-expect-error: https://github.com/microsoft/TypeScript/issues/43826
|
|
130
|
+
* storeState.n = useLocalStorage('key', 0)
|
|
131
|
+
* }
|
|
132
|
+
* })
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @param storeState - the current state in the store
|
|
136
|
+
* @param initialState - initialState
|
|
137
|
+
*/
|
|
138
|
+
hydrate?(storeState: UnwrapRef<S>, initialState: UnwrapRef<S>): void;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Options passed to `defineStore()` that are common between option and setup
|
|
143
|
+
* stores. Extend this interface if you want to add custom options to both kinds
|
|
144
|
+
* of stores.
|
|
145
|
+
*/
|
|
146
|
+
export declare interface DefineStoreOptionsBase<S extends StateTree, Store> {
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Available `options` when creating a pinia plugin.
|
|
151
|
+
*/
|
|
152
|
+
export declare interface DefineStoreOptionsInPlugin<Id extends string, S extends StateTree, G, A> extends Omit<DefineStoreOptions<Id, S, G, A>, 'id' | 'actions'> {
|
|
153
|
+
/**
|
|
154
|
+
* Extracted object of actions. Added by useStore() when the store is built
|
|
155
|
+
* using the setup API, otherwise uses the one passed to `defineStore()`.
|
|
156
|
+
* Defaults to an empty object if no actions are defined.
|
|
157
|
+
*/
|
|
158
|
+
actions: A;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Dispose a Pinia instance by stopping its effectScope and removing the state, plugins and stores. This is mostly
|
|
163
|
+
* useful in tests, with both a testing pinia or a regular pinia and in applications that use multiple pinia instances.
|
|
164
|
+
* Once disposed, the pinia instance cannot be used anymore.
|
|
165
|
+
*
|
|
166
|
+
* @param pinia - pinia instance
|
|
167
|
+
*/
|
|
168
|
+
export declare function disposePinia(pinia: Pinia): void;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* For internal use **only**
|
|
172
|
+
*/
|
|
173
|
+
export declare type _ExtractActionsFromSetupStore<SS> = SS extends undefined | void ? {} : Pick<SS, _ExtractActionsFromSetupStore_Keys<SS>>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Type that enables refactoring through IDE.
|
|
177
|
+
* For internal use **only**
|
|
178
|
+
*/
|
|
179
|
+
export declare type _ExtractActionsFromSetupStore_Keys<SS> = keyof {
|
|
180
|
+
[K in keyof SS as SS[K] extends _Method ? K : never]: any;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* For internal use **only**
|
|
185
|
+
*/
|
|
186
|
+
export declare type _ExtractGettersFromSetupStore<SS> = SS extends undefined | void ? {} : Pick<SS, _ExtractGettersFromSetupStore_Keys<SS>>;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Type that enables refactoring through IDE.
|
|
190
|
+
* For internal use **only**
|
|
191
|
+
*/
|
|
192
|
+
export declare type _ExtractGettersFromSetupStore_Keys<SS> = keyof {
|
|
193
|
+
[K in keyof SS as SS[K] extends ComputedRef ? K : never]: any;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* For internal use **only**
|
|
198
|
+
*/
|
|
199
|
+
export declare type _ExtractStateFromSetupStore<SS> = SS extends undefined | void ? {} : Pick<SS, _ExtractStateFromSetupStore_Keys<SS>>;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Type that enables refactoring through IDE.
|
|
203
|
+
* For internal use **only**
|
|
204
|
+
*/
|
|
205
|
+
export declare type _ExtractStateFromSetupStore_Keys<SS> = keyof {
|
|
206
|
+
[K in keyof SS as SS[K] extends _Method | ComputedRef ? never : K]: any;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Get the currently active pinia if there is any.
|
|
211
|
+
*/
|
|
212
|
+
export declare const getActivePinia: () => Pinia | undefined;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Type of an object of Getters that infers the argument. For internal usage only.
|
|
216
|
+
* For internal use **only**
|
|
217
|
+
*/
|
|
218
|
+
export declare type _GettersTree<S extends StateTree> = Record<string, ((state: UnwrapRef<S> & UnwrapRef<PiniaCustomStateProperties<S>>) => any) | (() => any)>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Internal utility type
|
|
222
|
+
*/
|
|
223
|
+
declare type _IfEquals<X, Y, A = true, B = false> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Internal utility type
|
|
227
|
+
*/
|
|
228
|
+
declare type _IsReadonly<T, K extends keyof T> = _IfEquals<{
|
|
229
|
+
[P in K]: T[P];
|
|
230
|
+
}, {
|
|
231
|
+
-readonly [P in K]: T[P];
|
|
232
|
+
}, false, // Property is not readonly if they are the same
|
|
233
|
+
true>;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Allows directly using actions from your store without using the composition
|
|
237
|
+
* API (`setup()`) by generating an object to be spread in the `methods` field
|
|
238
|
+
* of a component. The values of the object are the actions while the keys are
|
|
239
|
+
* the names of the resulting methods.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```js
|
|
243
|
+
* export default {
|
|
244
|
+
* methods: {
|
|
245
|
+
* // other methods properties
|
|
246
|
+
* // useCounterStore has two actions named `increment` and `setCount`
|
|
247
|
+
* ...mapActions(useCounterStore, { more: 'increment', setIt: 'setCount' })
|
|
248
|
+
* },
|
|
249
|
+
*
|
|
250
|
+
* created() {
|
|
251
|
+
* this.more()
|
|
252
|
+
* this.setIt(2)
|
|
253
|
+
* }
|
|
254
|
+
* }
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* @param useStore - store to map from
|
|
258
|
+
* @param keyMapper - object to define new names for the actions
|
|
259
|
+
*/
|
|
260
|
+
export declare function mapActions<Id extends string, S extends StateTree, G extends _GettersTree<S>, A, KeyMapper extends Record<string, keyof A>>(useStore: StoreDefinition<Id, S, G, A>, keyMapper: KeyMapper): _MapActionsObjectReturn<A, KeyMapper>;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Allows directly using actions from your store without using the composition
|
|
264
|
+
* API (`setup()`) by generating an object to be spread in the `methods` field
|
|
265
|
+
* of a component.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```js
|
|
269
|
+
* export default {
|
|
270
|
+
* methods: {
|
|
271
|
+
* // other methods properties
|
|
272
|
+
* ...mapActions(useCounterStore, ['increment', 'setCount'])
|
|
273
|
+
* },
|
|
274
|
+
*
|
|
275
|
+
* created() {
|
|
276
|
+
* this.increment()
|
|
277
|
+
* this.setCount(2) // pass arguments as usual
|
|
278
|
+
* }
|
|
279
|
+
* }
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* @param useStore - store to map from
|
|
283
|
+
* @param keys - array of action names to map
|
|
284
|
+
*/
|
|
285
|
+
export declare function mapActions<Id extends string, S extends StateTree, G extends _GettersTree<S>, A>(useStore: StoreDefinition<Id, S, G, A>, keys: Array<keyof A>): _MapActionsReturn<A>;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* For internal use **only**
|
|
289
|
+
*/
|
|
290
|
+
export declare type _MapActionsObjectReturn<A, T extends Record<string, keyof A>> = {
|
|
291
|
+
[key in keyof T]: A[T[key]];
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* For internal use **only**
|
|
296
|
+
*/
|
|
297
|
+
export declare type _MapActionsReturn<A> = {
|
|
298
|
+
[key in keyof A]: A[key];
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Alias for `mapState()`. You should use `mapState()` instead.
|
|
303
|
+
* @deprecated use `mapState()` instead.
|
|
304
|
+
*/
|
|
305
|
+
export declare const mapGetters: typeof mapState;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Allows using state and getters from one store without using the composition
|
|
309
|
+
* API (`setup()`) by generating an object to be spread in the `computed` field
|
|
310
|
+
* of a component. The values of the object are the state properties/getters
|
|
311
|
+
* while the keys are the names of the resulting computed properties.
|
|
312
|
+
* Optionally, you can also pass a custom function that will receive the store
|
|
313
|
+
* as its first argument. Note that while it has access to the component
|
|
314
|
+
* instance via `this`, it won't be typed.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```js
|
|
318
|
+
* export default {
|
|
319
|
+
* computed: {
|
|
320
|
+
* // other computed properties
|
|
321
|
+
* // useCounterStore has a state property named `count` and a getter `double`
|
|
322
|
+
* ...mapState(useCounterStore, {
|
|
323
|
+
* n: 'count',
|
|
324
|
+
* triple: store => store.n * 3,
|
|
325
|
+
* // note we can't use an arrow function if we want to use `this`
|
|
326
|
+
* custom(store) {
|
|
327
|
+
* return this.someComponentValue + store.n
|
|
328
|
+
* },
|
|
329
|
+
* doubleN: 'double'
|
|
330
|
+
* })
|
|
331
|
+
* },
|
|
332
|
+
*
|
|
333
|
+
* created() {
|
|
334
|
+
* this.n // 2
|
|
335
|
+
* this.doubleN // 4
|
|
336
|
+
* }
|
|
337
|
+
* }
|
|
338
|
+
* ```
|
|
339
|
+
*
|
|
340
|
+
* @param useStore - store to map from
|
|
341
|
+
* @param keyMapper - object of state properties or getters
|
|
342
|
+
*/
|
|
343
|
+
export declare function mapState<Id extends string, S extends StateTree, G extends _GettersTree<S> | {
|
|
344
|
+
[key: string]: ComputedRef;
|
|
345
|
+
}, A, KeyMapper extends Record<string, keyof S | keyof G | ((store: Store<Id, S, G, A>) => any)>>(useStore: StoreDefinition<Id, S, G, A>, keyMapper: KeyMapper): _MapStateObjectReturn<Id, S, G, A, KeyMapper>;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Allows using state and getters from one store without using the composition
|
|
349
|
+
* API (`setup()`) by generating an object to be spread in the `computed` field
|
|
350
|
+
* of a component.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```js
|
|
354
|
+
* export default {
|
|
355
|
+
* computed: {
|
|
356
|
+
* // other computed properties
|
|
357
|
+
* ...mapState(useCounterStore, ['count', 'double'])
|
|
358
|
+
* },
|
|
359
|
+
*
|
|
360
|
+
* created() {
|
|
361
|
+
* this.count // 2
|
|
362
|
+
* this.double // 4
|
|
363
|
+
* }
|
|
364
|
+
* }
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* @param useStore - store to map from
|
|
368
|
+
* @param keys - array of state properties or getters
|
|
369
|
+
*/
|
|
370
|
+
export declare function mapState<Id extends string, S extends StateTree, G extends _GettersTree<S> | {
|
|
371
|
+
[key: string]: ComputedRef;
|
|
372
|
+
}, A, Keys extends keyof S | keyof G>(useStore: StoreDefinition<Id, S, G, A>, keys: readonly Keys[]): _MapStateReturn<S, G, Keys>;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* For internal use **only**
|
|
376
|
+
*/
|
|
377
|
+
export declare type _MapStateObjectReturn<Id extends string, S extends StateTree, G extends _GettersTree<S> | {
|
|
378
|
+
[key: string]: ComputedRef;
|
|
379
|
+
}, A, T extends Record<string, keyof S | keyof G | ((store: Store<Id, S, G, A>) => any)> = {}> = {
|
|
380
|
+
[key in keyof T]: () => T[key] extends (store: any) => infer R ? R : T[key] extends keyof Store<Id, S, G, A> ? Store<Id, S, G, A>[T[key]] : never;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* For internal use **only**
|
|
385
|
+
*/
|
|
386
|
+
export declare type _MapStateReturn<S extends StateTree, G extends _GettersTree<S> | {
|
|
387
|
+
[key: string]: ComputedRef;
|
|
388
|
+
}, Keys extends keyof S | keyof G = keyof S | keyof G> = {
|
|
389
|
+
[key in Keys]: key extends keyof Store<string, S, G, {}> ? () => Store<string, S, G, {}>[key] : never;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Allows using stores without the composition API (`setup()`) by generating an
|
|
394
|
+
* object to be spread in the `computed` field of a component. It accepts a list
|
|
395
|
+
* of store definitions.
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```js
|
|
399
|
+
* export default {
|
|
400
|
+
* computed: {
|
|
401
|
+
* // other computed properties
|
|
402
|
+
* ...mapStores(useUserStore, useCartStore)
|
|
403
|
+
* },
|
|
404
|
+
*
|
|
405
|
+
* created() {
|
|
406
|
+
* this.userStore // store with id "user"
|
|
407
|
+
* this.cartStore // store with id "cart"
|
|
408
|
+
* }
|
|
409
|
+
* }
|
|
410
|
+
* ```
|
|
411
|
+
*
|
|
412
|
+
* @param stores - list of stores to map to an object
|
|
413
|
+
*/
|
|
414
|
+
export declare function mapStores<Stores extends any[]>(...stores: [...Stores]): _Spread<Stores>;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Interface to allow customizing map helpers. Extend this interface with the
|
|
418
|
+
* following properties:
|
|
419
|
+
*
|
|
420
|
+
* - `suffix`: string. Affects the suffix of `mapStores()`, defaults to `Store`.
|
|
421
|
+
*/
|
|
422
|
+
export declare interface MapStoresCustomization {
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Same as `mapState()` but creates computed setters as well so the state can be
|
|
427
|
+
* modified. Differently from `mapState()`, only `state` properties can be
|
|
428
|
+
* added.
|
|
429
|
+
*
|
|
430
|
+
* @param useStore - store to map from
|
|
431
|
+
* @param keyMapper - object of state properties
|
|
432
|
+
*/
|
|
433
|
+
export declare function mapWritableState<Id extends string, S extends StateTree, G, A, KeyMapper extends Record<string, _MapWritableStateKeys<S, G>>>(useStore: StoreDefinition<Id, S, G, A>, keyMapper: KeyMapper): _MapWritableStateObjectReturn<S, G, KeyMapper>;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Allows using state and getters from one store without using the composition
|
|
437
|
+
* API (`setup()`) by generating an object to be spread in the `computed` field
|
|
438
|
+
* of a component.
|
|
439
|
+
*
|
|
440
|
+
* @param useStore - store to map from
|
|
441
|
+
* @param keys - array of state properties
|
|
442
|
+
*/
|
|
443
|
+
export declare function mapWritableState<Id extends string, S extends StateTree, G, A, Keys extends _MapWritableStateKeys<S, G>>(useStore: StoreDefinition<Id, S, G, A>, keys: readonly Keys[]): Pick<_MapWritableStateReturn<S, G, Keys>, Keys>;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* For internal use **only**
|
|
447
|
+
*/
|
|
448
|
+
declare type _MapWritableStateKeys<S extends StateTree, G> = keyof UnwrapRef<S> | keyof _StoreWithGetters_Writable<G>;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* For internal use **only**
|
|
452
|
+
*/
|
|
453
|
+
export declare type _MapWritableStateObjectReturn<S extends StateTree, G, KeyMapper extends Record<string, _MapWritableStateKeys<S, G>>> = {
|
|
454
|
+
[key in keyof KeyMapper]: {
|
|
455
|
+
get: () => UnwrapRef<(S & G)[KeyMapper[key]]>;
|
|
456
|
+
set: (value: UnwrapRef<(S & G)[KeyMapper[key]]>) => any;
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* For internal use **only**
|
|
462
|
+
*/
|
|
463
|
+
export declare type _MapWritableStateReturn<S extends StateTree, G, Keys extends _MapWritableStateKeys<S, G>> = {
|
|
464
|
+
[key in Keys]: {
|
|
465
|
+
get: () => UnwrapRef<(S & G)[key]>;
|
|
466
|
+
set: (value: UnwrapRef<(S & G)[key]>) => any;
|
|
467
|
+
};
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Generic type for a function that can infer arguments and return type
|
|
472
|
+
*
|
|
473
|
+
* For internal use **only**
|
|
474
|
+
*/
|
|
475
|
+
export declare type _Method = (...args: any[]) => any;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Possible types for SubscriptionCallback
|
|
479
|
+
*/
|
|
480
|
+
export declare enum MutationType {
|
|
481
|
+
/**
|
|
482
|
+
* Direct mutation of the state:
|
|
483
|
+
*
|
|
484
|
+
* - `store.name = 'new name'`
|
|
485
|
+
* - `store.$state.name = 'new name'`
|
|
486
|
+
* - `store.list.push('new item')`
|
|
487
|
+
*/
|
|
488
|
+
direct = "direct",
|
|
489
|
+
/**
|
|
490
|
+
* Mutated the state with `$patch` and an object
|
|
491
|
+
*
|
|
492
|
+
* - `store.$patch({ name: 'newName' })`
|
|
493
|
+
*/
|
|
494
|
+
patchObject = "patch object",
|
|
495
|
+
/**
|
|
496
|
+
* Mutated the state with `$patch` and a function
|
|
497
|
+
*
|
|
498
|
+
* - `store.$patch(state => state.name = 'newName')`
|
|
499
|
+
*/
|
|
500
|
+
patchFunction = "patch function"
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Every application must own its own pinia to be able to create stores
|
|
505
|
+
*/
|
|
506
|
+
export declare interface Pinia {
|
|
507
|
+
install: (app: App) => void;
|
|
508
|
+
/**
|
|
509
|
+
* root state
|
|
510
|
+
*/
|
|
511
|
+
state: Ref<Record<string, StateTree>>;
|
|
512
|
+
/**
|
|
513
|
+
* Adds a store plugin to extend every store
|
|
514
|
+
*
|
|
515
|
+
* @param plugin - store plugin to add
|
|
516
|
+
*/
|
|
517
|
+
use(plugin: PiniaPlugin): Pinia;
|
|
518
|
+
/* Excluded from this release type: _p */
|
|
519
|
+
/* Excluded from this release type: _a */
|
|
520
|
+
/* Excluded from this release type: _e */
|
|
521
|
+
/* Excluded from this release type: _s */
|
|
522
|
+
/* Excluded from this release type: _testing */
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Interface to be extended by the user when they add properties through plugins.
|
|
527
|
+
*/
|
|
528
|
+
export declare interface PiniaCustomProperties<Id extends string = string, S extends StateTree = StateTree, G = _GettersTree<S>, A = _ActionsTree> {
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Properties that are added to every `store.$state` by `pinia.use()`.
|
|
533
|
+
*/
|
|
534
|
+
export declare interface PiniaCustomStateProperties<S extends StateTree = StateTree> {
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Plugin to extend every store.
|
|
539
|
+
*/
|
|
540
|
+
export declare interface PiniaPlugin {
|
|
541
|
+
/**
|
|
542
|
+
* Plugin to extend every store. Returns an object to extend the store or
|
|
543
|
+
* nothing.
|
|
544
|
+
*
|
|
545
|
+
* @param context - Context
|
|
546
|
+
*/
|
|
547
|
+
(context: PiniaPluginContext): Partial<PiniaCustomProperties & PiniaCustomStateProperties> | void;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Context argument passed to Pinia plugins.
|
|
552
|
+
*/
|
|
553
|
+
export declare interface PiniaPluginContext<Id extends string = string, S extends StateTree = StateTree, G = _GettersTree<S>, A = _ActionsTree> {
|
|
554
|
+
/**
|
|
555
|
+
* pinia instance.
|
|
556
|
+
*/
|
|
557
|
+
pinia: Pinia;
|
|
558
|
+
/**
|
|
559
|
+
* Current app created with `Vue.createApp()`.
|
|
560
|
+
*/
|
|
561
|
+
app: App;
|
|
562
|
+
/**
|
|
563
|
+
* Current store being extended.
|
|
564
|
+
*/
|
|
565
|
+
store: Store<Id, S, G, A>;
|
|
566
|
+
/**
|
|
567
|
+
* Initial options defining the store when calling `defineStore()`.
|
|
568
|
+
*/
|
|
569
|
+
options: DefineStoreOptionsInPlugin<Id, S, G, A>;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Plugin to extend every store.
|
|
574
|
+
* @deprecated use PiniaPlugin instead
|
|
575
|
+
*/
|
|
576
|
+
export declare type PiniaStorePlugin = PiniaPlugin;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Vue 2 Plugin that must be installed for pinia to work. Note **you don't need
|
|
580
|
+
* this plugin if you are using Nuxt.js**. Use the `buildModule` instead:
|
|
581
|
+
* https://pinia.vuejs.org/ssr/nuxt.html.
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```js
|
|
585
|
+
* import Vue from 'vue'
|
|
586
|
+
* import { PiniaVuePlugin, createPinia } from 'pinia'
|
|
587
|
+
*
|
|
588
|
+
* Vue.use(PiniaVuePlugin)
|
|
589
|
+
* const pinia = createPinia()
|
|
590
|
+
*
|
|
591
|
+
* new Vue({
|
|
592
|
+
* el: '#app',
|
|
593
|
+
* // ...
|
|
594
|
+
* pinia,
|
|
595
|
+
* })
|
|
596
|
+
* ```
|
|
597
|
+
*
|
|
598
|
+
* @param _Vue - `Vue` imported from 'vue'.
|
|
599
|
+
*/
|
|
600
|
+
export declare const PiniaVuePlugin: Plugin_2;
|
|
601
|
+
|
|
602
|
+
declare interface _SetActivePinia {
|
|
603
|
+
(pinia: Pinia): Pinia;
|
|
604
|
+
(pinia: undefined): undefined;
|
|
605
|
+
(pinia: Pinia | undefined): Pinia | undefined;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Sets or unsets the active pinia. Used in SSR and internally when calling
|
|
610
|
+
* actions and getters
|
|
611
|
+
*
|
|
612
|
+
* @param pinia - Pinia instance
|
|
613
|
+
*/
|
|
614
|
+
export declare const setActivePinia: _SetActivePinia;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Changes the suffix added by `mapStores()`. Can be set to an empty string.
|
|
618
|
+
* Defaults to `"Store"`. Make sure to extend the MapStoresCustomization
|
|
619
|
+
* interface if you are using TypeScript.
|
|
620
|
+
*
|
|
621
|
+
* @param suffix - new suffix
|
|
622
|
+
*/
|
|
623
|
+
export declare function setMapStoreSuffix(suffix: MapStoresCustomization extends Record<'suffix', infer Suffix> ? Suffix : string): void;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Return type of `defineStore()` with a setup function.
|
|
627
|
+
* - `Id` is a string literal of the store's name
|
|
628
|
+
* - `SS` is the return type of the setup function
|
|
629
|
+
* @see {@link StoreDefinition}
|
|
630
|
+
*/
|
|
631
|
+
export declare interface SetupStoreDefinition<Id extends string, SS> extends StoreDefinition<Id, _ExtractStateFromSetupStore<SS>, _ExtractGettersFromSetupStore<SS>, _ExtractActionsFromSetupStore<SS>> {
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
declare interface SetupStoreHelpers {
|
|
635
|
+
action: <Fn extends _Method>(fn: Fn) => Fn;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Returns whether a value should be hydrated
|
|
640
|
+
*
|
|
641
|
+
* @param obj - target variable
|
|
642
|
+
* @returns true if `obj` should be hydrated
|
|
643
|
+
*/
|
|
644
|
+
export declare function shouldHydrate(obj: any): boolean;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a
|
|
648
|
+
* stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store.
|
|
649
|
+
*
|
|
650
|
+
* @param obj - target object
|
|
651
|
+
* @returns obj
|
|
652
|
+
*/
|
|
653
|
+
export declare function skipHydrate<T = any>(obj: T): T;
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* For internal use **only**.
|
|
657
|
+
*/
|
|
658
|
+
export declare type _Spread<A extends readonly any[]> = A extends [infer L, ...infer R] ? _StoreObject<L> & _Spread<R> : unknown;
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Generic state of a Store
|
|
662
|
+
*/
|
|
663
|
+
export declare type StateTree = Record<PropertyKey, any>;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Store type to build a store.
|
|
667
|
+
*/
|
|
668
|
+
export declare type Store<Id extends string = string, S extends StateTree = {}, G = {}, A = {}> = _StoreWithState<Id, S, G, A> & UnwrapRef<S> & _StoreWithGetters<G> & (_ActionsTree extends A ? {} : A) & PiniaCustomProperties<Id, S, G, A> & PiniaCustomStateProperties<S>;
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Extract the actions of a store type. Works with both a Setup Store or an
|
|
672
|
+
* Options Store.
|
|
673
|
+
*/
|
|
674
|
+
export declare type StoreActions<SS> = SS extends Store<string, StateTree, _GettersTree<StateTree>, infer A> ? A : _ExtractActionsFromSetupStore<SS>;
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Return type of `defineStore()`. Function that allows instantiating a store.
|
|
678
|
+
*/
|
|
679
|
+
export declare interface StoreDefinition<Id extends string = string, S extends StateTree = StateTree, G = _GettersTree<S>, A = _ActionsTree> {
|
|
680
|
+
/**
|
|
681
|
+
* Returns a store, creates it if necessary.
|
|
682
|
+
*
|
|
683
|
+
* @param pinia - Pinia instance to retrieve the store
|
|
684
|
+
* @param hot - dev only hot module replacement
|
|
685
|
+
*/
|
|
686
|
+
(pinia?: Pinia | null | undefined, hot?: StoreGeneric): Store<Id, S, G, A>;
|
|
687
|
+
/**
|
|
688
|
+
* Id of the store. Used by map helpers.
|
|
689
|
+
*/
|
|
690
|
+
$id: Id;
|
|
691
|
+
/* Excluded from this release type: _pinia */
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Generic and type-unsafe version of Store. Doesn't fail on access with
|
|
696
|
+
* strings, making it much easier to write generic functions that do not care
|
|
697
|
+
* about the kind of store that is passed.
|
|
698
|
+
*/
|
|
699
|
+
export declare type StoreGeneric = Store<string, StateTree, _GettersTree<StateTree>, _ActionsTree>;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Extract the getters of a store type. Works with both a Setup Store or an
|
|
703
|
+
* Options Store.
|
|
704
|
+
*/
|
|
705
|
+
export declare type StoreGetters<SS> = SS extends Store<string, StateTree, infer G, _ActionsTree> ? _StoreWithGetters<G> : _ExtractGettersFromSetupStore<SS>;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* For internal use **only**.
|
|
709
|
+
*/
|
|
710
|
+
export declare type _StoreObject<S> = S extends StoreDefinition<infer Ids, infer State, infer Getters, infer Actions> ? {
|
|
711
|
+
[Id in `${Ids}${MapStoresCustomization extends Record<'suffix', infer Suffix> ? Suffix : 'Store'}`]: () => Store<Id extends `${infer RealId}${MapStoresCustomization extends Record<'suffix', infer Suffix> ? Suffix : 'Store'}` ? RealId : string, State, Getters, Actions>;
|
|
712
|
+
} : {};
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Argument of `store.$onAction()`
|
|
716
|
+
*/
|
|
717
|
+
export declare type StoreOnActionListener<Id extends string, S extends StateTree, G, A> = (context: StoreOnActionListenerContext<Id, S, G, {} extends A ? _ActionsTree : A>) => void;
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Context object passed to callbacks of `store.$onAction(context => {})`
|
|
721
|
+
* TODO: should have only the Id, the Store and Actions to generate the proper object
|
|
722
|
+
*/
|
|
723
|
+
export declare type StoreOnActionListenerContext<Id extends string, S extends StateTree, G, A> = _ActionsTree extends A ? _StoreOnActionListenerContext<StoreGeneric, string, _ActionsTree> : {
|
|
724
|
+
[Name in keyof A]: Name extends string ? _StoreOnActionListenerContext<Store<Id, S, G, A>, Name, A> : never;
|
|
725
|
+
}[keyof A];
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Actual type for {@link StoreOnActionListenerContext}. Exists for refactoring
|
|
729
|
+
* purposes. For internal use only.
|
|
730
|
+
* For internal use **only**
|
|
731
|
+
*/
|
|
732
|
+
export declare interface _StoreOnActionListenerContext<Store, ActionName extends string, A> {
|
|
733
|
+
/**
|
|
734
|
+
* Name of the action
|
|
735
|
+
*/
|
|
736
|
+
name: ActionName;
|
|
737
|
+
/**
|
|
738
|
+
* Store that is invoking the action
|
|
739
|
+
*/
|
|
740
|
+
store: Store;
|
|
741
|
+
/**
|
|
742
|
+
* Parameters passed to the action
|
|
743
|
+
*/
|
|
744
|
+
args: A extends Record<ActionName, _Method> ? Parameters<A[ActionName]> : unknown[];
|
|
745
|
+
/**
|
|
746
|
+
* Sets up a hook once the action is finished. It receives the return value
|
|
747
|
+
* of the action, if it's a Promise, it will be unwrapped.
|
|
748
|
+
*/
|
|
749
|
+
after: (callback: A extends Record<ActionName, _Method> ? (resolvedReturn: _Awaited<ReturnType<A[ActionName]>>) => void : () => void) => void;
|
|
750
|
+
/**
|
|
751
|
+
* Sets up a hook if the action fails. Return `false` to catch the error and
|
|
752
|
+
* stop it from propagating.
|
|
753
|
+
*/
|
|
754
|
+
onError: (callback: (error: unknown) => void) => void;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Properties of a store.
|
|
759
|
+
*/
|
|
760
|
+
export declare interface StoreProperties<Id extends string> {
|
|
761
|
+
/**
|
|
762
|
+
* Unique identifier of the store
|
|
763
|
+
*/
|
|
764
|
+
$id: Id;
|
|
765
|
+
/* Excluded from this release type: _p */
|
|
766
|
+
/* Excluded from this release type: _getters */
|
|
767
|
+
/* Excluded from this release type: _isOptionsAPI */
|
|
768
|
+
/**
|
|
769
|
+
* Used by devtools plugin to retrieve properties added with plugins. Removed
|
|
770
|
+
* in production. Can be used by the user to add property keys of the store
|
|
771
|
+
* that should be displayed in devtools.
|
|
772
|
+
*/
|
|
773
|
+
_customProperties: Set<string>;
|
|
774
|
+
/* Excluded from this release type: _hotUpdate */
|
|
775
|
+
/* Excluded from this release type: _hotUpdating */
|
|
776
|
+
/* Excluded from this release type: _hmrPayload */
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Extract the state of a store type. Works with both a Setup Store or an
|
|
781
|
+
* Options Store. Note this unwraps refs.
|
|
782
|
+
*/
|
|
783
|
+
export declare type StoreState<SS> = SS extends Store<string, infer S, _GettersTree<StateTree>, _ActionsTree> ? UnwrapRef<S> : _ExtractStateFromSetupStore<SS>;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Extracts the return type for `storeToRefs`.
|
|
787
|
+
* Will convert any `getters` into `ComputedRef`.
|
|
788
|
+
*/
|
|
789
|
+
declare type StoreToRefs<SS extends StoreGeneric> = SS extends unknown ? _ToStateRefs<SS> & ToRefs<PiniaCustomStateProperties<StoreState<SS>>> & _ToComputedRefs<StoreGetters<SS>> : never;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Creates an object of references with all the state, getters, and plugin-added
|
|
793
|
+
* state properties of the store. Similar to `toRefs()` but specifically
|
|
794
|
+
* designed for Pinia stores so methods and non reactive properties are
|
|
795
|
+
* completely ignored.
|
|
796
|
+
*
|
|
797
|
+
* @param store - store to extract the refs from
|
|
798
|
+
*/
|
|
799
|
+
export declare function storeToRefs<SS extends StoreGeneric>(store: SS): StoreToRefs<SS>;
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Store augmented for actions. For internal usage only.
|
|
803
|
+
* For internal use **only**
|
|
804
|
+
*/
|
|
805
|
+
export declare type _StoreWithActions<A> = {
|
|
806
|
+
[k in keyof A]: A[k] extends (...args: infer P) => infer R ? (...args: P) => R : never;
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Store augmented with getters. For internal usage only.
|
|
811
|
+
* For internal use **only**
|
|
812
|
+
*/
|
|
813
|
+
export declare type _StoreWithGetters<G> = _StoreWithGetters_Readonly<G> & _StoreWithGetters_Writable<G>;
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Store augmented with readonly getters. For internal usage **only**.
|
|
817
|
+
*/
|
|
818
|
+
declare type _StoreWithGetters_Readonly<G> = {
|
|
819
|
+
readonly [K in keyof G as G[K] extends (...args: any[]) => any ? K : ComputedRef extends G[K] ? K : never]: G[K] extends (...args: any[]) => infer R ? R : UnwrapRef<G[K]>;
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Store augmented with writable getters. For internal usage **only**.
|
|
824
|
+
*/
|
|
825
|
+
declare type _StoreWithGetters_Writable<G> = {
|
|
826
|
+
[K in keyof G as G[K] extends WritableComputedRef<any> ? K : never]: G[K] extends Readonly<WritableComputedRef<infer R>> ? R : never;
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Base store with state and functions. Should not be used directly.
|
|
831
|
+
*/
|
|
832
|
+
export declare interface _StoreWithState<Id extends string, S extends StateTree, G, A> extends StoreProperties<Id> {
|
|
833
|
+
/**
|
|
834
|
+
* State of the Store. Setting it will internally call `$patch()` to update the state.
|
|
835
|
+
*/
|
|
836
|
+
$state: UnwrapRef<S> & PiniaCustomStateProperties<S>;
|
|
837
|
+
/**
|
|
838
|
+
* Applies a state patch to current state. Allows passing nested values
|
|
839
|
+
*
|
|
840
|
+
* @param partialState - patch to apply to the state
|
|
841
|
+
*/
|
|
842
|
+
$patch(partialState: _DeepPartial<UnwrapRef<S>>): void;
|
|
843
|
+
/**
|
|
844
|
+
* Group multiple changes into one function. Useful when mutating objects like
|
|
845
|
+
* Sets or arrays and applying an object patch isn't practical, e.g. appending
|
|
846
|
+
* to an array. The function passed to `$patch()` **must be synchronous**.
|
|
847
|
+
*
|
|
848
|
+
* @param stateMutator - function that mutates `state`, cannot be asynchronous
|
|
849
|
+
*/
|
|
850
|
+
$patch<F extends (state: UnwrapRef<S>) => any>(stateMutator: ReturnType<F> extends Promise<any> ? never : F): void;
|
|
851
|
+
/**
|
|
852
|
+
* Resets the store to its initial state by building a new state object.
|
|
853
|
+
*/
|
|
854
|
+
$reset(): void;
|
|
855
|
+
/**
|
|
856
|
+
* Setups a callback to be called whenever the state changes. It also returns a function to remove the callback. Note
|
|
857
|
+
* that when calling `store.$subscribe()` inside of a component, it will be automatically cleaned up when the
|
|
858
|
+
* component gets unmounted unless `detached` is set to true.
|
|
859
|
+
*
|
|
860
|
+
* @param callback - callback passed to the watcher
|
|
861
|
+
* @param options - `watch` options + `detached` to detach the subscription from the context (usually a component)
|
|
862
|
+
* this is called from. Note that the `flush` option does not affect calls to `store.$patch()`.
|
|
863
|
+
* @returns function that removes the watcher
|
|
864
|
+
*/
|
|
865
|
+
$subscribe(callback: SubscriptionCallback<S>, options?: {
|
|
866
|
+
detached?: boolean;
|
|
867
|
+
} & WatchOptions): () => void;
|
|
868
|
+
/**
|
|
869
|
+
* Setups a callback to be called every time an action is about to get
|
|
870
|
+
* invoked. The callback receives an object with all the relevant information
|
|
871
|
+
* of the invoked action:
|
|
872
|
+
* - `store`: the store it is invoked on
|
|
873
|
+
* - `name`: The name of the action
|
|
874
|
+
* - `args`: The parameters passed to the action
|
|
875
|
+
*
|
|
876
|
+
* On top of these, it receives two functions that allow setting up a callback
|
|
877
|
+
* once the action finishes or when it fails.
|
|
878
|
+
*
|
|
879
|
+
* It also returns a function to remove the callback. Note than when calling
|
|
880
|
+
* `store.$onAction()` inside of a component, it will be automatically cleaned
|
|
881
|
+
* up when the component gets unmounted unless `detached` is set to true.
|
|
882
|
+
*
|
|
883
|
+
* @example
|
|
884
|
+
*
|
|
885
|
+
*```js
|
|
886
|
+
*store.$onAction(({ after, onError }) => {
|
|
887
|
+
* // Here you could share variables between all of the hooks as well as
|
|
888
|
+
* // setting up watchers and clean them up
|
|
889
|
+
* after((resolvedValue) => {
|
|
890
|
+
* // can be used to cleanup side effects
|
|
891
|
+
* . // `resolvedValue` is the value returned by the action, if it's a
|
|
892
|
+
* . // Promise, it will be the resolved value instead of the Promise
|
|
893
|
+
* })
|
|
894
|
+
* onError((error) => {
|
|
895
|
+
* // can be used to pass up errors
|
|
896
|
+
* })
|
|
897
|
+
*})
|
|
898
|
+
*```
|
|
899
|
+
*
|
|
900
|
+
* @param callback - callback called before every action
|
|
901
|
+
* @param detached - detach the subscription from the context this is called from
|
|
902
|
+
* @returns function that removes the watcher
|
|
903
|
+
*/
|
|
904
|
+
$onAction(callback: StoreOnActionListener<Id, S, G, A>, detached?: boolean): () => void;
|
|
905
|
+
/**
|
|
906
|
+
* Stops the associated effect scope of the store and remove it from the store
|
|
907
|
+
* registry. Plugins can override this method to cleanup any added effects.
|
|
908
|
+
* e.g. devtools plugin stops displaying disposed stores from devtools.
|
|
909
|
+
* Note this doesn't delete the state of the store, you have to do it manually with
|
|
910
|
+
* `delete pinia.state.value[store.$id]` if you want to. If you don't and the
|
|
911
|
+
* store is used again, it will reuse the previous state.
|
|
912
|
+
*/
|
|
913
|
+
$dispose(): void;
|
|
914
|
+
/* Excluded from this release type: _r */
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Callback of a subscription
|
|
919
|
+
*/
|
|
920
|
+
export declare type SubscriptionCallback<S> = (
|
|
921
|
+
/**
|
|
922
|
+
* Object with information relative to the store mutation that triggered the
|
|
923
|
+
* subscription.
|
|
924
|
+
*/
|
|
925
|
+
mutation: SubscriptionCallbackMutation<S>,
|
|
926
|
+
/**
|
|
927
|
+
* State of the store when the subscription is triggered. Same as
|
|
928
|
+
* `store.$state`.
|
|
929
|
+
*/
|
|
930
|
+
state: UnwrapRef<S>) => void;
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Context object passed to a subscription callback.
|
|
934
|
+
*/
|
|
935
|
+
export declare type SubscriptionCallbackMutation<S> = SubscriptionCallbackMutationDirect | SubscriptionCallbackMutationPatchObject<S> | SubscriptionCallbackMutationPatchFunction;
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Base type for the context passed to a subscription callback. Internal type.
|
|
939
|
+
*/
|
|
940
|
+
export declare interface _SubscriptionCallbackMutationBase {
|
|
941
|
+
/**
|
|
942
|
+
* Type of the mutation.
|
|
943
|
+
*/
|
|
944
|
+
type: MutationType;
|
|
945
|
+
/**
|
|
946
|
+
* `id` of the store doing the mutation.
|
|
947
|
+
*/
|
|
948
|
+
storeId: string;
|
|
949
|
+
/**
|
|
950
|
+
* 🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from
|
|
951
|
+
* https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in
|
|
952
|
+
* devtools and plugins **during development only**.
|
|
953
|
+
*/
|
|
954
|
+
events?: DebuggerEvent[] | DebuggerEvent;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Context passed to a subscription callback when directly mutating the state of
|
|
959
|
+
* a store with `store.someState = newValue` or `store.$state.someState =
|
|
960
|
+
* newValue`.
|
|
961
|
+
*/
|
|
962
|
+
export declare interface SubscriptionCallbackMutationDirect extends _SubscriptionCallbackMutationBase {
|
|
963
|
+
type: MutationType.direct;
|
|
964
|
+
events: DebuggerEvent;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Context passed to a subscription callback when `store.$patch()` is called
|
|
969
|
+
* with a function.
|
|
970
|
+
*/
|
|
971
|
+
export declare interface SubscriptionCallbackMutationPatchFunction extends _SubscriptionCallbackMutationBase {
|
|
972
|
+
type: MutationType.patchFunction;
|
|
973
|
+
events: DebuggerEvent[];
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* Context passed to a subscription callback when `store.$patch()` is called
|
|
978
|
+
* with an object.
|
|
979
|
+
*/
|
|
980
|
+
export declare interface SubscriptionCallbackMutationPatchObject<S> extends _SubscriptionCallbackMutationBase {
|
|
981
|
+
type: MutationType.patchObject;
|
|
982
|
+
events: DebuggerEvent[];
|
|
983
|
+
/**
|
|
984
|
+
* Object passed to `store.$patch()`.
|
|
985
|
+
*/
|
|
986
|
+
payload: _DeepPartial<UnwrapRef<S>>;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Extracts the getters of a store while keeping writable and readonly properties. **Internal type DO NOT USE**.
|
|
991
|
+
*/
|
|
992
|
+
declare type _ToComputedRefs<SS> = {
|
|
993
|
+
[K in keyof SS]: true extends _IsReadonly<SS, K> ? ComputedRef<SS[K]> : WritableComputedRef<SS[K]>;
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Extracts the refs of a state object from a store. If the state value is a Ref or type that extends ref, it will be kept as is.
|
|
998
|
+
* Otherwise, it will be converted into a Ref. **Internal type DO NOT USE**.
|
|
999
|
+
*/
|
|
1000
|
+
declare type _ToStateRefs<SS> = SS extends Store<string, infer UnwrappedState, _GettersTree<StateTree>, _ActionsTree> ? UnwrappedState extends _UnwrapAll<Pick<infer State, infer Key>> ? {
|
|
1001
|
+
[K in Key]: ToRef<State[K]>;
|
|
1002
|
+
} : ToRefs<UnwrappedState> : ToRefs<StoreState<SS>>;
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Type that enables refactoring through IDE.
|
|
1006
|
+
* For internal use **only**
|
|
1007
|
+
*/
|
|
1008
|
+
export declare type _UnwrapAll<SS> = {
|
|
1009
|
+
[K in keyof SS]: UnwrapRef<SS[K]>;
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
export { }
|
|
1013
|
+
|
|
1014
|
+
// Extensions of Vue types to be appended manually
|
|
1015
|
+
// https://github.com/microsoft/rushstack/issues/2090
|
|
1016
|
+
// https://github.com/microsoft/rushstack/issues/1709
|
|
1017
|
+
|
|
1018
|
+
// @ts-ignore: works on Vue 2, fails in Vue 3
|
|
1019
|
+
declare module 'vue/types/vue' {
|
|
1020
|
+
interface Vue {
|
|
1021
|
+
/**
|
|
1022
|
+
* Currently installed pinia instance.
|
|
1023
|
+
*/
|
|
1024
|
+
$pinia: Pinia
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* Cache of stores instantiated by the current instance. Used by map
|
|
1028
|
+
* helpers. Used internally by Pinia.
|
|
1029
|
+
*
|
|
1030
|
+
* @internal
|
|
1031
|
+
*/
|
|
1032
|
+
_pStores?: Record<string, Store>
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// @ts-ignore: works on Vue 2, fails in Vue 3
|
|
1037
|
+
declare module 'vue/types/options' {
|
|
1038
|
+
interface ComponentOptions<V> {
|
|
1039
|
+
/**
|
|
1040
|
+
* Pinia instance to install in your application. Should be passed to the
|
|
1041
|
+
* root Vue.
|
|
1042
|
+
*/
|
|
1043
|
+
pinia?: Pinia
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* NOTE: Used to be `@vue/runtime-core` but it break types from time to time. Then, in Vue docs, we started recommending
|
|
1049
|
+
* to use `vue` instead of `@vue/runtime-core` but that broke others' types so we reverted it. Now, local types do not
|
|
1050
|
+
* work if we use `@vue/runtime-core` so we are using `vue` again.
|
|
1051
|
+
*/
|
|
1052
|
+
// @ts-ignore: works on Vue 3, fails in Vue 2
|
|
1053
|
+
declare module 'vue' {
|
|
1054
|
+
// This seems to be needed to not break auto import types based on the order
|
|
1055
|
+
// https://github.com/vuejs/pinia/pull/2730
|
|
1056
|
+
interface GlobalComponents {}
|
|
1057
|
+
interface ComponentCustomProperties {
|
|
1058
|
+
/**
|
|
1059
|
+
* Access to the application's Pinia
|
|
1060
|
+
*/
|
|
1061
|
+
$pinia: Pinia
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Cache of stores instantiated by the current instance. Used by devtools to
|
|
1065
|
+
* list currently used stores. Used internally by Pinia.
|
|
1066
|
+
*
|
|
1067
|
+
* @internal
|
|
1068
|
+
*/
|
|
1069
|
+
_pStores?: Record<string, StoreGeneric>
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
// normally this is only needed in .d.ts files
|
|
1074
|
+
export {}
|