common.ts — astro Source File
Architecture documentation for common.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR dc345517_d883_7bce_edfa_c6cabf28094d["common.ts"] 10d4e39f_edb6_3e34_aa93_ae1211e7da05["../types/public/internal.js"] dc345517_d883_7bce_edfa_c6cabf28094d --> 10d4e39f_edb6_3e34_aa93_ae1211e7da05 a7eea85d_ea97_57b1_9a24_f99face6a97d["./escape.js"] dc345517_d883_7bce_edfa_c6cabf28094d --> a7eea85d_ea97_57b1_9a24_f99face6a97d 971ee397_31b4_35c6_1d6b_3d7c1711726e["../scripts.js"] dc345517_d883_7bce_edfa_c6cabf28094d --> 971ee397_31b4_35c6_1d6b_3d7c1711726e f39133ce_d2ba_8a67_096e_fd278b78377e["./head.js"] dc345517_d883_7bce_edfa_c6cabf28094d --> f39133ce_d2ba_8a67_096e_fd278b78377e ff0be6cd_e34f_b283_f541_4038fdcadce5["./instruction.js"] dc345517_d883_7bce_edfa_c6cabf28094d --> ff0be6cd_e34f_b283_f541_4038fdcadce5 d684f324_0073_af4e_091c_bf7f866bec5d["./server-islands.js"] dc345517_d883_7bce_edfa_c6cabf28094d --> d684f324_0073_af4e_091c_bf7f866bec5d 624e5f97_7f83_f926_3407_b10786361e90["./slot.js"] dc345517_d883_7bce_edfa_c6cabf28094d --> 624e5f97_7f83_f926_3407_b10786361e90 style dc345517_d883_7bce_edfa_c6cabf28094d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { SSRResult } from '../../../types/public/internal.js';
import type { HTMLBytes, HTMLString } from '../escape.js';
import { markHTMLString } from '../escape.js';
import {
determineIfNeedsHydrationScript,
determinesIfNeedsDirectiveScript,
getPrescripts,
} from '../scripts.js';
import { renderAllHeadContent } from './head.js';
import type { RenderInstruction } from './instruction.js';
import { isRenderInstruction } from './instruction.js';
import { renderServerIslandRuntime } from './server-islands.js';
import { isSlotString, type SlotString } from './slot.js';
/**
* Possible chunk types to be written to the destination, and it'll
* handle stringifying them at the end.
*
* NOTE: Try to reduce adding new types here. If possible, serialize
* the custom types to a string in `renderChild` in `any.ts`.
*/
export type RenderDestinationChunk =
| string
| HTMLBytes
| HTMLString
| SlotString
| ArrayBufferView
| RenderInstruction
| Response;
export interface RenderDestination {
/**
* Any rendering logic should call this to construct the HTML output.
* See the `chunk` parameter for possible writable values.
*/
write(chunk: RenderDestinationChunk): void;
}
export interface RenderInstance {
render: RenderFunction;
}
export type RenderFunction = (destination: RenderDestination) => Promise<void> | void;
export const Fragment = Symbol.for('astro:fragment');
export const Renderer = Symbol.for('astro:renderer');
export const encoder = new TextEncoder();
export const decoder = new TextDecoder();
// Rendering produces either marked strings of HTML or instructions for hydration.
// These directive instructions bubble all the way up to renderPage so that we
// can ensure they are added only once, and as soon as possible.
function stringifyChunk(
result: SSRResult,
chunk: string | HTMLString | SlotString | RenderInstruction,
): string {
if (isRenderInstruction(chunk)) {
const instruction = chunk;
switch (instruction.type) {
// ... (110 more lines)
Domain
Subdomains
Functions
Dependencies
- ../scripts.js
- ../types/public/internal.js
- ./escape.js
- ./head.js
- ./instruction.js
- ./server-islands.js
- ./slot.js
Source
Frequently Asked Questions
What does common.ts do?
common.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 common.ts?
common.ts defines 6 function(s): chunkToByteArray, chunkToByteArrayOrString, chunkToString, destination, isRenderInstance, stringifyChunk.
What does common.ts depend on?
common.ts imports 7 module(s): ../scripts.js, ../types/public/internal.js, ./escape.js, ./head.js, ./instruction.js, ./server-islands.js, ./slot.js.
Where is common.ts in the architecture?
common.ts is located at packages/astro/src/runtime/server/render/common.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/runtime/server/render).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free