Ver código fonte

rewrite with using react-native-webview

iou90 5 anos atrás
pai
commit
506b3e069a

+ 14
- 66
README.md Ver arquivo

@@ -1,43 +1,19 @@
1 1
 # react-native-autoheight-webview
2 2
 An auto height webview for React Native, or even auto width for inline html.
3 3
 
4
-The Current version do not support Android API version 18 and below and the native module has been removed.
4
+## Versioning
5 5
 
6
-Cause of javascript execution in webview is not working for Android API version 21 and below (https://github.com/facebook/react-native/issues/14754#issuecomment-361841219), auto width for inline html will not work on Android with API version 22 and below.
6
+`npm install react-native-autoheight-webview --save` (rn >= 0.57)
7 7
 
8
-Cause of changes to lifecycle methods in React 16.3.0 (https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html), please install react-native-autoheight-webview 0.6.1 for the project with 0.47 <= rn < 0.55
9
-
10
-Cause of removing unused createJSModules calls in React Naitve 0.47 (https://github.com/facebook/react-native/releases/tag/v0.47.2), please install react-native-autoheight-webview 0.3.1 for the project with 0.44 <= rn < 0.47.
11
-
12
-Cause of moving View.propTypes to ViewPropTypes in React Naitve 0.44 (https://github.com/facebook/react-native/releases/tag/v0.44.3) and PropTypes has been moved to a separate package in React 16 (https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes), please install react-native-autoheight-webview 0.2.3 for the project with rn < 0.44.
13
-
14
-`npm install react-native-autoheight-webview --save` (rn >= 0.56)
15
-
16
-`npm install react-native-autoheight-webview@0.6.1 --save` (0.47 <= rn < 0.56)
17
-
18
-`npm install react-native-autoheight-webview@0.3.1 --save` (0.44 <= rn < 0.47)
19
-
20
-`npm install react-native-autoheight-webview@0.2.3 --save` (rn < 0.44)
21
-
22
-## Android
23
-`react-native link react-native-autoheight-webview` (version <= 0.10.6)
24
-
25
-`react-native link react-native-webview` (version >= 1.0.0)
26
-
27
-`import AutoHeightWebView from 'react-native-autoheight-webview';`
28
-
29
-## iOS
30
-`react-native link react-native-webview` (version >= 1.0.0)
31
-
32
-`import AutoHeightWebView from 'react-native-autoheight-webview';`
33
-
34
-## showcase
35
-![react-native-autoheight-webview iOS](https://media.giphy.com/media/eehXhFjneVqEUCzYip/giphy.gif)&nbsp;
36
-![react-native-autoheight-webview Android](https://media.giphy.com/media/1yTcqipIfHbgNNfcEU/giphy.gif)
8
+Read [Readme.old](./Readme.old.md) for earlier version guide.
37 9
 
38 10
 ## usage
39 11
 
12
+`react-native link react-native-webview`
13
+
40 14
 ```javascript
15
+import AutoHeightWebView from 'react-native-autoheight-webview'
16
+
41 17
 <AutoHeightWebView
42 18
     // default width is the width of screen
43 19
     // if there are some text selection issues on iOS, the width should be reduced more than 15 and the marginTop should be added more than 35
@@ -52,15 +28,7 @@ Cause of moving View.propTypes to ViewPropTypes in React Naitve 0.44 (https://gi
52 28
         font-size: 16px;
53 29
       }
54 30
     `}
55
-    // animation enabled by default
56
-    enableAnimation={false},
57
-    // only works on enable animation
58
-    animationDuration={255},
59
-    // offset of rn webview margin 
60
-    heightOffset={5}
61
-    onMessage={e => console.log(e)},
62 31
     // either height or width updated will trigger this
63
-    // no support auto width and height will triggered by source changing only on android 5.1 or below version
64 32
     onSizeUpdated={({size => console.log(size.height)})},
65 33
     // 'file:///android_asset/web/' by default on android, 
66 34
     // web/' by default on iOS
@@ -76,38 +44,18 @@ Cause of moving View.propTypes to ViewPropTypes in React Naitve 0.44 (https://gi
76 44
         type: 'text/css',
77 45
         rel: 'stylesheet'
78 46
     }]}
79
-    // if set to true may cause some layout issues (smaller font size) on iOS
80
-    // if set to false may cause some layout issues (width of container will be than width of screen) on android
81
-    scalesPageToFit={Platform.OS === 'Android' ? true : false}
82 47
     // or uri
83 48
     source={{ html: `<p style="font-weight: 400;font-style: normal;font-size: 21px;line-height: 1.58;letter-spacing: -.003em;">Tags are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. <span style="background-color: transparent !important;background-image: linear-gradient(to bottom, rgba(146, 249, 190, 1), rgba(146, 249, 190, 1));">If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn’t only tag the piece with “moving”. I’d also use the tags “pets”, “marriage”, “career change”, and “travel tips”.</span></p>` }}
84
-    // rn WebView callbacks
85
-    onError={() => console.log('on error')}
86
-    onLoad={() => console.log('on load')}
87
-    onLoadStart={() => console.log('on load start')}
88
-    onLoadEnd={() => console.log('on load end')}
89
-    onNavigationStateChange={() => console.log('navigation state changed')}
90
-    // set scrollEnabled to true may cause some layout issues
91
-    // only on iOS
92
-    scrollEnabled={true},
93
-    // if page contains iframe on iOS, use a specific script for it
94
-    // only on iOS
95
-    hasIframe={true}
96
-    // only on iOS
97
-    onShouldStartLoadWithRequest={result => {
98
-      console.log(result)
99
-      return true;
100
-    }}
101
-    // only on Android for animating size (>= api 23)
102
-    animationEasing={Easing.ease()}
103 49
     /* 
104
-    other rn WebView props:
105
-    renderError, mediaPlaybackRequiresUserAction, originWhitelist
106
-    decelerationRate, allowsInlineMediaPlayback, bounces, dataDetectorTypes on iOS
107
-    domStorageEnabled, thirdPartyCookiesEnabled, userAgent, geolocationEnabled, allowUniversalAccessFromFileURLs, mixedContentMode on Android
50
+    other react-native-webview props
108 51
     */
109 52
   />
110 53
 ```
111 54
 
55
+
56
+## showcase
57
+![react-native-autoheight-webview iOS](https://media.giphy.com/media/tocJYDUGCgwac0kkyB/giphy.gif)&nbsp;
58
+![react-native-autoheight-webview Android](https://media.giphy.com/media/9JyX1wZshYIxuPklHK/giphy.gif)
59
+
112 60
 ## demo
113
-You may have to use yarn to install the dependencies of the demo and remove demo folder from demo/node_modules/react-native-autoheight-webview, cause of installing a local package with npm will create symlink, but there is no supporting of React Native to symlink (https://github.com/facebook/watchman/issues/105).
61
+You may have to use yarn to install the dependencies of the demo and remove demo/node_modules/react-native-autoheight-webview/demo manually, cause of installing a local package with npm will create symlink, but there is no supporting of React Native to symlink (https://github.com/facebook/watchman/issues/105).

+ 109
- 0
Readme.old.md Ver arquivo

@@ -0,0 +1,109 @@
1
+# react-native-autoheight-webview
2
+An auto height webview for React Native, or even auto width for inline html.
3
+
4
+The Current version do not support Android API version 18 and below and the native module has been removed.
5
+
6
+Cause of javascript execution in webview is not working for Android API version 21 and below (https://github.com/facebook/react-native/issues/14754#issuecomment-361841219), auto width for inline html will not work on Android with API version 22 and below.
7
+
8
+Cause of changes to lifecycle methods in React 16.3.0 (https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html), please install react-native-autoheight-webview 0.6.1 for the project with 0.47 <= rn < 0.55
9
+
10
+Cause of removing unused createJSModules calls in React Naitve 0.47 (https://github.com/facebook/react-native/releases/tag/v0.47.2), please install react-native-autoheight-webview 0.3.1 for the project with 0.44 <= rn < 0.47.
11
+
12
+Cause of moving View.propTypes to ViewPropTypes in React Naitve 0.44 (https://github.com/facebook/react-native/releases/tag/v0.44.3) and PropTypes has been moved to a separate package in React 16 (https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html#migrating-from-react.proptypes), please install react-native-autoheight-webview 0.2.3 for the project with rn < 0.44.
13
+
14
+`npm install react-native-autoheight-webview --save` (rn >= 0.56)
15
+
16
+`npm install react-native-autoheight-webview@0.6.1 --save` (0.47 <= rn < 0.56)
17
+
18
+`npm install react-native-autoheight-webview@0.3.1 --save` (0.44 <= rn < 0.47)
19
+
20
+`npm install react-native-autoheight-webview@0.2.3 --save` (rn < 0.44)
21
+
22
+## Android
23
+`react-native link react-native-autoheight-webview` (version 0.10.6 and below)
24
+
25
+`import AutoHeightWebView from 'react-native-autoheight-webview';`
26
+
27
+## iOS
28
+`import AutoHeightWebView from 'react-native-autoheight-webview';`
29
+
30
+## showcase
31
+![react-native-autoheight-webview iOS](https://media.giphy.com/media/eehXhFjneVqEUCzYip/giphy.gif)&nbsp;
32
+![react-native-autoheight-webview Android](https://media.giphy.com/media/1yTcqipIfHbgNNfcEU/giphy.gif)
33
+
34
+## usage
35
+
36
+```javascript
37
+<AutoHeightWebView
38
+    // default width is the width of screen
39
+    // if there are some text selection issues on iOS, the width should be reduced more than 15 and the marginTop should be added more than 35
40
+    style={{ width: Dimensions.get('window').width - 15, marginTop: 35 }}
41
+    customScript={`document.body.style.background = 'lightyellow';`}
42
+    // add custom CSS to the page's <head>
43
+    customStyle={`
44
+      * {
45
+        font-family: 'Times New Roman';
46
+      }
47
+      p {
48
+        font-size: 16px;
49
+      }
50
+    `}
51
+    // animation enabled by default
52
+    enableAnimation={false},
53
+    // only works on enable animation
54
+    animationDuration={255},
55
+    // offset of rn webview margin 
56
+    heightOffset={5}
57
+    onMessage={e => console.log(e)},
58
+    // either height or width updated will trigger this
59
+    // no support auto width and height will triggered by source changing only on android 5.1 or below version
60
+    onSizeUpdated={({size => console.log(size.height)})},
61
+    // 'file:///android_asset/web/' by default on android, 
62
+    // web/' by default on iOS
63
+    baseUrl: 'webAssets/',
64
+    /* 
65
+    use local or remote files
66
+    to add local files: 
67
+    add baseUrl/files... to android/app/src/assets/ on android
68
+    add baseUrl/files... to project root on iOS
69
+    */
70
+    files={[{
71
+        href: 'cssfileaddress',
72
+        type: 'text/css',
73
+        rel: 'stylesheet'
74
+    }]}
75
+    // if set to true may cause some layout issues (smaller font size) on iOS
76
+    // if set to false may cause some layout issues (width of container will be than width of screen) on android
77
+    scalesPageToFit={Platform.OS === 'Android' ? true : false}
78
+    // or uri
79
+    source={{ html: `<p style="font-weight: 400;font-style: normal;font-size: 21px;line-height: 1.58;letter-spacing: -.003em;">Tags are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. <span style="background-color: transparent !important;background-image: linear-gradient(to bottom, rgba(146, 249, 190, 1), rgba(146, 249, 190, 1));">If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn’t only tag the piece with “moving”. I’d also use the tags “pets”, “marriage”, “career change”, and “travel tips”.</span></p>` }}
80
+    // rn WebView callbacks
81
+    onError={() => console.log('on error')}
82
+    onLoad={() => console.log('on load')}
83
+    onLoadStart={() => console.log('on load start')}
84
+    onLoadEnd={() => console.log('on load end')}
85
+    onNavigationStateChange={() => console.log('navigation state changed')}
86
+    // set scrollEnabled to true may cause some layout issues
87
+    // only on iOS
88
+    scrollEnabled={true},
89
+    // if page contains iframe on iOS, use a specific script for it
90
+    // only on iOS
91
+    hasIframe={true}
92
+    // only on iOS
93
+    onShouldStartLoadWithRequest={result => {
94
+      console.log(result)
95
+      return true;
96
+    }}
97
+    // only on Android for animating size (>= api 23)
98
+    animationEasing={Easing.ease()}
99
+    /* 
100
+    other rn WebView props:
101
+    renderError, mediaPlaybackRequiresUserAction, originWhitelist
102
+    decelerationRate, allowsInlineMediaPlayback, bounces, dataDetectorTypes on iOS
103
+    domStorageEnabled, thirdPartyCookiesEnabled, userAgent, geolocationEnabled, allowUniversalAccessFromFileURLs, mixedContentMode on Android
104
+    */
105
+  />
106
+```
107
+
108
+## demo
109
+You may have to copy autoHeightWebView, node_modules folders and index.js to 'demo/node_modules/react-native-autoheight-webview/', cause of installing a local package with npm will create symlink, but there is no supporting of React Native to symlink (https://github.com/facebook/watchman/issues/105).

+ 0
- 271
autoHeightWebView/index.android.current.js Ver arquivo

@@ -1,271 +0,0 @@
1
-'use strict';
2
-
3
-import React, { PureComponent } from 'react';
4
-
5
-import { Animated, Easing, StyleSheet, WebView, Dimensions } from 'react-native';
6
-
7
-import PropTypes from 'prop-types';
8
-
9
-import { androidPropTypes } from 'react-native-autoheight-webview/autoHeightWebView/propTypes';
10
-
11
-import {
12
-  isEqual,
13
-  setState,
14
-  isSizeChanged,
15
-  handleSizeUpdated,
16
-  getWidth,
17
-  getScript,
18
-  domMutationObserveScript,
19
-  getCurrentSize
20
-} from 'react-native-autoheight-webview/autoHeightWebView/common';
21
-
22
-import momoize from 'react-native-autoheight-webview/autoHeightWebView/momoize';
23
-
24
-const getUpdatedState = momoize(setState, isEqual);
25
-
26
-function getRenderSize(enableAnimation, height, width, heightOffset, heightValue, widthValue) {
27
-  return {
28
-    height: enableAnimation ? heightValue : height ? height + heightOffset : 0,
29
-    width: enableAnimation ? widthValue : width
30
-  };
31
-}
32
-
33
-export default class AutoHeightWebView extends PureComponent {
34
-  static propTypes = {
35
-    ...androidPropTypes,
36
-    animationEasing: PropTypes.func
37
-  };
38
-
39
-  static defaultProps = {
40
-    baseUrl: 'file:///android_asset/web/',
41
-    scalesPageToFit: true,
42
-    enableAnimation: true,
43
-    animationDuration: 255,
44
-    heightOffset: 20,
45
-    animationEasing: Easing.out(Easing.quad)
46
-  };
47
-
48
-  constructor(props) {
49
-    super(props);
50
-    const { baseUrl, enableAnimation, style, source, heightOffset } = props;
51
-    this.webView = React.createRef();
52
-    this.finishInterval = true;
53
-    const initWidth = getWidth(style);
54
-    const initHeight = style ? (style.height ? style.height : 0) : 0;
55
-    let state = {
56
-      isSizeChanged: false,
57
-      isSizeMayChange: false,
58
-      height: initHeight,
59
-      width: initWidth,
60
-      script: getScript(props, getBaseScript),
61
-      source: Object.assign({}, source, { baseUrl })
62
-    };
63
-    if (enableAnimation) {
64
-      Object.assign(state, {
65
-        heightValue: new Animated.Value(initHeight ? initHeight + heightOffset : 0),
66
-        widthValue: new Animated.Value(initWidth)
67
-      });
68
-    }
69
-    this.state = state;
70
-  }
71
-
72
-  componentDidMount() {
73
-    this.startInterval();
74
-  }
75
-
76
-  static getDerivedStateFromProps(props, state) {
77
-    const { height: oldHeight, width: oldWidth, source: prevSource, script: prevScript } = state;
78
-    const { style } = props;
79
-    const { source, script } = getUpdatedState(props, getBaseScript);
80
-    const height = style ? style.height : null;
81
-    const width = style ? style.width : null;
82
-    if (source.html !== prevSource.html || source.uri !== prevSource.uri || script !== prevScript) {
83
-      return {
84
-        source,
85
-        script,
86
-        isSizeMayChange: true
87
-      };
88
-    }
89
-    if (isSizeChanged(height, oldHeight, width, oldWidth)) {
90
-      return {
91
-        height: height || oldHeight,
92
-        width: width || oldWidth,
93
-        isSizeChanged: true
94
-      };
95
-    }
96
-    return null;
97
-  }
98
-
99
-  componentDidUpdate() {
100
-    const { height, width, isSizeChanged, isSizeMayChange, heightValue, widthValue } = this.state;
101
-    if (isSizeMayChange) {
102
-      this.startInterval();
103
-      this.setState({ isSizeMayChange: false });
104
-    }
105
-    if (isSizeChanged) {
106
-      const { enableAnimation, animationDuration, animationEasing, onSizeUpdated, heightOffset } = this.props;
107
-      if (enableAnimation) {
108
-        Animated.parallel([
109
-          Animated.timing(heightValue, {
110
-            toValue: height ? height + heightOffset : 0,
111
-            easing: animationEasing,
112
-            duration: animationDuration
113
-          }),
114
-          Animated.timing(widthValue, {
115
-            toValue: width,
116
-            easing: animationEasing,
117
-            duration: animationDuration
118
-          })
119
-        ]).start(() => {
120
-          handleSizeUpdated(height, width, onSizeUpdated);
121
-        });
122
-      } else {
123
-        handleSizeUpdated(height, width, onSizeUpdated);
124
-      }
125
-      this.setState({ isSizeChanged: false });
126
-    }
127
-  }
128
-
129
-  componentWillUnmount() {
130
-    this.stopInterval();
131
-  }
132
-
133
-  startInterval() {
134
-    if (this.finishInterval === false) {
135
-      return;
136
-    }
137
-    this.finishInterval = false;
138
-    this.setState({
139
-      interval: setInterval(() => !this.finishInterval && this.webView.current.postMessage('getBodyHeight'), 205)
140
-    });
141
-  }
142
-
143
-  stopInterval() {
144
-    this.finishInterval = true;
145
-    clearInterval(this.state.interval);
146
-  }
147
-
148
-  onMessage = event => {
149
-    if (!event.nativeEvent) {
150
-      return;
151
-    }
152
-    let data = {};
153
-    // Sometimes the message is invalid JSON, so we ignore that case
154
-    try {
155
-      data = JSON.parse(event.nativeEvent.data);
156
-    } catch (error) {
157
-      console.error(error);
158
-      return;
159
-    }
160
-    const { height, width } = data;
161
-    const { height: oldHeight, width: oldWidth } = this.state;
162
-    if (isSizeChanged(height, oldHeight, width, oldWidth)) {
163
-      this.stopInterval();
164
-      this.setState({
165
-        isSizeChanged: true,
166
-        height,
167
-        width
168
-      });
169
-    }
170
-    const { onMessage } = this.props;
171
-    onMessage && onMessage(event);
172
-  };
173
-
174
-  render() {
175
-    const { height, width, script, source, heightValue, widthValue } = this.state;
176
-    const {
177
-      domStorageEnabled,
178
-      thirdPartyCookiesEnabled,
179
-      userAgent,
180
-      geolocationEnabled,
181
-      allowUniversalAccessFromFileURLs,
182
-      mixedContentMode,
183
-      onNavigationStateChange,
184
-      renderError,
185
-      originWhitelist,
186
-      mediaPlaybackRequiresUserAction,
187
-      scalesPageToFit,
188
-      style,
189
-      heightOffset,
190
-      enableAnimation,
191
-      onError,
192
-      onLoad,
193
-      onLoadStart,
194
-      onLoadEnd
195
-    } = this.props;
196
-    return (
197
-      <Animated.View
198
-        style={[
199
-          styles.container,
200
-          getRenderSize(enableAnimation, height, width, heightOffset, heightValue, widthValue),
201
-          style
202
-        ]}
203
-      >
204
-        <WebView
205
-          onNavigationStateChange={onNavigationStateChange}
206
-          domStorageEnabled={domStorageEnabled}
207
-          thirdPartyCookiesEnabled={thirdPartyCookiesEnabled}
208
-          userAgent={userAgent}
209
-          geolocationEnabled={geolocationEnabled}
210
-          allowUniversalAccessFromFileURLs={allowUniversalAccessFromFileURLs}
211
-          mixedContentMode={mixedContentMode}
212
-          renderError={renderError}
213
-          mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
214
-          originWhitelist={originWhitelist || ['*']}
215
-          ref={this.webView}
216
-          onMessage={this.onMessage}
217
-          onError={onError}
218
-          onLoad={onLoad}
219
-          onLoadStart={onLoadStart}
220
-          onLoadEnd={onLoadEnd}
221
-          style={styles.webView}
222
-          scalesPageToFit={scalesPageToFit}
223
-          javaScriptEnabled={true}
224
-          injectedJavaScript={script}
225
-          source={source}
226
-        />
227
-      </Animated.View>
228
-    );
229
-  }
230
-}
231
-
232
-const styles = StyleSheet.create({
233
-  container: {
234
-    height: 50,
235
-    width: Dimensions.get('window').width,
236
-    backgroundColor: 'transparent'
237
-  },
238
-  webView: {
239
-    flex: 1,
240
-    backgroundColor: 'transparent'
241
-  }
242
-});
243
-
244
-const commonScript = `
245
-    ${getCurrentSize}
246
-    var wrapper = document.createElement("div");
247
-    wrapper.id = "wrapper";
248
-    while (document.body.firstChild instanceof Node) {
249
-        wrapper.appendChild(document.body.firstChild);
250
-    }
251
-    document.body.appendChild(wrapper);
252
-    var height = 0;
253
-`;
254
-
255
-const getBaseScript = function(style) {
256
-  return `
257
-  ; 
258
-  ${commonScript}
259
-  var width = ${getWidth(style)};
260
-  function updateSize() {
261
-    var size = getSize(document.body.firstChild); 
262
-    height = size.height;
263
-    width = size.width;
264
-    window.postMessage(JSON.stringify({ width: width, height: height }), '*');
265
-  }
266
-  (function () {
267
-    document.addEventListener("message", updateSize);
268
-    ${domMutationObserveScript}
269
-  } ());
270
-`;
271
-};

+ 0
- 13
autoHeightWebView/index.android.js Ver arquivo

@@ -1,13 +0,0 @@
1
-'use strict';
2
-
3
-import { Platform } from 'react-native';
4
-
5
-import AutoHeightWebViewOld from './index.android.old.js';
6
-
7
-import AutoHeightWebView from './index.android.current.js';
8
-
9
-const isBelowMarshmallow = Platform.Version < 23;
10
-
11
-const webview = isBelowMarshmallow ? AutoHeightWebViewOld : AutoHeightWebView;
12
-
13
-export default webview;

+ 0
- 194
autoHeightWebView/index.android.old.js Ver arquivo

@@ -1,194 +0,0 @@
1
-'use strict';
2
-
3
-import React, { PureComponent } from 'react';
4
-
5
-import { Animated, Dimensions, StyleSheet, WebView } from 'react-native';
6
-
7
-import { androidPropTypes } from './propTypes.js';
8
-
9
-import Immutable from 'immutable';
10
-
11
-import { handleSizeUpdated, domMutationObserveScript } from './common.js';
12
-
13
-export default class AutoHeightWebView extends PureComponent {
14
-  static propTypes = androidPropTypes;
15
-
16
-  static defaultProps = {
17
-    scalesPageToFit: true,
18
-    enableBaseUrl: false,
19
-    enableAnimation: true,
20
-    animationDuration: 555,
21
-    heightOffset: 20
22
-  };
23
-
24
-  constructor(props) {
25
-    super(props);
26
-    props.enableAnimation && (this.opacityAnimatedValue = new Animated.Value(0));
27
-    this.state = {
28
-      isChangingSource: false,
29
-      height: 0,
30
-      heightOffset: 0,
31
-      script: baseScript
32
-    };
33
-  }
34
-
35
-  componentDidMount() {
36
-    this.startInterval();
37
-  }
38
-
39
-  componentWillReceiveProps(nextProps) {
40
-    // injectedJavaScript only works when webView reload (source changed)
41
-    if (Immutable.is(Immutable.fromJS(this.props.source), Immutable.fromJS(nextProps.source))) {
42
-      return;
43
-    } else {
44
-      this.setState(
45
-        {
46
-          isChangingSource: true,
47
-          height: 0,
48
-          heightOffset: 0
49
-        },
50
-        () => {
51
-          this.startInterval();
52
-          this.setState({ isChangingSource: false });
53
-        }
54
-      );
55
-    }
56
-    this.setState({ script: baseScript });
57
-  }
58
-
59
-  componentWillUnmount() {
60
-    this.stopInterval();
61
-  }
62
-
63
-  startInterval() {
64
-    this.finishInterval = false;
65
-    this.interval = setInterval(() => !this.finishInterval && this.webView.postMessage('getBodyHeight'), 205);
66
-  }
67
-
68
-  stopInterval() {
69
-    this.finishInterval = true;
70
-    clearInterval(this.interval);
71
-  }
72
-
73
-  onMessage = event => {
74
-    const height = parseInt(event.nativeEvent.data);
75
-    if (height && height !== this.state.height) {
76
-      const { enableAnimation, animationDuration, heightOffset, onSizeUpdated, style } = this.props;
77
-      enableAnimation && this.opacityAnimatedValue.setValue(0);
78
-      this.stopInterval();
79
-      this.setState(
80
-        {
81
-          heightOffset,
82
-          height
83
-        },
84
-        () => {
85
-          const currentWidth = Object.assign(styles.container, style).width;
86
-          enableAnimation
87
-            ? Animated.timing(this.opacityAnimatedValue, {
88
-                toValue: 1,
89
-                duration: animationDuration
90
-              }).start(() => handleSizeUpdated(height, currentWidth, onSizeUpdated))
91
-            : handleSizeUpdated(height, currentWidth, onSizeUpdated);
92
-        }
93
-      );
94
-    }
95
-    const { onMessage } = this.props;
96
-    onMessage && onMessage(event);
97
-  };
98
-
99
-  getWebView = webView => (this.webView = webView);
100
-
101
-  render() {
102
-    const { height, script, isChangingSource, heightOffset } = this.state;
103
-    const {
104
-      thirdPartyCookiesEnabled,
105
-      domStorageEnabled,
106
-      userAgent,
107
-      geolocationEnabled,
108
-      allowUniversalAccessFromFileURLs,
109
-      mixedContentMode,
110
-      onNavigationStateChange,
111
-      renderError,
112
-      originWhitelist,
113
-      mediaPlaybackRequiresUserAction,
114
-      scalesPageToFit,
115
-      enableAnimation,
116
-      source,
117
-      customScript,
118
-      style,
119
-      enableBaseUrl,
120
-      onError,
121
-      onLoad,
122
-      onLoadStart,
123
-      onLoadEnd
124
-    } = this.props;
125
-    let webViewSource = source;
126
-    if (enableBaseUrl) {
127
-      webViewSource = Object.assign({}, source, {
128
-        baseUrl: 'file:///android_asset/web/'
129
-      });
130
-    }
131
-    return (
132
-      <Animated.View
133
-        style={[
134
-          styles.container,
135
-          {
136
-            opacity: enableAnimation ? this.opacityAnimatedValue : 1,
137
-            height: height + heightOffset
138
-          },
139
-          style
140
-        ]}
141
-      >
142
-        {isChangingSource ? null : (
143
-          <WebView
144
-            onNavigationStateChange={onNavigationStateChange}
145
-            domStorageEnabled={domStorageEnabled}
146
-            thirdPartyCookiesEnabled={thirdPartyCookiesEnabled}
147
-            userAgent={userAgent}
148
-            geolocationEnabled={geolocationEnabled}
149
-            allowUniversalAccessFromFileURLs={allowUniversalAccessFromFileURLs}
150
-            mixedContentMode={mixedContentMode}
151
-            renderError={renderError}
152
-            mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
153
-            originWhitelist={originWhitelist}
154
-            ref={this.getWebView}
155
-            onMessage={this.onMessage}
156
-            onError={onError}
157
-            onLoad={onLoad}
158
-            onLoadStart={onLoadStart}
159
-            onLoadEnd={onLoadEnd}
160
-            style={styles.webView}
161
-            scalesPageToFit={scalesPageToFit}
162
-            javaScriptEnabled={true}
163
-            injectedJavaScript={script + customScript}
164
-            source={webViewSource}
165
-            messagingEnabled={true}
166
-          />
167
-        )}
168
-      </Animated.View>
169
-    );
170
-  }
171
-}
172
-
173
-const screenWidth = Dimensions.get('window').width;
174
-
175
-const styles = StyleSheet.create({
176
-  container: {
177
-    height: 50,
178
-    width: screenWidth,
179
-    backgroundColor: 'transparent'
180
-  },
181
-  webView: {
182
-    flex: 1,
183
-    backgroundColor: 'transparent'
184
-  }
185
-});
186
-
187
-const baseScript = `
188
-; (function () {
189
-    document.addEventListener('message', function (e) {
190
-        window.postMessage(String(document.body.offsetHeight));
191
-    });
192
-    ${domMutationObserveScript}
193
-} ());
194
-`;

+ 0
- 224
autoHeightWebView/index.ios.js Ver arquivo

@@ -1,224 +0,0 @@
1
-'use strict';
2
-
3
-import React, { PureComponent } from 'react';
4
-
5
-import { Animated, StyleSheet } from 'react-native';
6
-
7
-import PropTypes from 'prop-types';
8
-
9
-import { commonPropTypes } from './propTypes.js';
10
-
11
-import { WebView } from 'react-native-webview';
12
-
13
-import {
14
-  isEqual,
15
-  setState,
16
-  getWidth,
17
-  isSizeChanged,
18
-  handleSizeUpdated,
19
-  domMutationObserveScript,
20
-  getStateFromProps,
21
-  updateSizeWithMessage
22
-} from './common.js';
23
-
24
-import momoize from './momoize';
25
-
26
-export default class AutoHeightWebView extends PureComponent {
27
-  static propTypes = {
28
-    ...commonPropTypes,
29
-    hasIframe: PropTypes.bool,
30
-    // only works on enable animation
31
-    animationDuration: PropTypes.number,
32
-    // offset of rn webview margin
33
-    heightOffset: PropTypes.number,
34
-    // webview props
35
-    scrollEnabled: PropTypes.bool,
36
-    onShouldStartLoadWithRequest: PropTypes.func,
37
-    decelerationRate: PropTypes.number,
38
-    allowsInlineMediaPlayback: PropTypes.bool,
39
-    bounces: PropTypes.bool,
40
-    dataDetectorTypes: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
41
-  };
42
-
43
-  static defaultProps = {
44
-    baseUrl: 'web/',
45
-    enableAnimation: true,
46
-    animationDuration: 255,
47
-    heightOffset: 12
48
-  };
49
-
50
-  constructor(props) {
51
-    super(props);
52
-    const { enableAnimation, style } = props;
53
-    enableAnimation && (this.opacityAnimatedValue = new Animated.Value(0));
54
-    this.webView = React.createRef();
55
-    this.state = {
56
-      isSizeChanged: false,
57
-      width: getWidth(style),
58
-      height: style && style.height ? style.height : 0
59
-    };
60
-  }
61
-
62
-  getUpdatedState = momoize(setState, isEqual);
63
-
64
-  static getDerivedStateFromProps(props, state) {
65
-    return getStateFromProps(props, state);
66
-  }
67
-
68
-  componentDidUpdate() {
69
-    const { height, width, isSizeChanged } = this.state;
70
-    if (isSizeChanged) {
71
-      const { enableAnimation, animationDuration, onSizeUpdated } = this.props;
72
-      if (enableAnimation) {
73
-        Animated.timing(this.opacityAnimatedValue, {
74
-          toValue: 1,
75
-          duration: animationDuration
76
-        }).start(() => {
77
-          handleSizeUpdated(height, width, onSizeUpdated);
78
-        });
79
-      } else {
80
-        handleSizeUpdated(height, width, onSizeUpdated);
81
-      }
82
-      this.setState({ isSizeChanged: false });
83
-    }
84
-  }
85
-
86
-  onMessage = event => {
87
-    if (!event.nativeEvent) {
88
-      return;
89
-    }
90
-    let data = {};
91
-    // Sometimes the message is invalid JSON, so we ignore that case
92
-    try {
93
-      data = JSON.parse(event.nativeEvent.data);
94
-    } catch (error) {
95
-      console.error(error);
96
-      return;
97
-    }
98
-    const { height, width } = data;
99
-    const { height: oldHeight, width: oldWidth } = this.state;
100
-    if (isSizeChanged(height, oldHeight, width, oldWidth)) {
101
-      this.props.enableAnimation && this.opacityAnimatedValue.setValue(0);
102
-      this.setState({
103
-        isSizeChanged: true,
104
-        height,
105
-        width
106
-      });
107
-    }
108
-    const { onMessage } = this.props;
109
-    onMessage && onMessage(event);
110
-  };
111
-
112
-  stopLoading() {
113
-    this.webView.current.stopLoading();
114
-  }
115
-
116
-  render() {
117
-    const { height, width } = this.state;
118
-    const {
119
-      renderError,
120
-      originWhitelist,
121
-      mediaPlaybackRequiresUserAction,
122
-      bounces,
123
-      decelerationRate,
124
-      allowsInlineMediaPlayback,
125
-      dataDetectorTypes,
126
-      onNavigationStateChange,
127
-      onError,
128
-      onLoad,
129
-      onLoadStart,
130
-      onLoadEnd,
131
-      onShouldStartLoadWithRequest,
132
-      enableAnimation,
133
-      heightOffset,
134
-      style,
135
-      scrollEnabled
136
-    } = this.props;
137
-    const { source, script } = this.getUpdatedState(this.props, getBaseScript, getIframeBaseScript);
138
-    return (
139
-      <Animated.View
140
-        style={[
141
-          styles.container,
142
-          {
143
-            opacity: enableAnimation ? this.opacityAnimatedValue : 1,
144
-            width,
145
-            height: height + heightOffset
146
-          },
147
-          style
148
-        ]}
149
-      >
150
-        <WebView
151
-          renderError={renderError}
152
-          mediaPlaybackRequiresUserAction={mediaPlaybackRequiresUserAction}
153
-          bounces={bounces}
154
-          decelerationRate={decelerationRate}
155
-          allowsInlineMediaPlayback={allowsInlineMediaPlayback}
156
-          dataDetectorTypes={dataDetectorTypes}
157
-          originWhitelist={originWhitelist || ['*']}
158
-          ref={this.webView}
159
-          onMessage={this.onMessage}
160
-          onError={onError}
161
-          onLoad={onLoad}
162
-          onLoadStart={onLoadStart}
163
-          onLoadEnd={onLoadEnd}
164
-          onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
165
-          style={styles.webView}
166
-          scrollEnabled={!!scrollEnabled}
167
-          injectedJavaScript={script}
168
-          source={source}
169
-          onNavigationStateChange={onNavigationStateChange}
170
-        />
171
-      </Animated.View>
172
-    );
173
-  }
174
-}
175
-
176
-const styles = StyleSheet.create({
177
-  container: {
178
-    backgroundColor: 'transparent'
179
-  },
180
-  webView: {
181
-    backgroundColor: 'transparent',
182
-    flex: 1
183
-  }
184
-});
185
-
186
-// add viewport setting to meta for WKWebView
187
-const commonScript = `
188
-var meta = document.createElement('meta'); 
189
-meta.setAttribute('name', 'viewport'); 
190
-meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);
191
-updateSize();
192
-window.addEventListener('load', updateSize);
193
-window.addEventListener('resize', updateSize);
194
-`;
195
-
196
-function getBaseScript(style) {
197
-  return `
198
-  ;
199
-  (function () {
200
-    if (!document.getElementById("rnahw-wrapper")) {
201
-      var wrapper = document.createElement('div');
202
-      wrapper.id = 'rnahw-wrapper';
203
-      wrapper.appendChild(document.body.firstChild);
204
-      document.body.appendChild(wrapper);
205
-    }
206
-    var width = ${getWidth(style)};
207
-    ${updateSizeWithMessage('wrapper')}
208
-    ${commonScript}
209
-    ${domMutationObserveScript}
210
-  } ());
211
-  `;
212
-}
213
-
214
-function getIframeBaseScript(style) {
215
-  return `
216
-  ;
217
-  (function () {
218
-    var width = ${getWidth(style)};
219
-    ${updateSizeWithMessage('document.body.firstChild')}
220
-    ${commonScript}
221
-    ${domMutationObserveScript}
222
-  } ());
223
-  `;
224
-}

+ 136
- 0
autoHeightWebView/index.js Ver arquivo

@@ -0,0 +1,136 @@
1
+'use strict';
2
+
3
+import React, { PureComponent } from 'react';
4
+
5
+import { StyleSheet, Platform, ViewPropTypes } from 'react-native';
6
+
7
+import PropTypes from 'prop-types';
8
+
9
+import { WebView } from 'react-native-webview';
10
+
11
+import {
12
+  isEqual,
13
+  setState,
14
+  getWidth,
15
+  isSizeChanged,
16
+  handleSizeUpdated,
17
+  getStateFromProps,
18
+  getBaseScript
19
+} from './utils';
20
+
21
+import momoize from './momoize';
22
+
23
+export default class AutoHeightWebView extends PureComponent {
24
+  static propTypes = {
25
+    onSizeUpdated: PropTypes.func,
26
+    // 'web/' by default on iOS
27
+    // 'file:///android_asset/web/' by default on Android
28
+    baseUrl: PropTypes.string,
29
+    // add baseUrl/files... to android/app/src/assets/ on android
30
+    // add baseUrl/files... to project root on iOS
31
+    files: PropTypes.arrayOf(
32
+      PropTypes.shape({
33
+        href: PropTypes.string,
34
+        type: PropTypes.string,
35
+        rel: PropTypes.string
36
+      })
37
+    ),
38
+    style: ViewPropTypes.style,
39
+    customScript: PropTypes.string,
40
+    customStyle: PropTypes.string,
41
+    // webview props
42
+    originWhitelist: PropTypes.arrayOf(PropTypes.string),
43
+    onMessage: PropTypes.func
44
+  };
45
+
46
+  static defaultProps = {
47
+    baseUrl: Platform.OS === 'ios' ? 'web/' : 'file:///android_asset/web/'
48
+  };
49
+
50
+  constructor(props) {
51
+    super(props);
52
+    const { style } = props;
53
+    this.webView = React.createRef();
54
+    const width = getWidth(style);
55
+    const height = style && style.height ? style.height : 1;
56
+    this.size = {
57
+      oldWidth: width,
58
+      oldHeight: height
59
+    };
60
+    this.state = {
61
+      width,
62
+      height
63
+    };
64
+  }
65
+
66
+  getUpdatedState = momoize(setState, isEqual);
67
+
68
+  static getDerivedStateFromProps(props, state) {
69
+    return getStateFromProps(props, state);
70
+  }
71
+
72
+  onMessage = event => {
73
+    if (!event.nativeEvent) {
74
+      return;
75
+    }
76
+    let data = {};
77
+    // Sometimes the message is invalid JSON, so we ignore that case
78
+    try {
79
+      data = JSON.parse(event.nativeEvent.data);
80
+    } catch (error) {
81
+      console.error(error);
82
+      return;
83
+    }
84
+    const { height, width } = data;
85
+    const { oldHeight, oldWidth } = this.size;
86
+    if (isSizeChanged(height, oldHeight, width, oldWidth)) {
87
+      this.size = {
88
+        oldHeight: height,
89
+        oldWidth: width
90
+      };
91
+      this.setState(
92
+        {
93
+          height,
94
+          width
95
+        },
96
+        () => handleSizeUpdated(height, width, this.props.onSizeUpdated)
97
+      );
98
+    }
99
+    const { onMessage } = this.props;
100
+    onMessage && onMessage(event);
101
+  };
102
+
103
+  stopLoading() {
104
+    this.webView.current.stopLoading();
105
+  }
106
+
107
+  render() {
108
+    const { height, width } = this.state;
109
+    const { style, originWhitelist } = this.props;
110
+    const { source, script } = this.getUpdatedState(this.props, getBaseScript);
111
+    return (
112
+      <WebView
113
+        {...this.props}
114
+        originWhitelist={originWhitelist || ['*']}
115
+        ref={this.webView}
116
+        onMessage={this.onMessage}
117
+        style={[
118
+          styles.webView,
119
+          {
120
+            width,
121
+            height
122
+          },
123
+          style
124
+        ]}
125
+        injectedJavaScript={script}
126
+        source={source}
127
+      />
128
+    );
129
+  }
130
+}
131
+
132
+const styles = StyleSheet.create({
133
+  webView: {
134
+    backgroundColor: 'transparent'
135
+  }
136
+});

+ 0
- 53
autoHeightWebView/propTypes.js Ver arquivo

@@ -1,53 +0,0 @@
1
-import PropTypes from 'prop-types';
2
-
3
-import { ViewPropTypes, WebView } from 'react-native';
4
-
5
-export const commonPropTypes = {
6
-  style: ViewPropTypes.style,
7
-  customScript: PropTypes.string,
8
-  customStyle: PropTypes.string,
9
-  enableAnimation: PropTypes.bool,
10
-  // only works on enable animation
11
-  animationDuration: PropTypes.number,
12
-  // offset of rn webView margin
13
-  heightOffset: PropTypes.number,
14
-  // either height or width updated will trigger this
15
-  // no support auto width and height will triggered by source changing only on android 5.1 or below version
16
-  onSizeUpdated: PropTypes.func,
17
-  // 'file:///android_asset/web/' by default on android, 
18
-  // web/' by default on iOS
19
-  baseUrl: PropTypes.string,
20
-  // add baseUrl/files... to android/app/src/assets/ on android
21
-  // add baseUrl/files... to project root on iOS
22
-  files: PropTypes.arrayOf(
23
-    PropTypes.shape({
24
-      href: PropTypes.string,
25
-      type: PropTypes.string,
26
-      rel: PropTypes.string
27
-    })
28
-  ),
29
-  // if set to true may cause some layout issues (smaller font size) on iOS
30
-  // if set to false may cause some layout issues (width of container will be than width of screen) on android
31
-  scalesPageToFit: PropTypes.bool,
32
-  // other rn webview props
33
-  source: WebView.propTypes.source,
34
-  originWhitelist: PropTypes.arrayOf(PropTypes.string),
35
-  mediaPlaybackRequiresUserAction: PropTypes.bool,
36
-  renderError: PropTypes.func,
37
-  onError: PropTypes.func,
38
-  onMessage: PropTypes.func,
39
-  onNavigationStateChange: PropTypes.func,
40
-  onLoad: PropTypes.func,
41
-  onLoadStart: PropTypes.func,
42
-  onLoadEnd: PropTypes.func
43
-};
44
-
45
-export const androidPropTypes = {
46
-  ...commonPropTypes,
47
-  domStorageEnabled: PropTypes.bool,
48
-  thirdPartyCookiesEnabled: PropTypes.bool,
49
-  userAgent: PropTypes.string,
50
-  geolocationEnabled: PropTypes.string,
51
-  allowUniversalAccessFromFileURLs: PropTypes.bool,
52
-  mixedContentMode: PropTypes.oneOf(['never', 'always', 'compatibility'])
53
-};

autoHeightWebView/common.js → autoHeightWebView/utils.js Ver arquivo

@@ -1,6 +1,6 @@
1 1
 'use strict';
2 2
 
3
-import { Dimensions } from 'react-native';
3
+import { Dimensions, Platform } from 'react-native';
4 4
 
5 5
 import Immutable from 'immutable';
6 6
 
@@ -40,10 +40,9 @@ function appendStylesToHead(styles, script) {
40 40
 }
41 41
 
42 42
 function getReloadRelatedData(props) {
43
-  const { hasIframe, files, customStyle, customScript, style, source } = props;
43
+  const { files, customStyle, customScript, style, source } = props;
44 44
   return {
45 45
     source,
46
-    hasIframe,
47 46
     files,
48 47
     customStyle,
49 48
     customScript,
@@ -64,9 +63,9 @@ function getInjectedSource(html, script) {
64 63
     `;
65 64
 }
66 65
 
67
-export function getScript(props, getBaseScript) {
66
+function getScript(props, getScript) {
68 67
   const { files, customStyle, customScript, style } = getReloadRelatedData(props);
69
-  let script = getBaseScript(style);
68
+  let script = getScript(style);
70 69
   script = files && files.length > 0 ? appendFilesToHead(files, script) : script;
71 70
   script = appendStylesToHead(customStyle, script);
72 71
   customScript && (script = customScript + script);
@@ -81,9 +80,9 @@ export function isEqual(newProps, oldProps) {
81 80
   return isChanged(getReloadRelatedData(newProps), getReloadRelatedData(oldProps));
82 81
 }
83 82
 
84
-export function setState(props, getBaseScript, getIframeBaseScript) {
83
+export function setState(props, getBaseScript) {
85 84
   const { source, baseUrl } = props;
86
-  const script = getScript(props, getBaseScript, getIframeBaseScript);
85
+  const script = getScript(props, getBaseScript);
87 86
   let state = {};
88 87
   if (source.html) {
89 88
     let currentSource = { html: getInjectedSource(source.html, script) };
@@ -109,8 +108,8 @@ export function handleSizeUpdated(height, width, onSizeUpdated) {
109 108
 }
110 109
 
111 110
 export function isSizeChanged(height, oldHeight, width, oldWidth) {
112
-  if (height == null || width == null) {
113
-    return false;
111
+  if (!height || !width) {
112
+    return;
114 113
   }
115 114
   return height !== oldHeight || width !== oldWidth;
116 115
 }
@@ -128,14 +127,15 @@ export function updateSizeWithMessage(element) {
128 127
   return `
129 128
   var updateSizeInterval = null;
130 129
   var height = 0;
131
-  function updateSize() {
130
+  function updateSize(event) {
132 131
     if (!window.hasOwnProperty('ReactNativeWebView') || !window.ReactNativeWebView.hasOwnProperty('postMessage')) {
133 132
       !updateSizeInterval && (updateSizeInterval = setInterval(updateSize, 200));
134 133
       return;
135 134
     }
136
-    height = ${element}.offsetHeight || window.innerHeight,
135
+    clearInterval(updateSizeInterval)
136
+    height = ${element}.offsetHeight || window.innerHeight;
137 137
     width = ${element}.offsetWidth || window.innerWidth;
138
-    window.ReactNativeWebView.postMessage(JSON.stringify({ width: width, height: height }));
138
+    window.ReactNativeWebView.postMessage(JSON.stringify({ width: width, height: height, event: event }));
139 139
   }
140 140
   `;
141 141
 }
@@ -153,3 +153,31 @@ export function getStateFromProps(props, state) {
153 153
   }
154 154
   return null;
155 155
 }
156
+
157
+// add viewport setting to meta for WKWebView
158
+const makeScalePageToFit = `
159
+var meta = document.createElement('meta'); 
160
+meta.setAttribute('name', 'viewport'); 
161
+meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);
162
+`;
163
+
164
+export function getBaseScript(style) {
165
+  return `
166
+  ;
167
+  if (!document.getElementById("rnahw-wrapper")) {
168
+    var wrapper = document.createElement('div');
169
+    wrapper.id = 'rnahw-wrapper';
170
+    while (document.body.firstChild instanceof Node) {
171
+      wrapper.appendChild(document.body.firstChild);
172
+    }
173
+    document.body.appendChild(wrapper);
174
+  }
175
+  var width = ${getWidth(style)};
176
+  ${updateSizeWithMessage('wrapper')}
177
+  window.addEventListener('load', updateSize);
178
+  window.addEventListener('resize', updateSize);
179
+  ${domMutationObserveScript}
180
+  ${Platform.OS === 'ios' ? makeScalePageToFit : ''}
181
+  updateSize();
182
+  `;
183
+}

+ 2
- 2
index.js Ver arquivo

@@ -1,3 +1,3 @@
1
-var ReactNative = require('react-native')
2
-module.exports = ReactNative.NativeModules.AutoHeightWebView
1
+import AutoHeightWebView from './autoHeightWebView/AutoHeightWebView';
3 2
 
3
+export default AutoHeightWebView;

+ 25
- 24
package-lock.json Ver arquivo

@@ -221,7 +221,7 @@
221 221
     },
222 222
     "asap": {
223 223
       "version": "2.0.6",
224
-      "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
224
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/asap/-/asap-2.0.6.tgz",
225 225
       "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
226 226
     },
227 227
     "ast-types-flow": {
@@ -428,7 +428,7 @@
428 428
     },
429 429
     "core-js": {
430 430
       "version": "1.2.7",
431
-      "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz",
431
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/core-js/-/core-js-1.2.7.tgz",
432 432
       "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY="
433 433
     },
434 434
     "core-util-is": {
@@ -510,7 +510,7 @@
510 510
     },
511 511
     "encoding": {
512 512
       "version": "0.1.12",
513
-      "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
513
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/encoding/-/encoding-0.1.12.tgz",
514 514
       "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
515 515
       "requires": {
516 516
         "iconv-lite": "~0.4.13"
@@ -750,7 +750,7 @@
750 750
     },
751 751
     "fbjs": {
752 752
       "version": "0.8.17",
753
-      "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz",
753
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/fbjs/-/fbjs-0.8.17.tgz",
754 754
       "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=",
755 755
       "requires": {
756 756
         "core-js": "^1.0.0",
@@ -1024,7 +1024,7 @@
1024 1024
     },
1025 1025
     "is-stream": {
1026 1026
       "version": "1.1.0",
1027
-      "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
1027
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/is-stream/-/is-stream-1.1.0.tgz",
1028 1028
       "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
1029 1029
     },
1030 1030
     "is-symbol": {
@@ -1050,7 +1050,7 @@
1050 1050
     },
1051 1051
     "isomorphic-fetch": {
1052 1052
       "version": "2.2.1",
1053
-      "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
1053
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
1054 1054
       "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=",
1055 1055
       "requires": {
1056 1056
         "node-fetch": "^1.0.1",
@@ -1183,8 +1183,8 @@
1183 1183
     },
1184 1184
     "node-fetch": {
1185 1185
       "version": "1.7.3",
1186
-      "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
1187
-      "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
1186
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/node-fetch/-/node-fetch-1.7.3.tgz",
1187
+      "integrity": "sha1-mA9vcthSEaU0fGsrwYxbhMPrR+8=",
1188 1188
       "requires": {
1189 1189
         "encoding": "^0.1.11",
1190 1190
         "is-stream": "^1.0.1"
@@ -1316,17 +1316,18 @@
1316 1316
     },
1317 1317
     "promise": {
1318 1318
       "version": "7.3.1",
1319
-      "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
1320
-      "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
1319
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/promise/-/promise-7.3.1.tgz",
1320
+      "integrity": "sha1-BktyYCsY+Q8pGSuLG8QY/9Hr078=",
1321 1321
       "requires": {
1322 1322
         "asap": "~2.0.3"
1323 1323
       }
1324 1324
     },
1325 1325
     "prop-types": {
1326
-      "version": "15.7.1",
1327
-      "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.7.1.tgz",
1328
-      "integrity": "sha512-f8Lku2z9kERjOCcnDOPm68EBJAO2K00Q5mSgPAUE/gJuBgsYLbVy6owSrtcHj90zt8PvW+z0qaIIgsIhHOa1Qw==",
1326
+      "version": "15.7.2",
1327
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/prop-types/-/prop-types-15.7.2.tgz",
1328
+      "integrity": "sha1-UsQedbjIfnK52TYOAga5ncv/psU=",
1329 1329
       "requires": {
1330
+        "loose-envify": "^1.4.0",
1330 1331
         "object-assign": "^4.1.1",
1331 1332
         "react-is": "^16.8.1"
1332 1333
       }
@@ -1338,14 +1339,14 @@
1338 1339
       "dev": true
1339 1340
     },
1340 1341
     "react-is": {
1341
-      "version": "16.8.1",
1342
-      "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.1.tgz",
1343
-      "integrity": "sha512-ioMCzVDWvCvKD8eeT+iukyWrBGrA3DiFYkXfBsVYIRdaREZuBjENG+KjrikavCLasozqRWTwFUagU/O4vPpRMA=="
1342
+      "version": "16.8.2",
1343
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/react-is/-/react-is-16.8.2.tgz",
1344
+      "integrity": "sha1-CYkdMkytHLDB8tkfcKcaS+403w8="
1344 1345
     },
1345 1346
     "react-native-webview": {
1346
-      "version": "5.0.7",
1347
-      "resolved": "https://registry.npmjs.org/react-native-webview/-/react-native-webview-5.0.7.tgz",
1348
-      "integrity": "sha512-jzYrpxPdHGXc9KW0J6Ec4zOXeDFy8BZQS+nUjCqs/cPSPkQO2H/4e6IXz9Y1DTC4l08H2RQLeWPo9nml69MXmA==",
1347
+      "version": "5.2.1",
1348
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/react-native-webview/-/react-native-webview-5.2.1.tgz",
1349
+      "integrity": "sha1-ij8u4USIrT0FjxXHBU+1L6Rxleo=",
1349 1350
       "requires": {
1350 1351
         "escape-string-regexp": "^1.0.5",
1351 1352
         "fbjs": "^0.8.17"
@@ -1459,7 +1460,7 @@
1459 1460
     },
1460 1461
     "setimmediate": {
1461 1462
       "version": "1.0.5",
1462
-      "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
1463
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/setimmediate/-/setimmediate-1.0.5.tgz",
1463 1464
       "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU="
1464 1465
     },
1465 1466
     "shebang-command": {
@@ -1625,8 +1626,8 @@
1625 1626
     },
1626 1627
     "ua-parser-js": {
1627 1628
       "version": "0.7.19",
1628
-      "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.19.tgz",
1629
-      "integrity": "sha512-T3PVJ6uz8i0HzPxOF9SWzWAlfN/DavlpQqepn22xgve/5QecC+XMCAtmUNnY7C9StehaV6exjUCI801lOI7QlQ=="
1629
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/ua-parser-js/-/ua-parser-js-0.7.19.tgz",
1630
+      "integrity": "sha1-lBUb5MCn+x0AGvcCL9rKRkJlnks="
1630 1631
     },
1631 1632
     "util-deprecate": {
1632 1633
       "version": "1.0.2",
@@ -1636,8 +1637,8 @@
1636 1637
     },
1637 1638
     "whatwg-fetch": {
1638 1639
       "version": "3.0.0",
1639
-      "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz",
1640
-      "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q=="
1640
+      "resolved": "https://nexus.bybutter.com/repository/npm-group/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz",
1641
+      "integrity": "sha1-/IBORYzEYACbGiuWa8iBfSV4rvs="
1641 1642
     },
1642 1643
     "which": {
1643 1644
       "version": "1.3.0",

+ 2
- 3
package.json Ver arquivo

@@ -5,7 +5,6 @@
5 5
   "main": "autoHeightWebView",
6 6
   "files": [
7 7
     "index.js",
8
-    "android",
9 8
     "autoHeightWebView"
10 9
   ],
11 10
   "scripts": {
@@ -33,8 +32,8 @@
33 32
   },
34 33
   "dependencies": {
35 34
     "immutable": "^3.8.2",
36
-    "prop-types": "^15.7.1",
37
-    "react-native-webview": "^5.0.7"
35
+    "prop-types": "^15.7.2",
36
+    "react-native-webview": "^5.2.1"
38 37
   },
39 38
   "devDependencies": {
40 39
     "babel-eslint": "^8.2.6",