Home / File/ context.ts — astro Source File

context.ts — astro Source File

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

File typescript CoreAstro RoutingSystem 1 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  ab69be47_8646_3945_6749_5ae15a46d282["context.ts"]
  f16d8c76_2866_6150_bd14_0347b59abfe9["astro"]
  ab69be47_8646_3945_6749_5ae15a46d282 --> f16d8c76_2866_6150_bd14_0347b59abfe9
  style ab69be47_8646_3945_6749_5ae15a46d282 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { SSRResult } from 'astro';

const contexts = new WeakMap<SSRResult, { currentIndex: number; readonly id: string }>();

const ID_PREFIX = 'r';

function getContext(rendererContextResult: SSRResult) {
	if (contexts.has(rendererContextResult)) {
		return contexts.get(rendererContextResult);
	}
	const ctx = {
		currentIndex: 0,
		get id() {
			return ID_PREFIX + this.currentIndex.toString();
		},
	};
	contexts.set(rendererContextResult, ctx);
	return ctx;
}

export function incrementId(rendererContextResult: SSRResult) {
	const ctx = getContext(rendererContextResult)!;
	const id = ctx.id;
	ctx.currentIndex++;
	return id;
}

Domain

Subdomains

Dependencies

  • astro

Frequently Asked Questions

What does context.ts do?
context.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in context.ts?
context.ts defines 2 function(s): getContext, incrementId.
What does context.ts depend on?
context.ts imports 1 module(s): astro.
Where is context.ts in the architecture?
context.ts is located at packages/integrations/react/src/context.ts (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/integrations/react/src).

Analyze Your Own Codebase

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

Try Supermodel Free