@guihz/trading-vue-editor-tes 0.0.212 → 0.0.214

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,8 @@ export default class Request {
19
19
  security(args: IRequestArgs, posStr: string): any;
20
20
  private _parseExprCode;
21
21
  private _getRequestData;
22
+ private _lookaheadOnHandle;
23
+ private _lookaheadOffHandle;
22
24
  private _getDependCodes;
23
25
  private _runScripts;
24
26
  }
@@ -99,6 +99,7 @@ export interface IOrder extends IOrderArgs {
99
99
  in_high?: number;
100
100
  out_low?: number;
101
101
  out_high?: number;
102
+ isTiggerClose?: boolean;
102
103
  }
103
104
  interface IRisk {
104
105
  allow_entry_in?: VDirection;
@@ -1,8 +1,11 @@
1
+ import { IKeyObjectValue } from "../../type";
1
2
  import { BuiltInVariables } from "../buildInVariables";
2
3
  import { VSession } from "../enum";
3
4
  export declare class Syminfo {
4
5
  private _variables;
6
+ private _syminfo;
5
7
  constructor(variables: BuiltInVariables);
8
+ update(syminfo: IKeyObjectValue): void;
6
9
  get basecurrency(): string;
7
10
  get country(): undefined;
8
11
  get currency(): string;
@@ -13,7 +16,7 @@ export declare class Syminfo {
13
16
  get minmove(): void;
14
17
  get mintick(): number | undefined;
15
18
  get pointvalue(): void;
16
- get prefix(): void;
19
+ get prefix(): any;
17
20
  get pricescale(): void;
18
21
  get recommendations_buy(): void;
19
22
  get recommendations_buy_strong(): void;
@@ -34,8 +37,8 @@ export declare class Syminfo {
34
37
  get target_price_high(): void;
35
38
  get target_price_low(): void;
36
39
  get target_price_median(): void;
37
- get ticker(): string;
38
- get tickerid(): string;
40
+ get ticker(): any;
41
+ get tickerid(): any;
39
42
  get timezone(): void;
40
43
  get type(): void;
41
44
  get volumetype(): string;
@@ -13,5 +13,4 @@ export declare class Timeframe {
13
13
  get isweekly(): boolean;
14
14
  get multiplier(): number;
15
15
  get period(): string;
16
- private _transformPeriod;
17
16
  }
@@ -86,6 +86,7 @@ export declare const ERRORS_TIPS: {
86
86
  arrLenErr: string;
87
87
  mergeCellErr: string;
88
88
  minOrMaxErr: string;
89
+ requestsNumErr: string;
89
90
  };
90
91
  export declare const WARNING_TIPS: {
91
92
  repeatVar: string;
@@ -0,0 +1 @@
1
+ export declare const PERIOD_MAP: Record<string, string>;
@@ -5,7 +5,7 @@ export declare function parsePerid(period: string): (string | number)[];
5
5
  export declare function generateRandomId(length?: number): string;
6
6
  export declare function parseTimezoneOffset(timezone: string): number;
7
7
  export declare function parserTimezone(time?: dayjs.ConfigType, timezone?: string): dayjs.Dayjs;
8
- export declare function periodConvert(period: string): number;
8
+ export declare function periodConvert(period: string, time: number): number;
9
9
  export declare function isNotNum(num?: number): boolean;
10
10
  export declare function argColorsHandle(args: any, colors: string[]): void;
11
11
  export declare function encode(str: string): string;
@@ -1,5 +1,5 @@
1
1
  import { IKeyObjectValue } from '../type';
2
- export declare function runScript(strJs: string, options: IKeyObjectValue, isNew: boolean): {
2
+ export declare function runScript(strJs: string, options: IKeyObjectValue, isNew: boolean): Promise<{
3
3
  status: number;
4
4
  errors: any;
5
5
  requestList?: undefined;
@@ -9,7 +9,7 @@ export declare function runScript(strJs: string, options: IKeyObjectValue, isNew
9
9
  requestList: any[];
10
10
  errors: any;
11
11
  options: any;
12
- };
12
+ }>;
13
13
  export declare function removeScript(id: string): void;
14
14
  export interface IScriptWorker {
15
15
  runScript: typeof runScript;
@@ -60509,31 +60509,38 @@ function ux(a, n) {
60509
60509
  }), { mapObj: r, keys: o };
60510
60510
  }
60511
60511
  const { keyList: Ap, keyMapList: xt } = mx(), Ur = [{
60512
- title: "Variables",
60512
+ // title: 'Variables',
60513
+ title: "内置变量",
60513
60514
  key: "variables",
60514
60515
  prefix: "var"
60515
60516
  }, {
60516
- title: "Constants",
60517
+ // title: 'Constants',
60518
+ title: "常量",
60517
60519
  key: "constants",
60518
60520
  prefix: "const"
60519
60521
  }, {
60520
- title: "Functions",
60522
+ // title: 'Functions',
60523
+ title: "函数",
60521
60524
  key: "functions",
60522
60525
  prefix: "fun"
60523
60526
  }, {
60524
- title: "Keywords",
60527
+ // title: 'Keywords',
60528
+ title: "关键词",
60525
60529
  key: "keywords",
60526
60530
  prefix: "kw"
60527
60531
  }, {
60528
- title: "Types",
60532
+ // title: 'Types',
60533
+ title: "类型",
60529
60534
  key: "types",
60530
60535
  prefix: "type"
60531
60536
  }, {
60532
- title: "Operators",
60537
+ // title: 'Operators',
60538
+ title: "运算符",
60533
60539
  key: "operators",
60534
60540
  prefix: "op"
60535
60541
  }, {
60536
- title: "Annotations",
60542
+ // title: 'Annotations',
60543
+ title: "注释",
60537
60544
  key: "annotations",
60538
60545
  prefix: "an"
60539
60546
  }];
@@ -67600,14 +67607,14 @@ function nr(a, n, r) {
67600
67607
  function ih() {
67601
67608
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
67602
67609
  }
67603
- const Pp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-DvdFfBYN.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
67610
+ const Pp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-CRZrOXN_.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
67604
67611
  Pp.onerror = (a) => {
67605
67612
  console.error(a);
67606
67613
  };
67607
67614
  async function Op(a) {
67608
67615
  return await Ja.setInlayHints(a);
67609
67616
  }
67610
- const Fp = ji(Pp), Rp = ji(new Worker(new URL("" + new URL("assets/parserTccWorker-BwTU0Mcr.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
67617
+ const Fp = ji(Pp), Rp = ji(new Worker(new URL("" + new URL("assets/parserTccWorker-C_OkdWJ6.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
67611
67618
  async function oh(a, n = !1) {
67612
67619
  const { functions: r, types: o, constants: c, variables: l, methods: m } = xt;
67613
67620
  return await Rp.parseTcc(a, n, Hi(Op), { functions: Object.fromEntries(r), methods: Object.fromEntries(m), types: Object.fromEntries(o), constants: Object.fromEntries(c), variables: Object.fromEntries(l) });
@@ -103,7 +103,7 @@ else
103
103
  \${2:local_block_1}
104
104
  else
105
105
  \${3:local_block_2}
106
- `,kind:"statement"},{label:"for...to",insertText:"for ${1:i} = 1 to ${2:to_num} by 1\n ${3:local_block}\n",kind:"loop"},{label:"for...in",insertText:"for [${1:index}, ${2:value}] in ${3:arr}\n ${4:local_block}\n",kind:"loop"},{label:"while",insertText:"while ${1:condition}\n ${2:local_block}\n",kind:"statement"},{label:"switch",insertText:"switch ${1:condition}\n ${2:value_1} => ${3:local_block_1}\n ${4:value_2} => ${5:local_block_2}\n => ${6:default_local_block}\n",kind:"statement"}],ao=["in","as","continue","break","else","to","by"],ge={keywords:"keyword",functions:"built-in function",variables:"built-in variable",methods:"built-in method",types:"built-in type",annotations:"annotation",constants:"built-in constant",namespace:"namespace",userDefinedVariable:"user-defined variable",userDefinedType:"user-defined type",field:"field",enum:"enum",userDefinedMethod:"user-defined method",userDefinedFunction:"user-defined function",returns:"returns",parameter:"parameter",namespaceDesc:"**Namespaces** are immutable terms that act as prefixes for groups of identifiers. A dot and another term always follow a namespace when naming Tcc functions, variables, and methods.",toTriggerParameterHints:"to trigger parameters hint"},fd={clickOnKeywordForMoreHelp:"`click` on keyword for more help"};function gd(){const a={},n={};return Object.keys(so).reduce((s,o)=>{const c=so[o],l=ge[o],{mapObj:m,keys:y}=bd(c,l);return s.keyMapList[o]=m,s.keyList[o]=y,s},{keyList:a,keyMapList:n}),{keyList:a,keyMapList:n}}function bd(a,n){const s=new Map,o=[];return a.forEach(c=>{var m;c.title=n;const l=c.originalName||c.name;l!=="for...in"&&(s.has(l)?(m=s.get(l))==null||m.push(c):(o.push(l),s.set(l,[c])))}),{mapObj:s,keys:o}}const{keyList:no,keyMapList:ct}=gd(),ps=[{title:"Variables",key:"variables",prefix:"var"},{title:"Constants",key:"constants",prefix:"const"},{title:"Functions",key:"functions",prefix:"fun"},{title:"Keywords",key:"keywords",prefix:"kw"},{title:"Types",key:"types",prefix:"type"},{title:"Operators",key:"operators",prefix:"op"},{title:"Annotations",key:"annotations",prefix:"an"}];function xd(a){return a.replace(/<.*>/,"")}class hd{constructor(){Object.defineProperty(this,"delimiter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lineBreak",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"paragraphBreak",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.delimiter="***",this.lineBreak=`
106
+ `,kind:"statement"},{label:"for...to",insertText:"for ${1:i} = 1 to ${2:to_num} by 1\n ${3:local_block}\n",kind:"loop"},{label:"for...in",insertText:"for [${1:index}, ${2:value}] in ${3:arr}\n ${4:local_block}\n",kind:"loop"},{label:"while",insertText:"while ${1:condition}\n ${2:local_block}\n",kind:"statement"},{label:"switch",insertText:"switch ${1:condition}\n ${2:value_1} => ${3:local_block_1}\n ${4:value_2} => ${5:local_block_2}\n => ${6:default_local_block}\n",kind:"statement"}],ao=["in","as","continue","break","else","to","by"],ge={keywords:"keyword",functions:"built-in function",variables:"built-in variable",methods:"built-in method",types:"built-in type",annotations:"annotation",constants:"built-in constant",namespace:"namespace",userDefinedVariable:"user-defined variable",userDefinedType:"user-defined type",field:"field",enum:"enum",userDefinedMethod:"user-defined method",userDefinedFunction:"user-defined function",returns:"returns",parameter:"parameter",namespaceDesc:"**Namespaces** are immutable terms that act as prefixes for groups of identifiers. A dot and another term always follow a namespace when naming Tcc functions, variables, and methods.",toTriggerParameterHints:"to trigger parameters hint"},fd={clickOnKeywordForMoreHelp:"`click` on keyword for more help"};function gd(){const a={},n={};return Object.keys(so).reduce((s,o)=>{const c=so[o],l=ge[o],{mapObj:m,keys:y}=bd(c,l);return s.keyMapList[o]=m,s.keyList[o]=y,s},{keyList:a,keyMapList:n}),{keyList:a,keyMapList:n}}function bd(a,n){const s=new Map,o=[];return a.forEach(c=>{var m;c.title=n;const l=c.originalName||c.name;l!=="for...in"&&(s.has(l)?(m=s.get(l))==null||m.push(c):(o.push(l),s.set(l,[c])))}),{mapObj:s,keys:o}}const{keyList:no,keyMapList:ct}=gd(),ps=[{title:"内置变量",key:"variables",prefix:"var"},{title:"常量",key:"constants",prefix:"const"},{title:"函数",key:"functions",prefix:"fun"},{title:"关键词",key:"keywords",prefix:"kw"},{title:"类型",key:"types",prefix:"type"},{title:"运算符",key:"operators",prefix:"op"},{title:"注释",key:"annotations",prefix:"an"}];function xd(a){return a.replace(/<.*>/,"")}class hd{constructor(){Object.defineProperty(this,"delimiter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lineBreak",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"paragraphBreak",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.delimiter="***",this.lineBreak=`
107
107
  `,this.paragraphBreak=`
108
108
 
109
109
  `}bold(n){return`**${n}**`}italic(n){return`*${n.replace(">","&gt;").replace("<","&lt;")}*`}pineCode(n){return`\`\`\`
@@ -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 yo=Symbol("Comlink.proxy"),tm=Symbol("Comlink.endpoint"),rm=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),_o=a=>typeof a=="object"&&a!==null||typeof a=="function",sm={canHandle:a=>_o(a)&&a[yo],serialize(a){const{port1:n,port2:s}=new MessageChannel;return go(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},am={canHandle:a=>_o(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}},fo=new Map([["proxy",sm],["throw",am]]);function nm(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function go(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(c){if(!c||!c.data)return;if(!nm(s,c.origin)){console.warn(`Invalid origin '${c.origin}' for comlink proxy`);return}const{id:l,type:m,path:y}=Object.assign({path:[]},c.data),f=(c.data.argumentList||[]).map(br);let b;try{const h=y.slice(0,-1).reduce((N,F)=>N[F],a),T=y.reduce((N,F)=>N[F],a);switch(m){case"GET":b=T;break;case"SET":h[y.slice(-1)[0]]=br(c.data.value),b=!0;break;case"APPLY":b=T.apply(h,f);break;case"CONSTRUCT":{const N=new T(...f);b=gn(N)}break;case"ENDPOINT":{const{port1:N,port2:F}=new MessageChannel;go(a,F),b=pm(N,[N])}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,N]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:l}),N),m==="RELEASE"&&(n.removeEventListener("message",o),bo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,N]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:l}),N)})}),n.start&&n.start()}function im(a){return a.constructor.name==="MessagePort"}function bo(a){im(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 xo(a){return Lr(a,{type:"RELEASE"}).then(()=>{bo(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&&xo(a)});function om(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function lm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const c=new Proxy(s,{get(l,m){if(Qs(o),m===rm)return()=>{lm(c),xo(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>c};const y=Lr(a,{type:"GET",path:n.map(f=>f.toString())}).then(br);return y.then.bind(y)}return fn(a,[...n,m])},set(l,m,y){Qs(o);const[f,b]=ea(y);return Lr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:f},b).then(br)},apply(l,m,y){Qs(o);const f=n[n.length-1];if(f===tm)return Lr(a,{type:"ENDPOINT"}).then(br);if(f==="bind")return fn(a,n.slice(0,-1));const[b,h]=ho(y);return Lr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(br)},construct(l,m){Qs(o);const[y,f]=ho(m);return Lr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:y},f).then(br)}});return om(c,a),c}function cm(a){return Array.prototype.concat.apply([],a)}function ho(a){const n=a.map(ea);return[n.map(s=>s[0]),cm(n.map(s=>s[1]))]}const wo=new WeakMap;function pm(a,n){return wo.set(a,n),a}function gn(a){return Object.assign(a,{[yo]:!0})}function ea(a){for(const[n,s]of fo)if(s.canHandle(a)){const[o,c]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},c]}return[{type:"RAW",value:a},wo.get(a)||[]]}function br(a){switch(a.type){case"HANDLER":return fo.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Lr(a,n,s){return new Promise(o=>{const c=dm();a.addEventListener("message",function l(m){!m.data||!m.data.id||m.data.id!==c||(a.removeEventListener("message",l),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:c},n),s)})}function dm(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const vo=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-DvdFfBYN.js").href:new URL("assets/scriptsRunWorker-DvdFfBYN.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"});vo.onerror=a=>{console.error(a)};async function To(a){return await Gs.setInlayHints(a)}const Do=_n(vo),ko=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-BwTU0Mcr.js").href:new URL("assets/parserTccWorker-BwTU0Mcr.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 Io(a,n=!1){const{functions:s,types:o,constants:c,variables:l,methods:m}=ct;return await ko.parseTcc(a,n,gn(To),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function mm(a,n){const{functions:s,types:o,constants:c,variables:l,methods:m}=ct;return await ko.parseLibraryCode(a,n,gn(To),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function um(a,n,s=!0){return await Do.runScript(a,n,s)}async function ym(a){return await Do.removeScript(a)}function _m(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 _m({name:"Editor Worker"})}},sn.config({paths:{vs:"https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.45.0/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const fm=(a,n)=>{const{height:s,width:o,theme:c,options:l,hasDiff:m,readOnly:y,defaultValue:f,onChange:b,onLinkOpen:h,onCursorPositionChange:T,onActionTrigger:N,onEditorDidMount:F}=a,S=O.useRef(null),R=O.useRef(null),W=O.useRef(!1),V=O.useRef(!1);O.useImperativeHandle(n,()=>({setOriginalScript(E){var H;(H=S.current)==null||H.setOriginalScript(E)},setScript(E){var H;(H=S.current)==null||H.setValue(E)},gotoLine(){var E;(E=S.current)==null||E.gotoLine()},getEditorLayout(){var E;return(E=S.current)==null?void 0:E.getEditorLayout()},setPosition(E,H){var Q;(Q=S.current)==null||Q.setPosition({column:E,lineNumber:H})},setModelMarkers(E){var H;V.current=!0,(H=S.current)==null||H.setModelMarkers(E),setTimeout(()=>{V.current=!1},2e3)},focus(){var E;(E=S.current)==null||E.focus()}})),O.useEffect(()=>{var E,H;m?(H=S.current)==null||H.addDiffDecorations():(E=S.current)==null||E.removeDiffDecorations()},[m]),O.useEffect(()=>{c&&ke.editor.setTheme(c)},[c]),O.useEffect(()=>{var E;(E=S.current)==null||E.updateActionTrigger(N)},[N]),O.useEffect(()=>{var E;h&&((E=S.current)==null||E.addLinkOpenFunc(h))},[h]);function Y(E,H){var ie,Qe;zt.initBuiltinsTrees(),Gs.setEditor(E),S.current=new em(E,H,N),h&&((ie=S.current)==null||ie.addLinkOpenFunc(h)),m&&((Qe=S.current)==null||Qe.addDiffDecorations()),kd(E),requestAnimationFrame(B);const Q=E.getValue();S.current.onChangeCursorPosition(T),b&&b(Q),!y&&U(Q),F&&F()}const U=O.useCallback(async E=>{var $e;const H=Date.now();W.current=!1;const{errors:Q,functions:ie,methods:Qe,types:St,variables:Ue,overloadsFuncs:Ke,imports:J,enums:be}=await Io(E),Ee=new Map(Object.entries(ie)),Me=new Map(Object.entries(Qe)),pt=new Map(Object.entries(St)),ht=new Map(Object.entries(Ue)),se=new Map(Object.entries(J)),xe=new Map(Object.entries(be));gr.setUserDefined({functions:Ee,methods:Me,types:pt,variables:ht,imports:se,enums:xe},Ke),zt.setUserDefind(Ee,pt,ht,Me,xe);const Pe=Q.map(Nt=>({...Nt,severity:Nt.type||ke.MarkerSeverity.Error}));if(y)return;!W.current&&!V.current&&Pe.length&&(($e=S.current)==null||$e.setModelMarkers(Pe));const Et=Date.now();console.log((Et-H)/1e3)},[y]),K=O.useMemo(()=>qd.debounce(U,1500),[U]);function A(E){var H;if(y){U(E||"");return}W.current=!0,Gs.clearInlayHints(),(H=S.current)==null||H.setModelMarkers([]),E!==void 0&&(b&&b(E),K(E))}const B=O.useCallback(()=>{var H,Q;const E=(H=R.current)==null?void 0:H.getBoundingClientRect();(Q=S.current)==null||Q.setEditorLayout((E==null?void 0:E.height)||0,E==null?void 0:E.width)},[]);return O.useEffect(()=>{const E=()=>{window.requestAnimationFrame(B)},H=new ResizeObserver(E);return R.current&&H.observe(R.current),()=>{var Q;R.current&&H.unobserve(R.current),H.disconnect(),(Q=S.current)==null||Q.dispose()}},[]),M.jsx("div",{ref:R,children:M.jsx(yd,{height:s,width:o||"100%",defaultLanguage:Se,defaultValue:f||`indicator("我的脚本")
144
+ */const yo=Symbol("Comlink.proxy"),tm=Symbol("Comlink.endpoint"),rm=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),_o=a=>typeof a=="object"&&a!==null||typeof a=="function",sm={canHandle:a=>_o(a)&&a[yo],serialize(a){const{port1:n,port2:s}=new MessageChannel;return go(a,n),[s,[s]]},deserialize(a){return a.start(),_n(a)}},am={canHandle:a=>_o(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}},fo=new Map([["proxy",sm],["throw",am]]);function nm(a,n){for(const s of a)if(n===s||s==="*"||s instanceof RegExp&&s.test(n))return!0;return!1}function go(a,n=globalThis,s=["*"]){n.addEventListener("message",function o(c){if(!c||!c.data)return;if(!nm(s,c.origin)){console.warn(`Invalid origin '${c.origin}' for comlink proxy`);return}const{id:l,type:m,path:y}=Object.assign({path:[]},c.data),f=(c.data.argumentList||[]).map(br);let b;try{const h=y.slice(0,-1).reduce((N,F)=>N[F],a),T=y.reduce((N,F)=>N[F],a);switch(m){case"GET":b=T;break;case"SET":h[y.slice(-1)[0]]=br(c.data.value),b=!0;break;case"APPLY":b=T.apply(h,f);break;case"CONSTRUCT":{const N=new T(...f);b=gn(N)}break;case"ENDPOINT":{const{port1:N,port2:F}=new MessageChannel;go(a,F),b=pm(N,[N])}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,N]=ea(h);n.postMessage(Object.assign(Object.assign({},T),{id:l}),N),m==="RELEASE"&&(n.removeEventListener("message",o),bo(n),yn in a&&typeof a[yn]=="function"&&a[yn]())}).catch(h=>{const[T,N]=ea({value:new TypeError("Unserializable return value"),[Ys]:0});n.postMessage(Object.assign(Object.assign({},T),{id:l}),N)})}),n.start&&n.start()}function im(a){return a.constructor.name==="MessagePort"}function bo(a){im(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 xo(a){return Lr(a,{type:"RELEASE"}).then(()=>{bo(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&&xo(a)});function om(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function lm(a){Js&&Js.unregister(a)}function fn(a,n=[],s=function(){}){let o=!1;const c=new Proxy(s,{get(l,m){if(Qs(o),m===rm)return()=>{lm(c),xo(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>c};const y=Lr(a,{type:"GET",path:n.map(f=>f.toString())}).then(br);return y.then.bind(y)}return fn(a,[...n,m])},set(l,m,y){Qs(o);const[f,b]=ea(y);return Lr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:f},b).then(br)},apply(l,m,y){Qs(o);const f=n[n.length-1];if(f===tm)return Lr(a,{type:"ENDPOINT"}).then(br);if(f==="bind")return fn(a,n.slice(0,-1));const[b,h]=ho(y);return Lr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(br)},construct(l,m){Qs(o);const[y,f]=ho(m);return Lr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:y},f).then(br)}});return om(c,a),c}function cm(a){return Array.prototype.concat.apply([],a)}function ho(a){const n=a.map(ea);return[n.map(s=>s[0]),cm(n.map(s=>s[1]))]}const wo=new WeakMap;function pm(a,n){return wo.set(a,n),a}function gn(a){return Object.assign(a,{[yo]:!0})}function ea(a){for(const[n,s]of fo)if(s.canHandle(a)){const[o,c]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},c]}return[{type:"RAW",value:a},wo.get(a)||[]]}function br(a){switch(a.type){case"HANDLER":return fo.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Lr(a,n,s){return new Promise(o=>{const c=dm();a.addEventListener("message",function l(m){!m.data||!m.data.id||m.data.id!==c||(a.removeEventListener("message",l),o(m.data))}),a.start&&a.start(),a.postMessage(Object.assign({id:c},n),s)})}function dm(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const vo=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-CRZrOXN_.js").href:new URL("assets/scriptsRunWorker-CRZrOXN_.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"});vo.onerror=a=>{console.error(a)};async function To(a){return await Gs.setInlayHints(a)}const Do=_n(vo),ko=_n(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-C_OkdWJ6.js").href:new URL("assets/parserTccWorker-C_OkdWJ6.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 Io(a,n=!1){const{functions:s,types:o,constants:c,variables:l,methods:m}=ct;return await ko.parseTcc(a,n,gn(To),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function mm(a,n){const{functions:s,types:o,constants:c,variables:l,methods:m}=ct;return await ko.parseLibraryCode(a,n,gn(To),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function um(a,n,s=!0){return await Do.runScript(a,n,s)}async function ym(a){return await Do.removeScript(a)}function _m(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 _m({name:"Editor Worker"})}},sn.config({paths:{vs:"https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.45.0/min/vs"},"vs/nls":{availableLanguages:{"*":"zh-cn"}}});const fm=(a,n)=>{const{height:s,width:o,theme:c,options:l,hasDiff:m,readOnly:y,defaultValue:f,onChange:b,onLinkOpen:h,onCursorPositionChange:T,onActionTrigger:N,onEditorDidMount:F}=a,S=O.useRef(null),R=O.useRef(null),W=O.useRef(!1),V=O.useRef(!1);O.useImperativeHandle(n,()=>({setOriginalScript(E){var H;(H=S.current)==null||H.setOriginalScript(E)},setScript(E){var H;(H=S.current)==null||H.setValue(E)},gotoLine(){var E;(E=S.current)==null||E.gotoLine()},getEditorLayout(){var E;return(E=S.current)==null?void 0:E.getEditorLayout()},setPosition(E,H){var Q;(Q=S.current)==null||Q.setPosition({column:E,lineNumber:H})},setModelMarkers(E){var H;V.current=!0,(H=S.current)==null||H.setModelMarkers(E),setTimeout(()=>{V.current=!1},2e3)},focus(){var E;(E=S.current)==null||E.focus()}})),O.useEffect(()=>{var E,H;m?(H=S.current)==null||H.addDiffDecorations():(E=S.current)==null||E.removeDiffDecorations()},[m]),O.useEffect(()=>{c&&ke.editor.setTheme(c)},[c]),O.useEffect(()=>{var E;(E=S.current)==null||E.updateActionTrigger(N)},[N]),O.useEffect(()=>{var E;h&&((E=S.current)==null||E.addLinkOpenFunc(h))},[h]);function Y(E,H){var ie,Qe;zt.initBuiltinsTrees(),Gs.setEditor(E),S.current=new em(E,H,N),h&&((ie=S.current)==null||ie.addLinkOpenFunc(h)),m&&((Qe=S.current)==null||Qe.addDiffDecorations()),kd(E),requestAnimationFrame(B);const Q=E.getValue();S.current.onChangeCursorPosition(T),b&&b(Q),!y&&U(Q),F&&F()}const U=O.useCallback(async E=>{var $e;const H=Date.now();W.current=!1;const{errors:Q,functions:ie,methods:Qe,types:St,variables:Ue,overloadsFuncs:Ke,imports:J,enums:be}=await Io(E),Ee=new Map(Object.entries(ie)),Me=new Map(Object.entries(Qe)),pt=new Map(Object.entries(St)),ht=new Map(Object.entries(Ue)),se=new Map(Object.entries(J)),xe=new Map(Object.entries(be));gr.setUserDefined({functions:Ee,methods:Me,types:pt,variables:ht,imports:se,enums:xe},Ke),zt.setUserDefind(Ee,pt,ht,Me,xe);const Pe=Q.map(Nt=>({...Nt,severity:Nt.type||ke.MarkerSeverity.Error}));if(y)return;!W.current&&!V.current&&Pe.length&&(($e=S.current)==null||$e.setModelMarkers(Pe));const Et=Date.now();console.log((Et-H)/1e3)},[y]),K=O.useMemo(()=>qd.debounce(U,1500),[U]);function A(E){var H;if(y){U(E||"");return}W.current=!0,Gs.clearInlayHints(),(H=S.current)==null||H.setModelMarkers([]),E!==void 0&&(b&&b(E),K(E))}const B=O.useCallback(()=>{var H,Q;const E=(H=R.current)==null?void 0:H.getBoundingClientRect();(Q=S.current)==null||Q.setEditorLayout((E==null?void 0:E.height)||0,E==null?void 0:E.width)},[]);return O.useEffect(()=>{const E=()=>{window.requestAnimationFrame(B)},H=new ResizeObserver(E);return R.current&&H.observe(R.current),()=>{var Q;R.current&&H.unobserve(R.current),H.disconnect(),(Q=S.current)==null||Q.dispose()}},[]),M.jsx("div",{ref:R,children:M.jsx(yd,{height:s,width:o||"100%",defaultLanguage:Se,defaultValue:f||`indicator("我的脚本")
145
145
  plot(close)
146
146
  `,theme:c||"vs-dark",className:`tvue-script ${c||"vs-dark"}`,options:{colorDecorators:!0,useShadowDOM:!1,matchOnWordStartOnly:!0,automaticLayout:!1,unicodeHighlight:{allowedCharacters:{" ":!0}},suggest:{filterGraceful:!0},fontSize:13,...y?Ld:{},readOnlyMessage:{value:"该脚本是只读的。它无法被编辑。"},...l},onMount:Y,onChange:A})})},gm=O.forwardRef(fm),bm=a=>{const{theme:n,modified:s,original:o,height:c,width:l,renderSideBySide:m=!0}=a,y=O.useCallback((f,b)=>{b.languages.register({id:Se}),b.editor.defineTheme("vs-dark",cn),b.editor.defineTheme("vs",ln),b.languages.setMonarchTokensProvider(Se,Nr),b.languages.setLanguageConfiguration(Se,on)},[]);return M.jsx(cd,{height:c||"90vh",width:l||"100%",theme:n||"vs-dark",options:{readOnly:!0,renderSideBySide:m,scrollBeyondLastLine:!1},language:Se,modified:s,original:o,onMount:y})};I.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"}(I.VMarkerSeverity||(I.VMarkerSeverity={}));var ta={},xm=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(c){a.addRange(c)}),n&&n.focus()}},hm=xm,Ao={"text/plain":"Text","text/html":"Url",default:"Text"},wm="Copy to clipboard: #{key}, Enter";function vm(a){var n=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return a.replace(/#{\s*key\s*}/g,n)}function Tm(a,n){var s,o,c,l,m,y,f=!1;n||(n={}),s=n.debug||!1;try{c=hm(),l=document.createRange(),m=document.getSelection(),y=document.createElement("span"),y.textContent=a,y.ariaHidden="true",y.style.all="unset",y.style.position="fixed",y.style.top=0,y.style.clip="rect(0, 0, 0, 0)",y.style.whiteSpace="pre",y.style.webkitUserSelect="text",y.style.MozUserSelect="text",y.style.msUserSelect="text",y.style.userSelect="text",y.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=Ao[n.format]||Ao.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(y),l.selectNodeContents(y),m.addRange(l);var b=document.execCommand("copy");if(!b)throw new Error("copy command was unsuccessful");f=!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),f=!0}catch(T){s&&console.error("unable to copy using clipboardData: ",T),s&&console.error("falling back to prompt"),o=vm("message"in n?n.message:wm),window.prompt(o,a)}}finally{m&&(typeof m.removeRange=="function"?m.removeRange(l):m.removeAllRanges()),y&&document.body.removeChild(y),c()}return f}var Dm=Tm;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=qo(O),km=qo(Dm),Im=["text","onCopy","options","children"];function qo(a){return a&&a.__esModule?a:{default:a}}function Co(a,n){var s=Object.keys(a);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);n&&(o=o.filter(function(c){return Object.getOwnPropertyDescriptor(a,c).enumerable})),s.push.apply(s,o)}return s}function zo(a){for(var n=1;n<arguments.length;n++){var s=arguments[n]!=null?arguments[n]:{};n%2?Co(Object(s),!0).forEach(function(o){hn(a,o,s[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):Co(Object(s)).forEach(function(o){Object.defineProperty(a,o,Object.getOwnPropertyDescriptor(s,o))})}return a}function Am(a,n){if(a==null)return{};var s=qm(a,n),o,c;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(a);for(c=0;c<l.length;c++)o=l[c],!(n.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(a,o)&&(s[o]=a[o])}return s}function qm(a,n){if(a==null)return{};var s={},o=Object.keys(a),c,l;for(l=0;l<o.length;l++)c=o[l],!(n.indexOf(c)>=0)&&(s[c]=a[c]);return s}function Cm(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function So(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 zm(a,n,s){return n&&So(a.prototype,n),s&&So(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function Sm(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,c){return o.__proto__=c,o},xn(a,n)}function Em(a){var n=Lm();return function(){var o=sa(a),c;if(n){var l=sa(this).constructor;c=Reflect.construct(o,arguments,l)}else c=o.apply(this,arguments);return Nm(this,c)}}function Nm(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 Eo(a)}function Eo(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Lm(){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 No=function(a){Sm(s,a);var n=Em(s);function s(){var o;Cm(this,s);for(var c=arguments.length,l=new Array(c),m=0;m<c;m++)l[m]=arguments[m];return o=n.call.apply(n,[this].concat(l)),hn(Eo(o),"onClick",function(y){var f=o.props,b=f.text,h=f.onCopy,T=f.children,N=f.options,F=ra.default.Children.only(T),S=(0,km.default)(b,N);h&&h(b,S),F&&F.props&&typeof F.props.onClick=="function"&&F.props.onClick(y)}),o}return zm(s,[{key:"render",value:function(){var c=this.props;c.text,c.onCopy,c.options;var l=c.children,m=Am(c,Im),y=ra.default.Children.only(l);return ra.default.cloneElement(y,zo(zo({},m),{},{onClick:this.onClick}))}}]),s}(ra.default.PureComponent);ta.CopyToClipboard=No,hn(No,"defaultProps",{onCopy:void 0,options:void 0});var Mm=ta,wn=Mm.CopyToClipboard;wn.CopyToClipboard=wn;var Pm=wn;const vn=ip(Pm);async function Om(a,n=0){const s=a[n];if(!s)return;const{name:o,args:c,type:l,desc:m,examples:y,remarks:f,seeAlso:b,syntax:h,detailedDesc:T,fields:N,returns:F}=s,S={name:o};if(a.length>1&&(S.overloads=`${a.length} overloads`),l&&(S.type=l),c&&(S.name=`${o}()`,S.args=c.map(R=>{const{name:W,desc:V,displayType:Y}=R;return{label:`${W} (${Y})`,desc:V&&xr(V)}})),m&&(S.desc=m.map(R=>xr(R))),y&&(S.originalExample=y.join(`
147
147
  `),S.examples=await ke.editor.colorize(S.originalExample,Se,{tabSize:4})),T){S.detailedDesc=[];for(const R of T){const{desc:W,examples:V}=R;let Y=W.map(A=>xr(A)),U,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.212",
3
+ "version": "0.0.214",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"
@@ -26,6 +26,7 @@
26
26
  "comlink": "^4.4.1",
27
27
  "dayjs": "^1.11.10",
28
28
  "diff": "^5.2.0",
29
+ "ky": "^1.7.2",
29
30
  "lodash": "^4.17.21",
30
31
  "mathjs": "^12.4.1",
31
32
  "ml-matrix": "^6.11.0",