pinia-plugin-subscription 1.0.0-beta.11 → 1.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -5
- package/README.md +2 -0
- package/dist/chunks/{PluginSubscription-BbN48iuP.js → PluginSubscription-Bkqj4uSK.js} +189 -163
- package/dist/chunks/PluginSubscription-Bkqj4uSK.js.map +1 -0
- package/dist/core/PluginSubscription.d.ts +8 -0
- package/dist/helpers.js +326 -303
- package/dist/helpers.js.map +1 -1
- package/dist/pinia-plugin-subscription.js +2 -2
- package/dist/system/log/console-group.d.ts +8 -0
- package/dist/system/{log.d.ts → log/console.d.ts} +1 -11
- package/dist/system/log/index.d.ts +2 -0
- package/dist/system/log/log-trace.d.ts +8 -0
- package/dist/system/log/print-array.d.ts +7 -0
- package/dist/system/log/print-error.d.ts +6 -0
- package/dist/system/log/print-object.d.ts +1 -0
- package/dist/system/log/print-trace-payload.d.ts +1 -0
- package/dist/system/log/print-trace.d.ts +9 -0
- package/dist/system/log/trace-console.d.ts +9 -0
- package/dist/types/plugin.d.ts +7 -0
- package/dist/utils/store.d.ts +4 -1
- package/docs/authoring-plugins.md +22 -5
- package/docs/tracing.md +2 -0
- package/docs/using-plugins.md +12 -0
- package/package.json +3 -1
- package/dist/chunks/PluginSubscription-BbN48iuP.js.map +0 -1
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../src/core/PluginSubscriber.ts","../src/core/Store.ts","../src/factories/plugin-subscriber.ts","../src/system/Tracer.ts","../src/system/log.ts","../src/factories/console-trace-listener.ts","../src/factories/trace-listener.ts","../src/utils/environment.ts","../src/utils/redact.ts"],"sourcesContent":["import Store from \"./Store\";\nimport type { PiniaPluginContext, Store as PiniaStore } from \"pinia\";\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 { 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}","import type { PluginSubscriber, PluginSubscriberInvoke } from \"../types/plugin\";\n\n\n/**\n * Creates a new plugin subscriber with the given name, invoke function, and optional properties.\n * @param name - plugin name.\n * @param invoke - function to invoke for the plugin subscriber.\n * @param optionalProps - optional additional properties for the plugin subscriber.\n * @param {Function} optionalProps.afterHydration\n * @param {PluginExecutionOptions} optionalProps.execution\n * @param {Function} optionalProps.hydrate\n * @param {PluginHydrationScheduler} optionalProps.hydrationScheduler\n * @param {Function} optionalProps.resetStoreCallback\n * @param {StoreOnActionSubscription} optionalProps.storeOnActionSubscription\n * @param {StoreMutationSubscription} optionalProps.storeMutationSubscription\n * @param {PluginSubscriptions} optionalProps.subscriptions\n * @param \n * @returns A new plugin subscriber object.\n */\nexport function createPluginSubscriber(\n name: string,\n invoke: PluginSubscriberInvoke,\n optionalProps?: Omit<PluginSubscriber, \"name\" | \"invoke\">\n): PluginSubscriber {\n return {\n name,\n invoke,\n ...optionalProps,\n };\n}","import type { AnyObject } from '../types'\nimport type {\n TraceEvent,\n TraceEventMetadata,\n TraceGroupListener,\n TraceLevel,\n TraceListener,\n TracePayload,\n TracerOptions,\n} from '../types/trace'\n\nfunction resolvePayload(payload: TracePayload): AnyObject | undefined {\n if (typeof payload !== 'function') {\n return payload\n }\n\n try {\n return payload()\n } catch (error) {\n return { __tracePayloadError: error }\n }\n}\n\n/**\n * Emits structured trace events.\n *\n * Nothing is allocated when no listener matches:\n * the payload is a factory resolved only once a consumer is known.\n */\nexport default class Tracer {\n private readonly _listeners: Array<TraceListener | TraceGroupListener> = []\n private readonly _redactor?: (payload: AnyObject) => AnyObject\n private _scope?: string\n private readonly _source: string\n\n constructor(source: string, listeners: Array<TraceListener | TraceGroupListener>, options: TracerOptions = {}) {\n this._redactor = options.redactor\n this._scope = options.scope\n this._source = source\n this._listeners = listeners\n }\n\n get scope(): string | undefined {\n return this._scope\n }\n\n set scope(scope: string | undefined) {\n this._scope = scope\n }\n\n get source(): string {\n return this._source\n }\n\n debug(label: string, namespace: string, payload?: TracePayload, scope?: string): void {\n this.emit('debug', label, namespace, payload, scope)\n }\n\n /** Relays the error to matching listeners, or reports it when none match. */\n error(label: string, namespace: string, error: unknown, payload?: TracePayload, scope?: string): void {\n this.emit('error', label, namespace, payload, scope, error)\n }\n\n private resolveAndRedact(payload: TracePayload): AnyObject | undefined {\n const resolved = resolvePayload(payload)\n\n if (!this._redactor || resolved === undefined) {\n return resolved\n }\n\n try {\n return this._redactor(resolved)\n } catch (error) {\n // never leak the raw payload when redaction fails\n return { __traceRedactionError: error instanceof Error ? error.message : String(error) }\n }\n }\n\n private matchListeners(level: TraceLevel, label: string, namespace: string, scope?: string) {\n const metadata: TraceEventMetadata = {\n label,\n level,\n namespace,\n scope: scope ?? this._scope,\n source: this._source\n }\n const matched: Array<TraceListener | TraceGroupListener> = []\n\n for (const listener of this._listeners) {\n try {\n if (listener.filter(metadata)) {\n matched.push(listener)\n }\n } catch (error) {\n console.error('Error in trace listener filter:', error)\n }\n }\n\n return { matched, metadata }\n }\n\n private emit(\n level: TraceLevel,\n label: string,\n namespace: string,\n payload?: TracePayload,\n scope?: string,\n error?: unknown\n ): void {\n const { matched, metadata } = this._listeners.length === 0\n ? { matched: [], metadata: undefined }\n : this.matchListeners(level, label, namespace, scope)\n\n if (!metadata || matched.length === 0) {\n if (level === 'error') {\n console.error('Unhandled error trace event:', error)\n }\n return\n }\n\n const event: TraceEvent = {\n ...metadata,\n ...(error !== undefined && { error }),\n ...(payload !== undefined && { payload: this.resolveAndRedact(payload) }),\n timestamp: Date.now()\n }\n\n for (const listener of matched) {\n try {\n listener.handler(event)\n } catch (error) {\n // a faulty listener must never break the traced code\n console.error('Error in trace listener:', error)\n }\n }\n }\n}\n","import { pluginName } from '../utils/constants'\nimport type { Console, LogType, StyleDefinition, StyleDefinitions } from '../types/log'\nimport type { ConsoleTraceEvent, ConsoleTraceEventArgs, TraceEvent } from '../types/trace'\nimport type { Store } from 'pinia'\nimport { isRef } from 'vue'\n\n\nconst errorColor = '#f86f63'\nconst style = (bgColor: string, color: string = 'white') =>\n `background-color: ${bgColor}; color: ${color}; padding: 1px; margin-right: 5px; font-size: 12px`\n\nfunction getPrintablePayload(trace: TraceEvent) {\n const { payload } = trace\n if (payload && Object.keys(payload).length > 0) {\n return Object.keys(payload).reduce((acc, key) => {\n if (!['groupId', 'label', 'namespace', 'scope', 'source'].includes(key)) {\n acc[key] = isRef(payload[key]) ? payload[key].value : payload[key]\n }\n return acc\n }, {} as Record<string, unknown>)\n }\n return undefined\n}\n\nexport function printObject(label: string, payload: object, groupType: 'collapsed' | 'expanded' | 'none' = 'collapsed', source?: string) {\n if (payload instanceof Error) {\n console.groupCollapsed(\n '%c%s',\n `color: ${errorColor}; padding: 1px; margin-right: 5px; font-size: 11px`,\n `[ ${payload.name} ] ${payload.message}`,\n )\n if (payload.cause) {\n console.log('cause:', payload.cause)\n }\n const stack = payload.stack?.split('\\n')\n if (stack) {\n stack.forEach(line => {\n const trace = line.split('@')\n if (Array.isArray(trace)) {\n console.log(trace[0], trace[1])\n }\n })\n }\n console.groupEnd()\n }\n\n const isArray = Array.isArray(payload)\n const isEmpty = isArray ? payload.length === 0 : Object.keys(payload).length === 0\n if (isEmpty) {\n console.log(\n '%c%s',\n `color: ${errorColor}; padding: 1px; margin-right: 5px; font-size: 10px`,\n `[ ${label} ] Empty`\n )\n return\n }\n if (groupType === 'none' || (isArray && typeof payload[0] !== 'object')) {\n console.log(\n '%c%s',\n 'color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px',\n `[ ${label} ]`, payload\n )\n return\n }\n\n const styles: Record<string, string> = {\n options: '📚 ',\n store: '🏪 ',\n subscribers: '🧩 ',\n 'hooks subscriptions': '🔗 '\n }\n const icon = styles[label] ?? ''\n\n if (groupType === 'collapsed') {\n if (source) {\n console.groupCollapsed(\n '%c%s',\n 'color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px',\n `${icon} ${label}`, source)\n } else {\n console.groupCollapsed(\n '%c%s',\n 'color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px',\n `[ ${icon}${label} ]`)\n }\n } else if (groupType === 'expanded') {\n console.group(\n '%c%s',\n 'color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px',\n `[ ${icon} ${label} ]`)\n }\n\n if (isArray && typeof payload[0] === 'object') {\n payload.forEach((item: any) => {\n if (item.name) {\n printObject(item.name, item)\n } else if (item._id) {\n printObject(item._id, item)\n } else {\n console.dir(item)\n }\n })\n } else {\n let emptyKeys: string[] = []\n Object.keys(payload).forEach(key => {\n if (key === 'groupId') {\n return\n }\n\n const value = (payload as Record<string, unknown>)[key]\n if (typeof value === 'object') {\n if (Array.isArray(value)) {\n if (typeof value[0] === 'object') {\n printObject(key, value, 'expanded')\n } else {\n console.log(\n '%c%s',\n 'color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ]`, isRef(value) ? value.value : value)\n }\n } else if (value instanceof Error) {\n console.log(key, { name: value.name, message: value.message, stack: value.stack })\n } else {\n printObject(key, Object.assign({}, value), 'expanded')\n }\n } else {\n if (!value) {\n emptyKeys.push(key)\n } else {\n const typeOfValue = typeof value\n console.log(\n '%c%s',\n 'color: #b0fa05; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ]`, typeOfValue === 'function' ? typeOfValue : value\n )\n }\n }\n })\n if (emptyKeys.length) {\n console.log(\n '%c%s',\n 'color: #f86f63; font-size: 9px',\n `[ Empty properties ]`, emptyKeys\n )\n }\n }\n console.groupEnd()\n}\n\nfunction printTrace(trace: TraceEvent) {\n const payload = getPrintablePayload(trace)\n if (payload && Object.keys(payload).length > 0) {\n printObject(trace.label, payload, 'collapsed', trace.source)\n return\n }\n console.log(\n '%c%s',\n 'color: #f8f89f; padding: 1px; margin-right: 5px; font-size: 11px',\n trace.label, trace.source,\n )\n}\n\nfunction printTracePayload(tracePayload: Record<string, unknown>) {\n Object.keys(tracePayload).forEach((key: string) => {\n if (['groupId', 'label', 'namespace', 'scope', 'source'].includes(key)) {\n return\n }\n const arg = tracePayload[key]\n if (!arg) {\n console.log(\n '%c%s',\n 'color: #f86f63; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ] ${arg}`\n )\n return\n }\n\n switch (typeof arg) {\n case 'string': case 'number':\n console.log(\n '%c%s',\n 'color: #fafa05; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ]`, arg\n )\n break;\n case 'object':\n switch (key) {\n case 'mutation':\n console.groupCollapsed('[mutation]')\n console.dir(arg)\n console.groupEnd()\n break;\n case 'options':\n printObject(key, (arg as { storeOptions?: unknown })?.storeOptions ?? arg)\n break;\n case 'payload':\n printTracePayload(arg as Record<string, unknown>)\n break;\n case 'store':\n printObject(key, {\n $state: (arg as Store)['$state'],\n $actions: Object.keys(arg).reduce((acc, curr) => {\n if ((curr.startsWith('$') && !['$id', '$state'].includes(curr)) || curr.startsWith('_')) {\n return acc\n }\n\n const value = (arg as Record<string, unknown>)[curr]\n\n if (typeof value !== 'function') {\n if (!acc['computed']) {\n acc['computed'] = []\n }\n (acc['computed'] as string[]).push(curr)\n\n } else {\n acc[curr] = (arg as Record<string, unknown>)[curr]\n }\n\n return acc\n }, {} as Record<string, unknown>)\n })\n break;\n default:\n printObject(key, arg)\n }\n break;\n case 'function':\n console.dir(arg)\n break;\n default:\n console.info(key, arg)\n }\n })\n}\nexport function log(logStyle: string, args: any) {\n if (!logStyle) {\n throw new Error('Style instructions are required')\n }\n\n console.log(\n '%c%s',\n logStyle,\n args.shift(),\n ...args\n )\n}\n\n\nexport function logTrace(logStyle: string, args: any, pluginName: string) {\n if (!logStyle) {\n throw new Error('Style instructions are required')\n }\n\n const label = args.shift()\n const event = args[0]\n\n\n if (!event?.payload || Object.keys(event.payload).length === 0) {\n console.log(\n '%c%s',\n logStyle,\n `${event?.source === pluginName ? (event?.label ?? event?.namespace) : label}`,\n event?.source\n )\n return\n }\n\n console.groupCollapsed(\n '%c%s',\n logStyle,\n `${label}\n`, event?.source\n )\n\n args.forEach((arg: any) => {\n switch (typeof arg) {\n case 'string':\n console.info(arg)\n break;\n case 'object':\n if (Array.isArray(arg)) {\n console.table(arg)\n } else {\n printTracePayload(arg)\n }\n break;\n case 'function':\n console.dir(arg)\n break;\n default:\n console.info(arg)\n }\n })\n\n\n\n console.groupEnd()\n}\n\nexport abstract class CustomConsole implements Console {\n protected _bgColor: string = 'transparent'\n protected _color: string = '#f2f286'\n protected _icon: string = '🍍⚡'\n protected _errorBgColor: string = '#d24545'\n protected _errorColor: string = 'white'\n protected _errorIcon: string = '🍍⚠️'\n protected _pluginName?: string\n protected _styles: StyleDefinitions = {\n error: { bgColor: this._errorBgColor, color: this._errorColor, icon: this._errorIcon },\n info: { bgColor: this._bgColor, color: this._color, icon: this._icon }\n }\n\n protected formatMessage(message: string, icon: string): string {\n return this._pluginName ? ` [${icon} ${this._pluginName}] \n ${message} \n` : message\n }\n\n protected generateStyle(styleDefinition: StyleDefinition): string {\n return style(styleDefinition.bgColor, styleDefinition.color)\n }\n\n protected getStyleDefinition(messageType?: LogType): StyleDefinition {\n return this._styles[messageType ?? 'info']\n }\n\n log(...args: any) {\n this.useLog(\n this.getStyleDefinition(),\n args\n )\n }\n\n error(...args: any) {\n const logType = 'error'\n this.useLog(\n this.getStyleDefinition(logType),\n args\n )\n }\n\n protected rebuildArgs(args: string | any[]): any[] {\n if (typeof args === 'string') {\n return [args]\n }\n\n if (Array.isArray(args)) {\n return [args.shift(), ...args]\n }\n\n return [args]\n }\n\n protected useLog(styleDefinition: StyleDefinition, args: any) {\n log(\n this.generateStyle(styleDefinition),\n this.rebuildArgs(args)\n )\n }\n}\n\nexport class TraceConsole extends CustomConsole {\n protected _pluginName: string = pluginName\n\n constructor(pluginName?: string) {\n super()\n if (pluginName) {\n this._pluginName = pluginName\n }\n }\n\n\n logGroup(groups: ConsoleTraceEvent[]) {\n const firstEntry = groups.shift()\n const context = firstEntry?.[1] as ConsoleTraceEventArgs\n\n console.groupCollapsed(\n '%c%s',\n 'color: #87e47f; padding: 1px; margin-right: 5px; font-size: 11px; font-family: arial',\n `🍍 ${context?.label ?? context?.namespace}`, `[${context?.scope}]`\n )\n if (context?.payload) {\n printTracePayload(context.payload)\n }\n console.groupCollapsed(\n '%c%s',\n 'color: #f1f6b7; padding: 1px; margin-right: 5px; font-size: 11px',\n `[ ✨ traces ]`\n )\n groups.forEach(group => printTrace(group[1] as TraceEvent))\n console.groupEnd()\n console.groupEnd()\n }\n\n protected useLog(styleDefinition: StyleDefinition, args: any) {\n logTrace(\n this.generateStyle(styleDefinition),\n this.rebuildArgs(args),\n this._pluginName\n )\n }\n}","import { TraceConsole } from '../system/log'\n\nimport type { Console } from '../types/log'\nimport type {\n ConsoleTraceEvent, ConsoleTraceEventArgs, TraceEvent, TraceListenerGroupBy, ConsoleTraceGroupListener\n} from '../types/trace'\n\n\n/**\n * Builds the console arguments from a trace event.\n * @param event The trace event to build console arguments from.\n * @returns An array containing the formatted trace label and the sanitized event data.\n */\nfunction buildConsoleArgsFromEvent(event: TraceEvent): ConsoleTraceEvent {\n const sanitizedEvent = Object.keys(event).reduce((acc, curr) => {\n if (curr !== 'level' && curr !== 'timestamp') {\n acc[curr] = event[curr as keyof ConsoleTraceEventArgs]\n }\n return acc\n }, {} as Record<string, unknown>)\n\n return [formatTraceLabel(event), sanitizedEvent as ConsoleTraceEventArgs]\n}\n\nfunction formatTraceLabel(event: TraceEvent): string {\n return event.scope\n ? `${event.label} [${event.scope}]`\n : `${event.label}`\n}\n\nfunction log(target: Console, event: TraceEvent): void {\n const consoleMethod = event.level === 'error' ? 'error' : 'log'\n target[consoleMethod](...buildConsoleArgsFromEvent(event))\n}\n\n/**\n * Creates a console trace group listener that groups trace events by the specified key.\n * @param groupBy The key of the trace event metadata to group by.\n * @returns A console trace group listener configured to group trace events by the specified key.\n */\nexport function createConsoleGroupTraceListener(groupBy: TraceListenerGroupBy = 'scope'): ConsoleTraceGroupListener {\n const target = new TraceConsole()\n const groups = new Map<string, ConsoleTraceEvent[]>()\n // Overlapping starts for the same key (e.g. concurrent async mutations of a store) share one group\n const openCounts = new Map<string, number>()\n\n\n function createGroup(key: string) {\n if (!groups.has(key)) {\n groups.set(key, [])\n }\n openCounts.set(key, (openCounts.get(key) ?? 0) + 1)\n }\n\n function logGroup(key: string): void {\n const group = groups.get(key)\n\n if (!group) {\n target.error(`No group found for key \"${key}\"`)\n return\n }\n\n const remaining = (openCounts.get(key) ?? 1) - 1\n if (remaining > 0) {\n openCounts.set(key, remaining)\n return\n }\n\n if (group.length) { target.logGroup(group) }\n groups.delete(key)\n openCounts.delete(key)\n }\n\n return {\n createGroup,\n logGroup,\n handler(event): void {\n const groupKey = (event?.payload?.groupId ?? event[groupBy]) as string\n if (!groups.has(groupKey)) {\n log(target, event)\n return\n }\n\n groups.get(groupKey)?.push(buildConsoleArgsFromEvent(event))\n }\n }\n}\n\n\n","import { createConsoleGroupTraceListener } from \"./console-trace-listener\"\nimport { pluginName, pluginSubscriptionNamespace } from \"../utils/constants\"\n\nimport type {\n TraceEventMetadata,\n TraceFilter,\n TraceFilterFactoryCriterion,\n TraceFilterFactoryParam,\n TraceGroupListener\n} from \"../types/trace\"\n\n\nfunction createFilter(criteria: TraceFilterFactoryCriterion[], context: boolean = true, mode: 'every' | 'some') {\n return (event: TraceEventMetadata) => {\n return criteria[mode](({ comparator = 'equals', target, value }) => {\n if (target === 'namespace' && context && isPluginSubscription(event)) {\n return true\n }\n\n const eventValue = event[target]\n if (typeof eventValue !== 'string') return false\n\n let result = false\n switch (comparator) {\n case 'equals':\n result = eventValue === value\n break\n case 'contains':\n result = eventValue.includes(value)\n break\n case 'startsWith':\n result = eventValue.startsWith(value)\n break\n case 'endsWith':\n result = eventValue.endsWith(value)\n break\n default:\n result = false\n break\n }\n return result\n })\n }\n}\n\n/**\n * Creates a trace group listener with optional filtering.\n * @param listenerDef The listener definition or filter criteria for the trace group listener.\n * @param context Print the plugin context (subscribers, store, options, and traces) to the console.. Defaults to true.\n * @param filterMode The mode to apply when evaluating multiple filter criteria: 'every' or 'some'.\n * @param groupBy The key of the trace event metadata to group by.\n * @returns A trace listener configured with group handling and filtering.\n */\nexport function createTraceGroupListener(\n listenerDef: TraceFilterFactoryParam | TraceFilterFactoryCriterion[],\n context: boolean = true,\n filterMode: 'every' | 'some' = 'every',\n groupBy: keyof TraceEventMetadata = 'scope'\n) {\n return {\n groupBy,\n ...createConsoleGroupTraceListener(groupBy),\n ...createTraceFilter(listenerDef, context, filterMode)\n } as TraceGroupListener\n\n}\n\nfunction createTraceFilter(\n listenerDef: TraceFilterFactoryParam | TraceFilterFactoryCriterion[],\n context: boolean = true,\n filterMode: 'every' | 'some' = 'every'\n): TraceFilterFactoryParam & { filter: TraceFilter } {\n if (Array.isArray(listenerDef)) {\n return { filter: createFilter(listenerDef, context, filterMode) }\n }\n\n // Copy: the caller's definition must never be mutated.\n return {\n ...listenerDef,\n filter: Array.isArray(listenerDef.filter)\n ? createFilter(listenerDef.filter, context, filterMode)\n : listenerDef.filter\n }\n}\n\nfunction isPluginSubscription(event: TraceEventMetadata): boolean {\n return event?.source === pluginName && (!event?.namespace || event.namespace.startsWith(pluginSubscriptionNamespace))\n}","declare const process: { env: { NODE_ENV?: string } } | undefined\n\n/**\n * Tells whether the host application is built for production.\n * The literal `process.env.NODE_ENV` expression is kept on purpose: consumer bundlers\n * (Vite, webpack, Nuxt...) replace it statically. Without a bundler `process` may be\n * undefined, in which case the environment is not considered production.\n */\nexport function isProductionEnvironment(): boolean {\n try {\n return process!.env.NODE_ENV === 'production'\n } catch {\n return false\n }\n}\n","import type { AnyObject } from '../types'\nimport type { TraceRedactOptions } from '../types/trace'\n\nexport const DEFAULT_REDACTED_VALUE = '[REDACTED]'\n\n/**\n * Keys masked by default when redaction is enabled.\n * Matching is a case-insensitive \"contains\", so `accessToken` or `user_password` are masked too.\n */\nexport const defaultRedactedKeys: readonly RegExp[] = [\n /pass(word|wd|phrase|code)|^pwd/i,\n /secret/i,\n /token/i,\n /authorization/i,\n /api[-_]?key/i,\n /(private|encryption|signing|secret)[-_]?key/i,\n /credential/i,\n /cookie/i,\n /cipher/i,\n]\n\nconst MAX_DEPTH = 12\n\ntype KeyMatcher = (key: string) => boolean\n\nfunction createKeyMatcher(keys: ReadonlyArray<string | RegExp>): KeyMatcher {\n const exact = new Set<string>()\n const patterns: RegExp[] = []\n\n for (const key of keys) {\n if (typeof key === 'string') {\n exact.add(key.toLowerCase())\n } else {\n // a global/sticky regexp is stateful: rebuild it without those flags\n patterns.push(new RegExp(key.source, key.flags.replace(/[gy]/g, '')))\n }\n }\n\n return (key: string) => exact.has(key.toLowerCase()) || patterns.some(pattern => pattern.test(key))\n}\n\nfunction isTraversable(value: unknown): value is object {\n if (value === null || typeof value !== 'object') {\n return false\n }\n\n return !(\n value instanceof Date\n || value instanceof RegExp\n || value instanceof Error\n || value instanceof Promise\n || value instanceof WeakMap\n || value instanceof WeakSet\n )\n}\n\n/**\n * Creates a function returning a redacted copy of a trace payload.\n * The original value (usually the live store state) is never mutated.\n * @param options Redaction options, or `true` to use the default keys.\n * @returns The redaction function.\n */\nexport function createRedactor(options: TraceRedactOptions | true = true): (payload: AnyObject) => AnyObject {\n const { includeDefaults = true, keys = [], replacement = DEFAULT_REDACTED_VALUE } =\n options === true ? {} : options\n const isSensitive = createKeyMatcher([...(includeDefaults ? defaultRedactedKeys : []), ...keys])\n\n function redact(value: unknown, seen: WeakMap<object, unknown>, depth: number): unknown {\n if (!isTraversable(value)) {\n return value\n }\n\n const cached = seen.get(value)\n if (cached !== undefined) {\n return cached\n }\n\n if (depth >= MAX_DEPTH) {\n return '[MaxDepth]'\n }\n\n if (value instanceof Map) {\n const copy = new Map()\n seen.set(value, copy)\n value.forEach((entry, key) => {\n copy.set(key, typeof key === 'string' && isSensitive(key) ? replacement : redact(entry, seen, depth + 1))\n })\n return copy\n }\n\n if (value instanceof Set) {\n const copy = new Set()\n seen.set(value, copy)\n value.forEach(entry => copy.add(redact(entry, seen, depth + 1)))\n return copy\n }\n\n if (Array.isArray(value)) {\n const copy: unknown[] = []\n seen.set(value, copy)\n value.forEach(entry => copy.push(redact(entry, seen, depth + 1)))\n return copy\n }\n\n const copy: Record<string, unknown> = {}\n seen.set(value, copy)\n for (const key of Object.keys(value)) {\n const redactedValue = isSensitive(key)\n ? replacement\n : redact((value as Record<string, unknown>)[key], seen, depth + 1)\n Object.defineProperty(copy, key, {\n configurable: true,\n enumerable: true,\n value: redactedValue,\n writable: true\n })\n }\n return copy\n }\n\n return payload => redact(payload, new WeakMap(), 0) as AnyObject\n}\n"],"names":["PluginSubscriber","pluginName","createInstanceFunction","__publicField","options","subscriptions","_context","store","createTracer","Store","TraceEmitter","ctx","getDefineAStoreSetupContext","setEnhancedStore","onAction","state","storeSubscribe","name","value","isRef","ref","toRef","subscription","optionName","propertyName","isEmpty","property","hasDeniedFirstChar","requiredKey","createPluginSubscriber","invoke","optionalProps","resolvePayload","payload","error","source","listeners","scope","label","namespace","resolved","level","metadata","matched","listener","event","error2","style","bgColor","color","getPrintablePayload","trace","acc","key","printObject","groupType","errorColor","stack","line","isArray","icon","item","emptyKeys","typeOfValue","printTrace","printTracePayload","tracePayload","arg","curr","log$1","logStyle","args","logTrace","pluginName2","CustomConsole","message","styleDefinition","messageType","log","TraceConsole","groups","context","group","buildConsoleArgsFromEvent","sanitizedEvent","formatTraceLabel","target","consoleMethod","createConsoleGroupTraceListener","groupBy","createGroup","openCounts","logGroup","remaining","groupKey","criteria","mode","comparator","isPluginSubscription","eventValue","result","createTraceGroupListener","filterMode","listenerDef","createTraceFilter","createFilter","pluginSubscriptionNamespace","isProductionEnvironment","DEFAULT_REDACTED_VALUE","defaultRedactedKeys","MAX_DEPTH","createKeyMatcher","keys","exact","patterns","pattern","isTraversable","createRedactor","replacement","isSensitive","includeDefaults","seen","depth","cached","copy2","entry","redact","copy","redactedValue","noop","createTracerRegistry","enabled","redactor","addListener","listenerGroup","index","addScopesListener","scopes","clearTraceListeners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3G,CAAA;AAAA,MACpB,cAAc,CAAAE,GAAA/B,IAAc,CAAA,UAAW2I,EAAO5G,MAAiB,EAAA,UAAAiG,GAAA,GAAAhI,EAAA,CAAA;AAAA,MAC/D,mBAAA4I;AAAA,MACJ,YAAA,CAAA/G,MAAA2G,EAAA,eAAA3G,CAAA;AAAA,IAEA;AAAA,IACI,mBAAA+G;AAAA,EACA;AACA;"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../src/core/PluginSubscriber.ts","../src/core/Store.ts","../src/factories/plugin-subscriber.ts","../src/system/Tracer.ts","../src/system/log/index.ts","../src/system/log/console.ts","../src/system/log/console-group.ts","../src/system/log/print-array.ts","../src/system/log/print-error.ts","../src/system/log/print-object.ts","../src/system/log/print-trace-payload.ts","../src/system/log/log-trace.ts","../src/system/log/print-trace.ts","../src/system/log/trace-console.ts","../src/factories/console-trace-listener.ts","../src/factories/trace-listener.ts","../src/utils/environment.ts","../src/utils/redact.ts"],"sourcesContent":["import Store from \"./Store\";\nimport type { PiniaPluginContext, Store as PiniaStore } from \"pinia\";\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 { 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}","import type { PluginSubscriber, PluginSubscriberInvoke } from \"../types/plugin\";\n\n\n/**\n * Creates a new plugin subscriber with the given name, invoke function, and optional properties.\n * @param name - plugin name.\n * @param invoke - function to invoke for the plugin subscriber.\n * @param optionalProps - optional additional properties for the plugin subscriber.\n * @param {Function} optionalProps.afterHydration\n * @param {PluginExecutionOptions} optionalProps.execution\n * @param {Function} optionalProps.hydrate\n * @param {PluginHydrationScheduler} optionalProps.hydrationScheduler\n * @param {Function} optionalProps.resetStoreCallback\n * @param {StoreOnActionSubscription} optionalProps.storeOnActionSubscription\n * @param {StoreMutationSubscription} optionalProps.storeMutationSubscription\n * @param {PluginSubscriptions} optionalProps.subscriptions\n * @param \n * @returns A new plugin subscriber object.\n */\nexport function createPluginSubscriber(\n name: string,\n invoke: PluginSubscriberInvoke,\n optionalProps?: Omit<PluginSubscriber, \"name\" | \"invoke\">\n): PluginSubscriber {\n return {\n name,\n invoke,\n ...optionalProps,\n };\n}","import type { AnyObject } from '../types'\nimport type {\n TraceEvent,\n TraceEventMetadata,\n TraceGroupListener,\n TraceLevel,\n TraceListener,\n TracePayload,\n TracerOptions,\n} from '../types/trace'\n\nfunction resolvePayload(payload: TracePayload): AnyObject | undefined {\n if (typeof payload !== 'function') {\n return payload\n }\n\n try {\n return payload()\n } catch (error) {\n return { __tracePayloadError: error }\n }\n}\n\n/**\n * Emits structured trace events.\n *\n * Nothing is allocated when no listener matches:\n * the payload is a factory resolved only once a consumer is known.\n */\nexport default class Tracer {\n private readonly _listeners: Array<TraceListener | TraceGroupListener> = []\n private readonly _redactor?: (payload: AnyObject) => AnyObject\n private _scope?: string\n private readonly _source: string\n\n constructor(source: string, listeners: Array<TraceListener | TraceGroupListener>, options: TracerOptions = {}) {\n this._redactor = options.redactor\n this._scope = options.scope\n this._source = source\n this._listeners = listeners\n }\n\n get scope(): string | undefined {\n return this._scope\n }\n\n set scope(scope: string | undefined) {\n this._scope = scope\n }\n\n get source(): string {\n return this._source\n }\n\n debug(label: string, namespace: string, payload?: TracePayload, scope?: string): void {\n this.emit('debug', label, namespace, payload, scope)\n }\n\n /** Relays the error to matching listeners, or reports it when none match. */\n error(label: string, namespace: string, error: unknown, payload?: TracePayload, scope?: string): void {\n this.emit('error', label, namespace, payload, scope, error)\n }\n\n private resolveAndRedact(payload: TracePayload): AnyObject | undefined {\n const resolved = resolvePayload(payload)\n\n if (!this._redactor || resolved === undefined) {\n return resolved\n }\n\n try {\n return this._redactor(resolved)\n } catch (error) {\n // never leak the raw payload when redaction fails\n return { __traceRedactionError: error instanceof Error ? error.message : String(error) }\n }\n }\n\n private matchListeners(level: TraceLevel, label: string, namespace: string, scope?: string) {\n const metadata: TraceEventMetadata = {\n label,\n level,\n namespace,\n scope: scope ?? this._scope,\n source: this._source\n }\n const matched: Array<TraceListener | TraceGroupListener> = []\n\n for (const listener of this._listeners) {\n try {\n if (listener.filter(metadata)) {\n matched.push(listener)\n }\n } catch (error) {\n console.error('Error in trace listener filter:', error)\n }\n }\n\n return { matched, metadata }\n }\n\n private emit(\n level: TraceLevel,\n label: string,\n namespace: string,\n payload?: TracePayload,\n scope?: string,\n error?: unknown\n ): void {\n const { matched, metadata } = this._listeners.length === 0\n ? { matched: [], metadata: undefined }\n : this.matchListeners(level, label, namespace, scope)\n\n if (!metadata || matched.length === 0) {\n if (level === 'error') {\n console.error('Unhandled error trace event:', error)\n }\n return\n }\n\n const event: TraceEvent = {\n ...metadata,\n ...(error !== undefined && { error }),\n ...(payload !== undefined && { payload: this.resolveAndRedact(payload) }),\n timestamp: Date.now()\n }\n\n for (const listener of matched) {\n try {\n listener.handler(event)\n } catch (error) {\n // a faulty listener must never break the traced code\n console.error('Error in trace listener:', error)\n }\n }\n }\n}\n","export function log(logStyle: string, args: any) {\n if (!logStyle) {\n throw new Error('Style instructions are required')\n }\n\n console.log(\n '%c%s',\n logStyle,\n args.shift(),\n ...args\n )\n}\n\nexport const getStyleDefinition = (bgColor: string, color: string = 'white') =>\n `background-color: ${bgColor}; color: ${color}; padding: 1px; margin-right: 5px; font-size: 12px`","import { getStyleDefinition, log } from './index'\nimport type { Console, LogType, StyleDefinition, StyleDefinitions } from '../../types/log'\n\n\nexport abstract class CustomConsole implements Console {\n protected _bgColor: string = 'transparent'\n protected _color: string = '#f2f286'\n protected _icon: string = '🍍⚡'\n protected _errorBgColor: string = '#d24545'\n protected _errorColor: string = 'white'\n protected _errorIcon: string = '🍍⚠️'\n protected _pluginName?: string\n protected _styles: StyleDefinitions = {\n error: { bgColor: this._errorBgColor, color: this._errorColor, icon: this._errorIcon },\n info: { bgColor: this._bgColor, color: this._color, icon: this._icon }\n }\n\n protected formatMessage(message: string, icon: string): string {\n return this._pluginName ? ` [${icon} ${this._pluginName}] \n ${message} \n` : message\n }\n\n protected generateStyle(styleDefinition: StyleDefinition): string {\n return getStyleDefinition(styleDefinition.bgColor, styleDefinition.color)\n }\n\n protected getStyleDefinition(messageType?: LogType): StyleDefinition {\n return this._styles[messageType ?? 'info']\n }\n\n log(...args: any) {\n this.useLog(\n this.getStyleDefinition(),\n args\n )\n }\n\n error(...args: any) {\n const logType = 'error'\n this.useLog(\n this.getStyleDefinition(logType),\n args\n )\n }\n\n protected rebuildArgs(args: string | any[]): any[] {\n if (typeof args === 'string') {\n return [args]\n }\n\n if (Array.isArray(args)) {\n return [args.shift(), ...args]\n }\n\n return [args]\n }\n\n protected useLog(styleDefinition: StyleDefinition, args: any) {\n log(\n this.generateStyle(styleDefinition),\n this.rebuildArgs(args)\n )\n }\n}","/**\n * Utility function to create console groups with different styles.\n * @param groupType The type of console group: 'collapsed', 'expanded', or 'none'.\n * @param args The arguments to be passed to the console group.\n * @returns void\n * \n */\nexport function consoleGroup(groupType: 'collapsed' | 'expanded' | 'none' = 'none', ...args: any[]) {\n if (groupType === 'collapsed') {\n console.groupCollapsed(\n '%c%s',\n 'color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px',\n ...args)\n } else if (groupType === 'expanded') {\n console.group(\n '%c%s',\n 'color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px',\n ...args)\n }\n}","/**\n * Prints an array to the console with a specific label and group type.\n * @param label The label to display for the array.\n * @param payload The array to print.\n * @param icon An optional icon to display alongside the label.\n */\nexport function printArray(\n payload: any[],\n label?: string,\n icon: string = ''\n) {\n if (typeof payload[0] !== 'object') {\n const printablePayload = (typeof payload[0] === 'string') ? payload.join(', ') : payload\n if (label) {\n console.log(\n '%c%s',\n 'color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px',\n `[ ${icon}${label} ]`, printablePayload\n )\n } else {\n console.log(printablePayload)\n }\n }\n\n if (typeof payload[0] === 'object') {\n if (payload[0]?.name) {\n console.log(payload.reduce((acc, item) => {\n if (acc) { acc += '\\r\\n' }\n acc += `- ${item.name}`\n return acc\n }, ''))\n } else if (payload[0]?._id) {\n console.log(payload.reduce((acc, item) => {\n if (acc) { acc += '\\r\\n' }\n acc += `- ${item._id}`\n return acc\n }, ''))\n } else {\n payload.forEach((item: any) => {\n console.dir(item)\n })\n }\n }\n}","export const errorColor = '#f86f63'\n\n/**\n * Prints an error to the console with a specific format.\n * @param payload The error object to print.\n */\nexport function printError(payload: Error) {\n console.groupCollapsed(\n '%c%s',\n `color: ${errorColor}; padding: 1px; margin-right: 5px; font-size: 11px`,\n `[ ${payload.name} ] ${payload.message}`,\n )\n if (payload.cause) {\n console.log('cause:', payload.cause)\n }\n const stack = payload.stack?.split('\\n')\n if (stack) {\n stack.forEach(line => {\n const trace = line.split('@')\n if (Array.isArray(trace)) {\n console.log(trace[0], trace[1])\n }\n })\n }\n console.groupEnd()\n}","import { isRef } from 'vue'\nimport { consoleGroup } from './console-group'\nimport { printArray } from './print-array'\nimport { errorColor, printError } from './print-error'\n\n\nexport function printObject(label: string, payload: object, groupType: 'collapsed' | 'expanded' | 'none' = 'collapsed', source?: string) {\n if (payload instanceof Error) {\n printError(payload)\n }\n\n const isArray = Array.isArray(payload)\n const isEmpty = isArray ? payload.length === 0 : Object.keys(payload).length === 0\n if (isEmpty) {\n console.log(\n '%c%s',\n `color: ${errorColor}; padding: 1px; margin-right: 5px; font-size: 10px`,\n `[ ${label} ] Empty`\n )\n return\n }\n\n const styles: Record<string, string> = {\n environment: '🍃 ',\n options: '🧮 ',\n store: '🏬 ',\n subscribers: '🧩 ',\n 'hooks subscriptions': '🔗 '\n }\n const icon = styles[label] ?? ''\n\n let consoleGroupArgs = source ? [`${icon}${label}`, source] : [`[ ${icon}${label} ]`]\n consoleGroup(groupType, ...consoleGroupArgs)\n\n if (isArray) {\n printArray(payload, groupType === 'none' ? label : undefined, icon)\n } else {\n let emptyKeys: string[] = []\n Object.keys(payload).forEach(key => {\n if (key === 'groupId') {\n return\n }\n\n const value = (payload as Record<string, unknown>)[key]\n if (typeof value === 'object') {\n if (Array.isArray(value)) {\n if (typeof value[0] === 'object') {\n printObject(key, value, 'expanded')\n } else if (typeof value[0] === 'string') {\n printObject(\n key,\n value.map((item: string, index: number) => `${index > 0 ? '\\r\\n ' : ' '}- ${item}`),\n 'expanded'\n )\n } else {\n console.log(\n '%c%s',\n 'color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ]`, isRef(value) ? value.value : value\n )\n }\n } else if (value instanceof Error) {\n console.log(key, { name: value.name, message: value.message, stack: value.stack })\n } else {\n if (isRef(value)) {\n console.log(\n '%c%s',\n 'color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ]`, isRef(value) ? value.value : value\n )\n }\n printObject(key, Object.assign({}, value), 'expanded')\n }\n } else {\n if (!value) {\n emptyKeys.push(key)\n } else {\n const typeOfValue = typeof value\n console.log(\n '%c%s',\n 'color: #b0fa05; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ]`, typeOfValue === 'function' ? typeOfValue : value\n )\n }\n }\n })\n if (emptyKeys.length) {\n console.log(\n '%c%s',\n 'color: #f86f63; font-size: 9px',\n `[ Empty properties ]`, emptyKeys\n )\n }\n }\n console.groupEnd()\n}","import { printObject } from './print-object'\nimport type { Store } from 'pinia'\n\nexport function printTracePayload(tracePayload: Record<string, unknown>) {\n Object.keys(tracePayload).forEach((key: string) => {\n if (['groupId', 'label', 'namespace', 'scope', 'source'].includes(key)) {\n return\n }\n const arg = tracePayload[key]\n if (!arg) {\n console.log(\n '%c%s',\n 'color: #f86f63; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ] ${arg}`\n )\n return\n }\n\n switch (typeof arg) {\n case 'string': case 'number':\n console.log(\n '%c%s',\n 'color: #fafa05; padding: 1px; margin-right: 5px; font-size: 10px',\n `[ ${key} ]`, arg\n )\n break;\n case 'object':\n switch (key) {\n case 'mutation':\n console.groupCollapsed('[mutation]')\n console.dir(arg)\n console.groupEnd()\n break;\n case 'options':\n printObject(key, (arg as { storeOptions?: unknown })?.storeOptions ?? arg)\n break;\n case 'payload':\n printTracePayload(arg as Record<string, unknown>)\n break;\n case 'store':\n printObject(key, {\n $state: (arg as Store)['$state'],\n $actions: Object.keys(arg).reduce((acc, curr) => {\n if ((curr.startsWith('$') && !['$id', '$state'].includes(curr)) || curr.startsWith('_')) {\n return acc\n }\n\n const value = (arg as Record<string, unknown>)[curr]\n\n if (typeof value !== 'function') {\n if (!acc['computed']) {\n acc['computed'] = []\n }\n (acc['computed'] as string[]).push(curr)\n\n } else {\n acc[curr] = (arg as Record<string, unknown>)[curr]\n }\n\n return acc\n }, {} as Record<string, unknown>)\n })\n break;\n case 'subscribers':\n printObject(key, (arg as { name: string }[]).map(\n (item, index) => `${index > 0 ? '\\r\\n ' : ' '}- ${item.name}`\n ))\n break;\n default:\n printObject(key, arg)\n }\n break;\n case 'function':\n console.dir(arg)\n break;\n default:\n console.info(key, arg)\n }\n })\n}","import { printTracePayload } from './print-trace-payload'\n\n/**\n * Logs trace events to the console with a specific style.\n * @param logStyle - The CSS style string for the log.\n * @param args - The arguments to log, with the first argument being the label.\n * @param pluginName - The name of the plugin generating the log.\n * @returns void\n */\nexport function logTrace(logStyle: string, args: any, pluginName: string) {\n if (!logStyle) {\n throw new Error('Style instructions are required')\n }\n\n const label = args.shift()\n const event = args[0]\n\n\n if (!event?.payload || Object.keys(event.payload).length === 0) {\n console.log(\n '%c%s',\n logStyle,\n `${event?.source === pluginName ? (event?.label ?? event?.namespace) : label}`,\n event?.source\n )\n return\n }\n\n console.groupCollapsed(\n '%c%s',\n logStyle,\n `${label}\n`, event?.source\n )\n\n args.forEach((arg: any) => {\n switch (typeof arg) {\n case 'string':\n console.info(arg)\n break;\n case 'object':\n if (Array.isArray(arg)) {\n console.table(arg)\n } else {\n printTracePayload(arg)\n }\n break;\n case 'function':\n console.dir(arg)\n break;\n default:\n console.info(arg)\n }\n })\n\n\n\n console.groupEnd()\n}","import { isRef } from 'vue'\nimport { printObject } from './print-object'\nimport type { TraceEvent } from '../../types/trace'\n\n\nfunction getPrintablePayload(trace: TraceEvent) {\n const { payload } = trace\n if (payload && Object.keys(payload).length > 0) {\n return Object.keys(payload).reduce((acc, key) => {\n if (!['groupId', 'label', 'namespace', 'scope', 'source'].includes(key)) {\n acc[key] = isRef(payload[key]) ? payload[key].value : payload[key]\n }\n return acc\n }, {} as Record<string, unknown>)\n }\n return undefined\n}\n\n\n/**\n * Prints a trace event to the console.\n * If the trace has a payload, it will be printed as an object.\n * Otherwise, it will print the trace label and source.\n * @param trace The trace event to print.\n * @returns void\n */\nexport function printTrace(trace: TraceEvent) {\n const payload = getPrintablePayload(trace)\n if (payload && Object.keys(payload).length > 0) {\n printObject(trace.label, payload, 'collapsed', trace.source)\n return\n }\n console.log(\n '%c%s',\n 'color: #f8f89f; padding: 1px; margin-right: 5px; font-size: 11px',\n trace.label, trace.source,\n )\n}","import { CustomConsole } from './console'\nimport { logTrace } from './log-trace'\nimport { pluginName } from '../../utils/constants'\nimport { printTrace } from './print-trace'\nimport { printTracePayload } from './print-trace-payload'\nimport type { StyleDefinition } from '../../types/log'\nimport type { ConsoleTraceEvent, ConsoleTraceEventArgs, TraceEvent } from '../../types/trace'\n\nexport class TraceConsole extends CustomConsole {\n protected _pluginName: string = pluginName\n\n constructor(pluginName?: string) {\n super()\n if (pluginName) {\n this._pluginName = pluginName\n }\n }\n\n\n logGroup(groups: ConsoleTraceEvent[]) {\n const firstEntry = groups.shift()\n const context = firstEntry?.[1] as ConsoleTraceEventArgs\n\n console.groupCollapsed(\n '%c%s',\n 'color: #87e47f; padding: 1px; margin-right: 5px; font-size: 11px; font-family: arial',\n `🍍 ${context?.label ?? context?.namespace}`, `[${context?.scope}]`\n )\n if (context?.payload) {\n printTracePayload(context.payload)\n }\n console.groupCollapsed(\n '%c%s',\n 'color: #f1f6b7; padding: 1px; margin-right: 5px; font-size: 11px',\n `[ ✨ traces ]`\n )\n groups.forEach(group => printTrace(group[1] as TraceEvent))\n console.groupEnd()\n console.groupEnd()\n }\n\n protected useLog(styleDefinition: StyleDefinition, args: any) {\n logTrace(\n this.generateStyle(styleDefinition),\n this.rebuildArgs(args),\n this._pluginName\n )\n }\n}","import { TraceConsole } from '../system/log/trace-console'\n\nimport type { Console } from '../types/log'\nimport type {\n ConsoleTraceEvent, ConsoleTraceEventArgs, TraceEvent, TraceListenerGroupBy, ConsoleTraceGroupListener\n} from '../types/trace'\n\n\n/**\n * Builds the console arguments from a trace event.\n * @param event The trace event to build console arguments from.\n * @returns An array containing the formatted trace label and the sanitized event data.\n */\nfunction buildConsoleArgsFromEvent(event: TraceEvent): ConsoleTraceEvent {\n const sanitizedEvent = Object.keys(event).reduce((acc, curr) => {\n if (curr !== 'level' && curr !== 'timestamp') {\n acc[curr] = event[curr as keyof ConsoleTraceEventArgs]\n }\n return acc\n }, {} as Record<string, unknown>)\n\n return [formatTraceLabel(event), sanitizedEvent as ConsoleTraceEventArgs]\n}\n\nfunction formatTraceLabel(event: TraceEvent): string {\n return event.scope\n ? `${event.label} [${event.scope}]`\n : `${event.label}`\n}\n\nfunction log(target: Console, event: TraceEvent): void {\n const consoleMethod = event.level === 'error' ? 'error' : 'log'\n target[consoleMethod](...buildConsoleArgsFromEvent(event))\n}\n\n/**\n * Creates a console trace group listener that groups trace events by the specified key.\n * @param groupBy The key of the trace event metadata to group by.\n * @returns A console trace group listener configured to group trace events by the specified key.\n */\nexport function createConsoleGroupTraceListener(groupBy: TraceListenerGroupBy = 'scope'): ConsoleTraceGroupListener {\n const target = new TraceConsole()\n const groups = new Map<string, ConsoleTraceEvent[]>()\n // Overlapping starts for the same key (e.g. concurrent async mutations of a store) share one group\n const openCounts = new Map<string, number>()\n\n\n function createGroup(key: string) {\n if (!groups.has(key)) {\n groups.set(key, [])\n }\n openCounts.set(key, (openCounts.get(key) ?? 0) + 1)\n }\n\n function logGroup(key: string): void {\n const group = groups.get(key)\n\n if (!group) {\n target.error(`No group found for key \"${key}\"`)\n return\n }\n\n const remaining = (openCounts.get(key) ?? 1) - 1\n if (remaining > 0) {\n openCounts.set(key, remaining)\n return\n }\n\n if (group.length) { target.logGroup(group) }\n groups.delete(key)\n openCounts.delete(key)\n }\n\n return {\n createGroup,\n logGroup,\n handler(event): void {\n const groupKey = (event?.payload?.groupId ?? event[groupBy]) as string\n if (!groups.has(groupKey)) {\n log(target, event)\n return\n }\n\n const group = groups.get(groupKey)\n if (group?.[0]?.[0] === formatTraceLabel(event)) { return }\n\n groups.get(groupKey)?.push(buildConsoleArgsFromEvent(event))\n }\n }\n}\n\n\n","import { createConsoleGroupTraceListener } from \"./console-trace-listener\"\nimport { pluginName, pluginSubscriptionNamespace } from \"../utils/constants\"\n\nimport type {\n TraceEventMetadata,\n TraceFilter,\n TraceFilterFactoryCriterion,\n TraceFilterFactoryParam,\n TraceGroupListener\n} from \"../types/trace\"\n\n\nfunction createFilter(criteria: TraceFilterFactoryCriterion[], context: boolean = true, mode: 'every' | 'some') {\n return (event: TraceEventMetadata) => {\n return criteria[mode](({ comparator = 'equals', target, value }) => {\n if (target === 'namespace' && context && isPluginSubscription(event)) {\n return true\n }\n\n const eventValue = event[target]\n if (typeof eventValue !== 'string') return false\n\n let result = false\n switch (comparator) {\n case 'equals':\n result = eventValue === value\n break\n case 'contains':\n result = eventValue.includes(value)\n break\n case 'startsWith':\n result = eventValue.startsWith(value)\n break\n case 'endsWith':\n result = eventValue.endsWith(value)\n break\n default:\n result = false\n break\n }\n return result\n })\n }\n}\n\n/**\n * Creates a trace group listener with optional filtering.\n * @param listenerDef The listener definition or filter criteria for the trace group listener.\n * @param context Print the plugin context (subscribers, store, options, and traces) to the console.. Defaults to true.\n * @param filterMode The mode to apply when evaluating multiple filter criteria: 'every' or 'some'.\n * @param groupBy The key of the trace event metadata to group by.\n * @returns A trace listener configured with group handling and filtering.\n */\nexport function createTraceGroupListener(\n listenerDef: TraceFilterFactoryParam | TraceFilterFactoryCriterion[],\n context: boolean = true,\n filterMode: 'every' | 'some' = 'every',\n groupBy: keyof TraceEventMetadata = 'scope'\n) {\n return {\n groupBy,\n ...createConsoleGroupTraceListener(groupBy),\n ...createTraceFilter(listenerDef, context, filterMode)\n } as TraceGroupListener\n\n}\n\nfunction createTraceFilter(\n listenerDef: TraceFilterFactoryParam | TraceFilterFactoryCriterion[],\n context: boolean = true,\n filterMode: 'every' | 'some' = 'every'\n): TraceFilterFactoryParam & { filter: TraceFilter } {\n if (Array.isArray(listenerDef)) {\n return { filter: createFilter(listenerDef, context, filterMode) }\n }\n\n // Copy: the caller's definition must never be mutated.\n return {\n ...listenerDef,\n filter: Array.isArray(listenerDef.filter)\n ? createFilter(listenerDef.filter, context, filterMode)\n : listenerDef.filter\n }\n}\n\nfunction isPluginSubscription(event: TraceEventMetadata): boolean {\n return event?.source === pluginName && (!event?.namespace || event.namespace.startsWith(pluginSubscriptionNamespace))\n}","declare const process: { env: { NODE_ENV?: string } } | undefined\n\n/**\n * Tells whether the host application is built for production.\n * The literal `process.env.NODE_ENV` expression is kept on purpose: consumer bundlers\n * (Vite, webpack, Nuxt...) replace it statically. Without a bundler `process` may be\n * undefined, in which case the environment is not considered production.\n */\nexport function isProductionEnvironment(): boolean {\n try {\n return process!.env.NODE_ENV === 'production'\n } catch {\n return false\n }\n}\n","import type { AnyObject } from '../types'\nimport type { TraceRedactOptions } from '../types/trace'\n\nexport const DEFAULT_REDACTED_VALUE = '[REDACTED]'\n\n/**\n * Keys masked by default when redaction is enabled.\n * Matching is a case-insensitive \"contains\", so `accessToken` or `user_password` are masked too.\n */\nexport const defaultRedactedKeys: readonly RegExp[] = [\n /pass(word|wd|phrase|code)|^pwd/i,\n /secret/i,\n /token/i,\n /authorization/i,\n /api[-_]?key/i,\n /(private|encryption|signing|secret)[-_]?key/i,\n /credential/i,\n /cookie/i,\n /cipher/i,\n]\n\nconst MAX_DEPTH = 12\n\ntype KeyMatcher = (key: string) => boolean\n\nfunction createKeyMatcher(keys: ReadonlyArray<string | RegExp>): KeyMatcher {\n const exact = new Set<string>()\n const patterns: RegExp[] = []\n\n for (const key of keys) {\n if (typeof key === 'string') {\n exact.add(key.toLowerCase())\n } else {\n // a global/sticky regexp is stateful: rebuild it without those flags\n patterns.push(new RegExp(key.source, key.flags.replace(/[gy]/g, '')))\n }\n }\n\n return (key: string) => exact.has(key.toLowerCase()) || patterns.some(pattern => pattern.test(key))\n}\n\nfunction isTraversable(value: unknown): value is object {\n if (value === null || typeof value !== 'object') {\n return false\n }\n\n return !(\n value instanceof Date\n || value instanceof RegExp\n || value instanceof Error\n || value instanceof Promise\n || value instanceof WeakMap\n || value instanceof WeakSet\n )\n}\n\n/**\n * Creates a function returning a redacted copy of a trace payload.\n * The original value (usually the live store state) is never mutated.\n * @param options Redaction options, or `true` to use the default keys.\n * @returns The redaction function.\n */\nexport function createRedactor(options: TraceRedactOptions | true = true): (payload: AnyObject) => AnyObject {\n const { includeDefaults = true, keys = [], replacement = DEFAULT_REDACTED_VALUE } =\n options === true ? {} : options\n const isSensitive = createKeyMatcher([...(includeDefaults ? defaultRedactedKeys : []), ...keys])\n\n function redact(value: unknown, seen: WeakMap<object, unknown>, depth: number): unknown {\n if (!isTraversable(value)) {\n return value\n }\n\n const cached = seen.get(value)\n if (cached !== undefined) {\n return cached\n }\n\n if (depth >= MAX_DEPTH) {\n return '[MaxDepth]'\n }\n\n if (value instanceof Map) {\n const copy = new Map()\n seen.set(value, copy)\n value.forEach((entry, key) => {\n copy.set(key, typeof key === 'string' && isSensitive(key) ? replacement : redact(entry, seen, depth + 1))\n })\n return copy\n }\n\n if (value instanceof Set) {\n const copy = new Set()\n seen.set(value, copy)\n value.forEach(entry => copy.add(redact(entry, seen, depth + 1)))\n return copy\n }\n\n if (Array.isArray(value)) {\n const copy: unknown[] = []\n seen.set(value, copy)\n value.forEach(entry => copy.push(redact(entry, seen, depth + 1)))\n return copy\n }\n\n const copy: Record<string, unknown> = {}\n seen.set(value, copy)\n for (const key of Object.keys(value)) {\n const redactedValue = isSensitive(key)\n ? replacement\n : redact((value as Record<string, unknown>)[key], seen, depth + 1)\n Object.defineProperty(copy, key, {\n configurable: true,\n enumerable: true,\n value: redactedValue,\n writable: true\n })\n }\n return copy\n }\n\n return payload => redact(payload, new WeakMap(), 0) as AnyObject\n}\n"],"names":["PluginSubscriber","pluginName","createInstanceFunction","__publicField","options","subscriptions","_context","store","createTracer","Store","TraceEmitter","ctx","getDefineAStoreSetupContext","setEnhancedStore","onAction","state","storeSubscribe","name","value","isRef","ref","toRef","subscription","optionName","propertyName","isEmpty","property","hasDeniedFirstChar","requiredKey","createPluginSubscriber","invoke","optionalProps","resolvePayload","payload","error","source","listeners","scope","label","namespace","resolved","level","metadata","matched","listener","event","error2","logStyle","args","bgColor","color","CustomConsole","message","icon","styleDefinition","getStyleDefinition","messageType","log$1","groupType","printArray","printablePayload","acc","item","errorColor","printError","stack","line","trace","printObject","log","isArray","consoleGroupArgs","consoleGroup","key","index","emptyKeys","typeOfValue","tracePayload","arg","printTracePayload","curr","logTrace","getPrintablePayload","printTrace","TraceConsole","pluginName2","groups","context","group","buildConsoleArgsFromEvent","sanitizedEvent","formatTraceLabel","target","consoleMethod","createConsoleGroupTraceListener","groupBy","openCounts","createGroup","logGroup","remaining","groupKey","createFilter","criteria","mode","comparator","isPluginSubscription","eventValue","result","listenerDef","filterMode","createTraceFilter","pluginSubscriptionNamespace","isProductionEnvironment","DEFAULT_REDACTED_VALUE","defaultRedactedKeys","MAX_DEPTH","createKeyMatcher","keys","exact","patterns","pattern","isTraversable","createRedactor","replacement","isSensitive","includeDefaults","seen","depth","cached","copy2","entry","redact","copy","redactedValue","noop","createTracerRegistry","enabled","redactor","addListener","listenerGroup","createTraceGroupListener","addScopesListener","scopes","clearTraceListeners","getMatchedListener","listenerGroupAction","actionName","groupLabel","Tracer","hasTraceListeners"],"mappings":";;;;;;AAyBA,MAA8BA,GAA8E;AAAA,EAqDxG,YAAIC,GAAcC,GAAoC;AApD9C,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAA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EAAA;AAAA,MAQO,OAASA,EAAA;AAAA,MACZ,WAAQA,EAAA;AAAA,aAEFA,EAAA;AAAA,MAEN,UAAgB;AAAA,IACZ;AACI,aAAO,OAAA,CAAAW,MAAAA,EAAA,OAAAF,CAAA,CAAA;AAAA,EAAA;AAGX;AACA,WAAIN,EAAW,SAAW;AAAA,EACtB;AAAO,WACX6G,EAAAC,GAAAjH,GAAA;AAEA,IAAIG,EAAS,UACT4G,EAAO/G,CAAA,EAAA,QAAA,CAAAW,MAAA;AACX,YAAAuG,IAAAlH,EAAA,WAAAA,EAAAW,EAAA,OAAA;AAEA,MAAI,YAAsB,YACtBA,EAAMwF,CAAAA,EAAAA;IAEN,CAAA;AAAA,EACI;AAAwG,SAC3G;AAAA,IACD,aAAAM;AAAA,IACJ,mBAAAG;AAAA,IAEA,qBAAAE;AAAA,IACI,eAAMX;AAAAA,MACN,YAAS,CAAAnG,MAAWgH,EAAA,YAAAhH,CAAA;AAAA,MACpB,cAAc,CAAAE,GAAA/B,IAAc,CAAA,UAAWgJ,EAAOjH,MAAiB,EAAA,UAAAsG,GAAA,GAAArI,EAAA,CAAA;AAAA,MAC/D,mBAAAiJ;AAAA,MACJ,YAAA,CAAApH,MAAAgH,EAAA,eAAAhH,CAAA;AAAA,IAEA;AAAA,IACI,mBAAAoH;AAAA,EACA;AACA;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as i } from "./chunks/PluginSubscription-
|
|
2
|
-
import { p as d, d as s, b, c as l } from "./chunks/PluginSubscription-
|
|
1
|
+
import { P as i } from "./chunks/PluginSubscription-Bkqj4uSK.js";
|
|
2
|
+
import { p as d, d as s, b, c as l } from "./chunks/PluginSubscription-Bkqj4uSK.js";
|
|
3
3
|
function u(r, n) {
|
|
4
4
|
const e = new i(r, n);
|
|
5
5
|
return e.plugin.bind(e);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to create console groups with different styles.
|
|
3
|
+
* @param groupType The type of console group: 'collapsed', 'expanded', or 'none'.
|
|
4
|
+
* @param args The arguments to be passed to the console group.
|
|
5
|
+
* @returns void
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare function consoleGroup(groupType?: 'collapsed' | 'expanded' | 'none', ...args: any[]): void;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { Console, LogType, StyleDefinition, StyleDefinitions } from '
|
|
2
|
-
import type { ConsoleTraceEvent } from '../types/trace';
|
|
3
|
-
export declare function printObject(label: string, payload: object, groupType?: 'collapsed' | 'expanded' | 'none', source?: string): void;
|
|
4
|
-
export declare function log(logStyle: string, args: any): void;
|
|
5
|
-
export declare function logTrace(logStyle: string, args: any, pluginName: string): void;
|
|
1
|
+
import type { Console, LogType, StyleDefinition, StyleDefinitions } from '../../types/log';
|
|
6
2
|
export declare abstract class CustomConsole implements Console {
|
|
7
3
|
protected _bgColor: string;
|
|
8
4
|
protected _color: string;
|
|
@@ -20,9 +16,3 @@ export declare abstract class CustomConsole implements Console {
|
|
|
20
16
|
protected rebuildArgs(args: string | any[]): any[];
|
|
21
17
|
protected useLog(styleDefinition: StyleDefinition, args: any): void;
|
|
22
18
|
}
|
|
23
|
-
export declare class TraceConsole extends CustomConsole {
|
|
24
|
-
protected _pluginName: string;
|
|
25
|
-
constructor(pluginName?: string);
|
|
26
|
-
logGroup(groups: ConsoleTraceEvent[]): void;
|
|
27
|
-
protected useLog(styleDefinition: StyleDefinition, args: any): void;
|
|
28
|
-
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs trace events to the console with a specific style.
|
|
3
|
+
* @param logStyle - The CSS style string for the log.
|
|
4
|
+
* @param args - The arguments to log, with the first argument being the label.
|
|
5
|
+
* @param pluginName - The name of the plugin generating the log.
|
|
6
|
+
* @returns void
|
|
7
|
+
*/
|
|
8
|
+
export declare function logTrace(logStyle: string, args: any, pluginName: string): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prints an array to the console with a specific label and group type.
|
|
3
|
+
* @param label The label to display for the array.
|
|
4
|
+
* @param payload The array to print.
|
|
5
|
+
* @param icon An optional icon to display alongside the label.
|
|
6
|
+
*/
|
|
7
|
+
export declare function printArray(payload: any[], label?: string, icon?: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printObject(label: string, payload: object, groupType?: 'collapsed' | 'expanded' | 'none', source?: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printTracePayload(tracePayload: Record<string, unknown>): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TraceEvent } from '../../types/trace';
|
|
2
|
+
/**
|
|
3
|
+
* Prints a trace event to the console.
|
|
4
|
+
* If the trace has a payload, it will be printed as an object.
|
|
5
|
+
* Otherwise, it will print the trace label and source.
|
|
6
|
+
* @param trace The trace event to print.
|
|
7
|
+
* @returns void
|
|
8
|
+
*/
|
|
9
|
+
export declare function printTrace(trace: TraceEvent): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CustomConsole } from './console';
|
|
2
|
+
import type { StyleDefinition } from '../../types/log';
|
|
3
|
+
import type { ConsoleTraceEvent } from '../../types/trace';
|
|
4
|
+
export declare class TraceConsole extends CustomConsole {
|
|
5
|
+
protected _pluginName: string;
|
|
6
|
+
constructor(pluginName?: string);
|
|
7
|
+
logGroup(groups: ConsoleTraceEvent[]): void;
|
|
8
|
+
protected useLog(styleDefinition: StyleDefinition, args: any): void;
|
|
9
|
+
}
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -49,6 +49,13 @@ export interface PluginSubscriptionOptions {
|
|
|
49
49
|
* @type {PluginHydrationScheduler | undefined}
|
|
50
50
|
*/
|
|
51
51
|
hydrationScheduler?: PluginHydrationScheduler;
|
|
52
|
+
/**
|
|
53
|
+
* Maximum time (ms) a `hydration: 'defer'` subscriber keeps its trace group open while its
|
|
54
|
+
* asynchronous hydration hooks are pending. Once elapsed, the group is closed and a
|
|
55
|
+
* `subscriber:deferred:timeout` error is traced. Defaults to 2500.
|
|
56
|
+
* @type {number | undefined}
|
|
57
|
+
*/
|
|
58
|
+
deferredTraceGroupTimeout?: number;
|
|
52
59
|
/**
|
|
53
60
|
* Runtime environment for the plugin subscriber.
|
|
54
61
|
* @type {PluginRuntimeEnvironment | undefined}
|
package/dist/utils/store.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export declare function defineAStore<Sto, Sta>(id: string, storeDefinition: Omit
|
|
|
53
53
|
* @param options Optional store options.
|
|
54
54
|
* @returns The defined store with setup context.
|
|
55
55
|
*/
|
|
56
|
-
export declare function defineAStoreCtx<Id extends string, SS, TExtraExtensions extends Record<string, unknown> = EmptyExtensions>(id: Id, storeDefinition: (ctx: DefineAStoreSetupContext<
|
|
56
|
+
export declare function defineAStoreCtx<Id extends string, SS, TExtraExtensions extends Record<string, unknown> = EmptyExtensions>(id: Id, storeDefinition: (ctx: DefineAStoreSetupContext<unknown, TExtraExtensions>) => SS, options?: StoreOptions): SetupStoreDefinition<Id, SS>;
|
|
57
57
|
/**
|
|
58
58
|
* Define a store with a setup context and explicit store/state types, e.g.
|
|
59
59
|
* when plugins augment the store with members not returned by the setup function.
|
|
@@ -87,6 +87,7 @@ export declare function getDefineAStoreSetupContext(store: object): DefineAStore
|
|
|
87
87
|
* @returns The enhanced store casted to the specified types.
|
|
88
88
|
*/
|
|
89
89
|
export declare function getEnhancedStore<TEnhancedStore>(ctx: DefineAStoreSetupContext<TEnhancedStore>): TEnhancedStore;
|
|
90
|
+
export declare function getEnhancedStore<TEnhancedStore>(ctx: DefineAStoreSetupContext<unknown>): TEnhancedStore;
|
|
90
91
|
/**
|
|
91
92
|
* Set the enhanced store in context with deprecated alias support.
|
|
92
93
|
* @template TEnhancedStore The type of the enhanced store.
|
|
@@ -94,10 +95,12 @@ export declare function getEnhancedStore<TEnhancedStore>(ctx: DefineAStoreSetupC
|
|
|
94
95
|
* @param store The store to expose as enhancement.
|
|
95
96
|
*/
|
|
96
97
|
export declare function setEnhancedStore<TEnhancedStore>(ctx: DefineAStoreSetupContext<TEnhancedStore>, store: TEnhancedStore): void;
|
|
98
|
+
export declare function setEnhancedStore<TEnhancedStore>(ctx: DefineAStoreSetupContext<unknown>, store: TEnhancedStore): void;
|
|
97
99
|
/**
|
|
98
100
|
* @deprecated Use getEnhancedStore instead.
|
|
99
101
|
*/
|
|
100
102
|
export declare function getExtendingStore<TEnhancedStore>(ctx: DefineAStoreSetupContext<TEnhancedStore>): TEnhancedStore;
|
|
103
|
+
export declare function getExtendingStore<TEnhancedStore>(ctx: DefineAStoreSetupContext<unknown>): TEnhancedStore;
|
|
101
104
|
/**
|
|
102
105
|
* Get the storage key for a given action and store combination.
|
|
103
106
|
* @param actionName The name of the action.
|
|
@@ -517,7 +517,7 @@ Available execution options:
|
|
|
517
517
|
|
|
518
518
|
See [SSR / Nuxt best practices](#ssr--nuxt-best-practices) for guidance on matching the runtime policy to the app lifecycle.
|
|
519
519
|
|
|
520
|
-
##
|
|
520
|
+
## Execution policy recap
|
|
521
521
|
|
|
522
522
|
The example above shows the recommended pattern for SSR / Nuxt-safe plugins:
|
|
523
523
|
|
|
@@ -564,7 +564,24 @@ It runs automatically as part of `npm run build` and in CI. If it reports a leak
|
|
|
564
564
|
|
|
565
565
|
## Reference implementation
|
|
566
566
|
|
|
567
|
-
The demo app
|
|
568
|
-
|
|
569
|
-
`
|
|
570
|
-
|
|
567
|
+
The demo app in [`demo/`](../demo/) includes class-based, plain-object, and
|
|
568
|
+
SSR-aware subscribers. Run `npm run dev` for client-only rendering or
|
|
569
|
+
`npm run dev:ssr` to run the Vite SSR server and hydrate the rendered page in
|
|
570
|
+
the browser. Its two subscribers hydrate the same store from different environments: a
|
|
571
|
+
server-only one loads request data (the server waits for its async `hydrate()` before
|
|
572
|
+
rendering) and a client-only, deferred one reads browser APIs after hydration. Both modes
|
|
573
|
+
resolve the package to `src/`, so no build is needed. See also
|
|
574
|
+
[`demo/README.md`](../demo/README.md).
|
|
575
|
+
|
|
576
|
+
| Style | Files | Shows |
|
|
577
|
+
| --- | --- | --- |
|
|
578
|
+
| Class-based | [`demo/plugins/DemoPluginClass.ts`](../demo/plugins/DemoPluginClass.ts), [`demo/core/DemoStore.ts`](../demo/core/DemoStore.ts) | `PluginSubscriber` subclass, `Store` subclass, `hasRequiredKeys` gating, store augmentation (`this.state`, `this.store`), `onAction` / `storeSubscribe`, `trace()` |
|
|
579
|
+
| Plain object | [`demo/plugins/demoPluginObject.ts`](../demo/plugins/demoPluginObject.ts) | `createPluginSubscriber()`, per-store opt-in through `storeOptions`, `createTracer`, `traceGroups` |
|
|
580
|
+
| Environment-aware hydration | [`demo/plugins/demoPluginEnvironmentHydration.ts`](../demo/plugins/demoPluginEnvironmentHydration.ts), [`demo/core/VisitorEnvironmentStore.ts`](../demo/core/VisitorEnvironmentStore.ts), [`demo/stores/visitor-environment.ts`](../demo/stores/visitor-environment.ts), [`demo/entry-server.ts`](../demo/entry-server.ts) | One store hydrated by a server-only subscriber (awaited before render and serialization) and a client-only `hydration: 'defer'` subscriber; each is skipped in the other environment; traces via `Store.trace()` and the `onMutation` group |
|
|
581
|
+
| Enhanced store | [`demo/stores/enhanced-store.ts`](../demo/stores/enhanced-store.ts), [`demo/components/EnhancedExample.vue`](../demo/components/EnhancedExample.vue) | `defineAStoreCtx` + `getEnhancedStore` consuming the `DemoStore` augmentations |
|
|
582
|
+
| Option typing | [`demo/types/plugin.ts`](../demo/types/plugin.ts) | Extending `StoreOptions` with plugin options |
|
|
583
|
+
| Registration & tracing | [`demo/main.ts`](../demo/main.ts) | `createPlugin()` with several subscribers, `createTracerRegistry()`, `addScopesListener()` |
|
|
584
|
+
| Rollback | [`demo/stores/rollback-snapshot.ts`](../demo/stores/rollback-snapshot.ts), [`demo/components/Example.vue`](../demo/components/Example.vue) | `rollbackAfterFailure` option vs manual `$rollbackAfterFailure()` |
|
|
585
|
+
|
|
586
|
+
Open the browser console to see the trace output of the
|
|
587
|
+
`rollbackSnapshotStoreWithRollback` scope.
|
package/docs/tracing.md
CHANGED
|
@@ -136,6 +136,8 @@ registry.addListener([{ target: 'groupId', value: traceGroups.onActionAfter('car
|
|
|
136
136
|
|
|
137
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.
|
|
138
138
|
|
|
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.
|
|
140
|
+
|
|
139
141
|
## Emitting your own events
|
|
140
142
|
|
|
141
143
|
```ts
|
package/docs/using-plugins.md
CHANGED
|
@@ -229,10 +229,20 @@ export const useMyStore = defineAStoreCtx('myStore', (ctx) => {
|
|
|
229
229
|
})
|
|
230
230
|
```
|
|
231
231
|
|
|
232
|
+
Without explicit generics, the enhanced-store properties are `unknown`, since
|
|
233
|
+
the type added by a plugin cannot be inferred from this store's setup return.
|
|
234
|
+
Pass the enhanced-store type through `<Sto, Sta>` (with the behavior and state
|
|
235
|
+
interfaces) when it is known, or use `getEnhancedStore<YourEnhancedStore>(ctx)`.
|
|
236
|
+
Provide `TExtraExtensions` as a third generic when adding custom extension keys.
|
|
237
|
+
|
|
232
238
|
`defineAStoreCtx()` enables the `enhancedStore` store option automatically.
|
|
233
239
|
The internal setup-context lookup is cleaned up as soon as the store is
|
|
234
240
|
associated (and on store dispose), which limits map growth over time.
|
|
235
241
|
|
|
242
|
+
> The enhanced store is attached once plugins have run, after the setup
|
|
243
|
+
> function returns: call getEnhancedStore() lazily (inside actions), not
|
|
244
|
+
> during setup. See [`demo/stores/enhanced-store.ts`](../demo/stores/enhanced-store.ts).
|
|
245
|
+
|
|
236
246
|
## `$reset` on registered stores
|
|
237
247
|
|
|
238
248
|
Every store registered by the plugin exposes `$reset()`, which restores the
|
|
@@ -428,3 +438,5 @@ Plugins built on `pinia-plugin-subscription`:
|
|
|
428
438
|
- `pinia-plugin-persist-state`
|
|
429
439
|
|
|
430
440
|
Check each plugin's own README for its specific store options and behavior.
|
|
441
|
+
|
|
442
|
+
Browse all compatible plugins through the [`pinia-plugin-subscription` GitHub topic](https://github.com/topics/pinia-plugin-subscription), and add the topic to your own plugin's repository (and `pinia-plugin-subscription` to its `keywords`) so users can find it. A runnable example is available in [`demo/`](../demo/README.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinia-plugin-subscription",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
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,
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"plugin",
|
|
21
21
|
"store",
|
|
22
22
|
"subscription",
|
|
23
|
+
"pinia-plugin-subscription",
|
|
23
24
|
"vue3",
|
|
24
25
|
"state-management",
|
|
25
26
|
"typescript"
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
"scripts": {
|
|
67
68
|
"prebuild": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
68
69
|
"dev": "vite --config vite.demo.config.ts",
|
|
70
|
+
"dev:ssr": "node scripts/demo-ssr-server.mjs",
|
|
69
71
|
"dev:library": "vite",
|
|
70
72
|
"test": "vitest",
|
|
71
73
|
"coverage": "vitest run --coverage",
|