|
@@ -1,7 +1,7 @@
|
|
|
import * as UserUtils from "@sv443-network/userutils";
|
|
|
import * as compareVersions from "compare-versions";
|
|
|
import { mode, branch, host, buildNumber, compressionFormat, scriptInfo } from "./constants.js";
|
|
|
-import { getDomain, waitVideoElementReady, getResourceUrl, getSessionId, getVideoTime, log, setLocale, getLocale, hasKey, hasKeyFor, t, tp, type TrLocale, info, error, onInteraction, getThumbnailUrl, getBestThumbnailUrl, fetchVideoVotes, setInnerHtml, getCurrentMediaType, tl, tlp } from "./utils/index.js";
|
|
|
+import { getDomain, waitVideoElementReady, getResourceUrl, getSessionId, getVideoTime, log, setLocale, getLocale, hasKey, hasKeyFor, t, tp, type TrLocale, info, error, onInteraction, getThumbnailUrl, getBestThumbnailUrl, fetchVideoVotes, setInnerHtml, getCurrentMediaType, tl, tlp, PluginError } from "./utils/index.js";
|
|
|
import { addSelectorListener } from "./observers.js";
|
|
|
import { getFeatures, setFeatures } from "./config.js";
|
|
|
import { autoLikeStore, featInfo, fetchLyricsUrlTop, getLyricsCacheEntry, sanitizeArtists, sanitizeSong } from "./features/index.js";
|
|
@@ -234,11 +234,11 @@ export function initPlugins() {
|
|
|
const registerPlugin = (def: PluginDef): PluginRegisterResult => {
|
|
|
try {
|
|
|
if(registeredPlugins.has(getPluginKey(def)))
|
|
|
- throw new Error(`Failed to register plugin '${getPluginKey(def)}': Plugin with the same name and namespace is already registered`);
|
|
|
+ throw new PluginError(`Failed to register plugin '${getPluginKey(def)}': Plugin with the same name and namespace is already registered`);
|
|
|
|
|
|
const validationErrors = validatePluginDef(def);
|
|
|
if(validationErrors)
|
|
|
- throw new Error(`Failed to register plugin${def?.plugin?.name ? ` '${def?.plugin?.name}'` : ""} with invalid definition:\n- ${validationErrors.join("\n- ")}`);
|
|
|
+ throw new PluginError(`Failed to register plugin${def?.plugin?.name ? ` '${def?.plugin?.name}'` : ""} with invalid definition:\n- ${validationErrors.join("\n- ")}`);
|
|
|
|
|
|
const events = new NanoEmitter<PluginEventMap>({ publicEmit: true });
|
|
|
const token = randomId(32, 36, true);
|
|
@@ -259,7 +259,7 @@ export function initPlugins() {
|
|
|
};
|
|
|
}
|
|
|
catch(err) {
|
|
|
- error(`Failed to register plugin '${getPluginKey(def)}':`, err);
|
|
|
+ error(`Failed to register plugin '${getPluginKey(def)}':`, err instanceof PluginError ? err : new PluginError(String(err)));
|
|
|
throw err;
|
|
|
}
|
|
|
};
|