### Start Lynx Update Server Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Command to start the Lynx Update server, specifying the directory for update data. This is the initial step to get the server running. ```bash lynx-update server -d ./my-update-data ``` -------------------------------- ### Report Installation Status API (POST /api/report-install) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt API endpoint to report the success or failure of an update installation. This information is used for rollback detection and analytics. ```bash curl -X POST http://localhost:3000/api/report-install \ -H "Content-Type: application/json" \ -d '{ "deploymentKey": "your-deployment-key", "platform": "android", "version": "1.0.1", "status": "success" }' # Response { "success": true } ``` -------------------------------- ### Start Hot Update Server (CLI) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Launches the self-hosted Node.js server responsible for distributing hot updates. The server can be started on the default port (3000) or a custom port. ```bash # Start server on default port 3000 lynx-update server # Start on custom port lynx-update server -p 8080 ``` -------------------------------- ### GET /api/stats/:key Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Retrieves deployment statistics including checks, downloads, installs, and failures. ```APIDOC ## GET /api/stats/:key ### Description Retrieves deployment statistics including checks, downloads, installs, and failures. ### Method GET ### Endpoint /api/stats/:key ### Parameters #### Path Parameters - **key** (string) - Required - The deployment key to retrieve statistics for. ### Request Example ```bash curl http://localhost:3000/api/stats/your-deployment-key ``` ### Response #### Success Response (200) - **android** (object) - Statistics for the Android platform. - **checks** (integer) - Number of update checks. - **downloads** (integer) - Number of successful downloads. - **installs** (integer) - Number of successful installations. - **failures** (integer) - Number of installation failures. - **versions** (object) - A map of versions to their install counts. - **lastActivity** (string) - Timestamp of the last activity. - **ios** (object) - Statistics for the iOS platform (structure similar to android). #### Response Example ```json { "android": { "checks": 1250, "downloads": 890, "installs": 875, "failures": 15, "versions": { "1.0.1": 500, "1.0.0": 375 }, "lastActivity": "2024-01-15T10:30:00.000Z" }, "ios": { "checks": 980, "downloads": 720, "installs": 710, "failures": 10, "versions": { "1.0.1": 450, "1.0.0": 260 }, "lastActivity": "2024-01-15T10:25:00.000Z" } } ``` ``` -------------------------------- ### Android SDK (Kotlin) - Download and Install Update Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Downloads an available update with progress tracking and handles completion. ```APIDOC ### Download and Install Update Download an available update with progress tracking. ```kotlin import com.lynx.hotupdate.LynxHotUpdate import com.lynx.hotupdate.UpdateResult fun downloadUpdate(result: UpdateResult) { LynxHotUpdate.downloadUpdate( updateResult = result, onProgress = { progress -> // Update UI with download progress (0-100) println("Download progress: $progress%") progressBar.progress = progress }, onComplete = { success, error -> if (success) { println("Update downloaded successfully!") println("Update will be applied on next app launch") // Optionally show dialog asking user to restart showRestartDialog() } else { println("Download failed: $error") } } ) } fun showRestartDialog() { AlertDialog.Builder(context) .setTitle("Update Ready") .setMessage("A new version has been downloaded. Restart now to apply?") .setPositiveButton("Restart") { _, _ -> LynxHotUpdate.restartApp() } .setNegativeButton("Later", null) .show() } ``` ``` -------------------------------- ### Download and Install Update (Kotlin) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Downloads an available update with progress tracking and handles the completion callback. It allows for UI updates during download and provides feedback on success or failure, including instructions for applying the update on the next app launch. ```kotlin import com.lynx.hotupdate.LynxHotUpdate import com.lynx.hotupdate.UpdateResult fun downloadUpdate(result: UpdateResult) { LynxHotUpdate.downloadUpdate( updateResult = result, onProgress = { progress -> // Update UI with download progress (0-100) println("Download progress: $progress%") progressBar.progress = progress }, onComplete = { success, error -> if (success) { println("Update downloaded successfully!") println("Update will be applied on next app launch") // Optionally show dialog asking user to restart showRestartDialog() } else { println("Download failed: $error") } } ) } fun showRestartDialog() { AlertDialog.Builder(context) .setTitle("Update Ready") .setMessage("A new version has been downloaded. Restart now to apply?") .setPositiveButton("Restart") { _, _ -> LynxHotUpdate.restartApp() } .setNegativeButton("Later", null) .show() } ``` -------------------------------- ### GET /api/download/:file Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Downloads a bundle package by filename. ```APIDOC ## GET /api/download/:file ### Description Downloads a bundle package by filename. ### Method GET ### Endpoint /api/download/:file ### Parameters #### Path Parameters - **file** (string) - Required - The filename of the package to download. ### Request Example ```bash curl -O http://localhost:3000/api/download/com.example.app-android-1.0.1-1705312200000.zip ``` ### Response #### Success Response (200) - The content of the requested file. #### Response Example (Binary content of the zip file) ``` -------------------------------- ### Initialize Android SDK (Kotlin) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Initializes the Lynx Hot Update SDK within your Android Application class. This setup is crucial for enabling hot update functionality and requires the deployment key and server URL. ```kotlin import android.app.Application import com.lynx.hotupdate.LynxHotUpdate import com.lynx.hotupdate.HotUpdateTemplateProvider import com.lynx.tasm.LynxEnv class MyApplication : Application() { override fun onCreate() { super.onCreate() // Initialize hot update SDK LynxHotUpdate.init( context = this, deploymentKey = "your-production-deployment-key", serverUrl = "https://updates.example.com" ) // Replace default TemplateProvider with HotUpdateTemplateProvider LynxEnv.inst().setTemplateProvider(HotUpdateTemplateProvider(this)) } } ``` -------------------------------- ### Get Statistics API (GET /api/stats/:key) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt API endpoint to retrieve deployment statistics, including update checks, downloads, installs, and failures for a given deployment key. It also provides version-specific data. ```bash curl http://localhost:3000/api/stats/your-deployment-key # Response { "android": { "checks": 1250, "downloads": 890, "installs": 875, "failures": 15, "versions": { "1.0.1": 500, "1.0.0": 375 }, "lastActivity": "2024-01-15T10:30:00.000Z" }, "ios": { "checks": 980, "downloads": 720, "installs": 710, "failures": 10, "versions": { "1.0.1": 450, "1.0.0": 260 }, "lastActivity": "2024-01-15T10:25:00.000Z" } } ``` -------------------------------- ### POST /api/report-install Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Reports whether an update installation succeeded or failed. Used for rollback detection. ```APIDOC ## POST /api/report-install ### Description Reports whether an update installation succeeded or failed. Used for rollback detection. ### Method POST ### Endpoint /api/report-install ### Parameters #### Request Body - **deploymentKey** (string) - Required - The deployment key. - **platform** (string) - Required - The platform of the client (e.g., "android", "ios"). - **version** (string) - Required - The version of the installed update. - **status** (string) - Required - The installation status ("success" or "failure"). ### Request Example ```json { "deploymentKey": "your-deployment-key", "platform": "android", "version": "1.0.1", "status": "success" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the report was received successfully. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Android (Kotlin) - Bundle Loading Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Provides methods to get bundle paths, check if bundles should be loaded from the file system, and load bundle bytes directly for hot updates. ```APIDOC ## Bundle Loading (Kotlin) ### Description Load bundles with hot update support (used by TemplateProvider). ### Method ```kotlin // Get bundle path (returns hot update path if available, asset name otherwise) val bundlePath = LynxHotUpdate.getBundlePath("main.lynx.bundle") // Check if bundle should be loaded from file system val useFileSystem = LynxHotUpdate.shouldLoadFromFile("main.lynx.bundle") // Load bundle bytes directly val bundleBytes = LynxHotUpdate.loadBundle("main.lynx.bundle") ``` ``` -------------------------------- ### GET /api/releases/:key/:p Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Retrieves release history for a specific platform. ```APIDOC ## GET /api/releases/:key/:p ### Description Retrieves release history for a specific platform. ### Method GET ### Endpoint /api/releases/:key/:p ### Parameters #### Path Parameters - **key** (string) - Required - The deployment key. - **p** (string) - Required - The platform (e.g., "android", "ios"). ### Request Example ```bash curl http://localhost:3000/api/releases/your-deployment-key/android ``` ### Response #### Success Response (200) - **releases** (array) - A list of release objects. - **version** (string) - The version of the release. - **platform** (string) - The platform of the release. - **filename** (string) - The filename of the release package. - **hash** (string) - The hash of the release package. - **size** (integer) - The size of the release package in bytes. - **description** (string) - The description of the release. - **mandatory** (boolean) - Whether the release is mandatory. - **rollout** (integer) - The rollout percentage. - **disabled** (boolean) - Whether the release is disabled. - **createdAt** (string) - The timestamp when the release was created. #### Response Example ```json { "releases": [ { "version": "1.0.1", "platform": "android", "filename": "com.example.app-android-1.0.1-1705312200000.zip", "hash": "a1b2c3d4e5f6...", "size": 524288, "description": "Bug fixes", "mandatory": false, "rollout": 100, "disabled": false, "createdAt": "2024-01-15T10:30:00.000Z" }, { "version": "1.0.0", "platform": "android", "filename": "com.example.app-android-1.0.0-1705225800000.zip", "hash": "f6e5d4c3b2a1...", "size": 512000, "description": "Initial release", "mandatory": false, "rollout": 100, "disabled": false, "createdAt": "2024-01-14T10:30:00.000Z" } ] } ``` ``` -------------------------------- ### Load Lynx Bundles with Hot Update Support (Swift) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt This Swift code demonstrates loading Lynx bundles with hot update support on iOS. It mirrors the functionality found in the Kotlin snippet, showing how to get the bundle path, check if it should be loaded from the file system, and load the bundle data directly. This is essential for dynamically loading updated Lynx views in your iOS application. ```swift // Get bundle path (returns hot update path if available) let bundlePath = LynxHotUpdate.shared.getBundlePath("main.lynx.bundle") // Check if bundle should be loaded from file system let useFileSystem = LynxHotUpdate.shared.shouldLoadFromFile("main.lynx.bundle") // Load bundle data directly if let bundleData = LynxHotUpdate.shared.loadBundle("main.lynx.bundle") { // Use bundle data print("Bundle loaded: (bundleData.count) bytes") } ``` -------------------------------- ### Get Release History API (GET /api/releases/:key/:p) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt API endpoint to retrieve the release history for a specific platform associated with a deployment key. It returns a list of releases with their details. ```bash curl http://localhost:3000/api/releases/your-deployment-key/android # Response { "releases": [ { "version": "1.0.1", "platform": "android", "filename": "com.example.app-android-1.0.1-1705312200000.zip", "hash": "a1b2c3d4e5f6...", "size": 524288, "description": "Bug fixes", "mandatory": false, "rollout": 100, "disabled": false, "createdAt": "2024-01-15T10:30:00.000Z" }, { "version": "1.0.0", "platform": "android", "filename": "com.example.app-android-1.0.0-1705225800000.zip", "hash": "f6e5d4c3b2a1...", "size": 512000, "description": "Initial release", "mandatory": false, "rollout": 100, "disabled": false, "createdAt": "2024-01-14T10:30:00.000Z" } ] } ``` -------------------------------- ### Download and Install Lynx Update with Progress (Swift) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt This Swift function handles the download of an available Lynx update, including progress tracking. It uses the `downloadUpdate` method with `onProgress` and `completion` callbacks. The `onProgress` callback updates a UI progress view, while the `completion` callback indicates success or failure and prompts the user to restart the app to apply the update. A helper function `showRestartAlert` is also provided. ```swift func downloadUpdate(_ result: UpdateResult) { LynxHotUpdate.shared.downloadUpdate( result, onProgress: { progress in // Update UI with download progress (0-100) print("Download progress: (progress)%") DispatchQueue.main.async { self.progressView.progress = Float(progress) / 100.0 } }, completion: { success, error in if success { print("Update downloaded successfully!") print("Update will be applied on next app launch") // Show alert to restart app self.showRestartAlert() } else { print("Download failed: (error ?? "Unknown error")") } } ) } func showRestartAlert() { let alert = UIAlertController( title: "Update Ready", message: "A new version has been downloaded. Restart now to apply?", preferredStyle: .alert ) alert.addAction(UIAlertAction(title: "Later", style: .cancel)) alert.addAction(UIAlertAction(title: "Restart", style: .default) { _ in // Exit app - user needs to relaunch manually on iOS exit(0) }) present(alert, animated: true) } ``` -------------------------------- ### Install Lynx Hot Update CLI Source: https://github.com/1600822305/lynx-hot-update/blob/main/README.en.md Installs the Lynx Hot Update command-line interface globally using npm. This tool is used for managing hot updates, including initialization, publishing, and rollback. ```bash npm install -g lynx-hot-update ``` -------------------------------- ### iOS (Swift) - Download and Install Update Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Downloads an available update with progress tracking and prompts the user to restart the application to apply the update. ```APIDOC ## Download and Install Update (Swift) ### Description Download an available update with progress tracking. ### Method ```swift func downloadUpdate(_ result: UpdateResult) { LynxHotUpdate.shared.downloadUpdate( result, onProgress: { progress in // Update UI with download progress (0-100) print("Download progress: (progress)%") DispatchQueue.main.async { self.progressView.progress = Float(progress) / 100.0 } }, completion: { success, error in if success { print("Update downloaded successfully!") print("Update will be applied on next app launch") // Show alert to restart app self.showRestartAlert() } else { print("Download failed: (error ?? "Unknown error")") } } ) } func showRestartAlert() { let alert = UIAlertController( title: "Update Ready", message: "A new version has been downloaded. Restart now to apply?", preferredStyle: .alert ) alert.addAction(UIAlertAction(title: "Later", style: .cancel)) alert.addAction(UIAlertAction(title: "Restart", style: .default) { _ in // Exit app - user needs to relaunch manually on iOS exit(0) }) present(alert, animated: true) } ``` ``` -------------------------------- ### Load Lynx Bundles with Hot Update Support (Kotlin) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt This snippet demonstrates how to load Lynx bundles with hot update support using the LynxHotUpdate class in Kotlin. It shows how to get the bundle path, check if it should be loaded from the file system, and load the bundle bytes directly. This is useful for Android development where hot updates are managed. ```kotlin import com.lynx.hotupdate.LynxHotUpdate // Get bundle path (returns hot update path if available, asset name otherwise) val bundlePath = LynxHotUpdate.getBundlePath("main.lynx.bundle") // Check if bundle should be loaded from file system val useFileSystem = LynxHotUpdate.shouldLoadFromFile("main.lynx.bundle") // Load bundle bytes directly val bundleBytes = LynxHotUpdate.loadBundle("main.lynx.bundle") ``` -------------------------------- ### Download Package API (GET /api/download/:file) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt API endpoint to download a specific bundle package using its filename. This is typically used by clients to fetch update files. ```bash curl -O http://localhost:3000/api/download/com.example.app-android-1.0.1-1705312200000.zip ``` -------------------------------- ### Android SDK (Kotlin) - Version Management Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Provides functions for managing hot update versions, including getting the current version, clearing updates, and notifying update status. ```APIDOC ### Version Management Get current version and manage updates. ```kotlin import com.lynx.hotupdate.LynxHotUpdate // Get currently installed hot update version val currentVersion = LynxHotUpdate.getCurrentVersion() println("Current version: $currentVersion") // Clear all hot updates (revert to bundled version) LynxHotUpdate.clearUpdates() // Mark update as successful (prevents auto-rollback) LynxHotUpdate.notifyUpdateSuccess() // Mark update as failed (triggers rollback) LynxHotUpdate.notifyUpdateFailed() // Restart app to apply pending update LynxHotUpdate.restartApp() ``` ``` -------------------------------- ### GET /api/health Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Health check endpoint for the server. ```APIDOC ## GET /api/health ### Description Health check endpoint for the server. ### Method GET ### Endpoint /api/health ### Response #### Success Response (200) - A simple status indicator, e.g., "OK". #### Response Example ``` OK ``` ``` -------------------------------- ### Manage Lynx Update Versions (Swift) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt This Swift snippet covers version management for Lynx hot updates. It shows how to retrieve the currently installed hot update version, clear all applied updates to revert to the bundled version, and notify the SDK about the success or failure of an update. These functions are crucial for maintaining the integrity and state of hot updates. ```swift // Get currently installed hot update version let currentVersion = LynxHotUpdate.shared.getCurrentVersion() print("Current version: (currentVersion)") // Clear all hot updates (revert to bundled version) LynxHotUpdate.shared.clearUpdates() // Mark update as successful (prevents auto-rollback) LynxHotUpdate.shared.notifyUpdateSuccess() // Mark update as failed (triggers rollback) LynxHotUpdate.shared.notifyUpdateFailed() ``` -------------------------------- ### iOS (Swift) - Version Management Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Provides methods to get the current hot update version, clear all hot updates, and notify the SDK about the success or failure of an update. ```APIDOC ## Version Management (Swift) ### Description Get current version and manage updates. ### Method ```swift // Get currently installed hot update version let currentVersion = LynxHotUpdate.shared.getCurrentVersion() print("Current version: (currentVersion)") // Clear all hot updates (revert to bundled version) LynxHotUpdate.shared.clearUpdates() // Mark update as successful (prevents auto-rollback) LynxHotUpdate.shared.notifyUpdateSuccess() // Mark update as failed (triggers rollback) LynxHotUpdate.shared.notifyUpdateFailed() ``` ``` -------------------------------- ### Lynx Hot Update CLI Command Reference Source: https://github.com/1600822305/lynx-hot-update/blob/main/README.en.md Provides a reference for various Lynx Hot Update CLI commands, including initializing, publishing, rolling back, viewing status and history, modifying releases, promoting releases, configuring settings, and starting the update server. ```bash # Initialize hot update config lynx-update init lynx-update init --server # Specify update server # Publish Updates lynx-update publish # Publish to all platforms lynx-update publish -p android # Publish to Android only lynx-update publish -v 1.0.1 # Specify version lynx-update publish -d "Fixed some issues" # Add description lynx-update publish --mandatory # Force update lynx-update publish --rollout 50 # Gradual rollout 50% lynx-update publish --diff # Enable differential updates lynx-update publish --target-binary-version ">=1.0.0" # Target specific app versions # Rollback lynx-update rollback # Interactive version selection lynx-update rollback -v 1.0.0 # Rollback to specific version lynx-update rollback -p android # Rollback Android only # View Status lynx-update status # View deployment status lynx-update status -p android # View Android status # Release History lynx-update history # View release history lynx-update history -p android # View Android history lynx-update history -n 20 # Show last 20 releases lynx-update history -v # Show descriptions # Modify Releases lynx-update patch 1.0.1 --disabled true # Disable a version lynx-update patch 1.0.1 --disabled false # Enable a version lynx-update patch 1.0.1 --rollout 50 # Change rollout percentage lynx-update patch 1.0.1 --mandatory true # Set as mandatory # Promote Releases lynx-update promote # Staging → Production lynx-update promote -s staging -t production # Specify source and target lynx-update promote --rollout 10 # Rollout 10% after promote # Configuration lynx-update config --show # Show current config lynx-update config --server # Change server URL # Start Server lynx-update server # Start hot update server lynx-update server -p 8080 # Specify port lynx-update server -d ./data # Specify data directory ``` -------------------------------- ### Promote Release Between Environments (CLI) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Promotes a release from one deployment environment (e.g., staging) to another (e.g., production). This command can specify source and target environments, an initial rollout percentage, and skip confirmation prompts. ```bash # Promote staging to production lynx-update promote # Specify source and target environments lynx-update promote -s staging -t production # Promote with initial rollout percentage lynx-update promote --rollout 10 # Skip confirmation prompt lynx-update promote -y ``` -------------------------------- ### Android SDK (Kotlin) - Initialize SDK Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Initializes the hot update SDK within your Android Application class. ```APIDOC ### Initialize SDK Initialize the hot update SDK in your Application class. ```kotlin import android.app.Application import com.lynx.hotupdate.LynxHotUpdate import com.lynx.hotupdate.HotUpdateTemplateProvider import com.lynx.tasm.LynxEnv class MyApplication : Application() { override fun onCreate() { super.onCreate() // Initialize hot update SDK LynxHotUpdate.init( context = this, deploymentKey = "your-production-deployment-key", serverUrl = "https://updates.example.com" ) // Replace default TemplateProvider with HotUpdateTemplateProvider LynxEnv.inst().setTemplateProvider(HotUpdateTemplateProvider(this)) } } ``` ``` -------------------------------- ### View Release History (CLI) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Shows the history of published releases, including version numbers, timestamps, and descriptions. Options are available to limit the number of releases shown and to display detailed descriptions. ```bash # View last 10 releases lynx-update history # View Android history with last 20 releases lynx-update history -p android -n 20 # Show detailed descriptions lynx-update history -v ``` -------------------------------- ### iOS (Swift) - Bundle Loading Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Retrieves bundle paths, checks file system loading eligibility, and loads bundle data directly for hot updates. ```APIDOC ## Bundle Loading (Swift) ### Description Load bundles with hot update support. ### Method ```swift // Get bundle path (returns hot update path if available) let bundlePath = LynxHotUpdate.shared.getBundlePath("main.lynx.bundle") // Check if bundle should be loaded from file system let useFileSystem = LynxHotUpdate.shared.shouldLoadFromFile("main.lynx.bundle") // Load bundle data directly if let bundleData = LynxHotUpdate.shared.loadBundle("main.lynx.bundle") { // Use bundle data print("Bundle loaded: (bundleData.count) bytes") } ``` ``` -------------------------------- ### Version Management (Kotlin) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Provides utility functions for managing hot updates, including retrieving the current version, clearing all applied updates, notifying the system about update success or failure, and restarting the application to apply pending updates. ```kotlin import com.lynx.hotupdate.LynxHotUpdate // Get currently installed hot update version val currentVersion = LynxHotUpdate.getCurrentVersion() println("Current version: $currentVersion") // Clear all hot updates (revert to bundled version) LynxHotUpdate.clearUpdates() // Mark update as successful (prevents auto-rollback) LynxHotUpdate.notifyUpdateSuccess() // Mark update as failed (triggers rollback) LynxHotUpdate.notifyUpdateFailed() // Restart app to apply pending update LynxHotUpdate.restartApp() ``` -------------------------------- ### Initialize Lynx Hot Update Configuration (CLI) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Initializes hot update configuration for a Lynx project by creating `lynx-update.json`. It requires an existing Lynx Native project with `lynx.config.json`. The command can be run interactively or with a custom server URL. ```bash cd your-lynx-project lynx-update init lynx-update init --server https://updates.example.com # Output after initialization: # Configuration: # App Key: com.example.app # Server: http://localhost:3000 # Platforms: android, ios # # Deployment Keys: # Android Staging: AbCdEfGhIjKlMnOpQrStUvWxYz123456 # Android Production: ZyXwVuTsRqPoNmLkJiHgFeDcBa654321 # iOS Staging: ... # iOS Production: ... ``` -------------------------------- ### HotUpdateTemplateProvider for Bundle Loading (Kotlin) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Custom TemplateProvider for Android (Kotlin) that loads bundles from hot updates. It includes a fallback mechanism to load assets from the application's bundled assets if the hot update fails. ```kotlin // Android - HotUpdateTemplateProvider.kt import android.content.Context import com.lynx.tasm.provider.AbsTemplateProvider class HotUpdateTemplateProvider(context: Context) : AbsTemplateProvider() { private val mContext = context.applicationContext override fun loadTemplate(uri: String, callback: Callback) { Thread { try { // Try hot update bundle first val bundleBytes = LynxHotUpdate.loadBundle(uri) callback.onSuccess(bundleBytes) } catch (e: Exception) { // Fallback to assets try { mContext.assets.open(uri).use { inputStream -> callback.onSuccess(inputStream.readBytes()) } } catch (fallbackError: Exception) { callback.onFailed(fallbackError.message) } } }.start() } } // Usage in Application class LynxEnv.inst().setTemplateProvider(HotUpdateTemplateProvider(this)) ``` -------------------------------- ### View Deployment Status (CLI) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Displays the current deployment status of hot updates, including active versions and adoption statistics. This command can filter the status by platform. ```bash # View status for all platforms lynx-update status # View Android-only status lynx-update status -p android ``` -------------------------------- ### Initialize Hot Update in Lynx Project Source: https://github.com/1600822305/lynx-hot-update/blob/main/README.en.md Initializes the hot update configuration within a Lynx project directory. This command sets up the necessary files and configurations for the hot update system. ```bash cd your-lynx-project lynx-update init ``` -------------------------------- ### Android SDK (Kotlin) - Synchronous Update (Blocking) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Performs a synchronous update check and download, typically used for mandatory updates at app startup. ```APIDOC ### Synchronous Update (Blocking) For mandatory updates at app startup. ```kotlin import com.lynx.hotupdate.LynxHotUpdate import kotlinx.coroutines.runBlocking class SplashActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Check and download mandatory updates synchronously runBlocking { val updated = LynxHotUpdate.syncUpdate() if (updated) { // Restart to apply mandatory update LynxHotUpdate.restartApp() } } // Continue to main activity startActivity(Intent(this, MainActivity::class.java)) finish() } } ``` ``` -------------------------------- ### Manage Hot Update Configuration (CLI) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Allows viewing and modifying hot update settings such as the server URL and deployment keys. Changes made here affect subsequent CLI operations. ```bash # Show current configuration lynx-update config --show # Change server URL lynx-update config --server https://new-server.example.com # Update deployment key lynx-update config --key new-deployment-key ``` -------------------------------- ### Synchronous Update (Kotlin) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Performs a synchronous check and download of mandatory updates, typically used at app startup. It utilizes coroutines to block the main thread until the update process is complete, ensuring mandatory updates are applied before the application proceeds. ```kotlin import com.lynx.hotupdate.LynxHotUpdate import kotlinx.coroutines.runBlocking class SplashActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Check and download mandatory updates synchronously runBlocking { val updated = LynxHotUpdate.syncUpdate() if (updated) { // Restart to apply mandatory update LynxHotUpdate.restartApp() } } // Continue to main activity startActivity(Intent(this, MainActivity::class.java)) finish() } } ``` -------------------------------- ### Publish New Bundle Version (CLI) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Publishes a new JavaScript bundle version to the update server. Supports various options including gradual rollout, mandatory updates, differential updates, and targeting specific binary versions. The application must be built before publishing. ```bash # Build your Lynx app first npm run build # Publish to all platforms lynx-update publish # Publish with specific version and description lynx-update publish --version 1.0.1 --description "Bug fixes and performance improvements" # Publish to Android only with mandatory update lynx-update publish -p android -v 2.0.0 --mandatory # Gradual rollout (50% of users) lynx-update publish --rollout 50 # Enable differential updates (only upload changed files) lynx-update publish --diff # Target specific app versions lynx-update publish --target-binary-version ">=1.0.0 <2.0.0" # Full publish example lynx-update publish \ -p android \ -v 1.2.0 \ -d "New login feature" \ --mandatory \ --rollout 25 \ --diff \ --target-binary-version ">=1.0.0" ``` -------------------------------- ### POST /api/releases Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Uploads a new release to the server. Used internally by `lynx-update publish`. ```APIDOC ## POST /api/releases ### Description Uploads a new release to the server. Used internally by `lynx-update publish`. ### Method POST ### Endpoint /api/releases ### Parameters #### Query Parameters - **X-Deployment-Key** (string) - Required - The deployment key for authentication. - **X-App-Key** (string) - Required - The application key. #### Request Body - **file** (file) - Required - The release bundle file (e.g., bundle.zip). - **version** (string) - Required - The version of the release. - **platform** (string) - Required - The platform for the release (e.g., "android", "ios"). - **hash** (string) - Required - The hash of the release bundle. - **description** (string) - Optional - A description for the release. - **mandatory** (boolean) - Optional - Whether the release is mandatory. - **rollout** (integer) - Optional - The percentage of users to roll out to (0-100). ### Request Example ```bash curl -X POST http://localhost:3000/api/releases \ -H "X-Deployment-Key: your-deployment-key" \ -H "X-App-Key: com.example.app" \ -F "file=@bundle.zip" \ -F "version=1.0.1" \ -F "platform=android" \ -F "hash=a1b2c3d4e5f6..." \ -F "description=Bug fixes" \ -F "mandatory=false" \ -F "rollout=100" ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the upload was successful. - **release** (object) - Details of the uploaded release. - **version** (string) - The version of the release. - **platform** (string) - The platform of the release. - **filename** (string) - The filename of the release package. - **hash** (string) - The hash of the release package. - **size** (integer) - The size of the release package in bytes. - **description** (string) - The description of the release. - **mandatory** (boolean) - Whether the release is mandatory. - **rollout** (integer) - The rollout percentage. - **disabled** (boolean) - Whether the release is disabled. - **createdAt** (string) - The timestamp when the release was created. #### Response Example ```json { "success": true, "release": { "version": "1.0.1", "platform": "android", "filename": "com.example.app-android-1.0.1-1705312200000.zip", "hash": "a1b2c3d4e5f6...", "size": 524288, "description": "Bug fixes", "mandatory": false, "rollout": 100, "disabled": false, "createdAt": "2024-01-15T10:30:00.000Z" } } ``` ``` -------------------------------- ### Upload Release API (POST /api/releases) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt API endpoint for uploading a new release to the server. This is commonly used by the `lynx-update publish` command. It requires details about the release, including version, platform, and file. ```bash curl -X POST http://localhost:3000/api/releases \ -H "X-Deployment-Key: your-deployment-key" \ -H "X-App-Key: com.example.app" \ -F "file=@bundle.zip" \ -F "version=1.0.1" \ -F "platform=android" \ -F "hash=a1b2c3d4e5f6..." \ -F "description=Bug fixes" \ -F "mandatory=false" \ -F "rollout=100" # Response { "success": true, "release": { "version": "1.0.1", "platform": "android", "filename": "com.example.app-android-1.0.1-1705312200000.zip", "hash": "a1b2c3d4e5f6...", "size": 524288, "description": "Bug fixes", "mandatory": false, "rollout": 100, "disabled": false, "createdAt": "2024-01-15T10:30:00.000Z" } } ``` -------------------------------- ### Android SDK (Kotlin) - Check for Updates Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Asynchronously checks if a new update is available for the application. ```APIDOC ### Check for Updates Asynchronously check if an update is available. ```kotlin import com.lynx.hotupdate.LynxHotUpdate import com.lynx.hotupdate.UpdateResult // Check for updates LynxHotUpdate.checkForUpdate { result: UpdateResult -> if (result.updateAvailable) { println("Update available: ${result.version}") println("Size: ${result.size} bytes") println("Description: ${result.description}") println("Mandatory: ${result.mandatory}") // Download the update downloadUpdate(result) } else if (result.error != null) { println("Error checking for update: ${result.error}") } else { println("No update available") } } ``` ``` -------------------------------- ### Check for Updates (Kotlin) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Asynchronously checks for available updates using the LynxHotUpdate SDK. It provides a callback that receives an UpdateResult, indicating if an update is available, its details, or any errors encountered. ```kotlin import com.lynx.hotupdate.LynxHotUpdate import com.lynx.hotupdate.UpdateResult // Check for updates LynxHotUpdate.checkForUpdate { result: UpdateResult -> if (result.updateAvailable) { println("Update available: ${result.version}") println("Size: ${result.size} bytes") println("Description: ${result.description}") println("Mandatory: ${result.mandatory}") // Download the update downloadUpdate(result) } else if (result.error != null) { println("Error checking for update: ${result.error}") } else { println("No update available") } } ``` -------------------------------- ### Check for Lynx Updates (Swift) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt This Swift snippet demonstrates how to asynchronously check for available updates using the Lynx Hot Update SDK. The completion handler provides an `UpdateResult` object, which indicates if an update is available, its version, size, description, and whether it's mandatory. If an update is available, it suggests proceeding to download it. ```swift import Foundation // Check for updates LynxHotUpdate.shared.checkForUpdate { result in if result.updateAvailable { print("Update available: (result.version ?? "unknown")") print("Size: (result.size) bytes") print("Description: (result.description)") print("Mandatory: (result.mandatory)") // Download the update self.downloadUpdate(result) } else if let error = result.error { print("Error checking for update: (error)") } else { print("No update available") } } ``` -------------------------------- ### HotUpdateTemplateProvider for Bundle Loading (Swift) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Custom TemplateProvider for iOS (Swift) that loads bundles from hot updates. It prioritizes hot update bundles and falls back to loading from the main app bundle if the hot update is unavailable. ```swift // iOS - HotUpdateTemplateProvider.swift import Foundation class HotUpdateTemplateProvider: NSObject, LynxTemplateProvider { func loadTemplate(withUrl url: String!, onComplete callback: LynxTemplateLoadBlock!) { DispatchQueue.global(qos: .userInitiated).async { // Try hot update bundle first if let data = LynxHotUpdate.shared.loadBundle(url) { DispatchQueue.main.async { callback(data, nil) } return } // Fallback to app bundle if let filePath = Bundle.main.path(forResource: url, ofType: "bundle"), let data = try? Data(contentsOf: URL(fileURLWithPath: filePath)) { DispatchQueue.main.async { callback(data, nil) } } else { let error = NSError( domain: "com.lynx.hotupdate", code: 404, userInfo: [NSLocalizedDescriptionKey: "Bundle not found: (url ?? "")"] ) DispatchQueue.main.async { callback(nil, error) } } } } } ``` -------------------------------- ### Rollback to Previous Release (CLI) Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Reverts the application to a previous version. Users will receive the rolled-back version upon their next app launch. This command can be used interactively to select a version or specify a version directly. ```bash # Interactive rollback - shows list of previous versions lynx-update rollback # Rollback to specific version lynx-update rollback -v 1.0.0 # Rollback Android only lynx-update rollback -p android -v 1.0.0 ``` -------------------------------- ### Initialize Hot Update SDK on Android Source: https://github.com/1600822305/lynx-hot-update/blob/main/README.en.md Initializes the Lynx Hot Update SDK within an Android application's Application class. It requires the deployment key and the update server URL. It also sets up a TemplateProvider for hot updates. ```kotlin import com.lynx.hotupdate.LynxHotUpdate import com.lynx.hotupdate.HotUpdateTemplateProvider class MyApplication : Application() { override fun onCreate() { super.onCreate() // Initialize hot update LynxHotUpdate.init( this, "your-deployment-key", "https://your-update-server.com" ) // Use hot update TemplateProvider LynxEnv.inst().setTemplateProvider(HotUpdateTemplateProvider(this)) } } ``` -------------------------------- ### iOS (Swift) - Check for Updates Source: https://context7.com/1600822305/lynx-hot-update/llms.txt Asynchronously checks if an update is available for the application, providing details about the update if one exists. ```APIDOC ## Check for Updates (Swift) ### Description Asynchronously check if an update is available. ### Method ```swift import Foundation // Check for updates LynxHotUpdate.shared.checkForUpdate { result in if result.updateAvailable { print("Update available: (result.version ?? "unknown")") print("Size: (result.size) bytes") print("Description: (result.description)") print("Mandatory: (result.mandatory)") // Download the update self.downloadUpdate(result) } else if let error = result.error { print("Error checking for update: (error)") } else { print("No update available") } } ``` ```