Repository: vuejs/pinia Branch: v4 Commit: 97dff81b3a8e Files: 292 Total size: 855.7 KB Directory structure: gitextract_roq8u4o3/ ├── .github/ │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.yml │ │ ├── config.yml │ │ └── feature_request.yml │ ├── ISSUE_TEMPLATE.md │ ├── PULL_REQUEST_TEMPLATE.md │ ├── commit-convention.md │ ├── funding.yml │ ├── settings.yml │ └── workflows/ │ ├── ci.yml │ ├── pkg.pr.new.yml │ ├── release-tag.yml │ └── update-sponsors.yml ├── .gitignore ├── .npmrc ├── .oxfmtrc.json ├── .vscode/ │ ├── launch.json │ └── settings.json ├── LICENSE ├── README.md ├── SECURITY.md ├── codecov.yml ├── netlify.toml ├── package.json ├── packages/ │ ├── docs/ │ │ ├── .gitignore │ │ ├── .vitepress/ │ │ │ ├── config/ │ │ │ │ ├── en.ts │ │ │ │ ├── index.ts │ │ │ │ ├── shared.ts │ │ │ │ └── zh.ts │ │ │ ├── theme/ │ │ │ │ ├── components/ │ │ │ │ │ ├── AsideSponsors.vue │ │ │ │ │ ├── HomeSponsors.vue │ │ │ │ │ ├── HomeSponsorsGroup.vue │ │ │ │ │ ├── MadVueBanner.vue │ │ │ │ │ ├── MasteringPiniaLink.vue │ │ │ │ │ ├── PiniaLogo.vue │ │ │ │ │ ├── RuleKitLink.vue │ │ │ │ │ ├── VueMasteryBanner.vue │ │ │ │ │ ├── VueMasteryHomeLink.vue │ │ │ │ │ ├── VueMasteryLogoLink.vue │ │ │ │ │ ├── VueSchoolLink.vue │ │ │ │ │ ├── VuejsdeConfBanner.vue │ │ │ │ │ └── sponsors.json │ │ │ │ ├── index.ts │ │ │ │ └── styles/ │ │ │ │ ├── home-links.css │ │ │ │ ├── playground-links.css │ │ │ │ └── vars.css │ │ │ └── translation-status.json │ │ ├── cookbook/ │ │ │ ├── composables.md │ │ │ ├── composing-stores.md │ │ │ ├── hot-module-replacement.md │ │ │ ├── index.md │ │ │ ├── migration-0-0-7.md │ │ │ ├── migration-v1-v2.md │ │ │ ├── migration-v2-v3.md │ │ │ ├── migration-vuex.md │ │ │ ├── options-api.md │ │ │ ├── testing.md │ │ │ └── vscode-snippets.md │ │ ├── core-concepts/ │ │ │ ├── actions.md │ │ │ ├── getters.md │ │ │ ├── index.md │ │ │ ├── outside-component-usage.md │ │ │ ├── plugins.md │ │ │ └── state.md │ │ ├── getting-started.md │ │ ├── index.md │ │ ├── introduction.md │ │ ├── package.json │ │ ├── run-typedoc.mjs │ │ ├── ssr/ │ │ │ ├── index.md │ │ │ └── nuxt.md │ │ ├── typedoc-markdown.mjs │ │ ├── typedoc.tsconfig.json │ │ ├── vite-typedoc-plugin.ts │ │ ├── vite.config.ts │ │ └── zh/ │ │ ├── api/ │ │ │ ├── enums/ │ │ │ │ └── pinia.MutationType.md │ │ │ ├── index.md │ │ │ ├── interfaces/ │ │ │ │ ├── pinia.DefineSetupStoreOptions.md │ │ │ │ ├── pinia.DefineStoreOptions.md │ │ │ │ ├── pinia.DefineStoreOptionsBase.md │ │ │ │ ├── pinia.DefineStoreOptionsInPlugin.md │ │ │ │ ├── pinia.MapStoresCustomization.md │ │ │ │ ├── pinia.Pinia.md │ │ │ │ ├── pinia.PiniaCustomProperties.md │ │ │ │ ├── pinia.PiniaCustomStateProperties.md │ │ │ │ ├── pinia.PiniaPlugin.md │ │ │ │ ├── pinia.PiniaPluginContext.md │ │ │ │ ├── pinia.StoreDefinition.md │ │ │ │ ├── pinia.StoreProperties.md │ │ │ │ ├── pinia.SubscriptionCallbackMutationDirect.md │ │ │ │ ├── pinia.SubscriptionCallbackMutationPatchFunction.md │ │ │ │ ├── pinia.SubscriptionCallbackMutationPatchObject.md │ │ │ │ ├── pinia._StoreOnActionListenerContext.md │ │ │ │ ├── pinia._StoreWithState.md │ │ │ │ ├── pinia._SubscriptionCallbackMutationBase.md │ │ │ │ ├── pinia_nuxt.ModuleOptions.md │ │ │ │ ├── pinia_testing.TestingOptions.md │ │ │ │ └── pinia_testing.TestingPinia.md │ │ │ └── modules/ │ │ │ ├── pinia.md │ │ │ ├── pinia_nuxt.md │ │ │ └── pinia_testing.md │ │ ├── cookbook/ │ │ │ ├── composables.md │ │ │ ├── composing-stores.md │ │ │ ├── hot-module-replacement.md │ │ │ ├── index.md │ │ │ ├── migration-0-0-7.md │ │ │ ├── migration-v1-v2.md │ │ │ ├── migration-vuex.md │ │ │ ├── options-api.md │ │ │ ├── testing.md │ │ │ └── vscode-snippets.md │ │ ├── core-concepts/ │ │ │ ├── actions.md │ │ │ ├── getters.md │ │ │ ├── index.md │ │ │ ├── outside-component-usage.md │ │ │ ├── plugins.md │ │ │ └── state.md │ │ ├── getting-started.md │ │ ├── index.md │ │ ├── introduction.md │ │ └── ssr/ │ │ ├── index.md │ │ └── nuxt.md │ ├── nuxt/ │ │ ├── .gitignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── package.json │ │ ├── playground/ │ │ │ ├── app.vue │ │ │ ├── domain/ │ │ │ │ └── one/ │ │ │ │ └── stores/ │ │ │ │ └── testStore.ts │ │ │ ├── fake-main.js │ │ │ ├── layers/ │ │ │ │ └── layer-domain/ │ │ │ │ ├── nuxt.config.ts │ │ │ │ └── stores/ │ │ │ │ └── basic.ts │ │ │ ├── nuxt.config.ts │ │ │ ├── package.json │ │ │ ├── pages/ │ │ │ │ ├── index.vue │ │ │ │ └── skip-hydrate.vue │ │ │ ├── stores/ │ │ │ │ ├── counter.ts │ │ │ │ ├── nested/ │ │ │ │ │ └── some-store.ts │ │ │ │ └── with-skip-hydrate.ts │ │ │ └── tsconfig.json │ │ ├── shims.d.ts │ │ ├── src/ │ │ │ ├── auto-hmr-plugin.ts │ │ │ ├── module.ts │ │ │ └── runtime/ │ │ │ ├── composables.ts │ │ │ ├── payload-plugin.ts │ │ │ └── plugin.vue3.ts │ │ ├── test/ │ │ │ └── nuxt.spec.ts │ │ └── tsconfig.json │ ├── online-playground/ │ │ ├── README.md │ │ ├── deploy-check.sh │ │ ├── index.html │ │ ├── netlify.toml │ │ ├── package.json │ │ ├── shims-vue.d.ts │ │ ├── src/ │ │ │ ├── App.vue │ │ │ ├── Header.vue │ │ │ ├── VersionSelect.vue │ │ │ ├── defaults.ts │ │ │ ├── download/ │ │ │ │ ├── download.ts │ │ │ │ └── template/ │ │ │ │ ├── README.md │ │ │ │ ├── index.html │ │ │ │ ├── main.js │ │ │ │ ├── package.json │ │ │ │ └── vite.config.js │ │ │ ├── icons/ │ │ │ │ ├── Download.vue │ │ │ │ ├── GitHub.vue │ │ │ │ ├── Moon.vue │ │ │ │ ├── Share.vue │ │ │ │ └── Sun.vue │ │ │ ├── main.ts │ │ │ ├── pinia-dev-proxy.ts │ │ │ ├── vue-dev-proxy.ts │ │ │ └── vue-server-renderer-dev-proxy.ts │ │ ├── tsconfig.json │ │ └── vite.config.ts │ ├── pinia/ │ │ ├── .gitignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── __tests__/ │ │ │ ├── actions.spec.ts │ │ │ ├── combinedStores.spec.ts │ │ │ ├── devtools.spec.ts │ │ │ ├── getters.spec.ts │ │ │ ├── hmr.spec.ts │ │ │ ├── lifespan.spec.ts │ │ │ ├── mapHelpers.spec.ts │ │ │ ├── onAction.spec.ts │ │ │ ├── pinia/ │ │ │ │ └── stores/ │ │ │ │ ├── cart.ts │ │ │ │ ├── combined.ts │ │ │ │ └── user.ts │ │ │ ├── rootState.spec.ts │ │ │ ├── ssr.spec.ts │ │ │ ├── state.spec.ts │ │ │ ├── store.patch.spec.ts │ │ │ ├── store.spec.ts │ │ │ ├── storePlugins.spec.ts │ │ │ ├── storeSetup.spec.ts │ │ │ ├── storeToRefs.spec.ts │ │ │ ├── subscriptions.spec.ts │ │ │ ├── vitest-mock-warn.ts │ │ │ └── vitest-setup.ts │ │ ├── package.json │ │ ├── src/ │ │ │ ├── createPinia.ts │ │ │ ├── devtools/ │ │ │ │ ├── actions.ts │ │ │ │ ├── file-saver.ts │ │ │ │ ├── formatting.ts │ │ │ │ ├── index.ts │ │ │ │ ├── plugin.ts │ │ │ │ └── utils.ts │ │ │ ├── env.ts │ │ │ ├── global.d.ts │ │ │ ├── globalExtensions.ts │ │ │ ├── hmr.ts │ │ │ ├── index.ts │ │ │ ├── mapHelpers.ts │ │ │ ├── rootStore.ts │ │ │ ├── store.ts │ │ │ ├── storeToRefs.ts │ │ │ ├── subscriptions.ts │ │ │ └── types.ts │ │ ├── test-dts/ │ │ │ ├── actions.test-d.ts │ │ │ ├── customizations.test-d.ts │ │ │ ├── index.d.ts │ │ │ ├── mapHelpers.test-d.ts │ │ │ ├── onAction.test-d.ts │ │ │ ├── plugins.test-d.ts │ │ │ ├── state.test-d.ts │ │ │ ├── store.test-d.ts │ │ │ ├── storeSetup.test-d.ts │ │ │ ├── storeToRefs.test-d.ts │ │ │ ├── tsconfig.json │ │ │ └── typeHelpers.test-d.ts │ │ └── tsdown.config.ts │ ├── playground/ │ │ ├── .gitignore │ │ ├── index.html │ │ ├── package.json │ │ ├── src/ │ │ │ ├── App.vue │ │ │ ├── api/ │ │ │ │ ├── jokes.ts │ │ │ │ └── nasa.ts │ │ │ ├── composables/ │ │ │ │ └── useCachedRequest.ts │ │ │ ├── main.ts │ │ │ ├── router.ts │ │ │ ├── shims-vue.d.ts │ │ │ ├── stores/ │ │ │ │ ├── cart.ts │ │ │ │ ├── counter.ts │ │ │ │ ├── counterSetup.ts │ │ │ │ ├── demo-counter.ts │ │ │ │ ├── jokes-swrv.ts │ │ │ │ ├── jokes.ts │ │ │ │ ├── jokesUsePromised.ts │ │ │ │ ├── nasa-pod.ts │ │ │ │ ├── nasa.ts │ │ │ │ ├── user.ts │ │ │ │ └── wholeStore.ts │ │ │ ├── test.ts │ │ │ ├── views/ │ │ │ │ ├── 404.vue │ │ │ │ ├── About.vue │ │ │ │ ├── AllStores.vue │ │ │ │ ├── AllStoresDispose.vue │ │ │ │ ├── CounterSetupStore.vue │ │ │ │ ├── CounterStore.vue │ │ │ │ ├── DemoCounter.vue │ │ │ │ ├── Jokes.vue │ │ │ │ ├── JokesPromised.vue │ │ │ │ ├── NasaPOD.vue │ │ │ │ ├── NasaPODSwrv.vue │ │ │ │ └── swrv.vue │ │ │ └── vite-env.d.ts │ │ ├── tsconfig.json │ │ └── vite.config.ts │ ├── size-check/ │ │ ├── package.json │ │ ├── rollup.config.mjs │ │ ├── scripts/ │ │ │ └── check-size.mjs │ │ └── src/ │ │ └── pinia.js │ └── testing/ │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── src/ │ │ ├── index.ts │ │ ├── initialState.spec.ts │ │ ├── mocked-store.spec.ts │ │ ├── restoreGetters.spec.ts │ │ ├── restoreGetters.ts │ │ ├── testing.spec.ts │ │ └── testing.ts │ ├── tsconfig.build.json │ └── tsdown.config.ts ├── pnpm-workspace.yaml ├── renovate.json ├── scripts/ │ ├── docs-check.sh │ ├── release.mjs │ └── verifyCommit.mjs ├── tsconfig.json └── vitest.config.ts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/CODE_OF_CONDUCT.md ================================================ # Contributor Code of Conduct As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) ================================================ FILE: .github/CONTRIBUTING.md ================================================ # Contributing Contributions are welcome and will be fully credited! We accept contributions via Pull Requests on [Github](https://github.com/vuejs/pinia). ## Pull Requests Here are some guidelines to make the process smoother: - **Add a test** - New features and bugfixes need tests. If you find it difficult to test, please tell us in the pull request and we will try to help you! - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. - **Run `npm test` locally** - This will allow you to go faster - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. - **Send coherent history** - Make sure your commits message means something - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. ## Creating issues ### Bug reports Always try to provide as much information as possible. If you are reporting a bug, try to provide a repro on [this playground](https://play.pinia.vuejs.org) (or anything else) or a stacktrace at the very least. This will help us check the problem quicker. ### Feature requests Lay out the reasoning behind it and propose an API for it. Ideally, you should have a practical example to prove the utility of the feature you're requesting. ## Contributing Docs All the documentation files can be found in `packages/docs`. It contains the English markdown files while translation(s) are stored in their corresponding `` sub-folder(s): - [`zh`](https://github.com/vuejs/pinia/tree/v2/packages/docs/zh): Chinese translation. Besides that, the `.vitepress` sub-folder contains the config and theme, including the i18n information. Contributing to the English docs is the same as contributing to the source code. You can create a pull request to our GitHub repo. However, if you would like to contribute to the translations, there are two options and some extra steps to follow: ### Translate in a `` sub-folder and host it on our official repo If you want to start translating the docs in a _new_ language: 1. Create the corresponding `` sub-folder for your translation. 2. Modify the i18n configuration in the `.vitepress` sub-folder. 3. Translate the docs and run the doc site to self-test locally. 4. Create a checkpoint for your language by running `pnpm run docs:translation:update []`. A checkpoint is the hash and date of the latest commit when you do the translation. The checkpoint information is stored in the status file `packages/docs/.vitepress/translation-status.json`. _It's crucial for long-term maintenance since all the further translation sync-ups are based on their previous checkpoints._ 5. Commit all the changes and create a pull request to our GitHub repo. > [!TIP] > When you create the checkpoint, please remember to pass the second "commit" argument as `v2` since that's the base branch of Pinia now. We will have a paragraph at the top of each translation page that shows the translation status. That way, users can quickly determine if the translation is up-to-date or lags behind the English version. Speaking of the up-to-date translation, we also need good long-term maintenance for every language. If you want to _update_ an existing translation: 1. See what translation you need to sync up with the original docs. There are two popular ways: 1. Via the [GitHub Compare](https://github.com/vuejs/pinia/compare/) page, only see the changes in `packages/docs/*` from the checkpoint hash to `v2` branch. You can find the checkpoint hash for your language via the translation status file `packages/docs/.vitepress/translation-status.json`. The compare page can be directly opened with the hash as part of the URL, e.g. https://github.com/vuejs/pinia/compare/c67a5c9...v2 2. Via a local command: `pnpm run docs:translation:compare v2`. 2. Create your own branch and start the translation update, following the previous comparison. 3. Create a checkpoint for your language by running `pnpm run docs:translation:update v2`. 4. Commit all the changes and create a pull request to our GitHub repo. > [!TIP] > Before you create the new checkpoint, please remember fetch the latest v2 branch ahead. ### Self-host the translation You can also host the translation on your own. To create one, fork our GitHub repo and change the content and site config in `packages/docs`. To long-term maintain it, we _highly recommend_ a similar way that we do above for our officially hosted translations: - Ensure you maintain the _checkpoint_ properly. Also, ensure the _translation status_ is well-displayed on the top of each translation page. - Utilize the diff result between the latest official repository and your own checkpoint to guide your translation. Tip: you can add the official repo as a remote to your forked repo. This way, you can still run `pnpm run docs:translation:update []` and `npm run docs:translation:compare []` to get the checkpoint and diff result: ```bash # prepare the upstream remote git remote add upstream git@github.com:vuejs/pinia.git git fetch upstream v2 # set the checkpoint pnpm run docs:translation:update upstream/v2 # get the diff result pnpm run docs:translation:compare upstream/v2 ``` ### Translating Search text The search box is powered by Algolia and you will need to translate the properties. Inspire yourself from `.vitepress/config/zh.ts` `zhSearch` variable. ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.yml ================================================ name: "\U0001F41E Bug report" description: Report an issue with Pinia body: - type: markdown attributes: value: | Thanks for taking the time to fill out this bug report! - type: input id: reproduction attributes: label: Reproduction description: "If possible, provide a boiled down editable reproduction using [this playground](https://play.pinia.vuejs.org), a CodeSandbox or a GitHub repository based on [this template](https://github.com/piniajs/bug-report). A failing unit test is even better! Otherwise provide as much information as possible to reproduce the problem. There are other [examples of different environments](https://github.com/piniajs?q=example&type=source) that can be used as a bug reproduction. If no reproduction is provided and the information is not enough to reproduce the problem, we won't be able to give it a look **and the issue will be converted into a question and moved to discussions**." placeholder: Reproduction validations: required: true - type: textarea id: steps attributes: label: Steps to reproduce the bug description: | 1. Click on ... 2. Check log validations: required: true - type: textarea id: expected-behavior attributes: label: Expected behavior description: A clear and concise description of what you expected to happen. validations: required: true - type: textarea id: actual-behavior attributes: label: Actual behavior description: 'A clear and concise description of what actually happens.' validations: required: true - type: textarea id: other-info attributes: label: Additional information description: Add any other context about the problem here. - type: markdown attributes: value: | ## Before creating an issue make sure that: - This hasn't been [reported before](https://github.com/vuejs/pinia/issues). - The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug **with no external dependencies (e.g. vuetify)** ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ blank_issues_enabled: false contact_links: - name: 👨‍💻 Support url: https://cal.com/posva/consultancy about: Get direct help from the author of Pinia with your project - name: 🔧 Vue 2 Official Support url: https://cal.com/posva/consultancy about: Is your project still on Vue 2? Get official support - name: ❓ Questions url: https://github.com/vuejs/pinia/discussions/new?category=Q-A about: Ask a question or discuss about Pinia - name: 💡 Ideas url: https://github.com/vuejs/pinia/discussions/new?category=Ideas about: Start a discussion to improve Pinia - name: 🌟 GitHub Sponsors url: https://github.com/sponsors/posva about: Like this project? Please consider supporting the author. ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.yml ================================================ name: "\U0001F680 New feature proposal" description: Suggest an idea for Pinia labels: ['feature request'] body: - type: markdown attributes: value: | Thanks for your interest in the project and taking the time to fill out this feature report! - type: textarea id: feature-description attributes: label: What problem is this solving description: 'A clear and concise description of what the problem is. Ex. when using the function X we cannot do Y.' validations: required: true - type: textarea id: proposed-solution attributes: label: Proposed solution description: 'A clear and concise description of what you want to happen with an API proposal when applicable' validations: required: true - type: textarea id: alternative attributes: label: Describe alternatives you've considered description: A clear and concise description of any alternative solutions or features you've considered. - type: markdown attributes: value: | ## Before creating a feature request make sure that: - This hasn't been [requested before](https://github.com/vuejs/pinia/issues). ================================================ FILE: .github/ISSUE_TEMPLATE.md ================================================ ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ================================================ FILE: .github/commit-convention.md ================================================ ## Git Commit Message Convention > This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular). #### TL;DR: Messages must be matched by the following regex: ```text /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,50}/ ``` #### Examples Appears under "Features" header, `link` subheader: ``` feat(link): add `force` option ``` Appears under "Bug Fixes" header, `view` subheader, with a link to issue #28: ``` fix(view): handle keep-alive with aborted navigations close #28 ``` Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation: ``` perf: improve guard extraction BREAKING CHANGE: The 'beforeRouteEnter' option has been removed. ``` The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header. ``` revert: feat(compiler): add 'comments' option This reverts commit 667ecc1654a317a13331b17617d973392f415f02. ``` ### Full Message Format A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: ``` ():