Home / Function/ getToolbarServerCommunicationHelpers() — astro Function Reference

getToolbarServerCommunicationHelpers() — astro Function Reference

Architecture documentation for the getToolbarServerCommunicationHelpers() function in hooks.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  50c56fe8_d5b1_e583_7d3a_bd54264081e1["getToolbarServerCommunicationHelpers()"]
  19f4084c_157f_a15d_f001_5d8088b75dee["hooks.ts"]
  50c56fe8_d5b1_e583_7d3a_bd54264081e1 -->|defined in| 19f4084c_157f_a15d_f001_5d8088b75dee
  2142ce6a_584b_4a1e_0cf7_3de445c9b816["runHookServerSetup()"]
  2142ce6a_584b_4a1e_0cf7_3de445c9b816 -->|calls| 50c56fe8_d5b1_e583_7d3a_bd54264081e1
  style 50c56fe8_d5b1_e583_7d3a_bd54264081e1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/integrations/hooks.ts lines 114–149

export function getToolbarServerCommunicationHelpers(server: ViteDevServer) {
	return {
		/**
		 * Send a message to the dev toolbar that an app can listen for. The payload can be any serializable data.
		 * @param event - The event name
		 * @param payload - The payload to send
		 */
		send: <T>(event: string, payload: T) => {
			server.environments.client.hot.send(event, payload);
		},
		/**
		 * Receive a message from a dev toolbar app.
		 * @param event
		 * @param callback
		 */
		on: <T>(event: string, callback: (data: T) => void) => {
			server.hot.on(event, callback);
		},
		/**
		 * Fired when an app is initialized.
		 * @param appId - The id of the app that was initialized
		 * @param callback - The callback to run when the app is initialized
		 */
		onAppInitialized: (appId: string, callback: (data: Record<string, never>) => void) => {
			server.hot.on(`${serverEventPrefix}:${appId}:initialized`, callback);
		},
		/**
		 * Fired when an app is toggled on or off.
		 * @param appId - The id of the app that was toggled
		 * @param callback - The callback to run when the app is toggled
		 */
		onAppToggled: (appId: string, callback: (data: { state: boolean }) => void) => {
			server.hot.on(`${serverEventPrefix}:${appId}:toggled`, callback);
		},
	};
}

Domain

Subdomains

Frequently Asked Questions

What does getToolbarServerCommunicationHelpers() do?
getToolbarServerCommunicationHelpers() is a function in the astro codebase, defined in packages/astro/src/integrations/hooks.ts.
Where is getToolbarServerCommunicationHelpers() defined?
getToolbarServerCommunicationHelpers() is defined in packages/astro/src/integrations/hooks.ts at line 114.
What calls getToolbarServerCommunicationHelpers()?
getToolbarServerCommunicationHelpers() is called by 1 function(s): runHookServerSetup.

Analyze Your Own Codebase

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

Try Supermodel Free