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 CoreMiddleware 1 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  6c681793_21f0_90a5_f19f_4f75388ab5a2["context.ts"]
  88d5831c_10b7_7e11_b115_8c6e411804a3["./types.js"]
  6c681793_21f0_90a5_f19f_4f75388ab5a2 --> 88d5831c_10b7_7e11_b115_8c6e411804a3
  style 6c681793_21f0_90a5_f19f_4f75388ab5a2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { PropNameToSignalMap, RendererContext, SignalLike } from './types.js';

export type Context = {
	id: string;
	c: number;
	signals: Map<SignalLike, string>;
	propsToSignals: Map<Record<string, any>, PropNameToSignalMap>;
};

const contexts = new WeakMap<RendererContext['result'], Context>();

export function getContext(result: RendererContext['result']): Context {
	if (contexts.has(result)) {
		return contexts.get(result)!;
	}
	let ctx = {
		c: 0,
		get id() {
			return 'p' + this.c.toString();
		},
		signals: new Map(),
		propsToSignals: new Map(),
	};
	contexts.set(result, ctx);
	return ctx;
}

export function incrementId(ctx: Context): string {
	let id = ctx.id;
	ctx.c++;
	return id;
}

Domain

Subdomains

Types

Dependencies

  • ./types.js

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, CoreMiddleware 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): ./types.js.
Where is context.ts in the architecture?
context.ts is located at packages/integrations/preact/src/context.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/integrations/preact/src).

Analyze Your Own Codebase

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

Try Supermodel Free