Переглянути джерело

fix: plugin registration & event description

Sv443 9 місяців тому
батько
коміт
77eb58e8d1
1 змінених файлів з 2 додано та 2 видалено
  1. 2 2
      src/interface.ts

+ 2 - 2
src/interface.ts

@@ -27,7 +27,7 @@ export type InterfaceEvents = {
   "bytm:configReady": undefined;
   /** Emitted when the lyrics cache has been loaded */
   "bytm:lyricsCacheReady": undefined;
-  /** Emitted whenever the locale is changed */
+  /** Emitted whenever the locale is changed - if a plugin changed the locale, the plugin ID is provided as well */
   "bytm:setLocale": { locale: TrLocale, pluginId?: string };
   /**
    * When this is emitted, this is your call to register your plugin using `unsafeWindow.BYTM.registerPlugin()`  
@@ -394,7 +394,7 @@ export function registerPlugin(def: PluginDef): PluginRegisterResult {
 export function resolveToken(token: string | undefined): string | undefined {
   return typeof token === "string" && token.length > 0
     ? [...registeredPluginTokens.entries()]
-      .find(([, t]) => token === t)?.[0] ?? undefined
+      .find(([k, t]) => registeredPlugins.has(k) && token === t)?.[0] ?? undefined
     : undefined;
 }