@guihz/trading-vue-editor-tes 0.0.178 → 0.0.180
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/lib/assets/{parserTccWorker-Bcz7NTve.js → parserTccWorker-EAmu3SRf.js} +2 -2
- package/lib/assets/scriptsRunWorker-BuRjnA8Y.js +69 -0
- package/lib/components/editor/parseScript/buildInFuncNamespace/box.d.ts +1 -1
- package/lib/components/editor/parseScript/buildInFuncNamespace/label.d.ts +1 -1
- package/lib/components/editor/parseScript/buildInFuncNamespace/line.d.ts +1 -1
- package/lib/components/editor/parseScript/buildInFuncNamespace/table.d.ts +1 -1
- package/lib/trading-vue-editor.js +2 -2
- package/lib/trading-vue-editor.umd.cjs +1 -1
- package/package.json +1 -1
- package/lib/assets/scriptsRunWorker-Ci_BGrY5.js +0 -69
@@ -116,7 +116,7 @@ ${this._prefixNameVar}.againAssignParse(${v}, ${B});
|
|
116
116
|
})
|
117
117
|
`}return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:d}),d}_parserArrowFunction(e){let n=`$_${e.name}`;this._nameMap.set(e.name,n);const r=[...e.params];n=`${n}${e.index?`$${e.index}`:""}`,this._currentFuncName=n,this._dependsObj[n]=new Map;const s=e.hasRequest?", $paramsExpr":"",l=`const ${n} = (${this._parserParameters(r)}$posStr${s}) => {
|
118
118
|
${this._parserBlock(e.block,!0,!0)}
|
119
|
-
}`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:l}),l}_parserParameters(e){return e.length?`{${e.map(n=>{const{name:r,defaultValue:s}=n;let l=r;if(s){const h=this._parserSingleExpression(s);l=`${l} = ${h}`}return l}).join(", ")}},`:""}_parserBlock(e,n=!1,r=!1){return r&&(this._isInFunc=!0),this._parserBlockLine(Array.isArray(e)?e:[e],n,r)}_addVarList(e){var r,s;const n=this._varlist[this._blockCount]||{};if(e.names){const l=e.posList;for(const[h,d]of e.names.entries()){const v=((r=l[h])==null?void 0:r.reName)||d;n[v]=l[h]}}else{const l=((s=e.pos)==null?void 0:s.reName)||e.name;n[l]=e.pos}this._varlist[this._blockCount]=n}_parserDeclareAssign(e){var S;const{nameList:n,value:r}=e,s=this._parserDeclareAssignNames(n);this._addVarList(n);const l={code:"",varNames:s.replace(/[\[\]]/g,"").split(", "),depends:[]},h=`$${s}_${this._blockCount}`;this._dependsObj[h]=new Map;const d=this._parserSingleExpression(r);let v=`let ${s} = ${d}`;if(n.declare){const C=`${n.pos.column}_${n.pos.lineNumber}`,A=this._isInFunc?`$posStr + "_${C}"`:`"${C}"`;v=`let ${s} = ${this._prefixNameVar}.getVarValue("${s}", ${A},
|
119
|
+
}`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:l}),l}_parserParameters(e){return e.length?`{${e.map(n=>{const{name:r,defaultValue:s}=n;let l=r;if(s){const h=this._parserSingleExpression(s);l=`${l} = ${h}`}return l}).join(", ")}},`:""}_parserBlock(e,n=!1,r=!1){return r&&(this._isInFunc=!0),this._parserBlockLine(Array.isArray(e)?e:[e],n,r)}_addVarList(e){var r,s;const n=this._varlist[this._blockCount]||{};if(e.names){const l=e.posList;for(const[h,d]of e.names.entries()){const v=((r=l[h])==null?void 0:r.reName)||d;n[v]=l[h]}}else{const l=((s=e.pos)==null?void 0:s.reName)||e.name;n[l]=e.pos}this._varlist[this._blockCount]=n}_parserDeclareAssign(e){var S;const{nameList:n,value:r}=e,s=this._parserDeclareAssignNames(n);this._addVarList(n);const l={code:"",varNames:s.replace(/[\[\]]/g,"").split(", "),depends:[]},h=`$${s}_${this._blockCount}`;this._dependsObj[h]=new Map;const d=this._parserSingleExpression(r);let v=`let ${s} = ${d}`;if(n.declare){const C=`${n.pos.column}_${n.pos.lineNumber}`,A=this._isInFunc?`$posStr + "_${C}"`:`"${C}"`;v=`let ${s} = ${this._prefixNameVar}.getVarValue("${s}", ${A}, ${d}, "${n.declare}")`}return l.code=v,l.depends=this._getDepends(h),(S=this._codesCol[this._blockCount])==null||S.push(l),v}_parserDeclareAssignNames(e){var n,r;switch(e==null?void 0:e.ruleType){case"VarMultiple":const s=e.posList;return`[${e.names.map((l,h)=>{var d,v;return l==="_"?(this.__count++,`_$$${this.__count}`):(d=s[h])!=null&&d.reName?(v=s[h])==null?void 0:v.reName:Rn.includes(l)?`$${l}`:l}).join(", ")}]`;case"VarSingle":return e.name==="_"?(this.__count++,`_$$${this.__count}`):(n=e.pos)!=null&&n.reName?(r=e.pos)==null?void 0:r.reName:Rn.includes(e.name)?`$${e.name}`:e.name}return""}_parserSingleExpression(e){if(!e)return"";const{exprs:n,operator:r}=e;let s="",l=this._isInConditionalStmt;switch(e.ruleType){case le.MemberIndexExpression:return this._parserMemberIndexExpression(e);case le.MethodExpression:return this._parserMethodExpression(e);case le.UnaryExpression:return`${r}${this._parserSingleExpression(n[0])}`;case le.NotExpression:return`!${this._parserSingleExpression(n[0])}`;case le.AdditiveExpression:return this._parserAdditiveExpression(e);case le.MultiplicativeExpression:case le.RelationalExpression:case le.EqualityExpression:return`${this._parserSingleExpression(n[0])} ${r} ${this._parserSingleExpression(n[1])}`;case le.LogicalAndExpression:return this._isInConditionalStmt=!0,s=`${this._parserSingleExpression(n[0])} && ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=l,s;case le.LogicalOrExpression:return this._isInConditionalStmt=!0,s=`${this._parserSingleExpression(n[0])} || ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=l,s;case le.TernaryExpression:return this._isInConditionalStmt=!0,s=`${this._parserSingleExpression(n[0])} ? ${this._parserSingleExpression(n[1])} : ${this._parserSingleExpression(n[2])}`,this._isInConditionalStmt=l,s;case le.Name:return this._parserName(e);case le.Literal:return this._parseLiteral(e);case le.ParenthesizedExpression:return`(${this._parserSingleExpression(e.exprs)})`;default:return e.name||""}}_parserAdditiveExpression(e){const{exprs:n,operator:r}=e,s=this._parserSingleExpression(n[0]),l=this._parserSingleExpression(n[1]);return r==="-"?`${this._prefixNameVar}.sub(${s}, ${l})`:`${this._prefixNameVar}.add(${s}, ${l})`}_parserMemberIndexExpression(e){var C;const{exprs:n,isInFunc:r,ctx:s}=e,l=n[0],h=this._parserSingleExpression(n[1]);let d=this._parserSingleExpression(l);const v=s.start.tokenIndex,S=r?"$posStr":v;if(l.ruleType===le.Name&&!l.hasMethod){let A=this._blockCount;const R=((C=l.varPos)==null?void 0:C.reName)||l.name;for(;A>=0;){const B=this._varlist[A]||{},M=B[R];if(M)return this._getUserVarMemberIndexs(M,R,A,h,r);if(l.isBuiltIn){const b=this._memberIndexList[0]||{};return b[R]=`${this._prefixNameVar}.setCacheData("${R}", ${d})`,`${this._prefixNameVar}.getCacheData("${R}", ${h}, ${d})`}if(R.includes(".")){const b=R.split(".")[0],y=B[b];if(y)return this._getUserVarMemberIndexs(y,R,A,h,r)}A--}return this._getOtherVarMemberIndexs(`${R}_${l.varScope||l.scope}`,R,l.varScope||l.scope,h,r)}else{const A=this._preRunMembers[this._blockCount]||[],R=`$$m${v}_${S}`;A.push(`const ${R} = ${d};
|
120
120
|
${this._prefixNameVar}.setCacheData("m${v}_" + ${S}, ${R})`),this._preRunMembers[this._blockCount]=A}return`${this._prefixNameVar}.getCacheData("m${v}_" + ${S}, ${h}, ${d})`}_getOtherVarMemberIndexs(e,n,r,s,l){const h=this._memberIndexList[r]||{};e=l&&r!==0?`"${e}_" + $posStr`:`"${e}"`;const d=`${this._prefixNameVar}.setCacheData(${e}, ${n})`;return h[e]=d,this._memberIndexList[r]=h,this._setDepend({name:n,scope:r,memberCode:d}),`${this._prefixNameVar}.getCacheData(${e}, ${s}, ${n})`}_getUserVarMemberIndexs(e,n,r,s,l){return this._getOtherVarMemberIndexs(`${n}_${e.lineNumber}_${e.column}`,n,r,s,l)}_parseLiteral(e){return e.type.endsWith(U.COLOR)?`"${this._colorToRgba(e.value)}"`:e.value}_colorToRgba(e){if(e.startsWith("#")){let n;const r=parseInt(e.substring(1,3),16),s=parseInt(e.substring(3,5),16),l=parseInt(e.substring(5,7),16),h=e.substring(7);return h?n=parseInt(h,16)/255:n=1,`rgba(${Math.round(r)}, ${Math.round(s)}, ${Math.round(l)}, ${n.toFixed(2)})`}return e}_parserName(e,n=!1){const{exprs:r,varScope:s,hasMethod:l,arg:h,varPos:d}=e,v=r.map(S=>{var B;if(typeof S=="string")return(d==null?void 0:d.reName)||S;const{column:C,line:A}=((B=S==null?void 0:S.ctx)==null?void 0:B.start)||{},R=`${A}_${C}`;return this._parserMethodElement(S,R)});if(e.expr&&v.unshift(`(${this._parserSingleExpression(e.expr)})`),e.isBuiltIn)v.join(".")==="strategy.opentrades"&&v.push("opentrades"),v.unshift(e.isConst?this._prefixNameConst:this._prefixNameVar);else if(Rn.includes(v[0])&&(v[0]=`$${v[0]}`),!l){const S={name:v[0],scope:s||(h==null?void 0:h.varScope)||0,isAgainAssign:n,isArg:h==null?void 0:h.isArg,functionName:this._currentFuncName};this._setDepend(S)}return v.join(".")}_setDepend(e){const n=e.name;for(const r of Object.values(this._dependsObj)){const s=r.get(n)||{},l={...e,...s};r.set(n,l)}}_parserMethodExpression(e){const{exprs:n,ctx:r}=e,{column:s,line:l}=r.start,h=`${l}_${s}`;let d=this._isInFunc?`$posStr + "__${h}"`:`"${h}"`;d=this._isInLoop?`$$count${this._count} + ${d}`:d;let v=!1;const C=n.map(A=>(A.hasMemberIndex&&(v=!0),this._parserMethodElement(A,d))).join(".");if(this._isInConditionalStmt&&v){const A=`$$result_${this._preRunMemberFuncsCount}`;this._preRunMemberFuncsCount++;const R=this._preRunMembersFuncs[this._blockCount]||[];return R.push(`const ${A} = ${C}`),this._preRunMembersFuncs[this._blockCount]=R,A}return C}_parserMethodElement(e,n){let r="",s="";const l={...e.args};e.expr&&(r=`(${this._parserSingleExpression(e.expr)})`),r=r?`${r}.${e.name}`:this._nameMap.get(e.name)||e.name,e.hasVarPrefix&&(r=`${this._prefixNameVar}.${r}`);let h=!1;if(e.isBuiltIn){if(Ip.includes(r))r=`${r}.${r}`;else if(r==="max_bars_back"){const{name:v,varPos:S}=l.var||l.params[0];s=`var_name: "${S?`${v}_${S.lineNumber}_${S.column}`:v}"`}r.startsWith(U.INPUT)?(s=`index: ${this._inputCount}`,this._inputCount++):r.startsWith("request.")&&(h=!0),r=`${this._prefixNameFunc}.${r}`}else{const v=r.split(".");let S=v[0];Rn.includes(S)&&(S=`$${S}`,r=v.join("."))}if(e.selfArg){const v=r.split("."),S=v.length;Object.assign(l,{[e.selfArg.name]:{name:v.slice(0,S-1).join(".")}}),r=v[S-1],r=this._nameMap.get(r)||r,this._setDepend({name:v[0],scope:e.varScope||0})}r=`${r}${e.index?`$${e.index}`:""}`;const d=this._parserArguments(l,s,n,h,e.hasRequest,r);if(!e.isBuiltIn){const v=r.split(".");if(v.length>1?this._setDepend({name:v[0],scope:e.varScope||0}):this._setDepend({name:r,scope:0,hasRequest:e.hasRequest,isFunc:!0}),e.funcName){const S=this._nameMap.get(e.funcName)||e.funcName;this._setDepend({name:S,originName:r,scope:0,hasRequest:e.hasRequest,isFunc:!0})}}return r+d}_parserArguments(e,n,r,s=!1,l=!1,h){const d=e.params||[];delete e.params;const v=[],S=[];let C=[],A;const R=(M,b)=>{l&&(this._dependsObj[r]=new Map),s&&b==="expression"&&(this._dependsObj[`$arg_${b}${r}`]=new Map);let y=M.ruleType===le.Brackethesized?this._parserBrackethesized(M):this._parserSingleExpression(M);if(b&&!["arg0, arg1, ...","number0, number1, ..."].includes(b)){M.isSourceType?v.push(`sourceTypeName: "${M.name}"`):b==="defval"&&h===`${this._prefixNameFunc}.input.enum`&&(A=this._enums.get(M.enumName));const g=this._requestParamsHandle(s,b,r,l,y,h);y=(g==null?void 0:g.code)||y,g!=null&&g.paramsExpr&&C.push(g==null?void 0:g.paramsExpr),v.push(`${b}: ${y}`)}else S.push(y)};for(const M of d)R(M,M.originName);for(const M of Object.keys(e))R(e[M],M);s&&this._isInFunc&&v.push("paramsExpr: $paramsExpr"),n&&v.push(n),A&&v.unshift(`options: [${A.join(", ")}]`);const B=C.length?`, [${this._isInFunc?"...$paramsExpr, ":""}${C.join(", ")}]`:"";return S.length?`({${v.join(", ")}}, [${S.join(", ")}], ${r}${B})`:v.length?`({${v.join(", ")}}, ${r}${B})`:`(${r}${B})`}_requestParamsHandle(e,n,r,s,l,h){const d=this._memberIndexList[0],v={};for(const S of Object.keys(d))S.includes("_")||(v[S]=d[S]);if(e&&n==="expression"){const S=this._getDepends(`$arg_${n}${r}`),C=this._getExpressionContext(S);return C.push({scope:1,depends:S.map(A=>(A.isArg&&(A.functionName=this._currentFuncName),A)),code:l,memberCodes:v}),{code:`'${Lp(JSON.stringify(C))}'`}}else if(s){const S=this._getDepends(r),C=this._getExpressionContext(S);return C.push({scope:2,varNames:n,methodName:h,depends:S,dependSelf:S.some(A=>A.name===n),code:`${n} = ${l}`,memberCodes:v}),{paramsExpr:`'${Lp(JSON.stringify(C))}'`}}}_getExpressionContext(e){const n=[],r=[];return this._getDependsCode(e,n,r),n}_getDependsCode(e,n,r){var s,l;for(const h of e)if(!h.isArg){const d=this._codesCol[h.scope||0],v=d.find(C=>{var A;return((A=C.varNames)==null?void 0:A.includes(h.name))||C.funcName===h.name});v&&(r.includes(v)||(r.push(v),v.depends.length&&this._getDependsCode(v.depends,n,r),n.push({scope:h.scope||0,code:v.code,depends:v.depends,funcName:v.funcName,varNames:(s=v.varNames)==null?void 0:s.join(", ")})));const S=d.filter(C=>C.depends.some(A=>A.name===h.name&&A.scope===h.scope&&A.isAgainAssign));for(const C of S)r.includes(C)||(r.push(C),C.depends.length&&this._getDependsCode(C.depends,n,r),n.push({scope:h.scope||0,code:C.code,depends:C.depends,funcName:C.funcName,varNames:(l=C.varNames)==null?void 0:l.join(", ")}))}}_parserBrackethesized(e){return`[${e.exprs.map(r=>this._parserSingleExpression(r)).join(", ")}]`}_functionalProcess(e){return`(function () {
|
121
121
|
let $$_result=undefined;
|
122
122
|
${e}
|
@@ -226,6 +226,6 @@ Input files:
|
|
226
226
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,`+m0(A)}else e.sourceMap.url&&(v.code+=`
|
227
227
|
//# sourceMappingURL=`+e.sourceMap.url)}return e.nameCache&&e.mangle&&(e.mangle.cache&&(e.nameCache.vars=Id(e.mangle.cache)),e.mangle.properties&&e.mangle.properties.cache&&(e.nameCache.props=Id(e.mangle.properties.cache))),S&&S.source_map&&S.source_map.destroy(),r&&(r.end=Date.now(),v.timings={parse:.001*(r.rename-r.parse),rename:.001*(r.compress-r.rename),compress:.001*(r.scope-r.compress),scope:.001*(r.mangle-r.scope),mangle:.001*(r.properties-r.mangle),properties:.001*(r.format-r.properties),format:.001*(r.end-r.format),total:.001*(r.end-r.start)}),v}async function Pd(t,e,n){const r=g0(t,e,n);let s,l;do l=r.next(await s),s=l.value;while(!l.done);return l.value}function Fd(t){const e=new a_(t),n=new El(e);n.removeErrorListeners();const r=new r_(n),s=new F(r);s._interp.predictionMode=h_.SLL,s.removeErrorListeners();const l=new E0;n.addErrorListener(l),s.addErrorListener(l),s.buildParseTrees=!0;const h=s.program(),d=r.tokens.filter(v=>v.channel===2);return{errors:l.errors,ast:h,comments:d}}async function b0(t,e,n,r){const{errors:s,ast:l,comments:h}=Fd(t+`
|
228
228
|
|
229
|
-
`),d=new Mp(r,h,n),v=await d.visit(l);let S=s.splice(0,1);S.length||(S=d.errors);let C="";const A=new $_("$"),R=e?"":A.preParser(v);if(e&&!S.some(B=>B.type===Sn.Error)){const B=A.parser(v)||"";try{C=(await Pd(B,{compress:!0,mangle:!0})).code||"";const b={message:de.indiRunErr,type:Sn.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0};if(d.hasUseDrawFunc){if(d.scriptType===Ii.library)d.exportPositions.length||(b.message=de.libraryExportErr,S.push(b));else if(d.exportPositions.length){const y=d.exportPositions.map(g=>{const{type:O,...w}=g;return{message:ye(de.exportUseErr,{type:O}),type:Sn.Error,...w}});S.push(...y)}}else switch(d.scriptType){case Ii.indicator:S.push(b);break;case Ii.strategy:d.hasUseCreateOrderFunc||(b.message=de.strategyRunErr,S.push(b));break}}catch(M){S.push({message:(M==null?void 0:M.message)||"minify error",type:Sn.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0})}}return{errors:S,functions:Object.fromEntries(d.userFunctions),variables:Object.fromEntries(d.userVariables),types:Object.fromEntries(d.userTypes),methods:Object.fromEntries(d.userMethods),overloadsFuncs:d.overloadsFuncs,imports:Object.fromEntries(d.imports),enums:Object.fromEntries(d.userEnums),codeStr:C,preParserCode:R}}async function v0(t,e,n,r){const{ast:s,comments:l}=Fd(t+`
|
229
|
+
`),d=new Mp(r,h,n),v=await d.visit(l);let S=s.splice(0,1);S.length||(S=d.errors);let C="";const A=new $_("$"),R=e?"":A.preParser(v);if(console.log(R),e&&!S.some(B=>B.type===Sn.Error)){const B=A.parser(v)||"";try{C=(await Pd(B,{compress:!0,mangle:!0})).code||"";const b={message:de.indiRunErr,type:Sn.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0};if(d.hasUseDrawFunc){if(d.scriptType===Ii.library)d.exportPositions.length||(b.message=de.libraryExportErr,S.push(b));else if(d.exportPositions.length){const y=d.exportPositions.map(g=>{const{type:O,...w}=g;return{message:ye(de.exportUseErr,{type:O}),type:Sn.Error,...w}});S.push(...y)}}else switch(d.scriptType){case Ii.indicator:S.push(b);break;case Ii.strategy:d.hasUseCreateOrderFunc||(b.message=de.strategyRunErr,S.push(b));break}}catch(M){S.push({message:(M==null?void 0:M.message)||"minify error",type:Sn.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0})}}return{errors:S,functions:Object.fromEntries(d.userFunctions),variables:Object.fromEntries(d.userVariables),types:Object.fromEntries(d.userTypes),methods:Object.fromEntries(d.userMethods),overloadsFuncs:d.overloadsFuncs,imports:Object.fromEntries(d.imports),enums:Object.fromEntries(d.userEnums),codeStr:C,preParserCode:R}}async function v0(t,e,n,r){const{ast:s,comments:l}=Fd(t+`
|
230
230
|
|
231
231
|
`),h=new Mp(r,l,n),d=await h.visit(s),{name:v,index:S}=h.endExport,C=d.findIndex(b=>b.name===v&&b.index===S),A=d.slice(0,C+1),B=new H_("$",e).parser(A)||"",M=await Pd(B,{compress:!0,mangle:!0});return{...h.exportLibs,description:h.description,codeStr:M.code||""}}class E0 extends i_{constructor(){super(...arguments);k(this,"errors",[])}syntaxError(n,r,s,l,h){this.errors.push({message:`syntax error: ${h.replace(/expecting.+/,"")}`,type:Sn.Error,startColumn:l,startLineNumber:s,endColumn:l,endLineNumber:s})}}Cl({parseTcc:b0,parseLibraryCode:v0})})();
|