react-native-update 10.22.1 → 10.23.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 +2 -2
- package/harmony/README.md +0 -0
- package/harmony/oh-package-lock.json5 +7 -6
- package/harmony/oh-package.json5 +1 -1
- package/harmony/src/main/ets/DownloadTask.ts +1 -1
- package/harmony/src/main/ets/FileJSBundleProvider.ets +6 -11
- package/harmony/src/main/ets/PushyPackage.ts +2 -2
- package/harmony/src/main/ets/PushyTurboModule.ts +1 -1
- package/harmony/src/main/ets/UpdateContext.ts +32 -32
- package/harmony/src/main/ets/UpdateModuleImpl.ts +0 -3
- package/package.json +4 -4
- package/react-native-update.podspec +1 -1
- package/src/client.ts +1 -1
- package/src/core.ts +3 -3
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
### 本地开发
|
|
23
23
|
|
|
24
24
|
```
|
|
25
|
-
$ git clone git@github.com:reactnativecn/react-native-
|
|
25
|
+
$ git clone git@github.com:reactnativecn/react-native-update.git
|
|
26
26
|
$ cd react-native-pushy/Example/testHotUpdate
|
|
27
27
|
$ yarn
|
|
28
28
|
$ yarn start
|
|
@@ -34,4 +34,4 @@ $ yarn start
|
|
|
34
34
|
|
|
35
35
|
本组件由[React Native 中文网](https://reactnative.cn/)独家发布,如有定制需求可以[联系我们](https://reactnative.cn/about.html#content)。
|
|
36
36
|
|
|
37
|
-
关于此插件发现任何问题,可以前往[Issues](https://github.com/reactnativecn/react-native-
|
|
37
|
+
关于此插件发现任何问题,可以前往[Issues](https://github.com/reactnativecn/react-native-update/issues)发帖提问。
|
|
File without changes
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
"lockfileVersion": 3,
|
|
6
6
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
|
7
7
|
"specifiers": {
|
|
8
|
-
"rnoh
|
|
8
|
+
"@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38"
|
|
9
9
|
},
|
|
10
10
|
"packages": {
|
|
11
|
-
"rnoh
|
|
12
|
-
"name": "rnoh",
|
|
13
|
-
"version": "0.72.
|
|
14
|
-
"
|
|
15
|
-
"
|
|
11
|
+
"@rnoh/react-native-openharmony@0.72.38": {
|
|
12
|
+
"name": "@rnoh/react-native-openharmony",
|
|
13
|
+
"version": "0.72.38",
|
|
14
|
+
"integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==",
|
|
15
|
+
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.38.har",
|
|
16
|
+
"registryType": "ohpm"
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
}
|
package/harmony/oh-package.json5
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HotReloadConfig, JSBundleProvider, JSBundleProviderError, JSPackagerClientConfig } from 'rnoh';
|
|
1
|
+
import { HotReloadConfig, JSBundleProvider, JSBundleProviderError, JSPackagerClientConfig } from '@rnoh/react-native-openharmony';
|
|
2
2
|
import fileIo from '@ohos.file.fs';
|
|
3
3
|
import common from '@ohos.app.ability.common';
|
|
4
4
|
import { UpdateContext } from './UpdateContext';
|
|
@@ -40,20 +40,15 @@ export class FileJSBundleProvider extends JSBundleProvider {
|
|
|
40
40
|
}
|
|
41
41
|
throw new Error('Update bundle not found');
|
|
42
42
|
} catch (error) {
|
|
43
|
-
throw new JSBundleProviderError(
|
|
43
|
+
throw new JSBundleProviderError({
|
|
44
|
+
whatHappened: `Couldn't load JSBundle from ${this.filePath}`,
|
|
45
|
+
extraData: error,
|
|
46
|
+
howCanItBeFixed: [`Check if a bundle exists at "${this.filePath}" on your device.`]
|
|
47
|
+
})
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
getAppKeys(): string[] {
|
|
48
52
|
return [];
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
getHotReloadConfig(): HotReloadConfig | null {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
getJSPackagerClientConfig(): JSPackagerClientConfig | null {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
54
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RNPackage, TurboModulesFactory } from 'rnoh/ts';
|
|
2
|
-
import type { TurboModule, TurboModuleContext } from 'rnoh/ts';
|
|
1
|
+
import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
|
|
2
|
+
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
3
3
|
import { PushyTurboModule } from './PushyTurboModule';
|
|
4
4
|
|
|
5
5
|
class PushyTurboModulesFactory extends TurboModulesFactory {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TurboModule, TurboModuleContext } from 'rnoh/ts';
|
|
1
|
+
import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
2
2
|
import common from '@ohos.app.ability.common';
|
|
3
3
|
import dataPreferences from '@ohos.data.preferences';
|
|
4
4
|
import { bundleManager } from '@kit.AbilityKit';
|
|
@@ -26,49 +26,49 @@ export class UpdateContext {
|
|
|
26
26
|
this.initPreferences();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
private
|
|
29
|
+
private initPreferences() {
|
|
30
30
|
try {
|
|
31
|
-
this.preferences =
|
|
32
|
-
const packageVersion =
|
|
33
|
-
const storedVersion =
|
|
31
|
+
this.preferences = preferences.getPreferencesSync(this.context, {name:'update'});
|
|
32
|
+
const packageVersion = this.getPackageVersion();
|
|
33
|
+
const storedVersion = this.preferences.getSync('packageVersion', '');
|
|
34
34
|
if (packageVersion !== storedVersion) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
this.preferences.clear();
|
|
36
|
+
this.preferences.putSync('packageVersion', packageVersion);
|
|
37
|
+
this.preferences.flush();
|
|
38
|
+
this.cleanUp();
|
|
39
39
|
}
|
|
40
40
|
} catch (e) {
|
|
41
41
|
console.error('Failed to init preferences:', e);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
public
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
public setKv(key: string, value: string): void {
|
|
46
|
+
this.preferences.putSync(key, value);
|
|
47
|
+
this.preferences.flush();
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
public
|
|
51
|
-
return
|
|
50
|
+
public getKv(key: string): string {
|
|
51
|
+
return this.preferences.getSync(key, '') as string;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
public
|
|
55
|
-
return
|
|
54
|
+
public isFirstTime(): boolean {
|
|
55
|
+
return this.preferences.getSync('firstTime', false) as boolean;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
public
|
|
59
|
-
return
|
|
58
|
+
public rolledBackVersion(): string {
|
|
59
|
+
return this.preferences.getSync('rolledBackVersion', '') as string;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
public
|
|
63
|
-
|
|
64
|
-
const lastVersion =
|
|
65
|
-
const curVersion =
|
|
62
|
+
public markSuccess(): void {
|
|
63
|
+
this.preferences.putSync('firstTimeOk', true);
|
|
64
|
+
const lastVersion = this.preferences.getSync('lastVersion', '') as string;
|
|
65
|
+
const curVersion = this.preferences.getSync('currentVersion', '') as string;
|
|
66
66
|
|
|
67
67
|
if (lastVersion && lastVersion !== curVersion) {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
this.preferences.deleteSync('lastVersion');
|
|
69
|
+
this.preferences.deleteSync(`hash_${lastVersion}`);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
this.preferences.flush();
|
|
72
72
|
this.cleanUp();
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -143,23 +143,23 @@ export class UpdateContext {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
public
|
|
146
|
+
public switchVersion(hash: string): void {
|
|
147
147
|
try {
|
|
148
148
|
const bundlePath = `${this.rootDir}/${hash}/bundle.harmony.js`;
|
|
149
149
|
if (!fileIo.accessSync(bundlePath)) {
|
|
150
150
|
throw new Error(`Bundle version ${hash} not found.`);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
const lastVersion =
|
|
154
|
-
|
|
153
|
+
const lastVersion = this.getKv('currentVersion');
|
|
154
|
+
this.setKv('currentVersion', hash);
|
|
155
155
|
|
|
156
156
|
if (lastVersion && lastVersion !== hash) {
|
|
157
|
-
|
|
157
|
+
this.setKv('lastVersion', lastVersion);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
this.setKv('firstTime', 'true');
|
|
161
|
+
this.setKv('firstTimeOk', 'false');
|
|
162
|
+
this.setKv('rolledBackVersion', null);
|
|
163
163
|
} catch (e) {
|
|
164
164
|
console.error('Failed to switch version:', e);
|
|
165
165
|
}
|
|
@@ -176,7 +176,7 @@ export class UpdateContext {
|
|
|
176
176
|
return defaultAssetsUrl;
|
|
177
177
|
}
|
|
178
178
|
if (!this.isFirstTime()) {
|
|
179
|
-
if (!this.preferences.
|
|
179
|
+
if (!this.preferences.getSync('firstTimeOk', true)) {
|
|
180
180
|
return this.rollBack();
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { TurboModuleContext } from 'rnoh/ts';
|
|
2
|
-
import dataPreferences from '@ohos.data.preferences';
|
|
3
1
|
import bundleManager from '@ohos.bundle.bundleManager';
|
|
4
2
|
import common from '@ohos.app.ability.common';
|
|
5
|
-
import { BusinessError } from '@ohos.base';
|
|
6
3
|
import { UpdateContext } from './UpdateContext';
|
|
7
4
|
import { DownloadTaskParams } from './DownloadTaskParams';
|
|
8
5
|
import logger from './Logger';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.23.1",
|
|
4
4
|
"description": "react-native hot update",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/reactnativecn/react-native-
|
|
29
|
+
"url": "git+https://github.com/reactnativecn/react-native-update.git"
|
|
30
30
|
},
|
|
31
31
|
"keywords": [
|
|
32
32
|
"react-native",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"author": "reactnativecn",
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"bugs": {
|
|
40
|
-
"url": "https://github.com/reactnativecn/react-native-
|
|
40
|
+
"url": "https://github.com/reactnativecn/react-native-update/issues"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": ">=16.8.0",
|
|
44
44
|
"react-native": ">=0.59.0"
|
|
45
45
|
},
|
|
46
|
-
"homepage": "https://github.com/reactnativecn/react-native-
|
|
46
|
+
"homepage": "https://github.com/reactnativecn/react-native-update#readme",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"nanoid": "^3.3.3",
|
|
49
49
|
"react-native-url-polyfill": "^2.0.0"
|
|
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
|
|
|
18
18
|
s.cocoapods_version = '>= 1.6.0'
|
|
19
19
|
s.platform = :ios, "8.0"
|
|
20
20
|
s.platforms = { :ios => "11.0" }
|
|
21
|
-
s.source = { :git => 'https://github.com/reactnativecn/react-native-
|
|
21
|
+
s.source = { :git => 'https://github.com/reactnativecn/react-native-update.git', :tag => '#{s.version}' }
|
|
22
22
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
23
23
|
s.libraries = 'bz2', 'z'
|
|
24
24
|
s.vendored_libraries = 'RCTPushy/libRCTPushy.a'
|
package/src/client.ts
CHANGED
|
@@ -20,7 +20,7 @@ const defaultServer = {
|
|
|
20
20
|
backups: ['https://update.reactnative.cn/api'],
|
|
21
21
|
queryUrls: [
|
|
22
22
|
'https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json',
|
|
23
|
-
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-
|
|
23
|
+
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-update@master/endpoints.json',
|
|
24
24
|
],
|
|
25
25
|
};
|
|
26
26
|
|
package/src/core.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const PushyModule =
|
|
|
14
14
|
: NativeModules.Pushy;
|
|
15
15
|
|
|
16
16
|
if (!PushyModule) {
|
|
17
|
-
throw new Error('react-native-update
|
|
17
|
+
throw new Error('react-native-update 模块无法加载,请尝试重新编译');
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const PushyConstants = isTurboModuleEnabled
|
|
@@ -32,8 +32,8 @@ export const buildTime: string = PushyConstants.buildTime;
|
|
|
32
32
|
let uuid = PushyConstants.uuid;
|
|
33
33
|
|
|
34
34
|
if (Platform.OS === 'android' && !PushyConstants.isUsingBundleUrl) {
|
|
35
|
-
|
|
36
|
-
'react-native-update
|
|
35
|
+
console.warn(
|
|
36
|
+
'react-native-update 没有检测到 Bundle URL 的配置,这可能是因为您使用了某种懒加载机制(比如使用 expo,可忽略本警告),或是 Bundle URL 的配置不正确(请对照文档检查)',
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|