bc-deeplib 1.1.3 → 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/README.md +26 -2
- package/dist/deeplib.d.ts +160 -85
- package/dist/deeplib.js +509 -265
- package/dist/deeplib.js.map +3 -3
- package/dist/public/dl_images/arrow_left.svg +9 -1
- package/dist/public/dl_images/arrow_right.svg +9 -1
- package/dist/public/dl_images/bookmark.svg +17 -0
- package/dist/public/dl_images/bug.svg +9 -1
- package/dist/public/dl_images/exit.svg +12 -1
- package/dist/public/dl_images/notebook.svg +10 -1
- package/dist/public/dl_images/transfer.svg +9 -1
- package/dist/public/dl_images/trash_bin.svg +18 -1
- package/dist/public/dl_translations/en.lang +15 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/build.js +13 -0
- package/package.json +11 -11
- package/dist/3rd_party_types/bcmodsdk.d.ts +0 -184
- package/dist/3rd_party_types/declarations.d.ts +0 -4
- package/dist/index.js +0 -2556
- package/dist/index.js.map +0 -7
- package/dist/public/dl_images/cog.svg +0 -1
- package/dist/public/dl_images/round_arrow_left.svg +0 -1
- package/dist/public/dl_images/round_arrow_right.svg +0 -1
- package/dist/public/dl_images/round_transfer.svg +0 -7
package/README.md
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# ${{\color{#440171}\Large{\textsf{DeepLib}}}}$
|
|
2
|
+
## Active development (there might be a lot of breaking changes)
|
|
3
|
+
|
|
4
|
+
## What is DeepLib?
|
|
5
|
+
|
|
6
|
+
DeepLib is an opinionated library for easier development of BC mods, which strives to be a framework :D
|
|
7
|
+
|
|
8
|
+
## What it has to offer
|
|
9
|
+
|
|
10
|
+
* **Mod Initialization**: The `initMod()` function allows you to initialize a mod, which includes setting up the Mod SDK, initializing localization, and registering modules and migrators.
|
|
11
|
+
|
|
12
|
+
* **Modules**: provides a modular architecture, allowing you to create modules for different aspects of your mod.
|
|
13
|
+
|
|
14
|
+
* **Settings GUI**: provides an easily configurable HTML-based GUI system for creating different sorts of settings screens with a lot of built-in features.
|
|
15
|
+
|
|
16
|
+
* **Localization**: provides a localization system for creating different languages for your mod.
|
|
17
|
+
|
|
18
|
+
* **Migrators**: provides a migrator system for creating different migrations for your mod for easy transition between versions.
|
|
19
|
+
|
|
20
|
+
* **Hidden Events**: provides a hidden event system for sending and listening to events with help of `EventChannel`.
|
|
21
|
+
|
|
22
|
+
* **Out-Of-Box Themed Support**: custom elements support Themed customizations.
|
|
23
|
+
|
|
24
|
+
* **Build System**: provides a build system for easily building your mod with `esbuild`.
|
|
25
|
+
|
|
26
|
+
Take a look at [QUICKSTART.md](docs/QUICKSTART.md) for more information on how to get started.
|
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 (
|
|
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):
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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):
|
|
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. */
|
|
@@ -153,6 +179,7 @@ declare module 'bc-deeplib/base/base_subscreen' {
|
|
|
153
179
|
get pageStructure(): SettingElement[][];
|
|
154
180
|
/** Gets the currently visible page's settings elements. */
|
|
155
181
|
get currentPage(): SettingElement[];
|
|
182
|
+
getPageLabel(): string;
|
|
156
183
|
/**
|
|
157
184
|
* Changes the visible page in a multi-page subscreen.
|
|
158
185
|
* Automatically wraps around when going past the first or last page.
|
|
@@ -195,7 +222,7 @@ declare module 'bc-deeplib/base/base_subscreen' {
|
|
|
195
222
|
* Called when the window is resized.
|
|
196
223
|
* Also checks for overflow in the settings div and applies styling accordingly.
|
|
197
224
|
*/
|
|
198
|
-
resize(
|
|
225
|
+
resize(_onLoad?: boolean): void;
|
|
199
226
|
/**
|
|
200
227
|
* Called when this subscreen is being removed.
|
|
201
228
|
* Resets the static element registry and removes the subscreen from the layout.
|
|
@@ -203,7 +230,6 @@ declare module 'bc-deeplib/base/base_subscreen' {
|
|
|
203
230
|
*/
|
|
204
231
|
unload(): void;
|
|
205
232
|
}
|
|
206
|
-
export {};
|
|
207
233
|
|
|
208
234
|
}
|
|
209
235
|
declare module 'bc-deeplib/base/elements_typings' {
|
|
@@ -214,20 +240,13 @@ declare module 'bc-deeplib/base/elements_typings' {
|
|
|
214
240
|
position?: [x: number, y: number] | (() => [x: number, y: number]);
|
|
215
241
|
disabled?: boolean | (() => boolean);
|
|
216
242
|
};
|
|
217
|
-
type
|
|
218
|
-
id
|
|
243
|
+
export type Button = Omit<BaseElementModel, 'id'> & {
|
|
244
|
+
id: Parameters<typeof ElementButton.Create>[0];
|
|
245
|
+
type: 'button';
|
|
219
246
|
onClick?: Parameters<typeof ElementButton.Create>[1];
|
|
220
247
|
options?: Parameters<typeof ElementButton.Create>[2];
|
|
221
248
|
htmlOptions?: Parameters<typeof ElementButton.Create>[3];
|
|
222
249
|
};
|
|
223
|
-
export type Button = BaseElementModel & {
|
|
224
|
-
type: 'button';
|
|
225
|
-
image?: string;
|
|
226
|
-
label?: string;
|
|
227
|
-
tooltip?: string;
|
|
228
|
-
onClick?: () => void;
|
|
229
|
-
htmlOptions?: CustomButtonOptions;
|
|
230
|
-
};
|
|
231
250
|
export type Checkbox = BaseElementModel & {
|
|
232
251
|
type: 'checkbox';
|
|
233
252
|
label?: string;
|
|
@@ -254,7 +273,6 @@ declare module 'bc-deeplib/base/elements_typings' {
|
|
|
254
273
|
type: 'custom';
|
|
255
274
|
htmlOptions: HTMLOptions<keyof HTMLElementTagNameMap>;
|
|
256
275
|
};
|
|
257
|
-
export {};
|
|
258
276
|
|
|
259
277
|
}
|
|
260
278
|
declare module 'bc-deeplib/base/initialization' {
|
|
@@ -300,6 +318,11 @@ declare module 'bc-deeplib/base/initialization' {
|
|
|
300
318
|
* Initialized by `initMod()` and mod data loaded by `init()`.
|
|
301
319
|
*/
|
|
302
320
|
export let modStorage: ModStorage;
|
|
321
|
+
/**
|
|
322
|
+
* Global Mod SDK manager.
|
|
323
|
+
* Initialized by `initMod()`.
|
|
324
|
+
*/
|
|
325
|
+
export let sdk: ModSdkManager;
|
|
303
326
|
/**
|
|
304
327
|
* Entry point for initializing a mod. Handles:
|
|
305
328
|
* - Setting up the Mod SDK
|
|
@@ -307,9 +330,7 @@ declare module 'bc-deeplib/base/initialization' {
|
|
|
307
330
|
* - Injecting required styles
|
|
308
331
|
* - Delaying initialization until login (if necessary)
|
|
309
332
|
*/
|
|
310
|
-
export function initMod(options: InitOptions):
|
|
311
|
-
sdk: ModSdkManager;
|
|
312
|
-
};
|
|
333
|
+
export function initMod(options: InitOptions): void;
|
|
313
334
|
/**
|
|
314
335
|
* Fully initializes the mod after login.
|
|
315
336
|
* Handles:
|
|
@@ -415,6 +436,7 @@ declare module 'bc-deeplib/deeplib' {
|
|
|
415
436
|
export * from 'bc-deeplib/utilities/sdk';
|
|
416
437
|
export * from 'bc-deeplib/utilities/style';
|
|
417
438
|
export * from 'bc-deeplib/utilities/translation';
|
|
439
|
+
export * from 'bc-deeplib/utilities/event_channel';
|
|
418
440
|
|
|
419
441
|
}
|
|
420
442
|
declare module 'bc-deeplib/migrators/base_migrator' {
|
|
@@ -423,13 +445,13 @@ declare module 'bc-deeplib/migrators/base_migrator' {
|
|
|
423
445
|
*
|
|
424
446
|
* A migrator is responsible for upgrading or transforming stored data
|
|
425
447
|
* when the mod version changes. Each migrator targets a specific version
|
|
426
|
-
* and executes its {@link
|
|
448
|
+
* and executes its {@link migrate} method once when needed.
|
|
427
449
|
*
|
|
428
450
|
* @remarks
|
|
429
451
|
* To create a new migrator:
|
|
430
452
|
* 1. Extend `BaseMigrator`.
|
|
431
|
-
* 2. Implement the {@link
|
|
432
|
-
* 3. Implement {@link
|
|
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).
|
|
433
455
|
*/
|
|
434
456
|
export abstract class BaseMigrator {
|
|
435
457
|
/**
|
|
@@ -439,17 +461,17 @@ declare module 'bc-deeplib/migrators/base_migrator' {
|
|
|
439
461
|
* - This should exactly match the version format used by the mod
|
|
440
462
|
* - Used by the migration system to determine if this migration should be executed.
|
|
441
463
|
*/
|
|
442
|
-
abstract get
|
|
464
|
+
abstract get migrationVersion(): string;
|
|
443
465
|
/**
|
|
444
466
|
* Executes the migration logic for this version.
|
|
445
467
|
*
|
|
446
468
|
* @remarks
|
|
447
|
-
* - Called once when upgrading from a version earlier than {@link
|
|
469
|
+
* - Called once when upgrading from a version earlier than {@link migrationVersion}.
|
|
448
470
|
* - Should handle any necessary data transformations, cleanup, or initialization
|
|
449
471
|
* to bring the mod's state up to date with the new version.
|
|
450
472
|
* - Must be idempotent — running it multiple times should not cause data corruption.
|
|
451
473
|
*/
|
|
452
|
-
abstract
|
|
474
|
+
abstract migrate(): void;
|
|
453
475
|
}
|
|
454
476
|
|
|
455
477
|
}
|
|
@@ -478,22 +500,26 @@ declare module 'bc-deeplib/models/settings' {
|
|
|
478
500
|
declare module 'bc-deeplib/modules/gui' {
|
|
479
501
|
import { BaseModule, BaseSubscreen, MainMenu } from 'bc-deeplib/deeplib';
|
|
480
502
|
/** Options for configuring a mod's main button in the extensions menu. */
|
|
481
|
-
type
|
|
503
|
+
type GuiOptions = {
|
|
482
504
|
/**
|
|
483
505
|
* Unique identifier for the mod's settings button.
|
|
484
506
|
* Used internally by the preference system to track the button.
|
|
485
507
|
*/
|
|
486
|
-
|
|
508
|
+
identifier: string;
|
|
487
509
|
/**
|
|
488
510
|
* The label displayed on the settings button.
|
|
489
511
|
* Can be a string or a function that returns a string dynamically.
|
|
490
512
|
*/
|
|
491
|
-
|
|
513
|
+
buttonText: string | (() => string);
|
|
492
514
|
/**
|
|
493
515
|
* The path to or Base64 data of the icon for the settings button.
|
|
494
516
|
* Can be a string or a function that returns a string dynamically.
|
|
495
517
|
*/
|
|
496
|
-
|
|
518
|
+
image: string | (() => string);
|
|
519
|
+
/**
|
|
520
|
+
* The main menu screen for the mod.
|
|
521
|
+
*/
|
|
522
|
+
mainMenu?: typeof MainMenu;
|
|
497
523
|
};
|
|
498
524
|
/**
|
|
499
525
|
* Central mod GUI controller that manages all subscreens.
|
|
@@ -510,29 +536,18 @@ declare module 'bc-deeplib/modules/gui' {
|
|
|
510
536
|
private _subscreens;
|
|
511
537
|
/** The mod's main menu screen. */
|
|
512
538
|
private _mainMenu;
|
|
513
|
-
/** The currently active subscreen, or `null` if none is active. */
|
|
514
|
-
private _currentSubscreen;
|
|
515
539
|
/** Options defining how the mod's settings button is displayed and behaves. */
|
|
516
540
|
private _modButtonOptions;
|
|
517
541
|
/** Returns all registered subscreens. */
|
|
518
542
|
get subscreens(): BaseSubscreen[];
|
|
519
543
|
/** Returns the main menu subscreen instance. */
|
|
520
544
|
get mainMenu(): MainMenu;
|
|
521
|
-
/** Returns the currently active subscreen. */
|
|
522
|
-
get currentSubscreen(): BaseSubscreen | null;
|
|
523
|
-
/**
|
|
524
|
-
* Sets the current subscreen.
|
|
525
|
-
* Accepts either a `BaseSubscreen` instance or the `name` of a subscreen.
|
|
526
|
-
*
|
|
527
|
-
* @throws If a string is provided but no subscreen with that name exists.
|
|
528
|
-
*/
|
|
529
|
-
set currentSubscreen(subscreen: BaseSubscreen | string | null);
|
|
530
545
|
/**
|
|
531
546
|
* Creates the GUI instance and initializes the main menu.
|
|
532
547
|
*
|
|
533
548
|
* @throws If another `GUI` instance already exists.
|
|
534
549
|
*/
|
|
535
|
-
constructor(
|
|
550
|
+
constructor(guiOptions?: GuiOptions | null);
|
|
536
551
|
/**
|
|
537
552
|
* Loads the GUI and registers the mod's settings button in the extensions menu.
|
|
538
553
|
*
|
|
@@ -547,6 +562,13 @@ declare module 'bc-deeplib/modules/gui' {
|
|
|
547
562
|
}
|
|
548
563
|
declare module 'bc-deeplib/modules/version' {
|
|
549
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
|
+
};
|
|
550
572
|
/**
|
|
551
573
|
* Handles version tracking, new version detection, and version-based migrations
|
|
552
574
|
* for the mod. Also manages displaying a "new version" message to players and
|
|
@@ -562,11 +584,20 @@ declare module 'bc-deeplib/modules/version' {
|
|
|
562
584
|
/** Whether the current session is running a new version compared to stored data */
|
|
563
585
|
private static isItNewVersion;
|
|
564
586
|
/** The current mod version (retrieved from `ModSdkManager.ModInfo.version`) */
|
|
565
|
-
static
|
|
587
|
+
private static version;
|
|
566
588
|
/** Message to display when a new version is detected */
|
|
567
|
-
static
|
|
589
|
+
private static newVersionMessage;
|
|
568
590
|
/** List of registered migration handlers, sorted by version */
|
|
569
|
-
private static
|
|
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);
|
|
570
601
|
/**
|
|
571
602
|
* Initializes the module on load:
|
|
572
603
|
* - Stores the current mod version.
|
|
@@ -581,7 +612,7 @@ declare module 'bc-deeplib/modules/version' {
|
|
|
581
612
|
* - Updates stored version in player data.
|
|
582
613
|
* - Saves `modStorage`.
|
|
583
614
|
*/
|
|
584
|
-
static checkVersionUpdate
|
|
615
|
+
private static checkVersionUpdate;
|
|
585
616
|
/**
|
|
586
617
|
* Executes migrations for all registered migrators whose `MigrationVersion`
|
|
587
618
|
* is newer than the previously stored version.
|
|
@@ -592,8 +623,6 @@ declare module 'bc-deeplib/modules/version' {
|
|
|
592
623
|
* Migrators are sorted by their `MigrationVersion` in ascending order.
|
|
593
624
|
*/
|
|
594
625
|
static registerMigrator(migrator: BaseMigrator): void;
|
|
595
|
-
/** Sets the message that will be displayed when a new version is detected. */
|
|
596
|
-
static setNewVersionMessage(newVersionMessage: string): void;
|
|
597
626
|
/** Sends the currently configured "new version" message to the local player. */
|
|
598
627
|
static sendNewVersionMessage(): void;
|
|
599
628
|
/**
|
|
@@ -611,15 +640,15 @@ declare module 'bc-deeplib/modules/version' {
|
|
|
611
640
|
}
|
|
612
641
|
declare module 'bc-deeplib/screens/debug' {
|
|
613
642
|
import { SettingElement } from 'bc-deeplib/base/elements_typings';
|
|
614
|
-
import { BaseSubscreen } from 'bc-deeplib/deeplib';
|
|
643
|
+
import { BaseSubscreen, SubscreenOptions } from 'bc-deeplib/deeplib';
|
|
615
644
|
export class GuiDebug extends BaseSubscreen {
|
|
616
|
-
|
|
645
|
+
protected static subscreenOptions: SubscreenOptions;
|
|
617
646
|
get pageStructure(): SettingElement[][];
|
|
618
647
|
}
|
|
619
648
|
|
|
620
649
|
}
|
|
621
650
|
declare module 'bc-deeplib/screens/import_export' {
|
|
622
|
-
import { BaseSubscreen } from 'bc-deeplib/deeplib';
|
|
651
|
+
import { BaseSubscreen, SubscreenOptions } from 'bc-deeplib/deeplib';
|
|
623
652
|
/**
|
|
624
653
|
* Configuration options for the {@link GuiImportExport} class.
|
|
625
654
|
*/
|
|
@@ -646,7 +675,7 @@ declare module 'bc-deeplib/screens/import_export' {
|
|
|
646
675
|
*/
|
|
647
676
|
export class GuiImportExport extends BaseSubscreen {
|
|
648
677
|
private importExportOptions;
|
|
649
|
-
|
|
678
|
+
static subscreenOptions: SubscreenOptions;
|
|
650
679
|
constructor(importExportOptions: ImportExportOptions);
|
|
651
680
|
load(): void;
|
|
652
681
|
resize(): void;
|
|
@@ -667,7 +696,7 @@ declare module 'bc-deeplib/screens/import_export' {
|
|
|
667
696
|
|
|
668
697
|
}
|
|
669
698
|
declare module 'bc-deeplib/screens/main_menu' {
|
|
670
|
-
import { BaseSubscreen, GUI } from 'bc-deeplib/deeplib';
|
|
699
|
+
import { BaseSubscreen, GUI, SubscreenOptions } from 'bc-deeplib/deeplib';
|
|
671
700
|
import { GuiImportExport } from 'bc-deeplib/screens/import_export';
|
|
672
701
|
/**
|
|
673
702
|
* Configuration options for the main menu.
|
|
@@ -694,11 +723,15 @@ declare module 'bc-deeplib/screens/main_menu' {
|
|
|
694
723
|
* Provides tools to import or export data to or from the mod.
|
|
695
724
|
*/
|
|
696
725
|
importExportSubscreen?: GuiImportExport;
|
|
726
|
+
/**
|
|
727
|
+
* Optional boolean flag to enable the mod storage fullness indicator.
|
|
728
|
+
*/
|
|
729
|
+
storageFullnessIndicator?: boolean;
|
|
697
730
|
};
|
|
698
731
|
export class MainMenu extends BaseSubscreen {
|
|
699
732
|
subscreens: BaseSubscreen[];
|
|
700
733
|
private static options;
|
|
701
|
-
|
|
734
|
+
protected static subscreenOptions: SubscreenOptions;
|
|
702
735
|
constructor(module: GUI);
|
|
703
736
|
load(): void;
|
|
704
737
|
run(): void;
|
|
@@ -739,6 +772,10 @@ declare module 'bc-deeplib/utilities/common' {
|
|
|
739
772
|
export function hasGetter<T extends object>(obj: T, prop: keyof T | string): boolean;
|
|
740
773
|
/** Checks if the given property has a setter defined on the object or its prototype chain. */
|
|
741
774
|
export function hasSetter<T extends object>(obj: T, prop: keyof T | string): boolean;
|
|
775
|
+
/**
|
|
776
|
+
* Converts bytes to kilobytes.
|
|
777
|
+
*/
|
|
778
|
+
export const byteToKB: (nByte: number) => number;
|
|
742
779
|
|
|
743
780
|
}
|
|
744
781
|
declare module 'bc-deeplib/utilities/data' {
|
|
@@ -768,6 +805,7 @@ declare module 'bc-deeplib/utilities/data' {
|
|
|
768
805
|
save(): void;
|
|
769
806
|
static dataDecompress<T = object>(string: string): T | null;
|
|
770
807
|
static dataCompress(object: object): string;
|
|
808
|
+
static measureSize(data: unknown): number;
|
|
771
809
|
}
|
|
772
810
|
|
|
773
811
|
}
|
|
@@ -832,7 +870,7 @@ declare module 'bc-deeplib/utilities/elements/elements' {
|
|
|
832
870
|
};
|
|
833
871
|
export type ModalOptions<T extends string = string> = {
|
|
834
872
|
/** Content or DOM node displayed in the modal header. */
|
|
835
|
-
prompt:
|
|
873
|
+
prompt: ElementButton.StaticNode;
|
|
836
874
|
/** Optional input configuration. */
|
|
837
875
|
input?: ModalInputOptions;
|
|
838
876
|
/** Buttons to display in the modal. */
|
|
@@ -841,6 +879,10 @@ declare module 'bc-deeplib/utilities/elements/elements' {
|
|
|
841
879
|
closeOnBackdrop?: boolean;
|
|
842
880
|
/** Auto-close timeout in milliseconds. */
|
|
843
881
|
timeoutMs?: number;
|
|
882
|
+
/** Action sent when Escape key is pressed. */
|
|
883
|
+
escapeAction?: T;
|
|
884
|
+
/** Action sent when Enter key is pressed. */
|
|
885
|
+
enterAction?: T;
|
|
844
886
|
};
|
|
845
887
|
/**
|
|
846
888
|
* Modal dialog implementation with queuing, buttons, optional input, and focus trapping.
|
|
@@ -864,17 +906,17 @@ declare module 'bc-deeplib/utilities/elements/elements' {
|
|
|
864
906
|
/**
|
|
865
907
|
* Shows a simple alert modal with a single "OK" button.
|
|
866
908
|
*/
|
|
867
|
-
static alert(msg:
|
|
909
|
+
static alert(msg: ElementButton.StaticNode, timeoutMs?: number): Promise<void>;
|
|
868
910
|
/**
|
|
869
911
|
* Shows a confirmation modal with "Cancel" and "OK" buttons.
|
|
870
912
|
* Returns true if "OK" is clicked.
|
|
871
913
|
*/
|
|
872
|
-
static confirm(msg:
|
|
914
|
+
static confirm(msg: ElementButton.StaticNode): Promise<boolean>;
|
|
873
915
|
/**
|
|
874
916
|
* Shows a prompt modal with an input field and "Submit"/"Cancel" buttons.
|
|
875
917
|
* Returns the input value if submitted, otherwise null.
|
|
876
918
|
*/
|
|
877
|
-
static prompt(msg:
|
|
919
|
+
static prompt(msg: ElementButton.StaticNode, defaultValue?: string): Promise<string | null>;
|
|
878
920
|
/** Creates the input element for the modal, applying configuration and validation. */
|
|
879
921
|
private renderInput;
|
|
880
922
|
/** Creates modal action buttons from configuration. */
|
|
@@ -944,31 +986,64 @@ declare module 'bc-deeplib/utilities/elements/helpers' {
|
|
|
944
986
|
}
|
|
945
987
|
declare module 'bc-deeplib/utilities/elements/layout' {
|
|
946
988
|
export const layout: {
|
|
947
|
-
createSubscreen: typeof elementCreateSubscreenDiv;
|
|
948
989
|
getSubscreen: typeof elementGetSubscreenDiv;
|
|
949
990
|
appendToSubscreen: typeof elementAppendToSubscreenDiv;
|
|
950
991
|
removeSubscreen: typeof elementRemoveSubscreenDiv;
|
|
951
|
-
createSettingsDiv: typeof elementCreateSettingsDiv;
|
|
952
992
|
getSettingsDiv: typeof elementGetSettingsDiv;
|
|
953
993
|
appendToSettingsDiv: typeof elementAppendToSettingsDiv;
|
|
954
994
|
removeSettingsDiv: typeof elementRemoveSettingsDiv;
|
|
955
|
-
createMiscDiv: typeof elementCreateMiscDiv;
|
|
956
995
|
getMiscDiv: typeof elementGetMiscDiv;
|
|
957
996
|
appendToMiscDiv: typeof elementAppendToMiscDiv;
|
|
958
997
|
removeMiscDiv: typeof elementRemoveMiscDiv;
|
|
959
998
|
};
|
|
960
|
-
function
|
|
961
|
-
function
|
|
962
|
-
function
|
|
963
|
-
function
|
|
964
|
-
function
|
|
965
|
-
function
|
|
966
|
-
function
|
|
967
|
-
function
|
|
968
|
-
function
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
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;
|
|
1008
|
+
export {};
|
|
1009
|
+
|
|
1010
|
+
}
|
|
1011
|
+
declare module 'bc-deeplib/utilities/event_channel' {
|
|
1012
|
+
type DeepLibMessageDictionaryEntry<Type extends string, Data> = {
|
|
1013
|
+
type: Type;
|
|
1014
|
+
data: Data;
|
|
1015
|
+
};
|
|
1016
|
+
type Listener<Payload> = (data: Payload, sender: Character) => void;
|
|
1017
|
+
export interface UnverifiedMessage extends ServerChatRoomMessageBase {
|
|
1018
|
+
Target?: number;
|
|
1019
|
+
Content: ServerChatRoomMessageContentType;
|
|
1020
|
+
Type: ServerChatRoomMessageType;
|
|
1021
|
+
Dictionary?: {
|
|
1022
|
+
type: string;
|
|
1023
|
+
data?: any;
|
|
1024
|
+
}[];
|
|
1025
|
+
Timeout?: number;
|
|
1026
|
+
}
|
|
1027
|
+
export interface EventChannelMessage<TEvents extends Record<string, unknown> = Record<string, unknown>, TEvent extends keyof TEvents & string = keyof TEvents & string> extends ServerChatRoomMessageBase {
|
|
1028
|
+
Target?: number;
|
|
1029
|
+
Content: string;
|
|
1030
|
+
Type: 'Hidden';
|
|
1031
|
+
Dictionary: [
|
|
1032
|
+
DeepLibMessageDictionaryEntry<TEvent, TEvents[TEvent]>
|
|
1033
|
+
];
|
|
1034
|
+
Timeout?: number;
|
|
1035
|
+
Sender: number;
|
|
1036
|
+
}
|
|
1037
|
+
export class EventChannel<TEvents extends Record<string, unknown>, TChannelName extends string> {
|
|
1038
|
+
private channelName;
|
|
1039
|
+
private listeners;
|
|
1040
|
+
constructor(channelName: TChannelName);
|
|
1041
|
+
unload(): void;
|
|
1042
|
+
sendEvent<K extends keyof TEvents & string>(type: K, data: TEvents[K], target?: number | null): void;
|
|
1043
|
+
registerListener<K extends keyof TEvents & string>(event: K, listener: Listener<TEvents[K]>): () => void;
|
|
1044
|
+
unregisterListener<K extends keyof TEvents & string>(event: K, listener: Listener<TEvents[K]>): void;
|
|
1045
|
+
private isChannelMessage;
|
|
1046
|
+
}
|
|
972
1047
|
export {};
|
|
973
1048
|
|
|
974
1049
|
}
|