react-native-update 10.34.9 → 10.35.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/harmony/pushy/oh-package-lock.json5 +5 -5
- package/harmony/pushy/oh-package.json5 +10 -10
- package/harmony/pushy/src/main/ets/DownloadTask.ts +2 -2
- package/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets +23 -27
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +80 -55
- package/harmony/pushy/src/main/ets/UpdateContext.ts +5 -11
- package/package.json +1 -1
- package/src/core.ts +1 -1
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
"lockfileVersion": 3,
|
|
7
7
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
|
8
8
|
"specifiers": {
|
|
9
|
-
"@rnoh/react-native-openharmony
|
|
9
|
+
"@rnoh/react-native-openharmony@^0.72.96": "@rnoh/react-native-openharmony@0.72.96"
|
|
10
10
|
},
|
|
11
11
|
"packages": {
|
|
12
|
-
"@rnoh/react-native-openharmony@0.72.
|
|
12
|
+
"@rnoh/react-native-openharmony@0.72.96": {
|
|
13
13
|
"name": "",
|
|
14
|
-
"version": "0.72.
|
|
15
|
-
"integrity": "sha512-
|
|
16
|
-
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.
|
|
14
|
+
"version": "0.72.96",
|
|
15
|
+
"integrity": "sha512-gBbm8LLyqi5UE7qHWdZYeQnjyncfEpCczKZUP/9M2U1Z7exR0Kya8PMKMwr1ta5ujy7w/hZVC2LomEV4QvBeqA==",
|
|
16
|
+
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.96.har",
|
|
17
17
|
"registryType": "ohpm"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
license: 'MIT',
|
|
3
|
+
types: '',
|
|
4
|
+
devDependencies: {},
|
|
5
|
+
name: 'pushy',
|
|
6
|
+
description: '',
|
|
7
|
+
main: 'index.ets',
|
|
8
|
+
version: '10.35.1',
|
|
9
|
+
dependencies: {
|
|
10
|
+
'@rnoh/react-native-openharmony': '^0.72.96',
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
modelVersion: '5.0.0',
|
|
13
13
|
}
|
|
@@ -57,7 +57,7 @@ export class DownloadTask {
|
|
|
57
57
|
|
|
58
58
|
try {
|
|
59
59
|
try {
|
|
60
|
-
|
|
60
|
+
let exists = fileIo.accessSync(params.targetFile);
|
|
61
61
|
if (exists) {
|
|
62
62
|
await fileIo.unlink(params.targetFile);
|
|
63
63
|
} else {
|
|
@@ -65,7 +65,7 @@ export class DownloadTask {
|
|
|
65
65
|
0,
|
|
66
66
|
params.targetFile.lastIndexOf('/'),
|
|
67
67
|
);
|
|
68
|
-
|
|
68
|
+
exists = fileIo.accessSync(targetDir);
|
|
69
69
|
if (!exists) {
|
|
70
70
|
await fileIo.mkdir(targetDir);
|
|
71
71
|
}
|
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
FileJSBundle,
|
|
3
|
+
HotReloadConfig,
|
|
4
|
+
JSBundleProvider,
|
|
5
|
+
JSBundleProviderError
|
|
6
|
+
} from '@rnoh/react-native-openharmony';
|
|
3
7
|
import common from '@ohos.app.ability.common';
|
|
8
|
+
import fs from '@ohos.file.fs';
|
|
4
9
|
import { UpdateContext } from './UpdateContext';
|
|
5
10
|
|
|
6
11
|
export class PushyFileJSBundleProvider extends JSBundleProvider {
|
|
7
12
|
private updateContext: UpdateContext;
|
|
8
|
-
private
|
|
13
|
+
private path: string = ''
|
|
9
14
|
|
|
10
15
|
constructor(context: common.UIAbilityContext) {
|
|
11
16
|
super();
|
|
12
17
|
this.updateContext = new UpdateContext(context);
|
|
18
|
+
this.path = this.updateContext.getBundleUrl();
|
|
13
19
|
}
|
|
20
|
+
|
|
14
21
|
getURL(): string {
|
|
15
|
-
return this.
|
|
22
|
+
return this.path;
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
async getBundle(): Promise<
|
|
25
|
+
async getBundle(): Promise<FileJSBundle> {
|
|
26
|
+
if (!this.path) {
|
|
27
|
+
throw new JSBundleProviderError({
|
|
28
|
+
whatHappened: 'No pushy bundle found. using default bundle',
|
|
29
|
+
})
|
|
30
|
+
}
|
|
19
31
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
const stat = await fileIo.stat(this.filePath);
|
|
26
|
-
const fileSize = stat.size;
|
|
27
|
-
const buffer = new ArrayBuffer(fileSize);
|
|
28
|
-
const bytesRead = fileIo.readSync(file.fd, buffer, {
|
|
29
|
-
offset: 0,
|
|
30
|
-
length: fileSize
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (bytesRead !== fileSize) {
|
|
34
|
-
throw new Error(`Failed to read entire file: read ${bytesRead} of ${fileSize} bytes`);
|
|
35
|
-
}
|
|
36
|
-
return buffer;
|
|
37
|
-
} finally {
|
|
38
|
-
fileIo.closeSync(file.fd);
|
|
32
|
+
const status = await fs.access(this.path, fs.OpenMode.READ_ONLY);
|
|
33
|
+
if (status) {
|
|
34
|
+
return {
|
|
35
|
+
filePath: this.path
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
|
-
throw new Error('Update bundle not found');
|
|
42
38
|
} catch (error) {
|
|
43
39
|
throw new JSBundleProviderError({
|
|
44
|
-
whatHappened: `Couldn't load JSBundle from ${this.
|
|
40
|
+
whatHappened: `Couldn't load JSBundle from ${this.path}`,
|
|
45
41
|
extraData: error,
|
|
46
|
-
howCanItBeFixed: [`Check if a bundle exists at "${this.
|
|
42
|
+
howCanItBeFixed: [`Check if a bundle exists at "${this.path}" on your device.`]
|
|
47
43
|
})
|
|
48
44
|
}
|
|
49
45
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
TurboModule,
|
|
3
|
+
TurboModuleContext,
|
|
4
|
+
} from '@rnoh/react-native-openharmony/ts';
|
|
2
5
|
import common from '@ohos.app.ability.common';
|
|
3
6
|
import dataPreferences from '@ohos.data.preferences';
|
|
4
7
|
import { bundleManager } from '@kit.AbilityKit';
|
|
5
|
-
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
|
6
|
-
import { BusinessError } from '@ohos.base';
|
|
7
8
|
import logger from './Logger';
|
|
8
9
|
import { UpdateModuleImpl } from './UpdateModuleImpl';
|
|
9
10
|
import { UpdateContext } from './UpdateContext';
|
|
@@ -23,50 +24,60 @@ export class PushyTurboModule extends TurboModule {
|
|
|
23
24
|
EventHub.getInstance().setRNInstance(ctx.rnInstance);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
27
|
+
getConstants(): Object {
|
|
28
|
+
logger.debug(TAG, ',call getConstants');
|
|
29
|
+
const context = this.mUiCtx;
|
|
30
|
+
const preferencesManager = dataPreferences.getPreferencesSync(context, {
|
|
31
|
+
name: 'update',
|
|
32
|
+
});
|
|
33
|
+
const isFirstTime = preferencesManager.getSync(
|
|
34
|
+
'isFirstTime',
|
|
35
|
+
false,
|
|
36
|
+
) as boolean;
|
|
37
|
+
const rolledBackVersion = preferencesManager.getSync(
|
|
38
|
+
'rolledBackVersion',
|
|
39
|
+
'',
|
|
40
|
+
) as string;
|
|
41
|
+
const uuid = preferencesManager.getSync('uuid', '') as string;
|
|
42
|
+
const currentVersion = preferencesManager.getSync(
|
|
43
|
+
'currentVersion',
|
|
44
|
+
'',
|
|
45
|
+
) as string;
|
|
46
|
+
const currentVersionInfo = this.context.getKv(`hash_${currentVersion}`);
|
|
47
|
+
const buildTime = preferencesManager.getSync('buildTime', '') as string;
|
|
48
|
+
const isUsingBundleUrl = this.context.getIsUsingBundleUrl();
|
|
49
|
+
let bundleFlags =
|
|
50
|
+
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
|
|
51
|
+
let packageVersion = '';
|
|
52
|
+
try {
|
|
53
|
+
const bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleFlags);
|
|
54
|
+
packageVersion = bundleInfo?.versionName || 'Unknown';
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('Failed to get bundle info:', error);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (isFirstTime) {
|
|
60
|
+
preferencesManager.deleteSync('isFirstTime');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (rolledBackVersion) {
|
|
64
|
+
preferencesManager.deleteSync('rolledBackVersion');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
downloadRootDir: `${context.filesDir}/_update`,
|
|
69
|
+
currentVersionInfo,
|
|
70
|
+
packageVersion,
|
|
71
|
+
currentVersion,
|
|
72
|
+
buildTime,
|
|
73
|
+
isUsingBundleUrl,
|
|
74
|
+
isFirstTime,
|
|
75
|
+
rolledBackVersion,
|
|
76
|
+
uuid,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setLocalHashInfo(hash: string, info: string): boolean {
|
|
70
81
|
logger.debug(TAG, ',call setLocalHashInfo');
|
|
71
82
|
return UpdateModuleImpl.setLocalHashInfo(this.context, hash, info);
|
|
72
83
|
}
|
|
@@ -75,9 +86,9 @@ getConstants(): Object {
|
|
|
75
86
|
return UpdateModuleImpl.getLocalHashInfo(this.context, hash);
|
|
76
87
|
}
|
|
77
88
|
|
|
78
|
-
async setUuid(uuid: string): Promise<boolean>
|
|
89
|
+
async setUuid(uuid: string): Promise<boolean> {
|
|
79
90
|
logger.debug(TAG, ',call setUuid');
|
|
80
|
-
return UpdateModuleImpl.setUuid(this.context,uuid);
|
|
91
|
+
return UpdateModuleImpl.setUuid(this.context, uuid);
|
|
81
92
|
}
|
|
82
93
|
|
|
83
94
|
async reloadUpdate(options: { hash: string }): Promise<void> {
|
|
@@ -95,31 +106,45 @@ getConstants(): Object {
|
|
|
95
106
|
return UpdateModuleImpl.markSuccess(this.context);
|
|
96
107
|
}
|
|
97
108
|
|
|
98
|
-
async downloadPatchFromPpk(options: {
|
|
109
|
+
async downloadPatchFromPpk(options: {
|
|
110
|
+
updateUrl: string;
|
|
111
|
+
hash: string;
|
|
112
|
+
originHash: string;
|
|
113
|
+
}): Promise<void> {
|
|
99
114
|
logger.debug(TAG, ',call downloadPatchFromPpk');
|
|
100
115
|
return UpdateModuleImpl.downloadPatchFromPpk(this.context, options);
|
|
101
116
|
}
|
|
102
117
|
|
|
103
|
-
async downloadPatchFromPackage(options: {
|
|
118
|
+
async downloadPatchFromPackage(options: {
|
|
119
|
+
updateUrl: string;
|
|
120
|
+
hash: string;
|
|
121
|
+
}): Promise<void> {
|
|
104
122
|
logger.debug(TAG, ',call downloadPatchFromPackage');
|
|
105
123
|
return UpdateModuleImpl.downloadPatchFromPackage(this.context, options);
|
|
106
124
|
}
|
|
107
125
|
|
|
108
|
-
async downloadFullUpdate(options: {
|
|
126
|
+
async downloadFullUpdate(options: {
|
|
127
|
+
updateUrl: string;
|
|
128
|
+
hash: string;
|
|
129
|
+
}): Promise<void> {
|
|
109
130
|
logger.debug(TAG, ',call downloadFullUpdate');
|
|
110
131
|
return UpdateModuleImpl.downloadFullUpdate(this.context, options);
|
|
111
132
|
}
|
|
112
133
|
|
|
113
|
-
async downloadAndInstallApk(options: {
|
|
134
|
+
async downloadAndInstallApk(options: {
|
|
135
|
+
url: string;
|
|
136
|
+
target: string;
|
|
137
|
+
hash: string;
|
|
138
|
+
}): Promise<void> {
|
|
114
139
|
logger.debug(TAG, ',call downloadAndInstallApk');
|
|
115
140
|
return UpdateModuleImpl.downloadAndInstallApk(this.mUiCtx, options);
|
|
116
141
|
}
|
|
117
142
|
|
|
118
|
-
addListener(
|
|
143
|
+
addListener(_eventName: string): void {
|
|
119
144
|
logger.debug(TAG, ',call addListener');
|
|
120
145
|
}
|
|
121
146
|
|
|
122
|
-
removeListeners(
|
|
147
|
+
removeListeners(_count: number): void {
|
|
123
148
|
logger.debug(TAG, ',call removeListeners');
|
|
124
149
|
}
|
|
125
150
|
}
|
|
@@ -101,6 +101,7 @@ export class UpdateContext {
|
|
|
101
101
|
params.hash = hash;
|
|
102
102
|
params.listener = listener;
|
|
103
103
|
params.targetFile = `${this.rootDir}/${hash}.ppk`;
|
|
104
|
+
params.unzipDirectory = `${this.rootDir}/${hash}`;
|
|
104
105
|
const downloadTask = new DownloadTask(this.context);
|
|
105
106
|
await downloadTask.execute(params);
|
|
106
107
|
} catch (e) {
|
|
@@ -162,8 +163,8 @@ export class UpdateContext {
|
|
|
162
163
|
const downloadTask = new DownloadTask(this.context);
|
|
163
164
|
return await downloadTask.execute(params);
|
|
164
165
|
} catch (e) {
|
|
165
|
-
throw e;
|
|
166
166
|
console.error('Failed to download APK patch:', e);
|
|
167
|
+
throw e;
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -188,18 +189,11 @@ export class UpdateContext {
|
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
public
|
|
192
|
-
context: common.UIAbilityContext,
|
|
193
|
-
defaultAssetsUrl?: string,
|
|
194
|
-
): string {
|
|
195
|
-
return new UpdateContext(context).getBundleUrl(defaultAssetsUrl);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public getBundleUrl(defaultAssetsUrl?: string): string {
|
|
192
|
+
public getBundleUrl() {
|
|
199
193
|
UpdateContext.isUsingBundleUrl = true;
|
|
200
194
|
const currentVersion = this.getCurrentVersion();
|
|
201
195
|
if (!currentVersion) {
|
|
202
|
-
return
|
|
196
|
+
return '';
|
|
203
197
|
}
|
|
204
198
|
if (!this.isFirstTime()) {
|
|
205
199
|
if (!this.preferences.getSync('firstTimeOk', true)) {
|
|
@@ -221,7 +215,7 @@ export class UpdateContext {
|
|
|
221
215
|
version = this.rollBack();
|
|
222
216
|
}
|
|
223
217
|
}
|
|
224
|
-
return
|
|
218
|
+
return '';
|
|
225
219
|
}
|
|
226
220
|
|
|
227
221
|
getPackageVersion(): string {
|
package/package.json
CHANGED
package/src/core.ts
CHANGED
|
@@ -47,7 +47,7 @@ export const currentVersionInfo = _currentVersionInfo;
|
|
|
47
47
|
|
|
48
48
|
export const isFirstTime: boolean = PushyConstants.isFirstTime;
|
|
49
49
|
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
|
|
50
|
-
export const isRolledBack: boolean =
|
|
50
|
+
export const isRolledBack: boolean = !!rolledBackVersion;
|
|
51
51
|
|
|
52
52
|
export const buildTime: string = PushyConstants.buildTime;
|
|
53
53
|
let uuid = PushyConstants.uuid;
|