Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## Не выпущено

### Обновления программ
- Новая вкладка «Обновления»: что можно обновить через winget, Scoop и Chocolatey, с кнопками «Обновить» и «Обновить все». Обновления программ из каталога показываются под их названием и иконкой.
- История обновлений по дням. Успешное обновление можно откатить до предыдущей версии: `winget install --version`, `scoop reset app@версия` или `choco install --version --allow-downgrade`.
- Проверка при запуске и раз в 6 часов; по желанию обновления ставятся в фоне без вопросов. Количество доступных обновлений видно на вкладке.
- Обновления и откаты идут через общую очередь установок с прогрессом и отменой.

### Внешний вид
- Пять тем в «Расширенных → Внешний вид»: Классика, Светлая, OLED, Высокий контраст и Windows 11. На Windows 11 22H2+ тема Windows 11 включает системный фон Mica, на других системах рисует полупрозрачную подложку.
- Свой акцентный цвет (7 готовых или любой через палитру); цвет текста на кнопках подбирается по яркости акцента.
- Масштаб интерфейса: 90 / 100 / 110 / 125 %.
- Четыре вида списков: карточки, список с описанием, компактная таблица и плитки. Переключатель стоит над каждым списком, выбор запоминается.
- Значения внешнего вида проверяются в main-процессе: повреждённые настройки не ломают интерфейс.

## 1.2.5

### Установка
Expand Down
69 changes: 68 additions & 1 deletion electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { app, BrowserWindow, ipcMain, shell, protocol, Menu } from 'electron';
import path from 'node:path';
import os from 'node:os';
import { fileURLToPath } from 'node:url';
import { initProviders, getAllProviders, setCatalogRemoteUrl } from './providers/registry.js';
import { warmMetaCacheFromDisk, enrichMeta, prewarmMeta, maybeAutoPrewarm, getMetaCompleteness, getMetaProgress } from './enrich/meta-cache.js';
import { enqueuePackageMeta, onPackageMetaUpdate, type PackageMetaRequest } from './enrich/package-meta.js';
import { getCatalog, invalidateCatalog, setInstalledSet, findApp } from './catalog/merge.js';
import { searchPackages } from './search-cache.js';
import { installQueue } from './queue/install-queue.js';
import { updates } from './updates/updates.js';
import { buildIndex, isIndexEmptyOrSmall } from './index-builder.js';
import { getSettings, updateSettings } from './store/settings.js';
import { toggleFavorite, isFavorite } from './store/favorites.js';
import { registerMediaProtocol } from './protocol.js';
import { loadCuratedCatalog } from './providers/catalog.js';
import fs from 'node:fs';
import { getDataDir } from './paths.js';
import type { ProfileEntry } from './providers/types.js';
import type { ProfileEntry, UpdateInfo } from './providers/types.js';
import {
bootstrapRuntime,
isBootstrapComplete,
Expand Down Expand Up @@ -153,10 +155,44 @@ function createWindow(): void {
mainWindow.loadFile(path.join(__dirname, '../dist/index.html'));
}

mainWindow.webContents.on('did-finish-load', applyAppearance);
mainWindow.once('ready-to-show', () => mainWindow?.show());
mainWindow.on('closed', () => { mainWindow = null; });
}

/** Mica needs Windows 11 22H2+ (build 22621); elsewhere the theme falls back to a painted backdrop. */
function supportsMica(): boolean {
if (process.platform !== 'win32') return false;
const build = Number(os.release().split('.')[2]);
return Number.isFinite(build) && build >= 22621;
}

function applyAppearance(): void {
if (!mainWindow) return;
const { uiScale, theme } = getSettings();
mainWindow.webContents.setZoomFactor(uiScale);
if (!supportsMica()) return;
const mica = theme === 'mica';
mainWindow.setBackgroundColor(mica ? '#00000000' : '#0a1118');
mainWindow.setBackgroundMaterial(mica ? 'mica' : 'none');
}

function queueUpgrades(items: UpdateInfo[]): void {
installQueue.addMany(
items
.filter((u) => !installQueue.isQueued(u.provider, u.packageId))
.map((u) => ({
provider: u.provider,
packageId: u.packageId,
name: u.name,
kind: 'upgrade' as const,
fromVersion: u.installed,
toVersion: u.available,
catalogId: u.catalogId,
})),
);
}

function sendToRenderer(channel: string, ...args: unknown[]): void {
mainWindow?.webContents.send(channel, ...args);
}
Expand Down Expand Up @@ -239,6 +275,30 @@ function setupIpc(): void {
ipcMain.handle('queue:dismiss', (_e, jobId: string) => installQueue.dismiss(jobId));
ipcMain.handle('queue:retryJob', (_e, jobId: string) => installQueue.retryJob(jobId));

ipcMain.handle('updates:get', () => updates.getState());
ipcMain.handle('updates:check', () => updates.check());
ipcMain.handle('updates:clearHistory', () => updates.clearHistory());
// The renderer names packages; versions come from our own state, never from IPC.
ipcMain.handle('updates:upgrade', (_e, keys: Array<{ provider: string; packageId: string }>) => {
const items = updates.getState().items.filter((u) =>
keys.some((k) => k.provider === u.provider && k.packageId === u.packageId),
);
queueUpgrades(items);
return items.length;
});
ipcMain.handle('updates:rollback', (_e, historyId: string) => {
const entry = updates.getState().history.find((h) => h.id === historyId);
if (!entry || !entry.ok || entry.kind !== 'upgrade' || !entry.from) return false;
if (installQueue.isQueued(entry.provider, entry.packageId)) return false;
installQueue.add(entry.provider, entry.packageId, entry.name, {
kind: 'rollback',
fromVersion: entry.to,
toVersion: entry.from,
catalogId: entry.catalogId,
});
return true;
});

ipcMain.handle('index:rebuild', () => runIndexBuild());

ipcMain.handle('providers:status', async () => {
Expand All @@ -253,10 +313,13 @@ function setupIpc(): void {
});

ipcMain.handle('settings:get', () => getSettings());
ipcMain.handle('window:nativeMica', () => supportsMica());
ipcMain.handle('settings:update', (_e, partial) => {
const prev = getSettings();
const next = updateSettings(partial);
setCatalogRemoteUrl(next.remoteCatalogUrl);
if (next.uiScale !== prev.uiScale || next.theme !== prev.theme) applyAppearance();
if (next.autoCheckUpdates !== prev.autoCheckUpdates) updates.schedule();
if (partial.language && partial.language !== prev.language) {
invalidateCatalog('index');
sendToRenderer('catalog:onDirty');
Expand Down Expand Up @@ -378,11 +441,15 @@ app.whenReady().then(async () => {
});

installQueue.on('updated', (jobs) => sendToRenderer('queue:updated', jobs));
installQueue.on('job-finished', (job) => updates.record(job));
updates.on('changed', (state) => sendToRenderer('updates:changed', state));
updates.on('auto-install', (items: UpdateInfo[]) => queueUpgrades(items));
installQueue.on('installed-changed', () => {
refreshInstalledInBackground();
});

createWindow();
updates.schedule(true);

if (shouldRetryBootstrap()) {
startBootstrap();
Expand Down
22 changes: 20 additions & 2 deletions electron/preload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { contextBridge, ipcRenderer } from 'electron';
import type { MergedApp, Package, QueueJob, SearchResult, AppSettings } from './providers/types.js';
import type { MergedApp, Package, QueueJob, SearchResult, AppSettings, UpdatesState } from './providers/types.js';

export interface RuntimeToolInfo {
status: string;
Expand Down Expand Up @@ -60,6 +60,12 @@ export interface GetBoxAPI {
dismissQueueJob: (jobId: string) => Promise<boolean>;
retryQueueJob: (jobId: string) => Promise<boolean>;
onQueueUpdated: (cb: (jobs: QueueJob[]) => void) => () => void;
getUpdates: () => Promise<UpdatesState>;
checkUpdates: () => Promise<UpdatesState>;
upgradePackages: (keys: Array<{ provider: string; packageId: string }>) => Promise<number>;
rollbackUpdate: (historyId: string) => Promise<boolean>;
clearUpdateHistory: () => Promise<void>;
onUpdatesChanged: (cb: (state: UpdatesState) => void) => () => void;
rebuildIndex: () => Promise<{ ok: boolean; count: number; message?: string }>;
onIndexProgress: (cb: (msg: string) => void) => () => void;
onIndexDone: (cb: (count: number) => void) => () => void;
Expand All @@ -83,6 +89,7 @@ export interface GetBoxAPI {
windowMaximize: () => Promise<boolean>;
windowClose: () => Promise<void>;
windowIsMaximized: () => Promise<boolean>;
windowNativeMica: () => Promise<boolean>;
onWindowState: (cb: (state: { maximized: boolean }) => void) => () => void;
}

Expand Down Expand Up @@ -132,6 +139,16 @@ const api: GetBoxAPI = {
cancelQueueJob: (jobId) => ipcRenderer.invoke('queue:cancel', jobId),
dismissQueueJob: (jobId) => ipcRenderer.invoke('queue:dismiss', jobId),
retryQueueJob: (jobId) => ipcRenderer.invoke('queue:retryJob', jobId),
getUpdates: () => ipcRenderer.invoke('updates:get'),
checkUpdates: () => ipcRenderer.invoke('updates:check'),
upgradePackages: (keys) => ipcRenderer.invoke('updates:upgrade', keys),
rollbackUpdate: (historyId) => ipcRenderer.invoke('updates:rollback', historyId),
clearUpdateHistory: () => ipcRenderer.invoke('updates:clearHistory'),
onUpdatesChanged: (cb) => {
const handler = (_: unknown, state: UpdatesState) => cb(state);
ipcRenderer.on('updates:changed', handler);
return () => ipcRenderer.removeListener('updates:changed', handler);
},
onQueueUpdated: (cb) => {
const handler = (_: unknown, jobs: QueueJob[]) => cb(jobs);
ipcRenderer.on('queue:updated', handler);
Expand Down Expand Up @@ -192,6 +209,7 @@ const api: GetBoxAPI = {
windowMaximize: () => ipcRenderer.invoke('window:maximize'),
windowClose: () => ipcRenderer.invoke('window:close'),
windowIsMaximized: () => ipcRenderer.invoke('window:isMaximized'),
windowNativeMica: () => ipcRenderer.invoke('window:nativeMica'),
onWindowState: (cb) => {
const handler = (_: unknown, state: { maximized: boolean }) => cb(state);
ipcRenderer.on('window:state', handler);
Expand All @@ -207,4 +225,4 @@ declare global {
}
}

export type { MergedApp, Package, QueueJob, SearchResult, AppSettings };
export type { MergedApp, Package, QueueJob, SearchResult, AppSettings, UpdatesState };
17 changes: 17 additions & 0 deletions electron/providers/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,3 +767,20 @@ export function invalidateCatalogCache(): void {
wingetMapCache = null;
installersCache = null;
}

/**
* Package-manager id (`winget:Mozilla.Firefox`) → catalog package id, so an update
* reported by winget can be shown under the curated app's name and icon.
* Ids are compared case-insensitively: winget and choco ignore case.
*/
export function catalogIdsBySource(): Map<string, string> {
const installers = loadInstallers();
const wingetMap = loadWingetMap();
const map = new Map<string, string>();
for (const item of loadLocalCatalog()) {
const plan = resolveInstallPlan(item.id, installers, wingetMap);
const source = plan.fallback;
if (source) map.set(`${source.provider}:${source.packageId.toLowerCase()}`, item.packageId);
}
return map;
}
24 changes: 22 additions & 2 deletions electron/providers/chocolatey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import type {
PackageDetails,
PackageProvider,
ProviderStatus,
UpdateInfo,
} from './types.js';
import { getRuntimePaths, testChocolatey, runCmd } from '../bootstrap/runtime.js';
import { runCliWithProgress } from './cli-progress.js';
import { classifyError } from './install-errors.js';
import { parseChocoOutdated } from '../updates/parse.js';

const INFO_LABEL = /^\s*(Summary|Description|Software Site|Title)\s*:\s*(.*)$/i;

Expand Down Expand Up @@ -98,9 +100,27 @@ export class ChocolateyProvider implements PackageProvider {
}

async install(packageId: string, opts: InstallOptions): Promise<InstallResult> {
const args = ['install', packageId, '-y'];
if (opts.quiet) args.push('--force');
return this.run(packageId, args, opts);
}

async upgrade(packageId: string, opts: InstallOptions): Promise<InstallResult> {
return this.run(packageId, ['upgrade', packageId, '-y'], opts);
}

async installVersion(packageId: string, version: string, opts: InstallOptions): Promise<InstallResult> {
return this.run(packageId, ['install', packageId, '--version', version, '--allow-downgrade', '--force', '-y'], opts);
}

async listUpgrades(): Promise<UpdateInfo[]> {
if (!(await this.available()).ok) return [];
const out = await runCmd(this.chocoExe(), ['outdated', '--limit-output'], 120000);
return parseChocoOutdated(out).map((u) => ({ ...u, provider: this.id }));
}

private async run(packageId: string, args: string[], opts: InstallOptions): Promise<InstallResult> {
try {
const args = ['install', packageId, '-y'];
if (opts.quiet) args.push('--force');
const { code, output } = await runCliWithProgress(this.chocoExe(), args, {
timeout: 600000,
onProgress: opts.onProgress,
Expand Down
25 changes: 23 additions & 2 deletions electron/providers/scoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import type {
PackageDetails,
PackageProvider,
ProviderStatus,
UpdateInfo,
} from './types.js';
import { getRuntimePaths, testScoop, loadRuntimeState } from '../bootstrap/runtime.js';
import { runCliWithProgress } from './cli-progress.js';
import { classifyError } from './install-errors.js';
import { parseScoopStatus } from '../updates/parse.js';
import { getAppDataDir } from '../paths.js';
import path from 'node:path';

Expand Down Expand Up @@ -206,11 +208,30 @@ export class ScoopProvider implements PackageProvider {
}

async install(packageId: string, opts: InstallOptions): Promise<InstallResult> {
const args = ['install', packageId];
if (opts.quiet) args.push('-g');
return this.run(packageId, args, opts);
}

async upgrade(packageId: string, opts: InstallOptions): Promise<InstallResult> {
return this.run(packageId, ['update', packageId], opts);
}

/** Scoop keeps earlier versions on disk until `scoop cleanup`, so a reset switches back offline. */
async installVersion(packageId: string, version: string, opts: InstallOptions): Promise<InstallResult> {
return this.run(packageId, ['reset', `${packageId}@${version}`], opts);
}

async listUpgrades(): Promise<UpdateInfo[]> {
if (!(await this.available()).ok) return [];
const out = await runScoop(['status'], 120000);
return parseScoopStatus(out).map((u) => ({ ...u, provider: this.id }));
}

private async run(packageId: string, args: string[], opts: InstallOptions): Promise<InstallResult> {
try {
const resolved = await resolveScoopExe();
if (!resolved) throw new Error('Scoop runtime not ready');
const args = ['install', packageId];
if (opts.quiet) args.push('-g');
const { code, output } = await runCliWithProgress(resolved.exe, args, {
timeout: 300000,
env: resolved.env,
Expand Down
Loading
Loading