pinia-plugin-subscription 0.2.0-beta.0 → 0.2.1

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.
@@ -1,7 +1,7 @@
1
1
  var f = Object.defineProperty;
2
- var b = (s, t, e) => t in s ? f(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var n = (s, t, e) => b(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { ref as S, toRef as y } from "vue";
2
+ var S = (s, t, e) => t in s ? f(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var n = (s, t, e) => S(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { isRef as b, ref as y, toRef as C } from "vue";
5
5
  import { defineStore as g } from "pinia";
6
6
  class L {
7
7
  constructor(t, e, r) {
@@ -57,7 +57,7 @@ class L {
57
57
  return this._storeInstance = this._createInstance(t, { ...e, ...this.pluginOptions }, r, this.console), this._storeInstance ? (this._subscriptions = this._storeInstance.getSubscriptions(), this._storeMutationSubscription = this._storeInstance.storeSubscribe, this._storeOnActionSubscription = this._storeInstance.onAction, this.pluginCreated && this.pluginCreated(t), !0) : !1;
58
58
  }
59
59
  }
60
- class C {
60
+ class A {
61
61
  constructor(t, e) {
62
62
  n(this, "_console");
63
63
  n(this, "_debug", !1);
@@ -82,17 +82,17 @@ class C {
82
82
  this.console.error(...t);
83
83
  }
84
84
  }
85
- const p = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new WeakSet(), A = 50;
86
- function O(s) {
85
+ const p = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new WeakSet(), O = 50;
86
+ function x(s) {
87
87
  return s?.storeOptions?.debug === !0;
88
88
  }
89
89
  function h(s, t, e) {
90
- if (!O(t))
90
+ if (!x(t))
91
91
  return;
92
92
  const r = c.size;
93
- console.debug(`[defineAStoreSetup] ${s} - ${e} (contextsById=${r})`), r >= A && console.warn(`[defineAStoreSetup] contextsById reached ${r} entries`);
93
+ console.debug(`[defineAStoreSetup] ${s} - ${e} (contextsById=${r})`), r >= O && console.warn(`[defineAStoreSetup] contextsById reached ${r} entries`);
94
94
  }
95
- function x(s, t, e) {
95
+ function $(s, t, e) {
96
96
  if (l.has(s) || typeof s.$dispose != "function")
97
97
  return;
98
98
  const r = s.$dispose;
@@ -104,13 +104,13 @@ function N(s, t, e) {
104
104
  s,
105
105
  t,
106
106
  r
107
- ) : $(
107
+ ) : m(
108
108
  s,
109
109
  t,
110
110
  r
111
111
  );
112
112
  }
113
- function R(s, t, e) {
113
+ function T(s, t, e) {
114
114
  const r = e ? { storeOptions: { ...e, enhancedStore: !0 } } : { storeOptions: { enhancedStore: !0 } };
115
115
  return d(
116
116
  s,
@@ -122,22 +122,27 @@ function d(s, t, e) {
122
122
  const r = {
123
123
  id: s,
124
124
  extensions: {}
125
- }, o = e?.storeOptions?.enhancedStore === !0, i = g(s, () => t(r), e);
125
+ }, o = e?.storeOptions?.enhancedStore === !0, i = g(
126
+ s,
127
+ () => t(r),
128
+ e
129
+ );
126
130
  return Object.assign(((...u) => {
127
131
  o && (c.set(s, r), h(s, e, "registered context by id"));
128
132
  const a = i(...u);
129
- return o && (p.set(a, r), c.delete(s), h(s, e, "moved context to weak map"), x(a, s, e)), a;
133
+ return o && (p.set(a, r), c.delete(s), h(s, e, "moved context to weak map"), $(a, s, e)), a;
130
134
  }), i);
131
135
  }
132
- function $(s, t, e) {
136
+ function m(s, t, e) {
133
137
  return e && (t = { ...t, ...e ?? {} }), g(s, t);
134
138
  }
135
- const m = /* @__PURE__ */ new Set(["_", "$"]);
136
- function I(s) {
137
- return m.has(s[0]);
138
- }
139
+ const I = /* @__PURE__ */ new Set(["_", "$"]);
139
140
  function w(s) {
140
- return p.get(s) ?? (typeof s?.$id == "string" ? c.get(s.$id) : void 0);
141
+ return I.has(s[0]);
142
+ }
143
+ function E(s) {
144
+ const t = s;
145
+ return p.get(s) ?? (typeof t?.$id == "string" ? c.get(t.$id) : void 0);
141
146
  }
142
147
  function k(s) {
143
148
  const t = s.extensions.enhancedStore ?? s.extensions.extending;
@@ -148,16 +153,16 @@ function k(s) {
148
153
  function M(s, t) {
149
154
  s.extensions.enhancedStore = t, s.extensions.extending = t;
150
155
  }
151
- function T(s) {
152
- return k(s);
156
+ function W(s) {
157
+ return console.warn(`${s.id}Store - getExtendingStore is deprecated. Use getEnhancedStore instead.`), k(s);
153
158
  }
154
- function W(s, t) {
159
+ function F(s, t) {
155
160
  return `${s}-${t.$id}`;
156
161
  }
157
- function E(s) {
162
+ function P(s) {
158
163
  return s ? Array.isArray(s) ? s.length === 0 : typeof s == "object" ? Object.keys(s).length === 0 : typeof s == "string" ? s.trim() === "" : !1 : !(typeof s == "boolean" || typeof s == "number");
159
164
  }
160
- class P extends C {
165
+ class q extends A {
161
166
  constructor(e, r, o = !1, i) {
162
167
  super(o, i);
163
168
  n(this, "_className", "Store");
@@ -167,7 +172,7 @@ class P extends C {
167
172
  n(this, "_subscriptions", {});
168
173
  n(this, "_storeSubscribe");
169
174
  if (this._options = r.storeOptions, this._store = e, this._options?.enhancedStore) {
170
- const u = w(this.store);
175
+ const u = E(this.store);
171
176
  u && M(u, this.store);
172
177
  }
173
178
  }
@@ -203,26 +208,14 @@ class P extends C {
203
208
  set storeSubscribe(e) {
204
209
  this._storeSubscribe = e;
205
210
  }
206
- /**
207
- * Add property to state
208
- * @param name
209
- * @param value
210
- */
211
211
  addToState(e, r) {
212
- this.isOptionApi() || r?.value || (r = S(r)), this.state[e] = r, this.store[e] = y(this.state, e);
212
+ this.isOptionApi() || b(r) || (r = y(r)), this.state[e] = r, this.store[e] = C(this.state, e);
213
213
  }
214
214
  addSubscription(e, r, o) {
215
215
  this._subscriptions[e] = { subscription: r, ...o ?? {} };
216
216
  }
217
217
  afterHydration() {
218
218
  }
219
- /**
220
- * Create and return a class instance
221
- * @param store
222
- * @param options
223
- * @param debug
224
- * @returns
225
- */
226
219
  static customizeStore(e, r, o = !1, i) {
227
220
  if (r.storeOptions && this.hasRequiredKeys(r.storeOptions))
228
221
  return new this(e, r, o, i);
@@ -234,14 +227,14 @@ class P extends C {
234
227
  return this.getValue(this.state[e]);
235
228
  }
236
229
  getSubscriptions() {
237
- if (!E(this._subscriptions))
230
+ if (!P(this._subscriptions))
238
231
  return this._subscriptions;
239
232
  }
240
233
  getValue(e) {
241
234
  return e?.__v_isRef ? e.value : e;
242
235
  }
243
236
  hasDeniedFirstChar(e) {
244
- return I(e);
237
+ return w(e);
245
238
  }
246
239
  static hasRequiredKeys(e) {
247
240
  return this._requiredKeys !== void 0 && this._requiredKeys?.every((r) => !!e[r]);
@@ -258,9 +251,9 @@ class P extends C {
258
251
  return Object.prototype.hasOwnProperty.call(this.store, e);
259
252
  }
260
253
  }
261
- n(P, "_requiredKeys");
262
- const _ = "pinia-plugin-subscription", q = (s, t = "white") => `background-color: ${s}; color: ${t}; padding: 1px; margin-right: 5px; font-size: 12px`;
263
- function B(s, t) {
254
+ n(q, "_requiredKeys");
255
+ const _ = "pinia-plugin-subscription", B = (s, t = "white") => `background-color: ${s}; color: ${t}; padding: 1px; margin-right: 5px; font-size: 12px`;
256
+ function D(s, t) {
264
257
  if (!s)
265
258
  throw new Error("Style instructions are required");
266
259
  console.log(
@@ -270,7 +263,7 @@ function B(s, t) {
270
263
  ...t
271
264
  );
272
265
  }
273
- class D {
266
+ class K {
274
267
  constructor() {
275
268
  n(this, "_bgColor", "#ffec73");
276
269
  n(this, "_color", "green");
@@ -287,7 +280,7 @@ class D {
287
280
  return ` [${e} ${_}] - ${t} `;
288
281
  }
289
282
  generateStyle(t) {
290
- return q(t.bgColor, t.color);
283
+ return B(t.bgColor, t.color);
291
284
  }
292
285
  getStyleDefinition(t) {
293
286
  return this._styles[t ?? "info"];
@@ -311,33 +304,34 @@ class D {
311
304
  return [this.formatMessage(t.shift(), e), ...t ?? []];
312
305
  }
313
306
  useLog(t, e) {
314
- B(
307
+ D(
315
308
  this.generateStyle(t),
316
309
  this.rebuildArgs(e, t.icon)
317
310
  );
318
311
  }
319
312
  }
320
- class K extends D {
313
+ class R extends K {
321
314
  constructor() {
322
315
  super(...arguments);
323
316
  n(this, "_pluginName", _);
324
317
  }
325
318
  }
326
- const F = new K();
319
+ const V = new R();
327
320
  export {
328
- D as C,
329
- C as D,
330
- F as P,
331
- P as S,
321
+ K as C,
322
+ A as D,
323
+ V as P,
324
+ q as S,
332
325
  L as a,
333
- R as b,
334
- w as c,
326
+ T as b,
327
+ E as c,
335
328
  N as d,
336
329
  k as e,
337
- T as f,
338
- W as g,
339
- I as h,
340
- E as i,
330
+ W as f,
331
+ F as g,
332
+ w as h,
333
+ P as i,
341
334
  _ as p,
342
335
  M as s
343
336
  };
337
+ //# sourceMappingURL=index-DKdl-fiq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DKdl-fiq.js","sources":["../../src/core/PluginSubscriber.ts","../../src/system/Debug.ts","../../src/utils/store.ts","../../src/utils/validation/index.ts","../../src/core/Store.ts","../../src/utils/constantes.ts","../../src/system/log.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 StoreMutationSubscription,\n StoreOnActionSubscription\n} from \"../types/plugin\";\nimport type { Console } from \"../types/log\";\n\n\ntype CreateInstance<Instance = Store> = (store: PiniaStore, options: AnyObject, debug: boolean, customConsole?: Console) => Instance | undefined\n\n\nexport default abstract class PluginSubscriber<Instance extends Store> implements PluginSubscriberInterface {\n private _console?: Console\n private _createInstance: CreateInstance\n private _name: string\n private _pluginOptions?: AnyObject\n private _storeInstance?: Instance\n protected _resetStoreCallback?: (store?: PiniaStore) => void\n private _storeOnActionSubscription?: StoreOnActionSubscription\n private _storeMutationSubscription?: StoreMutationSubscription\n private _subscriptions?: PluginSubscriptions\n protected pluginCreated?: (store: PiniaStore) => void\n public execution?: PluginExecutionOptions\n public hydrationScheduler?: PluginHydrationScheduler\n\n\n get console(): Console {\n return this._console ?? console\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(): AnyObject {\n return this._pluginOptions ?? {};\n }\n\n set pluginOptions(options: AnyObject | 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, pluginConsole?: Console) {\n this._name = pluginName\n this._createInstance = createInstanceFunction\n\n if (pluginConsole) {\n this._console = pluginConsole\n }\n }\n\n\n public afterHydration(context: PiniaPluginContext, debug: boolean): void | Promise<void> {\n return\n }\n\n public hydrate(context: PiniaPluginContext, debug: boolean): void | Promise<void> {\n return\n }\n\n public invoke(\n { store, options }: PiniaPluginContext,\n debug: boolean\n ): boolean {\n this._storeInstance = this._createInstance(store, { ...options, ...this.pluginOptions }, debug, this.console) as Instance\n\n if (!this._storeInstance) {\n return false\n }\n\n this._subscriptions = this._storeInstance.getSubscriptions()\n this._storeMutationSubscription = this._storeInstance.storeSubscribe\n this._storeOnActionSubscription = this._storeInstance.onAction\n\n if (this.pluginCreated) {\n this.pluginCreated(store)\n }\n\n return true\n }\n}","import type { Console } from \"../types/log\"\n\nexport default abstract class Debug {\n protected abstract _className: string\n private _console?: Console\n private _debug: boolean = false\n\n get console(): Console {\n return this._console ?? console\n }\n set console(customConsole: Console) {\n this._console = customConsole\n }\n\n get debug(): boolean { return this._debug }\n set debug(debug: boolean) { this._debug = debug }\n\n constructor(debug: boolean, customConsole?: Console) {\n this._debug = debug\n\n if (customConsole) {\n this._console = customConsole\n }\n }\n\n\n debugLog(...args: any): void {\n if (this._debug) {\n if (Array.isArray(args)) {\n args[0] = `${this._className} - ${args[0]}`\n }\n this.console.log(...args)\n }\n }\n\n logError(...args: any): void {\n this.console.error(...args)\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 PluginStoreOptions,\n StoreOptions\n} from \"../types/store\"\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>()\nconst setupContextMapWarnThreshold = 50\n\nfunction isSetupContextDebugEnabled(options: PluginStoreOptions): boolean {\n return options?.storeOptions?.debug === true\n}\n\nfunction logSetupContextMapSizes(id: string, options: PluginStoreOptions, action: string): void {\n if (!isSetupContextDebugEnabled(options)) {\n return\n }\n\n const setupContextByIdSize = defineAStoreSetupContextsById.size\n console.debug(`[defineAStoreSetup] ${id} - ${action} (contextsById=${setupContextByIdSize})`)\n\n if (setupContextByIdSize >= setupContextMapWarnThreshold) {\n console.warn(`[defineAStoreSetup] contextsById reached ${setupContextByIdSize} entries`)\n }\n}\n\nfunction registerSetupContextCleanupOnDispose(\n store: AnyObject,\n id: string,\n options: PluginStoreOptions\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 logSetupContextMapSizes(id, options, 'dispose cleanup')\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 logSetupContextMapSizes(id, options, 'registered context by id')\n }\n\n const store = useStore(...args)\n\n if (shouldStoreSetupContext) {\n defineAStoreSetupContexts.set(store, setupContext as DefineAStoreSetupContext<AnyObject>)\n defineAStoreSetupContextsById.delete(id)\n logSetupContextMapSizes(id, options, 'moved context to weak map')\n registerSetupContextCleanupOnDispose(store as AnyObject, id, options)\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 Debug from \"../system/Debug\"\nimport { getDefineAStoreSetupContext, hasDeniedFirstChar, setEnhancedStore } from \"../utils/store\"\nimport { isEmpty } from \"../utils/validation\"\n\nimport type {\n PluginSubscriptions,\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 { Console } from \"../types/log\"\nimport type { AnyObject, PluginSubscriberInterface } from \"../types\"\nimport type { StoreOptions, StatePropertyValue } from \"../types/store\"\n\n\nexport default class Store extends Debug {\n protected _className = 'Store'\n private _onAction?: StoreOnActionSubscriptionCallback\n private _options: StoreOptions\n private _store: PiniaStore\n private _subscriptions: PluginSubscriptions = {}\n private _storeSubscribe?: StoreMutationSubscriptionCallback\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 constructor(store: PiniaStore, options: AnyObject, debug: boolean = false, customConsole?: Console) {\n super(debug, customConsole)\n this._options = options.storeOptions\n this._store = store\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 * Add property to state\n * @param name \n * @param value \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 addSubscription(\n pluginName: string,\n subscription: PluginSubscriberInterface,\n options?: { subscriptionOptions?: StoreOptions, stores?: PiniaStore[] }\n ): void {\n this._subscriptions[pluginName] = { subscription, ...(options ?? {}) }\n }\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 * @param debug \n * @returns \n */\n static customizeStore<Instance extends Store>(\n store: PiniaStore,\n options: AnyObject,\n debug: boolean = false,\n customConsole?: Console\n ): Instance | undefined {\n if (options.storeOptions && this.hasRequiredKeys(options.storeOptions)) {\n return new this(store, options, debug, customConsole) as Instance\n }\n }\n\n getOption(optionName: keyof StoreOptions) {\n return this.options && (this.options as StoreOptions)[optionName]\n }\n\n getStatePropertyValue(propertyName: string) {\n return this.getValue(this.state[propertyName])\n }\n\n getSubscriptions(): PluginSubscriptions | undefined {\n if (isEmpty(this._subscriptions)) {\n return\n }\n\n return this._subscriptions\n }\n\n getValue(value: any) {\n return value?.__v_isRef ? value.value : value\n }\n\n protected hasDeniedFirstChar(property: string): boolean {\n return hasDeniedFirstChar(property)\n }\n\n protected static hasRequiredKeys(options: AnyObject): boolean {\n return this._requiredKeys !== undefined && this._requiredKeys?.every(requiredKey => !!options[requiredKey])\n }\n\n hydrate(): void | Promise<void> {\n return\n }\n\n isOptionApi(): boolean { return this.store._isOptionsAPI }\n\n stateHas(property: string): boolean { return Object.prototype.hasOwnProperty.call(this.state, property) }\n\n storeHas(property: string): boolean { return Object.prototype.hasOwnProperty.call(this.store, property) }\n}","export const pluginName: string = 'pinia-plugin-subscription'","import { pluginName } from '../utils/constantes'\nimport type { Console, LogType, StyleDefinition, StyleDefinitions } from '../types/log'\n\n\nconst style = (bgColor: string, color: string = 'white') =>\n `background-color: ${bgColor}; color: ${color}; padding: 1px; margin-right: 5px; font-size: 12px`\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\nexport abstract class CustomConsole implements Console {\n protected _bgColor: string = '#ffec73'\n protected _color: string = 'green'\n protected _icon: string = '🍍⚡'\n protected _errorBgColor: string = '#d24545'\n protected _errorColor: string = 'white'\n protected _errorIcon: string = '🍍⚠️'\n protected abstract _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 ` [${icon} ${pluginName}] - ${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[], icon: string) {\n if (typeof args === 'string') {\n return [this.formatMessage(args, icon)]\n }\n\n if (Array.isArray(args)) {\n return [this.formatMessage(args.shift(), icon), ...(args ?? [])]\n }\n }\n\n protected useLog(styleDefinition: StyleDefinition, args: any) {\n log(\n this.generateStyle(styleDefinition),\n this.rebuildArgs(args, styleDefinition.icon)\n )\n }\n}\n\nclass PluginConsoleClass extends CustomConsole {\n protected _pluginName: string = pluginName\n}\n\nexport const PluginConsole = new PluginConsoleClass()"],"names":["PluginSubscriber","pluginName","createInstanceFunction","pluginConsole","__publicField","options","subscriptions","context","debug","store","Debug","customConsole","args","defineAStoreSetupContexts","defineAStoreSetupContextsById","setupContextDisposeWrappedStores","setupContextMapWarnThreshold","isSetupContextDebugEnabled","logSetupContextMapSizes","id","action","setupContextByIdSize","registerSetupContextCleanupOnDispose","originalDispose","defineAStore","storeDefinition","storeOptions","defineAStoreSetup","defineAStoreOptionApi","defineAStoreCtx","setupContext","shouldStoreSetupContext","useStore","defineStore","deniedFirstChar","hasDeniedFirstChar","property","getDefineAStoreSetupContext","storeRecord","getEnhancedStore","ctx","enhancedStore","setEnhancedStore","getExtendingStore","getActionStoreKey","actionName","isEmpty","value","Store","onAction","state","storeSubscribe","name","isRef","ref","subscription","optionName","propertyName","requiredKey","style","bgColor","color","log","logStyle","CustomConsole","message","icon","styleDefinition","messageType","PluginConsoleClass","PluginConsole"],"mappings":";;;;;AAiBA,MAA8BA,EAA8E;AAAA,EAwDxG,YAAYC,GAAoBC,GAAwCC,GAAyB;AAvDzF,IAAAC,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACE,IAAAA,EAAA;AACF,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACE,IAAAA,EAAA;AACH,IAA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c;AAAA,MACtD,KAAI,iBAA0B,IAAA;AAAA,IAC1B;AAAA,EAAsC;AAG1C;AACI,MAAAE,UAA2BL,EAAc;AAAA,EAAzC;AAAA;AAA+D,IAAA5D,EAAA,qBACnEH;AAAA;AAAA;AACJ,MAEUqE,IAAO,IAAkCD,EAAW;"}
@@ -5,11 +5,13 @@ export default class PluginSubscription extends Debug {
5
5
  protected _className: string;
6
6
  private _hydrationScheduler;
7
7
  private _onActionSubscriptions;
8
+ private _onActionStores;
8
9
  private _onActionAfterSubscriptions;
9
10
  private _onActionOnErrorSubscriptions;
10
11
  private _options?;
11
12
  private _pluginDebug?;
12
13
  private _resetStoreCallback;
14
+ private _disposedStores;
13
15
  private _storeRollbackSnapshotsHandler;
14
16
  private _subscribers;
15
17
  private _subscribersDelivered;
@@ -11,6 +11,7 @@ export default class RollbackStateSnapshotsHandler {
11
11
  /**
12
12
  * Adds a rollback action to the given store.
13
13
  * This method extends the store with a $rollbackAfterFailure function that handles rollback logic for actions.
14
+ * The action arguments are forwarded through apply(), so they must be provided as a single array.
14
15
  * @param {Store} store The store to which the rollback action will be added.
15
16
  * @returns void
16
17
  */
package/dist/helpers.js CHANGED
@@ -1,7 +1,8 @@
1
- import { C as a, a as r, S as e, i } from "./chunks/index-D-rnwSJk.js";
1
+ import { C as a, a as r, S as e, i } from "./chunks/index-DKdl-fiq.js";
2
2
  export {
3
3
  a as CustomConsole,
4
4
  r as PluginSubscriber,
5
5
  e as Store,
6
6
  i as isEmpty
7
7
  };
8
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -3,7 +3,7 @@ import PluginSubscription from '../core/PluginSubscription';
3
3
  import Store from '../core/Store';
4
4
  export { createPlugin } from "../plugins/createPlugin";
5
5
  export { createHydrationPlugin } from "../plugins/createHydrationPlugin";
6
- export type { AnyObject, Console, CustomStore, DefineAStoreSetupContext, DefineAStoreSetupExtensions, EmptyExtensions, PluginExecutionEnvironment, PluginExecutionOptions, PluginHydrationScheduler, PluginHydrationTiming, PluginRuntimeEnvironment, PluginStoreOptions, PluginSubscriptionOptions, PluginSubscriberInterface, PluginSubscriptionDefinition, PluginSubscriptions, StatePropertyValue, StoreOptions, StoreOptionsPropertyValue, StoreMutationSubscription, StoreMutationSubscriptionCallback, StoreOnActionCallbackParameters, StoreOnActionSubscription, StoreOnActionSubscriptionCallback, NativePiniaSubscription, NativePiniaSubscriptionReturn, SearchCollectionCriteria, LogType, StyleDefinition, StyleDefinitionKeys, StyleDefinitions, ConsoleStyleDefinition, ConsoleStyleDefinitionKeys, ConsoleStyleDefinitions, PartialList, ListTypes, ListTypesMap, List } from "../types";
6
+ export type { AnyObject, Console, CustomStore, DefineAStoreSetupContext, DefineAStoreSetupExtensions, EmptyExtensions, PluginExecutionEnvironment, PluginExecutionOptions, PluginHydrationScheduler, PluginHydrationTiming, PluginRuntimeEnvironment, PluginStoreOptions, PluginSubscriptionOptions, PluginSubscriberInterface, PluginSubscriptionDefinition, PluginSubscriptions, StatePropertyValue, StoreOptions, StoreOptionsExtensions, StoreOptionsPropertyValue, StoreMutationSubscription, StoreMutationSubscriptionCallback, StoreOnActionCallbackParameters, StoreOnActionSubscription, StoreOnActionSubscriptionCallback, NativePiniaSubscription, NativePiniaSubscriptionReturn, SearchCollectionCriteria, LogType, StyleDefinition, StyleDefinitionKeys, StyleDefinitions, ConsoleStyleDefinition, ConsoleStyleDefinitionKeys, ConsoleStyleDefinitions, PartialList, ListTypes, ListTypesMap, List } from "../types";
7
7
  export type { StoreMutationSubscriptionReturn, StoreOnActionSubscriptionReturn } from "../types/plugin";
8
8
  export type { RollbackActionParams, RollbackAfterFailureParams } from "../types/store";
9
9
  export { defineAStore, defineAStoreCtx, getDefineAStoreSetupContext, getEnhancedStore, getExtendingStore, setEnhancedStore } from "../utils/store";