@guihz/trading-vue-editor-tes 0.0.117 → 0.0.119

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,10 +67,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
67
67
  ${b}
68
68
  }`),this._isInLoop=f,T=`${F};
69
69
  let ${E} = 0;
70
- ${T}`,n?this._functionalProcess(T):T}_parserAgainAssign(e){const{operator:n,name:r,value:a}=e,{varPos:c,declare:f}=r,p=`$againAssign${this._blockCount}`;this._dependsObj[p]=new Map;const E=this._parserName(r,!0);let b="";const T=this._parserStmt(a,!0);let x="";const w=`$_tmp_${E.split(".").pop()}`;n===":="&&(x=`var ${w} = ${T}`);let F=`${E} ${n===":="?`= ${w}`:`${n} ${T}`}`;const R=`${c==null?void 0:c.column}_${c==null?void 0:c.lineNumber}`;if(f){const d=this._isInFunc?`$posStr + "_${R}"`:`"${R}"`;b=`;
71
- ${this._prefixNameVar}.setVarValue("${E}", ${d}, ${E}, "${f}")`}n==="-="?F=`${E} = ${this._prefixNameVar}.sub(${E}, ${T})`:n==="+="?F=`${E} = ${this._prefixNameVar}.add(${E}, ${T})`:n===":="&&(x=`${x};
72
- ${this._prefixNameVar}.againAssignParse(${E}, ${w});
73
- `);const v=`${x}${F}${b}`;return this._codesCol[this._blockCount].push({code:v,depends:this._getDepends(p)}),v}_parserSwitchStatement(e,n=!1){const{condition:r,cases:a,defaultCase:c}=e;let f=`$switch${this._blockCount}`;n||(this._dependsObj[f]=new Map);const p=this._isSwitch;this._isSwitch=!0;const E=a.length?this._parserCases(a,n):"",b=c?this._parserDefaultCase(c,n):"",T=`switch (${r===!0?r:this._parserSingleExpression(r)}) {
70
+ ${T}`,n?this._functionalProcess(T):T}_parserAgainAssign(e){const{operator:n,name:r,value:a}=e,{varPos:c,declare:f}=r,p=`$againAssign${this._blockCount}`;this._dependsObj[p]=new Map;const E=this._parserName(r,!0);let b="",T=this._parserStmt(a,!0,!0);const x=T.split(`
71
+ /****/
72
+ `);let w="";x.length>1&&(w=x[0],T=x[1]);const F=`$_tmp_${E.split(".").pop()}`;n===":="&&(w=`${w}
73
+ var ${F} = ${T}`);let R=`${E} ${n===":="?`= ${F}`:`${n} ${T}`}`;const v=`${c==null?void 0:c.column}_${c==null?void 0:c.lineNumber}`;if(f){const g=this._isInFunc?`$posStr + "_${v}"`:`"${v}"`;b=`;
74
+ ${this._prefixNameVar}.setVarValue("${E}", ${g}, ${E}, "${f}")`}n==="-="?R=`${E} = ${this._prefixNameVar}.sub(${E}, ${T})`:n==="+="?R=`${E} = ${this._prefixNameVar}.add(${E}, ${T})`:n===":="&&(w=`${w};
75
+ ${this._prefixNameVar}.againAssignParse(${E}, ${F});
76
+ `);const d=`${w}${R}${b}`;return this._codesCol[this._blockCount].push({code:d,depends:this._getDepends(p)}),d}_parserSwitchStatement(e,n=!1){const{condition:r,cases:a,defaultCase:c}=e;let f=`$switch${this._blockCount}`;n||(this._dependsObj[f]=new Map);const p=this._isSwitch;this._isSwitch=!0;const E=a.length?this._parserCases(a,n):"",b=c?this._parserDefaultCase(c,n):"",T=`switch (${r===!0?r:this._parserSingleExpression(r)}) {
74
77
  ${E}
75
78
  ${b}
76
79
  }`;n||this._codesCol[this._blockCount].push({code:T,depends:this._getDepends(f)});const x=n?this._functionalProcess(T):T;return this._isSwitch=p,x}_parserCases(e,n=!1){const r=[];for(const a of e)r.push(this._parserCase(a,n));return r.join(`
@@ -127,7 +130,7 @@ ${this._prefixNameVar}.againAssignParse(${E}, ${w});
127
130
  })
128
131
  `}return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:p}),p}_parserArrowFunction(e){let n=`$_${e.name}`;this._nameMap.set(e.name,n);const r=[...e.params];e.hasMemberIndex&&r.push({name:`${this._prefixNameVar}_position`}),n=`${n}${e.index?`$${e.index}`:""}`,this._currentFuncName=n,this._dependsObj[n]=new Map;const a=e.hasRequest?", $paramsExpr":"",c=`const ${n} = (${this._parserParameters(r)}$posStr${a}) => {
129
132
  ${this._parserBlock(e.block,!0,!0)}
130
- }`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:c}),c}_parserParameters(e){return e.length?`{${e.map(n=>{const{name:r,defaultValue:a}=n;let c=r;if(a){const f=this._parserSingleExpression(a);c=`${c} = ${f}`}return c}).join(", ")}},`:""}_parserBlock(e,n=!1,r=!1){return r&&(this._isInFunc=!0),this._parserBlockLine(Array.isArray(e)?e:[e],n,r)}_addVarList(e){const n=this._varlist[this._blockCount]||{};if(e.names)for(const[r,a]of e.names.entries())n[a]=e.posList[r];else n[e.name]=e.pos;this._varlist[this._blockCount]=n}_parserDeclareAssign(e){var E;const{nameList:n,value:r}=e;if(n.name==="_")return"";const a=this._parserDeclareAssignNames(n);this._addVarList(n);const c={code:"",varNames:a.replace(/[\[\]]/g,"").split(", "),depends:[]};this._dependsObj[a]=new Map;const f=this._parserSingleExpression(r);let p=`let ${a} = ${f}`;if(n.declare){const b=`${n.pos.column}_${n.pos.lineNumber}`,T=this._isInFunc?`$posStr + "_${b}"`:`"${b}"`;p=`let ${a} = ${this._prefixNameVar}.getVarValue("${a}", ${T}, "${n.declare}") || ${this._prefixNameVar}.setVarValue("${a}", ${T}, ${f}, "${n.declare}")`}return c.code=p,c.depends=this._getDepends(a),(E=this._codesCol[this._blockCount])==null||E.push(c),p}_parserDeclareAssignNames(e){switch(e==null?void 0:e.ruleType){case"VarMultiple":return`[${e.names.map(n=>Nn.includes(n)?`$${n}`:n).join(", ")}]`;case"VarSingle":return Nn.includes(e.name)?`$${e.name}`:e.name}return""}_parserSingleExpression(e){if(!e)return"";const{exprs:n,operator:r}=e;let a="",c=this._isInConditionalStmt;switch(e.ruleType){case ye.MemberIndexExpression:return this._parserMemberIndexExpression(e);case ye.MethodExpression:return this._parserMethodExpression(e);case ye.UnaryExpression:return`${r}${this._parserSingleExpression(n[0])}`;case ye.NotExpression:return`!${this._parserSingleExpression(n[0])}`;case ye.AdditiveExpression:return this._parserAdditiveExpression(e);case ye.MultiplicativeExpression:case ye.RelationalExpression:case ye.EqualityExpression:return`${this._parserSingleExpression(n[0])} ${r} ${this._parserSingleExpression(n[1])}`;case ye.LogicalAndExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} && ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=c,a;case ye.LogicalOrExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} || ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=c,a;case ye.TernaryExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} ? ${this._parserSingleExpression(n[1])} : ${this._parserSingleExpression(n[2])}`,this._isInConditionalStmt=c,a;case ye.Name:return this._parserName(e);case ye.Literal:return this._parseLiteral(e);case ye.ParenthesizedExpression:return`(${this._parserSingleExpression(e.exprs)})`;default:return e.name||""}}_parserAdditiveExpression(e){const{exprs:n,operator:r}=e,a=this._parserSingleExpression(n[0]),c=this._parserSingleExpression(n[1]);return r==="-"?`${this._prefixNameVar}.sub(${a}, ${c})`:`${this._prefixNameVar}.add(${a}, ${c})`}_parserMemberIndexExpression(e){const{exprs:n,isInFunc:r,ctx:a}=e,c=n[0],f=this._parserSingleExpression(n[1]),p=this._parserSingleExpression(c),E=a.start.tokenIndex,b=r?`${this._prefixNameVar}_position`:E;if(c.ruleType===ye.Name&&!c.hasMethod){let T=this._blockCount;const x=c.name;for(c.isBuiltIn||this._setDepend({name:x,scope:c.varScope});T>=0;){const w=this._varlist[T]||{},F=w[x];if(F)return this._getUserVarMemberIndexs(F,x,T,f,r);if(c.isBuiltIn){const R=this._memberIndexList[0]||{};return R[x]=`${this._prefixNameVar}.setCacheData("${x}", ${p})`,`${this._prefixNameVar}.getCacheData("${x}", ${f}, ${p})`}else if(x.includes(".")){const R=x.split(".")[0],v=w[R];if(v)return this._getUserVarMemberIndexs(v,x,T,f,r)}T--}}else{const T=this._preRunMembers[this._blockCount]||[];T.push(`${this._prefixNameVar}.setCacheData("m${E}_" + ${b}, ${p})`),this._preRunMembers[this._blockCount]=T}return`${this._prefixNameVar}.getCacheData("m${E}_" + ${b}, ${f}, ${p})`}_getUserVarMemberIndexs(e,n,r,a,c){const f=this._memberIndexList[r]||{};let p=`${n}_${e.lineNumber}_${e.column}`;return p=c&&r!==0?`"${p}_" + $posStr`:`"${p}"`,f[p]=`${this._prefixNameVar}.setCacheData(${p}, ${n})`,this._memberIndexList[r]=f,`${this._prefixNameVar}.getCacheData(${p}, ${a}, ${n})`}_parseLiteral(e){return e.type.endsWith(z.COLOR)?`"${this._colorToRgba(e.value)}"`:e.value}_colorToRgba(e){if(e.startsWith("#")){let n;const r=parseInt(e.substring(1,3),16),a=parseInt(e.substring(3,5),16),c=parseInt(e.substring(5,7),16),f=e.substring(7);return f?n=(255-parseInt(f,16))/255:n=1,`rgba(${Math.round(r)}, ${Math.round(a)}, ${Math.round(c)}, ${n.toFixed(2)})`}return e}_parserName(e,n=!1){const{exprs:r,varScope:a,hasMethod:c,arg:f}=e,p=r.map(E=>{var w;if(typeof E=="string")return E;const{column:b,line:T}=((w=E==null?void 0:E.ctx)==null?void 0:w.start)||{},x=`${T}_${b}`;return this._parserMethodElement(E,x)});if(e.expr&&p.unshift(`(${this._parserSingleExpression(e.expr)})`),e.isBuiltIn)p.join(".")==="strategy.opentrades"&&p.push("opentrades"),p.unshift(e.isConst?this._prefixNameConst:this._prefixNameVar);else if(Nn.includes(p[0])&&(p[0]=`$${p[0]}`),!c){const E={name:p[0],scope:a||(f==null?void 0:f.varScope)||0,isAgainAssign:n,isArg:f==null?void 0:f.isArg,functionName:this._currentFuncName};this._setDepend(E)}return p.join(".")}_setDepend(e){const n=e.name;for(const r of Object.values(this._dependsObj)){const a=r.get(n),c={...e};a&&a.isAgainAssign&&(c.isAgainAssign=!0),r.set(n,c)}}_parserMethodExpression(e){const{exprs:n,ctx:r}=e,{column:a,line:c}=r.start,f=`${c}_${a}`;let p=this._isInFunc?`$posStr + "__${f}"`:`"${f}"`;p=this._isInLoop?`$$count${this._count} + ${p}`:p;let E=!1;const T=n.map(x=>(x.hasMemberIndex&&(E=!0),this._parserMethodElement(x,p))).join(".");if(this._isInConditionalStmt&&E){const x=`$$result_${this._preRunMemberFuncsCount}`;this._preRunMemberFuncsCount++;const w=this._preRunMembersFuncs[this._blockCount]||[];return w.push(`const ${x} = ${T}`),this._preRunMembersFuncs[this._blockCount]=w,x}return T}_parserMethodElement(e,n){let r="",a="";const c={...e.args};e.hasMemberIndex&&(a=`${this._prefixNameVar}_position: ${e.position}`),e.expr&&(r=`(${this._parserSingleExpression(e.expr)})`),r=r?`${r}.${e.name}`:this._nameMap.get(e.name)||e.name;let f=!1;if(e.isBuiltIn){if(Sp.includes(r))r=`${r}.${r}`;else if(r==="max_bars_back"){const{name:E,varPos:b}=c.var||c.params[0];a=`var_name: "${b?`${E}_${b.lineNumber}_${b.column}`:E}"`}r.startsWith(z.INPUT)?(a=`index: ${this._inputCount}`,this._inputCount++):r.startsWith("request.")&&(f=!0),r=`${this._prefixNameFunc}.${r}`}else{const E=r.split(".");let b=E[0];Nn.includes(b)&&(b=`$${b}`,r=E.join("."))}if(e.selfArg){const E=r.split("."),b=E.length;Object.assign(c,{[e.selfArg.name]:{name:E.slice(0,b-1).join(".")}}),r=E[b-1],r=this._nameMap.get(r)||r,this._setDepend({name:E[0],scope:e.varScope||0})}r=`${r}${e.index?`$${e.index}`:""}`;const p=this._parserArguments(c,a,n,f,e.hasRequest,r);if(!e.isBuiltIn){const E=r.split(".");if(E.length>1?this._setDepend({name:E[0],scope:e.varScope||0}):this._setDepend({name:r,scope:0,hasRequest:e.hasRequest,isFunc:!0}),e.funcName){const b=this._nameMap.get(e.funcName)||e.funcName;this._setDepend({name:b,originName:r,scope:0,hasRequest:e.hasRequest,isFunc:!0})}}return r+p}_parserArguments(e,n,r,a=!1,c=!1,f){const p=e.params||[];delete e.params;const E=[],b=[];let T=[],x;const w=(R,v)=>{c&&(this._dependsObj[r]=new Map),a&&v==="expression"&&(this._dependsObj[`$arg_${v}${r}`]=new Map);let d=R.ruleType===ye.Brackethesized?this._parserBrackethesized(R):this._parserSingleExpression(R);if(v&&!["arg0, arg1, ...","number0, number1, ..."].includes(v)){R.isSourceType?E.push(`sourceTypeName: "${R.name}"`):v==="defval"&&f===`${this._prefixNameFunc}.input.enum`&&(x=this._enums.get(R.enumName));const g=this._requestParamsHandle(a,v,r,c,d,f);d=(g==null?void 0:g.code)||d,g!=null&&g.paramsExpr&&T.push(g==null?void 0:g.paramsExpr),E.push(`${v}: ${d}`)}else b.push(d)};for(const R of p)w(R,R.originName);for(const R of Object.keys(e))w(e[R],R);a&&this._isInFunc&&E.push("paramsExpr: $paramsExpr"),n&&E.push(n),x&&E.unshift(`options: [${x.join(", ")}]`);const F=T.length?`, [${this._isInFunc?"...$paramsExpr, ":""}${T.join(", ")}]`:"";return b.length?`({${E.join(", ")}}, [${b.join(", ")}], ${r}${F})`:E.length?`({${E.join(", ")}}, ${r}${F})`:`(${r}${F})`}_requestParamsHandle(e,n,r,a,c,f){if(e&&n==="expression"){const p=this._getDepends(`$arg_${n}${r}`),E=this._getExpressionContext(p);return E.push({scope:1,depends:p.map(b=>(b.isArg&&(b.functionName=this._currentFuncName),b)),code:c}),{code:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}else if(a){const p=this._getDepends(r),E=this._getExpressionContext(p);return E.push({scope:2,varNames:n,methodName:f,depends:p,dependSelf:p.some(b=>b.name===n),code:`${n} = ${c}`}),{paramsExpr:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}}_getExpressionContext(e){const n=[],r=[];return this._getDependsCode(e,n,r),n}_getDependsCode(e,n,r){var a,c;for(const f of e)if(!f.isArg){const p=this._codesCol[f.scope||0],E=p.find(T=>{var x;return((x=T.varNames)==null?void 0:x.includes(f.name))||T.funcName===f.name});E&&(r.includes(E)||(r.push(E),E.depends.length&&this._getDependsCode(E.depends,n,r),n.push({scope:f.scope||0,code:E.code,depends:E.depends,funcName:E.funcName,varNames:(a=E.varNames)==null?void 0:a.join(", ")})));const b=p.filter(T=>T.depends.some(x=>x.name===f.name&&x.scope===f.scope&&x.isAgainAssign));for(const T of b)r.includes(T)||(r.push(T),T.depends.length&&this._getDependsCode(T.depends,n,r),n.push({scope:f.scope||0,code:T.code,depends:T.depends,funcName:T.funcName,varNames:(c=T.varNames)==null?void 0:c.join(", ")}))}}_parserBrackethesized(e){return`[${e.exprs.map(r=>this._parserSingleExpression(r)).join(", ")}]`}_functionalProcess(e){return`(function () {
133
+ }`;return this._isInFunc=!1,this._currentFuncName="",this._codesCol[this._blockCount].push({funcName:n,depends:this._getDepends(n),hasRequest:e.hasRequest,code:c}),c}_parserParameters(e){return e.length?`{${e.map(n=>{const{name:r,defaultValue:a}=n;let c=r;if(a){const f=this._parserSingleExpression(a);c=`${c} = ${f}`}return c}).join(", ")}},`:""}_parserBlock(e,n=!1,r=!1){return r&&(this._isInFunc=!0),this._parserBlockLine(Array.isArray(e)?e:[e],n,r)}_addVarList(e){const n=this._varlist[this._blockCount]||{};if(e.names)for(const[r,a]of e.names.entries())n[a]=e.posList[r];else n[e.name]=e.pos;this._varlist[this._blockCount]=n}_parserDeclareAssign(e){var E;const{nameList:n,value:r}=e;if(n.name==="_")return"";const a=this._parserDeclareAssignNames(n);this._addVarList(n);const c={code:"",varNames:a.replace(/[\[\]]/g,"").split(", "),depends:[]};this._dependsObj[a]=new Map;const f=this._parserSingleExpression(r);let p=`let ${a} = ${f}`;if(n.declare){const b=`${n.pos.column}_${n.pos.lineNumber}`,T=this._isInFunc?`$posStr + "_${b}"`:`"${b}"`;p=`let ${a} = ${this._prefixNameVar}.getVarValue("${a}", ${T}, "${n.declare}") || ${this._prefixNameVar}.setVarValue("${a}", ${T}, ${f}, "${n.declare}")`}return c.code=p,c.depends=this._getDepends(a),(E=this._codesCol[this._blockCount])==null||E.push(c),p}_parserDeclareAssignNames(e){switch(e==null?void 0:e.ruleType){case"VarMultiple":return`[${e.names.map(n=>Nn.includes(n)?`$${n}`:n).join(", ")}]`;case"VarSingle":return Nn.includes(e.name)?`$${e.name}`:e.name}return""}_parserSingleExpression(e){if(!e)return"";const{exprs:n,operator:r}=e;let a="",c=this._isInConditionalStmt;switch(e.ruleType){case ye.MemberIndexExpression:return this._parserMemberIndexExpression(e);case ye.MethodExpression:return this._parserMethodExpression(e);case ye.UnaryExpression:return`${r}${this._parserSingleExpression(n[0])}`;case ye.NotExpression:return`!${this._parserSingleExpression(n[0])}`;case ye.AdditiveExpression:return this._parserAdditiveExpression(e);case ye.MultiplicativeExpression:case ye.RelationalExpression:case ye.EqualityExpression:return`${this._parserSingleExpression(n[0])} ${r} ${this._parserSingleExpression(n[1])}`;case ye.LogicalAndExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} && ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=c,a;case ye.LogicalOrExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} || ${this._parserSingleExpression(n[1])}`,this._isInConditionalStmt=c,a;case ye.TernaryExpression:return this._isInConditionalStmt=!0,a=`${this._parserSingleExpression(n[0])} ? ${this._parserSingleExpression(n[1])} : ${this._parserSingleExpression(n[2])}`,this._isInConditionalStmt=c,a;case ye.Name:return this._parserName(e);case ye.Literal:return this._parseLiteral(e);case ye.ParenthesizedExpression:return`(${this._parserSingleExpression(e.exprs)})`;default:return e.name||""}}_parserAdditiveExpression(e){const{exprs:n,operator:r}=e,a=this._parserSingleExpression(n[0]),c=this._parserSingleExpression(n[1]);return r==="-"?`${this._prefixNameVar}.sub(${a}, ${c})`:`${this._prefixNameVar}.add(${a}, ${c})`}_parserMemberIndexExpression(e){const{exprs:n,isInFunc:r,ctx:a}=e,c=n[0],f=this._parserSingleExpression(n[1]),p=this._parserSingleExpression(c),E=a.start.tokenIndex,b=r?`${this._prefixNameVar}_position`:E;if(c.ruleType===ye.Name&&!c.hasMethod){let T=this._blockCount;const x=c.name;for(c.isBuiltIn||this._setDepend({name:x,scope:c.varScope});T>=0;){const w=this._varlist[T]||{},F=w[x];if(F)return this._getUserVarMemberIndexs(F,x,T,f,r);if(c.isBuiltIn){const R=this._memberIndexList[0]||{};return R[x]=`${this._prefixNameVar}.setCacheData("${x}", ${p})`,`${this._prefixNameVar}.getCacheData("${x}", ${f}, ${p})`}if(x.includes(".")){const R=x.split(".")[0],v=w[R];if(v)return this._getUserVarMemberIndexs(v,x,T,f,r)}T--}return this._getOtherVarMemberIndexs(`${x}_${c.varScope||c.scope}`,x,c.varScope||c.scope,f,r)}else{const T=this._preRunMembers[this._blockCount]||[];T.push(`${this._prefixNameVar}.setCacheData("m${E}_" + ${b}, ${p})`),this._preRunMembers[this._blockCount]=T}return`${this._prefixNameVar}.getCacheData("m${E}_" + ${b}, ${f}, ${p})`}_getOtherVarMemberIndexs(e,n,r,a,c){const f=this._memberIndexList[r]||{};return e=c&&r!==0?`"${e}_" + $posStr`:`"${e}"`,f[e]=`${this._prefixNameVar}.setCacheData(${e}, ${n})`,this._memberIndexList[r]=f,`${this._prefixNameVar}.getCacheData(${e}, ${a}, ${n})`}_getUserVarMemberIndexs(e,n,r,a,c){return this._getOtherVarMemberIndexs(`${n}_${e.lineNumber}_${e.column}`,n,r,a,c)}_parseLiteral(e){return e.type.endsWith(z.COLOR)?`"${this._colorToRgba(e.value)}"`:e.value}_colorToRgba(e){if(e.startsWith("#")){let n;const r=parseInt(e.substring(1,3),16),a=parseInt(e.substring(3,5),16),c=parseInt(e.substring(5,7),16),f=e.substring(7);return f?n=(255-parseInt(f,16))/255:n=1,`rgba(${Math.round(r)}, ${Math.round(a)}, ${Math.round(c)}, ${n.toFixed(2)})`}return e}_parserName(e,n=!1){const{exprs:r,varScope:a,hasMethod:c,arg:f}=e,p=r.map(E=>{var w;if(typeof E=="string")return E;const{column:b,line:T}=((w=E==null?void 0:E.ctx)==null?void 0:w.start)||{},x=`${T}_${b}`;return this._parserMethodElement(E,x)});if(e.expr&&p.unshift(`(${this._parserSingleExpression(e.expr)})`),e.isBuiltIn)p.join(".")==="strategy.opentrades"&&p.push("opentrades"),p.unshift(e.isConst?this._prefixNameConst:this._prefixNameVar);else if(Nn.includes(p[0])&&(p[0]=`$${p[0]}`),!c){const E={name:p[0],scope:a||(f==null?void 0:f.varScope)||0,isAgainAssign:n,isArg:f==null?void 0:f.isArg,functionName:this._currentFuncName};this._setDepend(E)}return p.join(".")}_setDepend(e){const n=e.name;for(const r of Object.values(this._dependsObj)){const a=r.get(n),c={...e};a&&a.isAgainAssign&&(c.isAgainAssign=!0),r.set(n,c)}}_parserMethodExpression(e){const{exprs:n,ctx:r}=e,{column:a,line:c}=r.start,f=`${c}_${a}`;let p=this._isInFunc?`$posStr + "__${f}"`:`"${f}"`;p=this._isInLoop?`$$count${this._count} + ${p}`:p;let E=!1;const T=n.map(x=>(x.hasMemberIndex&&(E=!0),this._parserMethodElement(x,p))).join(".");if(this._isInConditionalStmt&&E){const x=`$$result_${this._preRunMemberFuncsCount}`;this._preRunMemberFuncsCount++;const w=this._preRunMembersFuncs[this._blockCount]||[];return w.push(`const ${x} = ${T}`),this._preRunMembersFuncs[this._blockCount]=w,x}return T}_parserMethodElement(e,n){let r="",a="";const c={...e.args};e.hasMemberIndex&&(a=`${this._prefixNameVar}_position: ${e.position}`),e.expr&&(r=`(${this._parserSingleExpression(e.expr)})`),r=r?`${r}.${e.name}`:this._nameMap.get(e.name)||e.name;let f=!1;if(e.isBuiltIn){if(Sp.includes(r))r=`${r}.${r}`;else if(r==="max_bars_back"){const{name:E,varPos:b}=c.var||c.params[0];a=`var_name: "${b?`${E}_${b.lineNumber}_${b.column}`:E}"`}r.startsWith(z.INPUT)?(a=`index: ${this._inputCount}`,this._inputCount++):r.startsWith("request.")&&(f=!0),r=`${this._prefixNameFunc}.${r}`}else{const E=r.split(".");let b=E[0];Nn.includes(b)&&(b=`$${b}`,r=E.join("."))}if(e.selfArg){const E=r.split("."),b=E.length;Object.assign(c,{[e.selfArg.name]:{name:E.slice(0,b-1).join(".")}}),r=E[b-1],r=this._nameMap.get(r)||r,this._setDepend({name:E[0],scope:e.varScope||0})}r=`${r}${e.index?`$${e.index}`:""}`;const p=this._parserArguments(c,a,n,f,e.hasRequest,r);if(!e.isBuiltIn){const E=r.split(".");if(E.length>1?this._setDepend({name:E[0],scope:e.varScope||0}):this._setDepend({name:r,scope:0,hasRequest:e.hasRequest,isFunc:!0}),e.funcName){const b=this._nameMap.get(e.funcName)||e.funcName;this._setDepend({name:b,originName:r,scope:0,hasRequest:e.hasRequest,isFunc:!0})}}return r+p}_parserArguments(e,n,r,a=!1,c=!1,f){const p=e.params||[];delete e.params;const E=[],b=[];let T=[],x;const w=(R,v)=>{c&&(this._dependsObj[r]=new Map),a&&v==="expression"&&(this._dependsObj[`$arg_${v}${r}`]=new Map);let d=R.ruleType===ye.Brackethesized?this._parserBrackethesized(R):this._parserSingleExpression(R);if(v&&!["arg0, arg1, ...","number0, number1, ..."].includes(v)){R.isSourceType?E.push(`sourceTypeName: "${R.name}"`):v==="defval"&&f===`${this._prefixNameFunc}.input.enum`&&(x=this._enums.get(R.enumName));const g=this._requestParamsHandle(a,v,r,c,d,f);d=(g==null?void 0:g.code)||d,g!=null&&g.paramsExpr&&T.push(g==null?void 0:g.paramsExpr),E.push(`${v}: ${d}`)}else b.push(d)};for(const R of p)w(R,R.originName);for(const R of Object.keys(e))w(e[R],R);a&&this._isInFunc&&E.push("paramsExpr: $paramsExpr"),n&&E.push(n),x&&E.unshift(`options: [${x.join(", ")}]`);const F=T.length?`, [${this._isInFunc?"...$paramsExpr, ":""}${T.join(", ")}]`:"";return b.length?`({${E.join(", ")}}, [${b.join(", ")}], ${r}${F})`:E.length?`({${E.join(", ")}}, ${r}${F})`:`(${r}${F})`}_requestParamsHandle(e,n,r,a,c,f){if(e&&n==="expression"){const p=this._getDepends(`$arg_${n}${r}`),E=this._getExpressionContext(p);return E.push({scope:1,depends:p.map(b=>(b.isArg&&(b.functionName=this._currentFuncName),b)),code:c}),{code:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}else if(a){const p=this._getDepends(r),E=this._getExpressionContext(p);return E.push({scope:2,varNames:n,methodName:f,depends:p,dependSelf:p.some(b=>b.name===n),code:`${n} = ${c}`}),{paramsExpr:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}}_getExpressionContext(e){const n=[],r=[];return this._getDependsCode(e,n,r),n}_getDependsCode(e,n,r){var a,c;for(const f of e)if(!f.isArg){const p=this._codesCol[f.scope||0],E=p.find(T=>{var x;return((x=T.varNames)==null?void 0:x.includes(f.name))||T.funcName===f.name});E&&(r.includes(E)||(r.push(E),E.depends.length&&this._getDependsCode(E.depends,n,r),n.push({scope:f.scope||0,code:E.code,depends:E.depends,funcName:E.funcName,varNames:(a=E.varNames)==null?void 0:a.join(", ")})));const b=p.filter(T=>T.depends.some(x=>x.name===f.name&&x.scope===f.scope&&x.isAgainAssign));for(const T of b)r.includes(T)||(r.push(T),T.depends.length&&this._getDependsCode(T.depends,n,r),n.push({scope:f.scope||0,code:T.code,depends:T.depends,funcName:T.funcName,varNames:(c=T.varNames)==null?void 0:c.join(", ")}))}}_parserBrackethesized(e){return`[${e.exprs.map(r=>this._parserSingleExpression(r)).join(", ")}]`}_functionalProcess(e){return`(function () {
131
134
  let $$_result=undefined;
132
135
  ${e}
133
136
  return $$_result
@@ -51,6 +51,7 @@ export default class ParseToJs {
51
51
  private _parserSingleExpression;
52
52
  private _parserAdditiveExpression;
53
53
  private _parserMemberIndexExpression;
54
+ private _getOtherVarMemberIndexs;
54
55
  private _getUserVarMemberIndexs;
55
56
  private _parseLiteral;
56
57
  private _colorToRgba;
@@ -67526,7 +67526,7 @@ Fp.onerror = (a) => {
67526
67526
  async function Rp(a) {
67527
67527
  return await Ja.setInlayHints(a);
67528
67528
  }
67529
- const Bp = Hi(Fp), Kp = Hi(new Worker(new URL("" + new URL("assets/parserTccWorker-f_NwLNZe.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
67529
+ const Bp = Hi(Fp), Kp = Hi(new Worker(new URL("" + new URL("assets/parserTccWorker-Dm4K7reM.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
67530
67530
  async function ch(a, n = !1) {
67531
67531
  const { functions: r, types: o, constants: l, variables: c, methods: m } = bt;
67532
67532
  return await Kp.parseTcc(a, n, ji(Rp), { functions: Object.fromEntries(r), methods: Object.fromEntries(m), types: Object.fromEntries(o), constants: Object.fromEntries(l), variables: Object.fromEntries(c) });
@@ -141,7 +141,7 @@ function print() { __p += __j.call(arguments, '') }
141
141
  * @license
142
142
  * Copyright 2019 Google LLC
143
143
  * SPDX-License-Identifier: Apache-2.0
144
- */const _o=Symbol("Comlink.proxy"),nm=Symbol("Comlink.endpoint"),im=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",om={canHandle:a=>fo(a)&&a[_o],serialize(a){const{port1:n,port2:s}=new MessageChannel;return bo(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},lm={canHandle:a=>fo(a)&&Ys in a,serialize({value:a}){let n;return a instanceof Error?n={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:n={isError:!1,value:a},[n,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},go=new Map([["proxy",om],["throw",lm]]);function cm(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function bo(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(l){if(!l||!l.data)return;if(!cm(s,l.origin)){console.warn(`Invalid origin '${l.origin}' for comlink proxy`);return}const{id:c,type:m,path:_}=Object.assign({path:[]},l.data),g=(l.data.argumentList||[]).map(gr);let b;try{const h=_.slice(0,-1).reduce((P,B)=>P[B],a),T=_.reduce((P,B)=>P[B],a);switch(m){case"GET":b=T;break;case"SET":h[_.slice(-1)[0]]=gr(l.data.value),b=!0;break;case"APPLY":b=T.apply(h,g);break;case"CONSTRUCT":{const P=new T(...g);b=gn(P)}break;case"ENDPOINT":{const{port1:P,port2:B}=new MessageChannel;bo(a,B),b=ym(P,[P])}break;case"RELEASE":b=void 0;break;default:return}}catch(h){b={value:h,[Ys]:0}}Promise.resolve(b).catch(h=>({value:h,[Ys]:0})).then(h=>{const[T,P]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:c}),P),m==="RELEASE"&&(n.removeEventListener("message",o),xo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,P]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:c}),P)})}),n.start&&n.start()}function pm(a){return a.constructor.name==="MessagePort"}function xo(a){pm(a)&&a.close()}function _n(a,n){return fn(a,[],n)}function Qs(a){if(a)throw new Error("Proxy has been released and is not useable")}function ho(a){return Lr(a,{type:"RELEASE"}).then(()=>{xo(a)})}const Zs=new WeakMap,Js="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const n=(Zs.get(a)||0)-1;Zs.set(a,n),n===0&&ho(a)});function dm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function mm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const l=new Proxy(s,{get(c,m){if(Qs(o),m===im)return()=>{mm(l),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>l};const _=Lr(a,{type:"GET",path:n.map(g=>g.toString())}).then(gr);return _.then.bind(_)}return fn(a,[...n,m])},set(c,m,_){Qs(o);const[g,b]=ea(_);return Lr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:g},b).then(gr)},apply(c,m,_){Qs(o);const g=n[n.length-1];if(g===nm)return Lr(a,{type:"ENDPOINT"}).then(gr);if(g==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(_);return Lr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(gr)},construct(c,m){Qs(o);const[_,g]=wo(m);return Lr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:_},g).then(gr)}});return dm(l,a),l}function um(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),um(n.map(s=>s[1]))]}const vo=new WeakMap;function ym(a,n){return vo.set(a,n),a}function gn(a){return Object.assign(a,{[_o]:!0})}function ea(a){for(const[n,s]of go)if(s.canHandle(a)){const[o,l]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},l]}return[{type:"RAW",value:a},vo.get(a)||[]]}function gr(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Lr(a,n,s){return new Promise(o=>{const l=_m();a.addEventListener("message",function c(m){!m.data||!m.data.id||m.data.id!==l||(a.removeEventListener("message",c),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:l},n),s)})}function _m(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const To=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-D9ObnG9j.js").href:new URL("assets/scriptsRunWorker-D9ObnG9j.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});To.onerror=a=>{console.error(a)};async function Do(a){return await Gs.setInlayHints(a)}const ko=_n(To),Io=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-f_NwLNZe.js").href:new URL("assets/parserTccWorker-f_NwLNZe.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function Ao(a,n=!1){const{functions:s,types:o,constants:l,variables:c,methods:m}=lt;return await Io.parseTcc(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(l),variables:Object.fromEntries(c)})}async function fm(a,n){const{functions:s,types:o,constants:l,variables:c,methods:m}=lt;return await Io.parseLibraryCode(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(l),variables:Object.fromEntries(c)})}async function qo(a,n,s=!0){return await ko.runScript(a,n,s)}async function gm(a){return await ko.removeScript(a)}function bm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}self.MonacoEnvironment={getWorker(){return new bm({name:"Editor Worker"})}},sn.config({monaco:pp});let Co={};const xm=(a,n)=>{const{height:s,width:o,theme:l,options:c,hasDiff:m,readOnly:_,defaultValue:g,onChange:b,onLinkOpen:h,onDeclareConfigChange:T,onCursorPositionChange:P,onActionTrigger:B,onEditorDidMount:R}=a,N=O.useRef(null),W=O.useRef(null);O.useImperativeHandle(n,()=>({setOriginalScript(q){var U;(U=N.current)==null||U.setOriginalScript(q)},setScript(q){var U;(U=N.current)==null||U.setValue(q)},gotoLine(){var q;(q=N.current)==null||q.gotoLine()},getEditorLayout(){var q;return(q=N.current)==null?void 0:q.getEditorLayout()},setPosition(q,U){var j;(j=N.current)==null||j.setPosition({column:q,lineNumber:U})},setModelMarkers(q){var U;(U=N.current)==null||U.setModelMarkers(q)}})),O.useEffect(()=>{var q,U;m?(U=N.current)==null||U.addDiffDecorations():(q=N.current)==null||q.removeDiffDecorations()},[m]),O.useEffect(()=>{var q;(q=N.current)==null||q.updateActionTrigger(B)},[B]),O.useEffect(()=>{var q;h&&((q=N.current)==null||q.addLinkOpenFunc(h))},[h]);function V(q,U){var ae,ye,le;zt.initBuiltinsTrees(),Gs.setEditor(q),N.current=new am(q,U,B),h&&((ae=N.current)==null||ae.addLinkOpenFunc(h)),m&&((ye=N.current)==null||ye.addDiffDecorations()),zd(q),(le=N.current)==null||le.setEditorLayout(Number(s));const j=q.getValue();N.current.onChangeCursorPosition(P),b&&b(j),!_&&G(j),R&&R()}const G=O.useCallback(async q=>{var ht;const U=Date.now(),{errors:j,functions:ae,methods:ye,types:le,variables:xt,overloadsFuncs:St,imports:$e,preParserCode:Be,enums:Q}=await Ao(q),ge=new Map(Object.entries(ae)),Ne=new Map(Object.entries(ye)),Pe=new Map(Object.entries(le)),ct=new Map(Object.entries(xt)),Et=new Map(Object.entries($e)),te=new Map(Object.entries(Q));Er.setUserDefined({functions:ge,methods:Ne,types:Pe,variables:ct,imports:Et,enums:te},St),zt.setUserDefind(ge,Pe,ct,Ne,te);const he=j.map(Ae=>({...Ae,severity:Ae.type||ke.MarkerSeverity.Error}));if(_)return;try{if(!j.length&&Be){const Ae=await qo(Be,{isPreParser:!0});io.isEqual(Ae,Co)||(Co=Ae,T&&T(Ae))}}catch(Ae){console.log(Ae),j.push({message:Ae.message,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}(ht=N.current)==null||ht.setModelMarkers(he);const Fe=Date.now();console.log((Fe-U)/1e3)},[T,_]),F=O.useMemo(()=>io.debounce(G,1500),[G]);function k(q){var U;if(_){G(q||"");return}Gs.clearInlayHints(),(U=N.current)==null||U.setModelMarkers([]),q!==void 0&&(b&&b(q),F(q))}return O.useEffect(()=>{const q=()=>{window.requestAnimationFrame(()=>{var ae,ye;const j=(ae=W.current)==null?void 0:ae.getBoundingClientRect();(ye=N.current)==null||ye.setEditorLayout((j==null?void 0:j.height)||0,j==null?void 0:j.width)})},U=new ResizeObserver(q);return W.current&&U.observe(W.current),()=>{W.current&&U.unobserve(W.current),U.disconnect()}},[]),L.jsx("div",{ref:W,children:L.jsx(xd,{height:s,width:o||"100%",defaultLanguage:Ee,defaultValue:g||`indicator("我的脚本")
144
+ */const _o=Symbol("Comlink.proxy"),nm=Symbol("Comlink.endpoint"),im=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",om={canHandle:a=>fo(a)&&a[_o],serialize(a){const{port1:n,port2:s}=new MessageChannel;return bo(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},lm={canHandle:a=>fo(a)&&Ys in a,serialize({value:a}){let n;return a instanceof Error?n={isError:!0,value:{message:a.message,name:a.name,stack:a.stack}}:n={isError:!1,value:a},[n,[]]},deserialize(a){throw a.isError?Object.assign(new Error(a.value.message),a.value):a.value}},go=new Map([["proxy",om],["throw",lm]]);function cm(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function bo(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(l){if(!l||!l.data)return;if(!cm(s,l.origin)){console.warn(`Invalid origin '${l.origin}' for comlink proxy`);return}const{id:c,type:m,path:_}=Object.assign({path:[]},l.data),g=(l.data.argumentList||[]).map(gr);let b;try{const h=_.slice(0,-1).reduce((P,B)=>P[B],a),T=_.reduce((P,B)=>P[B],a);switch(m){case"GET":b=T;break;case"SET":h[_.slice(-1)[0]]=gr(l.data.value),b=!0;break;case"APPLY":b=T.apply(h,g);break;case"CONSTRUCT":{const P=new T(...g);b=gn(P)}break;case"ENDPOINT":{const{port1:P,port2:B}=new MessageChannel;bo(a,B),b=ym(P,[P])}break;case"RELEASE":b=void 0;break;default:return}}catch(h){b={value:h,[Ys]:0}}Promise.resolve(b).catch(h=>({value:h,[Ys]:0})).then(h=>{const[T,P]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:c}),P),m==="RELEASE"&&(n.removeEventListener("message",o),xo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,P]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:c}),P)})}),n.start&&n.start()}function pm(a){return a.constructor.name==="MessagePort"}function xo(a){pm(a)&&a.close()}function _n(a,n){return fn(a,[],n)}function Qs(a){if(a)throw new Error("Proxy has been released and is not useable")}function ho(a){return Lr(a,{type:"RELEASE"}).then(()=>{xo(a)})}const Zs=new WeakMap,Js="FinalizationRegistry"in globalThis&&new FinalizationRegistry(a=>{const n=(Zs.get(a)||0)-1;Zs.set(a,n),n===0&&ho(a)});function dm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function mm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const l=new Proxy(s,{get(c,m){if(Qs(o),m===im)return()=>{mm(l),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>l};const _=Lr(a,{type:"GET",path:n.map(g=>g.toString())}).then(gr);return _.then.bind(_)}return fn(a,[...n,m])},set(c,m,_){Qs(o);const[g,b]=ea(_);return Lr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:g},b).then(gr)},apply(c,m,_){Qs(o);const g=n[n.length-1];if(g===nm)return Lr(a,{type:"ENDPOINT"}).then(gr);if(g==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(_);return Lr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(gr)},construct(c,m){Qs(o);const[_,g]=wo(m);return Lr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:_},g).then(gr)}});return dm(l,a),l}function um(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),um(n.map(s=>s[1]))]}const vo=new WeakMap;function ym(a,n){return vo.set(a,n),a}function gn(a){return Object.assign(a,{[_o]:!0})}function ea(a){for(const[n,s]of go)if(s.canHandle(a)){const[o,l]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},l]}return[{type:"RAW",value:a},vo.get(a)||[]]}function gr(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Lr(a,n,s){return new Promise(o=>{const l=_m();a.addEventListener("message",function c(m){!m.data||!m.data.id||m.data.id!==l||(a.removeEventListener("message",c),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:l},n),s)})}function _m(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const To=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-D9ObnG9j.js").href:new URL("assets/scriptsRunWorker-D9ObnG9j.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});To.onerror=a=>{console.error(a)};async function Do(a){return await Gs.setInlayHints(a)}const ko=_n(To),Io=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-Dm4K7reM.js").href:new URL("assets/parserTccWorker-Dm4K7reM.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Us&&Us.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function Ao(a,n=!1){const{functions:s,types:o,constants:l,variables:c,methods:m}=lt;return await Io.parseTcc(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(l),variables:Object.fromEntries(c)})}async function fm(a,n){const{functions:s,types:o,constants:l,variables:c,methods:m}=lt;return await Io.parseLibraryCode(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(l),variables:Object.fromEntries(c)})}async function qo(a,n,s=!0){return await ko.runScript(a,n,s)}async function gm(a){return await ko.removeScript(a)}function bm(a){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/editor.worker-CT5Cb1wO.js").href:new URL("assets/editor.worker-CT5Cb1wO.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.src||document.baseURI).href),{name:a==null?void 0:a.name})}self.MonacoEnvironment={getWorker(){return new bm({name:"Editor Worker"})}},sn.config({monaco:pp});let Co={};const xm=(a,n)=>{const{height:s,width:o,theme:l,options:c,hasDiff:m,readOnly:_,defaultValue:g,onChange:b,onLinkOpen:h,onDeclareConfigChange:T,onCursorPositionChange:P,onActionTrigger:B,onEditorDidMount:R}=a,N=O.useRef(null),W=O.useRef(null);O.useImperativeHandle(n,()=>({setOriginalScript(q){var U;(U=N.current)==null||U.setOriginalScript(q)},setScript(q){var U;(U=N.current)==null||U.setValue(q)},gotoLine(){var q;(q=N.current)==null||q.gotoLine()},getEditorLayout(){var q;return(q=N.current)==null?void 0:q.getEditorLayout()},setPosition(q,U){var j;(j=N.current)==null||j.setPosition({column:q,lineNumber:U})},setModelMarkers(q){var U;(U=N.current)==null||U.setModelMarkers(q)}})),O.useEffect(()=>{var q,U;m?(U=N.current)==null||U.addDiffDecorations():(q=N.current)==null||q.removeDiffDecorations()},[m]),O.useEffect(()=>{var q;(q=N.current)==null||q.updateActionTrigger(B)},[B]),O.useEffect(()=>{var q;h&&((q=N.current)==null||q.addLinkOpenFunc(h))},[h]);function V(q,U){var ae,ye,le;zt.initBuiltinsTrees(),Gs.setEditor(q),N.current=new am(q,U,B),h&&((ae=N.current)==null||ae.addLinkOpenFunc(h)),m&&((ye=N.current)==null||ye.addDiffDecorations()),zd(q),(le=N.current)==null||le.setEditorLayout(Number(s));const j=q.getValue();N.current.onChangeCursorPosition(P),b&&b(j),!_&&G(j),R&&R()}const G=O.useCallback(async q=>{var ht;const U=Date.now(),{errors:j,functions:ae,methods:ye,types:le,variables:xt,overloadsFuncs:St,imports:$e,preParserCode:Be,enums:Q}=await Ao(q),ge=new Map(Object.entries(ae)),Ne=new Map(Object.entries(ye)),Pe=new Map(Object.entries(le)),ct=new Map(Object.entries(xt)),Et=new Map(Object.entries($e)),te=new Map(Object.entries(Q));Er.setUserDefined({functions:ge,methods:Ne,types:Pe,variables:ct,imports:Et,enums:te},St),zt.setUserDefind(ge,Pe,ct,Ne,te);const he=j.map(Ae=>({...Ae,severity:Ae.type||ke.MarkerSeverity.Error}));if(_)return;try{if(!j.length&&Be){const Ae=await qo(Be,{isPreParser:!0});io.isEqual(Ae,Co)||(Co=Ae,T&&T(Ae))}}catch(Ae){console.log(Ae),j.push({message:Ae.message,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}(ht=N.current)==null||ht.setModelMarkers(he);const Fe=Date.now();console.log((Fe-U)/1e3)},[T,_]),F=O.useMemo(()=>io.debounce(G,1500),[G]);function k(q){var U;if(_){G(q||"");return}Gs.clearInlayHints(),(U=N.current)==null||U.setModelMarkers([]),q!==void 0&&(b&&b(q),F(q))}return O.useEffect(()=>{const q=()=>{window.requestAnimationFrame(()=>{var ae,ye;const j=(ae=W.current)==null?void 0:ae.getBoundingClientRect();(ye=N.current)==null||ye.setEditorLayout((j==null?void 0:j.height)||0,j==null?void 0:j.width)})},U=new ResizeObserver(q);return W.current&&U.observe(W.current),()=>{W.current&&U.unobserve(W.current),U.disconnect()}},[]),L.jsx("div",{ref:W,children:L.jsx(xd,{height:s,width:o||"100%",defaultLanguage:Ee,defaultValue:g||`indicator("我的脚本")
145
145
  plot(close)
146
146
  `,theme:l||"vs-dark",className:`tvue-script ${l||"vs-dark"}`,options:{colorDecorators:!0,useShadowDOM:!1,matchOnWordStartOnly:!0,automaticLayout:!1,suggest:{filterGraceful:!0},fontSize:13,..._?Rd:{},readOnlyMessage:{value:"该脚本是只读的。它无法被编辑。"},...c},onMount:V,onChange:k})})},hm=O.forwardRef(xm),wm=a=>{const{theme:n,modified:s,original:o,height:l,width:c,renderSideBySide:m=!0}=a,_=O.useCallback((g,b)=>{b.languages.register({id:Ee}),b.editor.defineTheme("vs-dark",cn),b.editor.defineTheme("vs",ln),b.languages.setMonarchTokensProvider(Ee,Nr),b.languages.setLanguageConfiguration(Ee,on)},[]);return L.jsx(yd,{height:l||"90vh",width:c||"100%",theme:n||"vs-dark",options:{readOnly:!0,renderSideBySide:m,scrollBeyondLastLine:!1},language:Ee,modified:s,original:o,onMount:_})};A.VMarkerSeverity=void 0,function(a){a[a.Hint=1]="Hint",a[a.Info=2]="Info",a[a.Warning=4]="Warning",a[a.Error=8]="Error"}(A.VMarkerSeverity||(A.VMarkerSeverity={}));var ta={},vm=function(){var a=document.getSelection();if(!a.rangeCount)return function(){};for(var n=document.activeElement,s=[],o=0;o<a.rangeCount;o++)s.push(a.getRangeAt(o));switch(n.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":n.blur();break;default:n=null;break}return a.removeAllRanges(),function(){a.type==="Caret"&&a.removeAllRanges(),a.rangeCount||s.forEach(function(l){a.addRange(l)}),n&&n.focus()}},Tm=vm,zo={"text/plain":"Text","text/html":"Url",default:"Text"},Dm="Copy to clipboard: #{key}, Enter";function km(a){var n=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return a.replace(/#{\s*key\s*}/g,n)}function Im(a,n){var s,o,l,c,m,_,g=!1;n||(n={}),s=n.debug||!1;try{l=Tm(),c=document.createRange(),m=document.getSelection(),_=document.createElement("span"),_.textContent=a,_.ariaHidden="true",_.style.all="unset",_.style.position="fixed",_.style.top=0,_.style.clip="rect(0, 0, 0, 0)",_.style.whiteSpace="pre",_.style.webkitUserSelect="text",_.style.MozUserSelect="text",_.style.msUserSelect="text",_.style.userSelect="text",_.addEventListener("copy",function(h){if(h.stopPropagation(),n.format)if(h.preventDefault(),typeof h.clipboardData>"u"){s&&console.warn("unable to use e.clipboardData"),s&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var T=zo[n.format]||zo.default;window.clipboardData.setData(T,a)}else h.clipboardData.clearData(),h.clipboardData.setData(n.format,a);n.onCopy&&(h.preventDefault(),n.onCopy(h.clipboardData))}),document.body.appendChild(_),c.selectNodeContents(_),m.addRange(c);var b=document.execCommand("copy");if(!b)throw new Error("copy command was unsuccessful");g=!0}catch(h){s&&console.error("unable to copy using execCommand: ",h),s&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(n.format||"text",a),n.onCopy&&n.onCopy(window.clipboardData),g=!0}catch(T){s&&console.error("unable to copy using clipboardData: ",T),s&&console.error("falling back to prompt"),o=km("message"in n?n.message:Dm),window.prompt(o,a)}}finally{m&&(typeof m.removeRange=="function"?m.removeRange(c):m.removeAllRanges()),_&&document.body.removeChild(_),l()}return g}var Am=Im;function bn(a){"@babel/helpers - typeof";return bn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},bn(a)}Object.defineProperty(ta,"__esModule",{value:!0}),ta.CopyToClipboard=void 0;var ra=So(O),qm=So(Am),Cm=["text","onCopy","options","children"];function So(a){return a&&a.__esModule?a:{default:a}}function Eo(a,n){var s=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);n&&(o=o.filter(function(l){return Object.getOwnPropertyDescriptor(a,l).enumerable})),s.push.apply(s,o)}return s}function No(a){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Eo(Object(s),!0).forEach(function(o){hn(a,o,s[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):Eo(Object(s)).forEach(function(o){Object.defineProperty(a,o,Object.getOwnPropertyDescriptor(s,o))})}return a}function zm(a,n){if(a==null)return{};var s=Sm(a,n),o,l;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(a);for(l=0;l<c.length;l++)o=c[l],!(n.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(a,o)&&(s[o]=a[o])}return s}function Sm(a,n){if(a==null)return{};var s={},o=Object.keys(a),l,c;for(c=0;c<o.length;c++)l=o[c],!(n.indexOf(l)>=0)&&(s[l]=a[l]);return s}function Em(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function Lo(a,n){for(var s=0;s<n.length;s++){var o=n[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(a,o.key,o)}}function Nm(a,n,s){return n&&Lo(a.prototype,n),s&&Lo(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function Lm(a,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(n&&n.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),n&&xn(a,n)}function xn(a,n){return xn=Object.setPrototypeOf||function(o,l){return o.__proto__=l,o},xn(a,n)}function Mm(a){var n=Om();return function(){var o=sa(a),l;if(n){var c=sa(this).constructor;l=Reflect.construct(o,arguments,c)}else l=o.apply(this,arguments);return Pm(this,l)}}function Pm(a,n){if(n&&(bn(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Mo(a)}function Mo(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Om(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sa(a){return sa=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},sa(a)}function hn(a,n,s){return n in a?Object.defineProperty(a,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[n]=s,a}var Po=function(a){Lm(s,a);var n=Mm(s);function s(){var o;Em(this,s);for(var l=arguments.length,c=new Array(l),m=0;m<l;m++)c[m]=arguments[m];return o=n.call.apply(n,[this].concat(c)),hn(Mo(o),"onClick",function(_){var g=o.props,b=g.text,h=g.onCopy,T=g.children,P=g.options,B=ra.default.Children.only(T),R=(0,qm.default)(b,P);h&&h(b,R),B&&B.props&&typeof B.props.onClick=="function"&&B.props.onClick(_)}),o}return Nm(s,[{key:"render",value:function(){var l=this.props;l.text,l.onCopy,l.options;var c=l.children,m=zm(l,Cm),_=ra.default.Children.only(c);return ra.default.cloneElement(_,No(No({},m),{},{onClick:this.onClick}))}}]),s}(ra.default.PureComponent);ta.CopyToClipboard=Po,hn(Po,"defaultProps",{onCopy:void 0,options:void 0});var Rm=ta,wn=Rm.CopyToClipboard;wn.CopyToClipboard=wn;var Fm=wn;const vn=dp(Fm);async function Bm(a,n=0){const s=a[n];if(!s)return;const{name:o,args:l,type:c,desc:m,examples:_,remarks:g,seeAlso:b,syntax:h,detailedDesc:T,fields:P,returns:B}=s,R={name:o};if(a.length>1&&(R.overloads=`${a.length} overloads`),c&&(R.type=c),l&&(R.name=`${o}()`,R.args=l.map(N=>{const{name:W,desc:V,displayType:G}=N;return{label:`${W} (${G})`,desc:V&&br(V)}})),m&&(R.desc=m.map(N=>br(N))),_&&(R.originalExample=_.join(`
147
147
  `),R.examples=await ke.editor.colorize(R.originalExample,Ee,{tabSize:4})),T){R.detailedDesc=[];for(const N of T){const{desc:W,examples:V}=N;let G=W.map(q=>br(q)),F,k;V&&(k=V.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guihz/trading-vue-editor-tes",
3
- "version": "0.0.117",
3
+ "version": "0.0.119",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"