@portal-hq/webview 4.2.13 → 4.3.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/lib/commonjs/index.js +21 -13
- package/lib/esm/index.js +4 -6
- package/package.json +5 -6
- package/src/index.tsx +16 -15
package/lib/commonjs/index.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -44,7 +54,7 @@ const react_1 = __importStar(require("react"));
|
|
|
44
54
|
const react_native_1 = require("react-native");
|
|
45
55
|
const react_native_webview_1 = __importDefault(require("react-native-webview"));
|
|
46
56
|
const loading_1 = __importDefault(require("./loading"));
|
|
47
|
-
const
|
|
57
|
+
const WebviewComponent = (0, react_1.forwardRef)(({ onNavigationStateChange, onSigningRequested, url }, webViewRef) => {
|
|
48
58
|
const Webview = () => {
|
|
49
59
|
var _a;
|
|
50
60
|
// Derive context.
|
|
@@ -52,7 +62,7 @@ const Webview = (0, react_1.memo)((0, react_1.forwardRef)(({ onNavigationStateCh
|
|
|
52
62
|
// Derive refs.
|
|
53
63
|
const canGoBack = (0, react_1.useRef)(false);
|
|
54
64
|
const initialized = (0, react_1.useRef)(false);
|
|
55
|
-
const webView = (0, react_1.useRef)();
|
|
65
|
+
const webView = (0, react_1.useRef)(null);
|
|
56
66
|
// Derive state.
|
|
57
67
|
const [currentUrl, setCurrentUrl] = (0, react_1.useState)(url);
|
|
58
68
|
const [walletAddress, setWalletAddress] = (0, react_1.useState)();
|
|
@@ -157,10 +167,8 @@ const Webview = (0, react_1.memo)((0, react_1.forwardRef)(({ onNavigationStateCh
|
|
|
157
167
|
</react_native_1.View>);
|
|
158
168
|
};
|
|
159
169
|
return <Webview />;
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
console.log(`nextProps:`, nextProps);
|
|
163
|
-
// return true
|
|
170
|
+
});
|
|
171
|
+
const Webview = (0, react_1.memo)(WebviewComponent, (prevProps, nextProps) => {
|
|
164
172
|
return prevProps.url === nextProps.url;
|
|
165
173
|
});
|
|
166
174
|
const styles = react_native_1.StyleSheet.create({
|
package/lib/esm/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import React, { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRe
|
|
|
16
16
|
import { BackHandler, Platform, StyleSheet, View } from 'react-native';
|
|
17
17
|
import WebView from 'react-native-webview';
|
|
18
18
|
import Loading from './loading';
|
|
19
|
-
const
|
|
19
|
+
const WebviewComponent = forwardRef(({ onNavigationStateChange, onSigningRequested, url }, webViewRef) => {
|
|
20
20
|
const Webview = () => {
|
|
21
21
|
var _a;
|
|
22
22
|
// Derive context.
|
|
@@ -24,7 +24,7 @@ const Webview = memo(forwardRef(({ onNavigationStateChange, onSigningRequested,
|
|
|
24
24
|
// Derive refs.
|
|
25
25
|
const canGoBack = useRef(false);
|
|
26
26
|
const initialized = useRef(false);
|
|
27
|
-
const webView = useRef();
|
|
27
|
+
const webView = useRef(null);
|
|
28
28
|
// Derive state.
|
|
29
29
|
const [currentUrl, setCurrentUrl] = useState(url);
|
|
30
30
|
const [walletAddress, setWalletAddress] = useState();
|
|
@@ -129,10 +129,8 @@ const Webview = memo(forwardRef(({ onNavigationStateChange, onSigningRequested,
|
|
|
129
129
|
</View>);
|
|
130
130
|
};
|
|
131
131
|
return <Webview />;
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
console.log(`nextProps:`, nextProps);
|
|
135
|
-
// return true
|
|
132
|
+
});
|
|
133
|
+
const Webview = memo(WebviewComponent, (prevProps, nextProps) => {
|
|
136
134
|
return prevProps.url === nextProps.url;
|
|
137
135
|
});
|
|
138
136
|
const styles = StyleSheet.create({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/webview",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/esm/index",
|
|
@@ -18,14 +18,13 @@
|
|
|
18
18
|
"test": "jest --passWithNoTests"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@portal-hq/core": "^4.
|
|
22
|
-
"@portal-hq/injected-provider": "^4.
|
|
23
|
-
"@portal-hq/utils": "^4.
|
|
21
|
+
"@portal-hq/core": "^4.3.1",
|
|
22
|
+
"@portal-hq/injected-provider": "^4.3.1",
|
|
23
|
+
"@portal-hq/utils": "^4.3.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/jest": "^29.2.0",
|
|
27
27
|
"@types/react": "*",
|
|
28
|
-
"@types/react-native": "*",
|
|
29
28
|
"jest": "^29.2.1",
|
|
30
29
|
"jest-environment-jsdom": "^29.2.2",
|
|
31
30
|
"ts-jest": "^29.0.3",
|
|
@@ -36,5 +35,5 @@
|
|
|
36
35
|
"react-native": "*",
|
|
37
36
|
"react-native-webview": "*"
|
|
38
37
|
},
|
|
39
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "0cfb3fc21c050a54e73044a87b92ac22f9e2edb7"
|
|
40
39
|
}
|
package/src/index.tsx
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
import { CHAIN_NAMESPACES, DEFAULT_CHAIN_ID_NUMERIC } from '@portal-hq/utils'
|
|
9
9
|
import React, {
|
|
10
10
|
FC,
|
|
11
|
-
MutableRefObject,
|
|
12
11
|
forwardRef,
|
|
13
12
|
memo,
|
|
14
13
|
useEffect,
|
|
@@ -32,7 +31,7 @@ interface WebviewProps {
|
|
|
32
31
|
url: string
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
const
|
|
34
|
+
const WebviewComponent =
|
|
36
35
|
forwardRef<WebView, WebviewProps>(
|
|
37
36
|
({ onNavigationStateChange, onSigningRequested, url }, webViewRef) => {
|
|
38
37
|
const Webview: FC = () => {
|
|
@@ -41,7 +40,7 @@ const Webview = memo(
|
|
|
41
40
|
// Derive refs.
|
|
42
41
|
const canGoBack = useRef<boolean>(false)
|
|
43
42
|
const initialized = useRef<boolean>(false)
|
|
44
|
-
const webView = useRef<WebView>()
|
|
43
|
+
const webView = useRef<WebView | null>(null)
|
|
45
44
|
|
|
46
45
|
// Derive state.
|
|
47
46
|
const [currentUrl, setCurrentUrl] = useState<string>(url)
|
|
@@ -99,7 +98,7 @@ const Webview = memo(
|
|
|
99
98
|
const handlePostMessage = async (event: WebViewMessageEvent) => {
|
|
100
99
|
const { type, data } = JSON.parse(event.nativeEvent.data)
|
|
101
100
|
const { method, params, options } = data as RequestArguments
|
|
102
|
-
|
|
101
|
+
|
|
103
102
|
switch (type) {
|
|
104
103
|
case 'portal_sign':
|
|
105
104
|
await portal.request(
|
|
@@ -111,7 +110,7 @@ const Webview = memo(
|
|
|
111
110
|
break
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
|
-
|
|
113
|
+
|
|
115
114
|
// Initialize Portal Bindings and set the wallet address
|
|
116
115
|
useEffect(() => {
|
|
117
116
|
if (portal && !initialized.current) {
|
|
@@ -177,7 +176,7 @@ const Webview = memo(
|
|
|
177
176
|
}, [])
|
|
178
177
|
|
|
179
178
|
// Ensure that the webView ref gets forwarded to the parent component
|
|
180
|
-
useImperativeHandle(webViewRef, () => webView.current
|
|
179
|
+
useImperativeHandle(webViewRef, () => webView.current!)
|
|
181
180
|
|
|
182
181
|
return (
|
|
183
182
|
<View style={styles.container}>
|
|
@@ -192,7 +191,7 @@ const Webview = memo(
|
|
|
192
191
|
mediaPlaybackRequiresUserAction={true}
|
|
193
192
|
onMessage={handlePostMessage}
|
|
194
193
|
onNavigationStateChange={handleNavigationStateChange}
|
|
195
|
-
ref={webView
|
|
194
|
+
ref={webView}
|
|
196
195
|
renderLoading={() => <Loading />}
|
|
197
196
|
source={source}
|
|
198
197
|
startInLoadingState={true}
|
|
@@ -205,14 +204,16 @@ const Webview = memo(
|
|
|
205
204
|
|
|
206
205
|
return <Webview />
|
|
207
206
|
},
|
|
208
|
-
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
const Webview =
|
|
211
|
+
memo(WebviewComponent,
|
|
212
|
+
(prevProps, nextProps) => {
|
|
213
|
+
return prevProps.url === nextProps.url
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
|
|
216
217
|
|
|
217
218
|
const styles = StyleSheet.create({
|
|
218
219
|
container: {
|