react-native-update 9.0.0-beta.3 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  1. 基于阿里云高速 CDN 分发,对比其他服务器在国外的热更新服务,分发更稳定,更新成功率极高。
12
12
  2. 基于 bsdiff/hdiff 算法创建的**超小更新包**,通常版本迭代后在几十 KB 级别(其他全量热更新服务所需流量通常在几十 MB 级别)。
13
- 3. 始终跟进 RN 最新正式版本,第一时间提供支持。支持 hermes 字节码格式。(暂不支持新架构,会待其相对稳定后跟进)
13
+ 3. 始终跟进 RN 最新正式版本,第一时间提供支持。支持 hermes 字节码格式。支持新架构。
14
14
  4. 跨越多个版本进行更新时,只需要下载**一个更新包**,不需要逐版本依次更新。
15
15
  5. 命令行工具 & 网页双端管理,版本发布过程简单便捷,完全可以集成 CI。
16
16
  6. 支持崩溃回滚,安全可靠。
@@ -53,7 +53,6 @@ typedef NS_ENUM(NSInteger, PushyType) {
53
53
  };
54
54
 
55
55
  static BOOL ignoreRollback = false;
56
- static BOOL isUsingBundleUrl = false;
57
56
 
58
57
  @implementation RCTPushy {
59
58
  RCTPushyManager *_fileManager;
@@ -66,7 +65,6 @@ RCT_EXPORT_MODULE(RCTPushy);
66
65
 
67
66
  + (NSURL *)bundleURL
68
67
  {
69
- isUsingBundleUrl = true;
70
68
  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
71
69
 
72
70
  NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
@@ -163,7 +161,6 @@ RCT_EXPORT_MODULE(RCTPushy);
163
161
  ret[@"uuid"] = [defaults objectForKey:keyUuid];
164
162
  NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
165
163
  ret[@"currentVersion"] = [pushyInfo objectForKey:paramCurrentVersion];
166
- ret[@"isUsingBundleUrl"] = @(isUsingBundleUrl);
167
164
 
168
165
  // clear isFirstTimemarked
169
166
  if (ret[@"isFirstTime"]) {
package/lib/main.ts CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  PermissionsAndroid,
11
11
  } from 'react-native';
12
12
  import {
13
+ CheckResult,
13
14
  EventType,
14
15
  ProgressData,
15
16
  UpdateAvailableResult,
@@ -44,7 +45,7 @@ export const buildTime = PushyConstants.buildTime;
44
45
  let blockUpdate = PushyConstants.blockUpdate;
45
46
  let uuid = PushyConstants.uuid;
46
47
 
47
- if (!PushyConstants.isUsingBundleUrl) {
48
+ if (Platform.OS === 'android' && !PushyConstants.isUsingBundleUrl) {
48
49
  throw new Error(
49
50
  'react-native-update模块无法加载,请对照文档检查Bundle URL的配置',
50
51
  );
@@ -130,24 +131,23 @@ function assertRelease() {
130
131
  }
131
132
  }
132
133
 
133
- let checkingThrottling = false;
134
+ let lastChecking = Date.now();
134
135
  export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
135
136
  assertRelease();
136
- if (checkingThrottling) {
137
+ const now = Date.now();
138
+ if (now - lastChecking < 1000 * 5) {
137
139
  logger('repeated checking, ignored');
138
140
  return;
139
141
  }
140
- checkingThrottling = true;
141
- setTimeout(() => {
142
- checkingThrottling = false;
143
- }, 3000);
142
+ lastChecking = now;
144
143
  if (blockUpdate && blockUpdate.until > Date.now() / 1000) {
145
- return report({
144
+ report({
146
145
  type: 'errorChecking',
147
146
  message: `热更新已暂停,原因:${blockUpdate.reason}。请在"${new Date(
148
147
  blockUpdate.until * 1000,
149
148
  ).toLocaleString()}"之后重试。`,
150
149
  });
150
+ return;
151
151
  }
152
152
  report({ type: 'checking' });
153
153
  let resp;
@@ -167,19 +167,26 @@ export async function checkUpdate(APPKEY: string, isRetry?: boolean) {
167
167
  });
168
168
  } catch (e) {
169
169
  if (isRetry) {
170
- return report({
170
+ report({
171
171
  type: 'errorChecking',
172
172
  message: '无法连接更新服务器,请检查网络连接后重试',
173
173
  });
174
+ return;
174
175
  }
175
176
  await tryBackupEndpoints();
176
177
  return checkUpdate(APPKEY, true);
177
178
  }
178
- const result = await resp.json();
179
+ const result: CheckResult = await resp.json();
180
+ // @ts-ignore
179
181
  checkOperation(result.op);
180
182
 
181
183
  if (resp.status !== 200) {
182
- return report({ type: 'errorChecking', message: result.message });
184
+ report({
185
+ type: 'errorChecking',
186
+ //@ts-ignore
187
+ message: result.message,
188
+ });
189
+ return;
183
190
  }
184
191
 
185
192
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "9.0.0-beta.3",
3
+ "version": "9.0.1",
4
4
  "description": "react-native hot update",
5
5
  "main": "lib/index.ts",
6
6
  "scripts": {