UNPKG

@jiess/core

Version:

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

1 lines 1.69 kB
!function(e={},t="toString"){if("function"==typeof e[t]){if("string"==typeof t){const n=new RegExp(t,"g");return(e[t]+"").replace(n,"")}e[t]}}(),new WeakMap;const e=(...e)=>{};var t;((((()=>{let e})(),()=>{let e=0;return function(t,n=100){let r=(new Date).getTime();r-e>n&&t(),e=r}})(),()=>{let e=!0;return function(t,n=100){e&&(e=!1,setTimeout((()=>{e=!0,t()}),n))}})(),()=>{let e=0;return function(t,n=100){let r=(new Date).getTime();r-e>n&&(e=r,t())}})(),function(e){e.React="react",e.Vue2="vue2",e.Vue3="vue3"}(t||(t={}));const n="react";class r{jiess;env=n;constructor(e,t){this.jiess=e,this.initRender(),this.env=e.$env=n,e.JiessComponent=e=>{const{is:n,setup:r,children:s,...o}=e,c={is:n,setup:r,jiessEnv:this};return this.createElement(t(c).start(o,s))}}initRender(){const{$render:e}=this.jiess;"function"==typeof e&&(this.jiess.createElement=(...t)=>{try{return e.call(this,...t)}catch(e){console.error("Error in custom createElement:",e)}})}createElement(e,t={},n){const{useRef:r,createElement:s}=this.jiess,{ref:o,...c}=t;return"function"==typeof o&&(c.ref=r(null),o(c.ref)),s(e,c,n)}createVNode({key:e},t){const{NativeComponent:n}=t(this);return this.createElement(n,{key:e})}component(t,n){let r=e;const{useRef:s,useEffect:o,useReducer:c}=this.jiess;return i=>{let u=!0,a=!0;const f=s(!1),[l,m]=c((e=>f.current=!e)),p=s({forceUpdate:m});return t.frame=p.current,t.frameProps=i,(e=>{const t=s(!0);t.current&&(t.current=!1,e())})((()=>{r=n(),r("beforeMount")})),(t.ctx.useCustomHook||e)(i),t.frame&&(t.frame.props=i),o((()=>(u=!1,r("mounted"),()=>{a=!1,r("beforeUnmount")})),[]),o((()=>(u&&r("updated"),()=>a&&r("beforeUpdate")))),t.ctx._buildVNodeTree()}}}export{r as default};