1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-17 22:36:09 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Compare commits

...

15 Commits

Author SHA1 Message Date
sunnylqm
a35c98ed4d v5.5.3 2019-12-18 18:05:47 +08:00
sunnylqm
dcea576fff Ignore hermes output to avoid buffer issue 2019-12-18 18:04:08 +08:00
Sunny Luo
201f11e770 Update guide.md 2019-12-14 12:26:04 +08:00
Sunny Luo
3a86218a48 Update guide.md 2019-12-14 12:24:39 +08:00
sunnylqm
5a5e27037c Update yauzl 2019-12-13 11:01:04 +08:00
sunnylqm
9b4016ba0a Update changelog 2019-12-06 15:27:26 +08:00
sunnylqm
5202cbec96 v5.5.2 2019-12-06 15:25:46 +08:00
sunnylqm
d7c7e27eaa 修复use_frameworks时无法获取编译时间戳的问题 2019-12-06 15:24:49 +08:00
Sunny Luo
e9e60bc5c6 Merge pull request #299 from nfq6612/progress
android 下载进度发送事件发出和发送事件频率优化
2019-12-04 11:12:22 +08:00
nonghuaqiang
a93875884c android 下载进度发送事件发出和发送事件频率优化 2019-12-03 12:34:02 +08:00
sunnylqm
f20263b827 v5.5.1 2019-11-25 16:09:34 +08:00
sunnylqm
8a74678b9c Add missing files 2019-11-25 16:09:05 +08:00
Sunny Luo
17b7920100 Merge pull request #296 from reactnativecn/dependabot/npm_and_yarn/brace-expansion-1.1.11
Bump brace-expansion from 1.1.6 to 1.1.11
2019-11-24 22:30:18 +08:00
sunnylqm
4d44eb858f Remove unused fs-promise 2019-11-24 22:30:04 +08:00
dependabot[bot]
74ef45056e Bump brace-expansion from 1.1.6 to 1.1.11
Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 1.1.6 to 1.1.11.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v1.1.6...1.1.11)

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-24 13:58:51 +00:00
12 changed files with 77 additions and 40 deletions

View File

@@ -1,5 +1,9 @@
### 最近更新 ### 最近更新
## 5.5.2 (2019-12-06)
1. 修复使用use_frameworks时无法读取时间戳的问题
## 5.5.0 (2019-11-24) ## 5.5.0 (2019-11-24)
1. 打包时加入时间戳 1. 打包时加入时间戳

View File

@@ -182,15 +182,15 @@ PODS:
- React-cxxreact (= 0.61.4) - React-cxxreact (= 0.61.4)
- React-jsi (= 0.61.4) - React-jsi (= 0.61.4)
- React-jsinspector (0.61.4) - React-jsinspector (0.61.4)
- react-native-update (5.3.2): - react-native-update (5.5.0):
- React - React
- react-native-update/BSDiff (= 5.3.2) - react-native-update/BSDiff (= 5.5.0)
- react-native-update/RCTPushy (= 5.3.2) - react-native-update/RCTPushy (= 5.5.0)
- SSZipArchive - SSZipArchive
- react-native-update/BSDiff (5.3.2): - react-native-update/BSDiff (5.5.0):
- React - React
- SSZipArchive - SSZipArchive
- react-native-update/RCTPushy (5.3.2): - react-native-update/RCTPushy (5.5.0):
- React - React
- SSZipArchive - SSZipArchive
- React-RCTActionSheet (0.61.4): - React-RCTActionSheet (0.61.4):
@@ -337,7 +337,7 @@ SPEC CHECKSUMS:
React-jsi: ca921f4041505f9d5197139b2d09eeb020bb12e8 React-jsi: ca921f4041505f9d5197139b2d09eeb020bb12e8
React-jsiexecutor: 8dfb73b987afa9324e4009bdce62a18ce23d983c React-jsiexecutor: 8dfb73b987afa9324e4009bdce62a18ce23d983c
React-jsinspector: d15478d0a8ada19864aa4d1cc1c697b41b3fa92f React-jsinspector: d15478d0a8ada19864aa4d1cc1c697b41b3fa92f
react-native-update: 7d4980517ec8d84ffa7909bad33d7a917a8d7f2f react-native-update: 0696134a23c2ad1be899c12b33f9d3521284d458
React-RCTActionSheet: 7369b7c85f99b6299491333affd9f01f5a130c22 React-RCTActionSheet: 7369b7c85f99b6299491333affd9f01f5a130c22
React-RCTAnimation: d07be15b2bd1d06d89417eb0343f98ffd2b099a7 React-RCTAnimation: d07be15b2bd1d06d89417eb0343f98ffd2b099a7
React-RCTBlob: 8e0b23d95c9baa98f6b0e127e07666aaafd96c34 React-RCTBlob: 8e0b23d95c9baa98f6b0e127e07666aaafd96c34

View File

@@ -3,6 +3,8 @@ package cn.reactnative.modules.update;
import android.content.Context; import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
@@ -31,11 +33,11 @@ import java.util.HashMap;
import okio.BufferedSink; import okio.BufferedSink;
import okio.BufferedSource; import okio.BufferedSource;
import okio.Okio; import okio.Okio;
import static cn.reactnative.modules.update.UpdateModule.sendEvent;
/** /**
* Created by tdzl2003 on 3/31/16. * Created by tdzl2003 on 3/31/16.
*/ */
class DownloadTask extends AsyncTask<DownloadTaskParams, Void, Void> { class DownloadTask extends AsyncTask<DownloadTaskParams, long[], Void> {
final int DOWNLOAD_CHUNK_SIZE = 4096; final int DOWNLOAD_CHUNK_SIZE = 4096;
Context context; Context context;
@@ -91,11 +93,17 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, Void, Void> {
long bytesRead = 0; long bytesRead = 0;
long totalRead = 0; long totalRead = 0;
double lastProgressValue=0;
while ((bytesRead = source.read(sink.buffer(), DOWNLOAD_CHUNK_SIZE)) != -1) { while ((bytesRead = source.read(sink.buffer(), DOWNLOAD_CHUNK_SIZE)) != -1) {
totalRead += bytesRead; totalRead += bytesRead;
if (UpdateContext.DEBUG) { if (UpdateContext.DEBUG) {
Log.d("RNUpdate", "Progress " + totalRead + "/" + contentLength); Log.d("RNUpdate", "Progress " + totalRead + "/" + contentLength);
} }
double progress = Math.round(((double) totalRead * 100) / contentLength);
if ((progress != lastProgressValue) || (totalRead == contentLength)) {
lastProgressValue = progress;
publishProgress(new long[]{(long)progress,totalRead, contentLength});
}
} }
if (totalRead != contentLength) { if (totalRead != contentLength) {
throw new Error("Unexpected eof while reading ppk"); throw new Error("Unexpected eof while reading ppk");
@@ -108,6 +116,17 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, Void, Void> {
} }
} }
@Override
protected void onProgressUpdate(long[]... values) {
super.onProgressUpdate(values);
WritableMap params = Arguments.createMap();
params.putDouble("progress", (values[0][0]));
params.putDouble("totalRead", (values[0][1]));
params.putDouble("contentLength", (values[0][2]));
sendEvent("progress", params);
}
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
private static native byte[] bsdiffPatch(byte[] origin, byte[] patch); private static native byte[] bsdiffPatch(byte[] origin, byte[] patch);

View File

@@ -9,11 +9,14 @@ import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.JSBundleLoader; import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@@ -25,10 +28,11 @@ import java.util.Map;
*/ */
public class UpdateModule extends ReactContextBaseJavaModule{ public class UpdateModule extends ReactContextBaseJavaModule{
UpdateContext updateContext; UpdateContext updateContext;
public static ReactApplicationContext mContext;
public UpdateModule(ReactApplicationContext reactContext, UpdateContext updateContext) { public UpdateModule(ReactApplicationContext reactContext, UpdateContext updateContext) {
super(reactContext); super(reactContext);
this.updateContext = updateContext; this.updateContext = updateContext;
mContext=reactContext;
} }
public UpdateModule(ReactApplicationContext reactContext) { public UpdateModule(ReactApplicationContext reactContext) {
@@ -170,4 +174,10 @@ public class UpdateModule extends ReactContextBaseJavaModule{
} }
}); });
} }
/* 发送事件*/
public static void sendEvent(String eventName, WritableMap params) {
((ReactContext) mContext).getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName,
params);
}
} }

View File

@@ -77,7 +77,17 @@ pod 'react-native-update', path: '../node_modules/react-native-update'
2. 进入`node_modules``react-native-update``ios 并选中 `RCTPushy.xcodeproj` 2. 进入`node_modules``react-native-update``ios 并选中 `RCTPushy.xcodeproj`
3. 在XCode中的project navigator里,选中你的工程,在 `Build Phases``Link Binary With Libraries` 中添加 `libRCTPushy.a` 3. 在XCode中的project navigator里,选中你的工程,在 `Build Phases``Link Binary With Libraries` 中添加 `libRCTPushy.a`
4. 继续在`Build Settings`里搜索`Header Search Path`,添加$(SRCROOT)/../node_modules/react-native-update/ios 4. 继续在`Build Settings`里搜索`Header Search Path`,添加$(SRCROOT)/../node_modules/react-native-update/ios
5. 重新编译 5. `Build Phases`添加一个`New Run Script Phase`运行脚本,内容如下
```
#!/bin/bash
set -x
DEST="../node_modules/react-native-update/ios/"
date +%s > "$DEST/pushy_build_time.txt"
```
编译的时候就会在`../node_modules/react-native-update/ios/`文件夹下面生成一个`pushy_build_time.txt`文件。
然后在`Copy Bundle Resources`里把生成的`pushy_build_time.txt`文件添加进去。
6. 重新编译
</details> </details>

1
ios/pushy_build_time.txt Normal file
View File

@@ -0,0 +1 @@
1574665292

View File

@@ -128,6 +128,7 @@ async function compileHermesByteCode(bundleName, outputFolder) {
: 'node_modules/hermesvm'; : 'node_modules/hermesvm';
execSync( execSync(
`${hermesPath}/${getHermesOSBin()}/hermes -emit-binary -out ${outputFolder}/${bundleName} ${outputFolder}/${bundleName} -O`, `${hermesPath}/${getHermesOSBin()}/hermes -emit-binary -out ${outputFolder}/${bundleName} ${outputFolder}/${bundleName} -O`,
{ stdio: 'ignore' },
); );
} }
} }

View File

@@ -71,11 +71,14 @@ export async function getApkInfo(fn) {
export async function getIpaInfo(fn) { export async function getIpaInfo(fn) {
const appInfoParser = new AppInfoParser(fn); const appInfoParser = new AppInfoParser(fn);
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse(); const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
try { let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/);
const buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/); if (!buildTimeTxtBuffer) {
const buildTime = buildTimeTxtBuffer.toString().replace('\n', ''); // Not in root bundle when use `use_frameworks`
return { versionName, buildTime }; buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/);
} catch (e) { }
if (!buildTimeTxtBuffer) {
throw new Error('Can not get build time for this app.'); throw new Error('Can not get build time for this app.');
} }
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
return { versionName, buildTime };
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "5.5.0", "version": "5.5.3",
"description": "react-native hot update", "description": "react-native hot update",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
@@ -37,7 +37,7 @@
"read": "^1.0.7", "read": "^1.0.7",
"request": "^2.69.0", "request": "^2.69.0",
"tty-table": "^2.7.0", "tty-table": "^2.7.0",
"yauzl": "2.4.1", "yauzl": "^2.10.0",
"yazl": "2.3.0" "yazl": "2.3.0"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -25,9 +25,6 @@
"bugs": { "bugs": {
"url": "https://github.com/reactnativecn/react-native-pushy/issues" "url": "https://github.com/reactnativecn/react-native-pushy/issues"
}, },
"dependencies": {
"fs-promise": "^0.4.1"
},
"homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli", "homepage": "https://github.com/reactnativecn/react-native-pushy/tree/master/react-native-pushy-cli",
"devDependencies": { "devDependencies": {
"babel-cli": "^6.5.1", "babel-cli": "^6.5.1",

View File

@@ -11,6 +11,7 @@ Pod::Spec.new do |s|
s.authors = package['author'] s.authors = package['author']
s.homepage = package['homepage'] s.homepage = package['homepage']
s.cocoapods_version = '>= 1.6.0'
s.platform = :ios, "8.0" s.platform = :ios, "8.0"
s.source = { :git => 'https://github.com/reactnativecn/react-native-pushy.git', :tag => '#{s.version}' } s.source = { :git => 'https://github.com/reactnativecn/react-native-pushy.git', :tag => '#{s.version}' }
s.libraries = 'bz2', 'z' s.libraries = 'bz2', 'z'

View File

@@ -526,9 +526,10 @@ babylon@^6.11.0, babylon@^6.15.0:
version "6.16.1" version "6.16.1"
resolved "http://registry.npm.taobao.org/babylon/download/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" resolved "http://registry.npm.taobao.org/babylon/download/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3"
balanced-match@^0.4.1: balanced-match@^1.0.0:
version "0.4.2" version "1.0.0"
resolved "http://registry.npm.taobao.org/balanced-match/download/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
base64-js@^1.0.2, base64-js@^1.2.3: base64-js@^1.0.2, base64-js@^1.2.3:
version "1.3.1" version "1.3.1"
@@ -574,10 +575,11 @@ bplist-parser@^0.2.0:
big-integer "^1.6.44" big-integer "^1.6.44"
brace-expansion@^1.0.0: brace-expansion@^1.0.0:
version "1.1.6" version "1.1.11"
resolved "http://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies: dependencies:
balanced-match "^0.4.1" balanced-match "^1.0.0"
concat-map "0.0.1" concat-map "0.0.1"
braces@^1.8.2: braces@^1.8.2:
@@ -761,7 +763,8 @@ commoner@~0.10.3:
concat-map@0.0.1: concat-map@0.0.1:
version "0.0.1" version "0.0.1"
resolved "http://registry.npm.taobao.org/concat-map/download/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
console-control-strings@^1.0.0, console-control-strings@~1.1.0: console-control-strings@^1.0.0, console-control-strings@~1.1.0:
version "1.1.0" version "1.1.0"
@@ -993,12 +996,6 @@ extsprintf@1.0.2:
version "1.0.2" version "1.0.2"
resolved "http://registry.npm.taobao.org/extsprintf/download/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" resolved "http://registry.npm.taobao.org/extsprintf/download/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550"
fd-slicer@~1.0.1:
version "1.0.1"
resolved "http://registry.npm.taobao.org/fd-slicer/download/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65"
dependencies:
pend "~1.2.0"
fd-slicer@~1.1.0: fd-slicer@~1.1.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e"
@@ -2581,13 +2578,7 @@ yargs@~3.27.0:
window-size "^0.1.2" window-size "^0.1.2"
y18n "^3.2.0" y18n "^3.2.0"
yauzl@2.4.1: yauzl@^2.10.0, yauzl@^2.8.0:
version "2.4.1"
resolved "http://registry.npm.taobao.org/yauzl/download/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005"
dependencies:
fd-slicer "~1.0.1"
yauzl@^2.8.0:
version "2.10.0" version "2.10.0"
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
integrity sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk= integrity sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=