diff --git a/Example/harmony_use_pushy/README.md b/Example/harmony_use_pushy/README.md index c243fdf..cf63189 100644 --- a/Example/harmony_use_pushy/README.md +++ b/Example/harmony_use_pushy/README.md @@ -1,25 +1,11 @@ ## 运行harmony_use_pushy项目步骤 -### 1.将项目克隆到本地后在项目根目录创建libs文件夹。 - -### 2.然后将[`rnoh`](https://github.com/bozaigao/rnoh)克隆到libs文件夹中。 - -说明:rnoh项目基于react-native 0.72.5版本适配,如果使用最新的RN版本可能会报错,项目适配RN新版本请关注[`gitee仓库`](https://gitee.com/openharmony-sig/ohos_react_native/tree/0.72.5-ohos-5.0-release/tester/harmony/react_native_openharmony/src/main) - -### 3.进入rnoh项目执行下面命令对rnoh项目依赖的C++库进行初始化; -``` -git submodule update --init --recursive -``` - -### 4. 确保在react-native-update根目录已经执行过yarn submodule命令。 -说明:这个命令会在harmony/src/main/cpp目录生成HDiffPatch和lzma的C++模块依赖。 - -### 5. 在项目根目录执行下面命令安装第三方依赖。 +### 1. 在项目根目录执行下面命令安装第三方依赖。 ``` yarn install ``` -### 6. 在项目根目录执行下面命令生成bundle包文件。 +### 2. 在项目根目录执行下面命令生成bundle包文件。 ``` yarn build ``` @@ -27,8 +13,8 @@ yarn build **注意⚠️**:在使用pushy bundle --platform harmony命令进行打包的默认bundle包名是Hbundle.harmony.js,不要随意修改包名,因为diff是匹配该包名进行生成的。 -### 7. 使用DevEco Studio IDE打开harmony目录然后执行sync运行项目 +### 3. 使用DevEco Studio IDE打开harmony目录然后执行sync运行项目 ![image](./sync.png) -### 8 运行效果图 +### 4 运行效果图 ![image](./demo.png) \ No newline at end of file diff --git a/Example/harmony_use_pushy/harmony/build-profile.json5 b/Example/harmony_use_pushy/harmony/build-profile.json5 index c31b589..8f4d86e 100644 --- a/Example/harmony_use_pushy/harmony/build-profile.json5 +++ b/Example/harmony_use_pushy/harmony/build-profile.json5 @@ -37,10 +37,6 @@ } ] }, - { - name: 'rnoh', - srcPath: '../libs/rnoh', - }, { name: 'pushy', srcPath: '../node_modules/react-native-update/harmony', diff --git a/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts b/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts index a1641ea..da601f2 100644 --- a/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts +++ b/Example/harmony_use_pushy/harmony/entry/hvigorfile.ts @@ -41,4 +41,4 @@ export function generatePushyBuildTime(str?: string) { export default { system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[generatePushyBuildTime()] /* Custom plugin to extend the functionality of Hvigor. */ -} +} \ No newline at end of file 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 e8da1c0..5147e75 100644 --- a/Example/harmony_use_pushy/harmony/entry/oh-package-lock.json5 +++ b/Example/harmony_use_pushy/harmony/entry/oh-package-lock.json5 @@ -5,24 +5,25 @@ "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": { - "pushy@../../node_modules/react-native-update/harmony": "pushy@../../node_modules/react-native-update/harmony", - "rnoh@../../libs/rnoh": "rnoh@../../libs/rnoh" + "@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" }, "packages": { + "@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" + }, "pushy@../../node_modules/react-native-update/harmony": { "name": "pushy", "version": "3.1.0-0.0.7", "resolved": "../../node_modules/react-native-update/harmony", "registryType": "local", "dependencies": { - "rnoh": "file:../../../libs/rnoh" + "@rnoh/react-native-openharmony": "^0.72.38" } - }, - "rnoh@../../libs/rnoh": { - "name": "rnoh", - "version": "0.72.12", - "resolved": "../../libs/rnoh", - "registryType": "local" } } } \ No newline at end of file diff --git a/Example/harmony_use_pushy/harmony/entry/oh-package.json5 b/Example/harmony_use_pushy/harmony/entry/oh-package.json5 index 7f088b4..0d832c9 100644 --- a/Example/harmony_use_pushy/harmony/entry/oh-package.json5 +++ b/Example/harmony_use_pushy/harmony/entry/oh-package.json5 @@ -6,7 +6,7 @@ "author": "", "license": "", "dependencies": { - "rnoh": "file:../../libs/rnoh", + "@rnoh/react-native-openharmony": "0.72.38", "pushy": "file:../../node_modules/react-native-update/harmony" } } diff --git a/Example/harmony_use_pushy/harmony/entry/src/main/cpp/CMakeLists.txt b/Example/harmony_use_pushy/harmony/entry/src/main/cpp/CMakeLists.txt index 5844b45..20fd1d1 100644 --- a/Example/harmony_use_pushy/harmony/entry/src/main/cpp/CMakeLists.txt +++ b/Example/harmony_use_pushy/harmony/entry/src/main/cpp/CMakeLists.txt @@ -2,12 +2,23 @@ cmake_minimum_required(VERSION 3.16) project(rnapp) set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") -set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../libs/rnoh/src/main/cpp") +set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp") set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") -add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy) +set(LOG_VERBOSITY_LEVEL 1) +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") +set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use +add_compile_definitions(WITH_HITRACE_SYSTRACE) +add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy) add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1 + add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} "./PackageProvider.cpp" "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" ) diff --git a/Example/harmony_use_pushy/harmony/entry/src/main/ets/RNPackagesFactory.ts b/Example/harmony_use_pushy/harmony/entry/src/main/ets/RNPackagesFactory.ts index 74e7aed..2d313b4 100644 --- a/Example/harmony_use_pushy/harmony/entry/src/main/ets/RNPackagesFactory.ts +++ b/Example/harmony_use_pushy/harmony/entry/src/main/ets/RNPackagesFactory.ts @@ -1,4 +1,4 @@ -import type {RNPackageContext, RNPackage} from 'rnoh/ts'; +import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts'; import {PushyPackage} from 'pushy/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { diff --git a/Example/harmony_use_pushy/harmony/entry/src/main/ets/entryability/EntryAbility.ets b/Example/harmony_use_pushy/harmony/entry/src/main/ets/entryability/EntryAbility.ets index c4f3354..a3539d8 100644 --- a/Example/harmony_use_pushy/harmony/entry/src/main/ets/entryability/EntryAbility.ets +++ b/Example/harmony_use_pushy/harmony/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,4 +1,4 @@ -import {RNAbility} from 'rnoh/ts'; +import {RNAbility} from '@rnoh/react-native-openharmony'; export default class EntryAbility extends RNAbility { getPagePath() { diff --git a/Example/harmony_use_pushy/harmony/entry/src/main/ets/pages/Index.ets b/Example/harmony_use_pushy/harmony/entry/src/main/ets/pages/Index.ets index ede16f4..f3923c8 100644 --- a/Example/harmony_use_pushy/harmony/entry/src/main/ets/pages/Index.ets +++ b/Example/harmony_use_pushy/harmony/entry/src/main/ets/pages/Index.ets @@ -1,26 +1,32 @@ import { FileJSBundleProvider } from 'pushy/src/main/ets/FileJSBundleProvider'; -import { ComponentBuilderContext, JSBundleProvider, RNOHLogger } from 'rnoh'; +import { ComponentBuilderContext, RNOHCoreContext,RNAbility } from '@rnoh/react-native-openharmony'; import { RNApp, - RNAbility, AnyJSBundleProvider, ResourceJSBundleProvider, TraceJSBundleProviderDecorator, -} from 'rnoh' +} from '@rnoh/react-native-openharmony' import { createRNPackages } from '../RNPackagesFactory' +import preferences from '@ohos.data.preferences'; + +const arkTsComponentNames: Array = []; @Builder -export function CustomComponentBuilder(ctx: ComponentBuilderContext) { - +export function buildCustomRNComponent(ctx: ComponentBuilderContext) { + // There seems to be a problem with the placement of ArkTS components in mixed mode. Nested Stack temporarily avoided. + Stack() { + } + .position({ x: 0, y: 0 }) } +const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent) + @Entry @Component struct Index { - @StorageLink('RNAbility') private rnAbility: RNAbility | undefined = undefined + @StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined @State shouldShow: boolean = false - @State message: string = 'Hello World'; aboutToAppear(): void { this.shouldShow = true @@ -30,28 +36,37 @@ struct Index { // NOTE: this is required since `Ability`'s `onBackPressed` function always // terminates or puts the app in the background, but we want Ark to ignore it completely // when handled by RN - return this.rnAbility?.onBackPress(); + this.rnohCoreContext!.dispatchBackPress() + + // this.preferences = preferences.getPreferencesSync(this.context, {name:'update'}); + return true } build() { Column() { - if (this.rnAbility && this.shouldShow) { + if (this.rnohCoreContext && this.shouldShow) { RNApp({ - rnInstanceConfig: { createRNPackages }, + rnInstanceConfig: { + createRNPackages, + enableNDKTextMeasuring: true, + enableBackgroundExecutor: false, + enableCAPIArchitecture: true, + arkTsComponentNames: arkTsComponentNames, + }, initialProps: { "foo": "bar" } as Record, appKey: "harmony_use_pushy", - buildCustomComponent: CustomComponentBuilder, + wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder, onSetUp: (rnInstance) => { rnInstance.enableFeatureFlag("ENABLE_RN_INSTANCE_CLEAN_UP") }, jsBundleProvider: new TraceJSBundleProviderDecorator( new AnyJSBundleProvider([ // MetroJSBundleProvider.fromServerIp('127.0.0.1'), - // new ResourceJSBundleProvider(this.rnAbility.context.resourceManager, 'hermes_bundle.hbc'), - new FileJSBundleProvider(this.rnAbility.context), - new ResourceJSBundleProvider(this.rnAbility.context.resourceManager, 'bundle.harmony.js') + // new ResourceJSBundleProvider(rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'), + new FileJSBundleProvider(this.rnohCoreContext.uiAbilityContext), + new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js') ]), - this.rnAbility.getLogger()), + this.rnohCoreContext.logger), }) } } diff --git a/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/bundle.harmony.js b/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/bundle.harmony.js index ad8adc1..1c6e21a 100644 --- a/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/bundle.harmony.js +++ b/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/bundle.harmony.js @@ -420,18 +420,18 @@ __d((function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0]).VirtualizedList}),41 __d((function(g,r,i,a,m,e,d){'use strict';var s={pointerEvents:!0,accessible:!0,accessibilityActions:!0,accessibilityLabel:!0,accessibilityLiveRegion:!0,accessibilityRole:!0,accessibilityState:!0,accessibilityValue:!0,accessibilityHint:!0,accessibilityLanguage:!0,importantForAccessibility:!0,nativeID:!0,testID:!0,renderToHardwareTextureAndroid:!0,shouldRasterizeIOS:!0,onLayout:!0,onAccessibilityAction:!0,onAccessibilityTap:!0,onMagicTap:!0,onAccessibilityEscape:!0,collapsable:!0,needsOffscreenAlphaCompositing:!0,style:r(d[0])(r(d[1])).default},c={UIView:s,RCTView:Object.assign({},s,{removeClippedSubviews:!0})};m.exports=c}),414,[3,160]); __d((function(g,_r,_i,_a,m,_e,d){Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=function(){return(0,_r(d[8]).jsx)(_r(d[7]).PushyProvider,{client:a,children:(0,_r(d[8]).jsx)(s,{})})};var e=_r(d[0])(_r(d[1])),t=_r(d[0])(_r(d[2])),n=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=o(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if("default"!==l&&{}.hasOwnProperty.call(e,l)){var s=i?Object.getOwnPropertyDescriptor(e,l):null;s&&(s.get||s.set)?Object.defineProperty(r,l,s):r[l]=e[l]}return r.default=e,n&&n.set(e,r),r})(_r(d[3])),r=_r(d[4]),i=_r(d[0])(_r(d[5]));function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(o=function(e){return e?n:t})(e)}var l=_r(d[0])(_r(d[6])).default.harmony.appKey;function s(){var o=(0,_r(d[7]).usePushy)(),l=o.client,s=o.checkUpdate,a=o.downloadUpdate,u=o.switchVersionLater,h=o.switchVersion,y=o.updateInfo,f=o.packageVersion,x=o.currentHash,j=o.progress,p=(j=void 0===j?{}:j).received,w=j.total,b=(0,n.useState)(!1),T=(0,t.default)(b,2),v=T[0],P=T[1],O=(0,n.useState)(!1),C=(0,t.default)(O,2),V=C[0],k=C[1],_=(0,n.useState)(!1),D=(0,t.default)(_,2),I=D[0],S=D[1],F=(0,n.useState)(!1),M=(0,t.default)(F,2),W=M[0],A=M[1],B=!v&&W&&(null==y?void 0:y.update);return V?(0,_r(d[8]).jsx)(i.default,{visible:!0,onClose:function(){return k(!1)}}):(0,_r(d[8]).jsxs)(r.View,{style:c.container,children:[(0,_r(d[8]).jsx)(r.Text,{style:c.welcome,children:"\u6b22\u8fce\u4f7f\u7528Pushy\u70ed\u66f4\u65b0\u670d\u52a1"}),(0,_r(d[8]).jsx)(r.View,{style:{flexDirection:'row'},children:(0,_r(d[8]).jsxs)(r.TouchableOpacity,{onPress:function(){null==l||l.setOptions({updateStrategy:v?'alwaysAlert':null}),A(v),P(!v)},style:{flexDirection:'row',alignItems:'center'},children:[(0,_r(d[8]).jsx)(r.View,{style:{width:20,height:20,borderWidth:1,borderColor:'#999',backgroundColor:v?'blue':'white',justifyContent:'center',alignItems:'center'},children:v&&(0,_r(d[8]).jsx)(r.Text,{style:{color:'white'},children:"\u2713"})}),(0,_r(d[8]).jsxs)(r.Text,{style:{marginLeft:8},children:[' ',v?'\u5f53\u524d\u4f7f\u7528':'\u5f53\u524d\u4e0d\u4f7f\u7528',"\u9ed8\u8ba4\u7684alert\u66f4\u65b0\u63d0\u793a"]})]})}),(0,_r(d[8]).jsx)(r.Image,{resizeMode:'contain',source:_r(d[9]),style:c.image}),(0,_r(d[8]).jsxs)(r.Text,{style:c.instructions,children:["\u8fd9\u662f\u7248\u672c\u4e00 ",'\n',"\u5f53\u524d\u539f\u751f\u5305\u7248\u672c\u53f7: ",f,'\n',"\u5f53\u524d\u70ed\u66f4\u65b0\u7248\u672cHash: ",x||'(\u7a7a)','\n']}),(0,_r(d[8]).jsxs)(r.Text,{children:["\u4e0b\u8f7d\u8fdb\u5ea6\uff1a",p," / ",w]}),(0,_r(d[8]).jsx)(r.TouchableOpacity,{onPress:function(){s(),A(!0)},children:(0,_r(d[8]).jsx)(r.Text,{style:c.instructions,children:"\u70b9\u51fb\u8fd9\u91cc\u68c0\u67e5\u66f4\u65b0"})}),(0,_r(d[8]).jsx)(r.TouchableOpacity,{testID:"testcase",style:{marginTop:15},onPress:function(){k(!0)},children:(0,_r(d[8]).jsxs)(r.Text,{style:c.instructions,children:["react-native-update\u7248\u672c\uff1a",null==l?void 0:l.version]})}),B&&(0,_r(d[8]).jsx)(r.View,{style:c.overlay,children:(0,_r(d[8]).jsxs)(r.View,{style:{width:'100%',backgroundColor:'#333',padding:16,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,_r(d[8]).jsxs)(r.Text,{style:{color:'white'},children:["\u6709\u65b0\u7248\u672c(",y.name,")\u53ef\u7528\uff0c\u662f\u5426\u66f4\u65b0\uff1f"]}),(0,_r(d[8]).jsxs)(r.View,{style:{flexDirection:'row'},children:[(0,_r(d[8]).jsx)(r.TouchableOpacity,{onPress:function(){return A(!1)},style:{marginRight:10},children:(0,_r(d[8]).jsx)(r.Text,{style:{color:'white'},children:"\u53d6\u6d88"})}),(0,_r(d[8]).jsx)(r.TouchableOpacity,{onPress:(0,e.default)((function*(){A(!1),yield a(),S(!0)})),children:(0,_r(d[8]).jsx)(r.Text,{style:{color:'#2196F3'},children:"\u66f4\u65b0"})})]})]})}),I&&(0,_r(d[8]).jsx)(r.View,{style:c.overlay,children:(0,_r(d[8]).jsxs)(r.View,{style:{width:'100%',backgroundColor:'#fff',padding:16,borderBottomWidth:1,borderBottomColor:'#eee'},children:[(0,_r(d[8]).jsx)(r.View,{style:{flexDirection:'row',alignItems:'center'},children:(0,_r(d[8]).jsx)(r.Text,{children:"\u66f4\u65b0\u5df2\u5b8c\u6210\uff0c\u662f\u5426\u7acb\u5373\u91cd\u542f\uff1f"})}),(0,_r(d[8]).jsxs)(r.View,{style:{flexDirection:'row',justifyContent:'flex-end',marginTop:10},children:[(0,_r(d[8]).jsx)(r.TouchableOpacity,{onPress:function(){u(),S(!1)},style:{marginRight:20},children:(0,_r(d[8]).jsx)(r.Text,{style:{color:'#2196F3'},children:"\u4e0b\u6b21\u518d\u8bf4"})}),(0,_r(d[8]).jsx)(r.TouchableOpacity,{onPress:h,children:(0,_r(d[8]).jsx)(r.Text,{style:{color:'#2196F3'},children:"\u7acb\u5373\u91cd\u542f"})})]})]})})]})}var c=r.StyleSheet.create({overlay:{position:'absolute',top:0,left:0,right:0,bottom:0,backgroundColor:'rgba(0, 0, 0, 0.5)',justifyContent:'center',alignItems:'center'},container:{flex:1,justifyContent:'center',alignItems:'center',backgroundColor:'#F5FCFF'},welcome:{fontSize:20,textAlign:'center',margin:10},instructions:{textAlign:'center',color:'#333333',marginBottom:5},image:{}}),a=new(_r(d[7]).Pushy)({appKey:l,debug:!0})}),415,[3,289,24,143,1,416,448,417,193,449]); __d((function(g,r,_i,a,m,_e,d){Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=function(x){var v=x.visible,k=x.onClose,j=(0,o.useState)(''),w=(0,n.default)(j,2),P=w[0],C=w[1],I=(0,o.useState)(!1),S=(0,n.default)(I,2),T=S[0],U=S[1],F=(0,o.useState)(),B=(0,n.default)(F,2),A=B[0],D=B[1],_=(0,o.useState)(!1),z=(0,n.default)(_,2),M=z[0],V=z[1],H=(0,o.useState)(''),E=(0,n.default)(H,2),L=E[0],N=E[1],O=(0,o.useMemo)((function(){return[{name:'setLocalHashInfo',invoke:function(){C(`setLocalHashInfo\n${l}\n{"version":"1.0.0","size":"19M"}`)}},{name:'getLocalHashInfo',invoke:function(){C(`getLocalHashInfo\n${l}`)}},{name:'setUuid',invoke:function(){C(`setUuid\n${s}`)}},{name:'reloadUpdate',invoke:function(){C('reloadUpdate'),D({hash:l})}},{name:'setNeedUpdateForApp',invoke:function(){C('setNeedUpdate'),D({hash:h})}},{name:'setNeedUpdateForPPK',invoke:function(){C('setNeedUpdate'),D({hash:p})}},{name:'markSuccess',invoke:function(){C('markSuccess'),D(void 0)}},{name:'downloadPatchFromPpk',invoke:function(){C('downloadPatchFromPpk'),D({updateUrl:f,hash:p,originHash:b})}},{name:'downloadPatchFromPackage',invoke:function(){C('downloadPatchFromPackage'),D({updateUrl:c,hash:h})}},{name:'downloadFullUpdate',invoke:function(){C('downloadFullUpdate'),D({updateUrl:u,hash:l})}},{name:'downloadAndInstallApk',invoke:function(){C('downloadAndInstallApk'),D({url:u,target:l,hash:l})}}]}),[]),W=(0,o.useCallback)((function(){for(var e=[],t=function(t){e.push((0,r(d[6]).jsx)(i.TouchableOpacity,{testID:O[t].name,onPress:function(){O[t].invoke()},children:(0,r(d[6]).jsx)(i.Text,{children:O[t].name})},t))},n=0;n0&&void 0!==arguments[0]?arguments[0]:y.options.server.main}/checkUpdate/${y.options.appKey}`},this.assertHash=function(e){if(y.downloadedHash){if(e===y.downloadedHash)return!0;(0,r(d[8]).log)(`use downloaded hash ${y.downloadedHash} first`)}},this.markSuccess=function(){!y.marked&&r(d[7]).isFirstTime&&(y.marked=!0,r(d[7]).PushyModule.markSuccess(),y.report({type:'markSuccess'}))},this.switchVersion=(function(){var e=(0,o.default)((function*(e){if(y.assertHash(e)&&!y.applyingUpdate)return(0,r(d[8]).log)('switchVersion: '+e),y.applyingUpdate=!0,r(d[7]).PushyModule.reloadUpdate({hash:e})}));return function(o){return e.apply(this,arguments)}})(),this.switchVersionLater=(function(){var e=(0,o.default)((function*(e){if(y.assertHash(e))return(0,r(d[8]).log)('switchVersionLater: '+e),r(d[7]).PushyModule.setNeedUpdate({hash:e})}));return function(o){return e.apply(this,arguments)}})(),this.checkUpdate=(function(){var e=(0,o.default)((function*(e){if('web'!==l.Platform.OS){if(!y.options.beforeCheckUpdate||!1!==(yield y.options.beforeCheckUpdate())){var o=Date.now();if(y.lastRespJson&&y.lastChecking&&o-y.lastChecking<5e3)return yield y.lastRespJson;y.lastChecking=o;var t,n=Object.assign({packageVersion:r(d[7]).packageVersion,hash:r(d[7]).currentVersion,buildTime:r(d[7]).buildTime,cInfo:r(d[7]).cInfo},e),s=JSON.stringify(n),p={method:'POST',headers:{Accept:'application/json','Content-Type':'application/json'},body:s};try{y.report({type:'checking',message:y.options.appKey+': '+s}),t=yield fetch(y.getCheckUrl(),p)}catch(e){y.report({type:'errorChecking',message:'Can not connect to update server. Trying backup endpoints.'});var u=yield y.getBackupEndpoints();if(u)try{t=yield Promise.race(u.map((function(e){return fetch(y.getCheckUrl(e),p)})))}catch(e){y.throwIfEnabled(new Error('errorCheckingUseBackup'))}else y.throwIfEnabled(new Error('errorCheckingGetBackup'))}if(!t)return y.report({type:'errorChecking',message:'Can not connect to update server. Please check your network.'}),y.throwIfEnabled(new Error('errorChecking')),y.lastRespJson?yield y.lastRespJson:c;y.lastRespJson=t.json();var h=yield y.lastRespJson;return(0,r(d[8]).log)('checking result:',h),200!==t.status&&(y.report({type:'errorChecking',message:h.message}),y.throwIfEnabled(new Error(h.message))),h}(0,r(d[8]).log)('beforeCheckUpdate \u8fd4\u56de false, \u5ffd\u7565\u68c0\u67e5')}else console.warn('web \u7aef\u4e0d\u652f\u6301\u70ed\u66f4\u65b0\u68c0\u67e5')}));return function(o){return e.apply(this,arguments)}})(),this.getBackupEndpoints=(0,o.default)((function*(){var o=y.options.server;if(!o)return[];if(o.queryUrls)try{var t=yield Promise.race(o.queryUrls.map((function(e){return fetch(e)}))),n=yield t.json();(0,r(d[8]).log)('fetch endpoints:',n),Array.isArray(n)&&(o.backups=Array.from(new Set([].concat((0,e.default)(o.backups||[]),(0,e.default)(n)))))}catch(e){(0,r(d[8]).log)('failed to fetch endpoints from: ',o.queryUrls)}return o.backups})),this.downloadUpdate=(function(){var e=(0,o.default)((function*(e,o){var t=e.hash,n=e.diff,s=e.pdiff,l=e.full,p=e.paths,c=void 0===p?[]:p,u=e.name,h=e.description,f=void 0===h?'':h,w=e.metaInfo;if(y.options.beforeDownloadUpdate&&!1===(yield y.options.beforeDownloadUpdate(e)))(0,r(d[8]).log)('beforeDownloadUpdate \u8fd4\u56de false, \u5ffd\u7565\u4e0b\u8f7d');else if(e.update&&t)if(r(d[7]).rolledBackVersion!==t){if(y.downloadedHash===t)return(0,r(d[8]).log)(`duplicated downloaded hash ${y.downloadedHash}, ignored`),y.downloadedHash;if(!y.progressHandlers[t]){o&&(y.progressHandlers[t]=r(d[7]).pushyNativeEventEmitter.addListener('RCTPushyDownloadProgress',(function(e){e.hash===t&&o(e)})));var k,v='';y.report({type:'downloading'});var P=yield(0,r(d[8]).testUrls)((0,r(d[8]).joinUrls)(c,n));if(P){(0,r(d[8]).log)('downloading diff');try{yield r(d[7]).PushyModule.downloadPatchFromPpk({updateUrl:P,hash:t,originHash:r(d[7]).currentVersion}),v='diff'}catch(e){k=e,(0,r(d[8]).log)(`diff error: ${e.message}, try pdiff`)}}var b=yield(0,r(d[8]).testUrls)((0,r(d[8]).joinUrls)(c,s));if(!v&&b){(0,r(d[8]).log)('downloading pdiff');try{yield r(d[7]).PushyModule.downloadPatchFromPackage({updateUrl:b,hash:t}),v='pdiff'}catch(e){k=e,(0,r(d[8]).log)(`pdiff error: ${e.message}, try full patch`)}}var U=yield(0,r(d[8]).testUrls)((0,r(d[8]).joinUrls)(c,l));if(!v&&U){(0,r(d[8]).log)('downloading full patch');try{yield r(d[7]).PushyModule.downloadFullUpdate({updateUrl:U,hash:t}),v='full'}catch(e){k=e,(0,r(d[8]).log)(`full patch error: ${e.message}`)}}if(y.progressHandlers[t]&&(y.progressHandlers[t].remove(),delete y.progressHandlers[t]),v)return y.report({type:'downloadSuccess',data:{newVersion:t,diff:v}}),(0,r(d[8]).log)(`downloaded ${v} hash:`,t),(0,r(d[7]).setLocalHashInfo)(t,{name:u,description:f,metaInfo:w}),y.downloadedHash=t,t;if(y.report({type:'errorUpdate',data:{newVersion:t}}),k)throw k}}else(0,r(d[8]).log)(`rolledback hash ${r(d[7]).rolledBackVersion}, ignored`)}));return function(o,t){return e.apply(this,arguments)}})(),this.downloadAndInstallApk=(function(){var e=(0,o.default)((function*(e,o){if('android'===l.Platform.OS){if(y.report({type:'downloadingApk'}),l.Platform.Version<=23)try{if((yield r(d[9]).PermissionsAndroid.request(r(d[9]).PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE))!==r(d[9]).PermissionsAndroid.RESULTS.GRANTED)return y.report({type:'rejectStoragePermission'}),void y.throwIfEnabled(new Error('rejectStoragePermission'))}catch(e){return y.report({type:'errorStoragePermission'}),void y.throwIfEnabled(e)}var t='downloadingApk';o&&(y.progressHandlers[t]&&y.progressHandlers[t].remove(),y.progressHandlers[t]=r(d[7]).pushyNativeEventEmitter.addListener('RCTPushyDownloadProgress',(function(e){e.hash===t&&o(e)}))),yield r(d[7]).PushyModule.downloadAndInstallApk({url:e,target:'update.apk',hash:t}).catch((function(){y.report({type:'errorDownloadAndInstallApk'}),y.throwIfEnabled(new Error('errorDownloadAndInstallApk'))})),y.progressHandlers[t]&&(y.progressHandlers[t].remove(),delete y.progressHandlers[t])}}));return function(o,t){return e.apply(this,arguments)}})(),('ios'===l.Platform.OS||'android'===l.Platform.OS)&&!h.appKey)throw new Error('appKey is required');this.setOptions(h),r(d[7]).isRolledBack&&this.report({type:'rollback',data:{rolledBackVersion:r(d[7]).rolledBackVersion}})}))}),418,[3,6,289,24,13,12,1,419,421,425]); -__d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.downloadRootDir=e.currentVersion=e.cInfo=e.buildTime=e.PushyModule=void 0,e.getCurrentVersionInfo=function(){return h.apply(this,arguments)},e.rolledBackVersion=e.pushyNativeEventEmitter=e.packageVersion=e.isRolledBack=e.isFirstTime=void 0,e.setLocalHashInfo=function(o,n){s.setLocalHashInfo(o,JSON.stringify(n))};var o=r(d[0])(r(d[1])),n=r(d[2]),t=`${r(d[3]).version.major}.${r(d[3]).version.minor}.${r(d[3]).version.patch}`,u=null!=g.__turboModuleProxy,s=e.PushyModule='web'===n.Platform.OS?r(d[4]).emptyModule:u?r(d[5]).default:n.NativeModules.Pushy;if(!s)throw new Error('react-native-update \u6a21\u5757\u65e0\u6cd5\u52a0\u8f7d\uff0c\u8bf7\u5bf9\u7167\u5b89\u88c5\u6587\u6863\u68c0\u67e5\u914d\u7f6e\u3002');var l=u?s.getConstants():s,c=(e.downloadRootDir=l.downloadRootDir,e.packageVersion=l.packageVersion,e.currentVersion=l.currentVersion),f=(e.isFirstTime=l.isFirstTime,e.rolledBackVersion=l.rolledBackVersion),p=(e.isRolledBack='string'==typeof f,e.buildTime=l.buildTime,l.uuid);if('android'===n.Platform.OS&&!l.isUsingBundleUrl)throw new Error('react-native-update \u6a21\u5757\u65e0\u6cd5\u52a0\u8f7d\uff0c\u8bf7\u5bf9\u7167\u6587\u6863\u68c0\u67e5 Bundle URL \u7684\u914d\u7f6e');function v(o){return y.apply(this,arguments)}function y(){return(y=(0,o.default)((function*(o){return JSON.parse(yield s.getLocalHashInfo(o))}))).apply(this,arguments)}function h(){return(h=(0,o.default)((function*(){return c&&(yield v(c))||{}}))).apply(this,arguments)}e.pushyNativeEventEmitter=new n.NativeEventEmitter(s);p||(p=r(d[6]).nanoid(),s.setUuid(p)),(0,r(d[4]).log)('uuid: '+p);e.cInfo={pushy:r(d[7]).version,rn:t,os:n.Platform.OS+' '+n.Platform.Version,uuid:p}}),419,[3,289,1,420,421,422,423,424]); -__d((function(g,r,i,a,m,e,d){e.version={major:0,minor:72,patch:5,prerelease:null}}),420,[]); -__d((function(g,_r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.emptyModule=void 0,e.joinUrls=function(n,t){if(t)return n.map((function(n){return'https://'+n+'/'+t}))},e.log=function(){for(var n,t=arguments.length,r=new Array(t),u=0;u0&&void 0!==arguments[0]?arguments[0]:h.options.server.main}/checkUpdate/${h.options.appKey}`},this.markSuccess=function(){!e.marked&&r(d[8]).isFirstTime&&(e.marked=!0,r(d[8]).PushyModule.markSuccess(),h.report({type:'markSuccess'}))},this.switchVersion=(function(){var o=(0,t.default)((function*(o){if(e.assertHash(o)&&!e.applyingUpdate)return(0,r(d[7]).log)('switchVersion: '+o),e.applyingUpdate=!0,r(d[8]).PushyModule.reloadUpdate({hash:o})}));return function(e){return o.apply(this,arguments)}})(),this.switchVersionLater=(function(){var o=(0,t.default)((function*(o){if(e.assertHash(o))return(0,r(d[7]).log)('switchVersionLater: '+o),r(d[8]).PushyModule.setNeedUpdate({hash:o})}));return function(e){return o.apply(this,arguments)}})(),this.checkUpdate=(function(){var e=(0,t.default)((function*(e){if('web'!==p.Platform.OS){if(!h.options.beforeCheckUpdate||!1!==(yield h.options.beforeCheckUpdate())){var o=Date.now();if(h.lastRespJson&&h.lastChecking&&o-h.lastChecking<5e3)return yield h.lastRespJson;h.lastChecking=o;var t,n=Object.assign({packageVersion:r(d[8]).packageVersion,hash:r(d[8]).currentVersion,buildTime:r(d[8]).buildTime,cInfo:r(d[8]).cInfo},e),s=JSON.stringify(n),l={method:'POST',headers:{Accept:'application/json','Content-Type':'application/json'},body:s};try{h.report({type:'checking',message:h.options.appKey+': '+s}),t=yield fetch(h.getCheckUrl(),l)}catch(e){h.report({type:'errorChecking',message:'Can not connect to update server. Trying backup endpoints.'});var c=yield h.getBackupEndpoints();if(c)try{t=yield(0,r(d[7]).promiseAny)(c.map((function(e){return fetch(h.getCheckUrl(e),l)})))}catch(e){h.throwIfEnabled(new Error('errorCheckingUseBackup'))}else h.throwIfEnabled(new Error('errorCheckingGetBackup'))}if(!t)return h.report({type:'errorChecking',message:'Can not connect to update server. Please check your network.'}),h.throwIfEnabled(new Error('errorChecking')),h.lastRespJson?yield h.lastRespJson:r(d[7]).emptyObj;h.lastRespJson=t.json();var u=yield h.lastRespJson;return(0,r(d[7]).log)('checking result:',u),200!==t.status&&(h.report({type:'errorChecking',message:u.message}),h.throwIfEnabled(new Error(u.message))),u}(0,r(d[7]).log)('beforeCheckUpdate \u8fd4\u56de false, \u5ffd\u7565\u68c0\u67e5')}else console.warn('web \u7aef\u4e0d\u652f\u6301\u70ed\u66f4\u65b0\u68c0\u67e5')}));return function(o){return e.apply(this,arguments)}})(),this.getBackupEndpoints=(0,t.default)((function*(){var e=h.options.server;if(!e)return[];if(e.queryUrls)try{var t=yield(0,r(d[7]).promiseAny)(e.queryUrls.map((function(e){return fetch(e)}))),n=yield t.json();(0,r(d[7]).log)('fetch endpoints:',n),Array.isArray(n)&&(e.backups=Array.from(new Set([].concat((0,o.default)(e.backups||[]),(0,o.default)(n)))))}catch(o){(0,r(d[7]).log)('failed to fetch endpoints from: ',e.queryUrls)}return e.backups})),this.downloadUpdate=(function(){var o=(0,t.default)((function*(o,t){var n=o.hash,s=o.diff,l=o.pdiff,p=o.full,c=o.paths,u=void 0===c?[]:c,f=o.name,y=o.description,w=void 0===y?'':y,k=o.metaInfo;if(h.options.beforeDownloadUpdate&&!1===(yield h.options.beforeDownloadUpdate(o)))(0,r(d[7]).log)('beforeDownloadUpdate \u8fd4\u56de false, \u5ffd\u7565\u4e0b\u8f7d');else if(o.update&&n)if(r(d[8]).rolledBackVersion!==n){if(e.downloadedHash===n)return(0,r(d[7]).log)(`duplicated downloaded hash ${e.downloadedHash}, ignored`),e.downloadedHash;if(!e.progressHandlers[n]){t&&(e.progressHandlers[n]=r(d[8]).pushyNativeEventEmitter.addListener('RCTPushyDownloadProgress',(function(e){e.hash===n&&t(e)})));var v,b='';h.report({type:'downloading'});var P=yield(0,r(d[7]).testUrls)((0,r(d[7]).joinUrls)(u,s));if(P){(0,r(d[7]).log)('downloading diff');try{yield r(d[8]).PushyModule.downloadPatchFromPpk({updateUrl:P,hash:n,originHash:r(d[8]).currentVersion}),b='diff'}catch(e){v=e,(0,r(d[7]).log)(`diff error: ${e.message}, try pdiff`)}}var U=yield(0,r(d[7]).testUrls)((0,r(d[7]).joinUrls)(u,l));if(!b&&U){(0,r(d[7]).log)('downloading pdiff');try{yield r(d[8]).PushyModule.downloadPatchFromPackage({updateUrl:U,hash:n}),b='pdiff'}catch(e){v=e,(0,r(d[7]).log)(`pdiff error: ${e.message}, try full patch`)}}var E=yield(0,r(d[7]).testUrls)((0,r(d[7]).joinUrls)(u,p));if(!b&&E){(0,r(d[7]).log)('downloading full patch');try{yield r(d[8]).PushyModule.downloadFullUpdate({updateUrl:E,hash:n}),b='full'}catch(e){v=e,(0,r(d[7]).log)(`full patch error: ${e.message}`)}}if(e.progressHandlers[n]&&(e.progressHandlers[n].remove(),delete e.progressHandlers[n]),b)return h.report({type:'downloadSuccess',data:{newVersion:n,diff:b}}),(0,r(d[7]).log)(`downloaded ${b} hash:`,n),(0,r(d[8]).setLocalHashInfo)(n,{name:f,description:w,metaInfo:k}),e.downloadedHash=n,n;if(h.report({type:'errorUpdate',data:{newVersion:n}}),v)throw v}}else(0,r(d[7]).log)(`rolledback hash ${r(d[8]).rolledBackVersion}, ignored`)}));return function(e,t){return o.apply(this,arguments)}})(),this.downloadAndInstallApk=(function(){var o=(0,t.default)((function*(o,t){if('android'===p.Platform.OS&&'downloading'!==e.apkStatus){if('downloaded'===e.apkStatus)return h.report({type:'errorInstallApk'}),void h.throwIfEnabled(new Error('errorInstallApk'));if(p.Platform.Version<=23)try{if((yield r(d[9]).PermissionsAndroid.request(r(d[9]).PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE))!==r(d[9]).PermissionsAndroid.RESULTS.GRANTED)return h.report({type:'rejectStoragePermission'}),void h.throwIfEnabled(new Error('rejectStoragePermission'))}catch(e){return h.report({type:'errorStoragePermission'}),void h.throwIfEnabled(e)}e.apkStatus='downloading',h.report({type:'downloadingApk'});var n='downloadingApk';t&&(e.progressHandlers[n]&&e.progressHandlers[n].remove(),e.progressHandlers[n]=r(d[8]).pushyNativeEventEmitter.addListener('RCTPushyDownloadProgress',(function(e){e.hash===n&&t(e)}))),yield r(d[8]).PushyModule.downloadAndInstallApk({url:o,target:'update.apk',hash:n}).catch((function(){e.apkStatus=null,h.report({type:'errorDownloadAndInstallApk'}),h.throwIfEnabled(new Error('errorDownloadAndInstallApk'))})),e.apkStatus='downloaded',e.progressHandlers[n]&&(e.progressHandlers[n].remove(),delete e.progressHandlers[n])}}));return function(e,t){return o.apply(this,arguments)}})(),('ios'===p.Platform.OS||'android'===p.Platform.OS)&&!s.appKey)throw new Error('appKey is required');this.setOptions(s),r(d[8]).isRolledBack&&this.report({type:'rollback',data:{rolledBackVersion:r(d[8]).rolledBackVersion}})}));e=u,u.progressHandlers={},u.apkStatus=null,u.marked=!1,u.applyingUpdate=!1,u.assertHash=function(o){if(e.downloadedHash){if(o===e.downloadedHash)return!0;(0,r(d[7]).log)(`use downloaded hash ${e.downloadedHash} first`)}}}),418,[3,6,289,24,13,12,1,419,420,425]); +__d((function(g,_r,i,a,m,_e,d){Object.defineProperty(_e,"__esModule",{value:!0}),_e.emptyObj=_e.emptyModule=void 0,_e.joinUrls=function(n,t){if(t)return n.map((function(n){return'https://'+n+'/'+t}))},_e.log=o,_e.noop=void 0,_e.promiseAny=u,_e.testUrls=void 0;var n=_r(d[0])(_r(d[1])),t=_r(d[0])(_r(d[2])),e=_r(d[0])(_r(d[3])),r=_r(d[4]);function o(){for(var n,t=arguments.length,e=new Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:21;return function(){for(var o='',i=0|(arguments.length>0&&void 0!==arguments[0]?arguments[0]:t);i--;)o+=n[Math.random()*n.length|0];return o}},e.nanoid=function(){for(var n='',t=0|(arguments.length>0&&void 0!==arguments[0]?arguments[0]:21);t--;)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return n}}),423,[]); -__d((function(e,t,a,i,s,r,n){s.exports={name:"react-native-update",version:"10.15.1",description:"react-native hot update",main:"src/index",scripts:{prepack:"yarn submodule && yarn lint",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":"yarn submodule && $ANDROID_HOME/ndk/20.1.5948944/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 && yarn && detox build --configuration ios.sim.debug","build:ios-release":"cd Example/testHotUpdate && yarn && detox build --configuration ios.sim.release","test:ios-debug":"cd Example/testHotUpdate && detox test --configuration ios.sim.debug","test:ios-release":"cd Example/testHotUpdate && yarn detox test --configuration ios.sim.release","build:android-debug":"cd Example/testHotUpdate && yarn && detox build --configuration android.emu.debug","build:android-release":"cd Example/testHotUpdate && yarn && detox build --configuration android.emu.release","test:android-release":"cd Example/testHotUpdate && yarn detox test --configuration android.emu.release --headless --record-logs all","test:android-debug":"cd Example/testHotUpdate && detox test --configuration android.emu.debug --headless --record-logs all","e2e:ios":"npm run build:ios-release && npm run test:ios-release","e2e:android":"npm run build:android-release && npm run test:android-release","tests:emulator:prepare":"cd .github/workflows/scripts/functions && yarn && yarn build","tests:emulator:start-ci":"yarn tests:emulator:prepare && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh","tests:packager:jet-ci":"cd Example/testHotUpdate && cross-env TMPDIR=$HOME/.metro REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --no-interactive","tests:ios:pod:install":"cd Example/testHotUpdate && yarn && yarn pod-install"},repository:{type:"git",url:"git+https://github.com/reactnativecn/react-native-pushy.git"},keywords:["react-native","ios","android","update"],author:"reactnativecn",license:"MIT",bugs:{url:"https://github.com/reactnativecn/react-native-pushy/issues"},peerDependencies:{react:">=16.8.0","react-native":">=0.59.0"},homepage:"https://github.com/reactnativecn/react-native-pushy#readme",dependencies:{nanoid:"^3.3.3","react-native-url-polyfill":"^2.0.0"},codegenConfig:{name:"RCTPushySpec",type:"modules",jsSrcsDir:"src"},devDependencies:{"@babel/core":"^7.25.8","@react-native/babel-preset":"^0.73.21","@react-native/eslint-config":"^0.73.2","@react-native/typescript-config":"^0.74.0","@types/fs-extra":"^11.0.4","@types/jest":"^29.5.13","@types/node":"^22.7.6","@types/react":"^18.3.11",detox:"^20.27.3",eslint:"^8.57.0","eslint-plugin-ft-flow":"^3.0.7","firebase-tools":"^13.22.1","fs-extra":"^11.2.0",jest:"^29.7.0","pod-install":"^0.2.2",prettier:"^3",react:"18.2.0","react-native":"0.73","ts-jest":"^29.2.5",typescript:"^5.6.3"}}}),424,[]); +__d((function(e,t,a,i,s,r,n){s.exports={name:"react-native-update",version:"10.19.6",description:"react-native hot update",main:"src/index",scripts:{prepack:"yarn submodule && yarn lint",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":"yarn submodule && $ANDROID_HOME/ndk/20.1.5948944/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 && yarn && detox build --configuration ios.sim.debug","build:ios-release":"cd Example/testHotUpdate && yarn && detox build --configuration ios.sim.release","test:ios-debug":"cd Example/testHotUpdate && detox test --configuration ios.sim.debug","test:ios-release":"cd Example/testHotUpdate && yarn detox test --configuration ios.sim.release","build:android-debug":"cd Example/testHotUpdate && yarn && detox build --configuration android.emu.debug","build:android-release":"cd Example/testHotUpdate && yarn && detox build --configuration android.emu.release","test:android-release":"cd Example/testHotUpdate && yarn detox test --configuration android.emu.release --headless --record-logs all","test:android-debug":"cd Example/testHotUpdate && detox test --configuration android.emu.debug --headless --record-logs all","e2e:ios":"npm run build:ios-release && npm run test:ios-release","e2e:android":"npm run build:android-release && npm run test:android-release","tests:emulator:prepare":"cd .github/workflows/scripts/functions && yarn && yarn build","tests:emulator:start-ci":"yarn tests:emulator:prepare && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh","tests:packager:jet-ci":"cd Example/testHotUpdate && cross-env TMPDIR=$HOME/.metro REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --no-interactive","tests:ios:pod:install":"cd Example/testHotUpdate && yarn && yarn pod-install"},repository:{type:"git",url:"git+https://github.com/reactnativecn/react-native-pushy.git"},keywords:["react-native","ios","android","update"],author:"reactnativecn",license:"MIT",bugs:{url:"https://github.com/reactnativecn/react-native-pushy/issues"},peerDependencies:{react:">=16.8.0","react-native":">=0.59.0"},homepage:"https://github.com/reactnativecn/react-native-pushy#readme",dependencies:{nanoid:"^3.3.3","react-native-url-polyfill":"^2.0.0"},codegenConfig:{name:"RCTPushySpec",type:"modules",jsSrcsDir:"src"},devDependencies:{"@babel/core":"^7.25.8","@react-native/babel-preset":"^0.73.21","@react-native/eslint-config":"^0.73.2","@react-native/typescript-config":"^0.74.0","@types/fs-extra":"^11.0.4","@types/jest":"^29.5.13","@types/node":"^22.7.6","@types/react":"^18.3.11",detox:"^20.27.3",eslint:"^8.57.0","eslint-plugin-ft-flow":"^3.0.7","firebase-tools":"^13.22.1","fs-extra":"^11.2.0",jest:"^29.7.0","pod-install":"^0.2.2",prettier:"^2",react:"18.2.0","react-native":"0.73","ts-jest":"^29.2.5",typescript:"^5.6.3"},packageManager:"yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"}}),424,[]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"PermissionsAndroid",{enumerable:!0,get:function(){return n.PermissionsAndroid}});var n=r(d[0])}),425,[1]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.usePushy=e.defaultContext=e.PushyContext=void 0;var t=r(d[0]),n=function(){},o=function(){return Promise.resolve()},s=e.defaultContext={checkUpdate:o,switchVersion:o,switchVersionLater:o,markSuccess:n,dismissError:n,downloadUpdate:o,downloadAndInstallApk:o,getCurrentVersionInfo:function(){return Promise.resolve({})},parseTestQrCode:function(){return!1},currentHash:'',packageVersion:''},u=e.PushyContext=(0,t.createContext)(s);e.usePushy=function(){return(0,t.useContext)(u)}}),426,[143]); -__d((function(g,_r,_i,_a,m,_e,d){Object.defineProperty(_e,"__esModule",{value:!0}),_e.PushyProvider=void 0;var e=_r(d[0])(_r(d[1])),t=_r(d[0])(_r(d[2])),r=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=a(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=o?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,r&&r.set(e,n),n})(_r(d[3])),n=_r(d[4]);function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(a=function(e){return e?r:t})(e)}_e.PushyProvider=function(a){var o=a.client,u=a.children,i=o.options,l=(0,r.useRef)(),s=(0,r.useState)(),c=(0,t.default)(s,2),f=c[0],p=c[1],y=(0,r.useRef)(f),h=(0,r.useState)(),v=(0,t.default)(h,2),k=v[0],w=v[1],S=(0,r.useState)(),A=(0,t.default)(S,2),P=A[0],b=A[1],L=(0,r.useRef)(0),C=(0,r.useCallback)((function(e){if(i.throwError)throw e}),[i.throwError]),V=(0,r.useCallback)((function(){b(void 0)}),[]),_=(0,r.useCallback)((function(){'alwaysAlert'!==i.updateStrategy&&'alertUpdateAndIgnoreError'!==i.updateStrategy||n.Alert.alert.apply(n.Alert,arguments)}),[i.updateStrategy]),O=(0,r.useCallback)((function(){'alwaysAlert'===i.updateStrategy&&n.Alert.alert.apply(n.Alert,arguments)}),[i.updateStrategy]),x=(0,r.useCallback)((0,e.default)((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y.current;if(e&&e.hash)return o.switchVersion(e.hash)})),[o]),E=(0,r.useCallback)((0,e.default)((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y.current;if(e&&e.hash)return o.switchVersionLater(e.hash)})),[o]),U=(0,r.useCallback)((0,e.default)((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y.current;if(e&&e.update)try{var t=yield o.downloadUpdate(e,w);if(!t)return;if(l.current&&l.current.remove(),'silentAndNow'===i.updateStrategy)return o.switchVersion(t);if('silentAndLater'===i.updateStrategy)return o.switchVersionLater(t);_('\u63d0\u793a','\u4e0b\u8f7d\u5b8c\u6bd5\uff0c\u662f\u5426\u7acb\u5373\u66f4\u65b0?',[{text:'\u4e0b\u6b21\u518d\u8bf4',style:'cancel',onPress:function(){o.switchVersionLater(t)}},{text:'\u7acb\u5373\u66f4\u65b0',style:'default',onPress:function(){o.switchVersion(t)}}])}catch(e){b(e),O('\u66f4\u65b0\u5931\u8d25',e.message),C(e)}})),[o,i.updateStrategy,_,O,C]),R=(0,r.useCallback)((function(){var t=(0,e.default)((function*(e){'android'===n.Platform.OS&&e&&(yield o.downloadAndInstallApk(e,w))}));return function(e){return t.apply(this,arguments)}})(),[o]),I=(0,r.useCallback)((0,e.default)((function*(){var e,t,r,a=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).extra,u=Date.now();if(!(L.current&&u-L.current<1e3)){var l;L.current=u;try{l=yield o.checkUpdate(a)}catch(e){return b(e),O('\u66f4\u65b0\u68c0\u67e5\u5931\u8d25',e.message),void C(e)}if(l){var s=null==(e=l.config)||null==(t=e.rollout)?void 0:t[_r(d[5]).packageVersion];if(s){if(!(0,_r(d[6]).isInRollout)(s))return void(0,_r(d[7]).log)(`not in ${s}% rollout, ignored`);(0,_r(d[7]).log)(`in ${s}% rollout, continue`)}if(l.description=null!=(r=l.description)?r:'',y.current=l,p(l),l.expired){var c=l.downloadUrl;if(c){if('silentAndNow'===i.updateStrategy)return void('android'===n.Platform.OS&&c.endsWith('.apk')?R(c):n.Linking.openURL(c));_('\u63d0\u793a','\u60a8\u7684\u5e94\u7528\u7248\u672c\u5df2\u66f4\u65b0\uff0c\u70b9\u51fb\u66f4\u65b0\u4e0b\u8f7d\u5b89\u88c5\u65b0\u7248\u672c',[{text:'\u66f4\u65b0',onPress:function(){'android'===n.Platform.OS&&c.endsWith('.apk')?R(c):n.Linking.openURL(c)}}])}}else if(l.update){if('silentAndNow'===i.updateStrategy||'silentAndLater'===i.updateStrategy)return U(l);_('\u63d0\u793a','\u68c0\u67e5\u5230\u65b0\u7684\u7248\u672c'+l.name+',\u662f\u5426\u4e0b\u8f7d?\n'+l.description,[{text:'\u53d6\u6d88',style:'cancel'},{text:'\u786e\u5b9a',style:'default',onPress:function(){U()}}])}}}})),[o,O,C,i.updateStrategy,_,R,U]),j=o.markSuccess;(0,r.useEffect)((function(){var e,t=i.checkStrategy,r=i.dismissErrorAfter;return i.autoMarkSuccess&&j(),'both'!==t&&'onAppResume'!==t||(l.current=n.AppState.addEventListener('change',(function(e){'active'===e&&I()}))),'both'!==t&&'onAppStart'!==t||I(),'number'==typeof r&&r>0&&(e=setTimeout((function(){V()}),r)),function(){l.current&&l.current.remove(),clearTimeout(e)}}),[I,i,V,j]);var M=(0,r.useCallback)((function(e){if(e&&e.type&&e.type.startsWith('__rnPushy')){var t=i.logger||function(){};return i.logger=function(e){var r=e.type,a=e.data;t({type:r,data:a}),n.Alert.alert(r,JSON.stringify(a))},'__rnPushyVersionHash'===e.type&&I({extra:{toHash:e.data}}).then((function(){y.current&&y.current.upToDate&&n.Alert.alert('\u63d0\u793a','\u5f53\u524d\u5c1a\u672a\u68c0\u6d4b\u5230\u66f4\u65b0\u7248\u672c\uff0c\u5982\u679c\u662f\u9996\u6b21\u626b\u7801\uff0c\u8bf7\u7b49\u5f85\u670d\u52a1\u5668\u7aef\u751f\u6210\u8865\u4e01\u5305\u540e\u518d\u8bd5\uff08\u7ea610\u79d2\uff09'),i.logger=t})),!0}return!1}),[I,i]),W=(0,r.useCallback)((function(e){try{var t='string'==typeof e?JSON.parse(e):e;return M(t)}catch(e){return!1}}),[M]);return(0,r.useEffect)((function(){var e=function(e){if(e){var t=new(_r(d[8]).URL)(e).searchParams,r={type:t.get('type'),data:t.get('data')};M(r)}};n.Linking.getInitialURL().then(e);var t=n.Linking.addEventListener('url',(function(t){var r=t.url;return e(r)}));return function(){t.remove()}}),[M]),(0,_r(d[9]).jsx)(_r(d[10]).PushyContext.Provider,{value:{checkUpdate:I,switchVersion:x,switchVersionLater:E,dismissError:V,updateInfo:f,lastError:P,markSuccess:j,client:o,downloadUpdate:U,packageVersion:_r(d[5]).packageVersion,currentHash:_r(d[5]).currentVersion,progress:k,downloadAndInstallApk:R,getCurrentVersionInfo:_r(d[5]).getCurrentVersionInfo,parseTestQrCode:W},children:u})}}),427,[3,289,24,143,1,419,428,421,429,193,426]); -__d((function(g,r,_i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.isInRollout=function(o){return t%1001&&void 0!==arguments[1]?arguments[1]:0;for(o=3&t.length,c=t.length-o,n=C,u=3432918353,i=461845907,A=0;A>>17))*i+(((l>>>16)*i&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(h>>>16)&65535)<<16);switch(l=0,o){case 3:l^=(255&t.charCodeAt(A+2))<<16;case 2:l^=(255&t.charCodeAt(A+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(A)))*u+(((l>>>16)*u&65535)<<16)&4294967295)<<15|l>>>17))*i+(((l>>>16)*i&65535)<<16)&4294967295}return n^=t.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0})(r(d[0]).cInfo.uuid)}),428,[419]); +__d((function(g,_r,_i,_a,m,_e,d){Object.defineProperty(_e,"__esModule",{value:!0}),_e.PushyProvider=void 0;var e=_r(d[0])(_r(d[1])),t=_r(d[0])(_r(d[2])),r=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=a(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=o?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,r&&r.set(e,n),n})(_r(d[3])),n=_r(d[4]);function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(a=function(e){return e?r:t})(e)}_e.PushyProvider=function(a){var o=a.client,u=a.children,i=o.options,l=(0,r.useRef)(),s=(0,r.useState)(),c=(0,t.default)(s,2),f=c[0],p=c[1],y=(0,r.useRef)(f),h=(0,r.useState)(),v=(0,t.default)(h,2),k=v[0],w=v[1],S=(0,r.useState)(),A=(0,t.default)(S,2),P=A[0],b=A[1],L=(0,r.useRef)(0),C=(0,r.useCallback)((function(e){if(i.throwError)throw e}),[i.throwError]),V=(0,r.useCallback)((function(){b(void 0)}),[]),_=(0,r.useCallback)((function(){'alwaysAlert'!==i.updateStrategy&&'alertUpdateAndIgnoreError'!==i.updateStrategy||n.Alert.alert.apply(n.Alert,arguments)}),[i.updateStrategy]),O=(0,r.useCallback)((function(){'alwaysAlert'===i.updateStrategy&&n.Alert.alert.apply(n.Alert,arguments)}),[i.updateStrategy]),x=(0,r.useCallback)((0,e.default)((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y.current;if(e&&e.hash)return o.switchVersion(e.hash)})),[o]),E=(0,r.useCallback)((0,e.default)((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y.current;if(e&&e.hash)return o.switchVersionLater(e.hash)})),[o]),U=(0,r.useCallback)((0,e.default)((function*(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y.current;if(!e||!e.update)return!1;try{var t=yield o.downloadUpdate(e,w);return!!t&&(l.current&&l.current.remove(),'silentAndNow'===i.updateStrategy?(o.switchVersion(t),!0):'silentAndLater'===i.updateStrategy?(o.switchVersionLater(t),!0):(_('\u63d0\u793a','\u4e0b\u8f7d\u5b8c\u6bd5\uff0c\u662f\u5426\u7acb\u5373\u66f4\u65b0?',[{text:'\u4e0b\u6b21\u518d\u8bf4',style:'cancel',onPress:function(){o.switchVersionLater(t)}},{text:'\u7acb\u5373\u66f4\u65b0',style:'default',onPress:function(){o.switchVersion(t)}}]),!0))}catch(e){return b(e),O('\u66f4\u65b0\u5931\u8d25',e.message),C(e),!1}})),[o,i.updateStrategy,_,O,C]),R=(0,r.useCallback)((function(){var t=(0,e.default)((function*(e){'android'===n.Platform.OS&&e&&(yield o.downloadAndInstallApk(e,w))}));return function(e){return t.apply(this,arguments)}})(),[o]),I=(0,r.useCallback)((0,e.default)((function*(){var e,t,r,a=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).extra,u=Date.now();if(!(L.current&&u-L.current<1e3)){var l;L.current=u;try{l=yield o.checkUpdate(a)}catch(e){return b(e),O('\u66f4\u65b0\u68c0\u67e5\u5931\u8d25',e.message),void C(e)}if(l){var s=null==(e=l.config)||null==(t=e.rollout)?void 0:t[_r(d[5]).packageVersion];if(s){if(!(0,_r(d[6]).isInRollout)(s))return void(0,_r(d[7]).log)(`not in ${s}% rollout, ignored`);(0,_r(d[7]).log)(`in ${s}% rollout, continue`)}if(l.description=null!=(r=l.description)?r:'',y.current=l,p(l),l.expired){var c=l.downloadUrl;if(c){if('silentAndNow'===i.updateStrategy)return void('android'===n.Platform.OS&&c.endsWith('.apk')?R(c):n.Linking.openURL(c));_('\u63d0\u793a','\u60a8\u7684\u5e94\u7528\u7248\u672c\u5df2\u66f4\u65b0\uff0c\u70b9\u51fb\u66f4\u65b0\u4e0b\u8f7d\u5b89\u88c5\u65b0\u7248\u672c',[{text:'\u66f4\u65b0',onPress:function(){'android'===n.Platform.OS&&c.endsWith('.apk')?R(c):n.Linking.openURL(c)}}])}}else if(l.update){if('silentAndNow'===i.updateStrategy||'silentAndLater'===i.updateStrategy)return void U(l);_('\u63d0\u793a','\u68c0\u67e5\u5230\u65b0\u7684\u7248\u672c'+l.name+',\u662f\u5426\u4e0b\u8f7d?\n'+l.description,[{text:'\u53d6\u6d88',style:'cancel'},{text:'\u786e\u5b9a',style:'default',onPress:function(){U()}}])}}}})),[o,O,C,i.updateStrategy,_,R,U]),j=o.markSuccess;(0,r.useEffect)((function(){var e,t=i.checkStrategy,r=i.dismissErrorAfter;return i.autoMarkSuccess&&j(),'both'!==t&&'onAppResume'!==t||(l.current=n.AppState.addEventListener('change',(function(e){'active'===e&&I()}))),'both'!==t&&'onAppStart'!==t||I(),'number'==typeof r&&r>0&&(e=setTimeout((function(){V()}),r)),function(){l.current&&l.current.remove(),clearTimeout(e)}}),[I,i,V,j]);var M=(0,r.useCallback)((function(e){if(e&&e.type&&e.type.startsWith('__rnPushy')){var t=i.logger||function(){};return i.logger=function(e){var r=e.type,a=e.data;t({type:r,data:a}),n.Alert.alert(r,JSON.stringify(a))},'__rnPushyVersionHash'===e.type&&I({extra:{toHash:e.data}}).then((function(){y.current&&y.current.upToDate&&n.Alert.alert('\u63d0\u793a','\u5f53\u524d\u5c1a\u672a\u68c0\u6d4b\u5230\u66f4\u65b0\u7248\u672c\uff0c\u5982\u679c\u662f\u9996\u6b21\u626b\u7801\uff0c\u8bf7\u7b49\u5f85\u670d\u52a1\u5668\u7aef\u751f\u6210\u8865\u4e01\u5305\u540e\u518d\u8bd5\uff08\u7ea610\u79d2\uff09'),i.logger=t})),!0}return!1}),[I,i]),W=(0,r.useCallback)((function(e){try{var t='string'==typeof e?JSON.parse(e):e;return M(t)}catch(e){return!1}}),[M]);return(0,r.useEffect)((function(){var e=function(e){if(e){var t=new(_r(d[8]).URL)(e).searchParams,r={type:t.get('type'),data:t.get('data')};M(r)}};n.Linking.getInitialURL().then(e);var t=n.Linking.addEventListener('url',(function(t){var r=t.url;return e(r)}));return function(){t.remove()}}),[M]),(0,_r(d[9]).jsx)(_r(d[10]).PushyContext.Provider,{value:{checkUpdate:I,switchVersion:x,switchVersionLater:E,dismissError:V,updateInfo:f,lastError:P,markSuccess:j,client:o,downloadUpdate:U,packageVersion:_r(d[5]).packageVersion,currentHash:_r(d[5]).currentVersion,progress:k,downloadAndInstallApk:R,getCurrentVersionInfo:_r(d[5]).getCurrentVersionInfo,parseTestQrCode:W},children:u})}}),427,[3,289,24,143,1,420,428,419,429,193,426]); +__d((function(g,r,_i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.isInRollout=function(o){return t%1001&&void 0!==arguments[1]?arguments[1]:0;for(o=3&t.length,c=t.length-o,n=C,u=3432918353,i=461845907,A=0;A>>17))*i+(((l>>>16)*i&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(h>>>16)&65535)<<16);switch(l=0,o){case 3:l^=(255&t.charCodeAt(A+2))<<16;case 2:l^=(255&t.charCodeAt(A+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(A)))*u+(((l>>>16)*u&65535)<<16)&4294967295)<<15|l>>>17))*i+(((l>>>16)*i&65535)<<16)&4294967295}return n^=t.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0})(r(d[0]).cInfo.uuid)}),428,[420]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0});var t={setupURLPolyfill:!0};e.setupURLPolyfill=function(){globalThis.REACT_NATIVE_URL_POLYFILL=`${l.default.name}@${l.default.version}`,globalThis.URL=r(d[3]).URL,globalThis.URLSearchParams=r(d[4]).URLSearchParams},r(d[0]);var l=r(d[1])(r(d[2]));Object.keys(r(d[3])).forEach((function(l){"default"!==l&&"__esModule"!==l&&(Object.prototype.hasOwnProperty.call(t,l)||l in e&&e[l]===r(d[3])[l]||Object.defineProperty(e,l,{enumerable:!0,get:function(){return r(d[3])[l]}}))})),Object.keys(r(d[4])).forEach((function(l){"default"!==l&&"__esModule"!==l&&(Object.prototype.hasOwnProperty.call(t,l)||l in e&&e[l]===r(d[4])[l]||Object.defineProperty(e,l,{enumerable:!0,get:function(){return r(d[4])[l]}}))}))}),429,[430,3,431,432,447]); __d((function(g,r,i,a,m,e,d){var t=r(d[0]),n=parseInt(t.Platform.Version,10);'ios'===t.Platform.OS&&10===n&&null==Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,'byteLength')&&Object.defineProperty(ArrayBuffer.prototype,'byteLength',{configurable:!0,enumerable:!1,get:function(){return null}})}),430,[1]); __d((function(e,t,i,r,a,n,l){a.exports={name:"react-native-url-polyfill",version:"2.0.0",description:"A lightweight and trustworthy URL polyfill for React Native",keywords:["URL","URLSearchParams","polyfill","react native","whatwg-url"],bugs:{url:"https://github.com/charpeni/react-native-url-polyfill/issues"},homepage:"https://github.com/charpeni/react-native-url-polyfill",readme:"https://github.com/charpeni/react-native-url-polyfill#readme",repository:{type:"git",url:"https://github.com/charpeni/react-native-url-polyfill.git"},main:"index.js",types:"index.d.ts",scripts:{test:"jest",lint:"eslint .",prepare:"husky install","bundle-size":"node scripts/bundle-size"},author:"Nicolas Charpentier ",license:"MIT",dependencies:{"whatwg-url-without-unicode":"8.0.0-3"},devDependencies:{"@react-native-community/eslint-config":"3.2.0",detox:"20.9.1",eslint:"8.44.0","eslint-plugin-prettier":"4.2.1",husky:"8.0.3",jest:"29.5.0","lint-staged":"13.2.3","metro-react-native-babel-preset":"0.76.7",nanoid:"3.3.6",prettier:"2.8.8",react:"18.2.0","react-native":"0.72.1","react-native-bundle-scale":"1.1.0",typescript:"5.1.6"},peerDependencies:{"react-native":"*"},jest:{preset:"react-native",testPathIgnorePatterns:["/node_modules/","./platforms/"]},"lint-staged":{"*.js":["eslint --fix"]}}}),431,[]); @@ -451,7 +451,7 @@ __d((function(g,r,_i,a,m,e,d){"use strict";var t=Object.create(r(d[0]).IteratorP __d((function(g,r,_i,_a,m,e,d){"use strict";e.implementation=(function(){return r(d[2])((function t(i,s,n){var l=n.doNotStripQMark,u=void 0!==l&&l;r(d[0])(this,t);var o=s[0];if(this._list=[],this._url=null,u||"string"!=typeof o||"?"!==o[0]||(o=o.slice(1)),Array.isArray(o))for(var a of o){if(2!==a.length)throw new TypeError("Failed to construct 'URLSearchParams': parameter 1 sequence's element does not contain exactly two elements.");this._list.push([a[0],a[1]])}else if("object"==typeof o&&null===Object.getPrototypeOf(o))for(var h of Object.keys(o)){var f=o[h];this._list.push([h,f])}else this._list=r(d[1]).parseUrlencoded(o)}),[{key:"_updateSteps",value:function(){if(null!==this._url){var t=r(d[1]).serializeUrlencoded(this._list);""===t&&(t=null),this._url._url.query=t}}},{key:"append",value:function(t,i){this._list.push([t,i]),this._updateSteps()}},{key:"delete",value:function(t){for(var i=0;ii[0]},t.map((function(t,i){return{item:t,index:i}})).sort((function(t,s){return i(t.item,s.item)||t.index-s.index})).map((function(t){return t.item}))),this._updateSteps()}},{key:Symbol.iterator,value:function(){return this._list[Symbol.iterator]()}},{key:"toString",value:function(){return r(d[1]).serializeUrlencoded(this._list)}}])})()}),445,[12,443,13]); __d((function(g,r,_i,_a,m,_e,_d){"use strict";function n(n,t){return`${t&&t.context?t.context:"Value"} ${n}.`}function t(n){if(null===n)return"Null";switch(typeof n){case"undefined":return"Undefined";case"boolean":return"Boolean";case"number":return"Number";case"string":return"String";case"symbol":return"Symbol";default:return"Object"}}function e(n){return a(n>0&&n%1==.5&&!(1&n)||n<0&&n%1==-.5&&!(1&~n)?Math.floor(n):Math.round(n))}function o(n){return a(Math.trunc(n))}function i(n){return n<0?-1:1}function u(n,t){var e=n%t;return i(t)!==i(e)?e+t:e}function a(n){return 0===n?0:n}function f(t,i){var f,c,s=!i.unsigned;64===t?(c=Math.pow(2,53)-1,f=s?1-Math.pow(2,53):0):s?(f=-Math.pow(2,t-1),c=Math.pow(2,t-1)-1):(f=0,c=Math.pow(2,t)-1);var l=Math.pow(2,t),y=Math.pow(2,t-1);return function(t,i){void 0===i&&(i={});var w=+t;if(w=a(w),i.enforceRange){if(!Number.isFinite(w))throw new TypeError(n("is not a finite number",i));if((w=o(w))c)throw new TypeError(n(`is outside the accepted range of ${f} to ${c}, inclusive`,i));return w}return!Number.isNaN(w)&&i.clamp?w=e(w=Math.min(Math.max(w,f),c)):Number.isFinite(w)&&0!==w?(w=o(w))>=f&&w<=c?w:(w=u(w,l),s&&w>=y?w-l:w):0}}function c(t,e){if("function"!=typeof t)throw new TypeError(n("is not a function",e));return t}_e.any=function(n){return n},_e.void=function(){},_e.boolean=function(n){return!!n},_e.byte=f(8,{unsigned:!1}),_e.octet=f(8,{unsigned:!0}),_e.short=f(16,{unsigned:!1}),_e["unsigned short"]=f(16,{unsigned:!0}),_e.long=f(32,{unsigned:!1}),_e["unsigned long"]=f(32,{unsigned:!0}),_e["long long"]=f(64,{unsigned:!1}),_e["unsigned long long"]=f(64,{unsigned:!0}),_e.double=function(t,e){var o=+t;if(!Number.isFinite(o))throw new TypeError(n("is not a finite floating-point value",e));return o},_e["unrestricted double"]=function(n){return+n},_e.float=function(t,e){var o=+t;if(!Number.isFinite(o))throw new TypeError(n("is not a finite floating-point value",e));if(Object.is(o,-0))return o;var i=Math.fround(o);if(!Number.isFinite(i))throw new TypeError(n("is outside the range of a single-precision floating-point value",e));return i},_e["unrestricted float"]=function(n){var t=+n;return isNaN(t)||Object.is(t,-0)?t:Math.fround(t)},_e.DOMString=function(t,e){if(void 0===e&&(e={}),e.treatNullAsEmptyString&&null===t)return"";if("symbol"==typeof t)throw new TypeError(n("is a symbol, which cannot be converted to a string",e));return String(t)},_e.ByteString=function(t,e){for(var o,i=_e.DOMString(t,e),u=0;void 0!==(o=i.codePointAt(u));++u)if(o>255)throw new TypeError(n("is not a valid ByteString",e));return i},_e.USVString=function(n,t){for(var e=_e.DOMString(n,t),o=e.length,i=[],u=0;u57343)i.push(String.fromCodePoint(a));else if(56320<=a&&a<=57343)i.push(String.fromCodePoint(65533));else if(u===o-1)i.push(String.fromCodePoint(65533));else{var f=e.charCodeAt(u+1);if(56320<=f&&f<=57343){var c=1023&a,s=1023&f;i.push(String.fromCodePoint(65536+1024*c+s)),++u}else i.push(String.fromCodePoint(65533))}}return i.join("")},_e.object=function(e,o){if("Object"!==t(e))throw new TypeError(n("is not an object",o));return e};var s=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get;function l(n){try{return s.call(n),!0}catch(n){return!1}}_e.ArrayBuffer=function(t,e){if(!l(t))throw new TypeError(n("is not a view on an ArrayBuffer object",e));return t};var y=Object.getOwnPropertyDescriptor(DataView.prototype,"byteLength").get;_e.DataView=function(t,e){try{return y.call(t),t}catch(t){throw new TypeError(n("is not a view on an DataView object",e))}},[Int8Array,Int16Array,Int32Array,Uint8Array,Uint16Array,Uint32Array,Uint8ClampedArray,Float32Array,Float64Array].forEach((function(t){var e=t.name,o=/^[AEIOU]/.test(e)?"an":"a";_e[e]=function(t,i){if(!ArrayBuffer.isView(t)||t.constructor.name!==e)throw new TypeError(n(`is not ${o} ${e} object`,i));return t}})),_e.ArrayBufferView=function(t,e){if(!ArrayBuffer.isView(t))throw new TypeError(n("is not a view on an ArrayBuffer object",e));return t},_e.BufferSource=function(t,e){if(!ArrayBuffer.isView(t)&&!l(t))throw new TypeError(n("is not an ArrayBuffer object or a view on one",e));return t},_e.DOMTimeStamp=_e["unsigned long long"],_e.Function=c,_e.VoidFunction=c}),446,[]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"URLSearchParams",{enumerable:!0,get:function(){return r(d[0]).URLSearchParams}})}),447,[433]); -__d((function(p,a,d,e,n,o,r){n.exports={ios:{appId:24794,appKey:"SqShg4Klnj2hG6LAFMW2PdcgSSuniz0T"},android:{appId:27509,appKey:"aQz3Uc2pA7gt_prDaQ4rbWRY"},harmony:{appId:29040,appKey:"gdzeAqAFE5Jew15c5Df8EKU9"}}}),448,[]); +__d((function(p,a,d,n,e,o,r){e.exports={ios:{appId:24794,appKey:"SqShg4Klnj2hG6LAFMW2PdcgSSuniz0T"},android:{appId:27509,appKey:"aQz3Uc2pA7gt_prDaQ4rbWRY"},harmony:{appId:29140,appKey:"JLklGflGIRbY-cMebjQwm1J1"}}}),448,[]); __d((function(g,r,i,a,m,e,d){m.exports=r(d[0]).registerAsset({__packager_asset:!0,httpServerLocation:"/assets/assets",width:24,height:24,scales:[1,2,3],hash:"9e7669fef128a85f6fae4b929ebff8dd",name:"shezhi",type:"png"})}),449,[450]); __d((function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])}),450,[177]); __d((function(s,_,a,e,n,u,y){n.exports={name:"harmony_use_pushy",displayName:"harmony_use_pushy"}}),451,[]); diff --git a/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/meta.json b/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/meta.json new file mode 100644 index 0000000..155e6ba --- /dev/null +++ b/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/meta.json @@ -0,0 +1,4 @@ +{ + "pushy_build_time": "2025-02-14T09:43:25.648Z", + "versionName": "1.0.0" +} \ No newline at end of file diff --git a/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/update.json b/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/update.json new file mode 100644 index 0000000..fdfbb09 --- /dev/null +++ b/Example/harmony_use_pushy/harmony/entry/src/main/resources/rawfile/update.json @@ -0,0 +1,14 @@ +{ + "ios": { + "appId": 24794, + "appKey": "SqShg4Klnj2hG6LAFMW2PdcgSSuniz0T" + }, + "android": { + "appId": 27509, + "appKey": "aQz3Uc2pA7gt_prDaQ4rbWRY" + }, + "harmony": { + "appId": 29140, + "appKey": "JLklGflGIRbY-cMebjQwm1J1" + } +} diff --git a/Example/harmony_use_pushy/harmony/oh-package.json5 b/Example/harmony_use_pushy/harmony/oh-package.json5 index 3354f78..60214be 100644 --- a/Example/harmony_use_pushy/harmony/oh-package.json5 +++ b/Example/harmony_use_pushy/harmony/oh-package.json5 @@ -13,5 +13,8 @@ "suppressImplicitAnyIndexErrors": true, "strict": false } + }, + "overrides": { + "@rnoh/react-native-openharmony": "0.72.38" } } diff --git a/Example/harmony_use_pushy/update.json b/Example/harmony_use_pushy/update.json index 8f7360c..fdfbb09 100644 --- a/Example/harmony_use_pushy/update.json +++ b/Example/harmony_use_pushy/update.json @@ -8,7 +8,7 @@ "appKey": "aQz3Uc2pA7gt_prDaQ4rbWRY" }, "harmony": { - "appId": 29040, - "appKey": "gdzeAqAFE5Jew15c5Df8EKU9" + "appId": 29140, + "appKey": "JLklGflGIRbY-cMebjQwm1J1" } } diff --git a/Example/harmony_use_pushy/yarn.lock b/Example/harmony_use_pushy/yarn.lock index 03b6f56..1337f5f 100644 --- a/Example/harmony_use_pushy/yarn.lock +++ b/Example/harmony_use_pushy/yarn.lock @@ -6003,7 +6003,7 @@ react-is@^17.0.1: integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== "react-native-update@file:../..": - version "10.15.1" + version "10.19.6" dependencies: nanoid "^3.3.3" react-native-url-polyfill "^2.0.0" diff --git a/harmony/README.md b/harmony/README.md new file mode 100644 index 0000000..e69de29 diff --git a/harmony/oh-package-lock.json5 b/harmony/oh-package-lock.json5 index aa8b768..3f97b95 100644 --- a/harmony/oh-package-lock.json5 +++ b/harmony/oh-package-lock.json5 @@ -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" } } } \ No newline at end of file diff --git a/harmony/oh-package.json5 b/harmony/oh-package.json5 index a092cb8..3465d35 100644 --- a/harmony/oh-package.json5 +++ b/harmony/oh-package.json5 @@ -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" } } diff --git a/harmony/oh_modules/@rnoh/react-native-openharmony b/harmony/oh_modules/@rnoh/react-native-openharmony new file mode 120000 index 0000000..37f4a5e --- /dev/null +++ b/harmony/oh_modules/@rnoh/react-native-openharmony @@ -0,0 +1 @@ +../../../../../harmony/oh_modules/.ohpm/@rnoh+react-native-openharmony@0.72.38/oh_modules/@rnoh/react-native-openharmony \ No newline at end of file diff --git a/harmony/src/main/ets/DownloadTask.ts b/harmony/src/main/ets/DownloadTask.ts index e2d5e60..867c4e5 100644 --- a/harmony/src/main/ets/DownloadTask.ts +++ b/harmony/src/main/ets/DownloadTask.ts @@ -491,4 +491,4 @@ export class DownloadTask { params.listener?.onDownloadFailed(error); } } -} +} \ No newline at end of file diff --git a/harmony/src/main/ets/FileJSBundleProvider.ets b/harmony/src/main/ets/FileJSBundleProvider.ets index 7dea184..59d5ac0 100644 --- a/harmony/src/main/ets/FileJSBundleProvider.ets +++ b/harmony/src/main/ets/FileJSBundleProvider.ets @@ -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; - } - } \ No newline at end of file diff --git a/harmony/src/main/ets/PushyPackage.ts b/harmony/src/main/ets/PushyPackage.ts index bbf400a..521f381 100644 --- a/harmony/src/main/ets/PushyPackage.ts +++ b/harmony/src/main/ets/PushyPackage.ts @@ -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 { diff --git a/harmony/src/main/ets/PushyTurboModule.ts b/harmony/src/main/ets/PushyTurboModule.ts index 310e2df..ecc0207 100644 --- a/harmony/src/main/ets/PushyTurboModule.ts +++ b/harmony/src/main/ets/PushyTurboModule.ts @@ -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'; diff --git a/harmony/src/main/ets/UpdateContext.ts b/harmony/src/main/ets/UpdateContext.ts index 9c7f25a..e6ec71f 100644 --- a/harmony/src/main/ets/UpdateContext.ts +++ b/harmony/src/main/ets/UpdateContext.ts @@ -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 { - 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 { - return await this.preferences.get(key, '') as string; + public getKv(key: string): string { + return this.preferences.getSync(key, '') as string; } - public async isFirstTime(): Promise { - return await this.preferences.get('firstTime', false) as boolean; + public isFirstTime(): boolean { + return this.preferences.getSync('firstTime', false) as boolean; } - public async rolledBackVersion(): Promise { - return await this.preferences.get('rolledBackVersion', '') as string; + public rolledBackVersion(): string { + return this.preferences.getSync('rolledBackVersion', '') as string; } - public async markSuccess(): Promise { - 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 { + 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(); } } diff --git a/harmony/src/main/ets/UpdateModuleImpl.ts b/harmony/src/main/ets/UpdateModuleImpl.ts index 5af0e93..e4473a6 100644 --- a/harmony/src/main/ets/UpdateModuleImpl.ts +++ b/harmony/src/main/ets/UpdateModuleImpl.ts @@ -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';