@sv443-network/userutils 10.0.6 → 10.1.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @sv443-network/userutils
2
2
 
3
+ ## 10.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c42bf93: Added constant object `versions` to find out the versions of UserUtils and the bundled and re-exported CoreUtils library at runtime.
8
+ - 7a81eba: Added translation transform `tr.transforms.i18n`, which works similar to `templateLiteral` but matches the commonly used i18n pattern `{{key}}`.
9
+ - fe726cd: Added function `tr.getAllTranslations()` to return a mutable or immutable (default) object of all registered translations.
10
+
11
+ ### Patch Changes
12
+
13
+ - 6118f4a: Updated CoreUtils to v3.3.0.
14
+ This fixes various `DataStore` and `DataStoreEngine` issues and adds `NanoEmitter` into `DataStore`'s inheritance chain, including many new events.
15
+ 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.
16
+ - ca4c9ed: An empty string can now be used as a valid translation language.
17
+ 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.
18
+ 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.
19
+ 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.
20
+
3
21
  ## 10.0.6
4
22
 
5
23
  ### 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>Everything is re-exported by UserUtils for backwards compatibility, but you may want to consider using CoreUtils directly if you don't need any of the DOM- or GreaseMonkey-specific features or want control over the installed version of CoreUtils.</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.deleteTranslations()`](./docs.md#function-trdeletetranslations) - delete the translation object for a language
73
- - 🟣 [`tr.setFallbackLanguage()`](./docs.md#function-trsetfallbacklanguage) - set the fallback language used when a key is not found in the given language
74
- - 🟣 [`tr.getFallbackLanguage()`](./docs.md#function-trgetfallbacklanguage) - returns the fallback language
75
- - 🟣 [`tr.addTransform()`](./docs.md#function-traddtransform) - adds a transform function to the translation system for custom argument insertion and much more
76
- - 🟣 [`tr.deleteTransform()`](./docs.md#function-trdeletetransform) - removes a transform function
77
- - 🟩 [`tr.transforms`](./docs.md#const-trtransforms) - predefined transform functions for quickly adding custom argument insertion
78
- - 🔷 [`TrKeys`](./docs.md#type-trkeys) - generic type that extracts all keys from a flat or recursive translation object into a union
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