pinia-plugin-subscription 1.0.0-beta.2 → 1.0.0-beta.3
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/dist/chunks/{constantes-CaTNAbzX.js → constantes-2FeJfVVy.js} +3 -3
- package/dist/chunks/{constantes-CaTNAbzX.js.map → constantes-2FeJfVVy.js.map} +1 -1
- package/dist/core/PluginSubscription.d.ts +2 -0
- package/dist/core/Store.d.ts +2 -2
- package/dist/helpers.js +116 -102
- package/dist/helpers.js.map +1 -1
- package/dist/pinia-plugin-subscription.js +109 -107
- package/dist/pinia-plugin-subscription.js.map +1 -1
- package/dist/system/log.d.ts +1 -3
- package/dist/types/plugin.d.ts +2 -1
- package/package.json +2 -2
|
@@ -233,10 +233,10 @@ class I {
|
|
|
233
233
|
return Object.prototype.hasOwnProperty.call(this.store, t);
|
|
234
234
|
}
|
|
235
235
|
trace(t, r, s, i) {
|
|
236
|
-
this.tracer && (t = this.traceLabelFormatter(t), this.tracer.debug(t, i ?? t.toLowerCase(),
|
|
236
|
+
this.tracer && (t = this.traceLabelFormatter(t), this.tracer.debug(t, i ?? t.toLowerCase(), s, r));
|
|
237
237
|
}
|
|
238
238
|
traceError(t, r, s, i, o) {
|
|
239
|
-
this.tracer ? (t = this.traceLabelFormatter(t), this.tracer.error(t, o ?? t.toLowerCase(), r,
|
|
239
|
+
this.tracer ? (t = this.traceLabelFormatter(t), this.tracer.error(t, o ?? t.toLowerCase(), r, i, s)) : console.error(r);
|
|
240
240
|
}
|
|
241
241
|
traceLabelFormatter(t) {
|
|
242
242
|
return this.classNameAddedToTraceNamespace && (t = `${this.constructor.name}:${t}`), t;
|
|
@@ -258,4 +258,4 @@ export {
|
|
|
258
258
|
M as p,
|
|
259
259
|
T as s
|
|
260
260
|
};
|
|
261
|
-
//# sourceMappingURL=constantes-
|
|
261
|
+
//# sourceMappingURL=constantes-2FeJfVVy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constantes-CaTNAbzX.js","sources":["../../src/core/PluginSubscriber.ts","../../src/utils/store.ts","../../src/utils/validation/index.ts","../../src/core/Store.ts"],"sourcesContent":["import Store from \"./Store\";\nimport type { PiniaPluginContext, Store as PiniaStore } from \"pinia\";\nimport type { AnyObject } from \"../types\";\nimport type {\n PluginExecutionOptions,\n PluginHydrationScheduler,\n PluginSubscriber as PluginSubscriberInterface,\n PluginSubscriptions,\n StoreClassConstructorParams,\n StoreMutationSubscription,\n StoreOnActionSubscription\n} from \"../types/plugin\";\nimport type Tracer from \"../system/Tracer\";\n\n\n\ntype CreateInstance<Instance = Store> = (store: PiniaStore, options: StoreClassConstructorParams) => Instance | undefined\n\n\n/**\n * Type definition for the function used to create an instance of a store.\n * @template Instance The type of the store instance, defaulting to the base Store class.\n * @param store The Pinia store for which the instance is being created.\n * @param options Additional options for creating the store instance.\n * @returns The created store instance or undefined if creation fails.\n */\nexport default abstract class PluginSubscriber<Instance extends Store> implements PluginSubscriberInterface {\n private _createInstance: CreateInstance\n private _name: string\n private _pluginOptions?: StoreClassConstructorParams\n private _storeInstance?: Instance\n /** Callback function to reset the store instance, if needed. */\n protected _resetStoreCallback?: (store?: PiniaStore) => void\n private _storeOnActionSubscription?: StoreOnActionSubscription\n private _storeMutationSubscription?: StoreMutationSubscription\n private _subscriptions?: PluginSubscriptions\n /**\n * Called when the plugin subscriber has been created for a specific store.\n * This callback can be used to perform any initialization or setup required for the plugin subscriber.\n */\n protected pluginCreated?: (store: PiniaStore) => void\n /** Options for the plugin subscriber's execution. */\n public execution?: PluginExecutionOptions\n /** Scheduler for handling the hydration process of the plugin subscriber. */\n public hydrationScheduler?: PluginHydrationScheduler\n\n\n get name(): string {\n return this._name;\n }\n\n get storeInstance(): Instance | undefined {\n return this._storeInstance\n }\n\n get pluginOptions(): StoreClassConstructorParams | undefined {\n return this._pluginOptions;\n }\n\n set pluginOptions(options: StoreClassConstructorParams | undefined) {\n this._pluginOptions = options;\n }\n\n get resetStoreCallback(): ((store?: PiniaStore) => void) | undefined {\n return this._resetStoreCallback as ((store?: PiniaStore) => void) | undefined;\n }\n\n get storeOnActionSubscription(): StoreOnActionSubscription | undefined {\n return this._storeOnActionSubscription;\n }\n\n get storeMutationSubscription(): StoreMutationSubscription | undefined {\n return this._storeMutationSubscription;\n }\n\n get subscriptions(): PluginSubscriptions | undefined {\n return this._subscriptions\n }\n\n set subscriptions(subscriptions: PluginSubscriptions) {\n this._subscriptions = subscriptions\n }\n\n\n constructor(pluginName: string, createInstanceFunction: CreateInstance) {\n this._name = pluginName\n this._createInstance = createInstanceFunction\n }\n\n /**\n * Called after the store has been hydrated.\n * @param context The Pinia plugin context containing the store and options.\n * @returns A promise that resolves when the post-hydration process is complete, or void if synchronous.\n */\n public afterHydration(context: PiniaPluginContext): void | Promise<void> {\n return\n }\n\n /**\n * Called when the plugin subscriber needs to hydrate its state.\n * @param context The Pinia plugin context containing the store and options.\n * @returns A promise that resolves when the hydration process is complete, or void if synchronous.\n */\n public hydrate(context: PiniaPluginContext): void | Promise<void> {\n return\n }\n\n /**\n * Invokes the plugin subscriber with the given context and optional tracer creation function.\n * @param context The Pinia plugin context containing the store and options.\n * @param createTracer Optional function to create a tracer for the plugin.\n * @returns True if the plugin was successfully invoked, otherwise false.\n */\n public invoke({ store, options }: PiniaPluginContext, createTracer?: (name: string) => Tracer): boolean {\n this._storeInstance = this._createInstance(store, {\n ...options,\n ...this.pluginOptions,\n createTracer: createTracer ? () => createTracer?.(this.name) : undefined\n }) as Instance\n\n if (!this._storeInstance) {\n return false\n }\n\n this._subscriptions = this._storeInstance.getSubscriptions()\n this._storeMutationSubscription = this._storeInstance.storeSubscribe\n this._storeOnActionSubscription = this._storeInstance.onAction\n\n if (this.pluginCreated) {\n this.pluginCreated(store)\n }\n\n return true\n }\n}","import { defineStore } from \"pinia\"\nimport type {\n DefineSetupStoreOptions,\n DefineStoreOptions,\n SetupStoreDefinition,\n StateTree,\n Store,\n StoreDefinition,\n _ExtractActionsFromSetupStore,\n _ExtractGettersFromSetupStore,\n _ExtractStateFromSetupStore,\n _GettersTree\n} from \"pinia\"\nimport type { AnyObject } from \"../types\"\nimport type {\n DefineAStoreDefinition,\n DefineAStoreSetupContext,\n EmptyExtensions,\n StoreOptions\n} from \"../types/store\"\nimport type { PluginStoreOptions } from \"../types/plugin\"\n\n\nexport const itemState = {\n '@id': undefined,\n id: undefined\n}\n\ntype DefineAStoreSetup<SS, TExtraExtensions extends Record<string, unknown> = EmptyExtensions> =\n (ctx: DefineAStoreSetupContext<SS, TExtraExtensions>) => SS\n\n/**\n * Options parameter of pinia's `defineStore()` for setup stores, derived from\n * the setup function return type.\n */\ntype DefineAStoreSetupOptions<Id extends string, SS> = DefineSetupStoreOptions<\n Id,\n _ExtractStateFromSetupStore<SS>,\n _ExtractGettersFromSetupStore<SS>,\n _ExtractActionsFromSetupStore<SS>\n>\n\nconst defineAStoreSetupContexts = new WeakMap<object, DefineAStoreSetupContext<AnyObject>>()\nconst defineAStoreSetupContextsById = new Map<string, DefineAStoreSetupContext<AnyObject>>()\nconst setupContextDisposeWrappedStores = new WeakSet<object>()\n\nfunction registerSetupContextCleanupOnDispose(\n store: AnyObject,\n id: string\n): void {\n if (setupContextDisposeWrappedStores.has(store) || typeof store.$dispose !== 'function') {\n return\n }\n\n const originalDispose = store.$dispose as (...args: unknown[]) => unknown\n store.$dispose = (...args: unknown[]) => {\n defineAStoreSetupContexts.delete(store)\n defineAStoreSetupContextsById.delete(id)\n return originalDispose.apply(store, args)\n }\n setupContextDisposeWrappedStores.add(store)\n}\n\n/**\n * Define a store with the setup API. State, getters and actions are inferred\n * from the setup function return, exactly like pinia's `defineStore`, so\n * store members are listed by IDEs and action prototypes are preserved.\n * @template Id The type of the store identifier.\n * @template SS The type of the setup function return.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Id extends string, SS>(\n id: Id,\n storeDefinition: (ctx?: DefineAStoreSetupContext<AnyObject>) => SS,\n options?: StoreOptions\n): SetupStoreDefinition<Id, SS>\n/**\n * Define a store with the options API, mirroring pinia's `defineStore` inference.\n * @template Id The type of the store identifier.\n * @template S The type of the store's state.\n * @template G The type of the store's getters.\n * @template A The type of the store's actions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The store options definition.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(\n id: Id,\n storeDefinition: Omit<DefineStoreOptions<Id, S, G, A>, 'id'>,\n options?: StoreOptions\n): StoreDefinition<Id, S, G, A>\n/**\n * Define a store with explicit store/state types, e.g. when plugins augment\n * the store with members not returned by the setup function.\n * @template Sto The type of the store.\n * @template Sta The type of the store's state.\n * @param id The unique identifier for the store.\n * @param storeDefinition The store definition, either as an options object or a setup function.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Sto, Sta>(\n id: string,\n storeDefinition:\n | Omit<DefineStoreOptions<string, StateTree & Sta, AnyObject, Partial<Sto>>, 'id'>\n | ((ctx?: DefineAStoreSetupContext<Sto & Sta>) => AnyObject),\n options?: StoreOptions\n): DefineAStoreDefinition<Sto, Sta>\nexport function defineAStore(\n id: string,\n storeDefinition:\n | Omit<DefineStoreOptions<string, StateTree, AnyObject, AnyObject>, 'id'>\n | DefineAStoreSetup<AnyObject>,\n options?: StoreOptions\n): StoreDefinition {\n const storeOptions: PluginStoreOptions = options ? { storeOptions: options } : {} as PluginStoreOptions\n\n return (typeof storeDefinition === 'function'\n ? defineAStoreSetup(\n id,\n storeDefinition as DefineAStoreSetup<AnyObject>,\n storeOptions\n )\n : defineAStoreOptionApi(\n id,\n storeDefinition,\n storeOptions\n )) as StoreDefinition\n}\n\n/**\n * Define a store with a required, fully typed setup context. State, getters\n * and actions are inferred from the setup function return.\n * @template Id The type of the store identifier.\n * @template SS The type of the setup function return.\n * @template TExtraExtensions The type of the store's extra extensions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store with setup context.\n */\nexport function defineAStoreCtx<Id extends string, SS, TExtraExtensions extends Record<string, unknown> = EmptyExtensions>(\n id: Id,\n storeDefinition: (ctx: DefineAStoreSetupContext<AnyObject, TExtraExtensions>) => SS,\n options?: StoreOptions\n): SetupStoreDefinition<Id, SS>\n/**\n * Define a store with a setup context and explicit store/state types, e.g.\n * when plugins augment the store with members not returned by the setup function.\n * @template Sto The type of the store.\n * @template Sta The type of the store's state.\n * @template TExtraExtensions The type of the store's extra extensions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store with setup context.\n */\nexport function defineAStoreCtx<Sto, Sta, TExtraExtensions extends Record<string, unknown> = EmptyExtensions>(\n id: string,\n storeDefinition: (ctx: DefineAStoreSetupContext<Sto & Sta, TExtraExtensions>) => AnyObject,\n options?: StoreOptions\n): DefineAStoreDefinition<Sto, Sta>\nexport function defineAStoreCtx(\n id: string,\n storeDefinition: DefineAStoreSetup<AnyObject, any>,\n options?: StoreOptions\n): StoreDefinition {\n const storeOptions: PluginStoreOptions = options\n ? { storeOptions: { ...options, enhancedStore: true } }\n : { storeOptions: { enhancedStore: true } } as PluginStoreOptions\n\n return defineAStoreSetup(\n id,\n storeDefinition,\n storeOptions\n ) as StoreDefinition\n}\n\nexport function defineAStoreSetup<Id extends string, SS>(\n id: Id,\n storeDefinition: DefineAStoreSetup<SS>,\n options: PluginStoreOptions\n): SetupStoreDefinition<Id, SS> {\n const setupContext: DefineAStoreSetupContext<SS> = {\n id,\n extensions: {}\n }\n\n const shouldStoreSetupContext = options?.storeOptions?.enhancedStore === true\n\n // `storeOptions` augments pinia's DefineStoreOptionsBase (see createPlugin.ts);\n // the assertion stays valid in compilation units where the augmentation is not loaded.\n const useStore = defineStore(\n id,\n () => storeDefinition(setupContext),\n options as unknown as DefineAStoreSetupOptions<Id, SS>\n )\n\n return Object.assign(((...args: Parameters<typeof useStore>) => {\n if (shouldStoreSetupContext) {\n defineAStoreSetupContextsById.set(id, setupContext as DefineAStoreSetupContext<AnyObject>)\n }\n\n const store = useStore(...args)\n\n if (shouldStoreSetupContext) {\n defineAStoreSetupContexts.set(store, setupContext as DefineAStoreSetupContext<AnyObject>)\n defineAStoreSetupContextsById.delete(id)\n registerSetupContextCleanupOnDispose(store as AnyObject, id)\n }\n\n return store\n }) as typeof useStore, useStore)\n}\n\nexport function defineAStoreOptionApi<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(\n id: Id,\n storeDefinition: Omit<DefineStoreOptions<Id, S, G, A>, 'id'>,\n options?: PluginStoreOptions\n): StoreDefinition<Id, S, G, A> {\n if (options) {\n storeDefinition = { ...storeDefinition, ...(options ?? {}) }\n }\n\n return defineStore(id, storeDefinition)\n}\n\nconst deniedFirstChar = new Set<string>(['_', '$'])\n\n/**\n * Check if a property has a denied first character : ['_', '$'].\n * @param property The property name to check.\n * @returns True if the property has a denied first character, false otherwise.\n */\nexport function hasDeniedFirstChar(property: string): boolean {\n return deniedFirstChar.has(property[0] as string)\n}\n\n/**\n * Get the setup context associated with a store instance (or pending store id).\n * @param store The store instance, or an object exposing the store `$id`.\n * @returns The setup context when the store was defined with `enhancedStore` enabled, undefined otherwise.\n */\nexport function getDefineAStoreSetupContext(store: object): DefineAStoreSetupContext<AnyObject> | undefined {\n const storeRecord = store as AnyObject\n\n return defineAStoreSetupContexts.get(store)\n ?? (typeof storeRecord?.$id === 'string'\n ? defineAStoreSetupContextsById.get(storeRecord.$id)\n : undefined)\n}\n\n/**\n * Get the enhanced store from the context.\n * @template TEnhancedStore The type of the enhanced store.\n * @param ctx The context containing the extensions.\n * @returns The enhanced store casted to the specified types.\n */\nexport function getEnhancedStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>\n): TEnhancedStore {\n const enhancedStore = ctx.extensions.enhancedStore ?? ctx.extensions.extending\n\n if (!enhancedStore) {\n throw new Error(`${ctx.id}Store - getEnhancedStore - Error: enhanced store is required`)\n }\n\n return enhancedStore\n}\n\n/**\n * Set the enhanced store in context with deprecated alias support.\n * @template TEnhancedStore The type of the enhanced store.\n * @param ctx The context containing the extensions.\n * @param store The store to expose as enhancement.\n */\nexport function setEnhancedStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>,\n store: TEnhancedStore\n): void {\n ctx.extensions.enhancedStore = store\n ctx.extensions.extending = store\n}\n\n/**\n * @deprecated Use getEnhancedStore instead.\n */\nexport function getExtendingStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>\n): TEnhancedStore {\n console.warn(`${ctx.id}Store - getExtendingStore is deprecated. Use getEnhancedStore instead.`)\n return getEnhancedStore<TEnhancedStore>(ctx)\n}\n\n/**\n * Get the storage key for a given action and store combination.\n * @param actionName The name of the action.\n * @param store The Pinia store instance.\n * @returns The storage key for the action and store combination.\n */\nexport function getActionStoreKey(actionName: string, store: Store): string {\n return `${actionName}-${store.$id}`\n}","export function isEmpty(value: any): boolean {\n if (!value) {\n return (typeof value === 'boolean' || typeof value === 'number') ? false : true\n }\n\n if (Array.isArray(value)) {\n return value.length === 0\n }\n\n if (typeof value === 'object') {\n return Object.keys(value).length === 0\n }\n\n if (typeof value === 'string') {\n return value.trim() === ''\n }\n\n return false\n}","import { isRef, ref, toRef } from \"vue\"\nimport Tracer from \"../system/Tracer\"\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 { TracePayload } from \"../types/trace\"\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 {\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 private _traceOptions: Record<string, boolean> = {\n /** Indicates whether to add the class name to the namespace for tracing purposes. */\n addClassNameToLabel: true,\n }\n private _tracer?: Tracer\n\n protected static _requiredKeys?: string[]\n\n get classNameAddedToTraceNamespace(): boolean {\n return this._traceOptions.addClassNameToLabel\n }\n\n set classNameAddedToTraceNamespace(value: boolean) {\n this._traceOptions.addClassNameToLabel = value\n }\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 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 this._options = options.storeOptions as StoreOptions\n this._store = store\n this.initializeTracer(options)\n\n if (this._options?.enhancedStore) {\n const ctx = getDefineAStoreSetupContext(this.store)\n\n if (ctx) {\n setEnhancedStore(ctx, this.store)\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 /**\n * Emits a structured trace event scoped to this store.\n * Prefer the factory form for `payload`: it is only resolved when consumed.\n */\n trace(label: string, payload?: TracePayload, scope?: string, namespace?: string): void {\n if (this.tracer) {\n label = this.traceLabelFormatter(label)\n this.tracer.debug(label, namespace ?? label.toLowerCase(), payload, scope)\n }\n }\n\n /**\n * Emits a structured error event, or rethrows it when no listener matches.\n */\n traceError(label: string, error: unknown, payload?: TracePayload, scope?: string, namespace?: string): void {\n if (this.tracer) {\n label = this.traceLabelFormatter(label)\n this.tracer.error(label, namespace ?? label.toLowerCase(), error, payload, scope)\n } else {\n console.error(error)\n }\n }\n\n private traceLabelFormatter(label: string): string {\n if (this.classNameAddedToTraceNamespace) {\n label = `${this.constructor.name}:${label}`\n }\n\n return label\n }\n}"],"names":["PluginSubscriber","pluginName","createInstanceFunction","__publicField","options","subscriptions","context","store","createTracer","defineAStoreSetupContexts","defineAStoreSetupContextsById","setupContextDisposeWrappedStores","registerSetupContextCleanupOnDispose","id","originalDispose","args","storeOptions","storeDefinition","defineAStoreSetup","defineAStoreOptionApi","defineAStoreCtx","setupContext","shouldStoreSetupContext","useStore","defineStore","deniedFirstChar","property","getDefineAStoreSetupContext","storeRecord","getEnhancedStore","ctx","enhancedStore","setEnhancedStore","getExtendingStore","getActionStoreKey","actionName","isEmpty","value","Store","onAction","state","storeSubscribe","name","isRef","ref","toRef","subscription","optionName","propertyName","hasDeniedFirstChar","requiredKey","label","payload","scope","namespace","error"],"mappings":";;;;;AA0BA,MAA8BA,EAA8E;AAAA,EAqDxG,YAAIC,GAAcC,GAAoC;AApD9C,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAEE,IAAAA,EAAA;AACF,IAA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oBAAAA,CAAA,GAOA,YAAU,MAAgCA,GAAAG,KAAAH,EAAA,YAAA,GAAAC,GAAAC,CAAA;AAAA,EAE1C;AAAA,EAAA,WAAAF,GAAAI,GAAAH,GAAAC,GAAAC,GAAA;AAAA,IAAA,KAAA,UAAAH,IAAA,KAAA,oBAAAA,CAAA,GAAA,KAAA,OAAA,MAAAA,GAAAG,KAAAH,EAAA,YAAA,GAAAI,GAAAH,GAAAC,CAAA,KAQI,QAAO,MAAKE,CAAS;AAAA,EACzB;AAAA,EAAA,oBAAAJ,GAAA;AAAA,WAAA,KAAA,mCAAAA,IAAA,GAAA,KAAA,YAAA,IAAA,IAAAA,CAAA,KAOQA;AAAA,EACA;AAAA;AD5LRhD,EAjBGmC,GAiBI;AC+LS,MAChBrC,IAAA;"}
|
|
1
|
+
{"version":3,"file":"constantes-2FeJfVVy.js","sources":["../../src/core/PluginSubscriber.ts","../../src/utils/store.ts","../../src/utils/validation/index.ts","../../src/core/Store.ts"],"sourcesContent":["import Store from \"./Store\";\nimport type { PiniaPluginContext, Store as PiniaStore } from \"pinia\";\nimport type { AnyObject } from \"../types\";\nimport type {\n PluginExecutionOptions,\n PluginHydrationScheduler,\n PluginSubscriber as PluginSubscriberInterface,\n PluginSubscriptions,\n StoreClassConstructorParams,\n StoreMutationSubscription,\n StoreOnActionSubscription\n} from \"../types/plugin\";\nimport type Tracer from \"../system/Tracer\";\n\n\n\ntype CreateInstance<Instance = Store> = (store: PiniaStore, options: StoreClassConstructorParams) => Instance | undefined\n\n\n/**\n * Type definition for the function used to create an instance of a store.\n * @template Instance The type of the store instance, defaulting to the base Store class.\n * @param store The Pinia store for which the instance is being created.\n * @param options Additional options for creating the store instance.\n * @returns The created store instance or undefined if creation fails.\n */\nexport default abstract class PluginSubscriber<Instance extends Store> implements PluginSubscriberInterface {\n private _createInstance: CreateInstance\n private _name: string\n private _pluginOptions?: StoreClassConstructorParams\n private _storeInstance?: Instance\n /** Callback function to reset the store instance, if needed. */\n protected _resetStoreCallback?: (store?: PiniaStore) => void\n private _storeOnActionSubscription?: StoreOnActionSubscription\n private _storeMutationSubscription?: StoreMutationSubscription\n private _subscriptions?: PluginSubscriptions\n /**\n * Called when the plugin subscriber has been created for a specific store.\n * This callback can be used to perform any initialization or setup required for the plugin subscriber.\n */\n protected pluginCreated?: (store: PiniaStore) => void\n /** Options for the plugin subscriber's execution. */\n public execution?: PluginExecutionOptions\n /** Scheduler for handling the hydration process of the plugin subscriber. */\n public hydrationScheduler?: PluginHydrationScheduler\n\n\n get name(): string {\n return this._name;\n }\n\n get storeInstance(): Instance | undefined {\n return this._storeInstance\n }\n\n get pluginOptions(): StoreClassConstructorParams | undefined {\n return this._pluginOptions;\n }\n\n set pluginOptions(options: StoreClassConstructorParams | undefined) {\n this._pluginOptions = options;\n }\n\n get resetStoreCallback(): ((store?: PiniaStore) => void) | undefined {\n return this._resetStoreCallback as ((store?: PiniaStore) => void) | undefined;\n }\n\n get storeOnActionSubscription(): StoreOnActionSubscription | undefined {\n return this._storeOnActionSubscription;\n }\n\n get storeMutationSubscription(): StoreMutationSubscription | undefined {\n return this._storeMutationSubscription;\n }\n\n get subscriptions(): PluginSubscriptions | undefined {\n return this._subscriptions\n }\n\n set subscriptions(subscriptions: PluginSubscriptions) {\n this._subscriptions = subscriptions\n }\n\n\n constructor(pluginName: string, createInstanceFunction: CreateInstance) {\n this._name = pluginName\n this._createInstance = createInstanceFunction\n }\n\n /**\n * Called after the store has been hydrated.\n * @param context The Pinia plugin context containing the store and options.\n * @returns A promise that resolves when the post-hydration process is complete, or void if synchronous.\n */\n public afterHydration(context: PiniaPluginContext): void | Promise<void> {\n return\n }\n\n /**\n * Called when the plugin subscriber needs to hydrate its state.\n * @param context The Pinia plugin context containing the store and options.\n * @returns A promise that resolves when the hydration process is complete, or void if synchronous.\n */\n public hydrate(context: PiniaPluginContext): void | Promise<void> {\n return\n }\n\n /**\n * Invokes the plugin subscriber with the given context and optional tracer creation function.\n * @param context The Pinia plugin context containing the store and options.\n * @param createTracer Optional function to create a tracer for the plugin.\n * @returns True if the plugin was successfully invoked, otherwise false.\n */\n public invoke({ store, options }: PiniaPluginContext, createTracer?: (name: string) => Tracer): boolean {\n this._storeInstance = this._createInstance(store, {\n ...options,\n ...this.pluginOptions,\n createTracer: createTracer ? () => createTracer?.(this.name) : undefined\n }) as Instance\n\n if (!this._storeInstance) {\n return false\n }\n\n this._subscriptions = this._storeInstance.getSubscriptions()\n this._storeMutationSubscription = this._storeInstance.storeSubscribe\n this._storeOnActionSubscription = this._storeInstance.onAction\n\n if (this.pluginCreated) {\n this.pluginCreated(store)\n }\n\n return true\n }\n}","import { defineStore } from \"pinia\"\nimport type {\n DefineSetupStoreOptions,\n DefineStoreOptions,\n SetupStoreDefinition,\n StateTree,\n Store,\n StoreDefinition,\n _ExtractActionsFromSetupStore,\n _ExtractGettersFromSetupStore,\n _ExtractStateFromSetupStore,\n _GettersTree\n} from \"pinia\"\nimport type { AnyObject } from \"../types\"\nimport type {\n DefineAStoreDefinition,\n DefineAStoreSetupContext,\n EmptyExtensions,\n StoreOptions\n} from \"../types/store\"\nimport type { PluginStoreOptions } from \"../types/plugin\"\n\n\nexport const itemState = {\n '@id': undefined,\n id: undefined\n}\n\ntype DefineAStoreSetup<SS, TExtraExtensions extends Record<string, unknown> = EmptyExtensions> =\n (ctx: DefineAStoreSetupContext<SS, TExtraExtensions>) => SS\n\n/**\n * Options parameter of pinia's `defineStore()` for setup stores, derived from\n * the setup function return type.\n */\ntype DefineAStoreSetupOptions<Id extends string, SS> = DefineSetupStoreOptions<\n Id,\n _ExtractStateFromSetupStore<SS>,\n _ExtractGettersFromSetupStore<SS>,\n _ExtractActionsFromSetupStore<SS>\n>\n\nconst defineAStoreSetupContexts = new WeakMap<object, DefineAStoreSetupContext<AnyObject>>()\nconst defineAStoreSetupContextsById = new Map<string, DefineAStoreSetupContext<AnyObject>>()\nconst setupContextDisposeWrappedStores = new WeakSet<object>()\n\nfunction registerSetupContextCleanupOnDispose(\n store: AnyObject,\n id: string\n): void {\n if (setupContextDisposeWrappedStores.has(store) || typeof store.$dispose !== 'function') {\n return\n }\n\n const originalDispose = store.$dispose as (...args: unknown[]) => unknown\n store.$dispose = (...args: unknown[]) => {\n defineAStoreSetupContexts.delete(store)\n defineAStoreSetupContextsById.delete(id)\n return originalDispose.apply(store, args)\n }\n setupContextDisposeWrappedStores.add(store)\n}\n\n/**\n * Define a store with the setup API. State, getters and actions are inferred\n * from the setup function return, exactly like pinia's `defineStore`, so\n * store members are listed by IDEs and action prototypes are preserved.\n * @template Id The type of the store identifier.\n * @template SS The type of the setup function return.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Id extends string, SS>(\n id: Id,\n storeDefinition: (ctx?: DefineAStoreSetupContext<AnyObject>) => SS,\n options?: StoreOptions\n): SetupStoreDefinition<Id, SS>\n/**\n * Define a store with the options API, mirroring pinia's `defineStore` inference.\n * @template Id The type of the store identifier.\n * @template S The type of the store's state.\n * @template G The type of the store's getters.\n * @template A The type of the store's actions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The store options definition.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(\n id: Id,\n storeDefinition: Omit<DefineStoreOptions<Id, S, G, A>, 'id'>,\n options?: StoreOptions\n): StoreDefinition<Id, S, G, A>\n/**\n * Define a store with explicit store/state types, e.g. when plugins augment\n * the store with members not returned by the setup function.\n * @template Sto The type of the store.\n * @template Sta The type of the store's state.\n * @param id The unique identifier for the store.\n * @param storeDefinition The store definition, either as an options object or a setup function.\n * @param options Optional store options.\n * @returns The defined store.\n */\nexport function defineAStore<Sto, Sta>(\n id: string,\n storeDefinition:\n | Omit<DefineStoreOptions<string, StateTree & Sta, AnyObject, Partial<Sto>>, 'id'>\n | ((ctx?: DefineAStoreSetupContext<Sto & Sta>) => AnyObject),\n options?: StoreOptions\n): DefineAStoreDefinition<Sto, Sta>\nexport function defineAStore(\n id: string,\n storeDefinition:\n | Omit<DefineStoreOptions<string, StateTree, AnyObject, AnyObject>, 'id'>\n | DefineAStoreSetup<AnyObject>,\n options?: StoreOptions\n): StoreDefinition {\n const storeOptions: PluginStoreOptions = options ? { storeOptions: options } : {} as PluginStoreOptions\n\n return (typeof storeDefinition === 'function'\n ? defineAStoreSetup(\n id,\n storeDefinition as DefineAStoreSetup<AnyObject>,\n storeOptions\n )\n : defineAStoreOptionApi(\n id,\n storeDefinition,\n storeOptions\n )) as StoreDefinition\n}\n\n/**\n * Define a store with a required, fully typed setup context. State, getters\n * and actions are inferred from the setup function return.\n * @template Id The type of the store identifier.\n * @template SS The type of the setup function return.\n * @template TExtraExtensions The type of the store's extra extensions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store with setup context.\n */\nexport function defineAStoreCtx<Id extends string, SS, TExtraExtensions extends Record<string, unknown> = EmptyExtensions>(\n id: Id,\n storeDefinition: (ctx: DefineAStoreSetupContext<AnyObject, TExtraExtensions>) => SS,\n options?: StoreOptions\n): SetupStoreDefinition<Id, SS>\n/**\n * Define a store with a setup context and explicit store/state types, e.g.\n * when plugins augment the store with members not returned by the setup function.\n * @template Sto The type of the store.\n * @template Sta The type of the store's state.\n * @template TExtraExtensions The type of the store's extra extensions.\n * @param id The unique identifier for the store.\n * @param storeDefinition The setup function defining the store.\n * @param options Optional store options.\n * @returns The defined store with setup context.\n */\nexport function defineAStoreCtx<Sto, Sta, TExtraExtensions extends Record<string, unknown> = EmptyExtensions>(\n id: string,\n storeDefinition: (ctx: DefineAStoreSetupContext<Sto & Sta, TExtraExtensions>) => AnyObject,\n options?: StoreOptions\n): DefineAStoreDefinition<Sto, Sta>\nexport function defineAStoreCtx(\n id: string,\n storeDefinition: DefineAStoreSetup<AnyObject, any>,\n options?: StoreOptions\n): StoreDefinition {\n const storeOptions: PluginStoreOptions = options\n ? { storeOptions: { ...options, enhancedStore: true } }\n : { storeOptions: { enhancedStore: true } } as PluginStoreOptions\n\n return defineAStoreSetup(\n id,\n storeDefinition,\n storeOptions\n ) as StoreDefinition\n}\n\nexport function defineAStoreSetup<Id extends string, SS>(\n id: Id,\n storeDefinition: DefineAStoreSetup<SS>,\n options: PluginStoreOptions\n): SetupStoreDefinition<Id, SS> {\n const setupContext: DefineAStoreSetupContext<SS> = {\n id,\n extensions: {}\n }\n\n const shouldStoreSetupContext = options?.storeOptions?.enhancedStore === true\n\n // `storeOptions` augments pinia's DefineStoreOptionsBase (see createPlugin.ts);\n // the assertion stays valid in compilation units where the augmentation is not loaded.\n const useStore = defineStore(\n id,\n () => storeDefinition(setupContext),\n options as unknown as DefineAStoreSetupOptions<Id, SS>\n )\n\n return Object.assign(((...args: Parameters<typeof useStore>) => {\n if (shouldStoreSetupContext) {\n defineAStoreSetupContextsById.set(id, setupContext as DefineAStoreSetupContext<AnyObject>)\n }\n\n const store = useStore(...args)\n\n if (shouldStoreSetupContext) {\n defineAStoreSetupContexts.set(store, setupContext as DefineAStoreSetupContext<AnyObject>)\n defineAStoreSetupContextsById.delete(id)\n registerSetupContextCleanupOnDispose(store as AnyObject, id)\n }\n\n return store\n }) as typeof useStore, useStore)\n}\n\nexport function defineAStoreOptionApi<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(\n id: Id,\n storeDefinition: Omit<DefineStoreOptions<Id, S, G, A>, 'id'>,\n options?: PluginStoreOptions\n): StoreDefinition<Id, S, G, A> {\n if (options) {\n storeDefinition = { ...storeDefinition, ...(options ?? {}) }\n }\n\n return defineStore(id, storeDefinition)\n}\n\nconst deniedFirstChar = new Set<string>(['_', '$'])\n\n/**\n * Check if a property has a denied first character : ['_', '$'].\n * @param property The property name to check.\n * @returns True if the property has a denied first character, false otherwise.\n */\nexport function hasDeniedFirstChar(property: string): boolean {\n return deniedFirstChar.has(property[0] as string)\n}\n\n/**\n * Get the setup context associated with a store instance (or pending store id).\n * @param store The store instance, or an object exposing the store `$id`.\n * @returns The setup context when the store was defined with `enhancedStore` enabled, undefined otherwise.\n */\nexport function getDefineAStoreSetupContext(store: object): DefineAStoreSetupContext<AnyObject> | undefined {\n const storeRecord = store as AnyObject\n\n return defineAStoreSetupContexts.get(store)\n ?? (typeof storeRecord?.$id === 'string'\n ? defineAStoreSetupContextsById.get(storeRecord.$id)\n : undefined)\n}\n\n/**\n * Get the enhanced store from the context.\n * @template TEnhancedStore The type of the enhanced store.\n * @param ctx The context containing the extensions.\n * @returns The enhanced store casted to the specified types.\n */\nexport function getEnhancedStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>\n): TEnhancedStore {\n const enhancedStore = ctx.extensions.enhancedStore ?? ctx.extensions.extending\n\n if (!enhancedStore) {\n throw new Error(`${ctx.id}Store - getEnhancedStore - Error: enhanced store is required`)\n }\n\n return enhancedStore\n}\n\n/**\n * Set the enhanced store in context with deprecated alias support.\n * @template TEnhancedStore The type of the enhanced store.\n * @param ctx The context containing the extensions.\n * @param store The store to expose as enhancement.\n */\nexport function setEnhancedStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>,\n store: TEnhancedStore\n): void {\n ctx.extensions.enhancedStore = store\n ctx.extensions.extending = store\n}\n\n/**\n * @deprecated Use getEnhancedStore instead.\n */\nexport function getExtendingStore<TEnhancedStore>(\n ctx: DefineAStoreSetupContext<TEnhancedStore>\n): TEnhancedStore {\n console.warn(`${ctx.id}Store - getExtendingStore is deprecated. Use getEnhancedStore instead.`)\n return getEnhancedStore<TEnhancedStore>(ctx)\n}\n\n/**\n * Get the storage key for a given action and store combination.\n * @param actionName The name of the action.\n * @param store The Pinia store instance.\n * @returns The storage key for the action and store combination.\n */\nexport function getActionStoreKey(actionName: string, store: Store): string {\n return `${actionName}-${store.$id}`\n}","export function isEmpty(value: any): boolean {\n if (!value) {\n return (typeof value === 'boolean' || typeof value === 'number') ? false : true\n }\n\n if (Array.isArray(value)) {\n return value.length === 0\n }\n\n if (typeof value === 'object') {\n return Object.keys(value).length === 0\n }\n\n if (typeof value === 'string') {\n return value.trim() === ''\n }\n\n return false\n}","import { isRef, ref, toRef } from \"vue\"\nimport Tracer from \"../system/Tracer\"\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 { TracePayload } from \"../types/trace\"\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 {\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 private _traceOptions: Record<string, boolean> = {\n /** Indicates whether to add the class name to the namespace for tracing purposes. */\n addClassNameToLabel: true,\n }\n private _tracer?: Tracer\n\n protected static _requiredKeys?: string[]\n\n get classNameAddedToTraceNamespace(): boolean {\n return this._traceOptions.addClassNameToLabel\n }\n\n set classNameAddedToTraceNamespace(value: boolean) {\n this._traceOptions.addClassNameToLabel = value\n }\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 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 this._options = options.storeOptions as StoreOptions\n this._store = store\n this.initializeTracer(options)\n\n if (this._options?.enhancedStore) {\n const ctx = getDefineAStoreSetupContext(this.store)\n\n if (ctx) {\n setEnhancedStore(ctx, this.store)\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 /**\n * Emits a structured trace event scoped to this store.\n * Prefer the factory form for `payload`: it is only resolved when consumed.\n */\n trace(label: string, scope?: string, payload?: TracePayload, namespace?: string): void {\n if (this.tracer) {\n label = this.traceLabelFormatter(label)\n this.tracer.debug(label, namespace ?? label.toLowerCase(), payload, scope)\n }\n }\n\n /**\n * Emits a structured error event, or rethrows it when no listener matches.\n */\n traceError(label: string, error: unknown, scope?: string, payload?: TracePayload, namespace?: string): void {\n if (this.tracer) {\n label = this.traceLabelFormatter(label)\n this.tracer.error(label, namespace ?? label.toLowerCase(), error, payload, scope)\n } else {\n console.error(error)\n }\n }\n\n private traceLabelFormatter(label: string): string {\n if (this.classNameAddedToTraceNamespace) {\n label = `${this.constructor.name}:${label}`\n }\n\n return label\n }\n}"],"names":["PluginSubscriber","pluginName","createInstanceFunction","__publicField","options","subscriptions","context","store","createTracer","defineAStoreSetupContexts","defineAStoreSetupContextsById","setupContextDisposeWrappedStores","registerSetupContextCleanupOnDispose","id","originalDispose","args","storeOptions","storeDefinition","defineAStoreSetup","defineAStoreOptionApi","defineAStoreCtx","setupContext","shouldStoreSetupContext","useStore","defineStore","deniedFirstChar","property","getDefineAStoreSetupContext","storeRecord","getEnhancedStore","ctx","enhancedStore","setEnhancedStore","getExtendingStore","getActionStoreKey","actionName","isEmpty","value","Store","onAction","state","storeSubscribe","name","isRef","ref","toRef","subscription","optionName","propertyName","hasDeniedFirstChar","requiredKey","label","scope","payload","namespace","error"],"mappings":";;;;;AA0BA,MAA8BA,EAA8E;AAAA,EAqDxG,YAAIC,GAAcC,GAAoC;AApD9C,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAEE,IAAAA,EAAA;AACF,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAAA,IAAAA,EAAA;AAAA,IAAAA,EAAA;AAKE,IAAAA,EAAA;AAwCN,SAAK,QAAAF,GACT,KAAA,kBAAAC;AAAA,EAGA;AAAA,EA1CO,IAAA,OAAA;AAAA,WAAA,KAAA;AAAA,EAEA;AAAA,EAGP,IAAI,gBAAe;AACf,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,gBAAsC;AACtC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,cAAAE,GAAyD;AACzD,SAAA,iBAAYA;AAAA,EAChB;AAAA,EAEA,IAAI,qBAAc;AACd,WAAK,KAAA;AAAA,EACT;AAAA,EAEA,IAAI,4BAAiE;AACjE,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,4BAAmE;AACnE,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI;AACA,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,cAAAC,GAAiD;AACjD,SAAA,iBAAYA;AAAA,EAChB;AAAA,EASI,eAAKC,GAAA;AAAA,EACT;AAAA,EAAA,QAAAA,GAAA;AAAA,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UAAM,KAAA,eAAkB,MAAY,CAAA8C,MAAG,CAAA,CAAA9C,EAAA8C,CAAA,CAAA;AAAA,EACzE;AAAA,EAAA,UAAA;AAAA,EAAA;AAAA,EAOI,iBAAA9C,GAAA;AACJ,SAAA,gBAAAA,GAAA;AAAA,EAAA;AAAA,EAAA,cAAA;AAAA,WAAA,KAAA,MAAA;AAAA,EAAA;AAAA,EAAA,SAAAsB,GAAA;WASO,OAAA,UACH,eAEoB,KAAA,KAAA,OAAAA,CAAA;AAAA,EACpB;AAAA,EACkC,SAClCA,GAAA;AACJ,WAAA,OAAA,UAAA,eAAA,KAAA,KAAA,OAAAA,CAAA;AAAA,EAAA;AAAA,EAAA,MAAAyB,GAAAC,GAAAC,GAAAC,GAAA;AAAA,IAAA,KAAA,WAAAH,IAAA,KAAA,oBAAAA,CAAA,GAOA,YAAU,MAAgCA,GAAAG,KAAAH,EAAA,YAAA,GAAAE,GAAAD,CAAA;AAAA,EAE1C;AAAA,EAAA,WAAAD,GAAAI,GAAAH,GAAAC,GAAAC,GAAA;AAAA,IAAA,KAAA,UAAAH,IAAA,KAAA,oBAAAA,CAAA,GAAA,KAAA,OAAA,MAAAA,GAAAG,KAAAH,EAAA,YAAA,GAAAI,GAAAF,GAAAD,CAAA,KAQI,QAAO,MAAKG,CAAS;AAAA,EACzB;AAAA,EAAA,oBAAAJ,GAAA;AAAA,WAAA,KAAA,mCAAAA,IAAA,GAAA,KAAA,YAAA,IAAA,IAAAA,CAAA,KAOQA;AAAA,EACA;AAAA;AD5LRhD,EAjBGmC,GAiBI;AC+LS,MAChBrC,IAAA;"}
|
package/dist/core/Store.d.ts
CHANGED
|
@@ -143,10 +143,10 @@ export default class Store {
|
|
|
143
143
|
* Emits a structured trace event scoped to this store.
|
|
144
144
|
* Prefer the factory form for `payload`: it is only resolved when consumed.
|
|
145
145
|
*/
|
|
146
|
-
trace(label: string,
|
|
146
|
+
trace(label: string, scope?: string, payload?: TracePayload, namespace?: string): void;
|
|
147
147
|
/**
|
|
148
148
|
* Emits a structured error event, or rethrows it when no listener matches.
|
|
149
149
|
*/
|
|
150
|
-
traceError(label: string, error: unknown,
|
|
150
|
+
traceError(label: string, error: unknown, scope?: string, payload?: TracePayload, namespace?: string): void;
|
|
151
151
|
private traceLabelFormatter;
|
|
152
152
|
}
|
package/dist/helpers.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var b = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var c = (e, r,
|
|
4
|
-
import { p as
|
|
5
|
-
import { P
|
|
2
|
+
var y = (e, r, t) => r in e ? b(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var c = (e, r, t) => y(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { p as _ } from "./chunks/constantes-2FeJfVVy.js";
|
|
5
|
+
import { P, S as F, i as B } from "./chunks/constantes-2FeJfVVy.js";
|
|
6
6
|
const m = (e, r = "white") => `background-color: ${e}; color: ${r}; padding: 1px; margin-right: 5px; font-size: 12px`;
|
|
7
7
|
function l(e, r) {
|
|
8
8
|
if (Array.isArray(r) ? r.length === 0 : Object.keys(r).length === 0) {
|
|
@@ -15,21 +15,21 @@ function l(e, r) {
|
|
|
15
15
|
}
|
|
16
16
|
if (console.groupCollapsed(
|
|
17
17
|
"%c%s",
|
|
18
|
-
"color: #
|
|
18
|
+
"color: #f7f7b0; padding: 1px; margin-right: 5px; font-size: 11px",
|
|
19
19
|
`[ ${e} ]`
|
|
20
20
|
), Array.isArray(r))
|
|
21
|
-
typeof r[0] == "object" ? r.forEach((
|
|
22
|
-
|
|
23
|
-
}) : r.forEach((
|
|
21
|
+
typeof r[0] == "object" ? r.forEach((o) => {
|
|
22
|
+
o._name ? l(o._name, o) : o._id ? l(o._id, o) : console.dir(o);
|
|
23
|
+
}) : r.forEach((o, s) => {
|
|
24
24
|
console.log(
|
|
25
25
|
"%c%s",
|
|
26
26
|
"color: #cae38f; padding: 1px; margin-right: 5px; font-size: 10px",
|
|
27
27
|
`[ ${s} ]`,
|
|
28
|
-
|
|
28
|
+
o
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
31
|
else {
|
|
32
|
-
let
|
|
32
|
+
let o = [];
|
|
33
33
|
Object.keys(r).forEach((s) => {
|
|
34
34
|
const i = r[s];
|
|
35
35
|
typeof i == "object" ? Array.isArray(i) ? typeof i[0] == "object" ? l(s, i) : (console.groupCollapsed(s), console.log(i), console.groupEnd()) : l(s, Object.assign({}, i)) : i ? console.log(
|
|
@@ -37,54 +37,57 @@ function l(e, r) {
|
|
|
37
37
|
"color: #b0fa05; padding: 1px; margin-right: 5px; font-size: 10px",
|
|
38
38
|
`[ ${s} ]`,
|
|
39
39
|
i
|
|
40
|
-
) :
|
|
41
|
-
}),
|
|
40
|
+
) : o.push(s);
|
|
41
|
+
}), o.length && console.log(
|
|
42
42
|
"%c%s",
|
|
43
43
|
"color: #f86f63; font-size: 9px",
|
|
44
44
|
"[ Empty properties ]",
|
|
45
|
-
|
|
45
|
+
o
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
console.groupEnd();
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function p(e) {
|
|
51
51
|
Object.keys(e).forEach((r) => {
|
|
52
52
|
if (["label", "namespace", "scope", "source"].includes(r))
|
|
53
53
|
return;
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
switch (typeof
|
|
54
|
+
const t = e[r];
|
|
55
|
+
if (t)
|
|
56
|
+
switch (typeof t) {
|
|
57
57
|
case "string":
|
|
58
58
|
console.log(
|
|
59
59
|
"%c%s",
|
|
60
60
|
"color: #fafa05; padding: 1px; margin-right: 5px; font-size: 10px",
|
|
61
61
|
`[ ${r} ]`,
|
|
62
|
-
|
|
62
|
+
t
|
|
63
63
|
);
|
|
64
64
|
break;
|
|
65
65
|
case "object":
|
|
66
66
|
switch (r) {
|
|
67
67
|
case "mutation":
|
|
68
|
-
console.groupCollapsed("[mutation]"), console.dir(
|
|
68
|
+
console.groupCollapsed("[mutation]"), console.dir(t), console.groupEnd();
|
|
69
69
|
break;
|
|
70
70
|
case "options":
|
|
71
|
-
l(r,
|
|
71
|
+
l(r, t?.storeOptions ?? t);
|
|
72
72
|
break;
|
|
73
73
|
case "payload":
|
|
74
|
-
|
|
74
|
+
p(t);
|
|
75
75
|
break;
|
|
76
76
|
case "store":
|
|
77
|
-
l(r,
|
|
77
|
+
l(r, {
|
|
78
|
+
$state: t.$state,
|
|
79
|
+
...Object.keys(t).reduce((n, o) => (o.startsWith("$") && !["$id", "$state"].includes(o) || o.startsWith("_") || (n[o] = t[o]), n), {})
|
|
80
|
+
});
|
|
78
81
|
break;
|
|
79
82
|
default:
|
|
80
|
-
l(r,
|
|
83
|
+
l(r, t);
|
|
81
84
|
}
|
|
82
85
|
break;
|
|
83
86
|
case "function":
|
|
84
|
-
console.dir(
|
|
87
|
+
console.dir(t);
|
|
85
88
|
break;
|
|
86
89
|
default:
|
|
87
|
-
console.info(
|
|
90
|
+
console.info(t);
|
|
88
91
|
}
|
|
89
92
|
});
|
|
90
93
|
}
|
|
@@ -98,23 +101,32 @@ function x(e, r) {
|
|
|
98
101
|
...r
|
|
99
102
|
);
|
|
100
103
|
}
|
|
101
|
-
function E(e, r,
|
|
104
|
+
function E(e, r, t) {
|
|
102
105
|
if (!e)
|
|
103
106
|
throw new Error("Style instructions are required");
|
|
104
|
-
const n = r.shift(),
|
|
107
|
+
const n = r.shift(), o = r[0];
|
|
108
|
+
if (!o?.payload || Object.keys(o.payload).length === 0) {
|
|
109
|
+
console.log(
|
|
110
|
+
"%c%s",
|
|
111
|
+
e,
|
|
112
|
+
`${o?.label ?? o?.namespace}`,
|
|
113
|
+
o?.source
|
|
114
|
+
);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
105
117
|
console.groupCollapsed(
|
|
106
118
|
"%c%s",
|
|
107
119
|
e,
|
|
108
120
|
`${n}
|
|
109
121
|
`,
|
|
110
|
-
|
|
122
|
+
o?.source
|
|
111
123
|
), r.forEach((s) => {
|
|
112
124
|
switch (typeof s) {
|
|
113
125
|
case "string":
|
|
114
126
|
console.info(s);
|
|
115
127
|
break;
|
|
116
128
|
case "object":
|
|
117
|
-
Array.isArray(s) ? console.table(s) :
|
|
129
|
+
Array.isArray(s) ? console.table(s) : p(s);
|
|
118
130
|
break;
|
|
119
131
|
case "function":
|
|
120
132
|
console.dir(s);
|
|
@@ -122,13 +134,9 @@ function E(e, r, o) {
|
|
|
122
134
|
default:
|
|
123
135
|
console.info(s);
|
|
124
136
|
}
|
|
125
|
-
}), console.
|
|
126
|
-
"%c%s",
|
|
127
|
-
"color: #fafa05; padding: 1px; margin-right: 5px; font-size: 10px",
|
|
128
|
-
"[ trace ]"
|
|
129
|
-
), console.trace(), console.groupEnd(), console.groupEnd();
|
|
137
|
+
}), console.groupEnd();
|
|
130
138
|
}
|
|
131
|
-
class
|
|
139
|
+
class $ {
|
|
132
140
|
constructor() {
|
|
133
141
|
c(this, "_bgColor", "transparent");
|
|
134
142
|
c(this, "_color", "#f2f286");
|
|
@@ -142,8 +150,8 @@ class A {
|
|
|
142
150
|
info: { bgColor: this._bgColor, color: this._color, icon: this._icon }
|
|
143
151
|
});
|
|
144
152
|
}
|
|
145
|
-
formatMessage(r,
|
|
146
|
-
return this._pluginName ? ` [${
|
|
153
|
+
formatMessage(r, t) {
|
|
154
|
+
return this._pluginName ? ` [${t} ${this._pluginName}]
|
|
147
155
|
${r}
|
|
148
156
|
` : r;
|
|
149
157
|
}
|
|
@@ -165,42 +173,45 @@ class A {
|
|
|
165
173
|
r
|
|
166
174
|
);
|
|
167
175
|
}
|
|
168
|
-
rebuildArgs(r,
|
|
176
|
+
rebuildArgs(r, t) {
|
|
169
177
|
if (typeof r == "string")
|
|
170
178
|
return [r];
|
|
171
179
|
if (Array.isArray(r))
|
|
172
180
|
return [r.shift(), ...r ?? []];
|
|
173
181
|
}
|
|
174
|
-
useLog(r,
|
|
182
|
+
useLog(r, t) {
|
|
175
183
|
x(
|
|
176
184
|
this.generateStyle(r),
|
|
177
|
-
this.rebuildArgs(
|
|
185
|
+
this.rebuildArgs(t, r.icon)
|
|
178
186
|
);
|
|
179
187
|
}
|
|
180
188
|
}
|
|
181
|
-
class
|
|
182
|
-
constructor(
|
|
189
|
+
class A extends $ {
|
|
190
|
+
constructor(t) {
|
|
183
191
|
super();
|
|
184
|
-
c(this, "_pluginName",
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
logGroup(o, n) {
|
|
188
|
-
this.startGroup(), this.log(o, n), this.endGroup();
|
|
189
|
-
}
|
|
190
|
-
startGroup(o) {
|
|
191
|
-
console.group(o);
|
|
192
|
+
c(this, "_pluginName", _);
|
|
193
|
+
t && (this._pluginName = t);
|
|
192
194
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
+
logGroup(t) {
|
|
196
|
+
const o = t.shift()?.[1];
|
|
197
|
+
console.groupCollapsed(
|
|
198
|
+
"%c%s",
|
|
199
|
+
"color: #68ca59; padding: 1px; margin-right: 5px; font-size: 12px",
|
|
200
|
+
`[ 🍍 ${o?.label ?? o?.namespace} ] - ${o?.scope}`
|
|
201
|
+
), o?.payload && p(o.payload), console.groupCollapsed(
|
|
202
|
+
"%c%s",
|
|
203
|
+
"color: #f1f6b7; padding: 1px; margin-right: 5px; font-size: 11px",
|
|
204
|
+
"[ TRACES ]"
|
|
205
|
+
), t.forEach((s) => this.log(...s)), console.groupEnd(), console.groupEnd();
|
|
195
206
|
}
|
|
196
|
-
useLog(
|
|
207
|
+
useLog(t, n) {
|
|
197
208
|
E(
|
|
198
|
-
this.generateStyle(
|
|
199
|
-
this.rebuildArgs(n,
|
|
209
|
+
this.generateStyle(t),
|
|
210
|
+
this.rebuildArgs(n, t.icon)
|
|
200
211
|
);
|
|
201
212
|
}
|
|
202
213
|
}
|
|
203
|
-
function
|
|
214
|
+
function C(e) {
|
|
204
215
|
if (typeof e != "function")
|
|
205
216
|
return e;
|
|
206
217
|
try {
|
|
@@ -210,11 +221,11 @@ function $(e) {
|
|
|
210
221
|
}
|
|
211
222
|
}
|
|
212
223
|
class T {
|
|
213
|
-
constructor(r,
|
|
224
|
+
constructor(r, t, n = {}) {
|
|
214
225
|
c(this, "_listeners", []);
|
|
215
226
|
c(this, "_scope");
|
|
216
227
|
c(this, "_source");
|
|
217
|
-
this._scope = n.scope, this._source = r, this._listeners =
|
|
228
|
+
this._scope = n.scope, this._source = r, this._listeners = t;
|
|
218
229
|
}
|
|
219
230
|
get scope() {
|
|
220
231
|
return this._scope;
|
|
@@ -225,66 +236,69 @@ class T {
|
|
|
225
236
|
get source() {
|
|
226
237
|
return this._source;
|
|
227
238
|
}
|
|
228
|
-
debug(r,
|
|
229
|
-
this.emit("debug", r,
|
|
239
|
+
debug(r, t, n, o) {
|
|
240
|
+
this.emit("debug", r, t, n, o);
|
|
230
241
|
}
|
|
231
|
-
error(r,
|
|
232
|
-
this.emit("error", r,
|
|
242
|
+
error(r, t, n, o, s) {
|
|
243
|
+
this.emit("error", r, t, o, s, n);
|
|
233
244
|
}
|
|
234
|
-
emit(r,
|
|
245
|
+
emit(r, t, n, o, s, i) {
|
|
235
246
|
if (this._listeners.length === 0) {
|
|
236
247
|
r === "error" && console.error("Unhandled error trace event:", i);
|
|
237
248
|
return;
|
|
238
249
|
}
|
|
239
250
|
const a = {
|
|
240
|
-
label:
|
|
251
|
+
label: t,
|
|
241
252
|
level: r,
|
|
242
253
|
namespace: n,
|
|
243
254
|
scope: s ?? this._scope,
|
|
244
255
|
source: this._source
|
|
245
|
-
},
|
|
256
|
+
}, h = this._listeners.filter((f) => {
|
|
246
257
|
try {
|
|
247
|
-
return
|
|
248
|
-
} catch (
|
|
249
|
-
return console.error("Error in trace listener filter:",
|
|
258
|
+
return f.filter(a);
|
|
259
|
+
} catch (u) {
|
|
260
|
+
return console.error("Error in trace listener filter:", u), !1;
|
|
250
261
|
}
|
|
251
262
|
});
|
|
252
|
-
if (
|
|
263
|
+
if (h.length === 0) {
|
|
253
264
|
r === "error" && console.error("Unhandled error trace event:", i);
|
|
254
265
|
return;
|
|
255
266
|
}
|
|
256
267
|
const d = {
|
|
257
268
|
...a,
|
|
258
269
|
...i !== void 0 && { error: i },
|
|
259
|
-
...
|
|
270
|
+
...o !== void 0 && { payload: C(o) },
|
|
260
271
|
timestamp: Date.now()
|
|
261
272
|
};
|
|
262
|
-
for (const
|
|
273
|
+
for (const f of h)
|
|
263
274
|
try {
|
|
264
|
-
|
|
265
|
-
} catch (
|
|
266
|
-
console.error("Error in trace listener:",
|
|
275
|
+
f.handler(d);
|
|
276
|
+
} catch (u) {
|
|
277
|
+
console.error("Error in trace listener:", u);
|
|
267
278
|
}
|
|
268
279
|
}
|
|
269
280
|
}
|
|
270
|
-
function w(e) {
|
|
271
|
-
const r = Object.keys(e).reduce((o, n) => (n !== "level" && n !== "timestamp" && (o[n] = e[n]), o), {});
|
|
272
|
-
return [j(e), r];
|
|
273
|
-
}
|
|
274
281
|
function j(e) {
|
|
282
|
+
const r = Object.keys(e).reduce((t, n) => (n !== "level" && n !== "timestamp" && (t[n] = e[n]), t), {});
|
|
283
|
+
return [w(e), r];
|
|
284
|
+
}
|
|
285
|
+
function w(e) {
|
|
275
286
|
return e.scope ? `${e.label} [${e.scope}]` : `${e.label}`;
|
|
276
287
|
}
|
|
277
|
-
function k(e) {
|
|
278
|
-
|
|
288
|
+
function k(e, r) {
|
|
289
|
+
const t = r.level === "error" ? "error" : "log";
|
|
290
|
+
e[t](...j(r));
|
|
291
|
+
}
|
|
292
|
+
function z(e) {
|
|
293
|
+
return e || (e = new A()), {
|
|
279
294
|
handler(r) {
|
|
280
|
-
|
|
281
|
-
e[o](...w(r));
|
|
295
|
+
k(e, r);
|
|
282
296
|
}
|
|
283
297
|
};
|
|
284
298
|
}
|
|
285
|
-
function
|
|
286
|
-
return (
|
|
287
|
-
const i = o
|
|
299
|
+
function g(e, r) {
|
|
300
|
+
return (t) => e[r](({ comparator: n = "equals", target: o, value: s }) => {
|
|
301
|
+
const i = t[o];
|
|
288
302
|
if (typeof i != "string") return !1;
|
|
289
303
|
let a = !1;
|
|
290
304
|
switch (n) {
|
|
@@ -309,21 +323,21 @@ function h(e, r) {
|
|
|
309
323
|
}
|
|
310
324
|
function L(e, r = "every") {
|
|
311
325
|
return Array.isArray(e) && (e = {
|
|
312
|
-
filter:
|
|
313
|
-
}), e.filter && Array.isArray(e.filter) && (e.filter =
|
|
326
|
+
filter: g(e, r)
|
|
327
|
+
}), e.filter && Array.isArray(e.filter) && (e.filter = g(e.filter, r)), (!e.filter || typeof e.filter != "function") && (e = { ...e, filter: () => !0 }), e;
|
|
314
328
|
}
|
|
315
|
-
function
|
|
316
|
-
return e = L(e, r), e?.handler || (e = { ...e, ...
|
|
329
|
+
function O(e, r = "every") {
|
|
330
|
+
return e = L(e, r), e?.handler || (e = { ...e, ...z() }), e;
|
|
317
331
|
}
|
|
318
|
-
function
|
|
332
|
+
function W() {
|
|
319
333
|
let e = [];
|
|
320
|
-
function r(
|
|
321
|
-
return (!
|
|
322
|
-
const i = e.indexOf(
|
|
334
|
+
function r(o, s = "every") {
|
|
335
|
+
return (!o || !o?.handler) && (o = O(o, s)), (!("filter" in o) || typeof o.filter != "function") && (o = { ...o, filter: () => !0 }), e.push(o), () => {
|
|
336
|
+
const i = e.indexOf(o);
|
|
323
337
|
i !== -1 && e.splice(i, 1);
|
|
324
338
|
};
|
|
325
339
|
}
|
|
326
|
-
function
|
|
340
|
+
function t() {
|
|
327
341
|
e = [];
|
|
328
342
|
}
|
|
329
343
|
function n() {
|
|
@@ -331,18 +345,18 @@ function N() {
|
|
|
331
345
|
}
|
|
332
346
|
return {
|
|
333
347
|
addTraceListener: r,
|
|
334
|
-
clearTraceListeners:
|
|
335
|
-
createTracer: (
|
|
348
|
+
clearTraceListeners: t,
|
|
349
|
+
createTracer: (o, s = {}) => new T(o, e, s),
|
|
336
350
|
hasTraceListeners: n
|
|
337
351
|
};
|
|
338
352
|
}
|
|
339
353
|
export {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
354
|
+
$ as CustomConsole,
|
|
355
|
+
P as PluginSubscriber,
|
|
356
|
+
F as Store,
|
|
343
357
|
T as Tracer,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
358
|
+
z as createConsoleTraceListener,
|
|
359
|
+
W as createTracerRegistry,
|
|
360
|
+
B as isEmpty
|
|
347
361
|
};
|
|
348
362
|
//# sourceMappingURL=helpers.js.map
|