@appzung/react-native-code-push 10.0.0-rc1 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/CodePush.podspec +1 -0
  2. package/LICENSE.md +2 -2
  3. package/README.md +74 -95
  4. package/android/app/build.gradle +62 -18
  5. package/android/app/src/main/AndroidManifest.xml +2 -3
  6. package/android/app/src/main/AndroidManifestNew.xml +3 -0
  7. package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePush.java +21 -89
  8. package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushNativeModule.java +32 -3
  9. package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUpdateManager.java +2 -2
  10. package/android/build.gradle +1 -11
  11. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  12. package/android/gradle.properties +4 -20
  13. package/docs/advanced-usage.md +2 -2
  14. package/docs/api-android.md +12 -10
  15. package/docs/api-ios.md +5 -5
  16. package/docs/api-js.md +180 -178
  17. package/docs/code-signing.md +62 -0
  18. package/docs/migrating-to-v10.md +31 -0
  19. package/docs/setup-android.md +52 -79
  20. package/docs/setup-ios.md +31 -28
  21. package/docs/setup-windows.md +1 -0
  22. package/ios/CodePush/CodePush.m +13 -57
  23. package/lib/commonjs/CodePush.js +90 -0
  24. package/lib/commonjs/CodePush.js.map +1 -0
  25. package/lib/commonjs/allowRestart.js +12 -0
  26. package/lib/commonjs/allowRestart.js.map +1 -0
  27. package/lib/commonjs/checkForUpdates.js +105 -0
  28. package/lib/commonjs/checkForUpdates.js.map +1 -0
  29. package/lib/commonjs/clearUpdates.js +15 -0
  30. package/lib/commonjs/clearUpdates.js.map +1 -0
  31. package/lib/commonjs/disallowRestart.js +12 -0
  32. package/lib/commonjs/disallowRestart.js.map +1 -0
  33. package/lib/commonjs/enums/CheckFrequency.enum.js +25 -0
  34. package/lib/commonjs/enums/CheckFrequency.enum.js.map +1 -0
  35. package/lib/commonjs/enums/DeploymentStatus.enum.js +21 -0
  36. package/lib/commonjs/enums/DeploymentStatus.enum.js.map +1 -0
  37. package/lib/commonjs/enums/InstallMode.enum.js +35 -0
  38. package/lib/commonjs/enums/InstallMode.enum.js.map +1 -0
  39. package/lib/commonjs/enums/SyncStatus.enum.js +53 -0
  40. package/lib/commonjs/enums/SyncStatus.enum.js.map +1 -0
  41. package/lib/commonjs/enums/UpdateState.enum.js +29 -0
  42. package/lib/commonjs/enums/UpdateState.enum.js.map +1 -0
  43. package/lib/commonjs/getUpdateMetadata.js +25 -0
  44. package/lib/commonjs/getUpdateMetadata.js.map +1 -0
  45. package/lib/commonjs/index.js +195 -0
  46. package/lib/commonjs/index.js.map +1 -0
  47. package/lib/commonjs/internals/AcquisitionSdk.js +9 -0
  48. package/lib/commonjs/internals/AcquisitionSdk.js.map +1 -0
  49. package/lib/commonjs/internals/LocalPackageImplementation.js +29 -0
  50. package/lib/commonjs/internals/LocalPackageImplementation.js.map +1 -0
  51. package/lib/commonjs/internals/NativeRNAppZungCodePushModule.js +8 -0
  52. package/lib/commonjs/internals/NativeRNAppZungCodePushModule.js.map +1 -0
  53. package/lib/commonjs/internals/RNAppZungCodePushModuleSpec.js +6 -0
  54. package/lib/commonjs/internals/RNAppZungCodePushModuleSpec.js.map +1 -0
  55. package/lib/commonjs/internals/RemotePackageImplementation.js +49 -0
  56. package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -0
  57. package/lib/commonjs/internals/getConfiguration.js +15 -0
  58. package/lib/commonjs/internals/getConfiguration.js.map +1 -0
  59. package/lib/commonjs/internals/getCurrentPackage.js +12 -0
  60. package/lib/commonjs/internals/getCurrentPackage.js.map +1 -0
  61. package/lib/commonjs/internals/getPromisifiedSdk.js +49 -0
  62. package/lib/commonjs/internals/getPromisifiedSdk.js.map +1 -0
  63. package/lib/commonjs/internals/shouldUpdateBeIgnored.js +62 -0
  64. package/lib/commonjs/internals/shouldUpdateBeIgnored.js.map +1 -0
  65. package/lib/commonjs/internals/types.js +6 -0
  66. package/lib/commonjs/internals/types.js.map +1 -0
  67. package/lib/commonjs/internals/utils/log.js +11 -0
  68. package/lib/commonjs/internals/utils/log.js.map +1 -0
  69. package/lib/commonjs/internals/utils/request-fetch-adapter.js +50 -0
  70. package/lib/commonjs/internals/utils/request-fetch-adapter.js.map +1 -0
  71. package/lib/commonjs/internals/version.js +9 -0
  72. package/lib/commonjs/internals/version.js.map +1 -0
  73. package/lib/commonjs/notifyAppReady.js +83 -0
  74. package/lib/commonjs/notifyAppReady.js.map +1 -0
  75. package/lib/commonjs/reactNative.d.js +2 -0
  76. package/lib/commonjs/reactNative.d.js.map +1 -0
  77. package/lib/commonjs/restartApp.js +16 -0
  78. package/lib/commonjs/restartApp.js.map +1 -0
  79. package/lib/commonjs/sync.js +219 -0
  80. package/lib/commonjs/sync.js.map +1 -0
  81. package/lib/commonjs/types.js +6 -0
  82. package/lib/commonjs/types.js.map +1 -0
  83. package/lib/module/CodePush.js +84 -0
  84. package/lib/module/CodePush.js.map +1 -0
  85. package/lib/module/allowRestart.js +9 -0
  86. package/lib/module/allowRestart.js.map +1 -0
  87. package/lib/module/checkForUpdates.js +101 -0
  88. package/lib/module/checkForUpdates.js.map +1 -0
  89. package/lib/module/clearUpdates.js +12 -0
  90. package/lib/module/clearUpdates.js.map +1 -0
  91. package/lib/module/disallowRestart.js +9 -0
  92. package/lib/module/disallowRestart.js.map +1 -0
  93. package/lib/module/enums/CheckFrequency.enum.js +21 -0
  94. package/lib/module/enums/CheckFrequency.enum.js.map +1 -0
  95. package/lib/module/enums/DeploymentStatus.enum.js +17 -0
  96. package/lib/module/enums/DeploymentStatus.enum.js.map +1 -0
  97. package/lib/module/enums/InstallMode.enum.js +32 -0
  98. package/lib/module/enums/InstallMode.enum.js.map +1 -0
  99. package/lib/module/enums/SyncStatus.enum.js +49 -0
  100. package/lib/module/enums/SyncStatus.enum.js.map +1 -0
  101. package/lib/module/enums/UpdateState.enum.js +26 -0
  102. package/lib/module/enums/UpdateState.enum.js.map +1 -0
  103. package/lib/module/getUpdateMetadata.js +21 -0
  104. package/lib/module/getUpdateMetadata.js.map +1 -0
  105. package/lib/module/index.js +19 -0
  106. package/lib/module/index.js.map +1 -0
  107. package/lib/module/internals/AcquisitionSdk.js +5 -0
  108. package/lib/module/internals/AcquisitionSdk.js.map +1 -0
  109. package/lib/module/internals/LocalPackageImplementation.js +24 -0
  110. package/lib/module/internals/LocalPackageImplementation.js.map +1 -0
  111. package/lib/module/internals/NativeRNAppZungCodePushModule.js +4 -0
  112. package/lib/module/internals/NativeRNAppZungCodePushModule.js.map +1 -0
  113. package/lib/module/internals/RNAppZungCodePushModuleSpec.js +4 -0
  114. package/lib/module/internals/RNAppZungCodePushModuleSpec.js.map +1 -0
  115. package/lib/module/internals/RemotePackageImplementation.js +44 -0
  116. package/lib/module/internals/RemotePackageImplementation.js.map +1 -0
  117. package/lib/module/internals/getConfiguration.js +11 -0
  118. package/lib/module/internals/getConfiguration.js.map +1 -0
  119. package/lib/module/internals/getCurrentPackage.js +8 -0
  120. package/lib/module/internals/getCurrentPackage.js.map +1 -0
  121. package/lib/module/internals/getPromisifiedSdk.js +45 -0
  122. package/lib/module/internals/getPromisifiedSdk.js.map +1 -0
  123. package/lib/module/internals/shouldUpdateBeIgnored.js +58 -0
  124. package/lib/module/internals/shouldUpdateBeIgnored.js.map +1 -0
  125. package/lib/module/internals/types.js +4 -0
  126. package/lib/module/internals/types.js.map +1 -0
  127. package/lib/module/internals/utils/log.js +7 -0
  128. package/lib/module/internals/utils/log.js.map +1 -0
  129. package/lib/module/internals/utils/request-fetch-adapter.js +46 -0
  130. package/lib/module/internals/utils/request-fetch-adapter.js.map +1 -0
  131. package/lib/module/internals/version.js +5 -0
  132. package/lib/module/internals/version.js.map +1 -0
  133. package/lib/module/notifyAppReady.js +79 -0
  134. package/lib/module/notifyAppReady.js.map +1 -0
  135. package/lib/module/reactNative.d.js +2 -0
  136. package/lib/module/reactNative.d.js.map +1 -0
  137. package/lib/module/restartApp.js +13 -0
  138. package/lib/module/restartApp.js.map +1 -0
  139. package/lib/module/sync.js +215 -0
  140. package/lib/module/sync.js.map +1 -0
  141. package/lib/module/types.js +4 -0
  142. package/lib/module/types.js.map +1 -0
  143. package/lib/typescript/commonjs/package.json +1 -0
  144. package/lib/typescript/commonjs/src/CodePush.d.ts +24 -0
  145. package/lib/typescript/commonjs/src/CodePush.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/src/allowRestart.d.ts +5 -0
  147. package/lib/typescript/commonjs/src/allowRestart.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/src/checkForUpdates.d.ts +9 -0
  149. package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -0
  150. package/lib/typescript/commonjs/src/clearUpdates.d.ts +8 -0
  151. package/lib/typescript/commonjs/src/clearUpdates.d.ts.map +1 -0
  152. package/lib/typescript/commonjs/src/disallowRestart.d.ts +5 -0
  153. package/lib/typescript/commonjs/src/disallowRestart.d.ts.map +1 -0
  154. package/lib/typescript/commonjs/src/enums/CheckFrequency.enum.d.ts +18 -0
  155. package/lib/typescript/commonjs/src/enums/CheckFrequency.enum.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts +14 -0
  157. package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts.map +1 -0
  158. package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts +27 -0
  159. package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts.map +1 -0
  160. package/lib/typescript/commonjs/src/enums/SyncStatus.enum.d.ts +46 -0
  161. package/lib/typescript/commonjs/src/enums/SyncStatus.enum.d.ts.map +1 -0
  162. package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts +21 -0
  163. package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/src/getUpdateMetadata.d.ts +9 -0
  165. package/lib/typescript/commonjs/src/getUpdateMetadata.d.ts.map +1 -0
  166. package/lib/typescript/commonjs/src/index.d.ts +17 -0
  167. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts +3 -0
  169. package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/src/internals/LocalPackageImplementation.d.ts +17 -0
  171. package/lib/typescript/commonjs/src/internals/LocalPackageImplementation.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/src/internals/NativeRNAppZungCodePushModule.d.ts +3 -0
  173. package/lib/typescript/commonjs/src/internals/NativeRNAppZungCodePushModule.d.ts.map +1 -0
  174. package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts +36 -0
  175. package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -0
  176. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts +18 -0
  177. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -0
  178. package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts +3 -0
  179. package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts.map +1 -0
  180. package/lib/typescript/commonjs/src/internals/getCurrentPackage.d.ts +2 -0
  181. package/lib/typescript/commonjs/src/internals/getCurrentPackage.d.ts.map +1 -0
  182. package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts +13 -0
  183. package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts +3 -0
  185. package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/src/internals/types.d.ts +16 -0
  187. package/lib/typescript/commonjs/src/internals/types.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/src/internals/utils/log.d.ts +2 -0
  189. package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts +3 -0
  191. package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts.map +1 -0
  192. package/lib/typescript/commonjs/src/internals/version.d.ts +2 -0
  193. package/lib/typescript/commonjs/src/internals/version.d.ts.map +1 -0
  194. package/lib/typescript/commonjs/src/notifyAppReady.d.ts +6 -0
  195. package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -0
  196. package/lib/typescript/commonjs/src/restartApp.d.ts +7 -0
  197. package/lib/typescript/commonjs/src/restartApp.d.ts.map +1 -0
  198. package/lib/typescript/commonjs/src/sync.d.ts +17 -0
  199. package/lib/typescript/commonjs/src/sync.d.ts.map +1 -0
  200. package/lib/typescript/commonjs/src/types.d.ts +196 -0
  201. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  202. package/lib/typescript/module/package.json +1 -0
  203. package/lib/typescript/module/src/CodePush.d.ts +24 -0
  204. package/lib/typescript/module/src/CodePush.d.ts.map +1 -0
  205. package/lib/typescript/module/src/allowRestart.d.ts +5 -0
  206. package/lib/typescript/module/src/allowRestart.d.ts.map +1 -0
  207. package/lib/typescript/module/src/checkForUpdates.d.ts +9 -0
  208. package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -0
  209. package/lib/typescript/module/src/clearUpdates.d.ts +8 -0
  210. package/lib/typescript/module/src/clearUpdates.d.ts.map +1 -0
  211. package/lib/typescript/module/src/disallowRestart.d.ts +5 -0
  212. package/lib/typescript/module/src/disallowRestart.d.ts.map +1 -0
  213. package/lib/typescript/module/src/enums/CheckFrequency.enum.d.ts +18 -0
  214. package/lib/typescript/module/src/enums/CheckFrequency.enum.d.ts.map +1 -0
  215. package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts +14 -0
  216. package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts.map +1 -0
  217. package/lib/typescript/module/src/enums/InstallMode.enum.d.ts +27 -0
  218. package/lib/typescript/module/src/enums/InstallMode.enum.d.ts.map +1 -0
  219. package/lib/typescript/module/src/enums/SyncStatus.enum.d.ts +46 -0
  220. package/lib/typescript/module/src/enums/SyncStatus.enum.d.ts.map +1 -0
  221. package/lib/typescript/module/src/enums/UpdateState.enum.d.ts +21 -0
  222. package/lib/typescript/module/src/enums/UpdateState.enum.d.ts.map +1 -0
  223. package/lib/typescript/module/src/getUpdateMetadata.d.ts +9 -0
  224. package/lib/typescript/module/src/getUpdateMetadata.d.ts.map +1 -0
  225. package/lib/typescript/module/src/index.d.ts +17 -0
  226. package/lib/typescript/module/src/index.d.ts.map +1 -0
  227. package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts +3 -0
  228. package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts.map +1 -0
  229. package/lib/typescript/module/src/internals/LocalPackageImplementation.d.ts +17 -0
  230. package/lib/typescript/module/src/internals/LocalPackageImplementation.d.ts.map +1 -0
  231. package/lib/typescript/module/src/internals/NativeRNAppZungCodePushModule.d.ts +3 -0
  232. package/lib/typescript/module/src/internals/NativeRNAppZungCodePushModule.d.ts.map +1 -0
  233. package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts +36 -0
  234. package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -0
  235. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts +18 -0
  236. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -0
  237. package/lib/typescript/module/src/internals/getConfiguration.d.ts +3 -0
  238. package/lib/typescript/module/src/internals/getConfiguration.d.ts.map +1 -0
  239. package/lib/typescript/module/src/internals/getCurrentPackage.d.ts +2 -0
  240. package/lib/typescript/module/src/internals/getCurrentPackage.d.ts.map +1 -0
  241. package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts +13 -0
  242. package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts.map +1 -0
  243. package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts +3 -0
  244. package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -0
  245. package/lib/typescript/module/src/internals/types.d.ts +16 -0
  246. package/lib/typescript/module/src/internals/types.d.ts.map +1 -0
  247. package/lib/typescript/module/src/internals/utils/log.d.ts +2 -0
  248. package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -0
  249. package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts +3 -0
  250. package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts.map +1 -0
  251. package/lib/typescript/module/src/internals/version.d.ts +2 -0
  252. package/lib/typescript/module/src/internals/version.d.ts.map +1 -0
  253. package/lib/typescript/module/src/notifyAppReady.d.ts +6 -0
  254. package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -0
  255. package/lib/typescript/module/src/restartApp.d.ts +7 -0
  256. package/lib/typescript/module/src/restartApp.d.ts.map +1 -0
  257. package/lib/typescript/module/src/sync.d.ts +17 -0
  258. package/lib/typescript/module/src/sync.d.ts.map +1 -0
  259. package/lib/typescript/module/src/types.d.ts +196 -0
  260. package/lib/typescript/module/src/types.d.ts.map +1 -0
  261. package/package.json +58 -11
  262. package/react-native.config.js +8 -8
  263. package/src/CodePush.tsx +108 -0
  264. package/src/allowRestart.ts +6 -0
  265. package/src/checkForUpdates.ts +109 -0
  266. package/src/clearUpdates.ts +9 -0
  267. package/src/disallowRestart.ts +6 -0
  268. package/src/enums/CheckFrequency.enum.ts +19 -0
  269. package/src/enums/DeploymentStatus.enum.ts +14 -0
  270. package/src/enums/InstallMode.enum.ts +31 -0
  271. package/src/enums/SyncStatus.enum.ts +53 -0
  272. package/src/enums/UpdateState.enum.ts +24 -0
  273. package/src/getUpdateMetadata.ts +23 -0
  274. package/src/index.ts +18 -0
  275. package/src/internals/AcquisitionSdk.ts +3 -0
  276. package/src/internals/LocalPackageImplementation.ts +45 -0
  277. package/src/internals/NativeRNAppZungCodePushModule.ts +3 -0
  278. package/src/internals/RNAppZungCodePushModuleSpec.ts +54 -0
  279. package/src/internals/RemotePackageImplementation.ts +69 -0
  280. package/src/internals/getConfiguration.ts +12 -0
  281. package/src/internals/getCurrentPackage.ts +6 -0
  282. package/src/internals/getPromisifiedSdk.ts +72 -0
  283. package/src/internals/shouldUpdateBeIgnored.ts +76 -0
  284. package/src/internals/types.ts +18 -0
  285. package/{logging.js → src/internals/utils/log.ts} +1 -3
  286. package/src/internals/utils/request-fetch-adapter.ts +58 -0
  287. package/src/internals/version.ts +2 -0
  288. package/src/notifyAppReady.ts +94 -0
  289. package/src/reactNative.d.ts +34 -0
  290. package/src/restartApp.ts +10 -0
  291. package/src/sync.ts +272 -0
  292. package/src/types.ts +237 -0
  293. package/tsconfig.build.json +4 -0
  294. package/tsconfig.json +29 -12
  295. package/AlertAdapter.js +0 -24
  296. package/CONTRIBUTING.md +0 -134
  297. package/CodePush.js +0 -674
  298. package/android/app/.gradle/config.properties +0 -2
  299. package/android/app/local.properties +0 -8
  300. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +0 -37
  301. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +0 -102
  302. package/package-mixins.js +0 -68
  303. package/request-fetch-adapter.js +0 -52
  304. package/tslint.json +0 -32
  305. package/typings/react-native-code-push.d.ts +0 -455
  306. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushConstants.java +0 -0
  307. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushInstallMode.java +0 -0
  308. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushInvalidPublicKeyException.java +0 -0
  309. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushInvalidUpdateException.java +0 -0
  310. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushMalformedDataException.java +0 -0
  311. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushNotInitializedException.java +0 -0
  312. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushTelemetryManager.java +0 -0
  313. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUnknownException.java +0 -0
  314. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUpdateState.java +0 -0
  315. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUpdateUtils.java +0 -0
  316. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/CodePushUtils.java +0 -0
  317. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/DownloadProgress.java +0 -0
  318. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/DownloadProgressCallback.java +0 -0
  319. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/FileUtils.java +0 -0
  320. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/ReactInstanceHolder.java +0 -0
  321. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/SettingsManager.java +0 -0
  322. /package/android/app/src/main/java/com/{microsoft → appzung}/codepush/react/TLSSocketFactory.java +0 -0
@@ -0,0 +1,108 @@
1
+ import hoistStatics from 'hoist-non-react-statics';
2
+ import React from 'react';
3
+ import { AppState } from 'react-native';
4
+ import { CheckFrequency } from './enums/CheckFrequency.enum';
5
+ import { notifyAppReady } from './notifyAppReady';
6
+ import { sync } from './sync';
7
+ import type {
8
+ DownloadProgressCallback,
9
+ HandleBinaryVersionMismatchCallback,
10
+ SyncOptions,
11
+ SyncStatusChangedCallback,
12
+ } from './types';
13
+
14
+ export interface CodePushOptions extends SyncOptions {
15
+ /**
16
+ * Specifies when you would like to synchronize updates with the CodePush server.
17
+ * Defaults to codePush.CheckFrequency.ON_APP_START.
18
+ */
19
+ checkFrequency?: CheckFrequency;
20
+ }
21
+
22
+ /**
23
+ * Decorates a React Component configuring it to sync for updates with the CodePush server.
24
+ *
25
+ * @param component the React Component that will be decorated
26
+ */
27
+ // @ts-ignore
28
+ export function withCodePush(component: any): React.FunctionComponent;
29
+
30
+ /**
31
+ * Decorates a React Component configuring it to sync for updates with the CodePush server.
32
+ *
33
+ * @param options Options used to configure the end-user sync and update experience (e.g. when to check for updates?, show a prompt?, install the update immediately?).
34
+ */
35
+ export function withCodePush(options: CodePushOptions): (component: any) => React.FunctionComponent;
36
+
37
+ export function withCodePush<P extends object>(optionsOrComponent: CodePushOptions | React.ComponentType<P>) {
38
+ const options: CodePushOptions = typeof optionsOrComponent === 'function' ? {} : optionsOrComponent;
39
+
40
+ const WithCodePush = (RootComponent: React.ComponentType<P>) => {
41
+ class CodePushComponent extends React.Component<P> {
42
+ rootComponentRef: React.RefObject<any>;
43
+
44
+ constructor(props: never) {
45
+ super(props);
46
+ this.rootComponentRef = React.createRef();
47
+ }
48
+
49
+ componentDidMount() {
50
+ if (options.checkFrequency === CheckFrequency.MANUAL) {
51
+ notifyAppReady();
52
+ } else {
53
+ const rootComponentInstance = this.rootComponentRef.current;
54
+
55
+ let syncStatusCallback: SyncStatusChangedCallback | undefined;
56
+ if (rootComponentInstance && rootComponentInstance.codePushStatusDidChange) {
57
+ syncStatusCallback = rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
58
+ }
59
+
60
+ let downloadProgressCallback: DownloadProgressCallback | undefined;
61
+ if (rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress) {
62
+ downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
63
+ }
64
+
65
+ let handleBinaryVersionMismatchCallback: HandleBinaryVersionMismatchCallback | undefined;
66
+ if (rootComponentInstance && rootComponentInstance.codePushOnBinaryVersionMismatch) {
67
+ handleBinaryVersionMismatchCallback =
68
+ rootComponentInstance.codePushOnBinaryVersionMismatch.bind(rootComponentInstance);
69
+ }
70
+
71
+ sync(options, syncStatusCallback, downloadProgressCallback, handleBinaryVersionMismatchCallback);
72
+
73
+ if (options.checkFrequency === CheckFrequency.ON_APP_RESUME) {
74
+ AppState.addEventListener('change', (newState: string) => {
75
+ if (newState === 'active') {
76
+ sync(options, syncStatusCallback, downloadProgressCallback);
77
+ }
78
+ });
79
+ }
80
+ }
81
+ }
82
+
83
+ render() {
84
+ const props = { ...this.props };
85
+
86
+ // We can set ref property on class components only (not stateless)
87
+ // Check it by render method
88
+ if (RootComponent.prototype && RootComponent.prototype.render) {
89
+ // @ts-ignore
90
+ props.ref = this.rootComponentRef;
91
+ }
92
+
93
+ return <RootComponent {...props} />;
94
+ }
95
+ }
96
+
97
+ return hoistStatics(CodePushComponent, RootComponent);
98
+ };
99
+
100
+ if (typeof optionsOrComponent === 'function') {
101
+ // Infer that the root component was directly passed to us.
102
+ return WithCodePush(optionsOrComponent);
103
+ } else {
104
+ return WithCodePush;
105
+ }
106
+ }
107
+
108
+ export default withCodePush;
@@ -0,0 +1,6 @@
1
+ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
2
+
3
+ /**
4
+ * Allow CodePush to restart the app.
5
+ */
6
+ export const allowRestart: () => void = NativeRNAppZungCodePushModule.allow;
@@ -0,0 +1,109 @@
1
+ import { Platform } from 'react-native';
2
+ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
3
+ import { RemotePackageImpl } from './internals/RemotePackageImplementation';
4
+ import { getConfiguration } from './internals/getConfiguration';
5
+ import { getCurrentPackage } from './internals/getCurrentPackage';
6
+ import { type PromisifiedSdkQueryPackage, getPromisifiedSdk } from './internals/getPromisifiedSdk';
7
+ import type { Configuration } from './internals/types';
8
+ import { log } from './internals/utils/log';
9
+ import { requestFetchAdapter } from './internals/utils/request-fetch-adapter';
10
+ import type { HandleBinaryVersionMismatchCallback, RemotePackage } from './types';
11
+
12
+ /**
13
+ * Asks the CodePush service whether the configured app release channel has an update available.
14
+ *
15
+ * @param releaseChannelPublicId The release channel public ID to use to query the CodePush server for an update.
16
+ * @param handleBinaryVersionMismatchCallback An optional callback for handling target binary version mismatch
17
+ */
18
+ export async function checkForUpdate(
19
+ releaseChannelPublicId?: string,
20
+ handleBinaryVersionMismatchCallback?: HandleBinaryVersionMismatchCallback,
21
+ ): Promise<RemotePackage | null> {
22
+ /*
23
+ * Before we ask the server if an update exists, we
24
+ * need to retrieve three pieces of information from the
25
+ * native side: release channel, app version (e.g. 1.0.1)
26
+ * and the hash of the currently running update (if there is one).
27
+ * This allows the client to only receive updates which are targeted
28
+ * for their specific release channel and version and which are actually
29
+ * different from the CodePush update they have already installed.
30
+ */
31
+ const nativeConfig = await getConfiguration();
32
+ /*
33
+ * If a release channel was explicitly provided,
34
+ * then let's override the one we retrieved
35
+ * from the native-side of the app. This allows
36
+ * dynamically "redirecting" end-users at different
37
+ * release channels (e.g. an early access release channel for insiders).
38
+ */
39
+ const config: Configuration = releaseChannelPublicId
40
+ ? { ...nativeConfig, ...{ releaseChannelPublicId } }
41
+ : nativeConfig;
42
+ const sdk = getPromisifiedSdk(requestFetchAdapter, config);
43
+
44
+ const localPackage = await getCurrentPackage();
45
+
46
+ /*
47
+ * If the app has a previously installed update, and that update
48
+ * was targeted at the same app version that is currently running,
49
+ * then we want to use its package hash to determine whether a new
50
+ * release has been made on the server. Otherwise, we only need
51
+ * to send the app version to the server, since we are interested
52
+ * in any updates for current binary version, regardless of hash.
53
+ */
54
+ let queryPackage: PromisifiedSdkQueryPackage;
55
+ if (localPackage) {
56
+ queryPackage = localPackage;
57
+ } else {
58
+ queryPackage = { appVersion: config.appVersion };
59
+ if (Platform.OS === 'ios' && config.packageHash) {
60
+ queryPackage.packageHash = config.packageHash;
61
+ }
62
+ }
63
+
64
+ const update = await sdk.queryUpdateWithCurrentPackage(queryPackage);
65
+
66
+ /*
67
+ * There are four cases where checkForUpdate will resolve to null:
68
+ * ----------------------------------------------------------------
69
+ * 1) The server said there isn't an update. This is the most common case.
70
+ * 2) The server said there is an update but it requires a newer binary version.
71
+ * This would occur when end-users are running an older binary version than
72
+ * is available, and CodePush is making sure they don't get an update that
73
+ * potentially wouldn't be compatible with what they are running.
74
+ * 3) The server said there is an update, but the update's hash is the same as
75
+ * the currently running update. This should _never_ happen, unless there is a
76
+ * bug in the server, but we're adding this check just to double-check that the
77
+ * client app is resilient to a potential issue with the update check.
78
+ * 4) The server said there is an update, but the update's hash is the same as that
79
+ * of the binary's currently running version. This should only happen in Android -
80
+ * unlike iOS, we don't attach the binary's hash to the updateCheck request
81
+ * because we want to avoid having to install diff updates against the binary's
82
+ * version, which we can't do yet on Android.
83
+ */
84
+ if (!update) {
85
+ return null;
86
+ }
87
+
88
+ if ('updateAppVersion' in update && update.updateAppVersion) {
89
+ log('An update is available but it is not targeting the binary version of your app.');
90
+ handleBinaryVersionMismatchCallback?.(update);
91
+
92
+ return null;
93
+ }
94
+
95
+ if (
96
+ (localPackage && 'packageHash' in update && update.packageHash === localPackage.packageHash) ||
97
+ ((!localPackage || ('_isDebugOnly' in localPackage && localPackage._isDebugOnly)) &&
98
+ 'packageHash' in update &&
99
+ config.packageHash === update.packageHash)
100
+ ) {
101
+ return null;
102
+ }
103
+
104
+ // @ts-expect-error sdk typing is wrong
105
+ const remotePackage = new RemotePackageImpl(update, sdk.reportStatusDownload);
106
+ remotePackage.failedInstall = await NativeRNAppZungCodePushModule.isFailedUpdate(remotePackage.packageHash);
107
+ remotePackage.releaseChannelPublicId = releaseChannelPublicId || nativeConfig.releaseChannelPublicId;
108
+ return remotePackage;
109
+ }
@@ -0,0 +1,9 @@
1
+ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
2
+
3
+ /**
4
+ * Clears all downloaded CodePush updates.
5
+ * This is useful when switching to a different release channel which may have an older release than the current package.
6
+ * Note: we don’t recommend to use this method in scenarios other than that (CodePush will call
7
+ * this method automatically when needed in other cases) as it could lead to unpredictable behavior.
8
+ */
9
+ export const clearUpdates: () => void = NativeRNAppZungCodePushModule.clearUpdates;
@@ -0,0 +1,6 @@
1
+ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
2
+
3
+ /**
4
+ * Forbid CodePush to restart the app.
5
+ */
6
+ export const disallowRestart: () => void = NativeRNAppZungCodePushModule.disallow;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Indicates when you would like to check for (and install) updates from the CodePush server.
3
+ */
4
+ export enum CheckFrequency {
5
+ /**
6
+ * When the app is fully initialized (or more specifically, when the root component is mounted).
7
+ */
8
+ ON_APP_START,
9
+
10
+ /**
11
+ * When the app re-enters the foreground.
12
+ */
13
+ ON_APP_RESUME,
14
+
15
+ /**
16
+ * Don't automatically check for updates, but only do it when codePush.sync() is manually called inside app code.
17
+ */
18
+ MANUAL,
19
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Indicates the status of a deployment (after installing and restarting).
3
+ */
4
+ export enum DeploymentStatus {
5
+ /**
6
+ * The deployment failed (and was rolled back).
7
+ */
8
+ FAILED = 'DeploymentFailed',
9
+
10
+ /**
11
+ * The deployment succeeded.
12
+ */
13
+ SUCCEEDED = 'DeploymentSucceeded',
14
+ }
@@ -0,0 +1,31 @@
1
+ import { NativeRNAppZungCodePushModule } from '../internals/NativeRNAppZungCodePushModule';
2
+
3
+ /**
4
+ * Indicates when you would like an installed update to actually be applied.
5
+ */
6
+ export enum InstallMode {
7
+ /**
8
+ * Indicates that you want to install the update and restart the app immediately.
9
+ */
10
+ IMMEDIATE = NativeRNAppZungCodePushModule.getConstants().codePushInstallModeImmediate,
11
+
12
+ /**
13
+ * Indicates that you want to install the update, but not forcibly restart the app.
14
+ */
15
+ ON_NEXT_RESTART = NativeRNAppZungCodePushModule.getConstants().codePushInstallModeOnNextRestart,
16
+
17
+ /**
18
+ * Indicates that you want to install the update, but don't want to restart the app until the next time
19
+ * the end user resumes it from the background. This way, you don't disrupt their current session,
20
+ * but you can get the update in front of them sooner than having to wait for the next natural restart.
21
+ * This value is appropriate for silent installs that can be applied on resume in a non-invasive way.
22
+ */
23
+ ON_NEXT_RESUME = NativeRNAppZungCodePushModule.getConstants().codePushInstallModeOnNextResume,
24
+
25
+ /**
26
+ * Indicates that you want to install the update when the app is in the background,
27
+ * but only after it has been in the background for "minimumBackgroundDuration" seconds (0 by default),
28
+ * so that user context isn't lost unless the app suspension is long enough to not matter.
29
+ */
30
+ ON_NEXT_SUSPEND = NativeRNAppZungCodePushModule.getConstants().codePushInstallModeOnNextSuspend,
31
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Indicates the current status of a sync operation.
3
+ */
4
+ export enum SyncStatus {
5
+ /**
6
+ * The app is up-to-date with the CodePush server.
7
+ */
8
+ UP_TO_DATE,
9
+
10
+ /**
11
+ * An available update has been installed and will be run either immediately after the
12
+ * syncStatusChangedCallback function returns or the next time the app resumes/restarts,
13
+ * depending on the InstallMode specified in SyncOptions
14
+ */
15
+ UPDATE_INSTALLED,
16
+
17
+ /**
18
+ * The app had an optional update which the end user chose to ignore.
19
+ * (This is only applicable when the updateDialog is used)
20
+ */
21
+ UPDATE_IGNORED,
22
+
23
+ /**
24
+ * The sync operation encountered an unknown error.
25
+ */
26
+ UNKNOWN_ERROR,
27
+
28
+ /**
29
+ * There is an ongoing sync operation running which prevents the current call from being executed.
30
+ */
31
+ SYNC_IN_PROGRESS,
32
+
33
+ /**
34
+ * The CodePush server is being queried for an update.
35
+ */
36
+ CHECKING_FOR_UPDATE,
37
+
38
+ /**
39
+ * An update is available, and a confirmation dialog was shown
40
+ * to the end user. (This is only applicable when the updateDialog is used)
41
+ */
42
+ AWAITING_USER_ACTION,
43
+
44
+ /**
45
+ * An available update is being downloaded from the CodePush server.
46
+ */
47
+ DOWNLOADING_PACKAGE,
48
+
49
+ /**
50
+ * An available update was downloaded and is about to be installed.
51
+ */
52
+ INSTALLING_UPDATE,
53
+ }
@@ -0,0 +1,24 @@
1
+ import { NativeRNAppZungCodePushModule } from '../internals/NativeRNAppZungCodePushModule';
2
+
3
+ /**
4
+ * Indicates the state that an update is currently in.
5
+ */
6
+ export enum UpdateState {
7
+ /**
8
+ * Indicates that an update represents the
9
+ * version of the app that is currently running.
10
+ */
11
+ RUNNING = NativeRNAppZungCodePushModule.getConstants().codePushUpdateStateRunning,
12
+
13
+ /**
14
+ * Indicates than an update has been installed, but the
15
+ * app hasn't been restarted yet in order to apply it.
16
+ */
17
+ PENDING = NativeRNAppZungCodePushModule.getConstants().codePushUpdateStatePending,
18
+
19
+ /**
20
+ * Indicates than an update represents the latest available
21
+ * release, and can be either currently running or pending.
22
+ */
23
+ LATEST = NativeRNAppZungCodePushModule.getConstants().codePushUpdateStateLatest,
24
+ }
@@ -0,0 +1,23 @@
1
+ import { UpdateState } from './enums/UpdateState.enum';
2
+ import { LocalPackageImplementation } from './internals/LocalPackageImplementation';
3
+ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
4
+ import type { LocalPackage } from './types';
5
+
6
+ /**
7
+ * Retrieves the metadata for an installed update (e.g. description, mandatory).
8
+ *
9
+ * @param updateState The state of the update you want to retrieve the metadata for. Defaults to UpdateState.RUNNING.
10
+ */
11
+ export async function getUpdateMetadata(updateState?: UpdateState): Promise<LocalPackage | null> {
12
+ const nativeUpdateMetadata = await NativeRNAppZungCodePushModule.getUpdateMetadata(
13
+ updateState || UpdateState.RUNNING,
14
+ );
15
+ if (!nativeUpdateMetadata) {
16
+ return null;
17
+ }
18
+
19
+ const localPackage = new LocalPackageImplementation(nativeUpdateMetadata);
20
+ localPackage.failedInstall = await NativeRNAppZungCodePushModule.isFailedUpdate(nativeUpdateMetadata.packageHash);
21
+ localPackage.isFirstRun = await NativeRNAppZungCodePushModule.isFirstRun(nativeUpdateMetadata.packageHash);
22
+ return localPackage;
23
+ }
package/src/index.ts ADDED
@@ -0,0 +1,18 @@
1
+ export * from './allowRestart';
2
+ export * from './checkForUpdates';
3
+ export * from './clearUpdates';
4
+ export * from './CodePush';
5
+ export { default } from './CodePush';
6
+ export * from './disallowRestart';
7
+ export * from './getUpdateMetadata';
8
+ export * from './notifyAppReady';
9
+ export * from './restartApp';
10
+ export * from './sync';
11
+
12
+ export * from './types';
13
+
14
+ export * from './enums/SyncStatus.enum';
15
+ export * from './enums/InstallMode.enum';
16
+ export * from './enums/UpdateState.enum';
17
+ export * from './enums/DeploymentStatus.enum';
18
+ export * from './enums/CheckFrequency.enum';
@@ -0,0 +1,3 @@
1
+ import { AcquisitionManager } from 'code-push/script/acquisition-sdk';
2
+
3
+ export const AcquisitionSdk = AcquisitionManager;
@@ -0,0 +1,45 @@
1
+ import type { InstallMode } from '../enums/InstallMode.enum';
2
+ import type { LocalPackage } from '../types';
3
+ import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
4
+
5
+ export class LocalPackageImplementation implements LocalPackage {
6
+ constructor(localPackageData: Omit<LocalPackage, 'install'>) {
7
+ Object.assign(this, localPackageData);
8
+
9
+ this.install = async (
10
+ installMode = NativeRNAppZungCodePushModule.getConstants().codePushInstallModeOnNextRestart,
11
+ minimumBackgroundDuration = 0,
12
+ updateInstalledCallback?: () => Promise<void> | void,
13
+ ) => {
14
+ const { ...localPackageCopy } = localPackageData;
15
+ await NativeRNAppZungCodePushModule.installUpdate(localPackageCopy, installMode, minimumBackgroundDuration);
16
+
17
+ if (installMode === NativeRNAppZungCodePushModule.getConstants().codePushInstallModeImmediate) {
18
+ await updateInstalledCallback?.();
19
+ await NativeRNAppZungCodePushModule.restartApp(false);
20
+ return;
21
+ }
22
+
23
+ await NativeRNAppZungCodePushModule.clearPendingRestart();
24
+ this.isPending = true; // Mark the package as pending since it hasn't been applied yet
25
+ await updateInstalledCallback?.();
26
+ };
27
+ }
28
+
29
+ appVersion!: string;
30
+ description!: string;
31
+ failedInstall!: boolean;
32
+ isFirstRun!: boolean;
33
+ isMandatory!: boolean;
34
+ isPending = false; // A local package wouldn't be pending until it was installed
35
+ label!: string;
36
+ packageHash!: string;
37
+ packageSize!: number;
38
+ releaseChannelPublicId!: string;
39
+
40
+ install: (
41
+ installMode?: InstallMode,
42
+ minimumBackgroundDuration?: number,
43
+ onUpdateInstalled?: () => Promise<void> | void,
44
+ ) => Promise<void>;
45
+ }
@@ -0,0 +1,3 @@
1
+ import { type Spec } from './RNAppZungCodePushModuleSpec';
2
+
3
+ export const NativeRNAppZungCodePushModule = require('react-native').NativeModules.CodePush as Spec;
@@ -0,0 +1,54 @@
1
+ import { type TurboModule } from 'react-native';
2
+ import type { InstallMode } from '../enums/InstallMode.enum';
3
+ import type { UpdateState } from '../enums/UpdateState.enum';
4
+ import type { LocalPackage, RemotePackage, StatusReport } from '../types';
5
+ import type { Configuration, LatestRollbackInfo, OmitFunctions } from './types';
6
+
7
+ export interface Spec extends TurboModule {
8
+ addListener: (eventName: string) => void;
9
+ removeListeners: (count: number) => void;
10
+
11
+ getConstants(): {
12
+ codePushInstallModeImmediate: number;
13
+ codePushInstallModeOnNextRestart: number;
14
+ codePushInstallModeOnNextResume: number;
15
+ codePushInstallModeOnNextSuspend: number;
16
+
17
+ codePushUpdateStateLatest: number;
18
+ codePushUpdateStatePending: number;
19
+ codePushUpdateStateRunning: number;
20
+ };
21
+
22
+ getConfiguration(): Promise<Configuration>;
23
+
24
+ getUpdateMetadata(updateState: UpdateState): Promise<OmitFunctions<LocalPackage>>;
25
+ installUpdate(
26
+ localPackage: OmitFunctions<LocalPackage>,
27
+ installMode: InstallMode,
28
+ minimumBackgroundDuration: number,
29
+ ): Promise<void>;
30
+ downloadUpdate(
31
+ remotePackage: OmitFunctions<RemotePackage>,
32
+ notifyProgress: boolean,
33
+ ): Promise<OmitFunctions<LocalPackage>>;
34
+
35
+ restartApp(onlyIfUpdateIsPending: boolean): Promise<void>;
36
+ clearPendingRestart(): Promise<void>;
37
+
38
+ disallow(): Promise<void>;
39
+ allow(): Promise<void>;
40
+
41
+ clearUpdates(): void;
42
+
43
+ notifyApplicationReady(): Promise<void>;
44
+ setLatestRollbackInfo(packageHash: string): Promise<void>;
45
+
46
+ getNewStatusReport(): Promise<StatusReport>;
47
+ recordStatusReported(statusReport: StatusReport): void;
48
+ saveStatusReportForRetry(statusReport: StatusReport): void;
49
+
50
+ getLatestRollbackInfo(): Promise<LatestRollbackInfo>;
51
+
52
+ isFirstRun(packageHash: string): Promise<boolean>;
53
+ isFailedUpdate(packageHash: string): Promise<boolean>;
54
+ }
@@ -0,0 +1,69 @@
1
+ import type { Package } from 'code-push/script/acquisition-sdk';
2
+ import { NativeEventEmitter } from 'react-native';
3
+ import type { DownloadProgressCallback, LocalPackage, RemotePackage } from '../types';
4
+ import { LocalPackageImplementation } from './LocalPackageImplementation';
5
+ import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
6
+ import { log } from './utils/log';
7
+
8
+ export class RemotePackageImpl implements RemotePackage {
9
+ constructor(
10
+ remotePackageData: Omit<RemotePackage, 'download'>,
11
+ reportStatusDownload?: (downloadedPackage: Package) => Promise<void>,
12
+ ) {
13
+ Object.assign(this, remotePackageData);
14
+
15
+ this.download = async (downloadProgressCallback?: DownloadProgressCallback) => {
16
+ if (!this.downloadUrl) {
17
+ throw new Error('Cannot download an update without a download url');
18
+ }
19
+
20
+ let downloadProgressSubscription;
21
+
22
+ if (downloadProgressCallback) {
23
+ const codePushEventEmitter = new NativeEventEmitter(NativeRNAppZungCodePushModule);
24
+ // Use event subscription to obtain download progress.
25
+ downloadProgressSubscription = codePushEventEmitter.addListener(
26
+ 'CodePushDownloadProgress',
27
+ downloadProgressCallback,
28
+ );
29
+ }
30
+
31
+ // Use the downloaded package info. Native code will save the package info
32
+ // so that the client knows what the current package version is.
33
+ try {
34
+ const { ...updatePackageCopy } = remotePackageData; // In dev mode, React Native deep freezes any object queued over the bridge
35
+ const downloadedPackage = await NativeRNAppZungCodePushModule.downloadUpdate(
36
+ updatePackageCopy,
37
+ !!downloadProgressCallback,
38
+ );
39
+
40
+ if (reportStatusDownload) {
41
+ reportStatusDownload({
42
+ ...this,
43
+ deploymentKey: this.releaseChannelPublicId,
44
+ }).catch((err) => {
45
+ log(`Report download status failed: ${err}`);
46
+ });
47
+ }
48
+
49
+ return new LocalPackageImplementation(downloadedPackage);
50
+ } finally {
51
+ downloadProgressSubscription && downloadProgressSubscription.remove();
52
+ }
53
+ };
54
+ }
55
+
56
+ download: (downloadProgressCallback?: DownloadProgressCallback) => Promise<LocalPackage>;
57
+
58
+ appVersion!: string;
59
+ description!: string;
60
+ downloadUrl!: string;
61
+ failedInstall!: boolean;
62
+ isFirstRun!: boolean;
63
+ isMandatory!: boolean;
64
+ isPending = false; // A remote package could never be in a pending state
65
+ label!: string;
66
+ packageHash!: string;
67
+ packageSize!: number;
68
+ releaseChannelPublicId!: string;
69
+ }
@@ -0,0 +1,12 @@
1
+ import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
2
+ import type { Configuration } from './types';
3
+
4
+ let config: Configuration;
5
+
6
+ export async function getConfiguration() {
7
+ if (!config) {
8
+ config = await NativeRNAppZungCodePushModule.getConfiguration();
9
+ }
10
+
11
+ return config;
12
+ }
@@ -0,0 +1,6 @@
1
+ import { UpdateState } from '../enums/UpdateState.enum';
2
+ import { getUpdateMetadata } from '../getUpdateMetadata';
3
+
4
+ export async function getCurrentPackage() {
5
+ return await getUpdateMetadata(UpdateState.LATEST);
6
+ }