web-background 1.0.1 → 1.0.2
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/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class e extends Worker{postMessage(e){super.postMessage(e)}addEventListener(e,t){super.addEventListener(e,t)}}class t extends e{constructor(e,t){super(e,t)}request(e){return new Promise((t=>{const r=({data:e})=>{t(e),this.removeEventListener("message",r)};this.postMessage(e),this.addEventListener("message",r)}))}}"function"==typeof SuppressedError&&SuppressedError;class r{static fromModule(e,t){var{module:r}=t,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]])}return r}(t,["module"]);const s=`\n self.addEventListener('message', event => {\n const result = (${r.toString()})(${r.length>1?"...event.data":"event.data"});\n \n self.postMessage(result);\n });\n `.trim()
|
|
1
|
+
class e extends Worker{postMessage(e){super.postMessage(e)}addEventListener(e,t){super.addEventListener(e,t)}}class t extends e{constructor(e,t){super(e,t)}request(e){return new Promise((t=>{const r=({data:e})=>{t(e),this.removeEventListener("message",r)};this.postMessage(e),this.addEventListener("message",r)}))}}"function"==typeof SuppressedError&&SuppressedError;class r{static fromModule(e,t){var{module:r}=t,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]])}return r}(t,["module"]);const s=`\n self.addEventListener('message', async event => {\n const result = await (${r.toString()})(${r.length>1?"...event.data":"event.data"});\n \n self.postMessage(result);\n });\n `.trim();console.log(window.__webpack_require__);const o=new Blob([s],{type:"application/javascript"}),a=URL.createObjectURL(o),i=new e(a,n),l=i.terminate;return i.terminate=()=>{l.call(i),URL.revokeObjectURL(a)},i}}const n=new FinalizationRegistry((e=>e.terminate()));function s(e){let s=null;return function o(...a){if("undefined"==typeof window)throw new Error("[web-background] You must use background in browser");return null==s&&(s=r.fromModule(t,{module:e,type:"module"}),n.register(o,s)),s.request.call(s,a.length>1?a:a[0])}}export{s as background};
|