@capawesome/capacitor-live-update 8.2.3 → 8.3.0-dev.f9cc1d15.1783929784
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/CapawesomeCapacitorLiveUpdate.podspec +16 -1
- package/Package.swift +22 -6
- package/README.md +213 -84
- package/android/build.gradle +17 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +69 -20
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +30 -1
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +9 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/FetchLatestBundleOptions.java +15 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +38 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/providers/ionic/LiveUpdateIonicManager.kt +169 -0
- package/dist/docs.json +14 -2
- package/dist/esm/definitions.d.ts +17 -2
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/Classes/Options/FetchLatestBundleOptions.swift +12 -0
- package/ios/Plugin/Classes/Results/FetchLatestBundleResult.swift +30 -1
- package/ios/Plugin/Enums/CustomError.swift +12 -0
- package/ios/Plugin/LiveUpdate.swift +23 -9
- package/ios/Plugin/LiveUpdatePlugin.swift +2 -2
- package/ios/Plugin/Protocols/Api/GetLatestBundleResponse.swift +1 -0
- package/ios/Plugin/Providers/Ionic/LiveUpdateIonicManager.swift +108 -0
- package/ios/Plugin/Providers/Ionic/LiveUpdatePlugin+LiveUpdateProvider.swift +15 -0
- package/package.json +11 -5
|
@@ -537,7 +537,10 @@ export interface Channel {
|
|
|
537
537
|
*/
|
|
538
538
|
export interface FetchLatestBundleOptions {
|
|
539
539
|
/**
|
|
540
|
-
* The
|
|
540
|
+
* The preferred channel name from which the latest bundle should be fetched.
|
|
541
|
+
*
|
|
542
|
+
* This is the SDK preference and may be overridden by a forced channel assignment
|
|
543
|
+
* configured in the Capawesome Cloud Console.
|
|
541
544
|
*
|
|
542
545
|
* @since 6.7.0
|
|
543
546
|
*/
|
|
@@ -563,6 +566,15 @@ export interface FetchLatestBundleResult {
|
|
|
563
566
|
* @since 6.6.0
|
|
564
567
|
*/
|
|
565
568
|
bundleId: string | null;
|
|
569
|
+
/**
|
|
570
|
+
* The name of the channel that the bundle is actually from.
|
|
571
|
+
*
|
|
572
|
+
* This is the resolved channel after applying any forced channel assignment
|
|
573
|
+
* and may differ from the channel set by the Live Update SDK.
|
|
574
|
+
*
|
|
575
|
+
* @since 8.3.0
|
|
576
|
+
*/
|
|
577
|
+
channel?: string;
|
|
566
578
|
/**
|
|
567
579
|
* The checksum of the latest bundle if the bundle is self-hosted.
|
|
568
580
|
*
|
|
@@ -875,7 +887,10 @@ export interface SetNextBundleOptions {
|
|
|
875
887
|
*/
|
|
876
888
|
export interface SyncOptions {
|
|
877
889
|
/**
|
|
878
|
-
* The
|
|
890
|
+
* The preferred channel name from which the latest bundle should be fetched.
|
|
891
|
+
*
|
|
892
|
+
* This is the SDK preference and may be overridden by a forced channel assignment
|
|
893
|
+
* configured in the Capawesome Cloud Console.
|
|
879
894
|
*
|
|
880
895
|
* @since 6.7.0
|
|
881
896
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n LiveUpdate?: {\n /**\n * The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * This is **NOT** the same as the app identifier (e.g. `com.example.app`).\n * This is a unique identifier generated by Capawesome Cloud (e.g. `6e351b4f-69a7-415e-a057-4567df7ffe94`).\n *\n * @since 5.0.0\n * @example '6e351b4f-69a7-415e-a057-4567df7ffe94'\n */\n appId?: string;\n /**\n * Whether or not to automatically block bundles that have been rolled back.\n *\n * When enabled, the plugin will automatically block bundles that caused a rollback\n * (up to 100 bundles). When the limit is reached, the oldest blocked bundle is unblocked.\n * Blocked bundles will be skipped in future sync operations.\n *\n * **Attention**: This option has no effect if `readyTimeout` is set to `0`.\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n * @default false\n */\n autoBlockRolledBackBundles?: boolean;\n /**\n * Whether or not to automatically delete unused bundles.\n *\n * When enabled, the plugin will automatically delete unused bundles after calling `ready()`.\n *\n * @since 5.0.0\n * @default false\n */\n autoDeleteBundles?: boolean;\n /**\n * The auto-update strategy for live updates.\n *\n * - `none`: Live updates will not be applied automatically.\n * - `background`: Live updates will be automatically downloaded\n * and applied in the background at app startup and when the app resumes\n * (if the last check was more than 15 minutes ago).\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n * @default 'none'\n * @example 'background'\n */\n autoUpdateStrategy?: 'none' | 'background';\n /**\n * The default channel of the app.\n *\n * This can be overridden by `setChannel()`, the `channel` parameter of `sync()`,\n * or the native channel configuration\n * (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or `capawesome_live_update_default_channel`\n * in `strings.xml` on Android).\n *\n * @since 6.3.0\n * @example 'production'\n */\n defaultChannel?: string;\n /**\n * The timeout in milliseconds for HTTP requests.\n *\n * @since 6.4.0\n * @default 60000\n */\n httpTimeout?: number;\n /**\n * The public key to verify the integrity of the bundle.\n *\n * The public key must be a PEM-encoded RSA public key.\n *\n * @since 6.1.0\n * @example '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----'\n */\n publicKey?: string;\n /**\n * The timeout in milliseconds to wait for the app to be ready\n * before resetting to the default bundle.\n *\n * It is strongly **recommended** to configure this option (e.g. `10000` ms)\n * so that the plugin can roll back to the default bundle in case of problems.\n * If configured, the plugin will wait for the app to call the `ready()`\n * method before resetting to the default bundle.\n *\n * Set to `0` to disable the timeout.\n *\n * @since 5.0.0\n * @default 0\n * @example 10000\n */\n readyTimeout?: number;\n /**\n * The API domain of the [Capawesome Cloud](https://cloud.capawesome.io) server **without** scheme or path.\n *\n * @since 7.0.0\n * @default 'api.cloud.capawesome.io'\n * @example 'api.cloud.capawesome.eu'\n */\n serverDomain?: string;\n };\n }\n}\n\nexport interface LiveUpdatePlugin {\n /**\n * Clear all blocked bundles from the blocked list.\n *\n * This removes all bundle identifiers that were automatically blocked\n * due to rollbacks when `autoBlockRolledBackBundles` is enabled.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n clearBlockedBundles(): Promise<void>;\n /**\n * Delete a bundle from the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n deleteBundle(options: DeleteBundleOptions): Promise<void>;\n /**\n * Download a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n downloadBundle(options: DownloadBundleOptions): Promise<void>;\n /**\n * Fetch channels from [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * This is primarily intended for development and QA purposes.\n * It allows you to retrieve a list of available channels so you can\n * dynamically switch between them using `setChannel(...)`.\n *\n * **Attention**: Only works for apps with public channels enabled.\n * If channels are private, they can still be set using `setChannel(...)`\n * but won't be returned by this method.\n *\n * Only available on Android and iOS.\n *\n * @since 8.2.0\n */\n fetchChannels(options?: FetchChannelsOptions): Promise<FetchChannelsResult>;\n /**\n * Fetch the latest bundle using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Only available on Android and iOS.\n *\n * @since 6.6.0\n */\n fetchLatestBundle(\n options?: FetchLatestBundleOptions,\n ): Promise<FetchLatestBundleResult>;\n /**\n * Get all blocked bundle identifiers.\n *\n * Returns the list of bundle identifiers that were automatically blocked\n * due to rollbacks when `autoBlockRolledBackBundles` is enabled.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n getBlockedBundles(): Promise<GetBlockedBundlesResult>;\n /**\n * Get all identifiers of bundles that have been downloaded.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n * @deprecated Use `getDownloadedBundles()` instead.\n */\n getBundles(): Promise<GetBundlesResult>;\n /**\n * Get the channel that is used for the update.\n *\n * The channel is resolved in the following order (highest priority first):\n * 1. `setChannel()` (SharedPreferences on Android / UserDefaults on iOS)\n * 2. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or\n * `capawesome_live_update_default_channel` in `strings.xml` on Android)\n * 3. Capacitor config `defaultChannel`\n *\n * **Note**: The `channel` parameter of `sync()` takes the highest priority\n * but is not persisted and therefore not returned by this method.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getChannel(): Promise<GetChannelResult>;\n /**\n * Get the runtime configuration.\n *\n * Returns the current plugin configuration including any runtime\n * overrides set via `setConfig()`.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n getConfig(): Promise<GetConfigResult>;\n /**\n * Get all identifiers of bundles that have been downloaded.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n getDownloadedBundles(): Promise<GetDownloadedBundlesResult>;\n /**\n * Get the bundle identifier of the current bundle.\n * The current bundle is the bundle that is currently used by the app.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n getCurrentBundle(): Promise<GetCurrentBundleResult>;\n /**\n * Get the custom identifier of the device.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getCustomId(): Promise<GetCustomIdResult>;\n /**\n * Get the unique device identifier.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getDeviceId(): Promise<GetDeviceIdResult>;\n /**\n * Check whether a sync operation is currently in progress.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n isSyncing(): Promise<IsSyncingResult>;\n /**\n * Get the bundle identifier of the next bundle.\n * The next bundle is the bundle that will be used after calling `reload()`\n * or restarting the app.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n getNextBundle(): Promise<GetNextBundleResult>;\n /**\n * Get the version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionCode(): Promise<GetVersionCodeResult>;\n /**\n * Get the version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionName(): Promise<GetVersionNameResult>;\n /**\n * Notify the plugin that the app is ready to use and no rollback is needed.\n *\n * **Attention**: This method should be called as soon as the app is ready to use\n * to prevent the app from being reset to the default bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n ready(): Promise<ReadyResult>;\n /**\n * Reload the app to apply the new bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reload(): Promise<void>;\n /**\n * Reset the app to the default bundle.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reset(): Promise<void>;\n /**\n * Reset the runtime configuration to the values from the Capacitor config file.\n *\n * This clears any runtime configuration set via `setConfig()`.\n * The changes take effect immediately.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n resetConfig(): Promise<void>;\n /**\n * Set the channel to use for the update.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setChannel(options: SetChannelOptions): Promise<void>;\n /**\n * Set the runtime configuration.\n *\n * This allows updating plugin configuration options at runtime.\n * The changes are persisted across app restarts and take effect immediately.\n *\n * **Important:** Runtime configuration is automatically reset to default values\n * whenever the native app is updated to a new version. This ensures that\n * configuration from previous versions doesn't persist after an app update.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n setConfig(options: SetConfigOptions): Promise<void>;\n /**\n * Set the custom identifier of the device.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n /**\n * Set the next bundle to use for the app.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n setNextBundle(options: SetNextBundleOptions): Promise<void>;\n /**\n * Automatically download and set the latest bundle for the app using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n sync(options?: SyncOptions): Promise<SyncResult>;\n /**\n * Listen for the download progress of a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 7.0.0\n */\n addListener(\n eventName: 'downloadBundleProgress',\n listenerFunc: DownloadBundleProgressListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for when a bundle is set as the next bundle.\n *\n * This event is triggered whenever a bundle is set to be used on the next app restart,\n * either through automatic updates or manual calls to `setNextBundle()`.\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n */\n addListener(\n eventName: 'nextBundleSet',\n listenerFunc: NextBundleSetListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for when the app is reloaded.\n *\n * This event is triggered after the `reload()` method is called\n * and the app has been reloaded.\n *\n * **Note:** To verify whether an update was successfully applied after a reload,\n * use the `ready()` method instead. The `ready()` method provides detailed information\n * about the current bundle, previous bundle, and whether a rollback occurred.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n addListener(\n eventName: 'reloaded',\n listenerFunc: ReloadedListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 7.2.0\n */\n removeAllListeners(): Promise<void>;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface DeleteBundleOptions {\n /**\n * The unique identifier of the bundle to delete.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\nexport interface DownloadBundleOptions {\n /**\n * The artifact type of the bundle.\n *\n * @since 6.6.0\n * @default 'zip'\n * @example 'manifest'\n */\n artifactType?: 'manifest' | 'zip';\n /**\n * The unique identifier of the bundle.\n *\n * **Attention**: The value `public` is reserved and cannot be used as a bundle identifier.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n /**\n * The checksum of the self-hosted bundle as a SHA-256 hash\n * in hex format to verify the integrity of the bundle.\n *\n * **Attention**: Only supported for the `zip` artifact type.\n *\n * @since 7.1.0\n */\n checksum?: string;\n /**\n * The signature of the self-hosted bundle as a signed SHA-256 hash\n * in base64 format to verify the integrity of the bundle.\n *\n * **Attention**: Only supported for the `zip` artifact type.\n *\n * @since 7.1.0\n */\n signature?: string;\n /**\n * The URL of the bundle to download.\n *\n * For the `zip` artifact type, the URL must point to a ZIP file.\n * For the `manifest` artifact type, the URL serves as the base URL\n * to download the individual files. For example, if the URL is\n * `https://example.com/download`, the plugin will download the file\n * with the href `index.html` from `https://example.com/download?href=index.html`.\n *\n * To **verify the integrity** of the file, the server should return\n * a `X-Checksum` header with the SHA-256 hash in hex format.\n *\n * To **verify the signature** of the file, the server should return\n * a `X-Signature` header with the signed SHA-256 hash in base64 format.\n *\n * @since 5.0.0\n * @example 'https://example.com/bundle.zip'\n */\n url: string;\n}\n\n/**\n * @since 8.2.0\n */\nexport interface FetchChannelsOptions {\n /**\n * The maximum number of channels to return.\n *\n * @since 8.2.0\n * @default 50\n */\n limit?: number;\n /**\n * The number of channels to skip.\n *\n * @since 8.2.0\n * @default 0\n */\n offset?: number;\n /**\n * The query to filter channels by name.\n *\n * @since 8.2.0\n */\n query?: string;\n}\n\n/**\n * @since 8.2.0\n */\nexport interface FetchChannelsResult {\n /**\n * The list of channels.\n *\n * @since 8.2.0\n */\n channels: Channel[];\n}\n\n/**\n * @since 8.2.0\n */\nexport interface Channel {\n /**\n * The unique identifier of the channel.\n *\n * @since 8.2.0\n */\n id: string;\n /**\n * The name of the channel.\n *\n * @since 8.2.0\n */\n name: string;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface FetchLatestBundleOptions {\n /**\n * The name of the channel where the latest bundle is fetched from.\n *\n * @since 6.7.0\n */\n channel?: string;\n}\n\n/**\n * @since 6.6.0\n */\nexport interface FetchLatestBundleResult {\n /**\n * The artifact type of the bundle.\n *\n * @since 6.7.0\n */\n artifactType?: 'manifest' | 'zip';\n /**\n * The unique identifier of the latest bundle.\n *\n * On Capawesome Cloud, this is the ID of the app build artifact.\n *\n * If `null`, no bundle is available.\n *\n * @since 6.6.0\n */\n bundleId: string | null;\n /**\n * The checksum of the latest bundle if the bundle is self-hosted.\n *\n * If the bundle is hosted on Capawesome Cloud, the checksum will be\n * returned as response header when downloading the bundle.\n *\n * @since 7.1.0\n */\n checksum?: string;\n /**\n * Custom properties that are associated with the latest bundle.\n *\n * @since 7.0.0\n * @example { \"key\": \"value\" }\n */\n customProperties?: { [key: string]: string };\n /**\n * The URL of the latest bundle to download.\n * Pass this URL to the `downloadBundle(...)` method to download the bundle.\n *\n * @since 6.7.0\n */\n downloadUrl?: string;\n /**\n * The signature of the latest bundle if the bundle is self-hosted.\n *\n * If the bundle is hosted on Capawesome Cloud, the signature will be\n * returned as response header when downloading the bundle.\n *\n * @since 7.1.0\n */\n signature?: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundleResult {\n /**\n * The unique identifier of the active bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 7.4.0\n */\nexport interface GetBlockedBundlesResult {\n /**\n * An array of unique identifiers of all blocked bundles.\n *\n * @since 7.4.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundlesResult {\n /**\n * An array of unique identifiers of all available bundles.\n *\n * @since 5.0.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 7.4.0\n */\nexport interface GetDownloadedBundlesResult {\n /**\n * An array of unique identifiers of all downloaded bundles.\n *\n * @since 7.4.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetChannelResult {\n /**\n * The channel name.\n *\n * If `null`, the app is using the default channel.\n *\n * @since 5.0.0\n * @example 'production'\n */\n channel: string | null;\n}\n\n/**\n * @since 7.4.0\n */\nexport interface GetConfigResult {\n /**\n * The app ID used to identify the app.\n *\n * If `null`, no app ID is configured.\n *\n * @since 7.4.0\n * @example '6e351b4f-69a7-415e-a057-4567df7ffe94'\n */\n appId: string | null;\n /**\n * The auto-update strategy for live updates.\n *\n * @since 7.4.0\n * @example 'background'\n */\n autoUpdateStrategy: 'none' | 'background';\n}\n\n/**\n * @since 6.7.0\n */\nexport interface GetCurrentBundleResult {\n /**\n * The unique identifier of the current bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 6.7.0\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetDeviceIdResult {\n /**\n * The unique identifier of the device.\n *\n * On iOS, [`identifierForVendor`](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) is used.\n * The value of this property is the same for apps that come from the same vendor running on the same device.\n *\n * @since 5.0.0\n *\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n deviceId: string;\n}\n\n/**\n * @since 7.4.0\n */\nexport interface IsSyncingResult {\n /**\n * Whether a sync operation is currently in progress.\n *\n * @since 7.4.0\n */\n syncing: boolean;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface GetNextBundleResult {\n /**\n * The unique identifier of the next bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 6.7.0\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionCodeResult {\n /**\n * The version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1\"\n */\n versionCode: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionNameResult {\n /**\n * The version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1.0.0\"\n */\n versionName: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetCustomIdResult {\n /**\n * The custom identifier of the device.\n *\n * If `null`, no custom identifier is set.\n *\n * @since 5.0.0\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n customId: string | null;\n}\n\n/**\n * @since 7.0.0\n */\nexport interface ReadyResult {\n /**\n * The identifier of the previous bundle used.\n *\n * If `null`, the default bundle was used.\n *\n * @since 7.0.0\n */\n previousBundleId: string | null;\n /**\n * The identifier of the current bundle used.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 7.0.0\n */\n currentBundleId: string | null;\n /**\n * Whether or not the app was reset to the default bundle.\n *\n * @since 7.0.0\n */\n rollback: boolean;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetChannelOptions {\n /**\n * The channel name.\n *\n * Set `null` to remove the channel.\n *\n * @since 5.0.0\n */\n channel: string | null;\n}\n\n/**\n * @since 7.4.0\n */\nexport interface SetConfigOptions {\n /**\n * The app ID used to identify the app.\n *\n * Set `null` to reset to the value from the Capacitor config file.\n *\n * @since 7.4.0\n * @example '6e351b4f-69a7-415e-a057-4567df7ffe94'\n */\n appId?: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetCustomIdOptions {\n /**\n * The custom identifier of the device.\n *\n * Set `null` to remove the custom identifier.\n *\n * @since 5.0.0\n */\n customId: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface SetNextBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * Set `null` to use the default bundle (same as calling `reset()`).\n *\n * @since 6.7.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface SyncOptions {\n /**\n * The name of the channel where the latest bundle is fetched from.\n *\n * @since 6.7.0\n */\n channel?: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SyncResult {\n /**\n * The identifier of the next bundle to use.\n *\n * If `null`, the app is up-to-date and no new bundle is available.\n *\n * @since 5.0.0\n */\n nextBundleId: string | null;\n}\n\n/**\n * Listener for the download progress of a bundle.\n *\n * @since 7.0.0\n */\nexport type DownloadBundleProgressListener = (\n event: DownloadBundleProgressEvent,\n) => void;\n\n/**\n * Event that is triggered when the download progress of a bundle changes.\n *\n * @since 7.0.0\n */\nexport interface DownloadBundleProgressEvent {\n /**\n * The unique identifier of the bundle that is being downloaded.\n *\n * @since 7.0.0\n */\n bundleId: string;\n /**\n * The number of bytes that have been downloaded.\n *\n * @since 7.0.0\n */\n downloadedBytes: number;\n /**\n * The progress of the download in percent as a value between `0` and `1`.\n *\n * @since 7.0.0\n * @example 0.5\n */\n progress: number;\n /**\n * The total number of bytes to download.\n *\n * @since 7.0.0\n */\n totalBytes: number;\n}\n\n/**\n * Listener for when a bundle is set as the next bundle.\n *\n * @since 7.3.0\n */\nexport type NextBundleSetListener = (event: NextBundleSetEvent) => void;\n\n/**\n * Event that is triggered when a bundle is set as the next bundle.\n *\n * @since 7.3.0\n */\nexport interface NextBundleSetEvent {\n /**\n * The unique identifier of the bundle that is set as the next bundle.\n *\n * If `null`, the default bundle will be used.\n *\n * @since 7.3.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * Listener for when the app is reloaded.\n *\n * @since 7.4.0\n */\nexport type ReloadedListener = () => void;\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n LiveUpdate?: {\n /**\n * The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * This is **NOT** the same as the app identifier (e.g. `com.example.app`).\n * This is a unique identifier generated by Capawesome Cloud (e.g. `6e351b4f-69a7-415e-a057-4567df7ffe94`).\n *\n * @since 5.0.0\n * @example '6e351b4f-69a7-415e-a057-4567df7ffe94'\n */\n appId?: string;\n /**\n * Whether or not to automatically block bundles that have been rolled back.\n *\n * When enabled, the plugin will automatically block bundles that caused a rollback\n * (up to 100 bundles). When the limit is reached, the oldest blocked bundle is unblocked.\n * Blocked bundles will be skipped in future sync operations.\n *\n * **Attention**: This option has no effect if `readyTimeout` is set to `0`.\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n * @default false\n */\n autoBlockRolledBackBundles?: boolean;\n /**\n * Whether or not to automatically delete unused bundles.\n *\n * When enabled, the plugin will automatically delete unused bundles after calling `ready()`.\n *\n * @since 5.0.0\n * @default false\n */\n autoDeleteBundles?: boolean;\n /**\n * The auto-update strategy for live updates.\n *\n * - `none`: Live updates will not be applied automatically.\n * - `background`: Live updates will be automatically downloaded\n * and applied in the background at app startup and when the app resumes\n * (if the last check was more than 15 minutes ago).\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n * @default 'none'\n * @example 'background'\n */\n autoUpdateStrategy?: 'none' | 'background';\n /**\n * The default channel of the app.\n *\n * This can be overridden by `setChannel()`, the `channel` parameter of `sync()`,\n * or the native channel configuration\n * (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or `capawesome_live_update_default_channel`\n * in `strings.xml` on Android).\n *\n * @since 6.3.0\n * @example 'production'\n */\n defaultChannel?: string;\n /**\n * The timeout in milliseconds for HTTP requests.\n *\n * @since 6.4.0\n * @default 60000\n */\n httpTimeout?: number;\n /**\n * The public key to verify the integrity of the bundle.\n *\n * The public key must be a PEM-encoded RSA public key.\n *\n * @since 6.1.0\n * @example '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----'\n */\n publicKey?: string;\n /**\n * The timeout in milliseconds to wait for the app to be ready\n * before resetting to the default bundle.\n *\n * It is strongly **recommended** to configure this option (e.g. `10000` ms)\n * so that the plugin can roll back to the default bundle in case of problems.\n * If configured, the plugin will wait for the app to call the `ready()`\n * method before resetting to the default bundle.\n *\n * Set to `0` to disable the timeout.\n *\n * @since 5.0.0\n * @default 0\n * @example 10000\n */\n readyTimeout?: number;\n /**\n * The API domain of the [Capawesome Cloud](https://cloud.capawesome.io) server **without** scheme or path.\n *\n * @since 7.0.0\n * @default 'api.cloud.capawesome.io'\n * @example 'api.cloud.capawesome.eu'\n */\n serverDomain?: string;\n };\n }\n}\n\nexport interface LiveUpdatePlugin {\n /**\n * Clear all blocked bundles from the blocked list.\n *\n * This removes all bundle identifiers that were automatically blocked\n * due to rollbacks when `autoBlockRolledBackBundles` is enabled.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n clearBlockedBundles(): Promise<void>;\n /**\n * Delete a bundle from the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n deleteBundle(options: DeleteBundleOptions): Promise<void>;\n /**\n * Download a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n downloadBundle(options: DownloadBundleOptions): Promise<void>;\n /**\n * Fetch channels from [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * This is primarily intended for development and QA purposes.\n * It allows you to retrieve a list of available channels so you can\n * dynamically switch between them using `setChannel(...)`.\n *\n * **Attention**: Only works for apps with public channels enabled.\n * If channels are private, they can still be set using `setChannel(...)`\n * but won't be returned by this method.\n *\n * Only available on Android and iOS.\n *\n * @since 8.2.0\n */\n fetchChannels(options?: FetchChannelsOptions): Promise<FetchChannelsResult>;\n /**\n * Fetch the latest bundle using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Only available on Android and iOS.\n *\n * @since 6.6.0\n */\n fetchLatestBundle(\n options?: FetchLatestBundleOptions,\n ): Promise<FetchLatestBundleResult>;\n /**\n * Get all blocked bundle identifiers.\n *\n * Returns the list of bundle identifiers that were automatically blocked\n * due to rollbacks when `autoBlockRolledBackBundles` is enabled.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n getBlockedBundles(): Promise<GetBlockedBundlesResult>;\n /**\n * Get all identifiers of bundles that have been downloaded.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n * @deprecated Use `getDownloadedBundles()` instead.\n */\n getBundles(): Promise<GetBundlesResult>;\n /**\n * Get the channel that is used for the update.\n *\n * The channel is resolved in the following order (highest priority first):\n * 1. `setChannel()` (SharedPreferences on Android / UserDefaults on iOS)\n * 2. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or\n * `capawesome_live_update_default_channel` in `strings.xml` on Android)\n * 3. Capacitor config `defaultChannel`\n *\n * **Note**: The `channel` parameter of `sync()` takes the highest priority\n * but is not persisted and therefore not returned by this method.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getChannel(): Promise<GetChannelResult>;\n /**\n * Get the runtime configuration.\n *\n * Returns the current plugin configuration including any runtime\n * overrides set via `setConfig()`.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n getConfig(): Promise<GetConfigResult>;\n /**\n * Get all identifiers of bundles that have been downloaded.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n getDownloadedBundles(): Promise<GetDownloadedBundlesResult>;\n /**\n * Get the bundle identifier of the current bundle.\n * The current bundle is the bundle that is currently used by the app.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n getCurrentBundle(): Promise<GetCurrentBundleResult>;\n /**\n * Get the custom identifier of the device.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getCustomId(): Promise<GetCustomIdResult>;\n /**\n * Get the unique device identifier.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getDeviceId(): Promise<GetDeviceIdResult>;\n /**\n * Check whether a sync operation is currently in progress.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n isSyncing(): Promise<IsSyncingResult>;\n /**\n * Get the bundle identifier of the next bundle.\n * The next bundle is the bundle that will be used after calling `reload()`\n * or restarting the app.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n getNextBundle(): Promise<GetNextBundleResult>;\n /**\n * Get the version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionCode(): Promise<GetVersionCodeResult>;\n /**\n * Get the version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionName(): Promise<GetVersionNameResult>;\n /**\n * Notify the plugin that the app is ready to use and no rollback is needed.\n *\n * **Attention**: This method should be called as soon as the app is ready to use\n * to prevent the app from being reset to the default bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n ready(): Promise<ReadyResult>;\n /**\n * Reload the app to apply the new bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reload(): Promise<void>;\n /**\n * Reset the app to the default bundle.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reset(): Promise<void>;\n /**\n * Reset the runtime configuration to the values from the Capacitor config file.\n *\n * This clears any runtime configuration set via `setConfig()`.\n * The changes take effect immediately.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n resetConfig(): Promise<void>;\n /**\n * Set the channel to use for the update.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setChannel(options: SetChannelOptions): Promise<void>;\n /**\n * Set the runtime configuration.\n *\n * This allows updating plugin configuration options at runtime.\n * The changes are persisted across app restarts and take effect immediately.\n *\n * **Important:** Runtime configuration is automatically reset to default values\n * whenever the native app is updated to a new version. This ensures that\n * configuration from previous versions doesn't persist after an app update.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n setConfig(options: SetConfigOptions): Promise<void>;\n /**\n * Set the custom identifier of the device.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n /**\n * Set the next bundle to use for the app.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n setNextBundle(options: SetNextBundleOptions): Promise<void>;\n /**\n * Automatically download and set the latest bundle for the app using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n sync(options?: SyncOptions): Promise<SyncResult>;\n /**\n * Listen for the download progress of a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 7.0.0\n */\n addListener(\n eventName: 'downloadBundleProgress',\n listenerFunc: DownloadBundleProgressListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for when a bundle is set as the next bundle.\n *\n * This event is triggered whenever a bundle is set to be used on the next app restart,\n * either through automatic updates or manual calls to `setNextBundle()`.\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n */\n addListener(\n eventName: 'nextBundleSet',\n listenerFunc: NextBundleSetListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for when the app is reloaded.\n *\n * This event is triggered after the `reload()` method is called\n * and the app has been reloaded.\n *\n * **Note:** To verify whether an update was successfully applied after a reload,\n * use the `ready()` method instead. The `ready()` method provides detailed information\n * about the current bundle, previous bundle, and whether a rollback occurred.\n *\n * Only available on Android and iOS.\n *\n * @since 7.4.0\n */\n addListener(\n eventName: 'reloaded',\n listenerFunc: ReloadedListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 7.2.0\n */\n removeAllListeners(): Promise<void>;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface DeleteBundleOptions {\n /**\n * The unique identifier of the bundle to delete.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\nexport interface DownloadBundleOptions {\n /**\n * The artifact type of the bundle.\n *\n * @since 6.6.0\n * @default 'zip'\n * @example 'manifest'\n */\n artifactType?: 'manifest' | 'zip';\n /**\n * The unique identifier of the bundle.\n *\n * **Attention**: The value `public` is reserved and cannot be used as a bundle identifier.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n /**\n * The checksum of the self-hosted bundle as a SHA-256 hash\n * in hex format to verify the integrity of the bundle.\n *\n * **Attention**: Only supported for the `zip` artifact type.\n *\n * @since 7.1.0\n */\n checksum?: string;\n /**\n * The signature of the self-hosted bundle as a signed SHA-256 hash\n * in base64 format to verify the integrity of the bundle.\n *\n * **Attention**: Only supported for the `zip` artifact type.\n *\n * @since 7.1.0\n */\n signature?: string;\n /**\n * The URL of the bundle to download.\n *\n * For the `zip` artifact type, the URL must point to a ZIP file.\n * For the `manifest` artifact type, the URL serves as the base URL\n * to download the individual files. For example, if the URL is\n * `https://example.com/download`, the plugin will download the file\n * with the href `index.html` from `https://example.com/download?href=index.html`.\n *\n * To **verify the integrity** of the file, the server should return\n * a `X-Checksum` header with the SHA-256 hash in hex format.\n *\n * To **verify the signature** of the file, the server should return\n * a `X-Signature` header with the signed SHA-256 hash in base64 format.\n *\n * @since 5.0.0\n * @example 'https://example.com/bundle.zip'\n */\n url: string;\n}\n\n/**\n * @since 8.2.0\n */\nexport interface FetchChannelsOptions {\n /**\n * The maximum number of channels to return.\n *\n * @since 8.2.0\n * @default 50\n */\n limit?: number;\n /**\n * The number of channels to skip.\n *\n * @since 8.2.0\n * @default 0\n */\n offset?: number;\n /**\n * The query to filter channels by name.\n *\n * @since 8.2.0\n */\n query?: string;\n}\n\n/**\n * @since 8.2.0\n */\nexport interface FetchChannelsResult {\n /**\n * The list of channels.\n *\n * @since 8.2.0\n */\n channels: Channel[];\n}\n\n/**\n * @since 8.2.0\n */\nexport interface Channel {\n /**\n * The unique identifier of the channel.\n *\n * @since 8.2.0\n */\n id: string;\n /**\n * The name of the channel.\n *\n * @since 8.2.0\n */\n name: string;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface FetchLatestBundleOptions {\n /**\n * The preferred channel name from which the latest bundle should be fetched.\n *\n * This is the SDK preference and may be overridden by a forced channel assignment\n * configured in the Capawesome Cloud Console.\n *\n * @since 6.7.0\n */\n channel?: string;\n}\n\n/**\n * @since 6.6.0\n */\nexport interface FetchLatestBundleResult {\n /**\n * The artifact type of the bundle.\n *\n * @since 6.7.0\n */\n artifactType?: 'manifest' | 'zip';\n /**\n * The unique identifier of the latest bundle.\n *\n * On Capawesome Cloud, this is the ID of the app build artifact.\n *\n * If `null`, no bundle is available.\n *\n * @since 6.6.0\n */\n bundleId: string | null;\n /**\n * The name of the channel that the bundle is actually from.\n *\n * This is the resolved channel after applying any forced channel assignment\n * and may differ from the channel set by the Live Update SDK.\n *\n * @since 8.3.0\n */\n channel?: string;\n /**\n * The checksum of the latest bundle if the bundle is self-hosted.\n *\n * If the bundle is hosted on Capawesome Cloud, the checksum will be\n * returned as response header when downloading the bundle.\n *\n * @since 7.1.0\n */\n checksum?: string;\n /**\n * Custom properties that are associated with the latest bundle.\n *\n * @since 7.0.0\n * @example { \"key\": \"value\" }\n */\n customProperties?: { [key: string]: string };\n /**\n * The URL of the latest bundle to download.\n * Pass this URL to the `downloadBundle(...)` method to download the bundle.\n *\n * @since 6.7.0\n */\n downloadUrl?: string;\n /**\n * The signature of the latest bundle if the bundle is self-hosted.\n *\n * If the bundle is hosted on Capawesome Cloud, the signature will be\n * returned as response header when downloading the bundle.\n *\n * @since 7.1.0\n */\n signature?: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundleResult {\n /**\n * The unique identifier of the active bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 7.4.0\n */\nexport interface GetBlockedBundlesResult {\n /**\n * An array of unique identifiers of all blocked bundles.\n *\n * @since 7.4.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundlesResult {\n /**\n * An array of unique identifiers of all available bundles.\n *\n * @since 5.0.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 7.4.0\n */\nexport interface GetDownloadedBundlesResult {\n /**\n * An array of unique identifiers of all downloaded bundles.\n *\n * @since 7.4.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetChannelResult {\n /**\n * The channel name.\n *\n * If `null`, the app is using the default channel.\n *\n * @since 5.0.0\n * @example 'production'\n */\n channel: string | null;\n}\n\n/**\n * @since 7.4.0\n */\nexport interface GetConfigResult {\n /**\n * The app ID used to identify the app.\n *\n * If `null`, no app ID is configured.\n *\n * @since 7.4.0\n * @example '6e351b4f-69a7-415e-a057-4567df7ffe94'\n */\n appId: string | null;\n /**\n * The auto-update strategy for live updates.\n *\n * @since 7.4.0\n * @example 'background'\n */\n autoUpdateStrategy: 'none' | 'background';\n}\n\n/**\n * @since 6.7.0\n */\nexport interface GetCurrentBundleResult {\n /**\n * The unique identifier of the current bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 6.7.0\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetDeviceIdResult {\n /**\n * The unique identifier of the device.\n *\n * On iOS, [`identifierForVendor`](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) is used.\n * The value of this property is the same for apps that come from the same vendor running on the same device.\n *\n * @since 5.0.0\n *\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n deviceId: string;\n}\n\n/**\n * @since 7.4.0\n */\nexport interface IsSyncingResult {\n /**\n * Whether a sync operation is currently in progress.\n *\n * @since 7.4.0\n */\n syncing: boolean;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface GetNextBundleResult {\n /**\n * The unique identifier of the next bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 6.7.0\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionCodeResult {\n /**\n * The version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1\"\n */\n versionCode: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionNameResult {\n /**\n * The version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1.0.0\"\n */\n versionName: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetCustomIdResult {\n /**\n * The custom identifier of the device.\n *\n * If `null`, no custom identifier is set.\n *\n * @since 5.0.0\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n customId: string | null;\n}\n\n/**\n * @since 7.0.0\n */\nexport interface ReadyResult {\n /**\n * The identifier of the previous bundle used.\n *\n * If `null`, the default bundle was used.\n *\n * @since 7.0.0\n */\n previousBundleId: string | null;\n /**\n * The identifier of the current bundle used.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 7.0.0\n */\n currentBundleId: string | null;\n /**\n * Whether or not the app was reset to the default bundle.\n *\n * @since 7.0.0\n */\n rollback: boolean;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetChannelOptions {\n /**\n * The channel name.\n *\n * Set `null` to remove the channel.\n *\n * @since 5.0.0\n */\n channel: string | null;\n}\n\n/**\n * @since 7.4.0\n */\nexport interface SetConfigOptions {\n /**\n * The app ID used to identify the app.\n *\n * Set `null` to reset to the value from the Capacitor config file.\n *\n * @since 7.4.0\n * @example '6e351b4f-69a7-415e-a057-4567df7ffe94'\n */\n appId?: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetCustomIdOptions {\n /**\n * The custom identifier of the device.\n *\n * Set `null` to remove the custom identifier.\n *\n * @since 5.0.0\n */\n customId: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface SetNextBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * Set `null` to use the default bundle (same as calling `reset()`).\n *\n * @since 6.7.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface SyncOptions {\n /**\n * The preferred channel name from which the latest bundle should be fetched.\n *\n * This is the SDK preference and may be overridden by a forced channel assignment\n * configured in the Capawesome Cloud Console.\n *\n * @since 6.7.0\n */\n channel?: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SyncResult {\n /**\n * The identifier of the next bundle to use.\n *\n * If `null`, the app is up-to-date and no new bundle is available.\n *\n * @since 5.0.0\n */\n nextBundleId: string | null;\n}\n\n/**\n * Listener for the download progress of a bundle.\n *\n * @since 7.0.0\n */\nexport type DownloadBundleProgressListener = (\n event: DownloadBundleProgressEvent,\n) => void;\n\n/**\n * Event that is triggered when the download progress of a bundle changes.\n *\n * @since 7.0.0\n */\nexport interface DownloadBundleProgressEvent {\n /**\n * The unique identifier of the bundle that is being downloaded.\n *\n * @since 7.0.0\n */\n bundleId: string;\n /**\n * The number of bytes that have been downloaded.\n *\n * @since 7.0.0\n */\n downloadedBytes: number;\n /**\n * The progress of the download in percent as a value between `0` and `1`.\n *\n * @since 7.0.0\n * @example 0.5\n */\n progress: number;\n /**\n * The total number of bytes to download.\n *\n * @since 7.0.0\n */\n totalBytes: number;\n}\n\n/**\n * Listener for when a bundle is set as the next bundle.\n *\n * @since 7.3.0\n */\nexport type NextBundleSetListener = (event: NextBundleSetEvent) => void;\n\n/**\n * Event that is triggered when a bundle is set as the next bundle.\n *\n * @since 7.3.0\n */\nexport interface NextBundleSetEvent {\n /**\n * The unique identifier of the bundle that is set as the next bundle.\n *\n * If `null`, the default bundle will be used.\n *\n * @since 7.3.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * Listener for when the app is reloaded.\n *\n * @since 7.4.0\n */\nexport type ReloadedListener = () => void;\n"]}
|
|
@@ -2,16 +2,28 @@ import Foundation
|
|
|
2
2
|
import Capacitor
|
|
3
3
|
|
|
4
4
|
@objc public class FetchLatestBundleOptions: NSObject {
|
|
5
|
+
private var appId: String?
|
|
5
6
|
private var channel: String?
|
|
6
7
|
|
|
7
8
|
init(_ call: CAPPluginCall) {
|
|
9
|
+
self.appId = nil
|
|
8
10
|
self.channel = call.getString("channel")
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
init(channel: String?) {
|
|
14
|
+
self.appId = nil
|
|
12
15
|
self.channel = channel
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
init(appId: String?, channel: String?) {
|
|
19
|
+
self.appId = appId
|
|
20
|
+
self.channel = channel
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func getAppId() -> String? {
|
|
24
|
+
return appId
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
func getChannel() -> String? {
|
|
16
28
|
return channel
|
|
17
29
|
}
|
|
@@ -4,20 +4,46 @@ import Capacitor
|
|
|
4
4
|
@objc public class FetchLatestBundleResult: NSObject, Result {
|
|
5
5
|
private let artifactType: ArtifactType?
|
|
6
6
|
private let bundleId: String?
|
|
7
|
+
private let channel: String?
|
|
7
8
|
private let checksum: String?
|
|
8
9
|
private let customProperties: [String: Any]?
|
|
9
10
|
private let downloadUrl: String?
|
|
10
11
|
private let signature: String?
|
|
11
12
|
|
|
12
|
-
init(artifactType: ArtifactType?, bundleId: String?, checksum: String?, customProperties: [String: Any]?, downloadUrl: String?, signature: String?) {
|
|
13
|
+
init(artifactType: ArtifactType?, bundleId: String?, channel: String?, checksum: String?, customProperties: [String: Any]?, downloadUrl: String?, signature: String?) {
|
|
13
14
|
self.artifactType = artifactType
|
|
14
15
|
self.bundleId = bundleId
|
|
16
|
+
self.channel = channel
|
|
15
17
|
self.checksum = checksum
|
|
16
18
|
self.customProperties = customProperties
|
|
17
19
|
self.downloadUrl = downloadUrl
|
|
18
20
|
self.signature = signature
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
public func getArtifactType() -> String? {
|
|
24
|
+
return artifactType?.rawValue
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public func getBundleId() -> String? {
|
|
28
|
+
return bundleId
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public func getChecksum() -> String? {
|
|
32
|
+
return checksum
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public func getCustomProperties() -> [String: Any]? {
|
|
36
|
+
return customProperties
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public func getDownloadUrl() -> String? {
|
|
40
|
+
return downloadUrl
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public func getSignature() -> String? {
|
|
44
|
+
return signature
|
|
45
|
+
}
|
|
46
|
+
|
|
21
47
|
public func toJSObject() -> AnyObject {
|
|
22
48
|
var result = JSObject()
|
|
23
49
|
if artifactType == .manifest {
|
|
@@ -26,6 +52,9 @@ import Capacitor
|
|
|
26
52
|
result["artifactType"] = "zip"
|
|
27
53
|
}
|
|
28
54
|
result["bundleId"] = bundleId == nil ? NSNull() : bundleId
|
|
55
|
+
if let channel = channel {
|
|
56
|
+
result["channel"] = channel
|
|
57
|
+
}
|
|
29
58
|
if let checksum = checksum {
|
|
30
59
|
result["checksum"] = checksum
|
|
31
60
|
}
|
|
@@ -3,6 +3,7 @@ import Foundation
|
|
|
3
3
|
public enum CustomError: Error {
|
|
4
4
|
case appIdMissing
|
|
5
5
|
case bundleAlreadyExists
|
|
6
|
+
case bundleDirectoryNotFound
|
|
6
7
|
case bundleIdMissing
|
|
7
8
|
case bundleIndexHtmlMissing
|
|
8
9
|
case bundleNotFound
|
|
@@ -12,7 +13,10 @@ public enum CustomError: Error {
|
|
|
12
13
|
case checksumMismatch
|
|
13
14
|
case customIdMissing
|
|
14
15
|
case downloadFailed
|
|
16
|
+
case downloadUrlMissing
|
|
15
17
|
case httpTimeout
|
|
18
|
+
case managerKeyMissing
|
|
19
|
+
case pluginNotInitialized
|
|
16
20
|
case signatureMissing
|
|
17
21
|
case signatureVerificationFailed
|
|
18
22
|
case syncInProgress
|
|
@@ -27,6 +31,8 @@ extension CustomError: LocalizedError {
|
|
|
27
31
|
return NSLocalizedString("appId must be configured.", comment: "appIdMissing")
|
|
28
32
|
case .bundleAlreadyExists:
|
|
29
33
|
return NSLocalizedString("bundle already exists.", comment: "bundleAlreadyExists")
|
|
34
|
+
case .bundleDirectoryNotFound:
|
|
35
|
+
return NSLocalizedString("Bundle directory could not be resolved.", comment: "bundleDirectoryNotFound")
|
|
30
36
|
case .bundleIdMissing:
|
|
31
37
|
return NSLocalizedString("bundleId must be provided.", comment: "bundleIdMissing")
|
|
32
38
|
case .bundleIndexHtmlMissing:
|
|
@@ -45,8 +51,14 @@ extension CustomError: LocalizedError {
|
|
|
45
51
|
return NSLocalizedString("customId must be provided.", comment: "customIdMissing")
|
|
46
52
|
case .downloadFailed:
|
|
47
53
|
return NSLocalizedString("Bundle could not be downloaded.", comment: "downloadFailed")
|
|
54
|
+
case .downloadUrlMissing:
|
|
55
|
+
return NSLocalizedString("Bundle does not have a valid download URL.", comment: "downloadUrlMissing")
|
|
48
56
|
case .httpTimeout:
|
|
49
57
|
return NSLocalizedString("Request timed out.", comment: "httpTimeout")
|
|
58
|
+
case .managerKeyMissing:
|
|
59
|
+
return NSLocalizedString("managerKey must be provided.", comment: "managerKeyMissing")
|
|
60
|
+
case .pluginNotInitialized:
|
|
61
|
+
return NSLocalizedString("Plugin is not initialized.", comment: "pluginNotInitialized")
|
|
50
62
|
case .signatureMissing:
|
|
51
63
|
return NSLocalizedString("Bundle does not contain a signature.", comment: "signatureMissing")
|
|
52
64
|
case .signatureVerificationFailed:
|
|
@@ -16,7 +16,7 @@ import CommonCrypto
|
|
|
16
16
|
private let httpClient: LiveUpdateHttpClient
|
|
17
17
|
private let libraryDirectoryUrl = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!
|
|
18
18
|
private let manifestFileName = "capawesome-live-update-manifest.json" // DO NOT CHANGE!
|
|
19
|
-
private let plugin: LiveUpdatePlugin
|
|
19
|
+
private let plugin: LiveUpdatePlugin?
|
|
20
20
|
private let preferences: LiveUpdatePreferences
|
|
21
21
|
|
|
22
22
|
private var rollbackDispatchWorkItem: DispatchWorkItem?
|
|
@@ -24,7 +24,10 @@ import CommonCrypto
|
|
|
24
24
|
private var lastAutoUpdateCheckTimestamp: Int64 = 0
|
|
25
25
|
private var syncInProgress = false
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
/// - Parameter plugin: The Capacitor plugin, or `nil` for a headless instance
|
|
28
|
+
/// (e.g. for Ionic Portals hosts that construct a provider manager directly).
|
|
29
|
+
/// In headless mode, WebView-related operations and plugin events are skipped.
|
|
30
|
+
init(config: LiveUpdateConfig, plugin: LiveUpdatePlugin? = nil) {
|
|
28
31
|
self.config = config
|
|
29
32
|
self.httpClient = LiveUpdateHttpClient(config: config)
|
|
30
33
|
self.plugin = plugin
|
|
@@ -118,7 +121,7 @@ import CommonCrypto
|
|
|
118
121
|
|
|
119
122
|
@objc public func fetchLatestBundle(_ options: FetchLatestBundleOptions) async throws -> FetchLatestBundleResult {
|
|
120
123
|
let response: GetLatestBundleResponse? = try await self.fetchLatestBundle(options)
|
|
121
|
-
return FetchLatestBundleResult(artifactType: response?.artifactType, bundleId: response?.bundleId, checksum: response?.checksum, customProperties: response?.customProperties, downloadUrl: response?.url, signature: response?.signature)
|
|
124
|
+
return FetchLatestBundleResult(artifactType: response?.artifactType, bundleId: response?.bundleId, channel: response?.channelName, checksum: response?.checksum, customProperties: response?.customProperties, downloadUrl: response?.url, signature: response?.signature)
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
@objc public func getBlockedBundles(completion: @escaping (Result?, Error?) -> Void) {
|
|
@@ -161,6 +164,14 @@ import CommonCrypto
|
|
|
161
164
|
completion(result, nil)
|
|
162
165
|
}
|
|
163
166
|
|
|
167
|
+
/// - Returns: The on-disk URL of a downloaded bundle, or `nil` if the bundle does not exist.
|
|
168
|
+
public func getBundleDirectory(bundleId: String) -> URL? {
|
|
169
|
+
guard hasBundleById(bundleId) else {
|
|
170
|
+
return nil
|
|
171
|
+
}
|
|
172
|
+
return buildBundleURLFor(bundleId: bundleId)
|
|
173
|
+
}
|
|
174
|
+
|
|
164
175
|
@objc public func getCustomId(completion: @escaping (Result?, Error?) -> Void) {
|
|
165
176
|
let customId = preferences.getCustomId()
|
|
166
177
|
|
|
@@ -580,6 +591,9 @@ import CommonCrypto
|
|
|
580
591
|
}
|
|
581
592
|
|
|
582
593
|
private func fetchLatestBundle(_ options: FetchLatestBundleOptions) async throws -> GetLatestBundleResponse? {
|
|
594
|
+
guard let appId = options.getAppId() ?? getAppId(), !appId.isEmpty else {
|
|
595
|
+
throw CustomError.appIdMissing
|
|
596
|
+
}
|
|
583
597
|
let channel = options.getChannel() ?? getChannel()
|
|
584
598
|
var parameters = [String: String]()
|
|
585
599
|
parameters["appVersionCode"] = getVersionCode()
|
|
@@ -591,7 +605,7 @@ import CommonCrypto
|
|
|
591
605
|
parameters["osVersion"] = await UIDevice.current.systemVersion
|
|
592
606
|
parameters["platform"] = "1"
|
|
593
607
|
parameters["pluginVersion"] = LiveUpdatePlugin.version
|
|
594
|
-
var urlComponents = URLComponents(string: "https://\(config.serverDomain)/v1/apps/\(
|
|
608
|
+
var urlComponents = URLComponents(string: "https://\(config.serverDomain)/v1/apps/\(appId)/bundles/latest")!
|
|
595
609
|
urlComponents.queryItems = parameters.map { URLQueryItem(name: $0.key, value: $0.value) }
|
|
596
610
|
let url = try urlComponents.asURL()
|
|
597
611
|
CAPLog.print("[", LiveUpdatePlugin.tag, "] Fetching latest bundle: ", url)
|
|
@@ -681,7 +695,7 @@ import CommonCrypto
|
|
|
681
695
|
|
|
682
696
|
/// - Returns: The path to the current bundle directory or `nil` if no view controller was found.
|
|
683
697
|
private func getCurrentCapacitorServerPath() -> String? {
|
|
684
|
-
guard let viewController = self.plugin
|
|
698
|
+
guard let viewController = self.plugin?.bridge?.viewController as? CAPBridgeViewController else {
|
|
685
699
|
return nil
|
|
686
700
|
}
|
|
687
701
|
return viewController.getServerBasePath()
|
|
@@ -763,7 +777,7 @@ import CommonCrypto
|
|
|
763
777
|
}
|
|
764
778
|
|
|
765
779
|
private func notifyDownloadBundleProgressListeners(_ event: DownloadBundleProgressEvent) {
|
|
766
|
-
plugin
|
|
780
|
+
plugin?.notifyDownloadBundleProgressListeners(event)
|
|
767
781
|
}
|
|
768
782
|
|
|
769
783
|
private func performAutoUpdate() {
|
|
@@ -840,7 +854,7 @@ import CommonCrypto
|
|
|
840
854
|
}
|
|
841
855
|
|
|
842
856
|
private func setCurrentCapacitorServerPath(path: String) {
|
|
843
|
-
guard let viewController = self.plugin
|
|
857
|
+
guard let viewController = self.plugin?.bridge?.viewController as? CAPBridgeViewController else {
|
|
844
858
|
return
|
|
845
859
|
}
|
|
846
860
|
viewController.setServerBasePath(path: path)
|
|
@@ -859,11 +873,11 @@ import CommonCrypto
|
|
|
859
873
|
|
|
860
874
|
private func notifyNextBundleSetListeners(_ bundleId: String?) {
|
|
861
875
|
let event = NextBundleSetEvent(bundleId: bundleId)
|
|
862
|
-
plugin
|
|
876
|
+
plugin?.notifyNextBundleSetListeners(event)
|
|
863
877
|
}
|
|
864
878
|
|
|
865
879
|
private func notifyReloadedListeners() {
|
|
866
|
-
plugin
|
|
880
|
+
plugin?.notifyReloadedListeners()
|
|
867
881
|
}
|
|
868
882
|
|
|
869
883
|
private func addBlockedBundleId(_ bundleId: String) {
|
|
@@ -8,7 +8,7 @@ import Capacitor
|
|
|
8
8
|
@objc(LiveUpdatePlugin)
|
|
9
9
|
public class LiveUpdatePlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
10
|
public static let tag = "LiveUpdate"
|
|
11
|
-
public static let version = "8.
|
|
11
|
+
public static let version = "8.3.0"
|
|
12
12
|
public static let userDefaultsPrefix = "CapawesomeLiveUpdate" // DO NOT CHANGE
|
|
13
13
|
|
|
14
14
|
public let identifier = "LiveUpdatePlugin"
|
|
@@ -47,7 +47,7 @@ public class LiveUpdatePlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
47
47
|
private let eventReloaded = "reloaded"
|
|
48
48
|
|
|
49
49
|
private var config: LiveUpdateConfig?
|
|
50
|
-
|
|
50
|
+
var implementation: LiveUpdate?
|
|
51
51
|
|
|
52
52
|
override public func load() {
|
|
53
53
|
self.config = liveUpdateConfig()
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#if CAPAWESOME_INCLUDE_IONIC_PROVIDER
|
|
2
|
+
import Foundation
|
|
3
|
+
import Capacitor
|
|
4
|
+
import LiveUpdateProvider
|
|
5
|
+
|
|
6
|
+
/// Ionic Live Update Provider manager backed by the Capawesome live update plugin.
|
|
7
|
+
///
|
|
8
|
+
/// Each manager instance is scoped by a `managerKey` so that multiple shells (Portals or
|
|
9
|
+
/// Federated Capacitor apps) can persist their own active bundle without colliding with
|
|
10
|
+
/// each other or with the standalone plugin's `currentBundleId` / `nextBundleId` state.
|
|
11
|
+
///
|
|
12
|
+
/// Provider configuration keys (V1):
|
|
13
|
+
/// - `managerKey` (required) — scopes per-manager persisted state
|
|
14
|
+
/// - `appId` (optional) — Capawesome Cloud app UUID; falls back to plugin config
|
|
15
|
+
/// - `channel` (optional) — channel to sync; falls back to plugin config
|
|
16
|
+
public final class LiveUpdateIonicManager: ProviderManager {
|
|
17
|
+
private static let userDefaultsPrefix = "CapawesomeLiveUpdateIonicProvider.lastSyncedBundleId."
|
|
18
|
+
|
|
19
|
+
public private(set) var latestAppDirectory: URL?
|
|
20
|
+
|
|
21
|
+
private let appId: String?
|
|
22
|
+
private let channel: String?
|
|
23
|
+
private let liveUpdate: LiveUpdate
|
|
24
|
+
private let managerKey: String
|
|
25
|
+
|
|
26
|
+
/// Creates a manager without a running Capacitor plugin, e.g. for Ionic Portals hosts
|
|
27
|
+
/// that construct the manager directly and attach it to a Portal via
|
|
28
|
+
/// `liveUpdateSource: .provider(manager:)`. Uses a headless `LiveUpdate` instance with
|
|
29
|
+
/// the default configuration; pass `appId` and `channel` via the configuration dictionary.
|
|
30
|
+
public convenience init(configuration: [String: Any]) throws {
|
|
31
|
+
try self.init(configuration: configuration, liveUpdate: LiveUpdate(config: LiveUpdateConfig()))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
init(configuration: [String: Any], liveUpdate: LiveUpdate) throws {
|
|
35
|
+
guard let managerKey = configuration["managerKey"] as? String, !managerKey.isEmpty else {
|
|
36
|
+
throw ProviderError.invalidConfiguration(message: CustomError.managerKeyMissing.localizedDescription)
|
|
37
|
+
}
|
|
38
|
+
self.managerKey = managerKey
|
|
39
|
+
self.appId = configuration["appId"] as? String
|
|
40
|
+
self.channel = configuration["channel"] as? String
|
|
41
|
+
self.liveUpdate = liveUpdate
|
|
42
|
+
|
|
43
|
+
// Restore the last synced bundle directory, if any.
|
|
44
|
+
if let persistedBundleId = UserDefaults.standard.string(forKey: lastSyncedBundleIdKey()) {
|
|
45
|
+
self.latestAppDirectory = liveUpdate.getBundleDirectory(bundleId: persistedBundleId)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public func sync() async throws -> (any ProviderSyncResult)? {
|
|
50
|
+
do {
|
|
51
|
+
let result = try await liveUpdate.fetchLatestBundle(FetchLatestBundleOptions(appId: appId, channel: channel))
|
|
52
|
+
|
|
53
|
+
// No update available; nothing to report.
|
|
54
|
+
guard let bundleId = result.getBundleId() else {
|
|
55
|
+
return nil
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Bundle already on disk — just point latestAppDirectory at it and persist.
|
|
59
|
+
if let existingDirectory = liveUpdate.getBundleDirectory(bundleId: bundleId) {
|
|
60
|
+
applySyncedBundle(bundleId: bundleId, directory: existingDirectory)
|
|
61
|
+
return MetadataSyncResult(metadata: buildMetadata(bundleId: bundleId, customProperties: result.getCustomProperties()))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Otherwise, download and then apply.
|
|
65
|
+
guard let downloadUrl = result.getDownloadUrl(), !downloadUrl.isEmpty else {
|
|
66
|
+
throw CustomError.downloadUrlMissing
|
|
67
|
+
}
|
|
68
|
+
let downloadOptions = DownloadBundleOptions(
|
|
69
|
+
artifactType: result.getArtifactType() ?? "zip",
|
|
70
|
+
bundleId: bundleId,
|
|
71
|
+
checksum: result.getChecksum(),
|
|
72
|
+
signature: result.getSignature(),
|
|
73
|
+
url: downloadUrl
|
|
74
|
+
)
|
|
75
|
+
try await liveUpdate.downloadBundle(downloadOptions)
|
|
76
|
+
|
|
77
|
+
guard let downloadedDirectory = liveUpdate.getBundleDirectory(bundleId: bundleId) else {
|
|
78
|
+
throw CustomError.bundleDirectoryNotFound
|
|
79
|
+
}
|
|
80
|
+
applySyncedBundle(bundleId: bundleId, directory: downloadedDirectory)
|
|
81
|
+
return MetadataSyncResult(metadata: buildMetadata(bundleId: bundleId, customProperties: result.getCustomProperties()))
|
|
82
|
+
} catch {
|
|
83
|
+
CAPLog.print("[", LiveUpdatePlugin.tag, "] Ionic provider sync failed: ", error.localizedDescription)
|
|
84
|
+
throw error
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private func applySyncedBundle(bundleId: String, directory: URL) {
|
|
89
|
+
latestAppDirectory = directory
|
|
90
|
+
UserDefaults.standard.set(bundleId, forKey: lastSyncedBundleIdKey())
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private func buildMetadata(bundleId: String, customProperties: [String: Any]?) -> [String: Any] {
|
|
94
|
+
var metadata: [String: Any] = ["bundleId": bundleId]
|
|
95
|
+
if let channel = channel {
|
|
96
|
+
metadata["channel"] = channel
|
|
97
|
+
}
|
|
98
|
+
if let customProperties = customProperties, !customProperties.isEmpty {
|
|
99
|
+
metadata["customProperties"] = customProperties
|
|
100
|
+
}
|
|
101
|
+
return metadata
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private func lastSyncedBundleIdKey() -> String {
|
|
105
|
+
return Self.userDefaultsPrefix + managerKey
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
#endif
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#if CAPAWESOME_INCLUDE_IONIC_PROVIDER
|
|
2
|
+
import Foundation
|
|
3
|
+
import LiveUpdateProvider
|
|
4
|
+
|
|
5
|
+
extension LiveUpdatePlugin: LiveUpdateProvider {
|
|
6
|
+
/// Creates a manager for the Ionic Live Update Provider SDK. Invoked natively by
|
|
7
|
+
/// Federated Capacitor after resolving this plugin by its Capacitor plugin name.
|
|
8
|
+
public func createManager(configuration: [String: Any]) throws -> any ProviderManager {
|
|
9
|
+
guard let implementation = implementation else {
|
|
10
|
+
throw ProviderError.invalidConfiguration(message: CustomError.pluginNotInitialized.localizedDescription)
|
|
11
|
+
}
|
|
12
|
+
return try LiveUpdateIonicManager(configuration: configuration, liveUpdate: implementation)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
#endif
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/capacitor-live-update",
|
|
3
|
-
"version": "8.
|
|
4
|
-
"description": "Capacitor plugin to update your app remotely in real-time.",
|
|
3
|
+
"version": "8.3.0-dev.f9cc1d15.1783929784",
|
|
4
|
+
"description": "Capacitor plugin to update your app remotely in real-time on Android and iOS.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/esm/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"bugs": {
|
|
24
24
|
"url": "https://github.com/capawesome-team/capacitor-plugins/issues"
|
|
25
25
|
},
|
|
26
|
-
"homepage": "https://capawesome.io/
|
|
26
|
+
"homepage": "https://capawesome.io/docs/sdks/capacitor/live-update/",
|
|
27
27
|
"funding": [
|
|
28
28
|
{
|
|
29
29
|
"type": "github",
|
|
@@ -44,7 +44,14 @@
|
|
|
44
44
|
"live update",
|
|
45
45
|
"remote update",
|
|
46
46
|
"ota",
|
|
47
|
-
"capgo"
|
|
47
|
+
"capgo",
|
|
48
|
+
"capacitor-plugin",
|
|
49
|
+
"live updates",
|
|
50
|
+
"ota update",
|
|
51
|
+
"over-the-air updates",
|
|
52
|
+
"code push",
|
|
53
|
+
"hot update",
|
|
54
|
+
"bundle management"
|
|
48
55
|
],
|
|
49
56
|
"scripts": {
|
|
50
57
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
@@ -74,7 +81,6 @@
|
|
|
74
81
|
"@capacitor/ios": "8.0.0",
|
|
75
82
|
"@ionic/eslint-config": "0.4.0",
|
|
76
83
|
"eslint": "8.57.0",
|
|
77
|
-
"prettier": "3.4.2",
|
|
78
84
|
"prettier-plugin-java": "2.6.7",
|
|
79
85
|
"rimraf": "6.1.2",
|
|
80
86
|
"rollup": "4.53.3",
|