Home / File/ index.js — svelte Source File

index.js — svelte Source File

Architecture documentation for index.js, a javascript file in the svelte codebase. 24 imports, 2 dependents.

File javascript ServerRuntime Serialization 24 imports 2 dependents 26 functions

Entity Profile

Dependency Diagram

graph LR
  1c4bc493_24af_177e_7307_a999997aceac["index.js"]
  22eadd41_615a_90cd_7963_26c9a3fc58cb["attributes.js"]
  1c4bc493_24af_177e_7307_a999997aceac --> 22eadd41_615a_90cd_7963_26c9a3fc58cb
  c5706cd2_ff56_80ba_e35d_9c5a0c2b6647["attr"]
  1c4bc493_24af_177e_7307_a999997aceac --> c5706cd2_ff56_80ba_e35d_9c5a0c2b6647
  cb6da1e2_2fb4_545a_1bea_8d33e5942ef9["clsx"]
  1c4bc493_24af_177e_7307_a999997aceac --> cb6da1e2_2fb4_545a_1bea_8d33e5942ef9
  efa24e01_f8d7_2cf4_7e7e_aadd84b2197e["to_class"]
  1c4bc493_24af_177e_7307_a999997aceac --> efa24e01_f8d7_2cf4_7e7e_aadd84b2197e
  82b89a82_43eb_55e9_a708_1e7df64f688c["to_style"]
  1c4bc493_24af_177e_7307_a999997aceac --> 82b89a82_43eb_55e9_a708_1e7df64f688c
  cb946435_ce66_d1e8_6bee_287bdb07e7c5["utils.js"]
  1c4bc493_24af_177e_7307_a999997aceac --> cb946435_ce66_d1e8_6bee_287bdb07e7c5
  b898b311_bec4_34ca_1aa6_2a0ff69b0212["is_promise"]
  1c4bc493_24af_177e_7307_a999997aceac --> b898b311_bec4_34ca_1aa6_2a0ff69b0212
  fa007f2b_f437_c5ef_5c2d_ea8b5902500f["noop"]
  1c4bc493_24af_177e_7307_a999997aceac --> fa007f2b_f437_c5ef_5c2d_ea8b5902500f
  dacfcaf1_66cb_9fe3_083b_4fee2b4eb64f["utils.js"]
  1c4bc493_24af_177e_7307_a999997aceac --> dacfcaf1_66cb_9fe3_083b_4fee2b4eb64f
  257e3ffe_958d_4447_c42b_d1cd05172fdb["subscribe_to_store"]
  1c4bc493_24af_177e_7307_a999997aceac --> 257e3ffe_958d_4447_c42b_d1cd05172fdb
  73865c3c_2786_c9ac_d34f_b51d28b3a29e["constants.js"]
  1c4bc493_24af_177e_7307_a999997aceac --> 73865c3c_2786_c9ac_d34f_b51d28b3a29e
  cb064307_faf7_de99_b8a6_9523086a7c01["escaping.js"]
  1c4bc493_24af_177e_7307_a999997aceac --> cb064307_faf7_de99_b8a6_9523086a7c01
  d6dfd043_7103_f2c7_aab3_9660fb0a5f75["escape_html"]
  1c4bc493_24af_177e_7307_a999997aceac --> d6dfd043_7103_f2c7_aab3_9660fb0a5f75
  bb0c9dd4_b592_cf45_1390_8cfbd8a288ec["hydration.js"]
  1c4bc493_24af_177e_7307_a999997aceac --> bb0c9dd4_b592_cf45_1390_8cfbd8a288ec
  style 1c4bc493_24af_177e_7307_a999997aceac fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { ComponentType, SvelteComponent, Component } from 'svelte' */
/** @import { Csp, RenderOutput } from '#server' */
/** @import { Store } from '#shared' */
export { FILENAME, HMR } from '../../constants.js';
import { attr, clsx, to_class, to_style } from '../shared/attributes.js';
import { is_promise, noop } from '../shared/utils.js';
import { subscribe_to_store } from '../../store/utils.js';
import {
	UNINITIALIZED,
	ELEMENT_PRESERVE_ATTRIBUTE_CASE,
	ELEMENT_IS_NAMESPACED,
	ELEMENT_IS_INPUT
} from '../../constants.js';
import { escape_html } from '../../escaping.js';
import { DEV } from 'esm-env';
import { EMPTY_COMMENT, BLOCK_CLOSE, BLOCK_OPEN, BLOCK_OPEN_ELSE } from './hydration.js';
import { validate_store } from '../shared/validate.js';
import { is_boolean_attribute, is_raw_text_element, is_void } from '../../utils.js';
import { Renderer } from './renderer.js';
import * as e from './errors.js';

// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
// https://infra.spec.whatwg.org/#noncharacter
const INVALID_ATTR_NAME_CHAR_REGEX =
	/[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;

/**
 * @param {Renderer} renderer
 * @param {string} tag
 * @param {() => void} attributes_fn
 * @param {() => void} children_fn
 * @returns {void}
 */
export function element(renderer, tag, attributes_fn = noop, children_fn = noop) {
	renderer.push('<!---->');

	if (tag) {
		renderer.push(`<${tag}`);
		attributes_fn();
		renderer.push(`>`);

		if (!is_void(tag)) {
			children_fn();
			if (!is_raw_text_element(tag)) {
				renderer.push(EMPTY_COMMENT);
			}
			renderer.push(`</${tag}>`);
		}
	}

	renderer.push('<!---->');
}

/**
 * Only available on the server and when compiling with the `server` option.
 * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
 * @template {Record<string, any>} Props
 * @param {Component<Props> | ComponentType<SvelteComponent<Props>>} component
 * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
 * @returns {RenderOutput}
// ... (431 more lines)

Domain

Subdomains

Frequently Asked Questions

What does index.js do?
index.js is a source file in the svelte codebase, written in javascript. It belongs to the ServerRuntime domain, Serialization subdomain.
What functions are defined in index.js?
index.js defines 26 function(s): attr_class, attr_style, attributes, await_block, bind_props, css_props, derived, element, ensure_array_like, head, and 16 more.
What does index.js depend on?
index.js imports 24 module(s): Renderer, attr, attributes.js, clsx, constants.js, errors.js, escape_html, escaping.js, and 16 more.
What files import index.js?
index.js is imported by 2 file(s): legacy-server.js, renderer.js.
Where is index.js in the architecture?
index.js is located at packages/svelte/src/internal/server/index.js (domain: ServerRuntime, subdomain: Serialization, directory: packages/svelte/src/internal/server).

Analyze Your Own Codebase

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

Try Supermodel Free