using UnityEngine;

/// <summary>
/// Initializes Sparkle auto-updater at app startup.
/// Uses RuntimeInitializeOnLoadMethod to ensure early initialization.
/// </summary>
public static class SparkleInitializer {
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
    private static void Initialize() {
        SparkleUpdater.Initialize();

#if UNITY_STANDALONE_OSX && !UNITY_EDITOR
        // Always check for updates on startup, regardless of scheduled check interval
        // This ensures users get updates promptly when a new version is available
        SparkleUpdater.CheckForUpdatesInBackground();

        // Check if the app is running from a read-only volume (DMG)
        // If so, block launch and tell user to install properly
        if (SparkleUpdater.IsRunningFromReadOnlyVolume()) {
            Debug.LogError(
                    "SparkleInitializer: App is running from read-only volume (DMG), blocking launch");
            SparkleUpdater.ShowDMGWarning();
        }
#endif
    }
}
