@appzung/react-native-code-push 11.0.0-rc1 → 11.0.0-rc10

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 (360) hide show
  1. package/CodePush.podspec +3 -5
  2. package/README.md +26 -24
  3. package/android/app/proguard-rules.pro +5 -0
  4. package/android/app/src/main/java/com/appzung/codepush/react/CodePush.java +4 -0
  5. package/android/app/src/main/java/com/appzung/codepush/react/CodePushConstants.java +2 -0
  6. package/android/app/src/main/java/com/appzung/codepush/react/CodePushNativeModule.java +86 -4
  7. package/android/app/src/main/java/com/appzung/codepush/react/ExpoUtils.java +22 -0
  8. package/ios/CodePush/CodePush.h +11 -6
  9. package/ios/CodePush/{CodePush.m → CodePush.mm} +132 -141
  10. package/ios/CodePush/CodePushConfig.m +54 -0
  11. package/ios/CodePush.xcodeproj/project.pbxproj +6 -6
  12. package/lib/commonjs/CodePush.js +11 -2
  13. package/lib/commonjs/CodePush.js.map +1 -1
  14. package/lib/commonjs/allowRestart.js +6 -2
  15. package/lib/commonjs/allowRestart.js.map +1 -1
  16. package/lib/commonjs/checkForUpdates.js +25 -26
  17. package/lib/commonjs/checkForUpdates.js.map +1 -1
  18. package/lib/commonjs/clearUpdates.js +6 -3
  19. package/lib/commonjs/clearUpdates.js.map +1 -1
  20. package/lib/commonjs/dataTransmission.js +28 -0
  21. package/lib/commonjs/dataTransmission.js.map +1 -0
  22. package/lib/commonjs/disallowRestart.js +6 -2
  23. package/lib/commonjs/disallowRestart.js.map +1 -1
  24. package/lib/commonjs/enums/CheckFrequency.enum.js +2 -2
  25. package/lib/commonjs/enums/InstallMode.enum.js +7 -3
  26. package/lib/commonjs/enums/InstallMode.enum.js.map +1 -1
  27. package/lib/commonjs/enums/LogLevel.enum.js +17 -0
  28. package/lib/commonjs/enums/LogLevel.enum.js.map +1 -0
  29. package/lib/commonjs/enums/SyncStatus.enum.js +7 -7
  30. package/lib/commonjs/enums/UpdateState.enum.js +7 -6
  31. package/lib/commonjs/enums/UpdateState.enum.js.map +1 -1
  32. package/lib/commonjs/getClientUniqueId.js +16 -0
  33. package/lib/commonjs/getClientUniqueId.js.map +1 -0
  34. package/lib/commonjs/index.js +90 -9
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/internals/CodePushApiSdk.errors.js +26 -0
  37. package/lib/commonjs/internals/CodePushApiSdk.errors.js.map +1 -0
  38. package/lib/commonjs/internals/CodePushApiSdk.js +122 -0
  39. package/lib/commonjs/internals/CodePushApiSdk.js.map +1 -0
  40. package/lib/commonjs/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +3 -2
  41. package/lib/commonjs/internals/CodePushApiSdk.types.js.map +1 -0
  42. package/lib/commonjs/internals/CodePushEventEmitter.js +10 -0
  43. package/lib/commonjs/internals/CodePushEventEmitter.js.map +1 -0
  44. package/lib/commonjs/internals/RemotePackageImplementation.js +9 -8
  45. package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -1
  46. package/lib/commonjs/internals/getConfiguration.js +4 -0
  47. package/lib/commonjs/internals/getConfiguration.js.map +1 -1
  48. package/lib/commonjs/internals/logger.js +51 -0
  49. package/lib/commonjs/internals/logger.js.map +1 -0
  50. package/lib/commonjs/internals/shouldUpdateBeIgnored.js +6 -5
  51. package/lib/commonjs/internals/shouldUpdateBeIgnored.js.map +1 -1
  52. package/lib/commonjs/internals/utils/fetchRetry.js +59 -0
  53. package/lib/commonjs/internals/utils/fetchRetry.js.map +1 -0
  54. package/lib/commonjs/internals/utils/log.js +10 -3
  55. package/lib/commonjs/internals/utils/log.js.map +1 -1
  56. package/lib/commonjs/internals/utils/queryStringify.js +25 -0
  57. package/lib/commonjs/internals/utils/queryStringify.js.map +1 -0
  58. package/lib/commonjs/internals/utils/requestFetchAdapter.js +38 -0
  59. package/lib/commonjs/internals/utils/requestFetchAdapter.js.map +1 -0
  60. package/lib/commonjs/internals/version.js +1 -1
  61. package/lib/commonjs/internals/version.js.map +1 -1
  62. package/lib/commonjs/logLevel.js +15 -0
  63. package/lib/commonjs/logLevel.js.map +1 -0
  64. package/lib/commonjs/logger.js +19 -0
  65. package/lib/commonjs/logger.js.map +1 -0
  66. package/lib/commonjs/notifyAppReady.js +26 -15
  67. package/lib/commonjs/notifyAppReady.js.map +1 -1
  68. package/lib/commonjs/resetClientUniqueId.js +18 -0
  69. package/lib/commonjs/resetClientUniqueId.js.map +1 -0
  70. package/lib/commonjs/restartApp.js +4 -2
  71. package/lib/commonjs/restartApp.js.map +1 -1
  72. package/lib/commonjs/sync.js +35 -28
  73. package/lib/commonjs/sync.js.map +1 -1
  74. package/lib/commonjs/telemetry.js +28 -0
  75. package/lib/commonjs/telemetry.js.map +1 -0
  76. package/lib/module/CodePush.js +11 -2
  77. package/lib/module/CodePush.js.map +1 -1
  78. package/lib/module/allowRestart.js +5 -1
  79. package/lib/module/allowRestart.js.map +1 -1
  80. package/lib/module/checkForUpdates.js +25 -26
  81. package/lib/module/checkForUpdates.js.map +1 -1
  82. package/lib/module/clearUpdates.js +5 -2
  83. package/lib/module/clearUpdates.js.map +1 -1
  84. package/lib/module/dataTransmission.js +24 -0
  85. package/lib/module/dataTransmission.js.map +1 -0
  86. package/lib/module/disallowRestart.js +5 -1
  87. package/lib/module/disallowRestart.js.map +1 -1
  88. package/lib/module/enums/CheckFrequency.enum.js +2 -2
  89. package/lib/module/enums/InstallMode.enum.js +7 -3
  90. package/lib/module/enums/InstallMode.enum.js.map +1 -1
  91. package/lib/module/enums/LogLevel.enum.js +13 -0
  92. package/lib/module/enums/LogLevel.enum.js.map +1 -0
  93. package/lib/module/enums/SyncStatus.enum.js +7 -7
  94. package/lib/module/enums/UpdateState.enum.js +7 -6
  95. package/lib/module/enums/UpdateState.enum.js.map +1 -1
  96. package/lib/module/getClientUniqueId.js +12 -0
  97. package/lib/module/getClientUniqueId.js.map +1 -0
  98. package/lib/module/index.js +8 -1
  99. package/lib/module/index.js.map +1 -1
  100. package/lib/module/internals/CodePushApiSdk.errors.js +20 -0
  101. package/lib/module/internals/CodePushApiSdk.errors.js.map +1 -0
  102. package/lib/module/internals/CodePushApiSdk.js +118 -0
  103. package/lib/module/internals/CodePushApiSdk.js.map +1 -0
  104. package/lib/module/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +2 -1
  105. package/lib/module/internals/CodePushApiSdk.types.js.map +1 -0
  106. package/lib/module/internals/CodePushEventEmitter.js +6 -0
  107. package/lib/module/internals/CodePushEventEmitter.js.map +1 -0
  108. package/lib/module/internals/RemotePackageImplementation.js +9 -8
  109. package/lib/module/internals/RemotePackageImplementation.js.map +1 -1
  110. package/lib/module/internals/getConfiguration.js +3 -0
  111. package/lib/module/internals/getConfiguration.js.map +1 -1
  112. package/lib/module/internals/logger.js +44 -0
  113. package/lib/module/internals/logger.js.map +1 -0
  114. package/lib/module/internals/shouldUpdateBeIgnored.js +6 -5
  115. package/lib/module/internals/shouldUpdateBeIgnored.js.map +1 -1
  116. package/lib/module/internals/utils/fetchRetry.js +55 -0
  117. package/lib/module/internals/utils/fetchRetry.js.map +1 -0
  118. package/lib/module/internals/utils/log.js +11 -3
  119. package/lib/module/internals/utils/log.js.map +1 -1
  120. package/lib/module/internals/utils/queryStringify.js +21 -0
  121. package/lib/module/internals/utils/queryStringify.js.map +1 -0
  122. package/lib/module/internals/utils/requestFetchAdapter.js +34 -0
  123. package/lib/module/internals/utils/requestFetchAdapter.js.map +1 -0
  124. package/lib/module/internals/version.js +1 -1
  125. package/lib/module/internals/version.js.map +1 -1
  126. package/lib/module/logLevel.js +9 -0
  127. package/lib/module/logLevel.js.map +1 -0
  128. package/lib/module/logger.js +4 -0
  129. package/lib/module/logger.js.map +1 -0
  130. package/lib/module/notifyAppReady.js +26 -15
  131. package/lib/module/notifyAppReady.js.map +1 -1
  132. package/lib/module/resetClientUniqueId.js +14 -0
  133. package/lib/module/resetClientUniqueId.js.map +1 -0
  134. package/lib/module/restartApp.js +4 -2
  135. package/lib/module/restartApp.js.map +1 -1
  136. package/lib/module/sync.js +35 -28
  137. package/lib/module/sync.js.map +1 -1
  138. package/lib/module/telemetry.js +24 -0
  139. package/lib/module/telemetry.js.map +1 -0
  140. package/lib/typescript/commonjs/src/CodePush.d.ts +10 -5
  141. package/lib/typescript/commonjs/src/CodePush.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/allowRestart.d.ts +3 -1
  143. package/lib/typescript/commonjs/src/allowRestart.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/clearUpdates.d.ts +3 -2
  146. package/lib/typescript/commonjs/src/clearUpdates.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/dataTransmission.d.ts +13 -0
  148. package/lib/typescript/commonjs/src/dataTransmission.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/src/disallowRestart.d.ts +3 -1
  150. package/lib/typescript/commonjs/src/disallowRestart.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/src/enums/CheckFrequency.enum.d.ts +2 -2
  152. package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts +7 -3
  153. package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts +10 -0
  155. package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/src/enums/SyncStatus.enum.d.ts +7 -7
  157. package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts +7 -6
  158. package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/src/getClientUniqueId.d.ts +5 -0
  160. package/lib/typescript/commonjs/src/getClientUniqueId.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/src/index.d.ts +8 -1
  162. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts +15 -0
  164. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts +9 -0
  166. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
  167. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts +103 -0
  168. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/src/internals/CodePushEventEmitter.d.ts +3 -0
  170. package/lib/typescript/commonjs/src/internals/CodePushEventEmitter.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts +5 -0
  172. package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
  173. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts +2 -2
  174. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts +1 -0
  176. package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/src/internals/logger.d.ts +33 -0
  178. package/lib/typescript/commonjs/src/internals/logger.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
  180. package/lib/typescript/commonjs/src/internals/types.d.ts +2 -2
  181. package/lib/typescript/commonjs/src/internals/types.d.ts.map +1 -1
  182. package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts +9 -0
  183. package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/src/internals/utils/log.d.ts +2 -1
  185. package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -1
  186. package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts +4 -0
  187. package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts +3 -0
  189. package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/src/internals/version.d.ts +1 -1
  191. package/lib/typescript/commonjs/src/internals/version.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/src/logLevel.d.ts +4 -0
  193. package/lib/typescript/commonjs/src/logLevel.d.ts.map +1 -0
  194. package/lib/typescript/commonjs/src/logger.d.ts +3 -0
  195. package/lib/typescript/commonjs/src/logger.d.ts.map +1 -0
  196. package/lib/typescript/commonjs/src/notifyAppReady.d.ts +4 -0
  197. package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -1
  198. package/lib/typescript/commonjs/src/resetClientUniqueId.d.ts +5 -0
  199. package/lib/typescript/commonjs/src/resetClientUniqueId.d.ts.map +1 -0
  200. package/lib/typescript/commonjs/src/restartApp.d.ts +2 -0
  201. package/lib/typescript/commonjs/src/restartApp.d.ts.map +1 -1
  202. package/lib/typescript/commonjs/src/sync.d.ts +5 -1
  203. package/lib/typescript/commonjs/src/sync.d.ts.map +1 -1
  204. package/lib/typescript/commonjs/src/telemetry.d.ts +13 -0
  205. package/lib/typescript/commonjs/src/telemetry.d.ts.map +1 -0
  206. package/lib/typescript/commonjs/src/types.d.ts +72 -29
  207. package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
  208. package/lib/typescript/module/src/CodePush.d.ts +10 -5
  209. package/lib/typescript/module/src/CodePush.d.ts.map +1 -1
  210. package/lib/typescript/module/src/allowRestart.d.ts +3 -1
  211. package/lib/typescript/module/src/allowRestart.d.ts.map +1 -1
  212. package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -1
  213. package/lib/typescript/module/src/clearUpdates.d.ts +3 -2
  214. package/lib/typescript/module/src/clearUpdates.d.ts.map +1 -1
  215. package/lib/typescript/module/src/dataTransmission.d.ts +13 -0
  216. package/lib/typescript/module/src/dataTransmission.d.ts.map +1 -0
  217. package/lib/typescript/module/src/disallowRestart.d.ts +3 -1
  218. package/lib/typescript/module/src/disallowRestart.d.ts.map +1 -1
  219. package/lib/typescript/module/src/enums/CheckFrequency.enum.d.ts +2 -2
  220. package/lib/typescript/module/src/enums/InstallMode.enum.d.ts +7 -3
  221. package/lib/typescript/module/src/enums/InstallMode.enum.d.ts.map +1 -1
  222. package/lib/typescript/module/src/enums/LogLevel.enum.d.ts +10 -0
  223. package/lib/typescript/module/src/enums/LogLevel.enum.d.ts.map +1 -0
  224. package/lib/typescript/module/src/enums/SyncStatus.enum.d.ts +7 -7
  225. package/lib/typescript/module/src/enums/UpdateState.enum.d.ts +7 -6
  226. package/lib/typescript/module/src/enums/UpdateState.enum.d.ts.map +1 -1
  227. package/lib/typescript/module/src/getClientUniqueId.d.ts +5 -0
  228. package/lib/typescript/module/src/getClientUniqueId.d.ts.map +1 -0
  229. package/lib/typescript/module/src/index.d.ts +8 -1
  230. package/lib/typescript/module/src/index.d.ts.map +1 -1
  231. package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts +15 -0
  232. package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts.map +1 -0
  233. package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts +9 -0
  234. package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
  235. package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts +103 -0
  236. package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
  237. package/lib/typescript/module/src/internals/CodePushEventEmitter.d.ts +3 -0
  238. package/lib/typescript/module/src/internals/CodePushEventEmitter.d.ts.map +1 -0
  239. package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts +5 -0
  240. package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
  241. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts +2 -2
  242. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -1
  243. package/lib/typescript/module/src/internals/getConfiguration.d.ts +1 -0
  244. package/lib/typescript/module/src/internals/getConfiguration.d.ts.map +1 -1
  245. package/lib/typescript/module/src/internals/logger.d.ts +33 -0
  246. package/lib/typescript/module/src/internals/logger.d.ts.map +1 -0
  247. package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
  248. package/lib/typescript/module/src/internals/types.d.ts +2 -2
  249. package/lib/typescript/module/src/internals/types.d.ts.map +1 -1
  250. package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts +9 -0
  251. package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts.map +1 -0
  252. package/lib/typescript/module/src/internals/utils/log.d.ts +2 -1
  253. package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -1
  254. package/lib/typescript/module/src/internals/utils/queryStringify.d.ts +4 -0
  255. package/lib/typescript/module/src/internals/utils/queryStringify.d.ts.map +1 -0
  256. package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts +3 -0
  257. package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
  258. package/lib/typescript/module/src/internals/version.d.ts +1 -1
  259. package/lib/typescript/module/src/internals/version.d.ts.map +1 -1
  260. package/lib/typescript/module/src/logLevel.d.ts +4 -0
  261. package/lib/typescript/module/src/logLevel.d.ts.map +1 -0
  262. package/lib/typescript/module/src/logger.d.ts +3 -0
  263. package/lib/typescript/module/src/logger.d.ts.map +1 -0
  264. package/lib/typescript/module/src/notifyAppReady.d.ts +4 -0
  265. package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -1
  266. package/lib/typescript/module/src/resetClientUniqueId.d.ts +5 -0
  267. package/lib/typescript/module/src/resetClientUniqueId.d.ts.map +1 -0
  268. package/lib/typescript/module/src/restartApp.d.ts +2 -0
  269. package/lib/typescript/module/src/restartApp.d.ts.map +1 -1
  270. package/lib/typescript/module/src/sync.d.ts +5 -1
  271. package/lib/typescript/module/src/sync.d.ts.map +1 -1
  272. package/lib/typescript/module/src/telemetry.d.ts +13 -0
  273. package/lib/typescript/module/src/telemetry.d.ts.map +1 -0
  274. package/lib/typescript/module/src/types.d.ts +72 -29
  275. package/lib/typescript/module/src/types.d.ts.map +1 -1
  276. package/package.json +24 -13
  277. package/scripts/generateBundledResourcesHash.js +73 -68
  278. package/scripts/getFilesInFolder.js +12 -12
  279. package/scripts/recordFilesBeforeBundleCommand.js +19 -20
  280. package/src/CodePush.tsx +20 -5
  281. package/src/allowRestart.ts +5 -1
  282. package/src/checkForUpdates.ts +26 -24
  283. package/src/clearUpdates.ts +5 -2
  284. package/src/dataTransmission.ts +21 -0
  285. package/src/disallowRestart.ts +5 -1
  286. package/src/enums/CheckFrequency.enum.ts +2 -2
  287. package/src/enums/InstallMode.enum.ts +7 -3
  288. package/src/enums/LogLevel.enum.ts +9 -0
  289. package/src/enums/SyncStatus.enum.ts +7 -7
  290. package/src/enums/UpdateState.enum.ts +7 -6
  291. package/src/getClientUniqueId.ts +9 -0
  292. package/src/index.ts +8 -1
  293. package/src/internals/CodePushApiSdk.errors.ts +22 -0
  294. package/src/internals/CodePushApiSdk.ts +160 -0
  295. package/src/internals/CodePushApiSdk.types.ts +117 -0
  296. package/src/internals/CodePushEventEmitter.ts +4 -0
  297. package/src/internals/RNAppZungCodePushModuleSpec.ts +7 -0
  298. package/src/internals/RemotePackageImplementation.ts +11 -10
  299. package/src/internals/getConfiguration.ts +4 -0
  300. package/src/internals/logger.ts +46 -0
  301. package/src/internals/shouldUpdateBeIgnored.ts +6 -5
  302. package/src/internals/types.ts +2 -2
  303. package/src/internals/utils/fetchRetry.ts +72 -0
  304. package/src/internals/utils/log.ts +13 -3
  305. package/src/internals/utils/queryStringify.ts +22 -0
  306. package/src/internals/utils/requestFetchAdapter.ts +36 -0
  307. package/src/internals/version.ts +1 -1
  308. package/src/logLevel.ts +9 -0
  309. package/src/logger.ts +2 -0
  310. package/src/notifyAppReady.ts +29 -18
  311. package/src/resetClientUniqueId.ts +11 -0
  312. package/src/restartApp.ts +4 -2
  313. package/src/sync.ts +41 -27
  314. package/src/telemetry.ts +21 -0
  315. package/src/types.ts +72 -29
  316. package/android/app/.gradle/config.properties +0 -2
  317. package/android/app/local.properties +0 -8
  318. package/docs/advanced-usage.md +0 -56
  319. package/docs/api-android.md +0 -22
  320. package/docs/api-ios.md +0 -19
  321. package/docs/api-js.md +0 -557
  322. package/docs/code-signing.md +0 -62
  323. package/docs/migrating-to-v10.md +0 -31
  324. package/docs/setup-android.md +0 -81
  325. package/docs/setup-ios.md +0 -108
  326. package/docs/setup-windows.md +0 -55
  327. package/lib/commonjs/enums/DeploymentStatus.enum.js.map +0 -1
  328. package/lib/commonjs/internals/AcquisitionSdk.js +0 -9
  329. package/lib/commonjs/internals/AcquisitionSdk.js.map +0 -1
  330. package/lib/commonjs/internals/getPromisifiedSdk.js +0 -49
  331. package/lib/commonjs/internals/getPromisifiedSdk.js.map +0 -1
  332. package/lib/commonjs/internals/utils/request-fetch-adapter.js +0 -50
  333. package/lib/commonjs/internals/utils/request-fetch-adapter.js.map +0 -1
  334. package/lib/module/enums/DeploymentStatus.enum.js.map +0 -1
  335. package/lib/module/internals/AcquisitionSdk.js +0 -5
  336. package/lib/module/internals/AcquisitionSdk.js.map +0 -1
  337. package/lib/module/internals/getPromisifiedSdk.js +0 -45
  338. package/lib/module/internals/getPromisifiedSdk.js.map +0 -1
  339. package/lib/module/internals/utils/request-fetch-adapter.js +0 -46
  340. package/lib/module/internals/utils/request-fetch-adapter.js.map +0 -1
  341. package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts +0 -14
  342. package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
  343. package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts +0 -3
  344. package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts.map +0 -1
  345. package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts +0 -13
  346. package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts.map +0 -1
  347. package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts +0 -3
  348. package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
  349. package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts +0 -14
  350. package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
  351. package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts +0 -3
  352. package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts.map +0 -1
  353. package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts +0 -13
  354. package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts.map +0 -1
  355. package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts +0 -3
  356. package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
  357. package/src/enums/DeploymentStatus.enum.ts +0 -14
  358. package/src/internals/AcquisitionSdk.ts +0 -3
  359. package/src/internals/getPromisifiedSdk.ts +0 -72
  360. package/src/internals/utils/request-fetch-adapter.ts +0 -58
@@ -6,18 +6,22 @@ import { NativeRNAppZungCodePushModule } from '../internals/NativeRNAppZungCodeP
6
6
  export enum InstallMode {
7
7
  /**
8
8
  * Indicates that you want to install the update and restart the app immediately.
9
+ *
10
+ * This value is appropriate for debugging scenarios as well as when displaying an update prompt to the user, since they would expect to see the changes immediately after accepting the installation. Additionally, this mode can be used to enforce mandatory updates, since it removes the potentially undesired latency between the update installation and the next time the end user restarts or resumes the app.
9
11
  */
10
12
  IMMEDIATE = NativeRNAppZungCodePushModule.getConstants().codePushInstallModeImmediate,
11
13
 
12
14
  /**
13
15
  * Indicates that you want to install the update, but not forcibly restart the app.
16
+ *
17
+ * When the app is "naturally" restarted (due the OS or end user killing it), the update will be seamlessly picked up. This value is appropriate when performing silent updates, since it would likely be disruptive to the end user if the app suddenly restarted out of nowhere, since they wouldn't have realized an update was even downloaded. This is the default mode used for both the `sync` and `LocalPackage.install` methods.
14
18
  */
15
19
  ON_NEXT_RESTART = NativeRNAppZungCodePushModule.getConstants().codePushInstallModeOnNextRestart,
16
20
 
17
21
  /**
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.
22
+ * Indicates that you want to install the update, but don't want to restart the app until the next time the end user resumes it from the background.
23
+ *
24
+ * This way, you don't disrupt their current session,but you can get the update in front of them sooner than having to wait for the next natural restart.
21
25
  * This value is appropriate for silent installs that can be applied on resume in a non-invasive way.
22
26
  */
23
27
  ON_NEXT_RESUME = NativeRNAppZungCodePushModule.getConstants().codePushInstallModeOnNextResume,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Used to categorize log messages by their severity and importance.
3
+ */
4
+ export enum LogLevel {
5
+ DEBUG,
6
+ INFO,
7
+ WARN,
8
+ ERROR,
9
+ }
@@ -3,30 +3,30 @@
3
3
  */
4
4
  export enum SyncStatus {
5
5
  /**
6
- * The app is up-to-date with the CodePush server.
6
+ * The app is fully up-to-date with the configured release channel.
7
7
  */
8
8
  UP_TO_DATE,
9
9
 
10
10
  /**
11
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
12
+ * `syncStatusChangedCallback` function returns or the next time the app resumes/restarts,
13
+ * depending on the `InstallMode` specified in `SyncOptions`
14
14
  */
15
15
  UPDATE_INSTALLED,
16
16
 
17
17
  /**
18
18
  * The app had an optional update which the end user chose to ignore.
19
- * (This is only applicable when the updateDialog is used)
19
+ * (This is only applicable when the `updateDialog` is used)
20
20
  */
21
21
  UPDATE_IGNORED,
22
22
 
23
23
  /**
24
- * The sync operation encountered an unknown error.
24
+ * The `sync` operation encountered an unknown error.
25
25
  */
26
26
  UNKNOWN_ERROR,
27
27
 
28
28
  /**
29
- * There is an ongoing sync operation running which prevents the current call from being executed.
29
+ * There is an ongoing `sync` operation running which prevents the current call from being executed.
30
30
  */
31
31
  SYNC_IN_PROGRESS,
32
32
 
@@ -37,7 +37,7 @@ export enum SyncStatus {
37
37
 
38
38
  /**
39
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)
40
+ * to the end user. (This is only applicable when the `updateDialog` is used)
41
41
  */
42
42
  AWAITING_USER_ACTION,
43
43
 
@@ -5,20 +5,21 @@ import { NativeRNAppZungCodePushModule } from '../internals/NativeRNAppZungCodeP
5
5
  */
6
6
  export enum UpdateState {
7
7
  /**
8
- * Indicates that an update represents the
9
- * version of the app that is currently running.
8
+ * Indicates that an update represents the version of the app that is currently running.
9
+ *
10
+ * This can be useful for identifying attributes about the app, for scenarios such as displaying the release description in a "what's new?" dialog or reporting the latest version to an analytics and/or crash reporting service.
10
11
  */
11
12
  RUNNING = NativeRNAppZungCodePushModule.getConstants().codePushUpdateStateRunning,
12
13
 
13
14
  /**
14
- * Indicates than an update has been installed, but the
15
- * app hasn't been restarted yet in order to apply it.
15
+ * Indicates than an update has been installed, but the app hasn't been restarted yet in order to apply it.
16
+ *
17
+ * This can be useful for determining whether there is a pending update, which you may want to force a programmatic restart (via `restartApp`) in order to apply.
16
18
  */
17
19
  PENDING = NativeRNAppZungCodePushModule.getConstants().codePushUpdateStatePending,
18
20
 
19
21
  /**
20
- * Indicates than an update represents the latest available
21
- * release, and can be either currently running or pending.
22
+ * Indicates than an update represents the latest available release, and can be either currently running or pending.
22
23
  */
23
24
  LATEST = NativeRNAppZungCodePushModule.getConstants().codePushUpdateStateLatest,
24
25
  }
@@ -0,0 +1,9 @@
1
+ import { getConfiguration } from './internals/getConfiguration';
2
+
3
+ /**
4
+ * Gets the client's unique ID set by the module. You may also see `resetClientUniqueId`.
5
+ */
6
+ export const getClientUniqueId = async () => {
7
+ const nativeConfig = await getConfiguration();
8
+ return nativeConfig.clientUniqueId;
9
+ };
package/src/index.ts CHANGED
@@ -8,11 +8,18 @@ export * from './getUpdateMetadata';
8
8
  export * from './notifyAppReady';
9
9
  export * from './restartApp';
10
10
  export * from './sync';
11
+ export * from './getClientUniqueId';
12
+ export * from './resetClientUniqueId';
13
+ export * from './logLevel';
14
+ export * from './logger';
15
+ export * from './telemetry';
16
+ export * from './dataTransmission';
11
17
 
12
18
  export * from './types';
13
19
 
14
20
  export * from './enums/SyncStatus.enum';
15
21
  export * from './enums/InstallMode.enum';
16
22
  export * from './enums/UpdateState.enum';
17
- export * from './enums/DeploymentStatus.enum';
23
+ export { DeploymentStatus } from './internals/CodePushApiSdk.types';
18
24
  export * from './enums/CheckFrequency.enum';
25
+ export * from './enums/LogLevel.enum';
@@ -0,0 +1,22 @@
1
+ export class CodePushError extends Error {
2
+ constructor(message: string) {
3
+ super(message);
4
+ this.name = 'CodePushError';
5
+ }
6
+ }
7
+
8
+ export class CodePushHttpError extends CodePushError {
9
+ constructor(
10
+ readonly url: string,
11
+ readonly statusCode: number,
12
+ message: string,
13
+ ) {
14
+ super(message);
15
+
16
+ if (statusCode === 0) {
17
+ this.message = `Couldn't send request to ${url}, xhr.statusCode = 0 was returned. One of the possible reasons for that might be connection problems. Please, check your internet connection.`;
18
+ }
19
+
20
+ this.name = 'CodePushHttpError';
21
+ }
22
+ }
@@ -0,0 +1,160 @@
1
+ import { LogLevel } from '../enums/LogLevel.enum';
2
+ import { CodePushError, CodePushHttpError } from './CodePushApiSdk.errors';
3
+ import {
4
+ type ApiSdkConfiguration,
5
+ type ApiSdkDeployReportPackageInfo,
6
+ type ApiSdkDownloadReportPackageInfo,
7
+ type ApiSdkNativeUpdateNotification,
8
+ type ApiSdkQueryUpdatePackageInfo,
9
+ type ApiSdkRemotePackage,
10
+ type CheckUpdateRequestInput,
11
+ type CheckUpdateResponse,
12
+ DeploymentStatus,
13
+ type Http,
14
+ type ReportDeployInput,
15
+ type ReportDownloadInput,
16
+ } from './CodePushApiSdk.types';
17
+ import { queryStringify } from './utils/queryStringify';
18
+
19
+ // TODO move this to @appzung/code-push-api-sdk
20
+
21
+ export class CodePushApiSdk {
22
+ private configuration: ApiSdkConfiguration;
23
+
24
+ constructor(
25
+ private readonly httpRequester: Http.Requester,
26
+ private readonly log: (level: LogLevel, message: string) => void,
27
+ configuration: ApiSdkConfiguration,
28
+ ) {
29
+ this.configuration = { ...configuration };
30
+ if (this.configuration.serverUrl.slice(-1) !== '/') {
31
+ this.configuration.serverUrl += '/';
32
+ }
33
+ this.configuration.serverUrl += 'v0.1/public/codepush';
34
+ }
35
+
36
+ async queryUpdateWithCurrentPackage(
37
+ currentPackageInfo: ApiSdkQueryUpdatePackageInfo,
38
+ ): Promise<ApiSdkRemotePackage | ApiSdkNativeUpdateNotification | null> {
39
+ if (!this.configuration.dataTransmissionEnabled) {
40
+ this.log(LogLevel.DEBUG, 'Skipped querying for update because data transmission is disabled');
41
+ return null;
42
+ }
43
+
44
+ const query: CheckUpdateRequestInput = {
45
+ deployment_key: this.configuration.releaseChannelPublicId,
46
+ app_version: currentPackageInfo.appVersion,
47
+ package_hash: currentPackageInfo.packageHash,
48
+ is_companion: this.configuration.ignoreAppVersion,
49
+ label: currentPackageInfo.label,
50
+ client_unique_id: this.configuration.clientUniqueId,
51
+ };
52
+
53
+ const url = `${this.configuration.serverUrl}/update_check?${queryStringify(query)}`;
54
+
55
+ const response = await this.httpRequester.request('GET', url);
56
+
57
+ if (response.statusCode < 200 || response.statusCode >= 300) {
58
+ throw new CodePushHttpError(url, response.statusCode, response.body || 'No body');
59
+ }
60
+
61
+ const responseObject: CheckUpdateResponse | Record<string, never> = JSON.parse(response.body || '{}');
62
+ if (!responseObject.update_info) {
63
+ throw new CodePushError('Missing update info in response');
64
+ }
65
+
66
+ const { update_info: updateInfo } = responseObject;
67
+
68
+ if (updateInfo.update_app_version) {
69
+ return {
70
+ updateAppVersion: true,
71
+ appVersion: responseObject.update_info.target_binary_range,
72
+ };
73
+ }
74
+
75
+ if (!updateInfo.is_available) {
76
+ return null;
77
+ }
78
+
79
+ return {
80
+ releaseChannelPublicId: this.configuration.releaseChannelPublicId,
81
+ description: updateInfo.description,
82
+ label: updateInfo.label,
83
+ appVersion: updateInfo.target_binary_range,
84
+ isMandatory: updateInfo.is_mandatory,
85
+ packageHash: updateInfo.package_hash,
86
+ packageSize: updateInfo.package_size,
87
+ downloadUrl: updateInfo.download_url,
88
+ };
89
+ }
90
+
91
+ async reportStatusDeploy(
92
+ deployedPackageInfo: { package: ApiSdkDeployReportPackageInfo; status: DeploymentStatus } | null,
93
+ previousLabelOrAppVersion: string | null,
94
+ previousDeploymentKey: string | null,
95
+ ): Promise<void> {
96
+ if (!this.configuration.dataTransmissionEnabled) {
97
+ this.log(LogLevel.DEBUG, 'Skipped reporting deploy status because data transmission is disabled');
98
+ return;
99
+ }
100
+
101
+ if (!this.configuration.telemetryEnabled) {
102
+ this.log(LogLevel.DEBUG, 'Skipped reporting deploy status because telemetry is disabled');
103
+ return;
104
+ }
105
+
106
+ const requestBody: ReportDeployInput = {
107
+ app_version: this.configuration.appVersion,
108
+ deployment_key: this.configuration.releaseChannelPublicId,
109
+ client_unique_id: this.configuration.clientUniqueId,
110
+ };
111
+
112
+ if (deployedPackageInfo) {
113
+ requestBody.label = deployedPackageInfo.package.label;
114
+ requestBody.app_version = deployedPackageInfo.package.appVersion;
115
+ requestBody.status = deployedPackageInfo.status;
116
+ }
117
+
118
+ if (previousLabelOrAppVersion) {
119
+ requestBody.previous_label_or_app_version = previousLabelOrAppVersion;
120
+ }
121
+
122
+ if (previousDeploymentKey) {
123
+ requestBody.previous_deployment_key = previousDeploymentKey;
124
+ }
125
+
126
+ const url = `${this.configuration.serverUrl}/report_status/deploy`;
127
+
128
+ const response = await this.httpRequester.request('POST', url, JSON.stringify(requestBody));
129
+
130
+ if (response.statusCode < 200 || response.statusCode >= 300) {
131
+ throw new CodePushHttpError(url, response.statusCode, response.body || 'No body');
132
+ }
133
+ }
134
+
135
+ async reportStatusDownload(downloadedPackage: ApiSdkDownloadReportPackageInfo): Promise<void> {
136
+ if (!this.configuration.dataTransmissionEnabled) {
137
+ this.log(LogLevel.DEBUG, 'Skipped reporting download because data transmission is disabled');
138
+ return;
139
+ }
140
+
141
+ if (!this.configuration.telemetryEnabled) {
142
+ this.log(LogLevel.DEBUG, 'Skipped reporting download because telemetry is disabled');
143
+ return;
144
+ }
145
+
146
+ const requestBody: ReportDownloadInput = {
147
+ client_unique_id: this.configuration.clientUniqueId,
148
+ deployment_key: this.configuration.releaseChannelPublicId,
149
+ label: downloadedPackage.label,
150
+ };
151
+
152
+ const url = `${this.configuration.serverUrl}/report_status/download`;
153
+
154
+ const response = await this.httpRequester.request('POST', url, JSON.stringify(requestBody));
155
+
156
+ if (response.statusCode < 200 || response.statusCode >= 300) {
157
+ throw new CodePushHttpError(url, response.statusCode, response.body || 'No body');
158
+ }
159
+ }
160
+ }
@@ -0,0 +1,117 @@
1
+ export interface ApiSdkQueryUpdatePackageInfo {
2
+ appVersion: string;
3
+ label?: string;
4
+ packageHash?: string;
5
+ }
6
+
7
+ export interface ApiSdkDeployReportPackageInfo {
8
+ label: string;
9
+ appVersion: string;
10
+ }
11
+
12
+ export interface ApiSdkDownloadReportPackageInfo {
13
+ label: string;
14
+ }
15
+
16
+ export interface ApiSdkRemotePackage {
17
+ releaseChannelPublicId: string;
18
+ label: string;
19
+ appVersion: string;
20
+ description: string;
21
+ isMandatory: boolean;
22
+ packageSize: number;
23
+ packageHash: string;
24
+ downloadUrl: string;
25
+ }
26
+
27
+ export interface ApiSdkNativeUpdateNotification {
28
+ updateAppVersion: true;
29
+ appVersion: string;
30
+ }
31
+
32
+ export namespace Http {
33
+ export interface Response {
34
+ statusCode: number;
35
+ body?: string;
36
+ }
37
+
38
+ export interface Requester {
39
+ request(verb: 'GET' | 'POST', url: string, requestBody?: string | object | null): Promise<Response>;
40
+ }
41
+ }
42
+
43
+ export interface ApiSdkConfiguration {
44
+ appVersion: string;
45
+ clientUniqueId: string;
46
+ releaseChannelPublicId: string;
47
+ serverUrl: string;
48
+ dataTransmissionEnabled: boolean;
49
+ telemetryEnabled: boolean;
50
+ ignoreAppVersion?: boolean;
51
+ }
52
+
53
+ /**
54
+ * Indicates the status of a deployment (after installing and restarting).
55
+ */
56
+ export enum DeploymentStatus {
57
+ /**
58
+ * The deployment failed (and was rolled back).
59
+ */
60
+ FAILED = 'DeploymentFailed',
61
+
62
+ /**
63
+ * The deployment succeeded.
64
+ */
65
+ SUCCEEDED = 'DeploymentSucceeded',
66
+ }
67
+
68
+ export interface ReportDeployInput {
69
+ deployment_key: string;
70
+ app_version: string;
71
+ status?: DeploymentStatus;
72
+ label?: string;
73
+ client_unique_id?: string;
74
+ previous_label_or_app_version?: string;
75
+ previous_deployment_key?: string;
76
+ }
77
+
78
+ export interface ReportDownloadInput {
79
+ deployment_key: string;
80
+ label: string;
81
+ client_unique_id?: string;
82
+ }
83
+
84
+ export interface CheckUpdateRequestInput {
85
+ deployment_key: string;
86
+ app_version: string;
87
+ package_hash?: string;
88
+ label?: string;
89
+ client_unique_id?: string;
90
+ is_companion?: boolean;
91
+ previous_label_or_app_version?: string;
92
+ previous_deployment_key?: string;
93
+ }
94
+
95
+ export interface CheckUpdateResponse {
96
+ update_info:
97
+ | {
98
+ is_available: true;
99
+ target_binary_range: string;
100
+ description: string;
101
+ is_disabled: boolean;
102
+ is_mandatory: boolean;
103
+ rollout: number;
104
+ download_url: string;
105
+ package_size: number;
106
+ package_hash: string;
107
+ label: string;
108
+ should_run_binary_version: boolean;
109
+ update_app_version: boolean;
110
+ }
111
+ | {
112
+ is_available: false;
113
+ should_run_binary_version: boolean;
114
+ target_binary_range: string;
115
+ update_app_version?: boolean;
116
+ };
117
+ }
@@ -0,0 +1,4 @@
1
+ import { NativeEventEmitter } from 'react-native';
2
+ import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
3
+
4
+ export const CodePushEventEmitter = new NativeEventEmitter(NativeRNAppZungCodePushModule);
@@ -20,6 +20,7 @@ export interface Spec extends TurboModule {
20
20
  };
21
21
 
22
22
  getConfiguration(): Promise<Configuration>;
23
+ resetClientUniqueId(): Promise<string>;
23
24
 
24
25
  getUpdateMetadata(updateState: UpdateState): Promise<OmitFunctions<LocalPackage>>;
25
26
  installUpdate(
@@ -51,4 +52,10 @@ export interface Spec extends TurboModule {
51
52
 
52
53
  isFirstRun(packageHash: string): Promise<boolean>;
53
54
  isFailedUpdate(packageHash: string): Promise<boolean>;
55
+
56
+ setTelemetryEnabled(enabled: boolean): Promise<void>;
57
+ getTelemetryEnabled(): Promise<boolean>;
58
+
59
+ setDataTransmissionEnabled(enabled: boolean): Promise<void>;
60
+ getDataTransmissionEnabled(): Promise<boolean>;
54
61
  }
@@ -1,6 +1,7 @@
1
- import type { Package } from 'code-push/script/acquisition-sdk';
2
- import { NativeEventEmitter } from 'react-native';
1
+ import { LogLevel } from '../enums/LogLevel.enum';
3
2
  import type { DownloadProgressCallback, LocalPackage, RemotePackage } from '../types';
3
+ import type { ApiSdkDownloadReportPackageInfo } from './CodePushApiSdk.types';
4
+ import { CodePushEventEmitter } from './CodePushEventEmitter';
4
5
  import { LocalPackageImplementation } from './LocalPackageImplementation';
5
6
  import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
6
7
  import { log } from './utils/log';
@@ -8,7 +9,7 @@ import { log } from './utils/log';
8
9
  export class RemotePackageImpl implements RemotePackage {
9
10
  constructor(
10
11
  remotePackageData: Omit<RemotePackage, 'download'>,
11
- reportStatusDownload?: (downloadedPackage: Package) => Promise<void>,
12
+ reportStatusDownload: (downloadedPackage: ApiSdkDownloadReportPackageInfo) => Promise<void>,
12
13
  ) {
13
14
  Object.assign(this, remotePackageData);
14
15
 
@@ -20,9 +21,8 @@ export class RemotePackageImpl implements RemotePackage {
20
21
  let downloadProgressSubscription;
21
22
 
22
23
  if (downloadProgressCallback) {
23
- const codePushEventEmitter = new NativeEventEmitter(NativeRNAppZungCodePushModule);
24
24
  // Use event subscription to obtain download progress.
25
- downloadProgressSubscription = codePushEventEmitter.addListener(
25
+ downloadProgressSubscription = CodePushEventEmitter.addListener(
26
26
  'CodePushDownloadProgress',
27
27
  downloadProgressCallback,
28
28
  );
@@ -38,12 +38,13 @@ export class RemotePackageImpl implements RemotePackage {
38
38
  );
39
39
 
40
40
  if (reportStatusDownload) {
41
- reportStatusDownload({
42
- ...this,
43
- deploymentKey: this.releaseChannelPublicId,
44
- }).catch((err) => {
45
- log(`Report download status failed: ${err}`);
41
+ const timeoutPromise = new Promise<void>((resolve) => setTimeout(resolve, 250));
42
+ const reportPromise = reportStatusDownload({
43
+ label: this.label,
44
+ }).catch((error) => {
45
+ log(LogLevel.ERROR, `Report download status failed: ${error}`);
46
46
  });
47
+ await Promise.race([timeoutPromise, reportPromise]);
47
48
  }
48
49
 
49
50
  return new LocalPackageImplementation(downloadedPackage);
@@ -10,3 +10,7 @@ export async function getConfiguration() {
10
10
 
11
11
  return config;
12
12
  }
13
+
14
+ export async function reloadCachedConfiguration() {
15
+ config = await NativeRNAppZungCodePushModule.getConfiguration();
16
+ }
@@ -0,0 +1,46 @@
1
+ import type { LogLevel } from '../enums/LogLevel.enum';
2
+
3
+ export type LoggerFunction = (level: LogLevel, message: string) => void;
4
+
5
+ const defaultLogger: LoggerFunction = (_level: LogLevel, message: string): void => {
6
+ console.log(`[CodePush] ${message}`);
7
+ };
8
+
9
+ let currentLogger: LoggerFunction = defaultLogger;
10
+
11
+ /**
12
+ * Set a custom logger function to handle all CodePush logs
13
+ *
14
+ * @param logger A function that takes a log level and message and handles the logging
15
+ * @example
16
+ * ```
17
+ * import { setLogger, LogLevel } from '@appzung/react-native-code-push';
18
+ *
19
+ * // Custom logger that sends critical logs to a crash reporting service
20
+ * setLogger((level, message) => {
21
+ * // Always log to console
22
+ * console.log(`[CodePush] ${message}`);
23
+ *
24
+ * // Send error logs to crash reporting
25
+ * if (level === LogLevel.ERROR) {
26
+ * MyCrashReportingService.log(`CodePush error: ${message}`);
27
+ * }
28
+ * });
29
+ * ```
30
+ */
31
+ export const setLogger = (logger: LoggerFunction): void => {
32
+ currentLogger = logger;
33
+ };
34
+
35
+ /**
36
+ * Get the current logger function
37
+ * @returns The current logger function
38
+ */
39
+ export const getLogger = (): LoggerFunction => currentLogger;
40
+
41
+ /**
42
+ * Reset the logger to the default implementation
43
+ */
44
+ export const resetLogger = (): void => {
45
+ currentLogger = defaultLogger;
46
+ };
@@ -1,3 +1,4 @@
1
+ import { LogLevel } from '../enums/LogLevel.enum';
1
2
  import type { RemotePackage, RollbackRetryOptions, SyncOptions } from '../types';
2
3
  import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
3
4
  import type { LatestRollbackInfo } from './types';
@@ -20,17 +21,17 @@ function validateLatestRollbackInfo(latestRollbackInfo: LatestRollbackInfo, pack
20
21
 
21
22
  function validateRollbackRetryOptions(rollbackRetryOptions: RollbackRetryOptions) {
22
23
  if (typeof rollbackRetryOptions.delayInHours !== 'number') {
23
- log("The 'delayInHours' rollback retry parameter must be a number.");
24
+ log(LogLevel.ERROR, "The 'delayInHours' rollback retry parameter must be a number.");
24
25
  return false;
25
26
  }
26
27
 
27
28
  if (typeof rollbackRetryOptions.maxRetryAttempts !== 'number') {
28
- log("The 'maxRetryAttempts' rollback retry parameter must be a number.");
29
+ log(LogLevel.ERROR, "The 'maxRetryAttempts' rollback retry parameter must be a number.");
29
30
  return false;
30
31
  }
31
32
 
32
33
  if (rollbackRetryOptions.maxRetryAttempts < 1) {
33
- log("The 'maxRetryAttempts' rollback retry parameter cannot be less then 1.");
34
+ log(LogLevel.ERROR, "The 'maxRetryAttempts' rollback retry parameter cannot be less then 1.");
34
35
  return false;
35
36
  }
36
37
 
@@ -61,14 +62,14 @@ export async function shouldUpdateBeIgnored(remotePackage: RemotePackage | null
61
62
 
62
63
  const latestRollbackInfo = await NativeRNAppZungCodePushModule.getLatestRollbackInfo();
63
64
  if (!validateLatestRollbackInfo(latestRollbackInfo, remotePackage.packageHash)) {
64
- log('The latest rollback info is not valid.');
65
+ log(LogLevel.ERROR, 'The latest rollback info is not valid.');
65
66
  return true;
66
67
  }
67
68
 
68
69
  const { delayInHours, maxRetryAttempts } = rollbackRetryOptions;
69
70
  const hoursSinceLatestRollback = (Date.now() - latestRollbackInfo.time) / (1000 * 60 * 60);
70
71
  if (hoursSinceLatestRollback >= delayInHours && maxRetryAttempts >= latestRollbackInfo.count) {
71
- log('Previous rollback should be ignored due to rollback retry options.');
72
+ log(LogLevel.INFO, 'Previous rollback should be ignored due to rollback retry options.');
72
73
  return false;
73
74
  }
74
75
 
@@ -1,6 +1,6 @@
1
- import type { Configuration as BaseConfiguration } from 'code-push/script/acquisition-sdk';
1
+ import type { ApiSdkConfiguration } from './CodePushApiSdk.types';
2
2
 
3
- export interface Configuration extends BaseConfiguration {
3
+ export interface Configuration extends ApiSdkConfiguration {
4
4
  releaseChannelPublicId: string;
5
5
  packageHash?: string;
6
6
  }