pinia-react 1.3.0 → 1.3.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.
package/README.md CHANGED
@@ -1,5 +1,167 @@
1
- # pinia-react
2
1
 
3
- 它是什么东西?它是适用于 react 框架的 pinia。
2
+ # React Pinia
4
3
 
5
- 没错!我又造了新轮子,react 的状态管理器派系众多,但是为什么会有这个 react 版的 pinia ?因为我不允许 pinia 这么好的东西只能局限于 vue 框架使用。
4
+ Pinia-react is a state management library for React inspired by Vue's Pinia, bringing a clean, reactive, and TypeScript-friendly state management experience.
5
+
6
+ [](https://www.npmjs.com/package/pinia-react)
7
+ [](https://github.com/your-username/pinia-react/blob/main/LICENSE)
8
+
9
+ ## Motivation
10
+
11
+ The React ecosystem has a variety of state management tools, but they can often be overly complex or lack structure. Inspired by Pinia's modular design and elegant API, pinia-react combines React Hooks with the Pinia philosophy to provide a lightweight, intuitive, and TypeScript-friendly state management solution suitable for modern React applications.
12
+
13
+ ## Features
14
+
15
+ - 🔄 **Powerful Reactivity** - Based on the Vue 3 reactivity system, it automatically tracks dependencies and efficiently updates components.
16
+ - ⚡️ **Reactive** - Built on `useSyncExternalStore`, it perfectly adapts to React rendering.
17
+ - 🛠 **Modular** - Independent stores that support dynamic loading.
18
+ - 🔍 **TypeScript Friendly** - Automatic type inference with zero configuration.
19
+ - 🧩 **Plugin System** - Flexible extensions for features like persistence and logging.
20
+ - 🔀 **Familiar API** - The API design is fully inspired by Pinia, making it friendly for Vue developers.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pnpm add pinia-react
26
+ ```
27
+
28
+ ## Basic Usage
29
+
30
+ ### Creating and Using a Store
31
+
32
+ ```tsx
33
+ import { defineStore } from 'pinia-react'
34
+ import { useEffect } from 'react'
35
+
36
+ // Define a store (API is identical to Pinia)
37
+ const useCounterStore = defineStore('counter', {
38
+   // Define the initial state
39
+   state: () => ({
40
+     count: 0,
41
+     name: 'Counter'
42
+   }),
43
+  
44
+   // Define getter methods (similar to computed properties)
45
+   getters: {
46
+     doubleCount() {
47
+       return this.count * 2
48
+     }
49
+   },
50
+  
51
+   // Define action methods
52
+   actions: {
53
+     increment() {
54
+       this.count++
55
+     },
56
+    
57
+     async fetchSomething() {
58
+       // Supports asynchronous operations
59
+       const result = await api.get('/data')
60
+       this.count = result.count
61
+     }
62
+   }
63
+ })
64
+
65
+ // Use in a component
66
+ function Counter() {
67
+   // Get the store instance
68
+   const store = useCounterStore()
69
+  
70
+   useEffect(() => {
71
+     // You can call an action method
72
+     store.fetchSomething()
73
+   }, [])
74
+  
75
+   return (
76
+     <div>
77
+       <h1>{store.name}: {store.count}</h1>
78
+       <p>Double count: {store.doubleCount}</p>
79
+       <button onClick={() => store.increment()}>Increment</button>
80
+     </div>
81
+   )
82
+ }
83
+ ```
84
+
85
+ ### Interacting Between Multiple Stores
86
+
87
+ ```tsx
88
+ import { defineStore } from 'pinia-react'
89
+
90
+ // User Store
91
+ const useUserStore = defineStore('user', {
92
+   state: () => ({
93
+     name: 'Anonymous',
94
+     isAdmin: false
95
+   }),
96
+   actions: {
97
+     login(name, admin = false) {
98
+       this.name = name
99
+       this.isAdmin = admin
100
+     },
101
+     logout() {
102
+       this.name = 'Anonymous'
103
+       this.isAdmin = false
104
+     }
105
+   }
106
+ })
107
+
108
+ // Cart Store, which depends on the User Store
109
+ const useCartStore = defineStore('cart', {
110
+   state: () => ({
111
+     items: []
112
+   }),
113
+   getters: {
114
+     isEmpty() {
115
+       return this.items.length === 0
116
+     },
117
+     // Can use other stores
118
+     isCheckoutAllowed() {
119
+       const userStore = useUserStore.$getStore()
120
+       return this.items.length > 0 && userStore.name !== 'Anonymous'
121
+     }
122
+   },
123
+   actions: {
124
+     addItem(item) {
125
+       this.items.push(item)
126
+     },
127
+     checkout() {
128
+       const userStore = useUserStore.$getStore()
129
+       if (userStore.name === 'Anonymous') {
130
+         throw new Error('Login required')
131
+       }
132
+       // Handle checkout logic...
133
+       this.items = []
134
+     }
135
+   }
136
+ })
137
+ ```
138
+
139
+ ### Plugin System
140
+
141
+ Pinia-react supports extending functionality through plugins.
142
+
143
+ ```ts
144
+ import { createpinia } from 'pinia-react'
145
+
146
+ // Create a pinia instance
147
+ const pinia = createpinia()
148
+
149
+ // Use a plugin
150
+ pinia.use(myPlugin)
151
+
152
+
153
+ // Plugin example
154
+ function myPlugin({ store, options }) {
155
+   // Add custom properties or methods to the store
156
+   return {
157
+     customProperty: 'value',
158
+     customMethod() {
159
+       // Custom logic
160
+     }
161
+   }
162
+ }
163
+ ```
164
+
165
+ ## License
166
+
167
+ MIT
package/dist/index.d.ts CHANGED
@@ -333,6 +333,9 @@ interface StoreDefinition<Id extends string = string, S extends StateTree = Stat
333
333
  * Id of the store. Used by map helpers.
334
334
  */
335
335
  $id: Id;
336
+ /**
337
+ * Return to store for use within non-functional components
338
+ */
336
339
  $getStore: () => Store<Id, S, G, A>;
337
340
  /**
338
341
  * Dev only pinia for HMR.
package/dist/index.js CHANGED
@@ -1,6 +1 @@
1
- import{useCallback as e,useId as t,useRef as n,useSyncExternalStore as r}from"react";function i(e,t){let n=new Set(e.split(`,`));return t?e=>n.has(e.toLowerCase()):e=>n.has(e)}var a=Object.freeze({});Object.freeze([]);var o=()=>{},s=()=>!1,c=Object.assign,l=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},u=Object.prototype.hasOwnProperty,d=(e,t)=>u.call(e,t),f=Array.isArray,p=e=>b(e)===`[object Map]`,m=e=>b(e)===`[object Set]`,h=e=>typeof e==`function`,g=e=>typeof e==`string`,_=e=>typeof e==`symbol`,v=e=>typeof e==`object`&&!!e,y=e=>(v(e)||h(e))&&h(e.then)&&h(e.catch),ee=Object.prototype.toString,b=e=>ee.call(e),x=e=>b(e).slice(8,-1),S=e=>b(e)===`[object Object]`,C=e=>g(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,w=e=>{let t=Object.create(null);return n=>{let r=t[n];return r||(t[n]=e(n))}},te=/-(\w)/g;w(e=>e.replace(te,(e,t)=>t?t.toUpperCase():``));var ne=/\B([A-Z])/g;w(e=>e.replace(ne,`-$1`).toLowerCase());var re=w(e=>e.charAt(0).toUpperCase()+e.slice(1)),ie=w(e=>{let t=e?`on${re(e)}`:``;return t}),T=(e,t)=>!Object.is(e,t),ae=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value:n})},oe,se=()=>oe||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},ce=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;ce+``;function le(e,...t){console.warn(`[Vue warn] ${e}`,...t)}var E,ue=class{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=E,!e&&E&&(this.index=(E.scopes||=[]).push(this)-1)}get active(){return this._active}run(e){if(this._active){let t=E;try{return E=this,e()}finally{E=t}}else le(`cannot run an inactive effect scope.`)}on(){E=this}off(){E=this.parent}stop(e){if(this._active){let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.scopes)for(t=0,n=this.scopes.length;t<n;t++)this.scopes[t].stop(!0);if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0,this._active=!1}}};function de(e){return new ue(e)}function fe(e,t=E){t&&t.active&&t.effects.push(e)}function pe(){return E}var D={value:void 0},me=class{constructor(e,t,n,r){this.fn=e,this.trigger=t,this.scheduler=n,this.active=!0,this.deps=[],this._dirtyLevel=2,this._trackId=0,this._runnings=0,this._shouldSchedule=!1,this._depsLength=0,fe(this,r)}get dirty(){if(this._dirtyLevel===1){xe();for(let e=0;e<this._depsLength;e++){let t=this.deps[e];if(t.computed&&(he(t.computed),this._dirtyLevel>=2))break}this._dirtyLevel<2&&(this._dirtyLevel=0),Se()}return this._dirtyLevel>=2}set dirty(e){this._dirtyLevel=e?2:0}run(){if(this._dirtyLevel=0,!this.active)return this.fn();let e=O,t=D.value;try{return O=!0,D.value=this,this._runnings++,ge(this),this.fn()}finally{_e(this),this._runnings--,D.value=t,O=e}}stop(){this.active&&(ge(this),_e(this),this.onStop?.(),this.active=!1)}};function he(e){return e.value}function ge(e){e._trackId++,e._depsLength=0}function _e(e){if(e.deps&&e.deps.length>e._depsLength){for(let t=e._depsLength;t<e.deps.length;t++)ve(e.deps[t],e);e.deps.length=e._depsLength}}function ve(e,t){let n=e.get(t);n!==void 0&&t._trackId!==n&&(e.delete(t),e.size===0&&e.cleanup())}var O=!0,ye=0,be=[];function xe(){be.push(O),O=!1}function Se(){let e=be.pop();O=e===void 0?!0:e}function Ce(){ye++}function we(){for(ye--;!ye&&Ee.length;)Ee.shift()()}function Te(e,t,n){if(t.get(e)!==e._trackId){t.set(e,e._trackId);let r=e.deps[e._depsLength];r===t?e._depsLength++:(r&&ve(r,e),e.deps[e._depsLength++]=t),e.onTrack?.(c({effect:e},n))}}var Ee=[];function De(e,t,n){Ce();for(let r of e.keys()){if(e.get(r)!==r._trackId)continue;if(r._dirtyLevel<t){let e=r._dirtyLevel;r._dirtyLevel=t,e===0&&(r._shouldSchedule=!0,r.onTrigger?.(c({effect:r},n)),r.trigger())}r.scheduler&&r._shouldSchedule&&(!r._runnings||r.allowRecurse)&&(r._shouldSchedule=!1,Ee.push(r.scheduler))}we()}var Oe=(e,t)=>{let n=new Map;return n.cleanup=e,n.computed=t,n},ke=new WeakMap,k=Symbol(`iterate`),Ae=Symbol(`Map key iterate`);function A(e,t,n){if(O&&D.value){let r=ke.get(e);r||ke.set(e,r=new Map);let i=r.get(n);i||r.set(n,i=Oe(()=>r.delete(n))),Te(D.value,i,{target:e,type:t,key:n})}}function j(e,t,n,r,i,a){let o=ke.get(e);if(!o)return;let s=[];if(t===`clear`)s=[...o.values()];else if(n===`length`&&f(e)){let e=Number(r);o.forEach((t,n)=>{(n===`length`||!_(n)&&n>=e)&&s.push(t)})}else switch(n!==void 0&&s.push(o.get(n)),t){case`add`:f(e)?C(n)&&s.push(o.get(`length`)):(s.push(o.get(k)),p(e)&&s.push(o.get(Ae)));break;case`delete`:f(e)||(s.push(o.get(k)),p(e)&&s.push(o.get(Ae)));break;case`set`:p(e)&&s.push(o.get(k));break}Ce();for(let o of s)o&&De(o,2,{target:e,type:t,key:n,newValue:r,oldValue:i,oldTarget:a});we()}function je(e,t){return ke.get(e)?.get(t)}var Me=i(`__proto__,__v_isRef,__isVue`),Ne=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(_)),Pe=Fe();function Fe(){let e={};return[`includes`,`indexOf`,`lastIndexOf`].forEach(t=>{e[t]=function(...e){let n=F(this);for(let e=0,t=this.length;e<t;e++)A(n,`get`,e+``);let r=n[t](...e);return r===-1||r===!1?n[t](...e.map(F)):r}}),[`push`,`pop`,`shift`,`unshift`,`splice`].forEach(t=>{e[t]=function(...e){xe(),Ce();let n=F(this)[t].apply(this,e);return we(),Se(),n}}),e}function Ie(e){let t=F(this);return A(t,`has`,e),t.hasOwnProperty(e)}var Le=class{constructor(e=!1,t=!1){this._isReadonly=e,this._shallow=t}get(e,t,n){let r=this._isReadonly,i=this._shallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?pt:ft:i?dt:ut).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=f(e);if(!r){if(a&&d(Pe,t))return Reflect.get(Pe,t,n);if(t===`hasOwnProperty`)return Ie}let o=Reflect.get(e,t,n);return(_(t)?Ne.has(t):Me(t))||(r||A(e,`get`,t),i)?o:L(o)?a&&C(t)?o:o.value:v(o)?r?_t(o):gt(o):o}},Re=class extends Le{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t];if(!this._shallow){let t=P(i);if(!bt(n)&&!P(n)&&(i=F(i),n=F(n)),!f(e)&&L(i)&&!L(n))return t?!1:(i.value=n,!0)}let a=f(e)&&C(t)?Number(t)<e.length:d(e,t),o=Reflect.set(e,t,n,r);return e===F(r)&&(a?T(n,i)&&j(e,`set`,t,n,i):j(e,`add`,t,n)),o}deleteProperty(e,t){let n=d(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&j(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!_(t)||!Ne.has(t))&&A(e,`has`,t),n}ownKeys(e){return A(e,`iterate`,f(e)?`length`:k),Reflect.ownKeys(e)}},ze=class extends Le{constructor(e=!1){super(!0,e)}set(e,t){return le(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0}deleteProperty(e,t){return le(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0}},Be=new Re,Ve=new ze,He=new ze(!0),Ue=e=>e,We=e=>Reflect.getPrototypeOf(e);function Ge(e,t,n=!1,r=!1){e=e.__v_raw;let i=F(e),a=F(t);n||(T(t,a)&&A(i,`get`,t),A(i,`get`,a));let{has:o}=We(i),s=r?Ue:n?Ct:I;if(o.call(i,t))return s(e.get(t));if(o.call(i,a))return s(e.get(a));e!==i&&e.get(t)}function Ke(e,t=!1){let n=this.__v_raw,r=F(n),i=F(e);return t||(T(e,i)&&A(r,`has`,e),A(r,`has`,i)),e===i?n.has(e):n.has(e)||n.has(i)}function qe(e,t=!1){return e=e.__v_raw,!t&&A(F(e),`iterate`,k),Reflect.get(e,`size`,e)}function Je(e){e=F(e);let t=F(this),n=We(t),r=n.has.call(t,e);return r||(t.add(e),j(t,`add`,e,e)),this}function Ye(e,t){t=F(t);let n=F(this),{has:r,get:i}=We(n),a=r.call(n,e);a?lt(n,r,e):(e=F(e),a=r.call(n,e));let o=i.call(n,e);return n.set(e,t),a?T(t,o)&&j(n,`set`,e,t,o):j(n,`add`,e,t),this}function Xe(e){let t=F(this),{has:n,get:r}=We(t),i=n.call(t,e);i?lt(t,n,e):(e=F(e),i=n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&j(t,`delete`,e,void 0,a),o}function Ze(){let e=F(this),t=e.size!==0,n=p(e)?new Map(e):new Set(e),r=e.clear();return t&&j(e,`clear`,void 0,void 0,n),r}function Qe(e,t){return function(n,r){let i=this,a=i.__v_raw,o=F(a),s=t?Ue:e?Ct:I;return!e&&A(o,`iterate`,k),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}}function $e(e,t,n){return function(...r){let i=this.__v_raw,a=F(i),o=p(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?Ue:t?Ct:I;return!t&&A(a,`iterate`,c?Ae:k),{next(){let{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:s?[u(e[0]),u(e[1])]:u(e),done:t}},[Symbol.iterator](){return this}}}}function M(e){return function(...t){{let n=t[0]?`on key "${t[0]}" `:``;console.warn(`${re(e)} operation ${n}failed: target is readonly.`,F(this))}return e===`delete`?!1:e===`clear`?void 0:this}}function et(){let e={get(e){return Ge(this,e)},get size(){return qe(this)},has:Ke,add:Je,set:Ye,delete:Xe,clear:Ze,forEach:Qe(!1,!1)},t={get(e){return Ge(this,e,!1,!0)},get size(){return qe(this)},has:Ke,add:Je,set:Ye,delete:Xe,clear:Ze,forEach:Qe(!1,!0)},n={get(e){return Ge(this,e,!0)},get size(){return qe(this,!0)},has(e){return Ke.call(this,e,!0)},add:M(`add`),set:M(`set`),delete:M(`delete`),clear:M(`clear`),forEach:Qe(!0,!1)},r={get(e){return Ge(this,e,!0,!0)},get size(){return qe(this,!0)},has(e){return Ke.call(this,e,!0)},add:M(`add`),set:M(`set`),delete:M(`delete`),clear:M(`clear`),forEach:Qe(!0,!0)},i=[`keys`,`values`,`entries`,Symbol.iterator];return i.forEach(i=>{e[i]=$e(i,!1,!1),n[i]=$e(i,!0,!1),t[i]=$e(i,!1,!0),r[i]=$e(i,!0,!0)}),[e,n,t,r]}var[tt,nt,rt,it]=et();function at(e,t){let n=t?e?it:rt:e?nt:tt;return(t,r,i)=>r===`__v_isReactive`?!e:r===`__v_isReadonly`?e:r===`__v_raw`?t:Reflect.get(d(n,r)&&r in t?n:t,r,i)}var ot={get:at(!1,!1)},st={get:at(!0,!1)},ct={get:at(!0,!0)};function lt(e,t,n){let r=F(n);if(r!==n&&t.call(e,r)){let t=x(e);console.warn(`Reactive ${t} contains both the raw and reactive versions of the same object${t===`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.`)}}var ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,pt=new WeakMap;function mt(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function ht(e){return e.__v_skip||!Object.isExtensible(e)?0:mt(x(e))}function gt(e){return P(e)?e:yt(e,!1,Be,ot,ut)}function _t(e){return yt(e,!0,Ve,st,ft)}function vt(e){return yt(e,!0,He,ct,pt)}function yt(e,t,n,r,i){if(!v(e))return console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&!(t&&e.__v_isReactive))return e;let a=i.get(e);if(a)return a;let o=ht(e);if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function N(e){return P(e)?N(e.__v_raw):!!(e&&e.__v_isReactive)}function P(e){return!!(e&&e.__v_isReadonly)}function bt(e){return!!(e&&e.__v_isShallow)}function xt(e){return N(e)||P(e)}function F(e){let t=e&&e.__v_raw;return t?F(t):e}function St(e){return ae(e,`__v_skip`,!0),e}var I=e=>v(e)?gt(e):e,Ct=e=>v(e)?_t(e):e,wt,Tt=class{constructor(e,t,n,r){this._setter=t,this.dep=void 0,this.__v_isRef=!0,this[wt]=!1,this.effect=new me(()=>e(this._value),()=>Ot(this,1)),this.effect.computed=this,this.effect.active=this._cacheable=!r,this.__v_isReadonly=n}static{wt=`__v_isReadonly`}get value(){let e=F(this);return(!e._cacheable||e.effect.dirty)&&T(e._value,e._value=e.effect.run())&&Ot(e,2),Dt(e),e._value}set value(e){this._setter(e)}get _dirty(){return this.effect.dirty}set _dirty(e){this.effect.dirty=e}};function Et(e,t,n=!1){let r,i,a=h(e);a?(r=e,i=()=>{console.warn(`Write operation failed: computed value is readonly`)}):(r=e.get,i=e.set);let o=new Tt(r,i,a||!i,n);return t&&!n&&(o.effect.onTrack=t.onTrack,o.effect.onTrigger=t.onTrigger),o}function Dt(e){O&&D.value&&(e=F(e),Te(D.value,e.dep||=Oe(()=>e.dep=void 0,e instanceof Tt?e:void 0),{target:e,type:`get`,key:`value`}))}function Ot(e,t=2,n){e=F(e);let r=e.dep;r&&De(r,t,{target:e,type:`set`,key:`value`,newValue:n})}function L(e){return!!(e&&e.__v_isRef===!0)}function kt(e){return At(e,!1)}function At(e,t){return L(e)?e:new jt(e,t)}var jt=class{constructor(e,t){this.__v_isShallow=t,this.dep=void 0,this.__v_isRef=!0,this._rawValue=t?e:F(e),this._value=t?e:I(e)}get value(){return Dt(this),this._value}set value(e){let t=this.__v_isShallow||bt(e)||P(e);e=t?e:F(e),T(e,this._rawValue)&&(this._rawValue=e,this._value=t?e:I(e),Ot(this,2,e))}};function Mt(e){return L(e)?e.value:e}var Nt={get:(e,t,n)=>Mt(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return L(i)&&!L(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function Pt(e){return N(e)?e:new Proxy(e,Nt)}function Ft(e){xt(e)||console.warn(`toRefs() expects a reactive object but received a plain one.`);let t=f(e)?Array(e.length):{};for(let n in e)t[n]=Lt(e,n);return t}var It=class{constructor(e,t,n){this._object=e,this._key=t,this._defaultValue=n,this.__v_isRef=!0}get value(){let e=this._object[this._key];return e===void 0?this._defaultValue:e}set value(e){this._object[this._key]=e}get dep(){return je(F(this._object),this._key)}};function Lt(e,t,n){let r=e[t];return L(r)?r:new It(e,t,n)}var R=[];function Rt(e){R.push(e)}function zt(){R.pop()}function z(e,...t){xe();let n=R.length?R[R.length-1].component:null,r=n&&n.appContext.config.warnHandler,i=Bt();if(r)B(r,n,11,[e+t.join(``),n&&n.proxy,i.map(({vnode:e})=>`at <${or(n,e.type)}>`).join(`
2
- `),i]);else{let n=[`[Vue warn]: ${e}`,...t];i.length&&n.push(`
3
- `,...Vt(i)),console.warn(...n)}Se()}function Bt(){let e=R[R.length-1];if(!e)return[];let t=[];for(;e;){let n=t[0];n&&n.vnode===e?n.recurseCount++:t.push({vnode:e,recurseCount:0});let r=e.component&&e.component.parent;e=r&&r.vnode}return t}function Vt(e){let t=[];return e.forEach((e,n)=>{t.push(...n===0?[]:[`
4
- `],...Ht(e))}),t}function Ht({vnode:e,recurseCount:t}){let n=t>0?`... (${t} recursive calls)`:``,r=e.component?e.component.parent==null:!1,i=` at <${or(e.component,e.type,r)}`,a=`>`+n;return e.props?[i,...Ut(e.props),a]:[i+a]}function Ut(e){let t=[],n=Object.keys(e);return n.slice(0,3).forEach(n=>{t.push(...Wt(n,e[n]))}),n.length>3&&t.push(` ...`),t}function Wt(e,t,n){return g(t)?(t=JSON.stringify(t),n?t:[`${e}=${t}`]):typeof t==`number`||typeof t==`boolean`||t==null?n?t:[`${e}=${t}`]:L(t)?(t=Wt(e,F(t.value),!0),n?t:[`${e}=Ref<`,t,`>`]):h(t)?[`${e}=fn${t.name?`<${t.name}>`:``}`]:(t=F(t),n?t:[`${e}=`,t])}var Gt={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. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core .`};function B(e,t,n,r){let i;try{i=r?e(...r):e()}catch(e){Kt(e,t,n)}return i}function V(e,t,n,r){if(h(e)){let i=B(e,t,n,r);return i&&y(i)&&i.catch(e=>{Kt(e,t,n)}),i}let i=[];for(let a=0;a<e.length;a++)i.push(V(e[a],t,n,r));return i}function Kt(e,t,n,r=!0){let i=t?t.vnode:null;if(t){let r=t.parent,i=t.proxy,a=Gt[n];for(;r;){let t=r.ec;if(t){for(let n=0;n<t.length;n++)if(t[n](e,i,a)===!1)return}r=r.parent}let o=t.appContext.config.errorHandler;if(o){B(o,null,10,[e,i,a]);return}}qt(e,n,i,r)}function qt(e,t,n,r=!0){{let i=Gt[t];if(n&&Rt(n),z(`Unhandled error${i?` during execution of ${i}`:``}`),n&&zt(),r)throw e;console.error(e)}}var Jt=!1,Yt=!1,H=[],U=0,W=[],G=null,K=0,Xt=Promise.resolve(),Zt=null,Qt=100;function $t(e){let t=Zt||Xt;return e?t.then(this?e.bind(this):e):t}function en(e){let t=U+1,n=H.length;for(;t<n;){let r=t+n>>>1,i=H[r],a=on(i);a<e||a===e&&i.pre?t=r+1:n=r}return t}function tn(e){(!H.length||!H.includes(e,Jt&&e.allowRecurse?U+1:U))&&(e.id==null?H.push(e):H.splice(en(e.id),0,e),nn())}function nn(){!Jt&&!Yt&&(Yt=!0,Zt=Xt.then(cn))}function rn(e){f(e)?W.push(...e):(!G||!G.includes(e,e.allowRecurse?K+1:K))&&W.push(e),nn()}function an(e){if(W.length){let t=[...new Set(W)].sort((e,t)=>on(e)-on(t));if(W.length=0,G){G.push(...t);return}for(G=t,e||=new Map,K=0;K<G.length;K++)ln(e,G[K])||G[K]();G=null,K=0}}var on=e=>e.id==null?1/0:e.id,sn=(e,t)=>{let n=on(e)-on(t);if(n===0){if(e.pre&&!t.pre)return-1;if(t.pre&&!e.pre)return 1}return n};function cn(e){Yt=!1,Jt=!0,e||=new Map,H.sort(sn);let t=t=>ln(e,t);try{for(U=0;U<H.length;U++){let e=H[U];if(e&&e.active!==!1){if(t(e))continue;B(e,null,14)}}}finally{U=0,H.length=0,an(e),Jt=!1,Zt=null,(H.length||W.length)&&cn(e)}}function ln(e,t){if(!e.has(t))e.set(t,1);else{let n=e.get(t);if(n>Qt){let e=t.ownerInstance,n=e&&ar(e.type);return Kt(`Maximum recursive updates exceeded${n?` in component <${n}>`:``}. 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}else e.set(t,n+1)}}var un=!1,dn=new Set;se().__VUE_HMR_RUNTIME__={createRecord:vn(pn),rerender:vn(hn),reload:vn(gn)};var fn=new Map;function pn(e,t){return fn.has(e)?!1:(fn.set(e,{initialDef:mn(t),instances:new Set}),!0)}function mn(e){return sr(e)?e.__vccOpts:e}function hn(e,t){let n=fn.get(e);n&&(n.initialDef.render=t,[...n.instances].forEach(e=>{t&&(e.render=t,mn(e.type).render=t),e.renderCache=[],un=!0,e.effect.dirty=!0,e.update(),un=!1}))}function gn(e,t){let n=fn.get(e);if(!n)return;t=mn(t),_n(n.initialDef,t);let r=[...n.instances];for(let e of r){let r=mn(e.type);dn.has(r)||(r!==n.initialDef&&_n(r,t),dn.add(r)),e.appContext.propsCache.delete(e.type),e.appContext.emitsCache.delete(e.type),e.appContext.optionsCache.delete(e.type),e.ceReload?(dn.add(r),e.ceReload(t.styles),dn.delete(r)):e.parent?(e.parent.effect.dirty=!0,tn(e.parent.update)):e.appContext.reload?e.appContext.reload():typeof window<`u`?window.location.reload():console.warn(`[HMR] Root or manually mounted instance modified. Full reload required.`)}rn(()=>{for(let e of r)dn.delete(mn(e.type))})}function _n(e,t){for(let n in c(e,t),e)n!==`__file`&&!(n in t)&&delete e[n]}function vn(e){return(t,n)=>{try{return e(t,n)}catch(e){console.error(e),console.warn(`[HMR] Something went wrong during Vue component hot-reload. Full reload required.`)}}}var yn=null,bn=!1;function xn(){bn=!0}var Sn=Symbol.for(`v-scx`),Cn=()=>{{let e=Jn(Sn);return e||z(`Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`),e}},wn={};function Tn(e,t,n){return h(t)||z("`watch(fn, options?)` signature has been moved to a separate API. Use `watchEffect(fn, options?)` instead. `watch` now only supports `watch(source, cb, options?) signature."),En(e,t,n)}function En(e,t,{immediate:n,deep:r,flush:i,once:s,onTrack:c,onTrigger:u}=a){if(t&&s){let e=t;t=(...t)=>{e(...t),ne()}}r!==void 0&&typeof r==`number`&&z(`watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`),t||(n!==void 0&&z(`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`),r!==void 0&&z(`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`),s!==void 0&&z(`watch() "once" option is only respected when using the watch(source, callback, options?) signature.`));let d=e=>{z(`Invalid watch source: `,e,`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`)},p=X,m=e=>r===!0?e:q(e,r===!1?1:void 0),g,_=!1,v=!1;if(L(e)?(g=()=>e.value,_=bt(e)):N(e)?(g=()=>m(e),_=!0):f(e)?(v=!0,_=e.some(e=>N(e)||bt(e)),g=()=>e.map(e=>{if(L(e))return e.value;if(N(e))return m(e);if(h(e))return B(e,p,2);d(e)})):h(e)?g=t?()=>B(e,p,2):()=>(y&&y(),V(e,p,3,[ee])):(g=o,d(e)),t&&r){let e=g;g=()=>q(e())}let y,ee=e=>{y=w.onStop=()=>{B(e,p,4),y=w.onStop=void 0}},b;if(tr)if(ee=o,t?n&&V(t,p,3,[g(),v?[]:void 0,ee]):g(),i===`sync`){let e=Cn();b=e.__watcherHandles||=[]}else return o;let x=v?Array(e.length).fill(wn):wn,S=()=>{if(!(!w.active||!w.dirty))if(t){let e=w.run();(r||_||(v?e.some((e,t)=>T(e,x[t])):T(e,x)))&&(y&&y(),V(t,p,3,[e,x===wn?void 0:v&&x[0]===wn?[]:x,ee]),x=e)}else w.run()};S.allowRecurse=!!t;let C;i===`sync`?C=S:i===`post`?C=()=>Yn(S,p&&p.suspense):(S.pre=!0,p&&(S.id=p.uid),C=()=>tn(S));let w=new me(g,o,C),te=pe(),ne=()=>{w.stop(),te&&l(te.effects,w)};return w.onTrack=c,w.onTrigger=u,t?n?S():x=w.run():i===`post`?Yn(w.run.bind(w),p&&p.suspense):w.run(),b&&b.push(ne),ne}function Dn(e,t,n){let r=this.proxy,i=g(e)?e.includes(`.`)?On(r,e):()=>r[e]:e.bind(r,r),a;h(t)?a=t:(a=t.handler,n=t);let o=$n(this),s=En(i,a.bind(r),n);return o(),s}function On(e,t){let n=t.split(`.`);return()=>{let t=e;for(let e=0;e<n.length&&t;e++)t=t[n[e]];return t}}function q(e,t,n=0,r){if(!v(e)||e.__v_skip)return e;if(t&&t>0){if(n>=t)return e;n++}if(r||=new Set,r.has(e))return e;if(r.add(e),L(e))q(e.value,t,n,r);else if(f(e))for(let i=0;i<e.length;i++)q(e[i],t,n,r);else if(m(e)||p(e))e.forEach(e=>{q(e,t,n,r)});else if(S(e))for(let i in e)q(e[i],t,n,r);return e}Symbol(`_leaveCb`),Symbol(`_enterCb`);function kn(e,t,n=X,r=!1){if(n){let i=n[e]||(n[e]=[]),a=t.__weh||=(...r)=>{if(n.isUnmounted)return;xe();let i=$n(n),a=V(t,n,e,r);return i(),Se(),a};return r?i.unshift(a):i.push(a),a}else{let t=ie(Gt[e].replace(/ hook$/,``));z(`${t} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`)}}var J=e=>(t,n=X)=>(!tr||e===`sp`)&&kn(e,(...e)=>t(...e),n);J(`bm`),J(`m`),J(`bu`),J(`u`),J(`bum`),J(`um`),J(`sp`),J(`rtg`),J(`rtc`),Symbol.for(`v-ndc`);var An=e=>e?er(e)?nr(e)||e.proxy:An(e.parent):null,jn=c(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>vt(e.props),$attrs:e=>vt(e.attrs),$slots:e=>vt(e.slots),$refs:e=>vt(e.refs),$parent:e=>An(e.parent),$root:e=>An(e.root),$emit:e=>e.emit,$options:e=>Ln(e),$forceUpdate:e=>e.f||=()=>{e.effect.dirty=!0,tn(e.update)},$nextTick:e=>e.n||=$t.bind(e.proxy),$watch:e=>Dn.bind(e)}),Mn=e=>e===`_`||e===`$`,Nn=(e,t)=>e!==a&&!e.__isScriptSetup&&d(e,t),Pn={get({_:e},t){let{ctx:n,setupState:r,data:i,props:o,accessCache:s,type:c,appContext:l}=e;if(t===`__isVue`)return!0;let u;if(t[0]!==`$`){let c=s[t];if(c!==void 0)switch(c){case 1:return r[t];case 2:return i[t];case 4:return n[t];case 3:return o[t]}else if(Nn(r,t))return s[t]=1,r[t];else if(i!==a&&d(i,t))return s[t]=2,i[t];else if((u=e.propsOptions[0])&&d(u,t))return s[t]=3,o[t];else if(n!==a&&d(n,t))return s[t]=4,n[t];else In&&(s[t]=0)}let f=jn[t],p,m;if(f)return t===`$attrs`?(A(e,`get`,t),xn()):t===`$slots`&&A(e,`get`,t),f(e);if((p=c.__cssModules)&&(p=p[t]))return p;if(n!==a&&d(n,t))return s[t]=4,n[t];if(m=l.config.globalProperties,d(m,t))return m[t];yn&&(!g(t)||t.indexOf(`__v`)!==0)&&(i!==a&&Mn(t[0])&&d(i,t)?z(`Property ${JSON.stringify(t)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`):e===yn&&z(`Property ${JSON.stringify(t)} was accessed during render but is not defined on instance.`))},set({_:e},t,n){let{data:r,setupState:i,ctx:o}=e;return Nn(i,t)?(i[t]=n,!0):i.__isScriptSetup&&d(i,t)?(z(`Cannot mutate <script setup> binding "${t}" from Options API.`),!1):r!==a&&d(r,t)?(r[t]=n,!0):d(e.props,t)?(z(`Attempting to mutate prop "${t}". Props are readonly.`),!1):t[0]===`$`&&t.slice(1)in e?(z(`Attempting to mutate public property "${t}". Properties starting with $ are reserved and readonly.`),!1):(t in e.appContext.config.globalProperties?Object.defineProperty(o,t,{enumerable:!0,configurable:!0,value:n}):o[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:i,propsOptions:o}},s){let c;return!!n[s]||e!==a&&d(e,s)||Nn(t,s)||(c=o[0])&&d(c,s)||d(r,s)||d(jn,s)||d(i.config.globalProperties,s)},defineProperty(e,t,n){return n.get==null?d(n,`value`)&&this.set(e,t,n.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,n)}};Pn.ownKeys=e=>(z(`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(e));function Fn(e){return f(e)?e.reduce((e,t)=>(e[t]=null,e),{}):e}var In=!0;function Ln(e){let t=e.type,{mixins:n,extends:r}=t,{mixins:i,optionsCache:a,config:{optionMergeStrategies:o}}=e.appContext,s=a.get(t),c;return s?c=s:!i.length&&!n&&!r?c=t:(c={},i.length&&i.forEach(e=>Rn(c,e,o,!0)),Rn(c,t,o)),v(t)&&a.set(t,c),c}function Rn(e,t,n,r=!1){let{mixins:i,extends:a}=t;for(let o in a&&Rn(e,a,n,!0),i&&i.forEach(t=>Rn(e,t,n,!0)),t)if(r&&o===`expose`)z(`"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`);else{let r=zn[o]||n&&n[o];e[o]=r?r(e[o],t[o]):t[o]}return e}var zn={data:Bn,props:Wn,emits:Wn,methods:Un,computed:Un,beforeCreate:Y,created:Y,beforeMount:Y,mounted:Y,beforeUpdate:Y,updated:Y,beforeDestroy:Y,beforeUnmount:Y,destroyed:Y,unmounted:Y,activated:Y,deactivated:Y,errorCaptured:Y,serverPrefetch:Y,components:Un,directives:Un,watch:Gn,provide:Bn,inject:Vn};function Bn(e,t){return t?e?function(){return c(h(e)?e.call(this,this):e,h(t)?t.call(this,this):t)}:t:e}function Vn(e,t){return Un(Hn(e),Hn(t))}function Hn(e){if(f(e)){let t={};for(let n=0;n<e.length;n++)t[e[n]]=e[n];return t}return e}function Y(e,t){return e?[...new Set([].concat(e,t))]:t}function Un(e,t){return e?c(Object.create(null),e,t):t}function Wn(e,t){return e?f(e)&&f(t)?[...new Set([...e,...t])]:c(Object.create(null),Fn(e),Fn(t??{})):t}function Gn(e,t){if(!e)return t;if(!t)return e;let n=c(Object.create(null),e);for(let r in t)n[r]=Y(e[r],t[r]);return n}function Kn(){return{app:null,config:{isNativeTag:s,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}var qn=null;function Jn(e,t,n=!1){let r=X||yn;if(r||qn){let i=r?r.parent==null?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:qn._context.provides;if(i&&e in i)return i[e];if(arguments.length>1)return n&&h(t)?t.call(r&&r.proxy):t;z(`injection "${String(e)}" not found.`)}else z(`inject() can only be used inside setup() or functional components.`)}var Yn=Xn;function Xn(e,t){t&&t.pendingBranch?f(e)?t.effects.push(...e):t.effects.push(e):rn(e)}Symbol.for(`v-fgt`),Symbol.for(`v-txt`),Symbol.for(`v-cmt`),Symbol.for(`v-stc`),Kn();var X=null,Zn,Qn;{let e=se(),t=(t,n)=>{let r;return(r=e[t])||(r=e[t]=[]),r.push(n),e=>{r.length>1?r.forEach(t=>t(e)):r[0](e)}};Zn=t(`__VUE_INSTANCE_SETTERS__`,e=>X=e),Qn=t(`__VUE_SSR_SETTERS__`,e=>tr=e)}var $n=e=>{let t=X;return Zn(e),e.scope.on(),()=>{e.scope.off(),Zn(t)}};function er(e){return e.vnode.shapeFlag&4}var tr=!1;function nr(e){if(e.exposed)return e.exposeProxy||=new Proxy(Pt(St(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in jn)return jn[n](e)},has(e,t){return t in e||t in jn}})}var rr=/(?:^|[-_])(\w)/g,ir=e=>e.replace(rr,e=>e.toUpperCase()).replace(/[-_]/g,``);function ar(e,t=!0){return h(e)?e.displayName||e.name:e.name||t&&e.__name}function or(e,t,n=!1){let r=ar(t);if(!r&&t.__file){let e=t.__file.match(/([^/\\]+)\.\w+$/);e&&(r=e[1])}if(!r&&e&&e.parent){let n=e=>{for(let n in e)if(e[n]===t)return n};r=n(e.components||e.parent.type.components)||n(e.appContext.components)}return r?ir(r):n?`App`:`Anonymous`}function sr(e){return h(e)&&`__vccOpts`in e}var cr=(e,t)=>Et(e,t,tr);
5
- /*! #__NO_SIDE_EFFECTS__ */
6
- const lr=()=>ur;let ur;function Z(e){ur=e}function dr(){let e=de(!0),t=e.run(()=>kt({})),n=[],r=St({use(e){return n.push(e),this},_p:n,_e:e,_s:new Map,state:t});return Z(r),r}const fr=()=>{};function pr(e,t,n,r=fr){e.add(t);let i=()=>{e.delete(t),r()};return i}function Q(e,...t){e.forEach(e=>{e(...t)})}let mr=function(e){return e.direct=`direct`,e.patchObject=`patch object`,e.patchFunction=`patch function`,e}({});function hr(e){return Object.prototype.toString.call(e).slice(8,-1)===`Array`}function gr(e){return Object.prototype.toString.call(e).slice(8,-1)===`Object`}function _r(e){return Object.prototype.toString.call(e).slice(8,-1)===`Null`}var vr=class{constructor(e={}){return this.subscribeList={},this.pubAndNoSub={},Object.assign(this,e)}subscribe(e,t){var n;this.pubAndNoSub[e]&&(t(this.pubAndNoSub[e]),Reflect.deleteProperty(this.pubAndNoSub,e)),(n=this.subscribeList[e])!=null&&n.push(t)||(this.subscribeList[e]=[t])}publish(e,t){let n=this.subscribeList[e];!n||n.length===0?this.pubAndNoSub[e]=t:n.forEach(e=>e(t))}remove(e,t){let n=this.subscribeList[e];!n||n.length===0||(t?n.forEach((n,r)=>{n===t&&this.subscribeList[e].splice(r,1)}):this.subscribeList[e]=[])}};new vr;var yr=class{constructor(){this.copyShallow=e=>this.copy(e,`shallow`),this.copyDeep=e=>this.copy(e,`deep`)}copy(e,t){if(typeof e==`object`&&e){let n=Reflect.construct(e.constructor,[]);return Object.keys(e).forEach(r=>{n[r]=t===`shallow`?e[r]:this.copy(e[r],`deep`)}),n}return e}},{copyShallow:br,copyDeep:xr}=new yr,Sr=class{constructor(){this.compareShallow=(e,t)=>this.compare(e,t,`shallow`),this.compareDeep=(e,t)=>this.compare(e,t,`deep`)}compare(e,t,n){if(e===t)return!0;if(!gr(e)||_r(e)||!gr(t)||_r(t))return!1;let r=Object.keys(e).length,i=Object.keys(t).length;if(r!==i)return!1;for(let r of Object.keys(e)){let i=r;if(n===`shallow`&&e[i]!==t[i])return!1;if(n===`deep`){let n=this.compare(e[i],t[i],`deep`);if(!n)return n}}return!0}},{compareShallow:Cr,compareDeep:wr}=new Sr,Tr=class{constructor(){this.mergeShallow=(e,...t)=>this.merge(e,`shallow`,...t),this.mergeDeep=(e,...t)=>this.merge(e,`deep`,...t)}merge(e,t,...n){if(hr(n)){for(;n.length>0;){let r=n.pop();if(!gr(r))return e;Reflect.ownKeys(r).forEach(n=>{if(t===`shallow`)e[n]=r[n];else{if(!Reflect.has(e,n)||!gr(r[n]))return e[n]=xr(r[n]);this.merge(e[n],`deep`,r[n])}})}return e}return e}},{mergeShallow:Er,mergeDeep:Dr}=new Tr;function Or(){return{}}function kr(e){return e&&typeof e==`object`&&Object.prototype.toString.call(e)===`[object Object]`&&typeof e.toJSON!=`function`}function Ar(e,t){for(let n in e instanceof Map&&t instanceof Map&&t.forEach((t,n)=>e.set(n,t)),e instanceof Set&&t instanceof Set&&t.forEach(e.add,e),t){if(!Object.hasOwn(t,n))continue;let r=t[n],i=e[n];kr(i)&&kr(r)&&e.hasOwnProperty(n)&&!L(r)&&!N(r)?e[n]=Ar(i,r):e[n]=r}return e}const jr=Symbol(),Mr=Symbol(),{assign:$}=Object;function Nr(e,t,n){let{state:r,actions:i,getters:a}=t,o=n.state.value[e],s;function c(){o||(n.state.value[e]=r?r():{});let t=Ft(n.state.value[e]);return $(t,i,Object.keys(a||{}).reduce((t,r)=>(t[r]=St(cr(()=>{Z(n);let t=n._s.get(e);return a[r].call(t,t)})),t),{}))}return s=Pr(e,c,t,n),s}function Pr(e,t,n={},r){let i,a=$({actions:{}},n),o={deep:!0},s,c,l=new Set,u=new Set,d=[],f;function p(t){let n;s=c=!1,typeof t==`function`?(t(r.state.value[e]),n={type:mr.patchFunction,storeId:e,events:d}):(Ar(r.state.value[e],t),n={type:mr.patchObject,payload:t,storeId:e,events:d}),f=Symbol();let i=f;$t().then(()=>{f===i&&(s=!0)}),c=!0,Q(l,n,r.state.value[e])}let m=function(){let{state:e}=n,t=e?e():{};this.$patch(e=>{$(e,t)})},h=(t,n=``)=>{if(jr in t)return t[Mr]=n,t;let i=function(){Z(r);let n=Array.from(arguments),a=new Set,o=new Set;function s(e){a.add(e)}function c(e){o.add(e)}Q(u,{args:n,name:i[Mr],store:_,after:s,onError:c});let l;try{l=t.apply(this&&this.$id===e?this:_,n)}catch(e){throw Q(o,e),e}return l instanceof Promise?l.then(e=>(Q(a,e),e)).catch(e=>(Q(o,e),Promise.reject(e))):(Q(a,l),l)};return i[jr]=!0,i[Mr]=n,i},g={_p:r,$id:e,$onAction:pr.bind(null,u),$patch:p,$reset:m,$subscribe(t,n={}){let a=pr(l,t,n.detached,()=>u()),u=i.run(()=>Tn(()=>r.state.value[e],r=>{(n.flush===`sync`?c:s)&&t({storeId:e,type:mr.direct,events:d},r)},$({},o,n)));return a}},_=gt(g);r._s.set(e,_),i=de();let v=i.run(()=>t({action:h}));for(let e in v){let t=v[e];if(typeof t==`function`){let n=h(t,e);v[e]=n,a.actions[e]=t}}return $(_,v),$(F(_),v),Object.defineProperty(_,`$state`,{get:()=>r.state.value[e],set:e=>{p(t=>{$(t,e)})}}),r._p.forEach(e=>{$(_,i.run(()=>e({store:_,pinia:r,options:a})))}),s=!0,c=!0,_}function Fr(i,a){let o=new WeakMap,s=new WeakMap;function c(c){c&&Z(c),c=ur;let l=D.value;D.value=void 0,c._s.has(i)||Nr(i,a,c),D.value=l;let u=c._s.get(i),d=n([t()]),f=n({...u}),p=n(!1),m=e(e=>(s.set(d.current,e),()=>{let e=o.get(d.current);e&&e.stop(),s.delete(d.current),o.delete(d.current)}),[]);r(m,()=>f.current,()=>f.current);let h=o.get(d.current);if(!h){let e=()=>{let e=s.get(d.current);p.current||(f.current={...u},e?.())};h=new me(e,Or,()=>{h?.dirty&&h.run()}),D.value=h,p.current=!0,h.run(),o.set(d.current,h),p.current=!1}return u}return c.$id=i,c.$getStore=e=>{e&&Z(e),e=ur,e._s.has(i)||Nr(i,a,e);let t=e._s.get(i);return t},c}export{mr as MutationType,dr as createPinia,Fr as defineStore,lr as getActivePinia,Z as setActivePinia};
1
+ import{ReactiveEffect as e,activeEffect as t,computed as n,effectScope as r,isReactive as i,isRef as a,markRaw as o,nextTick as s,reactive as c,ref as l,toRaw as u,toRefs as d,watch as f}from"@maoism/runtime-core";import{useCallback as p,useId as m,useRef as h,useSyncExternalStore as g}from"react";import"savage-types";import"savage-utils";const _=()=>v;let v;function y(e){v=e}function b(){let e=r(!0),t=e.run(()=>l({})),n=[],i=o({use(e){return n.push(e),this},_p:n,_e:e,_s:new Map,state:t});return y(i),i}const x=()=>{};function S(e,t,n,r=x){e.add(t);let i=()=>{e.delete(t),r()};return i}function C(e,...t){e.forEach(e=>{e(...t)})}let w=function(e){return e.direct=`direct`,e.patchObject=`patch object`,e.patchFunction=`patch function`,e}({});function T(){return{}}function E(e){return e&&typeof e==`object`&&Object.prototype.toString.call(e)===`[object Object]`&&typeof e.toJSON!=`function`}function D(e,t){for(let n in e instanceof Map&&t instanceof Map&&t.forEach((t,n)=>e.set(n,t)),e instanceof Set&&t instanceof Set&&t.forEach(e.add,e),t){if(!Object.hasOwn(t,n))continue;let r=t[n],o=e[n];E(o)&&E(r)&&e.hasOwnProperty(n)&&!a(r)&&!i(r)?e[n]=D(o,r):e[n]=r}return e}const O=Symbol(),k=Symbol(),{assign:A}=Object;function j(e,t,r){let{state:i,actions:a,getters:s}=t,c=r.state.value[e],l;function u(){c||(r.state.value[e]=i?i():{});let t=d(r.state.value[e]);return A(t,a,Object.keys(s||{}).reduce((t,i)=>(t[i]=o(n(()=>{y(r);let t=r._s.get(e);return s[i].call(t,t)})),t),{}))}return l=M(e,u,t,r),l}function M(e,t,n={},i){let a,o=A({actions:{}},n),l={deep:!0},d,p,m=new Set,h=new Set,g=[],_;function v(t){let n;d=p=!1,typeof t==`function`?(t(i.state.value[e]),n={type:w.patchFunction,storeId:e,events:g}):(D(i.state.value[e],t),n={type:w.patchObject,payload:t,storeId:e,events:g}),_=Symbol();let r=_;s().then(()=>{_===r&&(d=!0)}),p=!0,C(m,n,i.state.value[e])}let b=function(){let{state:e}=n,t=e?e():{};this.$patch(e=>{A(e,t)})},x=(t,n=``)=>{if(O in t)return t[k]=n,t;let r=function(){y(i);let n=Array.from(arguments),a=new Set,o=new Set;function s(e){a.add(e)}function c(e){o.add(e)}C(h,{args:n,name:r[k],store:E,after:s,onError:c});let l;try{l=t.apply(this&&this.$id===e?this:E,n)}catch(e){throw C(o,e),e}return l instanceof Promise?l.then(e=>(C(a,e),e)).catch(e=>(C(o,e),Promise.reject(e))):(C(a,l),l)};return r[O]=!0,r[k]=n,r},T={_p:i,$id:e,$onAction:S.bind(null,h),$patch:v,$reset:b,$subscribe(t,n={}){let r=S(m,t,n.detached,()=>o()),o=a.run(()=>f(()=>i.state.value[e],r=>{(n.flush===`sync`?p:d)&&t({storeId:e,type:w.direct,events:g},r)},A({},l,n)));return r}},E=c(T);i._s.set(e,E),a=r();let j=a.run(()=>t({action:x}));for(let e in j){let t=j[e];if(typeof t==`function`){let n=x(t,e);j[e]=n,o.actions[e]=t}}return A(E,j),A(u(E),j),Object.defineProperty(E,`$state`,{get:()=>i.state.value[e],set:e=>{v(t=>{A(t,e)})}}),i._p.forEach(e=>{A(E,a.run(()=>e({store:E,pinia:i,options:o})))}),d=!0,p=!0,E}function N(n,r){let i=new WeakMap,a=new WeakMap;function o(o){o&&y(o),o=v;let s=t.value;t.value=void 0,o._s.has(n)||j(n,r,o),t.value=s;let c=o._s.get(n),l=h([m()]),u=h({...c}),d=h(!1),f=p(e=>(a.set(l.current,e),()=>{let e=i.get(l.current);e&&e.stop(),a.delete(l.current),i.delete(l.current)}),[]);g(f,()=>u.current,()=>u.current);let _=i.get(l.current);if(!_){let n=()=>{let e=a.get(l.current);d.current||(u.current={...c},e?.())};_=new e(n,T,()=>{_?.dirty&&_.run()}),t.value=_,d.current=!0,_.run(),i.set(l.current,_),d.current=!1}return c}return o.$id=n,o.$getStore=e=>{e&&y(e),e=v,e._s.has(n)||j(n,r,e);let t=e._s.get(n);return t},o}export{w as MutationType,b as createPinia,N as defineStore,_ as getActivePinia,y as setActivePinia};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinia-react",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "homepage": "https://github.com/savageKarl/pinia-react#readme",
6
6
  "bugs": {