@jiess/core
Version:
基于javascript的配置式渲染库,同时支持vue2,vue3和react
1 lines • 48 kB
JavaScript
const e=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 t{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 n=0;n<e.length;n++){const i=e[n];if("{"===i)s++;else if("}"===i&&(s--,0===s)){const s=e.substring(r,n+1).trim();s&&t.push(s),r=n+1}}if(r<e.length){const s=e.substring(r).trim();s&&t.push(s)}return t}static isGlobalRule(t){const s=t.trim();for(const t of e)if(s.startsWith(t))return!0;return!!s.includes(":global")}}class s{static mount(e,t){t.isolated&&this.insertRules(e.isolated,t.isolated),t.global&&this.insertRules(e.global,t.global)}static mountStyleInfo(e,s,r){for(const n of r){if(!n.style||!n.style.trim())continue;const r=t.classify(n.style);r.isolated&&this.insertRules(e,r.isolated),r.global&&this.insertRules(s,r.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)}}}class r{_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="JIESS_CONSTRUCTOR",i="isJiess",o="THIS_IS_JIESS",c="JIESS_INIT_VALUE",a="__JIESS_REF__",l="__JIESS_COMPUTED__",h="__JIESS_PARENT__",f=new Set(["is","component","$exclude"]),u=(e,t)=>Array.isArray(e)?[...e]:N(e,"object")?{...e}:t?void(()=>{throw new Error("shallowCopy Error:须提供对象或数组")})():e;function p(e){return!(!e||"object"!=typeof e||!e[o])}const d=e=>!!N(e,"object")&&Reflect.has(e,"$proxy"),y=e=>{if(d(e)){const{$proxy:t,field:s="value"}=e;return t[s]}return e},g=(e,t)=>{throw new Error(`${e} Error:${t}`)};function _(e,t,s=k,r="数据类型"){return N(e,t)?s():g(r,`须提供 ${t} 类型`)}const m=(e,t,s=n)=>!!N(e,"object")&&Object.is(e[s],t),b=e=>null!==e&&"object"==typeof e&&(!!p(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 v(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 w=(()=>{const e=v();return(t,s)=>v(t,s)===e})(),x=(e,t,s={})=>(e.has(t)?s=e.get(t):e.set(t,s),s),S=e=>m(e,"JsRender");function j(e,t){S(e)?t(e):Array.isArray(e)&&e.forEach(e=>{S(e)&&t(e)})}function R(e){j(e,e=>{R(e._resData.children),e.destroy()})}const $=!0,C=e=>{const{$proxy:t,field:s,done:r}=e;return r?r(t):s?t[s]:t},O=(e,t)=>Array.isArray(e)?function(e){let t=null;return e.filter(e=>{if(S(e)){const s=e,{_resConfig:r}=s;let{$if:n=$,$elseIf:i}=r;if(n=y(n),i=y(i),I(i,!0)){"boolean"!=typeof t&&g("$elseIf","须配合$if");const e=!t&&!!i;return t=e,e}if(r.hasOwnProperty("$if")){const e=!!n;return t=e,e}return t=null,n}return t=null,!0})}(e).map(O):S(e)?e.getNative(t):I(e)?e:void 0;function A(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 n=Object.prototype.toString.call(e);if(n!==Object.prototype.toString.call(t))return!1;switch(n){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),n=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==n[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,n]of e)if(!t.has(r)||!A(n,t.get(r),s))return!1;return!0;case"[object Set]":if(e.size!==t.size)return!1;const i=[...e],o=[...t];for(let e=0;e<i.length;e++){let t=!1;for(let r=0;r<o.length;r++)if(A(i[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(!A(e[r],t[r],s))return!1;return!0}const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;const c=new Set(o);for(let r of i)if(!c.has(r)||!A(e[r],t[r],s))return!1;return!0}const E=(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],n=t[s];if(!Object.is(r,n)){if(typeof r!=typeof n)return!1;if(!r||!n||"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 n=new Set(r);for(const r of s){if(!n.has(r))return!1;const s=e[r],i=t[r];if(!Object.is(s,i)){if(typeof s!=typeof i)return!1;if(!s||!i||"object"!=typeof s)return!1}}}}let n=e,i=t;if(s){const s=(e,t)=>{if(!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(b(e))return e;const r=Array.isArray(e)?[]:{};t.set(e,r);for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Array.isArray(r)?r[Number(n)]=s(e[n],t):r[n]=s(e[n],t));return r},r=new WeakMap;n=s(e,r),i=s(t,r)}return A(n,i,new WeakMap)},k=(...e)=>{};function M(e,t,s=!0){if(Array.isArray(t))return t.some(t=>M(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,n=Object.prototype.toString.call(e)===`[object ${r}]`;if(!n&&"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 n}const N=M,T=(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(b(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 n=0;n<e.length;n++){const i=T(e[n],t,s);void 0!==i&&(r[n]=i)}else{for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const i=T(e[n],t,s);void 0!==i&&(r[n]=i)}Object.getOwnPropertySymbols(e).forEach(n=>{const i=T(e[n],t,s);void 0!==i&&(r[n]=i)})}if(t){const e=t(r,"clone");if(void 0!==e)return e}return r},P=(e,t)=>!(!t||""!==e)||[null,void 0,NaN].some(t=>Object.is(t,e)),I=(e,t)=>!P(e,t);function D(){let e=null;return(t,...s)=>(e||(e=Promise.resolve().then(()=>(e=null,t.call(this,...s)))),e)}const W=(e,t=!1)=>{let s;return function(r,n=100){const i=()=>"function"==typeof e?e():"function"==typeof r?r():void 0;I(s,!0)?clearTimeout(s):t&&i(),s=setTimeout(i,n)}};(((W(),e=>{let t;return function(s,r=100){I(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,n=100){const i="function"==typeof e?e:r;let o=Date.now();o-s>=n?(s=o,"function"==typeof i&&i()):I(t,!0)||(t=setTimeout(()=>{s=Date.now(),t=void 0,"function"==typeof i&&i()},n))}})(),"undefined"==typeof window||"undefined"==typeof document||!window.document||window.document.createElement;class J extends Error{code;timestamp;context;constructor(e,t,s){super(e),this.name="JiessError",this.code=t,this.timestamp=Date.now(),this.context=s,Error.captureStackTrace&&Error.captureStackTrace(this,J)}toJSON(){return{name:this.name,message:this.message,code:this.code,timestamp:this.timestamp,context:this.context,stack:this.stack}}}class U extends J{constructor(e,t){super(e,"JIESS_ADAPTER_ERROR",t),this.name="AdapterError"}}class V extends J{constructor(e,t){super(e,"JIESS_COMPONENT_CREATION_ERROR",t),this.name="ComponentCreationError"}}class F{static uid=1;constructor(e,t={}){this[n]=e,this.J_uid=F.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 B extends F{watcher;fn;flush;effecting="start";value;computer=!1;debounce2;debounce1=W();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=D.call(this)}initComputed(e,t){this.computer=!0,this.target=e,this.proxy=t}_initCounter=0;_initBaseTime=0;init(e,t,s,r){const n=Date.now();if(n-this._initBaseTime>1e3&&(this._initCounter=0,this._initBaseTime=n),!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?g("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((n=k)=>{"sync"===this.flush?n(this.init(e,t,s,r)):"pre"===this.flush?this.debounce2(()=>n(this.init())):this.debounce1(()=>n(this.init()),0)})}stop(){"function"==typeof this.value&&this.value(),this.watcher.effecter.stop(this)}}const K=new Set([Symbol.iterator,"constructor","__proto__","prototype",NaN,null,void 0,1/0]),z=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class L extends F{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||!z.has(t))&&(K.has(t)||w(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,n=this.collectCache.get(s);if(n){const s=n.get(e);if(s&&s.has(t))return}const i=x(this.mapStore,e);if(i[r]=i[r]||new Set,i[r].add(s),this.mapStore.set(e,i),n){const s=n.get(e)||new Set;s.add(t),n.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 n=x(this.mapStore,e),i=t;if(n.hasOwnProperty(i)){const o=new Set(n[i]),c=new Set;o.forEach(n=>{n===this.current||c.has(n)||(n.trigger(e,t,s,r),c.add(n))})}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 H=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class G extends F{watcher;_targetToProxy=new WeakMap;_childKeyMap=new WeakMap;constructor(e){super("Observer"),this.watcher=e}create(e,t,s=new WeakSet,r=!1){return b(e)&&"Target"!==e[n]?e:_(e,["array","object"],()=>{if(s.has(e))return this._targetToProxy.get(e)||e;s.add(e);const n=new Proxy(e,this.getProxyHandler(t));if(this._targetToProxy.set(e,n),!r)for(const t in e)if(!f.has(t)&&M(e[t],["array","object"])){const r=this.create(e[t],n,s,!1);this._childKeyMap.set(r,t),e[t]=r}return n},"创建响应式数据")}getProxyHandler(e){return{has:(e,t)=>(this.watcher.effecter.collect(e,t),t in e),get:(t,s,r)=>{if(s===o)return!0;if("__JIESS_TARGET__"===s)return t;if(s===h)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),m(t,!0,l)&&"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 n=Reflect.get(t,s,r);if(Array.isArray(t)&&"string"==typeof s&&H.has(s)){const e=this,n=Array.prototype[s];return function(...i){const o=t.length,c="sort"===s||"reverse"===s||"unshift"===s||"shift"===s,a=c?[...t]:null,l=n.apply(t,i);if("push"===s||"unshift"===s||"splice"===s){const n=[...i];"splice"===s&&n.splice(0,2),n.forEach((o,c)=>{if(M(o,["array","object"])&&!(o instanceof Map)&&!(o instanceof Set)&&!(o instanceof Date)&&!(o instanceof RegExp)){const a=new WeakSet,l=e.create(o,r,a,!1);let h=0;"push"===s?h=t.length-n.length+c:"unshift"===s?h=c:"splice"===s&&(h=i[0]+c),e._childKeyMap.set(l,h),t[h]=l}})}if("splice"===s)for(let s="number"==typeof i[0]?i[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,n=Math.max(o,t.length);"push"===s?(e=o,n=t.length):"pop"===s?(e=t.length,n=o):"splice"===s&&(e="number"==typeof i[0]?i[0]:0);for(let s=e;s<n;s++)r[s]=t[s]}return r.length=t.length,e.trigger(t,s,l,r),l}}return n},set:(t,s,r,n)=>{if(s===h)return e=r,!0;if(Object.is(t[s],r))return!0;const i=Reflect.set(t,s,r,n);return this.trigger(t,s,r,n),i},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:n}=this.watcher;if(m(e,!0,l))e.setValue(s,t);else if(n.trigger(e,t,s,r),Array.isArray(e)&&"string"==typeof t&&H.has(t)&&n.trigger(e,"length",e.length,r),r&&r[h]){const e=r[h],t=this._childKeyMap.get(r);void 0!==t&&n.trigger(e,t,r,e)}}}const q=(e,t)=>void 0===e?t:e;class Z extends F{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 r,this.cbs=new Set,this.debounce1=W(),this._resourceManager.add({disposed:!1,dispose:()=>{this.debounce1=null}});const{hasKey:n,defaultValue:i,observe:o,...c}=s;this.other=c,this.observe(o),this.value=u(n?e[t]:e);const a=this.value=q(this.value,i);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:n,done:i}=s;"function"==typeof i?N(i,"AsyncFunction")?(i(t,this).then(t=>e(t,!0)).catch(e=>{console.error("Observe.getValue async done error:",e)}),e(q(r,n))):e(i(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:n,sameState:i=!1,done:o}=this.config;if(n){try{i=E(t,e)}catch(e){console.error(e)}this.value=u(e),this.oldValue=t,i&&"function"!=typeof o||this.getValue(e=>this.dispatch(e,s))}else{const t=()=>{this.value=u(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 Q extends F{_setter;_composite;value;constructor(){super("Target"),this[o]=!0,this.value=c,this[l]=!0}initSetter(e){this._setter=e}initComposite(e){this._composite=e}getValue(){return(this.value===c||this._composite&&this._composite.isDirty)&&(this.value=this._composite?.init()),this.value}setValue(e,t){"value"!==t?g("Computed","仅允许对value赋值"):"function"==typeof this._setter?(this._setter(e),this.update()):"computed"===this._composite?.effecting||g("Computed","须提供setter")}update(){this._composite&&this._composite.trigger(this,"value",this.value,this)}}class X extends F{static _default;static getDefault(){return X._default&&!X._default.disposed||(X._default=new X),X._default}static _globalResourceManager;_proxyToObserve=new WeakMap;_proxyToObserveNo=new WeakMap;_pathCache=new WeakMap;_dependencyCache=new WeakMap;effecter;observer;_resourceManager;get disposed(){return this._resourceManager?.disposed??X._globalResourceManager?.disposed??!1}constructor(){super("Watcher"),this._resourceManager=new r,this.observer=new G(this),this.effecter=new L(this)}static getGlobalResourceManager(){return X._globalResourceManager||(X._globalResourceManager=new r),X._globalResourceManager}clearProxyResources(e){this.clearObservers(e),this._proxyToObserve.delete(e),this._proxyToObserveNo.delete(e)}dispose(){this._resourceManager?.disposed||(this._resourceManager?.dispose(),X._globalResourceManager&&!X._globalResourceManager.disposed&&(X._globalResourceManager.dispose(),X._globalResourceManager=void 0),this._proxyToObserve=new WeakMap,this._proxyToObserveNo=new WeakMap,this._pathCache=new WeakMap,this._dependencyCache=new WeakMap,X._default===this&&(X._default=void 0))}static disposeAll(){X.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:n,keys:i,index:o}=e;if(o>=i.length){t.delete(n),r.pop(),s--;continue}const c=i[o];e&&(e.index=o+1);const a=n[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=T(e)),this.observer?.create(t)}createShallowProxy(e){return this.observer?.create(e,void 0,new WeakSet,!0)}createComputed(e,t){const s=new Q,r=this.createProxy(s);if(N(e,"object")){const{get:t,set:r}=e;"function"==typeof t&&(e=t),"function"==typeof r&&s.initSetter(r)}const n=new B(this,e,t);return s.initComposite(n),n.initComputed(s,r),r}watchEffect(e,t){const s=new B(this,e,t);return s.init(),()=>s.stop()}observe(e={$proxy:{}}){let{$proxy:t,field:s,warn:r=!0,...n}=e,i=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,n=e.get(r);if(n)i=n.target,o=n.field;else{const n=s.split("."),c=n.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,n);e.set(r,{target:a,field:c}),i=a,o=c}}const c=N(i,"object")&&(Reflect.has(i,l)||Reflect.has(i,a))?"value":o,h=n.hasKey=N(c,["number","string"]);if(p(i)){const e=new Z(i,c,n);if(h){const t=x(this._proxyToObserve,i,{}),s=c;t[s]=t[s]||[],t[s].push(e),this._proxyToObserve.set(i,t)}else{const t=x(this._proxyToObserveNo,i,[]);this._proxyToObserveNo.set(i,t),t.push(e)}return e}if(r){if("function"==typeof r){const e=n.done,t=r(i,c);return e?e(t):t}console.warn("$proxy:需要定义为响应式对象")}return C(e)}bind(e,t,s,{cb:r}){if(!N(s,["number","string"])&&null!=s){const n=s,i=this.createProxy(n);return i[h]=e,"function"==typeof r?r(i):t&&(e[t]=i),i}e[t]=s}update(e,t,s){const r=this._proxyToObserve.get(e);if(r&&Object.keys(r).length>0){const n=r[t];if(n&&Array.isArray(n)&&n.length>0){const i=n.filter(e=>!e.isDestory);i.length>0&&(i.forEach(e=>e.resolve(s)),r[t]=i,0===i.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[h];t?.[o]&&this.resolveParent(t)}}class Y{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 n=s.trim(),i=r.trim();return t.set(n,i),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},n=(e,t=new Set)=>{let r,i=e;do{r=!1,i=i.replace(/\$([a-zA-Z0-9_-]+)/g,(e,i)=>{const o=s.variables.get(i);if(o){if(t.has(i))return console.warn(`变量循环引用检测到:$${i}`),e;const s=new Set(t);s.add(i);const c=n(o,s);return c!==e?(r=!0,c):e}return e})}while(r);return i},i=(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 n=[];let i=!1,o="";for(;t<e.length;){const s=e[t];if(!s||";"===s&&!i)break;'"'!==s&&"'"!==s||"\\"===e[t-1]||(i?s===o&&(i=!1):(i=!0,o=s)),n.push(s),t++}s.variables.set(r,n.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 l=1;for(;a<e.length&&l>0;){const t=e[a];if(!t)break;if("{"===t)l++;else if("}"===t&&(l--,0===l))break;o.push(t),a++}a++;const h=r.join("").split(",").map(e=>e.trim()).filter(Boolean);for(const e of h){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 h=0;for(;h<o.length;){for(;h<o.length;){const e=o[h];if(!e||!/\s/.test(e))break;h++}if(h>=o.length)break;let e=h;for(;e<o.length;){const t=o[e];if(!t||"{"===t||";"===t)break;e++}if(e<o.length&&"{"===o[e]){const t=o.slice(h,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("")}} `),h=e+1}else{let e=!1,t="";for(;h<o.length;){const s=o[h];if(!s||";"===s&&!e)break;'"'!==s&&"'"!==s||"\\"===o[h-1]||(e?s===t&&(e=!1):(e=!0,t=s)),r.push(s),h++}h<o.length&&(r.push(";"),h++)}}let f=n(r.join("")),u=n(a.join(""));f=f.trim(),f&&c.push(`${s}{${f}}`),u&&c.push(i(u,s,l+1))}}return c.join("")}catch(e){return console.error("Sass 解析错误:",e),""}};return i(t)}}const ee=new Map;let te=0;class se{static generateScopeId(){if(ee.size>=1e4){const e=Math.floor(1e3);let t=0;for(const s of ee.keys()){if(t>=e)break;ee.delete(s),t++}}return"jiess-scope"+ ++te}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(ee.has(s))return ee.get(s);t=t.trim();try{const r=Y.parseSassLikeSyntax(e),n=/([^{]+)\{([^}]+)\}/g,i=r.replace(n,(e,s,r)=>{const n=s.trim();if(!n)return n;if(n.includes(t))return n;let[i,...o]=n.split(":global");return i=i.replace(/([.#])([\w-]+)/g,(e,s,r)=>{const n=this.escapeCssIdentifier(r);return`${s}${t}_${n}`}),o&&(i+=o.join(" ")),i=i.replace(/\s+/g," ").trim(),`${i}{${r}}`}),o=Y.dedupeStyleString(i);return ee.set(s,o),o}catch(e){throw new Error(`处理样式时发生错误:${e instanceof Error?e.message:String(e)}`)}}static clearCache(){ee.clear()}static getCacheSize(){return ee.size}}let re=1,ne="jiess",ie="_static_";const oe=new Map,ce=[];function ae(e){const t=ce.indexOf(e);t>-1&&ce.splice(t,1),ce.push(e)}class le extends F{ctx;expose={};_childrenHistory={};_childrenCurrent={};isDestory=!1;observeInstance;_resourceManager=new r;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(ie)){if(s=oe.get(r),s)return ae(r),s.ctx=e,s;!function(e,t){oe.size>=1e3&&function(){if(ce.length>0){const e=ce.shift();if(e&&oe.has(e)){const t=oe.get(e);t&&"function"==typeof t.dispose?t.dispose():t&&"function"==typeof t.destroy&&t.destroy(),oe.delete(e)}}}(),oe.set(e,t),ae(e)}(r,this)}this.attrs=t,this._buildNode(t)}_buildNode({config:e,data:t}){this[i]=m(t.is,!0,i),this._resData=this._initData(t),this._resConfig=this._initConfig(e);const{$ref:s}=this._resConfig;var r;"function"==typeof s?this.ctx.nextTick(()=>{((e=k,t=0)=>{let s=setTimeout(()=>{null!==s&&clearTimeout(s),e()},t)})(()=>s(this.expose,this))}):N(r=s,"object")&&r[a]&&(s.value=this.expose)}_initData({id:e,class:t,className:s,...r}){const n={id:e,class:t,className:s};if(this.attrs&&"function"==typeof this.attrs.initAttrs&&this.attrs.initAttrs(n),r.$proxy&&r.field){const e={$proxy:r.$proxy,field:r.field,done:r.done};r.update&&(e.update=r.update),this._analyObserve(n,"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];N(t,["object","array"])?this._analyObserve(n,e,t):n[e]=t}return n}_initConfig(e){const t={};for(const s in e){const r=e[s];N(r,["object","array"])?this._analyObserve(t,s,r):t[s]=r}return t}_analyObserve(e,t,s){this._isJiessComponentField(t)?e[t]=s:d(s)?this._handleProxyObject(e,t,s):"children"===t?this._handleChildrenField(e,t,s):e[t]=s}_isJiessComponentField(e){return"$if"!==e&&"$elseIf"!==e&&this[i]}_handleProxyObject(e,t,s){const{$proxy:r,update:n}=s;n&&this._handleTwoWayBinding(e,s),p(r)?this._handleReactiveProxy(e,t,s):e[t]=C(s)}_handleTwoWayBinding(e,t){let s=null,{$proxy:r,update:n,field:i}=t;if(s="string"==typeof n?n:"vue3"===this.ctx.jiess.$env?"onUpdate:modelValue":"onInput",i&&"string"==typeof i||(i="vue3"===this.ctx.jiess.$env?"modelValue":"value"),"function"==typeof e[s]){const t=e[s];e[s]=e=>{t(e),r[i]=e}}else e[s]=e=>r[i]=e}_handleReactiveProxy(e,t,s){const r=this.ctx._toObserve(s,s=>{this.isDestory||("children"===t?(R(e[t]),this._handleChildrenField(e,t,s)):e[t]=s,this.ctx.forceUpdate())},this),n=this.ctx._slotRender;e[t]="children"===t?n.initNodes(r):r}_handleChildrenField(e,t,s){const r=this.ctx._slotRender;if(Array.isArray(s)){const n=s.flat(3);n.forEach((e,t)=>{d(e)&&e.is||this._analyObserve(n,t,e)}),e[t]=r.initNodes(n)}else e[t]=r.initNodes(s)}_initKey(e,t){return N(e,"object")&&P(e.key)&&(e.key=I(t)?`${ne}_${t}`:"auto_"+re++),e}_injectKey({J_uid:e}){let{key:t}=this._resData;if(t){if("string"==typeof t){if(t.startsWith(ie))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=`${ne}_${e}_${t}`}getNative(e){const{ctx:t,_resData:s}=this,{is:r,key:n,slot:o,children:c,...a}=s;if(m(r,!0,i)){const{jiessEnv:s}=t.component;return this._vnode=this._vnode||s.createVNode(this._initKey({is:r,key:n,slot:o},e),()=>(this.component=new ge(r,s),{NativeComponent:this.component.start(a,c,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[i]&&!this.component||this._resData&&this._resData.children&&R(this._resData.children))}}class he extends F{ctx;debounce1=W();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:n}=this.ctx.component.jiessEnv,i=this.ctx.styleScope;"string"==typeof e&&e.trim()&&(i&&(e=`${i}_${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)),i&&(e=e.map(e=>`${i}_${e?.trim()}`)),o=[...o,...e]}const c=[...new Set(o)];return c.length&&(r["vue3"===n?"class":"className"]=c.join(" ")),r}initCssValue(e,t){if(e){if(d(e)&&p(e.$proxy)){const s=X.getDefault().observe(e);s.observe(e=>{N(e,["string","number","array"])&&t&&t(e)}),e=s.result}if(N(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,n=>{t=n,this.debounceUpdate(e,{id:r,cs:s,cn:t})}),s=this.initCssValue(s,n=>{s=n,this.debounceUpdate(e,{id:r,cs:s,cn:t})}),r=this.initCssValue(r,n=>{r=n,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 n,i,o;return n=["$if","$ref","$elseIf","$name","$slots","$mergeAttrs"],i=r,o=this.config,n.forEach(e=>{i.hasOwnProperty(e)&&(o[e]=i[e],delete i[e])}),I(s)&&(r.children=s),this.data=r,this}}const fe=new WeakMap;class ue extends F{ctx;attrs;constructor(e,t){if(super("Done"),this.ctx=e,this.attrs=t,fe.has(t)){const s=fe.get(t);return s.ctx=e,s}fe.set(t,this)}beginSetup(e){const{ctx:t}=this,r={},{setup:n,props:i,name:o,style:c}=e,{$slots:l}=t.PJR?._resConfig||{},h=o?`【组件-${o}】`:"";let f=this.ctx.inject("jiess_css-scope",1/0);const u={default:()=>{const{default:e,children:s}=t.PJR?._resData||{};return e??s??null}};if(c&&!e.styleInfo){let r=null;r="function"==typeof c?c(this.ctx.jiess):c,_(r,["string","object"],()=>{let n="",i="";if("string"==typeof r?n=r:"object"==typeof r&&(r.scope&&(i=r.scope),n=r.css),"string"==typeof n&&n.trim()){const r=e.styleInfo={styleScope:"",style:""},o="web-component"===this.ctx.component.jiessEnv.env;if(i)if(o)r.style=n,e.styleMode=["share","break"].includes(i)?i:"self";else{const t=se.generateScopeId();r.styleScope=e.styleScope=t,r.style=se.scopeStyleString(n,t),e.styleMode=["share","break"].includes(i)?i:"self"}else r.style=n;if(!o){const e=t.jiess.getFrameworkAPI("jiessEnv");s.mountStyle(e,[r])}}},"function"==typeof c?`${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):f&&(this.ctx.styleScope=f);for(const e in l)"function"==typeof l[e]?u[e]=(...s)=>l[e].call(t,...s):u[e]=()=>l[e];const d=new he(this,this.attrs);r.$param={slots:u,data:d.data},r.$props=function(e,t,s=""){if(t){let r="",n={};return s&&(r=`${s} 组件 `),_(t,"function",()=>{let s=t();_(s,"object",()=>{for(let t in s){const i=s[t];let o,c=!1,l=null,h=!1,f=!1;if("string"==typeof i)l=i;else if("object"==typeof i){const e=i;l=e.type,o=e.default,f=!!e.isRef,c=!!e.required,h=!!e.isResponsive}c&&!e.hasOwnProperty(t)&&g(`${r}${t}`,"必须");const u=e=>{if(null!=e)return"string"!=typeof l||N(e,l)||g(`${r}${t}`,`须提供 ${l} 类型`),e},d=e=>e&&"object"==typeof e&&e[a],y=e.hasOwnProperty(t)?e[t]:o;h&&!p(y)&&g(`${r}${t}`,"须提供 Jiess 响应式数据"),d(y)?(u(y.value),n[t]=y):void 0!==y&&f?g(`${r}${t}`,"须提供 JiessRef 响应式数据"):n[t]=u(y)}},`${r}Props 返回`)},`${r}Props 定义`),n}return{...e}}(d.data,i,o),t.expose(r),_(n,["function","asyncFunction"],()=>{n.call(t,r.$props,r.$param)},"setup函数")}buildRender(e=this.attrs){return this.jsRender&&!this.jsRender.isDestory||(this.jsRender=new le(this.ctx,new he(this,e))),this.jsRender}}class pe extends F{ctx;children;_resourceManager;get disposed(){return this._resourceManager.disposed}constructor(e,t){super("SlotRender"),this.ctx=e,this.children=t,this._resourceManager=new r}dispose(){this._resourceManager.disposed||this._resourceManager.dispose()}initNodes(e){return P(e)?e:[e].flat(1/0).filter(e=>I(e)).map(e=>"function"==typeof e?e:"object"==typeof e?S(e)?e:new ue(this.ctx,e).buildRender():e+"")}toRender(e,t){const{$env:s}=this.ctx.jiess,r=this.ctx.jiess.getFrameworkAPI("$tag","div"),{is:n=r,children:i,...o}=e._resData;e._initKey(o,t);const c=this.getSlots(i,e);return"JiessFragment"===n?"vue3"===s?c.default?.call(this):c:this.$h(n,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,n=e=>{const s=this.initNodes(e);return j(s,e=>e._injectKey(t)),O(s)};let{$slots:i}=t._resConfig||{};if("react"===r){if(I(e)){let t=n(e);return t.length>1?t:t[0]}return null}{i={...i};let t={};for(let e in i){const r=i[e],o=N(r,"function");t[e]=e=>n(o?r.call(s,e):r)}return t.hasOwnProperty("default")||I(e)&&(t.default=()=>n(e)),t}}}function de(e,t=10,s){let r=null;if(s?.ctx){const{_provideData:n,PJR:i}=s?.ctx;N(n,"object")&&n.hasOwnProperty(e)?r=n[e]:i&&t>0&&(r=de(e,--t,i))}return r}class ye extends F{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,n){const{jiess:i}=e.jiessEnv;super("Context",ye.createInitCallback(i)),this.PJR=n,this.jiess=i,this.component=e,this._resourceManager=new r,this._slotRender=new pe(this,s||[]),new ue(this,t||{}).beginSetup(e.IS)}dropStaticJsRender(e){oe.has(e)&&oe.delete(e)}forceUpdate(){const{forceUpdate:e}=this.component?.frame||{};if("function"==typeof e)if(this._forceUpdating||X.getDefault()?.effecter?.current)this._pendingForceUpdate||(this._pendingForceUpdate=!0,requestAnimationFrame(()=>{this._pendingForceUpdate=!1,this.forceUpdate()}));else{this._forceUpdating=!0;try{const t=X.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),R(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(d(e)){if(p(e.$proxy)){const r=X.getDefault().observe(e);s&&(s.observeInstance=r);let n=this._funcToObserve.get(t);return n=n?[...n,r]:[r],this._funcToObserve.set(t,n),r.observe((e,s)=>{const n=this._funcToObserve.get(t),i=n.indexOf(r),o=[];n.forEach((e,t)=>{i<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 O(this._slotRender.initNodes(e))}provide(e={}){Object.assign(this._provideData,e)}inject(e,t=10){return N(this._provideData,"object")&&this._provideData.hasOwnProperty(e)?this._provideData[e]:t>0&&this.PJR?de(e,t-1,this.PJR):null}expose(e){this.PJR&&this.PJR.expose&&Object.assign(this.PJR.expose,e)}_buildVNodeTree(){const e=X.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=O(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 ge extends F{IS;jiessEnv;cpn;ctx;frame;frameProps={};constructor(e,t){super("Component"),this.IS=e,this.jiessEnv=t,this[i]=!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 ye(this,e,t,s),e=>{this.ctx._lifts[e].forEach(e=>{"function"==typeof e.fn&&(e.fn(),e.once&&delete e.fn)})}))}}const _e={},me=class extends F{contextParam;$env="";$name="default";JiessComponent;_frameworkProps={};_envProps={};constructor(e,t={},s={}){const{$name:r="default",...n}=t,i=_e[r];if(i)return i;super("Jiess"),this.contextParam=s,this.$name=r,this._envProps=e,this._frameworkProps=n,_e[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 时传入`)}};class be{env="web-component";styleNode;recordStyleInfo=[];jiess;_resourceManager;_disposed=!1;constructor(e,t){let n;try{if(n=new me({jiessEnv:this,$env:"web-component"},e,t),this.jiess=n,this._resourceManager=new r,"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:n,...o})=>{try{if(this.recordStyleInfo.length>0&&this.styleNode&&(s.mountStyle(this,this.recordStyleInfo),this.recordStyleInfo=[]),m(e,!0,i));else{if("function"!=typeof t)throw new Error("须提供(组件 is)或(setup 函数)");e={isJiess:!0,name:"JiessComponent",style:r,setup:t}}const c=new ge(e,this);return this.createElement(c.start(o,n))}catch(s){throw console.error("[Jiess Web Components 适配器]创建组件失败:",s),new V("创建 Web Components 组件失败",{is:e,setup:t,error:s})}}}catch(e){throw new U("初始化 Web Components 适配器失败",{error:e,jiess:n})}}createElement(e,s={},r){if(e&&"object"==typeof e&&e.__jiessComponent){const{that:s,initCycle:r,frame:n}=e,i=s.ctx.jiess.getFrameworkAPI("$tag","div"),o=document.createElement(i);o.className="jiess-component",n._container=o;const c=o.attachShadow({mode:"open"});n._shadowRoot=c;const a=document.createElement("style"),l=document.createElement("style");c.appendChild(a),c.appendChild(l);const h=document.createElement("div");if(c.appendChild(h),n._contentContainer=h,s.IS?.styleInfo?.style){const e=t.classify(s.IS.styleInfo.style);a.textContent=e.isolated,l.textContent=e.global}r("beforeMount");const f=s.ctx._buildVNodeTree(),u=this.resolveSlots(f);return this.appendChildren(h,u),r("mounted"),o}if("string"==typeof e){const t=document.createElement(e),{ref:n,...i}=s||{},o=[];t.__jiessEvents=o;for(const[e,s]of Object.entries(i))if(null!=s&&!1!==s)if(e.startsWith("on")&&"function"==typeof s){const r=e.slice(2).toLowerCase();t.addEventListener(r,s),o.push({eventName:r,handler:s})}else if("style"===e&&"object"==typeof s)Object.assign(t.style,s);else if("className"===e||"class"===e)t.className=String(s);else if("attrs"===e&&"object"==typeof s)for(const[e,r]of Object.entries(s))t.setAttribute(e,String(r));else if("innerHTML"===e)t.innerHTML=String(s);else if("textContent"===e)t.textContent=String(s);else if(e.startsWith("data-")||e.startsWith("aria-")||e.includes("-"))t.setAttribute(e,String(s));else try{t[e]=s}catch{t.setAttribute(e,String(s))}"function"==typeof n&&n(t),i&&null!=i.key&&t.setAttribute("data-key",String(i.key));const c=this.resolveSlots(r);return this.appendChildren(t,c),t}console.warn("[Jiess Web Components 适配器] 不支持的元素类型:",typeof e)}createVNode({key:e},t){const{NativeComponent:s}=t(this);return this.createElement(s,{key:e})}component(e,t){const s=this,r={forceUpdate:()=>{if(r._contentContainer){const t=e.ctx._buildVNodeTree(),n=s.resolveSlots(t);s.reconcileChildren(r._contentContainer,n)}},$nextTick:e=>setTimeout(e,0),$set:k,props:{},_container:null,_shadowRoot:null,_contentContainer:null};e.frame=r;const n=t();return{__jiessComponent:!0,that:e,initCycle:n,frame:r}}resolveSlots(e){if(e&&"object"==typeof e&&!Array.isArray(e)&&!(e instanceof Node)){const t=e;if("function"==typeof t.default)return t.default()}return e}appendChildren(e,t){null!=t&&!1!==t&&!0!==t&&("string"==typeof t||"number"==typeof t?e.appendChild(document.createTextNode(String(t))):t instanceof Node?e.appendChild(t):Array.isArray(t)&&t.forEach(t=>this.appendChildren(e,t)))}syncElementAttributes(e,t){e.className!==t.className&&(e.className=t.className);const s=t.style.cssText;e.style.cssText!==s&&(e.style.cssText=s);const r=t.attributes,n=Array.from(e.attributes).map(e=>e.name);for(const t of n)"data-key"!==t&&(r.getNamedItem(t)||e.removeAttribute(t));for(let t=0;t<r.length;t++){const s=r[t];"data-key"!==s.name&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}const i=e.__jiessEvents||[],o=t.__jiessEvents||[];for(const{eventName:t,handler:s}of i)e.removeEventListener(t,s);for(const{eventName:t,handler:s}of o)e.addEventListener(t,s);e.__jiessEvents=o}reconcileChildren(e,t){const s=e=>null==e||!1===e||!0===e?[]:"string"==typeof e||"number"==typeof e?[e]:e instanceof Node?3===e.nodeType?[e.textContent||""]:[e]:Array.isArray(e)?e.flatMap(s):[],r=s(t),n=Array.from(e.childNodes),i=Math.max(n.length,r.length);for(let t=0;t<i;t++){const s=n[t],i=r[t];if(t>=r.length){s&&e.removeChild(s);continue}if(t>=n.length){"string"==typeof i||"number"==typeof i?e.appendChild(document.createTextNode(String(i))):i instanceof Node&&e.appendChild(i);continue}const o=s&&1===s.nodeType,c=i instanceof Node&&1===i.nodeType;if(o&&c){const t=s,r=i;t.tagName===r.tagName?(this.syncElementAttributes(t,r),this.reconcileChildren(t,Array.from(r.childNodes))):e.replaceChild(r,t)}else o&&!c?"string"==typeof i||"number"==typeof i?e.replaceChild(document.createTextNode(String(i)),s):e.removeChild(s):!o&&c?e.replaceChild(i,s):!s||3!==s.nodeType||"string"!=typeof i&&"number"!=typeof i?e.replaceChild(document.createTextNode(String(i)),s):s.textContent=String(i)}}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=[]}catch(e){console.error("[Jiess Web Components 适配器] 清理资源失败:",e)}}}}const ve=be;export{be as JiessEnv,ve as default};