bc-deeplib 2.4.0 → 2.4.2
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 +4 -1
- package/dist/deeplib.js +15 -16
- package/dist/deeplib.js.map +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/deeplib.d.ts
CHANGED
|
@@ -767,7 +767,10 @@ declare module 'bc-deeplib/screens/main_menu' {
|
|
|
767
767
|
}
|
|
768
768
|
declare module 'bc-deeplib/utilities/common' {
|
|
769
769
|
export type DeepMergeOptions = {
|
|
770
|
+
/** Concatenate arrays instead of replacing them. */
|
|
770
771
|
concatArrays?: boolean;
|
|
772
|
+
/** Only merge matching keys. */
|
|
773
|
+
matchingOnly?: boolean;
|
|
771
774
|
};
|
|
772
775
|
/**
|
|
773
776
|
* Deeply merges two values into a new value.
|
|
@@ -852,7 +855,7 @@ declare module 'bc-deeplib/utilities/elements/elements' {
|
|
|
852
855
|
function elementCreateCustom(options: Omit<Custom, 'type'>): HTMLElement;
|
|
853
856
|
function elementCreateInput(options: Input): HTMLElement;
|
|
854
857
|
function elementCreateLabel(options: Omit<Label, 'type'>): HTMLElement;
|
|
855
|
-
function elementCreateDropdown(options: Omit<Dropdown, 'type'>):
|
|
858
|
+
function elementCreateDropdown(options: Omit<Dropdown, 'type'>): HTMLLabelElement | HTMLDivElement;
|
|
856
859
|
function elementCreateTooltip(): HTMLDivElement;
|
|
857
860
|
function elementGetTooltip(): HTMLElement | undefined;
|
|
858
861
|
function elementSetTooltip(text: string): boolean;
|
package/dist/deeplib.js
CHANGED
|
@@ -230,9 +230,9 @@ var BaseModule = class {
|
|
|
230
230
|
if (!this.settingsStorage) return {};
|
|
231
231
|
if (!modStorage.playerStorage) {
|
|
232
232
|
Player[modName] = {};
|
|
233
|
-
this.registerDefaultSettings();
|
|
233
|
+
this.registerDefaultSettings(modStorage.playerStorage);
|
|
234
234
|
} else if (!modStorage.playerStorage[this.settingsStorage]) {
|
|
235
|
-
this.registerDefaultSettings();
|
|
235
|
+
this.registerDefaultSettings(modStorage.playerStorage);
|
|
236
236
|
}
|
|
237
237
|
return modStorage.playerStorage[this.settingsStorage];
|
|
238
238
|
}
|
|
@@ -246,9 +246,9 @@ var BaseModule = class {
|
|
|
246
246
|
if (!this.settingsStorage) return;
|
|
247
247
|
if (!storage.playerStorage) {
|
|
248
248
|
Player[modName] = {};
|
|
249
|
-
this.registerDefaultSettings();
|
|
249
|
+
this.registerDefaultSettings(modStorage.playerStorage);
|
|
250
250
|
} else if (!storage.playerStorage[this.settingsStorage]) {
|
|
251
|
-
this.registerDefaultSettings();
|
|
251
|
+
this.registerDefaultSettings(modStorage.playerStorage);
|
|
252
252
|
}
|
|
253
253
|
storage.playerStorage[this.settingsStorage] = value;
|
|
254
254
|
}
|
|
@@ -266,12 +266,12 @@ var BaseModule = class {
|
|
|
266
266
|
* If some settings already exist, they will be merged with defaults.
|
|
267
267
|
* Existing values will NOT be overwritten.
|
|
268
268
|
*/
|
|
269
|
-
registerDefaultSettings() {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
269
|
+
registerDefaultSettings(target) {
|
|
270
|
+
const storage = this.settingsStorage;
|
|
271
|
+
const defaults = this.defaultSettings;
|
|
272
|
+
if (!storage || !defaults) return;
|
|
273
|
+
if (Object.entries(this.defaultSettings).length === 0) return;
|
|
274
|
+
target[storage] = deepMerge(this.defaultSettings, target[storage], { concatArrays: false, matchingOnly: true });
|
|
275
275
|
}
|
|
276
276
|
/**
|
|
277
277
|
* Provides default settings for this module.
|
|
@@ -1011,7 +1011,7 @@ function initModules(modulesToRegister) {
|
|
|
1011
1011
|
module.run();
|
|
1012
1012
|
}
|
|
1013
1013
|
for (const module of modules()) {
|
|
1014
|
-
module.registerDefaultSettings();
|
|
1014
|
+
module.registerDefaultSettings(modStorage.playerStorage);
|
|
1015
1015
|
}
|
|
1016
1016
|
logger.debug("Modules Loaded.");
|
|
1017
1017
|
return true;
|
|
@@ -1439,7 +1439,7 @@ function isPlainObject(value) {
|
|
|
1439
1439
|
return value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype && !Array.isArray(value);
|
|
1440
1440
|
}
|
|
1441
1441
|
__name(isPlainObject, "isPlainObject");
|
|
1442
|
-
function deepMerge(target, source, options = { concatArrays: true }) {
|
|
1442
|
+
function deepMerge(target, source, options = { concatArrays: true, matchingOnly: false }) {
|
|
1443
1443
|
if (target === void 0) return source;
|
|
1444
1444
|
if (source === void 0) return target;
|
|
1445
1445
|
if (Array.isArray(target) && Array.isArray(source) && options.concatArrays) {
|
|
@@ -1447,10 +1447,9 @@ function deepMerge(target, source, options = { concatArrays: true }) {
|
|
|
1447
1447
|
}
|
|
1448
1448
|
if (isPlainObject(target) && isPlainObject(source)) {
|
|
1449
1449
|
const result = { ...target };
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
}
|
|
1450
|
+
const keys = options.matchingOnly ? Object.keys(source).filter((k) => k in target) : Object.keys(source);
|
|
1451
|
+
for (const key of keys) {
|
|
1452
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
1454
1453
|
result[key] = key in target ? deepMerge(target[key], source[key], options) : source[key];
|
|
1455
1454
|
}
|
|
1456
1455
|
return result;
|