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/testHotUpdate/android/app/.cxx
Example/harmony_use_pushy/libs Example/harmony_use_pushy/libs
**/mcp.json **/mcp.json
harmony/package
**/oh_modules
harmony/pushy/.preview

6
.gitmodules vendored
View File

@@ -4,9 +4,3 @@
[submodule "android/jni/HDiffPatch"] [submodule "android/jni/HDiffPatch"]
path = android/jni/HDiffPatch path = android/jni/HDiffPatch
url = https://github.com/sisong/HDiffPatch.git 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": { app: {
"signingConfigs": [], signingConfigs: [],
"products": [ products: [
{ {
"name": "default", name: 'default',
"signingConfig": "default", signingConfig: 'default',
"compatibleSdkVersion": "5.0.0(12)", compatibleSdkVersion: '5.0.0(12)',
"runtimeOS": "HarmonyOS", runtimeOS: 'HarmonyOS',
"buildOption": { buildOption: {
"strictMode": { strictMode: {
"caseSensitiveCheck": true, caseSensitiveCheck: true,
"useNormalizedOHMUrl": true useNormalizedOHMUrl: true,
} },
} },
} },
], ],
"buildModeSet": [ buildModeSet: [
{ {
"name": "debug", name: 'debug',
}, },
{ {
"name": "release" name: 'release',
} },
] ],
}, },
"modules": [ modules: [
{ {
"name": "entry", name: 'entry',
"srcPath": "./entry", srcPath: './entry',
"targets": [ targets: [
{ {
"name": "default", name: 'default',
"applyToProducts": [ applyToProducts: ['default'],
"default" },
] ],
} },
] {
} name: 'pushy',
] srcPath: '../../../harmony/pushy',
} targets: [
{
name: 'default',
applyToProducts: ['default'],
},
],
},
],
}

View File

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

View File

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

View File

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

Binary file not shown.

View File

@@ -1,6 +1,7 @@
{ {
"meta": { "meta": {
"stableOrder": true "stableOrder": true,
"enableUnifiedLockfile": false
}, },
"lockfileVersion": 3, "lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
@@ -9,7 +10,7 @@
}, },
"packages": { "packages": {
"@rnoh/react-native-openharmony@0.72.38": { "@rnoh/react-native-openharmony@0.72.38": {
"name": "@rnoh/react-native-openharmony", "name": "",
"version": "0.72.38", "version": "0.72.38",
"integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==", "integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==",
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.38.har", "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": "", "types": "",
"devDependencies": {}, "devDependencies": {},
"name": "pushy", "name": "pushy",
@@ -8,5 +8,6 @@
"version": "3.1.0-0.0.7", "version": "3.1.0-0.0.7",
"dependencies": { "dependencies": {
"@rnoh/react-native-openharmony":"^0.72.38" "@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); this.updateContext = new UpdateContext(context);
} }
getURL(): string { getURL(): string {
return this.updateContext.getBundleUrl().substring(1); return this.updateContext.getBundleUrl()?.substring(1);
} }
async getBundle(): Promise<ArrayBuffer> { async getBundle(): Promise<ArrayBuffer> {

View File

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

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "10.34.0", "version": "10.34.1",
"description": "react-native hot update", "description": "react-native hot update",
"main": "src/index", "main": "src/index",
"scripts": { "scripts": {
@@ -9,7 +9,7 @@
"lint": "eslint \"src/*.@(ts|tsx|js|jsx)\" && tsc --noEmit", "lint": "eslint \"src/*.@(ts|tsx|js|jsx)\" && tsc --noEmit",
"submodule": "git submodule update --init --recursive", "submodule": "git submodule update --init --recursive",
"test": "echo \"Error: no test specified\" && exit 1", "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-debug": "cd Example/testHotUpdate && bun && detox build --configuration ios.sim.debug",
"build:ios-release": "cd Example/testHotUpdate && bun && detox build --configuration ios.sim.release", "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", "test:ios-debug": "cd Example/testHotUpdate && detox test --configuration ios.sim.debug",
@@ -72,6 +72,5 @@
"react-native": "0.73", "react-native": "0.73",
"ts-jest": "^29.3.2", "ts-jest": "^29.3.2",
"typescript": "^5.6.3" "typescript": "^5.6.3"
}, }
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
} }