Home / File/ SvelteBoundary.js — svelte Source File

SvelteBoundary.js — svelte Source File

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

File javascript Compiler Transformer 4 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  1831a41b_2cdc_bfcb_89c5_5a00675ed78c["SvelteBoundary.js"]
  74eddc85_a390_2aab_af5a_ef32b77d5430["utils.js"]
  1831a41b_2cdc_bfcb_89c5_5a00675ed78c --> 74eddc85_a390_2aab_af5a_ef32b77d5430
  9f24c33c_da34_a132_f273_3ffd2f6e5cf8["build_attribute_value"]
  1831a41b_2cdc_bfcb_89c5_5a00675ed78c --> 9f24c33c_da34_a132_f273_3ffd2f6e5cf8
  49bc6956_1326_e1db_837c_bb4db2493060["build_template"]
  1831a41b_2cdc_bfcb_89c5_5a00675ed78c --> 49bc6956_1326_e1db_837c_bb4db2493060
  95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"]
  1831a41b_2cdc_bfcb_89c5_5a00675ed78c --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc
  86cf8685_38fa_3a1c_9b81_21c452968289["transform-server.js"]
  86cf8685_38fa_3a1c_9b81_21c452968289 --> 1831a41b_2cdc_bfcb_89c5_5a00675ed78c
  style 1831a41b_2cdc_bfcb_89c5_5a00675ed78c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { BlockStatement } from 'estree' */
/** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */
import * as b from '#compiler/builders';
import {
	block_close,
	block_open,
	block_open_else,
	build_attribute_value,
	build_template
} from './shared/utils.js';

/**
 * @param {AST.SvelteBoundary} node
 * @param {ComponentContext} context
 */
export function SvelteBoundary(node, context) {
	// if this has a `pending` snippet, render it
	const pending_attribute = /** @type {AST.Attribute} */ (
		node.attributes.find((node) => node.type === 'Attribute' && node.name === 'pending')
	);
	const is_pending_attr_nullish =
		pending_attribute &&
		typeof pending_attribute.value === 'object' &&
		!Array.isArray(pending_attribute.value) &&
		!context.state.scope.evaluate(pending_attribute.value.expression).is_defined;

	const pending_snippet = /** @type {AST.SnippetBlock} */ (
		node.fragment.nodes.find(
			(node) => node.type === 'SnippetBlock' && node.expression.name === 'pending'
		)
	);

	if (pending_attribute || pending_snippet) {
		if (pending_attribute && is_pending_attr_nullish && !pending_snippet) {
			const callee = build_attribute_value(
				pending_attribute.value,
				context,
				(expression) => expression,
				false,
				true
			);
			const pending = b.call(callee, b.id('$$renderer'));
			const block = /** @type {BlockStatement} */ (context.visit(node.fragment));
			context.state.template.push(
				b.if(
					callee,
					b.block(build_template([block_open_else, b.stmt(pending), block_close])),
					b.block(build_template([block_open, block, block_close]))
				)
			);
		} else {
			const pending = pending_attribute
				? b.call(
						build_attribute_value(
							pending_attribute.value,
							context,
							(expression) => expression,
							false,
							true
						),
						b.id('$$renderer')
					)
				: /** @type {BlockStatement} */ (context.visit(pending_snippet.body));
			context.state.template.push(block_open_else, pending, block_close);
		}
	} else {
		const block = /** @type {BlockStatement} */ (context.visit(node.fragment));
		context.state.template.push(block_open, block, block_close);
	}
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does SvelteBoundary.js do?
SvelteBoundary.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 SvelteBoundary.js?
SvelteBoundary.js defines 1 function(s): SvelteBoundary.
What does SvelteBoundary.js depend on?
SvelteBoundary.js imports 4 module(s): build_attribute_value, build_template, builders, utils.js.
What files import SvelteBoundary.js?
SvelteBoundary.js is imported by 1 file(s): transform-server.js.
Where is SvelteBoundary.js in the architecture?
SvelteBoundary.js is located at packages/svelte/src/compiler/phases/3-transform/server/visitors/SvelteBoundary.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/3-transform/server/visitors).

Analyze Your Own Codebase

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

Try Supermodel Free