1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-10-23 01:36:43 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Update .gitignore to exclude new harmony package files, remove submodule entries from .gitmodules, and increment version in package.json to 10.34.1. Refactor build-profile.json5 for consistency and update PushyFileJSBundleProvider to handle optional chaining. Remove obsolete pushy.har file and adjust dependencies in oh-package.json5 for clarity.

This commit is contained in:
sunnylqm
2025-10-16 00:48:17 +08:00
parent 4e27d906c3
commit 57206dd2f1
14 changed files with 107 additions and 97 deletions

5
.gitignore vendored
View File

@@ -52,3 +52,8 @@ Example/testHotUpdate/harmony
Example/testHotUpdate/android/app/.cxx
Example/harmony_use_pushy/libs
**/mcp.json
harmony/package
**/oh_modules
harmony/pushy/.preview

6
.gitmodules vendored
View File

@@ -4,9 +4,3 @@
[submodule "android/jni/HDiffPatch"]
path = android/jni/HDiffPatch
url = https://github.com/sisong/HDiffPatch.git
[submodule "harmony/src/main/cpp/HDiffPatch"]
path = harmony/src/main/cpp/HDiffPatch
url = https://github.com/sisong/HDiffPatch.git
[submodule "harmony/src/main/cpp/lzma"]
path = harmony/src/main/cpp/lzma
url = https://github.com/sisong/lzma.git

View File

@@ -1,41 +1,49 @@
{
"app": {
"signingConfigs": [],
"products": [
app: {
signingConfigs: [],
products: [
{
"name": "default",
"signingConfig": "default",
"compatibleSdkVersion": "5.0.0(12)",
"runtimeOS": "HarmonyOS",
"buildOption": {
"strictMode": {
"caseSensitiveCheck": true,
"useNormalizedOHMUrl": true
}
}
}
name: 'default',
signingConfig: 'default',
compatibleSdkVersion: '5.0.0(12)',
runtimeOS: 'HarmonyOS',
buildOption: {
strictMode: {
caseSensitiveCheck: true,
useNormalizedOHMUrl: true,
},
},
},
],
"buildModeSet": [
buildModeSet: [
{
"name": "debug",
name: 'debug',
},
{
"name": "release"
}
]
name: 'release',
},
"modules": [
],
},
modules: [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
name: 'entry',
srcPath: './entry',
targets: [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
name: 'default',
applyToProducts: ['default'],
},
],
},
{
name: 'pushy',
srcPath: '../../../harmony/pushy',
targets: [
{
name: 'default',
applyToProducts: ['default'],
},
],
},
],
}

View File

@@ -1,25 +1,26 @@
{
"meta": {
"stableOrder": true
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38",
"pushy@../../node_modules/react-native-update/harmony": "pushy@../../node_modules/react-native-update/harmony"
"pushy@../../node_modules/react-native-update/harmony/pushy": "pushy@../../node_modules/react-native-update/harmony/pushy"
},
"packages": {
"@rnoh/react-native-openharmony@0.72.38": {
"name": "@rnoh/react-native-openharmony",
"name": "",
"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"
},
"pushy@../../node_modules/react-native-update/harmony": {
"pushy@../../node_modules/react-native-update/harmony/pushy": {
"name": "pushy",
"version": "3.1.0-0.0.7",
"resolved": "../../node_modules/react-native-update/harmony",
"resolved": "",
"registryType": "local",
"dependencies": {
"@rnoh/react-native-openharmony": "^0.72.38"

View File

@@ -1,13 +1,12 @@
{
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
"@rnoh/react-native-openharmony": "0.72.38",
"pushy": "file:../../node_modules/react-native-update/harmony/pushy.har",
name: 'entry',
version: '1.0.0',
description: 'Please describe the basic information.',
main: '',
author: '',
license: '',
dependencies: {
'@rnoh/react-native-openharmony': '0.72.38',
pushy: 'file:../../node_modules/react-native-update/harmony/pushy',
},
}
}

View File

@@ -1,6 +1,6 @@
import {appTasks} from '@ohos/hvigor-ohos-plugin';
export default {
system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}
system: appTasks /* Built-in plugin of Hvigor. It cannot be modified. */,
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */,
};

Binary file not shown.

View File

@@ -1,6 +1,7 @@
{
"meta": {
"stableOrder": true
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
@@ -9,7 +10,7 @@
},
"packages": {
"@rnoh/react-native-openharmony@0.72.38": {
"name": "@rnoh/react-native-openharmony",
"name": "",
"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",

View File

@@ -1,5 +1,5 @@
{
"license": "ISC",
"license": "MIT",
"types": "",
"devDependencies": {},
"name": "pushy",
@@ -8,5 +8,6 @@
"version": "3.1.0-0.0.7",
"dependencies": {
"@rnoh/react-native-openharmony":"^0.72.38"
}
},
"modelVersion": "5.0.0"
}

View File

@@ -0,0 +1 @@
../../../../../android/jni/HDiffPatch

View File

@@ -0,0 +1 @@
../../../../../android/jni/lzma

View File

@@ -12,7 +12,7 @@ export class PushyFileJSBundleProvider extends JSBundleProvider {
this.updateContext = new UpdateContext(context);
}
getURL(): string {
return this.updateContext.getBundleUrl().substring(1);
return this.updateContext.getBundleUrl()?.substring(1);
}
async getBundle(): Promise<ArrayBuffer> {

View File

@@ -9,47 +9,47 @@ import { UpdateModuleImpl } from './UpdateModuleImpl';
import { UpdateContext } from './UpdateContext';
import { EventHub } from './EventHub';
const TAG = "PushyTurboModule"
const TAG = 'PushyTurboModule';
export class PushyTurboModule extends TurboModule {
mUiCtx: common.UIAbilityContext
context: UpdateContext
mUiCtx: common.UIAbilityContext;
context: UpdateContext;
constructor(protected ctx: TurboModuleContext) {
super(ctx);
logger.debug(TAG, ",PushyTurboModule constructor");
this.mUiCtx = ctx.uiAbilityContext
this.context = new UpdateContext(this.mUiCtx)
EventHub.getInstance().setRNInstance(ctx.rnInstance)
logger.debug(TAG, ',PushyTurboModule constructor');
this.mUiCtx = ctx.uiAbilityContext;
this.context = new UpdateContext(this.mUiCtx);
EventHub.getInstance().setRNInstance(ctx.rnInstance);
}
getConstants(): Object {
logger.debug(TAG, ",call getConstants");
logger.debug(TAG, ',call getConstants');
const context = this.mUiCtx;
const preferencesManager = dataPreferences.getPreferencesSync(context,{ name: 'update' });
const isFirstTime = preferencesManager.getSync("isFirstTime", false) as boolean;
const rolledBackVersion = preferencesManager.getSync("rolledBackVersion", "") as string;
const uuid = preferencesManager.getSync("uuid", "") as string;
const currentVersion = preferencesManager.getSync("currentVersion", "") as string;
const isFirstTime = preferencesManager.getSync('isFirstTime', false) as boolean;
const rolledBackVersion = preferencesManager.getSync('rolledBackVersion', '') as string;
const uuid = preferencesManager.getSync('uuid', '') as string;
const currentVersion = preferencesManager.getSync('currentVersion', '') as string;
const currentVersionInfo = this.context.getKv(`hash_${currentVersion}`);
const buildTime = preferencesManager.getSync("buildTime", "") as string;
const buildTime = preferencesManager.getSync('buildTime', '') as string;
const isUsingBundleUrl = this.context.getIsUsingBundleUrl();
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
let packageVersion = '';
try {
const bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleFlags);
packageVersion = bundleInfo?.versionName || "Unknown"
packageVersion = bundleInfo?.versionName || 'Unknown';
} catch (error) {
console.error("Failed to get bundle info:", error);
console.error('Failed to get bundle info:', error);
}
if (isFirstTime) {
preferencesManager.deleteSync("isFirstTime");
preferencesManager.deleteSync('isFirstTime');
}
if (rolledBackVersion) {
preferencesManager.deleteSync("rolledBackVersion");
preferencesManager.deleteSync('rolledBackVersion');
}
return {
@@ -62,12 +62,12 @@ getConstants(): Object {
isFirstTime,
rolledBackVersion,
uuid,
}
};
}
setLocalHashInfo(hash: string, info: string): boolean {
logger.debug(TAG, ",call setLocalHashInfo");
logger.debug(TAG, ',call setLocalHashInfo');
return UpdateModuleImpl.setLocalHashInfo(this.context, hash, info);
}
@@ -76,50 +76,50 @@ getConstants(): Object {
}
async setUuid(uuid: string): Promise<boolean> {
logger.debug(TAG, `,call setUuid`);
logger.debug(TAG, ',call setUuid');
return UpdateModuleImpl.setUuid(this.context,uuid);
}
async reloadUpdate(options: { hash: string }): Promise<void> {
logger.debug(TAG, `,call reloadUpdate`);
logger.debug(TAG, ',call reloadUpdate');
return UpdateModuleImpl.reloadUpdate(this.context, this.mUiCtx, options);
}
async setNeedUpdate(options: { hash: string }): Promise<boolean> {
logger.debug(TAG, `,call setNeedUpdate`);
logger.debug(TAG, ',call setNeedUpdate');
return UpdateModuleImpl.setNeedUpdate(this.context, options);
}
async markSuccess(): Promise<boolean> {
logger.debug(TAG, `,call markSuccess`);
logger.debug(TAG, ',call markSuccess');
return UpdateModuleImpl.markSuccess(this.context);
}
async downloadPatchFromPpk(options: { updateUrl: string; hash: string; originHash: string }): Promise<void> {
logger.debug(TAG, `,call downloadPatchFromPpk`);
logger.debug(TAG, ',call downloadPatchFromPpk');
return UpdateModuleImpl.downloadPatchFromPpk(this.context, options);
}
async downloadPatchFromPackage(options: { updateUrl: string; hash: string }): Promise<void> {
logger.debug(TAG, `,call downloadPatchFromPackage`);
logger.debug(TAG, ',call downloadPatchFromPackage');
return UpdateModuleImpl.downloadPatchFromPackage(this.context, options);
}
async downloadFullUpdate(options: { updateUrl: string; hash: string }): Promise<void> {
logger.debug(TAG, `,call downloadFullUpdate`);
logger.debug(TAG, ',call downloadFullUpdate');
return UpdateModuleImpl.downloadFullUpdate(this.context, options);
}
async downloadAndInstallApk(options: { url: string; target: string; hash: string }): Promise<void> {
logger.debug(TAG, `,call downloadAndInstallApk`);
logger.debug(TAG, ',call downloadAndInstallApk');
return UpdateModuleImpl.downloadAndInstallApk(this.mUiCtx, options);
}
addListener(eventName: string): void {
logger.debug(TAG, `,call addListener`);
logger.debug(TAG, ',call addListener');
}
removeListeners(count: number): void {
logger.debug(TAG, `,call removeListeners`);
logger.debug(TAG, ',call removeListeners');
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-update",
"version": "10.34.0",
"version": "10.34.1",
"description": "react-native hot update",
"main": "src/index",
"scripts": {
@@ -9,7 +9,7 @@
"lint": "eslint \"src/*.@(ts|tsx|js|jsx)\" && tsc --noEmit",
"submodule": "git submodule update --init --recursive",
"test": "echo \"Error: no test specified\" && exit 1",
"build-lib": "bun submodule && $ANDROID_HOME/ndk/28.2.13676358/ndk-build NDK_PROJECT_PATH=android APP_BUILD_SCRIPT=android/jni/Android.mk NDK_APPLICATION_MK=android/jni/Application.mk NDK_LIBS_OUT=android/lib",
"build:so": "bun submodule && $ANDROID_HOME/ndk/28.2.13676358/ndk-build NDK_PROJECT_PATH=android APP_BUILD_SCRIPT=android/jni/Android.mk NDK_APPLICATION_MK=android/jni/Application.mk NDK_LIBS_OUT=android/lib",
"build:ios-debug": "cd Example/testHotUpdate && bun && detox build --configuration ios.sim.debug",
"build:ios-release": "cd Example/testHotUpdate && bun && detox build --configuration ios.sim.release",
"test:ios-debug": "cd Example/testHotUpdate && detox test --configuration ios.sim.debug",
@@ -72,6 +72,5 @@
"react-native": "0.73",
"ts-jest": "^29.3.2",
"typescript": "^5.6.3"
},
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
}
}