@jiess/core
Version:
基于javascript的配置式渲染库,同时支持vue2,vue3和react
1 lines • 2.76 kB
JavaScript
const t="JiessForceUpdate";!function(t={},e="toString"){if("function"==typeof t[e]){if("string"==typeof e){const s=new RegExp(e,"g");return(t[e]+"").replace(s,"")}t[e]}}(),new WeakMap;const e=(...t)=>{},s=function(t,e,n=!0){if("exp"===e&&(e="RegExp"),Array.isArray(e))return e.some((e=>s(t,e)));if(n&&!s(e,"string",!1))throw new Error(`${e} Error:须提供字符串`);return e=(r=e).slice(0,1).toUpperCase()+r.slice(1),Object.prototype.toString.call(t)===`[object ${e}]`;var r};var n;((((()=>{let t})(),()=>{let t=0;return function(e,s=100){let n=(new Date).getTime();n-t>s&&e(),t=n}})(),()=>{let t=!0;return function(e,s=100){t&&(t=!1,setTimeout((()=>{t=!0,e()}),s))}})(),()=>{let t=0;return function(e,s=100){let n=(new Date).getTime();n-t>s&&(t=n,e())}})(),function(t){t.React="react",t.Vue2="vue2",t.Vue3="vue3"}(n||(n={}));const r=function(t){if(s(t,"object"))for(const e in t){const n=t[e];if(void 0===n)delete t[e];else if(s(n,"object")){const t=n;(e+"").startsWith("$")||t.THIS_IS_JIESS||r(t)}}};function o(t){let{on:e,key:s,ref:n,slot:o,style:i,props:c,attrs:a,refInFor:u,domProps:l,nativeOn:f,className:p,directives:d,scopedSlots:h,...m}=t,v={key:s,ref:n,slot:o,style:i,props:c,refInFor:u,domProps:l,nativeOn:f,directives:d,scopedSlots:h,class:p};const y=function(t){const e={},s={};for(let n in t)"function"==typeof t[n]&&"string"==typeof n&&n.startsWith("on")&&/[A-Z]/.test(n[2])?e[n.slice(2,3).toLowerCase()+n.slice(3)]=t[n]:s[n]=t[n];return{on:e,attrs:s}}(m);return v.attrs=Object.assign({},a,y.attrs),v.on=Object.assign({},e,y.on),r(v),v}const i="vue2";class c{jiess;env=i;h;deal;constructor(t,s){this.jiess=t,this.h=e,this.deal=o;const n=this;this.env=t.$env=i,t.JiessComponent={inheritAttrs:!1,created(){const{component:t,setup:e,children:r,...o}=this.$attrs,i={is:t,setup:e,jiessEnv:n};this.result=s(i).start(o,r)},render(t){return t(this.result)}}}initRender(t){const{$render:e}=this.jiess;this.h="function"==typeof e?(...s)=>e.call(this,t,...s):t}createElement(t,e,s){return e=o(e),this.h(t,e,s)}createVNode({key:t,slot:e},s){const{NativeComponent:n}=s(this);return this.createElement(n,{key:t,slot:e})}component(n,r){let o=this,i=e;return{data:()=>({[t]:!1,values:{},state:{}}),inheritAttrs:!1,created(){n.frame=this,n.frameProps=this.$props,i=r()},beforeMount(){i("beforeMount")},mounted(){i("mounted")},beforeUpdate(){i("beforeUpdate")},updated(){i("updated")},beforeUnmount(){i("beforeUnmount")},render(e){o.initRender(e),this[t];const{$moTag:r}=o.jiess;let i=n.ctx._buildVNodeTree();if(Array.isArray(i)){if(i=i.flat(1/0),i.length>1)return e(r,i);{const t=i[0];return s(t,"object")?t:e(r,t)}}return i},methods:{forceUpdate(){this[t]=!this[t]},initResponsiveData(t,e=Symbol()){return this.$set(this.state,e,t)}}}}}export{c as default};