diff --git a/.gitignore b/.gitignore index 1421a4d..548a361 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.gitmodules b/.gitmodules index 51168f3..1bcca5b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/Example/harmony_use_pushy/harmony/build-profile.json5 b/Example/harmony_use_pushy/harmony/build-profile.json5 index 1e69556..fef3d12 100644 --- a/Example/harmony_use_pushy/harmony/build-profile.json5 +++ b/Example/harmony_use_pushy/harmony/build-profile.json5 @@ -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" - ] - } - ] - } - ] -} \ No newline at end of file + name: 'default', + applyToProducts: ['default'], + }, + ], + }, + { + name: 'pushy', + srcPath: '../../../harmony/pushy', + targets: [ + { + name: 'default', + applyToProducts: ['default'], + }, + ], + }, + ], +} diff --git a/Example/harmony_use_pushy/harmony/entry/oh-package-lock.json5 b/Example/harmony_use_pushy/harmony/entry/oh-package-lock.json5 index 5147e75..51312c5 100644 --- a/Example/harmony_use_pushy/harmony/entry/oh-package-lock.json5 +++ b/Example/harmony_use_pushy/harmony/entry/oh-package-lock.json5 @@ -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" diff --git a/Example/harmony_use_pushy/harmony/entry/oh-package.json5 b/Example/harmony_use_pushy/harmony/entry/oh-package.json5 index 49d27bf..2be7216 100644 --- a/Example/harmony_use_pushy/harmony/entry/oh-package.json5 +++ b/Example/harmony_use_pushy/harmony/entry/oh-package.json5 @@ -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', + }, } - diff --git a/Example/harmony_use_pushy/harmony/hvigorfile.ts b/Example/harmony_use_pushy/harmony/hvigorfile.ts index f3cb9f1..398be05 100644 --- a/Example/harmony_use_pushy/harmony/hvigorfile.ts +++ b/Example/harmony_use_pushy/harmony/hvigorfile.ts @@ -1,6 +1,6 @@ -import { appTasks } from '@ohos/hvigor-ohos-plugin'; +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. */, +}; diff --git a/harmony/pushy.har b/harmony/pushy.har deleted file mode 100644 index fdff729..0000000 Binary files a/harmony/pushy.har and /dev/null differ diff --git a/harmony/pushy/oh-package-lock.json5 b/harmony/pushy/oh-package-lock.json5 index 3f97b95..62bef8c 100644 --- a/harmony/pushy/oh-package-lock.json5 +++ b/harmony/pushy/oh-package-lock.json5 @@ -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", diff --git a/harmony/pushy/oh-package.json5 b/harmony/pushy/oh-package.json5 index 3465d35..7e03489 100644 --- a/harmony/pushy/oh-package.json5 +++ b/harmony/pushy/oh-package.json5 @@ -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" } diff --git a/harmony/pushy/src/main/cpp/HDiffPatch b/harmony/pushy/src/main/cpp/HDiffPatch new file mode 120000 index 0000000..9a07b2e --- /dev/null +++ b/harmony/pushy/src/main/cpp/HDiffPatch @@ -0,0 +1 @@ +../../../../../android/jni/HDiffPatch \ No newline at end of file diff --git a/harmony/pushy/src/main/cpp/lzma b/harmony/pushy/src/main/cpp/lzma new file mode 120000 index 0000000..fa70ff9 --- /dev/null +++ b/harmony/pushy/src/main/cpp/lzma @@ -0,0 +1 @@ +../../../../../android/jni/lzma \ No newline at end of file diff --git a/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets b/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets index 4cd0fe3..0a80d34 100644 --- a/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets +++ b/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets @@ -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 { diff --git a/harmony/pushy/src/main/ets/PushyTurboModule.ts b/harmony/pushy/src/main/ets/PushyTurboModule.ts index 70723d9..5db9950 100644 --- a/harmony/pushy/src/main/ets/PushyTurboModule.ts +++ b/harmony/pushy/src/main/ets/PushyTurboModule.ts @@ -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 { - logger.debug(TAG, `,call setUuid`); + logger.debug(TAG, ',call setUuid'); return UpdateModuleImpl.setUuid(this.context,uuid); } async reloadUpdate(options: { hash: string }): Promise { - logger.debug(TAG, `,call reloadUpdate`); + logger.debug(TAG, ',call reloadUpdate'); return UpdateModuleImpl.reloadUpdate(this.context, this.mUiCtx, options); } async setNeedUpdate(options: { hash: string }): Promise { - logger.debug(TAG, `,call setNeedUpdate`); + logger.debug(TAG, ',call setNeedUpdate'); return UpdateModuleImpl.setNeedUpdate(this.context, options); } async markSuccess(): Promise { - 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 { - logger.debug(TAG, `,call downloadPatchFromPpk`); + logger.debug(TAG, ',call downloadPatchFromPpk'); return UpdateModuleImpl.downloadPatchFromPpk(this.context, options); } async downloadPatchFromPackage(options: { updateUrl: string; hash: string }): Promise { - logger.debug(TAG, `,call downloadPatchFromPackage`); + logger.debug(TAG, ',call downloadPatchFromPackage'); return UpdateModuleImpl.downloadPatchFromPackage(this.context, options); } async downloadFullUpdate(options: { updateUrl: string; hash: string }): Promise { - 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 { - 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'); } -} \ No newline at end of file +} diff --git a/package.json b/package.json index bd1dbf2..5429934 100644 --- a/package.json +++ b/package.json @@ -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" + } }