@sv443-network/userutils 10.0.3 → 10.0.5
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/CHANGELOG.md +12 -0
- package/README.md +5 -19
- package/dist/UserUtils.cjs +16 -16
- package/dist/UserUtils.mjs +16 -16
- package/dist/UserUtils.umd.js +23 -23
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @sv443-network/userutils
|
|
2
2
|
|
|
3
|
+
## 10.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c63a9b: Added UMD bundle explicitly made for userscript usage (at `dist/UserUtils.user.js`).
|
|
8
|
+
|
|
9
|
+
## 10.0.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 13159d8: Updated CoreUtils to fix underlying encoding and decoding inconsistencies.
|
|
14
|
+
|
|
3
15
|
## 10.0.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -102,7 +102,6 @@ View the documentation of previous major versions:
|
|
|
102
102
|
- 🟧 [`class DataStore`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-datastore) - The main class for the data store
|
|
103
103
|
- 🔷 [`type DataStoreOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datastoreoptions) - Options for the data store
|
|
104
104
|
- 🔷 [`type DataMigrationsDict`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datamigrationsdict) - Dictionary of data migration functions
|
|
105
|
-
- 🔷 [`type DataStoreData`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datastoredata) - The type of the serializable data
|
|
106
105
|
- 🟧 [`class DataStoreSerializer`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-datastoreserializer) - Serializes and deserializes data for multiple DataStore instances
|
|
107
106
|
- 🔷 [`type DataStoreSerializerOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datastoreserializeroptions) - Options for the DataStoreSerializer
|
|
108
107
|
- 🔷 [`type LoadStoresDataResult`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-loadstoresdataresult) - Result of calling [`loadStoresData()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#datastoreserializer-loadstoresdata)
|
|
@@ -164,19 +163,6 @@ View the documentation of previous major versions:
|
|
|
164
163
|
- 🟣 [`function joinArrayReadable()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-joinarrayreadable) - Joins the given array into a string, using the given separators and last separator
|
|
165
164
|
- 🟣 [`function secsToTimeStr()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-secstotimestr) - Turns the given number of seconds into a string in the format `(hh:)mm:ss` with intelligent zero-padding
|
|
166
165
|
- 🟣 [`function truncStr()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-truncstr) - Truncates the given string to the given length
|
|
167
|
-
<!-- - *[**TieredCache:**](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#tieredcache)
|
|
168
|
-
- 🟧 *[`class TieredCache`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-tieredcache) - A multi-tier cache that uses multiple storage engines with different expiration times
|
|
169
|
-
- 🔷 *[`type TieredCacheOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-tieredcacheoptions) - Options for the [`TieredCache` class](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-tieredcache)
|
|
170
|
-
- 🔷 *[`type TieredCachePropagateTierOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-tieredcachestaleoptions) - Entry propagation options for each tier
|
|
171
|
-
- 🔷 *[`type TieredCacheStaleOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-tieredcachepropagatetieroptions) - Entry staleness options for each tier
|
|
172
|
-
- 🔷 *[`type TieredCacheTierOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-tieredcachetieroptions) - Options for each tier of a [`TieredCache` instance](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-tieredcache)
|
|
173
|
-
- *[**Translate:**](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#translate)
|
|
174
|
-
- 🟧 *[`class Translate`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-translate) - JSON-based translation system supporting transformation hooks, value injection, nested objects, etc.
|
|
175
|
-
- 🔷 *[`type TransformFn`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-transformfn) - The type of the transformation hook functions
|
|
176
|
-
- 🔷 *[`type TransformFnProps`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-transformfnprops) - The properties passed to the transformation functions
|
|
177
|
-
- 🔷 *[`type TranslateOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-translateoptions) - The options for the [`Translate` class](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-translate)
|
|
178
|
-
- 🔷 *[`type TrKeys`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-trkeys) - Generic type that gives you a union of keys from the passed [`TrObject` object](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-trobject)
|
|
179
|
-
- 🔷 *[`type TrObject`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-trobject) - The translation object for a specific language -->
|
|
180
166
|
- [**Misc. Types:**](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#types)
|
|
181
167
|
- 🔷 [`type LooseUnion`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-looseunion) - A union type that allows for autocomplete suggestions as well as substitutions of the same type
|
|
182
168
|
- 🔷 [`type ListLike`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-listlike) - Any value with a quantifiable `length`, `count` or `size` property
|
|
@@ -229,8 +215,8 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
229
215
|
|
|
230
216
|
Versioned (recommended):
|
|
231
217
|
```
|
|
232
|
-
// @require https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/
|
|
233
|
-
// @require https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/
|
|
218
|
+
// @require https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/UserUtils.user.js
|
|
219
|
+
// @require https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/UserUtils.user.js
|
|
234
220
|
```
|
|
235
221
|
Non-versioned (not recommended because it auto-updates):
|
|
236
222
|
```
|
|
@@ -240,12 +226,12 @@ Shameless plug: I made a [template for userscripts in TypeScript](https://github
|
|
|
240
226
|
|
|
241
227
|
- If you are using this library in a generic DOM environment without access to the GreaseMonkey API, either download the latest release from the [releases page](https://github.com/Sv443-Network/UserUtils/releases) to include in your project or add one of the following tags to the <head>:
|
|
242
228
|
```html
|
|
243
|
-
<script src="https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/
|
|
244
|
-
<script src="https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/
|
|
229
|
+
<script src="https://cdn.jsdelivr.net/npm/@sv443-network/userutils@INSERT_VERSION/dist/UserUtils.umd.js"></script>
|
|
230
|
+
<script src="https://unpkg.com/@sv443-network/userutils@INSERT_VERSION/dist/UserUtils.umd.js"></script>
|
|
245
231
|
```
|
|
246
232
|
|
|
247
233
|
> [!NOTE]
|
|
248
|
-
> In order for your script not to break on a major library update, use one the versioned URLs above after replacing `INSERT_VERSION` with the desired version (e.g. `
|
|
234
|
+
> In order for your script not to break on a major library update, use one the versioned URLs above after replacing `INSERT_VERSION` with the desired version (e.g. `10.0.4`) or the versioned URL that's shown [at the top of the GreasyFork page.](https://greasyfork.org/scripts/472956-userutils)
|
|
249
235
|
|
|
250
236
|
<br>
|
|
251
237
|
|
package/dist/UserUtils.cjs
CHANGED
|
@@ -114,7 +114,7 @@ __export(lib_exports, {
|
|
|
114
114
|
});
|
|
115
115
|
module.exports = __toCommonJS(lib_exports);
|
|
116
116
|
|
|
117
|
-
// node_modules/.pnpm/@sv443-network+coreutils@3.0.
|
|
117
|
+
// node_modules/.pnpm/@sv443-network+coreutils@3.0.4/node_modules/@sv443-network/coreutils/dist/CoreUtils.mjs
|
|
118
118
|
function bitSetHas(bitSet, checkVal) {
|
|
119
119
|
return (bitSet & checkVal) === checkVal;
|
|
120
120
|
}
|
|
@@ -598,7 +598,6 @@ var DataStore = class {
|
|
|
598
598
|
* @param opts The options for this DataStore instance
|
|
599
599
|
*/
|
|
600
600
|
constructor(opts) {
|
|
601
|
-
var _a;
|
|
602
601
|
this.id = opts.id;
|
|
603
602
|
this.formatVersion = opts.formatVersion;
|
|
604
603
|
this.defaultData = opts.defaultData;
|
|
@@ -607,16 +606,9 @@ var DataStore = class {
|
|
|
607
606
|
this.migrations = opts.migrations;
|
|
608
607
|
if (opts.migrateIds)
|
|
609
608
|
this.migrateIds = Array.isArray(opts.migrateIds) ? opts.migrateIds : [opts.migrateIds];
|
|
610
|
-
this.encodeData = opts.encodeData;
|
|
611
|
-
this.decodeData = opts.decodeData;
|
|
612
609
|
this.engine = typeof opts.engine === "function" ? opts.engine() : opts.engine;
|
|
613
610
|
this.options = opts;
|
|
614
|
-
if (
|
|
615
|
-
this.compressionFormat = opts.compressionFormat = ((_a = opts.encodeData) == null ? void 0 : _a[0]) ?? "deflate-raw";
|
|
616
|
-
if (typeof opts.compressionFormat === "string") {
|
|
617
|
-
this.encodeData = [opts.compressionFormat, async (data) => await compress(data, opts.compressionFormat, "string")];
|
|
618
|
-
this.decodeData = [opts.compressionFormat, async (data) => await decompress(data, opts.compressionFormat, "string")];
|
|
619
|
-
} else if ("encodeData" in opts && "decodeData" in opts && Array.isArray(opts.encodeData) && Array.isArray(opts.decodeData)) {
|
|
611
|
+
if ("encodeData" in opts && "decodeData" in opts && Array.isArray(opts.encodeData) && Array.isArray(opts.decodeData)) {
|
|
620
612
|
this.encodeData = [opts.encodeData[0], opts.encodeData[1]];
|
|
621
613
|
this.decodeData = [opts.decodeData[0], opts.decodeData[1]];
|
|
622
614
|
this.compressionFormat = opts.encodeData[0] ?? null;
|
|
@@ -624,9 +616,17 @@ var DataStore = class {
|
|
|
624
616
|
this.encodeData = void 0;
|
|
625
617
|
this.decodeData = void 0;
|
|
626
618
|
this.compressionFormat = null;
|
|
627
|
-
} else
|
|
628
|
-
|
|
629
|
-
|
|
619
|
+
} else {
|
|
620
|
+
const fmt = typeof opts.compressionFormat === "string" ? opts.compressionFormat : "deflate-raw";
|
|
621
|
+
this.compressionFormat = fmt;
|
|
622
|
+
this.encodeData = [fmt, async (data) => await compress(data, fmt, "string")];
|
|
623
|
+
this.decodeData = [fmt, async (data) => await decompress(data, fmt, "string")];
|
|
624
|
+
}
|
|
625
|
+
this.engine.setDataStoreOptions({
|
|
626
|
+
id: this.id,
|
|
627
|
+
encodeData: this.encodeData,
|
|
628
|
+
decodeData: this.decodeData
|
|
629
|
+
});
|
|
630
630
|
}
|
|
631
631
|
//#region loadData
|
|
632
632
|
/**
|
|
@@ -674,7 +674,7 @@ var DataStore = class {
|
|
|
674
674
|
}
|
|
675
675
|
const storedData = storedDataRaw ?? JSON.stringify(this.defaultData);
|
|
676
676
|
const encodingFmt = String(await this.engine.getValue(`__ds-${this.id}-enf`, null));
|
|
677
|
-
const isEncoded = encodingFmt !== "null" && encodingFmt !== "false";
|
|
677
|
+
const isEncoded = encodingFmt !== "null" && encodingFmt !== "false" && encodingFmt !== "0" && encodingFmt !== "" && encodingFmt !== null;
|
|
678
678
|
let saveData = false;
|
|
679
679
|
if (isNaN(storedFmtVer)) {
|
|
680
680
|
await this.engine.setValue(`__ds-${this.id}-ver`, storedFmtVer = this.formatVersion);
|
|
@@ -781,7 +781,7 @@ var DataStore = class {
|
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
783
|
await Promise.allSettled([
|
|
784
|
-
this.engine.setValue(`__ds-${this.id}-dat`, await this.engine.serializeData(newData)),
|
|
784
|
+
this.engine.setValue(`__ds-${this.id}-dat`, await this.engine.serializeData(newData, this.encodingEnabled())),
|
|
785
785
|
this.engine.setValue(`__ds-${this.id}-ver`, lastFmtVer),
|
|
786
786
|
this.engine.setValue(`__ds-${this.id}-enf`, this.compressionFormat)
|
|
787
787
|
]);
|
|
@@ -810,7 +810,7 @@ var DataStore = class {
|
|
|
810
810
|
return;
|
|
811
811
|
const parsed = await this.engine.deserializeData(data, isEncoded);
|
|
812
812
|
await Promise.allSettled([
|
|
813
|
-
this.engine.setValue(`__ds-${this.id}-dat`, await this.engine.serializeData(parsed)),
|
|
813
|
+
this.engine.setValue(`__ds-${this.id}-dat`, await this.engine.serializeData(parsed, this.encodingEnabled())),
|
|
814
814
|
this.engine.setValue(`__ds-${this.id}-ver`, fmtVer),
|
|
815
815
|
this.engine.setValue(`__ds-${this.id}-enf`, this.compressionFormat),
|
|
816
816
|
this.engine.deleteValue(`__ds-${id}-dat`),
|
package/dist/UserUtils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/@sv443-network+coreutils@3.0.
|
|
1
|
+
// node_modules/.pnpm/@sv443-network+coreutils@3.0.4/node_modules/@sv443-network/coreutils/dist/CoreUtils.mjs
|
|
2
2
|
function bitSetHas(bitSet, checkVal) {
|
|
3
3
|
return (bitSet & checkVal) === checkVal;
|
|
4
4
|
}
|
|
@@ -482,7 +482,6 @@ var DataStore = class {
|
|
|
482
482
|
* @param opts The options for this DataStore instance
|
|
483
483
|
*/
|
|
484
484
|
constructor(opts) {
|
|
485
|
-
var _a;
|
|
486
485
|
this.id = opts.id;
|
|
487
486
|
this.formatVersion = opts.formatVersion;
|
|
488
487
|
this.defaultData = opts.defaultData;
|
|
@@ -491,16 +490,9 @@ var DataStore = class {
|
|
|
491
490
|
this.migrations = opts.migrations;
|
|
492
491
|
if (opts.migrateIds)
|
|
493
492
|
this.migrateIds = Array.isArray(opts.migrateIds) ? opts.migrateIds : [opts.migrateIds];
|
|
494
|
-
this.encodeData = opts.encodeData;
|
|
495
|
-
this.decodeData = opts.decodeData;
|
|
496
493
|
this.engine = typeof opts.engine === "function" ? opts.engine() : opts.engine;
|
|
497
494
|
this.options = opts;
|
|
498
|
-
if (
|
|
499
|
-
this.compressionFormat = opts.compressionFormat = ((_a = opts.encodeData) == null ? void 0 : _a[0]) ?? "deflate-raw";
|
|
500
|
-
if (typeof opts.compressionFormat === "string") {
|
|
501
|
-
this.encodeData = [opts.compressionFormat, async (data) => await compress(data, opts.compressionFormat, "string")];
|
|
502
|
-
this.decodeData = [opts.compressionFormat, async (data) => await decompress(data, opts.compressionFormat, "string")];
|
|
503
|
-
} else if ("encodeData" in opts && "decodeData" in opts && Array.isArray(opts.encodeData) && Array.isArray(opts.decodeData)) {
|
|
495
|
+
if ("encodeData" in opts && "decodeData" in opts && Array.isArray(opts.encodeData) && Array.isArray(opts.decodeData)) {
|
|
504
496
|
this.encodeData = [opts.encodeData[0], opts.encodeData[1]];
|
|
505
497
|
this.decodeData = [opts.decodeData[0], opts.decodeData[1]];
|
|
506
498
|
this.compressionFormat = opts.encodeData[0] ?? null;
|
|
@@ -508,9 +500,17 @@ var DataStore = class {
|
|
|
508
500
|
this.encodeData = void 0;
|
|
509
501
|
this.decodeData = void 0;
|
|
510
502
|
this.compressionFormat = null;
|
|
511
|
-
} else
|
|
512
|
-
|
|
513
|
-
|
|
503
|
+
} else {
|
|
504
|
+
const fmt = typeof opts.compressionFormat === "string" ? opts.compressionFormat : "deflate-raw";
|
|
505
|
+
this.compressionFormat = fmt;
|
|
506
|
+
this.encodeData = [fmt, async (data) => await compress(data, fmt, "string")];
|
|
507
|
+
this.decodeData = [fmt, async (data) => await decompress(data, fmt, "string")];
|
|
508
|
+
}
|
|
509
|
+
this.engine.setDataStoreOptions({
|
|
510
|
+
id: this.id,
|
|
511
|
+
encodeData: this.encodeData,
|
|
512
|
+
decodeData: this.decodeData
|
|
513
|
+
});
|
|
514
514
|
}
|
|
515
515
|
//#region loadData
|
|
516
516
|
/**
|
|
@@ -558,7 +558,7 @@ var DataStore = class {
|
|
|
558
558
|
}
|
|
559
559
|
const storedData = storedDataRaw ?? JSON.stringify(this.defaultData);
|
|
560
560
|
const encodingFmt = String(await this.engine.getValue(`__ds-${this.id}-enf`, null));
|
|
561
|
-
const isEncoded = encodingFmt !== "null" && encodingFmt !== "false";
|
|
561
|
+
const isEncoded = encodingFmt !== "null" && encodingFmt !== "false" && encodingFmt !== "0" && encodingFmt !== "" && encodingFmt !== null;
|
|
562
562
|
let saveData = false;
|
|
563
563
|
if (isNaN(storedFmtVer)) {
|
|
564
564
|
await this.engine.setValue(`__ds-${this.id}-ver`, storedFmtVer = this.formatVersion);
|
|
@@ -665,7 +665,7 @@ var DataStore = class {
|
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
await Promise.allSettled([
|
|
668
|
-
this.engine.setValue(`__ds-${this.id}-dat`, await this.engine.serializeData(newData)),
|
|
668
|
+
this.engine.setValue(`__ds-${this.id}-dat`, await this.engine.serializeData(newData, this.encodingEnabled())),
|
|
669
669
|
this.engine.setValue(`__ds-${this.id}-ver`, lastFmtVer),
|
|
670
670
|
this.engine.setValue(`__ds-${this.id}-enf`, this.compressionFormat)
|
|
671
671
|
]);
|
|
@@ -694,7 +694,7 @@ var DataStore = class {
|
|
|
694
694
|
return;
|
|
695
695
|
const parsed = await this.engine.deserializeData(data, isEncoded);
|
|
696
696
|
await Promise.allSettled([
|
|
697
|
-
this.engine.setValue(`__ds-${this.id}-dat`, await this.engine.serializeData(parsed)),
|
|
697
|
+
this.engine.setValue(`__ds-${this.id}-dat`, await this.engine.serializeData(parsed, this.encodingEnabled())),
|
|
698
698
|
this.engine.setValue(`__ds-${this.id}-ver`, fmtVer),
|
|
699
699
|
this.engine.setValue(`__ds-${this.id}-enf`, this.compressionFormat),
|
|
700
700
|
this.engine.deleteValue(`__ds-${id}-dat`),
|
package/dist/UserUtils.umd.js
CHANGED
|
@@ -183,7 +183,7 @@ __export(lib_exports, {
|
|
|
183
183
|
});
|
|
184
184
|
module.exports = __toCommonJS(lib_exports);
|
|
185
185
|
|
|
186
|
-
// node_modules/.pnpm/@sv443-network+coreutils@3.0.
|
|
186
|
+
// node_modules/.pnpm/@sv443-network+coreutils@3.0.4/node_modules/@sv443-network/coreutils/dist/CoreUtils.mjs
|
|
187
187
|
function bitSetHas(bitSet, checkVal) {
|
|
188
188
|
return (bitSet & checkVal) === checkVal;
|
|
189
189
|
}
|
|
@@ -681,40 +681,40 @@ var DataStore = class {
|
|
|
681
681
|
__publicField(this, "cachedData");
|
|
682
682
|
__publicField(this, "migrations");
|
|
683
683
|
__publicField(this, "migrateIds", []);
|
|
684
|
-
var
|
|
685
|
-
var _a;
|
|
684
|
+
var _a, _b;
|
|
686
685
|
this.id = opts.id;
|
|
687
686
|
this.formatVersion = opts.formatVersion;
|
|
688
687
|
this.defaultData = opts.defaultData;
|
|
689
|
-
this.memoryCache = Boolean((
|
|
688
|
+
this.memoryCache = Boolean((_a = opts.memoryCache) != null ? _a : true);
|
|
690
689
|
this.cachedData = this.memoryCache ? opts.defaultData : {};
|
|
691
690
|
this.migrations = opts.migrations;
|
|
692
691
|
if (opts.migrateIds)
|
|
693
692
|
this.migrateIds = Array.isArray(opts.migrateIds) ? opts.migrateIds : [opts.migrateIds];
|
|
694
|
-
this.encodeData = opts.encodeData;
|
|
695
|
-
this.decodeData = opts.decodeData;
|
|
696
693
|
this.engine = typeof opts.engine === "function" ? opts.engine() : opts.engine;
|
|
697
694
|
this.options = opts;
|
|
698
|
-
if (
|
|
699
|
-
this.compressionFormat = opts.compressionFormat = (_b = (_a = opts.encodeData) == null ? void 0 : _a[0]) != null ? _b : "deflate-raw";
|
|
700
|
-
if (typeof opts.compressionFormat === "string") {
|
|
701
|
-
this.encodeData = [opts.compressionFormat, (data) => __async(this, null, function* () {
|
|
702
|
-
return yield compress(data, opts.compressionFormat, "string");
|
|
703
|
-
})];
|
|
704
|
-
this.decodeData = [opts.compressionFormat, (data) => __async(this, null, function* () {
|
|
705
|
-
return yield decompress(data, opts.compressionFormat, "string");
|
|
706
|
-
})];
|
|
707
|
-
} else if ("encodeData" in opts && "decodeData" in opts && Array.isArray(opts.encodeData) && Array.isArray(opts.decodeData)) {
|
|
695
|
+
if ("encodeData" in opts && "decodeData" in opts && Array.isArray(opts.encodeData) && Array.isArray(opts.decodeData)) {
|
|
708
696
|
this.encodeData = [opts.encodeData[0], opts.encodeData[1]];
|
|
709
697
|
this.decodeData = [opts.decodeData[0], opts.decodeData[1]];
|
|
710
|
-
this.compressionFormat = (
|
|
698
|
+
this.compressionFormat = (_b = opts.encodeData[0]) != null ? _b : null;
|
|
711
699
|
} else if (opts.compressionFormat === null) {
|
|
712
700
|
this.encodeData = void 0;
|
|
713
701
|
this.decodeData = void 0;
|
|
714
702
|
this.compressionFormat = null;
|
|
715
|
-
} else
|
|
716
|
-
|
|
717
|
-
|
|
703
|
+
} else {
|
|
704
|
+
const fmt = typeof opts.compressionFormat === "string" ? opts.compressionFormat : "deflate-raw";
|
|
705
|
+
this.compressionFormat = fmt;
|
|
706
|
+
this.encodeData = [fmt, (data) => __async(this, null, function* () {
|
|
707
|
+
return yield compress(data, fmt, "string");
|
|
708
|
+
})];
|
|
709
|
+
this.decodeData = [fmt, (data) => __async(this, null, function* () {
|
|
710
|
+
return yield decompress(data, fmt, "string");
|
|
711
|
+
})];
|
|
712
|
+
}
|
|
713
|
+
this.engine.setDataStoreOptions({
|
|
714
|
+
id: this.id,
|
|
715
|
+
encodeData: this.encodeData,
|
|
716
|
+
decodeData: this.decodeData
|
|
717
|
+
});
|
|
718
718
|
}
|
|
719
719
|
//#region loadData
|
|
720
720
|
/**
|
|
@@ -764,7 +764,7 @@ var DataStore = class {
|
|
|
764
764
|
}
|
|
765
765
|
const storedData = storedDataRaw != null ? storedDataRaw : JSON.stringify(this.defaultData);
|
|
766
766
|
const encodingFmt = String(yield this.engine.getValue(`__ds-${this.id}-enf`, null));
|
|
767
|
-
const isEncoded = encodingFmt !== "null" && encodingFmt !== "false";
|
|
767
|
+
const isEncoded = encodingFmt !== "null" && encodingFmt !== "false" && encodingFmt !== "0" && encodingFmt !== "" && encodingFmt !== null;
|
|
768
768
|
let saveData = false;
|
|
769
769
|
if (isNaN(storedFmtVer)) {
|
|
770
770
|
yield this.engine.setValue(`__ds-${this.id}-ver`, storedFmtVer = this.formatVersion);
|
|
@@ -877,7 +877,7 @@ var DataStore = class {
|
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
879
|
yield Promise.allSettled([
|
|
880
|
-
this.engine.setValue(`__ds-${this.id}-dat`, yield this.engine.serializeData(newData)),
|
|
880
|
+
this.engine.setValue(`__ds-${this.id}-dat`, yield this.engine.serializeData(newData, this.encodingEnabled())),
|
|
881
881
|
this.engine.setValue(`__ds-${this.id}-ver`, lastFmtVer),
|
|
882
882
|
this.engine.setValue(`__ds-${this.id}-enf`, this.compressionFormat)
|
|
883
883
|
]);
|
|
@@ -908,7 +908,7 @@ var DataStore = class {
|
|
|
908
908
|
return;
|
|
909
909
|
const parsed = yield this.engine.deserializeData(data, isEncoded);
|
|
910
910
|
yield Promise.allSettled([
|
|
911
|
-
this.engine.setValue(`__ds-${this.id}-dat`, yield this.engine.serializeData(parsed)),
|
|
911
|
+
this.engine.setValue(`__ds-${this.id}-dat`, yield this.engine.serializeData(parsed, this.encodingEnabled())),
|
|
912
912
|
this.engine.setValue(`__ds-${this.id}-ver`, fmtVer),
|
|
913
913
|
this.engine.setValue(`__ds-${this.id}-enf`, this.compressionFormat),
|
|
914
914
|
this.engine.deleteValue(`__ds-${id}-dat`),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sv443-network/userutils",
|
|
3
3
|
"libName": "UserUtils",
|
|
4
|
-
"version": "10.0.
|
|
4
|
+
"version": "10.0.5",
|
|
5
5
|
"description": "General purpose DOM/GreaseMonkey library that allows you to register listeners for when CSS selectors exist, intercept events, create persistent & synchronous data stores, modify the DOM more easily and much more",
|
|
6
6
|
"main": "dist/UserUtils.mjs",
|
|
7
7
|
"module": "dist/UserUtils.mjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/Sv443-Network/UserUtils",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@sv443-network/coreutils": "3.0.
|
|
36
|
+
"@sv443-network/coreutils": "3.0.4",
|
|
37
37
|
"nanoevents": "9.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|