mirror of https://github.com/buster-so/buster.git
Make query cache a little faster
This commit is contained in:
parent
b95f952166
commit
f544d93d6b
|
@ -94,12 +94,12 @@ const nextConfig = {
|
||||||
transpilePackages: ['shiki'],
|
transpilePackages: ['shiki'],
|
||||||
// ESLint configuration
|
// ESLint configuration
|
||||||
eslint: {
|
eslint: {
|
||||||
ignoreDuringBuilds: false,
|
ignoreDuringBuilds: process.env.NEXT_DISABLE_LINT === 'true' || process.env.CI === 'true',
|
||||||
dirs: ['src']
|
dirs: ['src']
|
||||||
},
|
},
|
||||||
// Disable TypeScript type checking during builds
|
// Disable TypeScript type checking during builds
|
||||||
typescript: {
|
typescript: {
|
||||||
ignoreBuildErrors: false
|
ignoreBuildErrors: process.env.NEXT_DISABLE_TS_CHECK === 'true'
|
||||||
},
|
},
|
||||||
sassOptions: {
|
sassOptions: {
|
||||||
includePaths: [path.join(__dirname, 'styles')],
|
includePaths: [path.join(__dirname, 'styles')],
|
||||||
|
|
|
@ -7,7 +7,6 @@ import './MonacoWebWorker';
|
||||||
|
|
||||||
import type { editor } from 'monaco-editor/esm/vs/editor/editor.api';
|
import type { editor } from 'monaco-editor/esm/vs/editor/editor.api';
|
||||||
import React, { forwardRef, useMemo } from 'react';
|
import React, { forwardRef, useMemo } from 'react';
|
||||||
import { useMemoizedFn } from '@/hooks';
|
|
||||||
import { cn } from '@/lib/classMerge';
|
import { cn } from '@/lib/classMerge';
|
||||||
import { CircleSpinnerLoaderContainer } from '../../loaders/CircleSpinnerLoaderContainer';
|
import { CircleSpinnerLoaderContainer } from '../../loaders/CircleSpinnerLoaderContainer';
|
||||||
import { configureMonacoToUseYaml } from './yamlHelper';
|
import { configureMonacoToUseYaml } from './yamlHelper';
|
||||||
|
@ -16,9 +15,14 @@ import { configureMonacoToUseYaml } from './yamlHelper';
|
||||||
//import NightOwnTheme from 'monaco-themes/themes/Night Owl.json';
|
//import NightOwnTheme from 'monaco-themes/themes/Night Owl.json';
|
||||||
//https://github.com/brijeshb42/monaco-ace-tokenizer
|
//https://github.com/brijeshb42/monaco-ace-tokenizer
|
||||||
|
|
||||||
import { Editor } from '@monaco-editor/react';
|
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
|
|
||||||
|
import dynamic from 'next/dynamic';
|
||||||
|
const Editor = dynamic(() => import('@monaco-editor/react').then((m) => m.Editor), {
|
||||||
|
ssr: false,
|
||||||
|
loading: () => null
|
||||||
|
});
|
||||||
|
|
||||||
interface AppCodeEditorProps {
|
interface AppCodeEditorProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
onChangeEditorHeight?: (height: number) => void;
|
onChangeEditorHeight?: (height: number) => void;
|
||||||
|
@ -103,43 +107,44 @@ export const AppCodeEditor = forwardRef<AppCodeEditorHandle, AppCodeEditorProps>
|
||||||
};
|
};
|
||||||
}, [readOnlyMessage, monacoEditorOptions]);
|
}, [readOnlyMessage, monacoEditorOptions]);
|
||||||
|
|
||||||
const onMountCodeEditor = useMemoizedFn(
|
const onMountCodeEditor = async (
|
||||||
async (editor: editor.IStandaloneCodeEditor, monaco: typeof import('monaco-editor')) => {
|
editor: editor.IStandaloneCodeEditor,
|
||||||
const [GithubLightTheme, NightOwlTheme] = await Promise.all([
|
monaco: typeof import('monaco-editor')
|
||||||
(await import('./themes/github_light_theme')).default,
|
) => {
|
||||||
(await import('./themes/tomorrow_night_theme')).default
|
const [GithubLightTheme, NightOwlTheme] = await Promise.all([
|
||||||
]);
|
(await import('./themes/github_light_theme')).default,
|
||||||
|
(await import('./themes/tomorrow_night_theme')).default
|
||||||
|
]);
|
||||||
|
|
||||||
monaco.editor.defineTheme('github-light', GithubLightTheme);
|
monaco.editor.defineTheme('github-light', GithubLightTheme);
|
||||||
monaco.editor.defineTheme('night-owl', NightOwlTheme);
|
monaco.editor.defineTheme('night-owl', NightOwlTheme);
|
||||||
editor.updateOptions({
|
editor.updateOptions({
|
||||||
theme: useDarkMode ? 'night-owl' : 'github-light',
|
theme: useDarkMode ? 'night-owl' : 'github-light',
|
||||||
colorDecorators: true
|
colorDecorators: true
|
||||||
});
|
});
|
||||||
if (onChangeEditorHeight) {
|
if (onChangeEditorHeight) {
|
||||||
editor.onDidContentSizeChange(() => {
|
editor.onDidContentSizeChange(() => {
|
||||||
const contentHeight = editor.getContentHeight();
|
const contentHeight = editor.getContentHeight();
|
||||||
onChangeEditorHeight(contentHeight);
|
onChangeEditorHeight(contentHeight);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (language === 'yaml') {
|
|
||||||
await configureMonacoToUseYaml(monaco);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount?.(editor, monaco);
|
|
||||||
|
|
||||||
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => {
|
|
||||||
onMetaEnter?.();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
const onChangeCodeEditor = useMemoizedFn((v: string | undefined) => {
|
if (language === 'yaml') {
|
||||||
|
await configureMonacoToUseYaml(monaco);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount?.(editor, monaco);
|
||||||
|
|
||||||
|
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => {
|
||||||
|
onMetaEnter?.();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onChangeCodeEditor = (v: string | undefined) => {
|
||||||
if (!readOnly) {
|
if (!readOnly) {
|
||||||
onChange?.(v || '');
|
onChange?.(v || '');
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -72,13 +72,6 @@ export const getCodeTokens = async (
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Pre-initialize highlighter on module load for better performance
|
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
initializeHighlighter().catch((error) => {
|
|
||||||
console.warn('Failed to pre-initialize syntax highlighter:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getFallbackStyle = (isDarkMode: boolean) => {
|
export const getFallbackStyle = (isDarkMode: boolean) => {
|
||||||
return {
|
return {
|
||||||
background: isDarkMode ? githubDark.bg : githubLight.bg,
|
background: isDarkMode ? githubDark.bg : githubLight.bg,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { isServer } from '@tanstack/react-query';
|
|
||||||
|
const isServer = typeof window === 'undefined';
|
||||||
|
|
||||||
if (!isServer) {
|
if (!isServer) {
|
||||||
throw new Error('env.mjs is only meant to be used on the server');
|
throw new Error('env.mjs is only meant to be used on the server');
|
||||||
|
|
|
@ -20,6 +20,7 @@ function makeQueryClient(params?: {
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
|
retryDelay: ERROR_RETRY_DELAY,
|
||||||
staleTime: PREFETCH_STALE_TIME,
|
staleTime: PREFETCH_STALE_TIME,
|
||||||
gcTime: GC_TIME,
|
gcTime: GC_TIME,
|
||||||
enabled: () => {
|
enabled: () => {
|
||||||
|
@ -31,8 +32,7 @@ function makeQueryClient(params?: {
|
||||||
params.openErrorNotification(error);
|
params.openErrorNotification(error);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
retryDelay: ERROR_RETRY_DELAY
|
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
retry: (failureCount, error) => {
|
retry: (failureCount, error) => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export const PREFETCH_STALE_TIME = 1000 * 10; // 10 seconds
|
export const PREFETCH_STALE_TIME = 1000 * 60 * 1; // 1 minutes
|
||||||
export const ERROR_RETRY_DELAY = 1 * 1000; // 1 second delay after error
|
export const ERROR_RETRY_DELAY = 1 * 1000; // 1 second delay after error
|
||||||
export const GC_TIME = 1000 * 60 * 60 * 24 * 3; // 3 days - matches persistence duration
|
export const GC_TIME = 1000 * 60 * 5; // 5 minutes - matches new persistence duration
|
||||||
export const USER_CANCELLED_ERROR = new Error('User cancelled');
|
export const USER_CANCELLED_ERROR = new Error('User cancelled');
|
||||||
|
|
Loading…
Reference in New Issue