bc-deeplib 2.4.1 → 3.0.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
@@ -38,12 +38,12 @@ declare module 'bc-deeplib/base/base_module' {
38
38
  * Retrieves the current settings for this module.
39
39
  * If no settings exist yet, registers default settings first.
40
40
  */
41
- get settings(): BaseSettingsModel;
41
+ get settings(): BaseSettingsModel | null;
42
42
  /**
43
43
  * Persists new settings for this module.
44
44
  * Automatically initializes storage and defaults if they don't exist.
45
45
  */
46
- set settings(value: BaseSettingsModel);
46
+ set settings(value: BaseSettingsModel | null);
47
47
  /**
48
48
  * Initializes the module.
49
49
  * Default implementation registers default settings immediately.
@@ -257,9 +257,9 @@ declare module 'bc-deeplib/base/elements_typings' {
257
257
  export type SettingElement = Button | Checkbox | Input | Label | Dropdown | Custom;
258
258
  export type BaseElementModel = {
259
259
  id: string;
260
- size?: [width: number | null, height: number | null] | (() => [width: number | null, height: number | null]);
261
- position?: [x: number, y: number] | (() => [x: number, y: number]);
262
- disabled?: boolean | (() => boolean);
260
+ size?: Thunk<[width: number | null, height: number | null]>;
261
+ position?: Thunk<[x: number, y: number, anchor?: ElementHelp.AnchorXY]>;
262
+ disabled?: Thunk<boolean>;
263
263
  };
264
264
  export type Button = Prettify<{
265
265
  id: Parameters<typeof ElementButton.Create>[0];
@@ -316,21 +316,25 @@ declare module 'bc-deeplib/base/initialization' {
316
316
  /** Configuration object for initializing a mod via `initMod`. */
317
317
  interface InitOptions {
318
318
  /**
319
- * Information about the mod being initialized.
320
- * - `info` — Required metadata describing the mod.
321
- * - `options` — Optional runtime configuration for the Mod SDK.
319
+ * Name of the mod.
320
+ * Used to identify the mod in the Mod SDK and storage.
322
321
  */
323
- modInfo: {
324
- info: ModSDKModInfo;
325
- options?: ModSDKModOptions;
326
- };
322
+ modName: string;
323
+ /**
324
+ * Repository URL for the mod.
325
+ * Used to register the mod with the Mod SDK and display in the main menu.
326
+ */
327
+ modRepository?: string;
327
328
  /**
328
329
  * List of modules (`BaseModule` subclasses) to register with the mod system.
329
330
  * Modules are initialized, loaded, and run in order.
330
331
  */
331
332
  modules?: BaseModule[];
332
- /** Configuration for customizing the main menu when the mod is active. */
333
- mainMenuOptions?: MainMenuOptions;
333
+ /**
334
+ * Configuration for customizing the main menu when the mod is active.
335
+ * Does nothing if GUI module is not loaded.
336
+ */
337
+ mainMenuOptions?: Prettify<Omit<MainMenuOptions, 'repoLink'>>;
334
338
  /**
335
339
  * Optional hook executed *before* login when the player is not yet authenticated.
336
340
  * Useful for pre-login setup or display changes.
@@ -358,7 +362,8 @@ declare module 'bc-deeplib/base/initialization' {
358
362
  * Mod specific logger instance.
359
363
  * Initialized by `initMod()`.
360
364
  */
361
- export let logger: Logger;
365
+ export let modLogger: Logger;
366
+ export let MOD_NAME: string;
362
367
  /**
363
368
  * Entry point for initializing a mod. Handles:
364
369
  * - Setting up the Mod SDK
@@ -377,13 +382,6 @@ declare module 'bc-deeplib/base/initialization' {
377
382
  }
378
383
  declare module 'bc-deeplib/base/modules' {
379
384
  import { BaseModule } from 'bc-deeplib/deeplib';
380
- /**
381
- * Global registry of all loaded modules, keyed by their class name.
382
- *
383
- * The map is populated via {@link registerModule} and accessed via {@link modules} or {@link getModule}.
384
- * This is the central storage for active `BaseModule` instances during the mod lifecycle.
385
- */
386
- export const modulesMap: Map<string, BaseModule>;
387
385
  /**
388
386
  * Retrieves all registered module instances.
389
387
  *
@@ -432,7 +430,7 @@ declare module 'bc-deeplib/base/modules' {
432
430
  * themeModule?.reloadTheme();
433
431
  * ```
434
432
  */
435
- export function getModule<T extends BaseModule>(moduleType: string): T;
433
+ export function getModule<T extends BaseModule>(moduleType: string): T | undefined;
436
434
 
437
435
  }
438
436
  declare module 'bc-deeplib/deeplib' {
@@ -453,6 +451,7 @@ declare module 'bc-deeplib/deeplib' {
453
451
  export * from 'bc-deeplib/utilities/elements/elements';
454
452
  export * from 'bc-deeplib/utilities/elements/helpers';
455
453
  export * from 'bc-deeplib/utilities/elements/layout';
454
+ export * from 'bc-deeplib/utilities/elements/modal';
456
455
  export * from 'bc-deeplib/utilities/common';
457
456
  export * from 'bc-deeplib/utilities/logger';
458
457
  export * from 'bc-deeplib/utilities/messages';
@@ -533,12 +532,12 @@ declare module 'bc-deeplib/modules/gui' {
533
532
  * The label displayed on the settings button.
534
533
  * Can be a string or a function that returns a string dynamically.
535
534
  */
536
- buttonText: string | (() => string);
535
+ buttonText: Thunk<string>;
537
536
  /**
538
537
  * The path to or Base64 data of the icon for the settings button.
539
538
  * Can be a string or a function that returns a string dynamically.
540
539
  */
541
- image: string | (() => string);
540
+ image: Thunk<string>;
542
541
  /**
543
542
  * The main menu screen for the mod.
544
543
  */
@@ -625,7 +624,7 @@ declare module 'bc-deeplib/modules/version' {
625
624
  private static afterEach?;
626
625
  private static beforeAll?;
627
626
  private static afterAll?;
628
- constructor(options: VersionModuleOptions);
627
+ constructor(options?: VersionModuleOptions);
629
628
  /**
630
629
  * Initializes the module on load:
631
630
  * - Stores the current mod version.
@@ -714,6 +713,9 @@ declare module 'bc-deeplib/screens/import_export' {
714
713
  exportToClipboard(data: string): Promise<void>;
715
714
  /** Prompts the user to enter data and returns it. */
716
715
  importFromClipboard(): Promise<string | null>;
716
+ private getSelectedModules;
717
+ private buildExportPayload;
718
+ private applyImportPayload;
717
719
  }
718
720
  export {};
719
721
 
@@ -767,7 +769,10 @@ declare module 'bc-deeplib/screens/main_menu' {
767
769
  }
768
770
  declare module 'bc-deeplib/utilities/common' {
769
771
  export type DeepMergeOptions = {
772
+ /** Concatenate arrays instead of replacing them. */
770
773
  concatArrays?: boolean;
774
+ /** Only merge matching keys. */
775
+ matchingOnly?: boolean;
771
776
  };
772
777
  /**
773
778
  * Deeply merges two values into a new value.
@@ -818,11 +823,12 @@ declare module 'bc-deeplib/utilities/data' {
818
823
  get playerStorage(): T;
819
824
  set playerStorage(value: T);
820
825
  get extensionStorage(): string;
821
- set extensionStorage(value: string);
826
+ private set extensionStorage(value);
822
827
  setLocalStorage(key: string, value: object): void;
823
828
  getLocalStorage(key: string): object | null;
824
829
  load(): void;
825
830
  save(): void;
831
+ storageSize(): number;
826
832
  static dataDecompress<T = object>(string: string): T | null;
827
833
  static dataCompress(object: object): string;
828
834
  static measureSize(data: unknown): number;
@@ -848,11 +854,11 @@ declare module 'bc-deeplib/utilities/elements/elements' {
848
854
  createBackNext: typeof elementPrevNext;
849
855
  };
850
856
  function elementCreateButton(options: Omit<Button, 'type'>): HTMLButtonElement;
851
- function elementCreateCheckbox(options: Omit<Checkbox, 'type'>): HTMLElement;
857
+ function elementCreateCheckbox(options: Omit<Checkbox, 'type'>): HTMLLabelElement;
852
858
  function elementCreateCustom(options: Omit<Custom, 'type'>): HTMLElement;
853
- function elementCreateInput(options: Input): HTMLElement;
854
- function elementCreateLabel(options: Omit<Label, 'type'>): HTMLElement;
855
- function elementCreateDropdown(options: Omit<Dropdown, 'type'>): HTMLDivElement | HTMLLabelElement;
859
+ function elementCreateInput(options: Input): HTMLLabelElement;
860
+ function elementCreateLabel(options: Omit<Label, 'type'>): HTMLLabelElement;
861
+ function elementCreateDropdown(options: Omit<Dropdown, 'type'>): HTMLLabelElement;
856
862
  function elementCreateTooltip(): HTMLDivElement;
857
863
  function elementGetTooltip(): HTMLElement | undefined;
858
864
  function elementSetTooltip(text: string): boolean;
@@ -870,6 +876,79 @@ declare module 'bc-deeplib/utilities/elements/elements' {
870
876
  setNextTooltip: (tooltip: string) => void;
871
877
  }
872
878
  function elementPrevNext(options: PrevNext): HTMLElement;
879
+ export {};
880
+
881
+ }
882
+ declare module 'bc-deeplib/utilities/elements/helpers' {
883
+ import { SettingElement } from 'bc-deeplib/base/elements_typings';
884
+ export const domUtil: {
885
+ /**
886
+ * Automatically sets the position of the element based on the given position.
887
+ * The position can be either a [x, y] tuple or a function returning such a tuple.
888
+ * If both x and y are defined, the element's position is updated accordingly.
889
+ */
890
+ autoSetPosition: typeof autoSetPosition;
891
+ /**
892
+ * Automatically sets the size of the element based on the given size.
893
+ * The size can be either a [width, height] tuple or a function returning such a tuple.
894
+ * If both width and height are defined, the element's size is updated accordingly.
895
+ */
896
+ autoSetSize: typeof autoSetSize;
897
+ /**
898
+ * Hides the element by setting its CSS display property to 'none'.
899
+ * If the element cannot be found, the function does nothing.
900
+ */
901
+ hide: typeof hide;
902
+ /**
903
+ * Unhides the element by clearing its CSS display property (sets it to '').
904
+ * If the element cannot be found, the function does nothing.
905
+ */
906
+ unhide: typeof unhide;
907
+ /**
908
+ * Checks if the element has overflow content.
909
+ * Returns an object indicating if there is any overflow,
910
+ * and specifically if there is vertical or horizontal overflow.
911
+ * Returns null if the element is not found.
912
+ */
913
+ hasOverflow: typeof hasOverflow;
914
+ };
915
+ function autoSetPosition(_: ElementHelp.ElementOrId, position: SettingElement['position']): void;
916
+ function autoSetSize(_: ElementHelp.ElementOrId, size: SettingElement['size']): void;
917
+ function hide(_: ElementHelp.ElementOrId): void;
918
+ function unhide(_: ElementHelp.ElementOrId): void;
919
+ function hasOverflow(el: ElementHelp.ElementOrId): {
920
+ any: boolean;
921
+ vertical: boolean;
922
+ horizontal: boolean;
923
+ } | null;
924
+ export {};
925
+
926
+ }
927
+ declare module 'bc-deeplib/utilities/elements/layout' {
928
+ export const layout: {
929
+ getSubscreen: typeof elementGetSubscreenDiv;
930
+ appendToSubscreen: typeof elementAppendToSubscreenDiv;
931
+ removeSubscreen: typeof elementRemoveSubscreenDiv;
932
+ getSettingsDiv: typeof elementGetSettingsDiv;
933
+ appendToSettingsDiv: typeof elementAppendToSettingsDiv;
934
+ removeSettingsDiv: typeof elementRemoveSettingsDiv;
935
+ getMiscDiv: typeof elementGetMiscDiv;
936
+ appendToMiscDiv: typeof elementAppendToMiscDiv;
937
+ removeMiscDiv: typeof elementRemoveMiscDiv;
938
+ };
939
+ function elementGetSubscreenDiv(): HTMLElement;
940
+ function elementRemoveSubscreenDiv(): void;
941
+ function elementAppendToSubscreenDiv(...element: HTMLElement[]): void;
942
+ function elementGetSettingsDiv(): HTMLElement;
943
+ function elementAppendToSettingsDiv(...element: HTMLElement[]): void;
944
+ function elementRemoveSettingsDiv(): void;
945
+ function elementGetMiscDiv(): HTMLElement;
946
+ function elementAppendToMiscDiv(...element: HTMLElement[]): void;
947
+ function elementRemoveMiscDiv(): void;
948
+ export {};
949
+
950
+ }
951
+ declare module 'bc-deeplib/utilities/elements/modal' {
873
952
  export type ModalButton<T extends string = string> = {
874
953
  /** Button label text. */
875
954
  text: string;
@@ -905,7 +984,24 @@ declare module 'bc-deeplib/utilities/elements/elements' {
905
984
  escapeAction?: T;
906
985
  /** Action sent when Enter key is pressed. */
907
986
  enterAction?: T;
987
+ /** Modal ID. */
988
+ modalId?: string;
908
989
  };
990
+ export interface AlertOptions {
991
+ /** Auto-close timeout in milliseconds. */
992
+ timeoutMs?: number;
993
+ /** Modal ID. */
994
+ modalId?: string;
995
+ }
996
+ export interface ConfirmOptions {
997
+ /** Modal ID. */
998
+ modalId?: string;
999
+ }
1000
+ export interface PromptOptions {
1001
+ defaultValue?: string;
1002
+ /** Modal ID. */
1003
+ modalId?: string;
1004
+ }
909
1005
  /**
910
1006
  * Modal dialog implementation with queuing, buttons, optional input, and focus trapping.
911
1007
  * Multiple modals are queued to ensure only one is visible at a time.
@@ -928,17 +1024,17 @@ declare module 'bc-deeplib/utilities/elements/elements' {
928
1024
  /**
929
1025
  * Shows a simple alert modal with a single "OK" button.
930
1026
  */
931
- static alert(msg: ElementButton.StaticNode, timeoutMs?: number): Promise<void>;
1027
+ static alert(msg: ElementButton.StaticNode, opts?: AlertOptions): Promise<void>;
932
1028
  /**
933
1029
  * Shows a confirmation modal with "Cancel" and "OK" buttons.
934
1030
  * Returns true if "OK" is clicked.
935
1031
  */
936
- static confirm(msg: ElementButton.StaticNode): Promise<boolean>;
1032
+ static confirm(msg: ElementButton.StaticNode, opts?: ConfirmOptions): Promise<boolean>;
937
1033
  /**
938
1034
  * Shows a prompt modal with an input field and "Submit"/"Cancel" buttons.
939
1035
  * Returns the input value if submitted, otherwise null.
940
1036
  */
941
- static prompt(msg: ElementButton.StaticNode, defaultValue?: string): Promise<string | null>;
1037
+ static prompt(msg: ElementButton.StaticNode, opts?: PromptOptions): Promise<string | null>;
942
1038
  /** Creates the input element for the modal, applying configuration and validation. */
943
1039
  private renderInput;
944
1040
  /** Creates modal action buttons from configuration. */
@@ -958,76 +1054,6 @@ declare module 'bc-deeplib/utilities/elements/elements' {
958
1054
  /** A function that processes the queue, removing the first modal */
959
1055
  private static dequeue;
960
1056
  }
961
- export {};
962
-
963
- }
964
- declare module 'bc-deeplib/utilities/elements/helpers' {
965
- import { SettingElement } from 'bc-deeplib/base/elements_typings';
966
- export const domUtil: {
967
- /**
968
- * Automatically sets the position of the element based on the given position.
969
- * The position can be either a [x, y] tuple or a function returning such a tuple.
970
- * If both x and y are defined, the element's position is updated accordingly.
971
- */
972
- autoSetPosition: typeof autoSetPosition;
973
- /**
974
- * Automatically sets the size of the element based on the given size.
975
- * The size can be either a [width, height] tuple or a function returning such a tuple.
976
- * If both width and height are defined, the element's size is updated accordingly.
977
- */
978
- autoSetSize: typeof autoSetSize;
979
- /**
980
- * Hides the element by setting its CSS display property to 'none'.
981
- * If the element cannot be found, the function does nothing.
982
- */
983
- hide: typeof hide;
984
- /**
985
- * Unhides the element by clearing its CSS display property (sets it to '').
986
- * If the element cannot be found, the function does nothing.
987
- */
988
- unhide: typeof unhide;
989
- /**
990
- * Checks if the element has overflow content.
991
- * Returns an object indicating if there is any overflow,
992
- * and specifically if there is vertical or horizontal overflow.
993
- * Returns null if the element is not found.
994
- */
995
- hasOverflow: typeof hasOverflow;
996
- };
997
- function autoSetPosition(_: ElementHelp.ElementOrId, position: SettingElement['position']): void;
998
- function autoSetSize(_: ElementHelp.ElementOrId, size: SettingElement['size']): void;
999
- function hide(_: ElementHelp.ElementOrId): void;
1000
- function unhide(_: ElementHelp.ElementOrId): void;
1001
- function hasOverflow(el: ElementHelp.ElementOrId): {
1002
- any: boolean;
1003
- vertical: boolean;
1004
- horizontal: boolean;
1005
- } | null;
1006
- export {};
1007
-
1008
- }
1009
- declare module 'bc-deeplib/utilities/elements/layout' {
1010
- export const layout: {
1011
- getSubscreen: typeof elementGetSubscreenDiv;
1012
- appendToSubscreen: typeof elementAppendToSubscreenDiv;
1013
- removeSubscreen: typeof elementRemoveSubscreenDiv;
1014
- getSettingsDiv: typeof elementGetSettingsDiv;
1015
- appendToSettingsDiv: typeof elementAppendToSettingsDiv;
1016
- removeSettingsDiv: typeof elementRemoveSettingsDiv;
1017
- getMiscDiv: typeof elementGetMiscDiv;
1018
- appendToMiscDiv: typeof elementAppendToMiscDiv;
1019
- removeMiscDiv: typeof elementRemoveMiscDiv;
1020
- };
1021
- function elementGetSubscreenDiv(): HTMLElement;
1022
- function elementRemoveSubscreenDiv(): void;
1023
- function elementAppendToSubscreenDiv(...element: HTMLElement[]): void;
1024
- function elementGetSettingsDiv(): HTMLElement;
1025
- function elementAppendToSettingsDiv(...element: HTMLElement[]): void;
1026
- function elementRemoveSettingsDiv(): void;
1027
- function elementGetMiscDiv(): HTMLElement;
1028
- function elementAppendToMiscDiv(...element: HTMLElement[]): void;
1029
- function elementRemoveMiscDiv(): void;
1030
- export {};
1031
1057
 
1032
1058
  }
1033
1059
  declare module 'bc-deeplib/utilities/event_channel' {
@@ -1128,9 +1154,8 @@ declare module 'bc-deeplib/utilities/sdk' {
1128
1154
  * provides methods to register mods, hook functions, and manage patches.
1129
1155
  */
1130
1156
  export class ModSdkManager {
1131
- private static SDK;
1132
- private static patchedFunctions;
1133
- static ModInfo: ModSDKModInfo;
1157
+ private SDK;
1158
+ private patchedFunctions;
1134
1159
  /** Registers a mod with the SDK and stores mod information. */
1135
1160
  constructor(info: ModSDKModInfo, options?: ModSDKModOptions);
1136
1161
  /** Retrieves or initializes patch data for a given target function. */
@@ -1159,6 +1184,10 @@ declare module 'bc-deeplib/utilities/sdk' {
1159
1184
  * Removes all hooks associated with a specific module across all patched functions.
1160
1185
  */
1161
1186
  removeAllHooksByModule(module: ModuleCategory): boolean;
1187
+ /**
1188
+ * Unloads the mod removing all hooks and patches by it.
1189
+ */
1190
+ unload(): void;
1162
1191
  }
1163
1192
  export {};
1164
1193