@vtj/renderer 0.18.8 → 0.18.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +5 -5
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
`;return r.evaluate(n)}Object.defineProperty(Rt,"__IS_FUNCTION_FUNC",{value:!0,writable:!1,enumerable:!1,configurable:!1});class Q{constructor(e){this.value=e}}class oe{constructor(e){this.value=e}}class se{constructor(e){this.value=e}}class me{constructor(e,s=null,i){this.name=i,this.parent=s,this.data=e,this.labelStack=[]}}function Me(){}function Zi(t=null,e){return new me(Object.create(null),t,e)}function er(t){return Object.create(t)}const Y={NaN:NaN,Infinity:1/0,undefined:void 0,Object,Array,String,Boolean,Number,Date,RegExp,Error,URIError,TypeError,RangeError,SyntaxError,ReferenceError,Math,parseInt,parseFloat,isNaN,isFinite,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,escape,unescape,eval:Tt,Function:Rt};typeof JSON<"u"&&(Y.JSON=JSON);typeof Promise<"u"&&(Y.Promise=Promise);typeof Set<"u"&&(Y.Set=Set);typeof Map<"u"&&(Y.Map=Map);typeof Symbol<"u"&&(Y.Symbol=Symbol);typeof Proxy<"u"&&(Y.Proxy=Proxy);typeof WeakMap<"u"&&(Y.WeakMap=WeakMap);typeof WeakSet<"u"&&(Y.WeakSet=WeakSet);typeof Reflect<"u"&&(Y.Reflect=Reflect);class D{constructor(e=D.global,s={}){this.sourceList=[],this.collectDeclVars=Object.create(null),this.collectDeclFuncs=Object.create(null),this.isVarDeclMode=!1,this.lastExecNode=null,this.isRunning=!1,this.options={ecmaVersion:s.ecmaVersion||D.ecmaVersion,timeout:s.timeout||0,rootContext:s.rootContext,globalContextInFunction:s.globalContextInFunction===void 0?D.globalContextInFunction:s.globalContextInFunction,_initEnv:s._initEnv},this.context=e||Object.create(null),this.callStack=[],this.initEnvironment(this.context)}initEnvironment(e){let s;if(e instanceof me)s=e;else{let r=null;const n=this.createSuperScope(e);this.options.rootContext&&(r=new me(er(this.options.rootContext),n,Kt)),s=new me(e,r||n,zt)}this.globalScope=s,this.currentScope=this.globalScope,this.globalContext=s.data,this.currentContext=s.data,this.collectDeclVars=Object.create(null),this.collectDeclFuncs=Object.create(null),this.execStartTime=Date.now(),this.execEndTime=this.execStartTime;const i=this.options._initEnv;i&&i.call(this)}getExecStartTime(){return this.execStartTime}getExecutionTime(){return this.execEndTime-this.execStartTime}setExecTimeout(e=0){this.options.timeout=e}getOptions(){return this.options}getGlobalScope(){return this.globalScope}getCurrentScope(){return this.currentScope}getCurrentContext(){return this.currentContext}isInterruptThrow(e){return e instanceof $s||e instanceof J||e instanceof Qi}createSuperScope(e){let s=Object.assign({},Y);return Object.keys(s).forEach(r=>{r in e&&delete s[r]}),new me(s,null,Wt)}setCurrentContext(e){this.currentContext=e}setCurrentScope(e){this.currentScope=e}evaluate(e=""){let s;if(e)return s=Wi(e,{ranges:!0,locations:!0,ecmaVersion:this.options.ecmaVersion||D.ecmaVersion}),this.evaluateNode(s,e)}appendCode(e){return this.evaluate(e)}evaluateNode(e,s=""){this.value=void 0,this.source=s,this.sourceList.push(s),this.isRunning=!0,this.execStartTime=Date.now(),this.execEndTime=this.execStartTime,this.collectDeclVars=Object.create(null),this.collectDeclFuncs=Object.create(null);const i=this.getCurrentScope(),r=this.getCurrentContext(),n=i.labelStack.concat([]),a=this.callStack.concat([]),u=()=>{this.setCurrentScope(i),this.setCurrentContext(r),i.labelStack=n,this.callStack=a};try{const c=this.createClosure(e);this.addDeclarationsToScope(this.collectDeclVars,this.collectDeclFuncs,this.getCurrentScope()),c()}catch(c){throw c}finally{u(),this.execEndTime=Date.now()}return this.isRunning=!1,this.getValue()}createErrorMessage(e,s,i){let r=e[1].replace("%0",String(s));return i!==null&&(r+=this.getNodePosition(i||this.lastExecNode)),r}createError(e,s){return new s(e)}createThrowError(e,s){return this.createError(e,s)}createInternalThrowError(e,s,i){return this.createError(this.createErrorMessage(e,s,i),e[2])}checkTimeout(){if(!this.isRunning)return!1;const e=this.options.timeout||0;return Date.now()-this.execStartTime>e}getNodePosition(e){return e&&e.loc?` [${e.loc.start.line}:${e.loc.start.column}]`:""}createClosure(e){let s;switch(e.type){case"BinaryExpression":s=this.binaryExpressionHandler(e);break;case"LogicalExpression":s=this.logicalExpressionHandler(e);break;case"UnaryExpression":s=this.unaryExpressionHandler(e);break;case"UpdateExpression":s=this.updateExpressionHandler(e);break;case"ObjectExpression":s=this.objectExpressionHandler(e);break;case"ArrayExpression":s=this.arrayExpressionHandler(e);break;case"CallExpression":s=this.callExpressionHandler(e);break;case"NewExpression":s=this.newExpressionHandler(e);break;case"MemberExpression":s=this.memberExpressionHandler(e);break;case"ThisExpression":s=this.thisExpressionHandler(e);break;case"SequenceExpression":s=this.sequenceExpressionHandler(e);break;case"Literal":s=this.literalHandler(e);break;case"Identifier":s=this.identifierHandler(e);break;case"AssignmentExpression":s=this.assignmentExpressionHandler(e);break;case"FunctionDeclaration":s=this.functionDeclarationHandler(e);break;case"VariableDeclaration":s=this.variableDeclarationHandler(e);break;case"BlockStatement":case"Program":s=this.programHandler(e);break;case"ExpressionStatement":s=this.expressionStatementHandler(e);break;case"EmptyStatement":s=this.emptyStatementHandler(e);break;case"ReturnStatement":s=this.returnStatementHandler(e);break;case"FunctionExpression":s=this.functionExpressionHandler(e);break;case"IfStatement":s=this.ifStatementHandler(e);break;case"ConditionalExpression":s=this.conditionalExpressionHandler(e);break;case"ForStatement":s=this.forStatementHandler(e);break;case"WhileStatement":s=this.whileStatementHandler(e);break;case"DoWhileStatement":s=this.doWhileStatementHandler(e);break;case"ForInStatement":s=this.forInStatementHandler(e);break;case"WithStatement":s=this.withStatementHandler(e);break;case"ThrowStatement":s=this.throwStatementHandler(e);break;case"TryStatement":s=this.tryStatementHandler(e);break;case"ContinueStatement":s=this.continueStatementHandler(e);break;case"BreakStatement":s=this.breakStatementHandler(e);break;case"SwitchStatement":s=this.switchStatementHandler(e);break;case"LabeledStatement":s=this.labeledStatementHandler(e);break;case"DebuggerStatement":s=this.debuggerStatementHandler(e);break;default:throw this.createInternalThrowError(V.NodeTypeSyntaxError,e.type,e)}return(...i)=>{const r=this.options.timeout;if(r&&r>0&&this.checkTimeout())throw this.createInternalThrowError(V.ExecutionTimeOutError,r,null);return this.lastExecNode=e,s(...i)}}binaryExpressionHandler(e){const s=this.createClosure(e.left),i=this.createClosure(e.right);return()=>{const r=s(),n=i();switch(e.operator){case"==":return r==n;case"!=":return r!=n;case"===":return r===n;case"!==":return r!==n;case"<":return r<n;case"<=":return r<=n;case">":return r>n;case">=":return r>=n;case"<<":return r<<n;case">>":return r>>n;case">>>":return r>>>n;case"+":return r+n;case"-":return r-n;case"*":return r*n;case"**":return Math.pow(r,n);case"/":return r/n;case"%":return r%n;case"|":return r|n;case"^":return r^n;case"&":return r&n;case"in":return r in n;case"instanceof":return r instanceof n;default:throw this.createInternalThrowError(V.BinaryOperatorSyntaxError,e.operator,e)}}}logicalExpressionHandler(e){const s=this.createClosure(e.left),i=this.createClosure(e.right);return()=>{switch(e.operator){case"||":return s()||i();case"&&":return s()&&i();default:throw this.createInternalThrowError(V.LogicalOperatorSyntaxError,e.operator,e)}}}unaryExpressionHandler(e){switch(e.operator){case"delete":const s=this.createObjectGetter(e.argument),i=this.createNameGetter(e.argument);return()=>{let n=s();const a=i();return delete n[a]};default:let r;if(e.operator==="typeof"&&e.argument.type==="Identifier"){const n=this.createObjectGetter(e.argument),a=this.createNameGetter(e.argument);r=()=>n()[a()]}else r=this.createClosure(e.argument);return()=>{const n=r();switch(e.operator){case"-":return-n;case"+":return+n;case"!":return!n;case"~":return~n;case"void":return;case"typeof":return typeof n;default:throw this.createInternalThrowError(V.UnaryOperatorSyntaxError,e.operator,e)}}}}updateExpressionHandler(e){const s=this.createObjectGetter(e.argument),i=this.createNameGetter(e.argument);return()=>{const r=s(),n=i();switch(this.assertVariable(r,n,e),e.operator){case"++":return e.prefix?++r[n]:r[n]++;case"--":return e.prefix?--r[n]:r[n]--;default:throw this.createInternalThrowError(V.UpdateOperatorSyntaxError,e.operator,e)}}}objectExpressionHandler(e){const s=[];function i(n){return n.type==="Identifier"?n.name:n.type==="Literal"?n.value:this.throwError(V.ObjectStructureSyntaxError,n.type,n)}const r=Object.create(null);return e.properties.forEach(n=>{const a=n.kind,u=i(n.key);(!r[u]||a==="init")&&(r[u]={}),r[u][a]=this.createClosure(n.value),s.push({key:u,property:n})}),()=>{const n={},a=s.length;for(let u=0;u<a;u++){const c=s[u],l=c.key,h=r[l],p=h.init?h.init():void 0,d=h.get?h.get():function(){},m=h.set?h.set():function(g){};if("set"in h||"get"in h)Object.defineProperty(n,l,{configurable:!0,enumerable:!0,get:d,set:m});else{const g=c.property,x=g.kind;g.key.type==="Identifier"&&g.value.type==="FunctionExpression"&&x==="init"&&!g.value.id&&$t(p,g.key.name),n[l]=p}}return n}}arrayExpressionHandler(e){const s=e.elements.map(i=>i&&this.createClosure(i));return()=>{const i=s.length,r=Array(i);for(let n=0;n<i;n++){const a=s[n];a&&(r[n]=a())}return r}}safeObjectGet(e,s,i){return e[s]}createCallFunctionGetter(e){switch(e.type){case"MemberExpression":const s=this.createClosure(e.object),i=this.createMemberKeyGetter(e),r=this.source;return()=>{const a=s(),u=i(),c=this.safeObjectGet(a,u,e);if(!c||!nt(c)){const l=r.slice(e.start,e.end);throw this.createInternalThrowError(V.FunctionUndefinedReferenceError,l,e)}return c.__IS_EVAL_FUNC?l=>c(new ie(this),l,!0):c.__IS_FUNCTION_FUNC?(...l)=>c(new ie(this),...l):c.bind(a)};default:const n=this.createClosure(e);return()=>{let a="";e.type==="Identifier"&&(a=e.name);const u=n();if(!u||!nt(u))throw this.createInternalThrowError(V.FunctionUndefinedReferenceError,a,e);if(e.type==="Identifier"&&u.__IS_EVAL_FUNC&&a==="eval")return l=>{const h=this.getScopeFromName(a,this.getCurrentScope()),p=h.name===Wt||h.name===zt||h.name===Kt;return u(new ie(this),l,!p)};if(u.__IS_EVAL_FUNC)return l=>u(new ie(this),l,!0);if(u.__IS_FUNCTION_FUNC)return(...l)=>u(new ie(this),...l);let c=this.options.globalContextInFunction;if(e.type==="Identifier"){const l=this.getIdentifierScope(e);l.name===qt&&(c=l.data)}return u.bind(c)}}}callExpressionHandler(e){const s=this.createCallFunctionGetter(e.callee),i=e.arguments.map(r=>this.createClosure(r));return()=>s()(...i.map(r=>r()))}functionExpressionHandler(e){const s=this,i=this.source,r=this.collectDeclVars,n=this.collectDeclFuncs;this.collectDeclVars=Object.create(null),this.collectDeclFuncs=Object.create(null);const a=e.id?e.id.name:"",u=e.params.length,c=e.params.map(d=>this.createParamNameGetter(d)),l=this.createClosure(e.body),h=this.collectDeclVars,p=this.collectDeclFuncs;return this.collectDeclVars=r,this.collectDeclFuncs=n,()=>{const d=s.getCurrentScope(),m=function(...g){s.callStack.push(`${a}`);const x=s.getCurrentScope(),v=Zi(d,`FunctionScope(${a})`);s.setCurrentScope(v),s.addDeclarationsToScope(h,p,v),a&&(v.data[a]=m),v.data.arguments=arguments,c.forEach((O,w)=>{v.data[O()]=g[w]});const E=s.getCurrentContext();s.setCurrentContext(this);const T=l();if(s.setCurrentContext(E),s.setCurrentScope(x),s.callStack.pop(),T instanceof Q)return T.value};return $t(m,a),Object.defineProperty(m,"length",{value:u,writable:!1,enumerable:!1,configurable:!0}),Object.defineProperty(m,"toString",{value:()=>i.slice(e.start,e.end),writable:!0,configurable:!0,enumerable:!1}),Object.defineProperty(m,"valueOf",{value:()=>i.slice(e.start,e.end),writable:!0,configurable:!0,enumerable:!1}),m}}newExpressionHandler(e){const s=this.source,i=this.createClosure(e.callee),r=e.arguments.map(n=>this.createClosure(n));return()=>{const n=i();if(!nt(n)||n.__IS_EVAL_FUNC){const a=e.callee,u=s.slice(a.start,a.end);throw this.createInternalThrowError(V.IsNotConstructor,u,e)}return n.__IS_FUNCTION_FUNC?n(new ie(this),...r.map(a=>a())):new n(...r.map(a=>a()))}}memberExpressionHandler(e){const s=this.createClosure(e.object),i=this.createMemberKeyGetter(e);return()=>{const r=s();let n=i();return r[n]}}thisExpressionHandler(e){return()=>this.getCurrentContext()}sequenceExpressionHandler(e){const s=e.expressions.map(i=>this.createClosure(i));return()=>{let i;const r=s.length;for(let n=0;n<r;n++){const a=s[n];i=a()}return i}}literalHandler(e){return()=>e.regex?new RegExp(e.regex.pattern,e.regex.flags):e.value}identifierHandler(e){return()=>{const s=this.getCurrentScope(),i=this.getScopeDataFromName(e.name,s);return this.assertVariable(i,e.name,e),i[e.name]}}getIdentifierScope(e){const s=this.getCurrentScope();return this.getScopeFromName(e.name,s)}assignmentExpressionHandler(e){e.left.type==="Identifier"&&e.right.type==="FunctionExpression"&&!e.right.id&&(e.right.id={type:"Identifier",name:e.left.name});const s=this.createObjectGetter(e.left),i=this.createNameGetter(e.left),r=this.createClosure(e.right);return()=>{const n=s(),a=i(),u=r();switch(e.operator!=="="&&this.assertVariable(n,a,e),e.operator){case"=":return n[a]=u;case"+=":return n[a]+=u;case"-=":return n[a]-=u;case"*=":return n[a]*=u;case"**=":return n[a]=Math.pow(n[a],u);case"/=":return n[a]/=u;case"%=":return n[a]%=u;case"<<=":return n[a]<<=u;case">>=":return n[a]>>=u;case">>>=":return n[a]>>>=u;case"&=":return n[a]&=u;case"^=":return n[a]^=u;case"|=":return n[a]|=u;default:throw this.createInternalThrowError(V.AssignmentExpressionSyntaxError,e.type,e)}}}functionDeclarationHandler(e){if(e.id){const s=this.functionExpressionHandler(e);Object.defineProperty(s,"isFunctionDeclareClosure",{value:!0,writable:!1,configurable:!1,enumerable:!1}),this.funcDeclaration(e.id.name,s)}return()=>N}getVariableName(e){if(e.type==="Identifier")return e.name;throw this.createInternalThrowError(V.VariableTypeSyntaxError,e.type,e)}variableDeclarationHandler(e){let s;const i=[];for(let r=0;r<e.declarations.length;r++){const n=e.declarations[r];this.varDeclaration(this.getVariableName(n.id)),n.init&&i.push({type:"AssignmentExpression",operator:"=",left:n.id,right:n.init})}return i.length&&(s=this.createClosure({type:"BlockStatement",body:i})),()=>{if(s){const r=this.isVarDeclMode;this.isVarDeclMode=!0,s(),this.isVarDeclMode=r}return N}}assertVariable(e,s,i){if(e===this.globalScope.data&&!(s in e))throw this.createInternalThrowError(V.VariableUndefinedReferenceError,s,i)}programHandler(e){const s=e.body.map(i=>this.createClosure(i));return()=>{let i=N;for(let r=0;r<s.length;r++){const n=s[r],a=this.setValue(n());if(a!==N&&(i=a,i instanceof Q||i instanceof oe||i instanceof se||i===fe||i===de))break}return i}}expressionStatementHandler(e){return this.createClosure(e.expression)}emptyStatementHandler(e){return()=>N}returnStatementHandler(e){const s=e.argument?this.createClosure(e.argument):Me;return()=>new Q(s())}ifStatementHandler(e){const s=this.createClosure(e.test),i=this.createClosure(e.consequent),r=e.alternate?this.createClosure(e.alternate):()=>N;return()=>s()?i():r()}conditionalExpressionHandler(e){return this.ifStatementHandler(e)}forStatementHandler(e){let s=Me,i=e.test?this.createClosure(e.test):()=>!0,r=Me;const n=this.createClosure(e.body);return e.type==="ForStatement"&&(s=e.init?this.createClosure(e.init):s,r=e.update?this.createClosure(e.update):Me),a=>{let u,c=N,l=e.type==="DoWhileStatement";for(a&&a.type==="LabeledStatement"&&(u=a.label.name),s();l||i();r()){l=!1;const h=this.setValue(n());if(!(h===N||h===de)){if(h===fe)break;if(c=h,c instanceof se&&c.value===u){c=N;continue}if(c instanceof Q||c instanceof oe||c instanceof se)break}}return c}}whileStatementHandler(e){return this.forStatementHandler(e)}doWhileStatementHandler(e){return this.forStatementHandler(e)}forInStatementHandler(e){let s=e.left;const i=this.createClosure(e.right),r=this.createClosure(e.body);return e.left.type==="VariableDeclaration"&&(this.createClosure(e.left)(),s=e.left.declarations[0].id),n=>{let a,u=N,c;n&&n.type==="LabeledStatement"&&(a=n.label.name);const l=i();for(c in l){this.assignmentExpressionHandler({type:"AssignmentExpression",operator:"=",left:s,right:{type:"Literal",value:c}})();const h=this.setValue(r());if(!(h===N||h===de)){if(h===fe)break;if(u=h,u instanceof se&&u.value===a){u=N;continue}if(u instanceof Q||u instanceof oe||u instanceof se)break}}return u}}withStatementHandler(e){const s=this.createClosure(e.object),i=this.createClosure(e.body);return()=>{const r=s(),n=this.getCurrentScope(),a=new me(r,n,qt);this.setCurrentScope(a);const u=this.setValue(i());return this.setCurrentScope(n),u}}throwStatementHandler(e){const s=this.createClosure(e.argument);return()=>{throw this.setValue(void 0),s()}}tryStatementHandler(e){const s=this.createClosure(e.block),i=e.handler?this.catchClauseHandler(e.handler):null,r=e.finalizer?this.createClosure(e.finalizer):null;return()=>{const n=this.getCurrentScope(),a=this.getCurrentContext(),u=n.labelStack.concat([]),c=this.callStack.concat([]);let l=N,h,p;const d=()=>{this.setCurrentScope(n),this.setCurrentContext(a),n.labelStack=u,this.callStack=c};try{l=this.setValue(s()),l instanceof Q&&(h=l)}catch(m){if(d(),this.isInterruptThrow(m))throw m;if(i)try{l=this.setValue(i(m)),l instanceof Q&&(h=l)}catch(g){if(d(),this.isInterruptThrow(g))throw g;p=g}}if(r)try{l=r(),l instanceof Q&&(h=l)}catch(m){if(d(),this.isInterruptThrow(m))throw m;p=m}if(p)throw p;return h||l}}catchClauseHandler(e){const s=this.createParamNameGetter(e.param),i=this.createClosure(e.body);return r=>{let n;const u=this.getCurrentScope().data,c=s(),l=Xi.call(u,c),h=u[c];return u[c]=r,n=i(),l?u[c]=h:delete u[c],n}}continueStatementHandler(e){return()=>e.label?new se(e.label.name):de}breakStatementHandler(e){return()=>e.label?new oe(e.label.name):fe}switchStatementHandler(e){const s=this.createClosure(e.discriminant),i=e.cases.map(r=>this.switchCaseHandler(r));return()=>{const r=s();let n=!1,a,u,c=0,l=!1;for(let h=0;h<2;h++){for(let p=c;p<i.length;p++){const d=i[p](),m=d.testClosure();if(!l&&m===Gt&&(l=!0,c=p),n||m===r){if(n=!0,u=this.setValue(d.bodyClosure()),u===N)continue;if(u===fe||(a=u,a instanceof Q||a instanceof oe||a instanceof se||a===de))break}}if(!n&&l)n=!0;else break}return a}}switchCaseHandler(e){const s=e.test?this.createClosure(e.test):()=>Gt,i=this.createClosure({type:"BlockStatement",body:e.consequent});return()=>({testClosure:s,bodyClosure:i})}labeledStatementHandler(e){const s=e.label.name,i=this.createClosure(e.body);return()=>{let r;const n=this.getCurrentScope();return n.labelStack.push(s),r=i(e),r instanceof oe&&r.value===s&&(r=N),n.labelStack.pop(),r}}debuggerStatementHandler(e){return()=>{debugger;return N}}createParamNameGetter(e){if(e.type==="Identifier")return()=>e.name;throw this.createInternalThrowError(V.ParamTypeSyntaxError,e.type,e)}createObjectKeyGetter(e){let s;return e.type==="Identifier"?s=()=>e.name:s=this.createClosure(e),function(){return s()}}createMemberKeyGetter(e){return e.computed?this.createClosure(e.property):this.createObjectKeyGetter(e.property)}createObjectGetter(e){switch(e.type){case"Identifier":return()=>this.getScopeDataFromName(e.name,this.getCurrentScope());case"MemberExpression":return this.createClosure(e.object);default:throw this.createInternalThrowError(V.AssignmentTypeSyntaxError,e.type,e)}}createNameGetter(e){switch(e.type){case"Identifier":return()=>e.name;case"MemberExpression":return this.createMemberKeyGetter(e);default:throw this.createInternalThrowError(V.AssignmentTypeSyntaxError,e.type,e)}}varDeclaration(e){const s=this.collectDeclVars;s[e]=void 0}funcDeclaration(e,s){const i=this.collectDeclFuncs;i[e]=s}addDeclarationsToScope(e,s,i){const r=i.data;for(let n in s){const a=s[n];r[n]=a&&a()}for(let n in e)n in r||(r[n]=void 0)}getScopeValue(e,s){return this.getScopeFromName(e,s).data[e]}getScopeDataFromName(e,s){return this.getScopeFromName(e,s).data}getScopeFromName(e,s){let i=s;do if(e in i.data)return i;while(i=i.parent);return this.globalScope}setValue(e){const s=this.callStack.length;return this.isVarDeclMode||s||e===N||e===fe||e===de||e instanceof oe||e instanceof se||(this.value=e instanceof Q?e.value:e),e}getValue(){return this.value}}D.version=Yi;D.eval=Tt;D.Function=Rt;D.ecmaVersion=5;D.globalContextInFunction=void 0;D.global=Object.create(null);const tr=(()=>{try{return new Function("return 1")(),!0}catch{return!1}})();function Ue(t){if(typeof globalThis>"u")return;const e=globalThis[0]||globalThis;if(e.__simulator__)try{const s=e.__simulator__.engine.provider.errorHandler;s&&s(t)}catch{}}function sr(t,e){return new D(e,{rootContext:e,globalContextInFunction:e}).evaluate(`(function($scope){ ${t} }).call(this, this)`)}function Se(t,e,s=!1,i=!1,r=!1){try{const n=['"use strict";',"var __self = arguments[0];"];n.push("return ");let a=(t.value||"").trim();r||(a=a.replace(/this(\W|$)/g,(c,l)=>`__self${l}`)),a=n.join(`
|
|
18
18
|
`)+a;const u=r?`
|
|
19
19
|
${a}
|
|
20
|
-
`:`with(${s?"{}":"$scope || {}"}) { ${a} }`;return tr?new Function("$scope",u)(e):sr(u,e)}catch(n){if(f.logger.error("parseExpression.error",n,t,e?.__self??e),Ue(n),i)throw n}}function G(t,e,s=!1,i=!1,r=!1){const n=Se(t,e,s,i,r);if(typeof n!="function"&&(f.logger.error("parseFunction.error","not a function",t,e?.__self??e),i))throw new Error(`"${t.value}" not a function`);return n}function R(t){return t&&t.type==="JSExpression"}function F(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function Gs(t){return R(t)||F(t)}function ir(t){return Gs(t)?t.value.startsWith("{")?`(${t.value})`:t.value:JSON.stringify(t)}const rr={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},Nt=Symbol("access");class Xe{options;data=null;mode=A.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},rr,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:s,router:i,request:r}=e;this.mode=s,i&&this.mode!==A.Design&&this.setGuard(i),r&&this.setRequest(r)}login(e){const{storageKey:s,storagePrefix:i,session:r,authKey:n}=this.options;this.setData(e),this.data&&(f.storage.save(s,e,{type:"local",prefix:i}),r&&f.cookie.set(n,this.data.token))}clear(){const{storageKey:e,storagePrefix:s,session:i,authKey:r}=this.options;this.data=null,f.storage.remove(e,{type:"local",prefix:s}),i&&f.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:s}=this.options,{permissions:i={}}=this.data||{};if(typeof e=="function")return e(i);const r=f.toArray(e);return Array.isArray(i)?r.every(n=>i.includes(n)||i.includes(s+"."+n)):r.every(n=>i[n]||i[s+"."+n])}some(e){const{appName:s}=this.options,{permissions:i={}}=this.data||{},r=f.toArray(e);return Array.isArray(i)?r.some(n=>i.includes(n)||i.includes(s+"."+n)):r.some(n=>i[n]||i[s+"."+n])}install(e){e.config.globalProperties.$access=this,e.provide(Nt,this)}isAuthPath(e){const{auth:s,isAuth:i}=this.options;if(i)return i(e);if(e.path&&typeof s=="string"){const r=s.split("#")[1]||s;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:s}=this.options;if(!e)return;const i=s?`?${s}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(i):location.href=s?`${e}${i}`:e}setData(e){const{privateKey:s}=this.options;if(Array.isArray(e)&&s){const i=e.map(r=>f.unRSA(r,s));try{this.data=JSON.parse(i.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const i=s?f.unRSA(e,s):e;i?this.data=JSON.parse(i):console.warn("RSA解密失败或登录信息缺失")}catch(i){console.warn(i)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:s}=this.options,i=f.storage.get(e,{type:"local",prefix:s});this.setData(i||null)}isLogined(){const{session:e,authKey:s}=this.options;return e&&s?!!f.cookie.get(s):!!this.getToken()}hasRoutePermission(e){if(e.name===ye){const s=e.params.id;return s&&this.can(s)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((s,i,r)=>this.guard(s,r))}async guard(e,s){if(this.isWhiteList(e)||this.isAuthPath(e))return s();if(this.isLogined()){if(this.hasRoutePermission(e))return s();{const{noPermissionMessage:i="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(i),f.isFunction(r)?(r(),s(!1)):f.isString(r)?s(r):s(!1)}}s(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:s}=this.options;return s?Array.isArray(s)?s.some(i=>e.fullPath.startsWith(i)):s(e):!1}isUnauthorized(e){const{unauthorizedCode:s=401,statusKey:i="code"}=this.options;return e.status===s||e.data?.[i]===s}async showUnauthorizedAlert(e){const{unauthorizedMessage:s="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(s)&&this.toLogin()}async showTip(e){const{alert:s}=this.options;return this.isTipShowing?!1:s?(this.isTipShowing=!0,await f.delay(150),await s(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(globalThis.alert?.(e)??console.warn(e),!0)}setRequest(e){e.useRequest(s=>(this.data?.token&&(s.headers[this.options.authKey]=this.data?.token),s)),e.useResponse(async s=>(this.interceptResponse&&await this.showUnauthorizedAlert(s),s),async s=>{if(!this.interceptResponse)return Promise.reject(s);const i=s.response||s||{};return await this.showUnauthorizedAlert(i),Promise.reject(s)})}}function qs(){return L.inject(Nt,null)}function nr(t={}){const{notify:e,loading:s,settings:i={},Startup:r,access:n,useTitle:a,alert:u}=t;let c=null;return{request:f.createRequest({adapter:t.axiosAdapter,settings:{type:"form",validSuccess:!1,originResponse:!0,loading:!0,validate:h=>h.data?.code===0||!!h.data?.success,failMessage:!0,showError:h=>{e&&e(h||"未知错误")},showLoading:()=>{c&&c.close(),s&&(c=s())},hideLoading:()=>{c&&(c.close(),c=null)},...i}}),jsonp:f.jsonp,notify:e,loading:s,useTitle:a,alert:u,startupComponent:r,access:n?new Xe({alert:u,...n}):void 0}}function ar(t={}){return new Xe(t)}function Ws(t,e){const{jsonp:s,request:i}=e;if(t.method==="jsonp")return(r={})=>s(t.url,{...t.jsonpOptions,query:r});{const r=t.headers?Se(t.headers,{},!0):void 0,n={url:t.url,method:t.method,settings:{...t.settings,headers:r}};return(a,u)=>(delete n.data,i.send(f.merge(n,u||{},{data:a})))}}function Ks(t,e){const{metaQuery:s}=e;if(!s)return;const{code:i,queryCode:r}=t;return(n,a)=>{if(!s){console.warn("adapter.metaQuery is not defined!");return}return s(i,r,n,a)}}function zs(t=[],e=[],s){const i={};for(const r of t){const n=Ws(r,s);i[r.id]=n,i[r.name]=n}for(const r of e)i[r.id]=Ks(r,s);return i}async function Js(t=[],e=globalThis){const s=be(e);s&&(Ot(e),t.forEach(i=>Ys(s,i)))}function Qs(t,e=globalThis){const s=F(t.mockTemplate)&&t.mockTemplate.value?G(t.mockTemplate,{},!0):void 0,i=be(e);return async(...r)=>{let n={};if(s)try{n=await s.apply(s,r)}catch(a){f.logger.warn("模拟数据模版异常",a)}return i?.mock(n)}}function Ys(t,e){if(!e.mock)return;const{url:s,mockTemplate:i,method:r="get",settings:n={}}=e;if(s&&i)try{const a=f.isUrl(s)?new URL(s).pathname:s,u=f.pathToRegexp(`(.*)${a}`,[],{end:!1}),c=new RegExp(u.source+"([?#].*)?$",u.flags),l=f.pathToRegexpMatch(a,{decode:decodeURIComponent}),h=Se(i,{},!0);t.mock(c,r.toLowerCase(),p=>{const d=f.url.parse(p.url)||{},m=n.type||"form";let g=p.body instanceof FormData?f.formDataToJson(p.body):p.body;if(typeof g=="string")if(m==="json")try{g=JSON.parse(g)}catch(E){console.warn("[Mock.mock]",E)}else g=f.url.parse(g);const x=f.isUrl(p.url)?new URL(p.url).pathname:p.url.split("?")[0],v=l(x)?.params;Object.assign(p,{data:g,params:v,query:d});try{return t.mock(h(p))}catch(E){return console.warn("[mockApi]",c,p,E),null}})}catch(a){console.warn("mockApi",a)}}function Ot(t=globalThis){const e=be(t);e&&(e._mocked={})}class Xs{__id=null;__mode;__instance=null;__contextRefs={};__refs={};__refCaches={};context={};state={};props={};$props={};$state={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;$uni=null;$getApp=null;__transform={};constructor(e){const{mode:s,dsl:i,attrs:r}=e;this.__mode=s,i&&(this.__id=i.id||null,this.__transform=i.transform||{}),r&&Object.assign(this,r)}setup(e,s=xe){const i=s.getCurrentInstance();if(!i)return;this.__refs={},this.__refCaches={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=i.proxy;const{state:r}=this,n=i.appContext.config.globalProperties;Object.assign(this,n,e||{}),this.$uni=this.$libs.UniH5?.uni??null,this.$getApp=this.$libs.UniH5?.getApp??null,this.$state=this.state=r,this.__proxy(),s.onMounted(()=>{this.__proxy()}),s.onUnmounted(()=>{this.__cleanup()}),s.onBeforeUpdate(()=>{if(this.__proxy(),this.$props)for(const a of Object.keys(this.$props))this[a]=this.$props[a];this.__reset()})}__proxy(){if(!this.__instance)return;const e=this.__instance;ct.forEach(s=>{this[s]=e[s]||e._?.[s.replace("$","")]||null})}__cleanup(){ct.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.__refCaches={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===A.Runtime){const{id:s,type:i}=e,r=s?this.__transform[s]??e.value:e.value;return G({type:i,value:r},this)}else return G(e,this)}__parseExpression(e){if(e)if(this.__mode===A.Runtime){const{id:s,type:i}=e,r=s?this.__transform[s]??e.value:e.value;return Se({type:i,value:r},this)}else return Se(e,this)}__ref(e=null,s){if(this.__mode===A.VNode)return;e&&e!==this.__id&&(this.__contextRefs[e]=this);let i=e?this.__refCaches[e]:null;return i||(i=async r=>{await f.delay(0);let n=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!n){typeof s=="string"&&(delete this.$refs[s],this[s]&&xe.isRef(this[s])&&(this[s].value=null),e&&delete this.__refs[e]);return}return n.nodeType===3&&n.nextSibling&&(n=n.nextSibling),n.__vtj__=e,A.Design===this.__mode&&(n.__context__=this,n.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,r)),typeof s=="function"?s(r):s&&(this.$refs[s]=this.__getRefEl(this.$refs,s,r),this[s]&&xe.isRef(this[s])&&(this[s].value=this.$refs[s])),r},e&&(this.__refCaches[e]=i),i)}__getRefEl(e,s,i){const r=e[s];if(r&&i!==r){const n=new Set([].concat(r,i));return Array.from(n)}else return i}__clone(e={}){const s={...this.context,...e},i={...s,context:s};return i.context.__proto__=this.context,i.__proto__=this,i}}function $e(t){const{Vue:e=xe,UniApp:s={},mode:i=A.Runtime,components:r={},libs:n={},apis:a={},loader:u}=t,c=e.computed(()=>t.dsl),l={$components:r,$libs:n,$apis:a},h=new Xs({mode:i,dsl:c.value,attrs:l}),p=e.defineComponent({name:c.value.name,__scopeId:c.value.id?`data-v-${c.value.id}`:void 0,props:{...ur(c.value.props??[],h)},async setup(d={}){h.$props=h.props=d,c.value.id&&qe(t.window||globalThis,c.value.id,c.value.css||"",!0);const m=c.value.apiMode==="composition";h.$state=h.state=cr(e,c.value.state??{},h);const g=m?dr(e,c.value.refs??{},h):{},x=m?mr(e,c.value.reactives??{},h):{},v=lr(e,c.value.computed??{},h),E=hr(c.value.methods??{},h),T=pr(e,c.value.inject,h),O=Zs(c.value.dataSources||{},h);let w={};m&&(w=gr(c.value.composables??[],h));const W={...d,...g,...x,...T,...v,...E,...O,...w};if(h.setup(W,e),fr(e,c.value.watch??[],h),m){if(await vr(e,c.value.lifeCycles??{},h,s),c.value.setup){const pe=h.__parseFunction(c.value.setup);if(f.isFunction(pe))try{await pe()}catch(we){console.warn("[VTJ] Composition setup 执行失败",we)}}xr(e,c.value.provide??{},h)}return{vtj:h,state:h.state,$state:h.$state,...d,...g,...x,...v,...E}},emits:or(c.value.emits),expose:["vtj",...c.value.expose||[]],render(){const d=c.value;if(d.refs)for(const g of Object.keys(d.refs))this[g];if(d.reactives)for(const g of Object.keys(d.reactives)){const x=this[g];if(x&&typeof x=="object")for(const v of Object.keys(x))x[v]}if(d.state){const g=this.state;for(const x of Object.keys(d.state))g[x]}if(d.computed)for(const g of Object.keys(d.computed))this[g];if(d.inject)for(const g of d.inject)this[g.name];if(!d.nodes)return null;const m=d.nodes||[];if(m.length===1)return le(m[0],h,e,u,m);{const g=m.map(x=>le(x,h,e,u,m)).flat();return e.createVNode("div",{},g)}},...c.value.apiMode!=="composition"?yr(c.value.lifeCycles??{},h):{}});return{renderer:e.markRaw(p),context:h}}function or(t=[]){return t.map(e=>f.isString(e)?e:e.name)}function ur(t=[],e){const s=i=>i?(Array.isArray(i)?i:[i]).map(n=>Yt[n]):void 0;return t.map(i=>f.isString(i)?{name:i}:{name:i.name,type:i.type,required:i.required,default:R(i.default)?e.__parseExpression(i.default):i.default}).reduce((i,r)=>(i[r.name]={type:s(r.type),required:r.required,default:r.default},i),{})}function cr(t,e,s){return t.reactive(Object.keys(e||{}).reduce((i,r)=>{let n=e[r];return R(n)?n=s.__parseExpression(n):F(n)&&(n=s.__parseFunction(n)),i[r]=n,i},{}))}function lr(t,e,s){return Object.entries(e??{}).reduce((i,[r,n])=>(F(n)?i[r]=t.computed(s.__parseFunction(n)):i[r]=t.computed(s.__parseExpression(n)),i),{})}function hr(t,e){return Object.entries(t??{}).reduce((s,[i,r])=>(s[i]=e.__parseFunction(r),s),{})}function pr(t,e=[],s){return e.reduce((i,r)=>{const{name:n,from:a}=r||{},u=R(a)?s.__parseExpression(a)||n:a??n,c=R(r.default)?s.__parseExpression(r.default):r.default??null;return i[n]=t.inject(u,c),i},{})}function Zs(t,e){return Object.keys(t).reduce((s,i)=>{const r=t[i];if(r.type==="mock")s[i]=Qs(r);else if(r.ref){const n=e.$apis[r.ref],a=F(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;s[i]=async(...u)=>{const c=await n.apply(e,u);return a?a(c):c}}return s},{})}function fr(t,e=[],s){e.forEach(i=>{t.watch(s.__parseExpression(i.source),s.__parseFunction(i.handler),{deep:i.deep,immediate:i.immediate,flush:i.flush})})}function dr(t,e,s){return Object.entries(e).reduce((i,[r,n])=>{const a=R(n)?s.__parseExpression(n):n;return i[r]=t.ref(a),i},{})}function mr(t,e,s){return Object.entries(e).reduce((i,[r,n])=>{const a=R(n)?s.__parseExpression(n):n;return i[r]=t.reactive(a??{}),i},{})}function gr(t,e){return t.reduce((s,i)=>{try{let r;if(R(i.composable)?r=e.__parseExpression(i.composable):f.isString(i.composable)&&(r=e.$libs[i.composable]),f.isFunction(r)){const n=(i.args||[]).map(u=>R(u)?e.__parseExpression(u):u),a=r(...n);if(i.destructure&&i.destructure.length>0)for(const u of i.destructure)s[u]=a?.[u];else s[i.name]=a}}catch(r){e.__mode===A.Design&&(console.warn("[VTJ] composable 执行失败,已降级处理",r),s[i.name]={})}return s},{})}function xr(t,e,s){Object.entries(e).forEach(([i,r])=>{let n=r;R(r)?n=s.__parseExpression(r):F(r)&&(n=s.__parseFunction(r)),t.provide(i,n)})}async function vr(t,e,s,i={}){const r={beforeMount:"onBeforeMount",mounted:"onMounted",beforeUpdate:"onBeforeUpdate",updated:"onUpdated",beforeUnmount:"onBeforeUnmount",unmounted:"onUnmounted",errorCaptured:"onErrorCaptured",renderTracked:"onRenderTracked",renderTriggered:"onRenderTriggered",activated:"onActivated",deactivated:"onDeactivated"};for(const[n,a]of Object.entries(e)){if(n==="created"||n==="beforeCreate"){const l=s.__parseFunction(a);if(f.isFunction(l))try{await l()}catch(h){console.warn(`[VTJ] Composition 生命周期 "${n}" 执行失败`,h),Ue(h)}continue}const u=r[n]||n,c=t[u]||i[u];if(c&&f.isFunction(c)){const l=s.__parseFunction(a);f.isFunction(l)&&c(async()=>{try{await f.delay(0),await l()}catch(h){console.warn(`[VTJ] Composition 生命周期 "${n}" 执行失败`,h),Ue(h)}})}else console.warn(`[VTJ] 无效的 Composition 生命周期钩子 "${n}"`)}}function yr(t,e){return Object.entries(t??{}).reduce((s,[i,r])=>{const n=e.__parseFunction(r);return s[i]=async()=>{f.isFunction(n)&&(await f.delay(0),await n())},s},{})}class br{__props={};__events={};__nodes={};constructor(){}setProps(e,s){this.__props[e]=s}getProps(e){return this.__props[e]}loadProps(e,s){const i=e?this.getProps(e):null;return i||(e&&this.setProps(e,s),s)}setEvents(e,s){}getEvents(e){return this.__events[e]}loadEvents(e,s){const i=e?this.getEvents(e):null;return i||(e&&this.setEvents(e,s),s)}setNode(e,s){this.__nodes[e]=s}getNode(e){return this.__nodes[e]}loadNode(e,s){const i=e?this.getNode(e):null;return i||(e&&this.setNode(e,s),s)}isEqual(e,s){return f.isEqual(e,s)}isNodeEqual(e,s){if(e===s)return!0;if(!e||!s)return!1;const i=u=>!u||typeof u!="object"?[]:Object.keys(u).filter(c=>f.isFunction(u[c])),r=u=>{if(!u||typeof u!="object")return u;const c={};for(const l in u)if(Object.prototype.hasOwnProperty.call(u,l)){const h=u[l];f.isFunction(h)||(c[l]=h)}return c},n=i(e).sort(),a=i(s).sort();return f.isEqual(n,a)?f.isEqual(r(e),r(s)):!1}clear(){this.__props={},this.__events={},this.__nodes={}}}const ge=new br,ei=new f.Queue;let at=[],ue={},ke={};const ti=(t,e)=>e;async function Vt(t,e=globalThis){const{urls:s=[],library:i}=t,r=s.filter(u=>Ve(u));if(r.length===0||!i)return null;const n=s.filter(u=>Oe(u));return n.length&&vt(n,e),await yt(r,i,e).catch(u=>(console.warn("loadScriptUrl error",r,i,u),null))}function Ge(t){const{getDsl:e,getDslByUrl:s,options:i}=t;return i.window&&(at.forEach(r=>{delete i.window[r]}),at=[]),(r,n,a,u=xe)=>{if(!a||typeof a=="string")return n;let c="";if(a.type==="Schema"&&a.id)return c=a.id+"_"+r,ke[c]||(ke[c]=u.defineAsyncComponent(async()=>{const l=ue[a.id]||await ei.add(a.id,()=>e(a.id));return l&&(l.name=n,ue[a.id]=l),l?$e({Vue:u,mode:A.Runtime,...i,dsl:f.cloneDeep(l),loader:Ge(t)}).renderer:null}));if(a.type==="UrlSchema"&&a.url)return c=a.url+"_"+r,ke[c]||(ke[c]=u.defineAsyncComponent(async()=>{const l=ue[a.url]||await s(a.url);return l&&(l.name=n,ue[a.url]=l),l?$e({...i,Vue:u,dsl:f.cloneDeep(l),mode:A.Runtime,loader:Ge(t)}).renderer:null}));if(a.type==="Plugin"){let l=a.library?ue[a.library]:null;return l||(a.library&&at.push(a.library),l=ue[a.library||Symbol()]=u.defineAsyncComponent(async()=>{const h=await Vt(a,i.window);return h||(console.warn("getPlugin result is null",a),null)}),l)}return n}}function _r(){ue={},ke={},ei.clearAllCache(),ge.clear()}function le(t,e,s=xe,i=ti,r=[],n=!1,a=0){if(!t||!t.name||t.invisible)return null;const u=s.getCurrentInstance()?.appContext,{id:c=null,directives:l=[]}=t,{vIf:h,vElseIf:p,vElse:d,vFor:m,vShow:g,vModels:x,vBind:v,vHtml:E,others:T}=si(l);if(!n&&(p||d))return null;if(h&&!Cr(h,e))return Pr(t,e,s,i,r);const O=(w,W=0)=>{const pe=w.$components,we=(()=>{if(t.name==="component")return wr(w,t.props?.is);if(t.name==="slot")return t.name;const K=i(`${t.id}_${W}`,t.name,t.from,s);return f.isString(K)?cs(K)||ls(K)?K:pe[K]??u?.app?.component(K)??K:K})(),te=Er(c,t.props??{},w),oi=Ar(s,t.id,t.events??{},w);if(t.name==="slot")return Tr(s,t,te,w,i);v&&Object.assign(te,w.__parseExpression(v.value)),g&&(te.style=Object.assign(te.style??{},Nr(g,w))),E&&Object.assign(te,Or(E,w)),x.forEach(K=>{gt.includes(t.name)?Object.assign(te,Vr(K,w)):Object.assign(te,Fr(s,K,w))});const ui=Lr(s,t.children??[],w,i,t),Mt=w?.__id?`data-v-${w.__id}`:void 0,ci=Mt?{[Mt]:""}:{},li=w.__mode===A.Design?{"data-vtj":c}:{},je=`${c}_${W}`,tt={key:je,...ci,...li,...te};ge.isNodeEqual(tt,ge.getNode(je))||ge.setNode(je,tt);let st=s.createVNode(we,{...ge.getNode(je)||tt,...oi},ui);const Dt=u?Sr(u,T,w):[];return Dt.length&&(st=s.withDirectives(st,Dt)),st};return m?Dr(m,O,e):O(e,a)}function Sr(t,e,s){const i=t.app;return e.map(r=>{const n=typeof r.name=="string"?i.directive(r.name):s.__parseExpression(r.name);if(!n)return null;const a=[n];return r.value&&a.push(s.__parseExpression(r.value)),r.arg&&a.push(r.arg),r.modifiers&&a.push(r.modifiers),a}).filter(r=>!!r)}function si(t=[]){const e=t.find(h=>f.camelCase(h.name)==="vIf"),s=t.find(h=>f.camelCase(h.name)==="vElseIf"),i=t.find(h=>f.camelCase(h.name)==="vElse"),r=t.find(h=>f.camelCase(h.name)==="vFor"),n=t.find(h=>f.camelCase(h.name)==="vShow"),a=t.find(h=>f.camelCase(h.name)==="vBind"),u=t.find(h=>f.camelCase(h.name)==="vHtml"),c=t.filter(h=>f.camelCase(h.name)==="vModel"),l=t.filter(h=>!Qt.includes(f.camelCase(h.name)));return{vIf:e,vElseIf:s,vElse:i,vFor:r,vShow:n,vModels:c,vBind:a,others:l,vHtml:u}}function Cr(t,e){return!!e.__parseExpression(t.value)}function wr(t,e){return e?R(e)?t.__parseExpression(e):e:"div"}function Er(t,e,s){const i=dt(e,s);return i.ref=s.__ref(t,i.ref),i}function dt(t,e){return R(t)?e.__parseExpression(t):F(t)?e.__parseFunction(t):Array.isArray(t)?t.map(s=>dt(s,e)):typeof t=="object"?Object.keys(t||{}).reduce((s,i)=>{let r=t[i];return s[i]=dt(r,e),s},{}):t}function kr(t,e){return s=>{s?.key?.toLowerCase()===e.toLowerCase()&&t(s)}}function Ir(t){return hs(t.value)?t:ps(t.value)?{type:"JSFunction",value:`(...args) => (() => {
|
|
20
|
+
`:`with(${s?"{}":"$scope || {}"}) { ${a} }`;return tr?new Function("$scope",u)(e):sr(u,e)}catch(n){if(f.logger.error("parseExpression.error",n,t,e?.__self??e),n&&(n.info=t.value),Ue(n),i)throw n}}function G(t,e,s=!1,i=!1,r=!1){const n=Se(t,e,s,i,r);if(typeof n!="function"&&(f.logger.error("parseFunction.error","not a function",t,e?.__self??e),i))throw new Error(`"${t.value}" not a function`);return n}function R(t){return t&&t.type==="JSExpression"}function F(t){return typeof t=="object"&&t&&t.type==="JSFunction"}function Gs(t){return R(t)||F(t)}function ir(t){return Gs(t)?t.value.startsWith("{")?`(${t.value})`:t.value:JSON.stringify(t)}const rr={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},Nt=Symbol("access");class Xe{options;data=null;mode=A.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},rr,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:s,router:i,request:r}=e;this.mode=s,i&&this.mode!==A.Design&&this.setGuard(i),r&&this.setRequest(r)}login(e){const{storageKey:s,storagePrefix:i,session:r,authKey:n}=this.options;this.setData(e),this.data&&(f.storage.save(s,e,{type:"local",prefix:i}),r&&f.cookie.set(n,this.data.token))}clear(){const{storageKey:e,storagePrefix:s,session:i,authKey:r}=this.options;this.data=null,f.storage.remove(e,{type:"local",prefix:s}),i&&f.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:s}=this.options,{permissions:i={}}=this.data||{};if(typeof e=="function")return e(i);const r=f.toArray(e);return Array.isArray(i)?r.every(n=>i.includes(n)||i.includes(s+"."+n)):r.every(n=>i[n]||i[s+"."+n])}some(e){const{appName:s}=this.options,{permissions:i={}}=this.data||{},r=f.toArray(e);return Array.isArray(i)?r.some(n=>i.includes(n)||i.includes(s+"."+n)):r.some(n=>i[n]||i[s+"."+n])}install(e){e.config.globalProperties.$access=this,e.provide(Nt,this)}isAuthPath(e){const{auth:s,isAuth:i}=this.options;if(i)return i(e);if(e.path&&typeof s=="string"){const r=s.split("#")[1]||s;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:s}=this.options;if(!e)return;const i=s?`?${s}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(i):location.href=s?`${e}${i}`:e}setData(e){const{privateKey:s}=this.options;if(Array.isArray(e)&&s){const i=e.map(r=>f.unRSA(r,s));try{this.data=JSON.parse(i.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const i=s?f.unRSA(e,s):e;i?this.data=JSON.parse(i):console.warn("RSA解密失败或登录信息缺失")}catch(i){console.warn(i)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:s}=this.options,i=f.storage.get(e,{type:"local",prefix:s});this.setData(i||null)}isLogined(){const{session:e,authKey:s}=this.options;return e&&s?!!f.cookie.get(s):!!this.getToken()}hasRoutePermission(e){if(e.name===ye){const s=e.params.id;return s&&this.can(s)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((s,i,r)=>this.guard(s,r))}async guard(e,s){if(this.isWhiteList(e)||this.isAuthPath(e))return s();if(this.isLogined()){if(this.hasRoutePermission(e))return s();{const{noPermissionMessage:i="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(i),f.isFunction(r)?(r(),s(!1)):f.isString(r)?s(r):s(!1)}}s(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:s}=this.options;return s?Array.isArray(s)?s.some(i=>e.fullPath.startsWith(i)):s(e):!1}isUnauthorized(e){const{unauthorizedCode:s=401,statusKey:i="code"}=this.options;return e.status===s||e.data?.[i]===s}async showUnauthorizedAlert(e){const{unauthorizedMessage:s="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(s)&&this.toLogin()}async showTip(e){const{alert:s}=this.options;return this.isTipShowing?!1:s?(this.isTipShowing=!0,await f.delay(150),await s(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(globalThis.alert?.(e)??console.warn(e),!0)}setRequest(e){e.useRequest(s=>(this.data?.token&&(s.headers[this.options.authKey]=this.data?.token),s)),e.useResponse(async s=>(this.interceptResponse&&await this.showUnauthorizedAlert(s),s),async s=>{if(!this.interceptResponse)return Promise.reject(s);const i=s.response||s||{};return await this.showUnauthorizedAlert(i),Promise.reject(s)})}}function qs(){return L.inject(Nt,null)}function nr(t={}){const{notify:e,loading:s,settings:i={},Startup:r,access:n,useTitle:a,alert:u}=t;let c=null;return{request:f.createRequest({adapter:t.axiosAdapter,settings:{type:"form",validSuccess:!1,originResponse:!0,loading:!0,validate:h=>h.data?.code===0||!!h.data?.success,failMessage:!0,showError:h=>{e&&e(h||"未知错误")},showLoading:()=>{c&&c.close(),s&&(c=s())},hideLoading:()=>{c&&(c.close(),c=null)},...i}}),jsonp:f.jsonp,notify:e,loading:s,useTitle:a,alert:u,startupComponent:r,access:n?new Xe({alert:u,...n}):void 0}}function ar(t={}){return new Xe(t)}function Ws(t,e){const{jsonp:s,request:i}=e;if(t.method==="jsonp")return(r={})=>s(t.url,{...t.jsonpOptions,query:r});{const r=t.headers?Se(t.headers,{},!0):void 0,n={url:t.url,method:t.method,settings:{...t.settings,headers:r}};return(a,u)=>(delete n.data,i.send(f.merge(n,u||{},{data:a})))}}function Ks(t,e){const{metaQuery:s}=e;if(!s)return;const{code:i,queryCode:r}=t;return(n,a)=>{if(!s){console.warn("adapter.metaQuery is not defined!");return}return s(i,r,n,a)}}function zs(t=[],e=[],s){const i={};for(const r of t){const n=Ws(r,s);i[r.id]=n,i[r.name]=n}for(const r of e)i[r.id]=Ks(r,s);return i}async function Js(t=[],e=globalThis){const s=be(e);s&&(Ot(e),t.forEach(i=>Ys(s,i)))}function Qs(t,e=globalThis){const s=F(t.mockTemplate)&&t.mockTemplate.value?G(t.mockTemplate,{},!0):void 0,i=be(e);return async(...r)=>{let n={};if(s)try{n=await s.apply(s,r)}catch(a){f.logger.warn("模拟数据模版异常",a)}return i?.mock(n)}}function Ys(t,e){if(!e.mock)return;const{url:s,mockTemplate:i,method:r="get",settings:n={}}=e;if(s&&i)try{const a=f.isUrl(s)?new URL(s).pathname:s,u=f.pathToRegexp(`(.*)${a}`,[],{end:!1}),c=new RegExp(u.source+"([?#].*)?$",u.flags),l=f.pathToRegexpMatch(a,{decode:decodeURIComponent}),h=Se(i,{},!0);t.mock(c,r.toLowerCase(),p=>{const d=f.url.parse(p.url)||{},m=n.type||"form";let g=p.body instanceof FormData?f.formDataToJson(p.body):p.body;if(typeof g=="string")if(m==="json")try{g=JSON.parse(g)}catch(E){console.warn("[Mock.mock]",E)}else g=f.url.parse(g);const x=f.isUrl(p.url)?new URL(p.url).pathname:p.url.split("?")[0],v=l(x)?.params;Object.assign(p,{data:g,params:v,query:d});try{return t.mock(h(p))}catch(E){return console.warn("[mockApi]",c,p,E),null}})}catch(a){console.warn("mockApi",a)}}function Ot(t=globalThis){const e=be(t);e&&(e._mocked={})}class Xs{__id=null;__mode;__instance=null;__contextRefs={};__refs={};__refCaches={};context={};state={};props={};$props={};$state={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;$uni=null;$getApp=null;__transform={};constructor(e){const{mode:s,dsl:i,attrs:r}=e;this.__mode=s,i&&(this.__id=i.id||null,this.__transform=i.transform||{}),r&&Object.assign(this,r)}setup(e,s=xe){const i=s.getCurrentInstance();if(!i)return;this.__refs={},this.__refCaches={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=i.proxy;const{state:r}=this,n=i.appContext.config.globalProperties;Object.assign(this,n,e||{}),this.$uni=this.$libs.UniH5?.uni??null,this.$getApp=this.$libs.UniH5?.getApp??null,this.$state=this.state=r,this.__proxy(),s.onMounted(()=>{this.__proxy()}),s.onUnmounted(()=>{this.__cleanup()}),s.onBeforeUpdate(()=>{if(this.__proxy(),this.$props)for(const a of Object.keys(this.$props))this[a]=this.$props[a];this.__reset()})}__proxy(){if(!this.__instance)return;const e=this.__instance;ct.forEach(s=>{this[s]=e[s]||e._?.[s.replace("$","")]||null})}__cleanup(){ct.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.__refCaches={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===A.Runtime){const{id:s,type:i}=e,r=s?this.__transform[s]??e.value:e.value;return G({type:i,value:r},this)}else return G(e,this)}__parseExpression(e){if(e)if(this.__mode===A.Runtime){const{id:s,type:i}=e,r=s?this.__transform[s]??e.value:e.value;return Se({type:i,value:r},this)}else return Se(e,this)}__ref(e=null,s){if(this.__mode===A.VNode)return;e&&e!==this.__id&&(this.__contextRefs[e]=this);let i=e?this.__refCaches[e]:null;return i||(i=async r=>{await f.delay(0);let n=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!n){typeof s=="string"&&(delete this.$refs[s],this[s]&&xe.isRef(this[s])&&(this[s].value=null),e&&delete this.__refs[e]);return}return n.nodeType===3&&n.nextSibling&&(n=n.nextSibling),n.__vtj__=e,A.Design===this.__mode&&(n.__context__=this,n.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,r)),typeof s=="function"?s(r):s&&(this.$refs[s]=this.__getRefEl(this.$refs,s,r),this[s]&&xe.isRef(this[s])&&(this[s].value=this.$refs[s])),r},e&&(this.__refCaches[e]=i),i)}__getRefEl(e,s,i){const r=e[s];if(r&&i!==r){const n=new Set([].concat(r,i));return Array.from(n)}else return i}__clone(e={}){const s={...this.context,...e},i={...s,context:s};return i.context.__proto__=this.context,i.__proto__=this,i}}function $e(t){const{Vue:e=xe,UniApp:s={},mode:i=A.Runtime,components:r={},libs:n={},apis:a={},loader:u}=t,c=e.computed(()=>t.dsl),l={$components:r,$libs:n,$apis:a},h=new Xs({mode:i,dsl:c.value,attrs:l}),p=e.defineComponent({name:c.value.name,__scopeId:c.value.id?`data-v-${c.value.id}`:void 0,props:{...ur(c.value.props??[],h)},async setup(d={}){h.$props=h.props=d,c.value.id&&qe(t.window||globalThis,c.value.id,c.value.css||"",!0);const m=c.value.apiMode==="composition";h.$state=h.state=cr(e,c.value.state??{},h);const g=m?dr(e,c.value.refs??{},h):{},x=m?mr(e,c.value.reactives??{},h):{},v=lr(e,c.value.computed??{},h),E=hr(c.value.methods??{},h),T=pr(e,c.value.inject,h),O=Zs(c.value.dataSources||{},h);let w={};m&&(w=gr(c.value.composables??[],h));const W={...d,...g,...x,...T,...v,...E,...O,...w};if(h.setup(W,e),fr(e,c.value.watch??[],h),m){if(await vr(e,c.value.lifeCycles??{},h,s),c.value.setup){const pe=h.__parseFunction(c.value.setup);if(f.isFunction(pe))try{await pe()}catch(we){console.warn("[VTJ] Composition setup 执行失败",we)}}xr(e,c.value.provide??{},h)}return{vtj:h,state:h.state,$state:h.$state,...d,...g,...x,...v,...E}},emits:or(c.value.emits),expose:["vtj",...c.value.expose||[]],render(){const d=c.value;if(d.refs)for(const g of Object.keys(d.refs))this[g];if(d.reactives)for(const g of Object.keys(d.reactives)){const x=this[g];if(x&&typeof x=="object")for(const v of Object.keys(x))x[v]}if(d.state){const g=this.state;for(const x of Object.keys(d.state))g[x]}if(d.computed)for(const g of Object.keys(d.computed))this[g];if(d.inject)for(const g of d.inject)this[g.name];if(!d.nodes)return null;const m=d.nodes||[];if(m.length===1)return le(m[0],h,e,u,m);{const g=m.map(x=>le(x,h,e,u,m)).flat();return e.createVNode("div",{},g)}},...c.value.apiMode!=="composition"?yr(c.value.lifeCycles??{},h):{}});return{renderer:e.markRaw(p),context:h}}function or(t=[]){return t.map(e=>f.isString(e)?e:e.name)}function ur(t=[],e){const s=i=>i?(Array.isArray(i)?i:[i]).map(n=>Yt[n]):void 0;return t.map(i=>f.isString(i)?{name:i}:{name:i.name,type:i.type,required:i.required,default:R(i.default)?e.__parseExpression(i.default):i.default}).reduce((i,r)=>(i[r.name]={type:s(r.type),required:r.required,default:r.default},i),{})}function cr(t,e,s){return t.reactive(Object.keys(e||{}).reduce((i,r)=>{let n=e[r];return R(n)?n=s.__parseExpression(n):F(n)&&(n=s.__parseFunction(n)),i[r]=n,i},{}))}function lr(t,e,s){return Object.entries(e??{}).reduce((i,[r,n])=>(F(n)?i[r]=t.computed(s.__parseFunction(n)):i[r]=t.computed(s.__parseExpression(n)),i),{})}function hr(t,e){return Object.entries(t??{}).reduce((s,[i,r])=>(s[i]=e.__parseFunction(r),s),{})}function pr(t,e=[],s){return e.reduce((i,r)=>{const{name:n,from:a}=r||{},u=R(a)?s.__parseExpression(a)||n:a??n,c=R(r.default)?s.__parseExpression(r.default):r.default??null;return i[n]=t.inject(u,c),i},{})}function Zs(t,e){return Object.keys(t).reduce((s,i)=>{const r=t[i];if(r.type==="mock")s[i]=Qs(r);else if(r.ref){const n=e.$apis[r.ref],a=F(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;s[i]=async(...u)=>{const c=await n.apply(e,u);return a?a(c):c}}return s},{})}function fr(t,e=[],s){e.forEach(i=>{t.watch(s.__parseExpression(i.source),s.__parseFunction(i.handler),{deep:i.deep,immediate:i.immediate,flush:i.flush})})}function dr(t,e,s){return Object.entries(e).reduce((i,[r,n])=>{const a=R(n)?s.__parseExpression(n):n;return i[r]=t.ref(a),i},{})}function mr(t,e,s){return Object.entries(e).reduce((i,[r,n])=>{const a=R(n)?s.__parseExpression(n):n;return i[r]=t.reactive(a??{}),i},{})}function gr(t,e){return t.reduce((s,i)=>{try{let r;if(R(i.composable)?r=e.__parseExpression(i.composable):f.isString(i.composable)&&(r=e.$libs[i.composable]),f.isFunction(r)){const n=(i.args||[]).map(u=>R(u)?e.__parseExpression(u):u),a=r(...n);if(i.destructure&&i.destructure.length>0)for(const u of i.destructure)s[u]=a?.[u];else s[i.name]=a}}catch(r){e.__mode===A.Design&&(console.warn("[VTJ] composable 执行失败,已降级处理",r),s[i.name]={})}return s},{})}function xr(t,e,s){Object.entries(e).forEach(([i,r])=>{let n=r;R(r)?n=s.__parseExpression(r):F(r)&&(n=s.__parseFunction(r)),t.provide(i,n)})}async function vr(t,e,s,i={}){const r={beforeMount:"onBeforeMount",mounted:"onMounted",beforeUpdate:"onBeforeUpdate",updated:"onUpdated",beforeUnmount:"onBeforeUnmount",unmounted:"onUnmounted",errorCaptured:"onErrorCaptured",renderTracked:"onRenderTracked",renderTriggered:"onRenderTriggered",activated:"onActivated",deactivated:"onDeactivated"};for(const[n,a]of Object.entries(e)){if(n==="created"||n==="beforeCreate"){const l=s.__parseFunction(a);if(f.isFunction(l))try{await l()}catch(h){console.warn(`[VTJ] Composition 生命周期 "${n}" 执行失败`,h),Ue(h)}continue}const u=r[n]||n,c=t[u]||i[u];if(c&&f.isFunction(c)){const l=s.__parseFunction(a);f.isFunction(l)&&c(async()=>{try{await f.delay(0),await l()}catch(h){console.warn(`[VTJ] Composition 生命周期 "${n}" 执行失败`,h),Ue(h)}})}else console.warn(`[VTJ] 无效的 Composition 生命周期钩子 "${n}"`)}}function yr(t,e){return Object.entries(t??{}).reduce((s,[i,r])=>{const n=e.__parseFunction(r);return s[i]=async()=>{f.isFunction(n)&&(await f.delay(0),await n())},s},{})}class br{__props={};__events={};__nodes={};constructor(){}setProps(e,s){this.__props[e]=s}getProps(e){return this.__props[e]}loadProps(e,s){const i=e?this.getProps(e):null;return i||(e&&this.setProps(e,s),s)}setEvents(e,s){}getEvents(e){return this.__events[e]}loadEvents(e,s){const i=e?this.getEvents(e):null;return i||(e&&this.setEvents(e,s),s)}setNode(e,s){this.__nodes[e]=s}getNode(e){return this.__nodes[e]}loadNode(e,s){const i=e?this.getNode(e):null;return i||(e&&this.setNode(e,s),s)}isEqual(e,s){return f.isEqual(e,s)}isNodeEqual(e,s){if(e===s)return!0;if(!e||!s)return!1;const i=u=>!u||typeof u!="object"?[]:Object.keys(u).filter(c=>f.isFunction(u[c])),r=u=>{if(!u||typeof u!="object")return u;const c={};for(const l in u)if(Object.prototype.hasOwnProperty.call(u,l)){const h=u[l];f.isFunction(h)||(c[l]=h)}return c},n=i(e).sort(),a=i(s).sort();return f.isEqual(n,a)?f.isEqual(r(e),r(s)):!1}clear(){this.__props={},this.__events={},this.__nodes={}}}const ge=new br,ei=new f.Queue;let at=[],ue={},ke={};const ti=(t,e)=>e;async function Vt(t,e=globalThis){const{urls:s=[],library:i}=t,r=s.filter(u=>Ve(u));if(r.length===0||!i)return null;const n=s.filter(u=>Oe(u));return n.length&&vt(n,e),await yt(r,i,e).catch(u=>(console.warn("loadScriptUrl error",r,i,u),null))}function Ge(t){const{getDsl:e,getDslByUrl:s,options:i}=t;return i.window&&(at.forEach(r=>{delete i.window[r]}),at=[]),(r,n,a,u=xe)=>{if(!a||typeof a=="string")return n;let c="";if(a.type==="Schema"&&a.id)return c=a.id+"_"+r,ke[c]||(ke[c]=u.defineAsyncComponent(async()=>{const l=ue[a.id]||await ei.add(a.id,()=>e(a.id));return l&&(l.name=n,ue[a.id]=l),l?$e({Vue:u,mode:A.Runtime,...i,dsl:f.cloneDeep(l),loader:Ge(t)}).renderer:null}));if(a.type==="UrlSchema"&&a.url)return c=a.url+"_"+r,ke[c]||(ke[c]=u.defineAsyncComponent(async()=>{const l=ue[a.url]||await s(a.url);return l&&(l.name=n,ue[a.url]=l),l?$e({...i,Vue:u,dsl:f.cloneDeep(l),mode:A.Runtime,loader:Ge(t)}).renderer:null}));if(a.type==="Plugin"){let l=a.library?ue[a.library]:null;return l||(a.library&&at.push(a.library),l=ue[a.library||Symbol()]=u.defineAsyncComponent(async()=>{const h=await Vt(a,i.window);return h||(console.warn("getPlugin result is null",a),null)}),l)}return n}}function _r(){ue={},ke={},ei.clearAllCache(),ge.clear()}function le(t,e,s=xe,i=ti,r=[],n=!1,a=0){if(!t||!t.name||t.invisible)return null;const u=s.getCurrentInstance()?.appContext,{id:c=null,directives:l=[]}=t,{vIf:h,vElseIf:p,vElse:d,vFor:m,vShow:g,vModels:x,vBind:v,vHtml:E,others:T}=si(l);if(!n&&(p||d))return null;if(h&&!Cr(h,e))return Pr(t,e,s,i,r);const O=(w,W=0)=>{const pe=w.$components,we=(()=>{if(t.name==="component")return wr(w,t.props?.is);if(t.name==="slot")return t.name;const K=i(`${t.id}_${W}`,t.name,t.from,s);return f.isString(K)?cs(K)||ls(K)?K:pe[K]??u?.app?.component(K)??K:K})(),te=Er(c,t.props??{},w),oi=Ar(s,t.id,t.events??{},w);if(t.name==="slot")return Tr(s,t,te,w,i);v&&Object.assign(te,w.__parseExpression(v.value)),g&&(te.style=Object.assign(te.style??{},Nr(g,w))),E&&Object.assign(te,Or(E,w)),x.forEach(K=>{gt.includes(t.name)?Object.assign(te,Vr(K,w)):Object.assign(te,Fr(s,K,w))});const ui=Lr(s,t.children??[],w,i,t),Mt=w?.__id?`data-v-${w.__id}`:void 0,ci=Mt?{[Mt]:""}:{},li=w.__mode===A.Design?{"data-vtj":c}:{},je=`${c}_${W}`,tt={key:je,...ci,...li,...te};ge.isNodeEqual(tt,ge.getNode(je))||ge.setNode(je,tt);let st=s.createVNode(we,{...ge.getNode(je)||tt,...oi},ui);const Dt=u?Sr(u,T,w):[];return Dt.length&&(st=s.withDirectives(st,Dt)),st};return m?Dr(m,O,e):O(e,a)}function Sr(t,e,s){const i=t.app;return e.map(r=>{const n=typeof r.name=="string"?i.directive(r.name):s.__parseExpression(r.name);if(!n)return null;const a=[n];return r.value&&a.push(s.__parseExpression(r.value)),r.arg&&a.push(r.arg),r.modifiers&&a.push(r.modifiers),a}).filter(r=>!!r)}function si(t=[]){const e=t.find(h=>f.camelCase(h.name)==="vIf"),s=t.find(h=>f.camelCase(h.name)==="vElseIf"),i=t.find(h=>f.camelCase(h.name)==="vElse"),r=t.find(h=>f.camelCase(h.name)==="vFor"),n=t.find(h=>f.camelCase(h.name)==="vShow"),a=t.find(h=>f.camelCase(h.name)==="vBind"),u=t.find(h=>f.camelCase(h.name)==="vHtml"),c=t.filter(h=>f.camelCase(h.name)==="vModel"),l=t.filter(h=>!Qt.includes(f.camelCase(h.name)));return{vIf:e,vElseIf:s,vElse:i,vFor:r,vShow:n,vModels:c,vBind:a,others:l,vHtml:u}}function Cr(t,e){return!!e.__parseExpression(t.value)}function wr(t,e){return e?R(e)?t.__parseExpression(e):e:"div"}function Er(t,e,s){const i=dt(e,s);return i.ref=s.__ref(t,i.ref),i}function dt(t,e){return R(t)?e.__parseExpression(t):F(t)?e.__parseFunction(t):Array.isArray(t)?t.map(s=>dt(s,e)):typeof t=="object"?Object.keys(t||{}).reduce((s,i)=>{let r=t[i];return s[i]=dt(r,e),s},{}):t}function kr(t,e){return s=>{s?.key?.toLowerCase()===e.toLowerCase()&&t(s)}}function Ir(t){return hs(t.value)?t:ps(t.value)?{type:"JSFunction",value:`(...args) => (() => {
|
|
21
21
|
return (($event) => {
|
|
22
22
|
${t.value}
|
|
23
23
|
}).apply(this, args);
|
package/dist/index.mjs
CHANGED
|
@@ -4214,7 +4214,7 @@ ${a}
|
|
|
4214
4214
|
` : `with(${s ? "{}" : "$scope || {}"}) { ${a} }`;
|
|
4215
4215
|
return fr ? new Function("$scope", u)(e) : dr(u, e);
|
|
4216
4216
|
} catch (n) {
|
|
4217
|
-
if (ge.error("parseExpression.error", n, t, e?.__self ?? e), xt(n), i)
|
|
4217
|
+
if (ge.error("parseExpression.error", n, t, e?.__self ?? e), n && (n.info = t.value), xt(n), i)
|
|
4218
4218
|
throw n;
|
|
4219
4219
|
}
|
|
4220
4220
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/renderer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.9",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"低代码引擎",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"eval5": "^1.4.8",
|
|
25
|
-
"@vtj/core": "~0.18.
|
|
26
|
-
"@vtj/utils": "~0.18.
|
|
25
|
+
"@vtj/core": "~0.18.9",
|
|
26
|
+
"@vtj/utils": "~0.18.9"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"vue": "~3.5.37",
|
|
30
30
|
"vue-router": "~4.6.0",
|
|
31
|
-
"@vtj/ui": "~0.18.8",
|
|
32
31
|
"@vtj/cli": "~0.13.0",
|
|
33
|
-
"@vtj/icons": "~0.18.
|
|
32
|
+
"@vtj/icons": "~0.18.9",
|
|
33
|
+
"@vtj/ui": "~0.18.9"
|
|
34
34
|
},
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
package/types/version.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/renderer
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.18.
|
|
5
|
+
* @version 0.18.8
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.18.
|
|
8
|
+
export declare const version = "0.18.8";
|