@getuserfeedback/react-native 1.3.4 → 1.3.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.d.ts +2 -7
- package/dist/index.js +2 -37
- package/dist/provider-command-helpers.d.ts +14 -0
- package/dist/provider-command-helpers.js +40 -0
- package/dist/version.js +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AppEventExternalId, AppEventJsonValue, PublicCommandPayload } from "@getuserfeedback/protocol";
|
|
2
|
-
import type { WebViewCommandEnvelope,
|
|
2
|
+
import type { WebViewCommandEnvelope, WebViewTransportNativeMessage, WebViewTransportWebMessage } from "@getuserfeedback/protocol/webview-transport";
|
|
3
3
|
import type { ConfigureOptions, InitOptions } from "@getuserfeedback/sdk";
|
|
4
4
|
import { type ReactElement, type ReactNode } from "react";
|
|
5
|
+
import { type CommandSettledEvent, type CommandSettledSuccessDetail } from "./provider-command-helpers.js";
|
|
5
6
|
import { WidgetHost, type WidgetHostProps, type WidgetHostSource } from "./widget-host.js";
|
|
6
7
|
export { REACT_NATIVE_SDK_VERSION } from "./version.js";
|
|
7
8
|
export { buildNativeMessageInjectionScript, buildWebViewBridgeScript, } from "./webview-bridge-script.js";
|
|
@@ -29,12 +30,6 @@ type PrerenderOptions = Pick<PrerenderCommand, "hideCloseButton">;
|
|
|
29
30
|
type HostContext = Extract<PublicCommandPayload, {
|
|
30
31
|
kind: "updateHostContext";
|
|
31
32
|
}>["context"];
|
|
32
|
-
type CommandSettledEvent = Extract<WebViewTransportHostEvent, {
|
|
33
|
-
name: "instance:command:settled";
|
|
34
|
-
}>;
|
|
35
|
-
type CommandSettledSuccessDetail = Extract<CommandSettledEvent["detail"], {
|
|
36
|
-
ok: true;
|
|
37
|
-
}>;
|
|
38
33
|
export interface ReactNativeCommandResult {
|
|
39
34
|
envelope: ReactNativeWidgetCommandEnvelope;
|
|
40
35
|
message: ReactNativeWidgetNativeMessage;
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { assertNoSegmentExternalIdsInValueArgument,
|
|
12
|
+
import { assertNoSegmentExternalIdsInValueArgument, CommandSettlementTimeoutError, } from "@getuserfeedback/protocol/host";
|
|
13
13
|
import { parseWebViewTransportNativeMessage } from "@getuserfeedback/protocol/webview-transport";
|
|
14
14
|
import { createContext, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
15
15
|
import { useResolvedHostViewport } from "./host-viewport.js";
|
|
16
|
+
import { toCommandFlowId, toCommandSettlementError, toRetryWithoutFlowHandle, toSettledFlowHandleId, } from "./provider-command-helpers.js";
|
|
16
17
|
import { applyProviderOverlayFlowState, applyProviderOverlayHandleInvalidated, createDefaultProviderOverlayState, DEFAULT_PROVIDER_OVERLAY_VISIBILITY, updateProviderOverlayReadySequence, } from "./provider-overlay-state.js";
|
|
17
18
|
import { ProviderWidgetHostOverlay, toProviderWidgetHostStyle, toProviderWidgetSheetHostViewport, } from "./provider-widget-host-overlay.js";
|
|
18
19
|
import { REACT_NATIVE_SDK_VERSION } from "./version.js";
|
|
@@ -104,42 +105,6 @@ const toIdentifyCommandPayload = (identifyInput, traitsOrOptions, options) => {
|
|
|
104
105
|
options: options !== null && options !== void 0 ? options : traitsOrOptions,
|
|
105
106
|
};
|
|
106
107
|
};
|
|
107
|
-
const isFlowCommand = (command) => command.kind === "open" ||
|
|
108
|
-
command.kind === "prefetch" ||
|
|
109
|
-
command.kind === "prerender";
|
|
110
|
-
const toSettledFlowHandleId = (result) => {
|
|
111
|
-
if (typeof result !== "object" || result === null) {
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
const flowHandleId = result.flowHandleId;
|
|
115
|
-
return typeof flowHandleId === "string" && flowHandleId.trim().length > 0
|
|
116
|
-
? flowHandleId
|
|
117
|
-
: undefined;
|
|
118
|
-
};
|
|
119
|
-
const toCommandFlowId = (command) => {
|
|
120
|
-
if (!isFlowCommand(command)) {
|
|
121
|
-
return undefined;
|
|
122
|
-
}
|
|
123
|
-
return command.flowId;
|
|
124
|
-
};
|
|
125
|
-
const toRetryWithoutFlowHandle = (command) => {
|
|
126
|
-
if (!isFlowCommand(command) || command.flowHandleId === undefined) {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
return Object.assign(Object.assign({}, command), { flowHandleId: undefined });
|
|
130
|
-
};
|
|
131
|
-
const toCommandSettlementError = (event) => {
|
|
132
|
-
if (event.detail.ok) {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
return new CommandSettlementError({
|
|
136
|
-
code: event.detail.error.code,
|
|
137
|
-
instanceId: event.detail.instanceId,
|
|
138
|
-
kind: event.detail.kind,
|
|
139
|
-
message: event.detail.error.message,
|
|
140
|
-
requestId: event.detail.requestId,
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
108
|
export function GetUserFeedbackProvider({ autoInit = true, children, commandTimeoutMs = DEFAULT_COMMAND_TIMEOUT_MS, configureOptions, hostViewport, instanceId: instanceIdProp, initOptions, loaderUrl, onCommandError, onInvalidWebMessage, onWebMessage, source, webViewComponent, webViewProps, }) {
|
|
144
109
|
var _a, _b;
|
|
145
110
|
const NativeView = useMemo(resolveNativeView, []);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommandSettlementError } from "@getuserfeedback/protocol/host";
|
|
2
|
+
import type { WebViewCommandEnvelope, WebViewTransportHostEvent } from "@getuserfeedback/protocol/webview-transport";
|
|
3
|
+
type ReactNativeWidgetCommand = WebViewCommandEnvelope["command"];
|
|
4
|
+
export type CommandSettledEvent = Extract<WebViewTransportHostEvent, {
|
|
5
|
+
name: "instance:command:settled";
|
|
6
|
+
}>;
|
|
7
|
+
export type CommandSettledSuccessDetail = Extract<CommandSettledEvent["detail"], {
|
|
8
|
+
ok: true;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function toSettledFlowHandleId(result: unknown): string | undefined;
|
|
11
|
+
export declare function toCommandFlowId(command: ReactNativeWidgetCommand): string | undefined;
|
|
12
|
+
export declare function toRetryWithoutFlowHandle(command: ReactNativeWidgetCommand): ReactNativeWidgetCommand | null;
|
|
13
|
+
export declare function toCommandSettlementError(event: CommandSettledEvent): CommandSettlementError | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CommandSettlementError } from "@getuserfeedback/protocol/host";
|
|
2
|
+
function isReactNativeFlowCommand(command) {
|
|
3
|
+
return (command.kind === "open" ||
|
|
4
|
+
command.kind === "prefetch" ||
|
|
5
|
+
command.kind === "prerender");
|
|
6
|
+
}
|
|
7
|
+
export function toSettledFlowHandleId(result) {
|
|
8
|
+
if (typeof result !== "object" || result === null) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const flowHandleId = result.flowHandleId;
|
|
12
|
+
return typeof flowHandleId === "string" && flowHandleId.trim().length > 0
|
|
13
|
+
? flowHandleId
|
|
14
|
+
: undefined;
|
|
15
|
+
}
|
|
16
|
+
export function toCommandFlowId(command) {
|
|
17
|
+
if (!isReactNativeFlowCommand(command)) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return command.flowId;
|
|
21
|
+
}
|
|
22
|
+
export function toRetryWithoutFlowHandle(command) {
|
|
23
|
+
if (!isReactNativeFlowCommand(command) ||
|
|
24
|
+
command.flowHandleId === undefined) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return Object.assign(Object.assign({}, command), { flowHandleId: undefined });
|
|
28
|
+
}
|
|
29
|
+
export function toCommandSettlementError(event) {
|
|
30
|
+
if (event.detail.ok) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return new CommandSettlementError({
|
|
34
|
+
code: event.detail.error.code,
|
|
35
|
+
instanceId: event.detail.instanceId,
|
|
36
|
+
kind: event.detail.kind,
|
|
37
|
+
message: event.detail.error.message,
|
|
38
|
+
requestId: event.detail.requestId,
|
|
39
|
+
});
|
|
40
|
+
}
|
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 : "1.3.
|
|
6
|
+
export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "1.3.5";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getuserfeedback/react-native",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "getuserfeedback React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"getuserfeedback",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"build": "bun scripts/build.ts",
|
|
41
41
|
"typecheck": "tsc -b tsconfig.json",
|
|
42
42
|
"test": "bun test --dots",
|
|
43
|
+
"test:changed": "bun test --changed=${TEST_CHANGED_BASE:-HEAD} --pass-with-no-tests --dots",
|
|
43
44
|
"lint": "ultracite check ."
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|