Home / File/ TreeNode.ts — astro Source File

TreeNode.ts — astro Source File

Architecture documentation for TreeNode.ts, a typescript file in the astro codebase. 3 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 3 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  a73f1f20_3c4c_06b9_4480_f1f15d6d68ab["TreeNode.ts"]
  9e63cbe8_497c_4ffa_fe72_98f051e32a00["markdoc"]
  a73f1f20_3c4c_06b9_4480_f1f15d6d68ab --> 9e63cbe8_497c_4ffa_fe72_98f051e32a00
  f16d8c76_2866_6150_bd14_0347b59abfe9["astro"]
  a73f1f20_3c4c_06b9_4480_f1f15d6d68ab --> f16d8c76_2866_6150_bd14_0347b59abfe9
  21c9aedb_261f_6744_350a_486c989130ae["index.js"]
  a73f1f20_3c4c_06b9_4480_f1f15d6d68ab --> 21c9aedb_261f_6744_350a_486c989130ae
  style a73f1f20_3c4c_06b9_4480_f1f15d6d68ab fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { RenderableTreeNodes } from '@markdoc/markdoc';
import Markdoc from '@markdoc/markdoc';
import type { AstroInstance, SSRResult } from 'astro';
import type { HTMLString } from 'astro/runtime/server/index.js';
import {
	createComponent,
	createHeadAndContent,
	isHTMLString,
	render,
	renderComponent,
	renderScriptElement,
	renderTemplate,
	renderUniqueStylesheet,
	unescapeHTML,
} from 'astro/runtime/server/index.js';

type TreeNode =
	// Markdoc `if` tag often returns an array of nodes in the AST, which gets translated
	// here as an array of `TreeNode`s, which we'll render all without a wrapper.
	| TreeNode[]
	| {
			type: 'text';
			content: string | HTMLString;
	  }
	| {
			type: 'component';
			component: AstroInstance['default'];
			collectedLinks?: string[];
			collectedStyles?: string[];
			collectedScripts?: string[];
			props: Record<string, any>;
			children: TreeNode[];
	  }
	| {
			type: 'element';
			tag: string;
			attributes: Record<string, any>;
			children: TreeNode[];
	  };

function renderTreeNodeToFactoryResult(result: SSRResult, treeNode: TreeNode) {
	if (Array.isArray(treeNode)) {
		return Promise.all(
			treeNode.map((node) =>
				renderComponent(result, 'ComponentNode', ComponentNode, { treeNode: node }),
			),
		);
	}

	if (treeNode.type === 'text') return render`${treeNode.content}`;

	const slots = {
		default: () =>
			render`${treeNode.children.map((child) =>
				renderComponent(result, 'ComponentNode', ComponentNode, { treeNode: child }),
			)}`,
	};
	if (treeNode.type === 'component') {
		let styles = '',
			links = '',
// ... (119 more lines)

Domain

Subdomains

Dependencies

  • astro
  • index.js
  • markdoc

Frequently Asked Questions

What does TreeNode.ts do?
TreeNode.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 TreeNode.ts?
TreeNode.ts defines 5 function(s): ComponentNode.factory, Promise, createTreeNode, isPropagatedAssetsModule, renderTreeNodeToFactoryResult.
What does TreeNode.ts depend on?
TreeNode.ts imports 3 module(s): astro, index.js, markdoc.
Where is TreeNode.ts in the architecture?
TreeNode.ts is located at packages/integrations/markdoc/components/TreeNode.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/integrations/markdoc/components).

Analyze Your Own Codebase

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

Try Supermodel Free