pinia-plugin-subscription 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -23
- package/dist/pinia-plugin-subscription.js +1 -1
- package/dist/pinia-plugin-subscription.umd.cjs +1 -1
- package/dist/types/index.d.ts +123 -3
- package/package.json +2 -1
- package/dist/types/comparison.d.ts +0 -3
- package/dist/types/log.d.ts +0 -8
- package/dist/types/plugin.d.ts +0 -34
- package/dist/types/resourceId.d.ts +0 -4
- package/dist/types/store.d.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -5,34 +5,58 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [0.1.
|
|
8
|
+
## [0.1.2] - 2026-08-09
|
|
9
|
+
|
|
10
|
+
### Fix
|
|
11
|
+
- Added export helper class and functions
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.1.1] - 2026-08-08
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- Added a GitHub Actions workflow to run the test suite on every push and pull request.
|
|
18
|
+
- Added npm provenance-based publishing for improved supply-chain security.
|
|
19
|
+
- Added a CODEOWNERS file to require maintainer review for repository changes.
|
|
20
|
+
- Included documentation files in the published npm tarball to improve package quality signals.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Improved package metadata for npm publishing and discoverability.
|
|
24
|
+
- Documented the release and publishing process in the README.
|
|
25
|
+
- Added explicit package publishing configuration for public access and provenance.
|
|
26
|
+
|
|
27
|
+
### Security
|
|
28
|
+
- Improved release transparency by publishing with npm provenance.
|
|
29
|
+
- Added security and contribution documentation to the package contents.
|
|
30
|
+
|
|
31
|
+
## [0.1.0] - 2026-08-07
|
|
9
32
|
|
|
10
33
|
### Added
|
|
11
|
-
- **Core Plugin System:** `createPlugin()` function to create Pinia plugins from subscribers
|
|
12
|
-
- **PluginSubscriber Class:** Abstract base class for creating reusable plugin subscribers
|
|
13
|
-
- **Store Helper Class:** Wrapper around PiniaStore with utilities for state and subscription management
|
|
14
|
-
- **PluginSubscriberInterface:** Interface for implementing custom subscribers
|
|
15
|
-
- **Debug Mode:** Detailed logging support for plugin development and troubleshooting
|
|
16
|
-
- **Reset Callbacks:** Custom store reset logic via `resetStoreCallback
|
|
17
|
-
- **Type Definitions:** Full TypeScript support with comprehensive type exports
|
|
18
|
-
- **Test Suite:** Comprehensive Vitest coverage for all core functionality
|
|
19
|
-
- **Documentation:** Complete README with API reference and examples
|
|
20
|
-
- **MIT License:** Open source license for community use
|
|
34
|
+
- **Core Plugin System:** `createPlugin()` function to create Pinia plugins from subscribers.
|
|
35
|
+
- **PluginSubscriber Class:** Abstract base class for creating reusable plugin subscribers.
|
|
36
|
+
- **Store Helper Class:** Wrapper around PiniaStore with utilities for state and subscription management.
|
|
37
|
+
- **PluginSubscriberInterface:** Interface for implementing custom subscribers.
|
|
38
|
+
- **Debug Mode:** Detailed logging support for plugin development and troubleshooting.
|
|
39
|
+
- **Reset Callbacks:** Custom store reset logic via `resetStoreCallback`.
|
|
40
|
+
- **Type Definitions:** Full TypeScript support with comprehensive type exports.
|
|
41
|
+
- **Test Suite:** Comprehensive Vitest coverage for all core functionality.
|
|
42
|
+
- **Documentation:** Complete README with API reference and examples.
|
|
43
|
+
- **MIT License:** Open source license for community use.
|
|
21
44
|
|
|
22
45
|
### Features
|
|
23
|
-
- Centralized subscriber registration for Pinia stores
|
|
24
|
-
- `$reset` method added to all stores modified by the plugin
|
|
25
|
-
- Support for store mutations and action subscriptions
|
|
26
|
-
- Plugin-specific subscription management
|
|
27
|
-
- State helper methods: `addToState()`, `stateHas()`, `getValue()
|
|
28
|
-
- Store helper methods: `storeHas()
|
|
29
|
-
- Performance monitoring utilities
|
|
30
|
-
- Validation utilities for common object operations
|
|
46
|
+
- Centralized subscriber registration for Pinia stores.
|
|
47
|
+
- `$reset` method added to all stores modified by the plugin.
|
|
48
|
+
- Support for store mutations and action subscriptions.
|
|
49
|
+
- Plugin-specific subscription management.
|
|
50
|
+
- State helper methods: `addToState()`, `stateHas()`, `getValue()`.
|
|
51
|
+
- Store helper methods: `storeHas()`.
|
|
52
|
+
- Performance monitoring utilities.
|
|
53
|
+
- Validation utilities for common object operations.
|
|
31
54
|
|
|
32
55
|
### Documentation
|
|
33
|
-
- Installation and usage examples
|
|
34
|
-
- API reference for all public classes and functions
|
|
35
|
-
- Contributing guidelines
|
|
36
|
-
- Security policy
|
|
56
|
+
- Installation and usage examples.
|
|
57
|
+
- API reference for all public classes and functions.
|
|
58
|
+
- Contributing guidelines.
|
|
59
|
+
- Security policy.
|
|
37
60
|
|
|
61
|
+
[0.1.1]: https://github.com/AlxBDo/pinia-plugin-subscription/releases/tag/v0.1.1
|
|
38
62
|
[0.1.0]: https://github.com/AlxBDo/pinia-plugin-subscription/releases/tag/v0.1.0
|
|
@@ -60,7 +60,7 @@ class Pt {
|
|
|
60
60
|
this._debug = e;
|
|
61
61
|
}
|
|
62
62
|
constructor(e, n) {
|
|
63
|
-
this._debug = e,
|
|
63
|
+
this._debug = e, n && (this._console = n);
|
|
64
64
|
}
|
|
65
65
|
debugLog(...e) {
|
|
66
66
|
this._debug && (Array.isArray(e) && (e[0] = `${this._className} - ${e[0]}`), this.console.log(...e));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(_,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("pinia")):typeof define=="function"&&define.amd?define(["exports","pinia"],F):(_=typeof globalThis<"u"?globalThis:_||self,F(_["pinia-plugin-subscription"]={},_.Pinia))})(this,(function(_,F){"use strict";class be{_console;_createInstance;_name;_pluginOptions;_storeInstance;_resetStoreCallback;_storeOnActionSubscription;_storeMutationSubscription;_subscriptions;pluginCreated;get console(){return this._console??console}get name(){return this._name}get pluginOptions(){return this._pluginOptions??{}}set pluginOptions(e){this._pluginOptions=e}get resetStoreCallback(){return this._resetStoreCallback}get storeOnActionSubscription(){return this._storeOnActionSubscription}get storeMutationSubscription(){return this._storeMutationSubscription}get subscriptions(){return this._subscriptions}set subscriptions(e){this._subscriptions=e}constructor(e,n,r){this._name=e,this._createInstance=n,r&&(this._console=r)}invoke({store:e,options:n},r){return this._storeInstance=this._createInstance(e,{...n,...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(e),!0):!1}}class Tt{_console;_debug=!1;get console(){return this._console??console}set console(e){this._console=e}get debug(){return this._debug}set debug(e){this._debug=e}constructor(e,n){this._debug=e,this._className=this.constructor.name,n&&(this._console=n)}debugLog(...e){this._debug&&(Array.isArray(e)&&(e[0]=`${this._className} - ${e[0]}`),this.console.log(...e))}logError(...e){this.console.error(...e)}}const pt="pinia-plugin-subscription",me=(t,e="white")=>`background-color: ${t}; color: ${e}; padding: 1px; margin-right: 5px; font-size: 12px`;function ye(t,e){if(!t)throw new Error("Style instructions are required");console.log("%c%s",t,e.shift(),...e)}class xt{_bgColor="#ffec73";_color="green";_icon="🍍⚡";_errorBgColor="#d24545";_errorColor="white";_errorIcon="🍍⚠️";_styles={error:{bgColor:this._errorBgColor,color:this._errorColor,icon:this._errorIcon},info:{bgColor:this._bgColor,color:this._color,icon:this._icon}};formatMessage(e,n){return` [${n} ${pt}] - ${e} `}generateStyle(e){return me(e.bgColor,e.color)}getStyleDefinition(e){return this._styles[e??"info"]}log(...e){this.useLog(this.getStyleDefinition(),e)}error(...e){this.useLog(this.getStyleDefinition("error"),e)}rebuildArgs(e,n){if(typeof e=="string")return[this.formatMessage(e,n)];if(Array.isArray(e))return[this.formatMessage(e.shift(),n),...e??[]]}useLog(e,n){ye(this.generateStyle(e),this.rebuildArgs(n,e.icon))}}class Se extends xt{_pluginName=pt}const Oe=new Se;function Q(t){return t?Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:typeof t=="string"?t.trim()==="":!1:!(typeof t=="boolean"||typeof t=="number")}const Mt="PluginSubscription";class Pt extends Tt{_className=Mt;_pluginDebug;_resetStoreCallback=[];_subscribers=[];_subscribersDelivered=new Set;_subscriptions=[];_subscriptionsDelivered=new Set;set subscribers(e){this._subscribers=e}get subscriptions(){if(!Q(this._subscriptions))return this._subscriptions}constructor(e,n){super(Array.isArray(n)&&!!n?.includes(Mt),Oe),this._pluginDebug=Array.isArray(n)?n:void 0,this._subscribers=e}addResetStoreCallback(e){this._resetStoreCallback.push(e)}definePluginDebug(e){return!!this._pluginDebug?.includes(e.name)}executeResetStoreCallbacks(e){this._resetStoreCallback.forEach(n=>n(e))}plugin({store:e,options:n}){if(this._subscribers.length){this.debugLog(`plugin() - ${e.$id}`,["subscriber:",this._subscribers,"store:",e,"options:",n]);try{this._subscribers.forEach(r=>{this._subscribersDelivered.has(`${r.name}-${e.$id}`)||r.invoke({store:e,options:n},this.definePluginDebug(r))&&(this._subscribersDelivered.add(`${r.name}-${e.$id}`),r.subscriptions&&this.subscriptionDelivery({store:e,options:n},r.subscriptions),r.storeMutationSubscription&&this.storeMutationSubscription(r.storeMutationSubscription),r.storeOnActionSubscription&&this.storeOnActionSubscription(r.storeOnActionSubscription),r.resetStoreCallback&&this.addResetStoreCallback(r.resetStoreCallback))}),this.rewriteResetStore({store:e},JSON.stringify(e.$state),Object.assign({},e))}catch(r){this.logError(r,e,n)}}}rewriteResetStore({store:e},n,r){e.$reset=()=>{this.debugLog("rewriteResetStore()",{initState:n,store:e,customStore:r}),this.executeResetStoreCallbacks(e),e.$patch(JSON.parse(n))}}storeOnActionSubscription(e){const{store:n,callback:r}=e();n.$onAction(({after:s,args:i,name:o})=>{this.debugLog(`storeOnActionSubscription ${n.$id}`,{after:s,args:i,name:o,store:n}),r({after:s,args:i,name:o})})}storeMutationSubscription(e){const{store:n,callback:r}=e();n.$subscribe(s=>{this.debugLog(`$subscribe ${n.$id}`,{mutation:s,store:n}),r(s)})}subscriptionDelivery({store:e,options:n},r){Object.entries(r).forEach(([s,i])=>{try{if(this._subscriptionsDelivered.has(`${s}-${e.$id}`))return;const{subscription:o,subscriptionOptions:c,stores:a}=i;this.debugLog(`subscriptionDelivery() - store: ${e.$id}`,["pluginName:",s,"subscription:",o,"options:",i,"stores:",a]);const u={storeOptions:{...n?.storeOptions??{},...c}};o.invoke({store:e,options:{...n,...u}},this.debug),this._subscriptionsDelivered.add(`${s}-${e.$id}`),Q(a)||a?.forEach(p=>o.invoke({store:p,options:{...n,...u,...p?.storeOptions??{}}},this.debug))}catch(o){this.logError("subscriptionDelivery()",o,e,n)}})}}function Ee(t){const e=Object.create(null);for(const n of t.split(","))e[n]=1;return n=>n in e}const dt=process.env.NODE_ENV!=="production"?Object.freeze({}):{};process.env.NODE_ENV!=="production"&&Object.freeze([]);const Ft=()=>{},we=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),Ne=t=>t.startsWith("onUpdate:"),D=Object.assign,ve=Object.prototype.hasOwnProperty,_t=(t,e)=>ve.call(t,e),d=Array.isArray,z=t=>kt(t)==="[object Map]",I=t=>typeof t=="function",v=t=>typeof t=="string",T=t=>typeof t=="symbol",b=t=>t!==null&&typeof t=="object",Re=Object.prototype.toString,kt=t=>Re.call(t),jt=t=>kt(t).slice(8,-1),X=t=>v(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Ce=(t=>{const e=Object.create(null);return(n=>e[n]||(e[n]=t(n)))})(t=>t.charAt(0).toUpperCase()+t.slice(1)),x=(t,e)=>!Object.is(t,e);let Kt;const Z=()=>Kt||(Kt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function gt(t){if(d(t)){const e={};for(let n=0;n<t.length;n++){const r=t[n],s=v(r)?Ve(r):gt(r);if(s)for(const i in s)e[i]=s[i]}return e}else if(v(t)||b(t))return t}const Ae=/;(?![^(]*\))/g,Ie=/:([^]+)/,$e=/\/\*[^]*?\*\//g;function Ve(t){const e={};return t.replace($e,"").split(Ae).forEach(n=>{if(n){const r=n.split(Ie);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function bt(t){let e="";if(v(t))e=t;else if(d(t))for(let n=0;n<t.length;n++){const r=bt(t[n]);r&&(e+=r+" ")}else if(b(t))for(const n in t)t[n]&&(e+=n+" ");return e.trim()}function k(t,...e){console.warn(`[Vue warn] ${t}`,...e)}let De,Ht=0,mt;function yt(){Ht++}function St(){if(--Ht>0)return;let t;for(;mt;){let e=mt;for(mt=void 0;e;){const n=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(r){t||(t=r)}e=n}}if(t)throw t}let tt=!0;const Lt=[];function et(){Lt.push(tt),tt=!1}function nt(){const t=Lt.pop();tt=t===void 0?!0:t}class Wt{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0,process.env.NODE_ENV!=="production"&&(this.subsHead=void 0)}track(e){}trigger(e){this.version++,this.notify(e)}notify(e){yt();try{if(process.env.NODE_ENV!=="production")for(let n=this.subsHead;n;n=n.nextSub)n.sub.onTrigger&&!(n.sub.flags&8)&&n.sub.onTrigger(D({effect:n.sub},e));for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{St()}}}const st=new WeakMap,M=Symbol(process.env.NODE_ENV!=="production"?"Object iterate":""),Ot=Symbol(process.env.NODE_ENV!=="production"?"Map keys iterate":""),U=Symbol(process.env.NODE_ENV!=="production"?"Array iterate":"");function g(t,e,n){if(tt&&De){let r=st.get(t);r||st.set(t,r=new Map);let s=r.get(n);s||(r.set(n,s=new Wt),s.map=r,s.key=n),process.env.NODE_ENV!=="production"?s.track({target:t,type:e,key:n}):s.track()}}function $(t,e,n,r,s,i){const o=st.get(t);if(!o)return;const c=a=>{a&&(process.env.NODE_ENV!=="production"?a.trigger({target:t,type:e,key:n,newValue:r,oldValue:s,oldTarget:i}):a.trigger())};if(yt(),e==="clear")o.forEach(c);else{const a=d(t),u=a&&X(n);if(a&&n==="length"){const p=Number(r);o.forEach((l,f)=>{(f==="length"||f===U||!T(f)&&f>=p)&&c(l)})}else switch((n!==void 0||o.has(void 0))&&c(o.get(n)),u&&c(o.get(U)),e){case"add":a?u&&c(o.get("length")):(c(o.get(M)),z(t)&&c(o.get(Ot)));break;case"delete":a||(c(o.get(M)),z(t)&&c(o.get(Ot)));break;case"set":z(t)&&c(o.get(M));break}}St()}function Te(t,e){const n=st.get(t);return n&&n.get(e)}function j(t){const e=h(t);return e===t?e:(g(e,"iterate",U),y(t)?e:e.map(C))}function Et(t){return g(t=h(t),"iterate",U),t}function E(t,e){return w(t)?B(Ct(t)?C(e):e):C(e)}const xe={__proto__:null,[Symbol.iterator](){return wt(this,Symbol.iterator,t=>E(this,t))},concat(...t){return j(this).concat(...t.map(e=>d(e)?j(e):e))},entries(){return wt(this,"entries",t=>(t[1]=E(this,t[1]),t))},every(t,e){return R(this,"every",t,e,void 0,arguments)},filter(t,e){return R(this,"filter",t,e,n=>n.map(r=>E(this,r)),arguments)},find(t,e){return R(this,"find",t,e,n=>E(this,n),arguments)},findIndex(t,e){return R(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return R(this,"findLast",t,e,n=>E(this,n),arguments)},findLastIndex(t,e){return R(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return R(this,"forEach",t,e,void 0,arguments)},includes(...t){return Nt(this,"includes",t)},indexOf(...t){return Nt(this,"indexOf",t)},join(t){return j(this).join(t)},lastIndexOf(...t){return Nt(this,"lastIndexOf",t)},map(t,e){return R(this,"map",t,e,void 0,arguments)},pop(){return q(this,"pop")},push(...t){return q(this,"push",t)},reduce(t,...e){return zt(this,"reduce",t,e)},reduceRight(t,...e){return zt(this,"reduceRight",t,e)},shift(){return q(this,"shift")},some(t,e){return R(this,"some",t,e,void 0,arguments)},splice(...t){return q(this,"splice",t)},toReversed(){return j(this).toReversed()},toSorted(t){return j(this).toSorted(t)},toSpliced(...t){return j(this).toSpliced(...t)},unshift(...t){return q(this,"unshift",t)},values(){return wt(this,"values",t=>E(this,t))}};function wt(t,e,n){const r=Et(t),s=r[e]();return r!==t&&!y(t)&&(s._next=s.next,s.next=()=>{const i=s._next();return i.done||(i.value=n(i.value)),i}),s}const Me=Array.prototype;function R(t,e,n,r,s,i){const o=Et(t),c=o!==t&&!y(t),a=o[e];if(a!==Me[e]){const l=a.apply(t,i);return c?C(l):l}let u=n;o!==t&&(c?u=function(l,f){return n.call(this,E(t,l),f,t)}:n.length>2&&(u=function(l,f){return n.call(this,l,f,t)}));const p=a.call(o,u,r);return c&&s?s(p):p}function zt(t,e,n,r){const s=Et(t),i=s!==t&&!y(t);let o=n,c=!1;s!==t&&(i?(c=r.length===0,o=function(u,p,l){return c&&(c=!1,u=E(t,u)),n.call(this,u,E(t,p),l,t)}):n.length>3&&(o=function(u,p,l){return n.call(this,u,p,l,t)}));const a=s[e](o,...r);return c?E(t,a):a}function Nt(t,e,n){const r=h(t);g(r,"iterate",U);const s=r[e](...n);return(s===-1||s===!1)&&J(n[0])?(n[0]=h(n[0]),r[e](...n)):s}function q(t,e,n=[]){et(),yt();const r=h(t)[e].apply(t,n);return St(),nt(),r}const Pe=Ee("__proto__,__v_isRef,__isVue"),Ut=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(T));function Fe(t){T(t)||(t=String(t));const e=h(this);return g(e,"has",t),e.hasOwnProperty(t)}class qt{constructor(e=!1,n=!1){this._isReadonly=e,this._isShallow=n}get(e,n,r){if(n==="__v_skip")return e.__v_skip;const s=this._isReadonly,i=this._isShallow;if(n==="__v_isReactive")return!s;if(n==="__v_isReadonly")return s;if(n==="__v_isShallow")return i;if(n==="__v_raw")return r===(s?i?Je:Gt:i?qe:Yt).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(r)?e:void 0;const o=d(e);if(!s){let a;if(o&&(a=xe[n]))return a;if(n==="hasOwnProperty")return Fe}const c=Reflect.get(e,n,m(e)?e:r);if((T(n)?Ut.has(n):Pe(n))||(s||g(e,"get",n),i))return c;if(m(c)){const a=o&&X(n)?c:c.value;return s&&b(a)?Rt(a):a}return b(c)?s?Rt(c):Qt(c):c}}class ke extends qt{constructor(e=!1){super(!1,e)}set(e,n,r,s){let i=e[n];const o=d(e)&&X(n);if(!this._isShallow){const u=w(i);if(!y(r)&&!w(r)&&(i=h(i),r=h(r)),!o&&m(i)&&!m(r))return u?(process.env.NODE_ENV!=="production"&&k(`Set operation on key "${String(n)}" failed: target is readonly.`,e[n]),!0):(i.value=r,!0)}const c=o?Number(n)<e.length:_t(e,n),a=Reflect.set(e,n,r,m(e)?e:s);return e===h(s)&&a&&(c?x(r,i)&&$(e,"set",n,r,i):$(e,"add",n,r)),a}deleteProperty(e,n){const r=_t(e,n),s=e[n],i=Reflect.deleteProperty(e,n);return i&&r&&$(e,"delete",n,void 0,s),i}has(e,n){const r=Reflect.has(e,n);return(!T(n)||!Ut.has(n))&&g(e,"has",n),r}ownKeys(e){return g(e,"iterate",d(e)?"length":M),Reflect.ownKeys(e)}}class je extends qt{constructor(e=!1){super(!0,e)}set(e,n){return process.env.NODE_ENV!=="production"&&k(`Set operation on key "${String(n)}" failed: target is readonly.`,e),!0}deleteProperty(e,n){return process.env.NODE_ENV!=="production"&&k(`Delete operation on key "${String(n)}" failed: target is readonly.`,e),!0}}const Ke=new ke,He=new je,vt=t=>t,rt=t=>Reflect.getPrototypeOf(t);function Le(t,e,n){return function(...r){const s=this.__v_raw,i=h(s),o=z(i),c=t==="entries"||t===Symbol.iterator&&o,a=t==="keys"&&o,u=s[t](...r),p=n?vt:e?B:C;return!e&&g(i,"iterate",a?Ot:M),D(Object.create(u),{next(){const{value:l,done:f}=u.next();return f?{value:l,done:f}:{value:c?[p(l[0]),p(l[1])]:p(l),done:f}}})}}function it(t){return function(...e){if(process.env.NODE_ENV!=="production"){const n=e[0]?`on key "${e[0]}" `:"";k(`${Ce(t)} operation ${n}failed: target is readonly.`,h(this))}return t==="delete"?!1:t==="clear"?void 0:this}}function We(t,e){const n={get(s){const i=this.__v_raw,o=h(i),c=h(s);t||(x(s,c)&&g(o,"get",s),g(o,"get",c));const{has:a}=rt(o),u=e?vt:t?B:C;if(a.call(o,s))return u(i.get(s));if(a.call(o,c))return u(i.get(c));i!==o&&i.get(s)},get size(){const s=this.__v_raw;return!t&&g(h(s),"iterate",M),s.size},has(s){const i=this.__v_raw,o=h(i),c=h(s);return t||(x(s,c)&&g(o,"has",s),g(o,"has",c)),s===c?i.has(s):i.has(s)||i.has(c)},forEach(s,i){const o=this,c=o.__v_raw,a=h(c),u=e?vt:t?B:C;return!t&&g(a,"iterate",M),c.forEach((p,l)=>s.call(i,u(p),u(l),o))}};return D(n,t?{add:it("add"),set:it("set"),delete:it("delete"),clear:it("clear")}:{add(s){const i=h(this),o=rt(i),c=h(s),a=!e&&!y(s)&&!w(s)?c:s;return o.has.call(i,a)||x(s,a)&&o.has.call(i,s)||x(c,a)&&o.has.call(i,c)||(i.add(a),$(i,"add",a,a)),this},set(s,i){!e&&!y(i)&&!w(i)&&(i=h(i));const o=h(this),{has:c,get:a}=rt(o);let u=c.call(o,s);u?process.env.NODE_ENV!=="production"&&Bt(o,c,s):(s=h(s),u=c.call(o,s));const p=a.call(o,s);return o.set(s,i),u?x(i,p)&&$(o,"set",s,i,p):$(o,"add",s,i),this},delete(s){const i=h(this),{has:o,get:c}=rt(i);let a=o.call(i,s);a?process.env.NODE_ENV!=="production"&&Bt(i,o,s):(s=h(s),a=o.call(i,s));const u=c?c.call(i,s):void 0,p=i.delete(s);return a&&$(i,"delete",s,void 0,u),p},clear(){const s=h(this),i=s.size!==0,o=process.env.NODE_ENV!=="production"?z(s)?new Map(s):new Set(s):void 0,c=s.clear();return i&&$(s,"clear",void 0,void 0,o),c}}),["keys","values","entries",Symbol.iterator].forEach(s=>{n[s]=Le(s,t,e)}),n}function Jt(t,e){const n=We(t,e);return(r,s,i)=>s==="__v_isReactive"?!t:s==="__v_isReadonly"?t:s==="__v_raw"?r:Reflect.get(_t(n,s)&&s in r?n:r,s,i)}const ze={get:Jt(!1,!1)},Ue={get:Jt(!0,!1)};function Bt(t,e,n){const r=h(n);if(r!==n&&e.call(t,r)){const s=jt(t);k(`Reactive ${s} contains both the raw and reactive versions of the same object${s==="Map"?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const Yt=new WeakMap,qe=new WeakMap,Gt=new WeakMap,Je=new WeakMap;function Be(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Qt(t){return w(t)?t:Xt(t,!1,Ke,ze,Yt)}function Rt(t){return Xt(t,!0,He,Ue,Gt)}function Xt(t,e,n,r,s){if(!b(t))return process.env.NODE_ENV!=="production"&&k(`value cannot be made ${e?"readonly":"reactive"}: ${String(t)}`),t;if(t.__v_raw&&!(e&&t.__v_isReactive)||t.__v_skip||!Object.isExtensible(t))return t;const i=s.get(t);if(i)return i;const o=Be(jt(t));if(o===0)return t;const c=new Proxy(t,o===2?r:n);return s.set(t,c),c}function Ct(t){return w(t)?Ct(t.__v_raw):!!(t&&t.__v_isReactive)}function w(t){return!!(t&&t.__v_isReadonly)}function y(t){return!!(t&&t.__v_isShallow)}function J(t){return t?!!t.__v_raw:!1}function h(t){const e=t&&t.__v_raw;return e?h(e):t}const C=t=>b(t)?Qt(t):t,B=t=>b(t)?Rt(t):t;function m(t){return t?t.__v_isRef===!0:!1}function Zt(t){return Ye(t,!1)}function Ye(t,e){return m(t)?t:new Ge(t,e)}class Ge{constructor(e,n){this.dep=new Wt,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?e:h(e),this._value=n?e:C(e),this.__v_isShallow=n}get value(){return process.env.NODE_ENV!=="production"?this.dep.track({target:this,type:"get",key:"value"}):this.dep.track(),this._value}set value(e){const n=this._rawValue,r=this.__v_isShallow||y(e)||w(e);e=r?e:h(e),x(e,n)&&(this._rawValue=e,this._value=r?e:C(e),process.env.NODE_ENV!=="production"?this.dep.trigger({target:this,type:"set",key:"value",newValue:e,oldValue:n}):this.dep.trigger())}}function Qe(t){return m(t)?t.value:t}class Xe{constructor(e,n,r){this._object=e,this._defaultValue=r,this.__v_isRef=!0,this._value=void 0,this._key=T(n)?n:String(n),this._raw=h(e);let s=!0,i=e;if(!d(e)||T(this._key)||!X(this._key))do s=!J(i)||y(i);while(s&&(i=i.__v_raw));this._shallow=s}get value(){let e=this._object[this._key];return this._shallow&&(e=Qe(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&m(this._raw[this._key])){const n=this._object[this._key];if(m(n)){n.value=e;return}}this._object[this._key]=e}get dep(){return Te(this._raw,this._key)}}class Ze{constructor(e){this._getter=e,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}}function tn(t,e,n){return m(t)?t:I(t)?new Ze(t):b(t)&&arguments.length>1?en(t,e,n):Zt(t)}function en(t,e,n){return new Xe(t,e,n)}const P=[];function nn(t){P.push(t)}function sn(){P.pop()}let At=!1;function K(t,...e){if(At)return;At=!0,et();const n=P.length?P[P.length-1].component:null,r=n&&n.appContext.config.warnHandler,s=rn();if(r)It(r,n,11,[t+e.map(i=>{var o,c;return(c=(o=i.toString)==null?void 0:o.call(i))!=null?c:JSON.stringify(i)}).join(""),n&&n.proxy,s.map(({vnode:i})=>`at <${_e(n,i.type)}>`).join(`
|
|
1
|
+
(function(_,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("pinia")):typeof define=="function"&&define.amd?define(["exports","pinia"],F):(_=typeof globalThis<"u"?globalThis:_||self,F(_["pinia-plugin-subscription"]={},_.Pinia))})(this,(function(_,F){"use strict";class be{_console;_createInstance;_name;_pluginOptions;_storeInstance;_resetStoreCallback;_storeOnActionSubscription;_storeMutationSubscription;_subscriptions;pluginCreated;get console(){return this._console??console}get name(){return this._name}get pluginOptions(){return this._pluginOptions??{}}set pluginOptions(e){this._pluginOptions=e}get resetStoreCallback(){return this._resetStoreCallback}get storeOnActionSubscription(){return this._storeOnActionSubscription}get storeMutationSubscription(){return this._storeMutationSubscription}get subscriptions(){return this._subscriptions}set subscriptions(e){this._subscriptions=e}constructor(e,n,r){this._name=e,this._createInstance=n,r&&(this._console=r)}invoke({store:e,options:n},r){return this._storeInstance=this._createInstance(e,{...n,...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(e),!0):!1}}class Tt{_console;_debug=!1;get console(){return this._console??console}set console(e){this._console=e}get debug(){return this._debug}set debug(e){this._debug=e}constructor(e,n){this._debug=e,n&&(this._console=n)}debugLog(...e){this._debug&&(Array.isArray(e)&&(e[0]=`${this._className} - ${e[0]}`),this.console.log(...e))}logError(...e){this.console.error(...e)}}const pt="pinia-plugin-subscription",me=(t,e="white")=>`background-color: ${t}; color: ${e}; padding: 1px; margin-right: 5px; font-size: 12px`;function ye(t,e){if(!t)throw new Error("Style instructions are required");console.log("%c%s",t,e.shift(),...e)}class xt{_bgColor="#ffec73";_color="green";_icon="🍍⚡";_errorBgColor="#d24545";_errorColor="white";_errorIcon="🍍⚠️";_styles={error:{bgColor:this._errorBgColor,color:this._errorColor,icon:this._errorIcon},info:{bgColor:this._bgColor,color:this._color,icon:this._icon}};formatMessage(e,n){return` [${n} ${pt}] - ${e} `}generateStyle(e){return me(e.bgColor,e.color)}getStyleDefinition(e){return this._styles[e??"info"]}log(...e){this.useLog(this.getStyleDefinition(),e)}error(...e){this.useLog(this.getStyleDefinition("error"),e)}rebuildArgs(e,n){if(typeof e=="string")return[this.formatMessage(e,n)];if(Array.isArray(e))return[this.formatMessage(e.shift(),n),...e??[]]}useLog(e,n){ye(this.generateStyle(e),this.rebuildArgs(n,e.icon))}}class Se extends xt{_pluginName=pt}const Oe=new Se;function Q(t){return t?Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:typeof t=="string"?t.trim()==="":!1:!(typeof t=="boolean"||typeof t=="number")}const Mt="PluginSubscription";class Pt extends Tt{_className=Mt;_pluginDebug;_resetStoreCallback=[];_subscribers=[];_subscribersDelivered=new Set;_subscriptions=[];_subscriptionsDelivered=new Set;set subscribers(e){this._subscribers=e}get subscriptions(){if(!Q(this._subscriptions))return this._subscriptions}constructor(e,n){super(Array.isArray(n)&&!!n?.includes(Mt),Oe),this._pluginDebug=Array.isArray(n)?n:void 0,this._subscribers=e}addResetStoreCallback(e){this._resetStoreCallback.push(e)}definePluginDebug(e){return!!this._pluginDebug?.includes(e.name)}executeResetStoreCallbacks(e){this._resetStoreCallback.forEach(n=>n(e))}plugin({store:e,options:n}){if(this._subscribers.length){this.debugLog(`plugin() - ${e.$id}`,["subscriber:",this._subscribers,"store:",e,"options:",n]);try{this._subscribers.forEach(r=>{this._subscribersDelivered.has(`${r.name}-${e.$id}`)||r.invoke({store:e,options:n},this.definePluginDebug(r))&&(this._subscribersDelivered.add(`${r.name}-${e.$id}`),r.subscriptions&&this.subscriptionDelivery({store:e,options:n},r.subscriptions),r.storeMutationSubscription&&this.storeMutationSubscription(r.storeMutationSubscription),r.storeOnActionSubscription&&this.storeOnActionSubscription(r.storeOnActionSubscription),r.resetStoreCallback&&this.addResetStoreCallback(r.resetStoreCallback))}),this.rewriteResetStore({store:e},JSON.stringify(e.$state),Object.assign({},e))}catch(r){this.logError(r,e,n)}}}rewriteResetStore({store:e},n,r){e.$reset=()=>{this.debugLog("rewriteResetStore()",{initState:n,store:e,customStore:r}),this.executeResetStoreCallbacks(e),e.$patch(JSON.parse(n))}}storeOnActionSubscription(e){const{store:n,callback:r}=e();n.$onAction(({after:s,args:i,name:o})=>{this.debugLog(`storeOnActionSubscription ${n.$id}`,{after:s,args:i,name:o,store:n}),r({after:s,args:i,name:o})})}storeMutationSubscription(e){const{store:n,callback:r}=e();n.$subscribe(s=>{this.debugLog(`$subscribe ${n.$id}`,{mutation:s,store:n}),r(s)})}subscriptionDelivery({store:e,options:n},r){Object.entries(r).forEach(([s,i])=>{try{if(this._subscriptionsDelivered.has(`${s}-${e.$id}`))return;const{subscription:o,subscriptionOptions:c,stores:a}=i;this.debugLog(`subscriptionDelivery() - store: ${e.$id}`,["pluginName:",s,"subscription:",o,"options:",i,"stores:",a]);const u={storeOptions:{...n?.storeOptions??{},...c}};o.invoke({store:e,options:{...n,...u}},this.debug),this._subscriptionsDelivered.add(`${s}-${e.$id}`),Q(a)||a?.forEach(p=>o.invoke({store:p,options:{...n,...u,...p?.storeOptions??{}}},this.debug))}catch(o){this.logError("subscriptionDelivery()",o,e,n)}})}}function Ee(t){const e=Object.create(null);for(const n of t.split(","))e[n]=1;return n=>n in e}const dt=process.env.NODE_ENV!=="production"?Object.freeze({}):{};process.env.NODE_ENV!=="production"&&Object.freeze([]);const Ft=()=>{},we=t=>t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&(t.charCodeAt(2)>122||t.charCodeAt(2)<97),Ne=t=>t.startsWith("onUpdate:"),D=Object.assign,ve=Object.prototype.hasOwnProperty,_t=(t,e)=>ve.call(t,e),d=Array.isArray,z=t=>kt(t)==="[object Map]",I=t=>typeof t=="function",v=t=>typeof t=="string",T=t=>typeof t=="symbol",b=t=>t!==null&&typeof t=="object",Re=Object.prototype.toString,kt=t=>Re.call(t),jt=t=>kt(t).slice(8,-1),X=t=>v(t)&&t!=="NaN"&&t[0]!=="-"&&""+parseInt(t,10)===t,Ce=(t=>{const e=Object.create(null);return(n=>e[n]||(e[n]=t(n)))})(t=>t.charAt(0).toUpperCase()+t.slice(1)),x=(t,e)=>!Object.is(t,e);let Kt;const Z=()=>Kt||(Kt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function gt(t){if(d(t)){const e={};for(let n=0;n<t.length;n++){const r=t[n],s=v(r)?Ve(r):gt(r);if(s)for(const i in s)e[i]=s[i]}return e}else if(v(t)||b(t))return t}const Ae=/;(?![^(]*\))/g,Ie=/:([^]+)/,$e=/\/\*[^]*?\*\//g;function Ve(t){const e={};return t.replace($e,"").split(Ae).forEach(n=>{if(n){const r=n.split(Ie);r.length>1&&(e[r[0].trim()]=r[1].trim())}}),e}function bt(t){let e="";if(v(t))e=t;else if(d(t))for(let n=0;n<t.length;n++){const r=bt(t[n]);r&&(e+=r+" ")}else if(b(t))for(const n in t)t[n]&&(e+=n+" ");return e.trim()}function k(t,...e){console.warn(`[Vue warn] ${t}`,...e)}let De,Ht=0,mt;function yt(){Ht++}function St(){if(--Ht>0)return;let t;for(;mt;){let e=mt;for(mt=void 0;e;){const n=e.next;if(e.next=void 0,e.flags&=-9,e.flags&1)try{e.trigger()}catch(r){t||(t=r)}e=n}}if(t)throw t}let tt=!0;const Lt=[];function et(){Lt.push(tt),tt=!1}function nt(){const t=Lt.pop();tt=t===void 0?!0:t}class Wt{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0,process.env.NODE_ENV!=="production"&&(this.subsHead=void 0)}track(e){}trigger(e){this.version++,this.notify(e)}notify(e){yt();try{if(process.env.NODE_ENV!=="production")for(let n=this.subsHead;n;n=n.nextSub)n.sub.onTrigger&&!(n.sub.flags&8)&&n.sub.onTrigger(D({effect:n.sub},e));for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{St()}}}const st=new WeakMap,M=Symbol(process.env.NODE_ENV!=="production"?"Object iterate":""),Ot=Symbol(process.env.NODE_ENV!=="production"?"Map keys iterate":""),U=Symbol(process.env.NODE_ENV!=="production"?"Array iterate":"");function g(t,e,n){if(tt&&De){let r=st.get(t);r||st.set(t,r=new Map);let s=r.get(n);s||(r.set(n,s=new Wt),s.map=r,s.key=n),process.env.NODE_ENV!=="production"?s.track({target:t,type:e,key:n}):s.track()}}function $(t,e,n,r,s,i){const o=st.get(t);if(!o)return;const c=a=>{a&&(process.env.NODE_ENV!=="production"?a.trigger({target:t,type:e,key:n,newValue:r,oldValue:s,oldTarget:i}):a.trigger())};if(yt(),e==="clear")o.forEach(c);else{const a=d(t),u=a&&X(n);if(a&&n==="length"){const p=Number(r);o.forEach((l,f)=>{(f==="length"||f===U||!T(f)&&f>=p)&&c(l)})}else switch((n!==void 0||o.has(void 0))&&c(o.get(n)),u&&c(o.get(U)),e){case"add":a?u&&c(o.get("length")):(c(o.get(M)),z(t)&&c(o.get(Ot)));break;case"delete":a||(c(o.get(M)),z(t)&&c(o.get(Ot)));break;case"set":z(t)&&c(o.get(M));break}}St()}function Te(t,e){const n=st.get(t);return n&&n.get(e)}function j(t){const e=h(t);return e===t?e:(g(e,"iterate",U),y(t)?e:e.map(C))}function Et(t){return g(t=h(t),"iterate",U),t}function E(t,e){return w(t)?B(Ct(t)?C(e):e):C(e)}const xe={__proto__:null,[Symbol.iterator](){return wt(this,Symbol.iterator,t=>E(this,t))},concat(...t){return j(this).concat(...t.map(e=>d(e)?j(e):e))},entries(){return wt(this,"entries",t=>(t[1]=E(this,t[1]),t))},every(t,e){return R(this,"every",t,e,void 0,arguments)},filter(t,e){return R(this,"filter",t,e,n=>n.map(r=>E(this,r)),arguments)},find(t,e){return R(this,"find",t,e,n=>E(this,n),arguments)},findIndex(t,e){return R(this,"findIndex",t,e,void 0,arguments)},findLast(t,e){return R(this,"findLast",t,e,n=>E(this,n),arguments)},findLastIndex(t,e){return R(this,"findLastIndex",t,e,void 0,arguments)},forEach(t,e){return R(this,"forEach",t,e,void 0,arguments)},includes(...t){return Nt(this,"includes",t)},indexOf(...t){return Nt(this,"indexOf",t)},join(t){return j(this).join(t)},lastIndexOf(...t){return Nt(this,"lastIndexOf",t)},map(t,e){return R(this,"map",t,e,void 0,arguments)},pop(){return q(this,"pop")},push(...t){return q(this,"push",t)},reduce(t,...e){return zt(this,"reduce",t,e)},reduceRight(t,...e){return zt(this,"reduceRight",t,e)},shift(){return q(this,"shift")},some(t,e){return R(this,"some",t,e,void 0,arguments)},splice(...t){return q(this,"splice",t)},toReversed(){return j(this).toReversed()},toSorted(t){return j(this).toSorted(t)},toSpliced(...t){return j(this).toSpliced(...t)},unshift(...t){return q(this,"unshift",t)},values(){return wt(this,"values",t=>E(this,t))}};function wt(t,e,n){const r=Et(t),s=r[e]();return r!==t&&!y(t)&&(s._next=s.next,s.next=()=>{const i=s._next();return i.done||(i.value=n(i.value)),i}),s}const Me=Array.prototype;function R(t,e,n,r,s,i){const o=Et(t),c=o!==t&&!y(t),a=o[e];if(a!==Me[e]){const l=a.apply(t,i);return c?C(l):l}let u=n;o!==t&&(c?u=function(l,f){return n.call(this,E(t,l),f,t)}:n.length>2&&(u=function(l,f){return n.call(this,l,f,t)}));const p=a.call(o,u,r);return c&&s?s(p):p}function zt(t,e,n,r){const s=Et(t),i=s!==t&&!y(t);let o=n,c=!1;s!==t&&(i?(c=r.length===0,o=function(u,p,l){return c&&(c=!1,u=E(t,u)),n.call(this,u,E(t,p),l,t)}):n.length>3&&(o=function(u,p,l){return n.call(this,u,p,l,t)}));const a=s[e](o,...r);return c?E(t,a):a}function Nt(t,e,n){const r=h(t);g(r,"iterate",U);const s=r[e](...n);return(s===-1||s===!1)&&J(n[0])?(n[0]=h(n[0]),r[e](...n)):s}function q(t,e,n=[]){et(),yt();const r=h(t)[e].apply(t,n);return St(),nt(),r}const Pe=Ee("__proto__,__v_isRef,__isVue"),Ut=new Set(Object.getOwnPropertyNames(Symbol).filter(t=>t!=="arguments"&&t!=="caller").map(t=>Symbol[t]).filter(T));function Fe(t){T(t)||(t=String(t));const e=h(this);return g(e,"has",t),e.hasOwnProperty(t)}class qt{constructor(e=!1,n=!1){this._isReadonly=e,this._isShallow=n}get(e,n,r){if(n==="__v_skip")return e.__v_skip;const s=this._isReadonly,i=this._isShallow;if(n==="__v_isReactive")return!s;if(n==="__v_isReadonly")return s;if(n==="__v_isShallow")return i;if(n==="__v_raw")return r===(s?i?Je:Gt:i?qe:Yt).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(r)?e:void 0;const o=d(e);if(!s){let a;if(o&&(a=xe[n]))return a;if(n==="hasOwnProperty")return Fe}const c=Reflect.get(e,n,m(e)?e:r);if((T(n)?Ut.has(n):Pe(n))||(s||g(e,"get",n),i))return c;if(m(c)){const a=o&&X(n)?c:c.value;return s&&b(a)?Rt(a):a}return b(c)?s?Rt(c):Qt(c):c}}class ke extends qt{constructor(e=!1){super(!1,e)}set(e,n,r,s){let i=e[n];const o=d(e)&&X(n);if(!this._isShallow){const u=w(i);if(!y(r)&&!w(r)&&(i=h(i),r=h(r)),!o&&m(i)&&!m(r))return u?(process.env.NODE_ENV!=="production"&&k(`Set operation on key "${String(n)}" failed: target is readonly.`,e[n]),!0):(i.value=r,!0)}const c=o?Number(n)<e.length:_t(e,n),a=Reflect.set(e,n,r,m(e)?e:s);return e===h(s)&&a&&(c?x(r,i)&&$(e,"set",n,r,i):$(e,"add",n,r)),a}deleteProperty(e,n){const r=_t(e,n),s=e[n],i=Reflect.deleteProperty(e,n);return i&&r&&$(e,"delete",n,void 0,s),i}has(e,n){const r=Reflect.has(e,n);return(!T(n)||!Ut.has(n))&&g(e,"has",n),r}ownKeys(e){return g(e,"iterate",d(e)?"length":M),Reflect.ownKeys(e)}}class je extends qt{constructor(e=!1){super(!0,e)}set(e,n){return process.env.NODE_ENV!=="production"&&k(`Set operation on key "${String(n)}" failed: target is readonly.`,e),!0}deleteProperty(e,n){return process.env.NODE_ENV!=="production"&&k(`Delete operation on key "${String(n)}" failed: target is readonly.`,e),!0}}const Ke=new ke,He=new je,vt=t=>t,rt=t=>Reflect.getPrototypeOf(t);function Le(t,e,n){return function(...r){const s=this.__v_raw,i=h(s),o=z(i),c=t==="entries"||t===Symbol.iterator&&o,a=t==="keys"&&o,u=s[t](...r),p=n?vt:e?B:C;return!e&&g(i,"iterate",a?Ot:M),D(Object.create(u),{next(){const{value:l,done:f}=u.next();return f?{value:l,done:f}:{value:c?[p(l[0]),p(l[1])]:p(l),done:f}}})}}function it(t){return function(...e){if(process.env.NODE_ENV!=="production"){const n=e[0]?`on key "${e[0]}" `:"";k(`${Ce(t)} operation ${n}failed: target is readonly.`,h(this))}return t==="delete"?!1:t==="clear"?void 0:this}}function We(t,e){const n={get(s){const i=this.__v_raw,o=h(i),c=h(s);t||(x(s,c)&&g(o,"get",s),g(o,"get",c));const{has:a}=rt(o),u=e?vt:t?B:C;if(a.call(o,s))return u(i.get(s));if(a.call(o,c))return u(i.get(c));i!==o&&i.get(s)},get size(){const s=this.__v_raw;return!t&&g(h(s),"iterate",M),s.size},has(s){const i=this.__v_raw,o=h(i),c=h(s);return t||(x(s,c)&&g(o,"has",s),g(o,"has",c)),s===c?i.has(s):i.has(s)||i.has(c)},forEach(s,i){const o=this,c=o.__v_raw,a=h(c),u=e?vt:t?B:C;return!t&&g(a,"iterate",M),c.forEach((p,l)=>s.call(i,u(p),u(l),o))}};return D(n,t?{add:it("add"),set:it("set"),delete:it("delete"),clear:it("clear")}:{add(s){const i=h(this),o=rt(i),c=h(s),a=!e&&!y(s)&&!w(s)?c:s;return o.has.call(i,a)||x(s,a)&&o.has.call(i,s)||x(c,a)&&o.has.call(i,c)||(i.add(a),$(i,"add",a,a)),this},set(s,i){!e&&!y(i)&&!w(i)&&(i=h(i));const o=h(this),{has:c,get:a}=rt(o);let u=c.call(o,s);u?process.env.NODE_ENV!=="production"&&Bt(o,c,s):(s=h(s),u=c.call(o,s));const p=a.call(o,s);return o.set(s,i),u?x(i,p)&&$(o,"set",s,i,p):$(o,"add",s,i),this},delete(s){const i=h(this),{has:o,get:c}=rt(i);let a=o.call(i,s);a?process.env.NODE_ENV!=="production"&&Bt(i,o,s):(s=h(s),a=o.call(i,s));const u=c?c.call(i,s):void 0,p=i.delete(s);return a&&$(i,"delete",s,void 0,u),p},clear(){const s=h(this),i=s.size!==0,o=process.env.NODE_ENV!=="production"?z(s)?new Map(s):new Set(s):void 0,c=s.clear();return i&&$(s,"clear",void 0,void 0,o),c}}),["keys","values","entries",Symbol.iterator].forEach(s=>{n[s]=Le(s,t,e)}),n}function Jt(t,e){const n=We(t,e);return(r,s,i)=>s==="__v_isReactive"?!t:s==="__v_isReadonly"?t:s==="__v_raw"?r:Reflect.get(_t(n,s)&&s in r?n:r,s,i)}const ze={get:Jt(!1,!1)},Ue={get:Jt(!0,!1)};function Bt(t,e,n){const r=h(n);if(r!==n&&e.call(t,r)){const s=jt(t);k(`Reactive ${s} contains both the raw and reactive versions of the same object${s==="Map"?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const Yt=new WeakMap,qe=new WeakMap,Gt=new WeakMap,Je=new WeakMap;function Be(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Qt(t){return w(t)?t:Xt(t,!1,Ke,ze,Yt)}function Rt(t){return Xt(t,!0,He,Ue,Gt)}function Xt(t,e,n,r,s){if(!b(t))return process.env.NODE_ENV!=="production"&&k(`value cannot be made ${e?"readonly":"reactive"}: ${String(t)}`),t;if(t.__v_raw&&!(e&&t.__v_isReactive)||t.__v_skip||!Object.isExtensible(t))return t;const i=s.get(t);if(i)return i;const o=Be(jt(t));if(o===0)return t;const c=new Proxy(t,o===2?r:n);return s.set(t,c),c}function Ct(t){return w(t)?Ct(t.__v_raw):!!(t&&t.__v_isReactive)}function w(t){return!!(t&&t.__v_isReadonly)}function y(t){return!!(t&&t.__v_isShallow)}function J(t){return t?!!t.__v_raw:!1}function h(t){const e=t&&t.__v_raw;return e?h(e):t}const C=t=>b(t)?Qt(t):t,B=t=>b(t)?Rt(t):t;function m(t){return t?t.__v_isRef===!0:!1}function Zt(t){return Ye(t,!1)}function Ye(t,e){return m(t)?t:new Ge(t,e)}class Ge{constructor(e,n){this.dep=new Wt,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?e:h(e),this._value=n?e:C(e),this.__v_isShallow=n}get value(){return process.env.NODE_ENV!=="production"?this.dep.track({target:this,type:"get",key:"value"}):this.dep.track(),this._value}set value(e){const n=this._rawValue,r=this.__v_isShallow||y(e)||w(e);e=r?e:h(e),x(e,n)&&(this._rawValue=e,this._value=r?e:C(e),process.env.NODE_ENV!=="production"?this.dep.trigger({target:this,type:"set",key:"value",newValue:e,oldValue:n}):this.dep.trigger())}}function Qe(t){return m(t)?t.value:t}class Xe{constructor(e,n,r){this._object=e,this._defaultValue=r,this.__v_isRef=!0,this._value=void 0,this._key=T(n)?n:String(n),this._raw=h(e);let s=!0,i=e;if(!d(e)||T(this._key)||!X(this._key))do s=!J(i)||y(i);while(s&&(i=i.__v_raw));this._shallow=s}get value(){let e=this._object[this._key];return this._shallow&&(e=Qe(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&m(this._raw[this._key])){const n=this._object[this._key];if(m(n)){n.value=e;return}}this._object[this._key]=e}get dep(){return Te(this._raw,this._key)}}class Ze{constructor(e){this._getter=e,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}}function tn(t,e,n){return m(t)?t:I(t)?new Ze(t):b(t)&&arguments.length>1?en(t,e,n):Zt(t)}function en(t,e,n){return new Xe(t,e,n)}const P=[];function nn(t){P.push(t)}function sn(){P.pop()}let At=!1;function K(t,...e){if(At)return;At=!0,et();const n=P.length?P[P.length-1].component:null,r=n&&n.appContext.config.warnHandler,s=rn();if(r)It(r,n,11,[t+e.map(i=>{var o,c;return(c=(o=i.toString)==null?void 0:o.call(i))!=null?c:JSON.stringify(i)}).join(""),n&&n.proxy,s.map(({vnode:i})=>`at <${_e(n,i.type)}>`).join(`
|
|
2
2
|
`),s]);else{const i=[`[Vue warn]: ${t}`,...e];s.length&&i.push(`
|
|
3
3
|
`,...on(s)),console.warn(...i)}nt(),At=!1}function rn(){let t=P[P.length-1];if(!t)return[];const e=[];for(;t;){const n=e[0];n&&n.vnode===t?n.recurseCount++:e.push({vnode:t,recurseCount:0});const r=t.component&&t.component.parent;t=r&&r.vnode}return e}function on(t){const e=[];return t.forEach((n,r)=>{e.push(...r===0?[]:[`
|
|
4
4
|
`],...cn(n))}),e}function cn({vnode:t,recurseCount:e}){const n=e>0?`... (${e} recursive calls)`:"",r=t.component?t.component.parent==null:!1,s=` at <${_e(t.component,t.type,r)}`,i=">"+n;return t.props?[s,...ln(t.props),i]:[s+i]}function ln(t){const e=[],n=Object.keys(t);return n.slice(0,3).forEach(r=>{e.push(...te(r,t[r]))}),n.length>3&&e.push(" ..."),e}function te(t,e,n){return v(e)?(e=JSON.stringify(e),n?e:[`${t}=${e}`]):typeof e=="number"||typeof e=="boolean"||e==null?n?e:[`${t}=${e}`]:m(e)?(e=te(t,h(e.value),!0),n?e:[`${t}=Ref<`,e,">"]):I(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=h(e),n?e:[`${t}=`,e])}const ee={sp:"serverPrefetch hook",bc:"beforeCreate hook",c:"created hook",bm:"beforeMount hook",m:"mounted hook",bu:"beforeUpdate hook",u:"updated",bum:"beforeUnmount hook",um:"unmounted hook",a:"activated hook",da:"deactivated hook",ec:"errorCaptured hook",rtc:"renderTracked hook",rtg:"renderTriggered hook",0:"setup function",1:"render function",2:"watcher getter",3:"watcher callback",4:"watcher cleanup function",5:"native event handler",6:"component event handler",7:"vnode hook",8:"directive hook",9:"transition hook",10:"app errorHandler",11:"app warnHandler",12:"ref function",13:"async component loader",14:"scheduler flush",15:"component update",16:"app unmount cleanup function"};function It(t,e,n,r){try{return r?t(...r):t()}catch(s){ne(s,e,n)}}function ne(t,e,n,r=!0){const s=e?e.vnode:null,{errorHandler:i,throwUnhandledErrorInProduction:o}=e&&e.appContext.config||dt;if(e){let c=e.parent;const a=e.proxy,u=process.env.NODE_ENV!=="production"?ee[n]:`https://vuejs.org/error-reference/#runtime-${n}`;for(;c;){const p=c.ec;if(p){for(let l=0;l<p.length;l++)if(p[l](t,a,u)===!1)return}c=c.parent}if(i){et(),It(i,null,10,[t,a,u]),nt();return}}an(t,n,s,r,o)}function an(t,e,n,r=!0,s=!1){if(process.env.NODE_ENV!=="production"){const i=ee[e];if(n&&nn(n),K(`Unhandled error${i?` during execution of ${i}`:""}`),n&&sn(),r)throw t;console.error(t)}else{if(s)throw t;console.error(t)}}const S=[];let A=-1;const H=[];let V=null,L=0;const un=Promise.resolve();let $t=null;const fn=100;function hn(t){let e=A+1,n=S.length;for(;e<n;){const r=e+n>>>1,s=S[r],i=Y(s);i<t||i===t&&s.flags&2?e=r+1:n=r}return e}function pn(t){if(!(t.flags&1)){const e=Y(t),n=S[S.length-1];!n||!(t.flags&2)&&e>=Y(n)?S.push(t):S.splice(hn(e),0,t),t.flags|=1,se()}}function se(){$t||($t=un.then(re))}function dn(t){d(t)?H.push(...t):V&&t.id===-1?V.splice(L+1,0,t):t.flags&1||(H.push(t),t.flags|=1),se()}function _n(t){if(H.length){const e=[...new Set(H)].sort((n,r)=>Y(n)-Y(r));if(H.length=0,V){V.push(...e);return}for(V=e,process.env.NODE_ENV!=="production"&&(t=t||new Map),L=0;L<V.length;L++){const n=V[L];process.env.NODE_ENV!=="production"&&ie(t,n)||(n.flags&4&&(n.flags&=-2),n.flags&8||n(),n.flags&=-2)}V=null,L=0}}const Y=t=>t.id==null?t.flags&2?-1:1/0:t.id;function re(t){process.env.NODE_ENV!=="production"&&(t=t||new Map);const e=process.env.NODE_ENV!=="production"?n=>ie(t,n):Ft;try{for(A=0;A<S.length;A++){const n=S[A];if(n&&!(n.flags&8)){if(process.env.NODE_ENV!=="production"&&e(n))continue;n.flags&4&&(n.flags&=-2),It(n,n.i,n.i?15:14),n.flags&4||(n.flags&=-2)}}}finally{for(;A<S.length;A++){const n=S[A];n&&(n.flags&=-2)}A=-1,S.length=0,_n(t),$t=null,(S.length||H.length)&&re(t)}}function ie(t,e){const n=t.get(e)||0;if(n>fn){const r=e.i,s=r&&de(r.type);return ne(`Maximum recursive updates exceeded${s?` in component <${s}>`:""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,null,10),!0}return t.set(e,n+1),!1}const Vt=new Map;process.env.NODE_ENV!=="production"&&(Z().__VUE_HMR_RUNTIME__={createRecord:Dt(gn),rerender:Dt(bn),reload:Dt(mn)});const ot=new Map;function gn(t,e){return ot.has(t)?!1:(ot.set(t,{initialDef:ct(e),instances:new Set}),!0)}function ct(t){return ge(t)?t.__vccOpts:t}function bn(t,e){const n=ot.get(t);n&&(n.initialDef.render=e,[...n.instances].forEach(r=>{e&&(r.render=e,ct(r.type).render=e),r.renderCache=[],r.job.flags&8||r.update()}))}function mn(t,e){const n=ot.get(t);if(!n)return;e=ct(e),oe(n.initialDef,e);const r=[...n.instances];for(let s=0;s<r.length;s++){const i=r[s],o=ct(i.type);let c=Vt.get(o);c||(o!==n.initialDef&&oe(o,e),Vt.set(o,c=new Set)),c.add(i),i.appContext.propsCache.delete(i.type),i.appContext.emitsCache.delete(i.type),i.appContext.optionsCache.delete(i.type),i.ceReload?(c.add(i),i.ceReload(e.styles),c.delete(i)):i.parent?pn(()=>{i.job.flags&8||(i.parent.update(),c.delete(i))}):i.appContext.reload?i.appContext.reload():typeof window<"u"?window.location.reload():console.warn("[HMR] Root or manually mounted instance modified. Full reload required."),i.root.ce&&i!==i.root&&i.root.ce._removeChildStyle(o)}dn(()=>{Vt.clear()})}function oe(t,e){D(t,e);for(const n in t)n!=="__file"&&!(n in e)&&delete t[n]}function Dt(t){return(e,n)=>{try{return t(e,n)}catch(r){console.error(r),console.warn("[HMR] Something went wrong during Vue component hot-reload. Full reload required.")}}}let W,lt=[];function ce(t,e){var n,r;W=t,W?(W.enabled=!0,lt.forEach(({event:s,args:i})=>W.emit(s,...i)),lt=[]):typeof window<"u"&&window.HTMLElement&&!((r=(n=window.navigator)==null?void 0:n.userAgent)!=null&&r.includes("jsdom"))?((e.__VUE_DEVTOOLS_HOOK_REPLAY__=e.__VUE_DEVTOOLS_HOOK_REPLAY__||[]).push(i=>{ce(i,e)}),setTimeout(()=>{W||(e.__VUE_DEVTOOLS_HOOK_REPLAY__=null,lt=[])},3e3)):lt=[]}let at=null,yn=null;const Sn=t=>t.__isTeleport;function le(t,e){t.shapeFlag&6&&t.component?(t.transition=e,le(t.component.subTree,e)):t.shapeFlag&128?(t.ssContent.transition=e.clone(t.ssContent),t.ssFallback.transition=e.clone(t.ssFallback)):t.transition=e}Z().requestIdleCallback,Z().cancelIdleCallback;const On=Symbol.for("v-ndc"),En={};process.env.NODE_ENV!=="production"&&(En.ownKeys=t=>(K("Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead."),Reflect.ownKeys(t)));const wn={},ae=t=>Object.getPrototypeOf(t)===wn,Nn=t=>t.__isSuspense,ue=Symbol.for("v-fgt"),vn=Symbol.for("v-txt"),Rn=Symbol.for("v-cmt");function Cn(t){return t?t.__v_isVNode===!0:!1}const An=(...t)=>he(...t),fe=({key:t})=>t??null,ut=({ref:t,ref_key:e,ref_for:n})=>(typeof t=="number"&&(t=""+t),t!=null?v(t)||m(t)||I(t)?{i:at,r:t,k:e,f:!!n}:t:null);function In(t,e=null,n=null,r=0,s=null,i=t===ue?0:1,o=!1,c=!1){const a={__v_isVNode:!0,__v_skip:!0,type:t,props:e,key:e&&fe(e),ref:e&&ut(e),scopeId:yn,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:r,dynamicProps:s,dynamicChildren:null,appContext:null,ctx:at};return c?(ht(a,n),i&128&&t.normalize(a)):n&&(a.shapeFlag|=v(n)?8:16),process.env.NODE_ENV!=="production"&&a.key!==a.key&&K("VNode created with invalid key (NaN). VNode type:",a.type),a}const $n=process.env.NODE_ENV!=="production"?An:he;function he(t,e=null,n=null,r=0,s=null,i=!1){if((!t||t===On)&&(process.env.NODE_ENV!=="production"&&!t&&K(`Invalid vnode type when creating vnode: ${t}.`),t=Rn),Cn(t)){const c=ft(t,e,!0);return n&&ht(c,n),c.patchFlag=-2,c}if(ge(t)&&(t=t.__vccOpts),e){e=Vn(e);let{class:c,style:a}=e;c&&!v(c)&&(e.class=bt(c)),b(a)&&(J(a)&&!d(a)&&(a=D({},a)),e.style=gt(a))}const o=v(t)?1:Nn(t)?128:Sn(t)?64:b(t)?4:I(t)?2:0;return process.env.NODE_ENV!=="production"&&o&4&&J(t)&&(t=h(t),K("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.",`
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,129 @@
|
|
|
1
|
+
import type { DefineStoreOptions, PiniaCustomProperties, PiniaPlugin, PiniaPluginContext, StateTree, Store as PiniaStore, SubscriptionCallbackMutation, StoreDefinition } from "pinia";
|
|
2
|
+
import type { Ref } from "vue";
|
|
1
3
|
export interface AnyObject {
|
|
2
4
|
[key: number | string | symbol]: any;
|
|
3
5
|
}
|
|
4
6
|
export interface SearchCollectionCriteria {
|
|
5
7
|
[key: number | string | symbol]: boolean | number | string;
|
|
6
8
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
export interface Console {
|
|
10
|
+
log(...args: any): void;
|
|
11
|
+
error(...args: any): void;
|
|
12
|
+
}
|
|
13
|
+
export type LogType = 'error' | 'info';
|
|
14
|
+
export type StyleDefinitionKeys = 'bgColor' | 'color' | 'icon';
|
|
15
|
+
export type StyleDefinition = Record<StyleDefinitionKeys, string>;
|
|
16
|
+
export type StyleDefinitions = Record<LogType, Record<StyleDefinitionKeys, string>>;
|
|
17
|
+
export type ConsoleStyleDefinition = StyleDefinition;
|
|
18
|
+
export type ConsoleStyleDefinitionKeys = StyleDefinitionKeys;
|
|
19
|
+
export type ConsoleStyleDefinitions = StyleDefinitions;
|
|
20
|
+
type OptionBaseProperty = string | number | boolean | null | undefined | object | Function;
|
|
21
|
+
type ObjectBaseProperty = Record<string, OptionBaseProperty | OptionBaseProperty[]>;
|
|
22
|
+
type StdStatePropertyValue = AnyObject | boolean | null | number | string | undefined;
|
|
23
|
+
export type CustomStore<TStore, TState> = PiniaStore & TStore & TState & PiniaCustomProperties & StoreDefinition;
|
|
24
|
+
export interface PluginStoreOptions {
|
|
25
|
+
storeOptions: StoreOptions;
|
|
26
|
+
}
|
|
27
|
+
export type StatePropertyValue = StdStatePropertyValue | Ref<StdStatePropertyValue> | StdStatePropertyValue[] | Ref<StdStatePropertyValue[]> | Ref<StdStatePropertyValue>[];
|
|
28
|
+
export type StoreOptions = Record<string, StoreOptionsPropertyValue>;
|
|
29
|
+
export type StoreOptionsPropertyValue = OptionBaseProperty | OptionBaseProperty[] | ObjectBaseProperty | ObjectBaseProperty[];
|
|
30
|
+
export interface NativePiniaSubscriptionReturn<Callback> {
|
|
31
|
+
store: PiniaStore;
|
|
32
|
+
callback: Callback;
|
|
33
|
+
}
|
|
34
|
+
export interface StoreOnActionCallbackParameters {
|
|
35
|
+
after: Function;
|
|
36
|
+
args: any[] | object;
|
|
37
|
+
name: string;
|
|
38
|
+
}
|
|
39
|
+
export interface PluginSubscriberInterface {
|
|
40
|
+
console?: Console;
|
|
41
|
+
invoke: (context: PiniaPluginContext, debug: boolean) => boolean;
|
|
42
|
+
name: string;
|
|
43
|
+
resetStoreCallback?: (store?: PiniaStore) => void;
|
|
44
|
+
storeOnActionSubscription?: StoreOnActionSubscription;
|
|
45
|
+
storeMutationSubscription?: StoreMutationSubscription;
|
|
46
|
+
subscriptions?: PluginSubscriptions;
|
|
47
|
+
}
|
|
48
|
+
export interface PluginSubscriptionDefinition {
|
|
49
|
+
stores?: PiniaStore[];
|
|
50
|
+
subscription: PluginSubscriberInterface;
|
|
51
|
+
subscriptionOptions?: StoreOptions;
|
|
52
|
+
}
|
|
53
|
+
export type PluginSubscriptions = Record<string, PluginSubscriptionDefinition>;
|
|
54
|
+
export type NativePiniaSubscription<Callback> = () => NativePiniaSubscriptionReturn<Callback>;
|
|
55
|
+
export type StoreOnActionSubscriptionCallback = (params: StoreOnActionCallbackParameters) => void;
|
|
56
|
+
export type StoreOnActionSubscription = NativePiniaSubscription<StoreOnActionSubscriptionCallback>;
|
|
57
|
+
export type StoreMutationSubscriptionCallback = (mutation: SubscriptionCallbackMutation<StateTree>) => void;
|
|
58
|
+
export type StoreMutationSubscription = NativePiniaSubscription<StoreMutationSubscriptionCallback>;
|
|
59
|
+
export declare const PLUGIN_NAME: string;
|
|
60
|
+
export declare function createPlugin(subscribers: PluginSubscriberInterface[], debug?: string[]): PiniaPlugin;
|
|
61
|
+
export declare function defineAStore<Sto, Sta>(id: string, storeDefinition: Omit<DefineStoreOptions<string, StateTree & Sta, AnyObject, Partial<Sto>>, 'id'> | (() => AnyObject), options?: StoreOptions): StoreDefinition & Sta & Sto;
|
|
62
|
+
export declare function isEmpty(value: any): boolean;
|
|
63
|
+
export declare abstract class Debug {
|
|
64
|
+
protected abstract _className: string;
|
|
65
|
+
console: Console;
|
|
66
|
+
debug: boolean;
|
|
67
|
+
constructor(debug: boolean, customConsole?: Console);
|
|
68
|
+
debugLog(...args: any): void;
|
|
69
|
+
logError(...args: any): void;
|
|
70
|
+
}
|
|
71
|
+
export declare abstract class CustomConsole implements Console {
|
|
72
|
+
protected _bgColor: string;
|
|
73
|
+
protected _color: string;
|
|
74
|
+
protected _icon: string;
|
|
75
|
+
protected _errorBgColor: string;
|
|
76
|
+
protected _errorColor: string;
|
|
77
|
+
protected _errorIcon: string;
|
|
78
|
+
protected abstract _pluginName: string;
|
|
79
|
+
log(...args: any): void;
|
|
80
|
+
error(...args: any): void;
|
|
81
|
+
}
|
|
82
|
+
export declare abstract class PluginSubscriber<Instance extends Store> implements PluginSubscriberInterface {
|
|
83
|
+
console: Console;
|
|
84
|
+
name: string;
|
|
85
|
+
pluginOptions: AnyObject;
|
|
86
|
+
resetStoreCallback?: (store?: PiniaStore) => void;
|
|
87
|
+
storeOnActionSubscription?: StoreOnActionSubscription;
|
|
88
|
+
storeMutationSubscription?: StoreMutationSubscription;
|
|
89
|
+
subscriptions?: PluginSubscriptions;
|
|
90
|
+
protected pluginCreated?: (store: PiniaStore) => void;
|
|
91
|
+
protected _resetStoreCallback?: (store?: PiniaStore) => void;
|
|
92
|
+
constructor(pluginName: string, createInstanceFunction: (store: PiniaStore, options: AnyObject, debug: boolean, customConsole?: Console) => Instance | undefined, pluginConsole?: Console);
|
|
93
|
+
invoke(context: PiniaPluginContext, debug: boolean): boolean;
|
|
94
|
+
}
|
|
95
|
+
export declare class PluginSubscription extends Debug {
|
|
96
|
+
protected _className: string;
|
|
97
|
+
constructor(subscribers: PluginSubscriberInterface[], debug?: string[]);
|
|
98
|
+
plugin(context: PiniaPluginContext): void;
|
|
99
|
+
}
|
|
100
|
+
export declare class Store extends Debug {
|
|
101
|
+
protected static _requiredKeys?: string[];
|
|
102
|
+
protected _className: string;
|
|
103
|
+
onAction: StoreOnActionSubscription | undefined;
|
|
104
|
+
readonly options: StoreOptions;
|
|
105
|
+
state: StateTree;
|
|
106
|
+
storeSubscribe: StoreMutationSubscriptionCallback | undefined;
|
|
107
|
+
readonly store: AnyObject;
|
|
108
|
+
constructor(store: PiniaStore, options: AnyObject, debug?: boolean, customConsole?: Console);
|
|
109
|
+
addSubscription(pluginName: string, subscription: PluginSubscriberInterface, options?: {
|
|
110
|
+
subscriptionOptions?: StoreOptions;
|
|
111
|
+
stores?: PiniaStore[];
|
|
112
|
+
}): void;
|
|
113
|
+
addToState(name: string, value?: StatePropertyValue): void;
|
|
114
|
+
static customizeStore<Instance extends Store>(store: PiniaStore, options: AnyObject, debug?: boolean, customConsole?: Console): Instance | undefined;
|
|
115
|
+
getOption(optionName: keyof StoreOptions): StoreOptionsPropertyValue;
|
|
116
|
+
getStatePropertyValue(propertyName: string): StatePropertyValue;
|
|
117
|
+
getSubscriptions(): PluginSubscriptions | undefined;
|
|
118
|
+
getValue(value: any): any;
|
|
119
|
+
hasDeniedFirstChar(property: string): boolean;
|
|
120
|
+
isOptionApi(): boolean;
|
|
121
|
+
stateHas(property: string): boolean;
|
|
122
|
+
storeHas(property: string): boolean;
|
|
123
|
+
}
|
|
124
|
+
declare module 'pinia' {
|
|
125
|
+
interface DefineStoreOptionsBase<S, Store> {
|
|
126
|
+
storeOptions?: StoreOptions;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinia-plugin-subscription",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Pinia plugin for Vue.js that helps building Pinia plugins by centralizing subscriber registration and providing a Store base class for store helpers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"provenance": true
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
+
"prebuild": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
50
51
|
"dev": "vite",
|
|
51
52
|
"test": "vitest",
|
|
52
53
|
"coverage": "vitest run --coverage",
|
package/dist/types/log.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface Console {
|
|
2
|
-
log(...args: any): void;
|
|
3
|
-
error(...args: any): void;
|
|
4
|
-
}
|
|
5
|
-
export type LogType = 'error' | 'info';
|
|
6
|
-
export type StyleDefinition = Record<StyleDefinitionKeys, string>;
|
|
7
|
-
export type StyleDefinitionKeys = 'bgColor' | 'color' | 'icon';
|
|
8
|
-
export type StyleDefinitions = Record<LogType, Record<StyleDefinitionKeys, string>>;
|
package/dist/types/plugin.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { PiniaPluginContext, StateTree, Store, SubscriptionCallbackMutation } from "pinia";
|
|
2
|
-
import { StoreOptions } from "./store";
|
|
3
|
-
import { Console, PluginSubscriberInterface } from ".";
|
|
4
|
-
export interface PluginSubscriber {
|
|
5
|
-
console?: Console;
|
|
6
|
-
invoke: (context: PiniaPluginContext, debug: boolean) => boolean;
|
|
7
|
-
name: string;
|
|
8
|
-
resetStoreCallback?: (store?: Store) => void;
|
|
9
|
-
storeOnActionSubscription?: StoreOnActionSubscription;
|
|
10
|
-
storeMutationSubscription?: StoreMutationSubscription;
|
|
11
|
-
subscriptions?: PluginSubscriptions;
|
|
12
|
-
}
|
|
13
|
-
export interface NativePiniaSubscriptionReturn<Callback> {
|
|
14
|
-
store: Store;
|
|
15
|
-
callback: Callback;
|
|
16
|
-
}
|
|
17
|
-
export interface StoreOnActionCallbackParameters {
|
|
18
|
-
after: Function;
|
|
19
|
-
args: any[] | object;
|
|
20
|
-
name: string;
|
|
21
|
-
}
|
|
22
|
-
export interface PluginSubscription {
|
|
23
|
-
stores?: Store[];
|
|
24
|
-
subscription: PluginSubscriberInterface;
|
|
25
|
-
subscriptionOptions?: StoreOptions;
|
|
26
|
-
}
|
|
27
|
-
export type PluginSubscriptions = Record<string, PluginSubscription>;
|
|
28
|
-
export type NativePiniaSubscription<Callback> = () => NativePiniaSubscriptionReturn<Callback>;
|
|
29
|
-
export type StoreOnActionSubscriptionCallback = (params: StoreOnActionCallbackParameters) => void;
|
|
30
|
-
export type StoreOnActionSubscriptionReturn = NativePiniaSubscriptionReturn<StoreOnActionSubscriptionCallback>;
|
|
31
|
-
export type StoreOnActionSubscription = NativePiniaSubscription<StoreOnActionSubscriptionCallback>;
|
|
32
|
-
export type StoreMutationSubscriptionCallback = (mutation: SubscriptionCallbackMutation<StateTree>) => void;
|
|
33
|
-
export type StoreMutationSubscriptionReturn = NativePiniaSubscriptionReturn<StoreMutationSubscriptionCallback>;
|
|
34
|
-
export type StoreMutationSubscription = NativePiniaSubscription<StoreMutationSubscriptionCallback>;
|
package/dist/types/store.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AnyObject } from ".";
|
|
2
|
-
import type { PiniaCustomProperties, Store, StoreDefinition } from "pinia";
|
|
3
|
-
import type { Ref } from "vue";
|
|
4
|
-
export type CustomStore<TStore, TState> = Store & TStore & TState & PiniaCustomProperties & StoreDefinition;
|
|
5
|
-
export type DefineAugmentedStore<TStore, TState> = (args?: any) => CustomStore<TStore, TState>;
|
|
6
|
-
export type ObjectBaseProperty = Record<string, OptionBaseProperty | OptionBaseProperty[]>;
|
|
7
|
-
export type OptionBaseProperty = string | number | boolean | null | undefined | object | Function;
|
|
8
|
-
export interface PluginStoreOptions {
|
|
9
|
-
storeOptions: StoreOptions;
|
|
10
|
-
}
|
|
11
|
-
export type StatePropertyValue = StdStatePropertyValue | Ref<StdStatePropertyValue> | StdStatePropertyValue[] | Ref<StdStatePropertyValue[]> | Ref<StdStatePropertyValue>[];
|
|
12
|
-
type StdStatePropertyValue = AnyObject | boolean | null | number | string | undefined;
|
|
13
|
-
export type StoreOptions = Record<string, StoreOptionsPropertyValue>;
|
|
14
|
-
export type StoreOptionsPropertyValue = OptionBaseProperty | OptionBaseProperty[] | ObjectBaseProperty | ObjectBaseProperty[];
|
|
15
|
-
export {};
|