index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 14 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 3d0a8903_cb4c_d139_320b_9571e3568661["index.ts"] 8d3d0086_915f_5a8c_ee4d_83532eb23d3f["./importPackage.js"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 8d3d0086_915f_5a8c_ee4d_83532eb23d3f fcea7c61_8834_bcc8_0062_ff8308eb913e["./utils.js"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> fcea7c61_8834_bcc8_0062_ff8308eb913e 1c830673_d3fc_59eb_ee93_023dd3e6e9ac["./astro2tsx.js"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 1c830673_d3fc_59eb_ee93_023dd3e6e9ac 5d635c24_aea1_c7f7_2c64_4fe0f5e4041b["../core/parseAstro.js"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 5d635c24_aea1_c7f7_2c64_4fe0f5e4041b b7c829b0_3a5e_2b92_185f_a40e684a4b76["./parseCSS.js"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> b7c829b0_3a5e_2b92_185f_a40e684a4b76 ad964aca_13b1_dc7e_07a7_99a8528689a8["./parseHTML.js"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> ad964aca_13b1_dc7e_07a7_99a8528689a8 89089639_838b_9c06_0a60_640766f5cb9b["./parseJS.js"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 89089639_838b_9c06_0a60_640766f5cb9b c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> c52a5f83_66e3_37d7_9ebb_767f7129bc62 81a20ac1_6143_16be_33ec_872bb8d3a54b["types"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 81a20ac1_6143_16be_33ec_872bb8d3a54b 040ca79b_dadf_4383_efd2_c0b13744e9f1["language-core"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 040ca79b_dadf_4383_efd2_c0b13744e9f1 85e74021_180c_6114_1615_e1a23a58c9f3["typescript"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 85e74021_180c_6114_1615_e1a23a58c9f3 41525615_7e06_b0e8_f601_674c57b118ee["typescript"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 41525615_7e06_b0e8_f601_674c57b118ee 4e2ee814_ff7b_a348_0e3a_6e6d7b34afb6["vscode-html-languageservice"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> 4e2ee814_ff7b_a348_0e3a_6e6d7b34afb6 abeb339e_cdba_0d7f_6b7f_3696c1eb86f9["vscode-uri"] 3d0a8903_cb4c_d139_320b_9571e3568661 --> abeb339e_cdba_0d7f_6b7f_3696c1eb86f9 style 3d0a8903_cb4c_d139_320b_9571e3568661 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as path from 'node:path';
import type { DiagnosticMessage, DiagnosticSeverity } from '@astrojs/compiler/types';
import {
type CodeMapping,
forEachEmbeddedCode,
type LanguagePlugin,
type VirtualCode,
} from '@volar/language-core';
import type { TypeScriptExtraServiceScript } from '@volar/typescript';
import type ts from 'typescript';
import type { HTMLDocument } from 'vscode-html-languageservice';
import type { URI } from 'vscode-uri';
import type { PackageInfo } from '../importPackage.js';
import { getLanguageServerTypesDir } from '../utils.js';
import { astro2tsx } from './astro2tsx.js';
import type { AstroMetadata } from './parseAstro.js';
import { getAstroMetadata } from './parseAstro.js';
import { extractStylesheets } from './parseCSS.js';
import { parseHTML } from './parseHTML.js';
import { extractScriptTags } from './parseJS.js';
const decoratedHosts = new WeakSet<ts.LanguageServiceHost>();
export function addAstroTypes(
astroInstall: PackageInfo | undefined,
ts: typeof import('typescript'),
host: ts.LanguageServiceHost,
) {
if (decoratedHosts.has(host)) {
return;
}
decoratedHosts.add(host);
const getScriptFileNames = host.getScriptFileNames.bind(host);
const getCompilationSettings = host.getCompilationSettings.bind(host);
host.getScriptFileNames = () => {
const languageServerTypesDirectory = getLanguageServerTypesDir(ts);
const fileNames = getScriptFileNames();
const addedFileNames = [];
if (astroInstall) {
addedFileNames.push(
...['./env.d.ts', './astro-jsx.d.ts'].map((filePath) =>
ts.sys.resolvePath(path.resolve(astroInstall.directory, filePath)),
),
);
// If Astro version is < 4.0.8, add jsx-runtime-augment.d.ts to the files to fake `JSX` being available from "astro/jsx-runtime".
// TODO: Remove this once a majority of users are on Astro 4.0.8+, erika - 2023-12-28
if (
astroInstall.version.major < 4 ||
(astroInstall.version.major === 4 &&
astroInstall.version.minor === 0 &&
astroInstall.version.patch < 8)
) {
addedFileNames.push(
...['./jsx-runtime-augment.d.ts'].map((filePath) =>
ts.sys.resolvePath(path.resolve(languageServerTypesDirectory, filePath)),
),
// ... (145 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
- ../core/parseAstro.js
- ./astro2tsx.js
- ./importPackage.js
- ./parseCSS.js
- ./parseHTML.js
- ./parseJS.js
- ./utils.js
- language-core
- node:path
- types
- typescript
- typescript
- vscode-html-languageservice
- vscode-uri
Source
Frequently Asked Questions
What does index.ts do?
index.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 index.ts?
index.ts defines 2 function(s): addAstroTypes, getAstroLanguagePlugin.
What does index.ts depend on?
index.ts imports 14 module(s): ../core/parseAstro.js, ./astro2tsx.js, ./importPackage.js, ./parseCSS.js, ./parseHTML.js, ./parseJS.js, ./utils.js, language-core, and 6 more.
What files import index.ts?
index.ts is imported by 1 file(s): languageServerPlugin.ts.
Where is index.ts in the architecture?
index.ts is located at packages/language-tools/language-server/src/core/index.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