You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
11 KiB

function t(t,e){const n=Object.create(null),s=t.split(",");for(let i=0;i<s.length;i++)n[s[i]]=!0;return e?t=>!!n[t.toLowerCase()]:t=>!!n[t]}const e=()=>{},n=Object.assign,s=Object.prototype.hasOwnProperty,i=(t,e)=>s.call(t,e),r=Array.isArray,c=t=>"[object Map]"===a(t),o=t=>"function"==typeof t,u=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,a=t=>l.call(t),f=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,_=(t,e)=>!Object.is(t,e);let d;const p=[];class v{constructor(t=!1){this.active=!0,this.effects=[],this.cleanups=[],!t&&d&&(this.parent=d,this.index=(d.scopes||(d.scopes=[])).push(this)-1)}run(t){if(this.active)try{return this.on(),t()}finally{this.off()}}on(){this.active&&(p.push(this),d=this)}off(){this.active&&(p.pop(),d=p[p.length-1])}stop(t){if(this.active){if(this.effects.forEach((t=>t.stop())),this.cleanups.forEach((t=>t())),this.scopes&&this.scopes.forEach((t=>t.stop(!0))),this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.active=!1}}}function g(t){return new v(t)}function y(t,e){(e=e||d)&&e.active&&e.effects.push(t)}function w(){return d}function b(t){d&&d.cleanups.push(t)}const R=t=>{const e=new Set(t);return e.w=0,e.n=0,e},k=t=>(t.w&S)>0,m=t=>(t.n&S)>0,j=new WeakMap;let O=0,S=1;const E=[];let x;const P=Symbol(""),M=Symbol("");class z{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],y(this,n)}run(){if(!this.active)return this.fn();if(!E.includes(this))try{return E.push(x=this),B(),S=1<<++O,O<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=S})(this):W(this),this.fn()}finally{O<=30&&(t=>{const{deps:e}=t;if(e.length){let n=0;for(let s=0;s<e.length;s++){const i=e[s];k(i)&&!m(i)?i.delete(t):e[n++]=i,i.w&=~S,i.n&=~S}e.length=n}})(this),S=1<<--O,C(),E.pop();const t=E.length;x=t>0?E[t-1]:void 0}}stop(){this.active&&(W(this),this.onStop&&this.onStop(),this.active=!1)}}function W(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}function A(t,e){t.effect&&(t=t.effect.fn);const s=new z(t);e&&(n(s,e),e.scope&&y(s,e.scope)),e&&e.lazy||s.run();const i=s.run.bind(s);return i.effect=s,i}function N(t){t.effect.stop()}let V=!0;const I=[];function K(){I.push(V),V=!1}function B(){I.push(V),V=!0}function C(){const t=I.pop();V=void 0===t||t}function L(t,e,n){if(!q())return;let s=j.get(t);s||j.set(t,s=new Map);let i=s.get(n);i||s.set(n,i=R()),D(i)}function q(){return V&&void 0!==x}function D(t,e){let n=!1;O<=30?m(t)||(t.n|=S,n=!k(t)):n=!t.has(x),n&&(t.add(x),x.deps.push(t))}function F(t,e,n,s,i,o){const u=j.get(t);if(!u)return;let h=[];if("clear"===e)h=[...u.values()];else if("length"===n&&r(t))u.forEach(((t,e)=>{("length"===e||e>=s)&&h.push(t)}));else switch(void 0!==n&&h.push(u.get(n)),e){case"add":r(t)?f(n)&&h.push(u.get("length")):(h.push(u.get(P)),c(t)&&h.push(u.get(M)));break;case"delete":r(t)||(h.push(u.get(P)),c(t)&&h.push(u.get(M)));break;case"set":c(t)&&h.push(u.get(P))}if(1===h.length)h[0]&&G(h[0]);else{const t=[];for(const e of h)e&&t.push(...e);G(R(t))}}function G(t,e){for(const n of r(t)?t:[...t])(n!==x||n.allowRecurse)&&(n.scheduler?n.scheduler():n.run())}const H=t("__proto__,__v_isRef,__isVue"),J=new Set(Object.getOwnPropertyNames(Symbol).map((t=>Symbol[t])).filter(u)),Q=$(),T=$(!1,!0),U=$(!0),X=$(!0,!0),Y=Z();function Z(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=Dt(this);for(let e=0,i=this.length;e<i;e++)L(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(Dt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){K();const n=Dt(this)[e].apply(this,t);return C(),n}})),t}function $(t=!1,e=!1){return function(n,s,c){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_raw"===s&&c===(t?e?Wt:zt:e?Mt:Pt).get(n))return n;const o=r(n);if(!t&&o&&i(Y,s))return Reflect.get(Y,s,c);const l=Reflect.get(n,s,c);if(u(s)?J.has(s):H(s))return l;if(t||L(n,0,s),e)return l;if(Qt(l)){return!o||!f(s)?l.value:l}return h(l)?t?It(l):Nt(l):l}}function tt(t=!1){return function(e,n,s,c){let o=e[n];if(!t&&(s=Dt(s),o=Dt(o),!r(e)&&Qt(o)&&!Qt(s)))return o.value=s,!0;const u=r(e)&&f(n)?Number(n)<e.length:i(e,n),h=Reflect.set(e,n,s,c);return e===Dt(c)&&(u?_(s,o)&&F(e,"set",n,s):F(e,"add",n,s)),h}}const et={get:Q,set:tt(),deleteProperty:function(t,e){const n=i(t,e),s=Reflect.deleteProperty(t,e);return s&&n&&F(t,"delete",e,void 0),s},has:function(t,e){const n=Reflect.has(t,e);return u(e)&&J.has(e)||L(t,0,e),n},ownKeys:function(t){return L(t,0,r(t)?"length":P),Reflect.ownKeys(t)}},nt={get:U,set:(t,e)=>!0,deleteProperty:(t,e)=>!0},st=n({},et,{get:T,set:tt(!0)}),it=n({},nt,{get:X}),rt=t=>h(t)?Nt(t):t,ct=t=>h(t)?It(t):t,ot=t=>t,ut=t=>Reflect.getPrototypeOf(t);function ht(t,e,n=!1,s=!1){const i=Dt(t=t.__v_raw),r=Dt(e);e!==r&&!n&&L(i,0,e),!n&&L(i,0,r);const{has:c}=ut(i),o=s?ot:n?ct:rt;return c.call(i,e)?o(t.get(e)):c.call(i,r)?o(t.get(r)):void(t!==i&&t.get(e))}function lt(t,e=!1){const n=this.__v_raw,s=Dt(n),i=Dt(t);return t!==i&&!e&&L(s,0,t),!e&&L(s,0,i),t===i?n.has(t):n.has(t)||n.has(i)}function at(t,e=!1){return t=t.__v_raw,!e&&L(Dt(t),0,P),Reflect.get(t,"size",t)}function ft(t){t=Dt(t);const e=Dt(this);return ut(e).has.call(e,t)||(e.add(t),F(e,"add",t,t)),this}function _t(t,e){e=Dt(e);const n=Dt(this),{has:s,get:i}=ut(n);let r=s.call(n,t);r||(t=Dt(t),r=s.call(n,t));const c=i.call(n,t);return n.set(t,e),r?_(e,c)&&F(n,"set",t,e):F(n,"add",t,e),this}function dt(t){const e=Dt(this),{has:n,get:s}=ut(e);let i=n.call(e,t);i||(t=Dt(t),i=n.call(e,t)),s&&s.call(e,t);const r=e.delete(t);return i&&F(e,"delete",t,void 0),r}function pt(){const t=Dt(this),e=0!==t.size,n=t.clear();return e&&F(t,"clear",void 0,void 0),n}function vt(t,e){return function(n,s){const i=this,r=i.__v_raw,c=Dt(r),o=e?ot:t?ct:rt;return!t&&L(c,0,P),r.forEach(((t,e)=>n.call(s,o(t),o(e),i)))}}function gt(t,e,n){return function(...s){const i=this.__v_raw,r=Dt(i),o=c(r),u="entries"===t||t===Symbol.iterator&&o,h="keys"===t&&o,l=i[t](...s),a=n?ot:e?ct:rt;return!e&&L(r,0,h?M:P),{next(){const{value:t,done:e}=l.next();return e?{value:t,done:e}:{value:u?[a(t[0]),a(t[1])]:a(t),done:e}},[Symbol.iterator](){return this}}}}function yt(t){return function(...e){return"delete"!==t&&this}}function wt(){const t={get(t){return ht(this,t)},get size(){return at(this)},has:lt,add:ft,set:_t,delete:dt,clear:pt,forEach:vt(!1,!1)},e={get(t){return ht(this,t,!1,!0)},get size(){return at(this)},has:lt,add:ft,set:_t,delete:dt,clear:pt,forEach:vt(!1,!0)},n={get(t){return ht(this,t,!0)},get size(){return at(this,!0)},has(t){return lt.call(this,t,!0)},add:yt("add"),set:yt("set"),delete:yt("delete"),clear:yt("clear"),forEach:vt(!0,!1)},s={get(t){return ht(this,t,!0,!0)},get size(){return at(this,!0)},has(t){return lt.call(this,t,!0)},add:yt("add"),set:yt("set"),delete:yt("delete"),clear:yt("clear"),forEach:vt(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((i=>{t[i]=gt(i,!1,!1),n[i]=gt(i,!0,!1),e[i]=gt(i,!1,!0),s[i]=gt(i,!0,!0)})),[t,n,e,s]}const[bt,Rt,kt,mt]=wt();function jt(t,e){const n=e?t?mt:kt:t?Rt:bt;return(e,s,r)=>"__v_isReactive"===s?!t:"__v_isReadonly"===s?t:"__v_raw"===s?e:Reflect.get(i(n,s)&&s in e?n:e,s,r)}const Ot={get:jt(!1,!1)},St={get:jt(!1,!0)},Et={get:jt(!0,!1)},xt={get:jt(!0,!0)},Pt=new WeakMap,Mt=new WeakMap,zt=new WeakMap,Wt=new WeakMap;function At(t){return t.__v_skip||!Object.isExtensible(t)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}((t=>a(t).slice(8,-1))(t))}function Nt(t){return t&&t.__v_isReadonly?t:Bt(t,!1,et,Ot,Pt)}function Vt(t){return Bt(t,!1,st,St,Mt)}function It(t){return Bt(t,!0,nt,Et,zt)}function Kt(t){return Bt(t,!0,it,xt,Wt)}function Bt(t,e,n,s,i){if(!h(t))return t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const r=i.get(t);if(r)return r;const c=At(t);if(0===c)return t;const o=new Proxy(t,2===c?s:n);return i.set(t,o),o}function Ct(t){return Lt(t)?Ct(t.__v_raw):!(!t||!t.__v_isReactive)}function Lt(t){return!(!t||!t.__v_isReadonly)}function qt(t){return Ct(t)||Lt(t)}function Dt(t){const e=t&&t.__v_raw;return e?Dt(e):t}function Ft(t){return((t,e,n)=>{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:n})})(t,"__v_skip",!0),t}function Gt(t){q()&&((t=Dt(t)).dep||(t.dep=R()),D(t.dep))}function Ht(t,e){(t=Dt(t)).dep&&G(t.dep)}const Jt=t=>h(t)?Nt(t):t;function Qt(t){return Boolean(t&&!0===t.__v_isRef)}function Tt(t){return Yt(t,!1)}function Ut(t){return Yt(t,!0)}class Xt{constructor(t,e){this._shallow=e,this.dep=void 0,this.__v_isRef=!0,this._rawValue=e?t:Dt(t),this._value=e?t:Jt(t)}get value(){return Gt(this),this._value}set value(t){t=this._shallow?t:Dt(t),_(t,this._rawValue)&&(this._rawValue=t,this._value=this._shallow?t:Jt(t),Ht(this))}}function Yt(t,e){return Qt(t)?t:new Xt(t,e)}function Zt(t){Ht(t)}function $t(t){return Qt(t)?t.value:t}const te={get:(t,e,n)=>$t(Reflect.get(t,e,n)),set:(t,e,n,s)=>{const i=t[e];return Qt(i)&&!Qt(n)?(i.value=n,!0):Reflect.set(t,e,n,s)}};function ee(t){return Ct(t)?t:new Proxy(t,te)}class ne{constructor(t){this.dep=void 0,this.__v_isRef=!0;const{get:e,set:n}=t((()=>Gt(this)),(()=>Ht(this)));this._get=e,this._set=n}get value(){return this._get()}set value(t){this._set(t)}}function se(t){return new ne(t)}function ie(t){const e=r(t)?new Array(t.length):{};for(const n in t)e[n]=ce(t,n);return e}class re{constructor(t,e){this._object=t,this._key=e,this.__v_isRef=!0}get value(){return this._object[this._key]}set value(t){this._object[this._key]=t}}function ce(t,e){const n=t[e];return Qt(n)?n:new re(t,e)}class oe{constructor(t,e,n){this._setter=e,this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this.effect=new z(t,(()=>{this._dirty||(this._dirty=!0,Ht(this))})),this.__v_isReadonly=n}get value(){const t=Dt(this);return Gt(t),t._dirty&&(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}function ue(t,n){let s,i;o(t)?(s=t,i=e):(s=t.get,i=t.set);return new oe(s,i,o(t)||!t.set)}var he;const le=Promise.resolve(),ae=[];let fe=!1;const _e=()=>{for(let t=0;t<ae.length;t++)ae[t]();ae.length=0,fe=!1};class de{constructor(t){let e;this.dep=void 0,this._dirty=!0,this.__v_isRef=!0,this[he]=!0;let n=!1,s=!1;this.effect=new z(t,(t=>{if(this.dep){if(t)e=this._value,n=!0;else if(!s){const t=n?e:this._value;s=!0,n=!1,ae.push((()=>{this.effect.active&&this._get()!==t&&Ht(this),s=!1})),fe||(fe=!0,le.then(_e))}for(const t of this.dep)t.computed&&t.scheduler(!0)}this._dirty=!0})),this.effect.computed=!0}_get(){return this._dirty?(this._dirty=!1,this._value=this.effect.run()):this._value}get value(){return Gt(this),Dt(this)._get()}}function pe(t){return new de(t)}he="__v_isReadonly";export{v as EffectScope,P as ITERATE_KEY,z as ReactiveEffect,ue as computed,se as customRef,pe as deferredComputed,A as effect,g as effectScope,B as enableTracking,w as getCurrentScope,qt as isProxy,Ct as isReactive,Lt as isReadonly,Qt as isRef,Ft as markRaw,b as onScopeDispose,K as pauseTracking,ee as proxyRefs,Nt as reactive,It as readonly,Tt as ref,C as resetTracking,Vt as shallowReactive,Kt as shallowReadonly,Ut as shallowRef,N as stop,Dt as toRaw,ce as toRef,ie as toRefs,L as track,F as trigger,Zt as triggerRef,$t as unref};