@getuserfeedback/react-native 3.0.76 → 3.0.79

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.
@@ -8,15 +8,10 @@ type NativeFlowAllocationCommand = (Omit<Extract<CoreTranslatablePublicCommandPa
8
8
  }) | Extract<CoreTranslatablePublicCommandPayload, {
9
9
  kind: "prefetch" | "prerender";
10
10
  }>;
11
- type NativeScopedCloseCommand = Extract<CoreTranslatablePublicCommandPayload, {
12
- kind: "close";
13
- }> & {
14
- flowHandleId: string;
15
- };
16
11
  /** Public commands accepted by the direct native provider session. */
17
12
  type NativeDirectCommandPayload = Exclude<CoreTranslatablePublicCommandPayload, {
18
- kind: "init" | "open" | "prefetch" | "prerender" | "close" | "reset";
19
- }> | NativeFlowAllocationCommand | NativeScopedCloseCommand;
13
+ kind: "init" | "open" | "prefetch" | "prerender" | "reset";
14
+ }> | NativeFlowAllocationCommand;
20
15
  /** Public command envelope accepted by the direct native provider session. */
21
16
  export type NativeDirectCommandEnvelope = Omit<CommandEnvelopeWithInstanceId, "command"> & {
22
17
  command: NativeDirectCommandPayload;
@@ -1,6 +1,6 @@
1
1
  import { getFlowHandleFromSettlementDetail } from "@getuserfeedback/protocol/host";
2
2
  import { toCoreCommandPayload, } from "@getuserfeedback/protocol/internal/public-core-command";
3
- // TODO(migration): Route reset, unscoped close, and the public provider client through this core-ordered direct session.
3
+ // TODO(migration): Route reset and the public provider client through this core-ordered direct session.
4
4
  // [from=native-core-ordered-command-session] [to=native-provider-direct-session] [scope=slice] [principle=core-owned-flow-lifecycle] [priority=high] [impact=high] [risk=high] [epic=runtime-neutral-view-host-orchestration] [epic_order=180]
5
5
  export function createNativeDirectCommandSession(input) {
6
6
  const dispatchToCore = (envelope, command) => {
@@ -1,5 +1,5 @@
1
1
  import type { CoreCommandEnvelope } from "@getuserfeedback/protocol";
2
- import type { InitOptions } from "@getuserfeedback/sdk";
2
+ import type { ConfigureOptions, InitOptions } from "@getuserfeedback/sdk";
3
3
  import { type ReactElement } from "react";
4
4
  import { type CoreWebViewHostProps } from "./core-webview-host.js";
5
5
  import { type NativeCoreCommandSession } from "./native-core-command-session.js";
@@ -9,24 +9,31 @@ export type NativeRuntimeRootProps = {
9
9
  coreUrl: string;
10
10
  coreWebViewComponent?: CoreWebViewHostProps["webViewComponent"];
11
11
  coreWebViewProps?: CoreWebViewHostProps["webViewProps"];
12
- instanceRegistrationEnvelope?: NativeRuntimeInstanceRegistrationEnvelope;
12
+ startupCommands?: NativeRuntimeStartupCommands;
13
13
  onCommandSessionChange?: (session: NativeCoreCommandSession | null) => void;
14
14
  onError?: (error: Error) => void;
15
15
  onInvalidMessage?: (error: Error, value: unknown) => void;
16
- registrationSettlementTimeoutMs?: number;
16
+ startupCommandSettlementTimeoutMs?: number;
17
17
  viewWebViewComponent?: NativeViewHostProjectionProps["webViewComponent"];
18
18
  viewWebViewProps?: NativeViewHostProjectionProps["webViewProps"];
19
19
  };
20
- type NativeRuntimeInstanceRegistrationEnvelope = Omit<CoreCommandEnvelope, "command"> & {
20
+ type NativeRuntimeInitCommand = Omit<CoreCommandEnvelope, "command"> & {
21
21
  command: Extract<CoreCommandEnvelope["command"], {
22
22
  kind: "init";
23
23
  }>;
24
24
  };
25
- type NativeProviderRuntimeProps = Omit<NativeRuntimeRootProps, "instanceRegistrationEnvelope" | "onCommandSessionChange"> & {
25
+ type NativeRuntimeConfigureCommand = Omit<CoreCommandEnvelope, "command"> & {
26
+ command: Extract<CoreCommandEnvelope["command"], {
27
+ kind: "configure";
28
+ }>;
29
+ };
30
+ type NativeRuntimeStartupCommands = readonly [NativeRuntimeInitCommand] | readonly [NativeRuntimeInitCommand, NativeRuntimeConfigureCommand];
31
+ type NativeProviderRuntimeProps = Omit<NativeRuntimeRootProps, "onCommandSessionChange" | "startupCommands"> & {
32
+ initialConfigureOptions?: ConfigureOptions;
26
33
  initOptions: InitOptions;
27
34
  instanceId: string;
28
35
  onCommandSessionChange?: (session: NativeDirectCommandSession | null) => void;
29
36
  };
30
- export declare function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, instanceRegistrationEnvelope, onCommandSessionChange, onError, onInvalidMessage, registrationSettlementTimeoutMs, viewWebViewComponent, viewWebViewProps, }: NativeRuntimeRootProps): ReactElement;
31
- export declare function NativeProviderRuntime({ initOptions, instanceId, onCommandSessionChange, ...runtimeProps }: NativeProviderRuntimeProps): ReactElement;
37
+ export declare function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onCommandSessionChange, onError, onInvalidMessage, startupCommandSettlementTimeoutMs, startupCommands, viewWebViewComponent, viewWebViewProps, }: NativeRuntimeRootProps): ReactElement;
38
+ export declare function NativeProviderRuntime({ initOptions, initialConfigureOptions, instanceId, onCommandSessionChange, ...runtimeProps }: NativeProviderRuntimeProps): ReactElement;
32
39
  export {};
@@ -18,8 +18,8 @@ import { createNativeDirectCommandSession, } from "./native-direct-command-sessi
18
18
  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
- const DEFAULT_REGISTRATION_SETTLEMENT_TIMEOUT_MS = 30000;
22
- function dispatchRegistration(input) {
21
+ const DEFAULT_STARTUP_COMMAND_SETTLEMENT_TIMEOUT_MS = 30000;
22
+ function dispatchStartupCommand(input) {
23
23
  let timeoutId;
24
24
  const timeout = new Promise((_resolve, reject) => {
25
25
  timeoutId = setTimeout(() => reject(new CommandSettlementTimeoutError(input.envelope.requestId)), Math.max(0, input.timeoutMs));
@@ -33,20 +33,29 @@ function dispatchRegistration(input) {
33
33
  }
34
34
  });
35
35
  }
36
- export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, instanceRegistrationEnvelope, onCommandSessionChange, onError, onInvalidMessage, registrationSettlementTimeoutMs = DEFAULT_REGISTRATION_SETTLEMENT_TIMEOUT_MS, viewWebViewComponent, viewWebViewProps, }) {
36
+ async function dispatchStartupCommands(input) {
37
+ for (const command of input.commands) {
38
+ await dispatchStartupCommand({
39
+ commandSession: input.commandSession,
40
+ envelope: command,
41
+ timeoutMs: input.timeoutMs,
42
+ });
43
+ }
44
+ }
45
+ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onCommandSessionChange, onError, onInvalidMessage, startupCommandSettlementTimeoutMs = DEFAULT_STARTUP_COMMAND_SETTLEMENT_TIMEOUT_MS, startupCommands, viewWebViewComponent, viewWebViewProps, }) {
37
46
  const [coreHostRevision, setCoreHostRevision] = useState(0);
38
47
  const [session, setSession] = useState(null);
39
48
  const sessionRef = useRef(null);
40
49
  const nextSessionKeyRef = useRef(0);
41
- const registrationRetryAttemptedRef = useRef(false);
50
+ const startupRetryAttemptedRef = useRef(false);
42
51
  const onErrorRef = useRef(onError);
43
52
  onErrorRef.current = onError;
44
53
  const onCommandSessionChangeRef = useRef(onCommandSessionChange);
45
54
  onCommandSessionChangeRef.current = onCommandSessionChange;
46
55
  const onInvalidMessageRef = useRef(onInvalidMessage);
47
56
  onInvalidMessageRef.current = onInvalidMessage;
48
- const instanceRegistrationEnvelopeRef = useRef(instanceRegistrationEnvelope);
49
- instanceRegistrationEnvelopeRef.current = instanceRegistrationEnvelope;
57
+ const startupCommandsRef = useRef(startupCommands);
58
+ startupCommandsRef.current = startupCommands;
50
59
  const reportError = useCallback((error) => {
51
60
  var _a;
52
61
  try {
@@ -100,18 +109,18 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
100
109
  if (sessionRef.current !== nextSession) {
101
110
  return;
102
111
  }
103
- registrationRetryAttemptedRef.current = false;
112
+ startupRetryAttemptedRef.current = false;
104
113
  nextSession.ready = true;
105
114
  nextSessionKeyRef.current = nextSession.key;
106
115
  setSession(nextSession);
107
116
  notifyCommandSessionObserver(nextSession.commandSessionObserver, commandSessionOwner.session);
108
117
  };
109
- const registrationEnvelope = instanceRegistrationEnvelopeRef.current;
110
- if (registrationEnvelope) {
111
- void dispatchRegistration({
118
+ const startupCommands = startupCommandsRef.current;
119
+ if (startupCommands) {
120
+ void dispatchStartupCommands({
121
+ commands: startupCommands,
112
122
  commandSession: commandSessionOwner.session,
113
- envelope: registrationEnvelope,
114
- timeoutMs: registrationSettlementTimeoutMs,
123
+ timeoutMs: startupCommandSettlementTimeoutMs,
115
124
  })
116
125
  .then(commitSession)
117
126
  .catch((error) => {
@@ -123,8 +132,8 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
123
132
  commandChannelOwner.dispose();
124
133
  controller.dispose();
125
134
  if (!(error instanceof CommandSettlementError) &&
126
- !registrationRetryAttemptedRef.current) {
127
- registrationRetryAttemptedRef.current = true;
135
+ !startupRetryAttemptedRef.current) {
136
+ startupRetryAttemptedRef.current = true;
128
137
  setCoreHostRevision((revision) => revision + 1);
129
138
  }
130
139
  reportError(error);
@@ -134,7 +143,7 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
134
143
  commitSession();
135
144
  }, [
136
145
  notifyCommandSessionObserver,
137
- registrationSettlementTimeoutMs,
146
+ startupCommandSettlementTimeoutMs,
138
147
  reportError,
139
148
  ]);
140
149
  const handleDisconnected = useCallback(() => {
@@ -196,7 +205,7 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
196
205
  }));
197
206
  }
198
207
  export function NativeProviderRuntime(_a) {
199
- var { initOptions, instanceId, onCommandSessionChange } = _a, runtimeProps = __rest(_a, ["initOptions", "instanceId", "onCommandSessionChange"]);
208
+ var { initOptions, initialConfigureOptions, instanceId, onCommandSessionChange } = _a, runtimeProps = __rest(_a, ["initOptions", "initialConfigureOptions", "instanceId", "onCommandSessionChange"]);
200
209
  const directSessionRef = useRef(null);
201
210
  const handleCommandSessionChange = useCallback((session) => {
202
211
  var _a;
@@ -214,10 +223,22 @@ export function NativeProviderRuntime(_a) {
214
223
  }
215
224
  onCommandSessionChange === null || onCommandSessionChange === void 0 ? void 0 : onCommandSessionChange(directSessionRef.current.directSession);
216
225
  }, [onCommandSessionChange]);
217
- const instanceRegistrationEnvelope = useMemo(() => createProviderCommandEnvelope({
218
- clientMeta: REACT_NATIVE_CLIENT_META,
219
- command: { kind: "init", opts: initOptions },
220
- instanceId,
221
- }), [initOptions, instanceId]);
222
- return createElement(NativeRuntimeRoot, Object.assign(Object.assign({}, runtimeProps), { instanceRegistrationEnvelope, onCommandSessionChange: handleCommandSessionChange }));
226
+ const startupCommands = useMemo(() => {
227
+ const initCommand = createProviderCommandEnvelope({
228
+ clientMeta: REACT_NATIVE_CLIENT_META,
229
+ command: { kind: "init", opts: initOptions },
230
+ instanceId,
231
+ });
232
+ if (initialConfigureOptions === undefined) {
233
+ return [initCommand];
234
+ }
235
+ return [
236
+ initCommand,
237
+ createProviderCommandEnvelope({
238
+ command: { kind: "configure", opts: initialConfigureOptions },
239
+ instanceId,
240
+ }),
241
+ ];
242
+ }, [initialConfigureOptions, initOptions, instanceId]);
243
+ return createElement(NativeRuntimeRoot, Object.assign(Object.assign({}, runtimeProps), { onCommandSessionChange: handleCommandSessionChange, startupCommands }));
223
244
  }
@@ -5,6 +5,9 @@ type ReactNativeWidgetCommand = WebViewCommandEnvelope["command"];
5
5
  type ReactNativeInitCommand = Extract<ReactNativeWidgetCommand, {
6
6
  kind: "init";
7
7
  }>;
8
+ type ReactNativeConfigureCommand = Extract<ReactNativeWidgetCommand, {
9
+ kind: "configure";
10
+ }>;
8
11
  export declare const REACT_NATIVE_CLIENT_META: ClientMeta;
9
12
  export declare const REACT_NATIVE_LOADER_CLIENT_META: ClientMeta;
10
13
  type CreateProviderCommandEnvelopeInput = {
@@ -19,6 +22,11 @@ export declare function createProviderCommandEnvelope(input: CreateProviderComma
19
22
  }): Omit<WebViewCommandEnvelope, "command"> & {
20
23
  command: ReactNativeInitCommand;
21
24
  };
25
+ export declare function createProviderCommandEnvelope(input: CreateProviderCommandEnvelopeInput & {
26
+ command: ReactNativeConfigureCommand;
27
+ }): Omit<WebViewCommandEnvelope, "command"> & {
28
+ command: ReactNativeConfigureCommand;
29
+ };
22
30
  export declare function createProviderCommandEnvelope(input: CreateProviderCommandEnvelopeInput): WebViewCommandEnvelope;
23
31
  export type CommandSettledEvent = Extract<WebViewTransportHostEvent, {
24
32
  name: "instance:command:settled";
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 : "3.0.76";
6
+ export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "3.0.79";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/react-native",
3
- "version": "3.0.76",
3
+ "version": "3.0.79",
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.19.0",
48
- "@getuserfeedback/sdk": "^0.12.4",
47
+ "@getuserfeedback/protocol": "^3.20.0",
48
+ "@getuserfeedback/sdk": "^0.12.5",
49
49
  "robot3": "^1.2.0"
50
50
  },
51
51
  "peerDependencies": {