@moonpay/platform-sdk-react-native 1.22.0 → 1.24.0
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.cjs +16 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -355,9 +355,16 @@ interface MoonPayApplePayButtonProps {
|
|
|
355
355
|
style?: ViewStyle;
|
|
356
356
|
/** Advanced props forwarded to the underlying react-native-webview. `ref`, `source`, and `onMessage` are SDK-managed. */
|
|
357
357
|
webViewProps?: Partial<WebViewProps>;
|
|
358
|
+
/**
|
|
359
|
+
* Called with the underlying WebView instance once the button mounts, and
|
|
360
|
+
* with `null` on unmount. The Apple Pay button is rendered inside this
|
|
361
|
+
* WebView; use the instance to inject JS into the frame (e.g. via
|
|
362
|
+
* `injectJavaScript`).
|
|
363
|
+
*/
|
|
364
|
+
onRef?: (webView: WebView | null) => void;
|
|
358
365
|
}
|
|
359
366
|
/** Inline Apple Pay button. Render it wherever it should appear in your layout. */
|
|
360
|
-
declare function MoonPayApplePayButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, }: MoonPayApplePayButtonProps): JSX.Element;
|
|
367
|
+
declare function MoonPayApplePayButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, onRef, }: MoonPayApplePayButtonProps): JSX.Element;
|
|
361
368
|
|
|
362
369
|
interface MoonPayAuthProps {
|
|
363
370
|
/** Callback for auth lifecycle events. */
|
|
@@ -526,12 +533,17 @@ interface MoonPayFrameProps {
|
|
|
526
533
|
* overridden; all other props (including `originWhitelist`) may be set here.
|
|
527
534
|
*/
|
|
528
535
|
webViewProps?: Partial<WebViewProps>;
|
|
536
|
+
/**
|
|
537
|
+
* Called with the underlying WebView instance once it mounts, and with `null`
|
|
538
|
+
* on unmount. Lets callers inject JS into the frame (e.g. `injectJavaScript`).
|
|
539
|
+
*/
|
|
540
|
+
onRef?: (webView: WebView | null) => void;
|
|
529
541
|
}
|
|
530
542
|
/**
|
|
531
543
|
* Reusable React Native component that renders a MoonPay frame as a WebView.
|
|
532
544
|
* Bridges the WebViewTransport to the actual WebView instance.
|
|
533
545
|
*/
|
|
534
|
-
declare function MoonPayFrame({ transport, hidden, style, webViewProps, }: MoonPayFrameProps): JSX.Element | null;
|
|
546
|
+
declare function MoonPayFrame({ transport, hidden, style, webViewProps, onRef, }: MoonPayFrameProps): JSX.Element | null;
|
|
535
547
|
|
|
536
548
|
interface MoonPayProviderProps {
|
|
537
549
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -355,9 +355,16 @@ interface MoonPayApplePayButtonProps {
|
|
|
355
355
|
style?: ViewStyle;
|
|
356
356
|
/** Advanced props forwarded to the underlying react-native-webview. `ref`, `source`, and `onMessage` are SDK-managed. */
|
|
357
357
|
webViewProps?: Partial<WebViewProps>;
|
|
358
|
+
/**
|
|
359
|
+
* Called with the underlying WebView instance once the button mounts, and
|
|
360
|
+
* with `null` on unmount. The Apple Pay button is rendered inside this
|
|
361
|
+
* WebView; use the instance to inject JS into the frame (e.g. via
|
|
362
|
+
* `injectJavaScript`).
|
|
363
|
+
*/
|
|
364
|
+
onRef?: (webView: WebView | null) => void;
|
|
358
365
|
}
|
|
359
366
|
/** Inline Apple Pay button. Render it wherever it should appear in your layout. */
|
|
360
|
-
declare function MoonPayApplePayButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, }: MoonPayApplePayButtonProps): JSX.Element;
|
|
367
|
+
declare function MoonPayApplePayButton({ quote, externalTransactionId, applePayButtonSettings, onEvent, style, webViewProps, onRef, }: MoonPayApplePayButtonProps): JSX.Element;
|
|
361
368
|
|
|
362
369
|
interface MoonPayAuthProps {
|
|
363
370
|
/** Callback for auth lifecycle events. */
|
|
@@ -526,12 +533,17 @@ interface MoonPayFrameProps {
|
|
|
526
533
|
* overridden; all other props (including `originWhitelist`) may be set here.
|
|
527
534
|
*/
|
|
528
535
|
webViewProps?: Partial<WebViewProps>;
|
|
536
|
+
/**
|
|
537
|
+
* Called with the underlying WebView instance once it mounts, and with `null`
|
|
538
|
+
* on unmount. Lets callers inject JS into the frame (e.g. `injectJavaScript`).
|
|
539
|
+
*/
|
|
540
|
+
onRef?: (webView: WebView | null) => void;
|
|
529
541
|
}
|
|
530
542
|
/**
|
|
531
543
|
* Reusable React Native component that renders a MoonPay frame as a WebView.
|
|
532
544
|
* Bridges the WebViewTransport to the actual WebView instance.
|
|
533
545
|
*/
|
|
534
|
-
declare function MoonPayFrame({ transport, hidden, style, webViewProps, }: MoonPayFrameProps): JSX.Element | null;
|
|
546
|
+
declare function MoonPayFrame({ transport, hidden, style, webViewProps, onRef, }: MoonPayFrameProps): JSX.Element | null;
|
|
535
547
|
|
|
536
548
|
interface MoonPayProviderProps {
|
|
537
549
|
/**
|
package/dist/index.js
CHANGED
|
@@ -165,7 +165,7 @@ var buyButtonSpec = {
|
|
|
165
165
|
function applyCredentialsOnComplete(msg, ctx) {
|
|
166
166
|
if (msg.kind !== "complete" || !ctx.privateKey) return;
|
|
167
167
|
const connection = msg.payload;
|
|
168
|
-
if (connection.status !== ConnectionStatus.active && connection.status !== ConnectionStatus.connectionRequired) {
|
|
168
|
+
if (connection.status !== ConnectionStatus.active && connection.status !== ConnectionStatus.pending && connection.status !== ConnectionStatus.connectionRequired) {
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
171
|
if (!connection.credentials) return;
|
|
@@ -266,7 +266,7 @@ var authSpec = {
|
|
|
266
266
|
return { kind: "error", payload: msg.payload };
|
|
267
267
|
case "complete": {
|
|
268
268
|
const connection = msg.payload;
|
|
269
|
-
if (connection.status === ConnectionStatus.active || connection.status === ConnectionStatus.termsAcceptanceRequired) {
|
|
269
|
+
if (connection.status === ConnectionStatus.active || connection.status === ConnectionStatus.pending || connection.status === ConnectionStatus.termsAcceptanceRequired) {
|
|
270
270
|
return { kind: "complete", payload: msg.payload };
|
|
271
271
|
}
|
|
272
272
|
return null;
|
|
@@ -473,7 +473,8 @@ function MoonPayFrame({
|
|
|
473
473
|
transport,
|
|
474
474
|
hidden,
|
|
475
475
|
style,
|
|
476
|
-
webViewProps
|
|
476
|
+
webViewProps,
|
|
477
|
+
onRef
|
|
477
478
|
}) {
|
|
478
479
|
const webViewRef = useRef(null);
|
|
479
480
|
useEffect(() => {
|
|
@@ -481,6 +482,10 @@ function MoonPayFrame({
|
|
|
481
482
|
return () => {
|
|
482
483
|
};
|
|
483
484
|
}, [transport]);
|
|
485
|
+
useEffect(() => {
|
|
486
|
+
onRef?.(webViewRef.current);
|
|
487
|
+
return () => onRef?.(null);
|
|
488
|
+
}, [onRef]);
|
|
484
489
|
const url = transport.url;
|
|
485
490
|
if (!url) return null;
|
|
486
491
|
const handleMessage = (event) => {
|
|
@@ -1341,7 +1346,8 @@ function MoonPayFrameView({
|
|
|
1341
1346
|
style,
|
|
1342
1347
|
defaultStyle,
|
|
1343
1348
|
onEvent,
|
|
1344
|
-
webViewProps
|
|
1349
|
+
webViewProps,
|
|
1350
|
+
onRef
|
|
1345
1351
|
}) {
|
|
1346
1352
|
const { sessionToken, core, frameBaseUrl, theme } = useMoonPayContext();
|
|
1347
1353
|
const [transport, setTransport] = useState3(null);
|
|
@@ -1409,10 +1415,10 @@ function MoonPayFrameView({
|
|
|
1409
1415
|
applyReactiveProps(spec, reactiveKeys, propsRef.current, appliedRef.current, handle);
|
|
1410
1416
|
}, [liveKey]);
|
|
1411
1417
|
if (spec.hidden) {
|
|
1412
|
-
return transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, hidden: true, webViewProps }) : null;
|
|
1418
|
+
return transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, hidden: true, webViewProps, onRef }) : null;
|
|
1413
1419
|
}
|
|
1414
1420
|
const resolvedStyle = { ...defaultStyle, ...style };
|
|
1415
|
-
return /* @__PURE__ */ jsx4(View3, { style: resolvedStyle, children: transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, webViewProps }) : null });
|
|
1421
|
+
return /* @__PURE__ */ jsx4(View3, { style: resolvedStyle, children: transport ? /* @__PURE__ */ jsx4(MoonPayFrame, { transport, webViewProps, onRef }) : null });
|
|
1416
1422
|
}
|
|
1417
1423
|
|
|
1418
1424
|
// src/components/add-card.tsx
|
|
@@ -1439,7 +1445,8 @@ function MoonPayApplePayButton({
|
|
|
1439
1445
|
applePayButtonSettings,
|
|
1440
1446
|
onEvent,
|
|
1441
1447
|
style,
|
|
1442
|
-
webViewProps
|
|
1448
|
+
webViewProps,
|
|
1449
|
+
onRef
|
|
1443
1450
|
}) {
|
|
1444
1451
|
return /* @__PURE__ */ jsx6(
|
|
1445
1452
|
MoonPayFrameView,
|
|
@@ -1449,7 +1456,8 @@ function MoonPayApplePayButton({
|
|
|
1449
1456
|
style,
|
|
1450
1457
|
defaultStyle: { height: 48 },
|
|
1451
1458
|
onEvent,
|
|
1452
|
-
webViewProps
|
|
1459
|
+
webViewProps,
|
|
1460
|
+
onRef
|
|
1453
1461
|
}
|
|
1454
1462
|
);
|
|
1455
1463
|
}
|