@subwallet/web-runner 0.4.8-0 → 0.5.1
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/172.js +1 -1
- package/272.js +1 -1
- package/397.js +1 -1
- package/856.js +1 -0
- package/925.js +1 -1
- package/index.html +42 -1
- package/package.json +7 -6
- package/smoldot.js +1 -1
- package/6232e8b6d7faadf8b94c.cjs +0 -1
- package/746.js +0 -1
- package/9fa231cfd679d2c5b7dd.cjs +0 -1
- package/fallback.js +0 -1
- package/web-runner.js +0 -42
- package/web-runner.js.LICENSE.txt +0 -56
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:()=>
|
|
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)}}}]);
|