bc-deeplib 2.2.0 → 2.4.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
@@ -1,5 +1,5 @@
1
1
  declare module 'bc-deeplib/base/base_module' {
2
- import { BaseSettingsModel, Subscreen } from 'bc-deeplib/deeplib';
2
+ import { BaseSettingsModel, SettingsModel, Subscreen } from 'bc-deeplib/deeplib';
3
3
  /**
4
4
  * An abstract foundation for modular systems that require:
5
5
  * - Optional settings screens
@@ -57,7 +57,7 @@ declare module 'bc-deeplib/base/base_module' {
57
57
  * If some settings already exist, they will be merged with defaults.
58
58
  * Existing values will NOT be overwritten.
59
59
  */
60
- registerDefaultSettings(): void;
60
+ registerDefaultSettings(target: SettingsModel): void;
61
61
  /**
62
62
  * Provides default settings for this module.
63
63
  * Subclasses should override this getter to return their defaults.
@@ -152,7 +152,7 @@ declare module 'bc-deeplib/base/base_subscreen' {
152
152
  */
153
153
  export type Subscreen = new (module?: BaseModule) => BaseSubscreen;
154
154
  /** Switches the active subscreen in the global `GUI` instance. */
155
- export function setSubscreen(subscreen: BaseSubscreen | string | null): Promise<void>;
155
+ export function setSubscreen(subscreen: BaseSubscreen | string): Promise<void>;
156
156
  /**
157
157
  * Abstract base class for creating settings/configuration subscreens in a module.
158
158
  *
@@ -182,9 +182,11 @@ declare module 'bc-deeplib/base/base_subscreen' {
182
182
  static readonly id: string;
183
183
  /** Optional configuration flags for a BaseSubscreen instance. */
184
184
  protected static readonly subscreenOptions: SubscreenOptions;
185
+ /** The menu at the top of the subscreen */
186
+ protected static menu: HTMLDivElement | null;
185
187
  constructor(module?: BaseModule);
186
188
  /** Changes the currently active subscreen. */
187
- setSubscreen(screen: BaseSubscreen | string | null): Promise<void>;
189
+ setSubscreen(screen: BaseSubscreen | string): Promise<void>;
188
190
  /** Gets this subscreen's settings object from its parent module. */
189
191
  get settings(): BaseSettingsModel;
190
192
  /** Updates this subscreen's settings in its parent module. */
@@ -310,7 +312,7 @@ declare module 'bc-deeplib/base/elements_typings' {
310
312
 
311
313
  }
312
314
  declare module 'bc-deeplib/base/initialization' {
313
- import { BaseModule, ModSdkManager, BaseMigrator, ModStorage, MainMenuOptions, TranslationOptions } from 'bc-deeplib/deeplib';
315
+ import { BaseModule, ModSdkManager, ModStorage, MainMenuOptions, TranslationOptions, Logger } from 'bc-deeplib/deeplib';
314
316
  /** Configuration object for initializing a mod via `initMod`. */
315
317
  interface InitOptions {
316
318
  /**
@@ -327,11 +329,6 @@ declare module 'bc-deeplib/base/initialization' {
327
329
  * Modules are initialized, loaded, and run in order.
328
330
  */
329
331
  modules?: BaseModule[];
330
- /**
331
- * List of data migration handlers to register with the `VersionModule`.
332
- * Each `BaseMigrator` handles upgrading data from one version to another.
333
- */
334
- migrators?: BaseMigrator[];
335
332
  /** Configuration for customizing the main menu when the mod is active. */
336
333
  mainMenuOptions?: MainMenuOptions;
337
334
  /**
@@ -357,6 +354,11 @@ declare module 'bc-deeplib/base/initialization' {
357
354
  * Initialized by `initMod()`.
358
355
  */
359
356
  export let sdk: ModSdkManager;
357
+ /**
358
+ * Mod specific logger instance.
359
+ * Initialized by `initMod()`.
360
+ */
361
+ export let logger: Logger;
360
362
  /**
361
363
  * Entry point for initializing a mod. Handles:
362
364
  * - Setting up the Mod SDK
@@ -584,10 +586,20 @@ declare module 'bc-deeplib/modules/gui' {
584
586
  declare module 'bc-deeplib/modules/version' {
585
587
  import { BaseMigrator, BaseModule } from 'bc-deeplib/deeplib';
586
588
  export type VersionModuleOptions = {
589
+ /**
590
+ * List of data migration handlers to register with the `VersionModule`.
591
+ * Each `BaseMigrator` handles upgrading data from one version to another.
592
+ */
593
+ migrators?: BaseMigrator[];
594
+ /** Message to display when a new version is detected */
587
595
  newVersionMessage?: string;
596
+ /** Optional lifecycle hook. Runs before each migration */
588
597
  beforeEach?: () => void;
598
+ /** Optional lifecycle hook. Runs after each migration */
589
599
  afterEach?: () => void;
600
+ /** Optional lifecycle hook. Runs before all migrations */
590
601
  beforeAll?: () => void;
602
+ /** Optional lifecycle hook. Runs after all migrations */
591
603
  afterAll?: () => void;
592
604
  };
593
605
  /**
@@ -606,17 +618,12 @@ declare module 'bc-deeplib/modules/version' {
606
618
  private static isItNewVersion;
607
619
  /** The current mod version (retrieved from `ModSdkManager.ModInfo.version`) */
608
620
  private static version;
609
- /** Message to display when a new version is detected */
610
621
  private static newVersionMessage?;
611
622
  /** List of registered migration handlers, sorted by version */
612
623
  private static migrators;
613
- /** Optional lifecycle hook. Runs before each migration */
614
624
  private static beforeEach?;
615
- /** Optional lifecycle hook. Runs after each migration */
616
625
  private static afterEach?;
617
- /** Optional lifecycle hook. Runs before all migrations */
618
626
  private static beforeAll?;
619
- /** Optional lifecycle hook. Runs after all migrations */
620
627
  private static afterAll?;
621
628
  constructor(options: VersionModuleOptions);
622
629
  /**
@@ -639,11 +646,6 @@ declare module 'bc-deeplib/modules/version' {
639
646
  * is newer than the previously stored version.
640
647
  */
641
648
  private static checkVersionMigration;
642
- /**
643
- * Registers a new migrator for handling version-specific changes.
644
- * Migrators are sorted by their `MigrationVersion` in ascending order.
645
- */
646
- static registerMigrator(migrator: BaseMigrator): void;
647
649
  /** Sends the currently configured "new version" message to the local player. */
648
650
  static sendNewVersionMessage(): void;
649
651
  /**
@@ -705,7 +707,7 @@ declare module 'bc-deeplib/screens/import_export' {
705
707
  /** Imports mod data using the specified method. */
706
708
  dataImport(transferMethod: DataTransferMethod): Promise<void>;
707
709
  /** Saves data to a file using the browser's save dialog. */
708
- exportToFile(data: string, defaultFileName: string): Promise<void>;
710
+ exportToFile(data: string, defaultFileName: string): Promise<boolean>;
709
711
  /** Opens a file picker and reads the selected file's contents, importing the data. */
710
712
  importFromFile(): Promise<string | null>;
711
713
  /** Copies the given data to the clipboard. */
@@ -764,13 +766,16 @@ declare module 'bc-deeplib/screens/main_menu' {
764
766
 
765
767
  }
766
768
  declare module 'bc-deeplib/utilities/common' {
769
+ export type DeepMergeOptions = {
770
+ concatArrays?: boolean;
771
+ };
767
772
  /**
768
773
  * Deeply merges two values into a new value.
769
774
  * - Arrays are concatenated.
770
775
  * - Plain objects are merged recursively.
771
776
  * - Other values are replaced by `source`.
772
777
  */
773
- export function deepMerge<T, U>(target: T, source: U): T & U;
778
+ export function deepMerge<T, U>(target: T, source: U, options?: DeepMergeOptions): T & U;
774
779
  /**
775
780
  * Returns a new array with elements of the input array shuffled.
776
781
  * Uses something-something shuffle algorithm by splicing from a cloned array.
@@ -783,12 +788,6 @@ declare module 'bc-deeplib/utilities/common' {
783
788
  * Example: `exportToGlobal('MyMod.Utils', value)` creates `globalThis.MyMod.Utils = value`.
784
789
  */
785
790
  export function exportToGlobal(name: string, value: any): void;
786
- /**
787
- * Deeply merges only matching properties from `mergeFrom` into `mergeTo`.
788
- * Properties not present in `mergeTo` are ignored.
789
- * Objects are recursively merged, primitive properties overwritten.
790
- */
791
- export function deepMergeMatchingProperties<T extends object>(mergeTo: T, mergeFrom: T): T;
792
791
  /** Checks if the given property has a getter defined on the object or its prototype chain. */
793
792
  export function hasGetter<T extends object>(obj: T, prop: keyof T | string): boolean;
794
793
  /** Checks if the given property has a setter defined on the object or its prototype chain. */
@@ -853,7 +852,7 @@ declare module 'bc-deeplib/utilities/elements/elements' {
853
852
  function elementCreateCustom(options: Omit<Custom, 'type'>): HTMLElement;
854
853
  function elementCreateInput(options: Input): HTMLElement;
855
854
  function elementCreateLabel(options: Omit<Label, 'type'>): HTMLElement;
856
- function elementCreateDropdown(options: Omit<Dropdown, 'type'>): HTMLDivElement;
855
+ function elementCreateDropdown(options: Omit<Dropdown, 'type'>): HTMLDivElement | HTMLLabelElement;
857
856
  function elementCreateTooltip(): HTMLDivElement;
858
857
  function elementGetTooltip(): HTMLElement | undefined;
859
858
  function elementSetTooltip(text: string): boolean;