index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR c35665ab_15da_1077_3e74_d5bc594df46d["index.ts"] a7eea85d_ea97_57b1_9a24_f99face6a97d["./escape.js"] c35665ab_15da_1077_3e74_d5bc594df46d --> a7eea85d_ea97_57b1_9a24_f99face6a97d 331fe5de_39c8_462f_a089_e3ee4a1fcd11["./index.js"] c35665ab_15da_1077_3e74_d5bc594df46d --> 331fe5de_39c8_462f_a089_e3ee4a1fcd11 style c35665ab_15da_1077_3e74_d5bc594df46d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// NOTE: Although this entrypoint is exported, it is internal API and may change at any time.
export { createComponent } from './astro-component.js';
export { createAstro } from './astro-global.js';
export { renderEndpoint } from './endpoint.js';
export {
escapeHTML,
HTMLBytes,
HTMLString,
isHTMLString,
markHTMLString,
unescapeHTML,
} from './escape.js';
export { renderJSX } from './jsx.js';
export type {
AstroComponentFactory,
AstroComponentInstance,
ComponentSlots,
RenderInstruction,
} from './render/index.js';
export {
addAttribute,
createHeadAndContent,
defineScriptVars,
Fragment,
maybeRenderHead,
Renderer as Renderer,
renderComponent,
renderHead,
renderHTMLElement,
renderPage,
renderScript,
renderScriptElement,
renderSlot,
renderSlotToString,
renderTemplate as render,
renderTemplate,
renderToString,
renderUniqueStylesheet,
voidElementNames,
} from './render/index.js';
export type { ServerIslandComponent } from './render/server-islands.js';
export { createTransitionScope, renderTransition } from './transition.js';
import { markHTMLString } from './escape.js';
import { addAttribute, Renderer } from './render/index.js';
export function mergeSlots(...slotted: unknown[]) {
const slots: Record<string, () => any> = {};
for (const slot of slotted) {
if (!slot) continue;
if (typeof slot === 'object') {
Object.assign(slots, slot);
} else if (typeof slot === 'function') {
Object.assign(slots, mergeSlots(slot()));
}
}
return slots;
}
/** @internal Associate JSX components with a specific renderer (see /packages/integrations/mdx/src/vite-plugin-mdx-postprocess.ts) */
export function __astro_tag_component__(Component: unknown, rendererName: string) {
if (!Component) return;
if (typeof Component !== 'function') return;
Object.defineProperty(Component, Renderer, {
value: rendererName,
enumerable: false,
writable: false,
});
}
// Adds support for `<Component {...value} />
export function spreadAttributes(
values: Record<any, any> = {},
_name?: string,
{ class: scopedClassName }: { class?: string } = {},
) {
let output = '';
// If the compiler passes along a scoped class, merge with existing props or inject it
if (scopedClassName) {
if (typeof values.class !== 'undefined') {
values.class += ` ${scopedClassName}`;
} else if (typeof values['class:list'] !== 'undefined') {
values['class:list'] = [values['class:list'], scopedClassName];
} else {
values.class = scopedClassName;
}
}
for (const [key, value] of Object.entries(values)) {
output += addAttribute(value, key, true, _name);
}
return markHTMLString(output);
}
// Adds CSS variables to an inline style tag
export function defineStyleVars(defs: Record<any, any> | Record<any, any>[]) {
let output = '';
let arr = !Array.isArray(defs) ? [defs] : defs;
for (const vars of arr) {
for (const [key, value] of Object.entries(vars)) {
if (value || value === 0) {
output += `--${key}: ${value};`;
}
}
}
return markHTMLString(output);
}
Domain
Subdomains
Dependencies
- ./escape.js
- ./index.js
Source
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 CoreAstro domain, RenderingEngine subdomain.
What functions are defined in index.ts?
index.ts defines 4 function(s): __astro_tag_component__, defineStyleVars, mergeSlots, spreadAttributes.
What does index.ts depend on?
index.ts imports 2 module(s): ./escape.js, ./index.js.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/runtime/server/index.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/runtime/server).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free