@getuserfeedback/react-native 4.0.8 → 4.0.9

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.
@@ -1,4 +1,5 @@
1
1
  import { type CoreCommandEnvelope } from "@getuserfeedback/protocol";
2
+ import { type EventHandleInvalidated } from "@getuserfeedback/protocol/internal/core-handle-invalidation";
2
3
  import { type EventCommandSettled } from "@getuserfeedback/protocol/internal/core-host-command-settlement";
3
4
  import type { CoreWebViewHostConnection } from "./core-webview-host-controller.js";
4
5
  export type NativeCoreCommandChannel = {
@@ -11,6 +12,7 @@ type OwnedNativeCoreCommandChannel = {
11
12
  };
12
13
  export declare function createNativeCoreCommandChannel(input: {
13
14
  coreConnection: CoreWebViewHostConnection;
15
+ onHandleInvalidated?: (message: EventHandleInvalidated) => void;
14
16
  onInvalidMessage?: (error: Error, value: unknown) => void;
15
17
  }): OwnedNativeCoreCommandChannel;
16
18
  export {};
@@ -1,4 +1,5 @@
1
1
  import { coreCommandEnvelopeSchema, } from "@getuserfeedback/protocol";
2
+ import { eventHandleInvalidatedSchema, } from "@getuserfeedback/protocol/internal/core-handle-invalidation";
2
3
  import { eventCommandSettledSchema, } from "@getuserfeedback/protocol/internal/core-host-command-settlement";
3
4
  const DISPOSED_MESSAGE = "Core command channel is disposed";
4
5
  const isRecord = (value) => typeof value === "object" && value !== null;
@@ -6,7 +7,7 @@ export function createNativeCoreCommandChannel(input) {
6
7
  const listeners = new Set();
7
8
  let disposed = false;
8
9
  const handleMessage = (value) => {
9
- var _a;
10
+ var _a, _b, _c;
10
11
  if (disposed || !isRecord(value)) {
11
12
  return;
12
13
  }
@@ -26,6 +27,20 @@ export function createNativeCoreCommandChannel(input) {
26
27
  }
27
28
  return;
28
29
  }
30
+ if (value.t !== "getuserfeedback:event:handleInvalidated") {
31
+ return;
32
+ }
33
+ const parsed = eventHandleInvalidatedSchema.safeParse(value);
34
+ if (!parsed.success) {
35
+ (_b = input.onInvalidMessage) === null || _b === void 0 ? void 0 : _b.call(input, parsed.error instanceof Error
36
+ ? parsed.error
37
+ : new Error("Invalid core handle invalidation message"), value);
38
+ return;
39
+ }
40
+ if (parsed.data.gen !== input.coreConnection.generation) {
41
+ return;
42
+ }
43
+ (_c = input.onHandleInvalidated) === null || _c === void 0 ? void 0 : _c.call(input, parsed.data);
29
44
  };
30
45
  const unsubscribeTransport = input.coreConnection.transport.subscribe(handleMessage);
31
46
  const channel = {
@@ -1,4 +1,5 @@
1
1
  import type { CoreCommandEnvelope } from "@getuserfeedback/protocol";
2
+ import type { EventHandleInvalidated } from "@getuserfeedback/protocol/internal/core-handle-invalidation";
2
3
  import type { ConfigureOptions, InitOptions } from "@getuserfeedback/sdk";
3
4
  import { type ReactElement } from "react";
4
5
  import { type CoreWebViewHostProps } from "./core-webview-host.js";
@@ -13,6 +14,7 @@ export type NativeRuntimeRootProps = {
13
14
  startupCommands?: NativeRuntimeStartupCommands;
14
15
  onCommandSessionChange?: (session: NativeCoreCommandSession | null) => void;
15
16
  onError?: (error: Error) => void;
17
+ onHandleInvalidated?: (message: EventHandleInvalidated) => void;
16
18
  onInvalidMessage?: (error: Error, value: unknown) => void;
17
19
  onStartupTerminalError?: (error: Error) => void;
18
20
  startupCommandSettlementTimeoutMs?: number;
@@ -39,6 +41,6 @@ type NativeProviderRuntimeProps = Omit<NativeRuntimeRootProps, "onCommandSession
39
41
  instanceId: string;
40
42
  onCommandSessionChange?: (session: NativeDirectCommandSession | null) => void;
41
43
  };
42
- export declare function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onCommandSessionChange, onError, onInvalidMessage, onStartupTerminalError, startupCommandSettlementTimeoutMs, startupCommands, viewNativeViewComponent, viewWebViewComponent, viewWebViewProps, }: NativeRuntimeRootProps): ReactElement;
44
+ export declare function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onCommandSessionChange, onError, onHandleInvalidated, onInvalidMessage, onStartupTerminalError, startupCommandSettlementTimeoutMs, startupCommands, viewNativeViewComponent, viewWebViewComponent, viewWebViewProps, }: NativeRuntimeRootProps): ReactElement;
43
45
  export declare function NativeProviderRuntime({ directSessionController, initOptions, initialConfigureOptions, instanceId, onCommandSessionChange, onError, ...runtimeProps }: NativeProviderRuntimeProps): ReactElement;
44
46
  export {};
@@ -26,7 +26,7 @@ async function dispatchStartupCommands(input) {
26
26
  });
27
27
  }
28
28
  }
29
- export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onCommandSessionChange, onError, onInvalidMessage, onStartupTerminalError, startupCommandSettlementTimeoutMs = DEFAULT_STARTUP_COMMAND_SETTLEMENT_TIMEOUT_MS, startupCommands, viewNativeViewComponent, viewWebViewComponent, viewWebViewProps, }) {
29
+ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onCommandSessionChange, onError, onHandleInvalidated, onInvalidMessage, onStartupTerminalError, startupCommandSettlementTimeoutMs = DEFAULT_STARTUP_COMMAND_SETTLEMENT_TIMEOUT_MS, startupCommands, viewNativeViewComponent, viewWebViewComponent, viewWebViewProps, }) {
30
30
  const [coreHostRevision, setCoreHostRevision] = useState(0);
31
31
  const [session, setSession] = useState(null);
32
32
  const sessionRef = useRef(null);
@@ -36,6 +36,8 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
36
36
  onErrorRef.current = onError;
37
37
  const onCommandSessionChangeRef = useRef(onCommandSessionChange);
38
38
  onCommandSessionChangeRef.current = onCommandSessionChange;
39
+ const onHandleInvalidatedRef = useRef(onHandleInvalidated);
40
+ onHandleInvalidatedRef.current = onHandleInvalidated;
39
41
  const onInvalidMessageRef = useRef(onInvalidMessage);
40
42
  onInvalidMessageRef.current = onInvalidMessage;
41
43
  const onStartupTerminalErrorRef = useRef(onStartupTerminalError);
@@ -77,6 +79,15 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
77
79
  });
78
80
  const commandChannelOwner = createNativeCoreCommandChannel({
79
81
  coreConnection,
82
+ onHandleInvalidated: (message) => {
83
+ var _a;
84
+ try {
85
+ (_a = onHandleInvalidatedRef.current) === null || _a === void 0 ? void 0 : _a.call(onHandleInvalidatedRef, message);
86
+ }
87
+ catch (error) {
88
+ reportError(error);
89
+ }
90
+ },
80
91
  onInvalidMessage: (error, value) => { var _a; return (_a = onInvalidMessageRef.current) === null || _a === void 0 ? void 0 : _a.call(onInvalidMessageRef, error, value); },
81
92
  });
82
93
  const commandSessionOwner = createNativeCoreCommandSession({
package/dist/version.js CHANGED
@@ -3,4 +3,4 @@ const reactNativeSdkVersion = typeof __GX_REACT_NATIVE_SDK_VERSION__ === "string
3
3
  : "";
4
4
  // Build scripts patch this fallback to the package version for published artifacts.
5
5
  // Source-linked workspace usage keeps the local fallback.
6
- export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "4.0.8";
6
+ export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "4.0.9";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/react-native",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "description": "getuserfeedback React Native SDK",
5
5
  "keywords": [
6
6
  "getuserfeedback",