@knime/hub-features 1.21.2 → 1.22.1

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,17 @@
1
1
  # @knime/hub-features
2
2
 
3
+ ## 1.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d0c7524: KDS-659: avoid instanceof; it fails with mulitple ofetch versions
8
+
9
+ ## 1.22.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 395300b: allow embedding failure to be sent after initialization step
14
+
3
15
  ## 1.21.2
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/hub-features",
3
- "version": "1.21.2",
3
+ "version": "1.22.1",
4
4
  "description": "Vue components & composables for shared hub features",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,9 +36,9 @@
36
36
  "lodash-es": "4.17.23",
37
37
  "ofetch": "^1.4.1",
38
38
  "typescript": "^5.9.3",
39
- "@knime/components": "1.45.7",
39
+ "@knime/styles": "1.15.0",
40
40
  "@knime/utils": "1.10.0",
41
- "@knime/styles": "1.15.0"
41
+ "@knime/components": "1.45.7"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "consola": "3.x",
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-use-before-define */
2
1
  import { MESSAGES } from "./messages";
3
2
  import {
4
3
  type EmbeddingContext,
@@ -20,9 +19,7 @@ export const init = (callbacks: {
20
19
  onReady: () => void;
21
20
  onError: (error: Error) => void;
22
21
  }) => {
23
- function teardown() {
24
- window.removeEventListener("message", onMessage);
25
- }
22
+ let _initDone = false;
26
23
 
27
24
  function onMessage(event: MessageEvent) {
28
25
  if (!messageValidators.isInitializationMessage(event)) {
@@ -30,9 +27,13 @@ export const init = (callbacks: {
30
27
  }
31
28
 
32
29
  if (event.data?.type === MESSAGES.AWAITING_EMBEDDING_CONTEXT) {
30
+ if (_initDone) {
31
+ return;
32
+ }
33
+
33
34
  logger().info("Got confirmation to send embedding context");
34
35
  callbacks.onReady();
35
- teardown();
36
+ _initDone = true;
36
37
  }
37
38
 
38
39
  if (event.data?.type === MESSAGES.EMBEDDING_FAILED) {
@@ -40,7 +41,6 @@ export const init = (callbacks: {
40
41
  event: event.data,
41
42
  });
42
43
  callbacks.onError(event.data.error);
43
- teardown();
44
44
  }
45
45
  }
46
46
 
@@ -41,12 +41,22 @@ const toToast = ({
41
41
  };
42
42
  };
43
43
 
44
+ const isFetchError = (error: unknown): error is FetchError => {
45
+ return (
46
+ error !== null &&
47
+ typeof error === "object" &&
48
+ "response" in error &&
49
+ "statusCode" in error &&
50
+ "data" in error
51
+ );
52
+ };
53
+
44
54
  /**
45
55
  * Parse an ofetch's `FetchError` to an `RFCError`.
46
56
  * When parsing is not possible it returns undefined.
47
57
  */
48
58
  const tryParse = (error: unknown): RFCError | undefined => {
49
- if (!(error instanceof FetchError)) {
59
+ if (!isFetchError(error)) {
50
60
  return undefined;
51
61
  }
52
62