pinia-plugin-subscription 1.0.0-beta.13 → 1.0.0-beta.14

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/README.md +15 -4
  3. package/dist/chunks/trace-registry-Cm_2un0x.js +1009 -0
  4. package/dist/chunks/trace-registry-Cm_2un0x.js.map +1 -0
  5. package/dist/chunks/traceGroups-DfxYkUpm.js +105 -0
  6. package/dist/chunks/traceGroups-DfxYkUpm.js.map +1 -0
  7. package/dist/core/PluginSubscription.d.ts +13 -12
  8. package/dist/devtools/components.d.ts +40 -0
  9. package/dist/devtools/index.d.ts +9 -0
  10. package/dist/devtools/model.d.ts +17 -0
  11. package/dist/devtools/styles.d.ts +1 -0
  12. package/dist/devtools.js +377 -0
  13. package/dist/devtools.js.map +1 -0
  14. package/dist/factories/trace-listener.d.ts +6 -7
  15. package/dist/factories/trace-registry.d.ts +1 -1
  16. package/dist/helpers/index.d.ts +2 -2
  17. package/dist/helpers.js +50 -638
  18. package/dist/helpers.js.map +1 -1
  19. package/dist/pinia-plugin-subscription.js +44 -18
  20. package/dist/pinia-plugin-subscription.js.map +1 -1
  21. package/dist/system/TraceJournal.d.ts +6 -0
  22. package/dist/system/Tracer.d.ts +6 -2
  23. package/dist/types/devtools.d.ts +60 -0
  24. package/dist/types/index.d.ts +2 -2
  25. package/dist/types/plugin.d.ts +6 -0
  26. package/dist/types/trace.d.ts +79 -21
  27. package/dist/utils/constants.d.ts +2 -1
  28. package/dist/utils/toSerializable.d.ts +10 -0
  29. package/dist/utils/traceContext.d.ts +7 -0
  30. package/dist/utils/traceGroups.d.ts +11 -7
  31. package/docs/authoring-plugins.md +2 -2
  32. package/docs/tracing.md +119 -28
  33. package/docs/using-plugins.md +17 -12
  34. package/package.json +9 -1
  35. package/dist/chunks/PluginSubscription-Bkqj4uSK.js +0 -662
  36. package/dist/chunks/PluginSubscription-Bkqj4uSK.js.map +0 -1
  37. package/dist/factories/console-trace-listener.d.ts +0 -7
  38. package/dist/system/log/console-group.d.ts +0 -8
  39. package/dist/system/log/console.d.ts +0 -18
  40. package/dist/system/log/index.d.ts +0 -2
  41. package/dist/system/log/log-trace.d.ts +0 -8
  42. package/dist/system/log/print-array.d.ts +0 -7
  43. package/dist/system/log/print-error.d.ts +0 -6
  44. package/dist/system/log/print-object.d.ts +0 -1
  45. package/dist/system/log/print-trace-payload.d.ts +0 -1
  46. package/dist/system/log/print-trace.d.ts +0 -9
  47. package/dist/system/log/trace-console.d.ts +0 -9
  48. package/dist/types/comparison.d.ts +0 -3
  49. package/dist/types/list.d.ts +0 -13
  50. package/dist/types/log.d.ts +0 -8
  51. package/dist/types/resourceId.d.ts +0 -4
  52. package/dist/utils/Performance.d.ts +0 -9
  53. package/dist/utils/object.d.ts +0 -4
@@ -0,0 +1,10 @@
1
+ import type { ToSerializableOptions } from '../types/trace';
2
+ /**
3
+ * Converts any value (live stores, class instances, circular graphs...) into a bounded, JSON-safe
4
+ * structure that is also readable in a UI. Keys starting with `_` (Vue/Pinia internals) are skipped.
5
+ */
6
+ export declare function toSerializable(value: unknown, { maxDepth, maxEntries, maxNodes }?: ToSerializableOptions): unknown;
7
+ /**
8
+ * JSON for embedding in an HTML `<script type="application/json">` element: neutralizes `<` and line separators.
9
+ */
10
+ export declare function stringifyForHtml(value: unknown): string;
@@ -0,0 +1,7 @@
1
+ import type { TraceEvent } from '../types/trace';
2
+ /** Context events describe a store (state, subscribers, options) and are emitted when a store is set up. */
3
+ export declare function isContextEvent(event: Pick<TraceEvent, 'namespace'>): boolean;
4
+ /** Subscribers by name, like the console does, keeping their execution options and plugin options. */
5
+ export declare function describeSubscribers(subscribers: unknown[]): Record<string, unknown>;
6
+ /** Context payload as displayed by the devtools: named subscribers, and options without their actions. */
7
+ export declare function buildContextView(payload: Record<string, unknown>): Record<string, unknown>;
@@ -1,7 +1,11 @@
1
- import type { TraceGroupId } from '../types/trace';
2
- /**
3
- * Glossary of the `groupId` values emitted by `PluginSubscription`.
4
- * Each builder returns the group identifier of a store, so listeners can subscribe to it
5
- * and custom traces can join the same group.
6
- */
7
- export declare const traceGroups: Record<TraceGroupId, (storeId: string) => string>;
1
+ export declare const traceGroups: {
2
+ onAction: (storeId: string, actionName: string, callId: number) => string;
3
+ onActionAfter: (storeId: string, actionName: string, callId: number) => string;
4
+ onActionError: (storeId: string, actionName: string, callId: number) => string;
5
+ onMutation: (storeId: string, callId: number) => string;
6
+ plugin: (storeId: string) => string;
7
+ pluginDeferred: (storeId: string, subscriberName: string, callId: number) => string;
8
+ reset: (storeId: string, callId: number) => string;
9
+ };
10
+ /** Human readable name of a group: its last segment, without the call counter. */
11
+ export declare function getTraceGroupName(groupId: string): string;
@@ -402,8 +402,8 @@ class CartStore extends Store {
402
402
 
403
403
  `createTracerRegistry()` is available from
404
404
  `pinia-plugin-subscription/helpers`. Register event criteria with
405
- `addListener()` and pass the registry's `tracerHandler` through
406
- `createPlugin()` options to group plugin and store events in the console.
405
+ `addListener()` (with your own `handler`) and pass the registry's `tracerHandler` through
406
+ `createPlugin()` options to consume plugin and store events.
407
407
  Criteria target event metadata and support `equals`, `contains`, `startsWith`
408
408
  and `endsWith` comparisons. See the [Tracing documentation](./tracing.md) for
409
409
  filtering, redaction, production safety and error reporting.
package/docs/tracing.md CHANGED
@@ -13,8 +13,11 @@ For SSR, create a fresh registry, Pinia instance, and plugin instance for every
13
13
  - [Redaction](#redaction)
14
14
  - [Filtering events](#filtering-events)
15
15
  - [Event shape](#event-shape)
16
+ - [Journal](#journal)
17
+ - [Server traces in the browser](#server-traces-in-the-browser)
18
+ - [In-page trace panel](#in-page-trace-panel)
16
19
  - [Emitting your own events](#emitting-your-own-events)
17
- - [Grouped console output](#grouped-console-output)
20
+ - [Custom listeners](#custom-listeners)
18
21
  - [Error reporting](#error-reporting)
19
22
  - [Migrating from `debugLog()` / `logError()`](#migrating-from-debuglog--logerror)
20
23
 
@@ -25,10 +28,13 @@ import { createPlugin } from 'pinia-plugin-subscription'
25
28
  import { createTracerRegistry } from 'pinia-plugin-subscription/helpers'
26
29
 
27
30
  const traceGroupsRegistry = createTracerRegistry()
28
- const remove = traceGroupsRegistry.addListener([
29
- { target: 'scope', value: 'cart' },
30
- { target: 'namespace', comparator: 'startsWith', value: 'pluginsubscription:subscription:' }
31
- ])
31
+ const remove = traceGroupsRegistry.addListener({
32
+ filter: [
33
+ { target: 'scope', value: 'cart' },
34
+ { target: 'namespace', comparator: 'startsWith', value: 'pluginsubscription:subscription:' }
35
+ ],
36
+ handler: event => console.log(event.label, event.payload)
37
+ })
32
38
 
33
39
  pinia.use(createPlugin(subscribers, {
34
40
  tracerHandler: traceGroupsRegistry.tracerHandler
@@ -76,31 +82,35 @@ Limits: only keys are inspected, not values (a secret stored under an innocuous
76
82
 
77
83
  Criteria are evaluated against event metadata, before the payload is resolved. They can target the `source`, `namespace`, `scope` or `level` of an event.
78
84
 
79
- By default, all criteria must match and events are grouped by `scope`. Supported comparators are `equals` (the default), `contains`, `startsWith` and `endsWith`; set `filterMode` to `some` to match any criterion, or `groupBy` to group by a different event metadata field:
85
+ By default, all criteria must match. Supported comparators are `equals` (the default), `contains`, `startsWith` and `endsWith`; set `filterMode` to `some` to match any criterion:
80
86
 
81
87
  ```ts
82
- traceGroupsRegistry.addListener([
83
- { target: 'scope', value: 'cart' },
84
- { target: 'namespace', comparator: 'startsWith', value: 'pluginsubscription:subscription:' }
85
- ], { filterMode: 'every', groupBy: 'scope' })
88
+ traceGroupsRegistry.addListener({
89
+ filter: [
90
+ { target: 'scope', value: 'cart' },
91
+ { target: 'namespace', comparator: 'startsWith', value: 'pluginsubscription:subscription:' }
92
+ ],
93
+ handler: event => console.log(event.label)
94
+ }, { filterMode: 'every' })
86
95
  ```
87
96
 
88
97
  Listener definitions passed to `addListener()` are never mutated.
89
98
 
90
- Trace filters, including custom filters used when starting or closing groups, receive event metadata only. They never receive payloads or error objects. The built-in registry also avoids resolving group payload factories when it has no registered listeners; custom `TracerHandler` implementations may expose the optional `hasTraceListeners()` capability to enable the same optimization.
99
+ Trace filters receive event metadata only. They never receive payloads or error objects. The built-in registry also avoids resolving payload factories when it has no registered listeners; custom `TracerHandler` implementations may expose the optional `hasTraceListeners()` capability to enable the same optimization.
91
100
 
92
- For the common case of selecting several store scopes, use `addScopesListener(scopes, context?)`. It registers one listener that matches events whose `scope` equals **any** of the supplied strings, groups them by scope, and returns a remover just like `addListener()`. The optional `context` flag controls whether the plugin context is printed and defaults to `true`:
101
+ For the common case of selecting several store scopes, use `addScopesListener(scopes, context?, handler?)`. It registers one listener that matches events whose `scope` equals **any** of the supplied strings and returns a remover just like `addListener()`. The optional `context` flag also matches the plugin's own context events and defaults to `true`:
93
102
 
94
103
  ```ts
95
104
  const removeStoreListeners = traceGroupsRegistry.addScopesListener(
96
105
  ['cart', 'checkout'],
97
- false
106
+ false,
107
+ event => console.log(event.label)
98
108
  )
99
109
 
100
110
  removeStoreListeners() // unsubscribe
101
111
  ```
102
112
 
103
- Use `addListener()` when you need other metadata criteria, a different grouping field, or custom filter logic.
113
+ Use `addListener()` when you need other metadata criteria or custom filter logic.
104
114
 
105
115
  ## Event shape
106
116
 
@@ -112,6 +122,9 @@ Use `addListener()` when you need other metadata criteria, a different grouping
112
122
  | `scope` | Instance identifier, usually `store.$id` |
113
123
  | `payload` | Event data, resolved only when consumed |
114
124
  | `level` | `debug` or `error` |
125
+ | `actionId` | Shared by every event of one store action (`<storeId>#<n>`), when emitted by an action |
126
+ | `seq` | Monotonic position in the registry. Journal only |
127
+ | `side` | `client` or `server`. Journal only |
115
128
  | `timestamp` | `Date.now()` at emission |
116
129
  | `error` | Present on `error` events |
117
130
 
@@ -119,24 +132,97 @@ By default, `Store` prefixes its class name to labels and derived namespaces. Li
119
132
 
120
133
  ## Trace groups glossary
121
134
 
122
- Events emitted within the same hook for the same store share a `groupId`. The `traceGroups` helper, exported from `pinia-plugin-subscription/helpers`, builds these identifiers from a store ID:
135
+ Events emitted for a store are grouped by lifecycle. A `groupId` is a `/` separated path whose prefixes are the parent groups, so `after` and `onError` are sub-groups of their `$onAction` call. The `traceGroups` helper, exported from `pinia-plugin-subscription/helpers`, builds these identifiers (`n` is the call counter):
123
136
 
124
- | Builder | `groupId` | Hook |
137
+ | Builder | `groupId` | Lifecycle |
125
138
  | --- | --- | --- |
126
- | `traceGroups.onActionAfter(id)` | `store:onAction:after:<id>` | `$onAction` `after` |
127
- | `traceGroups.onActionError(id)` | `store:onAction:onError:<id>` | `$onAction` `onError` |
128
- | `traceGroups.onMutation(id)` | `store:onMutation:<id>` | `$subscribe` |
129
- | `traceGroups.reset(id)` | `store:reset:<id>` | `$reset` |
139
+ | `traceGroups.plugin(id)` | `<id>/plugin` | Plugin setup and subscribers execution |
140
+ | `traceGroups.pluginDeferred(id, subscriber, n)` | `<id>/plugin/deferred:<subscriber>#<n>` | Deferred subscriber run |
141
+ | `traceGroups.onAction(id, name, n)` | `<id>/onAction:<name>#<n>` | One `$onAction` call |
142
+ | `traceGroups.onActionAfter(id, name, n)` | `<id>/onAction:<name>#<n>/after` | `after` callbacks of that call |
143
+ | `traceGroups.onActionError(id, name, n)` | `<id>/onAction:<name>#<n>/onError` | `onError` callbacks of that call |
144
+ | `traceGroups.onMutation(id, n)` | `<id>/onMutation#<n>` | `$subscribe` |
145
+ | `traceGroups.reset(id, n)` | `<id>/reset#<n>` | `$reset` |
146
+
147
+ You do not have to set a `groupId` yourself: while a group of a store is open, every trace emitted with that store as scope (subscribers, `Store` subclasses, custom tracers) joins the innermost open group. An explicit `groupId` in the payload wins, and is lifted to the event's `groupId` (like `actionId`), out of the payload. Listener handlers receive each event immediately and can use `groupId` to regroup them.
148
+
149
+ ```ts
150
+ registry.addListener([{ target: 'groupId', comparator: 'startsWith', value: 'cart/onAction:' }])
151
+ ```
152
+
153
+ `getTraceGroupName(groupId)` returns the readable name of a group (its last segment, without the counter). The plugin's action trace labels include the invoked action name (`store:onAction:<name>`).
154
+
155
+ Subscribers declared with `hydration: 'defer'` run after `plugin()` has closed its `PluginSubscription:context` group. Each deferred run opens its own sub-group of the plugin group (label `subscriber:deferred`, `groupId` `<id>/plugin/deferred:<subscriber>#<n>`); traces emitted by the subscriber during that run, such as those of a `Store` subclass, carry its `groupId`. The group stays open until asynchronous `hydrate()` / `afterHydration()` promises settle (fulfilled or rejected). A promise that never settles would keep the group open: after `deferredTraceGroupTimeout` milliseconds (plugin option, default `2500`) the group is closed anyway and a `subscriber:deferred:timeout` error is traced inside it.
156
+
157
+ ## Journal
158
+
159
+ Listeners receive each event as it is emitted. The journal instead records **every** event of **every** store, matched by a listener or not, so that a store trace can be read back at any time (the basis of an in-page trace panel).
130
160
 
131
161
  ```ts
132
- import { traceGroups } from 'pinia-plugin-subscription/helpers'
162
+ const registry = createTracerRegistry({ journal: { maxEventsPerStore: 1000 } })
133
163
 
134
- registry.addListener([{ target: 'groupId', value: traceGroups.onActionAfter('cart') }])
164
+ registry.journal?.getScopes() // ['cart', 'user']
165
+ registry.journal?.getEvents('cart') // ordered by `seq`, with `actionId` and `side`
166
+ registry.journal?.getDropped('cart') // events evicted by the size cap
167
+ registry.journal?.subscribe(event => { /* live updates */ })
135
168
  ```
136
169
 
137
- The plugin's action trace labels include the invoked action name (`store:onAction:<name>`). The `after` and `onError` callback trace labels also include that name, making activity from different actions distinguishable; their group IDs remain scoped to the store as shown above.
170
+ - Opt-in: `registry.journal` is `undefined` unless `journal` is `true` or an options object, or when tracing is disabled (`enabled: false`, production builds).
171
+ - Size cap: `maxEventsPerStore` (default `1000`) applies per store and per side; the oldest events are evicted first. Context and error events are kept in their own buffer under the same cap, and `side: 'server'` events do not compete with client ones.
172
+ - `side` defaults to `server` when `window` is undefined, `client` otherwise; override it with the `side` option.
173
+ - Events are stored by reference, after redaction when `redact` is enabled: use `redact` if payloads may hold secrets.
174
+ - Create one registry (hence one journal) per request on the server.
175
+
176
+ ## Server traces in the browser
177
+
178
+ `journal.serialize()` returns a JSON-safe, size-bounded snapshot (payloads go through `toSerializable`: circular references, functions and `_`-prefixed internals are handled, error stacks are dropped). Embed it in the page next to the Pinia state, then `import()` it on the client:
179
+
180
+ ```ts
181
+ // server, after rendering (one registry per request)
182
+ import { stringifyTraceSnapshot } from 'pinia-plugin-subscription/helpers'
183
+ const traces = stringifyTraceSnapshot(registry.journal?.serialize()) // HTML-safe JSON
184
+ // <script type="application/json" id="pinia-traces">${traces}</script>
185
+
186
+ // client
187
+ registry.journal?.import(JSON.parse(document.querySelector('#pinia-traces')!.textContent!))
188
+ ```
189
+
190
+ Imported events are marked `side: 'server'`, ordered before the local ones, and replace any earlier import. Malformed entries are skipped and unknown fields are never copied.
191
+
192
+ > **Security**: a snapshot exposes server-side payloads to the browser. Only embed it in development (the journal is off in production builds by default) and enable `redact` if payloads may hold secrets. When using `replace()` to inject it into an HTML template, pass a replacer function so that `$` sequences are not interpreted.
193
+
194
+ ## In-page trace panel
138
195
 
139
- Subscribers declared with `hydration: 'defer'` run after `plugin()` has closed its `PluginSubscription:context` group. Each deferred run opens its own group (label `subscriber:deferred`, no `groupId`, so it is keyed by the store scope like the `context` group); traces emitted by the subscriber during that run, such as those of a `Store` subclass, are printed inside it. The group stays open until asynchronous `hydrate()` / `afterHydration()` promises settle (fulfilled or rejected). While it is open, console listeners buffer every trace of that store scope, so a promise that never settles would hide them: after `deferredTraceGroupTimeout` milliseconds (plugin option, default `2500`) the group is closed anyway and a `subscriber:deferred:timeout` error is traced inside it.
196
+ `pinia-plugin-subscription/devtools` mounts an aside in the page that reads the journal: one selector per store, a **Timeline** (events nested by lifecycle, client and server interleaved, `P` / `E` chips on events carrying a payload / an error, expandable details, filters on text, side and level) and a **Context** tab (store, subscribers, hook subscriptions and options). It is isolated in a Shadow DOM, updates live, and renders text only.
197
+
198
+ For the simplest browser development setup, enable it directly on `createPlugin()`:
199
+
200
+ ```ts
201
+ pinia.use(createPlugin(subscribers, { devtools: true }))
202
+ ```
203
+
204
+ This creates a journal-backed tracer, loads the devtools entry dynamically, and mounts the panel without registering console listeners. If you already pass a registry's `tracerHandler`, its journal is reused. An SSR journal snapshot in a `<script type="application/json" id="pinia-traces">` element is imported automatically; set `serverSnapshotId` to a different element ID or `false` to disable importing it. Normal trace events appear in the panel, not the console; the existing `console.error` fallback for unmatched error events still applies. The option is inactive in production builds and outside the browser. Payloads are redacted using the default redaction keys for the automatically created registry. Pass panel options instead of `true` to customize it, for example `{ devtools: { open: true } }`.
205
+
206
+ When using a custom `tracerHandler`, it must expose a journal (as the built-in registry handler does). For custom trace listeners, server-side trace transfer, or other registry options, use the manual setup below.
207
+
208
+ ```ts
209
+ const registry = createTracerRegistry({ journal: true })
210
+ // ...pinia.use(createPlugin(subscribers, { tracerHandler: registry.tracerHandler }))
211
+
212
+ if (import.meta.env.DEV) {
213
+ import('pinia-plugin-subscription/devtools').then(({ mountTraceDevtools }) => mountTraceDevtools(registry))
214
+ }
215
+ ```
216
+
217
+ | Option | Default | Description |
218
+ | --- | --- | --- |
219
+ | `open` | `false` | Open the panel on mount (a floating `Devtools` button otherwise) |
220
+ | `position` | `right` | `left` or `right` |
221
+ | `width` | `480` | Aside width in pixels |
222
+ | `shortcut` | `Alt+Shift+P` | Toggle shortcut, `false` to disable |
223
+ | `container` | `document.body` | Element the panel host is appended to |
224
+
225
+ `mountTraceDevtools` returns `{ open, close, toggle, unmount }`. It does nothing outside a browser or without a journal. The panel uses `vue` (already a peer dependency); keep it out of production bundles with a dynamic import. The Context tab shows the store objects as they are when first opened.
140
226
 
141
227
  ## Emitting your own events
142
228
 
@@ -154,13 +240,18 @@ Always prefer the **function form** for `payload`: it is only invoked once a lis
154
240
 
155
241
  Trace groups opened by `onAction`, `$subscribe` and `$reset` are always closed, including when the action fails or a callback throws.
156
242
 
157
- ## Grouped console output
243
+ ## Custom listeners
158
244
 
159
- Normal trace events do not write to a console. The registry created by `createTracerRegistry()` uses the console's grouped output for the events matching its listeners: register listeners as shown in the [quick start](#quick-start) and pass `tracerHandler` to the plugin. Groups default to the `scope` metadata field; use the `groupBy` option of `addListener()` to group by another field.
245
+ The package no longer prints traces to the console: events are delivered to the `handler` of each matching listener, and the [in-page panel](#in-page-trace-panel) displays them. Pass a `handler` (and optionally a custom `filter` function) to forward events wherever you need, such as the console, a logging service or a test collector:
160
246
 
161
- When an event has a `payload.groupId`, that value takes precedence over the configured `groupBy` field as its console-group key. Events without an open group for their key are printed immediately outside a group. If multiple groups with the same key are opened concurrently, their events share one buffer; the buffered group is printed only after every matching open has been closed.
247
+ ```ts
248
+ registry.addListener({
249
+ filter: event => event.scope === 'cart' && event.level === 'debug', // metadata only
250
+ handler: event => console.log(event.label, event.payload) // resolved (and redacted) event
251
+ })
252
+ ```
162
253
 
163
- `CustomConsole` remains exported from `pinia-plugin-subscription/helpers` for plugins not yet migrated to the tracer.
254
+ `handler` is optional when a listener is only used to keep tracing active; criteria arrays can be used as `filter` too, and `addScopesListener(scopes, context?, handler?)` accepts a handler as its third argument. Events carry their `groupId`, `actionId` and `scope`, so a handler can reproduce any grouping it needs; it is called once per event, immediately.
164
255
 
165
256
  ## Error reporting
166
257
 
@@ -341,25 +341,30 @@ import {
341
341
 
342
342
  const traceGroupsRegistry = createTracerRegistry()
343
343
 
344
- traceGroupsRegistry.addListener([
345
- { target: 'scope', value: 'cart' }
346
- ])
344
+ traceGroupsRegistry.addListener({
345
+ filter: [{ target: 'scope', value: 'cart' }],
346
+ handler: event => myLogger.debug(event)
347
+ })
347
348
 
348
349
  pinia.use(createPlugin([myStoreSubscriber], {
349
350
  tracerHandler: traceGroupsRegistry.tracerHandler
350
351
  }))
351
352
  ```
352
353
 
353
- The registry groups matching events by store scope by default. Criteria can
354
- target a source, namespace, store scope, or trace level and support the
355
- `equals`, `contains`, `startsWith` and `endsWith` comparators. Criteria use
356
- `every` by default; pass `{ filterMode: 'some' }` to match any criterion.
354
+ Criteria can target a source, namespace, store scope, or trace level and
355
+ support the `equals`, `contains`, `startsWith` and `endsWith` comparators.
356
+ Criteria use `every` by default; pass `{ filterMode: 'some' }` to match any
357
+ criterion. The `handler` receives every matching event; nothing is printed
358
+ to the console by the package.
357
359
 
358
360
  ```js
359
- traceGroupsRegistry.addListener([
360
- { target: 'scope', value: 'cart' },
361
- { target: 'namespace', comparator: 'startsWith', value: 'pluginsubscription:subscription:' }
362
- ], { filterMode: 'every', groupBy: 'scope' })
361
+ traceGroupsRegistry.addListener({
362
+ filter: [
363
+ { target: 'scope', value: 'cart' },
364
+ { target: 'namespace', comparator: 'startsWith', value: 'pluginsubscription:subscription:' }
365
+ ],
366
+ handler: event => myLogger.debug(event)
367
+ }, { filterMode: 'every' })
363
368
  ```
364
369
 
365
370
  ## SSR / Nuxt
@@ -388,7 +393,7 @@ export function createRequestApp(traceCriteria) {
388
393
  const pinia = createPinia()
389
394
  const traceGroupsRegistry = createTracerRegistry()
390
395
 
391
- traceGroupsRegistry.addListener(traceCriteria)
396
+ traceGroupsRegistry.addListener({ filter: traceCriteria, handler: logTrace })
392
397
  pinia.use(createPlugin(subscribers, {
393
398
  tracerHandler: traceGroupsRegistry.tracerHandler
394
399
  }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinia-plugin-subscription",
3
- "version": "1.0.0-beta.13",
3
+ "version": "1.0.0-beta.14",
4
4
  "description": "Pinia plugin for Vue.js that helps building Pinia plugins by centralizing subscriber registration and providing a Store base class for store helpers.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -30,6 +30,10 @@
30
30
  "types": "./dist/lib/main.d.ts",
31
31
  "import": "./dist/pinia-plugin-subscription.js"
32
32
  },
33
+ "./devtools": {
34
+ "types": "./dist/devtools/index.d.ts",
35
+ "import": "./dist/devtools.js"
36
+ },
33
37
  "./helpers": {
34
38
  "types": "./dist/helpers/index.d.ts",
35
39
  "import": "./dist/helpers.js"
@@ -42,6 +46,9 @@
42
46
  "types": "./dist/lib/main.d.ts",
43
47
  "typesVersions": {
44
48
  "*": {
49
+ "devtools": [
50
+ "./dist/devtools/index.d.ts"
51
+ ],
45
52
  "helpers": [
46
53
  "./dist/helpers/index.d.ts"
47
54
  ],
@@ -94,6 +101,7 @@
94
101
  "@vitejs/plugin-vue": "^6.0.1",
95
102
  "@vitest/coverage-v8": "^4.0.15",
96
103
  "@vue/tsconfig": "^0.8.1",
104
+ "jsdom": "^30.1.3",
97
105
  "pinia": "^3.0.2",
98
106
  "pinia-plugin-extending-store": "^0.1.6-beta.2",
99
107
  "typescript": "~5.9.3",