bc-deeplib 1.2.0 → 2.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
@@ -85,22 +85,55 @@ declare module 'bc-deeplib/base/base_subscreen' {
85
85
  import { BaseModule, BaseSettingsModel } from 'bc-deeplib/deeplib';
86
86
  import { SettingElement } from 'bc-deeplib/base/elements_typings';
87
87
  /** Optional configuration flags for a `BaseSubscreen` instance. */
88
- type SubscreenOptions = {
88
+ export type SubscreenOptions = {
89
89
  /**
90
90
  * If `true`, the subscreen will draw the player's character model
91
91
  * in the UI when `run()` is called.
92
92
  * Also shift the UI to the right to make room for the character.
93
93
  */
94
94
  drawCharacter?: boolean;
95
+ /**
96
+ * Logical name of this subscreen.
97
+ * Used for localization key resolution in `load()`.
98
+ * Subclasses should override this with a meaningful identifier.
99
+ */
100
+ name: string;
101
+ /**
102
+ * Path to or Base64 data for an icon representing this subscreen.
103
+ * Defaults to empty string (no icon).
104
+ */
105
+ icon?: string;
106
+ /**
107
+ * An optional help button to open a subscreen or URL or run a function when clicked.
108
+ */
109
+ help?: {
110
+ /** A URL or BaseSubscreen to open or a function to run when the help button is clicked */
111
+ onClick: URL | string | BaseSubscreen | (() => void);
112
+ /** A tooltip to display when the help button is hovered over */
113
+ tooltip?: string;
114
+ /** An icon to display on the help button */
115
+ icon?: string;
116
+ };
117
+ /**
118
+ * Screen to return to when exiting this subscreen.
119
+ * If not configured, the default is the main menu for all screens, but main menu itself.
120
+ * For main menu, the default is the Extensions menu
121
+ */
122
+ returnScreen?: (() => ScreenSpecifier | BaseSubscreen) | ScreenSpecifier | BaseSubscreen;
123
+ /**
124
+ * The background image for this subscreen.
125
+ * Currently supports only images from the Club.
126
+ */
127
+ background?: string;
95
128
  };
96
129
  /**
97
130
  * Represents a constructor type for a subscreen.
98
131
  * Allows dynamic instantiation of subscreen classes with optional
99
132
  * configuration options and a parent module reference.
100
133
  */
101
- export type Subscreen = new (subscreenOptions?: SubscreenOptions, module?: BaseModule) => BaseSubscreen;
134
+ export type Subscreen = new (module?: BaseModule) => BaseSubscreen;
102
135
  /** Switches the active subscreen in the global `GUI` instance. */
103
- export function setSubscreen(subscreen: BaseSubscreen | string | null): BaseSubscreen | null;
136
+ export function setSubscreen(subscreen: BaseSubscreen | string | null): Promise<void>;
104
137
  /**
105
138
  * Abstract base class for creating settings/configuration subscreens in a module.
106
139
  *
@@ -126,20 +159,13 @@ declare module 'bc-deeplib/base/base_subscreen' {
126
159
  readonly options: SubscreenOptions;
127
160
  /** Reference to the module this subscreen belongs to. */
128
161
  readonly module: BaseModule;
129
- constructor(subscreenOptions?: SubscreenOptions, module?: BaseModule);
130
- /**
131
- * Logical name of this subscreen.
132
- * Used for localization key resolution in `load()`.
133
- * Subclasses should override this with a meaningful identifier.
134
- */
135
- get name(): string;
136
- /**
137
- * Path to or Base64 data for an icon representing this subscreen.
138
- * Defaults to empty string (no icon).
139
- */
140
- get icon(): string;
162
+ /** Identifier for internal use to avoid screen name collisions. */
163
+ static readonly id: string;
164
+ /** Optional configuration flags for a BaseSubscreen instance. */
165
+ protected static readonly subscreenOptions: SubscreenOptions;
166
+ constructor(module?: BaseModule);
141
167
  /** Changes the currently active subscreen. */
142
- setSubscreen(screen: BaseSubscreen | string | null): BaseSubscreen | null;
168
+ setSubscreen(screen: BaseSubscreen | string | null): Promise<void>;
143
169
  /** Gets this subscreen's settings object from its parent module. */
144
170
  get settings(): BaseSettingsModel;
145
171
  /** Updates this subscreen's settings in its parent module. */
@@ -196,7 +222,7 @@ declare module 'bc-deeplib/base/base_subscreen' {
196
222
  * Called when the window is resized.
197
223
  * Also checks for overflow in the settings div and applies styling accordingly.
198
224
  */
199
- resize(onLoad?: boolean): void;
225
+ resize(_onLoad?: boolean): void;
200
226
  /**
201
227
  * Called when this subscreen is being removed.
202
228
  * Resets the static element registry and removes the subscreen from the layout.
@@ -204,7 +230,6 @@ declare module 'bc-deeplib/base/base_subscreen' {
204
230
  */
205
231
  unload(): void;
206
232
  }
207
- export {};
208
233
 
209
234
  }
210
235
  declare module 'bc-deeplib/base/elements_typings' {
@@ -420,13 +445,13 @@ declare module 'bc-deeplib/migrators/base_migrator' {
420
445
  *
421
446
  * A migrator is responsible for upgrading or transforming stored data
422
447
  * when the mod version changes. Each migrator targets a specific version
423
- * and executes its {@link Migrate} method once when needed.
448
+ * and executes its {@link migrate} method once when needed.
424
449
  *
425
450
  * @remarks
426
451
  * To create a new migrator:
427
452
  * 1. Extend `BaseMigrator`.
428
- * 2. Implement the {@link MigrationVersion} getter to return the target version string.
429
- * 3. Implement {@link Migrate} with the migration logic (e.g., data structure changes).
453
+ * 2. Implement the {@link migrationVersion} getter to return the target version string.
454
+ * 3. Implement {@link migrate} with the migration logic (e.g., data structure changes).
430
455
  */
431
456
  export abstract class BaseMigrator {
432
457
  /**
@@ -436,17 +461,17 @@ declare module 'bc-deeplib/migrators/base_migrator' {
436
461
  * - This should exactly match the version format used by the mod
437
462
  * - Used by the migration system to determine if this migration should be executed.
438
463
  */
439
- abstract get MigrationVersion(): string;
464
+ abstract get migrationVersion(): string;
440
465
  /**
441
466
  * Executes the migration logic for this version.
442
467
  *
443
468
  * @remarks
444
- * - Called once when upgrading from a version earlier than {@link MigrationVersion}.
469
+ * - Called once when upgrading from a version earlier than {@link migrationVersion}.
445
470
  * - Should handle any necessary data transformations, cleanup, or initialization
446
471
  * to bring the mod's state up to date with the new version.
447
472
  * - Must be idempotent — running it multiple times should not cause data corruption.
448
473
  */
449
- abstract Migrate(): void;
474
+ abstract migrate(): void;
450
475
  }
451
476
 
452
477
  }
@@ -475,22 +500,26 @@ declare module 'bc-deeplib/models/settings' {
475
500
  declare module 'bc-deeplib/modules/gui' {
476
501
  import { BaseModule, BaseSubscreen, MainMenu } from 'bc-deeplib/deeplib';
477
502
  /** Options for configuring a mod's main button in the extensions menu. */
478
- type ModButtonOptions = {
503
+ type GuiOptions = {
479
504
  /**
480
505
  * Unique identifier for the mod's settings button.
481
506
  * Used internally by the preference system to track the button.
482
507
  */
483
- Identifier: string;
508
+ identifier: string;
484
509
  /**
485
510
  * The label displayed on the settings button.
486
511
  * Can be a string or a function that returns a string dynamically.
487
512
  */
488
- ButtonText: string | (() => string);
513
+ buttonText: string | (() => string);
489
514
  /**
490
515
  * The path to or Base64 data of the icon for the settings button.
491
516
  * Can be a string or a function that returns a string dynamically.
492
517
  */
493
- Image: string | (() => string);
518
+ image: string | (() => string);
519
+ /**
520
+ * The main menu screen for the mod.
521
+ */
522
+ mainMenu?: typeof MainMenu;
494
523
  };
495
524
  /**
496
525
  * Central mod GUI controller that manages all subscreens.
@@ -507,29 +536,18 @@ declare module 'bc-deeplib/modules/gui' {
507
536
  private _subscreens;
508
537
  /** The mod's main menu screen. */
509
538
  private _mainMenu;
510
- /** The currently active subscreen, or `null` if none is active. */
511
- private _currentSubscreen;
512
539
  /** Options defining how the mod's settings button is displayed and behaves. */
513
540
  private _modButtonOptions;
514
541
  /** Returns all registered subscreens. */
515
542
  get subscreens(): BaseSubscreen[];
516
543
  /** Returns the main menu subscreen instance. */
517
544
  get mainMenu(): MainMenu;
518
- /** Returns the currently active subscreen. */
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
- */
526
- set currentSubscreen(subscreen: BaseSubscreen | string | null);
527
545
  /**
528
546
  * Creates the GUI instance and initializes the main menu.
529
547
  *
530
548
  * @throws If another `GUI` instance already exists.
531
549
  */
532
- constructor(modButtonOptions: ModButtonOptions);
550
+ constructor(guiOptions?: GuiOptions | null);
533
551
  /**
534
552
  * Loads the GUI and registers the mod's settings button in the extensions menu.
535
553
  *
@@ -544,6 +562,13 @@ declare module 'bc-deeplib/modules/gui' {
544
562
  }
545
563
  declare module 'bc-deeplib/modules/version' {
546
564
  import { BaseMigrator, BaseModule } from 'bc-deeplib/deeplib';
565
+ export type VersionModuleOptions = {
566
+ newVersionMessage: string;
567
+ beforeEach?: () => void;
568
+ afterEach?: () => void;
569
+ beforeAll?: () => void;
570
+ afterAll?: () => void;
571
+ };
547
572
  /**
548
573
  * Handles version tracking, new version detection, and version-based migrations
549
574
  * for the mod. Also manages displaying a "new version" message to players and
@@ -559,11 +584,20 @@ declare module 'bc-deeplib/modules/version' {
559
584
  /** Whether the current session is running a new version compared to stored data */
560
585
  private static isItNewVersion;
561
586
  /** The current mod version (retrieved from `ModSdkManager.ModInfo.version`) */
562
- static Version: string;
587
+ private static version;
563
588
  /** Message to display when a new version is detected */
564
- static NewVersionMessage: string;
589
+ private static newVersionMessage;
565
590
  /** List of registered migration handlers, sorted by version */
566
- private static Migrators;
591
+ private static migrators;
592
+ /** Optional lifecycle hook. Runs before each migration */
593
+ private static beforeEach?;
594
+ /** Optional lifecycle hook. Runs after each migration */
595
+ private static afterEach?;
596
+ /** Optional lifecycle hook. Runs before all migrations */
597
+ private static beforeAll?;
598
+ /** Optional lifecycle hook. Runs after all migrations */
599
+ private static afterAll?;
600
+ constructor(options: VersionModuleOptions);
567
601
  /**
568
602
  * Initializes the module on load:
569
603
  * - Stores the current mod version.
@@ -578,7 +612,7 @@ declare module 'bc-deeplib/modules/version' {
578
612
  * - Updates stored version in player data.
579
613
  * - Saves `modStorage`.
580
614
  */
581
- static checkVersionUpdate(): void;
615
+ private static checkVersionUpdate;
582
616
  /**
583
617
  * Executes migrations for all registered migrators whose `MigrationVersion`
584
618
  * is newer than the previously stored version.
@@ -589,8 +623,6 @@ declare module 'bc-deeplib/modules/version' {
589
623
  * Migrators are sorted by their `MigrationVersion` in ascending order.
590
624
  */
591
625
  static registerMigrator(migrator: BaseMigrator): void;
592
- /** Sets the message that will be displayed when a new version is detected. */
593
- static setNewVersionMessage(newVersionMessage: string): void;
594
626
  /** Sends the currently configured "new version" message to the local player. */
595
627
  static sendNewVersionMessage(): void;
596
628
  /**
@@ -608,15 +640,15 @@ declare module 'bc-deeplib/modules/version' {
608
640
  }
609
641
  declare module 'bc-deeplib/screens/debug' {
610
642
  import { SettingElement } from 'bc-deeplib/base/elements_typings';
611
- import { BaseSubscreen } from 'bc-deeplib/deeplib';
643
+ import { BaseSubscreen, SubscreenOptions } from 'bc-deeplib/deeplib';
612
644
  export class GuiDebug extends BaseSubscreen {
613
- get name(): string;
645
+ protected static subscreenOptions: SubscreenOptions;
614
646
  get pageStructure(): SettingElement[][];
615
647
  }
616
648
 
617
649
  }
618
650
  declare module 'bc-deeplib/screens/import_export' {
619
- import { BaseSubscreen } from 'bc-deeplib/deeplib';
651
+ import { BaseSubscreen, SubscreenOptions } from 'bc-deeplib/deeplib';
620
652
  /**
621
653
  * Configuration options for the {@link GuiImportExport} class.
622
654
  */
@@ -643,7 +675,7 @@ declare module 'bc-deeplib/screens/import_export' {
643
675
  */
644
676
  export class GuiImportExport extends BaseSubscreen {
645
677
  private importExportOptions;
646
- get name(): string;
678
+ static subscreenOptions: SubscreenOptions;
647
679
  constructor(importExportOptions: ImportExportOptions);
648
680
  load(): void;
649
681
  resize(): void;
@@ -664,7 +696,7 @@ declare module 'bc-deeplib/screens/import_export' {
664
696
 
665
697
  }
666
698
  declare module 'bc-deeplib/screens/main_menu' {
667
- import { BaseSubscreen, GUI } from 'bc-deeplib/deeplib';
699
+ import { BaseSubscreen, GUI, SubscreenOptions } from 'bc-deeplib/deeplib';
668
700
  import { GuiImportExport } from 'bc-deeplib/screens/import_export';
669
701
  /**
670
702
  * Configuration options for the main menu.
@@ -699,7 +731,7 @@ declare module 'bc-deeplib/screens/main_menu' {
699
731
  export class MainMenu extends BaseSubscreen {
700
732
  subscreens: BaseSubscreen[];
701
733
  private static options;
702
- get name(): string;
734
+ protected static subscreenOptions: SubscreenOptions;
703
735
  constructor(module: GUI);
704
736
  load(): void;
705
737
  run(): void;
@@ -954,31 +986,25 @@ declare module 'bc-deeplib/utilities/elements/helpers' {
954
986
  }
955
987
  declare module 'bc-deeplib/utilities/elements/layout' {
956
988
  export const layout: {
957
- createSubscreen: typeof elementCreateSubscreenDiv;
958
989
  getSubscreen: typeof elementGetSubscreenDiv;
959
990
  appendToSubscreen: typeof elementAppendToSubscreenDiv;
960
991
  removeSubscreen: typeof elementRemoveSubscreenDiv;
961
- createSettingsDiv: typeof elementCreateSettingsDiv;
962
992
  getSettingsDiv: typeof elementGetSettingsDiv;
963
993
  appendToSettingsDiv: typeof elementAppendToSettingsDiv;
964
994
  removeSettingsDiv: typeof elementRemoveSettingsDiv;
965
- createMiscDiv: typeof elementCreateMiscDiv;
966
995
  getMiscDiv: typeof elementGetMiscDiv;
967
996
  appendToMiscDiv: typeof elementAppendToMiscDiv;
968
997
  removeMiscDiv: typeof elementRemoveMiscDiv;
969
998
  };
970
- function elementCreateSubscreenDiv(): HTMLElement;
971
- function elementGetSubscreenDiv(): HTMLElement | undefined;
972
- function elementRemoveSubscreenDiv(): void | undefined;
973
- function elementAppendToSubscreenDiv(...element: HTMLElement[]): void | undefined;
974
- function elementCreateSettingsDiv(): HTMLElement;
975
- function elementGetSettingsDiv(): HTMLElement | undefined;
976
- function elementAppendToSettingsDiv(...element: HTMLElement[]): void | undefined;
977
- function elementRemoveSettingsDiv(): void | undefined;
978
- function elementCreateMiscDiv(): HTMLElement;
979
- function elementGetMiscDiv(): HTMLElement | null;
980
- function elementAppendToMiscDiv(...element: HTMLElement[]): void | undefined;
981
- function elementRemoveMiscDiv(): void | undefined;
999
+ function elementGetSubscreenDiv(): HTMLElement;
1000
+ function elementRemoveSubscreenDiv(): void;
1001
+ function elementAppendToSubscreenDiv(...element: HTMLElement[]): void;
1002
+ function elementGetSettingsDiv(): HTMLElement;
1003
+ function elementAppendToSettingsDiv(...element: HTMLElement[]): void;
1004
+ function elementRemoveSettingsDiv(): void;
1005
+ function elementGetMiscDiv(): HTMLElement;
1006
+ function elementAppendToMiscDiv(...element: HTMLElement[]): void;
1007
+ function elementRemoveMiscDiv(): void;
982
1008
  export {};
983
1009
 
984
1010
  }