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