pinia-plugin-subscription 1.0.0-beta.4 → 1.0.0-beta.6

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-CBDmzOr_.js","sources":["../../src/core/PluginSubscriber.ts","../../src/system/TraceEmitter.ts","../../src/utils/store.ts","../../src/core/Store.ts","../../src/utils/validation/index.ts"],"sourcesContent":["import Store from \"./Store\";\nimport type { PiniaPluginContext, Store as PiniaStore } from \"pinia\";\nimport type { AnyObject } from \"../types\";\nimport type {\n PluginExecutionOptions,\n PluginHydrationScheduler,\n PluginSubscriber as PluginSubscriberInterface,\n PluginSubscriptions,\n StoreClassConstructorParams,\n StoreMutationSubscription,\n StoreOnActionSubscription\n} from \"../types/plugin\";\nimport type Tracer from \"../system/Tracer\";\n\n\n\ntype CreateInstance<Instance = Store> = (store: PiniaStore, options: StoreClassConstructorParams) => Instance | undefined\n\n\n/**\n * Type definition for the function used to create an instance of a store.\n * @template Instance The type of the store instance, defaulting to the base Store class.\n * @param store The Pinia store for which the instance is being created.\n * @param options Additional options for creating the store instance.\n * @returns The created store instance or undefined if creation fails.\n */\nexport default abstract class PluginSubscriber<Instance extends Store> implements PluginSubscriberInterface {\n private _createInstance: CreateInstance\n private _name: string\n private _pluginOptions?: StoreClassConstructorParams\n private _storeInstance?: Instance\n /** Callback function to reset the store instance, if needed. */\n protected _resetStoreCallback?: (store?: PiniaStore) => void\n private _storeOnActionSubscription?: StoreOnActionSubscription\n private _storeMutationSubscription?: StoreMutationSubscription\n private _subscriptions?: PluginSubscriptions\n /**\n * Called when the plugin subscriber has been created for a specific store.\n * This callback can be used to perform any initialization or setup required for the plugin subscriber.\n */\n protected pluginCreated?: (store: PiniaStore) => void\n /** Options for the plugin subscriber's execution. */\n public execution?: PluginExecutionOptions\n /** Scheduler for handling the hydration process of the plugin subscriber. */\n public hydrationScheduler?: PluginHydrationScheduler\n\n\n get name(): string {\n return this._name;\n }\n\n get storeInstance(): Instance | undefined {\n return this._storeInstance\n }\n\n get pluginOptions(): StoreClassConstructorParams | undefined {\n return this._pluginOptions;\n }\n\n set pluginOptions(options: StoreClassConstructorParams | undefined) {\n this._pluginOptions = options;\n }\n\n get resetStoreCallback(): ((store?: PiniaStore) => void) | undefined {\n return this._resetStoreCallback as ((store?: PiniaStore) => void) | undefined;\n }\n\n get storeOnActionSubscription(): StoreOnActionSubscription | undefined {\n return this._storeOnActionSubscription;\n }\n\n get storeMutationSubscription(): StoreMutationSubscription | undefined {\n return this._storeMutationSubscription;\n }\n\n get subscriptions(): PluginSubscriptions | undefined {\n return this._subscriptions\n }\n\n set subscriptions(subscriptions: PluginSubscriptions) {\n this._subscriptions = subscriptions\n }\n\n\n constructor(pluginName: string, createInstanceFunction: CreateInstance) {\n this._name = pluginName\n this._createInstance = createInstanceFunction\n }\n\n /**\n * Called after the store has been hydrated.\n * @param context The Pinia plugin context containing the store and options.\n * @returns A promise that resolves when the post-hydration process is complete, or void if synchronous.\n */\n public afterHydration(context: PiniaPluginContext): void | Promise<void> {\n return\n }\n\n /**\n * Called when the plugin subscriber needs to hydrate its state.\n * @param context The Pinia plugin context containing the store and options.\n * @returns A promise that resolves when the hydration process is complete, or void if synchronous.\n */\n public hydrate(context: PiniaPluginContext): void | Promise<void> {\n return\n }\n\n /**\n * Invokes the plugin subscriber with the given context and optional tracer creation function.\n * @param context The Pinia plugin context containing the store and options.\n * @param createTracer Optional function to create a tracer for the plugin.\n * @returns True if the plugin was successfully invoked, otherwise false.\n */\n public invoke({ store, options }: PiniaPluginContext, createTracer?: (name: string) => Tracer): boolean {\n this._storeInstance = this._createInstance(store, {\n ...options,\n ...this.pluginOptions,\n createTracer: createTracer ? () => createTracer?.(this.name) : undefined\n }) as Instance\n\n if (!this._storeInstance) {\n return false\n }\n\n this._subscriptions = this._storeInstance.getSubscriptions()\n this._storeMutationSubscription = this._storeInstance.storeSubscribe\n this._storeOnActionSubscription = this._storeInstance.onAction\n\n if (this.pluginCreated) {\n this.pluginCreated(store)\n }\n\n return true\n }\n}","import type Tracer from './Tracer'\nimport type { TracePayload } from '../types/trace'\n\n/**\n * Base class for objects emitting structured trace events.\n * Subclasses provide `_className` and may override `tracer` to build it lazily.\n */\nexport default abstract class TraceEmitter {\n protected abstract _className: string\n protected _tracer?: Tracer\n private _traceOptions: Record<string, boolean> = {\n /** Indicates whether to add the class name to the namespace for tracing purposes. */\n addClassNameToLabel: true,\n }\n\n get classNameAddedToTraceNamespace(): boolean {\n return this._traceOptions.addClassNameToLabel === true\n }\n\n set classNameAddedToTraceNamespace(value: boolean) {\n this._traceOptions.addClassNameToLabel = value\n }\n\n /** Returns the structured trace emitter, if tracing is enabled. */\n protected get tracer(): Tracer | undefined {\n return this._tracer\n }\n\n /**\n * Emits a structured trace event.\n * Prefer the factory form for `payload`: it is only resolved when consumed.\n */\n trace(label: string, scope?: string, payload?: TracePayload, namespace?: string): void {\n const tracer = this.tracer\n if (tracer) {\n label = this.traceLabelFormatter(label)\n tracer.debug(label, namespace ?? label.toLowerCase(), payload, scope)\n }\n }\n\n /**\n * Emits a structured error event, or reports it with `console.error` when tracing is disabled.\n */\n traceError(label: string, error: unknown, scope?: string, payload?: TracePayload, namespace?: string): void {\n const tracer = this.tracer\n if (tracer) {\n label = this.traceLabelFormatter(label)\n tracer.error(label, namespace ?? label.toLowerCase(), error, payload, scope)\n } else {\n console.error(error)\n }\n }\n\n private traceLabelFormatter(label: string): string {\n return this.classNameAddedToTraceNamespace ? `${this._className}:${label}` : label\n }\n}\n","import { defineStore } from \"pinia\"\nimport type {\n DefineSetupStoreOptions,\n DefineStoreOptions,\n SetupStoreDefinition,\n StateTree,\n Store,\n StoreDefinition,\n _ExtractActionsFromSetupStore,\n _ExtractGettersFromSetupStore,\n _ExtractStateFromSetupStore,\n _GettersTree\n} from \"pinia\"\nimport type { AnyObject } from \"../types\"\nimport type {\n DefineAStoreDefinition,\n DefineAStoreSetupContext,\n EmptyExtensions,\n StoreOptions\n} from \"../types/store\"\nimport type { PluginStoreOptions } from \"../types/plugin\"\n\n\nexport const itemState = {\n '@id': undefined,\n id: undefined\n}\n\ntype DefineAStoreSetup<SS, TExtraExtensions extends Record<string, unknown> = EmptyExtensions> =\n (ctx: DefineAStoreSetupContext<SS, TExtraExtensions>) => SS\n\n/**\n * Options parameter of pinia's `defineStore()` for setup stores, derived from\n * the setup function return type.\n */\ntype DefineAStoreSetupOptions<Id extends string, SS> = DefineSetupStoreOptions<\n Id,\n _ExtractStateFromSetupStore<SS>,\n _ExtractGettersFromSetupStore<SS>,\n _ExtractActionsFromSetupStore<SS>\n>\n\nconst defineAStoreSetupContexts = new WeakMap<object, DefineAStoreSetupContext<AnyObject>>()\nconst defineAStoreSetupContextsById = new Map<string, DefineAStoreSetupContext<AnyObject>>()\nconst setupContextDisposeWrappedStores = new WeakSet<object>()\n\nfunction registerSetupContextCleanupOnDispose(\n store: AnyObject,\n id: string\n): void {\n if (setupContextDisposeWrappedStores.has(store) || typeof store.$dispose !== 'function') {\n return\n }\n\n const originalDispose = store.$dispose as (...args: unknown[]) => unknown\n store.$dispose = (...args: unknown[]) => {\n defineAStoreSetupContexts.delete(store)\n defineAStoreSetupContextsById.delete(id)\n return originalDispose.apply(store, args)\n }\n setupContextDisposeWrappedStores.add(store)\n}\n\n/**\n * Define a store with the setup API. State, getters and actions are inferred\n * from the setup function return, exactly like pinia's `defineStore`, so\n * store members are listed by IDEs and action prototypes are preserved.\n * @template Id The type of the store identifier.\n * @template SS The type of the setup function return.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Id extends string, SS>(\n id: Id,\n storeDefinition: (ctx?: DefineAStoreSetupContext<AnyObject>) => SS,\n options?: StoreOptions\n): SetupStoreDefinition<Id, SS>\n/**\n * Define a store with the options API, mirroring pinia's `defineStore` inference.\n * @template Id The type of the store identifier.\n * @template S The type of the store's state.\n * @template G The type of the store's getters.\n * @template A The type of the store's actions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The store options definition.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(\n id: Id,\n storeDefinition: Omit<DefineStoreOptions<Id, S, G, A>, 'id'>,\n options?: StoreOptions\n): StoreDefinition<Id, S, G, A>\n/**\n * Define a store with explicit store/state types, e.g. when plugins augment\n * the store with members not returned by the setup function.\n * @template Sto The type of the store.\n * @template Sta The type of the store's state.\n * @param id The unique identifier for the store.\n * @param storeDefinition The store definition, either as an options object or a setup function.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Sto, Sta>(\n id: string,\n storeDefinition:\n | Omit<DefineStoreOptions<string, StateTree & Sta, AnyObject, Partial<Sto>>, 'id'>\n | ((ctx?: DefineAStoreSetupContext<Sto & Sta>) => AnyObject),\n options?: StoreOptions\n): DefineAStoreDefinition<Sto, Sta>\nexport function defineAStore(\n id: string,\n storeDefinition:\n | Omit<DefineStoreOptions<string, StateTree, AnyObject, AnyObject>, 'id'>\n | DefineAStoreSetup<AnyObject>,\n options?: StoreOptions\n): StoreDefinition {\n const storeOptions: PluginStoreOptions = options ? { storeOptions: options } : {} as PluginStoreOptions\n\n return (typeof storeDefinition === 'function'\n ? defineAStoreSetup(\n id,\n storeDefinition as DefineAStoreSetup<AnyObject>,\n storeOptions\n )\n : defineAStoreOptionApi(\n id,\n storeDefinition,\n storeOptions\n )) as StoreDefinition\n}\n\n/**\n * Define a store with a required, fully typed setup context. State, getters\n * and actions are inferred from the setup function return.\n * @template Id The type of the store identifier.\n * @template SS The type of the setup function return.\n * @template TExtraExtensions The type of the store's extra extensions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store with setup context.\n */\nexport function defineAStoreCtx<Id extends string, SS, TExtraExtensions extends Record<string, unknown> = EmptyExtensions>(\n id: Id,\n storeDefinition: (ctx: DefineAStoreSetupContext<AnyObject, TExtraExtensions>) => SS,\n options?: StoreOptions\n): SetupStoreDefinition<Id, SS>\n/**\n * Define a store with a setup context and explicit store/state types, e.g.\n * when plugins augment the store with members not returned by the setup function.\n * @template Sto The type of the store.\n * @template Sta The type of the store's state.\n * @template TExtraExtensions The type of the store's extra extensions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store with setup context.\n */\nexport function defineAStoreCtx<Sto, Sta, TExtraExtensions extends Record<string, unknown> = EmptyExtensions>(\n id: string,\n storeDefinition: (ctx: DefineAStoreSetupContext<Sto & Sta, TExtraExtensions>) => AnyObject,\n options?: StoreOptions\n): DefineAStoreDefinition<Sto, Sta>\nexport function defineAStoreCtx(\n id: string,\n storeDefinition: DefineAStoreSetup<AnyObject, any>,\n options?: StoreOptions\n): StoreDefinition {\n const storeOptions: PluginStoreOptions = options\n ? { storeOptions: { ...options, enhancedStore: true } }\n : { storeOptions: { enhancedStore: true } } as PluginStoreOptions\n\n return defineAStoreSetup(\n id,\n storeDefinition,\n storeOptions\n ) as StoreDefinition\n}\n\nexport function defineAStoreSetup<Id extends string, SS>(\n id: Id,\n storeDefinition: DefineAStoreSetup<SS>,\n options: PluginStoreOptions\n): SetupStoreDefinition<Id, SS> {\n const setupContext: DefineAStoreSetupContext<SS> = {\n id,\n extensions: {}\n }\n\n const shouldStoreSetupContext = options?.storeOptions?.enhancedStore === true\n\n // `storeOptions` augments pinia's DefineStoreOptionsBase (see createPlugin.ts);\n // the assertion stays valid in compilation units where the augmentation is not loaded.\n const useStore = defineStore(\n id,\n () => storeDefinition(setupContext),\n options as unknown as DefineAStoreSetupOptions<Id, SS>\n )\n\n return Object.assign(((...args: Parameters<typeof useStore>) => {\n if (shouldStoreSetupContext) {\n defineAStoreSetupContextsById.set(id, setupContext as DefineAStoreSetupContext<AnyObject>)\n }\n\n const store = useStore(...args)\n\n if (shouldStoreSetupContext) {\n defineAStoreSetupContexts.set(store, setupContext as DefineAStoreSetupContext<AnyObject>)\n defineAStoreSetupContextsById.delete(id)\n registerSetupContextCleanupOnDispose(store as AnyObject, id)\n }\n\n return store\n }) as typeof useStore, useStore)\n}\n\nexport function defineAStoreOptionApi<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(\n id: Id,\n storeDefinition: Omit<DefineStoreOptions<Id, S, G, A>, 'id'>,\n options?: PluginStoreOptions\n): StoreDefinition<Id, S, G, A> {\n if (options) {\n storeDefinition = { ...storeDefinition, ...(options ?? {}) }\n }\n\n return defineStore(id, storeDefinition)\n}\n\nconst deniedFirstChar = new Set<string>(['_', '$'])\n\n/**\n * Check if a property has a denied first character : ['_', '$'].\n * @param property The property name to check.\n * @returns True if the property has a denied first character, false otherwise.\n */\nexport function hasDeniedFirstChar(property: string): boolean {\n return deniedFirstChar.has(property[0] as string)\n}\n\n/**\n * Get the setup context associated with a store instance (or pending store id).\n * @param store The store instance, or an object exposing the store `$id`.\n * @returns The setup context when the store was defined with `enhancedStore` enabled, undefined otherwise.\n */\nexport function getDefineAStoreSetupContext(store: object): DefineAStoreSetupContext<AnyObject> | undefined {\n const storeRecord = store as AnyObject\n\n return defineAStoreSetupContexts.get(store)\n ?? (typeof storeRecord?.$id === 'string'\n ? defineAStoreSetupContextsById.get(storeRecord.$id)\n : undefined)\n}\n\n/**\n * Get the enhanced store from the context.\n * @template TEnhancedStore The type of the enhanced store.\n * @param ctx The context containing the extensions.\n * @returns The enhanced store casted to the specified types.\n */\nexport function getEnhancedStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>\n): TEnhancedStore {\n const enhancedStore = ctx.extensions.enhancedStore ?? ctx.extensions.extending\n\n if (!enhancedStore) {\n throw new Error(`${ctx.id}Store - getEnhancedStore - Error: enhanced store is required`)\n }\n\n return enhancedStore\n}\n\n/**\n * Set the enhanced store in context with deprecated alias support.\n * @template TEnhancedStore The type of the enhanced store.\n * @param ctx The context containing the extensions.\n * @param store The store to expose as enhancement.\n */\nexport function setEnhancedStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>,\n store: TEnhancedStore\n): void {\n ctx.extensions.enhancedStore = store\n ctx.extensions.extending = store\n}\n\n/**\n * @deprecated Use getEnhancedStore instead.\n */\nexport function getExtendingStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>\n): TEnhancedStore {\n console.warn(`${ctx.id}Store - getExtendingStore is deprecated. Use getEnhancedStore instead.`)\n return getEnhancedStore<TEnhancedStore>(ctx)\n}\n\n/**\n * Get the storage key for a given action and store combination.\n * @param actionName The name of the action.\n * @param store The Pinia store instance.\n * @returns The storage key for the action and store combination.\n */\nexport function getActionStoreKey(actionName: string, store: Store): string {\n return `${actionName}-${store.$id}`\n}","import { isRef, ref, toRef } from \"vue\"\nimport Tracer from \"../system/Tracer\"\nimport TraceEmitter from \"../system/TraceEmitter\"\nimport { getDefineAStoreSetupContext, hasDeniedFirstChar, setEnhancedStore } from \"../utils/store\"\nimport { isEmpty } from \"../utils/validation\"\n\nimport type {\n PluginSubscriptionOptions,\n PluginSubscriptions,\n StoreClassConstructorParams,\n StoreMutationSubscription,\n StoreMutationSubscriptionCallback,\n StoreMutationSubscriptionReturn,\n StoreOnActionSubscription,\n StoreOnActionSubscriptionCallback,\n StoreOnActionSubscriptionReturn\n} from \"../types/plugin\"\nimport type { Store as PiniaStore, StateTree } from \"pinia\"\nimport type { AnyObject, PluginSubscriberInterface } from \"../types\"\nimport type { StoreOptions, StatePropertyValue } from \"../types/store\"\n\n/**\n * Base class for a Pinia store with enhanced capabilities.\n * Provides structured tracing, plugin subscriptions, and state management utilities.\n * @remarks\n * This class is intended to be extended by specific store implementations\n * that require enhanced capabilities such as structured tracing and plugin subscriptions.\n */\nexport default class Store extends TraceEmitter {\n protected _className = 'Store'\n private _createTracer?: () => Tracer\n private _onAction?: StoreOnActionSubscriptionCallback\n private _options: StoreOptions\n private _store: PiniaStore\n private _storeSubscribe?: StoreMutationSubscriptionCallback\n private _subscriptions: PluginSubscriptions = {}\n\n protected static _requiredKeys?: string[]\n\n get onAction(): StoreOnActionSubscription | undefined {\n if (!this._onAction) {\n return\n }\n\n return () => ({\n store: this.store as PiniaStore,\n callback: this._onAction\n }) as StoreOnActionSubscriptionReturn\n }\n\n set onAction(onAction: StoreOnActionSubscriptionCallback) {\n this._onAction = onAction\n }\n\n get options(): StoreOptions { return this._options }\n\n get state(): StateTree { return this._store.$state }\n\n set state(state: StateTree) { this._store.$state = state }\n\n get store(): AnyObject { return this._store }\n\n get storeSubscribe(): StoreMutationSubscription | undefined {\n if (!this._storeSubscribe) {\n return\n }\n\n return () => ({\n store: this.store as PiniaStore,\n callback: this._storeSubscribe\n }) as StoreMutationSubscriptionReturn\n }\n\n set storeSubscribe(storeSubscribe: StoreMutationSubscriptionCallback) {\n this._storeSubscribe = storeSubscribe\n }\n\n /**\n * Returns the structured trace emitter of this store.\n * Built lazily so that subclasses overriding `_className` are reflected.\n */\n protected override get tracer(): Tracer | undefined {\n if (!this._tracer && this._createTracer) {\n this._tracer = this._createTracer()\n this._tracer.scope = this.store.$id\n }\n\n return this._tracer\n }\n\n /**\n * Constructs a new instance of the store.\n * @param store The Pinia store instance.\n * @param options The plugin store options and subscription options.\n * @remarks\n * This constructor is typically called by the `customizeStore` static method\n * to create an instance of the store with the provided Pinia store and options.\n * @see PluginStoreOptions\n * @see PluginSubscriptionOptions\n */\n constructor(store: PiniaStore, options: StoreClassConstructorParams) {\n super()\n this._options = options.storeOptions as StoreOptions\n this._store = store\n this.initializeTracer(options)\n this.trace('instance:created', store.$id)\n\n if (this._options?.enhancedStore) {\n const ctx = getDefineAStoreSetupContext(this.store)\n\n if (ctx) {\n setEnhancedStore(ctx, this.store)\n this.trace('setup:enhancedStore:success', this.store.$id)\n }\n }\n }\n\n /**\n * Adds a property to the state of this store.\n * @param name The name of the property to add.\n * @param value The value of the property to add.\n */\n addToState(name: string, value?: StatePropertyValue): void {\n if (!this.isOptionApi()) {\n if (!isRef(value)) {\n value = ref<StatePropertyValue>(value)\n }\n }\n\n this.state[name] = value\n this.store[name] = toRef(this.state, name)\n }\n\n /**\n * Adds a subscription for a specific plugin to this store.\n * @param pluginName The name of the plugin for which the subscription is being added.\n * @param subscription The subscription callback or object to add.\n * @param options Additional options for the subscription, including subscription options and target stores.\n */\n addSubscription(\n pluginName: string,\n subscription: PluginSubscriberInterface,\n options?: { subscriptionOptions?: StoreOptions, stores?: PiniaStore[] }\n ): void {\n this._subscriptions[pluginName] = { subscription, ...(options ?? {}) }\n }\n\n /**\n * Called after the store has been hydrated.\n * @returns A promise that resolves when the post-hydration process is complete, or void if synchronous.\n */\n afterHydration(): void | Promise<void> {\n return\n }\n\n /**\n * Create and return a class instance\n * @param store \n * @param options \n * @template Instance The type of the store instance being created.\n * @returns The created store instance of type `Instance`, or undefined if the required keys are not present.\n */\n static customizeStore<Instance extends Store>(\n store: PiniaStore,\n options: StoreClassConstructorParams\n ): Instance | undefined {\n if (options.storeOptions && this.hasRequiredKeys(options.storeOptions)) {\n return new this(store, options) as Instance\n }\n }\n\n /**\n * Retrieves the value of a specific store option.\n * @param optionName The name of the store option to retrieve.\n * @returns The value of the specified store option, or undefined if not found.\n */\n getOption(optionName: keyof StoreOptions) {\n return this.options && (this.options as StoreOptions)[optionName]\n }\n\n /**\n * Retrieves the value of a specific state property.\n * @param propertyName The name of the state property to retrieve.\n * @returns The value of the specified state property, or undefined if not found.\n */\n getStatePropertyValue(propertyName: string) {\n return this.getValue(this.state[propertyName])\n }\n\n /**\n * Retrieves all plugin subscriptions for this store.\n * @returns An object containing all plugin subscriptions, or undefined if there are none.\n */\n getSubscriptions(): PluginSubscriptions | undefined {\n if (isEmpty(this._subscriptions)) {\n return\n }\n\n return this._subscriptions\n }\n\n /**\n * Retrieves the actual value from a potentially reactive reference.\n * @param value The value to unwrap.\n * @returns The unwrapped value if it is a reactive reference, otherwise the original value.\n */\n getValue(value: any) {\n return value?.__v_isRef ? value.value : value\n }\n\n /**\n * Checks if the given property name has a denied first character.\n * @param property The property name to check.\n * @returns True if the property name has a denied first character, otherwise false.\n */\n protected hasDeniedFirstChar(property: string): boolean {\n return hasDeniedFirstChar(property)\n }\n\n /**\n * Checks if the given options object has all the required keys.\n * @param options The options object to check.\n * @returns True if all required keys are present, otherwise false.\n */\n protected static hasRequiredKeys(options: AnyObject): boolean {\n return this._requiredKeys !== undefined && this._requiredKeys?.every(requiredKey => !!options[requiredKey])\n }\n\n /**\n * Hydrates the store, potentially performing asynchronous operations.\n * @returns void or a Promise that resolves when hydration is complete.\n */\n hydrate(): void | Promise<void> {\n return\n }\n\n /**\n * Initializes the tracer for plugin subscriptions if the createTracer option is provided.\n * @param options The plugin subscription options containing the createTracer function.\n */\n private initializeTracer(options: Omit<PluginSubscriptionOptions, 'createTracer'> & { createTracer?: () => Tracer }) {\n this._createTracer = options?.createTracer\n }\n\n /**\n * Checks if the store is using the Options API.\n * @returns True if the store is using the Options API, otherwise false.\n */\n isOptionApi(): boolean { return this.store._isOptionsAPI }\n\n /**\n * Checks if the state object has the specified property.\n * @param property The property name to check.\n * @returns True if the state object has the property, otherwise false.\n */\n stateHas(property: string): boolean { return Object.prototype.hasOwnProperty.call(this.state, property) }\n\n /**\n * Checks if the store object has the specified property.\n * @param property The property name to check.\n * @returns True if the store object has the property, otherwise false.\n */\n storeHas(property: string): boolean { return Object.prototype.hasOwnProperty.call(this.store, property) }\n\n}","export function isEmpty(value: any): boolean {\n if (!value) {\n return (typeof value === 'boolean' || typeof value === 'number') ? false : true\n }\n\n if (Array.isArray(value)) {\n return value.length === 0\n }\n\n if (typeof value === 'object') {\n return Object.keys(value).length === 0\n }\n\n if (typeof value === 'string') {\n return value.trim() === ''\n }\n\n return false\n}"],"names":["PluginSubscriber","pluginName","createInstanceFunction","__publicField","options","subscriptions","context","store","createTracer","TraceEmitter","value","label","scope","payload","namespace","tracer","error","defineAStoreSetupContexts","defineAStoreSetupContextsById","setupContextDisposeWrappedStores","registerSetupContextCleanupOnDispose","id","originalDispose","args","defineAStore","storeDefinition","storeOptions","defineAStoreSetup","defineAStoreOptionApi","defineAStoreCtx","setupContext","shouldStoreSetupContext","useStore","defineStore","deniedFirstChar","hasDeniedFirstChar","property","storeRecord","enhancedStore","ctx","setEnhancedStore","getExtendingStore","getEnhancedStore","getActionStoreKey","actionName","isEmpty","Store","getDefineAStoreSetupContext","onAction","state","storeSubscribe","name","isRef","ref","toRef","subscription","optionName","propertyName","requiredKey","pluginSubscriptionClassName","pluginSubscriptionNamespace"],"mappings":";;;;;AA0BA,MAA8BA,EAA8E;AAAA,EAqDxG,YAAIC,GAAcC,GAAoC;AApD9C,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAEE,IAAAA,EAAA;AACF,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAAA,IAAAA,EAAA;AAAA,IAAAA,EAAA;AAKE,IAAAA,EAAA;AAwCN,SAAK,QAAAF,GACT,KAAA,kBAAAC;AAAA,EAGA;AAAA,EA1CO,IAAA,OAAA;AAAA,WAAA,KAAA;AAAA,EAEA;AAAA,EAGP,IAAI,gBAAe;AACf,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,gBAAsC;AACtC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,cAAAE,GAAyD;AACzD,SAAA,iBAAYA;AAAA,EAChB;AAAA,EAEA,IAAI,qBAAc;AACd,WAAK,KAAA;AAAA,EACT;AAAA,EAEA,IAAI,4BAAiE;AACjE,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,4BAAmE;AACnE,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI;AACA,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,cAAAC,GAAiD;AACjD,SAAA,iBAAYA;AAAA,EAChB;AAAA,EASI,eAAKC,GAAA;AAAA,EACT;AAAA,EAAA,QAA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YAAA;"}
@@ -1,6 +1,7 @@
1
+ import TraceEmitter from "../system/TraceEmitter";
1
2
  import type { PiniaPluginContext } from "pinia";
2
3
  import type { PluginSubscriber, PluginSubscriptionOptions, PluginSubscriptions } from "../types/plugin";
3
- export default class PluginSubscription {
4
+ export default class PluginSubscription extends TraceEmitter {
4
5
  protected _className: string;
5
6
  private _hydrationScheduler;
6
7
  private _onActionSubscriptions;
@@ -17,7 +18,6 @@ export default class PluginSubscription {
17
18
  private _subscriptions;
18
19
  private _subscriptionsDelivered;
19
20
  private _subscriptionsScheduled;
20
- private _tracer?;
21
21
  set subscribers(subscribers: PluginSubscriber[]);
22
22
  get subscriptions(): PluginSubscriptions[] | undefined;
23
23
  constructor(subscribers: PluginSubscriber[], options?: PluginSubscriptionOptions);
@@ -80,15 +80,6 @@ export default class PluginSubscription {
80
80
  private storeMutationSubscription;
81
81
  private subscriptionDelivery;
82
82
  private subscriptionDeliverySafely;
83
- /**
84
- * Emits a structured trace event.
85
- * Prefer the factory form for `payload`: it is only resolved when consumed.
86
- */
87
- private trace;
88
- /**
89
- * Emits a structured error event, or rethrows it when no listener matches.
90
- */
91
- private traceError;
92
83
  private traceGroupEnd;
93
84
  private traceGroupStart;
94
85
  }
@@ -1,7 +1,7 @@
1
1
  import Tracer from "../system/Tracer";
2
+ import TraceEmitter from "../system/TraceEmitter";
2
3
  import type { PluginSubscriptions, StoreClassConstructorParams, StoreMutationSubscription, StoreMutationSubscriptionCallback, StoreOnActionSubscription, StoreOnActionSubscriptionCallback } from "../types/plugin";
3
4
  import type { Store as PiniaStore, StateTree } from "pinia";
4
- import type { TracePayload } from "../types/trace";
5
5
  import type { AnyObject, PluginSubscriberInterface } from "../types";
6
6
  import type { StoreOptions, StatePropertyValue } from "../types/store";
7
7
  /**
@@ -11,7 +11,7 @@ import type { StoreOptions, StatePropertyValue } from "../types/store";
11
11
  * This class is intended to be extended by specific store implementations
12
12
  * that require enhanced capabilities such as structured tracing and plugin subscriptions.
13
13
  */
14
- export default class Store {
14
+ export default class Store extends TraceEmitter {
15
15
  protected _className: string;
16
16
  private _createTracer?;
17
17
  private _onAction?;
@@ -19,11 +19,7 @@ export default class Store {
19
19
  private _store;
20
20
  private _storeSubscribe?;
21
21
  private _subscriptions;
22
- private _traceOptions;
23
- private _tracer?;
24
22
  protected static _requiredKeys?: string[];
25
- get classNameAddedToTraceNamespace(): boolean;
26
- set classNameAddedToTraceNamespace(value: boolean);
27
23
  get onAction(): StoreOnActionSubscription | undefined;
28
24
  set onAction(onAction: StoreOnActionSubscriptionCallback);
29
25
  get options(): StoreOptions;
@@ -139,14 +135,4 @@ export default class Store {
139
135
  * @returns True if the store object has the property, otherwise false.
140
136
  */
141
137
  storeHas(property: string): boolean;
142
- /**
143
- * Emits a structured trace event scoped to this store.
144
- * Prefer the factory form for `payload`: it is only resolved when consumed.
145
- */
146
- trace(label: string, scope?: string, payload?: TracePayload, namespace?: string): void;
147
- /**
148
- * Emits a structured error event, or rethrows it when no listener matches.
149
- */
150
- traceError(label: string, error: unknown, scope?: string, payload?: TracePayload, namespace?: string): void;
151
- private traceLabelFormatter;
152
138
  }
@@ -1,7 +1,7 @@
1
- import type { Console } from '../types/log';
2
- import type { TraceListenerGroupBy, ConsoleTraceGroupListener, TraceListener } from '../types/trace';
1
+ import type { TraceListenerGroupBy, ConsoleTraceGroupListener } from '../types/trace';
3
2
  /**
4
- * Creates an opt-in trace listener that reproduces the former console output.
3
+ * Creates a console trace group listener that groups trace events by the specified key.
4
+ * @param groupBy The key of the trace event metadata to group by.
5
+ * @returns A console trace group listener configured to group trace events by the specified key.
5
6
  */
6
- export declare function createConsoleTraceListener(target?: Console): Omit<TraceListener, 'filter'>;
7
7
  export declare function createConsoleGroupTraceListener(groupBy?: TraceListenerGroupBy): ConsoleTraceGroupListener;
@@ -0,0 +1,18 @@
1
+ import type { PluginSubscriber, PluginSubscriberInvoke } from "../types/plugin";
2
+ /**
3
+ * Creates a new plugin subscriber with the given name, invoke function, and optional properties.
4
+ * @param name - plugin name.
5
+ * @param invoke - function to invoke for the plugin subscriber.
6
+ * @param optionalProps - optional additional properties for the plugin subscriber.
7
+ * @param {Function} optionalProps.afterHydration
8
+ * @param {PluginExecutionOptions} optionalProps.execution
9
+ * @param {Function} optionalProps.hydrate
10
+ * @param {PluginHydrationScheduler} optionalProps.hydrationScheduler
11
+ * @param {Function} optionalProps.resetStoreCallback
12
+ * @param {StoreOnActionSubscription} optionalProps.storeOnActionSubscription
13
+ * @param {StoreMutationSubscription} optionalProps.storeMutationSubscription
14
+ * @param {PluginSubscriptions} optionalProps.subscriptions
15
+ * @param
16
+ * @returns A new plugin subscriber object.
17
+ */
18
+ export declare function createPluginSubscriber(name: string, invoke: PluginSubscriberInvoke, optionalProps?: Omit<PluginSubscriber, "name" | "invoke">): PluginSubscriber;
@@ -1,16 +1,10 @@
1
- import type { TraceEventMetadata, TraceFilterFactoryCriterion, TraceFilterFactoryParam, TraceGroupListener, TraceListener } from "../types/trace";
1
+ import type { TraceEventMetadata, TraceFilterFactoryCriterion, TraceFilterFactoryParam, TraceGroupListener } from "../types/trace";
2
2
  /**
3
3
  * Creates a trace group listener with optional filtering.
4
- * @param filterDef The filter criteria for the trace events.
4
+ * @param listenerDef The listener definition or filter criteria for the trace group listener.
5
+ * @param context Print the plugin context (subscribers, store, options, and traces) to the console.. Defaults to true.
5
6
  * @param filterMode The mode to apply when evaluating multiple filter criteria: 'every' or 'some'.
6
7
  * @param groupBy The key of the trace event metadata to group by.
7
8
  * @returns A trace listener configured with group handling and filtering.
8
9
  */
9
- export declare function createTraceGroupListener(filterDef: TraceFilterFactoryCriterion[], filterMode?: 'every' | 'some', groupBy?: keyof TraceEventMetadata): TraceGroupListener;
10
- /**
11
- * Creates a trace listener with optional filtering.
12
- * @param param The trace listener parameters including handler and optional filter criteria.
13
- * @param filterMode The mode to apply when evaluating multiple filter criteria: 'every' or 'some'.
14
- * @returns A trace listener configured with the specified handler and filter.
15
- */
16
- export declare function createTraceListener(listenerDef: TraceFilterFactoryParam | TraceFilterFactoryCriterion[], filterMode?: 'every' | 'some'): TraceListener;
10
+ export declare function createTraceGroupListener(listenerDef: TraceFilterFactoryParam | TraceFilterFactoryCriterion[], context?: boolean, filterMode?: 'every' | 'some', groupBy?: keyof TraceEventMetadata): TraceGroupListener;
@@ -1,17 +1,2 @@
1
- import Tracer from '../system/Tracer';
2
- import type { AddTraceListenerOptions, TraceEvent, TraceFilterFactoryCriterion, TraceListenerRemover, TraceRegistry, TracerOptions } from '../types/trace';
3
- /**
4
- * Creates a registry for managing trace listeners and creating tracers.
5
- * @returns An object containing methods to add and clear trace listeners, and to create tracers.
6
- */
7
- export declare function createTracerRegistry(): TraceRegistry;
8
- export declare function createTraceGroupsRegistry(): {
9
- addListener: (criteria: TraceFilterFactoryCriterion[], { filterMode, groupBy }?: AddTraceListenerOptions) => TraceListenerRemover;
10
- clearTraceListeners: () => void;
11
- tracerHandler: {
12
- closeGroup: (payload: TraceEvent) => void;
13
- createTracer: (source: string, options?: TracerOptions) => Tracer;
14
- startGroup: (payload: TraceEvent) => void;
15
- };
16
- hasTraceListeners: () => boolean;
17
- };
1
+ import type { TraceRegistry, TracerRegistryOptions } from '../types/trace';
2
+ export declare function createTracerRegistry({ enabled, redact }?: TracerRegistryOptions): TraceRegistry;
@@ -3,7 +3,8 @@ export { default as Store } from '../core/Store';
3
3
  export { CustomConsole } from '../system/log';
4
4
  export { isEmpty } from '../utils/validation';
5
5
  export type { Console, LogType, StyleDefinition, StyleDefinitionKeys, StyleDefinitions, ConsoleStyleDefinition, ConsoleStyleDefinitionKeys, ConsoleStyleDefinitions } from "../types";
6
- export type { TraceEvent, TraceEventMetadata, TraceFilter, TraceHandler, TraceLevel, TraceListener, TraceListenerRemover, TracePayload, TraceRegistry, TracerOptions } from "../types/trace";
7
- export { createTracerRegistry, createTraceGroupsRegistry } from "../factories/trace-registry";
6
+ export type { TraceEvent, TraceEventMetadata, TraceFilter, TraceHandler, TraceLevel, TraceListener, TraceListenerRemover, TracePayload, TraceRedactOptions, TraceRegistry, TracerOptions, TracerRegistryOptions } from "../types/trace";
7
+ export { createTracerRegistry } from "../factories/trace-registry";
8
8
  export { default as Tracer } from "../system/Tracer";
9
- export { createConsoleTraceListener, createConsoleGroupTraceListener } from "../factories/console-trace-listener";
9
+ export { createConsoleGroupTraceListener } from "../factories/console-trace-listener";
10
+ export { defaultRedactedKeys } from '../utils/redact';