2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
var VueReactivity=function(t){"use strict";function e(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 n=()=>{},s=Object.assign,i=Object.prototype.hasOwnProperty,r=(t,e)=>i.call(t,e),c=Array.isArray,o=t=>"[object Map]"===f(t),u=t=>"function"==typeof t,a=t=>"symbol"==typeof t,h=t=>null!==t&&"object"==typeof t,l=Object.prototype.toString,f=t=>l.call(t),_=t=>"string"==typeof t&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,d=(t,e)=>!Object.is(t,e);let p;class v{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this.parent=p,!t&&p&&(this.index=(p.scopes||(p.scopes=[])).push(this)-1)}get active(){return this._active}run(t){if(this._active){const e=p;try{return p=this,t()}finally{p=e}}}on(){p=this}off(){p=this.parent}stop(t){if(this._active){let e,n;for(e=0,n=this.effects.length;e<n;e++)this.effects[e].stop();for(e=0,n=this.cleanups.length;e<n;e++)this.cleanups[e]();if(this.scopes)for(e=0,n=this.scopes.length;e<n;e++)this.scopes[e].stop(!0);if(!this.detached&&this.parent&&!t){const t=this.parent.scopes.pop();t&&t!==this&&(this.parent.scopes[this.index]=t,t.index=this.index)}this.parent=void 0,this._active=!1}}}function g(t,e=p){e&&e.active&&e.effects.push(t)}const y=t=>{const e=new Set(t);return e.w=0,e.n=0,e},w=t=>(t.w&S)>0,R=t=>(t.n&S)>0,b=new WeakMap;let m=0,S=1;let k;const O=Symbol(""),j=Symbol("");class E{constructor(t,e=null,n){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,g(this,n)}run(){if(!this.active)return this.fn();let t=k,e=P;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=k,k=this,P=!0,S=1<<++m,m<=30?(({deps:t})=>{if(t.length)for(let e=0;e<t.length;e++)t[e].w|=S})(this):x(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 i=e[s];w(i)&&!R(i)?i.delete(t):e[n++]=i,i.w&=~S,i.n&=~S}e.length=n}})(this),S=1<<--m,k=this.parent,P=e,this.parent=void 0,this.deferStop&&this.stop()}}stop(){k===this?this.deferStop=!0:this.active&&(x(this),this.onStop&&this.onStop(),this.active=!1)}}function x(t){const{deps:e}=t;if(e.length){for(let n=0;n<e.length;n++)e[n].delete(t);e.length=0}}let P=!0;const M=[];function V(){M.push(P),P=!1}function z(){const t=M.pop();P=void 0===t||t}function W(t,e,n){if(P&&k){let e=b.get(t);e||b.set(t,e=new Map);let s=e.get(n);s||e.set(n,s=y()),A(s)}}function A(t,e){let n=!1;m<=30?R(t)||(t.n|=S,n=!w(t)):n=!t.has(k),n&&(t.add(k),k.deps.push(t))}function N(t,e,n,s,i,r){const u=b.get(t);if(!u)return;let a=[];if("clear"===e)a=[...u.values()];else if("length"===n&&c(t)){const t=Number(s);u.forEach(((e,n)=>{("length"===n||n>=t)&&a.push(e)}))}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(j)));break;case"delete":c(t)||(a.push(u.get(O)),o(t)&&a.push(u.get(j)));break;case"set":o(t)&&a.push(u.get(O))}if(1===a.length)a[0]&&T(a[0]);else{const t=[];for(const e of a)e&&t.push(...e);T(y(t))}}function T(t,e){const n=c(t)?t:[...t];for(const s of n)s.computed&&C(s);for(const s of n)s.computed||C(s)}function C(t,e){(t!==k||t.allowRecurse)&&(t.scheduler?t.scheduler():t.run())}const I=e("__proto__,__v_isRef,__isVue"),K=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(a)),D=H(),L=H(!1,!0),Y=H(!0),q=H(!0,!0),B=F();function F(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const n=zt(this);for(let e=0,i=this.length;e<i;e++)W(n,0,e+"");const s=n[e](...t);return-1===s||!1===s?n[e](...t.map(zt)):s}})),["push","pop","shift","unshift","splice"].forEach((e=>{t[e]=function(...t){V();const n=zt(this)[e].apply(this,t);return z(),n}})),t}function G(t){const e=zt(this);return W(e,0,t),e.hasOwnProperty(t)}function H(t=!1,e=!1){return function(n,s,i){if("__v_isReactive"===s)return!t;if("__v_isReadonly"===s)return t;if("__v_isShallow"===s)return e;if("__v_raw"===s&&i===(t?e?kt:St:e?mt:bt).get(n))return n;const o=c(n);if(!t){if(o&&r(B,s))return Reflect.
|