Browse Source

fix: BytmDialog interface extension error

Sv443 22 hours ago
parent
commit
14ecfe7e7b
2 changed files with 4 additions and 8 deletions
  1. 3 2
      src/components/BytmDialog.ts
  2. 1 6
      src/dialogs/prompt.ts

+ 3 - 2
src/components/BytmDialog.ts

@@ -1,5 +1,6 @@
 // hoist the class declaration because either rollup or babel is being a hoe
 import { isDomLoaded, NanoEmitter } from "@sv443-network/userutils";
+import type { EventsMap } from "nanoevents";
 import { clearInner, error, getDomain, getResourceUrl, onInteraction, warn } from "../utils/index.js";
 import { t } from "../utils/translations.js";
 import { emitInterface } from "../interface.js";
@@ -37,7 +38,7 @@ export type BytmDialogOptions = {
   renderFooter?: () => HTMLElement | Promise<HTMLElement>;
 };
 
-export type BytmDialogEvents = {
+export interface BytmDialogEvents extends EventsMap {
   /** Emitted just **after** the dialog is closed */
   close: () => void;
   /** Emitted just **after** the dialog is opened */
@@ -48,7 +49,7 @@ export type BytmDialogEvents = {
   clear: () => void;
   /** Emitted just **after** the dialog is destroyed and **before** all listeners are removed */
   destroy: () => void;
-};
+}
 
 /** Whether the dialog system has been initialized */
 let dialogsInitialized = false;

+ 1 - 6
src/dialogs/prompt.ts

@@ -1,7 +1,6 @@
-import type { Emitter } from "nanoevents";
 import { consumeStringGen, type StringGen, type Stringifiable } from "@sv443-network/userutils";
 import { getOS, resourceAsString, setInnerHtml, t } from "../utils/index.js";
-import { BytmDialog, type BytmDialogEvents } from "../components/BytmDialog.js";
+import { BytmDialog } from "../components/BytmDialog.js";
 import { addSelectorListener } from "../observers.js";
 import "./prompt.css";
 
@@ -38,10 +37,6 @@ export type PromptDialogResolveVal = boolean | string | null;
 
 export type ShowPromptProps = Partial<PromptDialogRenderProps> & Required<Pick<PromptDialogRenderProps, "message">>;
 
-export type PromptDialogEmitter = Emitter<BytmDialogEvents & {
-  resolve: (result: PromptDialogResolveVal) => void;
-}>;
-
 //#region PromptDialog
 
 let promptDialog: PromptDialog | null = null;