astro-component.ts — astro Source File
Architecture documentation for astro-component.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 210ae47f_0b36_a098_f009_b4233604e5ef["astro-component.ts"] ef8a1e3f_e350_75a6_b92d_62a8566d8db9["../core/errors/index.js"] 210ae47f_0b36_a098_f009_b4233604e5ef --> ef8a1e3f_e350_75a6_b92d_62a8566d8db9 10d4e39f_edb6_3e34_aa93_ae1211e7da05["../types/public/internal.js"] 210ae47f_0b36_a098_f009_b4233604e5ef --> 10d4e39f_edb6_3e34_aa93_ae1211e7da05 331fe5de_39c8_462f_a089_e3ee4a1fcd11["./index.js"] 210ae47f_0b36_a098_f009_b4233604e5ef --> 331fe5de_39c8_462f_a089_e3ee4a1fcd11 style 210ae47f_0b36_a098_f009_b4233604e5ef fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import type { PropagationHint } from '../../types/public/internal.js';
import type { AstroComponentFactory } from './render/index.js';
function validateArgs(args: unknown[]): args is Parameters<AstroComponentFactory> {
if (args.length !== 3) return false;
if (!args[0] || typeof args[0] !== 'object') return false;
return true;
}
function baseCreateComponent(
cb: AstroComponentFactory,
moduleId?: string,
propagation?: PropagationHint,
): AstroComponentFactory {
const name = moduleId?.split('/').pop()?.replace('.astro', '') ?? '';
const fn = (...args: Parameters<AstroComponentFactory>) => {
if (!validateArgs(args)) {
throw new AstroError({
...AstroErrorData.InvalidComponentArgs,
message: AstroErrorData.InvalidComponentArgs.message(name),
});
}
return cb(...args);
};
Object.defineProperty(fn, 'name', { value: name, writable: false });
// Add a flag to this callback to mark it as an Astro component
fn.isAstroComponentFactory = true;
fn.moduleId = moduleId;
fn.propagation = propagation;
return fn;
}
interface CreateComponentOptions {
factory: AstroComponentFactory;
moduleId?: string;
propagation?: PropagationHint;
}
function createComponentWithOptions(opts: CreateComponentOptions) {
const cb = baseCreateComponent(opts.factory, opts.moduleId, opts.propagation);
return cb;
}
// Used in creating the component. aka the main export.
export function createComponent(
arg1: AstroComponentFactory | CreateComponentOptions,
moduleId?: string,
propagation?: PropagationHint,
) {
if (typeof arg1 === 'function') {
return baseCreateComponent(arg1, moduleId, propagation);
} else {
return createComponentWithOptions(arg1);
}
}
Domain
Subdomains
Types
Dependencies
- ../core/errors/index.js
- ../types/public/internal.js
- ./index.js
Source
Frequently Asked Questions
What does astro-component.ts do?
astro-component.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 astro-component.ts?
astro-component.ts defines 4 function(s): baseCreateComponent, createComponent, createComponentWithOptions, validateArgs.
What does astro-component.ts depend on?
astro-component.ts imports 3 module(s): ../core/errors/index.js, ../types/public/internal.js, ./index.js.
Where is astro-component.ts in the architecture?
astro-component.ts is located at packages/astro/src/runtime/server/astro-component.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