1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 11:51:38 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

update RNOH SDK dependence from local to remote (#473)

* fix harmony more than 2M issue

* fix mtpush-react-native conflics

* update harmony remote dependency flow

* udpate

* udpate

* udpate

* udpate

* udpate

* update

* uddate

* udpapte
This commit is contained in:
波仔糕
2025-02-14 17:55:09 +08:00
committed by GitHub
parent b04247b486
commit 2a96684de7
25 changed files with 145 additions and 121 deletions

0
harmony/README.md Normal file
View File

View File

@@ -5,14 +5,15 @@
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"rnoh@../../../libs/rnoh": "rnoh@../../../libs/rnoh"
"@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38"
},
"packages": {
"rnoh@../../../libs/rnoh": {
"name": "rnoh",
"version": "0.72.12",
"resolved": "../../../libs/rnoh",
"registryType": "local"
"@rnoh/react-native-openharmony@0.72.38": {
"name": "@rnoh/react-native-openharmony",
"version": "0.72.38",
"integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==",
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.38.har",
"registryType": "ohpm"
}
}
}

View File

@@ -7,6 +7,6 @@
"main": "index.ets",
"version": "3.1.0-0.0.7",
"dependencies": {
"rnoh": "file:../../../libs/rnoh"
"@rnoh/react-native-openharmony":"^0.72.38"
}
}

View File

@@ -0,0 +1 @@
../../../../../harmony/oh_modules/.ohpm/@rnoh+react-native-openharmony@0.72.38/oh_modules/@rnoh/react-native-openharmony

View File

@@ -491,4 +491,4 @@ export class DownloadTask {
params.listener?.onDownloadFailed(error);
}
}
}
}

View File

@@ -1,4 +1,4 @@
import { HotReloadConfig, JSBundleProvider, JSBundleProviderError, JSPackagerClientConfig } from 'rnoh';
import { HotReloadConfig, JSBundleProvider, JSBundleProviderError, JSPackagerClientConfig } from '@rnoh/react-native-openharmony';
import fileIo from '@ohos.file.fs';
import common from '@ohos.app.ability.common';
import { UpdateContext } from './UpdateContext';
@@ -40,20 +40,15 @@ export class FileJSBundleProvider extends JSBundleProvider {
}
throw new Error('Update bundle not found');
} catch (error) {
throw new JSBundleProviderError(`Couldn't load JSBundle from ${this.filePath}`, error)
throw new JSBundleProviderError({
whatHappened: `Couldn't load JSBundle from ${this.filePath}`,
extraData: error,
howCanItBeFixed: [`Check if a bundle exists at "${this.filePath}" on your device.`]
})
}
}
getAppKeys(): string[] {
return [];
}
getHotReloadConfig(): HotReloadConfig | null {
return null;
}
getJSPackagerClientConfig(): JSPackagerClientConfig | null {
return null;
}
}

View File

@@ -1,5 +1,5 @@
import { RNPackage, TurboModulesFactory } from 'rnoh/ts';
import type { TurboModule, TurboModuleContext } from 'rnoh/ts';
import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
import { PushyTurboModule } from './PushyTurboModule';
class PushyTurboModulesFactory extends TurboModulesFactory {

View File

@@ -1,4 +1,4 @@
import { TurboModule, TurboModuleContext } from 'rnoh/ts';
import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
import common from '@ohos.app.ability.common';
import dataPreferences from '@ohos.data.preferences';
import { bundleManager } from '@kit.AbilityKit';

View File

@@ -26,49 +26,49 @@ export class UpdateContext {
this.initPreferences();
}
private async initPreferences() {
private initPreferences() {
try {
this.preferences = await preferences.getPreferences(this.context, 'update');
const packageVersion = await this.getPackageVersion();
const storedVersion = await this.preferences.get('packageVersion', '');
this.preferences = preferences.getPreferencesSync(this.context, {name:'update'});
const packageVersion = this.getPackageVersion();
const storedVersion = this.preferences.getSync('packageVersion', '');
if (packageVersion !== storedVersion) {
await this.preferences.clear();
await this.preferences.put('packageVersion', packageVersion);
await this.preferences.flush();
this.cleanUp();
this.preferences.clear();
this.preferences.putSync('packageVersion', packageVersion);
this.preferences.flush();
this.cleanUp();
}
} catch (e) {
console.error('Failed to init preferences:', e);
}
}
public async setKv(key: string, value: string): Promise<void> {
await this.preferences.put(key, value);
await this.preferences.flush();
public setKv(key: string, value: string): void {
this.preferences.putSync(key, value);
this.preferences.flush();
}
public async getKv(key: string): Promise<string> {
return await this.preferences.get(key, '') as string;
public getKv(key: string): string {
return this.preferences.getSync(key, '') as string;
}
public async isFirstTime(): Promise<boolean> {
return await this.preferences.get('firstTime', false) as boolean;
public isFirstTime(): boolean {
return this.preferences.getSync('firstTime', false) as boolean;
}
public async rolledBackVersion(): Promise<string> {
return await this.preferences.get('rolledBackVersion', '') as string;
public rolledBackVersion(): string {
return this.preferences.getSync('rolledBackVersion', '') as string;
}
public async markSuccess(): Promise<void> {
await this.preferences.put('firstTimeOk', true);
const lastVersion = await this.preferences.get('lastVersion', '') as string;
const curVersion = await this.preferences.get('currentVersion', '') as string;
public markSuccess(): void {
this.preferences.putSync('firstTimeOk', true);
const lastVersion = this.preferences.getSync('lastVersion', '') as string;
const curVersion = this.preferences.getSync('currentVersion', '') as string;
if (lastVersion && lastVersion !== curVersion) {
await this.preferences.delete('lastVersion');
await this.preferences.delete(`hash_${lastVersion}`);
this.preferences.deleteSync('lastVersion');
this.preferences.deleteSync(`hash_${lastVersion}`);
}
await this.preferences.flush();
this.preferences.flush();
this.cleanUp();
}
@@ -143,23 +143,23 @@ export class UpdateContext {
}
}
public async switchVersion(hash: string): Promise<void> {
public switchVersion(hash: string): void {
try {
const bundlePath = `${this.rootDir}/${hash}/bundle.harmony.js`;
if (!fileIo.accessSync(bundlePath)) {
throw new Error(`Bundle version ${hash} not found.`);
}
const lastVersion = await this.getKv('currentVersion');
await this.setKv('currentVersion', hash);
const lastVersion = this.getKv('currentVersion');
this.setKv('currentVersion', hash);
if (lastVersion && lastVersion !== hash) {
await this.setKv('lastVersion', lastVersion);
this.setKv('lastVersion', lastVersion);
}
await this.setKv('firstTime', 'true');
await this.setKv('firstTimeOk', 'false');
await this.setKv('rolledBackVersion', null);
this.setKv('firstTime', 'true');
this.setKv('firstTimeOk', 'false');
this.setKv('rolledBackVersion', null);
} catch (e) {
console.error('Failed to switch version:', e);
}
@@ -176,7 +176,7 @@ export class UpdateContext {
return defaultAssetsUrl;
}
if (!this.isFirstTime()) {
if (!this.preferences.get('firstTimeOk', true)) {
if (!this.preferences.getSync('firstTimeOk', true)) {
return this.rollBack();
}
}

View File

@@ -1,8 +1,5 @@
import { TurboModuleContext } from 'rnoh/ts';
import dataPreferences from '@ohos.data.preferences';
import bundleManager from '@ohos.bundle.bundleManager';
import common from '@ohos.app.ability.common';
import { BusinessError } from '@ohos.base';
import { UpdateContext } from './UpdateContext';
import { DownloadTaskParams } from './DownloadTaskParams';
import logger from './Logger';