| import type { SettingSource } from './constants.js' |
| import type { SettingsJson } from './types.js' |
| import type { SettingsWithErrors, ValidationError } from './validation.js' |
|
|
| let sessionSettingsCache: SettingsWithErrors | null = null |
|
|
| export function getSessionSettingsCache(): SettingsWithErrors | null { |
| return sessionSettingsCache |
| } |
|
|
| export function setSessionSettingsCache(value: SettingsWithErrors): void { |
| sessionSettingsCache = value |
| } |
|
|
| |
| |
| |
| |
| |
| const perSourceCache = new Map<SettingSource, SettingsJson | null>() |
|
|
| export function getCachedSettingsForSource( |
| source: SettingSource, |
| ): SettingsJson | null | undefined { |
| |
| return perSourceCache.has(source) ? perSourceCache.get(source) : undefined |
| } |
|
|
| export function setCachedSettingsForSource( |
| source: SettingSource, |
| value: SettingsJson | null, |
| ): void { |
| perSourceCache.set(source, value) |
| } |
|
|
| |
| |
| |
| |
| |
| type ParsedSettings = { |
| settings: SettingsJson | null |
| errors: ValidationError[] |
| } |
| const parseFileCache = new Map<string, ParsedSettings>() |
|
|
| export function getCachedParsedFile(path: string): ParsedSettings | undefined { |
| return parseFileCache.get(path) |
| } |
|
|
| export function setCachedParsedFile(path: string, value: ParsedSettings): void { |
| parseFileCache.set(path, value) |
| } |
|
|
| export function resetSettingsCache(): void { |
| sessionSettingsCache = null |
| perSourceCache.clear() |
| parseFileCache.clear() |
| } |
|
|
| |
| |
| |
| |
| |
| let pluginSettingsBase: Record<string, unknown> | undefined |
|
|
| export function getPluginSettingsBase(): Record<string, unknown> | undefined { |
| return pluginSettingsBase |
| } |
|
|
| export function setPluginSettingsBase( |
| settings: Record<string, unknown> | undefined, |
| ): void { |
| pluginSettingsBase = settings |
| } |
|
|
| export function clearPluginSettingsBase(): void { |
| pluginSettingsBase = undefined |
| } |
|
|