@guihz/trading-vue-editor-tes 0.0.195 → 0.0.197
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/{parserTccWorker-BRdbggcL.js → parserTccWorker-0LoB3TSk.js} +213 -158
- package/lib/assets/{scriptsRunWorker-BD3Df3Mn.js → scriptsRunWorker-2p2wiWal.js} +17 -17
- package/lib/components/editor/parseScript/buildInFuncNamespace/strategy.d.ts +7 -0
- package/lib/components/editor/parseScript/buildInVarNamespace/strategy.d.ts +1 -0
- package/lib/components/editor/parseScript/parseToLibJs.d.ts +18 -0
- package/lib/components/editor/parseScript/utils.d.ts +1 -0
- package/lib/trading-vue-editor.js +2 -2
- package/lib/trading-vue-editor.umd.cjs +1 -1
- package/package.json +1 -1
@@ -94,6 +94,10 @@ export interface IOrder extends IOrderArgs {
|
|
94
94
|
trading_loss_percent?: number;
|
95
95
|
commission?: number;
|
96
96
|
original_qty?: number;
|
97
|
+
in_low?: number;
|
98
|
+
in_high?: number;
|
99
|
+
out_low?: number;
|
100
|
+
out_high?: number;
|
97
101
|
}
|
98
102
|
interface IRisk {
|
99
103
|
allow_entry_in?: VDirection;
|
@@ -129,6 +133,7 @@ export default class Strategy {
|
|
129
133
|
private _riskNamespace;
|
130
134
|
private _updateOptions;
|
131
135
|
private _id;
|
136
|
+
private _maxDrawdownVerifyIndex;
|
132
137
|
constructor(variables: BuiltInVariables, options: IKeyObjectValue, mintick: number, errorListener: TccErrorListener, id: string);
|
133
138
|
get orders(): IOrder[];
|
134
139
|
get historyOrders(): IOrder[];
|
@@ -159,6 +164,7 @@ export default class Strategy {
|
|
159
164
|
convert_to_symbol({ value }: IArgs): number | undefined;
|
160
165
|
default_entry_qty({ fill_price }: IArgs): number;
|
161
166
|
private _calcDefaultQty;
|
167
|
+
private _getLen;
|
162
168
|
private _getCapital;
|
163
169
|
private _calcProfitAndLoss;
|
164
170
|
private _calcProfitAndLossHandle;
|
@@ -186,6 +192,7 @@ export default class Strategy {
|
|
186
192
|
private _entryOrderHandle;
|
187
193
|
private _orderOrderHandle;
|
188
194
|
private _closeOrderHandle;
|
195
|
+
private _processCloseOrders;
|
189
196
|
private _exitOrderHandle;
|
190
197
|
private _exit;
|
191
198
|
private _ordersToExit;
|
@@ -6,18 +6,31 @@ export default class ParseToLibJs {
|
|
6
6
|
private _prefixNameConst;
|
7
7
|
private _userTypes;
|
8
8
|
private _isInFunc;
|
9
|
+
private _currentFuncName?;
|
9
10
|
private _varlist;
|
10
11
|
private _memberIndexList;
|
11
12
|
private _blockCount;
|
12
13
|
private _libTitle;
|
13
14
|
private _exportEles;
|
14
15
|
private _inputCount;
|
16
|
+
private _count;
|
17
|
+
private _isSwitch;
|
18
|
+
private _isInLoop;
|
19
|
+
private _codesCol;
|
20
|
+
private _dependsObj;
|
21
|
+
private _enums;
|
22
|
+
private _preRunMembers;
|
23
|
+
private _isInConditionalStmt;
|
24
|
+
private _preRunMembersFuncs;
|
25
|
+
private _preRunMemberFuncsCount;
|
26
|
+
private __count;
|
15
27
|
constructor(prefix: string, title: string);
|
16
28
|
parser(values: IKeyObjectValue[]): string | undefined;
|
17
29
|
private _parserStmt;
|
18
30
|
private _parserEnumStatement;
|
19
31
|
private _parserTypeStatement;
|
20
32
|
private _parserVarBlockStmt;
|
33
|
+
private _getDepends;
|
21
34
|
private _parserForToStatement;
|
22
35
|
private _parserForInStatement;
|
23
36
|
private _parserAgainAssign;
|
@@ -40,13 +53,18 @@ export default class ParseToLibJs {
|
|
40
53
|
private _parserSingleExpression;
|
41
54
|
private _parserAdditiveExpression;
|
42
55
|
private _parserMemberIndexExpression;
|
56
|
+
private _getOtherVarMemberIndexs;
|
43
57
|
private _getUserVarMemberIndexs;
|
44
58
|
private _parseLiteral;
|
45
59
|
private _colorToRgba;
|
46
60
|
private _parserName;
|
61
|
+
private _setDepend;
|
47
62
|
private _parserMethodExpression;
|
48
63
|
private _parserMethodElement;
|
49
64
|
private _parserArguments;
|
65
|
+
private _requestParamsHandle;
|
66
|
+
private _getExpressionContext;
|
67
|
+
private _getDependsCode;
|
50
68
|
private _parserBrackethesized;
|
51
69
|
private _functionalProcess;
|
52
70
|
}
|
@@ -10,3 +10,4 @@ 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;
|
12
12
|
export declare function decode(base64: string): string;
|
13
|
+
export declare function decimalTrunc(num: number, len: number): number;
|
@@ -67593,14 +67593,14 @@ function ir(a, n, r) {
|
|
67593
67593
|
function oh() {
|
67594
67594
|
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
67595
67595
|
}
|
67596
|
-
const Fp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-
|
67596
|
+
const Fp = new Worker(new URL("" + new URL("assets/scriptsRunWorker-2p2wiWal.js", import.meta.url).href, import.meta.url), { type: "module", name: "Run TccScript Server" });
|
67597
67597
|
Fp.onerror = (a) => {
|
67598
67598
|
console.error(a);
|
67599
67599
|
};
|
67600
67600
|
async function Rp(a) {
|
67601
67601
|
return await Ja.setInlayHints(a);
|
67602
67602
|
}
|
67603
|
-
const Bp = ji(Fp), Kp = ji(new Worker(new URL("" + new URL("assets/parserTccWorker-
|
67603
|
+
const Bp = ji(Fp), Kp = ji(new Worker(new URL("" + new URL("assets/parserTccWorker-0LoB3TSk.js", import.meta.url).href, import.meta.url), { type: "module", name: "Parser TccScript Server" }));
|
67604
67604
|
async function lh(a, n = !1) {
|
67605
67605
|
const { functions: r, types: o, constants: c, variables: l, methods: m } = ht;
|
67606
67606
|
return await Kp.parseTcc(a, n, Hi(Rp), { functions: Object.fromEntries(r), methods: Object.fromEntries(m), types: Object.fromEntries(o), constants: Object.fromEntries(c), variables: Object.fromEntries(l) });
|
@@ -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"),sm=Symbol("Comlink.endpoint"),am=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",nm={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)}},im={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",nm],["throw",im]]);function om(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(c){if(!c||!c.data)return;if(!om(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(xr);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]]=xr(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;bo(a,F),b=mm(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),xo(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 lm(a){return a.constructor.name==="MessagePort"}function xo(a){lm(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 Mr(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 cm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function pm(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===am)return()=>{pm(c),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>c};const y=Mr(a,{type:"GET",path:n.map(f=>f.toString())}).then(xr);return y.then.bind(y)}return fn(a,[...n,m])},set(l,m,y){Qs(o);const[f,b]=ea(y);return Mr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:f},b).then(xr)},apply(l,m,y){Qs(o);const f=n[n.length-1];if(f===sm)return Mr(a,{type:"ENDPOINT"}).then(xr);if(f==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(y);return Mr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(xr)},construct(l,m){Qs(o);const[y,f]=wo(m);return Mr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:y},f).then(xr)}});return cm(c,a),c}function dm(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),dm(n.map(s=>s[1]))]}const vo=new WeakMap;function mm(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,c]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},c]}return[{type:"RAW",value:a},vo.get(a)||[]]}function xr(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Mr(a,n,s){return new Promise(o=>{const c=um();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 um(){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-
|
144
|
+
*/const _o=Symbol("Comlink.proxy"),sm=Symbol("Comlink.endpoint"),am=Symbol("Comlink.releaseProxy"),yn=Symbol("Comlink.finalizer"),Ys=Symbol("Comlink.thrown"),fo=a=>typeof a=="object"&&a!==null||typeof a=="function",nm={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)}},im={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",nm],["throw",im]]);function om(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(c){if(!c||!c.data)return;if(!om(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(xr);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]]=xr(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;bo(a,F),b=mm(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),xo(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 lm(a){return a.constructor.name==="MessagePort"}function xo(a){lm(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 Mr(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 cm(a,n){const s=(Zs.get(n)||0)+1;Zs.set(n,s),Js&&Js.register(a,n,a)}function pm(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===am)return()=>{pm(c),ho(a),o=!0};if(m==="then"){if(n.length===0)return{then:()=>c};const y=Mr(a,{type:"GET",path:n.map(f=>f.toString())}).then(xr);return y.then.bind(y)}return fn(a,[...n,m])},set(l,m,y){Qs(o);const[f,b]=ea(y);return Mr(a,{type:"SET",path:[...n,m].map(h=>h.toString()),value:f},b).then(xr)},apply(l,m,y){Qs(o);const f=n[n.length-1];if(f===sm)return Mr(a,{type:"ENDPOINT"}).then(xr);if(f==="bind")return fn(a,n.slice(0,-1));const[b,h]=wo(y);return Mr(a,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:b},h).then(xr)},construct(l,m){Qs(o);const[y,f]=wo(m);return Mr(a,{type:"CONSTRUCT",path:n.map(b=>b.toString()),argumentList:y},f).then(xr)}});return cm(c,a),c}function dm(a){return Array.prototype.concat.apply([],a)}function wo(a){const n=a.map(ea);return[n.map(s=>s[0]),dm(n.map(s=>s[1]))]}const vo=new WeakMap;function mm(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,c]=s.serialize(a);return[{type:"HANDLER",name:n,value:o},c]}return[{type:"RAW",value:a},vo.get(a)||[]]}function xr(a){switch(a.type){case"HANDLER":return go.get(a.name).deserialize(a.value);case"RAW":return a.value}}function Mr(a,n,s){return new Promise(o=>{const c=um();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 um(){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-2p2wiWal.js").href:new URL("assets/scriptsRunWorker-2p2wiWal.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-0LoB3TSk.js").href:new URL("assets/parserTccWorker-0LoB3TSk.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:c,variables:l,methods:m}=pt;return await Io.parseTcc(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function ym(a,n){const{functions:s,types:o,constants:c,variables:l,methods:m}=pt;return await Io.parseLibraryCode(a,n,gn(Do),{functions:Object.fromEntries(s),methods:Object.fromEntries(m),types:Object.fromEntries(o),constants:Object.fromEntries(c),variables:Object.fromEntries(l)})}async function qo(a,n,s=!0){return await ko.runScript(a,n,s)}async function _m(a){return await ko.removeScript(a)}function fm(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 fm({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"}}});let Co={};const gm=(a,n)=>{const{height:s,width:o,theme:c,options:l,hasDiff:m,readOnly:y,defaultValue:f,onChange:b,onLinkOpen:h,onDeclareConfigChange:T,onCursorPositionChange:N,onActionTrigger:F,onEditorDidMount:O}=a,L=R.useRef(null),H=R.useRef(null),V=R.useRef(!1);R.useImperativeHandle(n,()=>({setOriginalScript(S){var W;(W=L.current)==null||W.setOriginalScript(S)},setScript(S){var W;(W=L.current)==null||W.setValue(S)},gotoLine(){var S;(S=L.current)==null||S.gotoLine()},getEditorLayout(){var S;return(S=L.current)==null?void 0:S.getEditorLayout()},setPosition(S,W){var Q;(Q=L.current)==null||Q.setPosition({column:S,lineNumber:W})},setModelMarkers(S){var W;(W=L.current)==null||W.setModelMarkers(S)},focus(){var S;(S=L.current)==null||S.focus()}})),R.useEffect(()=>{var S,W;m?(W=L.current)==null||W.addDiffDecorations():(S=L.current)==null||S.removeDiffDecorations()},[m]),R.useEffect(()=>{c&&ke.editor.setTheme(c)},[c]),R.useEffect(()=>{var S;(S=L.current)==null||S.updateActionTrigger(F)},[F]),R.useEffect(()=>{var S;h&&((S=L.current)==null||S.addLinkOpenFunc(h))},[h]);function Y(S,W){var ie,Ze;St.initBuiltinsTrees(),Gs.setEditor(S),L.current=new rm(S,W,F),h&&((ie=L.current)==null||ie.addLinkOpenFunc(h)),m&&((Ze=L.current)==null||Ze.addDiffDecorations()),qd(S),requestAnimationFrame(B);const Q=S.getValue();L.current.onChangeCursorPosition(N),b&&b(Q),!y&&U(Q),O&&O()}const U=R.useCallback(async S=>{var Lt;const W=Date.now();V.current=!1;const{errors:Q,functions:ie,methods:Ze,types:Et,variables:Ue,overloadsFuncs:Ke,imports:J,preParserCode:be,enums:Le}=await Ao(S),Me=new Map(Object.entries(ie)),dt=new Map(Object.entries(Ze)),wt=new Map(Object.entries(Et)),se=new Map(Object.entries(Ue)),he=new Map(Object.entries(J)),Pe=new Map(Object.entries(Le));br.setUserDefined({functions:Me,methods:dt,types:wt,variables:se,imports:he,enums:Pe},Ke),St.setUserDefind(Me,wt,se,dt,Pe);const Nt=Q.map(He=>({...He,severity:He.type||ke.MarkerSeverity.Error}));if(y)return;try{const He=await qo(be||"",{isPreParser:!0});(!io.isEqual(He,Co)||Q.length)&&(He.errors=He.errors.concat(Q),Co=He,T&&T(He))}catch(He){console.log(He),Q.push({message:He.message,startLineNumber:0,endLineNumber:0,startColumn:0,endColumn:0})}!V.current&&((Lt=L.current)==null||Lt.setModelMarkers(Nt));const je=Date.now();console.log((je-W)/1e3)},[T,y]),K=R.useMemo(()=>io.debounce(U,1500),[U]);function A(S){var W;if(y){U(S||"");return}V.current=!0,Gs.clearInlayHints(),(W=L.current)==null||W.setModelMarkers([]),S!==void 0&&(b&&b(S),K(S))}const B=R.useCallback(()=>{var W,Q;const S=(W=H.current)==null?void 0:W.getBoundingClientRect();(Q=L.current)==null||Q.setEditorLayout((S==null?void 0:S.height)||0,S==null?void 0:S.width)},[]);return R.useEffect(()=>{const S=()=>{window.requestAnimationFrame(B)},W=new ResizeObserver(S);return H.current&&W.observe(H.current),()=>{var Q;H.current&&W.unobserve(H.current),W.disconnect(),(Q=L.current)==null||Q.dispose()}},[]),M.jsx("div",{ref:H,children:M.jsx(gd,{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?Pd:{},readOnlyMessage:{value:"该脚本是只读的。它无法被编辑。"},...l},onMount:Y,onChange:A})})},bm=R.forwardRef(gm),xm=a=>{const{theme:n,modified:s,original:o,height:c,width:l,renderSideBySide:m=!0}=a,y=R.useCallback((f,b)=>{b.languages.register({id:Se}),b.editor.defineTheme("vs-dark",cn),b.editor.defineTheme("vs",ln),b.languages.setMonarchTokensProvider(Se,Lr),b.languages.setLanguageConfiguration(Se,on)},[]);return M.jsx(md,{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={},hm=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()}},wm=hm,zo={"text/plain":"Text","text/html":"Url",default:"Text"},vm="Copy to clipboard: #{key}, Enter";function Tm(a){var n=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return a.replace(/#{\s*key\s*}/g,n)}function Dm(a,n){var s,o,c,l,m,y,f=!1;n||(n={}),s=n.debug||!1;try{c=wm(),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=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(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=Tm("message"in n?n.message:vm),window.prompt(o,a)}}finally{m&&(typeof m.removeRange=="function"?m.removeRange(l):m.removeAllRanges()),y&&document.body.removeChild(y),c()}return f}var km=Dm;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(R),Im=So(km),Am=["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(c){return Object.getOwnPropertyDescriptor(a,c).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 qm(a,n){if(a==null)return{};var s=Cm(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 Cm(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 zm(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 Sm(a,n,s){return n&&Lo(a.prototype,n),s&&Lo(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function Em(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 Nm(a){var n=Mm();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 Lm(this,c)}}function Lm(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 Mm(){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){Em(s,a);var n=Nm(s);function s(){var o;zm(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(Mo(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),O=(0,Im.default)(b,N);h&&h(b,O),F&&F.props&&typeof F.props.onClick=="function"&&F.props.onClick(y)}),o}return Sm(s,[{key:"render",value:function(){var c=this.props;c.text,c.onCopy,c.options;var l=c.children,m=qm(c,Am),y=ra.default.Children.only(l);return ra.default.cloneElement(y,No(No({},m),{},{onClick:this.onClick}))}}]),s}(ra.default.PureComponent);ta.CopyToClipboard=Po,hn(Po,"defaultProps",{onCopy:void 0,options:void 0});var Pm=ta,wn=Pm.CopyToClipboard;wn.CopyToClipboard=wn;var Om=wn;const vn=cp(Om);async function Rm(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,O={name:o};if(a.length>1&&(O.overloads=`${a.length} overloads`),l&&(O.type=l),c&&(O.name=`${o}()`,O.args=c.map(L=>{const{name:H,desc:V,displayType:Y}=L;return{label:`${H} (${Y})`,desc:V&&hr(V)}})),m&&(O.desc=m.map(L=>hr(L))),y&&(O.originalExample=y.join(`
|
147
147
|
`),O.examples=await ke.editor.colorize(O.originalExample,Se,{tabSize:4})),T){O.detailedDesc=[];for(const L of T){const{desc:H,examples:V}=L;let Y=H.map(A=>hr(A)),U,K;V&&(K=V.join(`
|