@knime/utils 1.3.2 → 1.4.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,10 +1,23 @@
1
1
  # @knime/utils
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - dea510f: Moved getMetaOrCtrlKey from navigator util to hotkeys util
8
+
9
+ ## 1.3.3
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [6e1501f]
14
+ - @knime/styles@1.4.0
15
+
3
16
  ## 1.3.2
4
17
 
5
18
  ### Patch Changes
6
19
 
7
- - ee229d3: add isWindows check to navigator utils
20
+ - bb186d1: add isWindows check to navigator utils
8
21
 
9
22
  ## 1.3.1
10
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/utils",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Internal utility functions and constants shared across @knime packages.",
5
5
  "homepage": "https://knime.github.io/webapps-common/",
6
6
  "license": "GPL 3 and Additional Permissions according to Sec. 7 (SEE the file LICENSE)",
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "date-fns": "2.30.0",
11
11
  "date-fns-tz": "2.0.0",
12
- "@knime/styles": "1.3.1"
12
+ "@knime/styles": "1.4.0"
13
13
  },
14
14
  "peerDependencies": {
15
15
  "consola": "3.x"
@@ -1,3 +1,9 @@
1
- /* eslint-disable one-var */
1
+ import type { ConsolaInstance } from "consola";
2
2
 
3
- declare const consola: import("consola").ConsolaInstance;
3
+ declare global {
4
+ const consola: ConsolaInstance;
5
+
6
+ interface Window {
7
+ consola: ConsolaInstance;
8
+ }
9
+ }
package/src/filters.ts CHANGED
@@ -65,7 +65,7 @@ const modeDefinitions = [
65
65
  try {
66
66
  const flags = caseSensitiveSearch ? "" : "i";
67
67
  return new RegExp(searchTerm, flags);
68
- } catch (error) {
68
+ } catch (_error) {
69
69
  // In case of an invalid regular expression, an impossible
70
70
  // regex is returned, not matching anything.
71
71
  return /$^/;
@@ -82,7 +82,7 @@ const modeDefinitions = [
82
82
  try {
83
83
  const flags = caseSensitiveSearch ? "" : "i";
84
84
  return new RegExp(`^(${searchTerm})$`, flags);
85
- } catch (error) {
85
+ } catch (_error) {
86
86
  // In case of an invalid regular expression, an impossible
87
87
  // regex is returned, not matching anything.
88
88
  return /$^/;
package/src/format.ts CHANGED
@@ -13,7 +13,7 @@ export const formatDateString = (
13
13
  ) => {
14
14
  const date = new Date(dateString);
15
15
 
16
- // @ts-ignore
16
+ // @ts-expect-error Argument of type 'Date' is not assignable to parameter of type 'number'
17
17
  if (isNaN(date)) {
18
18
  throw Error("Invalid Date format");
19
19
  }
@@ -47,7 +47,7 @@ export const formatTimeString = (
47
47
  ) => {
48
48
  const time = new Date(timeString);
49
49
 
50
- // @ts-ignore
50
+ // @ts-expect-error Argument of type 'Date' is not assignable to parameter of type 'number'
51
51
  if (isNaN(time)) {
52
52
  throw Error("Invalid Date format");
53
53
  }
@@ -79,7 +79,6 @@ export const formatDateTimeString = (
79
79
  dateTimeString: string | number,
80
80
  useTimeZone = false,
81
81
  ) => {
82
- // eslint-disable-line arrow-body-style
83
82
  return `${formatDateString(dateTimeString, useTimeZone)} ${formatTimeString(
84
83
  dateTimeString,
85
84
  useTimeZone,
package/src/hotkeys.ts CHANGED
@@ -27,6 +27,6 @@ export const isKeyWithoutModifiers = (
27
27
  *
28
28
  * @returns name of the primary modifier key for the current platform
29
29
  */
30
- export const getMetaOrCtrlKey = (): string => {
31
- return navigatorUtils.getMetaOrCtrlKey();
30
+ export const getMetaOrCtrlKey = (): "ctrlKey" | "metaKey" => {
31
+ return navigatorUtils.isMac() ? "metaKey" : "ctrlKey";
32
32
  };
@@ -160,7 +160,7 @@ export const formatIntervalToHumanReadableIntervalString = (
160
160
  if (milliSecondsZero) {
161
161
  output += formatPart(toFormat.interval.seconds, "second");
162
162
  } else {
163
- output += `${toFormat.interval.seconds}.${toFormat.interval.milliseconds.toString().padStart(3, "0")} seconds `;
163
+ output += `${toFormat.interval.seconds}.${toFormat.interval.milliseconds.toString().padStart(3, "0")} seconds `; // eslint-disable-line no-magic-numbers
164
164
  }
165
165
  }
166
166
  }
@@ -308,7 +308,7 @@ export const isValidHumanReadableIntervalString = (
308
308
  } else {
309
309
  return { valid: false };
310
310
  }
311
- } catch (e) {
311
+ } catch (_e) {
312
312
  return { valid: false };
313
313
  }
314
314
  };
@@ -384,7 +384,7 @@ export const isValidISOIntervalString = (
384
384
  } else {
385
385
  return { valid: false };
386
386
  }
387
- } catch (e) {
387
+ } catch (_e) {
388
388
  return { valid: false };
389
389
  }
390
390
  };
package/src/navigator.ts CHANGED
@@ -11,17 +11,3 @@ export const isMac = (): boolean =>
11
11
  */
12
12
  export const isWindows = (): boolean =>
13
13
  navigator?.userAgent?.toLowerCase()?.includes("windows");
14
-
15
- /**
16
- * @deprecated Since version 1.3.6. Use `hotkeys.ts` instead.
17
- *
18
- * @returns name of the primary modifier key for the current platform.
19
- */
20
- export const getMetaOrCtrlKey = () => {
21
- if (import.meta.env.DEV) {
22
- consola.warn(
23
- "getMetaOrCtrlKey is deprecated on navigatorUtils. Please use hotkeys.ts instead.",
24
- );
25
- }
26
- return isMac() ? "metaKey" : "ctrlKey";
27
- };
@@ -8,6 +8,7 @@ const methods: ConsoleMethod[] = ["log", "warn", "error", "info"];
8
8
  * @param f The function to run. Can be async.
9
9
  * @returns The original function's return value
10
10
  */
11
+ // TODO: replace Function with fitting top type (...args: never[]) => unknown has unknown return type which makes problems in line 41
11
12
  export default (f: Function) => {
12
13
  const originals = methods.map((method) => console[method]);
13
14
  methods.forEach((method) => {
@@ -15,11 +16,11 @@ export default (f: Function) => {
15
16
  });
16
17
 
17
18
  let originalConsola: typeof consola;
18
- // @ts-ignore - needs to extend the globalThis namespace
19
+ // @ts-expect-error Property 'consola' does not exist on type 'typeof globalThis'.
19
20
  if (global.consola) {
20
- // @ts-ignore
21
+ // @ts-expect-error Property 'consola' does not exist on type 'typeof globalThis'.
21
22
  originalConsola = global.consola;
22
- // @ts-ignore
23
+ // @ts-expect-error Property 'consola' does not exist on type 'typeof globalThis'.
23
24
  global.consola = consola.create({
24
25
  level: -1,
25
26
  });
@@ -30,7 +31,7 @@ export default (f: Function) => {
30
31
  console[method] = originals[i];
31
32
  });
32
33
  if (originalConsola) {
33
- // @ts-ignore
34
+ // @ts-expect-error Property 'consola' does not exist on type 'typeof globalThis'.
34
35
  global.consola = originalConsola;
35
36
  }
36
37
  };