@jiess/core
Version:
基于javascript的配置式渲染库,同时支持vue2,vue3和react
1 lines • 45.2 kB
JavaScript
class e extends Error{code;timestamp;context;constructor(t,s,r){super(t),this.name="JiessError",this.code=s,this.timestamp=Date.now(),this.context=r,Error.captureStackTrace&&Error.captureStackTrace(this,e)}toJSON(){return{name:this.name,message:this.message,code:this.code,timestamp:this.timestamp,context:this.context,stack:this.stack}}}class t extends e{constructor(e,t){super(e,"JIESS_ADAPTER_ERROR",t),this.name="AdapterError"}}class s extends e{constructor(e,t){super(e,"JIESS_COMPONENT_CREATION_ERROR",t),this.name="ComponentCreationError"}}class r extends e{constructor(e,t){super(e,"JIESS_RESOURCE_ERROR",t),this.name="ResourceError"}}class i{_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}}const n=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"]);class o{static classify(e){if(!e||"string"!=typeof e||!e.trim())return{isolated:"",global:""};const t=this.splitRules(e),s=[],r=[];for(const e of t)this.isGlobalRule(e)?r.push(e):s.push(e);return{isolated:s.join("\n"),global:r.join("\n")}}static splitRules(e){const t=[];let s=0,r=0;for(let i=0;i<e.length;i++){const n=e[i];if("{"===n)s++;else if("}"===n&&(s--,0===s)){const s=e.substring(r,i+1).trim();s&&t.push(s),r=i+1}}if(r<e.length){const s=e.substring(r).trim();s&&t.push(s)}return t}static isGlobalRule(e){const t=e.trim();for(const e of n)if(t.startsWith(e))return!0;return!!t.includes(":global")}}class c{static mount(e,t){t.isolated&&this.insertRules(e.isolated,t.isolated),t.global&&this.insertRules(e.global,t.global)}static mountStyleInfo(e,t,s){for(const r of s){if(!r.style||!r.style.trim())continue;const s=o.classify(r.style);s.isolated&&this.insertRules(e,s.isolated),s.global&&this.insertRules(t,s.global)}}static mountStyle(e,t){if(!e||"object"!=typeof e)throw new Error("jiessEnv 必须是有效的环境对象");if(!Array.isArray(t))throw new Error("styleInfo 必须是数组类型");if("undefined"!=typeof window){if(!e.styleNode)return Array.isArray(e.recordStyleInfo)||(e.recordStyleInfo=[]),void e.recordStyleInfo.push(...t);try{const s=e.styleNode.sheet;t.forEach(({style:e})=>{if(e&&"string"==typeof e&&e.trim())try{e.split("}").filter(e=>e.trim()).forEach(e=>{e.trim()&&s.insertRule(e+"}",s.cssRules.length)})}catch(e){console.error("StyleInjector.mountStyle: 插入 CSS 规则失败",e)}})}catch(e){console.error("StyleInjector.mountStyle 执行失败:",e)}}else console.warn("StyleInjector.mountStyle: 非浏览器环境,样式挂载被跳过")}static insertRules(e,t){const s=t.split("}").filter(e=>e.trim());for(const t of s)if(t.trim())try{e.insertRule(t+"}",e.cssRules.length)}catch(e){console.error("StyleInjector.insertRules: 插入规则失败",e)}}}const a="JIESS_CONSTRUCTOR",h="isJiess",l="THIS_IS_JIESS",f="JIESS_INIT_VALUE",u="__JIESS_REF__",p="__JIESS_COMPUTED__",d="JiessForceUpdate",y="__JIESS_PARENT__",g=new Set(["is","component","$exclude"]),_=(e,t)=>Array.isArray(e)?[...e]:J(e,"object")?{...e}:t?void(()=>{throw new Error("shallowCopy Error:须提供对象或数组")})():e;function b(e){return!(!e||"object"!=typeof e||!e[l])}const m=e=>!!J(e,"object")&&Reflect.has(e,"$proxy"),v=e=>{if(m(e)){const{$proxy:t,field:s="value"}=e;return t[s]}return e},w=(e,t)=>{throw new Error(`${e} Error:${t}`)};function x(e,t,s=I,r="数据类型"){return J(e,t)?s():w(r,`须提供 ${t} 类型`)}const j=(e,t,s=a)=>!!J(e,"object")&&Object.is(e[s],t),S=e=>null!==e&&"object"==typeof e&&(!!b(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 R(e={},t="toString"){if("function"==typeof e[t]){if("string"==typeof t){const s=new RegExp(t,"g");return(e[t]+"").replace(s,"")}return e[t]+""}return""}const $=(()=>{const e=R();return(t,s)=>R(t,s)===e})(),O=(e,t,s={})=>(e.has(t)?s=e.get(t):e.set(t,s),s),E=e=>j(e,"JsRender");function k(e,t){E(e)?t(e):Array.isArray(e)&&e.forEach(e=>{E(e)&&t(e)})}function A(e){k(e,e=>{A(e._resData.children),e.destroy()})}const M=!0,C=e=>{const{$proxy:t,field:s,done:r}=e;return r?r(t):s?t[s]:t},P=(e,t)=>Array.isArray(e)?function(e){let t=null;return e.filter(e=>{if(E(e)){const s=e,{_resConfig:r}=s;let{$if:i=M,$elseIf:n}=r;if(i=v(i),n=v(n),V(n,!0)){"boolean"!=typeof t&&w("$elseIf","须配合$if");const e=!t&&!!n;return t=e,e}if(r.hasOwnProperty("$if")){const e=!!i;return t=e,e}return t=null,i}return t=null,!0})}(e).map(P):E(e)?e.getNative(t):V(e)?e:void 0;function N(e,t,s=new WeakMap){if(Object.is(e,t))return!0;const r=typeof e;if(r!==typeof t)return!1;if(!e||!t||"object"!==r)return!1;if(s.has(e)&&s.has(t))return s.get(e)===t&&s.get(t)===e;s.set(e,t),s.set(t,e);const i=Object.prototype.toString.call(e);if(i!==Object.prototype.toString.call(t))return!1;switch(i){case"[object Date]":return e.getTime()===t.getTime();case"[object Promise]":return!1;case"[object Function]":case"[object RegExp]":case"[object Symbol]":return String(e)===String(t);case"[object ArrayBuffer]":case"[object SharedArrayBuffer]":if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==i[t])return!1;return!0;case"[object BigInt]":return e===t;case"[object TypedArray]":return JSON.stringify(Array.from(e))===JSON.stringify(Array.from(t));case"[object Map]":if(e.size!==t.size)return!1;for(const[r,i]of e)if(!t.has(r)||!N(i,t.get(r),s))return!1;return!0;case"[object Set]":if(e.size!==t.size)return!1;const n=[...e],o=[...t];for(let e=0;e<n.length;e++){let t=!1;for(let r=0;r<o.length;r++)if(N(n[e],o[r],s)){t=!0;break}if(!t)return!1}return!0}if(Array.isArray(e)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!N(e[r],t[r],s))return!1;return!0}const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;const c=new Set(o);for(let r of n)if(!c.has(r)||!N(e[r],t[r],s))return!1;return!0}const T=(e,t,s=!0)=>{if(Object.is(e,t))return!0;const r=typeof e;if(r!==typeof t)return!1;if(!e||!t||"object"!==r)return!1;if(s)if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++){const r=e[s],i=t[s];if(!Object.is(r,i)){if(typeof r!=typeof i)return!1;if(!r||!i||"object"!=typeof r)return!1}}}else{if(Array.isArray(t))return!1;{const s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;const i=new Set(r);for(const r of s){if(!i.has(r))return!1;const s=e[r],n=t[r];if(!Object.is(s,n)){if(typeof s!=typeof n)return!1;if(!s||!n||"object"!=typeof s)return!1}}}}let i=e,n=t;if(s){const s=(e,t)=>{if(!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(S(e))return e;const r=Array.isArray(e)?[]:{};t.set(e,r);for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(Array.isArray(r)?r[Number(i)]=s(e[i],t):r[i]=s(e[i],t));return r},r=new WeakMap;i=s(e,r),n=s(t,r)}return N(i,n,new WeakMap)},I=(...e)=>{};function D(e,t,s=!0){if(Array.isArray(t))return t.some(t=>D(e,t));if("string"==typeof t){const e=t.toLowerCase();"exp"!==e&&"regex"!==e||(t="RegExp")}else if(s)throw new Error(`${t} Error:须提供字符串`);const r="string"==typeof t?t.charAt(0).toUpperCase()+t.slice(1):t,i=Object.prototype.toString.call(e)===`[object ${r}]`;if(!i&&"Object"===r&&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 J=D,W=(e,t,s=new WeakMap)=>{if(!e||"object"!=typeof e){if(t){const s=t(e,"filter");return void 0!==s?s:void 0}return e}if(s.has(e))return s.get(e);if(e instanceof Date){const t=new Date(e.getTime());return s.set(e,t),t}if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return s.set(e,t),t}if(S(e)){const s=t?.(e,"filter");return void 0!==s?s:e}let r;if(r=Array.isArray(e)?new Array(e.length):{},s.set(e,r),Array.isArray(e))for(let i=0;i<e.length;i++){const n=W(e[i],t,s);void 0!==n&&(r[i]=n)}else{for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)){const n=W(e[i],t,s);void 0!==n&&(r[i]=n)}Object.getOwnPropertySymbols(e).forEach(i=>{const n=W(e[i],t,s);void 0!==n&&(r[i]=n)})}if(t){const e=t(r,"clone");if(void 0!==e)return e}return r},U=(e,t)=>!(!t||""!==e)||[null,void 0,NaN].some(t=>Object.is(t,e)),V=(e,t)=>!U(e,t);function F(){let e=null;return(t,...s)=>(e||(e=Promise.resolve().then(()=>(e=null,t.call(this,...s)))),e)}const B=(e,t=!1)=>{let s;return function(r,i=100){const n=()=>"function"==typeof e?e():"function"==typeof r?r():void 0;V(s,!0)?clearTimeout(s):t&&n(),s=setTimeout(n,i)}};var K;(((B(),e=>{let t;return function(s,r=100){V(t,!0)&&clearTimeout(t),t=setTimeout(()=>"function"==typeof e?e():"function"==typeof s?s():void 0,r)}})(),e=>{let t=!0;return function(s,r=100){t&&(t=!1,setTimeout(()=>{t=!0,"function"==typeof e?e():"function"==typeof s&&s()},r))}})(),e=>{let t,s=0;return function(r,i=100){const n="function"==typeof e?e:r;let o=Date.now();o-s>=i?(s=o,"function"==typeof n&&n()):V(t,!0)||(t=setTimeout(()=>{s=Date.now(),t=void 0,"function"==typeof n&&n()},i))}})(),"undefined"==typeof window||"undefined"==typeof document||!window.document||window.document.createElement,function(e){e.React="react",e.Vue3="vue3",e.WebComponent="web-component"}(K||(K={}));class z{static uid=1;constructor(e,t={}){this[a]=e,this.J_uid=z.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 L extends z{watcher;fn;flush;effecting="start";value;computer=!1;debounce2;debounce1=B();dirty=!0;get isDirty(){return this.dirty}target;proxy;constructor(e,t,s="pre"){super("Composite"),this.watcher=e,this.fn=t,this.flush=s,this.debounce2=F.call(this)}initComputed(e,t){this.computer=!0,this.target=e,this.proxy=t}_initCounter=0;_initBaseTime=0;init(e,t,s,r){const i=Date.now();if(i-this._initBaseTime>1e3&&(this._initCounter=0,this._initBaseTime=i),!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,s,r),this.watcher.effecter.removeCurrent(),this.dirty=!1),this.value}done(e,t,s,r){return this.computer?"doned"===this.effecting?this.recomputeWithDependency(e,t,s,r):(this.effecting="start",this.value=this.fn(s,t,e,r),this.effecting="computed",this.computer&&(this.proxy.value=this.value),this.effecting="doned"):(this.effecting="start",this.value=this.fn(s,t,e,r),this.effecting="computed",this.effecting="doned"),this.value}recomputeWithDependency(e,t,s,r){this.effecting="start";try{this.value=this.fn(s,t,e,r),this.effecting="computed",this.computer&&(this.proxy.value=this.value)}finally{this.effecting="doned"}}check(e){this.computer?"start"===this.effecting?w("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,r){this.dirty=!0,this.check((i=I)=>{"sync"===this.flush?i(this.init(e,t,s,r)):"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 G=new Set([Symbol.iterator,"constructor","__proto__","prototype",NaN,null,void 0,1/0]),H=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class q extends z{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||!H.has(t))&&(G.has(t)||$(e,t))}getCacheKey(e,t){try{return`${e.constructor.name}-${JSON.stringify(t)}-${e[Symbol.toStringTag]||""}`}catch(s){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 s=this.current,r=t,i=this.collectCache.get(s);if(i){const s=i.get(e);if(s&&s.has(t))return}const n=O(this.mapStore,e);if(n[r]=n[r]||new Set,n[r].add(s),this.mapStore.set(e,n),i){const s=i.get(e)||new Set;s.add(t),i.set(e,s)}const o=this.reverseMap.get(s)||new Set;o.add({target:e,key:r}),this.reverseMap.set(s,o)}trigger(e,t,s,r){if(this.shouldExclude(e,t))return;this.current?.check();const i=O(this.mapStore,e),n=t;if(i.hasOwnProperty(n)){const o=new Set(i[n]),c=new Set;o.forEach(i=>{i===this.current||c.has(i)||(i.trigger(e,t,s,r),c.add(i))})}this.watcher.update(r,t,s)}stop(e){const t=this.reverseMap.get(e);t&&(t.forEach(({target:t,key:s})=>{const r=this.mapStore.get(t);r&&r[s]&&(r[s].delete(e),0===r[s].size&&delete r[s],0===Object.keys(r).length&&this.mapStore.delete(t))}),this.reverseMap.delete(e),this.collectCache.delete(e))}}const Z=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class Q extends z{watcher;_targetToProxy=new WeakMap;_childKeyMap=new WeakMap;constructor(e){super("Observer"),this.watcher=e}create(e,t,s=new WeakSet,r=!1){return S(e)&&"Target"!==e[a]?e:x(e,["array","object"],()=>{if(s.has(e))return this._targetToProxy.get(e)||e;s.add(e);const i=new Proxy(e,this.getProxyHandler(t));if(this._targetToProxy.set(e,i),!r)for(const t in e)if(!g.has(t)&&D(e[t],["array","object"])){const r=this.create(e[t],i,s,!1);this._childKeyMap.set(r,t),e[t]=r}return i},"创建响应式数据")}getProxyHandler(e){return{has:(e,t)=>(this.watcher.effecter.collect(e,t),t in e),get:(t,s,r)=>{if(s===l)return!0;if("__JIESS_TARGET__"===s)return t;if(s===y)return e;if(s===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,s),j(t,!0,p)&&"value"===s)return t.getValue();if(t instanceof Map||t instanceof Set||t instanceof Date||t instanceof RegExp){const e=Reflect.get(t,s);return"function"==typeof e?e.bind(t):e}const i=Reflect.get(t,s,r);if(Array.isArray(t)&&"string"==typeof s&&Z.has(s)){const e=this,i=Array.prototype[s];return function(...n){const o=t.length,c="sort"===s||"reverse"===s||"unshift"===s||"shift"===s,a=c?[...t]:null,h=i.apply(t,n);if("push"===s||"unshift"===s||"splice"===s){const i=[...n];"splice"===s&&i.splice(0,2),i.forEach((o,c)=>{if(D(o,["array","object"])&&!(o instanceof Map)&&!(o instanceof Set)&&!(o instanceof Date)&&!(o instanceof RegExp)){const a=new WeakSet,h=e.create(o,r,a,!1);let l=0;"push"===s?l=t.length-i.length+c:"unshift"===s?l=c:"splice"===s&&(l=n[0]+c),e._childKeyMap.set(h,l),t[l]=h}})}if("splice"===s)for(let s="number"==typeof n[0]?n[0]:0;s<t.length;s++){const r=t[s];r&&"object"==typeof r&&e._childKeyMap.has(r)&&e._childKeyMap.set(r,s)}else if("sort"===s||"reverse"===s||"shift"===s||"unshift"===s)for(let s=0;s<t.length;s++){const r=t[s];r&&"object"==typeof r&&e._childKeyMap.has(r)&&e._childKeyMap.set(r,s)}if(c&&a)for(let e=0;e<Math.max(o,t.length);e++)Object.is(a[e],t[e])||(r[e]=t[e]);else{let e=0,i=Math.max(o,t.length);"push"===s?(e=o,i=t.length):"pop"===s?(e=t.length,i=o):"splice"===s&&(e="number"==typeof n[0]?n[0]:0);for(let s=e;s<i;s++)r[s]=t[s]}return r.length=t.length,e.trigger(t,s,h,r),h}}return i},set:(t,s,r,i)=>{if(s===y)return e=r,!0;if(Object.is(t[s],r))return!0;const n=Reflect.set(t,s,r,i);return this.trigger(t,s,r,i),n},deleteProperty:(e,t)=>{if(t in e){const s=Reflect.deleteProperty(e,t),r=this._targetToProxy.get(e)||e;return this.trigger(e,t,void 0,r),s}return Reflect.deleteProperty(e,t)}}}trigger(e,t,s,r){const{effecter:i}=this.watcher;if(j(e,!0,p))e.setValue(s,t);else if(i.trigger(e,t,s,r),Array.isArray(e)&&"string"==typeof t&&Z.has(t)&&i.trigger(e,"length",e.length,r),r&&r[y]){const e=r[y],t=this._childKeyMap.get(r);void 0!==t&&i.trigger(e,t,r,e)}}}const X=(e,t)=>void 0===e?t:e;class Y extends z{proxy;field;config;value;result;oldValue;isDestory=!1;cbs;debounce1;other;_resourceManager;get disposed(){return this._resourceManager.disposed}constructor(e,t,s={}){super("Observe"),this.proxy=e,this.field=t,this.config=s,this._resourceManager=new i,this.cbs=new Set,this.debounce1=B(),this._resourceManager.add({disposed:!1,dispose:()=>{this.debounce1=null}});const{hasKey:r,defaultValue:n,observe:o,...c}=s;this.other=c,this.observe(o),this.value=_(r?e[t]:e);const a=this.value=X(this.value,n);this.getValue((e,t)=>{this.result=e,t&&this.dispatch(e,{value:a,...c})})}getValue(e){const{value:t,config:s,result:r}=this,{defaultValue:i,done:n}=s;"function"==typeof n?J(n,"AsyncFunction")?(n(t,this).then(t=>e(t,!0)).catch(e=>{console.error("Observe.getValue async done error:",e)}),e(X(r,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 t=this.value,s={value:e,oldValue:t,...this.other};let{isSync:r,hasKey:i,sameState:n=!1,done:o}=this.config;if(i){try{n=T(t,e)}catch(e){console.error(e)}this.value=_(e),this.oldValue=t,n&&"function"!=typeof o||this.getValue(e=>this.dispatch(e,s))}else{const t=()=>{this.value=_(e),this.getValue(e=>this.dispatch(e,s))};r?t():this.debounce1(()=>t(),0)}}dispatch(e,t){t.oldResult=this.result,t.result=this.result=e,this.cbs.forEach(s=>{s(e,t.oldResult,t)})}}class ee extends z{_setter;_composite;value;constructor(){super("Target"),this[l]=!0,this.value=f,this[p]=!0}initSetter(e){this._setter=e}initComposite(e){this._composite=e}getValue(){return(this.value===f||this._composite&&this._composite.isDirty)&&(this.value=this._composite?.init()),this.value}setValue(e,t){"value"!==t?w("Computed","仅允许对value赋值"):"function"==typeof this._setter?(this._setter(e),this.update()):"computed"===this._composite?.effecting||w("Computed","须提供setter")}update(){this._composite&&this._composite.trigger(this,"value",this.value,this)}}class te extends z{static _default;static getDefault(){return te._default&&!te._default.disposed||(te._default=new te),te._default}static _globalResourceManager;_proxyToObserve=new WeakMap;_proxyToObserveNo=new WeakMap;_pathCache=new WeakMap;_dependencyCache=new WeakMap;effecter;observer;_resourceManager;get disposed(){return this._resourceManager?.disposed??te._globalResourceManager?.disposed??!1}constructor(){super("Watcher"),this._resourceManager=new i,this.observer=new Q(this),this.effecter=new q(this)}static getGlobalResourceManager(){return te._globalResourceManager||(te._globalResourceManager=new i),te._globalResourceManager}clearProxyResources(e){this.clearObservers(e),this._proxyToObserve.delete(e),this._proxyToObserveNo.delete(e)}dispose(){this._resourceManager?.disposed||(this._resourceManager?.dispose(),te._globalResourceManager&&!te._globalResourceManager.disposed&&(te._globalResourceManager.dispose(),te._globalResourceManager=void 0),this._proxyToObserve=new WeakMap,this._proxyToObserveNo=new WeakMap,this._pathCache=new WeakMap,this._dependencyCache=new WeakMap,te._default===this&&(te._default=void 0))}static disposeAll(){te.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 s=0;const r=[{obj:e,keys:Object.keys(e),index:0}];for(;r.length>0&&s<1e3;){const e=r[r.length-1];if(!e)break;const{obj:i,keys:n,index:o}=e;if(o>=n.length){t.delete(i),r.pop(),s--;continue}const c=n[o];e&&(e.index=o+1);const a=i[c];if("object"==typeof a&&null!==a){if(t.has(a))return!0;t.add(a),r.push({obj:a,keys:Object.keys(a),index:0}),s++}}return r.forEach(e=>t.delete(e.obj)),!1}createProxy(e){let t=e;return this.hasLoopReference(e)&&(t=W(e)),this.observer?.create(t)}createShallowProxy(e){return this.observer?.create(e,void 0,new WeakSet,!0)}createComputed(e,t){const s=new ee,r=this.createProxy(s);if(J(e,"object")){const{get:t,set:r}=e;"function"==typeof t&&(e=t),"function"==typeof r&&s.initSetter(r)}const i=new L(this,e,t);return s.initComposite(i),i.initComputed(s,r),r}watchEffect(e,t){const s=new L(this,e,t);return s.init(),()=>s.stop()}observe(e={$proxy:{}}){let{$proxy:t,field:s,warn:r=!0,...i}=e,n=t,o=s;if("string"==typeof s&&s.includes(".")){let e=this._pathCache.get(t);e||(e=new Map,this._pathCache.set(t,e));const r=s,i=e.get(r);if(i)n=i.target,o=i.field;else{const i=s.split("."),c=i.pop(),a=function(e,t){if(!e||!t)return;let s;if(s=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),s=s.filter(Boolean),0===s.length)return;let r=e;for(const e of s)try{const t=Number(e);r=!isNaN(t)&&Number.isInteger(t)&&Array.isArray(r)?r[t]:r[e]}catch(e){return}return r}(t,i);e.set(r,{target:a,field:c}),n=a,o=c}}const c=J(n,"object")&&(Reflect.has(n,p)||Reflect.has(n,u))?"value":o,a=i.hasKey=J(c,["number","string"]);if(b(n)){const e=new Y(n,c,i);if(a){const t=O(this._proxyToObserve,n,{}),s=c;t[s]=t[s]||[],t[s].push(e),this._proxyToObserve.set(n,t)}else{const t=O(this._proxyToObserveNo,n,[]);this._proxyToObserveNo.set(n,t),t.push(e)}return e}if(r){if("function"==typeof r){const e=i.done,t=r(n,c);return e?e(t):t}console.warn("$proxy:需要定义为响应式对象")}return C(e)}bind(e,t,s,{cb:r}){if(!J(s,["number","string"])&&null!=s){const i=s,n=this.createProxy(i);return n[y]=e,"function"==typeof r?r(n):t&&(e[t]=n),n}e[t]=s}update(e,t,s){const r=this._proxyToObserve.get(e);if(r&&Object.keys(r).length>0){const i=r[t];if(i&&Array.isArray(i)&&i.length>0){const n=i.filter(e=>!e.isDestory);n.length>0&&(n.forEach(e=>e.resolve(s)),r[t]=n,0===n.length&&(delete r[t],0===Object.keys(r).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 s=t[e];Array.isArray(s)&&s.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 s=t.filter(t=>!t.isDestory&&(t.resolve(e),!0));s.length!==t.length&&(0===s.length?this._proxyToObserveNo.delete(e):this._proxyToObserveNo.set(e,s))}}const t=e[y];t?.[l]&&this.resolveParent(t)}}class se{static removeComments(e){if("string"!=typeof e)return e;const t=[];let s=0;const r=e.length;for(;s<r;)if("/"===e[s]&&"/"===e[s+1])for(;s<r&&"\n"!==e[s];)s++;else if("/"===e[s]&&"*"===e[s+1]){for(s+=2;s<r-1&&("*"!==e[s]||"/"!==e[s+1]);)s++;s+=2}else{const r=e[s];void 0!==r&&t.push(r),s++}return t.join("")}static dedupeStyleString(e){if("string"!=typeof e)throw new Error("styleString 必须是字符串类型");if(""===e.trim())return e;try{const t=new Map,s=/([^{]+)\{([^}]+)\}/g;e.replace(s,(e,s,r)=>{const i=s.trim(),n=r.trim();return t.set(i,n),e});const r=[];for(const[e,s]of t)r.push(`${e}{${s}}`);return r.join("")}catch(e){throw new Error(`去重样式规则时发生错误:${e instanceof Error?e.message:String(e)}`)}}static parseSassLikeSyntax(e){if("string"!=typeof e||""===e.trim())return"";const t=this.removeComments(e),s={variables:new Map},r=(e,t)=>{for(;t<e.length;){const s=e[t];if(!s||!/\s/.test(s))break;t++}return t},i=(e,t=new Set)=>{let r,n=e;do{r=!1,n=n.replace(/\$([a-zA-Z0-9_-]+)/g,(e,n)=>{const o=s.variables.get(n);if(o){if(t.has(n))return console.warn(`变量循环引用检测到:$${n}`),e;const s=new Set(t);s.add(n);const c=i(o,s);return c!==e?(r=!0,c):e}return e})}while(r);return n},n=(e,t="",o=0)=>{if(o>50)return console.warn("Sass 解析递归深度超过限制"),"";const c=[];let a=0;try{for(;a<e.length&&(a=r(e,a),!(a>=e.length));){if("$"===e[a]){let t=a+1;for(;t<e.length;){const s=e[t];if(!s||!/[a-zA-Z0-9_-]/.test(s))break;t++}if(t<e.length&&":"===e.substring(t,t+2).trim()){const r=e.substring(a+1,t).trim();for(t+=2;t<e.length;){const s=e[t];if(!s||!/\s/.test(s))break;t++}const i=[];let n=!1,o="";for(;t<e.length;){const s=e[t];if(!s||";"===s&&!n)break;'"'!==s&&"'"!==s||"\\"===e[t-1]||(n?s===o&&(n=!1):(n=!0,o=s)),i.push(s),t++}s.variables.set(r,i.join("").trim()),a=t+1;continue}}const r=[];for(;a<e.length;){const t=e[a];if(!t||"{"===t)break;r.push(t),a++}if(a>=e.length||"{"!==e[a])break;a++;const o=[];let h=1;for(;a<e.length&&h>0;){const t=e[a];if(!t)break;if("{"===t)h++;else if("}"===t&&(h--,0===h))break;o.push(t),a++}a++;const l=r.join("").split(",").map(e=>e.trim()).filter(Boolean);for(const e of l){let s=e;if(t)if(s=e.replace(/&/g,t),s.startsWith(t)){const e=s[t.length];void 0!==e&&/[\w-]/.test(e)&&(s=`${t} ${s}`)}else s=`${t} ${s}`;const r=[],a=[];let l=0;for(;l<o.length;){for(;l<o.length;){const e=o[l];if(!e||!/\s/.test(e))break;l++}if(l>=o.length)break;let e=l;for(;e<o.length;){const t=o[e];if(!t||"{"===t||";"===t)break;e++}if(e<o.length&&"{"===o[e]){const t=o.slice(l,e).join("").trim();let s=1;const r=[];for(e++;e<o.length&&s>0;){const t=o[e];if(!t)break;if("{"===t)s++;else if("}"===t&&(s--,0===s))break;r.push(t),e++}a.push(`${t}{${r.join("")}} `),l=e+1}else{let e=!1,t="";for(;l<o.length;){const s=o[l];if(!s||";"===s&&!e)break;'"'!==s&&"'"!==s||"\\"===o[l-1]||(e?s===t&&(e=!1):(e=!0,t=s)),r.push(s),l++}l<o.length&&(r.push(";"),l++)}}let f=i(r.join("")),u=i(a.join(""));f=f.trim(),f&&c.push(`${s}{${f}}`),u&&c.push(n(u,s,h+1))}}return c.join("")}catch(e){return console.error("Sass 解析错误:",e),""}};return n(t)}}const re=new Map;let ie=0;class ne{static generateScopeId(){if(re.size>=1e4){const e=Math.floor(1e3);let t=0;for(const s of re.keys()){if(t>=e)break;re.delete(s),t++}}return"jiess-scope"+ ++ie}static escapeCssIdentifier(e){return e.replace(/[^\w-]/g,"-")}static sanitizeCss(e){return"string"!=typeof e?"":e.replace(/javascript\s*:/gi,"").replace(/data\s*:/gi,"").replace(/@import[^;]+;/gi,"").replace(/url\s*\(\s*['"]?\s*(javascript|data|vbscript)\s*:[^)]*\)/gi,"url(about:blank)").trim()}static scopeStyleString(e,t){if("string"!=typeof e)throw new Error("styleString 必须是字符串类型");if(""===e.trim())throw new Error("styleString 必须是非空字符串");if("string"!=typeof t)throw new Error("scopeId 必须是字符串类型");if(""===t.trim())throw new Error("scopeId 必须是非空字符串");const s=`${e}__${t}`;if(re.has(s))return re.get(s);t=t.trim();try{const r=se.parseSassLikeSyntax(e),i=/([^{]+)\{([^}]+)\}/g,n=r.replace(i,(e,s,r)=>{const i=s.trim();if(!i)return i;if(i.includes(t))return i;let[n,...o]=i.split(":global");return n=n.replace(/([.#])([\w-]+)/g,(e,s,r)=>{const i=this.escapeCssIdentifier(r);return`${s}${t}_${i}`}),o&&(n+=o.join(" ")),n=n.replace(/\s+/g," ").trim(),`${n}{${r}}`}),o=se.dedupeStyleString(n);return re.set(s,o),o}catch(e){throw new Error(`处理样式时发生错误:${e instanceof Error?e.message:String(e)}`)}}static clearCache(){re.clear()}static getCacheSize(){return re.size}}let oe=1,ce="jiess",ae="_static_";const he=new Map,le=[];function fe(e){const t=le.indexOf(e);t>-1&&le.splice(t,1),le.push(e)}class ue extends z{ctx;expose={};_childrenHistory={};_childrenCurrent={};isDestory=!1;observeInstance;_resourceManager=new i;get disposed(){return this._resourceManager.disposed}constructor(e,t){super("JsRender"),this.ctx=e;let s=null;const{key:r}=t.data;if(r&&`${r}`.startsWith(ae)){if(s=he.get(r),s)return fe(r),s.ctx=e,s;!function(e,t){he.size>=1e3&&function(){if(le.length>0){const e=le.shift();if(e&&he.has(e)){const t=he.get(e);t&&"function"==typeof t.dispose?t.dispose():t&&"function"==typeof t.destroy&&t.destroy(),he.delete(e)}}}(),he.set(e,t),fe(e)}(r,this)}this.attrs=t,this._buildNode(t)}_buildNode({config:e,data:t}){this[h]=j(t.is,!0,h),this._resData=this._initData(t),this._resConfig=this._initConfig(e);const{$ref:s}=this._resConfig;var r;"function"==typeof s?this.ctx.nextTick(()=>{((e=I,t=0)=>{let s=setTimeout(()=>{null!==s&&clearTimeout(s),e()},t)})(()=>s(this.expose,this))}):J(r=s,"object")&&r[u]&&(s.value=this.expose)}_initData({id:e,class:t,className:s,...r}){const i={id:e,class:t,className:s};if(this.attrs&&"function"==typeof this.attrs.initAttrs&&this.attrs.initAttrs(i),r.$proxy&&r.field){const e={$proxy:r.$proxy,field:r.field,done:r.done};r.update&&(e.update=r.update),this._analyObserve(i,"children",e),delete r.$proxy,delete r.field,delete r.done,delete r.update,delete r.children}for(const e in r){const t=r[e];J(t,["object","array"])?this._analyObserve(i,e,t):i[e]=t}return i}_initConfig(e){const t={};for(const s in e){const r=e[s];J(r,["object","array"])?this._analyObserve(t,s,r):t[s]=r}return t}_analyObserve(e,t,s){this._isJiessComponentField(t)?e[t]=s:m(s)?this._handleProxyObject(e,t,s):"children"===t?this._handleChildrenField(e,t,s):e[t]=s}_isJiessComponentField(e){return"$if"!==e&&"$elseIf"!==e&&this[h]}_handleProxyObject(e,t,s){const{$proxy:r,update:i}=s;i&&this._handleTwoWayBinding(e,s),b(r)?this._handleReactiveProxy(e,t,s):e[t]=C(s)}_handleTwoWayBinding(e,t){let s=null,{$proxy:r,update:i,field:n}=t;if(s="string"==typeof i?i:"vue3"===this.ctx.jiess.$env?"onUpdate:modelValue":"onInput",n&&"string"==typeof n||(n="vue3"===this.ctx.jiess.$env?"modelValue":"value"),"function"==typeof e[s]){const t=e[s];e[s]=e=>{t(e),r[n]=e}}else e[s]=e=>r[n]=e}_handleReactiveProxy(e,t,s){const r=this.ctx._toObserve(s,s=>{this.isDestory||("children"===t?(A(e[t]),this._handleChildrenField(e,t,s)):e[t]=s,this.ctx.forceUpdate())},this),i=this.ctx._slotRender;e[t]="children"===t?i.initNodes(r):r}_handleChildrenField(e,t,s){const r=this.ctx._slotRender;if(Array.isArray(s)){const i=s.flat(3);i.forEach((e,t)=>{m(e)&&e.is||this._analyObserve(i,t,e)}),e[t]=r.initNodes(i)}else e[t]=r.initNodes(s)}_initKey(e,t){return J(e,"object")&&U(e.key)&&(e.key=V(t)?`${ce}_${t}`:"auto_"+oe++),e}_injectKey({J_uid:e}){let{key:t}=this._resData;if(t){if("string"==typeof t){if(t.startsWith(ae))return;const s=t.split("_"),r=s[1]?parseInt(s[1],10):NaN;if(s.length>2&&!isNaN(r)&&r===e)return}}else t=this.J_uid;this._resData.key=`${ce}_${e}_${t}`}getNative(e){const{ctx:t,_resData:s}=this,{is:r,key:i,slot:n,children:o,...c}=s;if(j(r,!0,h)){const{jiessEnv:s}=t.component;return this._vnode=this._vnode||s.createVNode(this._initKey({is:r,key:i,slot:n},e),()=>(this.component=new me(r,s),{NativeComponent:this.component.start(c,o,this),component:this.component})),this._vnode}return t._slotRender.toRender(this,e)}destroy(){this.dispose()}dispose(){this._resourceManager.disposed||this.isDestory||(this.isDestory=!0,this._vnode=void 0,this._resourceManager.dispose(),"function"==typeof this.observeInstance?.dispose?this.observeInstance.dispose():this.observeInstance&&this.observeInstance.destroy(),this[h]&&!this.component||this._resData&&this._resData.children&&A(this._resData.children))}}class pe extends z{ctx;debounce1=B();constructor(e,t){super("Attrs"),this.data={},this.config={},this.ctx=e.ctx,this.init(t)}handleAttrs({id:e,cs:t,cn:s,...r}={}){const{env:i}=this.ctx.component.jiessEnv,n=this.ctx.styleScope;"string"==typeof e&&e.trim()&&(n&&(e=`${n}_${e.trim()}`),r.id=e);let o=[];if(t&&(Array.isArray(t)?o=t.map(e=>e?.trim()).filter(Boolean):"string"==typeof t&&(o=t.split(" ").map(e=>e?.trim()).filter(Boolean))),s){let e=[];Array.isArray(s)?e=s.map(e=>e?.trim()).filter(Boolean):"string"==typeof s&&(e=s.split(" ").map(e=>e?.trim()).filter(Boolean)),n&&(e=e.map(e=>`${n}_${e?.trim()}`)),o=[...o,...e]}const c=[...new Set(o)];return c.length&&(r["vue3"===i?"class":"className"]=c.join(" ")),r}initCssValue(e,t){if(e){if(m(e)&&b(e.$proxy)){const s=te.getDefault().observe(e);s.observe(e=>{J(e,["string","number","array"])&&t&&t(e)}),e=s.result}if(J(e,["string","number","array"]))return e}}debounceUpdate(e,{id:t,cs:s,cn:r}){this.debounce1(()=>{Object.assign(e,this.handleAttrs({id:t,cs:s,cn:r})),this.ctx.forceUpdate()},0)}initAttrs(e){let t=e.className,s=e.class,r=e.id;delete e.className,delete e.class,delete e.id,t=this.initCssValue(t,i=>{t=i,this.debounceUpdate(e,{id:r,cs:s,cn:t})}),s=this.initCssValue(s,i=>{s=i,this.debounceUpdate(e,{id:r,cs:s,cn:t})}),r=this.initCssValue(r,i=>{r=i,this.debounceUpdate(e,{id:r,cs:s,cn:t})}),Object.assign(e,this.handleAttrs({id:r,cs:s,cn:t}))}init(e){const t=this.ctx.component?.jiessEnv?.env||"vue3",{children:s,...r}=function(e,t){const{$mergeAttrs:s,...r}=t||{};return Object.assign(r,s?.[e])}(t,e);var i,n,o;return i=["$if","$ref","$elseIf","$name","$slots","$mergeAttrs"],n=r,o=this.config,i.forEach(e=>{n.hasOwnProperty(e)&&(o[e]=n[e],delete n[e])}),V(s)&&(r.children=s),this.data=r,this}}const de=new WeakMap;class ye extends z{ctx;attrs;constructor(e,t){if(super("Done"),this.ctx=e,this.attrs=t,de.has(t)){const s=de.get(t);return s.ctx=e,s}de.set(t,this)}beginSetup(e){const{ctx:t}=this,s={},{setup:r,props:i,name:n,style:o}=e,{$slots:a}=t.PJR?._resConfig||{},h=n?`【组件-${n}】`:"";let l=this.ctx.inject("jiess_css-scope",1/0);const f={default:()=>{const{default:e,children:s}=t.PJR?._resData||{};return e??s??null}};if(o&&!e.styleInfo){let s=null;s="function"==typeof o?o(this.ctx.jiess):o,x(s,["string","object"],()=>{let r="",i="";if("string"==typeof s?r=s:"object"==typeof s&&(s.scope&&(i=s.scope),r=s.css),"string"==typeof r&&r.trim()){const s=e.styleInfo={styleScope:"",style:""},n="web-component"===this.ctx.component.jiessEnv.env;if(i)if(n)s.style=r,e.styleMode=["share","break"].includes(i)?i:"self";else{const t=ne.generateScopeId();s.styleScope=e.styleScope=t,s.style=ne.scopeStyleString(r,t),e.styleMode=["share","break"].includes(i)?i:"self"}else s.style=r;if(!n){const e=t.jiess.getFrameworkAPI("jiessEnv");c.mountStyle(e,[s])}}},"function"==typeof o?`${h}style返回`:`${h}style参数`)}e.styleScope?(this.ctx.styleScope=e.styleScope,"share"===e.styleMode?this.ctx.provide({"jiess_css-scope":e.styleScope}):"break"===e.styleMode?this.ctx.provide({"jiess_css-scope":null}):e.styleMode):l&&(this.ctx.styleScope=l);for(const e in a)"function"==typeof a[e]?f[e]=(...s)=>a[e].call(t,...s):f[e]=()=>a[e];const p=new pe(this,this.attrs);s.$param={slots:f,data:p.data},s.$props=function(e,t,s=""){if(t){let r="",i={};return s&&(r=`${s} 组件 `),x(t,"function",()=>{let s=t();x(s,"object",()=>{for(let t in s){const n=s[t];let o,c=!1,a=null,h=!1,l=!1;if("string"==typeof n)a=n;else if("object"==typeof n){const e=n;a=e.type,o=e.default,l=!!e.isRef,c=!!e.required,h=!!e.isResponsive}c&&!e.hasOwnProperty(t)&&w(`${r}${t}`,"必须");const f=e=>{if(null!=e)return"string"!=typeof a||J(e,a)||w(`${r}${t}`,`须提供 ${a} 类型`),e},p=e=>e&&"object"==typeof e&&e[u],d=e.hasOwnProperty(t)?e[t]:o;h&&!b(d)&&w(`${r}${t}`,"须提供 Jiess 响应式数据"),p(d)?(f(d.value),i[t]=d):void 0!==d&&l?w(`${r}${t}`,"须提供 JiessRef 响应式数据"):i[t]=f(d)}},`${r}Props 返回`)},`${r}Props 定义`),i}return{...e}}(p.data,i,n),t.expose(s),x(r,["function","asyncFunction"],()=>{r.call(t,s.$props,s.$param)},"setup函数")}buildRender(e=this.attrs){return this.jsRender&&!this.jsRender.isDestory||(this.jsRender=new ue(this.ctx,new pe(this,e))),this.jsRender}}class ge extends z{ctx;children;_resourceManager;get disposed(){return this._resourceManager.disposed}constructor(e,t){super("SlotRender"),this.ctx=e,this.children=t,this._resourceManager=new i}dispose(){this._resourceManager.disposed||this._resourceManager.dispose()}initNodes(e){return U(e)?e:[e].flat(1/0).filter(e=>V(e)).map(e=>"function"==typeof e?e:"object"==typeof e?E(e)?e:new ye(this.ctx,e).buildRender():e+"")}toRender(e,t){const{$env:s}=this.ctx.jiess,r=this.ctx.jiess.getFrameworkAPI("$tag","div"),{is:i=r,children:n,...o}=e._resData;e._initKey(o,t);const c=this.getSlots(n,e);return"JiessFragment"===i?"vue3"===s?c.default?.call(this):c:this.$h(i,o,c)}$h(e,t,s){const{jiessEnv:r}=this.ctx.component;return r.createElement(e,t,s)}getSlots(e,t){const{ctx:s}=this,{env:r}=s.component.jiessEnv,i=e=>{const s=this.initNodes(e);return k(s,e=>e._injectKey(t)),P(s)};let{$slots:n}=t._resConfig||{};if("react"===r){if(V(e)){let t=i(e);return t.length>1?t:t[0]}return null}{n={...n};let t={};for(let e in n){const r=n[e],o=J(r,"function");t[e]=e=>i(o?r.call(s,e):r)}return t.hasOwnProperty("default")||V(e)&&(t.default=()=>i(e)),t}}}function _e(e,t=10,s){let r=null;if(s?.ctx){const{_provideData:i,PJR:n}=s?.ctx;J(i,"object")&&i.hasOwnProperty(e)?r=i[e]:n&&t>0&&(r=_e(e,--t,n))}return r}class be extends z{component;PJR;_funcToObserve=new WeakMap;_provideData={};_slotRender;_nodes=[];_lifts={beforeRender:[],beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[]};_resourceManager;_forceUpdating=!1;_pendingForceUpdate=!1;get disposed(){return this._resourceManager.disposed}static createInitCallback(e){return t=>{if(!e||!e.contextParam)return;const{$page:s,...r}=e.contextParam;return"function"==typeof s&&(r.$page=s.call(t,e)),r}}constructor(e,t,s,r){const{jiess:n}=e.jiessEnv;super("Context",be.createInitCallback(n)),this.PJR=r,this.jiess=n,this.component=e,this._resourceManager=new i,this._slotRender=new ge(this,s||[]),new ye(this,t||{}).beginSetup(e.IS)}dropStaticJsRender(e){he.has(e)&&he.delete(e)}forceUpdate(){const{forceUpdate:e}=this.component?.frame||{};if("function"==typeof e)if(this._forceUpdating||te.getDefault()?.effecter?.current)this._pendingForceUpdate||(this._pendingForceUpdate=!0,requestAnimationFrame(()=>{this._pendingForceUpdate=!1,this.forceUpdate()}));else{this._forceUpdating=!0;try{const t=te.getDefault()?.effecter,s=t?.current;t&&(t.current=void 0);try{e()}finally{t&&(t.current=s)}}finally{this._forceUpdating=!1}}}onBeforeRender(e){this._lifts.beforeRender.push({fn:e,once:!1})}onBeforeMount(e){this._lifts.beforeMount.push({fn:e,once:!1})}onMounted(e,t=!1){this._lifts.mounted.push({fn:e,once:t})}onBeforeUpdate(e,t=!1){this._lifts.beforeUpdate.push({fn:e,once:t})}onUpdated(e,t=!1){this._lifts.updated.push({fn:e,once:t})}onBeforeUnmount(e){this._lifts.beforeUnmount.push({fn:e,once:!1})}nextTick(e){const t=Promise.resolve();return e?t.then(this?e.bind(this):e):t}add(...e){const t=this._nodes.length,s=this._slotRender,r=e=>{e=this._toObserve(e,r),A(this._nodes[t]),this._nodes[t]=s.initNodes(e),this.forceUpdate()};return 0===(e=this._toObserve(e,r)).length||this._nodes.push(s.initNodes(e)),this}_toObserve(e,t,s){const r=e=>{if(m(e)){if(b(e.$proxy)){const r=te.getDefault().observe(e);s&&(s.observeInstance=r);let i=this._funcToObserve.get(t);return i=i?[...i,r]:[r],this._funcToObserve.set(t,i),r.observe((e,s)=>{const i=this._funcToObserve.get(t),n=i.indexOf(r),o=[];i.forEach((e,t)=>{n<t?e.destroy():o.push(e)}),this._funcToObserve.set(t,o),t(e,s,r)}),this._toObserve(r.result,t,s)}return this._toObserve(C(e),t,s)}return e};return Array.isArray(e)?e.flat(1/0).map(r):r(e)}native(...e){return P(this._slotRender.initNodes(e))}provide(e={}){Object.assign(this._provideData,e)}inject(e,t=10){return J(this._provideData,"object")&&this._provideData.hasOwnProperty(e)?this._provideData[e]:t>0&&this.PJR?_e(e,t-1,this.PJR):null}expose(e){this.PJR&&this.PJR.expose&&Object.assign(this.PJR.expose,e)}_buildVNodeTree(){const e=te.getDefault()?.effecter;if(e){const t=e.current;e.current=void 0;try{return this._buildVNodeTreeInner()}finally{e.current=t}}return this._buildVNodeTreeInner()}_buildVNodeTreeInner(){let e=P(this._nodes);for(let t=this._lifts.beforeRender.length-1;t>=0;t--){const s=this._lifts.beforeRender[t];s&&"function"==typeof s.fn&&(e=s.fn(e)||e,s.once&&this._lifts.beforeRender.splice(t,1))}return e}dispose(){this._resourceManager.disposed||(this._resourceManager.dispose(),Object.values(this._lifts).forEach(e=>{e.forEach(e=>{e.fn=void 0})}),this._slotRender&&"function"==typeof this._slotRender.dispose&&this._slotRender.dispose(),this._slotRender=null,this._funcToObserve=new WeakMap,this.component=null,this.PJR=void 0,this._nodes=[])}destroy(){this.dispose()}}class me extends z{IS;jiessEnv;cpn;ctx;frame;frameProps={};constructor(e,t){super("Component"),this.IS=e,this.jiessEnv=t,this[h]=!0}start(e={},t,s){return this.cpn=this.cpn||this.component(e,t,s)}component(e,t,s){return this.jiessEnv.component(this,()=>(this.ctx=new be(this,e,t,s),e=>{this.ctx._lifts[e].forEach(e=>{"function"==typeof e.fn&&(e.fn(),e.once&&delete e.fn)})}))}}const ve={},we=class extends z{contextParam;$env="";$name="default";JiessComponent;_frameworkProps={};_envProps={};constructor(e,t={},s={}){const{$name:r="default",...i}=t,n=ve[r];if(n)return n;super("Jiess"),this.contextParam=s,this.$name=r,this._envProps=e,this._frameworkProps=i,ve[r]=this,this.$env=e.$env}createElement(e,t={},s){const r=this._frameworkProps.createElement;if("function"==typeof r)return r(e,t,s)}getFrameworkAPI(e,t){if(void 0!==this._frameworkProps[e])return this._frameworkProps[e];if(void 0!==this._envProps[e])return this._envProps[e];if(void 0!==t)return t;throw new Error(`[Jiess] getFrameworkAPI: "${e}" 未在 $entry 时传入`)}},xe="vue3";class je{env=xe;nativeCtx=null;nativeApp=null;styleNode;recordStyleInfo=[];jiess;_resourceManager;_disposed=!1;constructor(e,r){let n;try{if(n=new we({jiessEnv:this,$env:xe},e,r),this.jiess=n,this._resourceManager=new i,"undefined"!=typeof window&&window.document){const e=document.createElement("style");document.head.appendChild(e),this.styleNode=e,this._resourceManager.add({disposed:!1,dispose:()=>{this.styleNode&&this.styleNode.parentNode&&(this.styleNode.parentNode.removeChild(this.styleNode),this.styleNode=void 0)}})}this.jiess.JiessComponent=({is:e,setup:t,style:r,children:i,...n})=>{try{const s=this.jiess.getFrameworkAPI("getCurrentInstance");if(this.nativeCtx=s?s():null,this.nativeCtx&&"appContext"in this.nativeCtx&&(this.nativeApp=this.nativeCtx.appContext?.app||null),this.recordStyleInfo.length>0&&this.styleNode&&(c.mountStyle(this,this.recordStyleInfo),this.recordStyleInfo=[]),j(e,!0,h));else{if("function"!=typeof t)throw new Error("须提供(组件 is)或(setup 函数)");e={isJiess:!0,name:"JiessComponent",style:r,setup:t}}const o=new me(e,this);return this.createElement(o.start(n,i))}catch(r){throw console.error("[Jiess-Vue3 适配器]创建组件失败:",r),new s("创建 Vue3 组件失败",{is:e,setup:t,error:r})}}}catch(e){throw new t("初始化 Vue3 适配器失败",{error:e,jiess:n})}}createElement(e,t,s){const{useDirectives:r,...i}=t||{},n=this.jiess.getFrameworkAPI("h");if(!n)return void console.error("[Jiess Vue3 适配器] h 函数未定义");const o=this.jiess.getFrameworkAPI("withDirectives");return"function"==typeof r&&"function"==typeof o?o(n(e,i,s),r()):n(e,i,s)}createVNode({key:e},t){const{NativeComponent:s}=t(this);return this.createElement(s,{key:e})}component(e,t){let s=I;return{inheritAttrs:!0,props:{style:[Function,Object]},data:()=>({[d]:!1}),created(){e.frame=this,e.frameProps=this.$props,s=t()},beforeMount(){s("beforeMount")},mounted(){s("mounted")},beforeUpdate(){s("beforeUpdate")},updated(){s("updated")},beforeUnmount(){s("beforeUnmount")},render(){return this[d],e.ctx._buildVNodeTree()},methods:{forceUpdate(){this[d]=!this[d]}}}}get disposed(){return this._disposed}dispose(){if(!this._disposed){this._disposed=!0;try{this._resourceManager.dispose(),this.styleNode&&this.styleNode.parentNode&&(this.styleNode.parentNode.removeChild(this.styleNode),this.styleNode=void 0),this.recordStyleInfo=[],this.nativeCtx=null,this.nativeApp=null}catch(e){throw console.error("[Jiess Vue3 适配器] 清理资源失败:",e),new r("清理 Vue3 适配器资源失败",{error:e})}}}}const Se=je;export{je as JiessEnv,Se as default};