settings.ts — astro Source File
Architecture documentation for settings.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c2dd2feb_e979_16df_29d6_31bcce55c169["settings.ts"] 6e91fe0d_c6ce_0cca_abd3_06b774edbe23["./toolbar.js"] c2dd2feb_e979_16df_29d6_31bcce55c169 --> 6e91fe0d_c6ce_0cca_abd3_06b774edbe23 09fa95e1_0f5f_b352_8674_9da4b245b83b["./ui-library/window.js"] c2dd2feb_e979_16df_29d6_31bcce55c169 --> 09fa95e1_0f5f_b352_8674_9da4b245b83b style c2dd2feb_e979_16df_29d6_31bcce55c169 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { DevToolbarMetadata } from '../../../types/public/toolbar.js';
import { isValidPlacement, type Placement } from './ui-library/window.js';
export interface Settings {
disableAppNotification: boolean;
verbose: boolean;
placement: Placement;
}
export const defaultSettings = {
disableAppNotification: false,
verbose: false,
placement: 'bottom-center',
} satisfies Settings;
export const settings = getSettings();
function getSettings() {
// 1. Start with hardcoded defaults
let _settings: Settings = { ...defaultSettings };
// 2. Override with config placement (if provided)
const configPlacement = (globalThis as DevToolbarMetadata).__astro_dev_toolbar__?.placement;
if (configPlacement && isValidPlacement(configPlacement)) {
_settings.placement = configPlacement;
}
// 3. Override with localStorage (preserves user's UI choice)
const toolbarSettings = localStorage.getItem('astro:dev-toolbar:settings');
if (toolbarSettings) {
_settings = { ..._settings, ...JSON.parse(toolbarSettings) };
}
function updateSetting<Key extends keyof Settings>(key: Key, value: Settings[Key]) {
_settings[key] = value;
localStorage.setItem('astro:dev-toolbar:settings', JSON.stringify(_settings));
}
function log(message: string, level: 'log' | 'warn' | 'error' = 'log') {
// biome-ignore lint/suspicious/noConsole: it can't infer types yet
console[level](
`%cAstro`,
'background: linear-gradient(66.77deg, #D83333 0%, #F041FF 100%); color: white; padding-inline: 4px; border-radius: 2px; font-family: monospace;',
message,
);
}
return {
get config() {
return _settings;
},
updateSetting,
logger: {
log,
warn: (message: string) => {
log(message, 'warn');
},
error: (message: string) => {
log(message, 'error');
},
verboseLog: (message: string) => {
if (_settings.verbose) {
log(message);
}
},
},
};
}
Domain
Subdomains
Functions
Types
Dependencies
- ./toolbar.js
- ./ui-library/window.js
Source
Frequently Asked Questions
What does settings.ts do?
settings.ts is a source file in the astro codebase, written in typescript. It belongs to the DevToolbar domain, ToolbarClient subdomain.
What functions are defined in settings.ts?
settings.ts defines 1 function(s): getSettings.
What does settings.ts depend on?
settings.ts imports 2 module(s): ./toolbar.js, ./ui-library/window.js.
Where is settings.ts in the architecture?
settings.ts is located at packages/astro/src/runtime/client/dev-toolbar/settings.ts (domain: DevToolbar, subdomain: ToolbarClient, directory: packages/astro/src/runtime/client/dev-toolbar).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free