html.ts — astro Source File
Architecture documentation for html.ts, a typescript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d6917972_8d96_11d3_06c1_e3a1f8e8d585["html.ts"] 38342bd4_11df_7a37_2e70_333185fe2db2["../../core/index.js"] d6917972_8d96_11d3_06c1_e3a1f8e8d585 --> 38342bd4_11df_7a37_2e70_333185fe2db2 0753b470_ace8_8574_79bc_9613f801962c["./html-data.js"] d6917972_8d96_11d3_06c1_e3a1f8e8d585 --> 0753b470_ace8_8574_79bc_9613f801962c 89de2635_6169_bc8a_5f3b_51a713363774["../utils.js"] d6917972_8d96_11d3_06c1_e3a1f8e8d585 --> 89de2635_6169_bc8a_5f3b_51a713363774 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56["language-server"] d6917972_8d96_11d3_06c1_e3a1f8e8d585 --> 6857b6b2_4d48_bfb0_0a0e_8e2e52fabb56 e1ab4fe3_532a_4a05_e463_e765395b8c0f["volar-service-html"] d6917972_8d96_11d3_06c1_e3a1f8e8d585 --> e1ab4fe3_532a_4a05_e463_e765395b8c0f 4e2ee814_ff7b_a348_0e3a_6e6d7b34afb6["vscode-html-languageservice"] d6917972_8d96_11d3_06c1_e3a1f8e8d585 --> 4e2ee814_ff7b_a348_0e3a_6e6d7b34afb6 abeb339e_cdba_0d7f_6b7f_3696c1eb86f9["vscode-uri"] d6917972_8d96_11d3_06c1_e3a1f8e8d585 --> abeb339e_cdba_0d7f_6b7f_3696c1eb86f9 style d6917972_8d96_11d3_06c1_e3a1f8e8d585 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { LanguageServicePlugin, LanguageServicePluginInstance } from '@volar/language-server';
import { CompletionItemKind } from '@volar/language-server';
import { create as createHtmlService } from 'volar-service-html';
import * as html from 'vscode-html-languageservice';
import { URI, Utils } from 'vscode-uri';
import { AstroVirtualCode } from '../core/index.js';
import { astroAttributes, astroElements, classListAttribute } from './html-data.js';
import { isInComponentStartTag } from './utils.js';
export const create = (): LanguageServicePlugin => {
const htmlPlugin = createHtmlService({
getCustomData: async (context) => {
const customData: string[] = (await context.env.getConfiguration?.('html.customData')) ?? [];
const newData: html.IHTMLDataProvider[] = [];
for (const customDataPath of customData) {
for (const workspaceFolder of context.env.workspaceFolders) {
const uri = Utils.resolvePath(workspaceFolder, customDataPath);
const json = await context.env.fs?.readFile?.(uri);
if (json) {
try {
const data = JSON.parse(json);
newData.push(html.newHTMLDataProvider(customDataPath, data));
} catch (error) {
console.error(error);
}
break;
}
}
}
return [...newData, astroAttributes, astroElements, classListAttribute];
},
});
return {
...htmlPlugin,
create(context): LanguageServicePluginInstance {
const htmlPluginInstance = htmlPlugin.create(context);
return {
...htmlPluginInstance,
async provideCompletionItems(document, position, completionContext, token) {
if (document.languageId !== 'html') return;
const decoded = context.decodeEmbeddedDocumentUri(URI.parse(document.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
const root = sourceScript?.generated?.root;
if (!(root instanceof AstroVirtualCode)) return;
// Don't return completions if the current node is a component
if (isInComponentStartTag(root.htmlDocument, document.offsetAt(position))) {
return null;
}
const completions = await htmlPluginInstance.provideCompletionItems!(
document,
position,
completionContext,
token,
);
if (!completions) {
return null;
}
// We don't want completions for file references, as they're mostly invalid for Astro
completions.items = completions.items.filter(
(completion) => completion.kind !== CompletionItemKind.File,
);
return completions;
},
// Document links provided by `vscode-html-languageservice` are invalid for Astro
provideDocumentLinks() {
return [];
},
};
},
};
};
Domain
Subdomains
Functions
Dependencies
- ../../core/index.js
- ../utils.js
- ./html-data.js
- language-server
- volar-service-html
- vscode-html-languageservice
- vscode-uri
Source
Frequently Asked Questions
What does html.ts do?
html.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 html.ts?
html.ts defines 1 function(s): create.
What does html.ts depend on?
html.ts imports 7 module(s): ../../core/index.js, ../utils.js, ./html-data.js, language-server, volar-service-html, vscode-html-languageservice, vscode-uri.
Where is html.ts in the architecture?
html.ts is located at packages/language-tools/language-server/src/plugins/html.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/language-tools/language-server/src/plugins).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free