@moon-x/react-native-sdk 0.14.0 → 0.14.1
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/ethereum.mjs +1 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +96 -10
- package/dist/index.mjs +97 -10
- package/dist/solana.mjs +1 -0
- package/dist/tron.mjs +1 -0
- package/package.json +1 -1
package/dist/ethereum.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -11,6 +11,10 @@ export { LoginWithEmailState, UseEphemeralSignerResult, UseLoginWithEmailCallbac
|
|
|
11
11
|
export { E as ExportKeyResult, u as useExportKey } from './use-export-key-BIz_tV0k.mjs';
|
|
12
12
|
import { WalletConnectClientLike, WalletConnectSessionLike } from '@moon-x/core/lib';
|
|
13
13
|
|
|
14
|
+
type ResponseErrorListener = (error: Error, context: {
|
|
15
|
+
type: PostMessageType;
|
|
16
|
+
method: string;
|
|
17
|
+
}) => void;
|
|
14
18
|
interface WebViewRefLike {
|
|
15
19
|
injectJavaScript: (script: string) => void;
|
|
16
20
|
}
|
|
@@ -24,15 +28,19 @@ declare class WebViewBridge {
|
|
|
24
28
|
private webViewRef;
|
|
25
29
|
private pending;
|
|
26
30
|
private oneWayHandlers;
|
|
31
|
+
private responseErrorListeners;
|
|
27
32
|
constructor(webViewRef: {
|
|
28
33
|
current: WebViewRefLike | null;
|
|
29
34
|
});
|
|
30
35
|
handleMessage: (event: WebViewMessageEventLike) => void;
|
|
31
36
|
register<Payload>(type: PostMessageType, method: PostMessageMethod | string, handler: IncomingMessageHandler<Payload>): () => void;
|
|
37
|
+
onResponseError(listener: ResponseErrorListener): () => void;
|
|
32
38
|
isReady(): boolean;
|
|
33
39
|
send<Payload, Response>(type: PostMessageType, method: PostMessageMethod | string, payload?: Payload): Promise<Response>;
|
|
34
40
|
private sendOnce;
|
|
35
41
|
sendOneWay<Payload>(type: PostMessageType, method: PostMessageMethod | string, payload?: Payload): void;
|
|
42
|
+
rejectAllPending(reason: string): void;
|
|
43
|
+
private rejectPending;
|
|
36
44
|
cleanup(reason?: string): void;
|
|
37
45
|
}
|
|
38
46
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export { LoginWithEmailState, UseEphemeralSignerResult, UseLoginWithEmailCallbac
|
|
|
11
11
|
export { E as ExportKeyResult, u as useExportKey } from './use-export-key-BIz_tV0k.js';
|
|
12
12
|
import { WalletConnectClientLike, WalletConnectSessionLike } from '@moon-x/core/lib';
|
|
13
13
|
|
|
14
|
+
type ResponseErrorListener = (error: Error, context: {
|
|
15
|
+
type: PostMessageType;
|
|
16
|
+
method: string;
|
|
17
|
+
}) => void;
|
|
14
18
|
interface WebViewRefLike {
|
|
15
19
|
injectJavaScript: (script: string) => void;
|
|
16
20
|
}
|
|
@@ -24,15 +28,19 @@ declare class WebViewBridge {
|
|
|
24
28
|
private webViewRef;
|
|
25
29
|
private pending;
|
|
26
30
|
private oneWayHandlers;
|
|
31
|
+
private responseErrorListeners;
|
|
27
32
|
constructor(webViewRef: {
|
|
28
33
|
current: WebViewRefLike | null;
|
|
29
34
|
});
|
|
30
35
|
handleMessage: (event: WebViewMessageEventLike) => void;
|
|
31
36
|
register<Payload>(type: PostMessageType, method: PostMessageMethod | string, handler: IncomingMessageHandler<Payload>): () => void;
|
|
37
|
+
onResponseError(listener: ResponseErrorListener): () => void;
|
|
32
38
|
isReady(): boolean;
|
|
33
39
|
send<Payload, Response>(type: PostMessageType, method: PostMessageMethod | string, payload?: Payload): Promise<Response>;
|
|
34
40
|
private sendOnce;
|
|
35
41
|
sendOneWay<Payload>(type: PostMessageType, method: PostMessageMethod | string, payload?: Payload): void;
|
|
42
|
+
rejectAllPending(reason: string): void;
|
|
43
|
+
private rejectPending;
|
|
36
44
|
cleanup(reason?: string): void;
|
|
37
45
|
}
|
|
38
46
|
|
package/dist/index.js
CHANGED
|
@@ -484,6 +484,7 @@ var WebViewBridge = class {
|
|
|
484
484
|
constructor(webViewRef) {
|
|
485
485
|
this.pending = /* @__PURE__ */ new Map();
|
|
486
486
|
this.oneWayHandlers = /* @__PURE__ */ new Map();
|
|
487
|
+
this.responseErrorListeners = /* @__PURE__ */ new Set();
|
|
487
488
|
// Wire to <WebView onMessage={bridge.handleMessage}>. Demultiplexes
|
|
488
489
|
// by request id; one-way messages (no id, or unknown id) fall through
|
|
489
490
|
// to handlers registered via `register`.
|
|
@@ -510,6 +511,12 @@ var WebViewBridge = class {
|
|
|
510
511
|
err[key] = value;
|
|
511
512
|
}
|
|
512
513
|
}
|
|
514
|
+
for (const listener of this.responseErrorListeners) {
|
|
515
|
+
try {
|
|
516
|
+
listener(err, { type: resolver.type, method: resolver.method });
|
|
517
|
+
} catch {
|
|
518
|
+
}
|
|
519
|
+
}
|
|
513
520
|
resolver.reject(err);
|
|
514
521
|
}
|
|
515
522
|
return;
|
|
@@ -532,6 +539,15 @@ var WebViewBridge = class {
|
|
|
532
539
|
}
|
|
533
540
|
};
|
|
534
541
|
}
|
|
542
|
+
// Subscribe to structured request rejections from the iframe-app.
|
|
543
|
+
// Returns an unsubscribe fn. Timeouts and local failures are NOT
|
|
544
|
+
// reported — only errors the iframe-app deliberately sent back.
|
|
545
|
+
onResponseError(listener) {
|
|
546
|
+
this.responseErrorListeners.add(listener);
|
|
547
|
+
return () => {
|
|
548
|
+
this.responseErrorListeners.delete(listener);
|
|
549
|
+
};
|
|
550
|
+
}
|
|
535
551
|
// Conforms to the `Transport.isReady()` half of @moon-x/core/sdk's
|
|
536
552
|
// interface — used by shared SDK factories to short-circuit before
|
|
537
553
|
// attempting to inject JS into a not-yet-mounted WebView.
|
|
@@ -586,7 +602,9 @@ var WebViewBridge = class {
|
|
|
586
602
|
this.pending.set(id, {
|
|
587
603
|
resolve,
|
|
588
604
|
reject,
|
|
589
|
-
timeoutId
|
|
605
|
+
timeoutId,
|
|
606
|
+
type,
|
|
607
|
+
method
|
|
590
608
|
});
|
|
591
609
|
const envelope = { id, type, method, payload };
|
|
592
610
|
try {
|
|
@@ -612,21 +630,62 @@ var WebViewBridge = class {
|
|
|
612
630
|
} catch {
|
|
613
631
|
}
|
|
614
632
|
}
|
|
615
|
-
// Reject every outstanding request
|
|
616
|
-
//
|
|
617
|
-
|
|
633
|
+
// Reject every outstanding request without touching registrations.
|
|
634
|
+
// Used when the WebView's web process dies and the page reloads: the
|
|
635
|
+
// in-flight requests can never be answered, but the one-way handlers
|
|
636
|
+
// and error listeners belong to still-mounted React effects and must
|
|
637
|
+
// survive the reload.
|
|
638
|
+
//
|
|
639
|
+
// Rejects with TimeoutError deliberately: "the reply will never come"
|
|
640
|
+
// is exactly what TimeoutError models, and it lets `send`'s retry loop
|
|
641
|
+
// re-send idempotent reads (RETRYABLE_METHODS) against the reloaded
|
|
642
|
+
// page instead of surfacing a one-off hard error. Mutating methods
|
|
643
|
+
// still fail fast, as they must — the request may or may not have
|
|
644
|
+
// been processed before the process died.
|
|
645
|
+
rejectAllPending(reason) {
|
|
646
|
+
this.rejectPending(() => new TimeoutError(reason));
|
|
647
|
+
}
|
|
648
|
+
rejectPending(createError) {
|
|
618
649
|
for (const [id, resolver] of this.pending.entries()) {
|
|
619
650
|
clearTimeout(resolver.timeoutId);
|
|
620
|
-
resolver.reject(
|
|
651
|
+
resolver.reject(createError());
|
|
621
652
|
this.pending.delete(id);
|
|
622
653
|
}
|
|
654
|
+
}
|
|
655
|
+
// Reject every outstanding request — wire on unmount so dangling
|
|
656
|
+
// promises don't dangle forever. Unmount is definitive, so use a plain
|
|
657
|
+
// Error rather than the retryable TimeoutError used for process death.
|
|
658
|
+
cleanup(reason = "webview_unmounted") {
|
|
659
|
+
this.rejectPending(() => new Error(reason));
|
|
623
660
|
this.oneWayHandlers.clear();
|
|
661
|
+
this.responseErrorListeners.clear();
|
|
624
662
|
}
|
|
625
663
|
};
|
|
626
664
|
|
|
627
665
|
// src/provider.tsx
|
|
628
666
|
var import_react2 = require("@moon-x/core/react");
|
|
629
667
|
var import_lib2 = require("@moon-x/core/lib");
|
|
668
|
+
|
|
669
|
+
// src/webview-lifecycle.ts
|
|
670
|
+
var initialWebViewLifecycleState = {
|
|
671
|
+
ready: false,
|
|
672
|
+
recoveryNonce: 0,
|
|
673
|
+
key: 0
|
|
674
|
+
};
|
|
675
|
+
var webViewLifecycleReducer = (state, action) => {
|
|
676
|
+
switch (action.type) {
|
|
677
|
+
case "ready":
|
|
678
|
+
return state.ready ? state : { ...state, ready: true };
|
|
679
|
+
case "recover":
|
|
680
|
+
return {
|
|
681
|
+
ready: false,
|
|
682
|
+
recoveryNonce: state.recoveryNonce + 1,
|
|
683
|
+
key: state.key + (action.remount ? 1 : 0)
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
// src/provider.tsx
|
|
630
689
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
631
690
|
var DEFAULT_IFRAME_URL = "https://iframe.moonx-dev.com";
|
|
632
691
|
var MoonXContext = (0, import_react.createContext)(null);
|
|
@@ -651,7 +710,14 @@ var MoonXProvider = ({
|
|
|
651
710
|
);
|
|
652
711
|
const [sensitiveVisible, setSensitiveVisible] = (0, import_react.useState)(false);
|
|
653
712
|
const cancelRef = (0, import_react.useRef)(null);
|
|
654
|
-
const [
|
|
713
|
+
const [
|
|
714
|
+
{
|
|
715
|
+
ready,
|
|
716
|
+
recoveryNonce: webViewRecoveryNonce,
|
|
717
|
+
key: webViewKey
|
|
718
|
+
},
|
|
719
|
+
dispatchWebViewLifecycle
|
|
720
|
+
] = (0, import_react.useReducer)(webViewLifecycleReducer, initialWebViewLifecycleState);
|
|
655
721
|
const [isAuthenticated, setIsAuthenticated] = (0, import_react.useState)(false);
|
|
656
722
|
const [user, setUser] = (0, import_react.useState)(null);
|
|
657
723
|
const [revalidatedAt, setRevalidatedAt] = (0, import_react.useState)(0);
|
|
@@ -811,24 +877,34 @@ var MoonXProvider = ({
|
|
|
811
877
|
bridge.cleanup("provider_unmounted");
|
|
812
878
|
};
|
|
813
879
|
}, [bridge]);
|
|
880
|
+
(0, import_react.useEffect)(() => {
|
|
881
|
+
const unsubscribe = bridge.onResponseError((error) => {
|
|
882
|
+
if (error.message !== "no_session") return;
|
|
883
|
+
if (authFlowsInFlightRef.current > 0) return;
|
|
884
|
+
setIsAuthenticated(false);
|
|
885
|
+
setUser(null);
|
|
886
|
+
setRestoreNonce((value) => value + 1);
|
|
887
|
+
});
|
|
888
|
+
return unsubscribe;
|
|
889
|
+
}, [bridge]);
|
|
814
890
|
(0, import_react.useEffect)(() => {
|
|
815
891
|
let cancelled = false;
|
|
816
892
|
const unregister = bridge.register(
|
|
817
893
|
import_utils4.PostMessageType.INIT,
|
|
818
894
|
import_utils4.PostMessageMethod.READY,
|
|
819
895
|
() => {
|
|
820
|
-
if (!cancelled)
|
|
896
|
+
if (!cancelled) dispatchWebViewLifecycle({ type: "ready" });
|
|
821
897
|
}
|
|
822
898
|
);
|
|
823
899
|
const fallback = setTimeout(() => {
|
|
824
|
-
if (!cancelled)
|
|
900
|
+
if (!cancelled) dispatchWebViewLifecycle({ type: "ready" });
|
|
825
901
|
}, 2e3);
|
|
826
902
|
return () => {
|
|
827
903
|
cancelled = true;
|
|
828
904
|
unregister();
|
|
829
905
|
clearTimeout(fallback);
|
|
830
906
|
};
|
|
831
|
-
}, [bridge]);
|
|
907
|
+
}, [bridge, webViewRecoveryNonce]);
|
|
832
908
|
(0, import_react.useEffect)(() => {
|
|
833
909
|
if (!ready) return;
|
|
834
910
|
let cancelled = false;
|
|
@@ -949,6 +1025,15 @@ var MoonXProvider = ({
|
|
|
949
1025
|
ref: webViewRef,
|
|
950
1026
|
source: { uri: initialSourceUri },
|
|
951
1027
|
onMessage: handleMessage,
|
|
1028
|
+
onContentProcessDidTerminate: () => {
|
|
1029
|
+
dispatchWebViewLifecycle({ type: "recover", remount: false });
|
|
1030
|
+
bridge.rejectAllPending("webview_process_terminated");
|
|
1031
|
+
webViewRef.current?.reload();
|
|
1032
|
+
},
|
|
1033
|
+
onRenderProcessGone: () => {
|
|
1034
|
+
dispatchWebViewLifecycle({ type: "recover", remount: true });
|
|
1035
|
+
bridge.rejectAllPending("webview_process_terminated");
|
|
1036
|
+
},
|
|
952
1037
|
webviewDebuggingEnabled: __DEV__,
|
|
953
1038
|
javaScriptEnabled: true,
|
|
954
1039
|
domStorageEnabled: true,
|
|
@@ -957,7 +1042,8 @@ var MoonXProvider = ({
|
|
|
957
1042
|
startInLoadingState: false,
|
|
958
1043
|
originWhitelist: ["https://*", "http://*"],
|
|
959
1044
|
style: styles.webView
|
|
960
|
-
}
|
|
1045
|
+
},
|
|
1046
|
+
webViewKey
|
|
961
1047
|
)
|
|
962
1048
|
]
|
|
963
1049
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
useContext,
|
|
6
6
|
useEffect,
|
|
7
7
|
useMemo,
|
|
8
|
+
useReducer,
|
|
8
9
|
useRef,
|
|
9
10
|
useState
|
|
10
11
|
} from "react";
|
|
@@ -453,6 +454,7 @@ var WebViewBridge = class {
|
|
|
453
454
|
constructor(webViewRef) {
|
|
454
455
|
this.pending = /* @__PURE__ */ new Map();
|
|
455
456
|
this.oneWayHandlers = /* @__PURE__ */ new Map();
|
|
457
|
+
this.responseErrorListeners = /* @__PURE__ */ new Set();
|
|
456
458
|
// Wire to <WebView onMessage={bridge.handleMessage}>. Demultiplexes
|
|
457
459
|
// by request id; one-way messages (no id, or unknown id) fall through
|
|
458
460
|
// to handlers registered via `register`.
|
|
@@ -479,6 +481,12 @@ var WebViewBridge = class {
|
|
|
479
481
|
err[key] = value;
|
|
480
482
|
}
|
|
481
483
|
}
|
|
484
|
+
for (const listener of this.responseErrorListeners) {
|
|
485
|
+
try {
|
|
486
|
+
listener(err, { type: resolver.type, method: resolver.method });
|
|
487
|
+
} catch {
|
|
488
|
+
}
|
|
489
|
+
}
|
|
482
490
|
resolver.reject(err);
|
|
483
491
|
}
|
|
484
492
|
return;
|
|
@@ -501,6 +509,15 @@ var WebViewBridge = class {
|
|
|
501
509
|
}
|
|
502
510
|
};
|
|
503
511
|
}
|
|
512
|
+
// Subscribe to structured request rejections from the iframe-app.
|
|
513
|
+
// Returns an unsubscribe fn. Timeouts and local failures are NOT
|
|
514
|
+
// reported — only errors the iframe-app deliberately sent back.
|
|
515
|
+
onResponseError(listener) {
|
|
516
|
+
this.responseErrorListeners.add(listener);
|
|
517
|
+
return () => {
|
|
518
|
+
this.responseErrorListeners.delete(listener);
|
|
519
|
+
};
|
|
520
|
+
}
|
|
504
521
|
// Conforms to the `Transport.isReady()` half of @moon-x/core/sdk's
|
|
505
522
|
// interface — used by shared SDK factories to short-circuit before
|
|
506
523
|
// attempting to inject JS into a not-yet-mounted WebView.
|
|
@@ -555,7 +572,9 @@ var WebViewBridge = class {
|
|
|
555
572
|
this.pending.set(id, {
|
|
556
573
|
resolve,
|
|
557
574
|
reject,
|
|
558
|
-
timeoutId
|
|
575
|
+
timeoutId,
|
|
576
|
+
type,
|
|
577
|
+
method
|
|
559
578
|
});
|
|
560
579
|
const envelope = { id, type, method, payload };
|
|
561
580
|
try {
|
|
@@ -581,21 +600,62 @@ var WebViewBridge = class {
|
|
|
581
600
|
} catch {
|
|
582
601
|
}
|
|
583
602
|
}
|
|
584
|
-
// Reject every outstanding request
|
|
585
|
-
//
|
|
586
|
-
|
|
603
|
+
// Reject every outstanding request without touching registrations.
|
|
604
|
+
// Used when the WebView's web process dies and the page reloads: the
|
|
605
|
+
// in-flight requests can never be answered, but the one-way handlers
|
|
606
|
+
// and error listeners belong to still-mounted React effects and must
|
|
607
|
+
// survive the reload.
|
|
608
|
+
//
|
|
609
|
+
// Rejects with TimeoutError deliberately: "the reply will never come"
|
|
610
|
+
// is exactly what TimeoutError models, and it lets `send`'s retry loop
|
|
611
|
+
// re-send idempotent reads (RETRYABLE_METHODS) against the reloaded
|
|
612
|
+
// page instead of surfacing a one-off hard error. Mutating methods
|
|
613
|
+
// still fail fast, as they must — the request may or may not have
|
|
614
|
+
// been processed before the process died.
|
|
615
|
+
rejectAllPending(reason) {
|
|
616
|
+
this.rejectPending(() => new TimeoutError(reason));
|
|
617
|
+
}
|
|
618
|
+
rejectPending(createError) {
|
|
587
619
|
for (const [id, resolver] of this.pending.entries()) {
|
|
588
620
|
clearTimeout(resolver.timeoutId);
|
|
589
|
-
resolver.reject(
|
|
621
|
+
resolver.reject(createError());
|
|
590
622
|
this.pending.delete(id);
|
|
591
623
|
}
|
|
624
|
+
}
|
|
625
|
+
// Reject every outstanding request — wire on unmount so dangling
|
|
626
|
+
// promises don't dangle forever. Unmount is definitive, so use a plain
|
|
627
|
+
// Error rather than the retryable TimeoutError used for process death.
|
|
628
|
+
cleanup(reason = "webview_unmounted") {
|
|
629
|
+
this.rejectPending(() => new Error(reason));
|
|
592
630
|
this.oneWayHandlers.clear();
|
|
631
|
+
this.responseErrorListeners.clear();
|
|
593
632
|
}
|
|
594
633
|
};
|
|
595
634
|
|
|
596
635
|
// src/provider.tsx
|
|
597
636
|
import { SDKProvider } from "@moon-x/core/react";
|
|
598
637
|
import { validatePublishableKey } from "@moon-x/core/lib";
|
|
638
|
+
|
|
639
|
+
// src/webview-lifecycle.ts
|
|
640
|
+
var initialWebViewLifecycleState = {
|
|
641
|
+
ready: false,
|
|
642
|
+
recoveryNonce: 0,
|
|
643
|
+
key: 0
|
|
644
|
+
};
|
|
645
|
+
var webViewLifecycleReducer = (state, action) => {
|
|
646
|
+
switch (action.type) {
|
|
647
|
+
case "ready":
|
|
648
|
+
return state.ready ? state : { ...state, ready: true };
|
|
649
|
+
case "recover":
|
|
650
|
+
return {
|
|
651
|
+
ready: false,
|
|
652
|
+
recoveryNonce: state.recoveryNonce + 1,
|
|
653
|
+
key: state.key + (action.remount ? 1 : 0)
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
// src/provider.tsx
|
|
599
659
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
600
660
|
var DEFAULT_IFRAME_URL = "https://iframe.moonx-dev.com";
|
|
601
661
|
var MoonXContext = createContext(null);
|
|
@@ -620,7 +680,14 @@ var MoonXProvider = ({
|
|
|
620
680
|
);
|
|
621
681
|
const [sensitiveVisible, setSensitiveVisible] = useState(false);
|
|
622
682
|
const cancelRef = useRef(null);
|
|
623
|
-
const [
|
|
683
|
+
const [
|
|
684
|
+
{
|
|
685
|
+
ready,
|
|
686
|
+
recoveryNonce: webViewRecoveryNonce,
|
|
687
|
+
key: webViewKey
|
|
688
|
+
},
|
|
689
|
+
dispatchWebViewLifecycle
|
|
690
|
+
] = useReducer(webViewLifecycleReducer, initialWebViewLifecycleState);
|
|
624
691
|
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
625
692
|
const [user, setUser] = useState(null);
|
|
626
693
|
const [revalidatedAt, setRevalidatedAt] = useState(0);
|
|
@@ -780,24 +847,34 @@ var MoonXProvider = ({
|
|
|
780
847
|
bridge.cleanup("provider_unmounted");
|
|
781
848
|
};
|
|
782
849
|
}, [bridge]);
|
|
850
|
+
useEffect(() => {
|
|
851
|
+
const unsubscribe = bridge.onResponseError((error) => {
|
|
852
|
+
if (error.message !== "no_session") return;
|
|
853
|
+
if (authFlowsInFlightRef.current > 0) return;
|
|
854
|
+
setIsAuthenticated(false);
|
|
855
|
+
setUser(null);
|
|
856
|
+
setRestoreNonce((value) => value + 1);
|
|
857
|
+
});
|
|
858
|
+
return unsubscribe;
|
|
859
|
+
}, [bridge]);
|
|
783
860
|
useEffect(() => {
|
|
784
861
|
let cancelled = false;
|
|
785
862
|
const unregister = bridge.register(
|
|
786
863
|
PostMessageType3.INIT,
|
|
787
864
|
PostMessageMethod3.READY,
|
|
788
865
|
() => {
|
|
789
|
-
if (!cancelled)
|
|
866
|
+
if (!cancelled) dispatchWebViewLifecycle({ type: "ready" });
|
|
790
867
|
}
|
|
791
868
|
);
|
|
792
869
|
const fallback = setTimeout(() => {
|
|
793
|
-
if (!cancelled)
|
|
870
|
+
if (!cancelled) dispatchWebViewLifecycle({ type: "ready" });
|
|
794
871
|
}, 2e3);
|
|
795
872
|
return () => {
|
|
796
873
|
cancelled = true;
|
|
797
874
|
unregister();
|
|
798
875
|
clearTimeout(fallback);
|
|
799
876
|
};
|
|
800
|
-
}, [bridge]);
|
|
877
|
+
}, [bridge, webViewRecoveryNonce]);
|
|
801
878
|
useEffect(() => {
|
|
802
879
|
if (!ready) return;
|
|
803
880
|
let cancelled = false;
|
|
@@ -918,6 +995,15 @@ var MoonXProvider = ({
|
|
|
918
995
|
ref: webViewRef,
|
|
919
996
|
source: { uri: initialSourceUri },
|
|
920
997
|
onMessage: handleMessage,
|
|
998
|
+
onContentProcessDidTerminate: () => {
|
|
999
|
+
dispatchWebViewLifecycle({ type: "recover", remount: false });
|
|
1000
|
+
bridge.rejectAllPending("webview_process_terminated");
|
|
1001
|
+
webViewRef.current?.reload();
|
|
1002
|
+
},
|
|
1003
|
+
onRenderProcessGone: () => {
|
|
1004
|
+
dispatchWebViewLifecycle({ type: "recover", remount: true });
|
|
1005
|
+
bridge.rejectAllPending("webview_process_terminated");
|
|
1006
|
+
},
|
|
921
1007
|
webviewDebuggingEnabled: __DEV__,
|
|
922
1008
|
javaScriptEnabled: true,
|
|
923
1009
|
domStorageEnabled: true,
|
|
@@ -926,7 +1012,8 @@ var MoonXProvider = ({
|
|
|
926
1012
|
startInLoadingState: false,
|
|
927
1013
|
originWhitelist: ["https://*", "http://*"],
|
|
928
1014
|
style: styles.webView
|
|
929
|
-
}
|
|
1015
|
+
},
|
|
1016
|
+
webViewKey
|
|
930
1017
|
)
|
|
931
1018
|
]
|
|
932
1019
|
}
|
package/dist/solana.mjs
CHANGED
package/dist/tron.mjs
CHANGED
package/package.json
CHANGED