@sv443-network/userutils 5.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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/index.global.js +8 -8
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/dist/lib/ConfigManager.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ If you like using this library, please consider [supporting the development ❤
|
|
|
10
10
|
<br>
|
|
11
11
|
<sub>
|
|
12
12
|
|
|
13
|
-
View the documentation of previous major releases: [3.0.0](https://github.com/Sv443-Network/UserUtils/blob/v3.0.0/README.md), [2.0.1](https://github.com/Sv443-Network/UserUtils/blob/v2.0.1/README.md), [1.2.0](https://github.com/Sv443-Network/UserUtils/blob/v1.2.0/README.md), [0.5.3](https://github.com/Sv443-Network/UserUtils/blob/v0.5.3/README.md)
|
|
13
|
+
View the documentation of previous major releases: [4.2.1](https://github.com/Sv443-Network/UserUtils/blob/v4.2.1/README.md), [3.0.0](https://github.com/Sv443-Network/UserUtils/blob/v3.0.0/README.md), [2.0.1](https://github.com/Sv443-Network/UserUtils/blob/v2.0.1/README.md), [1.2.0](https://github.com/Sv443-Network/UserUtils/blob/v1.2.0/README.md), [0.5.3](https://github.com/Sv443-Network/UserUtils/blob/v0.5.3/README.md)
|
|
14
14
|
|
|
15
15
|
</sub>
|
|
16
16
|
</div>
|
package/dist/index.global.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// ==UserLibrary==
|
|
10
10
|
// @name UserUtils
|
|
11
11
|
// @description Library with various utilities for userscripts - register listeners for when CSS selectors exist, intercept events, manage persistent user configurations, modify the DOM more easily and more
|
|
12
|
-
// @version 5.0.
|
|
12
|
+
// @version 5.0.1
|
|
13
13
|
// @license MIT
|
|
14
14
|
// @copyright Sv443 (https://github.com/Sv443)
|
|
15
15
|
|
|
@@ -153,14 +153,14 @@ var UserUtils = (function (exports) {
|
|
|
153
153
|
__publicField(this, "id");
|
|
154
154
|
__publicField(this, "formatVersion");
|
|
155
155
|
__publicField(this, "defaultConfig");
|
|
156
|
-
__publicField(this, "
|
|
156
|
+
__publicField(this, "cachedData");
|
|
157
157
|
__publicField(this, "migrations");
|
|
158
158
|
__publicField(this, "encodeData");
|
|
159
159
|
__publicField(this, "decodeData");
|
|
160
160
|
this.id = options.id;
|
|
161
161
|
this.formatVersion = options.formatVersion;
|
|
162
162
|
this.defaultConfig = options.defaultConfig;
|
|
163
|
-
this.
|
|
163
|
+
this.cachedData = options.defaultConfig;
|
|
164
164
|
this.migrations = options.migrations;
|
|
165
165
|
this.encodeData = options.encodeData;
|
|
166
166
|
this.decodeData = options.decodeData;
|
|
@@ -177,7 +177,7 @@ var UserUtils = (function (exports) {
|
|
|
177
177
|
let gmFmtVer = Number(yield GM.getValue(`_uucfgver-${this.id}`));
|
|
178
178
|
if (typeof gmData !== "string") {
|
|
179
179
|
yield this.saveDefaultData();
|
|
180
|
-
return this.defaultConfig;
|
|
180
|
+
return __spreadValues({}, this.defaultConfig);
|
|
181
181
|
}
|
|
182
182
|
const isEncoded = yield GM.getValue(`_uucfgenc-${this.id}`, false);
|
|
183
183
|
if (isNaN(gmFmtVer))
|
|
@@ -185,7 +185,7 @@ var UserUtils = (function (exports) {
|
|
|
185
185
|
let parsed = yield this.deserializeData(gmData, isEncoded);
|
|
186
186
|
if (gmFmtVer < this.formatVersion && this.migrations)
|
|
187
187
|
parsed = yield this.runMigrations(parsed, gmFmtVer);
|
|
188
|
-
return this.
|
|
188
|
+
return __spreadValues({}, this.cachedData = parsed);
|
|
189
189
|
} catch (err) {
|
|
190
190
|
console.warn("Error while loading config data, resetting it to the default value.", err);
|
|
191
191
|
yield this.saveDefaultData();
|
|
@@ -198,11 +198,11 @@ var UserUtils = (function (exports) {
|
|
|
198
198
|
* Use {@linkcode loadData()} to get fresh data from persistent storage (usually not necessary since the cache should always exactly reflect persistent storage).
|
|
199
199
|
*/
|
|
200
200
|
getData() {
|
|
201
|
-
return this.deepCopy(this.
|
|
201
|
+
return this.deepCopy(this.cachedData);
|
|
202
202
|
}
|
|
203
203
|
/** Saves the data synchronously to the in-memory cache and asynchronously to the persistent storage */
|
|
204
204
|
setData(data) {
|
|
205
|
-
this.
|
|
205
|
+
this.cachedData = data;
|
|
206
206
|
const useEncoding = Boolean(this.encodeData && this.decodeData);
|
|
207
207
|
return new Promise((resolve) => __async(this, null, function* () {
|
|
208
208
|
yield Promise.all([
|
|
@@ -216,7 +216,7 @@ var UserUtils = (function (exports) {
|
|
|
216
216
|
/** Saves the default configuration data passed in the constructor synchronously to the in-memory cache and asynchronously to persistent storage */
|
|
217
217
|
saveDefaultData() {
|
|
218
218
|
return __async(this, null, function* () {
|
|
219
|
-
this.
|
|
219
|
+
this.cachedData = this.defaultConfig;
|
|
220
220
|
const useEncoding = Boolean(this.encodeData && this.decodeData);
|
|
221
221
|
return new Promise((resolve) => __async(this, null, function* () {
|
|
222
222
|
yield Promise.all([
|
package/dist/index.js
CHANGED
|
@@ -132,14 +132,14 @@ var ConfigManager = class {
|
|
|
132
132
|
__publicField(this, "id");
|
|
133
133
|
__publicField(this, "formatVersion");
|
|
134
134
|
__publicField(this, "defaultConfig");
|
|
135
|
-
__publicField(this, "
|
|
135
|
+
__publicField(this, "cachedData");
|
|
136
136
|
__publicField(this, "migrations");
|
|
137
137
|
__publicField(this, "encodeData");
|
|
138
138
|
__publicField(this, "decodeData");
|
|
139
139
|
this.id = options.id;
|
|
140
140
|
this.formatVersion = options.formatVersion;
|
|
141
141
|
this.defaultConfig = options.defaultConfig;
|
|
142
|
-
this.
|
|
142
|
+
this.cachedData = options.defaultConfig;
|
|
143
143
|
this.migrations = options.migrations;
|
|
144
144
|
this.encodeData = options.encodeData;
|
|
145
145
|
this.decodeData = options.decodeData;
|
|
@@ -156,7 +156,7 @@ var ConfigManager = class {
|
|
|
156
156
|
let gmFmtVer = Number(yield GM.getValue(`_uucfgver-${this.id}`));
|
|
157
157
|
if (typeof gmData !== "string") {
|
|
158
158
|
yield this.saveDefaultData();
|
|
159
|
-
return this.defaultConfig;
|
|
159
|
+
return __spreadValues({}, this.defaultConfig);
|
|
160
160
|
}
|
|
161
161
|
const isEncoded = yield GM.getValue(`_uucfgenc-${this.id}`, false);
|
|
162
162
|
if (isNaN(gmFmtVer))
|
|
@@ -164,7 +164,7 @@ var ConfigManager = class {
|
|
|
164
164
|
let parsed = yield this.deserializeData(gmData, isEncoded);
|
|
165
165
|
if (gmFmtVer < this.formatVersion && this.migrations)
|
|
166
166
|
parsed = yield this.runMigrations(parsed, gmFmtVer);
|
|
167
|
-
return this.
|
|
167
|
+
return __spreadValues({}, this.cachedData = parsed);
|
|
168
168
|
} catch (err) {
|
|
169
169
|
console.warn("Error while loading config data, resetting it to the default value.", err);
|
|
170
170
|
yield this.saveDefaultData();
|
|
@@ -177,11 +177,11 @@ var ConfigManager = class {
|
|
|
177
177
|
* Use {@linkcode loadData()} to get fresh data from persistent storage (usually not necessary since the cache should always exactly reflect persistent storage).
|
|
178
178
|
*/
|
|
179
179
|
getData() {
|
|
180
|
-
return this.deepCopy(this.
|
|
180
|
+
return this.deepCopy(this.cachedData);
|
|
181
181
|
}
|
|
182
182
|
/** Saves the data synchronously to the in-memory cache and asynchronously to the persistent storage */
|
|
183
183
|
setData(data) {
|
|
184
|
-
this.
|
|
184
|
+
this.cachedData = data;
|
|
185
185
|
const useEncoding = Boolean(this.encodeData && this.decodeData);
|
|
186
186
|
return new Promise((resolve) => __async(this, null, function* () {
|
|
187
187
|
yield Promise.all([
|
|
@@ -195,7 +195,7 @@ var ConfigManager = class {
|
|
|
195
195
|
/** Saves the default configuration data passed in the constructor synchronously to the in-memory cache and asynchronously to persistent storage */
|
|
196
196
|
saveDefaultData() {
|
|
197
197
|
return __async(this, null, function* () {
|
|
198
|
-
this.
|
|
198
|
+
this.cachedData = this.defaultConfig;
|
|
199
199
|
const useEncoding = Boolean(this.encodeData && this.decodeData);
|
|
200
200
|
return new Promise((resolve) => __async(this, null, function* () {
|
|
201
201
|
yield Promise.all([
|
package/dist/index.mjs
CHANGED
|
@@ -130,14 +130,14 @@ var ConfigManager = class {
|
|
|
130
130
|
__publicField(this, "id");
|
|
131
131
|
__publicField(this, "formatVersion");
|
|
132
132
|
__publicField(this, "defaultConfig");
|
|
133
|
-
__publicField(this, "
|
|
133
|
+
__publicField(this, "cachedData");
|
|
134
134
|
__publicField(this, "migrations");
|
|
135
135
|
__publicField(this, "encodeData");
|
|
136
136
|
__publicField(this, "decodeData");
|
|
137
137
|
this.id = options.id;
|
|
138
138
|
this.formatVersion = options.formatVersion;
|
|
139
139
|
this.defaultConfig = options.defaultConfig;
|
|
140
|
-
this.
|
|
140
|
+
this.cachedData = options.defaultConfig;
|
|
141
141
|
this.migrations = options.migrations;
|
|
142
142
|
this.encodeData = options.encodeData;
|
|
143
143
|
this.decodeData = options.decodeData;
|
|
@@ -154,7 +154,7 @@ var ConfigManager = class {
|
|
|
154
154
|
let gmFmtVer = Number(yield GM.getValue(`_uucfgver-${this.id}`));
|
|
155
155
|
if (typeof gmData !== "string") {
|
|
156
156
|
yield this.saveDefaultData();
|
|
157
|
-
return this.defaultConfig;
|
|
157
|
+
return __spreadValues({}, this.defaultConfig);
|
|
158
158
|
}
|
|
159
159
|
const isEncoded = yield GM.getValue(`_uucfgenc-${this.id}`, false);
|
|
160
160
|
if (isNaN(gmFmtVer))
|
|
@@ -162,7 +162,7 @@ var ConfigManager = class {
|
|
|
162
162
|
let parsed = yield this.deserializeData(gmData, isEncoded);
|
|
163
163
|
if (gmFmtVer < this.formatVersion && this.migrations)
|
|
164
164
|
parsed = yield this.runMigrations(parsed, gmFmtVer);
|
|
165
|
-
return this.
|
|
165
|
+
return __spreadValues({}, this.cachedData = parsed);
|
|
166
166
|
} catch (err) {
|
|
167
167
|
console.warn("Error while loading config data, resetting it to the default value.", err);
|
|
168
168
|
yield this.saveDefaultData();
|
|
@@ -175,11 +175,11 @@ var ConfigManager = class {
|
|
|
175
175
|
* Use {@linkcode loadData()} to get fresh data from persistent storage (usually not necessary since the cache should always exactly reflect persistent storage).
|
|
176
176
|
*/
|
|
177
177
|
getData() {
|
|
178
|
-
return this.deepCopy(this.
|
|
178
|
+
return this.deepCopy(this.cachedData);
|
|
179
179
|
}
|
|
180
180
|
/** Saves the data synchronously to the in-memory cache and asynchronously to the persistent storage */
|
|
181
181
|
setData(data) {
|
|
182
|
-
this.
|
|
182
|
+
this.cachedData = data;
|
|
183
183
|
const useEncoding = Boolean(this.encodeData && this.decodeData);
|
|
184
184
|
return new Promise((resolve) => __async(this, null, function* () {
|
|
185
185
|
yield Promise.all([
|
|
@@ -193,7 +193,7 @@ var ConfigManager = class {
|
|
|
193
193
|
/** Saves the default configuration data passed in the constructor synchronously to the in-memory cache and asynchronously to persistent storage */
|
|
194
194
|
saveDefaultData() {
|
|
195
195
|
return __async(this, null, function* () {
|
|
196
|
-
this.
|
|
196
|
+
this.cachedData = this.defaultConfig;
|
|
197
197
|
const useEncoding = Boolean(this.encodeData && this.decodeData);
|
|
198
198
|
return new Promise((resolve) => __async(this, null, function* () {
|
|
199
199
|
yield Promise.all([
|
|
@@ -62,7 +62,7 @@ export declare class ConfigManager<TData = any> {
|
|
|
62
62
|
readonly id: string;
|
|
63
63
|
readonly formatVersion: number;
|
|
64
64
|
readonly defaultConfig: TData;
|
|
65
|
-
private
|
|
65
|
+
private cachedData;
|
|
66
66
|
private migrations?;
|
|
67
67
|
private encodeData;
|
|
68
68
|
private decodeData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sv443-network/userutils",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Library with various utilities for userscripts - register listeners for when CSS selectors exist, intercept events, manage persistent user configurations, modify the DOM more easily and more",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|