@guihz/trading-vue-editor-tes 0.0.230 → 0.0.232

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.
@@ -66,4 +66,4 @@ ${g}`),g}_getRequestData(t,e){var C,E,A,N,S;let{symbol:r,timeframe:n,calc_bars_c
66
66
  * @license
67
67
  * Copyright 2019 Google LLC
68
68
  * SPDX-License-Identifier: Apache-2.0
69
- */const Rh=Symbol("Comlink.proxy"),mD=Symbol("Comlink.endpoint"),gD=Symbol("Comlink.releaseProxy"),su=Symbol("Comlink.finalizer"),xo=Symbol("Comlink.thrown"),Ph=i=>typeof i=="object"&&i!==null||typeof i=="function",vD={canHandle:i=>Ph(i)&&i[Rh],serialize(i){const{port1:t,port2:e}=new MessageChannel;return ou(i,t),[e,[e]]},deserialize(i){return i.start(),bD(i)}},yD={canHandle:i=>Ph(i)&&xo in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},kh=new Map([["proxy",vD],["throw",yD]]);function wD(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function ou(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!wD(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:u}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(ai);let f;try{const d=u.slice(0,-1).reduce((p,g)=>p[g],i),h=u.reduce((p,g)=>p[g],i);switch(a){case"GET":f=h;break;case"SET":d[u.slice(-1)[0]]=ai(n.data.value),f=!0;break;case"APPLY":f=h.apply(d,c);break;case"CONSTRUCT":{const p=new h(...c);f=MD(p)}break;case"ENDPOINT":{const{port1:p,port2:g}=new MessageChannel;ou(i,g),f=CD(p,[p])}break;case"RELEASE":f=void 0;break;default:return}}catch(d){f={value:d,[xo]:0}}Promise.resolve(f).catch(d=>({value:d,[xo]:0})).then(d=>{const[h,p]=Mo(d);t.postMessage(Object.assign(Object.assign({},h),{id:s}),p),a==="RELEASE"&&(t.removeEventListener("message",r),zh(t),su in i&&typeof i[su]=="function"&&i[su]())}).catch(d=>{const[h,p]=Mo({value:new TypeError("Unserializable return value"),[xo]:0});t.postMessage(Object.assign(Object.assign({},h),{id:s}),p)})}),t.start&&t.start()}function DD(i){return i.constructor.name==="MessagePort"}function zh(i){DD(i)&&i.close()}function bD(i,t){return au(i,[],t)}function Eo(i){if(i)throw new Error("Proxy has been released and is not useable")}function qh(i){return Li(i,{type:"RELEASE"}).then(()=>{zh(i)})}const Ao=new WeakMap,Co="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(Ao.get(i)||0)-1;Ao.set(i,t),t===0&&qh(i)});function xD(i,t){const e=(Ao.get(t)||0)+1;Ao.set(t,e),Co&&Co.register(i,t,i)}function ED(i){Co&&Co.unregister(i)}function au(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(Eo(r),a===gD)return()=>{ED(n),qh(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const u=Li(i,{type:"GET",path:t.map(c=>c.toString())}).then(ai);return u.then.bind(u)}return au(i,[...t,a])},set(s,a,u){Eo(r);const[c,f]=Mo(u);return Li(i,{type:"SET",path:[...t,a].map(d=>d.toString()),value:c},f).then(ai)},apply(s,a,u){Eo(r);const c=t[t.length-1];if(c===mD)return Li(i,{type:"ENDPOINT"}).then(ai);if(c==="bind")return au(i,t.slice(0,-1));const[f,d]=Uh(u);return Li(i,{type:"APPLY",path:t.map(h=>h.toString()),argumentList:f},d).then(ai)},construct(s,a){Eo(r);const[u,c]=Uh(a);return Li(i,{type:"CONSTRUCT",path:t.map(f=>f.toString()),argumentList:u},c).then(ai)}});return xD(n,i),n}function AD(i){return Array.prototype.concat.apply([],i)}function Uh(i){const t=i.map(Mo);return[t.map(e=>e[0]),AD(t.map(e=>e[1]))]}const jh=new WeakMap;function CD(i,t){return jh.set(i,t),i}function MD(i){return Object.assign(i,{[Rh]:!0})}function Mo(i){for(const[t,e]of kh)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},jh.get(i)||[]]}function ai(i){switch(i.type){case"HANDLER":return kh.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Li(i,t,e){return new Promise(r=>{const n=FD();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function FD(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class ND{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}class Wh extends Error{constructor(e,r,n){const s=e.status||e.status===0?e.status:"",a=e.statusText||"",u=`${s} ${a}`.trim(),c=u?`status code ${u}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`);$(this,"response");$(this,"request");$(this,"options");this.name="HTTPError",this.response=e,this.request=r,this.options=n}}class Yh extends Error{constructor(e){super(`Request timed out: ${e.method} ${e.url}`);$(this,"request");this.name="TimeoutError",this.request=e}}const ls=i=>i!==null&&typeof i=="object",Fo=(...i)=>{for(const t of i)if((!ls(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return uu({},...i)},Vh=(i={},t={})=>{const e=new globalThis.Headers(i),r=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[s,a]of n.entries())r&&a==="undefined"||a===void 0?e.delete(s):e.set(s,a);return e};function No(i,t,e){return Object.hasOwn(t,e)&&t[e]===void 0?[]:uu(i[e]??[],t[e]??[])}const Hh=(i={},t={})=>({beforeRequest:No(i,t,"beforeRequest"),beforeRetry:No(i,t,"beforeRetry"),afterResponse:No(i,t,"afterResponse"),beforeError:No(i,t,"beforeError")}),uu=(...i)=>{let t={},e={},r={};for(const n of i)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(ls(n)){for(let[s,a]of Object.entries(n))ls(a)&&s in t&&(a=uu(t[s],a)),t={...t,[s]:a};ls(n.hooks)&&(r=Hh(r,n.hooks),t.hooks=r),ls(n.headers)&&(e=Vh(e,n.headers),t.headers=e)}return t},SD=(()=>{let i=!1,t=!1;const e=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(e&&r)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return i=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return i&&!t})(),OD=typeof globalThis.AbortController=="function",BD=typeof globalThis.ReadableStream=="function",TD=typeof globalThis.FormData=="function",Zh=["get","post","put","patch","head","delete"],ID={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},lu=2147483647,Kh=Symbol("stop"),$D={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},LD={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},RD=i=>Zh.includes(i)?i.toUpperCase():i,Gh={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:i=>.3*2**(i-1)*1e3},PD=(i={})=>{if(typeof i=="number")return{...Gh,limit:i};if(i.methods&&!Array.isArray(i.methods))throw new Error("retry.methods must be an array");if(i.statusCodes&&!Array.isArray(i.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Gh,...i}};async function kD(i,t,e,r){return new Promise((n,s)=>{const a=setTimeout(()=>{e&&e.abort(),s(new Yh(i))},r.timeout);r.fetch(i,t).then(n).catch(s).then(()=>{clearTimeout(a)})})}async function zD(i,{signal:t}){return new Promise((e,r)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(s),r(t.reason)}const s=setTimeout(()=>{t==null||t.removeEventListener("abort",n),e()},i)})}const qD=(i,t)=>{const e={};for(const r in t)!(r in LD)&&!(r in $D)&&!(r in i)&&(e[r]=t[r]);return e};class So{constructor(t,e={}){$(this,"request");$(this,"abortController");$(this,"_retryCount",0);$(this,"_input");$(this,"_options");var r,n;if(this._input=t,this._options={...e,headers:Vh(this._input.headers,e.headers),hooks:Hh({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:RD(e.method??this._input.method),prefixUrl:String(e.prefixUrl||""),retry:PD(e.retry),throwHttpErrors:e.throwHttpErrors!==!1,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(OD){this.abortController=new globalThis.AbortController;const s=this._options.signal??this._input.signal;s==null||s.addEventListener("abort",()=>{this.abortController.abort(s.reason)}),this._options.signal=this.abortController.signal}if(SD&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((n=(r=this._options).stringifyJson)==null?void 0:n.call(r,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const a="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),u=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);(TD&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(u,{...this.request}),this._options)}}static create(t,e){const r=new So(t,e),n=async()=>{if(typeof r._options.timeout=="number"&&r._options.timeout>lu)throw new RangeError(`The \`timeout\` option cannot be greater than ${lu}`);await Promise.resolve();let u=await r._fetch();for(const c of r._options.hooks.afterResponse){const f=await c(r.request,r._options,r._decorateResponse(u.clone()));f instanceof globalThis.Response&&(u=f)}if(r._decorateResponse(u),!u.ok&&r._options.throwHttpErrors){let c=new Wh(u,r.request,r._options);for(const f of r._options.hooks.beforeError)c=await f(c);throw c}if(r._options.onDownloadProgress){if(typeof r._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!BD)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return r._stream(u.clone(),r._options.onDownloadProgress)}return u},a=r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(n):n();for(const[u,c]of Object.entries(ID))a[u]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||c);const d=(await a).clone();if(u==="json"){if(d.status===204||(await d.clone().arrayBuffer()).byteLength===0)return"";if(e.parseJson)return e.parseJson(await d.text())}return d[u]()};return a}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Yh)throw t;if(t instanceof Wh){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const r=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(r&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(r)*1e3;Number.isNaN(n)?n=Date.parse(r)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());const s=this._options.retry.maxRetryAfter??n;return n<s?n:s}if(t.response.status===413)throw t}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const r=Math.min(this._calculateRetryDelay(e),lu);if(this._retryCount<1)throw e;await zD(r,{signal:this._options.signal});for(const n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===Kh)return;return this._retry(t)}}async _fetch(){for(const r of this._options.hooks.beforeRequest){const n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}const t=qD(this.request,this._options),e=this.request;return this.request=e.clone(),this._options.timeout===!1?this._options.fetch(e,t):kD(e,t,this.abortController,this._options)}_stream(t,e){const r=Number(t.headers.get("content-length"))||0;let n=0;return t.status===204?(e&&e({percent:1,totalBytes:r,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(s){const a=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){const{done:c,value:f}=await a.read();if(c){s.close();return}if(e){n+=f.byteLength;const d=r===0?0:n/r;e({percent:d,transferredBytes:n,totalBytes:r},f)}s.enqueue(f),await u()}await u()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}}/*! MIT License © Sindre Sorhus */const cu=i=>{const t=(e,r)=>So.create(e,Fo(i,r));for(const e of Zh)t[e]=(r,n)=>So.create(r,Fo(i,n,{method:e}));return t.create=e=>cu(Fo(e)),t.extend=e=>(typeof e=="function"&&(e=e(i??{})),cu(Fo(i,e))),t.stop=Kh,t},UD=cu().create({prefixUrl:"https://data.tradingvue.com/",retry:0});function jD(i){return UD.post("symbol/data/v1/",{json:i})}async function WD(i,t,e){var E,A,N;const{data:r,isPreParser:n,id:s="default",syminfo:a,interval:u,inputs:c,chart:f,strategy:d,scriptType:h,isManuallyAdd:p,subscribeData:g}=t;self.workerStorage||(self.workerStorage=new ND);let{builtInGather:y,buildinConstants:_,buildInFunctions:w,tradingvueFunc:v}=self.workerStorage.get(s)||{},x=[];e&&(y=new Lh(s),_=new Ah,w=new $h((a==null?void 0:a.mintick)||1e-5,y,s),v=new Function("$_var","$_const","$_func",i),self.workerStorage.set(s,{builtInGather:y,buildinConstants:_,buildInFunctions:w,tradingvueFunc:v}),self.workerStorage.set(`request_${s}`,new Map),(p||!self.workerStorage.has(`request_${s}_data`))&&self.workerStorage.set(`request_${s}_data`,new Map),self.workerStorage.set(`request_${s}_list`,new Map),self.workerStorage.set(`request_${s}_tmp`,new Map));let b=[];if(YD(g,s),n)v(y,_,w);else if(r&&r.length){const S=r.length-1;y.updateOptions({interval:u,mintick:(a==null?void 0:a.mintick)||1e-5,chart:f,syminfo:a}),w.updateOptions({inputs:c,strategy:d});const I=self.workerStorage.get(`request_${s}_tmp`),F=self.workerStorage.get(`request_${s}_data`);try{let O;for(const[U,z]of r.entries()){const{barindex:j}=z;if(!e&&(j||j===0)&&x.push(j),I!=null&&I.size){const Z=[],Y=[];for(const[X,ut]of I){const{symbol:pt,timeframe:at,id:vt,calc_bars_count:wt,ignore_invalid_symbol:Nt}=ut,bt=`${pt}:${at}`;Y.push({id:vt,key:bt,ignore_invalid_symbol:Nt});const[ee,Bt]=pt.split(":");Z.push(jD({params:[{exchange:ee,symbol:Bt,limit:wt||5e3,start:0,end:0,period:at}]}).json())}const J=await Promise.all(Z);for(const[X,ut]of J.entries()){const{code:pt,data:at,msg:vt}=ut,wt=Y[X];if(pt!==200&&!wt.ignore_invalid_symbol)return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:vt,type:Lt.Error}]};F==null||F.set(wt.id,((A=(E=at[wt.key])==null?void 0:E.list)==null?void 0:A.reverse())||[])}I==null||I.clear(),O&&Jh(y,w,_,v,h,O)}O=Object.assign(z,{barIndex:j||U,lastBarIndex:r[S].barindex||S,lastBarTime:r[S].time,nextBarTime:(N=r[U+1])==null?void 0:N.time}),Jh(y,w,_,v,h,O);const P=w.errors;if(P.length&&P.some(Z=>Z.type===Lt.Error))return{status:1,errors:P}}const L=self.workerStorage.get(`request_${s}_list`);if((L==null?void 0:L.size)>40)return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:ne.requestsNumErr,type:Lt.Error}]};if(L!=null&&L.size){const U=new Map;for(const[z,j]of L)b.push(j),e&&(F!=null&&F.has(z))&&U.set(z,F.get(z));e&&self.workerStorage.set(`request_${s}_data`,U)}b.length&&(L==null||L.clear()),e&&self.workerStorage.delete(`request_${s}_tmp`)}catch(O){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:O==null?void 0:O.message,type:Lt.Error}]}}}const C=w.errors;return C.length&&C.some(S=>S.type===Lt.Error)?{status:1,errors:C}:{status:0,requestList:b,errors:C,options:{...w.options(x),id:s}}}function YD(i,t){if(!i)return;const e=self.workerStorage.get(`request_${t}_data`),r=Object.keys(i);if(r.length)for(const n of r){let s=i[n]||[];if(e!=null&&e.has(n)){const a=(e==null?void 0:e.get(n))||[];if(a.length){const u=a[a.length-1].time;s=s.filter(c=>c.time>=u),s[0].time===u&&a.pop()}e==null||e.set(n,a.concat(s))}}}function Jh(i,t,e,r,n,s){if(i.updateData(s),t.update({barIndex:s.barIndex}),n=n||t.scriptType,s.isrealtime&&n===ic.strategy&&!t.strategy.isCalcOnEveryTick){t.strategy.calcCurrentOrder();return}if(r(i,e,t),t.endExecution(),t.strategy.calcOnOrderFillsData.tradeData){for(;t.strategy.calcOnOrderFillsData.tradeData;)t.strategy.calcOnOrderFillsData.data=t.strategy.calcOnOrderFillsData.tradeData,t.strategy.calcOnOrderFillsData.tradeData=void 0,i.updateData(s),t.update({barIndex:s==null?void 0:s.barIndex}),r(i,e,t),t.endExecution();t.strategy.calcOnOrderFillsData={index:-1}}}function VD(i){self==null||self.workerStorage.deleteStartwidthKey(i),self==null||self.workerStorage.delete(`inputs_${i}`),self==null||self.workerStorage.delete(`strategy_${i}`),self==null||self.workerStorage.delete(`request_${i}`),self==null||self.workerStorage.delete(`request_${i}_data`),self==null||self.workerStorage.delete(`request_${i}_list`)}ou({runScript:WD,removeScript:VD})})();
69
+ */const Rh=Symbol("Comlink.proxy"),mD=Symbol("Comlink.endpoint"),gD=Symbol("Comlink.releaseProxy"),su=Symbol("Comlink.finalizer"),xo=Symbol("Comlink.thrown"),Ph=i=>typeof i=="object"&&i!==null||typeof i=="function",vD={canHandle:i=>Ph(i)&&i[Rh],serialize(i){const{port1:t,port2:e}=new MessageChannel;return ou(i,t),[e,[e]]},deserialize(i){return i.start(),bD(i)}},yD={canHandle:i=>Ph(i)&&xo in i,serialize({value:i}){let t;return i instanceof Error?t={isError:!0,value:{message:i.message,name:i.name,stack:i.stack}}:t={isError:!1,value:i},[t,[]]},deserialize(i){throw i.isError?Object.assign(new Error(i.value.message),i.value):i.value}},kh=new Map([["proxy",vD],["throw",yD]]);function wD(i,t){for(const e of i)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function ou(i,t=globalThis,e=["*"]){t.addEventListener("message",function r(n){if(!n||!n.data)return;if(!wD(e,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:a,path:u}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(ai);let f;try{const d=u.slice(0,-1).reduce((p,g)=>p[g],i),h=u.reduce((p,g)=>p[g],i);switch(a){case"GET":f=h;break;case"SET":d[u.slice(-1)[0]]=ai(n.data.value),f=!0;break;case"APPLY":f=h.apply(d,c);break;case"CONSTRUCT":{const p=new h(...c);f=MD(p)}break;case"ENDPOINT":{const{port1:p,port2:g}=new MessageChannel;ou(i,g),f=CD(p,[p])}break;case"RELEASE":f=void 0;break;default:return}}catch(d){f={value:d,[xo]:0}}Promise.resolve(f).catch(d=>({value:d,[xo]:0})).then(d=>{const[h,p]=Mo(d);t.postMessage(Object.assign(Object.assign({},h),{id:s}),p),a==="RELEASE"&&(t.removeEventListener("message",r),zh(t),su in i&&typeof i[su]=="function"&&i[su]())}).catch(d=>{const[h,p]=Mo({value:new TypeError("Unserializable return value"),[xo]:0});t.postMessage(Object.assign(Object.assign({},h),{id:s}),p)})}),t.start&&t.start()}function DD(i){return i.constructor.name==="MessagePort"}function zh(i){DD(i)&&i.close()}function bD(i,t){return au(i,[],t)}function Eo(i){if(i)throw new Error("Proxy has been released and is not useable")}function qh(i){return Li(i,{type:"RELEASE"}).then(()=>{zh(i)})}const Ao=new WeakMap,Co="FinalizationRegistry"in globalThis&&new FinalizationRegistry(i=>{const t=(Ao.get(i)||0)-1;Ao.set(i,t),t===0&&qh(i)});function xD(i,t){const e=(Ao.get(t)||0)+1;Ao.set(t,e),Co&&Co.register(i,t,i)}function ED(i){Co&&Co.unregister(i)}function au(i,t=[],e=function(){}){let r=!1;const n=new Proxy(e,{get(s,a){if(Eo(r),a===gD)return()=>{ED(n),qh(i),r=!0};if(a==="then"){if(t.length===0)return{then:()=>n};const u=Li(i,{type:"GET",path:t.map(c=>c.toString())}).then(ai);return u.then.bind(u)}return au(i,[...t,a])},set(s,a,u){Eo(r);const[c,f]=Mo(u);return Li(i,{type:"SET",path:[...t,a].map(d=>d.toString()),value:c},f).then(ai)},apply(s,a,u){Eo(r);const c=t[t.length-1];if(c===mD)return Li(i,{type:"ENDPOINT"}).then(ai);if(c==="bind")return au(i,t.slice(0,-1));const[f,d]=Uh(u);return Li(i,{type:"APPLY",path:t.map(h=>h.toString()),argumentList:f},d).then(ai)},construct(s,a){Eo(r);const[u,c]=Uh(a);return Li(i,{type:"CONSTRUCT",path:t.map(f=>f.toString()),argumentList:u},c).then(ai)}});return xD(n,i),n}function AD(i){return Array.prototype.concat.apply([],i)}function Uh(i){const t=i.map(Mo);return[t.map(e=>e[0]),AD(t.map(e=>e[1]))]}const jh=new WeakMap;function CD(i,t){return jh.set(i,t),i}function MD(i){return Object.assign(i,{[Rh]:!0})}function Mo(i){for(const[t,e]of kh)if(e.canHandle(i)){const[r,n]=e.serialize(i);return[{type:"HANDLER",name:t,value:r},n]}return[{type:"RAW",value:i},jh.get(i)||[]]}function ai(i){switch(i.type){case"HANDLER":return kh.get(i.name).deserialize(i.value);case"RAW":return i.value}}function Li(i,t,e){return new Promise(r=>{const n=FD();i.addEventListener("message",function s(a){!a.data||!a.data.id||a.data.id!==n||(i.removeEventListener("message",s),r(a.data))}),i.start&&i.start(),i.postMessage(Object.assign({id:n},t),e)})}function FD(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class ND{constructor(){$(this,"_cache");this._cache=new Map}set(t,e){this._cache.set(t,e)}setValue(t,e,r){const n=this._cache.get(t)||{};n[e]=r,this._cache.set(t,n)}updateValue(t,e,r){const n=this._cache.get(t)||{};this._cache.set(t,Object.assign(n[e]||{},r))}get(t){return this._cache.get(t)}has(t){return this._cache.has(t)}deleteStartwidthKey(t){for(const e of this._cache.keys())e.startsWith(t)&&this._cache.delete(e)}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}}class Wh extends Error{constructor(e,r,n){const s=e.status||e.status===0?e.status:"",a=e.statusText||"",u=`${s} ${a}`.trim(),c=u?`status code ${u}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`);$(this,"response");$(this,"request");$(this,"options");this.name="HTTPError",this.response=e,this.request=r,this.options=n}}class Yh extends Error{constructor(e){super(`Request timed out: ${e.method} ${e.url}`);$(this,"request");this.name="TimeoutError",this.request=e}}const ls=i=>i!==null&&typeof i=="object",Fo=(...i)=>{for(const t of i)if((!ls(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return uu({},...i)},Vh=(i={},t={})=>{const e=new globalThis.Headers(i),r=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[s,a]of n.entries())r&&a==="undefined"||a===void 0?e.delete(s):e.set(s,a);return e};function No(i,t,e){return Object.hasOwn(t,e)&&t[e]===void 0?[]:uu(i[e]??[],t[e]??[])}const Hh=(i={},t={})=>({beforeRequest:No(i,t,"beforeRequest"),beforeRetry:No(i,t,"beforeRetry"),afterResponse:No(i,t,"afterResponse"),beforeError:No(i,t,"beforeError")}),uu=(...i)=>{let t={},e={},r={};for(const n of i)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(ls(n)){for(let[s,a]of Object.entries(n))ls(a)&&s in t&&(a=uu(t[s],a)),t={...t,[s]:a};ls(n.hooks)&&(r=Hh(r,n.hooks),t.hooks=r),ls(n.headers)&&(e=Vh(e,n.headers),t.headers=e)}return t},SD=(()=>{let i=!1,t=!1;const e=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(e&&r)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return i=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return i&&!t})(),OD=typeof globalThis.AbortController=="function",BD=typeof globalThis.ReadableStream=="function",TD=typeof globalThis.FormData=="function",Zh=["get","post","put","patch","head","delete"],ID={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},lu=2147483647,Kh=Symbol("stop"),$D={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},LD={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},RD=i=>Zh.includes(i)?i.toUpperCase():i,Gh={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:i=>.3*2**(i-1)*1e3},PD=(i={})=>{if(typeof i=="number")return{...Gh,limit:i};if(i.methods&&!Array.isArray(i.methods))throw new Error("retry.methods must be an array");if(i.statusCodes&&!Array.isArray(i.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Gh,...i}};async function kD(i,t,e,r){return new Promise((n,s)=>{const a=setTimeout(()=>{e&&e.abort(),s(new Yh(i))},r.timeout);r.fetch(i,t).then(n).catch(s).then(()=>{clearTimeout(a)})})}async function zD(i,{signal:t}){return new Promise((e,r)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(s),r(t.reason)}const s=setTimeout(()=>{t==null||t.removeEventListener("abort",n),e()},i)})}const qD=(i,t)=>{const e={};for(const r in t)!(r in LD)&&!(r in $D)&&!(r in i)&&(e[r]=t[r]);return e};class So{constructor(t,e={}){$(this,"request");$(this,"abortController");$(this,"_retryCount",0);$(this,"_input");$(this,"_options");var r,n;if(this._input=t,this._options={...e,headers:Vh(this._input.headers,e.headers),hooks:Hh({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:RD(e.method??this._input.method),prefixUrl:String(e.prefixUrl||""),retry:PD(e.retry),throwHttpErrors:e.throwHttpErrors!==!1,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(OD){this.abortController=new globalThis.AbortController;const s=this._options.signal??this._input.signal;s==null||s.addEventListener("abort",()=>{this.abortController.abort(s.reason)}),this._options.signal=this.abortController.signal}if(SD&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((n=(r=this._options).stringifyJson)==null?void 0:n.call(r,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const a="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),u=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);(TD&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(u,{...this.request}),this._options)}}static create(t,e){const r=new So(t,e),n=async()=>{if(typeof r._options.timeout=="number"&&r._options.timeout>lu)throw new RangeError(`The \`timeout\` option cannot be greater than ${lu}`);await Promise.resolve();let u=await r._fetch();for(const c of r._options.hooks.afterResponse){const f=await c(r.request,r._options,r._decorateResponse(u.clone()));f instanceof globalThis.Response&&(u=f)}if(r._decorateResponse(u),!u.ok&&r._options.throwHttpErrors){let c=new Wh(u,r.request,r._options);for(const f of r._options.hooks.beforeError)c=await f(c);throw c}if(r._options.onDownloadProgress){if(typeof r._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!BD)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return r._stream(u.clone(),r._options.onDownloadProgress)}return u},a=r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(n):n();for(const[u,c]of Object.entries(ID))a[u]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||c);const d=(await a).clone();if(u==="json"){if(d.status===204||(await d.clone().arrayBuffer()).byteLength===0)return"";if(e.parseJson)return e.parseJson(await d.text())}return d[u]()};return a}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Yh)throw t;if(t instanceof Wh){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const r=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(r&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(r)*1e3;Number.isNaN(n)?n=Date.parse(r)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());const s=this._options.retry.maxRetryAfter??n;return n<s?n:s}if(t.response.status===413)throw t}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const r=Math.min(this._calculateRetryDelay(e),lu);if(this._retryCount<1)throw e;await zD(r,{signal:this._options.signal});for(const n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===Kh)return;return this._retry(t)}}async _fetch(){for(const r of this._options.hooks.beforeRequest){const n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}const t=qD(this.request,this._options),e=this.request;return this.request=e.clone(),this._options.timeout===!1?this._options.fetch(e,t):kD(e,t,this.abortController,this._options)}_stream(t,e){const r=Number(t.headers.get("content-length"))||0;let n=0;return t.status===204?(e&&e({percent:1,totalBytes:r,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(s){const a=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){const{done:c,value:f}=await a.read();if(c){s.close();return}if(e){n+=f.byteLength;const d=r===0?0:n/r;e({percent:d,transferredBytes:n,totalBytes:r},f)}s.enqueue(f),await u()}await u()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}}/*! MIT License © Sindre Sorhus */const cu=i=>{const t=(e,r)=>So.create(e,Fo(i,r));for(const e of Zh)t[e]=(r,n)=>So.create(r,Fo(i,n,{method:e}));return t.create=e=>cu(Fo(e)),t.extend=e=>(typeof e=="function"&&(e=e(i??{})),cu(Fo(i,e))),t.stop=Kh,t},UD=cu().create({prefixUrl:"https://data.tradingvue.com/",retry:0});function jD(i){return UD.post("symbol/data/v1/",{json:i})}async function WD(i,t,e){var E,A,N;const{data:r,isPreParser:n,id:s="default",syminfo:a,interval:u,inputs:c,chart:f,strategy:d,scriptType:h,isManuallyAdd:p,subscribeData:g}=t;self.workerStorage||(self.workerStorage=new ND);let{builtInGather:y,buildinConstants:_,buildInFunctions:w,tradingvueFunc:v}=self.workerStorage.get(s)||{},x=[];e&&(y=new Lh(s),_=new Ah,w=new $h((a==null?void 0:a.mintick)||1e-5,y,s),v=new Function("$_var","$_const","$_func",i),self.workerStorage.set(s,{builtInGather:y,buildinConstants:_,buildInFunctions:w,tradingvueFunc:v}),self.workerStorage.set(`request_${s}`,new Map),(p||!self.workerStorage.has(`request_${s}_data`))&&self.workerStorage.set(`request_${s}_data`,new Map),self.workerStorage.set(`request_${s}_list`,new Map),self.workerStorage.set(`request_${s}_tmp`,new Map));let b=[];if(YD(g,s),n)v(y,_,w);else if(r&&r.length){const S=r.length-1;y.updateOptions({interval:u,mintick:(a==null?void 0:a.mintick)||1e-5,chart:f,syminfo:a}),w.updateOptions({inputs:c,strategy:d});const I=self.workerStorage.get(`request_${s}_tmp`),F=self.workerStorage.get(`request_${s}_data`);try{let O;for(const[U,z]of r.entries()){const{barindex:j}=z;if(!e&&(j||j===0)&&x.push(j),I!=null&&I.size){const Z=[],Y=[];for(const[X,ut]of I){const{symbol:pt,timeframe:at,id:vt,calc_bars_count:wt,ignore_invalid_symbol:Nt}=ut,bt=`${pt}:${at}`;Y.push({id:vt,key:bt,ignore_invalid_symbol:Nt});const[ee,Bt]=pt.split(":");Z.push(jD({params:[{exchange:ee,symbol:Bt,limit:wt||5e3,start:0,end:0,period:at}]}).json())}const J=await Promise.all(Z);for(const[X,ut]of J.entries()){const{code:pt,data:at,msg:vt}=ut,wt=Y[X];if(pt!==200&&!wt.ignore_invalid_symbol)return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:vt,type:Lt.Error}]};F==null||F.set(wt.id,((A=(E=at[wt.key])==null?void 0:E.list)==null?void 0:A.reverse())||[])}I==null||I.clear(),O&&Jh(y,w,_,v,h,O)}O=Object.assign(z,{barIndex:j||U,lastBarIndex:r[S].barindex||S,lastBarTime:r[S].time,nextBarTime:(N=r[U+1])==null?void 0:N.time}),Jh(y,w,_,v,h,O);const P=w.errors;if(P.length&&P.some(Z=>Z.type===Lt.Error))return{status:1,errors:P}}const L=self.workerStorage.get(`request_${s}_list`);if((L==null?void 0:L.size)>40)return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:ne.requestsNumErr,type:Lt.Error}]};if(L!=null&&L.size){const U=new Map;for(const[z,j]of L)b.push(j),e&&(F!=null&&F.has(z))&&U.set(z,F.get(z));e&&self.workerStorage.set(`request_${s}_data`,U)}b.length&&(L==null||L.clear()),e&&self.workerStorage.delete(`request_${s}_tmp`)}catch(O){return{status:1,errors:[{endLineNumber:0,startColumn:0,endColumn:0,startLineNumber:0,message:O==null?void 0:O.message,type:Lt.Error}]}}}const C=w.errors;return C.length&&C.some(S=>S.type===Lt.Error)?{status:1,errors:C}:{status:0,requestList:b,errors:C,options:{...w.options(x),id:s}}}function YD(i,t){if(!i)return;const e=self.workerStorage.get(`request_${t}_data`),r=Object.keys(i);if(r.length)for(const n of r){let s=i[n]||[];if(e!=null&&e.has(n)){const a=(e==null?void 0:e.get(n))||[];if(a.length){const u=a[a.length-1].time;s=s.filter(c=>c.time>=u),s[0].time===u&&a.pop()}e==null||e.set(n,a.concat(s))}}}function Jh(i,t,e,r,n,s){if(i.updateData(s),t.update({barIndex:s.barIndex}),n=n||t.scriptType,s.isrealtime&&n===ic.strategy&&!t.strategy.isCalcOnEveryTick){t.strategy.calcCurrentOrder();return}if(r(i,e,t),t.endExecution(),t.strategy.calcOnOrderFillsData.tradeData){for(;t.strategy.calcOnOrderFillsData.tradeData;)t.strategy.calcOnOrderFillsData.data=t.strategy.calcOnOrderFillsData.tradeData,t.strategy.calcOnOrderFillsData.tradeData=void 0,i.updateData(s),t.update({barIndex:s==null?void 0:s.barIndex}),r(i,e,t),t.endExecution();t.strategy.calcOnOrderFillsData={index:-1}}}function VD(i){var t,e,r,n,s,a;(t=self==null?void 0:self.workerStorage)==null||t.deleteStartwidthKey(i),(e=self==null?void 0:self.workerStorage)==null||e.delete(`inputs_${i}`),(r=self==null?void 0:self.workerStorage)==null||r.delete(`strategy_${i}`),(n=self==null?void 0:self.workerStorage)==null||n.delete(`request_${i}`),(s=self==null?void 0:self.workerStorage)==null||s.delete(`request_${i}_data`),(a=self==null?void 0:self.workerStorage)==null||a.delete(`request_${i}_list`)}ou({runScript:WD,removeScript:VD})})();
@@ -1,6 +1,6 @@
1
1
  import { FC } from "react";
2
2
  import { IDocValue } from "../../editor/type";
3
- import { IContent } from "../../referenceManual/tools";
3
+ import { IContent } from "../../../utils/tools";
4
4
  interface IProps {
5
5
  item: IDocValue[];
6
6
  prefix: string;
@@ -7,4 +7,5 @@ export type { IError, IPosition } from '../components/editor/parseScript/type';
7
7
  export { VMarkerSeverity } from '../components/editor/parseScript/type';
8
8
  export { default as ReferenceManual } from '../components/referenceManual';
9
9
  export { default as ReferenceManualPage } from '../components/referenceManualPage';
10
+ export { transformCodeToHtml } from '../utils/tools';
10
11
  export { VAdjustment, VAlert, VBarmergeGaps, VCommission, VDirection, VEarnings, VExtend, VFormatType, VHlineStyle, VInputType, VLabelStyle, VLineStyle, VLocation, VOca, VPlotDisplay, VPlotStyle, VRuleType, VScale, VSession, VShape, VSortOrder, VSize, VStrategy, VText, VType, VXloc, VYloc, VPivotType, VPosition, VScriptType, VFont } from '../components/editor/parseScript/enum';