UNPKG

@jiess/core

Version:

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

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