react-native-update 10.11.8 → 10.12.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.11.8",
3
+ "version": "10.12.0",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {
package/src/client.ts CHANGED
@@ -163,6 +163,13 @@ export class Pushy {
163
163
  console.warn('web 端不支持热更新检查');
164
164
  return;
165
165
  }
166
+ if (
167
+ this.options.beforeCheckUpdate &&
168
+ (await this.options.beforeCheckUpdate()) === false
169
+ ) {
170
+ log('beforeCheckUpdate 返回 false, 忽略检查');
171
+ return;
172
+ }
166
173
  const now = Date.now();
167
174
  if (
168
175
  this.lastRespJson &&
@@ -275,6 +282,13 @@ export class Pushy {
275
282
  description,
276
283
  metaInfo,
277
284
  } = info;
285
+ if (
286
+ this.options.beforeDownloadUpdate &&
287
+ (await this.options.beforeDownloadUpdate(info)) === false
288
+ ) {
289
+ log('beforeDownloadUpdate 返回 false, 忽略下载');
290
+ return;
291
+ }
278
292
  if (!info.update || !hash) {
279
293
  return;
280
294
  }
package/src/type.ts CHANGED
@@ -81,6 +81,8 @@ export interface PushyOptions {
81
81
  dismissErrorAfter?: number;
82
82
  debug?: boolean;
83
83
  throwError?: boolean;
84
+ beforeCheckUpdate?: () => Promise<boolean>;
85
+ beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
84
86
  }
85
87
 
86
88
  export interface PushyTestPayload {