@getuserfeedback/react-native 4.0.3 → 4.0.5

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/dist/index.js CHANGED
@@ -53,9 +53,6 @@ const createReactNativeFlowRunController = (flowId, { enqueueFlowCommand, enqueu
53
53
  reportCommandError(error instanceof Error ? error : new Error(String(error)));
54
54
  throw error;
55
55
  });
56
- const clearResolvedHandle = () => {
57
- handleClient.clearResolvedHandle();
58
- };
59
56
  const reset = () => {
60
57
  handleClient.reset();
61
58
  };
@@ -91,8 +88,10 @@ const createReactNativeFlowRunController = (flowId, { enqueueFlowCommand, enqueu
91
88
  close: () => {
92
89
  return reportAsyncCommandError(handleClient.runResolvedHandleCommand((flowHandleId) => flowHandleId, enqueueScopedClose));
93
90
  },
94
- clearResolvedHandle,
95
91
  hasFlowHandleId: (flowHandleId) => handleClient.getHandleId() === flowHandleId,
92
+ invalidateResolvedHandle: (flowHandleId) => {
93
+ handleClient.invalidateResolvedHandle(flowHandleId);
94
+ },
96
95
  reset,
97
96
  resetIdleHandle,
98
97
  };
@@ -414,7 +413,7 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
414
413
  const handleFlowHandleInvalidated = useCallback((flowHandleId) => {
415
414
  for (const flowRun of flowRunsRef.current.values()) {
416
415
  if (flowRun.hasFlowHandleId(flowHandleId)) {
417
- flowRun.clearResolvedHandle();
416
+ flowRun.invalidateResolvedHandle(flowHandleId);
418
417
  }
419
418
  }
420
419
  setWidgetHostVisibility((visibility) => clearFlowHandleFromVisibility(visibility, flowHandleId));
@@ -2,7 +2,9 @@ import { type CoreCommandEnvelope } from "@getuserfeedback/protocol";
2
2
  import { type CommandSettledSuccessDetail } from "@getuserfeedback/protocol/host";
3
3
  import type { NativeCoreCommandChannel } from "./native-core-command-channel.js";
4
4
  export type NativeCoreCommandSession = {
5
- dispatch: (envelope: CoreCommandEnvelope) => Promise<CommandSettledSuccessDetail>;
5
+ dispatch: (envelope: CoreCommandEnvelope, options?: {
6
+ settlementTimeoutMs?: number;
7
+ }) => Promise<CommandSettledSuccessDetail>;
6
8
  };
7
9
  type NativeCoreCommandSessionOwner = {
8
10
  dispose: () => void;
@@ -10,5 +12,6 @@ type NativeCoreCommandSessionOwner = {
10
12
  };
11
13
  export declare function createNativeCoreCommandSession(input: {
12
14
  channel: NativeCoreCommandChannel;
15
+ settlementTimeoutMs?: number;
13
16
  }): NativeCoreCommandSessionOwner;
14
17
  export {};
@@ -1,6 +1,7 @@
1
1
  import { coreCommandEnvelopeSchema, } from "@getuserfeedback/protocol";
2
- import { toCommandSettlementError, } from "@getuserfeedback/protocol/host";
2
+ import { CommandSettlementTimeoutError, toCommandSettlementError, } from "@getuserfeedback/protocol/host";
3
3
  import { createPendingCommandTracker } from "./view-orchestration-runtime.js";
4
+ const DEFAULT_COMMAND_SETTLEMENT_TIMEOUT_MS = 30000;
4
5
  class NativeCoreCommandSessionClosedError extends Error {
5
6
  constructor(requestId) {
6
7
  super("Native core command session closed before settlement");
@@ -24,7 +25,16 @@ function toCommandSettledDetail(settlement) {
24
25
  export function createNativeCoreCommandSession(input) {
25
26
  const pendingCommands = createPendingCommandTracker();
26
27
  const pendingIdentityByRequestId = new Map();
28
+ const timeoutByRequestId = new Map();
27
29
  let disposed = false;
30
+ const clearPendingTimeout = (requestId) => {
31
+ const timeout = timeoutByRequestId.get(requestId);
32
+ if (timeout === undefined) {
33
+ return;
34
+ }
35
+ clearTimeout(timeout);
36
+ timeoutByRequestId.delete(requestId);
37
+ };
28
38
  const unsubscribeSettlements = input.channel.subscribe((settlement) => {
29
39
  const detail = toCommandSettledDetail(settlement);
30
40
  const pendingIdentity = pendingIdentityByRequestId.get(detail.requestId);
@@ -34,6 +44,7 @@ export function createNativeCoreCommandSession(input) {
34
44
  return;
35
45
  }
36
46
  pendingIdentityByRequestId.delete(detail.requestId);
47
+ clearPendingTimeout(detail.requestId);
37
48
  if (detail.ok) {
38
49
  pendingCommands.resolve(detail.requestId, detail);
39
50
  return;
@@ -42,7 +53,8 @@ export function createNativeCoreCommandSession(input) {
42
53
  });
43
54
  return {
44
55
  session: {
45
- dispatch: async (envelope) => {
56
+ dispatch: async (envelope, options) => {
57
+ var _a, _b;
46
58
  if (disposed) {
47
59
  return Promise.reject(new Error("Native core command session is closed"));
48
60
  }
@@ -52,11 +64,17 @@ export function createNativeCoreCommandSession(input) {
52
64
  instanceId: canonicalEnvelope.instanceId,
53
65
  kind: canonicalEnvelope.command.kind,
54
66
  });
67
+ timeoutByRequestId.set(canonicalEnvelope.requestId, setTimeout(() => {
68
+ pendingIdentityByRequestId.delete(canonicalEnvelope.requestId);
69
+ timeoutByRequestId.delete(canonicalEnvelope.requestId);
70
+ pendingCommands.reject(canonicalEnvelope.requestId, new CommandSettlementTimeoutError(canonicalEnvelope.requestId));
71
+ }, Math.max(0, (_b = (_a = options === null || options === void 0 ? void 0 : options.settlementTimeoutMs) !== null && _a !== void 0 ? _a : input.settlementTimeoutMs) !== null && _b !== void 0 ? _b : DEFAULT_COMMAND_SETTLEMENT_TIMEOUT_MS)));
55
72
  try {
56
73
  input.channel.post(canonicalEnvelope);
57
74
  }
58
75
  catch (error) {
59
76
  pendingIdentityByRequestId.delete(canonicalEnvelope.requestId);
77
+ clearPendingTimeout(canonicalEnvelope.requestId);
60
78
  pendingCommands.reject(canonicalEnvelope.requestId, error instanceof Error ? error : new Error(String(error)));
61
79
  }
62
80
  return settlement;
@@ -69,6 +87,10 @@ export function createNativeCoreCommandSession(input) {
69
87
  disposed = true;
70
88
  unsubscribeSettlements();
71
89
  pendingIdentityByRequestId.clear();
90
+ for (const timeout of timeoutByRequestId.values()) {
91
+ clearTimeout(timeout);
92
+ }
93
+ timeoutByRequestId.clear();
72
94
  pendingCommands.reset((requestId) => new NativeCoreCommandSessionClosedError(requestId));
73
95
  },
74
96
  };
@@ -19,26 +19,10 @@ import { NativeViewHostProjection, } from "./native-view-host-projection.js";
19
19
  import { createNativeViewRecordController, } from "./native-view-record-controller.js";
20
20
  import { createProviderCommandEnvelope, REACT_NATIVE_CLIENT_META, } from "./provider-command-helpers.js";
21
21
  const DEFAULT_STARTUP_COMMAND_SETTLEMENT_TIMEOUT_MS = 30000;
22
- function dispatchStartupCommand(input) {
23
- let timeoutId;
24
- const timeout = new Promise((_resolve, reject) => {
25
- timeoutId = setTimeout(() => reject(new CommandSettlementTimeoutError(input.envelope.requestId)), Math.max(0, input.timeoutMs));
26
- });
27
- return Promise.race([
28
- input.commandSession.dispatch(input.envelope).then(() => undefined),
29
- timeout,
30
- ]).finally(() => {
31
- if (timeoutId !== undefined) {
32
- clearTimeout(timeoutId);
33
- }
34
- });
35
- }
36
22
  async function dispatchStartupCommands(input) {
37
23
  for (const command of input.commands) {
38
- await dispatchStartupCommand({
39
- commandSession: input.commandSession,
40
- envelope: command,
41
- timeoutMs: input.timeoutMs,
24
+ await input.commandSession.dispatch(command, {
25
+ settlementTimeoutMs: input.timeoutMs,
42
26
  });
43
27
  }
44
28
  }
@@ -135,6 +119,7 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
135
119
  commandChannelOwner.dispose();
136
120
  controller.dispose();
137
121
  const shouldRetry = !(error instanceof CommandSettlementError) &&
122
+ !(error instanceof CommandSettlementTimeoutError) &&
138
123
  !startupRetryAttemptedRef.current;
139
124
  if (shouldRetry) {
140
125
  startupRetryAttemptedRef.current = true;
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.3";
6
+ export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "4.0.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/react-native",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "description": "getuserfeedback React Native SDK",
5
5
  "keywords": [
6
6
  "getuserfeedback",
@@ -44,8 +44,8 @@
44
44
  "lint": "biome check ."
45
45
  },
46
46
  "dependencies": {
47
- "@getuserfeedback/protocol": "^3.25.0",
48
- "@getuserfeedback/sdk": "^0.12.12",
47
+ "@getuserfeedback/protocol": "^3.25.1",
48
+ "@getuserfeedback/sdk": "^0.12.13",
49
49
  "robot3": "^1.2.0"
50
50
  },
51
51
  "peerDependencies": {