react-native-update 10.22.1 → 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.
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@../../../libs/rnoh": "rnoh@../../../libs/rnoh"
8
+ "@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38"
9
9
  },
10
10
  "packages": {
11
- "rnoh@../../../libs/rnoh": {
12
- "name": "rnoh",
13
- "version": "0.72.12",
14
- "resolved": "../../../libs/rnoh",
15
- "registryType": "local"
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
  }
@@ -7,6 +7,6 @@
7
7
  "main": "index.ets",
8
8
  "version": "3.1.0-0.0.7",
9
9
  "dependencies": {
10
- "rnoh": "file:../../../libs/rnoh"
10
+ "@rnoh/react-native-openharmony":"^0.72.38"
11
11
  }
12
12
  }
@@ -491,4 +491,4 @@ export class DownloadTask {
491
491
  params.listener?.onDownloadFailed(error);
492
492
  }
493
493
  }
494
- }
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(`Couldn't load JSBundle from ${this.filePath}`, error)
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 async initPreferences() {
29
+ private initPreferences() {
30
30
  try {
31
- this.preferences = await preferences.getPreferences(this.context, 'update');
32
- const packageVersion = await this.getPackageVersion();
33
- const storedVersion = await this.preferences.get('packageVersion', '');
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
- await this.preferences.clear();
36
- await this.preferences.put('packageVersion', packageVersion);
37
- await this.preferences.flush();
38
- this.cleanUp();
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 async setKv(key: string, value: string): Promise<void> {
46
- await this.preferences.put(key, value);
47
- await this.preferences.flush();
45
+ public setKv(key: string, value: string): void {
46
+ this.preferences.putSync(key, value);
47
+ this.preferences.flush();
48
48
  }
49
49
 
50
- public async getKv(key: string): Promise<string> {
51
- return await this.preferences.get(key, '') as string;
50
+ public getKv(key: string): string {
51
+ return this.preferences.getSync(key, '') as string;
52
52
  }
53
53
 
54
- public async isFirstTime(): Promise<boolean> {
55
- return await this.preferences.get('firstTime', false) as boolean;
54
+ public isFirstTime(): boolean {
55
+ return this.preferences.getSync('firstTime', false) as boolean;
56
56
  }
57
57
 
58
- public async rolledBackVersion(): Promise<string> {
59
- return await this.preferences.get('rolledBackVersion', '') as string;
58
+ public rolledBackVersion(): string {
59
+ return this.preferences.getSync('rolledBackVersion', '') as string;
60
60
  }
61
61
 
62
- public async markSuccess(): Promise<void> {
63
- await this.preferences.put('firstTimeOk', true);
64
- const lastVersion = await this.preferences.get('lastVersion', '') as string;
65
- const curVersion = await this.preferences.get('currentVersion', '') as string;
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
- await this.preferences.delete('lastVersion');
69
- await this.preferences.delete(`hash_${lastVersion}`);
68
+ this.preferences.deleteSync('lastVersion');
69
+ this.preferences.deleteSync(`hash_${lastVersion}`);
70
70
  }
71
- await this.preferences.flush();
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 async switchVersion(hash: string): Promise<void> {
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 = await this.getKv('currentVersion');
154
- await this.setKv('currentVersion', hash);
153
+ const lastVersion = this.getKv('currentVersion');
154
+ this.setKv('currentVersion', hash);
155
155
 
156
156
  if (lastVersion && lastVersion !== hash) {
157
- await this.setKv('lastVersion', lastVersion);
157
+ this.setKv('lastVersion', lastVersion);
158
158
  }
159
159
 
160
- await this.setKv('firstTime', 'true');
161
- await this.setKv('firstTimeOk', 'false');
162
- await this.setKv('rolledBackVersion', null);
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.get('firstTimeOk', true)) {
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.22.1",
3
+ "version": "10.23.0",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {