Vue Virtual TextDocument
An implementation of virtual filesystem for accessing blocks in a .vue
file as independent files.
Support
This package is part of VueDX project, maintained by Rahul Kadyan. You can 💖 sponsor him for continued development of this package and other VueDX tools.
npm add @vuedx/vue-virtual-textdocument
API
More info
Signature:
declare class AsyncDocumentStore<T> extends DocumentStore<T> {
constructor(resolve: (uri: string) => T | Promise<T | null> | null, normalize?: (uri: string) => string);
get(uri: string): T | null;
get(uri: string): Promise<T | null>;
}
Members:
Signature:
get(uri: string): T | null;
Parameter | Type | Description |
---|
uri | string | - |
Signature:
get(uri: string): Promise<T | null>;
Parameter | Type | Description |
---|
uri | string | - |
More info
Signature:
declare class DocumentStore<T> {
constructor(resolve: (uri: string) => T | null, normalize?: (uri: string) => string);
all(): string[];
delete(uri: string): boolean;
dispose(): void;
get(uri: string): T | null;
protected getNormalizedUri(uri: string): string;
has(uri: string): boolean;
protected map: Map<string, T>;
normalize: (uri: string) => string;
protected resolve: (uri: string) => T | null;
protected reverseUriMap: Map<string, string>;
set(uri: string, document: T): void;
}
Members:
Signature:
all(): string[];
Signature:
delete(uri: string): boolean;
Parameter | Type | Description |
---|
uri | string | - |
Signature:
dispose(): void;
Signature:
get(uri: string): T | null;
Parameter | Type | Description |
---|
uri | string | - |
Signature:
protected getNormalizedUri(uri: string): string;
Parameter | Type | Description |
---|
uri | string | - |
Signature:
has(uri: string): boolean;
Parameter | Type | Description |
---|
uri | string | - |
Signature:
set(uri: string, document: T): void;
Parameter | Type | Description |
---|
uri | string | - |
document | T | - |
More info
Signature:
declare class RenderFunctionTextDocument extends TransformedBlockTextDocument {
constructor(container: VueTextDocument, selector: Selector, transformed: TextDocument, source: TextDocument);
get ast(): CodegenResult['ast'] | undefined;
get contextCompletionsTriggerOffset(): number;
static create(options: CreateVirtualTextDocumentOptions): RenderFunctionTextDocument;
findExpression(offset: number, length: number): undefined | {
offset: number;
length: number;
};
protected generate(): string;
getAllGeneratedOffsetsAt(offset: number): undefined | Array<{
length: number;
offset: number;
}>;
getGeneratedOffsetAt(offset: number): undefined | {
length: number;
offset: number;
};
protected getKnownComponents(): Record<string, ComponentImport>;
getOriginalOffsetAt(offset: number): undefined | {
offset: number;
length: number;
};
isInGeneratedRange(offset: number): boolean;
isInTemplateIdentifierRange(offset: number): boolean;
get parserErrors(): CodegenResult['errors'];
get tagCompletionsTriggerOffset(): number;
toDisplayMappings(): string;
protected tryGenerate(): string;
}
Members:
Signature:
static create(options: CreateVirtualTextDocumentOptions): RenderFunctionTextDocument;
Signature:
findExpression(offset: number, length: number): undefined | {
offset: number;
length: number;
};
Parameter | Type | Description |
---|
offset | number | - |
length | number | - |
Signature:
protected generate(): string;
Signature:
getAllGeneratedOffsetsAt(offset: number): undefined | Array<{
length: number;
offset: number;
}>;
Parameter | Type | Description |
---|
offset | number | - |
Signature:
getGeneratedOffsetAt(offset: number): undefined | {
length: number;
offset: number;
};
Parameter | Type | Description |
---|
offset | number | - |
Signature:
protected getKnownComponents(): Record<string, ComponentImport>;
Signature:
getOriginalOffsetAt(offset: number): undefined | {
offset: number;
length: number;
};
Parameter | Type | Description |
---|
offset | number | - |
Signature:
isInGeneratedRange(offset: number): boolean;
Parameter | Type | Description |
---|
offset | number | - |
Signature:
isInTemplateIdentifierRange(offset: number): boolean;
Parameter | Type | Description |
---|
offset | number | - |
Signature:
toDisplayMappings(): string;
Signature:
protected tryGenerate(): string;
More info
Signature:
declare class TransformedBlockTextDocument extends VirtualTextDocument {
protected constructor(container: VueTextDocument, selector: Selector, transformed: TextDocument, source: TextDocument | VirtualTextDocument, _transform: (document: TransformedBlockTextDocument) => BlockTransformResult);
static create(options: CreateTransformedBlockTextDocumentOptions): TransformedBlockTextDocument;
protected refresh(): void;
transform(): BlockTransformResult;
tryGetGeneratedOffset(offset: number): number | undefined;
tryGetSourceOffset(offset: number): number | undefined;
}
Members:
Signature:
static create(options: CreateTransformedBlockTextDocumentOptions): TransformedBlockTextDocument;
Signature:
protected refresh(): void;
Signature:
transform(): BlockTransformResult;
Signature:
tryGetGeneratedOffset(offset: number): number | undefined;
Parameter | Type | Description |
---|
offset | number | - |
Signature:
tryGetSourceOffset(offset: number): number | undefined;
Parameter | Type | Description |
---|
offset | number | - |
More info
Signature:
declare class VirtualTextDocument extends ProxyTextDocument {
protected constructor(container: VueTextDocument, selector: Selector, doc: TextDocument);
readonly container: VueTextDocument;
static create(options: CreateVirtualTextDocumentOptions): VirtualTextDocument;
protected isDirty: boolean;
markDirty(): void;
protected refresh(): void;
readonly selector: Selector;
}
Members:
Signature:
static create(options: CreateVirtualTextDocumentOptions): VirtualTextDocument;
Signature:
markDirty(): void;
Signature:
protected refresh(): void;
More info
Signature:
declare class VueTextDocument extends ProxyTextDocument {
constructor(doc: TextDocument, options?: VueTextDocumentOptions, parseOptions?: SFCParseOptions);
all(): VirtualTextDocument[];
blockAt(position: Position | number): SFCBlock | null | undefined;
static create(uri: string, languageId: string, version: number, content: string, options?: VueTextDocumentOptions, parseOptions?: SFCParseOptions): VueTextDocument;
protected createBlockDocument(selector: BlockSelector): VirtualTextDocument | undefined;
protected createInternalModuleDocument(): TransformedBlockTextDocument;
protected createModuleDocument(): TransformedBlockTextDocument;
protected createRenderDocument(): RenderFunctionTextDocument;
protected createTemplateASTDocument(): TransformedBlockTextDocument;
get descriptor(): SFCDescriptor;
documentAt(position: Position | number): VirtualTextDocument | undefined;
getBlock(selector: BlockSelector): SFCBlock | null | undefined;
getBlockSelector(block: SFCBlock): BlockSelector | undefined;
getDocument(selector: typeof RENDER_SELECTOR): RenderFunctionTextDocument;
getDocument(selector: SelectorLike): VirtualTextDocument;
getDocument(selector: string): VirtualTextDocument | undefined;
getDocumentFileName(selectorLike: SelectorLike): string;
protected getDocumentId(selector: Selector): string;
protected getDocumentLanguage(selector: Selector): string;
markDirty(): void;
readonly options: VueTextDocumentOptions;
protected parse(): void;
static update(document: VueTextDocument, changes: TextDocumentContentChangeEvent[], version: number): VueTextDocument;
}
Members:
Signature:
all(): VirtualTextDocument[];
Signature:
blockAt(position: Position | number): SFCBlock | null | undefined;
Parameter | Type | Description |
---|
position | Position | number | - |
Signature:
static create(uri: string, languageId: string, version: number, content: string, options?: VueTextDocumentOptions, parseOptions?: SFCParseOptions): VueTextDocument;
Signature:
protected createBlockDocument(selector: BlockSelector): VirtualTextDocument | undefined;
Signature:
protected createInternalModuleDocument(): TransformedBlockTextDocument;
Signature:
protected createModuleDocument(): TransformedBlockTextDocument;
Signature:
protected createRenderDocument(): RenderFunctionTextDocument;
Signature:
protected createTemplateASTDocument(): TransformedBlockTextDocument;
Signature:
documentAt(position: Position | number): VirtualTextDocument | undefined;
Parameter | Type | Description |
---|
position | Position | number | - |
Signature:
getBlock(selector: BlockSelector): SFCBlock | null | undefined;
Signature:
getBlockSelector(block: SFCBlock): BlockSelector | undefined;
Signature:
getDocument(selector: typeof RENDER_SELECTOR): RenderFunctionTextDocument;
Signature:
getDocument(selector: SelectorLike): VirtualTextDocument;
Signature:
getDocument(selector: string): VirtualTextDocument | undefined;
Parameter | Type | Description |
---|
selector | string | - |
Signature:
getDocumentFileName(selectorLike: SelectorLike): string;
Signature:
protected getDocumentId(selector: Selector): string;
Parameter | Type | Description |
---|
selector | Selector | - |
Signature:
protected getDocumentLanguage(selector: Selector): string;
Parameter | Type | Description |
---|
selector | Selector | - |
Signature:
markDirty(): void;
Signature:
protected parse(): void;
Signature:
static update(document: VueTextDocument, changes: TextDocumentContentChangeEvent[], version: number): VueTextDocument;
More info
Signature:
declare function asFsPath(uri: string): string;
Parameter | Type | Description |
---|
uri | string | - |
More info
Signature:
declare function asFsUri(fileName: string): string;
Parameter | Type | Description |
---|
fileName | string | - |
More info
Signature:
declare function asUri(fileNameOrUri: string): string;
Parameter | Type | Description |
---|
fileNameOrUri | string | - |
More info
Signature:
declare function basename(fileName: string): string;
Parameter | Type | Description |
---|
fileName | string | - |
More info
Signature:
declare function binarySearch<T>(array: T[], isMatch: (a: T) => number, returnMin?: boolean): T | undefined;
Parameter | Type | Description |
---|
array | T[] | - |
isMatch | (a: T) => number | - |
returnMin | boolean | - |
More info
Signature:
declare function getBlockLanguage(block?: SFCBlock | null): string;
Parameter | Type | Description |
---|
block | SFCBlock | null | - |
More info
Signature:
declare function getContainingFile(fileName: string): string;
Parameter | Type | Description |
---|
fileName | string | - |
More info
Signature:
declare function getLanguageExtension(lang: string): string;
Parameter | Type | Description |
---|
lang | string | - |
More info
Signature:
declare function getLanguageIdFromExtension(ext: string): string;
Parameter | Type | Description |
---|
ext | string | - |
More info
Signature:
declare function isOffsetInBlock(offset: number, block?: SFCBlock | null): boolean;
Parameter | Type | Description |
---|
offset | number | - |
block | SFCBlock | null | - |
More info
Signature:
declare function isVirtualFile(fileName: string): boolean;
Parameter | Type | Description |
---|
fileName | string | - |
More info
Signature:
declare function isVirtualFileOfType(fileName: string, type: '_render' | '_module' | '_internal' | 'script' | 'scriptSetup'): boolean;
Parameter | Type | Description |
---|
fileName | string | - |
type | '_render' | '_module' | '_internal' | 'script' | 'scriptSetup' | - |
More info
Signature:
declare function isVueFile(fileName: string): boolean;
Parameter | Type | Description |
---|
fileName | string | - |
More info
Signature:
declare function parseVirtualFileName(fileName: string): {
uri: string;
selector: Selector;
} | null;
Parameter | Type | Description |
---|
fileName | string | - |
More info
Signature:
declare function relativeVirtualImportPath(fileName: string): string;
Parameter | Type | Description |
---|
fileName | string | - |
More info
Signature:
declare function replaceSlashes(fileName: string): string;
Parameter | Type | Description |
---|
fileName | string | - |