Create polished demo videos without editing skills. Mac/Windows/Linux
chore(updates): add disabled app update infrastructure
webadderall5ab9368858e3
diff --git a/electron/main.ts b/electron/main.tsindex 9503b706..80a8c091 100644--- a/electron/main.ts+++ b/electron/main.ts@@ -19,6 +19,7 @@ import {killWindowsCaptureProcess,registerIpcHandlers,} from "./ipc/handlers";+import { checkForAppUpdates, setupAutoUpdates } from "./updater";import { createEditorWindow, createHudOverlayWindow, createSourceSelectorWindow } from "./windows";const __dirname = path.dirname(fileURLToPath(import.meta.url));@@ -218,6 +219,17 @@ function setupApplicationMenu() {? [{ role: "minimize" }, { role: "zoom" }, { type: "separator" }, { role: "front" }]: [{ role: "minimize" }, { role: "close" }],},+ {+ label: "Help",+ submenu: [+ {+ label: "Check for Updates…",+ click: () => {+ void checkForAppUpdates(() => mainWindow, { manual: true });+ },+ },+ ],+ },);const menu = Menu.buildFromTemplate(template);@@ -418,6 +430,8 @@ app.whenReady().then(async () => {},);+ setupAutoUpdates(() => mainWindow);+// Register the display media handler so that renderer's getDisplayMedia()// calls land on the pre-selected source without showing a system picker.//diff --git a/electron/updater.ts b/electron/updater.tsnew file mode 100644index 00000000..f30fc120--- /dev/null+++ b/electron/updater.ts@@ -0,0 +1,160 @@+import { app, BrowserWindow, dialog } from "electron";+import { autoUpdater } from "electron-updater";++const UPDATE_CHECK_INTERVAL_MS = 6 * 60 * 60 * 1000;+const AUTO_UPDATES_ENABLED = process.env.RECORDLY_ENABLE_AUTO_UPDATES === "1";++let updaterInitialized = false;+let updateCheckInProgress = false;+let manualCheckRequested = false;+let periodicCheckTimer: NodeJS.Timeout | null = null;++function canUseAutoUpdates() {+ return AUTO_UPDATES_ENABLED && app.isPackaged && !process.mas;+}++export function isAutoUpdateFeatureEnabled() {+ return AUTO_UPDATES_ENABLED;+}++function getDialogWindow(getMainWindow: () => BrowserWindow | null) {+ const window = getMainWindow();+ return window && !window.isDestroyed() ? window : undefined;+}++async function showNoUpdatesDialog(getMainWindow: () => BrowserWindow | null) {+ await dialog.showMessageBox(getDialogWindow(getMainWindow), {+ type: "info",+ title: "No Updates Available",+ message: "Recordly is up to date.",+ detail: `You are running version ${app.getVersion()}.`,+ });+}++async function showUpdateErrorDialog(getMainWindow: () => BrowserWindow | null, error: unknown) {+ await dialog.showMessageBox(getDialogWindow(getMainWindow), {+ type: "error",+ title: "Update Check Failed",+ message: "Recordly could not check for updates.",+ detail: String(error),+ });+}++export async function checkForAppUpdates(+ getMainWindow: () => BrowserWindow | null,+ options?: { manual?: boolean },+) {+ if (!canUseAutoUpdates()) {+ if (options?.manual) {+ await dialog.showMessageBox(getDialogWindow(getMainWindow), {+ type: "info",+ title: "Updates Not Enabled",+ message: "Auto-updates are not enabled in this build.",+ detail: "The updater infrastructure is present, but release publishing and signed distribution are not enabled yet.",+ });+ }+ return;+ }++ if (updateCheckInProgress) {+ if (options?.manual) {+ await dialog.showMessageBox(getDialogWindow(getMainWindow), {+ type: "info",+ title: "Update Check In Progress",+ message: "Recordly is already checking for updates.",+ });+ }+ return;+ }++ manualCheckRequested = Boolean(options?.manual);+ updateCheckInProgress = true;++ try {+ await autoUpdater.checkForUpdates();+ } catch (error) {+ updateCheckInProgress = false;+ const shouldReport = manualCheckRequested;+ manualCheckRequested = false;+ console.error("Auto-update check failed:", error);+ if (shouldReport) {+ await showUpdateErrorDialog(getMainWindow, error);+ }+ }+}++export function setupAutoUpdates(getMainWindow: () => BrowserWindow | null) {+ if (updaterInitialized || !canUseAutoUpdates()) {+ return;+ }++ updaterInitialized = true;+ autoUpdater.autoDownload = true;+ autoUpdater.autoInstallOnAppQuit = true;++ autoUpdater.on("update-available", (info) => {+ updateCheckInProgress = false;+ if (!manualCheckRequested) {+ return;+ }++ void dialog.showMessageBox(getDialogWindow(getMainWindow), {+ type: "info",+ title: "Update Available",+ message: `Recordly ${info.version} is available.`,+ detail: "The update is downloading in the background and you will be prompted to restart when it is ready.",+ });+ });++ autoUpdater.on("update-not-available", () => {+ updateCheckInProgress = false;+ const shouldReport = manualCheckRequested;+ manualCheckRequested = false;+ if (shouldReport) {+ void showNoUpdatesDialog(getMainWindow);+ }+ });++ autoUpdater.on("error", (error) => {+ updateCheckInProgress = false;+ const shouldReport = manualCheckRequested;+ manualCheckRequested = false;+ console.error("Auto-updater error:", error);+ if (shouldReport) {+ void showUpdateErrorDialog(getMainWindow, error);+ }+ });++ autoUpdater.on("update-downloaded", async (info) => {+ updateCheckInProgress = false;+ manualCheckRequested = false;++ const result = await dialog.showMessageBox(getDialogWindow(getMainWindow), {+ type: "info",+ title: "Update Ready",+ message: `Recordly ${info.version} has been downloaded.`,+ detail: "Restart the app now to install the update.",+ buttons: ["Restart Now", "Later"],+ defaultId: 0,+ cancelId: 1,+ });++ if (result.response === 0) {+ setImmediate(() => {+ autoUpdater.quitAndInstall();+ });+ }+ });++ void checkForAppUpdates(getMainWindow);+ periodicCheckTimer = setInterval(() => {+ void checkForAppUpdates(getMainWindow);+ }, UPDATE_CHECK_INTERVAL_MS);++ app.on("before-quit", () => {+ if (periodicCheckTimer) {+ clearInterval(periodicCheckTimer);+ periodicCheckTimer = null;+ }+ });+}\ No newline at end of filediff --git a/package-lock.json b/package-lock.jsonindex 0f0de731..6ebeffe4 100644--- a/package-lock.json+++ b/package-lock.json@@ -10,6 +10,7 @@"hasInstallScript": true,"dependencies": {"capturekit": "^1.0.13",+ "electron-updater": "^6.8.3","ffmpeg-static": "^5.3.0","uiohook-napi": "^1.5.4"},@@ -5302,7 +5303,6 @@"version": "2.0.1","resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz","integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",- "dev": true,"license": "Python-2.0"},"node_modules/args": {@@ -5768,7 +5768,6 @@"version": "9.5.1","resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.5.1.tgz","integrity": "sha512-qt41tMfgHTllhResqM5DcnHyDIWNgzHvuY2jDcYP9iaGpkWxTUzV6GQjDeLnlR1/DtdlcsWQbA7sByMpmJFTLQ==",- "dev": true,"license": "MIT","dependencies": {"debug": "^4.3.4",@@ -7181,6 +7180,57 @@"dev": true,"license": "ISC"},+ "node_modules/electron-updater": {+ "version": "6.8.3",+ "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.8.3.tgz",+ "integrity": "sha512-Z6sgw3jgbikWKXei1ENdqFOxBP0WlXg3TtKfz0rgw2vIZFJUyI4pD7ZN7jrkm7EoMK+tcm/qTnPUdqfZukBlBQ==",+ "license": "MIT",+ "dependencies": {+ "builder-util-runtime": "9.5.1",+ "fs-extra": "^10.1.0",+ "js-yaml": "^4.1.0",+ "lazy-val": "^1.0.5",+ "lodash.escaperegexp": "^4.1.2",+ "lodash.isequal": "^4.5.0",+ "semver": "~7.7.3",+ "tiny-typed-emitter": "^2.1.0"+ }+ },+ "node_modules/electron-updater/node_modules/fs-extra": {+ "version": "10.1.0",+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",+ "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",+ "license": "MIT",+ "dependencies": {+ "graceful-fs": "^4.2.0",+ "jsonfile": "^6.0.1",+ "universalify": "^2.0.0"+ },+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/electron-updater/node_modules/jsonfile": {+ "version": "6.2.0",+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz",+ "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==",+ "license": "MIT",+ "dependencies": {+ "universalify": "^2.0.0"+ },+ "optionalDependencies": {+ "graceful-fs": "^4.1.6"+ }+ },+ "node_modules/electron-updater/node_modules/universalify": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",+ "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",+ "license": "MIT",+ "engines": {+ "node": ">= 10.0.0"+ }+ },"node_modules/electron-winstaller": {"version": "5.4.0","resolved": "https://registry.npmjs.org/electron-winstaller/-/electron-winstaller-5.4.0.tgz",@@ -8282,7 +8332,6 @@"version": "4.2.11","resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz","integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",- "dev": true,"license": "ISC"},"node_modules/gsap": {@@ -9004,7 +9053,6 @@"version": "4.1.1","resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz","integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",- "dev": true,"license": "MIT","dependencies": {"argparse": "^2.0.1"@@ -9156,7 +9204,6 @@"version": "1.0.5","resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz","integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==",- "dev": true,"license": "MIT"},"node_modules/lcid": {@@ -9280,6 +9327,19 @@"dev": true,"license": "MIT"},+ "node_modules/lodash.escaperegexp": {+ "version": "4.1.2",+ "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz",+ "integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==",+ "license": "MIT"+ },+ "node_modules/lodash.isequal": {+ "version": "4.5.0",+ "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",+ "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",+ "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.",+ "license": "MIT"+ },"node_modules/log-symbols": {"version": "4.1.0","resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",@@ -11882,7 +11942,6 @@"version": "1.4.1","resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz","integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==",- "dev": true,"license": "ISC"},"node_modules/scheduler": {@@ -11899,7 +11958,6 @@"version": "7.7.3","resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz","integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",- "dev": true,"license": "ISC","bin": {"semver": "bin/semver.js"@@ -12956,6 +13014,12 @@"node": ">=12"}},+ "node_modules/tiny-typed-emitter": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",+ "integrity": "sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==",+ "license": "MIT"+ },"node_modules/tinybench": {"version": "2.9.0","resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",diff --git a/package.json b/package.jsonindex f463fafe..8c2540cb 100644--- a/package.json+++ b/package.json@@ -37,6 +37,7 @@},"dependencies": {"capturekit": "^1.0.13",+ "electron-updater": "^6.8.3","ffmpeg-static": "^5.3.0","uiohook-napi": "^1.5.4"},@@ -91,8 +92,8 @@"react-rnd": "^10.5.2","sonner": "^2.0.7","tailwind-merge": "^3.3.1",- "tailwindcss-animate": "^1.0.7","tailwindcss": "^3.4.18",+ "tailwindcss-animate": "^1.0.7","terser": "^5.44.1","typescript": "^5.2.2","uuid": "^13.0.0",