Migrate to Vite+ unified toolchain (#428)

This commit is contained in:
Gregory Schier
2026-03-13 09:27:56 -07:00
committed by GitHub
parent aed7bd12ea
commit 45262edfbd
166 changed files with 1762 additions and 1519 deletions

View File

@@ -0,0 +1,16 @@
import { showErrorToast } from './toast';
/**
* Handles a fire-and-forget promise by catching and reporting errors
* via console.error and a toast notification.
*/
export function fireAndForget(promise: Promise<unknown>) {
promise.catch((err: unknown) => {
console.error('Unhandled async error:', err);
showErrorToast({
id: 'async-error',
title: 'Unexpected Error',
message: err instanceof Error ? err.message : String(err),
});
});
}

View File

@@ -5,7 +5,7 @@ import type { ReactNode } from 'react';
* https://stackoverflow.com/questions/50428910/get-text-content-from-node-in-react
*/
export function getNodeText(node: ReactNode): string {
if (['string', 'number'].includes(typeof node)) {
if (typeof node === 'string' || typeof node === 'number') {
return String(node);
}
@@ -14,7 +14,7 @@ export function getNodeText(node: ReactNode): string {
}
if (typeof node === 'object' && node) {
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
return getNodeText((node as any).props.children);
}

View File

@@ -22,6 +22,7 @@ import { HStack, VStack } from '../components/core/Stacks';
// Listen for toasts
import { listenToTauriEvent } from '../hooks/useListenToTauriEvent';
import { fireAndForget } from './fireAndForget';
import { updateAvailableAtom } from './atoms';
import { stringToColor } from './color';
import { generateId } from './generateId';
@@ -81,7 +82,7 @@ export function initGlobalListeners() {
done,
},
};
emit(event.id, result);
fireAndForget(emit(event.id, result));
};
const values = await showPromptForm({
@@ -110,7 +111,7 @@ export function initGlobalListeners() {
// Listen for update events
listenToTauriEvent<UpdateInfo>('update_available', async ({ payload }) => {
console.log('Got update available', payload);
showUpdateAvailableToast(payload);
fireAndForget(showUpdateAvailableToast(payload));
});
listenToTauriEvent<YaakNotification>('notification', ({ payload }) => {
@@ -125,7 +126,7 @@ export function initGlobalListeners() {
});
// Check for plugin initialization errors
invokeCmd<[string, string][]>('cmd_plugin_init_errors').then((errors) => {
fireAndForget(invokeCmd<[string, string][]>('cmd_plugin_init_errors').then((errors) => {
for (const [dir, message] of errors) {
const dirBasename = dir.split('/').pop() ?? dir;
showToast({
@@ -155,7 +156,7 @@ export function initGlobalListeners() {
),
});
}
});
}));
}
function showUpdateInstalledToast(version: string) {

View File

@@ -1,5 +1,5 @@
import type { HttpResponseEvent } from '@yaakapp-internal/models';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { getCookieCounts } from './model_util';
function makeEvent(

View File

@@ -15,10 +15,10 @@ export function setWorkspaceSearchParams(
folder_id: string | null;
}>,
) {
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
(router as any)
.navigate({
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
search: (prev: any) => {
// console.log('Navigating to', { prev, search });
const o = { ...prev, ...search };

View File

@@ -1,4 +1,5 @@
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
import { fireAndForget } from '../fireAndForget';
export type Appearance = 'light' | 'dark';
@@ -22,13 +23,13 @@ export function subscribeToWindowAppearanceChange(
unsubscribe: () => {},
};
getCurrentWebviewWindow()
fireAndForget(getCurrentWebviewWindow()
.onThemeChanged((t) => {
cb(t.payload);
})
.then((l) => {
container.unsubscribe = l;
});
}));
return () => container.unsubscribe();
}
@@ -43,6 +44,6 @@ export function resolveAppearance(
export function subscribeToPreferredAppearance(cb: (a: Appearance) => void) {
cb(getCSSAppearance());
getWindowAppearance().then(cb);
fireAndForget(getWindowAppearance().then(cb));
subscribeToWindowAppearanceChange(cb);
}

View File

@@ -279,7 +279,7 @@ export function getThemeCSS(theme: Theme): string {
theme.components.toast = theme.components.toast ?? theme.components.menu ?? {};
const { components, id, label } = theme;
const colors = Object.keys(theme.base).reduce((prev, key) => {
// biome-ignore lint/performance/noAccumulatingSpread: none
// oxlint-disable-next-line no-accumulating-spread
return { ...prev, [key]: theme.base[key as YaakColorKey] };
}, {}) as ThemeComponentColors;