@sv443-network/userutils 10.0.6 → 10.2.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/CHANGELOG.md +27 -0
- package/README.md +40 -32
- package/dist/UserUtils.cjs +600 -404
- package/dist/UserUtils.mjs +602 -404
- package/dist/UserUtils.umd.js +486 -309
- package/dist/lib/consts.d.ts +2 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/translation.d.ts +80 -2
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @sv443-network/userutils
|
|
2
2
|
|
|
3
|
+
## 10.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1f32c2e: Updated CoreUtils to v3.4.0, which includes the following changes:
|
|
8
|
+
- `Debouncer` and `debounce` now have an extra parameter of type `NanoEmitterOptions` to customize the underlying `NanoEmitter` instance.
|
|
9
|
+
- Added function `createRecurringTask()` as a "batteries included" alternative to `setImmediateTimeoutLoop()` and `setImmediateInterval()`, with more ways to control task execution and aborting.
|
|
10
|
+
- Fixed internal event emission problems in `Debouncer`
|
|
11
|
+
|
|
12
|
+
## 10.1.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- c42bf93: Added constant object `versions` to find out the versions of UserUtils and the bundled and re-exported CoreUtils library at runtime.
|
|
17
|
+
- 7a81eba: Added translation transform `tr.transforms.i18n`, which works similar to `templateLiteral` but matches the commonly used i18n pattern `{{key}}`.
|
|
18
|
+
- fe726cd: Added function `tr.getAllTranslations()` to return a mutable or immutable (default) object of all registered translations.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 6118f4a: Updated CoreUtils to v3.3.0.
|
|
23
|
+
This fixes various `DataStore` and `DataStoreEngine` issues and adds `NanoEmitter` into `DataStore`'s inheritance chain, including many new events.
|
|
24
|
+
It also adds a second parameter of type `DataStoreEngineDSOptions` to the `filePath` function property in `FileStorageEngineOptions`, which allows for setting the file path based on encoding options.
|
|
25
|
+
- ca4c9ed: An empty string can now be used as a valid translation language.
|
|
26
|
+
When the language parameter is an empty string, it will now be treated as an actual valid language instead of aggressively trying to use the fallback language and failing.
|
|
27
|
+
If the language is undefined at runtime (even though this is a TS error), it will default to an empty string, triggering the same behavior.
|
|
28
|
+
As a side effect, this also allows for a second fallback layer that is applied instead of the default "return the key if translation is missing" fallback.
|
|
29
|
+
|
|
3
30
|
## 10.0.6
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -33,7 +33,11 @@ View the documentation of previous major versions:
|
|
|
33
33
|
|
|
34
34
|
> [!NOTE]
|
|
35
35
|
> In version 10.0.0, many of the platform-agnostic features were moved to [the CoreUtils library.](https://github.com/Sv443-Network/CoreUtils)
|
|
36
|
-
> <sub>
|
|
36
|
+
> <sub>
|
|
37
|
+
> Everything in CoreUtils is re-exported by UserUtils for backwards compatibility, so installing both at the same time isn't usually necessary.
|
|
38
|
+
> Beware that when both are installed, class inheritance between the two libraries will only work if the installed version of CoreUtils matches the version of CoreUtils that is included in UserUtils (refer to `package.json`), so that the final bundler is able to deduplicate them correctly. See also [`const versions`](./docs.md#const-versions)
|
|
39
|
+
>
|
|
40
|
+
> </sub>
|
|
37
41
|
|
|
38
42
|
<br>
|
|
39
43
|
|
|
@@ -44,40 +48,42 @@ View the documentation of previous major versions:
|
|
|
44
48
|
- [**Preamble** (info about the documentation)](./docs.md#preamble)
|
|
45
49
|
- [**UserUtils Features**](./docs.md#features)
|
|
46
50
|
- [**DOM:**](./docs.md#dom)
|
|
47
|
-
- 🟧 [`Dialog`](./docs.md#class-dialog) - class for creating custom modal dialogs with a promise-based API and a generic, default style
|
|
48
|
-
- 🟧 [`SelectorObserver`](./docs.md#class-selectorobserver) - class that manages listeners that are called when selectors are found in the DOM
|
|
49
|
-
- 🟣 [`getUnsafeWindow()`](./docs.md#function-getunsafewindow) - get the unsafeWindow object or fall back to the regular window object
|
|
50
|
-
- 🟣 [`isDomLoaded()`](./docs.md#function-isdomloaded) - check if the DOM has finished loading and can be queried and modified
|
|
51
|
-
- 🟣 [`onDomLoad()`](./docs.md#function-ondomload) - run a function or pause async execution until the DOM has finished loading (or immediately if DOM is already loaded)
|
|
52
|
-
- 🟣 [`addParent()`](./docs.md#function-addparent) - add a parent element around another element
|
|
53
|
-
- 🟣 [`addGlobalStyle()`](./docs.md#function-addglobalstyle) - add a global style to the page
|
|
54
|
-
- 🟣 [`preloadImages()`](./docs.md#function-preloadimages) - preload images into the browser cache for faster loading later on
|
|
55
|
-
- 🟣 [`openInNewTab()`](./docs.md#function-openinnewtab) - open a link in a new tab
|
|
56
|
-
- 🟣 [`interceptEvent()`](./docs.md#function-interceptevent) - conditionally intercepts events registered by `addEventListener()` on any given EventTarget object
|
|
57
|
-
- 🟣 [`interceptWindowEvent()`](./docs.md#function-interceptwindowevent) - conditionally intercepts events registered by `addEventListener()` on the window object
|
|
58
|
-
- 🟣 [`isScrollable()`](./docs.md#function-isscrollable) - check if an element has a horizontal or vertical scroll bar
|
|
59
|
-
- 🟣 [`observeElementProp()`](./docs.md#function-observeelementprop) - observe changes to an element's property that can't be observed with MutationObserver
|
|
60
|
-
- 🟣 [`getSiblingsFrame()`](./docs.md#function-getsiblingsframe) - returns a frame of an element's siblings, with a given alignment and size
|
|
61
|
-
- 🟣 [`setInnerHtmlUnsafe()`](./docs.md#function-setinnerhtmlunsafe) - set the innerHTML of an element using a [Trusted Types policy](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) without sanitizing or escaping it
|
|
62
|
-
- 🟣 [`probeElementStyle()`](./docs.md#function-probeelementstyle) - probe the computed style of a temporary element (get default font size, resolve CSS variables, etc.)
|
|
51
|
+
- 🟧 [`class Dialog`](./docs.md#class-dialog) - class for creating custom modal dialogs with a promise-based API and a generic, default style
|
|
52
|
+
- 🟧 [`class SelectorObserver`](./docs.md#class-selectorobserver) - class that manages listeners that are called when selectors are found in the DOM
|
|
53
|
+
- 🟣 [`function getUnsafeWindow()`](./docs.md#function-getunsafewindow) - get the unsafeWindow object or fall back to the regular window object
|
|
54
|
+
- 🟣 [`function isDomLoaded()`](./docs.md#function-isdomloaded) - check if the DOM has finished loading and can be queried and modified
|
|
55
|
+
- 🟣 [`function onDomLoad()`](./docs.md#function-ondomload) - run a function or pause async execution until the DOM has finished loading (or immediately if DOM is already loaded)
|
|
56
|
+
- 🟣 [`function addParent()`](./docs.md#function-addparent) - add a parent element around another element
|
|
57
|
+
- 🟣 [`function addGlobalStyle()`](./docs.md#function-addglobalstyle) - add a global style to the page
|
|
58
|
+
- 🟣 [`function preloadImages()`](./docs.md#function-preloadimages) - preload images into the browser cache for faster loading later on
|
|
59
|
+
- 🟣 [`function openInNewTab()`](./docs.md#function-openinnewtab) - open a link in a new tab
|
|
60
|
+
- 🟣 [`function interceptEvent()`](./docs.md#function-interceptevent) - conditionally intercepts events registered by `addEventListener()` on any given EventTarget object
|
|
61
|
+
- 🟣 [`function interceptWindowEvent()`](./docs.md#function-interceptwindowevent) - conditionally intercepts events registered by `addEventListener()` on the window object
|
|
62
|
+
- 🟣 [`function isScrollable()`](./docs.md#function-isscrollable) - check if an element has a horizontal or vertical scroll bar
|
|
63
|
+
- 🟣 [`function observeElementProp()`](./docs.md#function-observeelementprop) - observe changes to an element's property that can't be observed with MutationObserver
|
|
64
|
+
- 🟣 [`function getSiblingsFrame()`](./docs.md#function-getsiblingsframe) - returns a frame of an element's siblings, with a given alignment and size
|
|
65
|
+
- 🟣 [`function setInnerHtmlUnsafe()`](./docs.md#function-setinnerhtmlunsafe) - set the innerHTML of an element using a [Trusted Types policy](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) without sanitizing or escaping it
|
|
66
|
+
- 🟣 [`function probeElementStyle()`](./docs.md#function-probeelementstyle) - probe the computed style of a temporary element (get default font size, resolve CSS variables, etc.)
|
|
63
67
|
- [**Misc:**](./docs.md#misc)
|
|
64
|
-
- 🟧 [`GMStorageEngine`](./docs.md#class-gmstorageengine) - storage engine class for [`DataStore`s](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#datastore) using the GreaseMonkey API
|
|
65
|
-
- 🟧 [`Mixins`](./docs.md#class-mixins) - class for creating mixin functions that allow multiple sources to modify a target value in a highly flexible way
|
|
68
|
+
- 🟧 [`class GMStorageEngine`](./docs.md#class-gmstorageengine) - storage engine class for [`DataStore`s](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#datastore) using the GreaseMonkey API
|
|
69
|
+
- 🟧 [`class Mixins`](./docs.md#class-mixins) - class for creating mixin functions that allow multiple sources to modify a target value in a highly flexible way
|
|
70
|
+
- 🟩 [`const versions`](./docs.md#const-versions) - contains version information for UserUtils and CoreUtils
|
|
66
71
|
- [**Translation:**](./docs.md#translation)
|
|
67
|
-
- 🟣 [`tr.for()`](./docs.md#function-trfor) - translates a key for the specified language
|
|
68
|
-
- 🟣 [`tr.use()`](./docs.md#function-truse) - creates a translation function for the specified language
|
|
69
|
-
- 🟣 [`tr.hasKey()`](./docs.md#function-trhaskey) - checks if a key exists in the given language
|
|
70
|
-
- 🟣 [`tr.addTranslations()`](./docs.md#function-traddtranslations) - add a flat or recursive translation object for a language
|
|
71
|
-
- 🟣 [`tr.getTranslations()`](./docs.md#function-trgettranslations) - returns the translation object for a language
|
|
72
|
-
- 🟣 [`tr.
|
|
73
|
-
- 🟣 [`tr.
|
|
74
|
-
- 🟣 [`tr.
|
|
75
|
-
- 🟣 [`tr.
|
|
76
|
-
- 🟣 [`tr.
|
|
77
|
-
-
|
|
78
|
-
-
|
|
72
|
+
- 🟣 [`function tr.for()`](./docs.md#function-trfor) - translates a key for the specified language
|
|
73
|
+
- 🟣 [`function tr.use()`](./docs.md#function-truse) - creates a translation function for the specified language
|
|
74
|
+
- 🟣 [`function tr.hasKey()`](./docs.md#function-trhaskey) - checks if a key exists in the given language
|
|
75
|
+
- 🟣 [`function tr.addTranslations()`](./docs.md#function-traddtranslations) - add a flat or recursive translation object for a language
|
|
76
|
+
- 🟣 [`function tr.getTranslations()`](./docs.md#function-trgettranslations) - returns the translation object for a language
|
|
77
|
+
- 🟣 [`function tr.getAllTranslations()`](./docs.md#function-trgetalltranslations) - returns all registered translations
|
|
78
|
+
- 🟣 [`function tr.deleteTranslations()`](./docs.md#function-trdeletetranslations) - delete the translation object for a language
|
|
79
|
+
- 🟣 [`function tr.setFallbackLanguage()`](./docs.md#function-trsetfallbacklanguage) - set the fallback language used when a key is not found in the given language
|
|
80
|
+
- 🟣 [`function tr.getFallbackLanguage()`](./docs.md#function-trgetfallbacklanguage) - returns the fallback language
|
|
81
|
+
- 🟣 [`function tr.addTransform()`](./docs.md#function-traddtransform) - adds a transform function to the translation system for custom argument insertion and much more
|
|
82
|
+
- 🟣 [`function tr.deleteTransform()`](./docs.md#function-trdeletetransform) - removes a transform function
|
|
83
|
+
- 🟩 [`const tr.transforms`](./docs.md#const-trtransforms) - predefined transform functions for quickly adding custom argument insertion
|
|
84
|
+
- 🔷 [`type TrKeys`](./docs.md#type-trkeys) - generic type that extracts all keys from a flat or recursive translation object into a union
|
|
79
85
|
- [**Errors**](./docs.md#error-classes)
|
|
80
|
-
- 🟧 [`PlatformError`](./docs.md#class-platformerror) - thrown when the current platform doesn't support a certain feature, like calling a DOM function in a non-DOM environment
|
|
86
|
+
- 🟧 [`class PlatformError`](./docs.md#class-platformerror) - thrown when the current platform doesn't support a certain feature, like calling a DOM function in a non-DOM environment
|
|
81
87
|
- [**CoreUtils Features** (re-exported for backwards compatibility)](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#table-of-contents)
|
|
82
88
|
- [**Array:**](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#array)
|
|
83
89
|
- 🟣 [`function randomItem()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-randomitem) - Returns a random item from the given array
|
|
@@ -102,6 +108,8 @@ View the documentation of previous major versions:
|
|
|
102
108
|
- 🟧 [`class DataStore`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-datastore) - The main class for the data store
|
|
103
109
|
- 🔷 [`type DataStoreOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datastoreoptions) - Options for the data store
|
|
104
110
|
- 🔷 [`type DataMigrationsDict`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datamigrationsdict) - Dictionary of data migration functions
|
|
111
|
+
- 🔷 [`type DataStoreData`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datastoredata) - The type of the serializable data
|
|
112
|
+
- 🔷 [`type DataStoreEventMap`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datastoreeventmap) - Map of DataStore events
|
|
105
113
|
- 🟧 [`class DataStoreSerializer`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-datastoreserializer) - Serializes and deserializes data for multiple DataStore instances
|
|
106
114
|
- 🔷 [`type DataStoreSerializerOptions`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#type-datastoreserializeroptions) - Options for the DataStoreSerializer
|
|
107
115
|
- 🔷 [`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)
|