pinia-plugin-subscription 1.0.0-beta.16 → 1.0.0-beta.18
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 +3 -1
- package/README.md +15 -4
- package/dist/chunks/{PluginSubscription-BVKaiyWT.js → PluginSubscription-BwmFDjfB.js} +211 -195
- package/dist/core/PluginSubscriber.d.ts +3 -35
- package/dist/core/PluginSubscriberWithoutInstance.d.ts +71 -0
- package/dist/core/Store.d.ts +1 -1
- package/dist/dictionaries/plugin-subscription-event.d.ts +4 -0
- package/dist/events/store-events-subscriber.d.ts +1 -0
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers.js +133 -101
- package/dist/pinia-plugin-subscription.js +5 -5
- package/dist/system/TraceEmitter.d.ts +3 -15
- package/dist/system/TraceEmitterBase.d.ts +20 -0
- package/dist/types/plugin.d.ts +11 -0
- package/docs/authoring-plugins.md +24 -15
- package/docs/using-plugins.md +19 -16
- package/package.json +1 -1
- package/dist/events/events-handler.d.ts +0 -7
- package/dist/events/events-store-handler.d.ts +0 -8
- package/dist/factories/event-listener.d.ts +0 -12
- package/dist/types/plugin-subscription-event.d.ts +0 -4
- package/dist/utils/deep-clone.d.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
24
24
|
- Added unit tests covering the tracing system and the leak detection logic
|
|
25
25
|
|
|
26
26
|
### Changed
|
|
27
|
+
- `PluginSubscriberWithoutInstance` now captures the shared store-events handler and provides helpers to register `StoreEventsSubscriber` instances or event callback maps; the state-snapshots subscriber uses this shared registration path.
|
|
28
|
+
- Subscribers now execute in ascending `execution.order` order (default `9`), preserving declaration order for equal priorities; `PluginSubscriber.tracer` exposes the tracer created for that subscriber and passes the same instance to its `Store` factory.
|
|
27
29
|
- Trace groups follow the lifecycles of a store: `groupId` is now a `/` separated path (`<storeId>/plugin`, `<storeId>/onAction:<name>#<n>`, with `/after` and `/onError` sub-groups, `<storeId>/onMutation#<n>`, `<storeId>/reset#<n>`, `<storeId>/plugin/deferred:<subscriber>#<n>`). Every trace emitted for a store while a group is open, including those of subscribers and `Store` subclasses, joins the innermost one. `traceGroups` builders take the call counter; `TraceGroupId` is removed, and `groupId` is lifted from the payload to the event like `actionId`
|
|
28
30
|
- `storeMutationSubscription` now supports several subscribers per store, like `storeOnActionSubscription`: a single `$subscribe` is registered per store and dispatches to every callback. A failing callback is reported through `traceError` without blocking the others, subscriber names are tracked, and the hook is unsubscribed when the store is disposed
|
|
29
31
|
- `storeOnActionSubscription` now receives the Pinia plugin context; action trace labels include the invoked action name
|
|
@@ -44,7 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
44
46
|
|
|
45
47
|
### Changed (breaking)
|
|
46
48
|
- Move automatic and manual rollback, including their types, to `pinia-plugin-state-snapshots`; register its subscriber explicitly.
|
|
47
|
-
- Move `$reset` ownership and
|
|
49
|
+
- Move `$reset` ownership and reset callback execution to `StateSnapshotsSubscriber`; callbacks are registered with `$onResetStore()`, while `PluginSubscription` only orchestrates subscribers.
|
|
48
50
|
- Allow store-event subscribers to opt in to error propagation; critical before-action failures abort the action and emit an error event for cleanup.
|
|
49
51
|
- removed the built-in console output of traces (`createConsoleGroupTraceListener`, `ConsoleTraceGroupListener`, `TraceGroupListener`, `TraceListenerGroupBy`, the `groupBy` option of `addListener()`, and the internal console printers). Listeners now only forward events to their own `handler` (a no-op when omitted); `startGroup` / `closeGroup` only maintain the open-group stack that sets `groupId`. Fixed `tracerHandler.journal` not being exposed by the registry
|
|
50
52
|
- The tracing solution moved to the new `pinia-plugin-subscription-devtools` package (`packages/devtools/`, same repository). `pinia-plugin-subscription` now only emits trace events through the `Tracer` / `TracerHandler` contract exported from `pinia-plugin-subscription/types`; without a `tracerHandler` it emits nothing. The compressed package drops from about 117 kB to about 50 kB, and the new package weighs about 19 kB.
|
package/README.md
CHANGED
|
@@ -6,8 +6,7 @@ This project provides:
|
|
|
6
6
|
- a lightweight mechanism to declare "subscribers" that are invoked when stores are registered or updated by Pinia;
|
|
7
7
|
- a `Store` base class (helper wrapper) to ease interacting with Pinia stores from subscribers or other plugin code;
|
|
8
8
|
- an API to create a Pinia plugin from a list of subscribers;
|
|
9
|
-
-
|
|
10
|
-
- optional state rollback through the separate [`pinia-plugin-state-snapshots`](packages/state-snapshots/) package.
|
|
9
|
+
- optional `$reset` support and state rollback through the separate [`pinia-plugin-state-snapshots`](packages/state-snapshots/) package.
|
|
11
10
|
|
|
12
11
|
Deferred subscribers attach their action and reset callbacks to their own store after hydration; disposing a store removes its callbacks.
|
|
13
12
|
If a snapshot cannot be created, the state-snapshots subscriber logs the error
|
|
@@ -65,10 +64,22 @@ app.use(pinia)
|
|
|
65
64
|
app.mount('#app')
|
|
66
65
|
```
|
|
67
66
|
|
|
67
|
+
## Compatible Plugins
|
|
68
|
+
|
|
69
|
+
These plugins build on `pinia-plugin-subscription`; register their subscribers
|
|
70
|
+
with `createPlugin()` to use their features:
|
|
71
|
+
|
|
72
|
+
- **[pinia-plugin-subscription-devtools](packages/devtools/README.md):** structured tracing with filtered listeners, a per-store journal, payload redaction and an in-page panel.
|
|
73
|
+
- **[pinia-plugin-state-snapshots](packages/state-snapshots/README.md):** opt-in `$reset` wrapping and reset callbacks, plus state rollback when configured actions fail.
|
|
74
|
+
- **[pinia-plugin-extending-store](https://github.com/AlxBDo/extending-pinia-store):** compose state, getters and actions from parent stores into a child store.
|
|
75
|
+
- **[pinia-plugin-persist-state](https://github.com/AlxBDo/pinia-plugin-persist-state):** persist store state to browser storage or IndexedDB, with optional encryption.
|
|
76
|
+
- **[pinia-plugin-action-flow](https://github.com/AlxBDo/pinia-plugin-action-flow):** define before/after flows around store actions, including validation and side effects.
|
|
77
|
+
|
|
78
|
+
Discover more compatible plugins on the [`pinia-plugin-subscription` GitHub topic](https://github.com/topics/pinia-plugin-subscription).
|
|
79
|
+
|
|
68
80
|
## Advanced Features
|
|
69
81
|
|
|
70
|
-
- **Structured tracing:** the plugin and `Store` emit typed trace events through an optional `tracerHandler
|
|
71
|
-
- **Reset callbacks:** Define `resetStoreCallback` to run custom logic when the registered [`StateSnapshotsSubscriber`](packages/state-snapshots/README.md) resets a store. `PluginSubscription` itself does not replace or reset the store's `$reset` method.
|
|
82
|
+
- **Structured tracing:** the plugin and `Store` emit typed trace events through an optional `tracerHandler`; without one, no trace events are emitted. See [Tracing](#tracing).
|
|
72
83
|
- **SSR and hydration control:** Configure whether each subscribed plugin runs on the server, the client, or only after client hydration.
|
|
73
84
|
- **Lifecycle safety:** Internal hydration ordering is now guarded so `hydrate()` completes before `afterHydration()` and disposed stores do not retain stale subscriber metadata.
|
|
74
85
|
|