@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.
- package/CodePush.podspec +3 -5
- package/README.md +26 -24
- package/android/app/proguard-rules.pro +5 -0
- package/android/app/src/main/java/com/appzung/codepush/react/CodePush.java +4 -0
- package/android/app/src/main/java/com/appzung/codepush/react/CodePushConstants.java +2 -0
- package/android/app/src/main/java/com/appzung/codepush/react/CodePushNativeModule.java +86 -4
- package/android/app/src/main/java/com/appzung/codepush/react/ExpoUtils.java +22 -0
- package/ios/CodePush/CodePush.h +11 -6
- package/ios/CodePush/{CodePush.m → CodePush.mm} +132 -141
- package/ios/CodePush/CodePushConfig.m +54 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +6 -6
- package/lib/commonjs/CodePush.js +11 -2
- package/lib/commonjs/CodePush.js.map +1 -1
- package/lib/commonjs/allowRestart.js +6 -2
- package/lib/commonjs/allowRestart.js.map +1 -1
- package/lib/commonjs/checkForUpdates.js +25 -26
- package/lib/commonjs/checkForUpdates.js.map +1 -1
- package/lib/commonjs/clearUpdates.js +6 -3
- package/lib/commonjs/clearUpdates.js.map +1 -1
- package/lib/commonjs/dataTransmission.js +28 -0
- package/lib/commonjs/dataTransmission.js.map +1 -0
- package/lib/commonjs/disallowRestart.js +6 -2
- package/lib/commonjs/disallowRestart.js.map +1 -1
- package/lib/commonjs/enums/CheckFrequency.enum.js +2 -2
- package/lib/commonjs/enums/InstallMode.enum.js +7 -3
- package/lib/commonjs/enums/InstallMode.enum.js.map +1 -1
- package/lib/commonjs/enums/LogLevel.enum.js +17 -0
- package/lib/commonjs/enums/LogLevel.enum.js.map +1 -0
- package/lib/commonjs/enums/SyncStatus.enum.js +7 -7
- package/lib/commonjs/enums/UpdateState.enum.js +7 -6
- package/lib/commonjs/enums/UpdateState.enum.js.map +1 -1
- package/lib/commonjs/getClientUniqueId.js +16 -0
- package/lib/commonjs/getClientUniqueId.js.map +1 -0
- package/lib/commonjs/index.js +90 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internals/CodePushApiSdk.errors.js +26 -0
- package/lib/commonjs/internals/CodePushApiSdk.errors.js.map +1 -0
- package/lib/commonjs/internals/CodePushApiSdk.js +122 -0
- package/lib/commonjs/internals/CodePushApiSdk.js.map +1 -0
- package/lib/commonjs/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +3 -2
- package/lib/commonjs/internals/CodePushApiSdk.types.js.map +1 -0
- package/lib/commonjs/internals/CodePushEventEmitter.js +10 -0
- package/lib/commonjs/internals/CodePushEventEmitter.js.map +1 -0
- package/lib/commonjs/internals/RemotePackageImplementation.js +9 -8
- package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -1
- package/lib/commonjs/internals/getConfiguration.js +4 -0
- package/lib/commonjs/internals/getConfiguration.js.map +1 -1
- package/lib/commonjs/internals/logger.js +51 -0
- package/lib/commonjs/internals/logger.js.map +1 -0
- package/lib/commonjs/internals/shouldUpdateBeIgnored.js +6 -5
- package/lib/commonjs/internals/shouldUpdateBeIgnored.js.map +1 -1
- package/lib/commonjs/internals/utils/fetchRetry.js +59 -0
- package/lib/commonjs/internals/utils/fetchRetry.js.map +1 -0
- package/lib/commonjs/internals/utils/log.js +10 -3
- package/lib/commonjs/internals/utils/log.js.map +1 -1
- package/lib/commonjs/internals/utils/queryStringify.js +25 -0
- package/lib/commonjs/internals/utils/queryStringify.js.map +1 -0
- package/lib/commonjs/internals/utils/requestFetchAdapter.js +38 -0
- package/lib/commonjs/internals/utils/requestFetchAdapter.js.map +1 -0
- package/lib/commonjs/internals/version.js +1 -1
- package/lib/commonjs/internals/version.js.map +1 -1
- package/lib/commonjs/logLevel.js +15 -0
- package/lib/commonjs/logLevel.js.map +1 -0
- package/lib/commonjs/logger.js +19 -0
- package/lib/commonjs/logger.js.map +1 -0
- package/lib/commonjs/notifyAppReady.js +26 -15
- package/lib/commonjs/notifyAppReady.js.map +1 -1
- package/lib/commonjs/resetClientUniqueId.js +18 -0
- package/lib/commonjs/resetClientUniqueId.js.map +1 -0
- package/lib/commonjs/restartApp.js +4 -2
- package/lib/commonjs/restartApp.js.map +1 -1
- package/lib/commonjs/sync.js +35 -28
- package/lib/commonjs/sync.js.map +1 -1
- package/lib/commonjs/telemetry.js +28 -0
- package/lib/commonjs/telemetry.js.map +1 -0
- package/lib/module/CodePush.js +11 -2
- package/lib/module/CodePush.js.map +1 -1
- package/lib/module/allowRestart.js +5 -1
- package/lib/module/allowRestart.js.map +1 -1
- package/lib/module/checkForUpdates.js +25 -26
- package/lib/module/checkForUpdates.js.map +1 -1
- package/lib/module/clearUpdates.js +5 -2
- package/lib/module/clearUpdates.js.map +1 -1
- package/lib/module/dataTransmission.js +24 -0
- package/lib/module/dataTransmission.js.map +1 -0
- package/lib/module/disallowRestart.js +5 -1
- package/lib/module/disallowRestart.js.map +1 -1
- package/lib/module/enums/CheckFrequency.enum.js +2 -2
- package/lib/module/enums/InstallMode.enum.js +7 -3
- package/lib/module/enums/InstallMode.enum.js.map +1 -1
- package/lib/module/enums/LogLevel.enum.js +13 -0
- package/lib/module/enums/LogLevel.enum.js.map +1 -0
- package/lib/module/enums/SyncStatus.enum.js +7 -7
- package/lib/module/enums/UpdateState.enum.js +7 -6
- package/lib/module/enums/UpdateState.enum.js.map +1 -1
- package/lib/module/getClientUniqueId.js +12 -0
- package/lib/module/getClientUniqueId.js.map +1 -0
- package/lib/module/index.js +8 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internals/CodePushApiSdk.errors.js +20 -0
- package/lib/module/internals/CodePushApiSdk.errors.js.map +1 -0
- package/lib/module/internals/CodePushApiSdk.js +118 -0
- package/lib/module/internals/CodePushApiSdk.js.map +1 -0
- package/lib/module/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +2 -1
- package/lib/module/internals/CodePushApiSdk.types.js.map +1 -0
- package/lib/module/internals/CodePushEventEmitter.js +6 -0
- package/lib/module/internals/CodePushEventEmitter.js.map +1 -0
- package/lib/module/internals/RemotePackageImplementation.js +9 -8
- package/lib/module/internals/RemotePackageImplementation.js.map +1 -1
- package/lib/module/internals/getConfiguration.js +3 -0
- package/lib/module/internals/getConfiguration.js.map +1 -1
- package/lib/module/internals/logger.js +44 -0
- package/lib/module/internals/logger.js.map +1 -0
- package/lib/module/internals/shouldUpdateBeIgnored.js +6 -5
- package/lib/module/internals/shouldUpdateBeIgnored.js.map +1 -1
- package/lib/module/internals/utils/fetchRetry.js +55 -0
- package/lib/module/internals/utils/fetchRetry.js.map +1 -0
- package/lib/module/internals/utils/log.js +11 -3
- package/lib/module/internals/utils/log.js.map +1 -1
- package/lib/module/internals/utils/queryStringify.js +21 -0
- package/lib/module/internals/utils/queryStringify.js.map +1 -0
- package/lib/module/internals/utils/requestFetchAdapter.js +34 -0
- package/lib/module/internals/utils/requestFetchAdapter.js.map +1 -0
- package/lib/module/internals/version.js +1 -1
- package/lib/module/internals/version.js.map +1 -1
- package/lib/module/logLevel.js +9 -0
- package/lib/module/logLevel.js.map +1 -0
- package/lib/module/logger.js +4 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/notifyAppReady.js +26 -15
- package/lib/module/notifyAppReady.js.map +1 -1
- package/lib/module/resetClientUniqueId.js +14 -0
- package/lib/module/resetClientUniqueId.js.map +1 -0
- package/lib/module/restartApp.js +4 -2
- package/lib/module/restartApp.js.map +1 -1
- package/lib/module/sync.js +35 -28
- package/lib/module/sync.js.map +1 -1
- package/lib/module/telemetry.js +24 -0
- package/lib/module/telemetry.js.map +1 -0
- package/lib/typescript/commonjs/src/CodePush.d.ts +10 -5
- package/lib/typescript/commonjs/src/CodePush.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/allowRestart.d.ts +3 -1
- package/lib/typescript/commonjs/src/allowRestart.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/clearUpdates.d.ts +3 -2
- package/lib/typescript/commonjs/src/clearUpdates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/dataTransmission.d.ts +13 -0
- package/lib/typescript/commonjs/src/dataTransmission.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/disallowRestart.d.ts +3 -1
- package/lib/typescript/commonjs/src/disallowRestart.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/enums/CheckFrequency.enum.d.ts +2 -2
- package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts +7 -3
- package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts +10 -0
- package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/enums/SyncStatus.enum.d.ts +7 -7
- package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts +7 -6
- package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/getClientUniqueId.d.ts +5 -0
- package/lib/typescript/commonjs/src/getClientUniqueId.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +8 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts +15 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts +9 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts +103 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/CodePushEventEmitter.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/CodePushEventEmitter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts +5 -0
- package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts +2 -2
- package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts +1 -0
- package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/logger.d.ts +33 -0
- package/lib/typescript/commonjs/src/internals/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/types.d.ts +2 -2
- package/lib/typescript/commonjs/src/internals/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts +9 -0
- package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts +2 -1
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts +4 -0
- package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/version.d.ts +1 -1
- package/lib/typescript/commonjs/src/internals/version.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/logLevel.d.ts +4 -0
- package/lib/typescript/commonjs/src/logLevel.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/logger.d.ts +3 -0
- package/lib/typescript/commonjs/src/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts +4 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/resetClientUniqueId.d.ts +5 -0
- package/lib/typescript/commonjs/src/resetClientUniqueId.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/restartApp.d.ts +2 -0
- package/lib/typescript/commonjs/src/restartApp.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/sync.d.ts +5 -1
- package/lib/typescript/commonjs/src/sync.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/telemetry.d.ts +13 -0
- package/lib/typescript/commonjs/src/telemetry.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +72 -29
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/CodePush.d.ts +10 -5
- package/lib/typescript/module/src/CodePush.d.ts.map +1 -1
- package/lib/typescript/module/src/allowRestart.d.ts +3 -1
- package/lib/typescript/module/src/allowRestart.d.ts.map +1 -1
- package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -1
- package/lib/typescript/module/src/clearUpdates.d.ts +3 -2
- package/lib/typescript/module/src/clearUpdates.d.ts.map +1 -1
- package/lib/typescript/module/src/dataTransmission.d.ts +13 -0
- package/lib/typescript/module/src/dataTransmission.d.ts.map +1 -0
- package/lib/typescript/module/src/disallowRestart.d.ts +3 -1
- package/lib/typescript/module/src/disallowRestart.d.ts.map +1 -1
- package/lib/typescript/module/src/enums/CheckFrequency.enum.d.ts +2 -2
- package/lib/typescript/module/src/enums/InstallMode.enum.d.ts +7 -3
- package/lib/typescript/module/src/enums/InstallMode.enum.d.ts.map +1 -1
- package/lib/typescript/module/src/enums/LogLevel.enum.d.ts +10 -0
- package/lib/typescript/module/src/enums/LogLevel.enum.d.ts.map +1 -0
- package/lib/typescript/module/src/enums/SyncStatus.enum.d.ts +7 -7
- package/lib/typescript/module/src/enums/UpdateState.enum.d.ts +7 -6
- package/lib/typescript/module/src/enums/UpdateState.enum.d.ts.map +1 -1
- package/lib/typescript/module/src/getClientUniqueId.d.ts +5 -0
- package/lib/typescript/module/src/getClientUniqueId.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +8 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts +15 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts +9 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts +103 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/CodePushEventEmitter.d.ts +3 -0
- package/lib/typescript/module/src/internals/CodePushEventEmitter.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts +5 -0
- package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts +2 -2
- package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/getConfiguration.d.ts +1 -0
- package/lib/typescript/module/src/internals/getConfiguration.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/logger.d.ts +33 -0
- package/lib/typescript/module/src/internals/logger.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/types.d.ts +2 -2
- package/lib/typescript/module/src/internals/types.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts +9 -0
- package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/log.d.ts +2 -1
- package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/utils/queryStringify.d.ts +4 -0
- package/lib/typescript/module/src/internals/utils/queryStringify.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts +3 -0
- package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/version.d.ts +1 -1
- package/lib/typescript/module/src/internals/version.d.ts.map +1 -1
- package/lib/typescript/module/src/logLevel.d.ts +4 -0
- package/lib/typescript/module/src/logLevel.d.ts.map +1 -0
- package/lib/typescript/module/src/logger.d.ts +3 -0
- package/lib/typescript/module/src/logger.d.ts.map +1 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts +4 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -1
- package/lib/typescript/module/src/resetClientUniqueId.d.ts +5 -0
- package/lib/typescript/module/src/resetClientUniqueId.d.ts.map +1 -0
- package/lib/typescript/module/src/restartApp.d.ts +2 -0
- package/lib/typescript/module/src/restartApp.d.ts.map +1 -1
- package/lib/typescript/module/src/sync.d.ts +5 -1
- package/lib/typescript/module/src/sync.d.ts.map +1 -1
- package/lib/typescript/module/src/telemetry.d.ts +13 -0
- package/lib/typescript/module/src/telemetry.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +72 -29
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +24 -13
- package/scripts/generateBundledResourcesHash.js +73 -68
- package/scripts/getFilesInFolder.js +12 -12
- package/scripts/recordFilesBeforeBundleCommand.js +19 -20
- package/src/CodePush.tsx +20 -5
- package/src/allowRestart.ts +5 -1
- package/src/checkForUpdates.ts +26 -24
- package/src/clearUpdates.ts +5 -2
- package/src/dataTransmission.ts +21 -0
- package/src/disallowRestart.ts +5 -1
- package/src/enums/CheckFrequency.enum.ts +2 -2
- package/src/enums/InstallMode.enum.ts +7 -3
- package/src/enums/LogLevel.enum.ts +9 -0
- package/src/enums/SyncStatus.enum.ts +7 -7
- package/src/enums/UpdateState.enum.ts +7 -6
- package/src/getClientUniqueId.ts +9 -0
- package/src/index.ts +8 -1
- package/src/internals/CodePushApiSdk.errors.ts +22 -0
- package/src/internals/CodePushApiSdk.ts +160 -0
- package/src/internals/CodePushApiSdk.types.ts +117 -0
- package/src/internals/CodePushEventEmitter.ts +4 -0
- package/src/internals/RNAppZungCodePushModuleSpec.ts +7 -0
- package/src/internals/RemotePackageImplementation.ts +11 -10
- package/src/internals/getConfiguration.ts +4 -0
- package/src/internals/logger.ts +46 -0
- package/src/internals/shouldUpdateBeIgnored.ts +6 -5
- package/src/internals/types.ts +2 -2
- package/src/internals/utils/fetchRetry.ts +72 -0
- package/src/internals/utils/log.ts +13 -3
- package/src/internals/utils/queryStringify.ts +22 -0
- package/src/internals/utils/requestFetchAdapter.ts +36 -0
- package/src/internals/version.ts +1 -1
- package/src/logLevel.ts +9 -0
- package/src/logger.ts +2 -0
- package/src/notifyAppReady.ts +29 -18
- package/src/resetClientUniqueId.ts +11 -0
- package/src/restartApp.ts +4 -2
- package/src/sync.ts +41 -27
- package/src/telemetry.ts +21 -0
- package/src/types.ts +72 -29
- package/android/app/.gradle/config.properties +0 -2
- package/android/app/local.properties +0 -8
- package/docs/advanced-usage.md +0 -56
- package/docs/api-android.md +0 -22
- package/docs/api-ios.md +0 -19
- package/docs/api-js.md +0 -557
- package/docs/code-signing.md +0 -62
- package/docs/migrating-to-v10.md +0 -31
- package/docs/setup-android.md +0 -81
- package/docs/setup-ios.md +0 -108
- package/docs/setup-windows.md +0 -55
- package/lib/commonjs/enums/DeploymentStatus.enum.js.map +0 -1
- package/lib/commonjs/internals/AcquisitionSdk.js +0 -9
- package/lib/commonjs/internals/AcquisitionSdk.js.map +0 -1
- package/lib/commonjs/internals/getPromisifiedSdk.js +0 -49
- package/lib/commonjs/internals/getPromisifiedSdk.js.map +0 -1
- package/lib/commonjs/internals/utils/request-fetch-adapter.js +0 -50
- package/lib/commonjs/internals/utils/request-fetch-adapter.js.map +0 -1
- package/lib/module/enums/DeploymentStatus.enum.js.map +0 -1
- package/lib/module/internals/AcquisitionSdk.js +0 -5
- package/lib/module/internals/AcquisitionSdk.js.map +0 -1
- package/lib/module/internals/getPromisifiedSdk.js +0 -45
- package/lib/module/internals/getPromisifiedSdk.js.map +0 -1
- package/lib/module/internals/utils/request-fetch-adapter.js +0 -46
- package/lib/module/internals/utils/request-fetch-adapter.js.map +0 -1
- package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts +0 -14
- package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts +0 -3
- package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts +0 -13
- package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts +0 -3
- package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
- package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts +0 -14
- package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts +0 -3
- package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts +0 -13
- package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts +0 -3
- package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
- package/src/enums/DeploymentStatus.enum.ts +0 -14
- package/src/internals/AcquisitionSdk.ts +0 -3
- package/src/internals/getPromisifiedSdk.ts +0 -72
- 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
|
-
*
|
|
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,
|
|
@@ -3,30 +3,30 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export enum SyncStatus {
|
|
5
5
|
/**
|
|
6
|
-
* The app is up-to-date with the
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
+
}
|
|
@@ -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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}).catch((
|
|
45
|
-
log(`Report download status failed: ${
|
|
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);
|
|
@@ -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
|
|
package/src/internals/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ApiSdkConfiguration } from './CodePushApiSdk.types';
|
|
2
2
|
|
|
3
|
-
export interface Configuration extends
|
|
3
|
+
export interface Configuration extends ApiSdkConfiguration {
|
|
4
4
|
releaseChannelPublicId: string;
|
|
5
5
|
packageHash?: string;
|
|
6
6
|
}
|