@guihz/trading-vue-editor-tes 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,7 @@ interface IProps {
15
15
  }
16
16
  export interface IRefs {
17
17
  saveScript: () => void;
18
+ gotoLine: () => void;
18
19
  setScript: (code: string) => void;
19
20
  }
20
21
  declare const TradingEditorComponent: import("react").ForwardRefExoticComponent<IProps & import("react").RefAttributes<IRefs>>;
@@ -64900,7 +64900,7 @@ const Zg = ({ height: n, width: s, theme: a, options: l, hasDiff: u, onChange: p
64900
64900
  (Ne = b.current) == null || Ne.setModelMarkers(dt);
64901
64901
  const Tt = Date.now();
64902
64902
  console.log((Tt - L) / 1e3);
64903
- }, [m]), z = Wh(() => cg.debounce(k, 5e3), [k]);
64903
+ }, [m]), z = Wh(() => cg.debounce(k, 1e3), [k]);
64904
64904
  function E(R) {
64905
64905
  var L;
64906
64906
  (L = b.current) == null || L.setModelMarkers([]), localStorage.setItem(uc, R || ""), R !== void 0 && (R = R + `
@@ -137,7 +137,7 @@ function print() { __p += __j.call(arguments, '') }
137
137
  * SPDX-License-Identifier: Apache-2.0
138
138
  */const Yn=Symbol("Comlink.proxy"),Td=Symbol("Comlink.endpoint"),Id=Symbol("Comlink.releaseProxy"),ri=Symbol("Comlink.finalizer"),$a=Symbol("Comlink.thrown"),Kn=n=>typeof n=="object"&&n!==null||typeof n=="function",Dd={canHandle:n=>Kn(n)&&n[Yn],serialize(n){const{port1:s,port2:a}=new MessageChannel;return Zn(n,s),[a,[a]]},deserialize(n){return n.start(),ai(n)}},kd={canHandle:n=>Kn(n)&&$a in n,serialize({value:n}){let s;return n instanceof Error?s={isError:!0,value:{message:n.message,name:n.name,stack:n.stack}}:s={isError:!1,value:n},[s,[]]},deserialize(n){throw n.isError?Object.assign(new Error(n.value.message),n.value):n.value}},Qn=new Map([["proxy",Dd],["throw",kd]]);function Ad(n,s){for(const a of n)if(s===a||a==="*"||a instanceof RegExp&&a.test(s))return!0;return!1}function Zn(n,s=globalThis,a=["*"]){s.addEventListener("message",function l(u){if(!u||!u.data)return;if(!Ad(a,u.origin)){console.warn(`Invalid origin '${u.origin}' for comlink proxy`);return}const{id:p,type:m,path:v}=Object.assign({path:[]},u.data),g=(u.data.argumentList||[]).map(hr);let b;try{const w=v.slice(0,-1).reduce((z,E)=>z[E],n),k=v.reduce((z,E)=>z[E],n);switch(m){case"GET":b=k;break;case"SET":w[v.slice(-1)[0]]=hr(u.data.value),b=!0;break;case"APPLY":b=k.apply(w,g);break;case"CONSTRUCT":{const z=new k(...g);b=Pd(z)}break;case"ENDPOINT":{const{port1:z,port2:E}=new MessageChannel;Zn(n,E),b=Nd(z,[z])}break;case"RELEASE":b=void 0;break;default:return}}catch(w){b={value:w,[$a]:0}}Promise.resolve(b).catch(w=>({value:w,[$a]:0})).then(w=>{const[k,z]=Ka(w);s.postMessage(Object.assign(Object.assign({},k),{id:p}),z),m==="RELEASE"&&(s.removeEventListener("message",l),Jn(s),ri in n&&typeof n[ri]=="function"&&n[ri]())}).catch(w=>{const[k,z]=Ka({value:new TypeError("Unserializable return value"),[$a]:0});s.postMessage(Object.assign(Object.assign({},k),{id:p}),z)})}),s.start&&s.start()}function qd(n){return n.constructor.name==="MessagePort"}function Jn(n){qd(n)&&n.close()}function ai(n,s){return si(n,[],s)}function Ga(n){if(n)throw new Error("Proxy has been released and is not useable")}function eo(n){return zr(n,{type:"RELEASE"}).then(()=>{Jn(n)})}const Xa=new WeakMap,Ya="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{const s=(Xa.get(n)||0)-1;Xa.set(n,s),s===0&&eo(n)});function Cd(n,s){const a=(Xa.get(s)||0)+1;Xa.set(s,a),Ya&&Ya.register(n,s,n)}function Sd(n){Ya&&Ya.unregister(n)}function si(n,s=[],a=function(){}){let l=!1;const u=new Proxy(a,{get(p,m){if(Ga(l),m===Id)return()=>{Sd(u),eo(n),l=!0};if(m==="then"){if(s.length===0)return{then:()=>u};const v=zr(n,{type:"GET",path:s.map(g=>g.toString())}).then(hr);return v.then.bind(v)}return si(n,[...s,m])},set(p,m,v){Ga(l);const[g,b]=Ka(v);return zr(n,{type:"SET",path:[...s,m].map(w=>w.toString()),value:g},b).then(hr)},apply(p,m,v){Ga(l);const g=s[s.length-1];if(g===Td)return zr(n,{type:"ENDPOINT"}).then(hr);if(g==="bind")return si(n,s.slice(0,-1));const[b,w]=to(v);return zr(n,{type:"APPLY",path:s.map(k=>k.toString()),argumentList:b},w).then(hr)},construct(p,m){Ga(l);const[v,g]=to(m);return zr(n,{type:"CONSTRUCT",path:s.map(b=>b.toString()),argumentList:v},g).then(hr)}});return Cd(u,n),u}function zd(n){return Array.prototype.concat.apply([],n)}function to(n){const s=n.map(Ka);return[s.map(a=>a[0]),zd(s.map(a=>a[1]))]}const ro=new WeakMap;function Nd(n,s){return ro.set(n,s),n}function Pd(n){return Object.assign(n,{[Yn]:!0})}function Ka(n){for(const[s,a]of Qn)if(a.canHandle(n)){const[l,u]=a.serialize(n);return[{type:"HANDLER",name:s,value:l},u]}return[{type:"RAW",value:n},ro.get(n)||[]]}function hr(n){switch(n.type){case"HANDLER":return Qn.get(n.name).deserialize(n.value);case"RAW":return n.value}}function zr(n,s,a){return new Promise(l=>{const u=Rd();n.addEventListener("message",function p(m){!m.data||!m.data.id||m.data.id!==u||(n.removeEventListener("message",p),l(m.data))}),n.start&&n.start(),n.postMessage(Object.assign({id:u},s),a)})}function Rd(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const ao=new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/scriptsRunWorker-CSDMAOri.js").href:new URL("assets/scriptsRunWorker-CSDMAOri.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:La&&La.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Run TccScript Server"});ao.onerror=n=>{console.error(n)};const Od=ai(ao),Ed=ai(new Worker(new URL(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/parserTccWorker-CFBnUzVu.js").href:new URL("assets/parserTccWorker-CFBnUzVu.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:La&&La.src||new URL("trading-vue-editor.umd.cjs",document.baseURI).href),{type:"module",name:"Parser TccScript Server"}));async function so(n,s=!1){const{functions:a,types:l,constants:u,variables:p,methods:m}=rr;return await Ed(n,s,{functions:Object.fromEntries(a),methods:Object.fromEntries(m),types:Object.fromEntries(l),constants:Object.fromEntries(u),variables:Object.fromEntries(p)})}async function io(n,s,a=!0){return await Od(n,s,a)}const Md=({height:n,width:s,theme:a,options:l,hasDiff:u,onChange:p,onDeclareConfigChange:m,onCursorPositionChange:v},g)=>{const b=F.useRef(null);F.useImperativeHandle(g,()=>({saveScript(){var R;(R=b.current)==null||R.saveScripts()},setScript(R){var L;(L=b.current)==null||L.setValue(R)},gotoLine(){var R;(R=b.current)==null||R.gotoLine()}})),F.useEffect(()=>{var R,L;u?(L=b.current)==null||L.addDiffDecorations():(R=b.current)==null||R.removeDiffDecorations()},[u]);function w(R,L){var de;Sr.initBuiltinsTrees(),b.current=new wd(R,L),u&&((de=b.current)==null||de.addDiffDecorations());const J=R.getValue()+`
139
139
 
140
- `;b.current.onChangeCursorPosition(v),p&&p(J),k(J)}const k=F.useCallback(async R=>{var Pe;const L=Date.now(),{errors:J,functions:de,methods:ee,types:De,variables:ne,overloadsFuncs:Y,preParserCode:le}=await so(R,!0);try{const we=await io(le,{isPreParser:!0,data:[{time:1473811200,open:.7459,high:.7496,low:.7447,close:.747}]});console.log(we),m&&m(we)}catch(we){console.log(we,"==================error- Run TccScript Server")}const K=new Map(Object.entries(de)),Ne=new Map(Object.entries(ee)),_e=new Map(Object.entries(De)),re=new Map(Object.entries(ne));oa.setUserDefined({functions:K,methods:Ne,types:_e,variables:re},Y),Sr.setUserDefind(K,_e,re,Ne);const yt=J.map(we=>({...we,severity:we.type||pt.MarkerSeverity.Error}));(Pe=b.current)==null||Pe.setModelMarkers(yt);const kt=Date.now();console.log((kt-L)/1e3)},[m]),z=F.useMemo(()=>Ku.debounce(k,5e3),[k]);function E(R){var L;(L=b.current)==null||L.setModelMarkers([]),localStorage.setItem(Hn,R||""),R!==void 0&&(R=R+`
140
+ `;b.current.onChangeCursorPosition(v),p&&p(J),k(J)}const k=F.useCallback(async R=>{var Pe;const L=Date.now(),{errors:J,functions:de,methods:ee,types:De,variables:ne,overloadsFuncs:Y,preParserCode:le}=await so(R,!0);try{const we=await io(le,{isPreParser:!0,data:[{time:1473811200,open:.7459,high:.7496,low:.7447,close:.747}]});console.log(we),m&&m(we)}catch(we){console.log(we,"==================error- Run TccScript Server")}const K=new Map(Object.entries(de)),Ne=new Map(Object.entries(ee)),_e=new Map(Object.entries(De)),re=new Map(Object.entries(ne));oa.setUserDefined({functions:K,methods:Ne,types:_e,variables:re},Y),Sr.setUserDefind(K,_e,re,Ne);const yt=J.map(we=>({...we,severity:we.type||pt.MarkerSeverity.Error}));(Pe=b.current)==null||Pe.setModelMarkers(yt);const kt=Date.now();console.log((kt-L)/1e3)},[m]),z=F.useMemo(()=>Ku.debounce(k,1e3),[k]);function E(R){var L;(L=b.current)==null||L.setModelMarkers([]),localStorage.setItem(Hn,R||""),R!==void 0&&(R=R+`
141
141
 
142
142
  `,p&&p(R),z(R))}return mt.jsx(Fu,{height:n||"90vh",width:s||"100%",defaultLanguage:"tccScript",defaultValue:localStorage.getItem(Hn)||`indicator("我的脚本")
143
143
  plot(close)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guihz/trading-vue-editor-tes",
3
- "version": "0.0.002",
3
+ "version": "0.0.004",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "lib"