diff --git a/browser/VencordNativeStub.ts b/browser/VencordNativeStub.ts index 664e9eef..e3df0d66 100644 --- a/browser/VencordNativeStub.ts +++ b/browser/VencordNativeStub.ts @@ -19,9 +19,11 @@ /// /// -import monacoHtml from "~fileContent/../src/components/monacoWin.html"; +import monacoHtmlLocal from "~fileContent/monacoWin.html"; +import monacoHtmlCdn from "~fileContent/../src/main/monacoWin.html"; import * as DataStore from "../src/api/DataStore"; import { debounce } from "../src/utils"; +import { EXTENSION_BASE_URL } from "../src/utils/web-metadata"; import { getTheme, Theme } from "../src/utils/discord"; import { getThemeInfo } from "../src/main/themes"; @@ -80,6 +82,7 @@ window.VencordNative = { return; } + win.baseUrl = EXTENSION_BASE_URL; win.setCss = setCssDebounced; win.getCurrentCss = () => VencordNative.quickCss.get(); win.getTheme = () => @@ -87,7 +90,7 @@ window.VencordNative = { ? "vs-light" : "vs-dark"; - win.document.write(monacoHtml); + win.document.write(IS_EXTENSION ? monacoHtmlLocal : monacoHtmlCdn); }, }, diff --git a/browser/content.js b/browser/content.js index e47ef837..4810fe3c 100644 --- a/browser/content.js +++ b/browser/content.js @@ -4,6 +4,11 @@ if (typeof browser === "undefined") { const script = document.createElement("script"); script.src = browser.runtime.getURL("dist/Vencord.js"); +script.id = "vencord-script"; +Object.assign(script.dataset, { + extensionBaseUrl: browser.runtime.getURL(""), + version: browser.runtime.getManifest().version +}); const style = document.createElement("link"); style.type = "text/css"; diff --git a/browser/manifest.json b/browser/manifest.json index 49536a71..69bf0cec 100644 --- a/browser/manifest.json +++ b/browser/manifest.json @@ -28,7 +28,7 @@ "web_accessible_resources": [ { - "resources": ["dist/Vencord.js", "dist/Vencord.css"], + "resources": ["dist/*", "third-party/*"], "matches": ["*://*.discord.com/*"] } ], diff --git a/browser/monaco.ts b/browser/monaco.ts new file mode 100644 index 00000000..ead061d6 --- /dev/null +++ b/browser/monaco.ts @@ -0,0 +1,43 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./patch-worker"; + +import * as monaco from "monaco-editor/esm/vs/editor/editor.main.js"; + +declare global { + const baseUrl: string; + const getCurrentCss: () => Promise; + const setCss: (css: string) => void; + const getTheme: () => string; +} + +const BASE = "/dist/monaco/vs"; + +self.MonacoEnvironment = { + getWorkerUrl(_moduleId: unknown, label: string) { + const path = label === "css" ? "/language/css/css.worker.js" : "/editor/editor.worker.js"; + return new URL(BASE + path, baseUrl).toString(); + } +}; + +getCurrentCss().then(css => { + const editor = monaco.editor.create( + document.getElementById("container")!, + { + value: css, + language: "css", + theme: getTheme(), + } + ); + editor.onDidChangeModelContent(() => + setCss(editor.getValue()) + ); + window.addEventListener("resize", () => { + // make monaco re-layout + editor.layout(); + }); +}); diff --git a/browser/monacoWin.html b/browser/monacoWin.html new file mode 100644 index 00000000..a55b0e54 --- /dev/null +++ b/browser/monacoWin.html @@ -0,0 +1,37 @@ + + + + + Vencord QuickCSS Editor + + + + +
+ + + + diff --git a/browser/patch-worker.js b/browser/patch-worker.js new file mode 100644 index 00000000..428ea6cc --- /dev/null +++ b/browser/patch-worker.js @@ -0,0 +1,135 @@ +/* +Copyright 2013 Rob Wu +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Target: Chrome 20+ + +// W3-compliant Worker proxy. +// This module replaces the global Worker object. +// When invoked, the default Worker object is called. +// If this call fails with SECURITY_ERR, the script is fetched +// using async XHR, and transparently proxies all calls and +// setters/getters to the new Worker object. +// Note: This script does not magically circumvent the Same origin policy. + +(function () { + 'use strict'; + var Worker_ = window.Worker; + var URL = window.URL || window.webkitURL; + // Create dummy worker for the following purposes: + // 1. Don't override the global Worker object if the fallback isn't + // going to work (future API changes?) + // 2. Use it to trigger early validation of postMessage calls + // Note: Blob constructor is supported since Chrome 20, but since + // some of the used Chrome APIs are only supported as of Chrome 20, + // I don't bother adding a BlobBuilder fallback. + var dummyWorker = new Worker_( + URL.createObjectURL(new Blob([], { type: 'text/javascript' }))); + window.Worker = function Worker(scriptURL) { + if (arguments.length === 0) { + throw new TypeError('Not enough arguments'); + } + try { + return new Worker_(scriptURL); + } catch (e) { + if (e.code === 18/*DOMException.SECURITY_ERR*/) { + return new WorkerXHR(scriptURL); + } else { + throw e; + } + } + }; + // Bind events and replay queued messages + function bindWorker(worker, workerURL) { + if (worker._terminated) { + return; + } + worker.Worker = new Worker_(workerURL); + worker.Worker.onerror = worker._onerror; + worker.Worker.onmessage = worker._onmessage; + var o; + while ((o = worker._replayQueue.shift())) { + worker.Worker[o.method].apply(worker.Worker, o.arguments); + } + while ((o = worker._messageQueue.shift())) { + worker.Worker.postMessage.apply(worker.Worker, o); + } + } + function WorkerXHR(scriptURL) { + var worker = this; + var x = new XMLHttpRequest(); + x.responseType = 'blob'; + x.onload = function () { + // http://stackoverflow.com/a/10372280/938089 + var workerURL = URL.createObjectURL(x.response); + bindWorker(worker, workerURL); + }; + x.open('GET', scriptURL); + x.send(); + worker._replayQueue = []; + worker._messageQueue = []; + } + WorkerXHR.prototype = { + constructor: Worker_, + terminate: function () { + if (!this._terminated) { + this._terminated = true; + if (this.Worker) + this.Worker.terminate(); + } + }, + postMessage: function (message, transfer) { + if (!(this instanceof WorkerXHR)) + throw new TypeError('Illegal invocation'); + if (this.Worker) { + this.Worker.postMessage.apply(this.Worker, arguments); + } else { + // Trigger validation: + dummyWorker.postMessage(message); + // Alright, push the valid message to the queue. + this._messageQueue.push(arguments); + } + } + }; + // Implement the EventTarget interface + [ + 'addEventListener', + 'removeEventListener', + 'dispatchEvent' + ].forEach(function (method) { + WorkerXHR.prototype[method] = function () { + if (!(this instanceof WorkerXHR)) { + throw new TypeError('Illegal invocation'); + } + if (this.Worker) { + this.Worker[method].apply(this.Worker, arguments); + } else { + this._replayQueue.push({ method: method, arguments: arguments }); + } + }; + }); + Object.defineProperties(WorkerXHR.prototype, { + onmessage: { + get: function () { return this._onmessage || null; }, + set: function (func) { + this._onmessage = typeof func === 'function' ? func : null; + } + }, + onerror: { + get: function () { return this._onerror || null; }, + set: function (func) { + this._onerror = typeof func === 'function' ? func : null; + } + } + }); +})(); \ No newline at end of file diff --git a/browser/third-party/rnnoise/LICENSE b/browser/third-party/rnnoise/LICENSE new file mode 100644 index 00000000..bc8b047a --- /dev/null +++ b/browser/third-party/rnnoise/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 翠 / green + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/browser/third-party/rnnoise/rnnoise.wasm b/browser/third-party/rnnoise/rnnoise.wasm new file mode 100644 index 00000000..6f9fbb60 Binary files /dev/null and b/browser/third-party/rnnoise/rnnoise.wasm differ diff --git a/browser/third-party/rnnoise/rnnoise/workletProcessor.js b/browser/third-party/rnnoise/rnnoise/workletProcessor.js new file mode 100644 index 00000000..e29fdc88 --- /dev/null +++ b/browser/third-party/rnnoise/rnnoise/workletProcessor.js @@ -0,0 +1,13 @@ +var Ke=Object.defineProperty;var Ze=(d,n,e)=>n in d?Ke(d,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[n]=e;var N=(d=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(d,{get:(n,e)=>(typeof require<"u"?require:n)[e]}):d)(function(d){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+d+'" is not supported')});var R=(d,n,e)=>(Ze(d,typeof n!="symbol"?n+"":n,e),e);var S={};var Je=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),Pe=(()=>{var d=import.meta.url;return function(e){e=e||{};var e=typeof e<"u"?e:{},a=Object.assign,p,u;e.ready=new Promise(function(r,o){p=r,u=o}),Object.getOwnPropertyDescriptor(e.ready,"_rnnoise_process_frame")||(Object.defineProperty(e.ready,"_rnnoise_process_frame",{configurable:!0,get:function(){t("You are getting _rnnoise_process_frame on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_rnnoise_process_frame",{configurable:!0,set:function(){t("You are setting _rnnoise_process_frame on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"_rnnoise_destroy")||(Object.defineProperty(e.ready,"_rnnoise_destroy",{configurable:!0,get:function(){t("You are getting _rnnoise_destroy on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_rnnoise_destroy",{configurable:!0,set:function(){t("You are setting _rnnoise_destroy on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"_rnnoise_create")||(Object.defineProperty(e.ready,"_rnnoise_create",{configurable:!0,get:function(){t("You are getting _rnnoise_create on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_rnnoise_create",{configurable:!0,set:function(){t("You are setting _rnnoise_create on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"_rnnoise_get_frame_size")||(Object.defineProperty(e.ready,"_rnnoise_get_frame_size",{configurable:!0,get:function(){t("You are getting _rnnoise_get_frame_size on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_rnnoise_get_frame_size",{configurable:!0,set:function(){t("You are setting _rnnoise_get_frame_size on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"_rnnoise_model_from_string")||(Object.defineProperty(e.ready,"_rnnoise_model_from_string",{configurable:!0,get:function(){t("You are getting _rnnoise_model_from_string on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_rnnoise_model_from_string",{configurable:!0,set:function(){t("You are setting _rnnoise_model_from_string on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"_rnnoise_model_free")||(Object.defineProperty(e.ready,"_rnnoise_model_free",{configurable:!0,get:function(){t("You are getting _rnnoise_model_free on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_rnnoise_model_free",{configurable:!0,set:function(){t("You are setting _rnnoise_model_free on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"_malloc")||(Object.defineProperty(e.ready,"_malloc",{configurable:!0,get:function(){t("You are getting _malloc on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_malloc",{configurable:!0,set:function(){t("You are setting _malloc on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"_free")||(Object.defineProperty(e.ready,"_free",{configurable:!0,get:function(){t("You are getting _free on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_free",{configurable:!0,set:function(){t("You are setting _free on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"_fflush")||(Object.defineProperty(e.ready,"_fflush",{configurable:!0,get:function(){t("You are getting _fflush on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"_fflush",{configurable:!0,set:function(){t("You are setting _fflush on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}})),Object.getOwnPropertyDescriptor(e.ready,"onRuntimeInitialized")||(Object.defineProperty(e.ready,"onRuntimeInitialized",{configurable:!0,get:function(){t("You are getting onRuntimeInitialized on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}),Object.defineProperty(e.ready,"onRuntimeInitialized",{configurable:!0,set:function(){t("You are setting onRuntimeInitialized on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")}}));var g=a({},e),b=typeof S=="object",f=typeof importScripts=="function",y=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",m=!b&&!y&&!f;if(e.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -s ENVIRONMENT=web or -s ENVIRONMENT=node)");var T="";function B(r){return e.locateFile?e.locateFile(r,T):T+r}var U,x,v,J,W,$;if(y){if(!(typeof process=="object"&&typeof N=="function"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");f?T=N("path").dirname(T)+"/":T=__dirname+"/",$=function(){W||(J=N("fs"),W=N("path"))},U=function(o,i){return $(),o=W.normalize(o),J.readFileSync(o,i?null:"utf8")},v=function(o){var i=U(o,!0);return i.buffer||(i=new Uint8Array(i)),s(i.buffer),i},x=function(o,i,c){$(),o=W.normalize(o),J.readFile(o,function(O,M){O?c(O):i(M.buffer)})},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(r){if(!(r instanceof Ve))throw r}),process.on("unhandledRejection",function(r){throw r}),e.inspect=function(){return"[Emscripten Module object]"}}else if(m){if(typeof process=="object"&&typeof N=="function"||typeof S=="object"||typeof importScripts=="function")throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");typeof read<"u"&&(U=function(o){return read(o)}),v=function(o){let i;return typeof readbuffer=="function"?new Uint8Array(readbuffer(o)):(i=read(o,"binary"),s(typeof i=="object"),i)},x=function(o,i,c){setTimeout(()=>i(v(o)),0)},typeof scriptArgs<"u"&&scriptArgs,typeof print<"u"&&(typeof console>"u"&&(console={}),console.log=print,console.warn=console.error=typeof printErr<"u"?printErr:print)}else if(b||f){if(f?T=self.location.href:typeof document<"u"&&document.currentScript&&(T=document.currentScript.src),d&&(T=d),T.indexOf("blob:")!==0?T=T.substr(0,T.replace(/[?#].*/,"").lastIndexOf("/")+1):T="",!(typeof S=="object"||typeof importScripts=="function"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");U=function(r){var o=new XMLHttpRequest;return o.open("GET",r,!1),o.send(null),o.responseText},f&&(v=function(r){var o=new XMLHttpRequest;return o.open("GET",r,!1),o.responseType="arraybuffer",o.send(null),new Uint8Array(o.response)}),x=function(r,o,i){var c=new XMLHttpRequest;c.open("GET",r,!0),c.responseType="arraybuffer",c.onload=function(){if(c.status==200||c.status==0&&c.response){o(c.response);return}i()},c.onerror=i,c.send(null)}}else throw new Error("environment detection error");e.print||console.log.bind(console);var _=e.printErr||console.warn.bind(console);a(e,g),g=null,e.arguments,Object.getOwnPropertyDescriptor(e,"arguments")||Object.defineProperty(e,"arguments",{configurable:!0,get:function(){t("Module.arguments has been replaced with plain arguments_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),e.thisProgram,Object.getOwnPropertyDescriptor(e,"thisProgram")||Object.defineProperty(e,"thisProgram",{configurable:!0,get:function(){t("Module.thisProgram has been replaced with plain thisProgram (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),e.quit,Object.getOwnPropertyDescriptor(e,"quit")||Object.defineProperty(e,"quit",{configurable:!0,get:function(){t("Module.quit has been replaced with plain quit_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),s(typeof e.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),s(typeof e.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),s(typeof e.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),s(typeof e.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),s(typeof e.read>"u","Module.read option was removed (modify read_ in JS)"),s(typeof e.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),s(typeof e.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),s(typeof e.setWindowTitle>"u","Module.setWindowTitle option was removed (modify setWindowTitle in JS)"),s(typeof e.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),Object.getOwnPropertyDescriptor(e,"read")||Object.defineProperty(e,"read",{configurable:!0,get:function(){t("Module.read has been replaced with plain read_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),Object.getOwnPropertyDescriptor(e,"readAsync")||Object.defineProperty(e,"readAsync",{configurable:!0,get:function(){t("Module.readAsync has been replaced with plain readAsync (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),Object.getOwnPropertyDescriptor(e,"readBinary")||Object.defineProperty(e,"readBinary",{configurable:!0,get:function(){t("Module.readBinary has been replaced with plain readBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),Object.getOwnPropertyDescriptor(e,"setWindowTitle")||Object.defineProperty(e,"setWindowTitle",{configurable:!0,get:function(){t("Module.setWindowTitle has been replaced with plain setWindowTitle (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),s(!m,"shell environment detected but not enabled at build time. Add 'shell' to `-s ENVIRONMENT` to enable.");function H(r){H.shown||(H.shown={}),H.shown[r]||(H.shown[r]=1,_(r))}var k;e.wasmBinary&&(k=e.wasmBinary),Object.getOwnPropertyDescriptor(e,"wasmBinary")||Object.defineProperty(e,"wasmBinary",{configurable:!0,get:function(){t("Module.wasmBinary has been replaced with plain wasmBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),e.noExitRuntime,Object.getOwnPropertyDescriptor(e,"noExitRuntime")||Object.defineProperty(e,"noExitRuntime",{configurable:!0,get:function(){t("Module.noExitRuntime has been replaced with plain noExitRuntime (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),typeof WebAssembly!="object"&&t("no native wasm support detected");var C,Y=!1;function s(r,o){r||t("Assertion failed"+(o?": "+o:""))}var Ee=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Fe(r,o,i){for(var c=o+i,O=o;r[O]&&!(O>=c);)++O;if(O-o>16&&r.subarray&&Ee)return Ee.decode(r.subarray(o,O));for(var M="";o>10,56320|j&1023)}}return M}function ee(r,o){return r?Fe(z,r,o):""}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function Ae(r,o){return r%o>0&&(r+=o-r%o),r}var te,z,X,re;function Oe(r){te=r,e.HEAP8=new Int8Array(r),e.HEAP16=new Int16Array(r),e.HEAP32=X=new Int32Array(r),e.HEAPU8=z=new Uint8Array(r),e.HEAPU16=new Uint16Array(r),e.HEAPU32=re=new Uint32Array(r),e.HEAPF32=new Float32Array(r),e.HEAPF64=new Float64Array(r)}var oe=5242880;e.TOTAL_STACK&&s(oe===e.TOTAL_STACK,"the stack size can no longer be determined at runtime");var ne=e.INITIAL_MEMORY||16777216;Object.getOwnPropertyDescriptor(e,"INITIAL_MEMORY")||Object.defineProperty(e,"INITIAL_MEMORY",{configurable:!0,get:function(){t("Module.INITIAL_MEMORY has been replaced with plain INITIAL_MEMORY (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}}),s(ne>=oe,"INITIAL_MEMORY should be larger than TOTAL_STACK, was "+ne+"! (TOTAL_STACK="+oe+")"),s(typeof Int32Array<"u"&&typeof Float64Array<"u"&&Int32Array.prototype.subarray!==void 0&&Int32Array.prototype.set!==void 0,"JS engine does not provide full typed array support"),s(!e.wasmMemory,"Use of `wasmMemory` detected. Use -s IMPORTED_MEMORY to define wasmMemory externally"),s(ne==16777216,"Detected runtime INITIAL_MEMORY setting. Use -s IMPORTED_MEMORY to define wasmMemory dynamically");var V;function ue(){var r=ce();s((r&3)==0),X[r+4>>2]=34821223,X[r+8>>2]=2310721022,X[0]=1668509029}function G(){if(!Y){var r=ce(),o=re[r+4>>2],i=re[r+8>>2];(o!=34821223||i!=2310721022)&&t("Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x"+i.toString(16)+" 0x"+o.toString(16)),X[0]!==1668509029&&t("Runtime error: The application has corrupted its heap memory area (address zero)!")}}(function(){var r=new Int16Array(1),o=new Int8Array(r.buffer);if(r[0]=25459,o[0]!==115||o[1]!==99)throw"Runtime error: expected the system to be little-endian! (Run with -s SUPPORT_BIG_ENDIAN=1 to bypass)"})();var Te=[],_e=[],ge=[],ie=!1,Ie=!1;function Ue(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Ne(e.preRun.shift());ae(Te)}function ve(){G(),s(!ie),ie=!0,ae(_e)}function je(){if(G(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)He(e.postRun.shift());ae(ge)}function Ne(r){Te.unshift(r)}function xe(r){_e.unshift(r)}function He(r){ge.unshift(r)}s(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),s(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),s(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),s(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var F=0,A=null,Q=null,L={};function ke(r){F++,e.monitorRunDependencies&&e.monitorRunDependencies(F),r?(s(!L[r]),L[r]=1,A===null&&typeof setInterval<"u"&&(A=setInterval(function(){if(Y){clearInterval(A),A=null;return}var o=!1;for(var i in L)o||(o=!0,_("still waiting on run dependencies:")),_("dependency: "+i);o&&_("(end of list)")},1e4))):_("warning: run dependency added without ID")}function Ce(r){if(F--,e.monitorRunDependencies&&e.monitorRunDependencies(F),r?(s(L[r]),delete L[r]):_("warning: run dependency removed without ID"),F==0&&(A!==null&&(clearInterval(A),A=null),Q)){var o=Q;Q=null,o()}}e.preloadedImages={},e.preloadedAudios={};function t(r){e.onAbort&&e.onAbort(r),r="Aborted("+r+")",_(r),Y=!0;var o=new WebAssembly.RuntimeError(r);throw u(o),o}var h={error:function(){t("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -s FORCE_FILESYSTEM=1")},init:function(){h.error()},createDataFile:function(){h.error()},createPreloadedFile:function(){h.error()},createLazyFile:function(){h.error()},open:function(){h.error()},mkdev:function(){h.error()},registerDevice:function(){h.error()},analyzePath:function(){h.error()},loadFilesFromDB:function(){h.error()},ErrnoError:function(){h.error()}};e.FS_createDataFile=h.createDataFile,e.FS_createPreloadedFile=h.createPreloadedFile;var Xe="data:application/octet-stream;base64,";function De(r){return r.startsWith(Xe)}function se(r){return r.startsWith("file://")}function D(r,o){return function(){var i=r,c=o;return o||(c=e.asm),s(ie,"native function `"+i+"` called before runtime initialization"),s(!Ie,"native function `"+i+"` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)"),c[r]||s(c[r],"exported native function `"+i+"` not found"),c[r].apply(null,arguments)}}var E;e.locateFile?(E="rnnoise.wasm",De(E)||(E=B(E))):E=new URL("rnnoise.wasm",import.meta.url).toString();function ye(r){try{if(r==E&&k)return new Uint8Array(k);if(v)return v(r);throw"both async and sync fetching of the wasm failed"}catch(o){t(o)}}function Qe(){if(!k&&(b||f)){if(typeof fetch=="function"&&!se(E))return fetch(E,{credentials:"same-origin"}).then(function(r){if(!r.ok)throw"failed to load wasm binary file at '"+E+"'";return r.arrayBuffer()}).catch(function(){return ye(E)});if(x)return new Promise(function(r,o){x(E,function(i){r(new Uint8Array(i))},o)})}return Promise.resolve().then(function(){return ye(E)})}function Le(){var r={env:he,wasi_snapshot_preview1:he};function o(w,P){var j=w.exports;e.asm=j,C=e.asm.memory,s(C,"memory not found in wasm exports"),Oe(C.buffer),V=e.asm.__indirect_function_table,s(V,"table not found in wasm exports"),xe(e.asm.__wasm_call_ctors),Ce("wasm-instantiate")}ke("wasm-instantiate");var i=e;function c(w){s(e===i,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),i=null,o(w.instance)}function O(w){return Qe().then(function(P){return WebAssembly.instantiate(P,r)}).then(function(P){return P}).then(w,function(P){_("failed to asynchronously prepare wasm: "+P),se(E)&&_("warning: Loading from a file URI ("+E+") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"),t(P)})}function M(){return!k&&typeof WebAssembly.instantiateStreaming=="function"&&!De(E)&&!se(E)&&typeof fetch=="function"?fetch(E,{credentials:"same-origin"}).then(function(w){var P=WebAssembly.instantiateStreaming(w,r);return P.then(c,function(j){return _("wasm streaming compile failed: "+j),_("falling back to ArrayBuffer instantiation"),O(c)})}):O(c)}if(e.instantiateWasm)try{var l=e.instantiateWasm(r,o);return l}catch(w){return _("Module.instantiateWasm callback failed with error: "+w),!1}return M().catch(u),{}}function ae(r){for(;r.length>0;){var o=r.shift();if(typeof o=="function"){o(e);continue}var i=o.func;typeof i=="number"?o.arg===void 0?we(i)():we(i)(o.arg):i(o.arg===void 0?null:o.arg)}}var K=[];function we(r){var o=K[r];return o||(r>=K.length&&(K.length=r+1),K[r]=o=V.get(r)),s(V.get(r)==o,"JavaScript-side Wasm function table mirror is out of date!"),o}function Be(r,o,i,c){t("Assertion failed: "+ee(r)+", at: "+[o?ee(o):"unknown filename",i,c?ee(c):"unknown function"])}function We(r,o,i){z.copyWithin(r,o,o+i)}function Ye(r){try{return C.grow(r-te.byteLength+65535>>>16),Oe(C.buffer),1}catch(o){_("emscripten_realloc_buffer: Attempted to grow heap from "+te.byteLength+" bytes to "+r+" bytes, but got error: "+o)}}function ze(r){var o=z.length;r=r>>>0,s(r>o);var i=2147483648;if(r>i)return _("Cannot enlarge memory, asked to go up to "+r+" bytes, but the limit is "+i+" bytes!"),!1;for(var c=1;c<=4;c*=2){var O=o*(1+.2/c);O=Math.min(O,r+100663296);var M=Math.min(i,Ae(Math.max(r,O),65536)),l=Ye(M);if(l)return!0}return _("Failed to grow the heap from "+o+" bytes to "+M+" bytes, not enough memory!"),!1}var he={__assert_fail:Be,emscripten_memcpy_big:We,emscripten_resize_heap:ze};Le(),e.___wasm_call_ctors=D("__wasm_call_ctors"),e._rnnoise_get_frame_size=D("rnnoise_get_frame_size"),e._rnnoise_create=D("rnnoise_create"),e._rnnoise_destroy=D("rnnoise_destroy"),e._rnnoise_process_frame=D("rnnoise_process_frame"),e._rnnoise_model_free=D("rnnoise_model_free"),e._rnnoise_model_from_string=D("rnnoise_model_from_string"),e.___errno_location=D("__errno_location"),e._fflush=D("fflush");var Me=e._emscripten_stack_init=function(){return(Me=e._emscripten_stack_init=e.asm.emscripten_stack_init).apply(null,arguments)};e._emscripten_stack_get_free=function(){return(e._emscripten_stack_get_free=e.asm.emscripten_stack_get_free).apply(null,arguments)};var ce=e._emscripten_stack_get_end=function(){return(ce=e._emscripten_stack_get_end=e.asm.emscripten_stack_get_end).apply(null,arguments)};e.stackSave=D("stackSave"),e.stackRestore=D("stackRestore"),e.stackAlloc=D("stackAlloc"),e._malloc=D("malloc"),e._free=D("free"),Object.getOwnPropertyDescriptor(e,"intArrayFromString")||(e.intArrayFromString=function(){t("'intArrayFromString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"intArrayToString")||(e.intArrayToString=function(){t("'intArrayToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"ccall")||(e.ccall=function(){t("'ccall' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"cwrap")||(e.cwrap=function(){t("'cwrap' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setValue")||(e.setValue=function(){t("'setValue' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getValue")||(e.getValue=function(){t("'getValue' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"allocate")||(e.allocate=function(){t("'allocate' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"UTF8ArrayToString")||(e.UTF8ArrayToString=function(){t("'UTF8ArrayToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"UTF8ToString")||(e.UTF8ToString=function(){t("'UTF8ToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stringToUTF8Array")||(e.stringToUTF8Array=function(){t("'stringToUTF8Array' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stringToUTF8")||(e.stringToUTF8=function(){t("'stringToUTF8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"lengthBytesUTF8")||(e.lengthBytesUTF8=function(){t("'lengthBytesUTF8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stackTrace")||(e.stackTrace=function(){t("'stackTrace' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"addOnPreRun")||(e.addOnPreRun=function(){t("'addOnPreRun' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"addOnInit")||(e.addOnInit=function(){t("'addOnInit' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"addOnPreMain")||(e.addOnPreMain=function(){t("'addOnPreMain' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"addOnExit")||(e.addOnExit=function(){t("'addOnExit' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"addOnPostRun")||(e.addOnPostRun=function(){t("'addOnPostRun' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeStringToMemory")||(e.writeStringToMemory=function(){t("'writeStringToMemory' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeArrayToMemory")||(e.writeArrayToMemory=function(){t("'writeArrayToMemory' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeAsciiToMemory")||(e.writeAsciiToMemory=function(){t("'writeAsciiToMemory' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"addRunDependency")||(e.addRunDependency=function(){t("'addRunDependency' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(e,"removeRunDependency")||(e.removeRunDependency=function(){t("'removeRunDependency' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(e,"FS_createFolder")||(e.FS_createFolder=function(){t("'FS_createFolder' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"FS_createPath")||(e.FS_createPath=function(){t("'FS_createPath' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(e,"FS_createDataFile")||(e.FS_createDataFile=function(){t("'FS_createDataFile' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(e,"FS_createPreloadedFile")||(e.FS_createPreloadedFile=function(){t("'FS_createPreloadedFile' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(e,"FS_createLazyFile")||(e.FS_createLazyFile=function(){t("'FS_createLazyFile' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(e,"FS_createLink")||(e.FS_createLink=function(){t("'FS_createLink' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"FS_createDevice")||(e.FS_createDevice=function(){t("'FS_createDevice' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(e,"FS_unlink")||(e.FS_unlink=function(){t("'FS_unlink' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ). Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you")}),Object.getOwnPropertyDescriptor(e,"getLEB")||(e.getLEB=function(){t("'getLEB' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getFunctionTables")||(e.getFunctionTables=function(){t("'getFunctionTables' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"alignFunctionTables")||(e.alignFunctionTables=function(){t("'alignFunctionTables' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerFunctions")||(e.registerFunctions=function(){t("'registerFunctions' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"addFunction")||(e.addFunction=function(){t("'addFunction' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"removeFunction")||(e.removeFunction=function(){t("'removeFunction' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getFuncWrapper")||(e.getFuncWrapper=function(){t("'getFuncWrapper' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"prettyPrint")||(e.prettyPrint=function(){t("'prettyPrint' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"dynCall")||(e.dynCall=function(){t("'dynCall' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getCompilerSetting")||(e.getCompilerSetting=function(){t("'getCompilerSetting' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"print")||(e.print=function(){t("'print' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"printErr")||(e.printErr=function(){t("'printErr' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getTempRet0")||(e.getTempRet0=function(){t("'getTempRet0' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setTempRet0")||(e.setTempRet0=function(){t("'setTempRet0' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"callMain")||(e.callMain=function(){t("'callMain' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"abort")||(e.abort=function(){t("'abort' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"keepRuntimeAlive")||(e.keepRuntimeAlive=function(){t("'keepRuntimeAlive' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"zeroMemory")||(e.zeroMemory=function(){t("'zeroMemory' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stringToNewUTF8")||(e.stringToNewUTF8=function(){t("'stringToNewUTF8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setFileTime")||(e.setFileTime=function(){t("'setFileTime' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"emscripten_realloc_buffer")||(e.emscripten_realloc_buffer=function(){t("'emscripten_realloc_buffer' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"ENV")||(e.ENV=function(){t("'ENV' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"withStackSave")||(e.withStackSave=function(){t("'withStackSave' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"ERRNO_CODES")||(e.ERRNO_CODES=function(){t("'ERRNO_CODES' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"ERRNO_MESSAGES")||(e.ERRNO_MESSAGES=function(){t("'ERRNO_MESSAGES' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setErrNo")||(e.setErrNo=function(){t("'setErrNo' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"inetPton4")||(e.inetPton4=function(){t("'inetPton4' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"inetNtop4")||(e.inetNtop4=function(){t("'inetNtop4' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"inetPton6")||(e.inetPton6=function(){t("'inetPton6' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"inetNtop6")||(e.inetNtop6=function(){t("'inetNtop6' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"readSockaddr")||(e.readSockaddr=function(){t("'readSockaddr' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeSockaddr")||(e.writeSockaddr=function(){t("'writeSockaddr' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"DNS")||(e.DNS=function(){t("'DNS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getHostByName")||(e.getHostByName=function(){t("'getHostByName' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"GAI_ERRNO_MESSAGES")||(e.GAI_ERRNO_MESSAGES=function(){t("'GAI_ERRNO_MESSAGES' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"Protocols")||(e.Protocols=function(){t("'Protocols' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"Sockets")||(e.Sockets=function(){t("'Sockets' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getRandomDevice")||(e.getRandomDevice=function(){t("'getRandomDevice' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"traverseStack")||(e.traverseStack=function(){t("'traverseStack' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"convertFrameToPC")||(e.convertFrameToPC=function(){t("'convertFrameToPC' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"UNWIND_CACHE")||(e.UNWIND_CACHE=function(){t("'UNWIND_CACHE' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"saveInUnwindCache")||(e.saveInUnwindCache=function(){t("'saveInUnwindCache' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"convertPCtoSourceLocation")||(e.convertPCtoSourceLocation=function(){t("'convertPCtoSourceLocation' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"readAsmConstArgsArray")||(e.readAsmConstArgsArray=function(){t("'readAsmConstArgsArray' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"readAsmConstArgs")||(e.readAsmConstArgs=function(){t("'readAsmConstArgs' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"mainThreadEM_ASM")||(e.mainThreadEM_ASM=function(){t("'mainThreadEM_ASM' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"jstoi_q")||(e.jstoi_q=function(){t("'jstoi_q' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"jstoi_s")||(e.jstoi_s=function(){t("'jstoi_s' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getExecutableName")||(e.getExecutableName=function(){t("'getExecutableName' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"listenOnce")||(e.listenOnce=function(){t("'listenOnce' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"autoResumeAudioContext")||(e.autoResumeAudioContext=function(){t("'autoResumeAudioContext' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"dynCallLegacy")||(e.dynCallLegacy=function(){t("'dynCallLegacy' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getDynCaller")||(e.getDynCaller=function(){t("'getDynCaller' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"dynCall")||(e.dynCall=function(){t("'dynCall' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"callRuntimeCallbacks")||(e.callRuntimeCallbacks=function(){t("'callRuntimeCallbacks' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"wasmTableMirror")||(e.wasmTableMirror=function(){t("'wasmTableMirror' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setWasmTableEntry")||(e.setWasmTableEntry=function(){t("'setWasmTableEntry' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getWasmTableEntry")||(e.getWasmTableEntry=function(){t("'getWasmTableEntry' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"handleException")||(e.handleException=function(){t("'handleException' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"runtimeKeepalivePush")||(e.runtimeKeepalivePush=function(){t("'runtimeKeepalivePush' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"runtimeKeepalivePop")||(e.runtimeKeepalivePop=function(){t("'runtimeKeepalivePop' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"callUserCallback")||(e.callUserCallback=function(){t("'callUserCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"maybeExit")||(e.maybeExit=function(){t("'maybeExit' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"safeSetTimeout")||(e.safeSetTimeout=function(){t("'safeSetTimeout' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"asmjsMangle")||(e.asmjsMangle=function(){t("'asmjsMangle' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"asyncLoad")||(e.asyncLoad=function(){t("'asyncLoad' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"alignMemory")||(e.alignMemory=function(){t("'alignMemory' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"mmapAlloc")||(e.mmapAlloc=function(){t("'mmapAlloc' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"reallyNegative")||(e.reallyNegative=function(){t("'reallyNegative' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"unSign")||(e.unSign=function(){t("'unSign' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"reSign")||(e.reSign=function(){t("'reSign' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"formatString")||(e.formatString=function(){t("'formatString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"PATH")||(e.PATH=function(){t("'PATH' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"PATH_FS")||(e.PATH_FS=function(){t("'PATH_FS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"SYSCALLS")||(e.SYSCALLS=function(){t("'SYSCALLS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"syscallMmap2")||(e.syscallMmap2=function(){t("'syscallMmap2' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"syscallMunmap")||(e.syscallMunmap=function(){t("'syscallMunmap' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getSocketFromFD")||(e.getSocketFromFD=function(){t("'getSocketFromFD' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getSocketAddress")||(e.getSocketAddress=function(){t("'getSocketAddress' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"JSEvents")||(e.JSEvents=function(){t("'JSEvents' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerKeyEventCallback")||(e.registerKeyEventCallback=function(){t("'registerKeyEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"specialHTMLTargets")||(e.specialHTMLTargets=function(){t("'specialHTMLTargets' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"maybeCStringToJsString")||(e.maybeCStringToJsString=function(){t("'maybeCStringToJsString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"findEventTarget")||(e.findEventTarget=function(){t("'findEventTarget' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"findCanvasEventTarget")||(e.findCanvasEventTarget=function(){t("'findCanvasEventTarget' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getBoundingClientRect")||(e.getBoundingClientRect=function(){t("'getBoundingClientRect' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillMouseEventData")||(e.fillMouseEventData=function(){t("'fillMouseEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerMouseEventCallback")||(e.registerMouseEventCallback=function(){t("'registerMouseEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerWheelEventCallback")||(e.registerWheelEventCallback=function(){t("'registerWheelEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerUiEventCallback")||(e.registerUiEventCallback=function(){t("'registerUiEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerFocusEventCallback")||(e.registerFocusEventCallback=function(){t("'registerFocusEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillDeviceOrientationEventData")||(e.fillDeviceOrientationEventData=function(){t("'fillDeviceOrientationEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerDeviceOrientationEventCallback")||(e.registerDeviceOrientationEventCallback=function(){t("'registerDeviceOrientationEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillDeviceMotionEventData")||(e.fillDeviceMotionEventData=function(){t("'fillDeviceMotionEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerDeviceMotionEventCallback")||(e.registerDeviceMotionEventCallback=function(){t("'registerDeviceMotionEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"screenOrientation")||(e.screenOrientation=function(){t("'screenOrientation' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillOrientationChangeEventData")||(e.fillOrientationChangeEventData=function(){t("'fillOrientationChangeEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerOrientationChangeEventCallback")||(e.registerOrientationChangeEventCallback=function(){t("'registerOrientationChangeEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillFullscreenChangeEventData")||(e.fillFullscreenChangeEventData=function(){t("'fillFullscreenChangeEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerFullscreenChangeEventCallback")||(e.registerFullscreenChangeEventCallback=function(){t("'registerFullscreenChangeEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerRestoreOldStyle")||(e.registerRestoreOldStyle=function(){t("'registerRestoreOldStyle' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"hideEverythingExceptGivenElement")||(e.hideEverythingExceptGivenElement=function(){t("'hideEverythingExceptGivenElement' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"restoreHiddenElements")||(e.restoreHiddenElements=function(){t("'restoreHiddenElements' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setLetterbox")||(e.setLetterbox=function(){t("'setLetterbox' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"currentFullscreenStrategy")||(e.currentFullscreenStrategy=function(){t("'currentFullscreenStrategy' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"restoreOldWindowedStyle")||(e.restoreOldWindowedStyle=function(){t("'restoreOldWindowedStyle' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"softFullscreenResizeWebGLRenderTarget")||(e.softFullscreenResizeWebGLRenderTarget=function(){t("'softFullscreenResizeWebGLRenderTarget' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"doRequestFullscreen")||(e.doRequestFullscreen=function(){t("'doRequestFullscreen' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillPointerlockChangeEventData")||(e.fillPointerlockChangeEventData=function(){t("'fillPointerlockChangeEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerPointerlockChangeEventCallback")||(e.registerPointerlockChangeEventCallback=function(){t("'registerPointerlockChangeEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerPointerlockErrorEventCallback")||(e.registerPointerlockErrorEventCallback=function(){t("'registerPointerlockErrorEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"requestPointerLock")||(e.requestPointerLock=function(){t("'requestPointerLock' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillVisibilityChangeEventData")||(e.fillVisibilityChangeEventData=function(){t("'fillVisibilityChangeEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerVisibilityChangeEventCallback")||(e.registerVisibilityChangeEventCallback=function(){t("'registerVisibilityChangeEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerTouchEventCallback")||(e.registerTouchEventCallback=function(){t("'registerTouchEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillGamepadEventData")||(e.fillGamepadEventData=function(){t("'fillGamepadEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerGamepadEventCallback")||(e.registerGamepadEventCallback=function(){t("'registerGamepadEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerBeforeUnloadEventCallback")||(e.registerBeforeUnloadEventCallback=function(){t("'registerBeforeUnloadEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"fillBatteryEventData")||(e.fillBatteryEventData=function(){t("'fillBatteryEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"battery")||(e.battery=function(){t("'battery' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"registerBatteryEventCallback")||(e.registerBatteryEventCallback=function(){t("'registerBatteryEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setCanvasElementSize")||(e.setCanvasElementSize=function(){t("'setCanvasElementSize' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getCanvasElementSize")||(e.getCanvasElementSize=function(){t("'getCanvasElementSize' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"demangle")||(e.demangle=function(){t("'demangle' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"demangleAll")||(e.demangleAll=function(){t("'demangleAll' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"jsStackTrace")||(e.jsStackTrace=function(){t("'jsStackTrace' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stackTrace")||(e.stackTrace=function(){t("'stackTrace' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getEnvStrings")||(e.getEnvStrings=function(){t("'getEnvStrings' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"checkWasiClock")||(e.checkWasiClock=function(){t("'checkWasiClock' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"flush_NO_FILESYSTEM")||(e.flush_NO_FILESYSTEM=function(){t("'flush_NO_FILESYSTEM' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeI53ToI64")||(e.writeI53ToI64=function(){t("'writeI53ToI64' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeI53ToI64Clamped")||(e.writeI53ToI64Clamped=function(){t("'writeI53ToI64Clamped' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeI53ToI64Signaling")||(e.writeI53ToI64Signaling=function(){t("'writeI53ToI64Signaling' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeI53ToU64Clamped")||(e.writeI53ToU64Clamped=function(){t("'writeI53ToU64Clamped' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"writeI53ToU64Signaling")||(e.writeI53ToU64Signaling=function(){t("'writeI53ToU64Signaling' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"readI53FromI64")||(e.readI53FromI64=function(){t("'readI53FromI64' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"readI53FromU64")||(e.readI53FromU64=function(){t("'readI53FromU64' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"convertI32PairToI53")||(e.convertI32PairToI53=function(){t("'convertI32PairToI53' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"convertU32PairToI53")||(e.convertU32PairToI53=function(){t("'convertU32PairToI53' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setImmediateWrapped")||(e.setImmediateWrapped=function(){t("'setImmediateWrapped' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"clearImmediateWrapped")||(e.clearImmediateWrapped=function(){t("'clearImmediateWrapped' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"polyfillSetImmediate")||(e.polyfillSetImmediate=function(){t("'polyfillSetImmediate' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"Browser")||(e.Browser=function(){t("'Browser' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"funcWrappers")||(e.funcWrappers=function(){t("'funcWrappers' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"getFuncWrapper")||(e.getFuncWrapper=function(){t("'getFuncWrapper' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"setMainLoop")||(e.setMainLoop=function(){t("'setMainLoop' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"wget")||(e.wget=function(){t("'wget' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"FS")||(e.FS=function(){t("'FS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"MEMFS")||(e.MEMFS=function(){t("'MEMFS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"TTY")||(e.TTY=function(){t("'TTY' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"PIPEFS")||(e.PIPEFS=function(){t("'PIPEFS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"SOCKFS")||(e.SOCKFS=function(){t("'SOCKFS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"_setNetworkCallback")||(e._setNetworkCallback=function(){t("'_setNetworkCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"warnOnce")||(e.warnOnce=function(){t("'warnOnce' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stackSave")||(e.stackSave=function(){t("'stackSave' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stackRestore")||(e.stackRestore=function(){t("'stackRestore' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stackAlloc")||(e.stackAlloc=function(){t("'stackAlloc' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"AsciiToString")||(e.AsciiToString=function(){t("'AsciiToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stringToAscii")||(e.stringToAscii=function(){t("'stringToAscii' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"UTF16ToString")||(e.UTF16ToString=function(){t("'UTF16ToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stringToUTF16")||(e.stringToUTF16=function(){t("'stringToUTF16' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"lengthBytesUTF16")||(e.lengthBytesUTF16=function(){t("'lengthBytesUTF16' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"UTF32ToString")||(e.UTF32ToString=function(){t("'UTF32ToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"stringToUTF32")||(e.stringToUTF32=function(){t("'stringToUTF32' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"lengthBytesUTF32")||(e.lengthBytesUTF32=function(){t("'lengthBytesUTF32' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"allocateUTF8")||(e.allocateUTF8=function(){t("'allocateUTF8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),Object.getOwnPropertyDescriptor(e,"allocateUTF8OnStack")||(e.allocateUTF8OnStack=function(){t("'allocateUTF8OnStack' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}),e.writeStackCookie=ue,e.checkStackCookie=G,Object.getOwnPropertyDescriptor(e,"ALLOC_NORMAL")||Object.defineProperty(e,"ALLOC_NORMAL",{configurable:!0,get:function(){t("'ALLOC_NORMAL' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}}),Object.getOwnPropertyDescriptor(e,"ALLOC_STACK")||Object.defineProperty(e,"ALLOC_STACK",{configurable:!0,get:function(){t("'ALLOC_STACK' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)")}});var Z;function Ve(r){this.name="ExitStatus",this.message="Program terminated with exit("+r+")",this.status=r}Q=function r(){Z||de(),Z||(Q=r)};function Ge(){Me(),ue()}function de(r){if(F>0||(Ge(),Ue(),F>0))return;function o(){Z||(Z=!0,e.calledRun=!0,!Y&&(ve(),p(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),s(!e._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),je()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),o()},1)):o(),G()}if(e.run=de,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return de(),e.ready}})(),I=class{constructor(n){R(this,"rnnoiseModule");R(this,"frameSize");this.rnnoiseModule=n,this.frameSize=n._rnnoise_get_frame_size()}static async load(n={}){let e=await Je().then(a=>Pe({locateFile:(p,u)=>(n.assetsPath!==void 0&&(u=n.assetsPath+"/"),n.wasmFileName!==void 0?(p=n.wasmFileName,console.debug("Loads rnnoise-wasm: ",u+p)):a?(p="rnnoise_simd.wasm",console.debug("Loads rnnoise-wasm (SIMD ver): ",u+p)):console.debug("Loads rnnoise-wasm (non SIMD ver): ",u+p),u+p)}));return Promise.resolve(new I(e))}static async loadBinary(n){let e=await Pe({locateFile:a=>a,wasmBinary:n});return new I(e)}createDenoiseState(n){return new pe(this.rnnoiseModule,n)}createModel(n){return new le(this.rnnoiseModule,n)}},q=4,pe=class{constructor(n,e){R(this,"rnnoiseModule");R(this,"state");R(this,"pcmInputBuf");R(this,"pcmOutputBuf");R(this,"frameSize");R(this,"model");this.rnnoiseModule=n,this.model=e,this.frameSize=this.rnnoiseModule._rnnoise_get_frame_size();let a;e!==void 0?a=this.rnnoiseModule._rnnoise_create(e.model):a=this.rnnoiseModule._rnnoise_create();let p=this.rnnoiseModule._malloc(this.frameSize*q),u=this.rnnoiseModule._malloc(this.frameSize*q);if(!a||!p||!u)throw this.destroy(),Error("Failed to allocate DenoiseState or PCM buffers.");this.state=a,this.pcmInputBuf=p,this.pcmOutputBuf=u}processFrame(n){if(this.rnnoiseModule===void 0)throw Error("This denoise state has already been destroyed.");if(n.length!=this.frameSize)throw Error(`Expected frame size ${this.frameSize}, but got ${n.length}`);let e=this.pcmInputBuf/q,a=this.pcmOutputBuf/q;this.rnnoiseModule.HEAPF32.set(n,e);let p=this.rnnoiseModule._rnnoise_process_frame(this.state,this.pcmOutputBuf,this.pcmInputBuf);return n.set(this.rnnoiseModule.HEAPF32.subarray(a,a+this.frameSize)),p}destroy(){this.rnnoiseModule!==void 0&&(this.rnnoiseModule._rnnoise_destroy(this.state),this.rnnoiseModule._free(this.pcmInputBuf),this.rnnoiseModule._free(this.pcmOutputBuf),this.rnnoiseModule=void 0)}},le=class{constructor(n,e){R(this,"rnnoiseModule");R(this,"model");this.rnnoiseModule=n;let a=new TextEncoder().encode(e+"\0"),p=n._malloc(a.length);if(n.HEAPU8.subarray(p,p+a.length).set(a),this.model=n._rnnoise_model_from_string(p),n._free(p),!this.model)throw Error("Failed to create Model from a given model string.")}free(){this.rnnoiseModule!==void 0&&(this.rnnoiseModule._rnnoise_model_free(this.model),this.rnnoiseModule=void 0)}};var Re=d=>{for(let[n,e]of d.entries())d[n]=e*32767},be=d=>{for(let[n,e]of d.entries())d[n]=e/32767};var $e=d=>{let n=d.createDenoiseState(),e=m=>{Re(m),n.processFrame(m),be(m)},a=128,p=480,u=(Math.floor(p/a)+1)*a+a,g=1920,b=new Float32Array(g),f=0,y=g-p*2;return{process:(m,T)=>{if(b.set(m,f),f=(f+a)%g,f===128||f===512||f===1024||f===1536){y=(y+p)%g;let U=b.subarray(y,y+p);e(U)}let B=(f+(g-u))%g;T.set(b.subarray(B,B+a))},destroy:()=>{n.destroy()}}},me=(d,{bufferSize:n,maxChannels:e})=>{if(d.frameSize!==480)throw new Error(`rnnoise frameSize must be 480. (was ${d.frameSize})`);if(n!==128)throw new Error(`bufferSize must be 128. (was ${n}).`);let a=Array.from({length:e},()=>$e(d));return{process:(g,b)=>{let f=Math.min(g.length,e);for(let y=0;y{for(let g of a)g.destroy()}}};var Se="@sapphi-red/web-noise-suppressor/rnnoise";var et=128,fe=class extends AudioWorkletProcessor{constructor(e){super();this.destroyed=!1;this.port.addEventListener("message",a=>{a.data==="destroy"&&this.destroy()}),(async()=>{let a=await I.loadBinary(e.processorOptions.wasmBinary);this.processor=me(a,{bufferSize:et,maxChannels:e.processorOptions.maxChannels}),this.destroyed&&this.destroy()})()}process(e,a,p){return e.length===0||!e[0]||e[0]?.length===0||!this.processor||this.processor.process(e[0],a[0]),!0}destroy(){this.destroyed=!0,this.processor?.destroy(),this.processor=void 0}};registerProcessor(Se,fe); +/*! Bundled license information: + +@shiguredo/rnnoise-wasm/dist/rnnoise.mjs: + (** + * @shiguredo/rnnoise-wasm + * SIMD-accelerated WebAssembly build of RNNoise + * @version: 2022.2.0 + * @author: Shiguredo Inc. + * @license: Apache-2.0 + **) +*/ +//# sourceMappingURL=workletProcessor.js.map \ No newline at end of file diff --git a/browser/third-party/rnnoise/rnnoise_simd.wasm b/browser/third-party/rnnoise/rnnoise_simd.wasm new file mode 100644 index 00000000..6f9fbb60 Binary files /dev/null and b/browser/third-party/rnnoise/rnnoise_simd.wasm differ diff --git a/package.json b/package.json index 0db7ddfa..3a10aeb3 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,13 @@ "@vap/shiki": "0.10.5", "eslint-plugin-simple-header": "^1.0.2", "fflate": "^0.7.4", + "gifenc": "github:mattdesl/gifenc#64842fca317b112a8590f8fef2bf3825da8f6fe3", + "monaco-editor": "^0.43.0", "nanoid": "^4.0.2", "virtual-merge": "^1.0.1" }, "devDependencies": { + "@types/chrome": "^0.0.246", "@types/diff": "^5.0.3", "@types/lodash": "^4.14.194", "@types/node": "^18.16.3", @@ -64,7 +67,8 @@ "stylelint-config-standard": "^33.0.0", "tsx": "^3.12.7", "type-fest": "^3.9.0", - "typescript": "^5.0.4" + "typescript": "^5.0.4", + "zip-local": "^0.3.5" }, "packageManager": "pnpm@8.1.1", "pnpm": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5edbb11a..be7befab 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + patchedDependencies: eslint-plugin-path-alias@1.0.0: hash: m6sma4g6bh67km3q6igf6uxaja @@ -24,6 +28,12 @@ dependencies: fflate: specifier: ^0.7.4 version: 0.7.4 + gifenc: + specifier: github:mattdesl/gifenc#64842fca317b112a8590f8fef2bf3825da8f6fe3 + version: github.com/mattdesl/gifenc/64842fca317b112a8590f8fef2bf3825da8f6fe3 + monaco-editor: + specifier: ^0.43.0 + version: 0.43.0 nanoid: specifier: ^4.0.2 version: 4.0.2 @@ -32,6 +42,9 @@ dependencies: version: 1.0.1 devDependencies: + '@types/chrome': + specifier: ^0.0.246 + version: 0.0.246 '@types/diff': specifier: ^5.0.3 version: 5.0.3 @@ -107,6 +120,9 @@ devDependencies: typescript: specifier: ^5.0.4 version: 5.0.4 + zip-local: + specifier: ^0.3.5 + version: 0.3.5 packages: @@ -520,10 +536,31 @@ packages: resolution: {integrity: sha512-gAC33DCXYwNTI/k1PxOVHmbbzakUSMbb/DHpoV6rn4pKZtPI1dduULSmAAm/y1ipgIlArnk2JcnQzw4n2tCZHw==} dev: false + /@types/chrome@0.0.246: + resolution: {integrity: sha512-MxGxEomGxsJiL9xe/7ZwVgwdn8XVKWbPvxpVQl3nWOjrS0Ce63JsfzxUc4aU3GvRcUPYsfufHmJ17BFyKxeA4g==} + dependencies: + '@types/filesystem': 0.0.33 + '@types/har-format': 1.2.13 + dev: true + /@types/diff@5.0.3: resolution: {integrity: sha512-amrLbRqTU9bXMCc6uX0sWpxsQzRIo9z6MJPkH1pkez/qOxuqSZVuryJAWoBRq94CeG8JxY+VK4Le9HtjQR5T9A==} dev: true + /@types/filesystem@0.0.33: + resolution: {integrity: sha512-2KedRPzwu2K528vFkoXnnWdsG0MtUwPjuA7pRy4vKxlxHEe8qUDZibYHXJKZZr2Cl/ELdCWYqyb/MKwsUuzBWw==} + dependencies: + '@types/filewriter': 0.0.30 + dev: true + + /@types/filewriter@0.0.30: + resolution: {integrity: sha512-lB98tui0uxc7erbj0serZfJlHKLNJHwBltPnbmO1WRpL5T325GOHRiQfr2E29V2q+S1brDO63Fpdt6vb3bES9Q==} + dev: true + + /@types/har-format@1.2.13: + resolution: {integrity: sha512-PwBsCBD3lDODn4xpje3Y1di0aDJp4Ww7aSfMRVw6ysnxD4I7Wmq2mBkSKaDtN403hqH5sp6c9xQUvFYY3+lkBg==} + dev: true + /@types/json-schema@7.0.11: resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} dev: true @@ -843,6 +880,10 @@ packages: engines: {node: '>=8'} dev: true + /async@1.5.2: + resolution: {integrity: sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==} + dev: true + /atob@2.1.2: resolution: {integrity: sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==} engines: {node: '>= 4.5.0'} @@ -1867,6 +1908,10 @@ packages: resolution: {integrity: sha512-xYfnw62CKG8nLkZBfWbhWwDw02CHty86jfPcc2cr3ZfeuK9ysoVPPEUxf21bAD/rWAgk52SuBrLJlefNy8mvFg==} dev: true + /graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + dev: true + /grapheme-splitter@1.0.4: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} dev: true @@ -2184,6 +2229,12 @@ packages: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} dev: false + /jszip@2.7.0: + resolution: {integrity: sha512-JIsRKRVC3gTRo2vM4Wy9WBC3TRcfnIZU8k65Phi3izkvPH975FowRYtKGT6PxevA0XnJ/yO8b0QwV0ydVyQwfw==} + dependencies: + pako: 1.0.11 + dev: true + /kind-of@3.2.2: resolution: {integrity: sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==} engines: {node: '>=0.10.0'} @@ -2354,6 +2405,10 @@ packages: resolution: {integrity: sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==} dev: true + /monaco-editor@0.43.0: + resolution: {integrity: sha512-cnoqwQi/9fml2Szamv1XbSJieGJ1Dc8tENVMD26Kcfl7xGQWp7OBKMjlwKVGYFJ3/AXJjSOGvcqK7Ry/j9BM1Q==} + dev: false + /ms@2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} dev: true @@ -2511,6 +2566,10 @@ packages: engines: {node: '>=6'} dev: true + /pako@1.0.11: + resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} + dev: true + /parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} @@ -2662,6 +2721,11 @@ packages: - utf-8-validate dev: true + /q@1.5.1: + resolution: {integrity: sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==} + engines: {node: '>=0.6.0', teleport: '>=0.2.0'} + dev: true + /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -3377,6 +3441,17 @@ packages: engines: {node: '>=10'} dev: true -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false + /zip-local@0.3.5: + resolution: {integrity: sha512-GRV3D5TJY+/PqyeRm5CYBs7xVrKTKzljBoEXvocZu0HJ7tPEcgpSOYa2zFIsCZWgKWMuc4U3yMFgFkERGFIB9w==} + dependencies: + async: 1.5.2 + graceful-fs: 4.2.11 + jszip: 2.7.0 + q: 1.5.1 + dev: true + + github.com/mattdesl/gifenc/64842fca317b112a8590f8fef2bf3825da8f6fe3: + resolution: {tarball: https://codeload.github.com/mattdesl/gifenc/tar.gz/64842fca317b112a8590f8fef2bf3825da8f6fe3} + name: gifenc + version: 1.0.3 + dev: false diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index ce84fed5..97e50b98 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -78,6 +78,7 @@ await Promise.all([ define: { ...defines, IS_WEB: false, + IS_EXTENSION: false, IS_DISCORD_DESKTOP: true, IS_VESKTOP: false } @@ -124,6 +125,7 @@ await Promise.all([ define: { ...defines, IS_WEB: false, + IS_EXTENSION: false, IS_DISCORD_DESKTOP: false, IS_VESKTOP: true } diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs index aab82d06..8cf1ff36 100644 --- a/scripts/build/buildWeb.mjs +++ b/scripts/build/buildWeb.mjs @@ -17,12 +17,11 @@ * along with this program. If not, see . */ - import esbuild from "esbuild"; -import { zip } from "fflate"; import { readFileSync } from "fs"; -import { appendFile, mkdir, readFile, rm, writeFile } from "fs/promises"; +import { appendFile, mkdir, readdir, readFile, rm, writeFile } from "fs/promises"; import { join } from "path"; +import Zip from "zip-local"; import { BUILD_TIMESTAMP, commonOpts, globPlugins, VERSION, watch } from "./common.mjs"; @@ -42,6 +41,7 @@ const commonOptions = { target: ["esnext"], define: { IS_WEB: "true", + IS_EXTENSION: "false", IS_STANDALONE: "true", IS_DEV: JSON.stringify(watch), IS_DISCORD_DESKTOP: "false", @@ -52,19 +52,51 @@ const commonOptions = { } }; +const MonacoWorkerEntryPoints = [ + "vs/language/css/css.worker.js", + "vs/editor/editor.worker.js" +]; + await Promise.all( [ + esbuild.build({ + entryPoints: MonacoWorkerEntryPoints.map(entry => `node_modules/monaco-editor/esm/${entry}`), + bundle: true, + minify: true, + format: "iife", + outbase: "node_modules/monaco-editor/esm/", + outdir: "dist/monaco" + }), + esbuild.build({ + entryPoints: ["browser/monaco.ts"], + bundle: true, + minify: true, + format: "iife", + outfile: "dist/monaco/index.js", + loader: { + ".ttf": "file" + } + }), esbuild.build({ ...commonOptions, outfile: "dist/browser.js", footer: { js: "//# sourceURL=VencordWeb" }, }), + esbuild.build({ + ...commonOptions, + outfile: "dist/extension.js", + define: { + ...commonOptions?.define, + IS_EXTENSION: "true", + }, + footer: { js: "//# sourceURL=VencordWeb" }, + }), esbuild.build({ ...commonOptions, inject: ["browser/GMPolyfill.js", ...(commonOptions?.inject || [])], define: { - "window": "unsafeWindow", - ...(commonOptions?.define) + ...(commonOptions?.define), + window: "unsafeWindow", }, outfile: "dist/Vencord.user.js", banner: { @@ -79,12 +111,39 @@ await Promise.all( ); /** - * @type {(target: string, files: string[], shouldZip: boolean) => Promise} + * @type {(dir: string) => Promise} */ -async function buildPluginZip(target, files, shouldZip) { +async function globDir(dir) { + const files = []; + + for (const child of await readdir(dir, { withFileTypes: true })) { + const p = join(dir, child.name); + if (child.isDirectory()) + files.push(...await globDir(p)); + else + files.push(p); + } + + return files; +} + +/** + * @type {(dir: string, basePath?: string) => Promise>} + */ +async function loadDir(dir, basePath = "") { + const files = await globDir(dir); + return Object.fromEntries(await Promise.all(files.map(async f => [f.slice(basePath.length), await readFile(f)]))); +} + +/** + * @type {(target: string, files: string[]) => Promise} + */ +async function buildExtension(target, files) { const entries = { - "dist/Vencord.js": await readFile("dist/browser.js"), - "dist/Vencord.css": await readFile("dist/browser.css"), + "dist/Vencord.js": await readFile("dist/extension.js"), + "dist/Vencord.css": await readFile("dist/extension.css"), + ...await loadDir("dist/monaco"), + ...await loadDir("browser/third-party", "browser/"), ...Object.fromEntries(await Promise.all(files.map(async f => { let content = await readFile(join("browser", f)); if (f.startsWith("manifest")) { @@ -100,31 +159,15 @@ async function buildPluginZip(target, files, shouldZip) { }))), }; - if (shouldZip) { - return new Promise((resolve, reject) => { - zip(entries, {}, (err, data) => { - if (err) { - reject(err); - } else { - const out = join("dist", target); - writeFile(out, data).then(() => { - console.info("Extension written to " + out); - resolve(); - }).catch(reject); - } - }); - }); - } else { - await rm(target, { recursive: true, force: true }); - await Promise.all(Object.entries(entries).map(async ([file, content]) => { - const dest = join("dist", target, file); - const parentDirectory = join(dest, ".."); - await mkdir(parentDirectory, { recursive: true }); - await writeFile(dest, content); - })); + await rm(target, { recursive: true, force: true }); + await Promise.all(Object.entries(entries).map(async ([file, content]) => { + const dest = join("dist", target, file); + const parentDirectory = join(dest, ".."); + await mkdir(parentDirectory, { recursive: true }); + await writeFile(dest, content); + })); - console.info("Unpacked Extension written to dist/" + target); - } + console.info("Unpacked Extension written to dist/" + target); } const appendCssRuntime = readFile("dist/Vencord.user.css", "utf-8").then(content => { @@ -142,8 +185,9 @@ const appendCssRuntime = readFile("dist/Vencord.user.css", "utf-8").then(content await Promise.all([ appendCssRuntime, - buildPluginZip("extension.zip", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], true), - buildPluginZip("chromium-unpacked", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], false), - buildPluginZip("firefox-unpacked", ["background.js", "content.js", "manifestv2.json", "icon.png"], false), + buildExtension("chromium-unpacked", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"]), + buildExtension("firefox-unpacked", ["background.js", "content.js", "manifestv2.json", "icon.png"]), ]); +Zip.sync.zip("dist/chromium-unpacked").compress().save("dist/extension.zip"); +console.info("Packed Chromium Extension written to dist/extension.zip"); diff --git a/src/globals.d.ts b/src/globals.d.ts index daccf33d..94b5f15e 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -33,6 +33,7 @@ declare global { * replace: `${IS_WEB}?foo:bar` */ export var IS_WEB: boolean; + export var IS_EXTENSION: boolean; export var IS_DEV: boolean; export var IS_STANDALONE: boolean; export var IS_UPDATER_DISABLED: boolean; diff --git a/src/main/ipcMain.ts b/src/main/ipcMain.ts index c8e45676..61cbe7ab 100644 --- a/src/main/ipcMain.ts +++ b/src/main/ipcMain.ts @@ -27,7 +27,7 @@ import { mkdirSync, readFileSync, watch } from "fs"; import { open, readdir, readFile, writeFile } from "fs/promises"; import { join, normalize } from "path"; -import monacoHtml from "~fileContent/../components/monacoWin.html;base64"; +import monacoHtml from "~fileContent/monacoWin.html;base64"; import { getThemeInfo, stripBOM, UserThemeHeader } from "./themes"; import { ALLOWED_PROTOCOLS, QUICKCSS_PATH, SETTINGS_DIR, SETTINGS_FILE, THEMES_DIR } from "./utils/constants"; diff --git a/src/components/monacoWin.html b/src/main/monacoWin.html similarity index 100% rename from src/components/monacoWin.html rename to src/main/monacoWin.html diff --git a/src/plugins/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx similarity index 99% rename from src/plugins/supportHelper.tsx rename to src/plugins/_core/supportHelper.tsx index f36cc0fd..674be8e5 100644 --- a/src/plugins/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -27,7 +27,7 @@ import { Alerts, Forms, UserStore } from "@webpack/common"; import gitHash from "~git-hash"; import plugins from "~plugins"; -import settings from "./_core/settings"; +import settings from "./settings"; const REMEMBER_DISMISS_KEY = "Vencord-SupportHelper-Dismiss"; diff --git a/src/plugins/fakeNitro.ts b/src/plugins/fakeNitro.ts index f56239f5..13131456 100644 --- a/src/plugins/fakeNitro.ts +++ b/src/plugins/fakeNitro.ts @@ -19,7 +19,7 @@ import { addPreEditListener, addPreSendListener, removePreEditListener, removePreSendListener } from "@api/MessageEvents"; import { definePluginSettings, Settings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import { ApngBlendOp, ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies"; +import { ApngBlendOp, ApngDisposeOp, importApngJs } from "@utils/dependencies"; import { getCurrentGuild } from "@utils/discord"; import { proxyLazy } from "@utils/lazy"; import { Logger } from "@utils/Logger"; @@ -27,6 +27,7 @@ import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy, findByPropsLazy, findLazy, findStoreLazy } from "@webpack"; import { ChannelStore, EmojiStore, FluxDispatcher, Parser, PermissionStore, UserStore } from "@webpack/common"; import type { Message } from "discord-types/general"; +import { applyPalette, GIFEncoder, quantize } from "gifenc"; import type { ReactElement, ReactNode } from "react"; const DRAFT_TYPE = 0; @@ -650,15 +651,11 @@ export default definePlugin({ }, async sendAnimatedSticker(stickerLink: string, stickerId: string, channelId: string) { - const [{ parseURL }, { - GIFEncoder, - quantize, - applyPalette - }] = await Promise.all([importApngJs(), getGifEncoder()]); + const { parseURL } = importApngJs(); const { frames, width, height } = await parseURL(stickerLink); - const gif = new GIFEncoder(); + const gif = GIFEncoder(); const resolution = Settings.plugins.FakeNitro.stickerSize; const canvas = document.createElement("canvas"); diff --git a/src/plugins/invisibleChat/components/DecryptionModal.tsx b/src/plugins/invisibleChat.desktop/components/DecryptionModal.tsx similarity index 100% rename from src/plugins/invisibleChat/components/DecryptionModal.tsx rename to src/plugins/invisibleChat.desktop/components/DecryptionModal.tsx diff --git a/src/plugins/invisibleChat/components/EncryptionModal.tsx b/src/plugins/invisibleChat.desktop/components/EncryptionModal.tsx similarity index 100% rename from src/plugins/invisibleChat/components/EncryptionModal.tsx rename to src/plugins/invisibleChat.desktop/components/EncryptionModal.tsx diff --git a/src/plugins/invisibleChat/index.tsx b/src/plugins/invisibleChat.desktop/index.tsx similarity index 100% rename from src/plugins/invisibleChat/index.tsx rename to src/plugins/invisibleChat.desktop/index.tsx diff --git a/src/plugins/petpet.ts b/src/plugins/petpet.ts index 9b1c2f16..0bfd21af 100644 --- a/src/plugins/petpet.ts +++ b/src/plugins/petpet.ts @@ -18,10 +18,10 @@ import { ApplicationCommandInputType, ApplicationCommandOptionType, Argument, CommandContext, findOption, sendBotMessage } from "@api/Commands"; import { Devs } from "@utils/constants"; -import { getGifEncoder } from "@utils/dependencies"; import { makeLazy } from "@utils/lazy"; import definePlugin from "@utils/types"; import { findByCodeLazy, findByPropsLazy } from "@webpack"; +import { applyPalette, GIFEncoder, quantize } from "gifenc"; const DRAFT_TYPE = 0; const DEFAULT_DELAY = 20; @@ -124,7 +124,6 @@ export default definePlugin({ } ], execute: async (opts, cmdCtx) => { - const { GIFEncoder, quantize, applyPalette } = await getGifEncoder(); const frames = await getFrames(); const noServerPfp = findOption(opts, "no-server-pfp", false); @@ -143,7 +142,7 @@ export default definePlugin({ const delay = findOption(opts, "delay", DEFAULT_DELAY); const resolution = findOption(opts, "resolution", DEFAULT_RESOLUTION); - const gif = new GIFEncoder(); + const gif = GIFEncoder(); const canvas = document.createElement("canvas"); canvas.width = canvas.height = resolution; diff --git a/src/plugins/shikiCodeblocks/api/languages.ts b/src/plugins/shikiCodeblocks.desktop/api/languages.ts similarity index 100% rename from src/plugins/shikiCodeblocks/api/languages.ts rename to src/plugins/shikiCodeblocks.desktop/api/languages.ts diff --git a/src/plugins/shikiCodeblocks/api/shiki.ts b/src/plugins/shikiCodeblocks.desktop/api/shiki.ts similarity index 100% rename from src/plugins/shikiCodeblocks/api/shiki.ts rename to src/plugins/shikiCodeblocks.desktop/api/shiki.ts diff --git a/src/plugins/shikiCodeblocks/api/themes.ts b/src/plugins/shikiCodeblocks.desktop/api/themes.ts similarity index 100% rename from src/plugins/shikiCodeblocks/api/themes.ts rename to src/plugins/shikiCodeblocks.desktop/api/themes.ts diff --git a/src/plugins/shikiCodeblocks/components/ButtonRow.tsx b/src/plugins/shikiCodeblocks.desktop/components/ButtonRow.tsx similarity index 100% rename from src/plugins/shikiCodeblocks/components/ButtonRow.tsx rename to src/plugins/shikiCodeblocks.desktop/components/ButtonRow.tsx diff --git a/src/plugins/shikiCodeblocks/components/Code.tsx b/src/plugins/shikiCodeblocks.desktop/components/Code.tsx similarity index 100% rename from src/plugins/shikiCodeblocks/components/Code.tsx rename to src/plugins/shikiCodeblocks.desktop/components/Code.tsx diff --git a/src/plugins/shikiCodeblocks/components/CopyButton.tsx b/src/plugins/shikiCodeblocks.desktop/components/CopyButton.tsx similarity index 100% rename from src/plugins/shikiCodeblocks/components/CopyButton.tsx rename to src/plugins/shikiCodeblocks.desktop/components/CopyButton.tsx diff --git a/src/plugins/shikiCodeblocks/components/Header.tsx b/src/plugins/shikiCodeblocks.desktop/components/Header.tsx similarity index 100% rename from src/plugins/shikiCodeblocks/components/Header.tsx rename to src/plugins/shikiCodeblocks.desktop/components/Header.tsx diff --git a/src/plugins/shikiCodeblocks/components/Highlighter.tsx b/src/plugins/shikiCodeblocks.desktop/components/Highlighter.tsx similarity index 100% rename from src/plugins/shikiCodeblocks/components/Highlighter.tsx rename to src/plugins/shikiCodeblocks.desktop/components/Highlighter.tsx diff --git a/src/plugins/shikiCodeblocks/devicon.css b/src/plugins/shikiCodeblocks.desktop/devicon.css similarity index 100% rename from src/plugins/shikiCodeblocks/devicon.css rename to src/plugins/shikiCodeblocks.desktop/devicon.css diff --git a/src/plugins/shikiCodeblocks/hooks/useCopyCooldown.ts b/src/plugins/shikiCodeblocks.desktop/hooks/useCopyCooldown.ts similarity index 100% rename from src/plugins/shikiCodeblocks/hooks/useCopyCooldown.ts rename to src/plugins/shikiCodeblocks.desktop/hooks/useCopyCooldown.ts diff --git a/src/plugins/shikiCodeblocks/hooks/useShikiSettings.ts b/src/plugins/shikiCodeblocks.desktop/hooks/useShikiSettings.ts similarity index 100% rename from src/plugins/shikiCodeblocks/hooks/useShikiSettings.ts rename to src/plugins/shikiCodeblocks.desktop/hooks/useShikiSettings.ts diff --git a/src/plugins/shikiCodeblocks/hooks/useTheme.ts b/src/plugins/shikiCodeblocks.desktop/hooks/useTheme.ts similarity index 100% rename from src/plugins/shikiCodeblocks/hooks/useTheme.ts rename to src/plugins/shikiCodeblocks.desktop/hooks/useTheme.ts diff --git a/src/plugins/shikiCodeblocks/index.ts b/src/plugins/shikiCodeblocks.desktop/index.ts similarity index 100% rename from src/plugins/shikiCodeblocks/index.ts rename to src/plugins/shikiCodeblocks.desktop/index.ts diff --git a/src/plugins/shikiCodeblocks/previewExample.tsx b/src/plugins/shikiCodeblocks.desktop/previewExample.tsx similarity index 100% rename from src/plugins/shikiCodeblocks/previewExample.tsx rename to src/plugins/shikiCodeblocks.desktop/previewExample.tsx diff --git a/src/plugins/shikiCodeblocks/settings.ts b/src/plugins/shikiCodeblocks.desktop/settings.ts similarity index 100% rename from src/plugins/shikiCodeblocks/settings.ts rename to src/plugins/shikiCodeblocks.desktop/settings.ts diff --git a/src/plugins/shikiCodeblocks/shiki.css b/src/plugins/shikiCodeblocks.desktop/shiki.css similarity index 100% rename from src/plugins/shikiCodeblocks/shiki.css rename to src/plugins/shikiCodeblocks.desktop/shiki.css diff --git a/src/plugins/shikiCodeblocks/types.ts b/src/plugins/shikiCodeblocks.desktop/types.ts similarity index 100% rename from src/plugins/shikiCodeblocks/types.ts rename to src/plugins/shikiCodeblocks.desktop/types.ts diff --git a/src/plugins/shikiCodeblocks/utils/color.ts b/src/plugins/shikiCodeblocks.desktop/utils/color.ts similarity index 100% rename from src/plugins/shikiCodeblocks/utils/color.ts rename to src/plugins/shikiCodeblocks.desktop/utils/color.ts diff --git a/src/plugins/shikiCodeblocks/utils/createStyle.ts b/src/plugins/shikiCodeblocks.desktop/utils/createStyle.ts similarity index 100% rename from src/plugins/shikiCodeblocks/utils/createStyle.ts rename to src/plugins/shikiCodeblocks.desktop/utils/createStyle.ts diff --git a/src/plugins/shikiCodeblocks/utils/misc.ts b/src/plugins/shikiCodeblocks.desktop/utils/misc.ts similarity index 100% rename from src/plugins/shikiCodeblocks/utils/misc.ts rename to src/plugins/shikiCodeblocks.desktop/utils/misc.ts diff --git a/src/utils/apng-canvas.js b/src/utils/apng-canvas.js new file mode 100644 index 00000000..5149dcc0 --- /dev/null +++ b/src/utils/apng-canvas.js @@ -0,0 +1,1168 @@ +/* eslint-disable */ + +const self = module.exports; +/** + * apng-canvas v2.1.2 + * + * @copyright 2011-2019 David Mzareulyan + * @link https://github.com/davidmz/apng-canvas + * @license MIT + */ +!(function i(o, a, s) { + function u(n, t) { + if (!a[n]) { + if (!o[n]) { + var e = "function" == typeof require && require; + if (!t && e) return e(n, !0); + if (c) return c(n, !0); + throw new Error("Cannot find module '" + n + "'"); + } + var r = (a[n] = { exports: {} }); + o[n][0].call( + r.exports, + function (t) { + var e = o[n][1][t]; + return u(e || t); + }, + r, + r.exports, + i, + o, + a, + s + ); + } + return a[n].exports; + } + for ( + var c = "function" == typeof require && require, t = 0; + t < s.length; + t++ + ) + u(s[t]); + return u; +})( + { + 1: [ + function (Y, n, r) { + (function (G, q) { + var t, e; + (t = this), + (e = function () { + "use strict"; + function u(t) { + return "function" == typeof t; + } + var n = Array.isArray + ? Array.isArray + : function (t) { + return ( + "[object Array]" === + Object.prototype.toString.call(t) + ); + }, + r = 0, + e = void 0, + i = void 0, + a = function (t, e) { + (l[r] = t), + (l[r + 1] = e), + 2 === (r += 2) && (i ? i(d) : g()); + }; + var t = + "undefined" != typeof window + ? window + : void 0, + o = t || {}, + s = + o.MutationObserver || + o.WebKitMutationObserver, + c = + "undefined" == typeof self && + void 0 !== G && + "[object process]" === {}.toString.call(G), + f = + "undefined" != typeof Uint8ClampedArray && + "undefined" != typeof importScripts && + "undefined" != typeof MessageChannel; + function h() { + var t = setTimeout; + return function () { + return t(d, 1); + }; + } + var l = new Array(1e3); + function d() { + for (var t = 0; t < r; t += 2) { + (0, l[t])(l[t + 1]), + (l[t] = void 0), + (l[t + 1] = void 0); + } + r = 0; + } + var p, + v, + A, + m, + g = void 0; + function w(t, e) { + var n = this, + r = new this.constructor(b); + void 0 === r[_] && j(r); + var i = n._state; + if (i) { + var o = arguments[i - 1]; + a(function () { + return L(i, r, o, n._result); + }); + } else U(n, r, t, e); + return r; + } + function y(t) { + if ( + t && + "object" == typeof t && + t.constructor === this + ) + return t; + var e = new this(b); + return T(e, t), e; + } + g = c + ? function () { + return G.nextTick(d); + } + : s + ? ((v = 0), + (A = new s(d)), + (m = document.createTextNode("")), + A.observe(m, { characterData: !0 }), + function () { + m.data = v = ++v % 2; + }) + : f + ? (((p = new MessageChannel()).port1.onmessage = + d), + function () { + return p.port2.postMessage(0); + }) + : void 0 === t && "function" == typeof Y + ? (function () { + try { + var t = + Function("return this")().require( + "vertx" + ); + return void 0 !== + (e = + t.runOnLoop || t.runOnContext) + ? function () { + e(d); + } + : h(); + } catch (t) { + return h(); + } + })() + : h(); + var _ = Math.random().toString(36).substring(2); + function b() { } + var E = void 0, + P = 1, + x = 2; + function N(t, r, i) { + a(function (e) { + var n = !1, + t = (function (t, e, n, r) { + try { + t.call(e, n, r); + } catch (t) { + return t; + } + })( + i, + r, + function (t) { + n || + ((n = !0), + r !== t + ? T(e, t) + : O(e, t)); + }, + function (t) { + n || ((n = !0), R(e, t)); + }, + e._label + ); + !n && t && ((n = !0), R(e, t)); + }, t); + } + function C(t, e, n) { + e.constructor === t.constructor && + n === w && + e.constructor.resolve === y + ? (function (e, t) { + t._state === P + ? O(e, t._result) + : t._state === x + ? R(e, t._result) + : U( + t, + void 0, + function (t) { + return T(e, t); + }, + function (t) { + return R(e, t); + } + ); + })(t, e) + : void 0 === n + ? O(t, e) + : u(n) + ? N(t, e, n) + : O(t, e); + } + function T(e, t) { + if (e === t) + R( + e, + new TypeError( + "You cannot resolve a promise with itself" + ) + ); + else if ( + (function (t) { + var e = typeof t; + return ( + null !== t && + ("object" == e || "function" == e) + ); + })(t) + ) { + var n = void 0; + try { + n = t.then; + } catch (t) { + return void R(e, t); + } + C(e, t, n); + } else O(e, t); + } + function B(t) { + t._onerror && t._onerror(t._result), I(t); + } + function O(t, e) { + t._state === E && + ((t._result = e), + (t._state = P), + 0 !== t._subscribers.length && a(I, t)); + } + function R(t, e) { + t._state === E && + ((t._state = x), (t._result = e), a(B, t)); + } + function U(t, e, n, r) { + var i = t._subscribers, + o = i.length; + (t._onerror = null), + (i[o] = e), + (i[o + P] = n), + (i[o + x] = r), + 0 === o && t._state && a(I, t); + } + function I(t) { + var e = t._subscribers, + n = t._state; + if (0 !== e.length) { + for ( + var r = void 0, + i = void 0, + o = t._result, + a = 0; + a < e.length; + a += 3 + ) + (r = e[a]), + (i = e[a + n]), + r ? L(n, r, i, o) : i(o); + t._subscribers.length = 0; + } + } + function L(t, e, n, r) { + var i = u(n), + o = void 0, + a = void 0, + s = !0; + if (i) { + try { + o = n(r); + } catch (t) { + (s = !1), (a = t); + } + if (e === o) + return void R( + e, + new TypeError( + "A promises callback cannot return that same promise." + ) + ); + } else o = r; + e._state !== E || + (i && s + ? T(e, o) + : !1 === s + ? R(e, a) + : t === P + ? O(e, o) + : t === x && R(e, o)); + } + var D = 0; + function j(t) { + (t[_] = D++), + (t._state = void 0), + (t._result = void 0), + (t._subscribers = []); + } + var k = + ((F.prototype._enumerate = function (t) { + for ( + var e = 0; + this._state === E && e < t.length; + e++ + ) + this._eachEntry(t[e], e); + }), + (F.prototype._eachEntry = function (e, t) { + var n = this._instanceConstructor, + r = n.resolve; + if (r === y) { + var i = void 0, + o = void 0, + a = !1; + try { + i = e.then; + } catch (t) { + (a = !0), (o = t); + } + if (i === w && e._state !== E) + this._settledAt( + e._state, + t, + e._result + ); + else if ("function" != typeof i) + this._remaining--, + (this._result[t] = e); + else if (n === S) { + var s = new n(b); + a ? R(s, o) : C(s, e, i), + this._willSettleAt(s, t); + } else + this._willSettleAt( + new n(function (t) { + return t(e); + }), + t + ); + } else this._willSettleAt(r(e), t); + }), + (F.prototype._settledAt = function (t, e, n) { + var r = this.promise; + r._state === E && + (this._remaining--, + t === x + ? R(r, n) + : (this._result[e] = n)), + 0 === this._remaining && + O(r, this._result); + }), + (F.prototype._willSettleAt = function (t, e) { + var n = this; + U( + t, + void 0, + function (t) { + return n._settledAt(P, e, t); + }, + function (t) { + return n._settledAt(x, e, t); + } + ); + }), + F); + function F(t, e) { + (this._instanceConstructor = t), + (this.promise = new t(b)), + this.promise[_] || j(this.promise), + n(e) + ? ((this.length = e.length), + (this._remaining = e.length), + (this._result = new Array( + this.length + )), + 0 === this.length + ? O(this.promise, this._result) + : ((this.length = + this.length || 0), + this._enumerate(e), + 0 === this._remaining && + O( + this.promise, + this._result + ))) + : R( + this.promise, + new Error( + "Array Methods must be provided an Array" + ) + ); + } + var S = + ((M.prototype.catch = function (t) { + return this.then(null, t); + }), + (M.prototype.finally = function (e) { + var n = this.constructor; + return u(e) + ? this.then( + function (t) { + return n + .resolve(e()) + .then(function () { + return t; + }); + }, + function (t) { + return n + .resolve(e()) + .then(function () { + throw t; + }); + } + ) + : this.then(e, e); + }), + M); + function M(t) { + (this[_] = D++), + (this._result = this._state = void 0), + (this._subscribers = []), + b !== t && + ("function" != typeof t && + (function () { + throw new TypeError( + "You must pass a resolver function as the first argument to the promise constructor" + ); + })(), + this instanceof M + ? (function (e, t) { + try { + t( + function (t) { + T(e, t); + }, + function (t) { + R(e, t); + } + ); + } catch (t) { + R(e, t); + } + })(this, t) + : (function () { + throw new TypeError( + "Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function." + ); + })()); + } + return ( + (S.prototype.then = w), + (S.all = function (t) { + return new k(this, t).promise; + }), + (S.race = function (i) { + var o = this; + return n(i) + ? new o(function (t, e) { + for ( + var n = i.length, r = 0; + r < n; + r++ + ) + o.resolve(i[r]).then(t, e); + }) + : new o(function (t, e) { + return e( + new TypeError( + "You must pass an array to race." + ) + ); + }); + }), + (S.resolve = y), + (S.reject = function (t) { + var e = new this(b); + return R(e, t), e; + }), + (S._setScheduler = function (t) { + i = t; + }), + (S._setAsap = function (t) { + a = t; + }), + (S._asap = a), + (S.polyfill = function () { + var t = void 0; + if (void 0 !== q) t = q; + else if ("undefined" != typeof self) + t = self; + else + try { + t = Function("return this")(); + } catch (t) { + throw new Error( + "polyfill failed because global object is unavailable in this environment" + ); + } + var e = t.Promise; + if (e) { + var n = null; + try { + n = Object.prototype.toString.call( + e.resolve() + ); + } catch (t) { } + if ("[object Promise]" === n && !e.cast) + return; + } + t.Promise = S; + }), + (S.Promise = S) + ); + }), + "object" == typeof r && void 0 !== n + ? (n.exports = e()) + : "function" == typeof define && define.amd + ? define(e) + : (t.ES6Promise = e()); + }).call( + this, + Y("VCmEsw"), + "undefined" != typeof self + ? self + : "undefined" != typeof window + ? window + : {} + ); + }, + { VCmEsw: 2 }, + ], + 2: [ + function (t, e, n) { + var r = (e.exports = {}); + function i() { } + (r.nextTick = (function () { + var t = "undefined" != typeof window && window.setImmediate, + e = + "undefined" != typeof window && + window.postMessage && + window.addEventListener; + if (t) + return function (t) { + return window.setImmediate(t); + }; + if (e) { + var n = []; + return ( + window.addEventListener( + "message", + function (t) { + var e = t.source; + (e !== window && null !== e) || + "process-tick" !== t.data || + (t.stopPropagation(), + 0 < n.length && n.shift()()); + }, + !0 + ), + function (t) { + n.push(t), + window.postMessage("process-tick", "*"); + } + ); + } + return function (t) { + setTimeout(t, 0); + }; + })()), + (r.title = "browser"), + (r.browser = !0), + (r.env = {}), + (r.argv = []), + (r.on = i), + (r.addListener = i), + (r.once = i), + (r.off = i), + (r.removeListener = i), + (r.removeAllListeners = i), + (r.emit = i), + (r.binding = function (t) { + throw new Error("process.binding is not supported"); + }), + (r.cwd = function () { + return "/"; + }), + (r.chdir = function (t) { + throw new Error("process.chdir is not supported"); + }); + }, + {}, + ], + 3: [ + function (t, e, n) { + "use strict"; + e.exports = function () { + (this.width = 0), + (this.height = 0), + (this.numPlays = 0), + (this.playTime = 0), + (this.frames = []), + (this.play = function () { + s || + u || + (this.rewind(), + (s = !0), + requestAnimationFrame(e)); + }), + (this.rewind = function () { + (o = i = 0), (a = null), (u = s = !1); + }), + (this.addContext = function (t) { + if (0 < c.length) { + var e = c[0].getImageData( + 0, + 0, + this.width, + this.height + ); + t.putImageData(e, 0, 0); + } + c.push(t), (t._apng_animation = this); + }), + (this.removeContext = function (t) { + var e = c.indexOf(t); + -1 !== e && + (c.splice(e, 1), + 0 === c.length && this.rewind(), + "_apng_animation" in t && + delete t._apng_animation); + }), + (this.isPlayed = function () { + return s; + }), + (this.isFinished = function () { + return u; + }); + var r = this, + i = 0, + o = 0, + a = null, + s = !1, + u = !1, + c = [], + e = function (t) { + for (; s && i <= t;) n(t); + s && requestAnimationFrame(e); + }, + n = function (t) { + var e = o++ % r.frames.length, + n = r.frames[e]; + if ( + 0 == r.numPlays || + o / r.frames.length <= r.numPlays + ) { + for ( + 0 == e && + (c.forEach(function (t) { + t.clearRect( + 0, + 0, + r.width, + r.height + ); + }), + (a = null), + 2 == n.disposeOp && (n.disposeOp = 1)), + a && 1 == a.disposeOp + ? c.forEach(function (t) { + t.clearRect( + a.left, + a.top, + a.width, + a.height + ); + }) + : a && + 2 == a.disposeOp && + c.forEach(function (t) { + t.putImageData( + a.iData, + a.left, + a.top + ); + }), + (a = n).iData = null, + 2 == a.disposeOp && + (a.iData = c[0].getImageData( + n.left, + n.top, + n.width, + n.height + )), + 0 == n.blendOp && + c.forEach(function (t) { + t.clearRect( + n.left, + n.top, + n.width, + n.height + ); + }), + c.forEach(function (t) { + t.drawImage(n.img, n.left, n.top); + }), + 0 == i && (i = t); + t > i + r.playTime; + + ) + i += r.playTime; + i += n.delay; + } else u = !(s = !1); + }; + }; + }, + {}, + ], + 4: [ + function (t, e, n) { + "use strict"; + for (var a = new Uint32Array(256), r = 0; r < 256; r++) { + for (var i = r, o = 0; o < 8; o++) + i = 1 & i ? 3988292384 ^ (i >>> 1) : i >>> 1; + a[r] = i; + } + e.exports = function (t, e, n) { + for ( + var r = -1, + i = (e = e || 0), + o = e + (n = n || t.length - e); + i < o; + i++ + ) + r = (r >>> 8) ^ a[255 & (r ^ t[i])]; + return -1 ^ r; + }; + }, + {}, + ], + 5: [ + function (a, t, e) { + (function (t) { + "use strict"; + var e = a("./support-test"), + n = a("./parser"), + r = a("./loader"), + i = (t.APNG = {}); + (i.checkNativeFeatures = e.checkNativeFeatures), + (i.ifNeeded = e.ifNeeded), + (i.parseBuffer = function (t) { + return n(t); + }); + var o = {}; + (i.parseURL = function (t) { + return t in o || (o[t] = r(t).then(n)), o[t]; + }), + (i.animateContext = function (t, e) { + return i.parseURL(t).then(function (t) { + return t.addContext(e), t.play(), t; + }); + }), + (i.animateImage = function (s) { + return ( + s.setAttribute("data-is-apng", "progress"), + i.parseURL(s.src).then( + function (t) { + s.setAttribute("data-is-apng", "yes"); + var e = + document.createElement("canvas"); + (e.width = t.width), + (e.height = t.height), + Array.prototype.slice + .call(s.attributes) + .forEach(function (t) { + -1 == + [ + "alt", + "src", + "usemap", + "ismap", + "data-is-apng", + "width", + "height", + ].indexOf(t.nodeName) && + e.setAttributeNode( + t.cloneNode(!1) + ); + }), + e.setAttribute( + "data-apng-src", + s.src + ), + "" != s.alt && + e.appendChild( + document.createTextNode( + s.alt + ) + ); + var n = "", + r = "", + i = 0, + o = ""; + "" != s.style.width && + "auto" != s.style.width + ? (n = s.style.width) + : s.hasAttribute("width") && + (n = + s.getAttribute("width") + + "px"), + "" != s.style.height && + "auto" != s.style.height + ? (r = s.style.height) + : s.hasAttribute("height") && + (r = + s.getAttribute("height") + + "px"), + "" != n && + "" == r && + ((i = parseFloat(n)), + (o = n.match(/\D+$/)[0]), + (r = + Math.round( + (e.height * i) / e.width + ) + o)), + "" != r && + "" == n && + ((i = parseFloat(r)), + (o = r.match(/\D+$/)[0]), + (n = + Math.round( + (e.width * i) / e.height + ) + o)), + (e.style.width = n), + (e.style.height = r); + var a = s.parentNode; + a.insertBefore(e, s), + a.removeChild(s), + t.addContext(e.getContext("2d")), + t.play(); + }, + function () { + s.setAttribute("data-is-apng", "no"); + } + ) + ); + }), + (i.releaseCanvas = function (t) { + var e = t.getContext("2d"); + "_apng_animation" in e && + e._apng_animation.removeContext(e); + }); + }).call( + this, + "undefined" != typeof self + ? self + : "undefined" != typeof window + ? window + : {} + ); + }, + { "./loader": 6, "./parser": 7, "./support-test": 8 }, + ], + 6: [ + function (t, e, n) { + "use strict"; + var i = i || t("es6-promise").Promise; + e.exports = function (r) { + return new i(function (t, e) { + var n = new XMLHttpRequest(); + n.open("GET", r), + (n.responseType = "arraybuffer"), + (n.onload = function () { + 200 == this.status ? t(this.response) : e(this); + }), + n.send(); + }); + }; + }, + { "es6-promise": 1 }, + ], + 7: [ + function (t, e, n) { + "use strict"; + var r = r || t("es6-promise").Promise, + m = t("./animation"), + o = t("./crc32"), + g = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]); + e.exports = function (t) { + var A = new Uint8Array(t); + return new r(function (t, e) { + for (var n = 0; n < g.length; n++) + if (g[n] != A[n]) + return void e( + "Not a PNG file (invalid file signature)" + ); + var r = !1; + if ( + (w(A, function (t) { + return "acTL" != t || !(r = !0); + }), + r) + ) { + var a = [], + s = [], + u = null, + c = null, + f = new m(); + if ( + (w(A, function (t, e, n, r) { + switch (t) { + case "IHDR": + (u = e.subarray(n + 8, n + 8 + r)), + (f.width = y(e, n + 8)), + (f.height = y(e, n + 12)); + break; + case "acTL": + f.numPlays = y(e, n + 8 + 4); + break; + case "fcTL": + c && f.frames.push(c), + ((c = {}).width = y( + e, + n + 8 + 4 + )), + (c.height = y(e, n + 8 + 8)), + (c.left = y(e, n + 8 + 12)), + (c.top = y(e, n + 8 + 16)); + var i = _(e, n + 8 + 20), + o = _(e, n + 8 + 22); + 0 == o && (o = 100), + (c.delay = (1e3 * i) / o), + c.delay <= 10 && + (c.delay = 100), + (f.playTime += c.delay), + (c.disposeOp = b( + e, + n + 8 + 24 + )), + (c.blendOp = b(e, n + 8 + 25)), + (c.dataParts = []); + break; + case "fdAT": + c && + c.dataParts.push( + e.subarray( + n + 8 + 4, + n + 8 + r + ) + ); + break; + case "IDAT": + c && + c.dataParts.push( + e.subarray(n + 8, n + 8 + r) + ); + break; + case "IEND": + s.push(E(e, n, 12 + r)); + break; + default: + a.push(E(e, n, 12 + r)); + } + }), + c && f.frames.push(c), + 0 != f.frames.length) + ) + for ( + var i = 0, + o = new Blob(a), + h = new Blob(s), + l = 0; + l < f.frames.length; + l++ + ) { + c = f.frames[l]; + var d = []; + d.push(g), + u.set(P(c.width), 0), + u.set(P(c.height), 4), + d.push(x("IHDR", u)), + d.push(o); + for (var p = 0; p < c.dataParts.length; p++) + d.push(x("IDAT", c.dataParts[p])); + d.push(h); + var v = URL.createObjectURL( + new Blob(d, { type: "image/png" }) + ); + delete c.dataParts, + (d = null), + (c.img = document.createElement("img")), + (c.img.onload = function () { + URL.revokeObjectURL(this.src), + ++i == f.frames.length && t(f); + }), + (c.img.onerror = function () { + e("Image creation error"); + }), + (c.img.src = v); + } + else e("Not an animated PNG"); + } else e("Not an animated PNG"); + }); + }; + var w = function (t, e) { + var n = 8; + do { + var r = y(t, n), + i = a(t, n + 4, 4), + o = e(i, t, n, r); + n += 12 + r; + } while (!1 !== o && "IEND" != i && n < t.length); + }, + y = function (t, e) { + var n = 0; + n += (t[0 + e] << 24) >>> 0; + for (var r = 1; r < 4; r++) + n += t[r + e] << (8 * (3 - r)); + return n; + }, + _ = function (t, e) { + for (var n = 0, r = 0; r < 2; r++) + n += t[r + e] << (8 * (1 - r)); + return n; + }, + b = function (t, e) { + return t[e]; + }, + E = function (t, e, n) { + var r = new Uint8Array(n); + return r.set(t.subarray(e, e + n)), r; + }, + a = function (t, e, n) { + var r = Array.prototype.slice.call( + t.subarray(e, e + n) + ); + return String.fromCharCode.apply(String, r); + }, + P = function (t) { + return [ + (t >>> 24) & 255, + (t >>> 16) & 255, + (t >>> 8) & 255, + 255 & t, + ]; + }, + x = function (t, e) { + var n = t.length + e.length, + r = new Uint8Array(new ArrayBuffer(n + 8)); + r.set(P(e.length), 0), + r.set( + (function (t) { + for (var e = [], n = 0; n < t.length; n++) + e.push(t.charCodeAt(n)); + return e; + })(t), + 4 + ), + r.set(e, 8); + var i = o(r, 4, n); + return r.set(P(i), n + 4), r; + }; + }, + { "./animation": 3, "./crc32": 4, "es6-promise": 1 }, + ], + 8: [ + function (o, a, t) { + (function (t) { + "use strict"; + var e, + n, + r = r || o("es6-promise").Promise, + i = + ((e = function (e) { + var n = document.createElement("canvas"), + r = { + TypedArrays: "ArrayBuffer" in t, + BlobURLs: "URL" in t, + requestAnimationFrame: + "requestAnimationFrame" in t, + pageProtocol: + "http:" == location.protocol || + "https:" == location.protocol, + canvas: + "getContext" in + document.createElement("canvas"), + APNG: !1, + }; + if (r.canvas) { + var i = new Image(); + (i.onload = function () { + var t = n.getContext("2d"); + t.drawImage(i, 0, 0), + (r.APNG = + 0 === + t.getImageData(0, 0, 1, 1) + .data[3]), + e(r); + }), + (i.src = + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg=="); + } else e(r); + }), + (n = null), + function (t) { + return (n = n || new r(e)), t && n.then(t), n; + }); + a.exports = { + checkNativeFeatures: i, + ifNeeded: function (r) { + return ( + void 0 === r && (r = !1), + i().then(function (t) { + if (t.APNG && !r) reject(); + else { + var e = !0; + for (var n in t) + t.hasOwnProperty(n) && + "APNG" != n && + (e = e && t[n]); + } + }) + ); + }, + }; + }).call( + this, + "undefined" != typeof self + ? self + : "undefined" != typeof window + ? window + : {} + ); + }, + { "es6-promise": 1 }, + ], + }, + {}, + [5] +); diff --git a/src/utils/dependencies.ts b/src/utils/dependencies.ts index f1a5c262..f05900e1 100644 --- a/src/utils/dependencies.ts +++ b/src/utils/dependencies.ts @@ -17,23 +17,15 @@ */ import { makeLazy } from "./lazy"; +import { EXTENSION_BASE_URL } from "./web-metadata"; /* Add dynamically loaded dependencies for plugins here. */ -// https://github.com/mattdesl/gifenc -// this lib is way better than gif.js and all other libs, they're all so terrible but this one is nice -// @ts-ignore ts mad -export const getGifEncoder = makeLazy(() => import("https://unpkg.com/gifenc@1.0.3/dist/gifenc.esm.js")); - // needed to parse APNGs in the nitroBypass plugin -export const importApngJs = makeLazy(async () => { - const exports = {}; - const winProxy = new Proxy(window, { set: (_, k, v) => exports[k] = v }); - Function("self", await fetch("https://cdnjs.cloudflare.com/ajax/libs/apng-canvas/2.1.1/apng-canvas.min.js").then(r => r.text()))(winProxy); - // @ts-ignore - return exports.APNG as { parseURL(url: string): Promise; }; +export const importApngJs = makeLazy(() => { + return require("./apng-canvas").APNG as { parseURL(url: string): Promise; }; }); // https://wiki.mozilla.org/APNG_Specification#.60fcTL.60:_The_Frame_Control_Chunk @@ -75,13 +67,20 @@ export interface ApngFrameData { playTime: number; } -const shikiWorkerDist = "https://unpkg.com/@vap/shiki-worker@0.0.8/dist"; -export const shikiWorkerSrc = `${shikiWorkerDist}/${IS_DEV ? "index.js" : "index.min.js"}`; -export const shikiOnigasmSrc = "https://unpkg.com/@vap/shiki@0.10.3/dist/onig.wasm"; - -export const rnnoiseDist = "https://unpkg.com/@sapphi-red/web-noise-suppressor@0.3.3/dist"; +// On web (extensions), use extension uri as basepath (load files from extension) +// On desktop (electron), load from cdn +export const rnnoiseDist = IS_EXTENSION + ? new URL("/third-party/rnnoise", EXTENSION_BASE_URL).toString() + : "https://unpkg.com/@sapphi-red/web-noise-suppressor@0.3.3/dist"; export const rnnoiseWasmSrc = (simd = false) => `${rnnoiseDist}/rnnoise${simd ? "_simd" : ""}.wasm`; export const rnnoiseWorkletSrc = `${rnnoiseDist}/rnnoise/workletProcessor.js`; -// @ts-expect-error SHUT UP -export const getStegCloak = makeLazy(() => import("https://unpkg.com/stegcloak-dist@1.0.0/index.js")); + +// The below code is only used on the Desktop (electron) build of Vencord. +// Browser (extension) builds do not contain these remote imports. + +export const shikiWorkerSrc = `https://unpkg.com/@vap/shiki-worker@0.0.8/dist/${IS_DEV ? "index.js" : "index.min.js"}`; +export const shikiOnigasmSrc = "https://unpkg.com/@vap/shiki@0.10.3/dist/onig.wasm"; + +// @ts-expect-error +export const getStegCloak = /* #__PURE__*/ makeLazy(() => import("https://unpkg.com/stegcloak-dist@1.0.0/index.js")); diff --git a/src/utils/web-metadata.ts b/src/utils/web-metadata.ts new file mode 100644 index 00000000..26409a21 --- /dev/null +++ b/src/utils/web-metadata.ts @@ -0,0 +1,14 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +export let EXTENSION_BASE_URL: string; +export let EXTENSION_VERSION: string; + +if (IS_EXTENSION) { + const script = document.querySelector("#vencord-script") as HTMLScriptElement; + EXTENSION_BASE_URL = script.dataset.extensionBaseUrl!; + EXTENSION_VERSION = script.dataset.version!; +}