@guihz/trading-vue-editor-tes 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,6 +135,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
135
135
|
* @license
|
136
136
|
* Copyright 2019 Google LLC
|
137
137
|
* SPDX-License-Identifier: Apache-2.0
|
138
|
-
*/const Jn=Symbol("Comlink.proxy"),ap=Symbol("Comlink.endpoint"),sp=Symbol("Comlink.releaseProxy"),si=Symbol("Comlink.finalizer"),Xa=Symbol("Comlink.thrown"),Zn=s=>typeof s=="object"&&s!==null||typeof s=="function",ip={canHandle:s=>Zn(s)&&s[Jn],serialize(s){const{port1:i,port2:a}=new MessageChannel;return to(s,i),[a,[a]]},deserialize(s){return s.start(),ii(s)}},np={canHandle:s=>Zn(s)&&Xa in s,serialize({value:s}){let i;return s instanceof Error?i={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:i={isError:!1,value:s},[i,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},eo=new Map([["proxy",ip],["throw",np]]);function op(s,i){for(const a of s)if(i===a||a==="*"||a instanceof RegExp&&a.test(i))return!0;return!1}function to(s,i=globalThis,a=["*"]){i.addEventListener("message",function o(u){if(!u||!u.data)return;if(!op(a,u.origin)){console.warn(`Invalid origin '${u.origin}' for comlink proxy`);return}const{id:p,type:m,path:g}=Object.assign({path:[]},u.data),v=(u.data.argumentList||[]).map(gr);let b;try{const w=g.slice(0,-1).reduce((N,z)=>N[z],s),k=g.reduce((N,z)=>N[z],s);switch(m){case"GET":b=k;break;case"SET":w[g.slice(-1)[0]]=gr(u.data.value),b=!0;break;case"APPLY":b=k.apply(w,v);break;case"CONSTRUCT":{const N=new k(...v);b=mp(N)}break;case"ENDPOINT":{const{port1:N,port2:z}=new MessageChannel;to(s,z),b=pp(N,[N])}break;case"RELEASE":b=void 0;break;default:return}}catch(w){b={value:w,[Xa]:0}}Promise.resolve(b).catch(w=>({value:w,[Xa]:0})).then(w=>{const[k,N]=Qa(w);i.postMessage(Object.assign(Object.assign({},k),{id:p}),N),m==="RELEASE"&&(i.removeEventListener("message",o),ro(i),si in s&&typeof s[si]=="function"&&s[si]())}).catch(w=>{const[k,N]=Qa({value:new TypeError("Unserializable return value"),[Xa]:0});i.postMessage(Object.assign(Object.assign({},k),{id:p}),N)})}),i.start&&i.start()}function lp(s){return s.constructor.name==="MessagePort"}function ro(s){lp(s)&&s.close()}function ii(s,i){return ni(s,[],i)}function Ya(s){if(s)throw new Error("Proxy has been released and is not useable")}function ao(s){return Nr(s,{type:"RELEASE"}).then(()=>{ro(s)})}const Va=new WeakMap,Ka="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const i=(Va.get(s)||0)-1;Va.set(s,i),i===0&&ao(s)});function cp(s,i){const a=(Va.get(i)||0)+1;Va.set(i,a),Ka&&Ka.register(s,i,s)}function up(s){Ka&&Ka.unregister(s)}function ni(s,i=[],a=function(){}){let o=!1;const u=new Proxy(a,{get(p,m){if(Ya(o),m===sp)return()=>{up(u),ao(s),o=!0};if(m==="then"){if(i.length===0)return{then:()=>u};const g=Nr(s,{type:"GET",path:i.map(v=>v.toString())}).then(gr);return g.then.bind(g)}return ni(s,[...i,m])},set(p,m,g){Ya(o);const[v,b]=Qa(g);return Nr(s,{type:"SET",path:[...i,m].map(w=>w.toString()),value:v},b).then(gr)},apply(p,m,g){Ya(o);const v=i[i.length-1];if(v===ap)return Nr(s,{type:"ENDPOINT"}).then(gr);if(v==="bind")return ni(s,i.slice(0,-1));const[b,w]=so(g);return Nr(s,{type:"APPLY",path:i.map(k=>k.toString()),argumentList:b},w).then(gr)},construct(p,m){Ya(o);const[g,v]=so(m);return Nr(s,{type:"CONSTRUCT",path:i.map(b=>b.toString()),argumentList:g},v).then(gr)}});return cp(u,s),u}function dp(s){return Array.prototype.concat.apply([],s)}function so(s){const i=s.map(Qa);return[i.map(a=>a[0]),dp(i.map(a=>a[1]))]}const io=new WeakMap;function pp(s,i){return io.set(s,i),s}function mp(s){return Object.assign(s,{[Jn]:!0})}function Qa(s){for(const[i,a]of eo)if(a.canHandle(s)){const[o,u]=a.serialize(s);return[{type:"HANDLER",name:i,value:o},u]}return[{type:"RAW",value:s},io.get(s)||[]]}function gr(s){switch(s.type){case"HANDLER":return eo.get(s.name).deserialize(s.value);case"RAW":return s.value}}function Nr(s,i,a){return new Promise(o=>{const u=fp();s.addEventListener("message",function p(m){!m.data||!m.data.id||m.data.id!==u||(s.removeEventListener("message",p),o(m.data))}),s.start&&s.start(),s.postMessage(Object.assign({id:u},i),a)})}function fp(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const no=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-uULdCfgb.js").href:new URL("assets/scriptsRunWorker-uULdCfgb.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:Fa&&Fa.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});no.onerror=s=>{console.error(s)};const oo=ii(no),yp=ii(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-C_bOG4Oe.js").href:new URL("assets/parserTccWorker-C_bOG4Oe.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:Fa&&Fa.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function lo(s,i=!1){const{functions:a,types:o,constants:u,variables:p,methods:m}=Rt;return await yp(s,i,{functions:Object.fromEntries(a),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(u),variables:Object.fromEntries(p)})}async function co(s,i,a=!0){return await oo.runScript(s,i,a)}async function hp(s){return await oo.removeScript(s)}function _p(s){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:s==null?void 0:s.name})}var qt;(function(s){s.BOOL="bool",s.INT="int",s.FLOAT="float",s.ARRAY="array",s.BOX="box",s.CHART_POINT="chart.point",s.COLOR="color",s.CONST="const",s.LABEL="label",s.LINE="line",s.LINEFILL="linefill",s.MAP="map",s.MATRIX="matrix",s.POLYLINE="polyline",s.SERIES="series",s.SIMPLE="simple",s.STRING="string",s.TABLE="table",s.UNDETERMINED="undetermined type",s.INPUT="input",s.NA="na",s.VOID="void"})(qt||(qt={}));var uo;(function(s){s.FlowStmt="FlowStmt",s.DeclareAssign="DeclareAssign",s.VarBlockStmt="VarBlockStmt",s.VarSingle="VarSingle",s.VarMultiple="VarMultiple",s.ParenthesizedExpression="ParenthesizedExpression",s.AdditiveExpression="AdditiveExpression",s.RelationalExpression="RelationalExpression",s.EqualityExpression="EqualityExpression",s.TernaryExpression="TernaryExpression",s.UnaryExpression="UnaryExpression",s.NotExpression="NotExpression",s.MemberIndexExpression="MemberIndexExpression",s.MethodExpression="MethodExpression",s.LogicalAndExpression="LogicalAndExpression",s.LogicalOrExpression="LogicalOrExpression",s.MultiplicativeExpression="MultiplicativeExpression",s.Brackethesized="Brackethesized",s.IfStatement="IfStatement",s.ForToStatement="ForToStatement",s.ForInStatement="ForInStatement",s.SwitchStatement="SwitchStatement",s.CaseClause="CaseClause",s.DefaultCaluse="DefaultCaluse",s.WhileStatement="WhileStatement",s.ImportElement="ImportElement",s.Literal="Literal",s.ArrowFunction="ArrowFunction",s.ArrowMethod="ArrowMethod",s.TypeStatement="TypeStatement",s.Name="Name",s.AgainAssign="AgainAssign"})(uo||(uo={}));var po;(function(s){s.dividends="dividends",s.none="none",s.splits="splits"})(po||(po={}));var mo;(function(s){s.freqAll="freq_all",s.freqOncePerBar="freq_once_per_bar",s.freqOncePerBarClose="freq_once_per_bar_close"})(mo||(mo={}));var fo;(function(s){s.gapsOff="gaps_off",s.gapsOn="gaps_on",s.lookaheadOff="lookahead_off",s.lookaheadOn="lookahead_on"})(fo||(fo={}));var yo;(function(s){s.all="all",s.dataWindow="data_window",s.none="none",s.pane="pane",s.priceScale="price_scale",s.statusLine="status_line"})(yo||(yo={}));var ho;(function(s){s.both="both",s.left="left",s.none="none",s.right="right"})(ho||(ho={}));var _o;(function(s){s.inherit="inherit",s.mintick="mintick",s.percent="percent",s.price="price",s.volume="volume"})(_o||(_o={}));var go;(function(s){s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid"})(go||(go={}));var bo;(function(s){s.styleArrowdown="style_arrowdown",s.styleArrowup="style_arrowup",s.styleCircle="style_circle",s.styleCross="style_cross",s.styleDiamond="style_diamond",s.styleFlag="style_flag",s.styleLabelCenter="style_label_center",s.styleLabelDown="style_label_down",s.styleLabelLeft="style_label_left",s.styleLabelLowerLeft="style_label_lower_left",s.styleLabelLowerRight="style_label_lower_right",s.styleLabelRight="style_label_right",s.styleLabelUp="style_label_up",s.styleLabelUpperLeft="style_label_upper_left",s.styleLabelUpperRight="style_label_upper_right",s.styleNone="style_none",s.styleSquare="style_square",s.styleTextOutline="style_text_outline",s.styleTriangledown="style_triangledown",s.styleTriangleup="style_triangleup",s.styleXcross="style_xcross"})(bo||(bo={}));var xo;(function(s){s.styleArrowBoth="style_arrow_both",s.styleArrowLeft="style_arrow_left",s.styleArrowRight="style_arrow_right",s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid"})(xo||(xo={}));var vo;(function(s){s.abovebar="abovebar",s.absolute="absolute",s.belowbar="belowbar",s.bottom="bottom",s.top="top"})(vo||(vo={}));var wo;(function(s){s.ascending="ascending",s.descending="descending"})(wo||(wo={}));var To;(function(s){s.styleArea="Area",s.styleAreabr="Area With Breaks",s.styleCircles="Circles",s.styleColumns="Columns",s.styleCross="Cross",s.styleHistogram="Histogram",s.styleLine="Line",s.styleLinebr="Line With Breaks",s.styleStepline="Step Line",s.styleSteplineDiamond="Step Line With Diamonds",s.styleSteplinebr="Step line with Breaks"})(To||(To={}));var Io;(function(s){s.bottomCenter="bottom_center",s.bottomLeft="bottom_left",s.bottomRight="bottom_right",s.middleCenter="middle_center",s.middleLeft="middle_left",s.middleRight="middle_right",s.topCenter="top_center",s.topLeft="top_left",s.topRight="top_right"})(Io||(Io={}));var Do;(function(s){s.left="left",s.none="none",s.right="right"})(Do||(Do={}));var ko;(function(s){s.extended="extended",s.regular="regular"})(ko||(ko={}));var Ao;(function(s){s.arrowdown="arrowdown",s.arrowup="arrowup",s.circle="circle",s.cross="cross",s.diamond="diamond",s.flag="flag",s.labeldown="labeldown",s.labelup="labelup",s.square="square",s.triangledown="triangledown",s.triangleup="triangleup",s.xcross="xcross"})(Ao||(Ao={}));var qo;(function(s){s.auto="auto",s.huge="huge",s.large="large",s.normal="normal",s.small="small",s.tiny="tiny"})(qo||(qo={}));var Co;(function(s){s.cash="cash",s.fixed="fixed",s.percentOfEquity="percent_of_equity"})(Co||(Co={}));var So;(function(s){s.cashPerContract="cash_per_contract",s.cashPerOrder="cash_per_order",s.percent="percent"})(So||(So={}));var zo;(function(s){s.all="all",s.long="long",s.short="short"})(zo||(zo={}));var No;(function(s){s.cancel="cancel",s.none="none",s.reduce="reduce"})(No||(No={}));var Oo;(function(s){s.alignBottom="align_bottom",s.alignCenter="align_center",s.alignLeft="align_left",s.alignRight="align_right",s.alignTop="align_top",s.wrapAuto="wrap_auto",s.wrapNone="wrap_none"})(Oo||(Oo={}));var Po;(function(s){s.bar_index="bar_index",s.bar_time="bar_time"})(Po||(Po={}));var Ro;(function(s){s.abovebar="abovebar",s.belowbar="belowbar",s.price="price"})(Ro||(Ro={}));var Eo;(function(s){s.actual="actual",s.estimate="estimate",s.standardized="standardized"})(Eo||(Eo={}));var Mo;(function(s){s.traditional="Traditional",s.fibonacci="Fibonacci",s.woodie="Woodie",s.classic="Classic",s.dm="DM",s.camarilla="Camarilla"})(Mo||(Mo={})),qt.SERIES,qt.SIMPLE,qt.INPUT,qt.CONST,qt.INT,qt.FLOAT,qt.BOOL,qt.COLOR,qt.STRING;const gp={domReadOnly:!0,scrollBeyondLastLine:!1,readOnly:!0,minimap:{enabled:!1},scrollbar:{vertical:"hidden",horizontal:"hidden",alwaysConsumeMouseWheel:!1},contextmenu:!1};self.MonacoEnvironment={getWorker(){return new _p({name:"Editor Worker"})}},Qs.config({monaco:du});const bp=(s,i)=>{const{height:a,width:o,theme:u,options:p,hasDiff:m,readOnly:g,defaultValue:v,onChange:b,onDeclareConfigChange:w,onCursorPositionChange:k,onActionTrigger:N}=s,z=M.useRef(null);M.useImperativeHandle(i,()=>({saveScript(){var O;(O=z.current)==null||O.saveScripts()},setScript(O){var Q;(Q=z.current)==null||Q.setValue(O)},gotoLine(){var O;(O=z.current)==null||O.gotoLine()},getEditorLayout(){var O;return(O=z.current)==null?void 0:O.getEditorLayout()},setPosition(O,Q){var Y;(Y=z.current)==null||Y.setPosition({column:O,lineNumber:Q})},setModelMarkers(O){var Q;(Q=z.current)==null||Q.setModelMarkers(O)}})),M.useEffect(()=>{var O,Q;m?(Q=z.current)==null||Q.addDiffDecorations():(O=z.current)==null||O.removeDiffDecorations()},[m]),M.useEffect(()=>{var O;(O=z.current)==null||O.updateActionTrigger(N)},[N]),M.useEffect(()=>{var O;a&&((O=z.current)==null||O.setEditorLayout(Number(a)))},[a,z.current]);function B(O,Q){var V,ie;Et.initBuiltinsTrees(),z.current=new rp(O,Q,N),m&&((V=z.current)==null||V.addDiffDecorations()),Sd(O),(ie=z.current)==null||ie.setEditorLayout(Number(a));const Y=O.getValue();z.current.onChangeCursorPosition(k),b&&b(Y),!g&&F(Y)}const F=M.useCallback(async O=>{var Ce;const Q=Date.now(),{errors:Y,functions:V,methods:ie,types:ee,variables:Pe,overloadsFuncs:be,preParserCode:ne}=await lo(O),ot=new Map(Object.entries(V)),_t=new Map(Object.entries(ie)),Re=new Map(Object.entries(ee)),Ee=new Map(Object.entries(Pe));la.setUserDefined({functions:ot,methods:_t,types:Re,variables:Ee},be),Et.setUserDefind(ot,Re,Ee,_t);const U=Y.map(ve=>({...ve,severity:ve.type||Je.MarkerSeverity.Error}));if(g)return;try{if(!Y.length){const ve=await co(ne,{isPreParser:!0});w&&w(ve)}}catch(ve){console.log(ve,"==================error- Run TccScript Server"),Y.push({message:`Runtime Error: ${ve.message}`,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}(Ce=z.current)==null||Ce.setModelMarkers(U);const de=Date.now();console.log((de-Q)/1e3)},[w,g]),ae=M.useMemo(()=>Od.debounce(F,1e3),[F]);function me(O){var Q;if(g){F(O||"");return}(Q=z.current)==null||Q.setModelMarkers([]),O!==void 0&&(b&&b(O),ae(O))}return it.jsx(bd,{height:a,width:o||"100%",defaultLanguage:Xe,defaultValue:v||`indicator("我的脚本")
|
138
|
+
*/const Jn=Symbol("Comlink.proxy"),ap=Symbol("Comlink.endpoint"),sp=Symbol("Comlink.releaseProxy"),si=Symbol("Comlink.finalizer"),Xa=Symbol("Comlink.thrown"),Zn=s=>typeof s=="object"&&s!==null||typeof s=="function",ip={canHandle:s=>Zn(s)&&s[Jn],serialize(s){const{port1:i,port2:a}=new MessageChannel;return to(s,i),[a,[a]]},deserialize(s){return s.start(),ii(s)}},np={canHandle:s=>Zn(s)&&Xa in s,serialize({value:s}){let i;return s instanceof Error?i={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:i={isError:!1,value:s},[i,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},eo=new Map([["proxy",ip],["throw",np]]);function op(s,i){for(const a of s)if(i===a||a==="*"||a instanceof RegExp&&a.test(i))return!0;return!1}function to(s,i=globalThis,a=["*"]){i.addEventListener("message",function o(u){if(!u||!u.data)return;if(!op(a,u.origin)){console.warn(`Invalid origin '${u.origin}' for comlink proxy`);return}const{id:p,type:m,path:g}=Object.assign({path:[]},u.data),v=(u.data.argumentList||[]).map(gr);let b;try{const w=g.slice(0,-1).reduce((N,z)=>N[z],s),k=g.reduce((N,z)=>N[z],s);switch(m){case"GET":b=k;break;case"SET":w[g.slice(-1)[0]]=gr(u.data.value),b=!0;break;case"APPLY":b=k.apply(w,v);break;case"CONSTRUCT":{const N=new k(...v);b=mp(N)}break;case"ENDPOINT":{const{port1:N,port2:z}=new MessageChannel;to(s,z),b=pp(N,[N])}break;case"RELEASE":b=void 0;break;default:return}}catch(w){b={value:w,[Xa]:0}}Promise.resolve(b).catch(w=>({value:w,[Xa]:0})).then(w=>{const[k,N]=Qa(w);i.postMessage(Object.assign(Object.assign({},k),{id:p}),N),m==="RELEASE"&&(i.removeEventListener("message",o),ro(i),si in s&&typeof s[si]=="function"&&s[si]())}).catch(w=>{const[k,N]=Qa({value:new TypeError("Unserializable return value"),[Xa]:0});i.postMessage(Object.assign(Object.assign({},k),{id:p}),N)})}),i.start&&i.start()}function lp(s){return s.constructor.name==="MessagePort"}function ro(s){lp(s)&&s.close()}function ii(s,i){return ni(s,[],i)}function Ya(s){if(s)throw new Error("Proxy has been released and is not useable")}function ao(s){return Nr(s,{type:"RELEASE"}).then(()=>{ro(s)})}const Va=new WeakMap,Ka="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const i=(Va.get(s)||0)-1;Va.set(s,i),i===0&&ao(s)});function cp(s,i){const a=(Va.get(i)||0)+1;Va.set(i,a),Ka&&Ka.register(s,i,s)}function up(s){Ka&&Ka.unregister(s)}function ni(s,i=[],a=function(){}){let o=!1;const u=new Proxy(a,{get(p,m){if(Ya(o),m===sp)return()=>{up(u),ao(s),o=!0};if(m==="then"){if(i.length===0)return{then:()=>u};const g=Nr(s,{type:"GET",path:i.map(v=>v.toString())}).then(gr);return g.then.bind(g)}return ni(s,[...i,m])},set(p,m,g){Ya(o);const[v,b]=Qa(g);return Nr(s,{type:"SET",path:[...i,m].map(w=>w.toString()),value:v},b).then(gr)},apply(p,m,g){Ya(o);const v=i[i.length-1];if(v===ap)return Nr(s,{type:"ENDPOINT"}).then(gr);if(v==="bind")return ni(s,i.slice(0,-1));const[b,w]=so(g);return Nr(s,{type:"APPLY",path:i.map(k=>k.toString()),argumentList:b},w).then(gr)},construct(p,m){Ya(o);const[g,v]=so(m);return Nr(s,{type:"CONSTRUCT",path:i.map(b=>b.toString()),argumentList:g},v).then(gr)}});return cp(u,s),u}function dp(s){return Array.prototype.concat.apply([],s)}function so(s){const i=s.map(Qa);return[i.map(a=>a[0]),dp(i.map(a=>a[1]))]}const io=new WeakMap;function pp(s,i){return io.set(s,i),s}function mp(s){return Object.assign(s,{[Jn]:!0})}function Qa(s){for(const[i,a]of eo)if(a.canHandle(s)){const[o,u]=a.serialize(s);return[{type:"HANDLER",name:i,value:o},u]}return[{type:"RAW",value:s},io.get(s)||[]]}function gr(s){switch(s.type){case"HANDLER":return eo.get(s.name).deserialize(s.value);case"RAW":return s.value}}function Nr(s,i,a){return new Promise(o=>{const u=fp();s.addEventListener("message",function p(m){!m.data||!m.data.id||m.data.id!==u||(s.removeEventListener("message",p),o(m.data))}),s.start&&s.start(),s.postMessage(Object.assign({id:u},i),a)})}function fp(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const no=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-uULdCfgb.js").href:new URL("assets/scriptsRunWorker-uULdCfgb.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:Fa&&Fa.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});no.onerror=s=>{console.error(s)};const oo=ii(no),yp=ii(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-CwSYSKEG.js").href:new URL("assets/parserTccWorker-CwSYSKEG.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:Fa&&Fa.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function lo(s,i=!1){const{functions:a,types:o,constants:u,variables:p,methods:m}=Rt;return await yp(s,i,{functions:Object.fromEntries(a),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(u),variables:Object.fromEntries(p)})}async function co(s,i,a=!0){return await oo.runScript(s,i,a)}async function hp(s){return await oo.removeScript(s)}function _p(s){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:s==null?void 0:s.name})}var qt;(function(s){s.BOOL="bool",s.INT="int",s.FLOAT="float",s.ARRAY="array",s.BOX="box",s.CHART_POINT="chart.point",s.COLOR="color",s.CONST="const",s.LABEL="label",s.LINE="line",s.LINEFILL="linefill",s.MAP="map",s.MATRIX="matrix",s.POLYLINE="polyline",s.SERIES="series",s.SIMPLE="simple",s.STRING="string",s.TABLE="table",s.UNDETERMINED="undetermined type",s.INPUT="input",s.NA="na",s.VOID="void"})(qt||(qt={}));var uo;(function(s){s.FlowStmt="FlowStmt",s.DeclareAssign="DeclareAssign",s.VarBlockStmt="VarBlockStmt",s.VarSingle="VarSingle",s.VarMultiple="VarMultiple",s.ParenthesizedExpression="ParenthesizedExpression",s.AdditiveExpression="AdditiveExpression",s.RelationalExpression="RelationalExpression",s.EqualityExpression="EqualityExpression",s.TernaryExpression="TernaryExpression",s.UnaryExpression="UnaryExpression",s.NotExpression="NotExpression",s.MemberIndexExpression="MemberIndexExpression",s.MethodExpression="MethodExpression",s.LogicalAndExpression="LogicalAndExpression",s.LogicalOrExpression="LogicalOrExpression",s.MultiplicativeExpression="MultiplicativeExpression",s.Brackethesized="Brackethesized",s.IfStatement="IfStatement",s.ForToStatement="ForToStatement",s.ForInStatement="ForInStatement",s.SwitchStatement="SwitchStatement",s.CaseClause="CaseClause",s.DefaultCaluse="DefaultCaluse",s.WhileStatement="WhileStatement",s.ImportElement="ImportElement",s.Literal="Literal",s.ArrowFunction="ArrowFunction",s.ArrowMethod="ArrowMethod",s.TypeStatement="TypeStatement",s.Name="Name",s.AgainAssign="AgainAssign"})(uo||(uo={}));var po;(function(s){s.dividends="dividends",s.none="none",s.splits="splits"})(po||(po={}));var mo;(function(s){s.freqAll="freq_all",s.freqOncePerBar="freq_once_per_bar",s.freqOncePerBarClose="freq_once_per_bar_close"})(mo||(mo={}));var fo;(function(s){s.gapsOff="gaps_off",s.gapsOn="gaps_on",s.lookaheadOff="lookahead_off",s.lookaheadOn="lookahead_on"})(fo||(fo={}));var yo;(function(s){s.all="all",s.dataWindow="data_window",s.none="none",s.pane="pane",s.priceScale="price_scale",s.statusLine="status_line"})(yo||(yo={}));var ho;(function(s){s.both="both",s.left="left",s.none="none",s.right="right"})(ho||(ho={}));var _o;(function(s){s.inherit="inherit",s.mintick="mintick",s.percent="percent",s.price="price",s.volume="volume"})(_o||(_o={}));var go;(function(s){s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid"})(go||(go={}));var bo;(function(s){s.styleArrowdown="style_arrowdown",s.styleArrowup="style_arrowup",s.styleCircle="style_circle",s.styleCross="style_cross",s.styleDiamond="style_diamond",s.styleFlag="style_flag",s.styleLabelCenter="style_label_center",s.styleLabelDown="style_label_down",s.styleLabelLeft="style_label_left",s.styleLabelLowerLeft="style_label_lower_left",s.styleLabelLowerRight="style_label_lower_right",s.styleLabelRight="style_label_right",s.styleLabelUp="style_label_up",s.styleLabelUpperLeft="style_label_upper_left",s.styleLabelUpperRight="style_label_upper_right",s.styleNone="style_none",s.styleSquare="style_square",s.styleTextOutline="style_text_outline",s.styleTriangledown="style_triangledown",s.styleTriangleup="style_triangleup",s.styleXcross="style_xcross"})(bo||(bo={}));var xo;(function(s){s.styleArrowBoth="style_arrow_both",s.styleArrowLeft="style_arrow_left",s.styleArrowRight="style_arrow_right",s.styleDashed="style_dashed",s.styleDotted="style_dotted",s.styleSolid="style_solid"})(xo||(xo={}));var vo;(function(s){s.abovebar="abovebar",s.absolute="absolute",s.belowbar="belowbar",s.bottom="bottom",s.top="top"})(vo||(vo={}));var wo;(function(s){s.ascending="ascending",s.descending="descending"})(wo||(wo={}));var To;(function(s){s.styleArea="Area",s.styleAreabr="Area With Breaks",s.styleCircles="Circles",s.styleColumns="Columns",s.styleCross="Cross",s.styleHistogram="Histogram",s.styleLine="Line",s.styleLinebr="Line With Breaks",s.styleStepline="Step Line",s.styleSteplineDiamond="Step Line With Diamonds",s.styleSteplinebr="Step line with Breaks"})(To||(To={}));var Io;(function(s){s.bottomCenter="bottom_center",s.bottomLeft="bottom_left",s.bottomRight="bottom_right",s.middleCenter="middle_center",s.middleLeft="middle_left",s.middleRight="middle_right",s.topCenter="top_center",s.topLeft="top_left",s.topRight="top_right"})(Io||(Io={}));var Do;(function(s){s.left="left",s.none="none",s.right="right"})(Do||(Do={}));var ko;(function(s){s.extended="extended",s.regular="regular"})(ko||(ko={}));var Ao;(function(s){s.arrowdown="arrowdown",s.arrowup="arrowup",s.circle="circle",s.cross="cross",s.diamond="diamond",s.flag="flag",s.labeldown="labeldown",s.labelup="labelup",s.square="square",s.triangledown="triangledown",s.triangleup="triangleup",s.xcross="xcross"})(Ao||(Ao={}));var qo;(function(s){s.auto="auto",s.huge="huge",s.large="large",s.normal="normal",s.small="small",s.tiny="tiny"})(qo||(qo={}));var Co;(function(s){s.cash="cash",s.fixed="fixed",s.percentOfEquity="percent_of_equity"})(Co||(Co={}));var So;(function(s){s.cashPerContract="cash_per_contract",s.cashPerOrder="cash_per_order",s.percent="percent"})(So||(So={}));var zo;(function(s){s.all="all",s.long="long",s.short="short"})(zo||(zo={}));var No;(function(s){s.cancel="cancel",s.none="none",s.reduce="reduce"})(No||(No={}));var Oo;(function(s){s.alignBottom="align_bottom",s.alignCenter="align_center",s.alignLeft="align_left",s.alignRight="align_right",s.alignTop="align_top",s.wrapAuto="wrap_auto",s.wrapNone="wrap_none"})(Oo||(Oo={}));var Po;(function(s){s.bar_index="bar_index",s.bar_time="bar_time"})(Po||(Po={}));var Ro;(function(s){s.abovebar="abovebar",s.belowbar="belowbar",s.price="price"})(Ro||(Ro={}));var Eo;(function(s){s.actual="actual",s.estimate="estimate",s.standardized="standardized"})(Eo||(Eo={}));var Mo;(function(s){s.traditional="Traditional",s.fibonacci="Fibonacci",s.woodie="Woodie",s.classic="Classic",s.dm="DM",s.camarilla="Camarilla"})(Mo||(Mo={})),qt.SERIES,qt.SIMPLE,qt.INPUT,qt.CONST,qt.INT,qt.FLOAT,qt.BOOL,qt.COLOR,qt.STRING;const gp={domReadOnly:!0,scrollBeyondLastLine:!1,readOnly:!0,minimap:{enabled:!1},scrollbar:{vertical:"hidden",horizontal:"hidden",alwaysConsumeMouseWheel:!1},contextmenu:!1};self.MonacoEnvironment={getWorker(){return new _p({name:"Editor Worker"})}},Qs.config({monaco:du});const bp=(s,i)=>{const{height:a,width:o,theme:u,options:p,hasDiff:m,readOnly:g,defaultValue:v,onChange:b,onDeclareConfigChange:w,onCursorPositionChange:k,onActionTrigger:N}=s,z=M.useRef(null);M.useImperativeHandle(i,()=>({saveScript(){var O;(O=z.current)==null||O.saveScripts()},setScript(O){var Q;(Q=z.current)==null||Q.setValue(O)},gotoLine(){var O;(O=z.current)==null||O.gotoLine()},getEditorLayout(){var O;return(O=z.current)==null?void 0:O.getEditorLayout()},setPosition(O,Q){var Y;(Y=z.current)==null||Y.setPosition({column:O,lineNumber:Q})},setModelMarkers(O){var Q;(Q=z.current)==null||Q.setModelMarkers(O)}})),M.useEffect(()=>{var O,Q;m?(Q=z.current)==null||Q.addDiffDecorations():(O=z.current)==null||O.removeDiffDecorations()},[m]),M.useEffect(()=>{var O;(O=z.current)==null||O.updateActionTrigger(N)},[N]),M.useEffect(()=>{var O;a&&((O=z.current)==null||O.setEditorLayout(Number(a)))},[a,z.current]);function B(O,Q){var V,ie;Et.initBuiltinsTrees(),z.current=new rp(O,Q,N),m&&((V=z.current)==null||V.addDiffDecorations()),Sd(O),(ie=z.current)==null||ie.setEditorLayout(Number(a));const Y=O.getValue();z.current.onChangeCursorPosition(k),b&&b(Y),!g&&F(Y)}const F=M.useCallback(async O=>{var Ce;const Q=Date.now(),{errors:Y,functions:V,methods:ie,types:ee,variables:Pe,overloadsFuncs:be,preParserCode:ne}=await lo(O),ot=new Map(Object.entries(V)),_t=new Map(Object.entries(ie)),Re=new Map(Object.entries(ee)),Ee=new Map(Object.entries(Pe));la.setUserDefined({functions:ot,methods:_t,types:Re,variables:Ee},be),Et.setUserDefind(ot,Re,Ee,_t);const U=Y.map(ve=>({...ve,severity:ve.type||Je.MarkerSeverity.Error}));if(g)return;try{if(!Y.length){const ve=await co(ne,{isPreParser:!0});w&&w(ve)}}catch(ve){console.log(ve,"==================error- Run TccScript Server"),Y.push({message:`Runtime Error: ${ve.message}`,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}(Ce=z.current)==null||Ce.setModelMarkers(U);const de=Date.now();console.log((de-Q)/1e3)},[w,g]),ae=M.useMemo(()=>Od.debounce(F,1e3),[F]);function me(O){var Q;if(g){F(O||"");return}(Q=z.current)==null||Q.setModelMarkers([]),O!==void 0&&(b&&b(O),ae(O))}return it.jsx(bd,{height:a,width:o||"100%",defaultLanguage:Xe,defaultValue:v||`indicator("我的脚本")
|
139
139
|
plot(close)
|
140
140
|
`,theme:u||"vs-dark",className:u||"vs-dark",options:{colorDecorators:!0,matchOnWordStartOnly:!0,useShadowDOM:!1,suggest:{preview:!0,matchOnWordStartOnly:!0},fontSize:13,...g?gp:{},readOnlyMessage:{value:"该脚本是只读的。它无法被编辑。"},...p},onMount:B,onChange:me})},xp=M.forwardRef(bp),vp=s=>{const{theme:i,modified:a,original:o,height:u,width:p,renderSideBySide:m=!0}=s,g=M.useCallback((v,b)=>{b.languages.register({id:Xe}),b.editor.defineTheme("vs-dark",Gn),b.editor.defineTheme("vs",$n),b.languages.setMonarchTokensProvider(Xe,Wn),b.languages.setLanguageConfiguration(Xe,Hn)},[]);return it.jsx(fd,{height:u||"90vh",width:p||"100%",theme:i||"vs-dark",options:{readOnly:!0,renderSideBySide:m,scrollBeyondLastLine:!1},language:Xe,modified:a,original:o,onMount:g})};qe.VMarkerSeverity=void 0,function(s){s[s.Hint=1]="Hint",s[s.Info=2]="Info",s[s.Warning=4]="Warning",s[s.Error=8]="Error"}(qe.VMarkerSeverity||(qe.VMarkerSeverity={})),qe.TradingVueDiffEditor=vp,qe.TradingVueEditor=xp,qe.parseTcc=lo,qe.removeScript=hp,qe.scriptsRun=co,Object.defineProperty(qe,Symbol.toStringTag,{value:"Module"})});
|