hide lazy context menu force loading errors

pull/95/head
dperolio 2 years ago
parent 63f6cce40d
commit f6628eb86a
No known key found for this signature in database
GPG Key ID: 4191689562D51409

@ -1,5 +1,5 @@
/**
*
*
* @module Vizality
* @namespace Vizality
*/
@ -54,7 +54,6 @@ export default class Vizality extends Updatable {
this._labels = [ 'Vizality', 'Core' ];
this._initialized = false;
this._patchWebSocket();
/**
* Wait for the document to be loaded and then initialize Vizality.
@ -258,7 +257,7 @@ export default class Vizality extends Updatable {
}
/**
*
*
*/
async _patchDiscordLogs () {
try {
@ -317,7 +316,7 @@ export default class Vizality extends Updatable {
try {
const success = await super._update(force);
/**
*
*
*/
if (success) {
try {
@ -326,7 +325,7 @@ export default class Vizality extends Updatable {
return this.error(`An error occurred while updating Vizality's dependencies!`, err);
}
/**
*
*
*/
if (!document.querySelector(`#vz-updater-update-complete, [vz-route='updater']`)) {
this.api.notifications.sendToast({
@ -438,8 +437,8 @@ export default class Vizality extends Updatable {
}
/**
*
* @param {...any} message
*
* @param {...any} message
* @returns {void}
*/
log (...message) {
@ -447,8 +446,8 @@ export default class Vizality extends Updatable {
}
/**
*
* @param {...any} message
*
* @param {...any} message
* @returns {void}
*/
warn (...message) {
@ -456,8 +455,8 @@ export default class Vizality extends Updatable {
}
/**
*
* @param {...any} message
*
* @param {...any} message
* @returns {void}
*/
error (...message) {

@ -18,16 +18,16 @@ import SettingsPage from './components/Settings';
const regex = [
{
regex: /return Promise\.all\(\[(.*?)\]\)\.then\(\D+(.+?)\)\)/,
parse(match) {
parse (match) {
return {
imports: matchAll(/\(([\de]+)\)/g, match[0]).map(e => Number(e)),
main: match[1]
main: match[1]
};
}
},
{
regex: /return Promise\.resolve\(\)\.then\(\D+(.+?)\)/,
parse(match) {
parse (match) {
return {
imports: [],
main: match[0]
@ -36,27 +36,29 @@ import SettingsPage from './components/Settings';
},
{
regex: /return [rn]\.e\((\d+)\)\.then\(\D+(\d+)\)\)/,
parse(match) {
parse (match) {
return {
imports: [match[0]],
imports: [ match[0] ],
main: match[0]
};
}
}
];
function matchAll(regex, input, parent = false) {
let matches, output = [], lastIndex = 0;
function matchAll (regex, input, parent = false) {
let matches,
output = [],
lastIndex = 0;
while (matches = regex.exec(input.slice(lastIndex))) {
if (!regex.global) lastIndex += matches.index + matches[0].length;
if (parent) output.push(matches);
else {
const [, ...match] = matches;
const [ , ...match ] = matches;
output.push(match);
}
}
return output;
};
}
const found = [];
@ -64,23 +66,21 @@ import SettingsPage from './components/Settings';
const str = modules[i].toString();
for (let i2 = 0; i2 < regex.length; i2++) {
const {regex: reg, parse} = regex[i2];
const { regex: reg, parse } = regex[i2];
if (!reg.test(str)) continue;
const result = matchAll(reg, str).map(res => ({...parse(res), module: modules[i], reg}));
const result = matchAll(reg, str).map(res => ({ ...parse(res), module: modules[i], reg }));
found.push(...result);
break;
}
}
Promise.all(found.map(item => {
try {
const imports = item.imports.map(i => instance.e(i));
return Promise.all(imports).then(instance.bind(instance, item.main)).catch(console.error);
return Promise.all(imports).then(instance.bind(instance, item.main)).catch(() => void 0);
} catch (error) {
console.error(error);
return Promise.resolve();
}
}));

Loading…
Cancel
Save