@getuserfeedback/react-native 2.0.5 → 2.0.6

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
@@ -17,7 +17,7 @@ import { toCommandFlowId, toCommandSettlementError, toRetryWithoutFlowHandle, }
17
17
  import { useProviderCommandTransport } from "./provider-command-transport.js";
18
18
  import { clearProviderFlowHandleCache, createProviderFlowHandleCache, deleteCachedProviderFlowHandleId, deleteCachedProviderFlowId, getCachedProviderFlowHandleId, snapshotProviderFlowCommand, writeSettledProviderFlowHandleId, } from "./provider-flow-handle-cache.js";
19
19
  import { createProviderWidgetHostLifecycleController, HIDDEN_PROVIDER_WIDGET_HOST_VISIBILITY, } from "./provider-widget-host-lifecycle.js";
20
- import { ProviderWidgetHostOverlay, toProviderWidgetHostStyle, toProviderWidgetSheetHostLayoutUpdate, } from "./provider-widget-host-overlay.js";
20
+ import { ProviderWidgetHostOverlay, toProviderWidgetHostStyle, toProviderWidgetSheetHostLayoutPlan, } from "./provider-widget-host-overlay.js";
21
21
  import { REACT_NATIVE_SDK_VERSION } from "./version.js";
22
22
  import { WidgetHost, } from "./widget-host.js";
23
23
  export { REACT_NATIVE_SDK_VERSION } from "./version.js";
@@ -70,6 +70,15 @@ const FallbackNativeView = (_a) => {
70
70
  var { children } = _a, props = __rest(_a, ["children"]);
71
71
  return createElement("div", props, children);
72
72
  };
73
+ function getProviderWidgetLayoutPlanNowMs() {
74
+ var _a;
75
+ const performanceNow = typeof ((_a = globalThis.performance) === null || _a === void 0 ? void 0 : _a.now) === "function"
76
+ ? globalThis.performance.now()
77
+ : undefined;
78
+ return typeof performanceNow === "number" && Number.isFinite(performanceNow)
79
+ ? performanceNow
80
+ : Date.now();
81
+ }
73
82
  function resolveReactNativeComponents() {
74
83
  var _a;
75
84
  try {
@@ -112,6 +121,7 @@ const toIdentifyCommandPayload = (identifyInput, traitsOrOptions, options) => {
112
121
  };
113
122
  };
114
123
  export function GetUserFeedbackProvider({ autoInit = true, children, commandTimeoutMs = DEFAULT_COMMAND_TIMEOUT_MS, configureOptions, hostViewport, instanceId: instanceIdProp, initOptions, loaderUrl, onCommandError, onInvalidWebMessage, onWebMessage, source, webViewComponent, webViewProps, }) {
124
+ var _a;
115
125
  const { View: NativeView } = useMemo(resolveReactNativeComponents, []);
116
126
  const [instanceId] = useState(() => { var _a; return (_a = normalizeOptionalString(instanceIdProp)) !== null && _a !== void 0 ? _a : createUniqueId("rn"); });
117
127
  const [widgetHostVisibility, setWidgetHostVisibility] = useState(HIDDEN_PROVIDER_WIDGET_HOST_VISIBILITY);
@@ -471,6 +481,7 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
471
481
  emitHostSignal: (name, data, options) => enqueueCommand(Object.assign({ kind: "emitHostSignal", name: resolveRequiredString("name", name) }, (data === undefined ? {} : { data })), options),
472
482
  handleWebMessage,
473
483
  }), [enqueueCommand, getNativeMessages, handleWebMessage, instanceId]);
484
+ const previousSheetHostLayoutUpdateRef = useRef(undefined);
474
485
  useEffect(() => {
475
486
  resetStartupQueuedKeyIfChanged(startupOptionsKey);
476
487
  enqueueStartupCommands();
@@ -480,10 +491,36 @@ export function GetUserFeedbackProvider({ autoInit = true, children, commandTime
480
491
  startupOptionsKey,
481
492
  ]);
482
493
  const providerHostViewport = hostViewport !== null && hostViewport !== void 0 ? hostViewport : resolvedHostViewport;
483
- const sheetHostLayoutUpdate = toProviderWidgetSheetHostLayoutUpdate(providerHostViewport, {
484
- height: widgetHostVisibility.flowHeight,
494
+ const sheetHostLayoutPlan = toProviderWidgetSheetHostLayoutPlan({
495
+ previous: previousSheetHostLayoutUpdateRef.current,
496
+ viewport: providerHostViewport,
497
+ flowSize: {
498
+ height: widgetHostVisibility.flowHeight,
499
+ },
500
+ nowMs: getProviderWidgetLayoutPlanNowMs(),
485
501
  });
502
+ let sheetHostLayoutUpdate;
503
+ if (sheetHostLayoutPlan) {
504
+ switch (sheetHostLayoutPlan.kind) {
505
+ case "unchanged":
506
+ sheetHostLayoutUpdate =
507
+ (_a = previousSheetHostLayoutUpdateRef.current) !== null && _a !== void 0 ? _a : sheetHostLayoutPlan.update;
508
+ break;
509
+ case "instant":
510
+ sheetHostLayoutUpdate = sheetHostLayoutPlan.update;
511
+ break;
512
+ default: {
513
+ const unreachable = sheetHostLayoutPlan;
514
+ throw new Error(`Unsupported widget layout transition plan: ${JSON.stringify(unreachable)}`);
515
+ }
516
+ }
517
+ }
486
518
  const isWidgetHostVisible = resolveIsWidgetHostVisible(widgetHostVisibility, sheetHostLayoutUpdate !== undefined);
519
+ useEffect(() => {
520
+ previousSheetHostLayoutUpdateRef.current = isWidgetHostVisible
521
+ ? sheetHostLayoutUpdate
522
+ : undefined;
523
+ }, [isWidgetHostVisible, sheetHostLayoutUpdate]);
487
524
  const widgetHostViewport = providerHostViewport;
488
525
  const composedWebViewStyle = toProviderWidgetHostStyle({
489
526
  isVisible: isWidgetHostVisible,
@@ -1,4 +1,4 @@
1
- import { type WidgetLayoutSizeUpdate } from "@getuserfeedback/protocol/host";
1
+ import { type WidgetLayoutSizeUpdate, type WidgetLayoutTransitionPlan } from "@getuserfeedback/protocol/host";
2
2
  import { type ComponentType, type ReactElement, type ReactNode } from "react";
3
3
  import type { WidgetHostProps } from "./widget-host.js";
4
4
  type NativeViewComponent = ComponentType<Record<string, unknown>>;
@@ -8,6 +8,14 @@ export declare function toProviderWidgetSheetHostViewport(viewport: WidgetHostPr
8
8
  export declare function toProviderWidgetSheetHostLayoutUpdate(viewport: WidgetHostProps["hostViewport"], flowSize?: {
9
9
  height?: number;
10
10
  }): WidgetLayoutSizeUpdate | undefined;
11
+ export declare function toProviderWidgetSheetHostLayoutPlan(input: {
12
+ flowSize?: {
13
+ height?: number;
14
+ };
15
+ nowMs: number;
16
+ previous?: WidgetLayoutSizeUpdate;
17
+ viewport: WidgetHostProps["hostViewport"];
18
+ }): WidgetLayoutTransitionPlan | undefined;
11
19
  export declare function toProviderWidgetHostStyle({ isVisible, webViewStyle, }: {
12
20
  isVisible: boolean;
13
21
  webViewStyle: unknown;
@@ -1,4 +1,4 @@
1
- import { toInstantWidgetLayoutSizeUpdate, } from "@getuserfeedback/protocol/host";
1
+ import { planWidgetLayoutTransition, toInstantWidgetLayoutSizeUpdate, } from "@getuserfeedback/protocol/host";
2
2
  import { createElement, useCallback, useMemo, useRef, } from "react";
3
3
  const HIDDEN_WIDGET_HOST_STYLE = {
4
4
  bottom: 0,
@@ -129,6 +129,17 @@ export function toProviderWidgetSheetHostLayoutUpdate(viewport, flowSize) {
129
129
  : Math.max(LOADER_FLOATING_CONTAINER_MIN_HEIGHT, Math.ceil(measuredHeight))),
130
130
  });
131
131
  }
132
+ export function toProviderWidgetSheetHostLayoutPlan(input) {
133
+ const next = toProviderWidgetSheetHostLayoutUpdate(input.viewport, input.flowSize);
134
+ if (!next) {
135
+ return undefined;
136
+ }
137
+ return planWidgetLayoutTransition({
138
+ previous: input.previous,
139
+ next,
140
+ nowMs: input.nowMs,
141
+ });
142
+ }
132
143
  function toVisibleWidgetHostPresentationStyle(style) {
133
144
  if (style === undefined || style === null) {
134
145
  return undefined;
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 : "2.0.5";
6
+ export const REACT_NATIVE_SDK_VERSION = reactNativeSdkVersion.length > 0 ? reactNativeSdkVersion : "2.0.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getuserfeedback/react-native",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "getuserfeedback React Native SDK",
5
5
  "keywords": [
6
6
  "getuserfeedback",