zhenxun_bot/assets/js/4523.ade0edda.js

2 lines
43 KiB
JavaScript
Raw Permalink Normal View History

/*! For license information please see 4523.ade0edda.js.LICENSE.txt */
(self.webpackChunkzhenxun_docs=self.webpackChunkzhenxun_docs||[]).push([[4523],{540:(e,t,r)=>{"use strict";const n=Symbol("Comlink.proxy"),i=Symbol("Comlink.endpoint"),s=Symbol("Comlink.releaseProxy"),o=Symbol("Comlink.finalizer"),a=Symbol("Comlink.thrown"),u=e=>"object"==typeof e&&null!==e||"function"==typeof e,l={canHandle:e=>u(e)&&e[n],serialize(e){const{port1:t,port2:r}=new MessageChannel;return h(e,t),[r,[r]]},deserialize:e=>(e.start(),function(e,t){const r=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}})),g(e,r,[],t)}(e))},c=new Map([["proxy",l],["throw",{canHandle:e=>u(e)&&a in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function h(e,t=globalThis,r=["*"]){t.addEventListener("message",(function i(s){if(!s||!s.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(r,s.origin))return void console.warn(`Invalid origin '${s.origin}' for comlink proxy`);const{id:u,type:l,path:c}=Object.assign({path:[]},s.data),f=(s.data.argumentList||[]).map(b);let p;try{const t=c.slice(0,-1).reduce(((e,t)=>e[t]),e),r=c.reduce(((e,t)=>e[t]),e);switch(l){case"GET":p=r;break;case"SET":t[c.slice(-1)[0]]=b(s.data.value),p=!0;break;case"APPLY":p=r.apply(t,f);break;case"CONSTRUCT":p=function(e){return Object.assign(e,{[n]:!0})}(new r(...f));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;h(e,r),p=function(e,t){return x.set(e,t),e}(t,[t])}break;case"RELEASE":p=void 0;break;default:return}}catch(m){p={value:m,[a]:0}}Promise.resolve(p).catch((e=>({value:e,[a]:0}))).then((r=>{const[n,s]=w(r);t.postMessage(Object.assign(Object.assign({},n),{id:u}),s),"RELEASE"===l&&(t.removeEventListener("message",i),d(t),o in e&&"function"==typeof e[o]&&e[o]())})).catch((e=>{const[r,n]=w({value:new TypeError("Unserializable return value"),[a]:0});t.postMessage(Object.assign(Object.assign({},r),{id:u}),n)}))})),t.start&&t.start()}function d(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function f(e){if(e)throw new Error("Proxy has been released and is not useable")}function p(e){return k(e,new Map,{type:"RELEASE"}).then((()=>{d(e)}))}const m=new WeakMap,y="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(m.get(e)||0)-1;m.set(e,t),0===t&&p(e)}));function g(e,t,r=[],n=function(){}){let o=!1;const a=new Proxy(n,{get(n,i){if(f(o),i===s)return()=>{!function(e){y&&y.unregister(e)}(a),p(e),t.clear(),o=!0};if("then"===i){if(0===r.length)return{then:()=>a};const n=k(e,t,{type:"GET",path:r.map((e=>e.toString()))}).then(b);return n.then.bind(n)}return g(e,t,[...r,i])},set(n,i,s){f(o);const[a,u]=w(s);return k(e,t,{type:"SET",path:[...r,i].map((e=>e.toString())),value:a},u).then(b)},apply(n,s,a){f(o);const u=r[r.length-1];if(u===i)return k(e,t,{type:"ENDPOINT"}).then(b);if("bind"===u)return g(e,t,r.slice(0,-1));const[l,c]=v(a);return k(e,t,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:l},c).then(b)},construct(n,i){f(o);const[s,a]=v(i);return k(e,t,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:s},a).then(b)}});return function(e,t){const r=(m.get(t)||0)+1;m.set(t,r),y&&y.register(e,t,e)}(a,e),a}function v(e){const t=e.map(w);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const x=new WeakMap;function w(e){for(const[t,r]of c)if(r.canHandle(e)){const[n,i]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},i]}return[{type:"RAW",value:e},x.get(e)||[]]}function b(e){switch(e.type){case"HANDLER":return c.get(e.name).deserialize(e.value);case"RAW":return e.value}}function k(e,t,r,n){return new Promise((i=>{const s=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(s,i),e.start&&e.start(),e.postMessage(Object.ass