Skip to content

Commit

Permalink
chore: bump dependencies & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
prazdevs committed Oct 25, 2024
1 parent 6a525ba commit 3418005
Show file tree
Hide file tree
Showing 16 changed files with 1,634 additions and 1,199 deletions.
22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
## Quickstart

1. Install with your favorite package manager:

- **pnpm** : `pnpm add pinia-plugin-persistedstate`
- npm : `npm i pinia-plugin-persistedstate`
- yarn : `yarn add pinia-plugin-persistedstate`

2. Add the plugin to pinia:

```ts
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
Expand All @@ -41,6 +43,7 @@ pinia.use(piniaPluginPersistedstate)
```

3. Add the `persist` option to the store you want to be persisted:

```ts
import { defineStore } from 'pinia'

Expand Down
53 changes: 30 additions & 23 deletions docs/frameworks/nuxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ The `pinia-plugin-persistedstate` package comes with a Nuxt module to offer an S
## Installation

1. Install the dependency with your favorite package manager:
::: code-group
```sh [pnpm]
pnpm add pinia-plugin-persistedstate
```
```sh [npm]
npm i pinia-plugin-persistedstate
```
```sh [yarn]
yarn add pinia-plugin-persistedstate
```
:::
::: code-group

```sh [pnpm]
pnpm add pinia-plugin-persistedstate
```

```sh [npm]
npm i pinia-plugin-persistedstate
```

```sh [yarn]
yarn add pinia-plugin-persistedstate
```

:::

1. Add the module to the Nuxt config:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
modules: [
Expand All @@ -32,6 +37,7 @@ export default defineNuxtConfig({
When declaring your store, set the new `persist` option to `true`.

::: code-group

```ts{11} [setup syntax]
import { defineStore } from 'pinia'
import { ref } from 'vue'
Expand All @@ -47,6 +53,7 @@ export const useStore = defineStore(
},
)
```

```ts{9} [option syntax]
import { defineStore } from 'pinia'
Expand All @@ -59,6 +66,7 @@ export const useStore = defineStore('main', {
persist: true,
})
```

:::

## Defaults
Expand Down Expand Up @@ -96,14 +104,15 @@ export const useStore = defineStore('main', {

> [!TIP]
> The `persistedState.cookies` method accept an object parameter to configure cookies with the following options (inherited from Nuxt's `useCookie`):
> - [`domain`](https://nuxt.com/docs/api/composables/use-cookie#domain)
> - [`expires`](https://nuxt.com/docs/api/composables/use-cookie#maxage-expires)
> - [`httpOnly`](https://nuxt.com/docs/api/composables/use-cookie#httponly)
> - [`maxAge`](https://nuxt.com/docs/api/composables/use-cookie#maxage-expires)
> - [`partitioned`](https://nuxt.com/docs/api/composables/use-cookie#partitioned)
> - [`path`](https://nuxt.com/docs/api/composables/use-cookie#path)
> - [`sameSite`](https://nuxt.com/docs/api/composables/use-cookie#samesite)
> - [`secure`](https://nuxt.com/docs/api/composables/use-cookie#secure)
>
> - [`domain`](https://nuxt.com/docs/api/composables/use-cookie#domain)
> - [`expires`](https://nuxt.com/docs/api/composables/use-cookie#maxage-expires)
> - [`httpOnly`](https://nuxt.com/docs/api/composables/use-cookie#httponly)
> - [`maxAge`](https://nuxt.com/docs/api/composables/use-cookie#maxage-expires)
> - [`partitioned`](https://nuxt.com/docs/api/composables/use-cookie#partitioned)
> - [`path`](https://nuxt.com/docs/api/composables/use-cookie#path)
> - [`sameSite`](https://nuxt.com/docs/api/composables/use-cookie#samesite)
> - [`secure`](https://nuxt.com/docs/api/composables/use-cookie#secure)
> [!WARNING]
> Be careful when saving stores with a lot of data as cookie size is **limited to 4098 bytes**. More on cookie storage in [the MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#data_storage).
Expand All @@ -125,8 +134,7 @@ export const useStore = defineStore('main', {
})
```

> [!WARNING]
> `localStorage` is client side only.
> [!WARNING] > `localStorage` is client side only.
### `sessionStorage`

Expand All @@ -145,8 +153,7 @@ export const useStore = defineStore('main', {
})
```

> [!WARNING]
> `sessionStorage` is client side only.
> [!WARNING] > `sessionStorage` is client side only.
## Global options

Expand Down
1 change: 1 addition & 0 deletions docs/guide/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pinia.use(createPersistedState({
In this example, every store declaring `persist: true` will by default persist data to `sessionStorage`.

Available global options include:

- [`storage`](/guide/config#storage)
- [`serializer`](/guide/config#serializer)
- [`debug`](/guide/config#debug)
Expand Down
10 changes: 10 additions & 0 deletions docs/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The plugin comes pre-configured with the following:
You can pass an object to the `persist` property of the store to configure the persistence.

::: code-group

```ts [setup syntax]
import { defineStore } from 'pinia'
import { ref } from 'vue'
Expand All @@ -26,6 +27,7 @@ export const useStore = defineStore('main', () => {
}
})
```

```ts [option syntax]
import { defineStore } from 'pinia'

Expand All @@ -38,6 +40,7 @@ export const useStore = defineStore('main', {
},
})
```

:::

## key
Expand All @@ -48,6 +51,7 @@ export const useStore = defineStore('main', {
Key used to reference the stored deserialized data in the storage.

:::details Example

```ts{8} twoslash
import { defineStore } from 'pinia'
Expand All @@ -72,6 +76,7 @@ This store will be persisted under the `my-custom-key` key in `localStorage`.
Storage to persist the data to. Must have `getItem: (key: string) => string | null` and `setItem: (key: string, value: string) => void` methods.

:::details Example

```ts{8} twoslash
import { defineStore } from 'pinia'
Expand Down Expand Up @@ -99,6 +104,7 @@ This store will be persisted in [`sessionStorage`](https://developer.mozilla.org
Custom serializer to serialize data before persisted and deserialize data before rehydrating the store. Must have `serialize: (value: StateTree) => string` and `deserialize: (value: string) => StateTree` methods.

:::details Example

```ts{9-11}
import { defineStore } from 'pinia'
import { parse, stringify } from 'zipson'
Expand Down Expand Up @@ -127,6 +133,7 @@ This store will use [`zipson`](https://jgranstrom.github.io/zipson/)'s `stringif
Array of dot-notation paths to pick what should be persisted. `[]` means no state is persisted and `undefined` means the whole state is persisted.

:::details Example

```ts{12} twoslash
import { defineStore } from 'pinia'
Expand Down Expand Up @@ -158,6 +165,7 @@ In this store, only `save.me` and `saveMeToo` values will be persisted. `save.no
Array of dot-notation paths to omit from what should be persisted. `[]` or `undefined` means the whole state persisted (nothing is omitted).

:::details Example

```ts{12} twoslash
import { defineStore } from 'pinia'
Expand Down Expand Up @@ -189,6 +197,7 @@ In this store, only `ignore.notMe` value will be persisted. `ignore.me` and `ign
Hook function run before hydrating a store state with persisted data. The hook gives access to the whole [`PiniaPluginContext`](https://pinia.vuejs.org/api/pinia/interfaces/PiniaPluginContext.html). This can be used to enforce specific actions before hydration.

:::details Example

```ts{8-9} twoslash
import { defineStore } from 'pinia'
Expand Down Expand Up @@ -218,6 +227,7 @@ This store will log `about to hydrate 'store'` _before_ being rehydrated.
Hook function run after rehydrating a persisted state. The hook gives access to the whole [`PiniaPluginContext`](https://pinia.vuejs.org/api/interfaces/pinia.PiniaPluginContext.html). This can be used to enforce specific actions after hydration.

:::details Example

```ts{8-9} twoslash
import { defineStore } from 'pinia'
Expand Down
30 changes: 19 additions & 11 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ This plugin is compatible with `pinia>=2.0.0`, make sure you have [Pinia install
## Installation

1. Install the dependency with your favorite package manager:
::: code-group
```sh [pnpm]
pnpm add pinia-plugin-persistedstate
```
```sh [npm]
npm i pinia-plugin-persistedstate
```
```sh [yarn]
yarn add pinia-plugin-persistedstate
```
:::
::: code-group

```sh [pnpm]
pnpm add pinia-plugin-persistedstate
```

```sh [npm]
npm i pinia-plugin-persistedstate
```

```sh [yarn]
yarn add pinia-plugin-persistedstate
```

:::

2. Add the plugin to your pinia instance:

```ts
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
Expand All @@ -42,6 +47,7 @@ pinia.use(piniaPluginPersistedstate)
When declaring your store, set the new `persist` option to `true`.

::: code-group

```ts{11} [setup syntax]
import { defineStore } from 'pinia'
import { ref } from 'vue'
Expand All @@ -57,6 +63,7 @@ export const useStore = defineStore(
},
)
```

```ts{9} [option syntax]
import { defineStore } from 'pinia'
Expand All @@ -69,6 +76,7 @@ export const useStore = defineStore('main', {
persist: true,
})
```

:::

Your whole store will now be saved with the [default persistence settings](/guide/config).
5 changes: 4 additions & 1 deletion docs/guide/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ const b = a
```

Before serialization, `a` and `b` point to the same object:

```ts
a === b // -> true
```

After deserialization, `a` and `b` are two different objects with the same content:

```ts
a === b // -> false
```
Expand All @@ -46,6 +48,7 @@ Due to the serialization process, non-primitive types such as `Date` are not reh

:::tip Workaround
To get around this you can:

- Use the [`afterHydrate`](/guide/config#afterhydrate) hook to recreate the objects after rehydration.
- Use a custom [`serializer`](/guide/config#serializer) that supports the data types you want to persist.
:::
:::
Loading

0 comments on commit 3418005

Please sign in to comment.