Browse Source

change android package name to com.iou90.autoheightwebview; update index.ios.js to improve capacity; update rn version of demo to 0.54.3; bump version to 0.6.0

iou90 6 years ago
parent
commit
1ee501e889

+ 2
- 2
android/src/androidTest/java/com/dscj/autoheightwebview/ExampleInstrumentedTest.java View File

@@ -1,4 +1,4 @@
1
-package com.dscj.autoheightwebview;
1
+package com.iou90.autoheightwebview;
2 2
 
3 3
 import android.content.Context;
4 4
 import android.support.test.InstrumentationRegistry;
@@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
21 21
         // Context of the app under test.
22 22
         Context appContext = InstrumentationRegistry.getTargetContext();
23 23
 
24
-        assertEquals("com.dscj.autoheightwebview.test", appContext.getPackageName());
24
+        assertEquals("com.iou90.autoheightwebview.test", appContext.getPackageName());
25 25
     }
26 26
 }

+ 1
- 1
android/src/main/AndroidManifest.xml View File

@@ -1,5 +1,5 @@
1 1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
-          package="com.dscj.autoheightwebview">
2
+          package="com.iou90.autoheightwebview">
3 3
 
4 4
     <application android:allowBackup="false"
5 5
                  android:label="@string/app_name"

+ 1
- 1
android/src/main/java/com/dscj/autoheightwebview/AutoHeightWebViewManager.java View File

@@ -1,4 +1,4 @@
1
-package com.dscj.autoheightwebview;
1
+package com.iou90.autoheightwebview;
2 2
 
3 3
 import android.webkit.WebView;
4 4
 

+ 1
- 1
android/src/main/java/com/dscj/autoheightwebview/AutoHeightWebViewPackage.java View File

@@ -1,4 +1,4 @@
1
-package com.dscj.autoheightwebview;
1
+package com.iou90.autoheightwebview;
2 2
 
3 3
 import com.facebook.react.ReactPackage;
4 4
 import com.facebook.react.bridge.JavaScriptModule;

+ 1
- 1
android/src/main/java/com/dscj/autoheightwebview/JavascriptBridge.java View File

@@ -1,4 +1,4 @@
1
-package com.dscj.autoheightwebview;
1
+package com.iou90.autoheightwebview;
2 2
 
3 3
 import android.webkit.JavascriptInterface;
4 4
 import android.webkit.WebView;

+ 1
- 1
android/src/test/java/com/dscj/autoheightwebview/ExampleUnitTest.java View File

@@ -1,4 +1,4 @@
1
-package com.dscj.autoheightwebview;
1
+package com.iou90.autoheightwebview;
2 2
 
3 3
 import org.junit.Test;
4 4
 

+ 1
- 1
autoHeightWebView/common.js View File

@@ -52,6 +52,6 @@ observer.observe(document, {
52 52
     subtree: true,
53 53
     attributes: true
54 54
 });
55
-`
55
+`;
56 56
 
57 57
 export { getScript, onHeightUpdated, domMutationObserveScript };

+ 1
- 1
autoHeightWebView/index.android.js View File

@@ -19,7 +19,7 @@ import PropTypes from 'prop-types';
19 19
 
20 20
 import Immutable from 'immutable';
21 21
 
22
-import { getScript, onHeightUpdated, domMutationObserveScript } from './common.js';
22
+import { getScript, onHeightUpdated, domMutationObserveScript, getHeight } from './common.js';
23 23
 
24 24
 const RCTAutoHeightWebView = requireNativeComponent('RCTAutoHeightWebView', AutoHeightWebView, {
25 25
   nativeOnly: {

+ 16
- 5
autoHeightWebView/index.ios.js View File

@@ -146,21 +146,31 @@ const commonScript = `
146 146
     window.addEventListener('resize', updateHeight);
147 147
     `;
148 148
 
149
+const getHeight = `
150
+    function getHeight(height) {
151
+      if(height < 1) {
152
+        return document.body.offsetHeight;
153
+      }
154
+      return height;
155
+    }
156
+    `;
157
+
149 158
 const baseScript = `
150 159
     ;
160
+    ${getHeight}
151 161
     (function () {
152 162
         var i = 0;
153 163
         var height = 0;
154 164
         var wrapper = document.createElement('div');
155 165
         wrapper.id = 'height-wrapper';
156
-        while (document.body.firstChild) {
166
+        while (document.body.firstChild instanceof Node) {
157 167
             wrapper.appendChild(document.body.firstChild);
158 168
         }
159 169
         document.body.appendChild(wrapper);
160 170
         function updateHeight() {
161 171
             if(document.body.offsetHeight !== height) {
162
-                height = wrapper.clientHeight;
163
-                document.title = wrapper.clientHeight;
172
+                height = getHeight(wrapper.clientHeight);
173
+                document.title = height;
164 174
                 window.location.hash = ++i;
165 175
             }
166 176
         }
@@ -171,13 +181,14 @@ const baseScript = `
171 181
 
172 182
 const iframeBaseScript = `
173 183
     ;
184
+    ${getHeight}
174 185
     (function () {
175 186
         var i = 0;
176 187
         var height = 0;
177 188
         function updateHeight() {
178 189
             if(document.body.offsetHeight !== height) {
179
-                height = document.body.firstChild.clientHeight;
180
-                document.title = document.body.firstChild.clientHeight;
190
+                height = getHeight(document.body.firstChild.clientHeight);
191
+                document.title = height;
181 192
                 window.location.hash = ++i;
182 193
             }
183 194
         }

+ 1
- 1
demo/.flowconfig View File

@@ -51,4 +51,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
51 51
 suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
52 52
 
53 53
 [version]
54
-^0.63.0
54
+^0.65.0

+ 2
- 8
demo/android/app/src/main/AndroidManifest.xml View File

@@ -1,20 +1,14 @@
1 1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
-    package="com.demo"
3
-    android:versionCode="1"
4
-    android:versionName="1.0">
2
+    package="com.demo">
5 3
 
6 4
     <uses-permission android:name="android.permission.INTERNET" />
7 5
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
8 6
 
9
-    <uses-sdk
10
-        android:minSdkVersion="16"
11
-        android:targetSdkVersion="22" />
12
-
13 7
     <application
14 8
       android:name=".MainApplication"
15
-      android:allowBackup="false"
16 9
       android:label="@string/app_name"
17 10
       android:icon="@mipmap/ic_launcher"
11
+      android:allowBackup="false"
18 12
       android:theme="@style/AppTheme">
19 13
       <activity
20 14
         android:name=".MainActivity"

+ 1
- 1
demo/android/app/src/main/java/com/demo/MainApplication.java View File

@@ -3,7 +3,7 @@ package com.demo;
3 3
 import android.app.Application;
4 4
 
5 5
 import com.facebook.react.ReactApplication;
6
-import com.dscj.autoheightwebview.AutoHeightWebViewPackage;
6
+import com.iou90.autoheightwebview.AutoHeightWebViewPackage;
7 7
 import com.facebook.react.ReactNativeHost;
8 8
 import com.facebook.react.ReactPackage;
9 9
 import com.facebook.react.shell.MainReactPackage;

+ 2
- 2
demo/ios/demo.xcodeproj/project.pbxproj View File

@@ -499,7 +499,7 @@
499 499
 			isa = PBXGroup;
500 500
 			children = (
501 501
 				146834041AC3E56700842450 /* libReact.a */,
502
-				3DAD3EA31DF850E9000B6D8A /* libReact-tvOS.a */,
502
+				3DAD3EA31DF850E9000B6D8A /* libReact.a */,
503 503
 				3DAD3EA51DF850E9000B6D8A /* libyoga.a */,
504 504
 				3DAD3EA71DF850E9000B6D8A /* libyoga.a */,
505 505
 				3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */,
@@ -962,7 +962,7 @@
962 962
 			remoteRef = 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */;
963 963
 			sourceTree = BUILT_PRODUCTS_DIR;
964 964
 		};
965
-		3DAD3EA31DF850E9000B6D8A /* libReact-tvOS.a */ = {
965
+		3DAD3EA31DF850E9000B6D8A /* libReact.a */ = {
966 966
 			isa = PBXReferenceProxy;
967 967
 			fileType = archive.ar;
968 968
 			path = libReact.a;

+ 15
- 14
demo/ios/demo/Info.plist View File

@@ -24,6 +24,21 @@
24 24
 	<string>1</string>
25 25
 	<key>LSRequiresIPhoneOS</key>
26 26
 	<true/>
27
+	<key>NSAppTransportSecurity</key>
28
+	<dict>
29
+		<key>NSAllowsArbitraryLoads</key>
30
+		<true/>
31
+		<key>NSExceptionDomains</key>
32
+		<dict>
33
+			<key>localhost</key>
34
+			<dict>
35
+				<key>NSExceptionAllowsInsecureHTTPLoads</key>
36
+				<true/>
37
+			</dict>
38
+		</dict>
39
+	</dict>
40
+	<key>NSLocationWhenInUseUsageDescription</key>
41
+	<string></string>
27 42
 	<key>UILaunchStoryboardName</key>
28 43
 	<string>LaunchScreen</string>
29 44
 	<key>UIRequiredDeviceCapabilities</key>
@@ -38,19 +53,5 @@
38 53
 	</array>
39 54
 	<key>UIViewControllerBasedStatusBarAppearance</key>
40 55
 	<false/>
41
-	<key>NSLocationWhenInUseUsageDescription</key>
42
-	<string></string>
43
-	<key>NSAppTransportSecurity</key>
44
-	<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
45
-	<dict>
46
-		<key>NSExceptionDomains</key>
47
-		<dict>
48
-			<key>localhost</key>
49
-			<dict>
50
-				<key>NSExceptionAllowsInsecureHTTPLoads</key>
51
-				<true/>
52
-			</dict>
53
-		</dict>
54
-	</dict>
55 56
 </dict>
56 57
 </plist>

+ 8965
- 8342
demo/package-lock.json
File diff suppressed because it is too large
View File


+ 2
- 2
demo/package.json View File

@@ -7,8 +7,8 @@
7 7
     "test": "jest"
8 8
   },
9 9
   "dependencies": {
10
-    "react": "16.2.0",
11
-    "react-native": "0.53.3",
10
+    "react": "^16.3.0-alpha.1",
11
+    "react-native": "0.54.3",
12 12
     "react-native-autoheight-webview": "../"
13 13
   },
14 14
   "devDependencies": {

+ 0
- 4504
demo/yarn.lock
File diff suppressed because it is too large
View File


+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "react-native-autoheight-webview",
3
-  "version": "0.5.1",
3
+  "version": "0.6.0",
4 4
   "description": "An auto height webview for React Native",
5 5
   "main": "autoHeightWebView",
6 6
   "files": [