README
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
AsyncDocumentStore
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:
get
Signature:
get(uri: string): T | null;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
get
Signature:
get(uri: string): Promise<T | null>;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
DocumentStore
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:
all
Signature:
all(): string[];
delete
Signature:
delete(uri: string): boolean;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
dispose
Signature:
dispose(): void;
get
Signature:
get(uri: string): T | null;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
getNormalizedUri
Signature:
protected getNormalizedUri(uri: string): string;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
has
Signature:
has(uri: string): boolean;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
set
Signature:
set(uri: string, document: T): void;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
document | T |
- |
RenderFunctionTextDocument
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:
create
Signature:
static create(options: CreateVirtualTextDocumentOptions): RenderFunctionTextDocument;
Parameter | Type | Description |
---|---|---|
options | CreateVirtualTextDocumentOptions |
- |
findExpression
Signature:
findExpression(offset: number, length: number): undefined | {
offset: number;
length: number;
};
Parameter | Type | Description |
---|---|---|
offset | number |
- |
length | number |
- |
generate
Signature:
protected generate(): string;
getAllGeneratedOffsetsAt
Signature:
getAllGeneratedOffsetsAt(offset: number): undefined | Array<{
length: number;
offset: number;
}>;
Parameter | Type | Description |
---|---|---|
offset | number |
- |
getGeneratedOffsetAt
Signature:
getGeneratedOffsetAt(offset: number): undefined | {
length: number;
offset: number;
};
Parameter | Type | Description |
---|---|---|
offset | number |
- |
getKnownComponents
Signature:
protected getKnownComponents(): Record<string, ComponentImport>;
getOriginalOffsetAt
Signature:
getOriginalOffsetAt(offset: number): undefined | {
offset: number;
length: number;
};
Parameter | Type | Description |
---|---|---|
offset | number |
- |
isInGeneratedRange
Signature:
isInGeneratedRange(offset: number): boolean;
Parameter | Type | Description |
---|---|---|
offset | number |
- |
isInTemplateIdentifierRange
Signature:
isInTemplateIdentifierRange(offset: number): boolean;
Parameter | Type | Description |
---|---|---|
offset | number |
- |
toDisplayMappings
Signature:
toDisplayMappings(): string;
tryGenerate
Signature:
protected tryGenerate(): string;
TransformedBlockTextDocument
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:
create
Signature:
static create(options: CreateTransformedBlockTextDocumentOptions): TransformedBlockTextDocument;
Parameter | Type | Description |
---|---|---|
options | CreateTransformedBlockTextDocumentOptions |
- |
refresh
Signature:
protected refresh(): void;
transform
Signature:
transform(): BlockTransformResult;
tryGetGeneratedOffset
Signature:
tryGetGeneratedOffset(offset: number): number | undefined;
Parameter | Type | Description |
---|---|---|
offset | number |
- |
tryGetSourceOffset
Signature:
tryGetSourceOffset(offset: number): number | undefined;
Parameter | Type | Description |
---|---|---|
offset | number |
- |
VirtualTextDocument
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:
create
Signature:
static create(options: CreateVirtualTextDocumentOptions): VirtualTextDocument;
Parameter | Type | Description |
---|---|---|
options | CreateVirtualTextDocumentOptions |
- |
markDirty
Signature:
markDirty(): void;
refresh
Signature:
protected refresh(): void;
VueTextDocument
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:
all
Signature:
all(): VirtualTextDocument[];
blockAt
Signature:
blockAt(position: Position | number): SFCBlock | null | undefined;
Parameter | Type | Description |
---|---|---|
position | Position | number |
- |
create
Signature:
static create(uri: string, languageId: string, version: number, content: string, options?: VueTextDocumentOptions, parseOptions?: SFCParseOptions): VueTextDocument;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
languageId | string |
- |
version | number |
- |
content | string |
- |
options | VueTextDocumentOptions |
- |
parseOptions | SFCParseOptions |
- |
createBlockDocument
Signature:
protected createBlockDocument(selector: BlockSelector): VirtualTextDocument | undefined;
Parameter | Type | Description |
---|---|---|
selector | BlockSelector |
- |
createInternalModuleDocument
Signature:
protected createInternalModuleDocument(): TransformedBlockTextDocument;
createModuleDocument
Signature:
protected createModuleDocument(): TransformedBlockTextDocument;
createRenderDocument
Signature:
protected createRenderDocument(): RenderFunctionTextDocument;
createTemplateASTDocument
Signature:
protected createTemplateASTDocument(): TransformedBlockTextDocument;
documentAt
Signature:
documentAt(position: Position | number): VirtualTextDocument | undefined;
Parameter | Type | Description |
---|---|---|
position | Position | number |
- |
getBlock
Signature:
getBlock(selector: BlockSelector): SFCBlock | null | undefined;
Parameter | Type | Description |
---|---|---|
selector | BlockSelector |
- |
getBlockSelector
Signature:
getBlockSelector(block: SFCBlock): BlockSelector | undefined;
Parameter | Type | Description |
---|---|---|
block | SFCBlock |
- |
getDocument
Signature:
getDocument(selector: typeof RENDER_SELECTOR): RenderFunctionTextDocument;
Parameter | Type | Description |
---|---|---|
selector | typeof RENDER_SELECTOR |
- |
getDocument
Signature:
getDocument(selector: SelectorLike): VirtualTextDocument;
Parameter | Type | Description |
---|---|---|
selector | SelectorLike |
- |
getDocument
Signature:
getDocument(selector: string): VirtualTextDocument | undefined;
Parameter | Type | Description |
---|---|---|
selector | string |
- |
getDocumentFileName
Signature:
getDocumentFileName(selectorLike: SelectorLike): string;
Parameter | Type | Description |
---|---|---|
selectorLike | SelectorLike |
- |
getDocumentId
Signature:
protected getDocumentId(selector: Selector): string;
Parameter | Type | Description |
---|---|---|
selector | Selector |
- |
getDocumentLanguage
Signature:
protected getDocumentLanguage(selector: Selector): string;
Parameter | Type | Description |
---|---|---|
selector | Selector |
- |
markDirty
Signature:
markDirty(): void;
parse
Signature:
protected parse(): void;
update
Signature:
static update(document: VueTextDocument, changes: TextDocumentContentChangeEvent[], version: number): VueTextDocument;
Parameter | Type | Description |
---|---|---|
document | VueTextDocument |
- |
changes | TextDocumentContentChangeEvent[] |
- |
version | number |
- |
asFsPath
More info
Signature:
declare function asFsPath(uri: string): string;
Parameter | Type | Description |
---|---|---|
uri | string |
- |
asFsUri
More info
Signature:
declare function asFsUri(fileName: string): string;
Parameter | Type | Description |
---|---|---|
fileName | string |
- |
asUri
More info
Signature:
declare function asUri(fileNameOrUri: string): string;
Parameter | Type | Description |
---|---|---|
fileNameOrUri | string |
- |
basename
More info
Signature:
declare function basename(fileName: string): string;
Parameter | Type | Description |
---|---|---|
fileName | string |
- |
binarySearch
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 |
- |
getBlockLanguage
More info
Signature:
declare function getBlockLanguage(block?: SFCBlock | null): string;
Parameter | Type | Description |
---|---|---|
block | SFCBlock | null |
- |
getContainingFile
More info
Signature:
declare function getContainingFile(fileName: string): string;
Parameter | Type | Description |
---|---|---|
fileName | string |
- |
getLanguageExtension
More info
Signature:
declare function getLanguageExtension(lang: string): string;
Parameter | Type | Description |
---|---|---|
lang | string |
- |
getLanguageIdFromExtension
More info
Signature:
declare function getLanguageIdFromExtension(ext: string): string;
Parameter | Type | Description |
---|---|---|
ext | string |
- |
isOffsetInBlock
More info
Signature:
declare function isOffsetInBlock(offset: number, block?: SFCBlock | null): boolean;
Parameter | Type | Description |
---|---|---|
offset | number |
- |
block | SFCBlock | null |
- |
isVirtualFile
More info
Signature:
declare function isVirtualFile(fileName: string): boolean;
Parameter | Type | Description |
---|---|---|
fileName | string |
- |
isVirtualFileOfType
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' |
- |
isVueFile
More info
Signature:
declare function isVueFile(fileName: string): boolean;
Parameter | Type | Description |
---|---|---|
fileName | string |
- |
parseVirtualFileName
More info
Signature:
declare function parseVirtualFileName(fileName: string): {
uri: string;
selector: Selector;
} | null;
Parameter | Type | Description |
---|---|---|
fileName | string |
- |
relativeVirtualImportPath
More info
Signature:
declare function relativeVirtualImportPath(fileName: string): string;
Parameter | Type | Description |
---|---|---|
fileName | string |
- |
replaceSlashes
More info
Signature:
declare function replaceSlashes(fileName: string): string;
Parameter | Type | Description |
---|---|---|
fileName | string |
- |