mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-17 12:42:20 +08:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a35c98ed4d | ||
![]() |
dcea576fff | ||
![]() |
201f11e770 | ||
![]() |
3a86218a48 | ||
![]() |
5a5e27037c | ||
![]() |
9b4016ba0a | ||
![]() |
5202cbec96 | ||
![]() |
d7c7e27eaa | ||
![]() |
e9e60bc5c6 | ||
![]() |
a93875884c |
@@ -1,5 +1,9 @@
|
||||
### 最近更新
|
||||
|
||||
## 5.5.2 (2019-12-06)
|
||||
|
||||
1. 修复使用use_frameworks时无法读取时间戳的问题
|
||||
|
||||
## 5.5.0 (2019-11-24)
|
||||
|
||||
1. 打包时加入时间戳
|
||||
|
@@ -3,6 +3,8 @@ package cn.reactnative.modules.update;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
@@ -31,11 +33,11 @@ import java.util.HashMap;
|
||||
import okio.BufferedSink;
|
||||
import okio.BufferedSource;
|
||||
import okio.Okio;
|
||||
|
||||
import static cn.reactnative.modules.update.UpdateModule.sendEvent;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
Context context;
|
||||
@@ -91,11 +93,17 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, Void, Void> {
|
||||
|
||||
long bytesRead = 0;
|
||||
long totalRead = 0;
|
||||
double lastProgressValue=0;
|
||||
while ((bytesRead = source.read(sink.buffer(), DOWNLOAD_CHUNK_SIZE)) != -1) {
|
||||
totalRead += bytesRead;
|
||||
if (UpdateContext.DEBUG) {
|
||||
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) {
|
||||
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];
|
||||
|
||||
private static native byte[] bsdiffPatch(byte[] origin, byte[] patch);
|
||||
|
@@ -9,11 +9,14 @@ import com.facebook.react.ReactApplication;
|
||||
import com.facebook.react.ReactInstanceManager;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
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.Method;
|
||||
@@ -25,10 +28,11 @@ import java.util.Map;
|
||||
*/
|
||||
public class UpdateModule extends ReactContextBaseJavaModule{
|
||||
UpdateContext updateContext;
|
||||
|
||||
public static ReactApplicationContext mContext;
|
||||
public UpdateModule(ReactApplicationContext reactContext, UpdateContext updateContext) {
|
||||
super(reactContext);
|
||||
this.updateContext = updateContext;
|
||||
mContext=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);
|
||||
}
|
||||
}
|
||||
|
@@ -77,7 +77,17 @@ pod 'react-native-update', path: '../node_modules/react-native-update'
|
||||
2. 进入`node_modules` ➜ `react-native-update` ➜ `ios 并选中 `RCTPushy.xcodeproj`
|
||||
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
|
||||
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>
|
||||
|
||||
|
@@ -128,6 +128,7 @@ async function compileHermesByteCode(bundleName, outputFolder) {
|
||||
: 'node_modules/hermesvm';
|
||||
execSync(
|
||||
`${hermesPath}/${getHermesOSBin()}/hermes -emit-binary -out ${outputFolder}/${bundleName} ${outputFolder}/${bundleName} -O`,
|
||||
{ stdio: 'ignore' },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -71,11 +71,14 @@ export async function getApkInfo(fn) {
|
||||
export async function getIpaInfo(fn) {
|
||||
const appInfoParser = new AppInfoParser(fn);
|
||||
const { CFBundleShortVersionString: versionName } = await appInfoParser.parse();
|
||||
try {
|
||||
const buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/);
|
||||
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
|
||||
return { versionName, buildTime };
|
||||
} catch (e) {
|
||||
let buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/pushy_build_time.txt/);
|
||||
if (!buildTimeTxtBuffer) {
|
||||
// Not in root bundle when use `use_frameworks`
|
||||
buildTimeTxtBuffer = await appInfoParser.parser.getEntry(/payload\/.+?\.app\/frameworks\/react_native_update.framework\/pushy_build_time.txt/);
|
||||
}
|
||||
if (!buildTimeTxtBuffer) {
|
||||
throw new Error('Can not get build time for this app.');
|
||||
}
|
||||
const buildTime = buildTimeTxtBuffer.toString().replace('\n', '');
|
||||
return { versionName, buildTime };
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "5.5.1",
|
||||
"version": "5.5.3",
|
||||
"description": "react-native hot update",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
@@ -37,7 +37,7 @@
|
||||
"read": "^1.0.7",
|
||||
"request": "^2.69.0",
|
||||
"tty-table": "^2.7.0",
|
||||
"yauzl": "2.4.1",
|
||||
"yauzl": "^2.10.0",
|
||||
"yazl": "2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -11,6 +11,7 @@ Pod::Spec.new do |s|
|
||||
s.authors = package['author']
|
||||
s.homepage = package['homepage']
|
||||
|
||||
s.cocoapods_version = '>= 1.6.0'
|
||||
s.platform = :ios, "8.0"
|
||||
s.source = { :git => 'https://github.com/reactnativecn/react-native-pushy.git', :tag => '#{s.version}' }
|
||||
s.libraries = 'bz2', 'z'
|
||||
|
14
yarn.lock
14
yarn.lock
@@ -996,12 +996,6 @@ extsprintf@1.0.2:
|
||||
version "1.0.2"
|
||||
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:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e"
|
||||
@@ -2584,13 +2578,7 @@ yargs@~3.27.0:
|
||||
window-size "^0.1.2"
|
||||
y18n "^3.2.0"
|
||||
|
||||
yauzl@2.4.1:
|
||||
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:
|
||||
yauzl@^2.10.0, yauzl@^2.8.0:
|
||||
version "2.10.0"
|
||||
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
|
||||
integrity sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=
|
||||
|
Reference in New Issue
Block a user