pinia-plugin-subscription 0.1.3 → 0.1.4-beta.1
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/CHANGELOG.md +15 -0
- package/README.md +24 -2
- package/dist/pinia-plugin-subscription.js +347 -324
- package/dist/pinia-plugin-subscription.umd.cjs +4 -4
- package/dist/types/index.d.ts +20 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.4-beta.0] - 2026-08-16
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Added `defineAStoreCtx()` with mandatory setup context argument for improved developer experience.
|
|
12
|
+
- Added `DefineAStoreSetupExtensions` with `enhancedStore` and `extending` extension keys.
|
|
13
|
+
- Added `getEnhancedStore()` and `setEnhancedStore()` helpers for context-based store enhancements.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- `getDefineAStoreSetupContext()` now falls back to store ID lookup during plugin execution timing.
|
|
17
|
+
- Public exports now include `defineAStoreCtx`, `getEnhancedStore`, and `setEnhancedStore`.
|
|
18
|
+
|
|
19
|
+
### Deprecated
|
|
20
|
+
- `ctx.extensions.extending` is deprecated. Use `ctx.extensions.enhancedStore`.
|
|
21
|
+
- `getExtendingStore()` is deprecated. Use `getEnhancedStore()`.
|
|
22
|
+
|
|
8
23
|
## [0.1.3] - 2026-08-15
|
|
9
24
|
|
|
10
25
|
### Added
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Ensure Pinia is installed, then register the plugin in your `main.ts`:
|
|
|
17
17
|
```typescript
|
|
18
18
|
import { createApp } from 'vue'
|
|
19
19
|
import { createPinia } from 'pinia'
|
|
20
|
-
import { createPlugin } from 'pinia-plugin-subscription'
|
|
20
|
+
import { createPlugin, PLUGIN_NAME as PPS } from 'pinia-plugin-subscription'
|
|
21
21
|
import { myStoreSubscriber } from './src/core/my-store'
|
|
22
22
|
import App from './App.vue'
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ const app = createApp(App)
|
|
|
25
25
|
const pinia = createPinia()
|
|
26
26
|
|
|
27
27
|
// Register plugin (subscribers array, debug mode)
|
|
28
|
-
pinia.use(createPlugin([myStoreSubscriber],
|
|
28
|
+
pinia.use(createPlugin([myStoreSubscriber], [PPS]))
|
|
29
29
|
|
|
30
30
|
app.use(pinia)
|
|
31
31
|
app.mount('#app')
|
|
@@ -90,6 +90,28 @@ export const myStoreSubscriber: PluginSubscriberInterface = {
|
|
|
90
90
|
|
|
91
91
|
Creates and returns a Pinia plugin from the provided `subscribers`. Each subscriber is invoked when a store is registered.
|
|
92
92
|
|
|
93
|
+
### `defineAStoreCtx(id, setup, options?)`
|
|
94
|
+
|
|
95
|
+
Use this helper when your setup callback must always receive a typed `ctx`.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { defineAStoreCtx, getEnhancedStore } from 'pinia-plugin-subscription'
|
|
99
|
+
|
|
100
|
+
type EnhancedStore = { addItem: (value: unknown) => void }
|
|
101
|
+
|
|
102
|
+
export const useMyStore = defineAStoreCtx('myStore', (ctx) => {
|
|
103
|
+
const enhanced = getEnhancedStore<EnhancedStore>(ctx)
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
addViaEnhanced: (value: unknown) => enhanced.addItem(value)
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`ctx.extensions` now supports:
|
|
112
|
+
- `enhancedStore` (recommended)
|
|
113
|
+
- `extending` (deprecated alias for backward compatibility)
|
|
114
|
+
|
|
93
115
|
### `PluginSubscriberInterface`
|
|
94
116
|
|
|
95
117
|
An object with at least an `invoke(context: PiniaPluginContext, debug?: boolean)` method, plus optional properties:
|