Skip to content

v9.0.0 #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
18a46e9
feat: reworked translation system
Sv443 Dec 23, 2024
6ba1fc3
fix: exports order
Sv443 Dec 26, 2024
b28f943
feat: start working on new debouncer class
Sv443 Dec 26, 2024
f2574cb
chore: update deps
Sv443 Jan 11, 2025
c780ae6
feat: debugger with tsx
Sv443 Jan 11, 2025
fff7b00
ref: debouncer stuff
Sv443 Jan 11, 2025
4f52ccd
feat: fix .d.ts whitespaces tool
Sv443 Jan 11, 2025
61706e0
ref: logging in cli tools
Sv443 Jan 11, 2025
0c2e8d2
ref: replace ts-node with node --import tsx
Sv443 Jan 11, 2025
2b62b14
ref: tsdoc stuff
Sv443 Jan 11, 2025
a93a1c9
docs: more clear DataStore documentation
Sv443 Jan 11, 2025
057c1ef
ref: replace any with unknown
Sv443 Jan 11, 2025
2cf8656
feat: complete translation system overhaul
Sv443 Jan 14, 2025
18a2a2a
chore: tsdoc comment newlines changeset
Sv443 Jan 14, 2025
61ac745
feat: unfinished debouncer stuff
Sv443 Jan 14, 2025
9a9f46a
feat: launch cfg stuff
Sv443 Jan 15, 2025
95a6ef8
docs: NanoEmitter comments
Sv443 Jan 15, 2025
addc119
feat: queuedImmediate Debouncer done
Sv443 Jan 15, 2025
4709526
ref!: rename debouncer edge types & remove discardingImmediate
Sv443 Jan 15, 2025
6e00171
feat: new debounce type sketch
Sv443 Jan 15, 2025
858d501
fix: selectorobserver default debounce type
Sv443 Jan 15, 2025
4ef0932
ref: remove old debounce & change links
Sv443 Jan 15, 2025
422622d
docs: debouncer docs & rename usage to signature
Sv443 Jan 22, 2025
e95d835
docs: fix stuff
Sv443 Jan 22, 2025
962e8cd
ref: separate docs file (#71) & edit links
Sv443 Jan 22, 2025
217e160
fix: randRange with enhancedEntropy only returning first digit
Sv443 Jan 22, 2025
a85f9c6
feat: changesets
Sv443 Jan 22, 2025
007aa9d
docs: fix StringGen and ValueGen documentation
Sv443 Jan 22, 2025
5bf974d
feat: add argument `additionalProps` to `openInNewTab()`
Sv443 Jan 22, 2025
8be8ba6
docs: change description
Sv443 Jan 22, 2025
dfa265e
docs: LooseUnion in translation docs
Sv443 Jan 22, 2025
99d268d
fix: don't backtrack on translation key if nested value was not found
Sv443 Jan 22, 2025
4b0ab30
ref: changeset
Sv443 Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/beige-dots-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
"@sv443-network/userutils": major
---

**BREAKING** - Reworked translation system:
- Removed `tr()`, `tr.setLanguage()` and `tr.getLanguage()`
- Renamed function `tr.addLanguage()` to `tr.addTranslations()`
- Removed `%n`-based argument insertion by default (re-enable explicitly with `tr.addTransform(tr.transforms.percent)`).
- Added ability for nested translation objects and object traversal via dot notation.
- Added functions:
- `tr.for()` - translates a key for the specified language.
- `tr.use()` - creates a translation function for the specified language for much easier usage.
- `tr.hasKey()` - checks if a key exists in the given language.
- `tr.setFallbackLanguage()` - sets the fallback language used when a key is not found in the given language.
- `tr.getFallbackLanguage()` - returns the fallback language.
- `tr.addTransform()` - adds a transform function to the translation system, allowing for custom argument insertion and much more.
- `tr.deleteTransform()` - removes a transform function.
- Added ability to specify transform patterns and functions for arbitrary modification of the translation string.
- Added transform for template literal syntax (e.g. `${keyName}`) with `tr.addTransform(tr.transforms.templateLiteral)`. This transform supports positional argument injection, as well as named arguments via an object with the same keys as in the template literal pattern. See the documentation for more information and a code example.
- Added TS type `TrKeys<T>` for extracting the keys of a translation object (both flat and nested).
- Fixed bug with resolving translations for flat objects.
5 changes: 5 additions & 0 deletions .changeset/eighty-cooks-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sv443-network/userutils": patch
---

Fixed newlines being collapsed in TSDoc comments.
5 changes: 5 additions & 0 deletions .changeset/great-donuts-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sv443-network/userutils": minor
---

Added `additionalProps` parameter to `openInNewTab()` to add or overwrite anchor element props (only if `GM.openInTab()` is unavailable)
15 changes: 15 additions & 0 deletions .changeset/grumpy-toys-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@sv443-network/userutils": major
---

**BREAKING** - Reworked debounce system:
- Edge types `rising` and `falling` have been removed.
- Added new edge types `immediate` and `idle` with new behavior.
- `immediate` (default & recommended) will trigger immediately, then queue all subsequent calls until the timeout has passed.
- `idle` will trigger the last queued call only after there haven't been any subsequent calls for the specified timeout.
- Added `Debouncer` class for more advanced control over debouncing, and with that the following changes:
- Ability to attach and manage multiple listeners.
- Inherits from NanoEmitter, allowing event-based debouncing.
- Can be inherited by your own classes for built-in debouncing.
- `debounce()` function can still be called as usual (after replacing the edge type names with the new ones). Internally, it will instantiate a `Debouncer` instance, which is available via the `debouncer` property on the returned function.
- Reduced default timeout from 300ms to 200ms.
5 changes: 5 additions & 0 deletions .changeset/rude-trains-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sv443-network/userutils": patch
---

Fixed `randRange()` with `enhancedEntropy = true` only returning the first digit.
5 changes: 5 additions & 0 deletions .changeset/shiny-icons-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sv443-network/userutils": minor
---

Moved documentation to separate file `docs.md` to speed up `README.md` load time.
Binary file added .github/assets/debounce.pdn
Binary file not shown.
Binary file modified .github/assets/debounce.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .github/assets/debounce_v2.pdn
Binary file not shown.
Binary file removed .github/assets/debounce_v2.png
Binary file not shown.
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "fix-dts",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/tools/fix-dts.mts",
"runtimeExecutable": "tsx",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
]
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/test.ts",
"runtimeExecutable": "tsx",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
]
},
]
}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@
- separate instances can have different MutationObserver options set to further reduce performance impact
- the separation into instances allows for a new "chaining" paradigm where selector listeners are only added and checked for once they are actually needed (see examples in the documentation)
- when using chaining, separate instances can be created and have listeners added to them before their base element is available in the DOM tree
- every listener can have a set debounce time, so that it doesn't get called too often (works the same as the [`debounce()` function](https://github.com/Sv443-Network/UserUtils/blob/main/README.md#debounce), but is disabled by default)
- every listener can have a set debounce time, so that it doesn't get called too often (works the same as the [`debounce()` function](https://github.com/Sv443-Network/UserUtils/blob/v3.0.0/README.md#debounce), but is disabled by default)
- there are now multiple methods to get and delete specific listeners

The `SelectorObserver.addListener()` method is backwards compatible with the old `onSelector()` function, so you can just add the class instance in front (for full backwards compat use `document.body` for the `baseElement` parameter of the constructor), then change the old function's name and it should work as before.
For more info and examples, please view the [SelectorObserver documentation](https://github.com/Sv443-Network/UserUtils/blob/main/README.md#selectorobserver)
For more info and examples, please view the [SelectorObserver documentation](https://github.com/Sv443-Network/UserUtils/blob/v3.0.0/README.md#selectorobserver)

### Minor Changes

Expand Down
Loading
Loading