@guihz/trading-vue-editor-tes 0.0.135 → 0.0.136

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,11 +31,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
31
31
  `)}`,this._preRunMembers[this._blockCount]=[]),a&&(r=`${a}${n?`
32
32
  /****/
33
33
  `:`;
34
- `}${r}`),r}_parserEnumStatement(e){let{name:n,fields:r}=e;const a=[],c=[];for(const d of r){const{name:E,value:b}=d,T=b===void 0?`"${E}"`:b;c.push(T),a.push(`${E}: ${T}`)}Nn.includes(n)&&(n=`$${n}`),this._enums.set(n,c);const h=`const ${n} = {${a.join(", ")}}`;return this._codesCol[this._blockCount].push({code:h,varNames:[n],depends:[]}),h}_parserTypeStatement(e){const n=[],r=[];for(const h of e.fields){const{name:d,value:E}=h;h.isVarip&&r.push(`"${d}"`),n.push(`${d}: ${E?this._parserSingleExpression(E):"undefined"}`)}this._userTypes.push(e.name);let a=e.name;Nn.includes(a)&&(a=`$${a}`);const c=`const ${a} = ${this._prefixNameVar}.getTypeInstance({${n.join(", ")}}, [${r.join()}])`;return this._codesCol[this._blockCount].push({code:c,varNames:[a],depends:[]}),c}_parserVarBlockStmt(e){const{nameList:n,value:r}=e;this._addVarList(n);const a=this._parserDeclareAssignNames(n);this._dependsObj[a]=new Map;const c=this._parserStmt(r,!0),h=c.split(`
34
+ `}${r}`),r}_parserEnumStatement(e){let{name:n,fields:r}=e;const a=[],c=[];for(const d of r){const{name:E,value:b}=d,T=b===void 0?`"${E}"`:b;c.push(T),a.push(`${E}: ${T}`)}Nn.includes(n)&&(n=`$${n}`),this._enums.set(n,c);const h=`const ${n} = {${a.join(", ")}}`;return this._codesCol[this._blockCount].push({code:h,varNames:[n],depends:[]}),h}_parserTypeStatement(e){const n=[],r=[];for(const h of e.fields){const{name:d,value:E}=h;h.isVarip&&r.push(`"${d}"`),n.push(`${d}: ${E?this._parserSingleExpression(E):"undefined"}`)}this._userTypes.push(e.name);let a=e.name;Nn.includes(a)&&(a=`$${a}`);const c=`const ${a} = ${this._prefixNameVar}.getTypeInstance({${n.join(", ")}}, [${r.join()}])`;return this._codesCol[this._blockCount].push({code:c,varNames:[a],depends:[]}),c}_parserVarBlockStmt(e){const{nameList:n,value:r}=e;this._addVarList(n);const a=this._parserDeclareAssignNames(n),c=`$${a}_${this._blockCount}`;this._dependsObj[c]=new Map;const h=this._parserStmt(r,!0),d=h.split(`
35
35
  /****/
36
- `);let d="";h.length>1?d=`${h[0]}
37
- let ${a} = ${h[1]}
38
- `:d=`let ${a} = ${c}`;const E={code:d,varNames:a.replace(/[\[\]]/g,"").split(", "),depends:this._getDepends(a)};return this._codesCol[this._blockCount].push(E),d}_getDepends(e){const n=[];for(const[r,a]of this._dependsObj[e])(a.scope||0)>this._blockCount||n.push(a);return delete this._dependsObj[e],n}_parserForToStatement(e,n=!1){let{numerical:r,block:a,name:c}=e;const[h,d,E]=r,b=this._isInLoop;this._isInLoop=!0;const T=`$start${this._count++}`,x=`$$count${this._count}`,w=`$forTo${this._blockCount}`;n||(this._dependsObj[w]=new Map);const F=this._parserSingleExpression(h),R=this._parserSingleExpression(d),v=E?this._parserSingleExpression(E):"",p=this._parserBlockLine(a,n,!1,!0);Nn.includes(c)&&(c=`$${c}`);const g=`const ${T} = Date.now()`,A=`for (let ${c}=${F}; ${c}>=(${R}); ${c}-=(${v||"1"})){
36
+ `);let E="";d.length>1?E=`${d[0]}
37
+ let ${a} = ${d[1]}
38
+ `:E=`let ${a} = ${h}`;const b={code:E,varNames:a.replace(/[\[\]]/g,"").split(", "),depends:this._getDepends(c)};return this._codesCol[this._blockCount].push(b),E}_getDepends(e){const n=[];for(const[r,a]of this._dependsObj[e])(a.scope||0)>this._blockCount||n.push(a);return delete this._dependsObj[e],n}_parserForToStatement(e,n=!1){let{numerical:r,block:a,name:c}=e;const[h,d,E]=r,b=this._isInLoop;this._isInLoop=!0;const T=`$start${this._count++}`,x=`$$count${this._count}`,w=`$forTo${this._blockCount}`;n||(this._dependsObj[w]=new Map);const F=this._parserSingleExpression(h),R=this._parserSingleExpression(d),v=E?this._parserSingleExpression(E):"",p=this._parserBlockLine(a,n,!1,!0);Nn.includes(c)&&(c=`$${c}`);const g=`const ${T} = Date.now()`,A=`for (let ${c}=${F}; ${c}>=(${R}); ${c}-=(${v||"1"})){
39
39
  if (Date.now() - ${T} > 500) {
40
40
  throw new Error('${xe.loopRuntimeErr}')
41
41
  }
@@ -129,7 +129,7 @@ ${this._prefixNameVar}.againAssignParse(${E}, ${F});
129
129
  })
130
130
  `}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];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}) => {
131
131
  ${this._parserBlock(e.block,!0,!0)}
132
- }`;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 h=this._parserSingleExpression(a);c=`${c} = ${h}`}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 h=this._parserSingleExpression(r);let d=`let ${a} = ${h}`;if(n.declare){const b=`${n.pos.column}_${n.pos.lineNumber}`,T=this._isInFunc?`$posStr + "_${b}"`:`"${b}"`;d=`let ${a} = ${this._prefixNameVar}.getVarValue("${a}", ${T}, "${n.declare}") || ${this._prefixNameVar}.setVarValue("${a}", ${T}, ${h}, "${n.declare}")`}return c.code=d,c.depends=this._getDepends(a),(E=this._codesCol[this._blockCount])==null||E.push(c),d}_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],h=this._parserSingleExpression(n[1]);let d=this._parserSingleExpression(c);const 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,h,r);if(c.isBuiltIn){const R=this._memberIndexList[0]||{};return R[x]=`${this._prefixNameVar}.setCacheData("${x}", ${d})`,`${this._prefixNameVar}.getCacheData("${x}", ${h}, ${d})`}if(x.includes(".")){const R=x.split(".")[0],v=w[R];if(v)return this._getUserVarMemberIndexs(v,x,T,h,r)}T--}return this._getOtherVarMemberIndexs(`${x}_${c.varScope||c.scope}`,x,c.varScope||c.scope,h,r)}else{const T=this._preRunMembers[this._blockCount]||[],x=`$$m${E}_${b}`;T.push(`const ${x} = ${d};
132
+ }`;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 h=this._parserSingleExpression(a);c=`${c} = ${h}`}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 b;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:[]},h=`$${a}_${this._blockCount}`;this._dependsObj[h]=new Map;const d=this._parserSingleExpression(r);let E=`let ${a} = ${d}`;if(n.declare){const T=`${n.pos.column}_${n.pos.lineNumber}`,x=this._isInFunc?`$posStr + "_${T}"`:`"${T}"`;E=`let ${a} = ${this._prefixNameVar}.getVarValue("${a}", ${x}, "${n.declare}") || ${this._prefixNameVar}.setVarValue("${a}", ${x}, ${d}, "${n.declare}")`}return c.code=E,c.depends=this._getDepends(h),(b=this._codesCol[this._blockCount])==null||b.push(c),E}_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],h=this._parserSingleExpression(n[1]);let d=this._parserSingleExpression(c);const 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,h,r);if(c.isBuiltIn){const R=this._memberIndexList[0]||{};return R[x]=`${this._prefixNameVar}.setCacheData("${x}", ${d})`,`${this._prefixNameVar}.getCacheData("${x}", ${h}, ${d})`}if(x.includes(".")){const R=x.split(".")[0],v=w[R];if(v)return this._getUserVarMemberIndexs(v,x,T,h,r)}T--}return this._getOtherVarMemberIndexs(`${x}_${c.varScope||c.scope}`,x,c.varScope||c.scope,h,r)}else{const T=this._preRunMembers[this._blockCount]||[],x=`$$m${E}_${b}`;T.push(`const ${x} = ${d};
133
133
  ${this._prefixNameVar}.setCacheData("m${E}_" + ${b}, ${x})`),this._preRunMembers[this._blockCount]=T}return`${this._prefixNameVar}.getCacheData("m${E}_" + ${b}, ${h}, ${d})`}_getOtherVarMemberIndexs(e,n,r,a,c){const h=this._memberIndexList[r]||{};return e=c&&r!==0?`"${e}_" + $posStr`:`"${e}"`,h[e]=`${this._prefixNameVar}.setCacheData(${e}, ${n})`,this._memberIndexList[r]=h,`${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),h=e.substring(7);return h?n=parseInt(h,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:h}=e,d=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&&d.unshift(`(${this._parserSingleExpression(e.expr)})`),e.isBuiltIn)d.join(".")==="strategy.opentrades"&&d.push("opentrades"),d.unshift(e.isConst?this._prefixNameConst:this._prefixNameVar);else if(Nn.includes(d[0])&&(d[0]=`$${d[0]}`),!c){const E={name:d[0],scope:a||(h==null?void 0:h.varScope)||0,isAgainAssign:n,isArg:h==null?void 0:h.isArg,functionName:this._currentFuncName};this._setDepend(E)}return d.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,h=`${c}_${a}`;let d=this._isInFunc?`$posStr + "__${h}"`:`"${h}"`;d=this._isInLoop?`$$count${this._count} + ${d}`:d;let E=!1;const T=n.map(x=>(x.hasMemberIndex&&(E=!0),this._parserMethodElement(x,d))).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 h=!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.")&&(h=!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 d=this._parserArguments(c,a,n,h,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+d}_parserArguments(e,n,r,a=!1,c=!1,h){const d=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 p=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"&&h===`${this._prefixNameFunc}.input.enum`&&(x=this._enums.get(R.enumName));const g=this._requestParamsHandle(a,v,r,c,p,h);p=(g==null?void 0:g.code)||p,g!=null&&g.paramsExpr&&T.push(g==null?void 0:g.paramsExpr),E.push(`${v}: ${p}`)}else b.push(p)};for(const R of d)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,h){if(e&&n==="expression"){const d=this._getDepends(`$arg_${n}${r}`),E=this._getExpressionContext(d);return E.push({scope:1,depends:d.map(b=>(b.isArg&&(b.functionName=this._currentFuncName),b)),code:c}),{code:`'${ld.AES.encrypt(JSON.stringify(E),"1234").toString()}'`}}else if(a){const d=this._getDepends(r),E=this._getExpressionContext(d);return E.push({scope:2,varNames:n,methodName:h,depends:d,dependSelf:d.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 h of e)if(!h.isArg){const d=this._codesCol[h.scope||0],E=d.find(T=>{var x;return((x=T.varNames)==null?void 0:x.includes(h.name))||T.funcName===h.name});E&&(r.includes(E)||(r.push(E),E.depends.length&&this._getDependsCode(E.depends,n,r),n.push({scope:h.scope||0,code:E.code,depends:E.depends,funcName:E.funcName,varNames:(a=E.varNames)==null?void 0:a.join(", ")})));const b=d.filter(T=>T.depends.some(x=>x.name===h.name&&x.scope===h.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:h.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 () {
134
134
  let $$_result=undefined;
135
135
  ${e}
@@ -239,6 +239,6 @@ Input files:
239
239
  //# sourceMappingURL=data:application/json;charset=utf-8;base64,`+gv(x)}else e.sourceMap.url&&(E.code+=`
240
240
  //# sourceMappingURL=`+e.sourceMap.url)}return e.nameCache&&e.mangle&&(e.mangle.cache&&(e.nameCache.vars=a_(e.mangle.cache)),e.mangle.properties&&e.mangle.properties.cache&&(e.nameCache.props=a_(e.mangle.properties.cache))),b&&b.source_map&&b.source_map.destroy(),r&&(r.end=Date.now(),E.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)}),E}async function s_(t,e,n){const r=Ev(t,e,n);let a,c;do c=r.next(await a),a=c.value;while(!c.done);return c.value}function u_(t){const e=new Nm(t),n=new kl(e);n.removeErrorListeners();const r=new wm(n),a=new j(r);a._interp.predictionMode=Um.SLL,a.removeErrorListeners();const c=new Tv;n.addErrorListener(c),a.addErrorListener(c),a.buildParseTrees=!0;const h=a.program(),d=r.tokens.filter(E=>E.channel===2);return{errors:c.errors,ast:h,comments:d}}async function xv(t,e,n,r){const{errors:a,ast:c,comments:h}=u_(t+`
241
241
 
242
- `),d=new Ap(r,h,n),E=await d.visit(c);let b=a.splice(0,1);b.length||(b=d.errors);let T="";const x=new Ky("$"),w=e?"":x.preParser(E);if(e&&!b.some(F=>F.type===Vn.Error)){const F=x.parser(E)||"";T=(await s_(F,{compress:!0,mangle:!0})).code||"";const v={message:xe.indiRunErr,type:Vn.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0};if(d.hasUseDrawFunc){if(d.scriptType===Ui.library)d.exportPositions.length||(v.message=xe.libraryExportErr,b.push(v));else if(d.exportPositions.length){const p=d.exportPositions.map(g=>{const{type:A,...O}=g;return{message:Se(xe.exportUseErr,{type:A}),type:Vn.Error,...O}});b.push(...p)}}else switch(d.scriptType){case Ui.indicator:b.push(v);break;case Ui.strategy:d.hasUseCreateOrderFunc||(v.message=xe.strategyRunErr,b.push(v));break}}return{errors:b,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:T,preParserCode:w}}async function Sv(t,e,n,r){const{ast:a,comments:c}=u_(t+`
242
+ `),d=new Ap(r,h,n),E=await d.visit(c);let b=a.splice(0,1);b.length||(b=d.errors);let T="";const x=new Ky("$"),w=e?"":x.preParser(E);if(e&&!b.some(F=>F.type===Vn.Error)){const F=x.parser(E)||"";console.log(F),T=(await s_(F,{compress:!0,mangle:!0})).code||"";const v={message:xe.indiRunErr,type:Vn.Error,startColumn:0,startLineNumber:0,endColumn:0,endLineNumber:0};if(d.hasUseDrawFunc){if(d.scriptType===Ui.library)d.exportPositions.length||(v.message=xe.libraryExportErr,b.push(v));else if(d.exportPositions.length){const p=d.exportPositions.map(g=>{const{type:A,...O}=g;return{message:Se(xe.exportUseErr,{type:A}),type:Vn.Error,...O}});b.push(...p)}}else switch(d.scriptType){case Ui.indicator:b.push(v);break;case Ui.strategy:d.hasUseCreateOrderFunc||(v.message=xe.strategyRunErr,b.push(v));break}}return{errors:b,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:T,preParserCode:w}}async function Sv(t,e,n,r){const{ast:a,comments:c}=u_(t+`
243
243
 
244
244
  `),h=new Ap(r,c,n),d=await h.visit(a),{name:E,index:b}=h.endExport,T=d.findIndex(v=>v.name===E&&v.index===b),x=d.slice(0,T+1),F=new zy("$",e).parser(x)||"",R=await s_(F,{compress:!0,mangle:!0});return{...h.exportLibs,description:h.description,codeStr:R.code||""}}class Tv extends Rm{constructor(){super(...arguments);I(this,"errors",[])}syntaxError(n,r,a,c,h){this.errors.push({message:`syntax error: ${h.replace(/expecting.+/,"")}`,type:Vn.Error,startColumn:c,startLineNumber:a,endColumn:c,endLineNumber:a})}}yf({parseTcc:xv,parseLibraryCode:Sv})})();
@@ -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-CpxYiTUZ.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-cirR5d2e.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) });
@@ -67601,7 +67601,7 @@ const mh = (a, n) => {
67601
67601
  }
67602
67602
  const j = $r(async (A) => {
67603
67603
  var ht;
67604
- const R = Date.now(), { errors: U, functions: se, methods: me, types: ie, variables: xt, overloadsFuncs: Et, imports: Ke, preParserCode: Fe, enums: Y } = await ch(A), _e = new Map(Object.entries(se)), Ce = new Map(Object.entries(me)), Se = new Map(Object.entries(ie)), lt = new Map(Object.entries(xt)), Nt = new Map(Object.entries(Ke)), J = new Map(Object.entries(Y));
67604
+ const R = Date.now(), { errors: U, functions: se, methods: me, types: ie, variables: xt, overloadsFuncs: Et, imports: Ke, preParserCode: Fe, enums: Y } = await ch(A, !0), _e = new Map(Object.entries(se)), Ce = new Map(Object.entries(me)), Se = new Map(Object.entries(ie)), lt = new Map(Object.entries(xt)), Nt = new Map(Object.entries(Ke)), J = new Map(Object.entries(Y));
67605
67605
  or.setUserDefined({
67606
67606
  functions: _e,
67607
67607
  methods: Ce,
@@ -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-DTH9vYgp.js").href:new URL("assets/scriptsRunWorker-DTH9vYgp.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-CpxYiTUZ.js").href:new URL("assets/parserTccWorker-CpxYiTUZ.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-DTH9vYgp.js").href:new URL("assets/scriptsRunWorker-DTH9vYgp.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-cirR5d2e.js").href:new URL("assets/parserTccWorker-cirR5d2e.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,!0),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.135",
3
+ "version": "0.0.136",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"