Home / File/ AwaitBlock.js — svelte Source File

AwaitBlock.js — svelte Source File

Architecture documentation for AwaitBlock.js, a javascript file in the svelte codebase. 7 imports, 1 dependents.

File javascript Compiler Transformer 7 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b["AwaitBlock.js"]
  bf0d8f1b_17da_970d_bf44_fbcf099d5371["utils.js"]
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b --> bf0d8f1b_17da_970d_bf44_fbcf099d5371
  ea08cb05_2664_4e93_7551_6103e0cb3a87["validate_block_not_empty"]
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b --> ea08cb05_2664_4e93_7551_6103e0cb3a87
  7148e639_69d8_a03d_3f08_bd23f41e718a["validate_opening_tag"]
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b --> 7148e639_69d8_a03d_3f08_bd23f41e718a
  495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"]
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b --> 495501a4_a342_6a4d_ac11_e3e2fee8b218
  a146f6ac_0088_8736_b6ce_318f9f115170["e"]
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b --> a146f6ac_0088_8736_b6ce_318f9f115170
  c4b4ac8d_9914_5ede_1aea_723bf80d2e9b["fragment.js"]
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b --> c4b4ac8d_9914_5ede_1aea_723bf80d2e9b
  313d2a82_30ea_3161_3aad_0cc2094979aa["mark_subtree_dynamic"]
  93e88a6f_3f11_4770_b83f_853f9bf1fc2b --> 313d2a82_30ea_3161_3aad_0cc2094979aa
  4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"]
  4aa8a188_84d4_0274_ed83_cac0ab1d3572 --> 93e88a6f_3f11_4770_b83f_853f9bf1fc2b
  style 93e88a6f_3f11_4770_b83f_853f9bf1fc2b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { AST } from '#compiler' */
/** @import { Context } from '../types' */
import { validate_block_not_empty, validate_opening_tag } from './shared/utils.js';
import * as e from '../../../errors.js';
import { mark_subtree_dynamic } from './shared/fragment.js';

/**
 * @param {AST.AwaitBlock} node
 * @param {Context} context
 */
export function AwaitBlock(node, context) {
	validate_block_not_empty(node.pending, context);
	validate_block_not_empty(node.then, context);
	validate_block_not_empty(node.catch, context);

	if (context.state.analysis.runes) {
		validate_opening_tag(node, context.state, '#');

		if (node.value) {
			const start = /** @type {number} */ (node.value.start);
			const match = context.state.analysis.source
				.substring(start - 10, start)
				.match(/{(\s*):then\s+$/);

			if (match && match[1] !== '') {
				e.block_unexpected_character({ start: start - 10, end: start }, ':');
			}
		}

		if (node.error) {
			const start = /** @type {number} */ (node.error.start);
			const match = context.state.analysis.source
				.substring(start - 10, start)
				.match(/{(\s*):catch\s+$/);

			if (match && match[1] !== '') {
				e.block_unexpected_character({ start: start - 10, end: start }, ':');
			}
		}
	}

	mark_subtree_dynamic(context.path);

	context.visit(node.expression, { ...context.state, expression: node.metadata.expression });
	if (node.pending) context.visit(node.pending);
	if (node.then) context.visit(node.then);
	if (node.catch) context.visit(node.catch);
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does AwaitBlock.js do?
AwaitBlock.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in AwaitBlock.js?
AwaitBlock.js defines 1 function(s): AwaitBlock.
What does AwaitBlock.js depend on?
AwaitBlock.js imports 7 module(s): e, errors.js, fragment.js, mark_subtree_dynamic, utils.js, validate_block_not_empty, validate_opening_tag.
What files import AwaitBlock.js?
AwaitBlock.js is imported by 1 file(s): index.js.
Where is AwaitBlock.js in the architecture?
AwaitBlock.js is located at packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitBlock.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/2-analyze/visitors).

Analyze Your Own Codebase

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

Try Supermodel Free