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

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.
@@ -53,6 +53,7 @@ typedef NS_ENUM(NSInteger, PushyType) {
53
53
  };
54
54
 
55
55
  static BOOL ignoreRollback = false;
56
+ static BOOL isUsingBundleUrl = false;
56
57
 
57
58
  @implementation RCTPushy {
58
59
  RCTPushyManager *_fileManager;
@@ -65,6 +66,7 @@ RCT_EXPORT_MODULE(RCTPushy);
65
66
 
66
67
  + (NSURL *)bundleURL
67
68
  {
69
+ isUsingBundleUrl = true;
68
70
  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
69
71
 
70
72
  NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
@@ -161,6 +163,7 @@ RCT_EXPORT_MODULE(RCTPushy);
161
163
  ret[@"uuid"] = [defaults objectForKey:keyUuid];
162
164
  NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
163
165
  ret[@"currentVersion"] = [pushyInfo objectForKey:paramCurrentVersion];
166
+ ret[@"isUsingBundleUrl"] = @(isUsingBundleUrl);
164
167
 
165
168
  // clear isFirstTimemarked
166
169
  if (ret[@"isFirstTime"]) {
@@ -1,51 +1,45 @@
1
- /**
2
- * @format
3
- * @flow strict-local
4
- */
5
- 'use strict';
6
-
7
1
  import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
8
2
  import { TurboModuleRegistry } from 'react-native';
9
3
 
10
4
  export interface Spec extends TurboModule {
11
5
  getConstants: () => {
12
- downloadRootDir: string,
13
- packageVersion: string,
14
- currentVersion: string,
15
- isFirstTime: boolean,
16
- rolledBackVersion: string,
17
- buildTime: string,
18
- blockUpdate: Object,
19
- uuid: string,
20
- isUsingBundleUrl: boolean,
6
+ downloadRootDir: string;
7
+ packageVersion: string;
8
+ currentVersion: string;
9
+ isFirstTime: boolean;
10
+ rolledBackVersion: string;
11
+ buildTime: string;
12
+ blockUpdate: Object;
13
+ uuid: string;
14
+ isUsingBundleUrl: boolean;
21
15
  };
22
16
  setLocalHashInfo(hash: string, info: string): Promise<void>;
23
17
  getLocalHashInfo(hash: string): Promise<string>;
24
18
  setUuid(uuid: string): Promise<void>;
25
- setBlockUpdate(options: { reason: string, until: number }): Promise<void>;
19
+ setBlockUpdate(options: { reason: string; until: number }): Promise<void>;
26
20
  reloadUpdate(options: { hash: string }): Promise<void>;
27
21
  setNeedUpdate(options: { hash: string }): Promise<void>;
28
22
  markSuccess(): Promise<void>;
29
23
  downloadPatchFromPpk(options: {
30
- updateUrl: string,
31
- hash: string,
32
- originHash: string,
24
+ updateUrl: string;
25
+ hash: string;
26
+ originHash: string;
33
27
  }): Promise<void>;
34
28
  downloadPatchFromPackage(options: {
35
- updateUrl: string,
36
- hash: string,
29
+ updateUrl: string;
30
+ hash: string;
37
31
  }): Promise<void>;
38
32
  downloadFullUpdate(options: {
39
- updateUrl: string,
40
- hash: string,
33
+ updateUrl: string;
34
+ hash: string;
41
35
  }): Promise<void>;
42
36
  downloadAndInstallApk(options: {
43
- url: string,
44
- target: string,
45
- hash: string,
37
+ url: string;
38
+ target: string;
39
+ hash: string;
46
40
  }): Promise<void>;
47
41
  addListener(eventName: string): void;
48
42
  removeListeners(count: number): void;
49
43
  }
50
44
 
51
- export default (TurboModuleRegistry.get<Spec>('Pushy'): ?Spec);
45
+ export default TurboModuleRegistry.get<Spec>('Pushy') as Spec | null;
package/lib/main.ts CHANGED
@@ -44,7 +44,7 @@ export const buildTime = PushyConstants.buildTime;
44
44
  let blockUpdate = PushyConstants.blockUpdate;
45
45
  let uuid = PushyConstants.uuid;
46
46
 
47
- if (Platform.OS === 'android' && !PushyConstants.isUsingBundleUrl) {
47
+ if (!PushyConstants.isUsingBundleUrl) {
48
48
  throw new Error(
49
49
  'react-native-update模块无法加载,请对照文档检查Bundle URL的配置',
50
50
  );
@@ -125,7 +125,6 @@ export const cInfo = {
125
125
  };
126
126
 
127
127
  function assertRelease() {
128
- // @ts-expect-error
129
128
  if (__DEV__) {
130
129
  throw new Error('react-native-update 只能在 RELEASE 版本中运行.');
131
130
  }
@@ -1,5 +1,11 @@
1
- import React, { PureComponent } from 'react';
2
- import { Platform, Alert, Linking, AppState } from 'react-native';
1
+ import React, { PureComponent, ComponentType } from 'react';
2
+ import {
3
+ Platform,
4
+ Alert,
5
+ Linking,
6
+ AppState,
7
+ NativeEventSubscription,
8
+ } from 'react-native';
3
9
 
4
10
  import {
5
11
  isFirstTime,
@@ -15,7 +21,7 @@ import {
15
21
  import { UpdateEventsListener } from './type';
16
22
 
17
23
  export function simpleUpdate(
18
- WrappedComponent: JSX.Element,
24
+ WrappedComponent: ComponentType,
19
25
  options: { appKey?: string; onEvents?: UpdateEventsListener } = {},
20
26
  ) {
21
27
  const { appKey, onEvents: eventListeners } = options;
@@ -25,10 +31,10 @@ export function simpleUpdate(
25
31
  if (typeof eventListeners === 'function') {
26
32
  onEvents(eventListeners);
27
33
  }
28
- // @ts-expect-error
29
34
  return __DEV__
30
35
  ? WrappedComponent
31
36
  : class AppUpdate extends PureComponent {
37
+ stateListener: NativeEventSubscription;
32
38
  componentDidMount() {
33
39
  if (isRolledBack) {
34
40
  Alert.alert('抱歉', '刚刚更新遭遇错误,已为您恢复到更新前版本');
@@ -79,7 +85,7 @@ export function simpleUpdate(
79
85
  checkUpdate = async () => {
80
86
  let info;
81
87
  try {
82
- info = await checkUpdate(appKey);
88
+ info = await checkUpdate(appKey!);
83
89
  } catch (err) {
84
90
  Alert.alert('更新检查失败', err.message);
85
91
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "9.0.0-beta.2",
3
+ "version": "9.0.0-beta.3",
4
4
  "description": "react-native hot update",
5
5
  "main": "lib/index.ts",
6
6
  "scripts": {
@@ -2,7 +2,6 @@ require 'json'
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
 
5
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6
5
  Pod::Spec.new do |s|
7
6
  s.name = package['name']
8
7
  s.version = package['version']
@@ -41,18 +40,5 @@ Pod::Spec.new do |s|
41
40
  'android/jni/lzma/C/Lzma2Dec.{h,c}']
42
41
  ss.private_header_files = 'ios/RCTPushy/HDiffPatch/**/*.h'
43
42
  end
44
- # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
45
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
46
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
47
- s.pod_target_xcconfig = {
48
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
49
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
50
- }
51
-
52
- s.dependency "React-Codegen"
53
- s.dependency "RCT-Folly"
54
- s.dependency "RCTRequired"
55
- s.dependency "RCTTypeSafety"
56
- s.dependency "ReactCommon/turbomodule/core"
57
- end
43
+ install_modules_dependencies(s)
58
44
  end