bc-deeplib 4.0.0 → 5.0.1

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
@@ -118,7 +118,7 @@ declare module 'bc-deeplib/base/base_subscreen' {
118
118
  * If not configured, the default is the main menu for all screens, but main menu itself.
119
119
  * For main menu, the default is the Extensions menu
120
120
  */
121
- returnScreen?: (() => ScreenSpecifier | BaseSubscreen) | ScreenSpecifier | BaseSubscreen;
121
+ returnScreen?: Thunk<ScreenSpecifier | BaseSubscreen>;
122
122
  /**
123
123
  * The background image for this subscreen.
124
124
  * Currently supports only images from the Club.
@@ -254,8 +254,9 @@ declare module 'bc-deeplib/base/base_subscreen' {
254
254
  }
255
255
  declare module 'bc-deeplib/base/elements_typings' {
256
256
  export type SettingElement = Button | Checkbox | Input | Label | Dropdown | Custom;
257
+ type ElementFlexDirection = 'row' | 'column' | 'rowReverse' | 'columnReverse';
257
258
  export type BaseElementModel = {
258
- id: string;
259
+ id: string | null;
259
260
  size?: Thunk<[width: number | null, height: number | null]>;
260
261
  position?: Thunk<[x: number, y: number, anchor?: ElementHelp.AnchorXY]>;
261
262
  disabled?: Thunk<boolean>;
@@ -274,6 +275,9 @@ declare module 'bc-deeplib/base/elements_typings' {
274
275
  setElementValue?: () => boolean;
275
276
  setSettingValue?: (val: boolean) => void;
276
277
  htmlOptions?: Partial<Record<'container' | 'checkbox' | 'label', Omit<HTMLOptions<any>, 'tag'>>> | null | undefined;
278
+ options?: {
279
+ direction?: ElementFlexDirection;
280
+ };
277
281
  } & BaseElementModel>;
278
282
  export type Input = Prettify<{
279
283
  type: 'text' | 'number' | 'color';
@@ -282,21 +286,23 @@ declare module 'bc-deeplib/base/elements_typings' {
282
286
  setElementValue?: () => string;
283
287
  setSettingValue?: (val: string) => void;
284
288
  htmlOptions?: Partial<Record<'container' | 'input' | 'label', Omit<HTMLOptions<any>, 'tag'>>> | null | undefined;
289
+ options?: {
290
+ direction?: ElementFlexDirection;
291
+ };
285
292
  } & BaseElementModel>;
286
293
  export type Dropdown = Prettify<{
287
- id: Parameters<typeof ElementCreateDropdown>[0];
294
+ id: Parameters<typeof ElementDropdown.CreateLabelled>[0];
288
295
  type: 'dropdown';
289
296
  label?: string;
297
+ optionsList: Parameters<typeof ElementDropdown.CreateLabelled>[1];
298
+ onChange?: Parameters<typeof ElementDropdown.CreateLabelled>[3];
290
299
  description?: ElementButton.StaticNode;
291
- optionsList: Parameters<typeof ElementCreateDropdown>[1];
292
300
  setElementValue?: () => string;
293
301
  setSettingValue?: (val: string) => void;
294
- options?: Parameters<typeof ElementCreateDropdown>[3];
295
- htmlOptions?: {
296
- container?: Partial<Omit<HTMLOptions<any>, 'tag'>>;
297
- select?: Parameters<typeof ElementCreateDropdown>[4];
298
- label?: Partial<Omit<HTMLOptions<'label'>, 'tag'>>;
302
+ options?: Parameters<typeof ElementDropdown.CreateLabelled>[4] & {
303
+ direction?: ElementFlexDirection;
299
304
  };
305
+ htmlOptions?: Partial<Record<'label' | 'container' | 'select', Omit<HTMLOptions<any>, 'tag'>>> | null | undefined;
300
306
  } & Omit<BaseElementModel, 'id' | 'disabled'>>;
301
307
  export type Label = Prettify<{
302
308
  type: 'label';
@@ -308,22 +314,14 @@ declare module 'bc-deeplib/base/elements_typings' {
308
314
  type: 'custom';
309
315
  htmlOptions: HTMLOptions<keyof HTMLElementTagNameMap>;
310
316
  } & BaseElementModel>;
317
+ export {};
311
318
 
312
319
  }
313
320
  declare module 'bc-deeplib/base/initialization' {
314
- import { ModSdkManager, ModStorage, MainMenuOptions, TranslationOptions, Logger, ModulesList } from 'bc-deeplib/deeplib';
321
+ import { ModSdkManager, ModStorage, MainMenuOptions, TranslationOptions, ModulesList } from 'bc-deeplib/deeplib';
322
+ import { ILogger } from 'js-logger';
315
323
  /** Configuration object for initializing a mod via `initMod`. */
316
324
  interface InitOptions {
317
- /**
318
- * Name of the mod.
319
- * Used to identify the mod in the Mod SDK and storage.
320
- */
321
- modName: string;
322
- /**
323
- * Repository URL for the mod.
324
- * Used to register the mod with the Mod SDK and display in the main menu.
325
- */
326
- modRepository?: string;
327
325
  /**
328
326
  * List of modules (`BaseModule` subclasses) to register with the mod system.
329
327
  * Modules are initialized, loaded, and run in order.
@@ -361,8 +359,7 @@ declare module 'bc-deeplib/base/initialization' {
361
359
  * Mod specific logger instance.
362
360
  * Initialized by `initMod()`.
363
361
  */
364
- export let modLogger: Logger;
365
- export let MOD_NAME: string;
362
+ export let modLogger: ILogger;
366
363
  /**
367
364
  * Entry point for initializing a mod. Handles:
368
365
  * - Setting up the Mod SDK
@@ -370,7 +367,7 @@ declare module 'bc-deeplib/base/initialization' {
370
367
  * - Injecting required styles
371
368
  * - Delaying initialization until login (if necessary)
372
369
  */
373
- export function initMod(options: InitOptions): void;
370
+ export function initMod(options: InitOptions): Promise<void>;
374
371
  /**
375
372
  * Cleans up and removes the mod from memory.
376
373
  * Calls `unload()` on all modules and removes the global loaded flag.
@@ -509,12 +506,7 @@ declare module 'bc-deeplib/models/base' {
509
506
  * Represents the base settings structure for a mod.
510
507
  * Present for all mods.
511
508
  */
512
- export type BaseSettingsModel = {
513
- /** Whether the mod is currently active. */
514
- modEnabled: boolean;
515
- /** Whether to display a notification when a new version is detected. */
516
- doShowNewVersionMessage: boolean;
517
- };
509
+ export type BaseSettingsModel = Record<string, unknown>;
518
510
 
519
511
  }
520
512
  declare module 'bc-deeplib/models/settings' {
@@ -593,7 +585,7 @@ declare module 'bc-deeplib/modules/gui' {
593
585
  /** Returns all registered subscreens. */
594
586
  get subscreens(): BaseSubscreen[];
595
587
  /** Returns the main menu subscreen instance. */
596
- get mainMenu(): MainMenu;
588
+ get mainMenu(): MainMenu | null;
597
589
  /**
598
590
  * Creates the GUI instance and initializes the main menu.
599
591
  *
@@ -907,7 +899,7 @@ declare module 'bc-deeplib/utilities/elements/elements' {
907
899
  function elementGetTooltip(): HTMLElement | undefined;
908
900
  function elementSetTooltip(text: ElementButton.StaticNode, position?: 'top' | 'bottom'): boolean;
909
901
  interface PrevNext {
910
- id: string;
902
+ id: string | null;
911
903
  initialLabel?: string;
912
904
  back: (arg0: PrevNextCallbacks) => void;
913
905
  initialPrevTooltip?: string;
@@ -1003,7 +995,7 @@ declare module 'bc-deeplib/utilities/elements/modal' {
1003
995
  /** Button label text. */
1004
996
  text: string;
1005
997
  /** Action identifier returned when the button is clicked. */
1006
- action: T;
998
+ action: T | (() => void);
1007
999
  /** Whether the button is disabled. */
1008
1000
  disabled?: boolean;
1009
1001
  };
@@ -1036,21 +1028,43 @@ declare module 'bc-deeplib/utilities/elements/modal' {
1036
1028
  enterAction?: T;
1037
1029
  /** Modal ID. */
1038
1030
  modalId?: string;
1031
+ /** Modal class list. */
1032
+ modalClassList?: string[];
1033
+ /** Callback function to be called when the modal is shown. */
1034
+ onShow?: (this: HTMLDialogElement) => void;
1039
1035
  };
1040
- export interface AlertOptions {
1036
+ export interface AlertOptions<T extends string = string> {
1041
1037
  /** Auto-close timeout in milliseconds. */
1042
1038
  timeoutMs?: number;
1043
1039
  /** Modal ID. */
1044
1040
  modalId?: string;
1041
+ /** Modal class list. */
1042
+ modalClassList?: string[];
1043
+ /** Additional buttons to display in the modal. */
1044
+ buttons?: ModalButton<T>[];
1045
+ /** Callback function to be called when the modal is shown. */
1046
+ onShow?: (this: HTMLDialogElement) => void;
1045
1047
  }
1046
- export interface ConfirmOptions {
1048
+ export interface ConfirmOptions<T extends string = string> {
1047
1049
  /** Modal ID. */
1048
1050
  modalId?: string;
1051
+ /** Modal class list. */
1052
+ modalClassList?: string[];
1053
+ /** Additional buttons to display in the modal. */
1054
+ buttons?: ModalButton<T>[];
1055
+ /** Callback function to be called when the modal is shown. */
1056
+ onShow?: (this: HTMLDialogElement) => void;
1049
1057
  }
1050
- export interface PromptOptions {
1058
+ export interface PromptOptions<T extends string = string> {
1051
1059
  defaultValue?: string;
1052
1060
  /** Modal ID. */
1053
1061
  modalId?: string;
1062
+ /** Modal class list. */
1063
+ modalClassList?: string[];
1064
+ /** Additional buttons to display in the modal. */
1065
+ buttons?: ModalButton<T>[];
1066
+ /** Callback function to be called when the modal is shown. */
1067
+ onShow?: (this: HTMLDialogElement) => void;
1054
1068
  }
1055
1069
  /**
1056
1070
  * Modal dialog implementation with queuing, buttons, optional input, and focus trapping.
@@ -1062,6 +1076,7 @@ declare module 'bc-deeplib/utilities/elements/modal' {
1062
1076
  private blocker;
1063
1077
  private inputEl?;
1064
1078
  private timeoutId?;
1079
+ private updateIntervalId?;
1065
1080
  /** Static modal queue. */
1066
1081
  private static queue;
1067
1082
  /** Flag to indicate if a modal is currently being shown. */
@@ -1146,25 +1161,7 @@ declare module 'bc-deeplib/utilities/event_channel' {
1146
1161
 
1147
1162
  }
1148
1163
  declare module 'bc-deeplib/utilities/logger' {
1149
- type LogLevel = 'info' | 'log' | 'warn' | 'error' | 'debug';
1150
- interface LogEntry {
1151
- readonly args: readonly any[];
1152
- readonly date: Date;
1153
- readonly logLevel: LogLevel;
1154
- }
1155
- export class Logger extends Array<LogEntry> {
1156
- private ModName;
1157
- constructor(modName?: string);
1158
- private _Log;
1159
- info(...args: any[]): void;
1160
- log(...args: any[]): void;
1161
- warn(...args: any[]): void;
1162
- error(...args: any[]): void;
1163
- debug(...args: any[]): void;
1164
- static colorizeLog(logLevel: LogLevel): string;
1165
- }
1166
- export const deepLibLogger: Logger;
1167
- export {};
1164
+ export const deepLibLogger: import("js-logger").ILogger;
1168
1165
 
1169
1166
  }
1170
1167
  declare module 'bc-deeplib/utilities/messages' {
@@ -1280,6 +1277,8 @@ declare module 'bc-deeplib/utilities/translation' {
1280
1277
  defaultLanguage?: string;
1281
1278
  /** If true, the localization will be fixed to the default language, ignoring user language settings. */
1282
1279
  fixedLanguage?: boolean;
1280
+ /** If true, the localization will fetch the translations from the folder. */
1281
+ fetchFolder?: boolean;
1283
1282
  }
1284
1283
  /**
1285
1284
  * Localization class handles loading and retrieving translation strings
@@ -1291,7 +1290,7 @@ declare module 'bc-deeplib/utilities/translation' {
1291
1290
  private static PathToModTranslation;
1292
1291
  private static PathToLibTranslation;
1293
1292
  private static DefaultLanguage;
1294
- /** Flag to prevent re-initialization */
1293
+ private static FetchFolder;
1295
1294
  private static initialized;
1296
1295
  /** Initialize the localization system by loading translation files. */
1297
1296
  static init(initOptions?: TranslationOptions): Promise<void>;
@@ -1299,16 +1298,25 @@ declare module 'bc-deeplib/utilities/translation' {
1299
1298
  static getTextMod(srcTag: string): string | undefined;
1300
1299
  /** Get a translated string from library translations by source tag. */
1301
1300
  static getTextLib(srcTag: string): string | undefined;
1301
+ private static fetchTranslation;
1302
1302
  /**
1303
- * Fetch and parse a language file from the given base URL and language code.
1304
- * Falls back to default language if the requested language file is unavailable.
1303
+ * Fetch and parse a single translation file for a given language.
1304
+ * Only requests `${baseUrl}${lang}.lang` and returns its parsed contents,
1305
+ * or an empty dictionary if the file cannot be fetched.
1305
1306
  */
1306
1307
  private static fetchLanguageFile;
1308
+ /**
1309
+ * Fetch and parse all translation files from a language folder.
1310
+ * First attempts to load a manifest file listing all translation files,
1311
+ * then falls back to trying common file names.
1312
+ * Returns empty dict if folder doesn't exist or has no valid files.
1313
+ */
1314
+ private static fetchLanguageFolder;
1307
1315
  /**
1308
1316
  * Parse the raw content of a language file into a TranslationDict.
1309
1317
  * Ignores empty lines and comments starting with '#'.
1310
1318
  */
1311
- private static parseLanguageFile;
1319
+ private static parseTranslation;
1312
1320
  }
1313
1321
  /**
1314
1322
  * Retrieve a localized string for the given source tag.
@@ -1316,7 +1324,7 @@ declare module 'bc-deeplib/utilities/translation' {
1316
1324
  * then falls back to the library translation,
1317
1325
  * and if neither exist, returns the source tag itself.
1318
1326
  */
1319
- export const getText: (srcTag: string) => string;
1327
+ export const getText: (srcTag: string, replacements?: Record<string, string | number | boolean>) => string;
1320
1328
 
1321
1329
  }
1322
1330
  declare module 'bc-deeplib' {