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

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":"PluginSubscription-DPu3ft-c.js","sources":["../../src/utils/deep-clone.ts","../../src/factories/state-snapshot.ts","../../src/utils/store.ts","../../src/core/RollbackStateSnapshotsHandler.ts","../../src/system/TraceEmitter.ts","../../src/utils/constants.ts","../../src/utils/validation/index.ts","../../src/core/PluginSubscription.ts"],"sourcesContent":["/**\n * Deeply clones the provided value, handling objects, arrays, maps, and sets. Uses `structuredClone` if available, otherwise falls back to a manual deep clone.\n * @template T The type of the value to deep clone.\n * @param value The value to deep clone.\n * @returns A deep clone of the provided value.\n */\nexport function deepClone<T>(value: T): T {\n if (typeof structuredClone === 'function') {\n try {\n return structuredClone(value)\n } catch {\n // fall through to the safe manual clone below\n }\n }\n\n if (value === null || typeof value !== 'object') {\n return value\n }\n\n if (value instanceof Map) {\n return new Map(\n Array.from(value.entries(), ([key, entryValue]) => [deepClone(key), deepClone(entryValue)])\n ) as T\n }\n\n if (value instanceof Set) {\n return new Set(Array.from(value.values(), entryValue => deepClone(entryValue))) as T\n }\n\n if (Array.isArray(value)) {\n return value.map(item => deepClone(item)) as T\n }\n\n if (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null) {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>).map(([key, item]) => [key, deepClone(item)])\n ) as T\n }\n\n const clonedObject = Object.create(Object.getPrototypeOf(value)) as Record<string, unknown>\n for (const [key, item] of Object.entries(value as Record<string, unknown>)) {\n clonedObject[key] = deepClone(item)\n }\n\n return clonedObject as T\n}","import { toRaw } from 'vue'\nimport { deepClone } from '../utils/deep-clone'\n\nimport type { StateTree } from 'pinia'\nimport type { CreateStateSnapshotKeys } from '../types/plugin'\n\n\nexport function createStateSnapshot(state: StateTree, keys: CreateStateSnapshotKeys = 'all') {\n if (Array.isArray(keys)) {\n const clonedState: Partial<StateTree> = {}\n for (const key of keys) {\n if (key in state) {\n clonedState[key] = deepClone(toRaw(state[key]))\n }\n }\n return clonedState\n }\n\n if (keys !== 'all') {\n throw new Error(`Invalid keys parameter: ${keys}`)\n }\n\n return deepClone(toRaw(state))\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 { createStateSnapshot } from \"../factories/state-snapshot\"\nimport { getActionStoreKey, hasDeniedFirstChar } from '../utils/store'\n\nimport type { PiniaPluginContext, StateTree, Store } from 'pinia'\nimport type { AnyObject } from '../types'\nimport type { CreateStateSnapshotKeys } from '../types/plugin'\nimport type { RollbackActionParams } from '../types/store'\n\n\n/**\n * Handles rollback state snapshots for Pinia stores.\n * This class provides methods to add rollback actions to stores,\n * create rollback snapshots, and manage the state snapshots internally.\n */\nexport default class RollbackStateSnapshotsHandler {\n private _stateSnapshots: Map<symbol, StateTree> = new Map()\n private _storeHasRollbackSnapshots: Set<string> = new Set()\n private _storeRollbackSnapshotsParams: Map<string, CreateStateSnapshotKeys> = new Map()\n\n\n /**\n * Adds a rollback action to the given store.\n * This method extends the store with a $rollbackAfterFailure function that handles rollback logic for actions.\n * The action arguments are forwarded through apply(), so they must be provided as a single array.\n * @param {Store} store The store to which the rollback action will be added.\n * @returns void\n */\n addRollbackAction(store: Store): void {\n if (typeof store.$rollbackAfterFailure === 'function') {\n return\n }\n\n store.$rollbackAfterFailure = async ({ action, stateKeys }: RollbackActionParams, args: any[] = []) => {\n const actionFn = (store as AnyObject)[action]\n if (typeof actionFn !== 'function' || hasDeniedFirstChar(action)) {\n return\n }\n\n const keys: CreateStateSnapshotKeys = !stateKeys || stateKeys.length === 0 ? 'all' : stateKeys\n\n const snapshotKey = this.saveStateSnapshot(store, action, keys)\n try {\n await actionFn.apply(store, args)\n } catch (error) {\n this.patchStore(snapshotKey, store)\n throw error\n } finally {\n this.removeStateSnapshot(snapshotKey)\n }\n }\n }\n\n /**\n * Creates a rollback snapshot for the specified action and store.\n * This snapshot can be used to restore the store's state in case of an error during the action execution.\n * @param {string} actionName The name of the action for which the rollback snapshot is created.\n * @param {Store} store The Pinia store instance.\n * @returns An object containing `after` and `onError` callbacks for handling the rollback, or `undefined` if no snapshot is created.\n */\n createOnActionCallbacks(\n actionName: string,\n store: Store\n ): {\n after: () => void,\n onError: () => void\n } | undefined {\n const stateKeys = this._storeRollbackSnapshotsParams.get(\n getActionStoreKey(actionName, store)\n )\n\n if (!stateKeys) {\n return\n }\n\n const keys: CreateStateSnapshotKeys = stateKeys.length === 0 ? 'all' : stateKeys\n const snapshotKey = this.saveStateSnapshot(store, actionName, keys)\n\n return {\n after: () => { this.removeStateSnapshot(snapshotKey) },\n onError: () => {\n this.patchStore(snapshotKey, store)\n this.removeStateSnapshot(snapshotKey)\n }\n }\n }\n\n /**\n * Initializes the rollback state snapshots handler from the given Pinia plugin context.\n * This method extracts the rollback snapshot parameters from the store options and stores them internally.\n * @param {PiniaPluginContext} param0 The Pinia plugin context containing the store and its options.\n * @returns void\n */\n initFromPluginContext({ options, store }: PiniaPluginContext) {\n const rollbackSnapshotParams = options?.storeOptions?.rollbackAfterFailure as Record<string, CreateStateSnapshotKeys>\n if (rollbackSnapshotParams && !this._storeHasRollbackSnapshots.has(store.$id)) {\n Object.keys(rollbackSnapshotParams).forEach(key => {\n const stateKeys = rollbackSnapshotParams[key]\n if (stateKeys) {\n this._storeRollbackSnapshotsParams.set(\n getActionStoreKey(key, store),\n stateKeys\n )\n }\n })\n this._storeHasRollbackSnapshots.add(store.$id)\n }\n this.addRollbackAction(store)\n }\n\n /**\n * Clears all rollback tracking data for the given store.\n * Must be called when the store is disposed to avoid memory leaks with dynamically created stores.\n * @param {Store} store The disposed Pinia store instance.\n * @returns void\n */\n clearStoreTracking(store: Store): void {\n const suffix = `-${store.$id}`\n\n for (const key of Array.from(this._storeRollbackSnapshotsParams.keys())) {\n if (key.endsWith(suffix)) {\n this._storeRollbackSnapshotsParams.delete(key)\n }\n }\n\n this._storeHasRollbackSnapshots.delete(store.$id)\n\n for (const snapshotKey of Array.from(this._stateSnapshots.keys())) {\n if (snapshotKey.description?.startsWith(`${store.$id}:`)) {\n this._stateSnapshots.delete(snapshotKey)\n }\n }\n }\n\n private patchStore(snapshotKey: symbol, store: Store): void {\n const stateSnapshot = this._stateSnapshots.get(snapshotKey)\n if (!stateSnapshot) {\n return\n }\n\n try {\n store.$patch(stateSnapshot)\n } catch (error) {\n console.error(`Failed to patch store with snapshot ${String(snapshotKey)}`, error)\n }\n }\n\n /**\n * Removes a state snapshot identified by the given snapshot key from the internal state snapshot tracking.\n * @param snapshotKey The key of the state snapshot to be removed.\n * @returns void\n */\n private removeStateSnapshot(snapshotKey?: symbol): void {\n if (!snapshotKey) {\n return\n }\n\n this._stateSnapshots.delete(snapshotKey)\n }\n\n /**\n * Saves the current state snapshot for a given store and action.\n * @param store The Pinia store instance.\n * @param actionName The name of the action being executed.\n * @param stateKeys The state keys to include in the snapshot, or 'all' for the full state.\n * @returns A unique symbol key representing the saved snapshot.\n */\n private saveStateSnapshot(store: Store, actionName: string, stateKeys: CreateStateSnapshotKeys): symbol {\n const stateSnapshot = createStateSnapshot(\n store.$state,\n stateKeys\n )\n\n const snapshotKey = Symbol(`${store.$id}:${actionName}`)\n this._stateSnapshots.set(snapshotKey, stateSnapshot)\n return snapshotKey\n }\n\n /**\n * Checks if the given store has rollback snapshots.\n * @param store The Pinia store instance.\n * @returns True if the store has rollback snapshots, false otherwise.\n */\n storeHasRollbackSnapshots(store: Store): boolean {\n return this._storeHasRollbackSnapshots.has(store.$id)\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","export const pluginName: string = 'pinia-plugin-subscription'\nexport const pluginSubscriptionClassName = 'PluginSubscription'\n/** Prefix of every namespace emitted by `PluginSubscription` (labels are lowercased into namespaces). */\nexport const pluginSubscriptionNamespace: string = pluginSubscriptionClassName.toLowerCase()","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}","import RollbackStateSnapshotsHandler from \"./RollbackStateSnapshotsHandler\"\nimport { deepClone } from '../utils/deep-clone'\nimport { getActionStoreKey } from '../utils/store'\nimport TraceEmitter from \"../system/TraceEmitter\"\nimport { isEmpty } from \"../utils/validation\"\nimport { pluginName, pluginSubscriptionClassName } from \"../utils/constants\"\n\nimport type { PiniaPluginContext, StateTree, Store, SubscriptionCallbackMutation } from \"pinia\"\nimport type { AnyObject } from \"../types\"\nimport type { TraceEvent, TracePayload } from \"../types/trace\"\nimport type {\n PluginExecutionOptions,\n PluginHydrationScheduler,\n PluginRuntimeEnvironment,\n PluginSubscriber,\n PluginSubscription as PluginSubscriptionDefinition,\n PluginSubscriptionOptions,\n PluginSubscriptions,\n StoreMutationSubscription,\n StoreOnActionAfterCallbackParameter,\n StoreOnActionSubscriptionCallback\n} from \"../types/plugin\"\n\n\nconst className = pluginSubscriptionClassName\nconst defaultPluginExecution: Required<PluginExecutionOptions> = {\n environment: 'both',\n hydration: 'immediate'\n}\n\nfunction defaultHydrationScheduler(callback: () => void): void {\n if (typeof window !== 'undefined' && typeof window.requestAnimationFrame === 'function') {\n window.requestAnimationFrame(() => globalThis.setTimeout(callback, 0))\n return\n }\n\n globalThis.setTimeout(callback, 0)\n}\n\nexport default class PluginSubscription extends TraceEmitter {\n protected _className: string = className\n private _hydrationScheduler: PluginHydrationScheduler\n private _onActionSubscriptions: Map<Store, Set<StoreOnActionSubscriptionCallback>> = new Map()\n private _onActionStores: Set<Store> = new Set()\n private _onActionAfterSubscriptions: Record<string, StoreOnActionAfterCallbackParameter[]> = {}\n private _onActionOnErrorSubscriptions: Record<string, Array<(error: unknown) => void>> = {}\n private _options?: PluginSubscriptionOptions\n private _resetStoreCallback: Map<Store, Set<NonNullable<PluginSubscriber['resetStoreCallback']>>> = new Map()\n private _disposedStores: WeakSet<Store> = new WeakSet()\n private _storeRollbackSnapshotsHandler: RollbackStateSnapshotsHandler = new RollbackStateSnapshotsHandler()\n private _subscribers: PluginSubscriber[] = []\n private _subscribersDelivered: Set<string> = new Set()\n private _subscribersScheduled: Set<string> = new Set()\n private _subscriptions: PluginSubscriptions[] = []\n private _subscriptionsDelivered: Set<string> = new Set()\n private _subscriptionsScheduled: Set<string> = new Set()\n set subscribers(subscribers: PluginSubscriber[]) {\n this._subscribers = subscribers\n }\n\n get subscriptions(): PluginSubscriptions[] | undefined {\n if (!isEmpty(this._subscriptions)) {\n return this._subscriptions\n }\n }\n\n constructor(\n subscribers: PluginSubscriber[],\n options?: PluginSubscriptionOptions\n ) {\n super()\n this._hydrationScheduler = options?.hydrationScheduler ?? defaultHydrationScheduler\n this._options = options\n this._subscribers = subscribers\n this.initializeTracer()\n }\n\n private addOnActionAfterCallback(actionName: string, store: Store, callback: StoreOnActionAfterCallbackParameter): void {\n const key = getActionStoreKey(actionName, store)\n if (!this._onActionAfterSubscriptions[key]) {\n this._onActionAfterSubscriptions[key] = []\n }\n this._onActionAfterSubscriptions[key]?.push(callback)\n }\n\n private addOnActionOnErrorCallback(actionName: string, store: Store, callback: (error: unknown) => void): void {\n const key = getActionStoreKey(actionName, store)\n if (!this._onActionOnErrorSubscriptions[key]) {\n this._onActionOnErrorSubscriptions[key] = []\n }\n this._onActionOnErrorSubscriptions[key]?.push(callback)\n }\n\n private addResetStoreCallback(store: Store, callback: NonNullable<PluginSubscriber['resetStoreCallback']>): void {\n if (!this._resetStoreCallback.has(store)) {\n this._resetStoreCallback.set(store, new Set())\n }\n this._resetStoreCallback.get(store)!.add(callback)\n }\n\n private clearOnActionCallbacksSubscriptions(storageKey: string): void {\n delete this._onActionAfterSubscriptions[storageKey]\n delete this._onActionOnErrorSubscriptions[storageKey]\n }\n\n private clearStoreTracking(store: Store): void {\n this._onActionSubscriptions.delete(store)\n this._onActionStores.delete(store)\n this._resetStoreCallback.delete(store)\n const suffix = `-${store.$id}`\n\n for (const key of Array.from(this._subscribersDelivered)) {\n if (key.endsWith(suffix)) {\n this._subscribersDelivered.delete(key)\n }\n }\n\n for (const key of Array.from(this._subscribersScheduled)) {\n if (key.endsWith(suffix)) {\n this._subscribersScheduled.delete(key)\n }\n }\n\n for (const key of Array.from(this._subscriptionsDelivered)) {\n if (key.endsWith(suffix)) {\n this._subscriptionsDelivered.delete(key)\n }\n }\n\n for (const key of Array.from(this._subscriptionsScheduled)) {\n if (key.endsWith(suffix)) {\n this._subscriptionsScheduled.delete(key)\n }\n }\n\n for (const key of Object.keys(this._onActionAfterSubscriptions)) {\n if (key.endsWith(suffix)) {\n delete this._onActionAfterSubscriptions[key]\n }\n }\n\n for (const key of Object.keys(this._onActionOnErrorSubscriptions)) {\n if (key.endsWith(suffix)) {\n delete this._onActionOnErrorSubscriptions[key]\n }\n }\n }\n\n /**\n * Creates a callback collector for the specified action and store.\n * @param actionName The name of the action to collect callbacks for.\n * @param store The store instance associated with the action.\n * @returns A function that collects callbacks for the specified action and store.\n */\n private createOnActionAfterCallbackCollector(actionName: string, store: Store) {\n return (callback: StoreOnActionAfterCallbackParameter) => {\n this.addOnActionAfterCallback(actionName, store, callback)\n }\n }\n\n /**\n * Creates a callback collector for the specified action and store that handles errors.\n * @param actionName The name of the action to collect error callbacks for.\n * @param store The store instance associated with the action.\n * @returns A function that collects error callbacks for the specified action and store.\n */\n private createOnActionOnErrorCallbackCollector(actionName: string, store: Store) {\n return (callback: (error: unknown) => void) => {\n this.addOnActionOnErrorCallback(actionName, store, callback)\n }\n }\n\n /**\n * Rolls back the state snapshot for a given action if an error occurs, and removes the snapshot after the action completes or fails.\n * @param actionName The name of the action being executed.\n * @param store The Pinia store instance.\n * @returns void\n */\n private createRollbackSnapshot(\n actionName: string,\n store: Store\n ) {\n const {\n after,\n onError\n } = this._storeRollbackSnapshotsHandler.createOnActionCallbacks(\n actionName,\n store\n ) ?? {}\n\n if (!after || !onError) {\n return\n }\n\n this.addOnActionAfterCallback(actionName, store, after)\n this.addOnActionOnErrorCallback(actionName, store, onError)\n this.trace('store:onAction:rollbackSnapshot:created', store.$id)\n }\n\n private defineCurrentEnvironment(): PluginRuntimeEnvironment {\n return this._options?.runtimeEnvironment\n ?? (typeof window === 'undefined' ? 'server' : 'client')\n }\n\n private definePluginExecution(subscriber: PluginSubscriber): Required<PluginExecutionOptions> {\n return {\n ...defaultPluginExecution,\n ...(this._options?.execution ?? {}),\n ...(subscriber.execution ?? {}),\n ...(this._options?.subscriberExecution?.[subscriber.name] ?? {}),\n }\n }\n\n private defineHydrationScheduler(subscriber: PluginSubscriber | PluginSubscriptionDefinition['subscription']): PluginHydrationScheduler {\n return subscriber.hydrationScheduler ?? this._hydrationScheduler\n }\n\n private defineSubscriberKey(subscriber: PluginSubscriber, store: Store): string {\n return `${subscriber.name}-${store.$id}`\n }\n\n private defineSubscriptionKey(pluginName: string, store: Store): string {\n return `${pluginName}-${store.$id}`\n }\n\n private executeResetStoreCallbacks(store: Store): void {\n this._resetStoreCallback.get(store)?.forEach(callback => callback(store))\n }\n\n /**\n * Executes the store's onAction subscription for the given plugin subscriber.\n * @param store The Pinia store instance.\n * @param subscriber The plugin subscriber.\n * @returns void\n */\n private executeStoreOnActionSubscription(store: Store): void {\n if (this._onActionStores.has(store) || typeof store.$onAction !== 'function') {\n return\n }\n const onActionSubscriptions = this._onActionSubscriptions.get(store)\n const hasRollbackSnapshots = this._storeRollbackSnapshotsHandler.storeHasRollbackSnapshots(store)\n\n if (!onActionSubscriptions?.size && !hasRollbackSnapshots) {\n return\n }\n\n this._onActionStores.add(store)\n store.$onAction(({ after, args, name, onError }) => {\n const callbacks = this._onActionSubscriptions.get(store)\n const callbacksLength = callbacks?.size\n if (!callbacksLength) {\n return\n }\n\n this.traceGroupStart(() => ({ args, callbacks: callbacksLength, name }), store.$id, 'onAction')\n // The group must be closed exactly once, whichever way the action ends.\n let groupClosed = false\n const closeGroup = () => {\n if (!groupClosed) {\n groupClosed = true\n this.traceGroupEnd({}, store.$id)\n }\n }\n\n try {\n const storageKey = getActionStoreKey(name, store)\n\n if (this._storeRollbackSnapshotsHandler.storeHasRollbackSnapshots(store)) {\n this.createRollbackSnapshot(name, store)\n }\n\n callbacks.forEach(callback => callback({\n after: this.createOnActionAfterCallbackCollector(name, store),\n args,\n name,\n onError: this.createOnActionOnErrorCallbackCollector(name, store)\n }))\n closeGroup()\n this.executeStoreOnActionAfterCallbacks(after, storageKey, store)\n this.executeStoreOnActionOnErrorCallbacks(onError, storageKey, store)\n this.clearOnActionCallbacksSubscriptions(storageKey)\n } catch (error) {\n closeGroup()\n throw error\n }\n })\n }\n\n private executeStoreOnActionAfterCallbacks(\n after: (callback: (result: any) => void) => void,\n storageKey: string,\n store: Store\n ) {\n const afterCallbacks = this._onActionAfterSubscriptions[storageKey]\n const afterCallbacksLength = afterCallbacks?.length\n\n if (afterCallbacksLength) {\n after((result) => {\n this.traceGroupStart(() => ({\n callbacks: afterCallbacksLength,\n result\n }), store.$id, 'execute:store:onAction:after:callbacks')\n\n afterCallbacks.forEach(callback => {\n try {\n callback(result)\n } catch (error) {\n this.traceError('executeStoreOnActionAfterCallbacks', error, store.$id)\n }\n })\n\n this.traceGroupEnd(() => ({}), store.$id)\n })\n }\n }\n\n private executeStoreOnActionOnErrorCallbacks(\n onError: (callback: (error: any) => void) => void,\n storageKey: string,\n store: Store\n ) {\n const onErrorCallbacks = this._onActionOnErrorSubscriptions[storageKey]\n\n if (onErrorCallbacks?.length) {\n onError((error) => {\n this.traceGroupStart(() => ({\n callbacks: onErrorCallbacks.length,\n error\n }), store.$id, 'execute:store:onAction:onError:callbacks')\n\n onErrorCallbacks.forEach(callback => {\n try {\n callback(error)\n } catch (err) {\n this.traceError('execute:store:onAction:onError:callbacks:error', err, store.$id)\n }\n })\n\n this.traceGroupEnd(() => ({}), store.$id)\n })\n }\n }\n\n private executeSubscriber(context: PiniaPluginContext, subscriber: PluginSubscriber): void {\n const subscriberKey = this.defineSubscriberKey(subscriber, context.store)\n\n if (this._subscribersDelivered.has(subscriberKey)) {\n return\n }\n\n if (\n !subscriber.invoke(context, this._options?.tracerHandler?.createTracer)) {\n return\n }\n\n this._subscribersDelivered.add(subscriberKey)\n\n let hydrateResult: void | Promise<void>\n\n try {\n hydrateResult = subscriber.hydrate?.(context)\n } catch (error) {\n this.traceError('subscriber:hydrate', error, context.store.$id)\n return\n }\n\n const runAfterHydration = () => {\n try {\n const afterHydration = subscriber.afterHydration?.(context)\n if (afterHydration && typeof (afterHydration as Promise<void>).then === 'function') {\n ; (afterHydration as Promise<void>).catch(\n error => this.traceError('subscriber:afterHydration', error, context.store.$id)\n )\n }\n } catch (error) {\n this.traceError('subscriber:afterHydration', error, context.store.$id)\n }\n }\n\n if (hydrateResult && typeof (hydrateResult as Promise<void>).then === 'function') {\n ; (hydrateResult as Promise<void>)\n .then(() => runAfterHydration())\n .catch(error => this.traceError('subscriber:hydrate', error, context.store.$id))\n } else {\n runAfterHydration()\n }\n\n if (subscriber.subscriptions) {\n this.subscriptionDelivery(context, subscriber.subscriptions)\n }\n\n if (subscriber.storeMutationSubscription) {\n this.storeMutationSubscription(subscriber.storeMutationSubscription)\n }\n\n this.storeOnActionSubscription(subscriber)\n\n if (subscriber.resetStoreCallback) {\n this.addResetStoreCallback(context.store, subscriber.resetStoreCallback)\n }\n }\n\n private executeSubscriberSafely(context: PiniaPluginContext, subscriber: PluginSubscriber): void {\n try {\n this.executeSubscriber(context, subscriber)\n } catch (e) {\n this.traceError('subscriber:execute', e, context.store.$id)\n }\n }\n\n private initializeTracer() {\n if (this._options?.tracerHandler) {\n this._tracer = this._options.tracerHandler.createTracer(pluginName)\n }\n }\n\n /**\n * Invokes the plugin with the given Pinia plugin context, executing all relevant subscribers safely.\n * @param param0 The Pinia plugin context containing the store and options.\n * @param param0.store The Pinia store instance.\n * @param param0.options The options passed to the Pinia store.\n * @returns void\n */\n plugin({ store, options }: PiniaPluginContext) {\n if (!this._subscribers.length) {\n return\n }\n\n this.traceGroupStart(() => ({\n environment: this.defineCurrentEnvironment(),\n subscribers: this._subscribers,\n store,\n options\n }), store.$id)\n\n try {\n this._subscribers.forEach(\n subscriber => {\n const subscriberKey = this.defineSubscriberKey(subscriber, store)\n const execution = this.definePluginExecution(subscriber)\n\n if (\n this._subscribersDelivered.has(subscriberKey)\n || this._subscribersScheduled.has(subscriberKey)\n ) {\n return\n }\n\n if (!this.shouldInvokePlugin(execution)) {\n return\n }\n\n if (this.shouldScheduleAfterHydration(execution)) {\n this.queueSubscriberExecution({ store, options } as PiniaPluginContext, subscriber, subscriberKey)\n return\n }\n\n this.executeSubscriber({ store, options } as PiniaPluginContext, subscriber)\n }\n )\n\n this.rewriteResetStore({ store } as PiniaPluginContext, store.$state)\n this._storeRollbackSnapshotsHandler.initFromPluginContext({ store, options } as PiniaPluginContext)\n this.executeStoreOnActionSubscription(store)\n this.registerStoreCleanup(store)\n } catch (e) {\n this.traceError('plugin:invoke', e, store.$id)\n }\n this.traceGroupEnd(() => ({}), store.$id)\n }\n\n private queueSubscriberExecution(\n context: PiniaPluginContext,\n subscriber: PluginSubscriber,\n subscriberKey: string\n ): void {\n const scheduler = this.defineHydrationScheduler(subscriber)\n\n this._subscribersScheduled.add(subscriberKey)\n scheduler(() => {\n if (this._disposedStores.has(context.store)) {\n return\n }\n this._subscribersScheduled.delete(subscriberKey)\n this.executeSubscriberSafely(context, subscriber)\n })\n }\n\n private registerStoreCleanup(store: Store): void {\n if (typeof store.$dispose !== 'function') {\n return\n }\n\n const dispose = store.$dispose.bind(store)\n const scopedStore = store as AnyObject\n\n if (scopedStore.__piniaPluginSubscriptionDisposed) {\n return\n }\n\n scopedStore.__piniaPluginSubscriptionDisposed = true\n store.$dispose = () => {\n this._disposedStores.add(store)\n this.clearStoreTracking(store)\n this._storeRollbackSnapshotsHandler.clearStoreTracking(store)\n return dispose()\n }\n }\n\n private rewriteResetStore({ store }: PiniaPluginContext, initState: StateTree): void {\n const safeState = deepClone(initState)\n\n store.$reset = () => {\n this.traceGroupStart(() => ({ initialState: safeState }), store.$id, 'store:reset')\n try {\n this.executeResetStoreCallbacks(store)\n store.$patch(deepClone(safeState))\n } finally {\n this.traceGroupEnd(() => ({ initialState: safeState }), store.$id)\n }\n }\n }\n\n private shouldInvokePlugin(execution: Required<PluginExecutionOptions>): boolean {\n const currentEnvironment = this.defineCurrentEnvironment()\n\n return execution.environment === 'both' || execution.environment === currentEnvironment\n }\n\n private shouldScheduleAfterHydration(execution: Required<PluginExecutionOptions>): boolean {\n return this.defineCurrentEnvironment() === 'client' && execution.hydration === 'defer'\n }\n\n private storeOnActionSubscription(subscriber: PluginSubscriber): void {\n const { store, callback } = subscriber?.storeOnActionSubscription?.() ?? {}\n\n if (!store || !callback) {\n return\n }\n\n if (!this._onActionSubscriptions.has(store)) {\n this._onActionSubscriptions.set(store, new Set())\n }\n this._onActionSubscriptions.get(store)!.add(callback)\n this.executeStoreOnActionSubscription(store)\n }\n\n private storeMutationSubscription(subscription: StoreMutationSubscription): void {\n const { store, callback } = subscription()\n\n store.$subscribe((mutation: SubscriptionCallbackMutation<StateTree>) => {\n this.traceGroupStart(() => ({ mutation }), store.$id, 'store:mutation')\n try {\n callback(mutation)\n } finally {\n this.traceGroupEnd({}, store.$id)\n }\n })\n }\n\n private subscriptionDelivery(\n context: PiniaPluginContext,\n pluginSubscriptions: PluginSubscriptions\n ): void {\n Object.entries(pluginSubscriptions).forEach(([pluginName, pluginSubscription]) => {\n const subscriptionKey = this.defineSubscriptionKey(pluginName, context.store)\n const execution = this.definePluginExecution(pluginSubscription.subscription)\n\n if (\n this._subscriptionsDelivered.has(subscriptionKey)\n || this._subscriptionsScheduled.has(subscriptionKey)\n ) {\n return\n }\n\n if (!this.shouldInvokePlugin(execution)) {\n return\n }\n\n if (this.shouldScheduleAfterHydration(execution)) {\n const scheduler = this.defineHydrationScheduler(pluginSubscription.subscription)\n\n this._subscriptionsScheduled.add(subscriptionKey)\n scheduler(() => {\n if (this._disposedStores.has(context.store)) {\n return\n }\n this._subscriptionsScheduled.delete(subscriptionKey)\n this.subscriptionDeliverySafely(context, pluginName, pluginSubscription)\n })\n return\n }\n\n this.subscriptionDeliverySafely(context, pluginName, pluginSubscription)\n })\n }\n\n private subscriptionDeliverySafely(\n { store, options }: PiniaPluginContext,\n pluginName: string,\n pluginSubscription: PluginSubscriptionDefinition\n ): void {\n try {\n if (this._subscriptionsDelivered.has(this.defineSubscriptionKey(pluginName, store))) {\n return\n }\n\n const { subscription, subscriptionOptions, stores } = pluginSubscription\n\n this.trace('Subscription:delivery', store.$id, () => ({\n pluginName,\n subscription,\n subscriptionOptions\n }))\n\n const pluginOptions = {\n storeOptions: { ...(options?.storeOptions ?? {}), ...subscriptionOptions }\n }\n\n subscription.invoke(\n { store, options: { ...options, ...pluginOptions } } as PiniaPluginContext\n )\n this._subscriptionsDelivered.add(this.defineSubscriptionKey(pluginName, store))\n\n if (!isEmpty(stores)) {\n stores?.forEach(\n store => subscription.invoke({\n store,\n options: {\n ...options,\n ...pluginOptions,\n ...((store as AnyObject)?.storeOptions ?? {})\n }\n } as PiniaPluginContext)\n )\n }\n } catch (e) {\n this.traceError('subscription:delivery', e, store.$id)\n }\n }\n\n private traceGroupEnd(payload: TracePayload, scope: string): void {\n if (this._options?.tracerHandler) {\n this._options.tracerHandler.closeGroup({\n ...(typeof payload === 'function' ? payload() : (payload ?? {})),\n scope\n })\n }\n }\n\n private traceGroupStart(payload: TracePayload, scope: string, label?: string): void {\n if (this._options?.tracerHandler) {\n payload = (typeof payload === 'function' ? payload() : (payload ?? {}));\n this._options.tracerHandler.startGroup({\n ...payload,\n scope\n } as TraceEvent)\n this.trace(label ?? 'context', scope, payload)\n }\n }\n}"],"names":["deepClone","value","key","entryValue","item","clonedObject","createStateSnapshot","state","keys","clonedState","toRaw","defineAStoreSetupContexts","defineAStoreSetupContextsById","setupContextDisposeWrappedStores","registerSetupContextCleanupOnDispose","store","id","originalDispose","args","defineAStore","storeDefinition","options","storeOptions","defineAStoreSetup","defineAStoreOptionApi","defineAStoreCtx","setupContext","shouldStoreSetupContext","useStore","defineStore","deniedFirstChar","hasDeniedFirstChar","property","getDefineAStoreSetupContext","storeRecord","getEnhancedStore","ctx","enhancedStore","setEnhancedStore","getActionStoreKey","actionName","RollbackStateSnapshotsHandler","__publicField","action","stateKeys","actionFn","snapshotKey","error","rollbackSnapshotParams","suffix","stateSnapshot","TraceEmitter","payload","namespace","tracer","label","scope","isEmpty","pluginName","pluginSubscriptionClassName","pluginSubscriptionNamespace","className","defaultPluginExecution","defaultHydrationScheduler","callback","PluginSubscription","subscribers","storageKey","after","onError","subscriber","pluginName2","onActionSubscriptions","hasRollbackSnapshots","name","callbacks","callbacksLength","groupClosed","closeGroup","afterCallbacks","afterCallbacksLength","result","onErrorCallbacks","err","context","subscriberKey","hydrateResult","afterHydration","runAfterHydration","e","execution","scheduler","dispose","scopedStore","initState","safeState","currentEnvironment","subscription","mutation","pluginSubscriptions","pluginSubscription","subscriptionKey","subscriptionOptions","stores","pluginOptions","store2"],"mappings":";;;;;AAMO,SAASA,EAAaC,GAAa;AACtC,MAAI,OAAO,mBAAoB;AAC3B,QAAI;AACA,aAAO,gBAAgBA,CAAK;AAAA,IAChC,QAAQ;AAAA,IAER;AAGJ,MAAIA,MAAU,QAAQ,OAAOA,KAAU;AACnC,WA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aAAAA,EAAA,IAAsBM,KAAY,CAAA,GAC/D,KAAA,SAAM;SAGFN;AAAA,MAGA,OAAAI;AAAA,IACJ,CAAA,GAEA,KAAK,sBAAwBA,GAASJ,CAAG;AAAA,EACrC;AAGJ;"}
@@ -44,13 +44,13 @@ export default abstract class PluginSubscriber<Instance extends Store> implement
44
44
  * @param context The Pinia plugin context containing the store and options.
45
45
  * @returns A promise that resolves when the post-hydration process is complete, or void if synchronous.
46
46
  */
47
- afterHydration(context: PiniaPluginContext): void | Promise<void>;
47
+ afterHydration(_context: PiniaPluginContext): void | Promise<void>;
48
48
  /**
49
49
  * Called when the plugin subscriber needs to hydrate its state.
50
50
  * @param context The Pinia plugin context containing the store and options.
51
51
  * @returns A promise that resolves when the hydration process is complete, or void if synchronous.
52
52
  */
53
- hydrate(context: PiniaPluginContext): void | Promise<void>;
53
+ hydrate(_context: PiniaPluginContext): void | Promise<void>;
54
54
  /**
55
55
  * Invokes the plugin subscriber with the given context and optional tracer creation function.
56
56
  * @param context The Pinia plugin context containing the store and options.
@@ -60,6 +60,8 @@ export default class PluginSubscription extends TraceEmitter {
60
60
  * @returns void
61
61
  */
62
62
  private executeStoreOnActionSubscription;
63
+ private executeStoreOnActionAfterCallbacks;
64
+ private executeStoreOnActionOnErrorCallbacks;
63
65
  private executeSubscriber;
64
66
  private executeSubscriberSafely;
65
67
  private initializeTracer;
@@ -1,9 +1,9 @@
1
1
  export { default as PluginSubscriber } from '../core/PluginSubscriber';
2
+ export { default as PluginSubscription } from '../core/PluginSubscription';
2
3
  export { default as Store } from '../core/Store';
3
- export { CustomConsole } from '../system/log';
4
4
  export { isEmpty } from '../utils/validation';
5
- export type { Console, LogType, StyleDefinition, StyleDefinitionKeys, StyleDefinitions, ConsoleStyleDefinition, ConsoleStyleDefinitionKeys, ConsoleStyleDefinitions } from "../types";
6
- export type { TraceEvent, TraceEventMetadata, TraceFilter, TraceHandler, TraceLevel, TraceListener, TraceListenerRemover, TracePayload, TraceRedactOptions, TraceRegistry, TracerOptions, TracerRegistryOptions } from "../types/trace";
5
+ export { createPluginSubscriber } from '../factories/plugin-subscriber';
6
+ export { getDefineAStoreSetupContext, setEnhancedStore } from "../utils/store";
7
7
  export { createTracerRegistry } from "../factories/trace-registry";
8
8
  export { default as Tracer } from "../system/Tracer";
9
9
  export { createConsoleGroupTraceListener } from "../factories/console-trace-listener";