@onekeyfe/react-native-chart-webview 3.0.78 → 3.0.80
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 +5 -17
- package/lib/module/bridge.js +0 -1
- 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 +0 -1
|
@@ -109,28 +109,21 @@ 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))
|
|
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
|
-
}
|
|
112
|
+
private fun registerBridgeForOrigins(origins: Set<String>) {
|
|
113
|
+
if (outboundBridgeJs.isEmpty() || origins.isEmpty()) return
|
|
114
|
+
if (!WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) return
|
|
121
115
|
// No-op if nothing changed (same script + same origin set already registered).
|
|
122
116
|
if (bridgeScriptHandler != null &&
|
|
123
117
|
registeredBridgeJs == outboundBridgeJs &&
|
|
124
118
|
registeredOrigins == origins
|
|
125
119
|
) {
|
|
126
|
-
return
|
|
120
|
+
return
|
|
127
121
|
}
|
|
128
122
|
bridgeScriptHandler?.remove()
|
|
129
123
|
bridgeScriptHandler =
|
|
130
124
|
WebViewCompat.addDocumentStartJavaScript(webView, outboundBridgeJs, origins)
|
|
131
125
|
registeredBridgeJs = outboundBridgeJs
|
|
132
126
|
registeredOrigins = origins
|
|
133
|
-
return true
|
|
134
127
|
}
|
|
135
128
|
|
|
136
129
|
// The trusted origin set for the current source: the offline asset origin
|
|
@@ -582,12 +575,7 @@ class PooledChartWebView private constructor(
|
|
|
582
575
|
// uses (offline asset origin, plus the online `uri` origin when present) before
|
|
583
576
|
// navigating, so the page boots with the bridge but cross-origin subframes /
|
|
584
577
|
// untrusted pages don't receive it.
|
|
585
|
-
|
|
586
|
-
(owner ?: warmDriver)?.dispatchError(
|
|
587
|
-
"Document-start JavaScript is not supported; chart bridge was not installed",
|
|
588
|
-
)
|
|
589
|
-
return
|
|
590
|
-
}
|
|
578
|
+
registerBridgeForOrigins(trustedOriginsFor(uri))
|
|
591
579
|
val target = computeTargetUrl(uri, localBundle, entry, paramsJson) ?: return
|
|
592
580
|
if (target == lastLoadedUrl) return
|
|
593
581
|
lastLoadedUrl = target
|
package/lib/module/bridge.js
CHANGED
|
@@ -26,6 +26,5 @@ 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 || '')}});
|
|
30
29
|
})();`;
|
|
31
30
|
//# 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
|
|
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,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})();";
|
|
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,2qBAatB,CAAC"}
|
package/package.json
CHANGED
package/src/bridge.ts
CHANGED
|
@@ -24,5 +24,4 @@ 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 || '')}});
|
|
28
27
|
})();`;
|