voice-changer/client/demo_so-vits-svc_40_c/dist/index.js

2 lines
2.8 MiB
JavaScript
Raw Normal View History

2023-03-30 05:11:41 +03:00
/*! For license information please see index.js.LICENSE.txt */
2023-04-05 22:03:09 +03:00
(()=>{var __webpack_modules__={516:function(e){var t;"undefined"!=typeof self&&self,t=()=>(()=>{var e={642:function(e){var t;"undefined"!=typeof self&&self,t=()=>(()=>{"use strict";var e={477:e=>{e.exports=function(e,t,n,i){var r=self||window;try{try{var a;try{a=new r.Blob([e])}catch(t){(a=new(r.BlobBuilder||r.WebKitBlobBuilder||r.MozBlobBuilder||r.MSBlobBuilder)).append(e),a=a.getBlob()}var c=r.URL||r.webkitURL,s=c.createObjectURL(a),o=new r[t](s,n);return c.revokeObjectURL(s),o}catch(i){return new r[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch(e){if(!i)throw Error("Inline worker is not supported");return new r[t](i,n)}}}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{n.r(i),n.d(i,{BrowserTypes:()=>u,Processor:()=>l,WorkerCommand:()=>e,WorkerManager:()=>o,WorkerResponse:()=>t,getBrowserType:()=>d});const e={INITIALIZE:"initialize",EXECUTE:"execute"},t={INITIALIZED:"initialized",EXECUTED:"EXECUTED"};class r{constructor(){this._resolvers=[],this._promises=[]}_add(){this._promises.push(new Promise((e=>{this._resolvers.push(e)})))}enqueue(e){0==this._resolvers.length&&this._add(),this._resolvers.shift()(e)}dequeue(){return 0==this._promises.length&&this._add(),this._promises.shift()}isEmpty(){return 0==this._promises.length}isBlocked(){return 0!=this._resolvers.length}get length(){return this._promises.length-this._resolvers.length}}var a=n(477),c=n.n(a);const s=e=>{const t=e.transfer.map((t=>{if(t instanceof HTMLCanvasElement){const n=t.transferControlToOffscreen();for(const i in e)e[i]==t&&(e[i]=n);return n}return t}));e.transfer=t};class o{constructor(){this.worker=null,this.processor=null,this.config=null,this.sem=new r,this.lock=async()=>await this.sem.dequeue(),this.unlock=e=>{this.sem.enqueue(e+1)},this.init=async i=>{const r=await this.lock();if(this.config=i,this.worker&&this.worker.terminate(),this.worker=null,"SAFARI"==i.browserType||1==i.onLocal)await(a=i.processorURL,new Promise(((e,t)=>{const n=document.createElement("script");n.src=a,n.async=!0,n.onload=()=>e(window.external_global_component),n.onerror=t,document.body.appendChild(n)}))),this.processor=new n.g[i.processorName](i),console.log("[WorkerManager] Processor work on local");else{const n=c()('(()=>{"use strict";const e="EXECUTED",s=self;let a=null,o=null;onmessage=async t=>{if("initialize"===t.data.message)a=t.data.config,importScripts(a.processorURL),o=new self[a.processorName](a),s.postMessage({message:"initialized"});else if("execute"===t.data.message){if(!a||!o)return i=`${a?.processorName||"Config or Processor"} is not initialized.`,void s.postMessage({message:e,data:["error",i]});const r=t.data.params,n=o.process(r);s.postMessage({message:e,data:n},n.transfer)}else console.log("not implemented");var i}})();',"Worker",void 0,void 0),r=new Promise(((r,a)=>{n.onmessage=e=>{e.data.message===t.INITIALIZED?(this.worker=n,r()):(console.warn("Initialization something wrong.."),a())},s(i),n.postMessage({message:e.INITIALIZE,config:i},i.transfer)}));await r,console.log("[WorkerManager] Processor work on Worker")}var a;await this.unlock(r)},this.execute=async n=>{if(this.sem.length>100)throw new Error(`queue is fulled: ${this.sem.length}`);if(!this.config)throw new Error("no config.");const i=await this.lock();try{if("SAFARI"==this.config.browserType||1==this.config.onLocal){if(!this.processor)throw new Error("processor is not activated.");return this.processor.process(n)}{const i=ne