| 
				
			 | 
			
			
				@@ -18,6 +18,8 @@ import { 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				18
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				19
			 | 
			
				19
			 | 
			
			
				 import ImmutableComponent from 'react-immutable-component'; 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				20
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				21
			 | 
			
			
				+import Immutable from 'immutable'; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				23
			 | 
			
			
				 const RCTAutoHeightWebView = requireNativeComponent('RCTAutoHeightWebView', AutoHeightWebView, { nativeOnly: { messagingEnabled: PropTypes.bool } }); 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				24
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				23
			 | 
			
				25
			 | 
			
			
				 export default class AutoHeightWebView extends ImmutableComponent { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -47,9 +49,8 @@ export default class AutoHeightWebView extends ImmutableComponent { 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				49
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				50
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				49
			 | 
			
				51
			 | 
			
			
				     componentWillReceiveProps(nextProps) { 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-        // injectedJavaScript only works when webview reload (html changed) 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				
			 | 
			
			
				-        if (nextProps.html === this.props.html) { 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				
			 | 
			
			
				-            this.htmlHasChanged = false; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+        // injectedJavaScript only works when webview reload (source changed) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+        if (Immutable.is(Immutable.fromJS(this.props.source), Immutable.fromJS(nextProps.source))) { 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				54
			 | 
			
			
				             return; 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				55
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				56
			 | 
			
			
				         else { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -149,24 +150,30 @@ export default class AutoHeightWebView extends ImmutableComponent { 
			 | 
		
	
		
			
			| 
				149
			 | 
			
				150
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				150
			 | 
			
				151
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				151
			 | 
			
				152
			 | 
			
			
				     render() { 
			 | 
		
	
		
			
			| 
				152
			 | 
			
				
			 | 
			
			
				-        const source = this.props.enableBaseUrl ? { 
			 | 
		
	
		
			
			| 
				153
			 | 
			
				
			 | 
			
			
				-            html: this.props.html, 
			 | 
		
	
		
			
			| 
				154
			 | 
			
				
			 | 
			
			
				-            baseUrl: 'file:///android_asset/web/' 
			 | 
		
	
		
			
			| 
				155
			 | 
			
				
			 | 
			
			
				-        } : { html: this.props.html }; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				153
			 | 
			
			
				+        const { height, script, isChangingSource } = this.state; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				154
			 | 
			
			
				+        const { source, heightOffset, customScript, style, enableBaseUrl } = this.props; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				155
			 | 
			
			
				+        let webViewSource = source; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				156
			 | 
			
			
				+        if (enableBaseUrl) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				157
			 | 
			
			
				+            webViewSource = Object.assign({}, source, { baseUrl: 'file:///android_asset/web/' }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				158
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				156
			 | 
			
				159
			 | 
			
			
				         return ( 
			 | 
		
	
		
			
			| 
				157
			 | 
			
				160
			 | 
			
			
				             <View style={[{ 
			 | 
		
	
		
			
			| 
				158
			 | 
			
				161
			 | 
			
			
				                 width: ScreenWidth, 
			 | 
		
	
		
			
			| 
				159
			 | 
			
				
			 | 
			
			
				-                height: this.state.height + this.state.heightOffset 
			 | 
		
	
		
			
			| 
				160
			 | 
			
				
			 | 
			
			
				-            }, this.props.style]}> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				162
			 | 
			
			
				+                height: height + heightOffset, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				163
			 | 
			
			
				+                backgroundColor: 'transparent' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				164
			 | 
			
			
				+            }, style]}> 
			 | 
		
	
		
			
			| 
				161
			 | 
			
				165
			 | 
			
			
				                 { 
			 | 
		
	
		
			
			| 
				162
			 | 
			
				
			 | 
			
			
				-                    this.state.isChangingSource ? null : 
			 | 
		
	
		
			
			| 
				
			 | 
			
				166
			 | 
			
			
				+                    isChangingSource ? null : 
			 | 
		
	
		
			
			| 
				163
			 | 
			
				167
			 | 
			
			
				                         <RCTAutoHeightWebView 
			 | 
		
	
		
			
			| 
				164
			 | 
			
				168
			 | 
			
			
				                             ref={webview => this.webview = webview} 
			 | 
		
	
		
			
			| 
				165
			 | 
			
				
			 | 
			
			
				-                            style={{ flex: 1 }} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				169
			 | 
			
			
				+                            style={{ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				170
			 | 
			
			
				+                                flex: 1, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				171
			 | 
			
			
				+                                backgroundColor: 'transparent' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				172
			 | 
			
			
				+                            }} 
			 | 
		
	
		
			
			| 
				166
			 | 
			
				173
			 | 
			
			
				                             javaScriptEnabled={true} 
			 | 
		
	
		
			
			| 
				167
			 | 
			
				
			 | 
			
			
				-                            injectedJavaScript={this.state.script + this.props.customScript} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				174
			 | 
			
			
				+                            injectedJavaScript={script + customScript} 
			 | 
		
	
		
			
			| 
				168
			 | 
			
				175
			 | 
			
			
				                             scrollEnabled={false} 
			 | 
		
	
		
			
			| 
				169
			 | 
			
				
			 | 
			
			
				-                            source={source} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				176
			 | 
			
			
				+                            source={webViewSource} 
			 | 
		
	
		
			
			| 
				170
			 | 
			
				177
			 | 
			
			
				                             // below kitkat 
			 | 
		
	
		
			
			| 
				171
			 | 
			
				178
			 | 
			
			
				                             onChange={this.onMessage} 
			 | 
		
	
		
			
			| 
				172
			 | 
			
				179
			 | 
			
			
				                             onMessage={this.onMessage} 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -178,14 +185,14 @@ export default class AutoHeightWebView extends ImmutableComponent { 
			 | 
		
	
		
			
			| 
				178
			 | 
			
				185
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				179
			 | 
			
				186
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				180
			 | 
			
				187
			 | 
			
			
				 AutoHeightWebView.propTypes = { 
			 | 
		
	
		
			
			| 
				181
			 | 
			
				
			 | 
			
			
				-    ...WebView.propTypes, 
			 | 
		
	
		
			
			| 
				182
			 | 
			
				
			 | 
			
			
				-    html: PropTypes.string, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				188
			 | 
			
			
				+    source: WebView.propTypes.source, 
			 | 
		
	
		
			
			| 
				183
			 | 
			
				189
			 | 
			
			
				     onHeightUpdated: PropTypes.func, 
			 | 
		
	
		
			
			| 
				184
			 | 
			
				190
			 | 
			
			
				     customScript: PropTypes.string, 
			 | 
		
	
		
			
			| 
				185
			 | 
			
				191
			 | 
			
			
				     // offset rn webview margin 
			 | 
		
	
		
			
			| 
				186
			 | 
			
				192
			 | 
			
			
				     heightOffset: PropTypes.number, 
			 | 
		
	
		
			
			| 
				187
			 | 
			
				193
			 | 
			
			
				     // baseUrl not work in android 4.3 or below version 
			 | 
		
	
		
			
			| 
				188
			 | 
			
				194
			 | 
			
			
				     enableBaseUrl: PropTypes.bool, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				195
			 | 
			
			
				+    style: View.propTypes.style, 
			 | 
		
	
		
			
			| 
				189
			 | 
			
				196
			 | 
			
			
				     // works if set enableBaseUrl to true; add web/files... to android/app/src/assets/ 
			 | 
		
	
		
			
			| 
				190
			 | 
			
				197
			 | 
			
			
				     files: PropTypes.arrayOf(PropTypes.shape({ 
			 | 
		
	
		
			
			| 
				191
			 | 
			
				198
			 | 
			
			
				         href: PropTypes.string, 
			 |