@marko/language-server 0.12.17 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2071 -1567
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +2103 -1593
- package/dist/index.mjs.map +4 -4
- package/dist/service/marko/complete/AttrName.d.ts +2 -2
- package/dist/service/marko/complete/AttrValue.d.ts +2 -2
- package/dist/service/marko/complete/Import.d.ts +3 -0
- package/dist/service/marko/complete/OpenTagName.d.ts +2 -2
- package/dist/service/marko/complete/Tag.d.ts +2 -2
- package/dist/service/marko/complete/index.d.ts +5 -8
- package/dist/service/marko/definition/AttrName.d.ts +2 -2
- package/dist/service/marko/definition/OpenTagName.d.ts +2 -2
- package/dist/service/marko/definition/index.d.ts +5 -8
- package/dist/service/marko/hover/OpenTagName.d.ts +2 -2
- package/dist/service/marko/hover/index.d.ts +5 -8
- package/dist/service/marko/util/is-document-link-attr.d.ts +2 -3
- package/dist/service/script/index.d.ts +3 -0
- package/dist/service/types.d.ts +6 -4
- package/dist/ts-plugin/host.d.ts +5 -0
- package/dist/ts-plugin/index.d.ts +5 -0
- package/dist/utils/constants.d.ts +3 -0
- package/dist/utils/file.d.ts +21 -0
- package/dist/utils/get-component-filename.d.ts +2 -0
- package/dist/utils/get-runtime-types.d.ts +8 -0
- package/dist/utils/get-script-lang.d.ts +4 -0
- package/dist/utils/project.d.ts +11 -0
- package/dist/utils/text-documents.d.ts +10 -0
- package/dist/utils/workspace.d.ts +5 -0
- package/package.json +20 -16
- package/dist/service/marko/complete/Statement.d.ts +0 -3
- package/dist/service/stylesheet/extract.d.ts +0 -10
- package/dist/utils/compiler.d.ts +0 -21
- package/dist/utils/doc-file.d.ts +0 -3
- package/dist/utils/extractor.d.ts +0 -12
- package/dist/utils/get-node-at-offset.d.ts +0 -2
- package/dist/utils/parser.d.ts +0 -176
- package/dist/utils/utils.d.ts +0 -4
- /package/dist/service/{stylesheet → style}/index.d.ts +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Node } from "
|
|
1
|
+
import type { Node } from "@marko/language-tools";
|
|
2
2
|
import type { CompletionMeta, CompletionResult } from ".";
|
|
3
|
-
export declare function AttrName({ offset, node, parsed, lookup, }: CompletionMeta<Node.AttrName>): CompletionResult;
|
|
3
|
+
export declare function AttrName({ offset, node, file: { parsed, project: { lookup }, }, }: CompletionMeta<Node.AttrName>): CompletionResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CompletionItem } from "vscode-languageserver";
|
|
2
|
-
import type { Node } from "
|
|
2
|
+
import type { Node } from "@marko/language-tools";
|
|
3
3
|
import type { CompletionMeta } from ".";
|
|
4
|
-
export declare function AttrValue({
|
|
4
|
+
export declare function AttrValue({ offset, node, file: { uri, parsed, code }, }: CompletionMeta<Node.AttrValue>): Promise<void | CompletionItem[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type Node } from "
|
|
1
|
+
import { type Node } from "@marko/language-tools";
|
|
2
2
|
import type { CompletionMeta, CompletionResult } from ".";
|
|
3
|
-
export declare function OpenTagName({
|
|
3
|
+
export declare function OpenTagName({ node, file: { parsed, filename, project: { lookup }, }, }: CompletionMeta<Node.OpenTagName>): CompletionResult;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type Node } from "
|
|
1
|
+
import { type Node } from "@marko/language-tools";
|
|
2
2
|
import type { CompletionMeta, CompletionResult } from ".";
|
|
3
3
|
/**
|
|
4
4
|
* Provide completion for the closing tag.
|
|
5
5
|
*/
|
|
6
|
-
export declare function Tag(
|
|
6
|
+
export declare function Tag({ node, offset, file: { parsed, code }, }: CompletionMeta<Node.Tag>): CompletionResult;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import { getCompilerInfo, parse } from "../../../utils/compiler";
|
|
1
|
+
import type { CompletionItem, CompletionParams } from "vscode-languageserver";
|
|
2
|
+
import { MarkoFile } from "../../../utils/file";
|
|
4
3
|
import type { Plugin, Result } from "../../types";
|
|
5
|
-
export
|
|
6
|
-
export interface CompletionMeta<N = unknown>
|
|
7
|
-
|
|
4
|
+
export type CompletionResult = Result<CompletionItem[]>;
|
|
5
|
+
export interface CompletionMeta<N = unknown> {
|
|
6
|
+
file: MarkoFile;
|
|
8
7
|
params: CompletionParams;
|
|
9
|
-
parsed: ReturnType<typeof parse>;
|
|
10
8
|
offset: number;
|
|
11
|
-
code: string;
|
|
12
9
|
node: N;
|
|
13
10
|
}
|
|
14
11
|
export declare const doComplete: Plugin["doComplete"];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Node } from "@marko/language-tools";
|
|
2
2
|
import type { DefinitionMeta, DefinitionResult } from ".";
|
|
3
|
-
export declare function AttrName({
|
|
3
|
+
export declare function AttrName({ node, file: { parsed, project: { lookup }, }, }: DefinitionMeta<Node.AttrName>): DefinitionResult;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Node } from "
|
|
1
|
+
import { type Node } from "@marko/language-tools";
|
|
2
2
|
import type { DefinitionMeta, DefinitionResult } from ".";
|
|
3
|
-
export declare function OpenTagName({
|
|
3
|
+
export declare function OpenTagName({ node, file: { parsed, project: { lookup }, }, }: DefinitionMeta<Node.OpenTagName>): DefinitionResult;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import { getCompilerInfo, parse } from "../../../utils/compiler";
|
|
1
|
+
import type { DefinitionLink, DefinitionParams } from "vscode-languageserver";
|
|
2
|
+
import { MarkoFile } from "../../../utils/file";
|
|
4
3
|
import type { Plugin, Result } from "../../types";
|
|
5
|
-
export
|
|
6
|
-
export interface DefinitionMeta<N = unknown>
|
|
7
|
-
|
|
4
|
+
export type DefinitionResult = Result<DefinitionLink[]>;
|
|
5
|
+
export interface DefinitionMeta<N = unknown> {
|
|
6
|
+
file: MarkoFile;
|
|
8
7
|
params: DefinitionParams;
|
|
9
|
-
parsed: ReturnType<typeof parse>;
|
|
10
8
|
offset: number;
|
|
11
|
-
code: string;
|
|
12
9
|
node: N;
|
|
13
10
|
}
|
|
14
11
|
export declare const findDefinition: Plugin["findDefinition"];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Node } from "
|
|
1
|
+
import type { Node } from "@marko/language-tools";
|
|
2
2
|
import type { HoverMeta, HoverResult } from ".";
|
|
3
|
-
export declare function OpenTagName({
|
|
3
|
+
export declare function OpenTagName({ node, file: { parsed, filename, project: { lookup }, }, }: HoverMeta<Node.OpenTagName>): HoverResult;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import { getCompilerInfo, parse } from "../../../utils/compiler";
|
|
1
|
+
import type { Hover, HoverParams } from "vscode-languageserver";
|
|
2
|
+
import { MarkoFile } from "../../../utils/file";
|
|
4
3
|
import type { Plugin, Result } from "../../types";
|
|
5
|
-
export
|
|
6
|
-
export interface HoverMeta<N = unknown>
|
|
7
|
-
|
|
4
|
+
export type HoverResult = Result<Hover>;
|
|
5
|
+
export interface HoverMeta<N = unknown> {
|
|
6
|
+
file: MarkoFile;
|
|
8
7
|
params: HoverParams;
|
|
9
|
-
parsed: ReturnType<typeof parse>;
|
|
10
8
|
offset: number;
|
|
11
|
-
code: string;
|
|
12
9
|
node: N;
|
|
13
10
|
}
|
|
14
11
|
export declare const doHover: Plugin["doHover"];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export default function isDocumentLinkAttr(doc: TextDocument, tag: Node.ParentTag, attr: Node.AttrNode): attr is Node.AttrNamed & {
|
|
1
|
+
import { type Node } from "@marko/language-tools";
|
|
2
|
+
export default function isDocumentLinkAttr(code: string, tag: Node.ParentTag, attr: Node.AttrNode): attr is Node.AttrNamed & {
|
|
4
3
|
value: Node.AttrValue;
|
|
5
4
|
};
|
package/dist/service/types.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { CancellationToken, CodeAction, CodeActionParams, ColorInformation, ColorPresentation, ColorPresentationParams, Command, CompletionItem, CompletionList, CompletionParams, DefinitionParams, Diagnostic, DocumentColorParams, DocumentFormattingParams, DocumentHighlight, DocumentHighlightParams, DocumentLink, DocumentLinkParams, DocumentSymbolParams, Hover, HoverParams, InitializeParams, Location, LocationLink, ReferenceParams, RenameParams, SymbolInformation, TextEdit, WorkspaceEdit } from "vscode-languageserver";
|
|
1
|
+
import type { CancellationToken, CodeAction, CodeActionParams, ColorInformation, ColorPresentation, ColorPresentationParams, Command, CompletionItem, CompletionList, CompletionParams, DefinitionParams, Diagnostic, DocumentColorParams, DocumentFormattingParams, DocumentHighlight, DocumentHighlightParams, DocumentLink, DocumentLinkParams, DocumentSymbolParams, GenericRequestHandler, Hover, HoverParams, InitializeParams, Location, LocationLink, ReferenceParams, RenameParams, SymbolInformation, TextEdit, WorkspaceEdit } from "vscode-languageserver";
|
|
2
2
|
import type { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
export type Result<V> = Promise<V | void> | V | void;
|
|
4
|
+
type Handler<P, R> = (doc: TextDocument, params: P extends null ? CancellationToken : P, token: P extends null ? never : CancellationToken) => Result<R>;
|
|
5
|
+
export type Plugin = {
|
|
6
|
+
commands: Record<string, GenericRequestHandler<any, any>>;
|
|
6
7
|
initialize: (params: InitializeParams) => Promise<void> | void;
|
|
7
8
|
doComplete: Handler<CompletionParams, CompletionItem[] | CompletionList>;
|
|
9
|
+
doCompletionResolve: (item: CompletionItem, token: CancellationToken) => Result<CompletionItem>;
|
|
8
10
|
doValidate: (doc: TextDocument) => Result<Diagnostic[]>;
|
|
9
11
|
doHover: Handler<HoverParams, Hover>;
|
|
10
12
|
doRename: Handler<RenameParams, WorkspaceEdit>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Extracted, ScriptLang } from "@marko/language-tools";
|
|
2
|
+
export interface ExtractedSnapshot extends Extracted {
|
|
3
|
+
snapshot: ts.IScriptSnapshot;
|
|
4
|
+
}
|
|
5
|
+
export declare function patch(ts: typeof import("typescript/lib/tsserverlibrary"), scriptLang: ScriptLang, cache: Map<string, ExtractedSnapshot>, host: ts.LanguageServiceHost): import("typescript/lib/tsserverlibrary").LanguageServiceHost;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TextDocument } from "vscode-languageserver-textdocument";
|
|
2
|
+
import { type Parsed } from "@marko/language-tools";
|
|
3
|
+
import { MarkoProject } from "./project";
|
|
4
|
+
export interface MarkoFile {
|
|
5
|
+
project: MarkoProject;
|
|
6
|
+
uri: string;
|
|
7
|
+
scheme: string;
|
|
8
|
+
version: number;
|
|
9
|
+
filename: string;
|
|
10
|
+
dirname: string;
|
|
11
|
+
parsed: Parsed;
|
|
12
|
+
code: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getFSDir(doc: TextDocument): string | undefined;
|
|
15
|
+
export declare function getFSPath(doc: TextDocument): string | undefined;
|
|
16
|
+
export declare function getMarkoFile(doc: TextDocument): MarkoFile;
|
|
17
|
+
/**
|
|
18
|
+
* Run some processing against a parsed document and cache the result.
|
|
19
|
+
* Anytime the document changes, the cache is cleared.
|
|
20
|
+
*/
|
|
21
|
+
export declare function processDoc<T>(doc: TextDocument, process: (file: MarkoFile) => T): T;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LanguageServiceHost } from "typescript/lib/tsserverlibrary";
|
|
2
|
+
import type TS from "typescript/lib/tsserverlibrary";
|
|
3
|
+
import type { MarkoProject } from "./project";
|
|
4
|
+
export default function getProjectTypeLibs(project: MarkoProject, ts: typeof TS, host: LanguageServiceHost): {
|
|
5
|
+
internalTypesFile: string;
|
|
6
|
+
markoTypesFile: string;
|
|
7
|
+
markoTypesCode: string;
|
|
8
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ScriptLang } from "@marko/language-tools";
|
|
2
|
+
import type { LanguageServiceHost } from "typescript/lib/tsserverlibrary";
|
|
3
|
+
import type TS from "typescript/lib/tsserverlibrary";
|
|
4
|
+
export default function getScriptLang(filename: string, ts: typeof TS, host: LanguageServiceHost, projectScriptLang: ScriptLang): ScriptLang;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TaglibLookup } from "@marko/babel-utils";
|
|
2
|
+
import * as defaultCompiler from "@marko/compiler";
|
|
3
|
+
export type MarkoProject = {
|
|
4
|
+
rootDir: string;
|
|
5
|
+
cache: Map<unknown, unknown>;
|
|
6
|
+
lookup: TaglibLookup;
|
|
7
|
+
compiler: typeof import("@marko/compiler");
|
|
8
|
+
translator: defaultCompiler.Config["translator"];
|
|
9
|
+
};
|
|
10
|
+
export declare function getMarkoProject(dir?: string): MarkoProject;
|
|
11
|
+
export declare function getMarkoProjects(): Set<MarkoProject>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Connection } from "vscode-languageserver";
|
|
2
|
+
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
|
+
export type FileChangeHandler = (document: TextDocument | undefined) => void;
|
|
4
|
+
export declare let projectVersion: number;
|
|
5
|
+
export declare function onFileChange(handler: FileChangeHandler): void;
|
|
6
|
+
export declare function getAllOpen(): Set<TextDocument>;
|
|
7
|
+
export declare function get(uri: string): TextDocument | undefined;
|
|
8
|
+
export declare function exists(uri: string): boolean;
|
|
9
|
+
export declare function isOpen(doc: TextDocument): boolean;
|
|
10
|
+
export declare function setup(connection: Connection): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Connection } from "vscode-languageserver";
|
|
2
|
+
export declare function getConfig<T = any>(section: string): Promise<T>;
|
|
3
|
+
export type ConfigChangeHandler = () => void;
|
|
4
|
+
export declare function onConfigChange(handler: ConfigChangeHandler): void;
|
|
5
|
+
export declare function setup(_: Connection): void;
|
package/package.json
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-server",
|
|
3
3
|
"description": "Marko Language Server",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"bin": {
|
|
6
6
|
"marko-language-server": "./bin.js"
|
|
7
7
|
},
|
|
8
8
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@
|
|
11
|
-
"@marko/
|
|
12
|
-
"@marko/
|
|
13
|
-
"
|
|
10
|
+
"@babel/helper-validator-identifier": "^7.19.1",
|
|
11
|
+
"@marko/language-tools": "^1.0.0",
|
|
12
|
+
"@marko/babel-utils": "^5.21.4",
|
|
13
|
+
"@marko/compiler": "^5.23.6",
|
|
14
|
+
"@marko/translator-default": "^5.22.6",
|
|
15
|
+
"htmljs-parser": "^5.3.0",
|
|
14
16
|
"lasso-package-root": "^1.0.1",
|
|
15
|
-
"marko": "^5.
|
|
16
|
-
"prettier": "^2.
|
|
17
|
-
"prettier-plugin-marko": "^1.2.
|
|
17
|
+
"marko": "^5.22.8",
|
|
18
|
+
"prettier": "^2.8.4",
|
|
19
|
+
"prettier-plugin-marko": "^1.2.3",
|
|
20
|
+
"relative-import-path": "^1.0.0",
|
|
18
21
|
"resolve-from": "^5.0.0",
|
|
19
|
-
"
|
|
20
|
-
"vscode-
|
|
21
|
-
"vscode-languageserver
|
|
22
|
-
"vscode-
|
|
22
|
+
"typescript": "^4.9.5",
|
|
23
|
+
"vscode-css-languageservice": "^6.2.4",
|
|
24
|
+
"vscode-languageserver": "^8.1.0",
|
|
25
|
+
"vscode-languageserver-textdocument": "^1.0.8",
|
|
26
|
+
"vscode-uri": "^3.0.7"
|
|
23
27
|
},
|
|
24
28
|
"devDependencies": {
|
|
25
|
-
"@types/prettier": "^2.
|
|
26
|
-
"tsx": "^3.
|
|
29
|
+
"@types/prettier": "^2.7.2",
|
|
30
|
+
"tsx": "^3.12.3"
|
|
27
31
|
},
|
|
28
32
|
"exports": {
|
|
29
33
|
".": {
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
"!**/__tests__",
|
|
37
41
|
"!**/*.tsbuildinfo"
|
|
38
42
|
],
|
|
39
|
-
"homepage": "https://github.com/marko-js/language-server/tree/
|
|
43
|
+
"homepage": "https://github.com/marko-js/language-server/tree/main/packages/language-server/README.md",
|
|
40
44
|
"keywords": [
|
|
41
45
|
"autocomplete",
|
|
42
46
|
"intellisense",
|
|
@@ -49,7 +53,7 @@
|
|
|
49
53
|
"module": "./dist/index.mjs",
|
|
50
54
|
"repository": {
|
|
51
55
|
"type": "git",
|
|
52
|
-
"url": "https://github.com/marko-js/language-server/tree/
|
|
56
|
+
"url": "https://github.com/marko-js/language-server/tree/main/packages/language-server"
|
|
53
57
|
},
|
|
54
58
|
"scripts": {
|
|
55
59
|
"build": "tsc -b && tsx build.mts"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TaglibLookup } from "@marko/babel-utils";
|
|
2
|
-
import { Node } from "../../utils/parser";
|
|
3
|
-
/**
|
|
4
|
-
* Iterate over the Marko CST and extract all the stylesheets.
|
|
5
|
-
*/
|
|
6
|
-
export declare function extractStyleSheets(code: string, program: Node.Program, lookup: TaglibLookup): Record<string, {
|
|
7
|
-
generated: string;
|
|
8
|
-
sourceOffsetAt(generatedOffset: number): number | undefined;
|
|
9
|
-
generatedOffsetAt(sourceOffset: number): number | undefined;
|
|
10
|
-
}>;
|
package/dist/utils/compiler.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { TextDocument } from "vscode-languageserver-textdocument";
|
|
2
|
-
import type { AttributeDefinition, TagDefinition, TaglibLookup } from "@marko/babel-utils";
|
|
3
|
-
import * as builtinCompiler from "@marko/compiler";
|
|
4
|
-
import * as parser from "./parser";
|
|
5
|
-
export declare type Compiler = typeof import("@marko/compiler");
|
|
6
|
-
export { AttributeDefinition, TagDefinition, TaglibLookup };
|
|
7
|
-
export declare type CompilerInfo = {
|
|
8
|
-
cache: Map<unknown, unknown>;
|
|
9
|
-
lookup: TaglibLookup;
|
|
10
|
-
compiler: Compiler;
|
|
11
|
-
translator: builtinCompiler.Config["translator"];
|
|
12
|
-
};
|
|
13
|
-
export declare function parse(doc: TextDocument): {
|
|
14
|
-
read: (range: parser.Range) => string;
|
|
15
|
-
locationAt: (range: parser.Range) => import("htmljs-parser").Location;
|
|
16
|
-
positionAt: (offset: number) => import("htmljs-parser").Position;
|
|
17
|
-
nodeAt: (offset: number) => parser.Node.AnyNode;
|
|
18
|
-
program: parser.Node.Program;
|
|
19
|
-
};
|
|
20
|
-
export declare function getCompilerInfo(doc: TextDocument): CompilerInfo;
|
|
21
|
-
export declare function clearCompilerCache(doc?: TextDocument): void;
|
package/dist/utils/doc-file.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Range } from "./parser";
|
|
2
|
-
/**
|
|
3
|
-
* Utility to build up generate code from source ranges while maintaining a source mapping.
|
|
4
|
-
*/
|
|
5
|
-
export declare function createExtractor(code: string): {
|
|
6
|
-
write(strs: TemplateStringsArray, ...exprs: (string | Range)[]): void;
|
|
7
|
-
end(): {
|
|
8
|
-
generated: string;
|
|
9
|
-
sourceOffsetAt(generatedOffset: number): number | undefined;
|
|
10
|
-
generatedOffsetAt(sourceOffset: number): number | undefined;
|
|
11
|
-
};
|
|
12
|
-
};
|
package/dist/utils/parser.d.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { TagType, Range, Ranges } from "htmljs-parser";
|
|
2
|
-
export { Range, Ranges };
|
|
3
|
-
export declare const UNFINISHED: number;
|
|
4
|
-
export declare enum NodeType {
|
|
5
|
-
Program = 0,
|
|
6
|
-
Tag = 1,
|
|
7
|
-
OpenTagName = 2,
|
|
8
|
-
ShorthandId = 3,
|
|
9
|
-
ShorthandClassName = 4,
|
|
10
|
-
TagVar = 5,
|
|
11
|
-
TagArgs = 6,
|
|
12
|
-
TagParams = 7,
|
|
13
|
-
AttrNamed = 8,
|
|
14
|
-
AttrName = 9,
|
|
15
|
-
AttrArgs = 10,
|
|
16
|
-
AttrValue = 11,
|
|
17
|
-
AttrMethod = 12,
|
|
18
|
-
AttrSpread = 13,
|
|
19
|
-
AttrTag = 14,
|
|
20
|
-
Text = 15,
|
|
21
|
-
CDATA = 16,
|
|
22
|
-
Doctype = 17,
|
|
23
|
-
Declaration = 18,
|
|
24
|
-
Comment = 19,
|
|
25
|
-
Statement = 20,
|
|
26
|
-
Placeholder = 21,
|
|
27
|
-
Scriptlet = 22
|
|
28
|
-
}
|
|
29
|
-
export declare namespace Node {
|
|
30
|
-
type AnyNode = Program | Tag | OpenTagName | ShorthandId | ShorthandClassName | TagVar | TagArgs | TagParams | AttrNamed | AttrName | AttrArgs | AttrValue | AttrMethod | AttrSpread | AttrTag | Text | CDATA | Doctype | Declaration | Comment | Statement | Placeholder | Scriptlet;
|
|
31
|
-
type ParentNode = Program | Tag | AttrTag;
|
|
32
|
-
type StaticNode = Comment | Statement;
|
|
33
|
-
type ParentTag = Tag | AttrTag;
|
|
34
|
-
type AttrNode = AttrNamed | AttrSpread | AttrTag;
|
|
35
|
-
type ChildNode = Tag | AttrTag | Text | Doctype | Declaration | CDATA | Comment | Placeholder | Scriptlet;
|
|
36
|
-
interface Program extends Range {
|
|
37
|
-
type: NodeType.Program;
|
|
38
|
-
parent: undefined;
|
|
39
|
-
static: StaticNode[];
|
|
40
|
-
body: ChildNode[];
|
|
41
|
-
}
|
|
42
|
-
interface Tag extends Range {
|
|
43
|
-
type: NodeType.Tag;
|
|
44
|
-
parent: ParentNode;
|
|
45
|
-
owner: undefined;
|
|
46
|
-
concise: boolean;
|
|
47
|
-
open: Range;
|
|
48
|
-
close: Range | undefined;
|
|
49
|
-
nameText: string | undefined;
|
|
50
|
-
bodyType: Exclude<TagType, "statement">;
|
|
51
|
-
name: OpenTagName;
|
|
52
|
-
var: TagVar | undefined;
|
|
53
|
-
args: TagArgs | undefined;
|
|
54
|
-
params: TagParams | undefined;
|
|
55
|
-
shorthandId: ShorthandId | undefined;
|
|
56
|
-
shorthandClassNames: ShorthandClassName[] | undefined;
|
|
57
|
-
attrs: AttrNode[] | undefined;
|
|
58
|
-
selfClosed: boolean;
|
|
59
|
-
body: undefined | ChildNode[];
|
|
60
|
-
}
|
|
61
|
-
interface AttrTag extends Range {
|
|
62
|
-
type: NodeType.AttrTag;
|
|
63
|
-
parent: ParentTag;
|
|
64
|
-
owner: ParentTag | undefined;
|
|
65
|
-
concise: boolean;
|
|
66
|
-
open: Range;
|
|
67
|
-
close: Range | undefined;
|
|
68
|
-
nameText: string | undefined;
|
|
69
|
-
bodyType: TagType.html;
|
|
70
|
-
name: OpenTagName;
|
|
71
|
-
var: TagVar | undefined;
|
|
72
|
-
args: TagArgs | undefined;
|
|
73
|
-
params: TagParams | undefined;
|
|
74
|
-
shorthandId: ShorthandId | undefined;
|
|
75
|
-
shorthandClassNames: ShorthandClassName[] | undefined;
|
|
76
|
-
attrs: AttrNode[] | undefined;
|
|
77
|
-
selfClosed: boolean;
|
|
78
|
-
body: undefined | ChildNode[];
|
|
79
|
-
}
|
|
80
|
-
interface OpenTagName extends Ranges.Template {
|
|
81
|
-
type: NodeType.OpenTagName;
|
|
82
|
-
parent: ParentTag;
|
|
83
|
-
}
|
|
84
|
-
interface ShorthandId extends Ranges.Template {
|
|
85
|
-
type: NodeType.ShorthandId;
|
|
86
|
-
parent: ParentTag;
|
|
87
|
-
}
|
|
88
|
-
interface ShorthandClassName extends Ranges.Template {
|
|
89
|
-
type: NodeType.ShorthandClassName;
|
|
90
|
-
parent: ParentTag;
|
|
91
|
-
}
|
|
92
|
-
interface TagVar extends Ranges.Value {
|
|
93
|
-
type: NodeType.TagVar;
|
|
94
|
-
parent: ParentTag;
|
|
95
|
-
}
|
|
96
|
-
interface TagArgs extends Ranges.Value {
|
|
97
|
-
type: NodeType.TagArgs;
|
|
98
|
-
parent: ParentTag;
|
|
99
|
-
}
|
|
100
|
-
interface TagParams extends Ranges.Value {
|
|
101
|
-
type: NodeType.TagParams;
|
|
102
|
-
parent: ParentTag;
|
|
103
|
-
}
|
|
104
|
-
interface Statement extends Range {
|
|
105
|
-
type: NodeType.Statement;
|
|
106
|
-
parent: ParentNode;
|
|
107
|
-
}
|
|
108
|
-
interface Text extends Range {
|
|
109
|
-
type: NodeType.Text;
|
|
110
|
-
parent: ParentNode;
|
|
111
|
-
}
|
|
112
|
-
interface CDATA extends Ranges.Value {
|
|
113
|
-
type: NodeType.CDATA;
|
|
114
|
-
parent: ParentNode;
|
|
115
|
-
}
|
|
116
|
-
interface Doctype extends Ranges.Value {
|
|
117
|
-
type: NodeType.Doctype;
|
|
118
|
-
parent: ParentNode;
|
|
119
|
-
}
|
|
120
|
-
interface Declaration extends Ranges.Value {
|
|
121
|
-
type: NodeType.Declaration;
|
|
122
|
-
parent: ParentNode;
|
|
123
|
-
}
|
|
124
|
-
interface Comment extends Ranges.Value {
|
|
125
|
-
type: NodeType.Comment;
|
|
126
|
-
parent: ParentNode;
|
|
127
|
-
}
|
|
128
|
-
interface Placeholder extends Ranges.Value {
|
|
129
|
-
type: NodeType.Placeholder;
|
|
130
|
-
parent: ParentNode;
|
|
131
|
-
escape: boolean;
|
|
132
|
-
}
|
|
133
|
-
interface Scriptlet extends Ranges.Value {
|
|
134
|
-
type: NodeType.Scriptlet;
|
|
135
|
-
parent: ParentNode;
|
|
136
|
-
block: boolean;
|
|
137
|
-
}
|
|
138
|
-
interface AttrNamed extends Range {
|
|
139
|
-
type: NodeType.AttrNamed;
|
|
140
|
-
parent: ParentTag;
|
|
141
|
-
name: AttrName;
|
|
142
|
-
args: undefined | AttrArgs;
|
|
143
|
-
value: undefined | AttrValue | AttrMethod;
|
|
144
|
-
}
|
|
145
|
-
interface AttrName extends Range {
|
|
146
|
-
type: NodeType.AttrName;
|
|
147
|
-
parent: AttrNamed;
|
|
148
|
-
}
|
|
149
|
-
interface AttrArgs extends Ranges.Value {
|
|
150
|
-
type: NodeType.AttrArgs;
|
|
151
|
-
parent: AttrNamed;
|
|
152
|
-
}
|
|
153
|
-
interface AttrValue extends Range {
|
|
154
|
-
type: NodeType.AttrValue;
|
|
155
|
-
parent: AttrNamed;
|
|
156
|
-
value: Range;
|
|
157
|
-
bound: boolean;
|
|
158
|
-
}
|
|
159
|
-
interface AttrMethod extends Range {
|
|
160
|
-
type: NodeType.AttrMethod;
|
|
161
|
-
parent: AttrNamed;
|
|
162
|
-
params: Range;
|
|
163
|
-
body: Range;
|
|
164
|
-
}
|
|
165
|
-
interface AttrSpread extends Ranges.Value {
|
|
166
|
-
type: NodeType.AttrSpread;
|
|
167
|
-
parent: ParentTag;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
export declare function parse(source: string): {
|
|
171
|
-
read: (range: Range) => string;
|
|
172
|
-
locationAt: (range: Range) => import("htmljs-parser").Location;
|
|
173
|
-
positionAt: (offset: number) => import("htmljs-parser").Position;
|
|
174
|
-
nodeAt: (offset: number) => Node.AnyNode;
|
|
175
|
-
program: Node.Program;
|
|
176
|
-
};
|
package/dist/utils/utils.d.ts
DELETED
|
File without changes
|