Home / File/ window.ts — astro Source File

window.ts — astro Source File

Architecture documentation for window.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.

File typescript DevToolbar ToolbarClient 2 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  bd769712_125e_47f5_295b_20dbbbe7a68d["window.ts"]
  844d479d_bd2c_31dd_1673_36b5e7e8016a["../settings.js"]
  bd769712_125e_47f5_295b_20dbbbe7a68d --> 844d479d_bd2c_31dd_1673_36b5e7e8016a
  09fa95e1_0f5f_b352_8674_9da4b245b83b["./ui-library/window.js"]
  bd769712_125e_47f5_295b_20dbbbe7a68d --> 09fa95e1_0f5f_b352_8674_9da4b245b83b
  style bd769712_125e_47f5_295b_20dbbbe7a68d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { settings } from '../../settings.js';
import type { Placement } from '../../ui-library/window.js';

export function createWindowElement(content: string, placement = settings.config.placement) {
	const windowElement = document.createElement('astro-dev-toolbar-window');
	windowElement.innerHTML = content;
	windowElement.placement = placement;
	return windowElement;
}

export function closeOnOutsideClick(
	eventTarget: EventTarget,
	additionalCheck?: (target: Element) => boolean,
) {
	function onPageClick(event: MouseEvent) {
		const target = event.target as Element | null;
		if (!target) return;
		if (!target.closest) return;
		if (target.closest('astro-dev-toolbar')) return;
		if (additionalCheck && additionalCheck(target)) return;
		eventTarget.dispatchEvent(
			new CustomEvent('toggle-app', {
				detail: {
					state: false,
				},
			}),
		);
	}
	eventTarget.addEventListener('app-toggled', (event: any) => {
		if (event.detail.state === true) {
			document.addEventListener('click', onPageClick, true);
		} else {
			document.removeEventListener('click', onPageClick, true);
		}
	});
}

export function synchronizePlacementOnUpdate(eventTarget: EventTarget, canvas: ShadowRoot) {
	eventTarget.addEventListener('placement-updated', (evt) => {
		if (!(evt instanceof CustomEvent)) {
			return;
		}
		const windowElement = canvas.querySelector('astro-dev-toolbar-window');
		if (!windowElement) {
			return;
		}
		const event: CustomEvent<{ placement: Placement }> = evt;
		windowElement.placement = event.detail.placement;
	});
}

Domain

Subdomains

Dependencies

  • ../settings.js
  • ./ui-library/window.js

Frequently Asked Questions

What does window.ts do?
window.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 window.ts?
window.ts defines 3 function(s): closeOnOutsideClick, createWindowElement, synchronizePlacementOnUpdate.
What does window.ts depend on?
window.ts imports 2 module(s): ../settings.js, ./ui-library/window.js.
Where is window.ts in the architecture?
window.ts is located at packages/astro/src/runtime/client/dev-toolbar/apps/utils/window.ts (domain: DevToolbar, subdomain: ToolbarClient, directory: packages/astro/src/runtime/client/dev-toolbar/apps/utils).

Analyze Your Own Codebase

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

Try Supermodel Free