@subwallet/web-runner 0.4.9-0 → 0.5.3-0

Sign up to get free protection for your applications and to get access to all the features.
package/272.js CHANGED
@@ -1 +1 @@
1
- "use strict";(("undefined"!=typeof self?self:this).webpackChunk_subwallet_web_runner=("undefined"!=typeof self?self:this).webpackChunk_subwallet_web_runner||[]).push([[272],{57272:(e,s,t)=>{t.r(s),t.d(s,{AddChainError:()=>a,AlreadyDestroyedError:()=>n,CrashError:()=>r,JsonRpcDisabledError:()=>o,start:()=>i});class a extends Error{constructor(e){super(e),this.name="AddChainError"}}class n extends Error{constructor(){super(),this.name="AlreadyDestroyedError"}}class o extends Error{constructor(){super(),this.name="JsonRpcDisabledError"}}class r extends Error{constructor(e){super(e)}}function i(e){const s=(e=e||{}).logCallback||((e,s,t)=>{e<=1?console.error("[%s] %s",s,t):2==e?console.warn("[%s] %s",s,t):3==e?console.info("[%s] %s",s,t):4==e?console.debug("[%s] %s",s,t):console.trace("[%s] %s",s,t)}),i=function(){if(!window.Worker)throw new Error("Workers not available");return new Worker(new URL(t.p+t.u(726),t.b),{name:"smoldot"})}();let l=null,d=[],h=new Map,u=new WeakMap;const b={name:null};let f=null;const p=()=>{null!==f&&globalThis.clearTimeout(f),f=globalThis.setTimeout((()=>{f=null,console.warn("Smoldot appears unresponsive"+(b.name?" while executing task `"+b.name+"`":"")+". Please open an issue at https://github.com/paritytech/smoldot/issues. If you have a debugger available, please pause execution, generate a stack trace of the thread that isn't the main execution thread, and paste it in the issue. Please also include any other log found in the console or elsewhere.")}),1e4)};return globalThis.setTimeout((()=>p()),15e3),function(e,s){e.onmessage=e=>s(e.data)}(i,(e=>{switch(e.kind){case"jsonrpc":{const s=h.get(e.chainId)?.jsonRpcCallback;s&&s(e.data);break}case"chainAddedOk":{const s=d.shift(),t=e.chainId;if(h.has(t))throw"Unexpected reuse of a chain ID";h.set(t,{jsonRpcCallback:s.jsonRpcCallback,databasePromises:new Array});const a={sendJsonRpc:e=>{if(l)throw l;if(!h.has(t))throw new n;if(!h.get(t)?.jsonRpcCallback)throw new o;e.length>=8388608||c(i,{ty:"request",request:e,chainId:t})},databaseContent:e=>{if(l)return Promise.reject(l);const s=h.get(t)?.databasePromises;if(!s)return Promise.reject(new n);const a=new Promise(((e,t)=>{s.push({resolve:e,reject:t})})),o=e||4294967295;return c(i,{ty:"databaseContent",chainId:t,maxUtf8BytesSize:o>=4*(1<<30)?4294967295:o}),a},remove:()=>{if(l)throw l;if(!h.delete(t))throw new n;console.assert(u.has(a)),u.delete(a),c(i,{ty:"removeChain",chainId:t})}};u.set(a,t),s.resolve(a);break}case"chainAddedErr":d.shift().reject(new a(e.error));break;case"databaseContent":{const s=h.get(e.chainId)?.databasePromises;s&&s.shift().resolve(e.data);break}case"log":s(e.level,e.target,e.message);break;case"livenessPing":p();break;case"currentTask":b.name=e.taskName;break;default:return e}})),function(e,s){e.onerror=e=>{const s=e.toString();for(var t of(console.error("Smoldot has panicked"+(b.name?" while executing task `"+b.name+"`":"")+". This is a bug in smoldot. Please open an issue at https://github.com/paritytech/smoldot/issues with the following message:\n"+s),l=new r(s),d))"chainAdded"==t.ty&&t.reject(l);d=[];for(const e of h)for(const s of e[1].databasePromises)s.reject(l);h.clear()}}(i),c(i,{maxLogLevel:e.maxLogLevel||3,enableCurrentTask:!0,cpuRateLimit:e.cpuRateLimit||1,forbidTcp:e.forbidTcp||!1,forbidWs:e.forbidWs||!1,forbidNonLocalWs:e.forbidNonLocalWs||!1,forbidWss:e.forbidWss||!1}),{addChain:e=>{if(l)throw l;let s,t,a=[];if(e.potentialRelayChains)for(const s of e.potentialRelayChains){const e=u.get(s);void 0!==e&&a.push(e)}const n=new Promise(((e,a)=>{s=e,t=a}));return d.push({ty:"chainAdded",reject:t,resolve:s,jsonRpcCallback:e.jsonRpcCallback}),c(i,{ty:"addChain",chainSpec:e.chainSpec,databaseContent:"string"==typeof e.databaseContent?e.databaseContent:"",potentialRelayChains:a,jsonRpcRunning:!!e.jsonRpcCallback}),n},terminate:()=>l?Promise.reject(l):(l=new n,null!==f&&globalThis.clearTimeout(f),function(e){return e.terminate(),Promise.resolve()}(i))}}function c(e,s){e.postMessage(s)}}}]);
1
+ "use strict";(("undefined"!=typeof self?self:this).webpackChunk_subwallet_web_runner=("undefined"!=typeof self?self:this).webpackChunk_subwallet_web_runner||[]).push([[272],{57272:(e,s,t)=>{t.r(s),t.d(s,{AddChainError:()=>a,AlreadyDestroyedError:()=>r,CrashError:()=>o,JsonRpcDisabledError:()=>n,start:()=>i});class a extends Error{constructor(e){super(e),this.name="AddChainError"}}class r extends Error{constructor(){super(),this.name="AlreadyDestroyedError"}}class n extends Error{constructor(){super(),this.name="JsonRpcDisabledError"}}class o extends Error{constructor(e){super(e)}}function i(e){const s=(e=e||{}).logCallback||((e,s,t)=>{e<=1?console.error("[%s] %s",s,t):2==e?console.warn("[%s] %s",s,t):3==e?console.info("[%s] %s",s,t):4==e?console.debug("[%s] %s",s,t):console.trace("[%s] %s",s,t)}),i=function(){if(!window.Worker)throw new Error("Workers not available");return new Worker(new URL(t.p+t.u(726),t.b),{name:"smoldot"})}();let l=null,d=[],h=new Map,u=new WeakMap;const f={name:null};let b=null;const p=()=>{null!==b&&globalThis.clearTimeout(b),b=globalThis.setTimeout((()=>{b=null,l||console.warn("Smoldot appears unresponsive"+(f.name?" while executing task `"+f.name+"`":"")+". Please open an issue at https://github.com/paritytech/smoldot/issues. If you have a debugger available, please pause execution, generate a stack trace of the thread that isn't the main execution thread, and paste it in the issue. Please also include any other log found in the console or elsewhere.")}),1e4)};return globalThis.setTimeout((()=>p()),15e3),function(e,s){e.onmessage=e=>s(e.data)}(i,(e=>{switch(e.kind){case"jsonrpc":{const s=h.get(e.chainId)?.jsonRpcCallback;s&&s(e.data);break}case"chainAddedOk":{const s=d.shift(),t=e.chainId;if(h.has(t))throw"Unexpected reuse of a chain ID";h.set(t,{jsonRpcCallback:s.jsonRpcCallback,databasePromises:new Array});const a={sendJsonRpc:e=>{if(l)throw l;if(!h.has(t))throw new r;if(!h.get(t)?.jsonRpcCallback)throw new n;e.length>=8388608||c(i,{ty:"request",request:e,chainId:t})},databaseContent:e=>{if(l)return Promise.reject(l);const s=h.get(t)?.databasePromises;if(!s)return Promise.reject(new r);const a=new Promise(((e,t)=>{s.push({resolve:e,reject:t})})),n=e||4294967295;return c(i,{ty:"databaseContent",chainId:t,maxUtf8BytesSize:n>=4*(1<<30)?4294967295:n}),a},remove:()=>{if(l)throw l;if(!h.delete(t))throw new r;console.assert(u.has(a)),u.delete(a),c(i,{ty:"removeChain",chainId:t})}};u.set(a,t),s.resolve(a);break}case"chainAddedErr":d.shift().reject(new a(e.error));break;case"databaseContent":{const s=h.get(e.chainId)?.databasePromises;s&&s.shift().resolve(e.data);break}case"log":s(e.level,e.target,e.message);break;case"livenessPing":p();break;case"currentTask":f.name=e.taskName;break;default:return e}})),function(e,s){e.onerror=e=>{e.error instanceof Error?s(e.error):s(new Error(e.message||e))}}(i,(e=>{const s=e.toString();for(var t of(console.error("Smoldot has panicked"+(f.name?" while executing task `"+f.name+"`":"")+". This is a bug in smoldot. Please open an issue at https://github.com/paritytech/smoldot/issues with the following message:\n"+s),l=new o(s),d))"chainAdded"==t.ty&&t.reject(l);d=[];for(const e of h)for(const s of e[1].databasePromises)s.reject(l);h.clear()})),c(i,{maxLogLevel:e.maxLogLevel||3,enableCurrentTask:!0,cpuRateLimit:e.cpuRateLimit||1,forbidTcp:e.forbidTcp||!1,forbidWs:e.forbidWs||!1,forbidNonLocalWs:e.forbidNonLocalWs||!1,forbidWss:e.forbidWss||!1}),{addChain:e=>{if(l)throw l;if("string"!=typeof e.chainSpec)throw new Error("Chain specification must be a string");let s,t,a=[];if(e.potentialRelayChains)for(const s of e.potentialRelayChains){const e=u.get(s);void 0!==e&&a.push(e)}const r=new Promise(((e,a)=>{s=e,t=a}));return d.push({ty:"chainAdded",reject:t,resolve:s,jsonRpcCallback:e.jsonRpcCallback}),c(i,{ty:"addChain",chainSpec:e.chainSpec,databaseContent:"string"==typeof e.databaseContent?e.databaseContent:"",potentialRelayChains:a,jsonRpcRunning:!!e.jsonRpcCallback}),r},terminate:()=>l?Promise.reject(l):(l=new r,null!==b&&globalThis.clearTimeout(b),function(e){return e.terminate(),Promise.resolve()}(i))}}function c(e,s){e.postMessage(s)}}}]);