bc-deeplib 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/deeplib.d.ts CHANGED
@@ -99,8 +99,6 @@ declare module 'bc-deeplib/base/base_subscreen' {
99
99
  * configuration options and a parent module reference.
100
100
  */
101
101
  export type Subscreen = new (subscreenOptions?: SubscreenOptions, module?: BaseModule) => BaseSubscreen;
102
- /** Retrieves the currently active subscreen from the global `GUI` instance. */
103
- export function getCurrentSubscreen(): BaseSubscreen | null;
104
102
  /** Switches the active subscreen in the global `GUI` instance. */
105
103
  export function setSubscreen(subscreen: BaseSubscreen | string | null): BaseSubscreen | null;
106
104
  /**
@@ -155,6 +153,7 @@ declare module 'bc-deeplib/base/base_subscreen' {
155
153
  get pageStructure(): SettingElement[][];
156
154
  /** Gets the currently visible page's settings elements. */
157
155
  get currentPage(): SettingElement[];
156
+ getPageLabel(): string;
158
157
  /**
159
158
  * Changes the visible page in a multi-page subscreen.
160
159
  * Automatically wraps around when going past the first or last page.
@@ -216,20 +215,13 @@ declare module 'bc-deeplib/base/elements_typings' {
216
215
  position?: [x: number, y: number] | (() => [x: number, y: number]);
217
216
  disabled?: boolean | (() => boolean);
218
217
  };
219
- type CustomButtonOptions = {
220
- id?: Parameters<typeof ElementButton.Create>[0];
218
+ export type Button = Omit<BaseElementModel, 'id'> & {
219
+ id: Parameters<typeof ElementButton.Create>[0];
220
+ type: 'button';
221
221
  onClick?: Parameters<typeof ElementButton.Create>[1];
222
222
  options?: Parameters<typeof ElementButton.Create>[2];
223
223
  htmlOptions?: Parameters<typeof ElementButton.Create>[3];
224
224
  };
225
- export type Button = BaseElementModel & {
226
- type: 'button';
227
- image?: string;
228
- label?: string;
229
- tooltip?: string;
230
- onClick?: () => void;
231
- htmlOptions?: CustomButtonOptions;
232
- };
233
225
  export type Checkbox = BaseElementModel & {
234
226
  type: 'checkbox';
235
227
  label?: string;
@@ -256,7 +248,6 @@ declare module 'bc-deeplib/base/elements_typings' {
256
248
  type: 'custom';
257
249
  htmlOptions: HTMLOptions<keyof HTMLElementTagNameMap>;
258
250
  };
259
- export {};
260
251
 
261
252
  }
262
253
  declare module 'bc-deeplib/base/initialization' {
@@ -302,6 +293,11 @@ declare module 'bc-deeplib/base/initialization' {
302
293
  * Initialized by `initMod()` and mod data loaded by `init()`.
303
294
  */
304
295
  export let modStorage: ModStorage;
296
+ /**
297
+ * Global Mod SDK manager.
298
+ * Initialized by `initMod()`.
299
+ */
300
+ export let sdk: ModSdkManager;
305
301
  /**
306
302
  * Entry point for initializing a mod. Handles:
307
303
  * - Setting up the Mod SDK
@@ -309,9 +305,7 @@ declare module 'bc-deeplib/base/initialization' {
309
305
  * - Injecting required styles
310
306
  * - Delaying initialization until login (if necessary)
311
307
  */
312
- export function initMod(options: InitOptions): {
313
- sdk: ModSdkManager;
314
- };
308
+ export function initMod(options: InitOptions): void;
315
309
  /**
316
310
  * Fully initializes the mod after login.
317
311
  * Handles:
@@ -417,6 +411,7 @@ declare module 'bc-deeplib/deeplib' {
417
411
  export * from 'bc-deeplib/utilities/sdk';
418
412
  export * from 'bc-deeplib/utilities/style';
419
413
  export * from 'bc-deeplib/utilities/translation';
414
+ export * from 'bc-deeplib/utilities/event_channel';
420
415
 
421
416
  }
422
417
  declare module 'bc-deeplib/migrators/base_migrator' {
@@ -456,8 +451,14 @@ declare module 'bc-deeplib/migrators/base_migrator' {
456
451
 
457
452
  }
458
453
  declare module 'bc-deeplib/models/base' {
454
+ /**
455
+ * Represents the base settings structure for a mod.
456
+ * Present for all mods.
457
+ */
459
458
  export type BaseSettingsModel = {
459
+ /** Whether the mod is currently active. */
460
460
  modEnabled: boolean;
461
+ /** Whether to display a notification when a new version is detected. */
461
462
  doShowNewVersionMessage: boolean;
462
463
  };
463
464
 
@@ -473,28 +474,69 @@ declare module 'bc-deeplib/models/settings' {
473
474
  }
474
475
  declare module 'bc-deeplib/modules/gui' {
475
476
  import { BaseModule, BaseSubscreen, MainMenu } from 'bc-deeplib/deeplib';
477
+ /** Options for configuring a mod's main button in the extensions menu. */
476
478
  type ModButtonOptions = {
479
+ /**
480
+ * Unique identifier for the mod's settings button.
481
+ * Used internally by the preference system to track the button.
482
+ */
477
483
  Identifier: string;
484
+ /**
485
+ * The label displayed on the settings button.
486
+ * Can be a string or a function that returns a string dynamically.
487
+ */
478
488
  ButtonText: string | (() => string);
489
+ /**
490
+ * The path to or Base64 data of the icon for the settings button.
491
+ * Can be a string or a function that returns a string dynamically.
492
+ */
479
493
  Image: string | (() => string);
480
- load?: () => void;
481
- click?: () => void;
482
- run?: () => void;
483
- unload?: () => void;
484
- exit?: () => boolean | void;
485
494
  };
495
+ /**
496
+ * Central mod GUI controller that manages all subscreens.
497
+ *
498
+ * This module is responsible for:
499
+ * - Registering the mod's settings button in the game's preferences.
500
+ * - Managing subscreens (including settings screens for all registered modules).
501
+ * - Routing lifecycle events (load, run, click, exit, unload) to the active subscreen.
502
+ */
486
503
  export class GUI extends BaseModule {
504
+ /** The singleton instance of the GUI controller. */
487
505
  static instance: GUI | null;
506
+ /** All subscreens managed by this GUI, including the main menu and module settings screens. */
488
507
  private _subscreens;
508
+ /** The mod's main menu screen. */
489
509
  private _mainMenu;
510
+ /** The currently active subscreen, or `null` if none is active. */
490
511
  private _currentSubscreen;
512
+ /** Options defining how the mod's settings button is displayed and behaves. */
491
513
  private _modButtonOptions;
514
+ /** Returns all registered subscreens. */
492
515
  get subscreens(): BaseSubscreen[];
516
+ /** Returns the main menu subscreen instance. */
493
517
  get mainMenu(): MainMenu;
518
+ /** Returns the currently active subscreen. */
494
519
  get currentSubscreen(): BaseSubscreen | null;
520
+ /**
521
+ * Sets the current subscreen.
522
+ * Accepts either a `BaseSubscreen` instance or the `name` of a subscreen.
523
+ *
524
+ * @throws If a string is provided but no subscreen with that name exists.
525
+ */
495
526
  set currentSubscreen(subscreen: BaseSubscreen | string | null);
527
+ /**
528
+ * Creates the GUI instance and initializes the main menu.
529
+ *
530
+ * @throws If another `GUI` instance already exists.
531
+ */
496
532
  constructor(modButtonOptions: ModButtonOptions);
497
- get defaultSettings(): null;
533
+ /**
534
+ * Loads the GUI and registers the mod's settings button in the extensions menu.
535
+ *
536
+ * - Creates subscreens for each module's settings screen.
537
+ * - Registers lifecycle callbacks for subscreens events.
538
+ * - Sets up the main menu and its subscreens.
539
+ */
498
540
  load(): void;
499
541
  }
500
542
  export {};
@@ -502,19 +544,64 @@ declare module 'bc-deeplib/modules/gui' {
502
544
  }
503
545
  declare module 'bc-deeplib/modules/version' {
504
546
  import { BaseMigrator, BaseModule } from 'bc-deeplib/deeplib';
547
+ /**
548
+ * Handles version tracking, new version detection, and version-based migrations
549
+ * for the mod. Also manages displaying a "new version" message to players and
550
+ * executing registered migration routines when an update occurs.
551
+ *
552
+ * **Key Responsibilities:**
553
+ * - Track and store the current mod version in persistent player storage.
554
+ * - Detect if the mod has been updated since the last session.
555
+ * - Run version-specific migrations via registered `BaseMigrator` instances.
556
+ * - Optionally display a message to the user upon detecting a new version.
557
+ */
505
558
  export class VersionModule extends BaseModule {
559
+ /** Whether the current session is running a new version compared to stored data */
506
560
  private static isItNewVersion;
561
+ /** The current mod version (retrieved from `ModSdkManager.ModInfo.version`) */
507
562
  static Version: string;
563
+ /** Message to display when a new version is detected */
508
564
  static NewVersionMessage: string;
565
+ /** List of registered migration handlers, sorted by version */
509
566
  private static Migrators;
567
+ /**
568
+ * Initializes the module on load:
569
+ * - Stores the current mod version.
570
+ * - Hooks into `ChatRoomSync` to show a "new version" message when applicable.
571
+ */
510
572
  load(): void;
573
+ /**
574
+ * Checks if the stored version differs from the current version.
575
+ * If a new version is detected:
576
+ * - Flags the session as updated.
577
+ * - Runs applicable migrations.
578
+ * - Updates stored version in player data.
579
+ * - Saves `modStorage`.
580
+ */
511
581
  static checkVersionUpdate(): void;
582
+ /**
583
+ * Executes migrations for all registered migrators whose `MigrationVersion`
584
+ * is newer than the previously stored version.
585
+ */
512
586
  private static checkVersionMigration;
587
+ /**
588
+ * Registers a new migrator for handling version-specific changes.
589
+ * Migrators are sorted by their `MigrationVersion` in ascending order.
590
+ */
513
591
  static registerMigrator(migrator: BaseMigrator): void;
592
+ /** Sets the message that will be displayed when a new version is detected. */
514
593
  static setNewVersionMessage(newVersionMessage: string): void;
594
+ /** Sends the currently configured "new version" message to the local player. */
515
595
  static sendNewVersionMessage(): void;
596
+ /**
597
+ * Determines if a given `candidate` version is newer than the `current` version.
598
+ *
599
+ * Version strings are expected in `MAJOR.MINOR.PATCH` format.
600
+ */
516
601
  private static isNewVersion;
602
+ /** Saves the current mod version into persistent player storage. */
517
603
  private static saveVersion;
604
+ /** Loads the stored mod version from persistent player storage. */
518
605
  private static loadVersion;
519
606
  }
520
607
 
@@ -530,26 +617,47 @@ declare module 'bc-deeplib/screens/debug' {
530
617
  }
531
618
  declare module 'bc-deeplib/screens/import_export' {
532
619
  import { BaseSubscreen } from 'bc-deeplib/deeplib';
620
+ /**
621
+ * Configuration options for the {@link GuiImportExport} class.
622
+ */
533
623
  export type ImportExportOptions = {
534
- /** A custom save file extension. */
624
+ /**
625
+ * A custom save file extension (e.g., ".mydata").
626
+ * If it doesn't start with a dot, it will be automatically prefixed.
627
+ */
535
628
  customFileExtension: string;
536
- /** A callback to be called after data is imported. */
629
+ /** Optional callback invoked after data has been successfully imported. */
537
630
  onImport?: () => void;
538
- /** A callback to be called after data is exported. */
631
+ /** Optional callback invoked after data has been successfully exported. */
539
632
  onExport?: () => void;
540
633
  };
634
+ /**
635
+ * Possible data transfer methods for import/export operations.
636
+ * - `clipboard`: Uses the system clipboard.
637
+ * - `file`: Uses file save/load dialogs.
638
+ */
541
639
  type DataTransferMethod = 'clipboard' | 'file';
640
+ /**
641
+ * GUI screen for importing and exporting mod data.
642
+ * Provides buttons to import/export data either via file or clipboard.
643
+ */
542
644
  export class GuiImportExport extends BaseSubscreen {
543
645
  private importExportOptions;
544
646
  get name(): string;
545
647
  constructor(importExportOptions: ImportExportOptions);
546
648
  load(): void;
547
649
  resize(): void;
650
+ /** Exports the mod data using the specified method. */
548
651
  dataExport(transferMethod: DataTransferMethod): Promise<void>;
652
+ /** Imports mod data using the specified method. */
549
653
  dataImport(transferMethod: DataTransferMethod): Promise<void>;
654
+ /** Saves data to a file using the browser's save dialog. */
550
655
  exportToFile(data: string, defaultFileName: string): Promise<void>;
656
+ /** Opens a file picker and reads the selected file's contents, importing the data. */
551
657
  importFromFile(): Promise<string | null>;
658
+ /** Copies the given data to the clipboard. */
552
659
  exportToClipboard(data: string): Promise<void>;
660
+ /** Prompts the user to enter data and returns it. */
553
661
  importFromClipboard(): Promise<string | null>;
554
662
  }
555
663
  export {};
@@ -558,11 +666,35 @@ declare module 'bc-deeplib/screens/import_export' {
558
666
  declare module 'bc-deeplib/screens/main_menu' {
559
667
  import { BaseSubscreen, GUI } from 'bc-deeplib/deeplib';
560
668
  import { GuiImportExport } from 'bc-deeplib/screens/import_export';
669
+ /**
670
+ * Configuration options for the main menu.
671
+ *
672
+ * If these are defined, new button for each option will be added to the main menu.
673
+ */
561
674
  export type MainMenuOptions = {
675
+ /**
676
+ * Optional URL to the project's repository.
677
+ * Example: "https://github.com/user/project"
678
+ */
562
679
  repoLink?: string;
680
+ /**
681
+ * Optional URL to the project's wiki or documentation.
682
+ * Example: "https://github.com/user/project/wiki"
683
+ */
563
684
  wikiLink?: string;
685
+ /**
686
+ * Optional subscreen to use for the "reset" action.
687
+ */
564
688
  resetSubscreen?: BaseSubscreen;
689
+ /**
690
+ * Optional subscreen for import/export functionality.
691
+ * Provides tools to import or export data to or from the mod.
692
+ */
565
693
  importExportSubscreen?: GuiImportExport;
694
+ /**
695
+ * Optional boolean flag to enable the mod storage fullness indicator.
696
+ */
697
+ storageFullnessIndicator?: boolean;
566
698
  };
567
699
  export class MainMenu extends BaseSubscreen {
568
700
  subscreens: BaseSubscreen[];
@@ -579,19 +711,56 @@ declare module 'bc-deeplib/screens/main_menu' {
579
711
 
580
712
  }
581
713
  declare module 'bc-deeplib/utilities/common' {
714
+ /**
715
+ * Deeply merges properties from `source` into `target`.
716
+ * - If both target and source properties are arrays, concatenates them.
717
+ * - If both are objects, recursively merges them.
718
+ * - Otherwise, source overwrites target.
719
+ */
582
720
  export function deepMerge(target: any, source: any): any;
721
+ /**
722
+ * Returns a new array with elements of the input array shuffled.
723
+ * Uses something-something shuffle algorithm by splicing from a cloned array.
724
+ */
583
725
  export function shuffleArray(array: string[]): string[];
726
+ /**
727
+ * Exports a value to the global object under a nested namespace path.
728
+ * Creates intermediate objects if they do not exist.
729
+ *
730
+ * Example: `exportToGlobal('MyMod.Utils', value)` creates `globalThis.MyMod.Utils = value`.
731
+ */
584
732
  export function exportToGlobal(name: string, value: any): void;
585
- /** Merges matching properties from `mergeFrom` into `mergeTo`. */
733
+ /**
734
+ * Deeply merges only matching properties from `mergeFrom` into `mergeTo`.
735
+ * Properties not present in `mergeTo` are ignored.
736
+ * Objects are recursively merged, primitive properties overwritten.
737
+ */
586
738
  export function deepMergeMatchingProperties<T extends object>(mergeTo: T, mergeFrom: T): T;
739
+ /** Checks if the given property has a getter defined on the object or its prototype chain. */
587
740
  export function hasGetter<T extends object>(obj: T, prop: keyof T | string): boolean;
741
+ /** Checks if the given property has a setter defined on the object or its prototype chain. */
588
742
  export function hasSetter<T extends object>(obj: T, prop: keyof T | string): boolean;
743
+ /**
744
+ * Converts bytes to kilobytes.
745
+ */
746
+ export const byteToKB: (nByte: number) => number;
589
747
 
590
748
  }
591
749
  declare module 'bc-deeplib/utilities/data' {
592
750
  import { SettingsModel } from 'bc-deeplib/deeplib';
751
+ /**
752
+ * ModStorage is a singleton class responsible for managing
753
+ * mod-specific persistent storage both in player settings
754
+ * and in browser localStorage.
755
+ *
756
+ * It provides methods to load and save mod data compressed
757
+ * as base64 strings, and exposes typed accessors for
758
+ * playerStorage and extensionStorage.
759
+ */
593
760
  export class ModStorage<T extends SettingsModel = SettingsModel> {
761
+ /** Singleton instance of ModStorage */
594
762
  private static _instance;
763
+ /** The unique mod identifier used as key prefix in storage */
595
764
  private modName;
596
765
  constructor(modName: string);
597
766
  get playerStorage(): T;
@@ -604,11 +773,16 @@ declare module 'bc-deeplib/utilities/data' {
604
773
  save(): void;
605
774
  static dataDecompress<T = object>(string: string): T | null;
606
775
  static dataCompress(object: object): string;
776
+ static measureSize(data: unknown): number;
607
777
  }
608
778
 
609
779
  }
610
780
  declare module 'bc-deeplib/utilities/elements/elements' {
611
781
  import { Button, Checkbox, Custom, Input, Label } from 'bc-deeplib/base/elements_typings';
782
+ /**
783
+ * Collection of element creation utilities.
784
+ * Provides convenience wrappers for generating commonly used UI elements.
785
+ */
612
786
  export const advElement: {
613
787
  createButton: typeof elementCreateButton;
614
788
  createCheckbox: typeof elementCreateCheckbox;
@@ -643,41 +817,83 @@ declare module 'bc-deeplib/utilities/elements/elements' {
643
817
  }
644
818
  function elementPrevNext(options: PrevNext): HTMLElement;
645
819
  export type ModalButton<T extends string = string> = {
820
+ /** Button label text. */
646
821
  text: string;
822
+ /** Action identifier returned when the button is clicked. */
647
823
  action: T;
824
+ /** Whether the button is disabled. */
648
825
  disabled?: boolean;
649
826
  };
650
827
  export type ModalInputOptions = {
828
+ /** Default input value. */
651
829
  defaultValue?: string;
830
+ /** Makes the input read-only if true. */
652
831
  readOnly?: boolean;
832
+ /** Placeholder text. */
653
833
  placeholder?: string;
834
+ /** Input type. */
654
835
  type: 'input' | 'textarea';
836
+ /** Validation callback to check if the input value is valid. */
655
837
  validate?: (value: string) => string | null;
656
838
  };
657
839
  export type ModalOptions<T extends string = string> = {
658
- prompt: string | Node;
840
+ /** Content or DOM node displayed in the modal header. */
841
+ prompt: ElementButton.StaticNode;
842
+ /** Optional input configuration. */
659
843
  input?: ModalInputOptions;
844
+ /** Buttons to display in the modal. */
660
845
  buttons?: ModalButton<T>[];
846
+ /** Whether clicking backdrop closes the modal (default: true). */
661
847
  closeOnBackdrop?: boolean;
848
+ /** Auto-close timeout in milliseconds. */
662
849
  timeoutMs?: number;
850
+ /** Action sent when Escape key is pressed. */
851
+ escapeAction?: T;
852
+ /** Action sent when Enter key is pressed. */
853
+ enterAction?: T;
663
854
  };
855
+ /**
856
+ * Modal dialog implementation with queuing, buttons, optional input, and focus trapping.
857
+ * Multiple modals are queued to ensure only one is visible at a time.
858
+ */
664
859
  export class Modal<T extends string = string> {
665
860
  private opts;
666
861
  private dialog;
667
862
  private blocker;
668
863
  private inputEl?;
669
864
  private timeoutId?;
865
+ /** Static modal queue. */
670
866
  private static queue;
867
+ /** Flag to indicate if a modal is currently being shown. */
671
868
  private static processing;
672
869
  constructor(opts: ModalOptions<T>);
870
+ /**
871
+ * Displays the modal and resolves with the chosen action and input value.
872
+ */
673
873
  show(): Promise<[T, string | null]>;
674
- static alert(msg: string, timeoutMs?: number): Promise<void>;
675
- static confirm(msg: string): Promise<boolean>;
676
- static prompt(msg: string, defaultValue?: string): Promise<string | null>;
874
+ /**
875
+ * Shows a simple alert modal with a single "OK" button.
876
+ */
877
+ static alert(msg: ElementButton.StaticNode, timeoutMs?: number): Promise<void>;
878
+ /**
879
+ * Shows a confirmation modal with "Cancel" and "OK" buttons.
880
+ * Returns true if "OK" is clicked.
881
+ */
882
+ static confirm(msg: ElementButton.StaticNode): Promise<boolean>;
883
+ /**
884
+ * Shows a prompt modal with an input field and "Submit"/"Cancel" buttons.
885
+ * Returns the input value if submitted, otherwise null.
886
+ */
887
+ static prompt(msg: ElementButton.StaticNode, defaultValue?: string): Promise<string | null>;
888
+ /** Creates the input element for the modal, applying configuration and validation. */
677
889
  private renderInput;
890
+ /** Creates modal action buttons from configuration. */
678
891
  private renderButtons;
892
+ /** Creates the modal backdrop blocker with optional click-to-close behavior. */
679
893
  private createBlocker;
894
+ /** Implements a focus trap to keep keyboard navigation inside the modal. */
680
895
  private setupFocusTrap;
896
+ /** Closes the modal, cleans up DOM, resolves promise, and shows next queued modal. */
681
897
  private close;
682
898
  /**
683
899
  * An internal function where we will save promise function.
@@ -694,10 +910,34 @@ declare module 'bc-deeplib/utilities/elements/elements' {
694
910
  declare module 'bc-deeplib/utilities/elements/helpers' {
695
911
  import { SettingElement } from 'bc-deeplib/base/elements_typings';
696
912
  export const domUtil: {
913
+ /**
914
+ * Automatically sets the position of the element based on the given position.
915
+ * The position can be either a [x, y] tuple or a function returning such a tuple.
916
+ * If both x and y are defined, the element's position is updated accordingly.
917
+ */
697
918
  autoSetPosition: typeof autoSetPosition;
919
+ /**
920
+ * Automatically sets the size of the element based on the given size.
921
+ * The size can be either a [width, height] tuple or a function returning such a tuple.
922
+ * If both width and height are defined, the element's size is updated accordingly.
923
+ */
698
924
  autoSetSize: typeof autoSetSize;
925
+ /**
926
+ * Hides the element by setting its CSS display property to 'none'.
927
+ * If the element cannot be found, the function does nothing.
928
+ */
699
929
  hide: typeof hide;
930
+ /**
931
+ * Unhides the element by clearing its CSS display property (sets it to '').
932
+ * If the element cannot be found, the function does nothing.
933
+ */
700
934
  unhide: typeof unhide;
935
+ /**
936
+ * Checks if the element has overflow content.
937
+ * Returns an object indicating if there is any overflow,
938
+ * and specifically if there is vertical or horizontal overflow.
939
+ * Returns null if the element is not found.
940
+ */
701
941
  hasOverflow: typeof hasOverflow;
702
942
  };
703
943
  function autoSetPosition(_: ElementHelp.ElementOrId, position: SettingElement['position']): void;
@@ -741,6 +981,45 @@ declare module 'bc-deeplib/utilities/elements/layout' {
741
981
  function elementRemoveMiscDiv(): void | undefined;
742
982
  export {};
743
983
 
984
+ }
985
+ declare module 'bc-deeplib/utilities/event_channel' {
986
+ type DeepLibMessageDictionaryEntry<Type extends string, Data> = {
987
+ type: Type;
988
+ data: Data;
989
+ };
990
+ type Listener<Payload> = (data: Payload, sender: Character) => void;
991
+ export interface UnverifiedMessage extends ServerChatRoomMessageBase {
992
+ Target?: number;
993
+ Content: ServerChatRoomMessageContentType;
994
+ Type: ServerChatRoomMessageType;
995
+ Dictionary?: {
996
+ type: string;
997
+ data?: any;
998
+ }[];
999
+ Timeout?: number;
1000
+ }
1001
+ export interface EventChannelMessage<TEvents extends Record<string, unknown> = Record<string, unknown>, TEvent extends keyof TEvents & string = keyof TEvents & string> extends ServerChatRoomMessageBase {
1002
+ Target?: number;
1003
+ Content: string;
1004
+ Type: 'Hidden';
1005
+ Dictionary: [
1006
+ DeepLibMessageDictionaryEntry<TEvent, TEvents[TEvent]>
1007
+ ];
1008
+ Timeout?: number;
1009
+ Sender: number;
1010
+ }
1011
+ export class EventChannel<TEvents extends Record<string, unknown>, TChannelName extends string> {
1012
+ private channelName;
1013
+ private listeners;
1014
+ constructor(channelName: TChannelName);
1015
+ unload(): void;
1016
+ sendEvent<K extends keyof TEvents & string>(type: K, data: TEvents[K], target?: number | null): void;
1017
+ registerListener<K extends keyof TEvents & string>(event: K, listener: Listener<TEvents[K]>): () => void;
1018
+ unregisterListener<K extends keyof TEvents & string>(event: K, listener: Listener<TEvents[K]>): void;
1019
+ private isChannelMessage;
1020
+ }
1021
+ export {};
1022
+
744
1023
  }
745
1024
  declare module 'bc-deeplib/utilities/logger' {
746
1025
  type LogLevel = 'info' | 'log' | 'warn' | 'error' | 'debug';
@@ -770,6 +1049,10 @@ declare module 'bc-deeplib/utilities/messages' {
770
1049
 
771
1050
  }
772
1051
  declare module 'bc-deeplib/utilities/sdk' {
1052
+ /**
1053
+ * Defines priority levels for hooking functions.
1054
+ * Hooks with higher priority are called first in hook chain.
1055
+ */
773
1056
  export const HookPriority: {
774
1057
  Observe: number;
775
1058
  AddBehavior: number;
@@ -777,7 +1060,12 @@ declare module 'bc-deeplib/utilities/sdk' {
777
1060
  OverrideBehavior: number;
778
1061
  Top: number;
779
1062
  };
1063
+ /** Type alias representing module of hook? */
780
1064
  export type ModuleCategory = number | string;
1065
+ /**
1066
+ * Interface representing data about a patched function,
1067
+ * including the function name and all hooks applied to it.
1068
+ */
781
1069
  interface IPatchedFunctionData {
782
1070
  name: string;
783
1071
  hooks: {
@@ -787,16 +1075,41 @@ declare module 'bc-deeplib/utilities/sdk' {
787
1075
  removeCallback: () => void;
788
1076
  }[];
789
1077
  }
1078
+ /**
1079
+ * Manager class for mod SDK integration,
1080
+ * provides methods to register mods, hook functions, and manage patches.
1081
+ */
790
1082
  export class ModSdkManager {
791
1083
  private static SDK;
792
1084
  private static patchedFunctions;
793
1085
  static ModInfo: ModSDKModInfo;
1086
+ /** Registers a mod with the SDK and stores mod information. */
794
1087
  constructor(info: ModSDKModInfo, options?: ModSDKModOptions);
1088
+ /** Retrieves or initializes patch data for a given target function. */
795
1089
  initPatchableFunction(target: string): IPatchedFunctionData;
1090
+ /**
1091
+ * Hooks a function with a callback at a given priority.
1092
+ *
1093
+ * Prevents duplicate hooks.
1094
+ */
796
1095
  hookFunction<TargetName extends string>(target: TargetName, priority: number, hook: PatchHook<GetDotedPathType<typeof globalThis, TargetName>>, module?: ModuleCategory | null): () => void;
1096
+ /**
1097
+ * Applies patches to a target function.
1098
+ *
1099
+ * **This method is DANGEROUS** to use and has high potential to conflict with other mods.
1100
+ */
797
1101
  patchFunction(target: string, patches: Record<string, string>): void;
1102
+ /**
1103
+ * Removes all patches from a target function.
1104
+ */
798
1105
  unpatchFunction(target: string): void;
1106
+ /**
1107
+ * Removes all hooks associated with a specific module from a target function.
1108
+ */
799
1109
  removeHookByModule(target: string, module: ModuleCategory): boolean;
1110
+ /**
1111
+ * Removes all hooks associated with a specific module across all patched functions.
1112
+ */
800
1113
  removeAllHooksByModule(module: ModuleCategory): boolean;
801
1114
  }
802
1115
  export {};
@@ -804,36 +1117,78 @@ declare module 'bc-deeplib/utilities/sdk' {
804
1117
  }
805
1118
  declare module 'bc-deeplib/utilities/style' {
806
1119
  export const Style: {
1120
+ /**
1121
+ * Injects a CSS style block directly into the document head using a <style> tag.
1122
+ * If a style element with the same `styleId` already exists, it won't inject again.
1123
+ */
807
1124
  injectInline(styleId: string, styleSource: string): void;
1125
+ /**
1126
+ * Injects a CSS stylesheet link into the document head using a <link> tag.
1127
+ * If a link element with the same `styleId` already exists, it won't inject again.
1128
+ */
808
1129
  injectEmbed(styleId: string, styleLink: string): void;
1130
+ /**
1131
+ * Removes a style element from the document head by its ID.
1132
+ * Does nothing if the element is not found.
1133
+ */
809
1134
  eject(id: string): void;
1135
+ /**
1136
+ * Reloads an inline style by removing the existing style element (if any)
1137
+ * and injecting the new styles inline again.
1138
+ */
810
1139
  reload(styleId: string, styleSource: string): void;
1140
+ /** Fetches the text content of a stylesheet or any resource at the given link. */
811
1141
  fetch(link: string): Promise<string>;
812
1142
  };
813
1143
 
814
1144
  }
815
1145
  declare module 'bc-deeplib/utilities/translation' {
1146
+ /**
1147
+ * Options for initializing the Localization system.
1148
+ */
816
1149
  export interface TranslationOptions {
817
1150
  /** The path to the folder where the translations are stored. */
818
1151
  pathToTranslationsFolder?: string;
819
1152
  /** The default language to use. */
820
1153
  defaultLanguage?: string;
821
- /** If true, the localization will be fixed to the default language. */
1154
+ /** If true, the localization will be fixed to the default language, ignoring user language settings. */
822
1155
  fixedLanguage?: boolean;
823
1156
  }
1157
+ /**
1158
+ * Localization class handles loading and retrieving translation strings
1159
+ * from library and mod-specific language files.
1160
+ */
824
1161
  export class Localization {
825
1162
  private static LibTranslation;
826
1163
  private static ModTranslation;
827
1164
  private static PathToModTranslation;
828
1165
  private static PathToLibTranslation;
829
1166
  private static DefaultLanguage;
1167
+ /** Flag to prevent re-initialization */
830
1168
  private static initialized;
1169
+ /** Initialize the localization system by loading translation files. */
831
1170
  static init(initOptions?: TranslationOptions): Promise<void>;
1171
+ /** Get a translated string from mod translations by source tag. */
832
1172
  static getTextMod(srcTag: string): string | undefined;
1173
+ /** Get a translated string from library translations by source tag. */
833
1174
  static getTextLib(srcTag: string): string | undefined;
1175
+ /**
1176
+ * Fetch and parse a language file from the given base URL and language code.
1177
+ * Falls back to default language if the requested language file is unavailable.
1178
+ */
834
1179
  private static fetchLanguageFile;
1180
+ /**
1181
+ * Parse the raw content of a language file into a TranslationDict.
1182
+ * Ignores empty lines and comments starting with '#'.
1183
+ */
835
1184
  private static parseLanguageFile;
836
1185
  }
1186
+ /**
1187
+ * Retrieve a localized string for the given source tag.
1188
+ * First attempts to get the mod-specific translation,
1189
+ * then falls back to the library translation,
1190
+ * and if neither exist, returns the source tag itself.
1191
+ */
837
1192
  export const getText: (srcTag: string) => string;
838
1193
 
839
1194
  }