@onekeyfe/react-native-chart-webview 3.0.73 → 3.0.75
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/android/src/main/java/com/margelo/nitro/chartwebview/PooledChartWebView.kt +17 -5
- package/lib/module/bridge.js +1 -0
- package/lib/module/bridge.js.map +1 -1
- package/lib/typescript/src/bridge.d.ts +1 -1
- package/lib/typescript/src/bridge.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bridge.ts +1 -0
|
@@ -109,21 +109,28 @@ class PooledChartWebView private constructor(
|
|
|
109
109
|
// trusted origins we load. allowedOriginRules of setOf("*") would leak the
|
|
110
110
|
// privileged bridge into every cross-origin subframe; here we pass only the
|
|
111
111
|
// offline asset origin and (in online mode) the configured chart origin.
|
|
112
|
-
private fun registerBridgeForOrigins(origins: Set<String>) {
|
|
113
|
-
if (outboundBridgeJs.isEmpty() || origins.isEmpty()) return
|
|
114
|
-
if (!WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT))
|
|
112
|
+
private fun registerBridgeForOrigins(origins: Set<String>): Boolean {
|
|
113
|
+
if (outboundBridgeJs.isEmpty() || origins.isEmpty()) return false
|
|
114
|
+
if (!WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) {
|
|
115
|
+
android.util.Log.e(
|
|
116
|
+
TAG,
|
|
117
|
+
"Document-start JavaScript is not supported; refusing to load chart without bridge",
|
|
118
|
+
)
|
|
119
|
+
return false
|
|
120
|
+
}
|
|
115
121
|
// No-op if nothing changed (same script + same origin set already registered).
|
|
116
122
|
if (bridgeScriptHandler != null &&
|
|
117
123
|
registeredBridgeJs == outboundBridgeJs &&
|
|
118
124
|
registeredOrigins == origins
|
|
119
125
|
) {
|
|
120
|
-
return
|
|
126
|
+
return true
|
|
121
127
|
}
|
|
122
128
|
bridgeScriptHandler?.remove()
|
|
123
129
|
bridgeScriptHandler =
|
|
124
130
|
WebViewCompat.addDocumentStartJavaScript(webView, outboundBridgeJs, origins)
|
|
125
131
|
registeredBridgeJs = outboundBridgeJs
|
|
126
132
|
registeredOrigins = origins
|
|
133
|
+
return true
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
// The trusted origin set for the current source: the offline asset origin
|
|
@@ -575,7 +582,12 @@ class PooledChartWebView private constructor(
|
|
|
575
582
|
// uses (offline asset origin, plus the online `uri` origin when present) before
|
|
576
583
|
// navigating, so the page boots with the bridge but cross-origin subframes /
|
|
577
584
|
// untrusted pages don't receive it.
|
|
578
|
-
registerBridgeForOrigins(trustedOriginsFor(uri))
|
|
585
|
+
if (!registerBridgeForOrigins(trustedOriginsFor(uri))) {
|
|
586
|
+
(owner ?: warmDriver)?.dispatchError(
|
|
587
|
+
"Document-start JavaScript is not supported; chart bridge was not installed",
|
|
588
|
+
)
|
|
589
|
+
return
|
|
590
|
+
}
|
|
579
591
|
val target = computeTargetUrl(uri, localBundle, entry, paramsJson) ?: return
|
|
580
592
|
if (target == lastLoadedUrl) return
|
|
581
593
|
lastLoadedUrl = target
|
package/lib/module/bridge.js
CHANGED
|
@@ -26,5 +26,6 @@ export const CHART_BRIDGE_JS = `(function(){
|
|
|
26
26
|
window.addEventListener('message', function(e){
|
|
27
27
|
try { var d = e && e.data; if (d && d.scope === '$private') fwd(d); } catch (err) {}
|
|
28
28
|
});
|
|
29
|
+
fwd({scope:'$private',method:'onekey_chartBridgeReady',data:{version:1,href:String(window.location && window.location.href || '')}});
|
|
29
30
|
})();`;
|
|
30
31
|
//# sourceMappingURL=bridge.js.map
|
package/lib/module/bridge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CHART_BRIDGE_JS"],"sourceRoot":"../../src","sources":["bridge.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,eAAe,GAAG;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["CHART_BRIDGE_JS"],"sourceRoot":"../../src","sources":["bridge.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,eAAe,GAAG;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const CHART_BRIDGE_JS = "(function(){\n if (window.__onekeyChartBridge) return; window.__onekeyChartBridge = true;\n var fwd = function(m){\n try { window.__chartNativePost(typeof m === 'string' ? m : JSON.stringify(m)); } catch (e) {}\n };\n window.$onekey = window.$onekey || {};\n window.$onekey.$private = window.$onekey.$private || {};\n window.$onekey.$private.request = function(m){ fwd(m); };\n window.ReactNativeWebView = window.ReactNativeWebView || {};\n window.ReactNativeWebView.postMessage = function(s){ fwd(String(s)); };\n window.addEventListener('message', function(e){\n try { var d = e && e.data; if (d && d.scope === '$private') fwd(d); } catch (err) {}\n });\n})();";
|
|
1
|
+
export declare const CHART_BRIDGE_JS = "(function(){\n if (window.__onekeyChartBridge) return; window.__onekeyChartBridge = true;\n var fwd = function(m){\n try { window.__chartNativePost(typeof m === 'string' ? m : JSON.stringify(m)); } catch (e) {}\n };\n window.$onekey = window.$onekey || {};\n window.$onekey.$private = window.$onekey.$private || {};\n window.$onekey.$private.request = function(m){ fwd(m); };\n window.ReactNativeWebView = window.ReactNativeWebView || {};\n window.ReactNativeWebView.postMessage = function(s){ fwd(String(s)); };\n window.addEventListener('message', function(e){\n try { var d = e && e.data; if (d && d.scope === '$private') fwd(d); } catch (err) {}\n });\n fwd({scope:'$private',method:'onekey_chartBridgeReady',data:{version:1,href:String(window.location && window.location.href || '')}});\n})();";
|
|
2
2
|
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../../src/bridge.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,eAAe,ozBActB,CAAC"}
|
package/package.json
CHANGED
package/src/bridge.ts
CHANGED
|
@@ -24,4 +24,5 @@ export const CHART_BRIDGE_JS = `(function(){
|
|
|
24
24
|
window.addEventListener('message', function(e){
|
|
25
25
|
try { var d = e && e.data; if (d && d.scope === '$private') fwd(d); } catch (err) {}
|
|
26
26
|
});
|
|
27
|
+
fwd({scope:'$private',method:'onekey_chartBridgeReady',data:{version:1,href:String(window.location && window.location.href || '')}});
|
|
27
28
|
})();`;
|