@getuserfeedback/react-native 3.0.94 → 3.0.95
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/native-direct-command-session-controller.d.ts +1 -0
- package/dist/native-direct-command-session-controller.js +25 -24
- package/dist/native-direct-command-session.js +0 -2
- package/dist/native-runtime-root.d.ts +4 -1
- package/dist/native-runtime-root.js +5 -4
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { NativeDirectCommandSession } from "./native-direct-command-session.js";
|
|
2
2
|
export type NativeDirectCommandSessionController = {
|
|
3
3
|
attach: (session: NativeDirectCommandSession) => void;
|
|
4
|
+
beginAttachmentAttempt: () => void;
|
|
4
5
|
detach: (session: NativeDirectCommandSession) => void;
|
|
5
6
|
dispose: (error: Error) => void;
|
|
6
7
|
rejectUntilAttached: (error: Error) => void;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export function createNativeDirectCommandSessionController() {
|
|
2
|
-
let
|
|
3
|
-
let disposed = false;
|
|
4
|
-
let disposalError;
|
|
2
|
+
let state = { kind: "awaitingAttachment" };
|
|
5
3
|
let pendingCommands = [];
|
|
6
|
-
let unavailableError;
|
|
7
4
|
const dispatchThrough = (session, envelope) => {
|
|
8
5
|
try {
|
|
9
6
|
return Promise.resolve(session.dispatch(envelope));
|
|
@@ -14,14 +11,12 @@ export function createNativeDirectCommandSessionController() {
|
|
|
14
11
|
};
|
|
15
12
|
const session = {
|
|
16
13
|
dispatch: (envelope) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (unavailableError !== undefined) {
|
|
24
|
-
return Promise.reject(unavailableError);
|
|
14
|
+
switch (state.kind) {
|
|
15
|
+
case "attached":
|
|
16
|
+
return dispatchThrough(state.session, envelope);
|
|
17
|
+
case "disposed":
|
|
18
|
+
case "unavailable":
|
|
19
|
+
return Promise.reject(state.error);
|
|
25
20
|
}
|
|
26
21
|
return new Promise((resolve, reject) => {
|
|
27
22
|
pendingCommands.push({ envelope, reject, resolve });
|
|
@@ -29,44 +24,50 @@ export function createNativeDirectCommandSessionController() {
|
|
|
29
24
|
},
|
|
30
25
|
};
|
|
31
26
|
const dispose = (error) => {
|
|
32
|
-
if (disposed) {
|
|
27
|
+
if (state.kind === "disposed") {
|
|
33
28
|
return;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
disposalError = error;
|
|
37
|
-
attachedSession = null;
|
|
30
|
+
state = { error, kind: "disposed" };
|
|
38
31
|
const queuedCommands = pendingCommands;
|
|
39
32
|
pendingCommands = [];
|
|
40
33
|
for (const command of queuedCommands) {
|
|
41
34
|
command.reject(error);
|
|
42
35
|
}
|
|
43
36
|
};
|
|
37
|
+
const getDisposalError = () => state.kind === "disposed" ? state.error : undefined;
|
|
44
38
|
return {
|
|
45
39
|
attach: (nextSession) => {
|
|
46
|
-
if (disposed) {
|
|
40
|
+
if (state.kind === "disposed") {
|
|
47
41
|
return;
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
unavailableError = undefined;
|
|
43
|
+
state = { kind: "attached", session: nextSession };
|
|
51
44
|
const queuedCommands = pendingCommands;
|
|
52
45
|
pendingCommands = [];
|
|
53
46
|
for (const command of queuedCommands) {
|
|
54
|
-
|
|
47
|
+
const disposalError = getDisposalError();
|
|
48
|
+
if (disposalError) {
|
|
55
49
|
command.reject(disposalError);
|
|
56
50
|
continue;
|
|
57
51
|
}
|
|
58
52
|
void dispatchThrough(nextSession, command.envelope).then(command.resolve, command.reject);
|
|
59
53
|
}
|
|
60
54
|
},
|
|
55
|
+
beginAttachmentAttempt: () => {
|
|
56
|
+
if (state.kind === "unavailable") {
|
|
57
|
+
state = { kind: "awaitingAttachment" };
|
|
58
|
+
}
|
|
59
|
+
},
|
|
61
60
|
detach: (sessionToDetach) => {
|
|
62
|
-
if (
|
|
63
|
-
|
|
61
|
+
if (state.kind === "attached" && state.session === sessionToDetach) {
|
|
62
|
+
state = { kind: "awaitingAttachment" };
|
|
64
63
|
}
|
|
65
64
|
},
|
|
66
65
|
dispose,
|
|
67
66
|
rejectUntilAttached: (error) => {
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
if (state.kind === "disposed") {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
state = { error, kind: "unavailable" };
|
|
70
71
|
const queuedCommands = pendingCommands;
|
|
71
72
|
pendingCommands = [];
|
|
72
73
|
for (const command of queuedCommands) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { getFlowHandleFromSettlementDetail } from "@getuserfeedback/protocol/host";
|
|
2
2
|
import { toCoreCommandPayload, } from "@getuserfeedback/protocol/internal/public-core-command";
|
|
3
|
-
// TODO(migration): Route the public provider client through this core-ordered direct session after native per-view presentation is complete.
|
|
4
|
-
// [from=native-view-presentation-behavior] [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=190]
|
|
5
3
|
export function createNativeDirectCommandSession(input) {
|
|
6
4
|
const dispatchToCore = (envelope, command) => {
|
|
7
5
|
const coreEnvelope = Object.assign(Object.assign({}, envelope), { command: toCoreCommandPayload(command) });
|
|
@@ -4,6 +4,7 @@ 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";
|
|
6
6
|
import { type NativeDirectCommandSession } from "./native-direct-command-session.js";
|
|
7
|
+
import type { NativeDirectCommandSessionController } from "./native-direct-command-session-controller.js";
|
|
7
8
|
import { type NativeViewHostProjectionProps } from "./native-view-host-projection.js";
|
|
8
9
|
export type NativeRuntimeRootProps = {
|
|
9
10
|
coreUrl: string;
|
|
@@ -31,11 +32,13 @@ type NativeRuntimeConfigureCommand = Omit<CoreCommandEnvelope, "command"> & {
|
|
|
31
32
|
};
|
|
32
33
|
type NativeRuntimeStartupCommands = readonly [NativeRuntimeInitCommand] | readonly [NativeRuntimeInitCommand, NativeRuntimeConfigureCommand];
|
|
33
34
|
type NativeProviderRuntimeProps = Omit<NativeRuntimeRootProps, "onCommandSessionChange" | "onStartupTerminalError" | "startupCommands"> & {
|
|
35
|
+
/** Stable, exclusive controller retained and disposed by the component that owns this runtime's mounted lifetime. */
|
|
36
|
+
directSessionController: NativeDirectCommandSessionController;
|
|
34
37
|
initialConfigureOptions?: ConfigureOptions;
|
|
35
38
|
initOptions: InitOptions;
|
|
36
39
|
instanceId: string;
|
|
37
40
|
onCommandSessionChange?: (session: NativeDirectCommandSession | null) => void;
|
|
38
41
|
};
|
|
39
42
|
export declare function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onCommandSessionChange, onError, onInvalidMessage, onStartupTerminalError, startupCommandSettlementTimeoutMs, startupCommands, viewNativeViewComponent, viewWebViewComponent, viewWebViewProps, }: NativeRuntimeRootProps): ReactElement;
|
|
40
|
-
export declare function NativeProviderRuntime({ initOptions, initialConfigureOptions, instanceId, onCommandSessionChange, onError, ...runtimeProps }: NativeProviderRuntimeProps): ReactElement;
|
|
43
|
+
export declare function NativeProviderRuntime({ directSessionController, initOptions, initialConfigureOptions, instanceId, onCommandSessionChange, onError, ...runtimeProps }: NativeProviderRuntimeProps): ReactElement;
|
|
41
44
|
export {};
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { CommandSettlementError, CommandSettlementTimeoutError, } from "@getuserfeedback/protocol/host";
|
|
13
|
-
import { createElement, Fragment, useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
13
|
+
import { createElement, Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
14
14
|
import { CoreWebViewHost, } from "./core-webview-host.js";
|
|
15
15
|
import { createNativeCoreCommandChannel } from "./native-core-command-channel.js";
|
|
16
16
|
import { createNativeCoreCommandSession, } from "./native-core-command-session.js";
|
|
@@ -18,7 +18,6 @@ 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
|
-
import { useNativeDirectCommandSessionController } from "./use-native-direct-command-session-controller.js";
|
|
22
21
|
const DEFAULT_STARTUP_COMMAND_SETTLEMENT_TIMEOUT_MS = 30000;
|
|
23
22
|
function dispatchStartupCommand(input) {
|
|
24
23
|
let timeoutId;
|
|
@@ -220,9 +219,11 @@ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewPr
|
|
|
220
219
|
}));
|
|
221
220
|
}
|
|
222
221
|
export function NativeProviderRuntime(_a) {
|
|
223
|
-
var { initOptions, initialConfigureOptions, instanceId, onCommandSessionChange, onError } = _a, runtimeProps = __rest(_a, ["initOptions", "initialConfigureOptions", "instanceId", "onCommandSessionChange", "onError"]);
|
|
224
|
-
const directSessionController = useNativeDirectCommandSessionController();
|
|
222
|
+
var { directSessionController, initOptions, initialConfigureOptions, instanceId, onCommandSessionChange, onError } = _a, runtimeProps = __rest(_a, ["directSessionController", "initOptions", "initialConfigureOptions", "instanceId", "onCommandSessionChange", "onError"]);
|
|
225
223
|
const directSessionRef = useRef(null);
|
|
224
|
+
useLayoutEffect(() => {
|
|
225
|
+
directSessionController.beginAttachmentAttempt();
|
|
226
|
+
}, [directSessionController]);
|
|
226
227
|
const handleStartupTerminalError = useCallback((error) => {
|
|
227
228
|
directSessionController.rejectUntilAttached(error);
|
|
228
229
|
}, [directSessionController]);
|
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.
|
|
6
|
+
export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "3.0.95";
|