UNPKG

@jiess/core

Version:

基于javascript的配置式渲染库,同时支持vue2,vue3和react

1 lines 23.7 kB
function e(t,r,s=new WeakMap){if(Object.is(t,r))return!0;const o=typeof t;if(o!==typeof r)return!1;if(!t||!r||"object"!==o)return!1;if(s.has(t)&&s.has(r))return s.get(t)===r&&s.get(r)===t;s.set(t,r),s.set(r,t);const i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(r))return!1;switch(i){case"[object Date]":return t.getTime()===r.getTime();case"[object Promise]":return!1;case"[object Function]":case"[object RegExp]":case"[object Symbol]":return String(t)===String(r);case"[object ArrayBuffer]":case"[object SharedArrayBuffer]":if(t.byteLength!==r.byteLength)return!1;const o=new Uint8Array(t),i=new Uint8Array(r);for(let e=0;e<t.byteLength;e++)if(o[e]!==i[e])return!1;return!0;case"[object BigInt]":return t===r;case"[object TypedArray]":return JSON.stringify(Array.from(t))===JSON.stringify(Array.from(r));case"[object Map]":if(t.size!==r.size)return!1;for(const[o,i]of t)if(!r.has(o)||!e(i,r.get(o),s))return!1;return!0;case"[object Set]":if(t.size!==r.size)return!1;const n=[...t],c=[...r];for(let t=0;t<n.length;t++){let r=!1;for(let o=0;o<c.length;o++)if(e(n[t],c[o],s)){r=!0;break}if(!r)return!1}return!0}if(Array.isArray(t)){if(t.length!==r.length)return!1;for(let o=0;o<t.length;o++)if(!e(t[o],r[o],s))return!1;return!0}const n=Object.keys(t),c=Object.keys(r);if(n.length!==c.length)return!1;const a=new Set(c);for(let o of n)if(!a.has(o)||!e(t[o],r[o],s))return!1;return!0}const t=(t,r,s=!0)=>{if(Object.is(t,r))return!0;const o=typeof t;if(o!==typeof r)return!1;if(!t||!r||"object"!==o)return!1;if(s)if(Array.isArray(t)){if(!Array.isArray(r))return!1;if(t.length!==r.length)return!1;for(let e=0;e<t.length;e++){const s=t[e],o=r[e];if(!Object.is(s,o)){if(typeof s!=typeof o)return!1;if(!s||!o||"object"!=typeof s)return!1}}}else{if(Array.isArray(r))return!1;{const e=Object.keys(t),s=Object.keys(r);if(e.length!==s.length)return!1;const o=new Set(s);for(const s of e){if(!o.has(s))return!1;const e=t[s],i=r[s];if(!Object.is(e,i)){if(typeof e!=typeof i)return!1;if(!e||!i||"object"!=typeof e)return!1}}}}let i=t,n=r;if(s){const e=(t,r)=>{if(!t||"object"!=typeof t)return t;if(r.has(t))return r.get(t);if(x(t))return t;const s=Array.isArray(t)?[]:{};r.set(t,s);for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(Array.isArray(s)?s[Number(o)]=e(t[o],r):s[o]=e(t[o],r));return s},s=new WeakMap;i=e(t,s),n=e(r,s)}return e(i,n,new WeakMap)},r=(...e)=>{};function s(e,t,r=!0){if(Array.isArray(t))return t.some(t=>s(e,t));if("string"==typeof t){const e=t.toLowerCase();"exp"!==e&&"regex"!==e||(t="RegExp")}else if(r)throw new Error(`${t} Error:须提供字符串`);const o="string"==typeof t?t.charAt(0).toUpperCase()+t.slice(1):t,i=Object.prototype.toString.call(e)===`[object ${o}]`;if(!i&&"Object"===o&&null!==e&&"object"==typeof e){const t=Object.prototype.toString.call(e);return t.includes("ArrayBuffer")||t.includes("TypedArray")||t.startsWith("[object ")}return i}const o=s,i=(e,t,r=new WeakMap)=>{if(!e||"object"!=typeof e){if(t){const r=t(e,"filter");return void 0!==r?r:void 0}return e}if(r.has(e))return r.get(e);if(e instanceof Date){const t=new Date(e.getTime());return r.set(e,t),t}if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return r.set(e,t),t}if(x(e)){const r=t?.(e,"filter");return void 0!==r?r:e}let s;if(s=Array.isArray(e)?new Array(e.length):{},r.set(e,s),Array.isArray(e))for(let o=0;o<e.length;o++){const n=i(e[o],t,r);void 0!==n&&(s[o]=n)}else{for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const n=i(e[o],t,r);void 0!==n&&(s[o]=n)}Object.getOwnPropertySymbols(e).forEach(o=>{const n=i(e[o],t,r);void 0!==n&&(s[o]=n)})}if(t){const e=t(s,"clone");if(void 0!==e)return e}return s},n=(e,t)=>!((e,t)=>!(!t||""!==e)||[null,void 0,NaN].some(t=>Object.is(t,e)))(e,t);function c(){let e=null;return(t,...r)=>(e||(e=Promise.resolve().then(()=>(e=null,t.call(this,...r)))),e)}const a=(e,t=!1)=>{let r;return function(s,o=100){const i=()=>"function"==typeof e?e():"function"==typeof s?s():void 0;n(r,!0)?clearTimeout(r):t&&i(),r=setTimeout(i,o)}};function h(e,t){if(!e||!t)return;let r;if(r=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),r=r.filter(Boolean),0===r.length)return;let s=e;for(const e of r)try{const t=Number(e);s=!isNaN(t)&&Number.isInteger(t)&&Array.isArray(s)?s[t]:s[e]}catch(e){return}return s}(((a(),e=>{let t;return function(r,s=100){n(t,!0)&&clearTimeout(t),t=setTimeout(()=>"function"==typeof e?e():"function"==typeof r?r():void 0,s)}})(),e=>{let t=!0;return function(r,s=100){t&&(t=!1,setTimeout(()=>{t=!0,"function"==typeof e?e():"function"==typeof r&&r()},s))}})(),e=>{let t,r=0;return function(s,o=100){const i="function"==typeof e?e:s;let c=Date.now();c-r>=o?(r=c,"function"==typeof i&&i()):n(t,!0)||(t=setTimeout(()=>{r=Date.now(),t=void 0,"function"==typeof i&&i()},o))}})(),"undefined"==typeof window||"undefined"==typeof document||!window.document||window.document.createElement;const f="JIESS_CONSTRUCTOR",u="THIS_IS_JIESS",l="JIESS_INIT_VALUE",p="__JIESS_REF__",y="__JIESS_COMPUTED__",d="__JIESS_PARENT__",g=new Set(["is","component","$exclude"]),b=(e,t)=>Array.isArray(e)?[...e]:o(e,"object")?{...e}:t?void(()=>{throw new Error("shallowCopy Error:须提供对象或数组")})():e;function _(e){return!(!e||"object"!=typeof e||!e[u])}const v=(e,t)=>{throw new Error(`${e} Error:${t}`)};function w(e,t,s=r,i="数据类型"){return o(e,t)?s():v(i,`须提供 ${t} 类型`)}const m=(e,t,r=f)=>!!o(e,"object")&&Object.is(e[r],t),x=e=>null!==e&&"object"==typeof e&&(!!_(e)||(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer||(e instanceof Promise||(!!(Reflect.has(e,"__v_isReactive")||Reflect.has(e,"__v_isReadonly")||Reflect.has(e,"$")||Reflect.has(e,"_")||Reflect.has(e,"__")||Reflect.has(e,"is")||Reflect.has(e,"$slots")||Reflect.has(e,"$$typeof")||Reflect.has(e,"nodeType"))||(!!Object.keys(e).some(e=>e.startsWith("__v_")||e.startsWith("__react")||e.startsWith("El")||e.startsWith("a-")||e.startsWith("van-"))||"function"==typeof e.install))))));function M(e={},t="toString"){if("function"==typeof e[t]){if("string"==typeof t){const r=new RegExp(t,"g");return(e[t]+"").replace(r,"")}return e[t]+""}return""}const S=(()=>{const e=M();return(t,r)=>M(t,r)===e})(),j=(e,t,r={})=>(e.has(t)?r=e.get(t):e.set(t,r),r);class O{_disposed=!1;_resources=[];add(e){if(this._disposed)throw new Error("ResourceManager has been disposed");return this._resources.push(e),this}remove(e){if(this._disposed)return;const t=this._resources.indexOf(e);-1!==t&&this._resources.splice(t,1)}get disposed(){return this._disposed}dispose(){if(!this._disposed){this._disposed=!0;for(let e=this._resources.length-1;e>=0;e--)try{this._resources[e].dispose()}catch(e){}this._resources=[]}}get size(){return this._resources.length}}class A{static uid=1;constructor(e,t={}){this[f]=e,this.J_uid=A.uid++,"function"==typeof t&&(t=t(this)),Object.assign(this,t),this.bindCxt()}bindCxt(){for(const e of Reflect.ownKeys(this.__proto__))if("constructor"!==e&&"string"==typeof e){if(e.startsWith("_"))continue;const t=Object.getOwnPropertyDescriptor(this.__proto__,e);if(t&&t.get)continue;"function"==typeof this[e]&&(this[e]=this[e].bind(this)),this.freezeField(e)}}resetField(e,t){Object.prototype.hasOwnProperty.call(this,e)&&Object.defineProperty(this,e,{value:t})}freezeField(e){Object.prototype.hasOwnProperty.call(this,e)&&Object.defineProperty(this,e,{writable:!1,enumerable:!0,configurable:!0})}}class k extends A{watcher;fn;flush;effecting="start";value;computer=!1;debounce2;debounce1=a();dirty=!0;get isDirty(){return this.dirty}target;proxy;constructor(e,t,r="pre"){super("Composite"),this.watcher=e,this.fn=t,this.flush=r,this.debounce2=c.call(this)}initComputed(e,t){this.computer=!0,this.target=e,this.proxy=t}_initCounter=0;_initBaseTime=0;init(e,t,r,s){const o=Date.now();if(o-this._initBaseTime>1e3&&(this._initCounter=0,this._initBaseTime=o),!this.computer&&++this._initCounter>500)throw new Error(`[死循环检测] Composite.init 循环调用超过 500 次,key=${String(t)}`);return this.computer&&!this.dirty||(this.computer||("function"==typeof this.value&&this.value(),this.watcher.effecter.stop(this)),this.watcher.effecter.addCurrent(this),this.done(e,t,r,s),this.watcher.effecter.removeCurrent(),this.dirty=!1),this.value}done(e,t,r,s){return this.computer?"doned"===this.effecting?this.recomputeWithDependency(e,t,r,s):(this.effecting="start",this.value=this.fn(r,t,e,s),this.effecting="computed",this.computer&&(this.proxy.value=this.value),this.effecting="doned"):(this.effecting="start",this.value=this.fn(r,t,e,s),this.effecting="computed",this.effecting="doned"),this.value}recomputeWithDependency(e,t,r,s){this.effecting="start";try{this.value=this.fn(r,t,e,s),this.effecting="computed",this.computer&&(this.proxy.value=this.value)}finally{this.effecting="doned"}}check(e){this.computer?"start"===this.effecting?v("Computed","计算中禁止赋值"):"function"==typeof e&&e(e=>{this.target.value=e,this.watcher.effecter.trigger(this.target,"value",e,this.proxy)}):"function"==typeof e&&e()}trigger(e,t,s,o){this.dirty=!0,this.check((i=r)=>{"sync"===this.flush?i(this.init(e,t,s,o)):"pre"===this.flush?this.debounce2(()=>i(this.init())):this.debounce1(()=>i(this.init()),0)})}stop(){"function"==typeof this.value&&this.value(),this.watcher.effecter.stop(this)}}const R=new Set([Symbol.iterator,"constructor","__proto__","prototype",NaN,null,void 0,1/0]),T=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class E extends A{watcher;current;execStack=[];mapStore;reverseMap;collectCache;constructor(e){super("Effecter"),this.watcher=e,this.mapStore=new WeakMap,this.reverseMap=new WeakMap,this.collectCache=new WeakMap}addCurrent(e){this.current&&this.execStack.push(this.current),this.current=e,this.collectCache.set(e,new WeakMap)}removeCurrent(){this.current&&this.collectCache.delete(this.current),this.current=this.execStack.pop()}shouldExclude(e,t){return(!Array.isArray(e)||"string"!=typeof t||!T.has(t))&&(R.has(t)||S(e,t))}getCacheKey(e,t){try{return`${e.constructor.name}-${JSON.stringify(t)}-${e[Symbol.toStringTag]||""}`}catch(r){return`${e.constructor.name}-${String(t)}-${e[Symbol.toStringTag]||""}`}}collect(e,t){if(!this.current||"start"!==this.current.effecting)return;if(this.shouldExclude(e,t))return;const r=this.current,s=t,o=this.collectCache.get(r);if(o){const r=o.get(e);if(r&&r.has(t))return}const i=j(this.mapStore,e);if(i[s]=i[s]||new Set,i[s].add(r),this.mapStore.set(e,i),o){const r=o.get(e)||new Set;r.add(t),o.set(e,r)}const n=this.reverseMap.get(r)||new Set;n.add({target:e,key:s}),this.reverseMap.set(r,n)}trigger(e,t,r,s){if(this.shouldExclude(e,t))return;this.current?.check();const o=j(this.mapStore,e),i=t;if(o.hasOwnProperty(i)){const n=new Set(o[i]),c=new Set;n.forEach(o=>{o===this.current||c.has(o)||(o.trigger(e,t,r,s),c.add(o))})}this.watcher.update(s,t,r)}stop(e){const t=this.reverseMap.get(e);t&&(t.forEach(({target:t,key:r})=>{const s=this.mapStore.get(t);s&&s[r]&&(s[r].delete(e),0===s[r].size&&delete s[r],0===Object.keys(s).length&&this.mapStore.delete(t))}),this.reverseMap.delete(e),this.collectCache.delete(e))}}const C=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class W extends A{watcher;_targetToProxy=new WeakMap;_childKeyMap=new WeakMap;constructor(e){super("Observer"),this.watcher=e}create(e,t,r=new WeakSet,o=!1){return x(e)&&"Target"!==e[f]?e:w(e,["array","object"],()=>{if(r.has(e))return this._targetToProxy.get(e)||e;r.add(e);const i=new Proxy(e,this.getProxyHandler(t));if(this._targetToProxy.set(e,i),!o)for(const t in e)if(!g.has(t)&&s(e[t],["array","object"])){const s=this.create(e[t],i,r,!1);this._childKeyMap.set(s,t),e[t]=s}return i},"创建响应式数据")}getProxyHandler(e){return{has:(e,t)=>(this.watcher.effecter.collect(e,t),t in e),get:(t,r,o)=>{if(r===u)return!0;if("__JIESS_TARGET__"===r)return t;if(r===d)return e;if(r===Symbol.toStringTag)return Array.isArray(t)?"Array":t instanceof Map?"Map":t instanceof Set?"Set":t instanceof Date?"Date":t instanceof RegExp?"RegExp":"Object";if(this.watcher.effecter.collect(t,r),m(t,!0,y)&&"value"===r)return t.getValue();if(t instanceof Map||t instanceof Set||t instanceof Date||t instanceof RegExp){const e=Reflect.get(t,r);return"function"==typeof e?e.bind(t):e}const i=Reflect.get(t,r,o);if(Array.isArray(t)&&"string"==typeof r&&C.has(r)){const e=this,i=Array.prototype[r];return function(...n){const c=t.length,a="sort"===r||"reverse"===r||"unshift"===r||"shift"===r,h=a?[...t]:null,f=i.apply(t,n);if("push"===r||"unshift"===r||"splice"===r){const i=[...n];"splice"===r&&i.splice(0,2),i.forEach((c,a)=>{if(s(c,["array","object"])&&!(c instanceof Map)&&!(c instanceof Set)&&!(c instanceof Date)&&!(c instanceof RegExp)){const s=new WeakSet,h=e.create(c,o,s,!1);let f=0;"push"===r?f=t.length-i.length+a:"unshift"===r?f=a:"splice"===r&&(f=n[0]+a),e._childKeyMap.set(h,f),t[f]=h}})}if("splice"===r)for(let r="number"==typeof n[0]?n[0]:0;r<t.length;r++){const s=t[r];s&&"object"==typeof s&&e._childKeyMap.has(s)&&e._childKeyMap.set(s,r)}else if("sort"===r||"reverse"===r||"shift"===r||"unshift"===r)for(let r=0;r<t.length;r++){const s=t[r];s&&"object"==typeof s&&e._childKeyMap.has(s)&&e._childKeyMap.set(s,r)}if(a&&h)for(let e=0;e<Math.max(c,t.length);e++)Object.is(h[e],t[e])||(o[e]=t[e]);else{let e=0,s=Math.max(c,t.length);"push"===r?(e=c,s=t.length):"pop"===r?(e=t.length,s=c):"splice"===r&&(e="number"==typeof n[0]?n[0]:0);for(let r=e;r<s;r++)o[r]=t[r]}return o.length=t.length,e.trigger(t,r,f,o),f}}return i},set:(t,r,s,o)=>{if(r===d)return e=s,!0;if(Object.is(t[r],s))return!0;const i=Reflect.set(t,r,s,o);return this.trigger(t,r,s,o),i},deleteProperty:(e,t)=>{if(t in e){const r=Reflect.deleteProperty(e,t),s=this._targetToProxy.get(e)||e;return this.trigger(e,t,void 0,s),r}return Reflect.deleteProperty(e,t)}}}trigger(e,t,r,s){const{effecter:o}=this.watcher;if(m(e,!0,y))e.setValue(r,t);else if(o.trigger(e,t,r,s),Array.isArray(e)&&"string"==typeof t&&C.has(t)&&o.trigger(e,"length",e.length,s),s&&s[d]){const e=s[d],t=this._childKeyMap.get(s);void 0!==t&&o.trigger(e,t,s,e)}}}const P=(e,t)=>void 0===e?t:e;class D extends A{proxy;field;config;value;result;oldValue;isDestory=!1;cbs;debounce1;other;_resourceManager;get disposed(){return this._resourceManager.disposed}constructor(e,t,r={}){super("Observe"),this.proxy=e,this.field=t,this.config=r,this._resourceManager=new O,this.cbs=new Set,this.debounce1=a(),this._resourceManager.add({disposed:!1,dispose:()=>{this.debounce1=null}});const{hasKey:s,defaultValue:o,observe:i,...n}=r;this.other=n,this.observe(i),this.value=b(s?e[t]:e);const c=this.value=P(this.value,o);this.getValue((e,t)=>{this.result=e,t&&this.dispatch(e,{value:c,...n})})}getValue(e){const{value:t,config:r,result:s}=this,{defaultValue:i,done:n}=r;"function"==typeof n?o(n,"AsyncFunction")?(n(t,this).then(t=>e(t,!0)).catch(e=>{console.error("Observe.getValue async done error:",e)}),e(P(s,i))):e(n(t,this)):e(t)}observe(e){return"function"==typeof e&&this.cbs.add(e),this}remove(e){return"function"==typeof e&&this.cbs.delete(e),this}destroy(){this.dispose()}dispose(){this._resourceManager.disposed||(this.isDestory=!0,this._resourceManager.dispose(),this.cbs.clear(),this.proxy=null,this.field=null,this.config=null,this.other=null)}resolve(e){if(this.isDestory||!this.config)return;const r=this.value,s={value:e,oldValue:r,...this.other};let{isSync:o,hasKey:i,sameState:n=!1,done:c}=this.config;if(i){try{n=t(r,e)}catch(e){console.error(e)}this.value=b(e),this.oldValue=r,n&&"function"!=typeof c||this.getValue(e=>this.dispatch(e,s))}else{const t=()=>{this.value=b(e),this.getValue(e=>this.dispatch(e,s))};o?t():this.debounce1(()=>t(),0)}}dispatch(e,t){t.oldResult=this.result,t.result=this.result=e,this.cbs.forEach(r=>{r(e,t.oldResult,t)})}}class N extends A{_setter;_composite;value;constructor(){super("Target"),this[u]=!0,this.value=l,this[y]=!0}initSetter(e){this._setter=e}initComposite(e){this._composite=e}getValue(){return(this.value===l||this._composite&&this._composite.isDirty)&&(this.value=this._composite?.init()),this.value}setValue(e,t){"value"!==t?v("Computed","仅允许对value赋值"):"function"==typeof this._setter?(this._setter(e),this.update()):"computed"===this._composite?.effecting||v("Computed","须提供setter")}update(){this._composite&&this._composite.trigger(this,"value",this.value,this)}}class $ extends A{static _default;static getDefault(){return $._default&&!$._default.disposed||($._default=new $),$._default}static _globalResourceManager;_proxyToObserve=new WeakMap;_proxyToObserveNo=new WeakMap;_pathCache=new WeakMap;_dependencyCache=new WeakMap;effecter;observer;_resourceManager;get disposed(){return this._resourceManager?.disposed??$._globalResourceManager?.disposed??!1}constructor(){super("Watcher"),this._resourceManager=new O,this.observer=new W(this),this.effecter=new E(this)}static getGlobalResourceManager(){return $._globalResourceManager||($._globalResourceManager=new O),$._globalResourceManager}clearProxyResources(e){this.clearObservers(e),this._proxyToObserve.delete(e),this._proxyToObserveNo.delete(e)}dispose(){this._resourceManager?.disposed||(this._resourceManager?.dispose(),$._globalResourceManager&&!$._globalResourceManager.disposed&&($._globalResourceManager.dispose(),$._globalResourceManager=void 0),this._proxyToObserve=new WeakMap,this._proxyToObserveNo=new WeakMap,this._pathCache=new WeakMap,this._dependencyCache=new WeakMap,$._default===this&&($._default=void 0))}static disposeAll(){$.getGlobalResourceManager().dispose()}hasLoopReference(e,t=new WeakSet){if("object"!=typeof e||null===e)return!1;if(t.has(e))return!0;t.add(e);let r=0;const s=[{obj:e,keys:Object.keys(e),index:0}];for(;s.length>0&&r<1e3;){const e=s[s.length-1];if(!e)break;const{obj:o,keys:i,index:n}=e;if(n>=i.length){t.delete(o),s.pop(),r--;continue}const c=i[n];e&&(e.index=n+1);const a=o[c];if("object"==typeof a&&null!==a){if(t.has(a))return!0;t.add(a),s.push({obj:a,keys:Object.keys(a),index:0}),r++}}return s.forEach(e=>t.delete(e.obj)),!1}createProxy(e){let t=e;return this.hasLoopReference(e)&&(t=i(e)),this.observer?.create(t)}createShallowProxy(e){return this.observer?.create(e,void 0,new WeakSet,!0)}createComputed(e,t){const r=new N,s=this.createProxy(r);if(o(e,"object")){const{get:t,set:s}=e;"function"==typeof t&&(e=t),"function"==typeof s&&r.initSetter(s)}const i=new k(this,e,t);return r.initComposite(i),i.initComputed(r,s),s}watchEffect(e,t){const r=new k(this,e,t);return r.init(),()=>r.stop()}observe(e={$proxy:{}}){let{$proxy:t,field:r,warn:s=!0,...i}=e,n=t,c=r;if("string"==typeof r&&r.includes(".")){let e=this._pathCache.get(t);e||(e=new Map,this._pathCache.set(t,e));const s=r,o=e.get(s);if(o)n=o.target,c=o.field;else{const o=r.split("."),i=o.pop(),a=h(t,o);e.set(s,{target:a,field:i}),n=a,c=i}}const a=o(n,"object")&&(Reflect.has(n,y)||Reflect.has(n,p))?"value":c,f=i.hasKey=o(a,["number","string"]);if(_(n)){const e=new D(n,a,i);if(f){const t=j(this._proxyToObserve,n,{}),r=a;t[r]=t[r]||[],t[r].push(e),this._proxyToObserve.set(n,t)}else{const t=j(this._proxyToObserveNo,n,[]);this._proxyToObserveNo.set(n,t),t.push(e)}return e}if(s){if("function"==typeof s){const e=i.done,t=s(n,a);return e?e(t):t}console.warn("$proxy:需要定义为响应式对象")}return(e=>{const{$proxy:t,field:r,done:s}=e;return s?s(t):r?t[r]:t})(e)}bind(e,t,r,{cb:s}){if(!o(r,["number","string"])&&null!=r){const o=r,i=this.createProxy(o);return i[d]=e,"function"==typeof s?s(i):t&&(e[t]=i),i}e[t]=r}update(e,t,r){const s=this._proxyToObserve.get(e);if(s&&Object.keys(s).length>0){const o=s[t];if(o&&Array.isArray(o)&&o.length>0){const i=o.filter(e=>!e.isDestory);i.length>0&&(i.forEach(e=>e.resolve(r)),s[t]=i,0===i.length&&(delete s[t],0===Object.keys(s).length&&this._proxyToObserve.delete(e)))}}this.resolveParent(e)}clearObservers(e){if(this._proxyToObserve.has(e)){const t=this._proxyToObserve.get(e);if(t)for(const e in t){const r=t[e];Array.isArray(r)&&r.forEach(e=>e.destroy())}this._proxyToObserve.delete(e)}if(this._proxyToObserveNo.has(e)){const t=this._proxyToObserveNo.get(e);Array.isArray(t)&&t.forEach(e=>e.destroy()),this._proxyToObserveNo.delete(e)}}resolveParent(e){if(this._proxyToObserveNo.has(e)){const t=this._proxyToObserveNo.get(e);if(Array.isArray(t)){const r=t.filter(t=>!t.isDestory&&(t.resolve(e),!0));r.length!==t.length&&(0===r.length?this._proxyToObserveNo.delete(e):this._proxyToObserveNo.set(e,r))}}const t=e[d];t?.[u]&&this.resolveParent(t)}}const V={reactive:new WeakMap,shallowReactive:new WeakMap,refCache:new Map,refMap:new WeakMap,computedMap:new WeakMap},I=new WeakMap;function K(e){return _(e)}function B(e){return!!o(t=e,"object")&&!!t[p];var t}function J(e,t={}){return w(e,["Object","Array"],()=>{let r;const{shallow:s=!1}=t;return s?V.shallowReactive.has(e)?r=V.shallowReactive.get(e):(r=$.getDefault().createShallowProxy(e),V.shallowReactive.set(e,r)):V.reactive.has(e)?r=V.reactive.get(e):(r=$.getDefault().createProxy(e),V.reactive.set(e,r)),r},"创建响应式对象:参数必须是对象或数组类型")}function z(e,t,r={}){const{shallow:s=!1}=r;if(t&&V.refCache.has(t))return V.refCache.get(t);if(o(e,["array","object"])){const t=e;if(V.refMap.has(t))return V.refMap.get(t)}const i={value:e,[p]:!0},n=s?$.getDefault().createShallowProxy(i):$.getDefault().createProxy(i);return t?V.refCache.set(t,n):o(e,["array","object"])&&V.refMap.set(e,n),n}function F(e,t){return w(e,["Object","Function"],()=>{let r=null;return V.computedMap.has(e)?r=V.computedMap.get(e):(r=$.getDefault().createComputed(e,t),V.computedMap.set(e,r)),r},"创建计算属性:参数必须是函数或包含 getter/setter 的对象")}function L(e,t,r,s={}){return $.getDefault().bind(e,t,r,s)}function U(e,t,r){const s={};"number"==typeof t?isNaN(t)||(s.field=t):"function"==typeof t?(r=t,t=void 0):t&&("object"==typeof t?Object.assign(s,t):"string"==typeof t&&(s.field=t));let o=e;if("string"==typeof s.field){let t=s.field;if(t&&t.includes(".")){let r=I.get(e);r||(r=new Map,I.set(e,r));const i=t,n=r.get(i);if(n)o=n.target,t=n.field;else{const s=t.split("."),n=s.pop(),c=h(e,s);r.set(i,{target:c,field:n}),o=c,t=n}s.field=t}}const i=$.getDefault().observe({$proxy:o,...s});if(m(i,"Observe")){if(s.immediate){let e;e=!s.field||"string"!=typeof s.field&&"number"!=typeof s.field?o:o[s.field],r(e,void 0)}return i.observe((e,t)=>{r(e,t)}),()=>{i.destroy()}}return()=>{}}const G=(e,t)=>w(e,"function",()=>$.getDefault().watchEffect(e,t),"创建副作用观察器:参数必须是函数");function H(e){if(V.reactive.has(e)&&V.reactive.delete(e),V.shallowReactive.has(e)&&V.shallowReactive.delete(e),V.refMap.has(e)){const t=V.refMap.get(e);if(t)for(const[e,r]of V.refCache.entries())r===t&&V.refCache.delete(e);V.refMap.delete(e)}}function q(e){V.refCache.delete(e)}new Map,new Set(["@keyframes","@-webkit-keyframes","@-moz-keyframes","@-o-keyframes","@font-face","@import","@charset","@namespace","@layer","@media","@supports","@page","@counter-style","@font-feature-values","@property","@color-profile"]),new WeakMap;const Q=new Map,X=[];function Y(){X.forEach(e=>{const t=Q.get(e);t&&"function"==typeof t.dispose?t.dispose():t&&"function"==typeof t.destroy&&t.destroy()}),Q.clear(),X.length=0}function Z(){return Q.size}function ee(e,t,r){return new e((({...e})=>{const{default:t,...r}=e;return Object.assign(r,t||{})})(t),r).jiess}const te=ee;export{H as $clearReactiveCache,q as $clearRefCache,F as $computed,ee as $entry,K as $isReactive,B as $isRef,J as $reactive,z as $ref,L as $set,U as $watch,G as $watchEffect,Y as clearStaticCache,te as default,Z as getCacheSize,Q as staticJsRenders};