@getuserfeedback/react-native 3.0.44 → 3.0.46

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.
@@ -0,0 +1,13 @@
1
+ import { type ReactElement } from "react";
2
+ import { type CoreWebViewHostProps } from "./core-webview-host.js";
3
+ import { type NativeViewHostProjectionProps } from "./native-view-host-projection.js";
4
+ export type NativeRuntimeRootProps = {
5
+ coreUrl: string;
6
+ coreWebViewComponent?: CoreWebViewHostProps["webViewComponent"];
7
+ coreWebViewProps?: CoreWebViewHostProps["webViewProps"];
8
+ onError?: (error: Error) => void;
9
+ onInvalidMessage?: (error: Error, value: unknown) => void;
10
+ viewWebViewComponent?: NativeViewHostProjectionProps["webViewComponent"];
11
+ viewWebViewProps?: NativeViewHostProjectionProps["webViewProps"];
12
+ };
13
+ export declare function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onError, onInvalidMessage, viewWebViewComponent, viewWebViewProps, }: NativeRuntimeRootProps): ReactElement;
@@ -0,0 +1,56 @@
1
+ import { createElement, Fragment, useCallback, useEffect, useRef, useState, } from "react";
2
+ import { CoreWebViewHost, } from "./core-webview-host.js";
3
+ import { NativeViewHostProjection, } from "./native-view-host-projection.js";
4
+ import { createNativeViewRecordController, } from "./native-view-record-controller.js";
5
+ export function NativeRuntimeRoot({ coreUrl, coreWebViewComponent, coreWebViewProps, onError, onInvalidMessage, viewWebViewComponent, viewWebViewProps, }) {
6
+ const [session, setSession] = useState(null);
7
+ const sessionRef = useRef(null);
8
+ const nextSessionKeyRef = useRef(0);
9
+ const onErrorRef = useRef(onError);
10
+ onErrorRef.current = onError;
11
+ const handleConnected = useCallback((coreConnection) => {
12
+ const previousSession = sessionRef.current;
13
+ previousSession === null || previousSession === void 0 ? void 0 : previousSession.controller.dispose();
14
+ const controller = createNativeViewRecordController({
15
+ coreConnection,
16
+ onError: (error) => { var _a; return (_a = onErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onErrorRef, error); },
17
+ });
18
+ const nextSession = {
19
+ controller,
20
+ key: nextSessionKeyRef.current + 1,
21
+ };
22
+ nextSessionKeyRef.current = nextSession.key;
23
+ sessionRef.current = nextSession;
24
+ setSession(nextSession);
25
+ }, []);
26
+ const handleDisconnected = useCallback(() => {
27
+ const currentSession = sessionRef.current;
28
+ if (!currentSession) {
29
+ return;
30
+ }
31
+ currentSession.controller.dispose();
32
+ sessionRef.current = null;
33
+ setSession(null);
34
+ }, []);
35
+ useEffect(() => () => {
36
+ const currentSession = sessionRef.current;
37
+ sessionRef.current = null;
38
+ currentSession === null || currentSession === void 0 ? void 0 : currentSession.controller.dispose();
39
+ }, []);
40
+ return createElement(Fragment, null, createElement(CoreWebViewHost, {
41
+ coreUrl,
42
+ onConnected: handleConnected,
43
+ onDisconnected: handleDisconnected,
44
+ onInvalidMessage,
45
+ webViewComponent: coreWebViewComponent,
46
+ webViewProps: coreWebViewProps,
47
+ }), session === null
48
+ ? null
49
+ : createElement(NativeViewHostProjection, {
50
+ controller: session.controller,
51
+ key: session.key,
52
+ onInvalidMessage,
53
+ webViewComponent: viewWebViewComponent,
54
+ webViewProps: viewWebViewProps,
55
+ }));
56
+ }
@@ -38,5 +38,5 @@ export function NativeViewHostProjection({ controller, onInvalidMessage, webView
38
38
  key: record.allocationId,
39
39
  })));
40
40
  }
41
- // TODO(migration): Compose CoreWebViewHost, a mount-stable NativeViewRecordController, and this projection behind one private native runtime root while the provider runtime remains active.
42
- // [from=private-native-view-rendering-proof] [to=private-native-runtime-composition] [scope=slice] [priority=high] [impact=high] [risk=high] [epic=runtime-neutral-view-host-orchestration] [epic_order=50]
41
+ // TODO(architecture): Prove command/bootstrap composition from the private native runtime root without switching provider ownership.
42
+ // [from=private-native-runtime-composition] [to=private-native-command-bootstrap-composition] [scope=slice] [principle=preserve-provider-runtime] [priority=high] [impact=high] [risk=high] [epic=runtime-neutral-view-host-orchestration] [epic_order=60]
@@ -0,0 +1,11 @@
1
+ import type { WidgetFrameAppearance } from "@getuserfeedback/protocol/host";
2
+ export type ProviderWidgetFrameAppearanceProjection = {
3
+ shadowPolicy: "clear" | "legacy";
4
+ topLeftRadius: number;
5
+ topRightRadius: number;
6
+ };
7
+ export declare function safeParseProviderWidgetCanonicalTopRadii(value: string): {
8
+ topLeft: number;
9
+ topRight: number;
10
+ } | undefined;
11
+ export declare function toProviderWidgetFrameAppearance(appearance?: WidgetFrameAppearance): ProviderWidgetFrameAppearanceProjection;
@@ -0,0 +1,47 @@
1
+ const LEGACY_WIDGET_SHEET_RADIUS = 24;
2
+ const CANONICAL_PX_PATTERN = /^(?:0|[1-9]\d*)(?:\.\d+)?px$/;
3
+ const safeParseCanonicalPx = (value) => {
4
+ if (!CANONICAL_PX_PATTERN.test(value)) {
5
+ return undefined;
6
+ }
7
+ const parsed = Number.parseFloat(value);
8
+ return Number.isFinite(parsed) ? parsed : undefined;
9
+ };
10
+ export function safeParseProviderWidgetCanonicalTopRadii(value) {
11
+ if (value.includes("/")) {
12
+ return undefined;
13
+ }
14
+ const radii = value.split(/\s+/).map(safeParseCanonicalPx);
15
+ if (radii.length === 0 ||
16
+ radii.length > 4 ||
17
+ radii.some((radius) => radius === undefined)) {
18
+ return undefined;
19
+ }
20
+ const [topLeft, topRight = topLeft] = radii;
21
+ return topLeft === undefined || topRight === undefined
22
+ ? undefined
23
+ : { topLeft, topRight };
24
+ }
25
+ export function toProviderWidgetFrameAppearance(appearance) {
26
+ var _a, _b;
27
+ if (appearance === undefined) {
28
+ return {
29
+ shadowPolicy: "legacy",
30
+ topLeftRadius: LEGACY_WIDGET_SHEET_RADIUS,
31
+ topRightRadius: LEGACY_WIDGET_SHEET_RADIUS,
32
+ };
33
+ }
34
+ if (appearance.kind === "none") {
35
+ return {
36
+ shadowPolicy: "clear",
37
+ topLeftRadius: 0,
38
+ topRightRadius: 0,
39
+ };
40
+ }
41
+ const radius = safeParseProviderWidgetCanonicalTopRadii(appearance.borderRadius);
42
+ return {
43
+ shadowPolicy: "clear",
44
+ topLeftRadius: (_a = radius === null || radius === void 0 ? void 0 : radius.topLeft) !== null && _a !== void 0 ? _a : 0,
45
+ topRightRadius: (_b = radius === null || radius === void 0 ? void 0 : radius.topRight) !== null && _b !== void 0 ? _b : 0,
46
+ };
47
+ }
@@ -1,5 +1,6 @@
1
1
  import { planWidgetLayoutTransition, toInstantWidgetLayoutSizeUpdate, } from "@getuserfeedback/protocol/host";
2
2
  import { createElement, useCallback, useEffect, useMemo, useRef, } from "react";
3
+ import { toProviderWidgetFrameAppearance } from "./provider-widget-frame-appearance.js";
3
4
  const HIDDEN_WIDGET_HOST_STYLE = {
4
5
  bottom: 0,
5
6
  left: 0,
@@ -31,22 +32,25 @@ const WIDGET_SHEET_LAYOUT_STYLE = {
31
32
  position: "absolute",
32
33
  right: 0,
33
34
  };
34
- const WIDGET_SHEET_FRAME_STYLE = {
35
+ const WIDGET_SHEET_LEGACY_FRAME_STYLE = {
35
36
  shadowColor: "#000000",
36
37
  shadowOffset: { height: -4, width: 0 },
37
38
  shadowOpacity: 0.16,
38
39
  shadowRadius: 18,
39
40
  elevation: 18,
40
41
  };
42
+ const WIDGET_SHEET_CLEARED_FRAME_STYLE = {
43
+ shadowColor: "transparent",
44
+ shadowOffset: { height: 0, width: 0 },
45
+ shadowOpacity: 0,
46
+ shadowRadius: 0,
47
+ elevation: 0,
48
+ };
41
49
  const WIDGET_SHEET_CONTENT_BASE_STYLE = {
42
50
  backgroundColor: "#ffffff",
43
51
  flex: 1,
44
52
  overflow: "hidden",
45
53
  };
46
- const WIDGET_SHEET_RADIUS_STYLE = {
47
- borderTopLeftRadius: 24,
48
- borderTopRightRadius: 24,
49
- };
50
54
  const WIDGET_SHEET_DRAG_HANDLE_TOUCH_STYLE = {
51
55
  alignItems: "center",
52
56
  elevation: 19,
@@ -199,14 +203,20 @@ export function toProviderWidgetHostStyle({ isVisible, webViewStyle, }) {
199
203
  : VISIBLE_WIDGET_HOST_STYLE;
200
204
  }
201
205
  export function toProviderWidgetSheetSurfaceStyles(input) {
202
- var _a, _b;
206
+ var _a;
203
207
  const sheetHostViewport = (_a = input.sheetHostLayoutUpdate) === null || _a === void 0 ? void 0 : _a.size;
204
- const hasFrame = ((_b = input.frameAppearance) === null || _b === void 0 ? void 0 : _b.kind) !== "none";
208
+ const appearance = toProviderWidgetFrameAppearance(input.frameAppearance);
209
+ const radiusStyle = {
210
+ borderTopLeftRadius: appearance.topLeftRadius,
211
+ borderTopRightRadius: appearance.topRightRadius,
212
+ };
213
+ const frameStyle = appearance.shadowPolicy === "legacy"
214
+ ? WIDGET_SHEET_LEGACY_FRAME_STYLE
215
+ : WIDGET_SHEET_CLEARED_FRAME_STYLE;
205
216
  return {
206
- contentStyle: Object.assign(Object.assign({}, WIDGET_SHEET_CONTENT_BASE_STYLE), (hasFrame ? WIDGET_SHEET_RADIUS_STYLE : {})),
217
+ contentStyle: Object.assign(Object.assign({}, WIDGET_SHEET_CONTENT_BASE_STYLE), radiusStyle),
207
218
  sheetStyle: input.isVisible && sheetHostViewport !== undefined
208
- ? Object.assign(Object.assign(Object.assign({}, WIDGET_SHEET_LAYOUT_STYLE), (hasFrame
209
- ? Object.assign(Object.assign({}, WIDGET_SHEET_RADIUS_STYLE), WIDGET_SHEET_FRAME_STYLE) : {})), { height: sheetHostViewport.height }) : HIDDEN_WIDGET_HOST_STYLE,
219
+ ? Object.assign(Object.assign(Object.assign(Object.assign({}, WIDGET_SHEET_LAYOUT_STYLE), radiusStyle), frameStyle), { height: sheetHostViewport.height }) : HIDDEN_WIDGET_HOST_STYLE,
210
220
  };
211
221
  }
212
222
  function useProviderWidgetSheetPresentation(input) {
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.44";
6
+ export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "3.0.46";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/react-native",
3
- "version": "3.0.44",
3
+ "version": "3.0.46",
4
4
  "description": "getuserfeedback React Native SDK",
5
5
  "keywords": [
6
6
  "getuserfeedback",