Home / File/ index.ts — astro Source File

index.ts — astro Source File

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

File typescript DevToolbar ToolbarClient 10 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  00de791e_c3ec_5c38_2e33_352734c87e5a["index.ts"]
  6e91fe0d_c6ce_0cca_abd3_06b774edbe23["./toolbar.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> 6e91fe0d_c6ce_0cca_abd3_06b774edbe23
  844d479d_bd2c_31dd_1673_36b5e7e8016a["../settings.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> 844d479d_bd2c_31dd_1673_36b5e7e8016a
  76a8dde1_0437_fd1c_f3f4_3c2497b06de9["../ui-library/highlight.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> 76a8dde1_0437_fd1c_f3f4_3c2497b06de9
  36c86db7_583c_6a41_001d_26ecc3b5189e["./utils/highlight.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> 36c86db7_583c_6a41_001d_26ecc3b5189e
  2c2fd83a_a206_7736_5927_a82639572edb["./utils/window.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> 2c2fd83a_a206_7736_5927_a82639572edb
  7fecc1f7_6786_be13_5f20_8914b287345d["../annotations.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> 7fecc1f7_6786_be13_5f20_8914b287345d
  c19ed93d_c905_8e8a_abab_010a7ccd1966["../rules/index.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> c19ed93d_c905_8e8a_abab_010a7ccd1966
  a0e7eef3_2348_71cb_bd73_9658fb1fac9a["./audit-list-item.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> a0e7eef3_2348_71cb_bd73_9658fb1fac9a
  a02cd417_d1b2_5651_8a46_70c124177e86["./ui/audit-list-window.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> a02cd417_d1b2_5651_8a46_70c124177e86
  216a244b_0ba2_9719_66dd_0fa688d2512b["./ui/audit-ui.js"]
  00de791e_c3ec_5c38_2e33_352734c87e5a --> 216a244b_0ba2_9719_66dd_0fa688d2512b
  style 00de791e_c3ec_5c38_2e33_352734c87e5a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { ResolvedDevToolbarApp } from '../../../../../types/public/toolbar.js';
import { settings } from '../../settings.js';
import type { DevToolbarHighlight } from '../../ui-library/highlight.js';
import { positionHighlight } from '../utils/highlight.js';
import { closeOnOutsideClick } from '../utils/window.js';
import { processAnnotations } from './annotations.js';
import { type AuditRule, rulesCategories } from './rules/index.js';
import { DevToolbarAuditListItem } from './ui/audit-list-item.js';
import { DevToolbarAuditListWindow } from './ui/audit-list-window.js';
import { createAuditUI } from './ui/audit-ui.js';

const icon =
	'<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 1 20 16" aria-hidden="true"><path fill="#fff" d="M.6 2A1.1 1.1 0 0 1 1.7.9h16.6a1.1 1.1 0 1 1 0 2.2H1.6A1.1 1.1 0 0 1 .8 2Zm1.1 7.1h6a1.1 1.1 0 0 0 0-2.2h-6a1.1 1.1 0 0 0 0 2.2ZM9.3 13H1.8a1.1 1.1 0 1 0 0 2.2h7.5a1.1 1.1 0 1 0 0-2.2Zm11.3 1.9a1.1 1.1 0 0 1-1.5 0l-1.7-1.7a4.1 4.1 0 1 1 1.6-1.6l1.6 1.7a1.1 1.1 0 0 1 0 1.6Zm-5.3-3.4a1.9 1.9 0 1 0 0-3.8 1.9 1.9 0 0 0 0 3.8Z"/></svg>';

export type Audit = {
	auditedElement: HTMLElement;
	rule: AuditRule;
	highlight: DevToolbarHighlight | null;
	card: HTMLElement | null;
};

try {
	customElements.define('astro-dev-toolbar-audit-window', DevToolbarAuditListWindow);
	customElements.define('astro-dev-toolbar-audit-list-item', DevToolbarAuditListItem);
} catch {}

let showState = false;

export default {
	id: 'astro:audit',
	name: 'Audit',
	icon: icon,
	async init(canvas, eventTarget) {
		let audits: Audit[] = [];
		let auditWindow = document.createElement(
			'astro-dev-toolbar-audit-window',
		) as DevToolbarAuditListWindow;
		let hasCreatedUI = false;
		auditWindow.popover = '';

		canvas.appendChild(auditWindow);

		await run();

		let mutationDebounce: ReturnType<typeof setTimeout>;
		const observer = new MutationObserver(() => {
			// We don't want to rerun the audit lints on every single mutation, so we'll debounce it.
			if (mutationDebounce) {
				clearTimeout(mutationDebounce);
			}

			mutationDebounce = setTimeout(() => {
				settings.logger.verboseLog('Rerunning audit lints because the DOM has been updated.');

				// Even though we're ready to run the lints, we'll wait for the next idle period to do so, as it is less likely
				// to interfere with any other work the browser is doing post-mutation. For instance, the page or the user might
				// be interacting with the newly added elements, or the browser might be doing some work (layout, paint, etc.)
				if ('requestIdleCallback' in window) {
					window.requestIdleCallback(
						async () => {
// ... (170 more lines)

Domain

Subdomains

Functions

Types

Dependencies

  • ../annotations.js
  • ../rules/index.js
  • ../settings.js
  • ../ui-library/highlight.js
  • ./audit-list-item.js
  • ./toolbar.js
  • ./ui/audit-list-window.js
  • ./ui/audit-ui.js
  • ./utils/highlight.js
  • ./utils/window.js

Frequently Asked Questions

What does index.ts do?
index.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 index.ts?
index.ts defines 1 function(s): default.init.
What does index.ts depend on?
index.ts imports 10 module(s): ../annotations.js, ../rules/index.js, ../settings.js, ../ui-library/highlight.js, ./audit-list-item.js, ./toolbar.js, ./ui/audit-list-window.js, ./ui/audit-ui.js, and 2 more.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/runtime/client/dev-toolbar/apps/audit/index.ts (domain: DevToolbar, subdomain: ToolbarClient, directory: packages/astro/src/runtime/client/dev-toolbar/apps/audit).

Analyze Your Own Codebase

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

Try Supermodel Free