react-native-update 10.22.0 → 10.23.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/harmony/README.md +0 -0
- package/harmony/oh-package-lock.json5 +7 -6
- package/harmony/oh-package.json5 +1 -1
- package/harmony/src/main/cpp/pushy.c +4 -2
- package/harmony/src/main/ets/DownloadTask.ts +4 -2
- 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 +1 -1
|
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
|
@@ -72,16 +72,18 @@ napi_value HdiffPatch(napi_env env, napi_callback_info info) {
|
|
|
72
72
|
// 创建结果buffer
|
|
73
73
|
napi_value resultBuffer;
|
|
74
74
|
uint8_t* outPtr;
|
|
75
|
-
|
|
75
|
+
void* data;
|
|
76
|
+
|
|
77
|
+
status = napi_create_arraybuffer(env, newsize, &data, &resultBuffer);
|
|
76
78
|
if (status != napi_ok) {
|
|
77
79
|
napi_throw_error(env, NULL, "Failed to create result buffer");
|
|
78
80
|
return NULL;
|
|
79
81
|
}
|
|
82
|
+
outPtr = (uint8_t*)data;
|
|
80
83
|
|
|
81
84
|
// 执行patch
|
|
82
85
|
_check(kHPatch_ok==hpatch_by_mem(originPtr, originLength, outPtr, newsize,
|
|
83
86
|
patchPtr, patchLength, &patInfo), "hpatch");
|
|
84
|
-
|
|
85
87
|
return resultBuffer;
|
|
86
88
|
|
|
87
89
|
_clear:
|
|
@@ -288,7 +288,9 @@ export class DownloadTask {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
|
|
291
|
+
if(entry.filename !== '.DS_Store'){
|
|
292
|
+
await zip.decompressFile(entry.filename, params.unzipDirectory);
|
|
293
|
+
}
|
|
292
294
|
}
|
|
293
295
|
|
|
294
296
|
if (!foundDiff) {
|
|
@@ -489,4 +491,4 @@ export class DownloadTask {
|
|
|
489
491
|
params.listener?.onDownloadFailed(error);
|
|
490
492
|
}
|
|
491
493
|
}
|
|
492
|
-
}
|
|
494
|
+
}
|
|
@@ -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';
|