Home / File/ vite-plugin-dev-toolbar.ts — astro Source File

vite-plugin-dev-toolbar.ts — astro Source File

Architecture documentation for vite-plugin-dev-toolbar.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 4 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  2c450f40_35a1_631d_078f_d2de72a7448a["vite-plugin-dev-toolbar.ts"]
  e62808d9_0c55_b3a9_00c0_ce588f164dab["../events/index.js"]
  2c450f40_35a1_631d_078f_d2de72a7448a --> e62808d9_0c55_b3a9_00c0_ce588f164dab
  c1c91d83_9dbe_c8f8_8cc2_e90a6eb79d08["../events/toolbar.js"]
  2c450f40_35a1_631d_078f_d2de72a7448a --> c1c91d83_9dbe_c8f8_8cc2_e90a6eb79d08
  e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"]
  2c450f40_35a1_631d_078f_d2de72a7448a --> e9b74c5a_8d34_34a7_e196_5e41b87214aa
  263e522e_1aa5_ebc3_e7d6_45ebc51671f7["vite"]
  2c450f40_35a1_631d_078f_d2de72a7448a --> 263e522e_1aa5_ebc3_e7d6_45ebc51671f7
  style 2c450f40_35a1_631d_078f_d2de72a7448a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type * as vite from 'vite';
import { telemetry } from '../events/index.js';
import { eventAppToggled } from '../events/toolbar.js';
import type { AstroPluginOptions } from '../types/astro.js';

// This is used by Cloudflare optimizeDeps config
const VIRTUAL_MODULE_ID = 'astro:toolbar:internal';
const RESOLVED_VIRTUAL_MODULE_ID = '\0' + VIRTUAL_MODULE_ID;

export default function astroDevToolbar({ settings, logger }: AstroPluginOptions): vite.Plugin {
	let telemetryTimeout: ReturnType<typeof setTimeout>;

	return {
		name: 'astro:dev-toolbar',
		config() {
			return {
				optimizeDeps: {
					// Optimize CJS dependencies used by the dev toolbar
					include: ['astro > aria-query', 'astro > axobject-query'],
				},
			};
		},
		resolveId: {
			filter: {
				id: new RegExp(`^${VIRTUAL_MODULE_ID}$`),
			},
			handler() {
				return RESOLVED_VIRTUAL_MODULE_ID;
			},
		},
		configureServer(server) {
			server.hot.on('astro:devtoolbar:error:load', (args) => {
				logger.error(
					'toolbar',
					`Failed to load dev toolbar app from ${args.entrypoint}: ${args.error}`,
				);
			});

			server.hot.on('astro:devtoolbar:error:init', (args) => {
				logger.error(
					'toolbar',
					`Failed to initialize dev toolbar app ${args.app.name} (${args.app.id}):\n${args.error}`,
				);
			});

			server.hot.on('astro:devtoolbar:app:toggled', (args) => {
				// Debounce telemetry to avoid recording events when the user is rapidly toggling apps for debugging
				clearTimeout(telemetryTimeout);
				telemetryTimeout = setTimeout(() => {
					let nameToRecord = args?.app?.id;
					// Only record apps names for apps that are built-in
					if (!nameToRecord || !nameToRecord.startsWith('astro:')) {
						nameToRecord = 'other';
					}
					telemetry.record(
						eventAppToggled({
							appName: nameToRecord,
						}),
					);
				}, 200);
// ... (69 more lines)

Domain

Subdomains

Functions

Dependencies

  • ../events/index.js
  • ../events/toolbar.js
  • ../types/astro.js
  • vite

Frequently Asked Questions

What does vite-plugin-dev-toolbar.ts do?
vite-plugin-dev-toolbar.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in vite-plugin-dev-toolbar.ts?
vite-plugin-dev-toolbar.ts defines 1 function(s): astroDevToolbar.
What does vite-plugin-dev-toolbar.ts depend on?
vite-plugin-dev-toolbar.ts imports 4 module(s): ../events/index.js, ../events/toolbar.js, ../types/astro.js, vite.
Where is vite-plugin-dev-toolbar.ts in the architecture?
vite-plugin-dev-toolbar.ts is located at packages/astro/src/toolbar/vite-plugin-dev-toolbar.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/toolbar).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free