@sv443-network/userutils 6.0.0 → 6.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 +4 -1
- package/dist/index.global.js +3 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/lib/DataStore.d.ts +5 -5
- package/dist/lib/dom.d.ts +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -8,9 +8,12 @@ Contains builtin TypeScript declarations. Fully web compatible and supports ESM
|
|
|
8
8
|
If you like using this library, please consider [supporting the development ❤️](https://github.com/sponsors/Sv443)
|
|
9
9
|
|
|
10
10
|
<br>
|
|
11
|
+
<sup>
|
|
12
|
+
View the documentation of previous major releases:
|
|
13
|
+
</sup>
|
|
11
14
|
<sub>
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
<a href="https://github.com/Sv443-Network/UserUtils/blob/v5.0.1/README.md" rel="noopener noreferrer">5.0.1</a>, <a href="https://github.com/Sv443-Network/UserUtils/blob/v4.2.1/README.md" rel="noopener noreferrer">4.2.1</a>, <a href="https://github.com/Sv443-Network/UserUtils/blob/v3.0.0/README.md" rel="noopener noreferrer">3.0.0</a>, <a href="https://github.com/Sv443-Network/UserUtils/blob/v2.0.1/README.md" rel="noopener noreferrer">2.0.1</a>, <a href="https://github.com/Sv443-Network/UserUtils/blob/v1.2.0/README.md" rel="noopener noreferrer">1.2.0</a>, <a href="https://github.com/Sv443-Network/UserUtils/blob/v0.5.3/README.md" rel="noopener noreferrer">0.5.3</a>
|
|
14
17
|
|
|
15
18
|
</sub>
|
|
16
19
|
</div>
|
package/dist/index.global.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// ==UserLibrary==
|
|
9
9
|
// @name UserUtils
|
|
10
10
|
// @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
|
|
11
|
-
// @version 6.0.
|
|
11
|
+
// @version 6.0.1
|
|
12
12
|
// @license MIT
|
|
13
13
|
// @copyright Sv443 (https://github.com/Sv443)
|
|
14
14
|
|
|
@@ -145,7 +145,7 @@ var UserUtils = (function (exports) {
|
|
|
145
145
|
* ⚠️ Requires the directives `@grant GM.getValue` and `@grant GM.setValue`
|
|
146
146
|
* ⚠️ Make sure to call {@linkcode loadData()} at least once after creating an instance, or the returned data will be the same as `options.defaultData`
|
|
147
147
|
*
|
|
148
|
-
* @template TData The type of the data that is saved in persistent storage (will be automatically inferred from `
|
|
148
|
+
* @template TData The type of the data that is saved in persistent storage (will be automatically inferred from `options.defaultData`) - this should also be the type of the data format associated with the current `options.formatVersion`
|
|
149
149
|
* @param options The options for this DataStore instance
|
|
150
150
|
*/
|
|
151
151
|
constructor(options) {
|
|
@@ -212,7 +212,7 @@ var UserUtils = (function (exports) {
|
|
|
212
212
|
resolve();
|
|
213
213
|
}));
|
|
214
214
|
}
|
|
215
|
-
/** Saves the default
|
|
215
|
+
/** Saves the default data passed in the constructor synchronously to the in-memory cache and asynchronously to persistent storage */
|
|
216
216
|
saveDefaultData() {
|
|
217
217
|
return __async(this, null, function* () {
|
|
218
218
|
this.cachedData = this.defaultData;
|
package/dist/index.js
CHANGED
|
@@ -125,7 +125,7 @@ var DataStore = class {
|
|
|
125
125
|
* ⚠️ Requires the directives `@grant GM.getValue` and `@grant GM.setValue`
|
|
126
126
|
* ⚠️ Make sure to call {@linkcode loadData()} at least once after creating an instance, or the returned data will be the same as `options.defaultData`
|
|
127
127
|
*
|
|
128
|
-
* @template TData The type of the data that is saved in persistent storage (will be automatically inferred from `
|
|
128
|
+
* @template TData The type of the data that is saved in persistent storage (will be automatically inferred from `options.defaultData`) - this should also be the type of the data format associated with the current `options.formatVersion`
|
|
129
129
|
* @param options The options for this DataStore instance
|
|
130
130
|
*/
|
|
131
131
|
constructor(options) {
|
|
@@ -192,7 +192,7 @@ var DataStore = class {
|
|
|
192
192
|
resolve();
|
|
193
193
|
}));
|
|
194
194
|
}
|
|
195
|
-
/** Saves the default
|
|
195
|
+
/** Saves the default 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
198
|
this.cachedData = this.defaultData;
|
package/dist/index.mjs
CHANGED
|
@@ -123,7 +123,7 @@ var DataStore = class {
|
|
|
123
123
|
* ⚠️ Requires the directives `@grant GM.getValue` and `@grant GM.setValue`
|
|
124
124
|
* ⚠️ Make sure to call {@linkcode loadData()} at least once after creating an instance, or the returned data will be the same as `options.defaultData`
|
|
125
125
|
*
|
|
126
|
-
* @template TData The type of the data that is saved in persistent storage (will be automatically inferred from `
|
|
126
|
+
* @template TData The type of the data that is saved in persistent storage (will be automatically inferred from `options.defaultData`) - this should also be the type of the data format associated with the current `options.formatVersion`
|
|
127
127
|
* @param options The options for this DataStore instance
|
|
128
128
|
*/
|
|
129
129
|
constructor(options) {
|
|
@@ -190,7 +190,7 @@ var DataStore = class {
|
|
|
190
190
|
resolve();
|
|
191
191
|
}));
|
|
192
192
|
}
|
|
193
|
-
/** Saves the default
|
|
193
|
+
/** Saves the default 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
196
|
this.cachedData = this.defaultData;
|
package/dist/lib/DataStore.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Function that takes the data in the old format and returns the data in the new format. Also supports an asynchronous migration. */
|
|
2
2
|
type MigrationFunc = (oldData: any) => any | Promise<any>;
|
|
3
3
|
/** Dictionary of format version numbers and the function that migrates to them from the previous whole integer */
|
|
4
|
-
export type
|
|
4
|
+
export type DataMigrationsDict = Record<number, MigrationFunc>;
|
|
5
5
|
/** Options for the DataStore instance */
|
|
6
6
|
export type DataStoreOptions<TData> = {
|
|
7
7
|
/** A unique internal ID for this data store - choose wisely as changing it is not supported yet. */
|
|
@@ -27,7 +27,7 @@ export type DataStoreOptions<TData> = {
|
|
|
27
27
|
* The functions will be run in order from the oldest to the newest version.
|
|
28
28
|
* If the current format version is not in the dictionary, no migrations will be run.
|
|
29
29
|
*/
|
|
30
|
-
migrations?:
|
|
30
|
+
migrations?: DataMigrationsDict;
|
|
31
31
|
} & ({
|
|
32
32
|
/**
|
|
33
33
|
* Function to use to encode the data prior to saving it in persistent storage.
|
|
@@ -51,7 +51,7 @@ export type DataStoreOptions<TData> = {
|
|
|
51
51
|
});
|
|
52
52
|
/**
|
|
53
53
|
* Manages a sync & async persistent JSON database that is cached in memory and persistently saved across sessions.
|
|
54
|
-
* Supports migrating data from older versions
|
|
54
|
+
* Supports migrating data from older format versions to newer ones and populating the cache with default data if no persistent data is found.
|
|
55
55
|
*
|
|
56
56
|
* ⚠️ Requires the directives `@grant GM.getValue` and `@grant GM.setValue`
|
|
57
57
|
* ⚠️ Make sure to call {@linkcode loadData()} at least once after creating an instance, or the returned data will be the same as `options.defaultData`
|
|
@@ -73,7 +73,7 @@ export declare class DataStore<TData = any> {
|
|
|
73
73
|
* ⚠️ Requires the directives `@grant GM.getValue` and `@grant GM.setValue`
|
|
74
74
|
* ⚠️ Make sure to call {@linkcode loadData()} at least once after creating an instance, or the returned data will be the same as `options.defaultData`
|
|
75
75
|
*
|
|
76
|
-
* @template TData The type of the data that is saved in persistent storage (will be automatically inferred from `
|
|
76
|
+
* @template TData The type of the data that is saved in persistent storage (will be automatically inferred from `options.defaultData`) - this should also be the type of the data format associated with the current `options.formatVersion`
|
|
77
77
|
* @param options The options for this DataStore instance
|
|
78
78
|
*/
|
|
79
79
|
constructor(options: DataStoreOptions<TData>);
|
|
@@ -90,7 +90,7 @@ export declare class DataStore<TData = any> {
|
|
|
90
90
|
getData(): TData;
|
|
91
91
|
/** Saves the data synchronously to the in-memory cache and asynchronously to the persistent storage */
|
|
92
92
|
setData(data: TData): Promise<void>;
|
|
93
|
-
/** Saves the default
|
|
93
|
+
/** Saves the default data passed in the constructor synchronously to the in-memory cache and asynchronously to persistent storage */
|
|
94
94
|
saveDefaultData(): Promise<void>;
|
|
95
95
|
/**
|
|
96
96
|
* Call this method to clear all persistently stored data associated with this DataStore instance.
|
package/dist/lib/dom.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare function observeElementProp<TElem extends Element = HTMLElement,
|
|
|
67
67
|
* @param siblingAmount The amount of siblings to return
|
|
68
68
|
* @param refElementAlignment Can be set to `center-top` (default), `center-bottom`, `top`, or `bottom`, which will determine where the relative location of the provided {@linkcode refElement} is in the returned array
|
|
69
69
|
* @param includeRef If set to `true` (default), the provided {@linkcode refElement} will be included in the returned array at the corresponding position
|
|
70
|
-
* @template
|
|
70
|
+
* @template TSibling The type of the sibling elements that are returned
|
|
71
71
|
* @returns An array of sibling elements
|
|
72
72
|
*/
|
|
73
|
-
export declare function getSiblingsFrame<
|
|
73
|
+
export declare function getSiblingsFrame<TSibling extends Element = HTMLElement>(refElement: Element, siblingAmount: number, refElementAlignment?: "center-top" | "center-bottom" | "top" | "bottom", includeRef?: boolean): TSibling[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sv443-network/userutils",
|
|
3
3
|
"libName": "UserUtils",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.1",
|
|
5
5
|
"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",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"lint": "tsc --noEmit && eslint .",
|
|
11
11
|
"build-types": "tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
12
12
|
"build-common": "tsup lib/index.ts --format cjs,esm --clean --treeshake",
|
|
13
|
-
"build-
|
|
13
|
+
"build-all": "tsup lib/index.ts --format cjs,esm,iife --treeshake --onSuccess \"npm run post-build-global && echo Finished building.\"",
|
|
14
14
|
"build": "npm run build-common -- && npm run build-types",
|
|
15
15
|
"post-build-global": "npm run node-ts -- ./tools/post-build-global.mts",
|
|
16
16
|
"dev": "npm run build-common -- --sourcemap --watch --onSuccess \"npm run build-types && echo Finished building.\"",
|