astro2tsx.ts — astro Source File
Architecture documentation for astro2tsx.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f004a067_f0ae_35cb_fc32_ccf4d7476223["astro2tsx.ts"] 93e56c2d_f370_b182_229b_84d794b9c282["./utils.js"] f004a067_f0ae_35cb_fc32_ccf4d7476223 --> 93e56c2d_f370_b182_229b_84d794b9c282 881bedca_8bf1_6c82_1d1d_caae9da803fd["sync"] f004a067_f0ae_35cb_fc32_ccf4d7476223 --> 881bedca_8bf1_6c82_1d1d_caae9da803fd 81a20ac1_6143_16be_33ec_872bb8d3a54b["types"] f004a067_f0ae_35cb_fc32_ccf4d7476223 --> 81a20ac1_6143_16be_33ec_872bb8d3a54b d4ac305a_acbb_9af4_f554_8b9cd20cb784["sourcemap-codec"] f004a067_f0ae_35cb_fc32_ccf4d7476223 --> d4ac305a_acbb_9af4_f554_8b9cd20cb784 040ca79b_dadf_4383_efd2_c0b13744e9f1["language-core"] f004a067_f0ae_35cb_fc32_ccf4d7476223 --> 040ca79b_dadf_4383_efd2_c0b13744e9f1 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56["language-server"] f004a067_f0ae_35cb_fc32_ccf4d7476223 --> 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56 4e2ee814_ff7b_a348_0e3a_6e6d7b34afb6["vscode-html-languageservice"] f004a067_f0ae_35cb_fc32_ccf4d7476223 --> 4e2ee814_ff7b_a348_0e3a_6e6d7b34afb6 style f004a067_f0ae_35cb_fc32_ccf4d7476223 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { convertToTSX } from '@astrojs/compiler/sync';
import type {
ConvertToTSXOptions,
TSXExtractedScript,
TSXExtractedStyle,
TSXResult,
} from '@astrojs/compiler/types';
import { decode } from '@jridgewell/sourcemap-codec';
import type { CodeMapping, VirtualCode } from '@volar/language-core';
import { Range } from '@volar/language-server';
import { TextDocument } from 'vscode-html-languageservice';
import { patchTSX } from './utils.js';
export interface LSPTSXRanges {
frontmatter: Range;
body: Range;
scripts: TSXExtractedScript[];
styles: TSXExtractedStyle[];
}
export function safeConvertToTSX(content: string, options: ConvertToTSXOptions) {
try {
const tsx = convertToTSX(content, {
filename: options.filename,
includeScripts: false,
includeStyles: false,
});
return tsx;
} catch (e) {
console.error(
`There was an error transforming ${options.filename} to TSX. An empty file will be returned instead. Please create an issue: https://github.com/withastro/astro/issues\nError: ${e}.`,
);
return {
code: '',
map: {
file: options.filename ?? '',
sources: [],
sourcesContent: [],
names: [],
mappings: '',
version: 0,
},
diagnostics: [
{
code: 1000,
location: { file: options.filename!, line: 1, column: 1, length: content.length },
severity: 1,
text: `The Astro compiler encountered an unknown error while transform this file to TSX. Please create an issue with your code and the error shown in the server's logs: https://github.com/withastro/astro/issues`,
},
],
metaRanges: {
frontmatter: {
start: 0,
end: 0,
},
body: {
start: 0,
end: 0,
},
// ... (115 more lines)
Domain
Subdomains
Types
Dependencies
- ./utils.js
- language-core
- language-server
- sourcemap-codec
- sync
- types
- vscode-html-languageservice
Source
Frequently Asked Questions
What does astro2tsx.ts do?
astro2tsx.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 astro2tsx.ts?
astro2tsx.ts defines 4 function(s): astro2tsx, getTSXRangesAsLSPRanges, getVirtualCodeTSX, safeConvertToTSX.
What does astro2tsx.ts depend on?
astro2tsx.ts imports 7 module(s): ./utils.js, language-core, language-server, sourcemap-codec, sync, types, vscode-html-languageservice.
Where is astro2tsx.ts in the architecture?
astro2tsx.ts is located at packages/language-tools/language-server/src/core/astro2tsx.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/language-tools/language-server/src/core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free