@knime/utils 1.11.1 → 1.12.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +67 -14
  3. package/dist/globals.d.ts +8 -0
  4. package/dist/index.js +751 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/src/capitalize.d.ts +20 -0
  7. package/dist/src/capitalize.d.ts.map +1 -0
  8. package/dist/src/dateMinMaxCheck.d.ts +19 -0
  9. package/dist/src/dateMinMaxCheck.d.ts.map +1 -0
  10. package/dist/src/debounce.d.ts +4 -0
  11. package/dist/src/debounce.d.ts.map +1 -0
  12. package/dist/src/fileExtensions.d.ts +33 -0
  13. package/dist/src/fileExtensions.d.ts.map +1 -0
  14. package/dist/src/filters.d.ts +13 -0
  15. package/dist/src/filters.d.ts.map +1 -0
  16. package/dist/src/format.d.ts +39 -0
  17. package/dist/src/format.d.ts.map +1 -0
  18. package/dist/src/getDeepActiveElement.d.ts +3 -0
  19. package/dist/src/getDeepActiveElement.d.ts.map +1 -0
  20. package/{src/getWrappedAroundIndex.ts → dist/src/getWrappedAroundIndex.d.ts} +3 -2
  21. package/dist/src/getWrappedAroundIndex.d.ts.map +1 -0
  22. package/dist/src/hotkeys/enums.d.ts +11 -0
  23. package/dist/src/hotkeys/enums.d.ts.map +1 -0
  24. package/dist/src/hotkeys/format.d.ts +15 -0
  25. package/dist/src/hotkeys/format.d.ts.map +1 -0
  26. package/dist/src/hotkeys/index.d.ts +19 -0
  27. package/dist/src/hotkeys/index.d.ts.map +1 -0
  28. package/dist/src/hotkeys/match.d.ts +12 -0
  29. package/dist/src/hotkeys/match.d.ts.map +1 -0
  30. package/dist/src/hotkeys/modifiers.d.ts +18 -0
  31. package/dist/src/hotkeys/modifiers.d.ts.map +1 -0
  32. package/dist/src/hotkeys/types.d.ts +10 -0
  33. package/dist/src/hotkeys/types.d.ts.map +1 -0
  34. package/dist/src/index.d.ts +21 -0
  35. package/dist/src/index.d.ts.map +1 -0
  36. package/dist/src/intervalUtils.d.ts +114 -0
  37. package/dist/src/intervalUtils.d.ts.map +1 -0
  38. package/{src/localTimezone.ts → dist/src/localTimezone.d.ts} +3 -2
  39. package/dist/src/localTimezone.d.ts.map +1 -0
  40. package/{src/numIntegerDigits.ts → dist/src/numIntegerDigits.d.ts} +3 -2
  41. package/dist/src/numIntegerDigits.d.ts.map +1 -0
  42. package/dist/src/platform/index.d.ts +2 -0
  43. package/dist/src/platform/index.d.ts.map +1 -0
  44. package/dist/src/platform/navigator.d.ts +11 -0
  45. package/dist/src/platform/navigator.d.ts.map +1 -0
  46. package/dist/src/promise/createAbortablePromise.d.ts +32 -0
  47. package/dist/src/promise/createAbortablePromise.d.ts.map +1 -0
  48. package/dist/src/promise/createUnwrappedPromise.d.ts +7 -0
  49. package/dist/src/promise/createUnwrappedPromise.d.ts.map +1 -0
  50. package/dist/src/promise/index.d.ts +4 -0
  51. package/dist/src/promise/index.d.ts.map +1 -0
  52. package/dist/src/promise/retryPromise.d.ts +16 -0
  53. package/dist/src/promise/retryPromise.d.ts.map +1 -0
  54. package/dist/src/sanitization.d.ts +8 -0
  55. package/dist/src/sanitization.d.ts.map +1 -0
  56. package/dist/src/sleep.d.ts +5 -0
  57. package/dist/src/sleep.d.ts.map +1 -0
  58. package/dist/src/truncateString.d.ts +3 -0
  59. package/dist/src/truncateString.d.ts.map +1 -0
  60. package/dist/src/updateDate.d.ts +11 -0
  61. package/dist/src/updateDate.d.ts.map +1 -0
  62. package/{src/updateTime.ts → dist/src/updateTime.d.ts} +3 -11
  63. package/dist/src/updateTime.d.ts.map +1 -0
  64. package/dist/test-utils/index.d.ts +3 -0
  65. package/dist/test-utils/index.d.ts.map +1 -0
  66. package/dist/test-utils/index.js +40 -0
  67. package/dist/test-utils/index.js.map +1 -0
  68. package/dist/test-utils/muteConsole.d.ts +8 -0
  69. package/dist/test-utils/muteConsole.d.ts.map +1 -0
  70. package/package.json +51 -33
  71. package/src/capitalize.ts +0 -45
  72. package/src/dateMinMaxCheck.ts +0 -68
  73. package/src/debounce.ts +0 -28
  74. package/src/fileExtensions.ts +0 -87
  75. package/src/filters.ts +0 -114
  76. package/src/format.ts +0 -113
  77. package/src/formatHotkeys.ts +0 -98
  78. package/src/getDeepActiveElement.ts +0 -9
  79. package/src/hotkeys.ts +0 -32
  80. package/src/index.ts +0 -76
  81. package/src/intervalUtils.ts +0 -434
  82. package/src/navigator.ts +0 -13
  83. package/src/promise/createAbortablePromise.ts +0 -56
  84. package/src/promise/createUnwrappedPromise.ts +0 -17
  85. package/src/promise/index.ts +0 -3
  86. package/src/promise/retryPromise.ts +0 -45
  87. package/src/sanitization.ts +0 -72
  88. package/src/sleep.ts +0 -6
  89. package/src/truncateString.ts +0 -7
  90. package/src/updateDate.ts +0 -23
  91. package/src/uploadManager/index.ts +0 -370
  92. package/test-utils/index.ts +0 -3
  93. package/test-utils/muteConsole.ts +0 -54
  94. /package/{src/audit → audit}/README.md +0 -0
  95. /package/{src/audit → audit}/bulkAudit.js +0 -0
  96. /package/{src/audit → audit}/cli.js +0 -0
  97. /package/{src/config/globals.d.ts → globals.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @knime/utils
2
2
 
3
+ ## 1.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e774645: - `formatFileSize`: now formatted with `pretty-bytes` instead of `filesize`, dropping the `filesize` dependency. Sizes are now rendered in decimal (SI) units to three significant figures (e.g. `1024` → `"1.02 kB"`, `24117248` → `"24.1 MB"`) instead of binary IEC units (`KiB`, `MiB`, `GiB`). The unused `decimals` parameter has been removed (no caller passed it); precision is fixed at three significant figures.
8
+ - c2d135a: - `hotkeys`: added `match(event, hotkeys)` to test a `KeyboardEvent` against an ordered list of `Hotkey` tokens, including support for single-digit ranges (e.g. `"1-9"`) and treating `Backspace` as `Delete` on macOS.
9
+ - `hotkeys.getDefaultSeparator` / `hotkeys.formatHotkeys`: the default separator is now platform-aware — `"+"` on Windows/Linux (e.g. `Ctrl+S`) and `" "` on macOS (e.g. `⌘ S`). Pass a custom `getSeparator` to `formatHotkeys` to override.
10
+ - `Hotkey`: the type now includes `NumberRange` tokens (e.g. `"1-9"`).
11
+ - `hotkeys.formatHotkey`: added an optional `platform` argument to force a platform's modifier glyphs instead of auto-detecting from the user agent. Exposed the `hotkeyPlatform` value and `HotkeyPlatform` type for it.
12
+
13
+ ## 1.11.2
14
+
15
+ ### Patch Changes
16
+
17
+ - 6f1aed0: `@knime/utils`: migrated the package into the KNIME Design System monorepo. The package now builds to `dist` (compiled ESM + type declarations) like the other published packages.
18
+
3
19
  ## 1.11.1
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -1,29 +1,82 @@
1
- # ![Image](https://www.knime.com/sites/default/files/knime_logo_github_40x40_4layers.png) @knime/utils
1
+ # KNIME® Frontend – Utils
2
2
 
3
- Internal utility functions and constants shared across `@knime` packages.
3
+ This package is maintained by the [UI Core Team](mailto:team-ui-core@knime.com).
4
4
 
5
- ## Installation
5
+ It contains framework-agnostic utility functions and constants shared across KNIME projects — date/time formatting, hotkey helpers, string and number utilities, HTML sanitization, file-size and file-extension helpers, promise helpers, and an upload manager. It has no Vue dependency and can be used from any TypeScript/JavaScript project.
6
6
 
7
- To install the `@knime/utils` package, you can use npm:
7
+ It's published as npm package: [@knime/utils]
8
8
 
9
- ```bash
10
- npm install @knime/utils
9
+ ## Why is this not a `@knime/kds-*` package?
10
+
11
+ `@knime/utils` predates the design system and is consumed beyond it. It keeps its original name and is **versioned independently** (currently `1.x`) — it is _not_ part of the `@knime/kds-*` Changesets group. It is also pure TypeScript (no Vue, no styles), so its build does not need the Vue/CSS toolchain the component packages use.
12
+
13
+ ## Development
14
+
15
+ This package is part of the [KNIME Design System monorepo](../../README.md). For setup instructions, see the **[root README](../../README.md)**.
16
+
17
+ ### Testing
18
+
19
+ Unit tests are based on [Vitest]. Run from the monorepo root:
20
+
21
+ ```sh
22
+ pnpm run test:unit # Run all unit tests (packages/*)
23
+ pnpm run coverage # Generate coverage reports
24
+ ```
25
+
26
+ Date/time tests assert against a fixed timezone (`Europe/Berlin`), configured in [`vite.config.ts`](vite.config.ts).
27
+
28
+ ### Logging
29
+
30
+ You can log using the global `consola` variable (which the embedding application needs to provide).
31
+
32
+ See https://github.com/nuxt/consola for details.
33
+
34
+ ## Building
35
+
36
+ To build the package as an ES library:
37
+
38
+ ```sh
39
+ pnpm run build # Build only this package
11
40
  ```
12
41
 
13
- ## Usage
42
+ Results are saved to `dist/` (compiled ESM plus type declarations under `dist/src`).
43
+
44
+ ## Using the utilities in an application
45
+
46
+ Install the [@knime/utils] npm package as a dependency:
47
+
48
+ ```sh
49
+ pnpm add @knime/utils
50
+ ```
14
51
 
15
- To use it in your project, you can import it as follows:
52
+ ```ts
53
+ import { capitalize, formatFileSize, sleep } from "@knime/utils";
16
54
 
17
- ```javascript
18
- import { capitalize } from "@knime/utils";
55
+ capitalize("hello"); // "Hello"
56
+ formatFileSize(1024); // "1.02 kB"
57
+ await sleep(100);
19
58
  ```
20
59
 
60
+ ### Subpath exports
61
+
62
+ | Entry | Description |
63
+ | --------------------------- | ---------------------------------------------------------------- |
64
+ | `@knime/utils` | The utility functions and constants |
65
+ | `@knime/utils/test-utils` | Test helpers (e.g. `muteConsole`) |
66
+ | `@knime/utils/globals.d.ts` | Ambient `consola` global declaration (reference from a `*.d.ts`) |
67
+ | `@knime/utils/audit` | Programmatic API for the bulk advisory audit |
68
+
69
+ ### Requirements
70
+
71
+ The embedding app must provide:
72
+
73
+ - A `consola` instance compatible with the version defined in [`package.json`](package.json)
74
+
21
75
  ## Audit tool
22
76
 
23
77
  This package also ships a CLI tool (`pnpm-bulk-audit`) that audits dependencies
24
78
  using the npm bulk advisory API — a drop-in workaround while `pnpm audit` is
25
- broken. See [src/audit/README.md](src/audit/README.md) for details.
26
-
27
- # Join the Community!
79
+ broken. See [audit/README.md](audit/README.md) for details.
28
80
 
29
- - [KNIME Forum](https://forum.knime.com/)
81
+ [Vitest]: https://vitest.dev/
82
+ [@knime/utils]: https://www.npmjs.com/package/@knime/utils
@@ -0,0 +1,8 @@
1
+ import { ConsolaInstance } from 'consola';
2
+ declare global {
3
+ const consola: ConsolaInstance;
4
+
5
+ interface Window {
6
+ consola: ConsolaInstance;
7
+ }
8
+ }