Files
fad_oa/ruoyi-ui/public/file-viewer/assets/worker-bundle-Dx5mKZOL.js

7 lines
60 KiB
JavaScript
Raw Normal View History

/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
const e=Symbol("Comlink.proxy"),r=Symbol("Comlink.endpoint"),t=Symbol("Comlink.releaseProxy"),n=Symbol("Comlink.finalizer"),o=Symbol("Comlink.thrown"),a=e=>"object"==typeof e&&null!==e||"function"==typeof e,s=new Map([["proxy",{canHandle:r=>a(r)&&r[e],serialize(e){const{port1:r,port2:t}=new MessageChannel;return i(e,r),[t,[t]]},deserialize(e){return e.start(),f(e,[],r);var r}}],["throw",{canHandle:e=>a(e)&&o in e,serialize({value:e}){let r;return r=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[r,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function i(r,t=globalThis,a=["*"]){t.addEventListener("message",(function s(l){if(!l||!l.data)return;if(!function(e,r){for(const t of e){if(r===t||"*"===t)return!0;if(t instanceof RegExp&&t.test(r))return!0}return!1}(a,l.origin))return void console.warn(`Invalid origin '${l.origin}' for comlink proxy`);const{id:c,type:d,path:h}=Object.assign({path:[]},l.data),f=(l.data.argumentList||[]).map(w);let m;try{const t=h.slice(0,-1).reduce(((e,r)=>e[r]),r),n=h.reduce(((e,r)=>e[r]),r);switch(d){case"GET":m=n;break;case"SET":t[h.slice(-1)[0]]=w(l.data.value),m=!0;break;case"APPLY":m=n.apply(t,f);break;case"CONSTRUCT":m=function(r){return Object.assign(r,{[e]:!0})}(new n(...f));break;case"ENDPOINT":{const{port1:e,port2:t}=new MessageChannel;i(r,t),m=function(e,r){return p.set(e,r),e}(e,[e])}break;case"RELEASE":m=void 0;break;default:return}}catch(e){m={value:e,[o]:0}}Promise.resolve(m).catch((e=>({value:e,[o]:0}))).then((e=>{const[o,a]=v(e);t.postMessage(Object.assign(Object.assign({},o),{id:c}),a),"RELEASE"===d&&(t.removeEventListener("message",s),u(t),n in r&&"function"==typeof r[n]&&r[n]())})).catch((e=>{const[r,n]=v({value:new TypeError("Unserializable return value"),[o]:0});t.postMessage(Object.assign(Object.assign({},r),{id:c}),n)}))})),t.start&&t.start()}function u(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function l(e){if(e)throw new Error("Proxy has been released and is not useable")}function c(e){return g(e,{type:"RELEASE"}).then((()=>{u(e)}))}const d=new WeakMap,h="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const r=(d.get(e)||0)-1;d.set(e,r),0===r&&c(e)}));function f(e,n=[],o=function(){}){let a=!1;const s=new Proxy(o,{get(r,o){if(l(a),o===t)return()=>{!function(e){h&&h.unregister(e)}(s),c(e),a=!0};if("then"===o){if(0===n.length)return{then:()=>s};const r=g(e,{type:"GET",path:n.map((e=>e.toString()))}).then(w);return r.then.bind(r)}return f(e,[...n,o])},set(r,t,o){l(a);const[s,i]=v(o);return g(e,{type:"SET",path:[...n,t].map((e=>e.toString())),value:s},i).then(w)},apply(t,o,s){l(a);const i=n[n.length-1];if(i===r)return g(e,{type:"ENDPOINT"}).then(w);if("bind"===i)return f(e,n.slice(0,-1));const[u,c]=m(s);return g(e,{type:"APPLY",path:n.map((e=>e.toString())),argumentList:u},c).then(w)},construct(r,t){l(a);const[o,s]=m(t);return g(e,{type:"CONSTRUCT",path:n.map((e=>e.toString())),argumentList:o},s).then(w)}});return function(e,r){const t=(d.get(r)||0)+1;d.set(r,t),h&&h.register(e,r,e)}(s,e),s}function m(e){const r=e.map(v);return[r.map((e=>e[0])),(t=r.map((e=>e[1])),Array.prototype.concat.apply([],t))];var t}const p=new WeakMap;function v(e){for(const[r,t]of s)if(t.canHandle(e)){const[n,o]=t.serialize(e);return[{type:"HANDLER",name:r,value:n},o]}return[{type:"RAW",value:e},p.get(e)||[]]}function w(e){switch(e.type){case"HANDLER":return s.get(e.name).deserialize(e.value);case"RAW":return e.value}}function g(e,r,t){return new Promise((n=>{const o=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function r(t){t.data&&t.data.id&&t.data.id===o&&(e.removeEventListener("message",r),n(t.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:o},r),t)}))}const _={32768:"FILE",16384:"DIR",40960:"SYMBOLIC_LINK",49152:"SOCKET",8192:"CHARACTER_DEVICE",24576:"BLOCK_DEVICE",4096:"NAMED_PIPE"};class y{constructor(e){this._wasmModule=e,thi