mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-17 15:36:13 +08:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a35c98ed4d | ||
![]() |
dcea576fff | ||
![]() |
201f11e770 | ||
![]() |
3a86218a48 | ||
![]() |
5a5e27037c | ||
![]() |
9b4016ba0a | ||
![]() |
5202cbec96 | ||
![]() |
d7c7e27eaa | ||
![]() |
e9e60bc5c6 | ||
![]() |
a93875884c | ||
![]() |
f20263b827 | ||
![]() |
8a74678b9c | ||
![]() |
17b7920100 | ||
![]() |
4d44eb858f | ||
![]() |
74ef45056e |
@@ -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. 打包时加入时间戳
|
||||||
|
@@ -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
|
||||||
|
@@ -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);
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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
1
ios/pushy_build_time.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1574665292
|
@@ -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' },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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 };
|
||||||
}
|
}
|
||||||
|
@@ -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": {
|
||||||
|
@@ -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",
|
||||||
|
@@ -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'
|
||||||
|
31
yarn.lock
31
yarn.lock
@@ -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=
|
||||||
|
Reference in New Issue
Block a user