shiki 3.2.1 → 3.3.0
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/bundle-full.d.mts +6 -5
- package/dist/bundle-web.d.mts +6 -5
- package/dist/core-unwasm.mjs +3 -0
- package/dist/core.d.mts +1 -0
- package/dist/index.d.mts +2 -75
- package/dist/langs.d.mts +2 -1
- package/dist/textmate.d.mts +1 -711
- package/dist/themes.d.mts +3 -2
- package/dist/types.d.mts +4 -2
- package/package.json +11 -11
- package/dist/types/index.d.d.mts +0 -335
package/dist/bundle-full.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as hast from 'hast';
|
|
2
2
|
import * as _shikijs_types from '@shikijs/types';
|
|
3
3
|
import { HighlighterGeneric } from '@shikijs/types';
|
|
4
4
|
import { BundledLanguage } from './langs.mjs';
|
|
@@ -20,11 +20,12 @@ type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>;
|
|
|
20
20
|
*/
|
|
21
21
|
declare const createHighlighter: _shikijs_types.CreateHighlighterFactory<BundledLanguage, BundledTheme>;
|
|
22
22
|
declare const codeToHtml: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<string>;
|
|
23
|
-
declare const codeToHast: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<Root>;
|
|
23
|
+
declare const codeToHast: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<hast.Root>;
|
|
24
24
|
declare const codeToTokens: (code: string, options: _shikijs_types.CodeToTokensOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.TokensResult>;
|
|
25
|
-
declare const codeToTokensBase: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>, "
|
|
25
|
+
declare const codeToTokensBase: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>, "theme" | "lang">) => Promise<_shikijs_types.ThemedToken[][]>;
|
|
26
26
|
declare const codeToTokensWithThemes: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensWithThemesOptions<BundledLanguage, BundledTheme>, "lang" | "themes">) => Promise<_shikijs_types.ThemedTokenWithVariants[][]>;
|
|
27
27
|
declare const getSingletonHighlighter: (options?: Partial<_shikijs_types.BundledHighlighterOptions<BundledLanguage, BundledTheme>> | undefined) => Promise<HighlighterGeneric<BundledLanguage, BundledTheme>>;
|
|
28
|
-
declare const getLastGrammarState: ((element: _shikijs_types.ThemedToken[][] | Root) => _shikijs_types.GrammarState) | ((code: string, options: _shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.GrammarState>);
|
|
28
|
+
declare const getLastGrammarState: ((element: _shikijs_types.ThemedToken[][] | hast.Root) => _shikijs_types.GrammarState) | ((code: string, options: _shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.GrammarState>);
|
|
29
29
|
|
|
30
|
-
export { BundledLanguage, BundledTheme,
|
|
30
|
+
export { BundledLanguage, BundledTheme, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
|
|
31
|
+
export type { Highlighter };
|
package/dist/bundle-web.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as hast from 'hast';
|
|
2
2
|
import * as _shikijs_types from '@shikijs/types';
|
|
3
3
|
import { BundledLanguageInfo, DynamicImportLanguageRegistration, HighlighterGeneric } from '@shikijs/types';
|
|
4
4
|
import { BundledTheme } from './themes.mjs';
|
|
@@ -28,11 +28,12 @@ type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>;
|
|
|
28
28
|
*/
|
|
29
29
|
declare const createHighlighter: _shikijs_types.CreateHighlighterFactory<BundledLanguage, BundledTheme>;
|
|
30
30
|
declare const codeToHtml: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<string>;
|
|
31
|
-
declare const codeToHast: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<Root>;
|
|
32
|
-
declare const codeToTokensBase: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>, "
|
|
31
|
+
declare const codeToHast: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<hast.Root>;
|
|
32
|
+
declare const codeToTokensBase: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>, "theme" | "lang">) => Promise<_shikijs_types.ThemedToken[][]>;
|
|
33
33
|
declare const codeToTokens: (code: string, options: _shikijs_types.CodeToTokensOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.TokensResult>;
|
|
34
34
|
declare const codeToTokensWithThemes: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensWithThemesOptions<BundledLanguage, BundledTheme>, "lang" | "themes">) => Promise<_shikijs_types.ThemedTokenWithVariants[][]>;
|
|
35
35
|
declare const getSingletonHighlighter: (options?: Partial<_shikijs_types.BundledHighlighterOptions<BundledLanguage, BundledTheme>> | undefined) => Promise<HighlighterGeneric<BundledLanguage, BundledTheme>>;
|
|
36
|
-
declare const getLastGrammarState: ((element: _shikijs_types.ThemedToken[][] | Root) => _shikijs_types.GrammarState) | ((code: string, options: _shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.GrammarState>);
|
|
36
|
+
declare const getLastGrammarState: ((element: _shikijs_types.ThemedToken[][] | hast.Root) => _shikijs_types.GrammarState) | ((code: string, options: _shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.GrammarState>);
|
|
37
37
|
|
|
38
|
-
export {
|
|
38
|
+
export { BundledTheme, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
|
|
39
|
+
export type { BundledLanguage, Highlighter };
|
package/dist/core-unwasm.mjs
CHANGED
package/dist/core.d.mts
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,83 +1,10 @@
|
|
|
1
1
|
export { Highlighter, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter } from './bundle-full.mjs';
|
|
2
2
|
export { BuiltinLanguage, BuiltinTheme } from './types.mjs';
|
|
3
3
|
export { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
|
|
4
|
+
export { createOnigurumaEngine, loadWasm } from '@shikijs/engine-oniguruma';
|
|
4
5
|
export * from '@shikijs/core';
|
|
5
6
|
export { BundledLanguage, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
|
|
6
7
|
export { BundledTheme, bundledThemes, bundledThemesInfo } from './themes.mjs';
|
|
7
|
-
import '
|
|
8
|
+
import 'hast';
|
|
8
9
|
import '@shikijs/types';
|
|
9
10
|
import '@shikijs/core/types';
|
|
10
|
-
|
|
11
|
-
interface IOnigCaptureIndex {
|
|
12
|
-
start: number;
|
|
13
|
-
end: number;
|
|
14
|
-
length: number;
|
|
15
|
-
}
|
|
16
|
-
interface IOnigMatch {
|
|
17
|
-
index: number;
|
|
18
|
-
captureIndices: IOnigCaptureIndex[];
|
|
19
|
-
}
|
|
20
|
-
declare const enum FindOption {
|
|
21
|
-
None = 0,
|
|
22
|
-
/**
|
|
23
|
-
* equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
|
|
24
|
-
*/
|
|
25
|
-
NotBeginString = 1,
|
|
26
|
-
/**
|
|
27
|
-
* equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
|
|
28
|
-
*/
|
|
29
|
-
NotEndString = 2,
|
|
30
|
-
/**
|
|
31
|
-
* equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
|
|
32
|
-
*/
|
|
33
|
-
NotBeginPosition = 4,
|
|
34
|
-
/**
|
|
35
|
-
* used for debugging purposes.
|
|
36
|
-
*/
|
|
37
|
-
DebugCall = 8
|
|
38
|
-
}
|
|
39
|
-
interface OnigScanner {
|
|
40
|
-
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
|
|
41
|
-
dispose?(): void;
|
|
42
|
-
}
|
|
43
|
-
interface OnigString {
|
|
44
|
-
readonly content: string;
|
|
45
|
-
dispose?(): void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A union of given const enum values.
|
|
50
|
-
*/
|
|
51
|
-
type OrMask<T extends number> = number;
|
|
52
|
-
|
|
53
|
-
type Awaitable<T> = T | Promise<T>;
|
|
54
|
-
|
|
55
|
-
interface PatternScanner extends OnigScanner {
|
|
56
|
-
}
|
|
57
|
-
interface RegexEngineString extends OnigString {
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Engine for RegExp matching and scanning.
|
|
61
|
-
*/
|
|
62
|
-
interface RegexEngine {
|
|
63
|
-
createScanner: (patterns: (string | RegExp)[]) => PatternScanner;
|
|
64
|
-
createString: (s: string) => RegexEngineString;
|
|
65
|
-
}
|
|
66
|
-
interface WebAssemblyInstantiator {
|
|
67
|
-
(importObject: Record<string, Record<string, WebAssembly.ImportValue>> | undefined): Promise<WebAssemblyInstance>;
|
|
68
|
-
}
|
|
69
|
-
type WebAssemblyInstance = WebAssembly.WebAssemblyInstantiatedSource | WebAssembly.Instance | WebAssembly.Instance['exports'];
|
|
70
|
-
type OnigurumaLoadOptions = {
|
|
71
|
-
instantiator: WebAssemblyInstantiator;
|
|
72
|
-
} | {
|
|
73
|
-
default: WebAssemblyInstantiator;
|
|
74
|
-
} | {
|
|
75
|
-
data: ArrayBufferView | ArrayBuffer | Response;
|
|
76
|
-
};
|
|
77
|
-
type LoadWasmOptionsPlain = OnigurumaLoadOptions | WebAssemblyInstantiator | ArrayBufferView | ArrayBuffer | Response;
|
|
78
|
-
type LoadWasmOptions = Awaitable<LoadWasmOptionsPlain> | (() => Awaitable<LoadWasmOptionsPlain>);
|
|
79
|
-
|
|
80
|
-
declare function loadWasm(options: LoadWasmOptions): Promise<void>;
|
|
81
|
-
declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
|
|
82
|
-
|
|
83
|
-
export { createOnigurumaEngine, loadWasm };
|
package/dist/langs.d.mts
CHANGED
|
@@ -10,4 +10,5 @@ declare const bundledLanguagesAlias: {
|
|
|
10
10
|
type BundledLanguage = '1c' | '1c-query' | 'abap' | 'actionscript-3' | 'ada' | 'adoc' | 'angular-html' | 'angular-ts' | 'apache' | 'apex' | 'apl' | 'applescript' | 'ara' | 'asciidoc' | 'asm' | 'astro' | 'awk' | 'ballerina' | 'bash' | 'bat' | 'batch' | 'be' | 'beancount' | 'berry' | 'bibtex' | 'bicep' | 'blade' | 'bsl' | 'c' | 'c#' | 'c++' | 'cadence' | 'cairo' | 'cdc' | 'clarity' | 'clj' | 'clojure' | 'closure-templates' | 'cmake' | 'cmd' | 'cobol' | 'codeowners' | 'codeql' | 'coffee' | 'coffeescript' | 'common-lisp' | 'console' | 'coq' | 'cpp' | 'cql' | 'crystal' | 'cs' | 'csharp' | 'css' | 'csv' | 'cue' | 'cypher' | 'd' | 'dart' | 'dax' | 'desktop' | 'diff' | 'docker' | 'dockerfile' | 'dotenv' | 'dream-maker' | 'edge' | 'elisp' | 'elixir' | 'elm' | 'emacs-lisp' | 'erb' | 'erl' | 'erlang' | 'f' | 'f#' | 'f03' | 'f08' | 'f18' | 'f77' | 'f90' | 'f95' | 'fennel' | 'fish' | 'fluent' | 'for' | 'fortran-fixed-form' | 'fortran-free-form' | 'fs' | 'fsharp' | 'fsl' | 'ftl' | 'gdresource' | 'gdscript' | 'gdshader' | 'genie' | 'gherkin' | 'git-commit' | 'git-rebase' | 'gjs' | 'gleam' | 'glimmer-js' | 'glimmer-ts' | 'glsl' | 'gnuplot' | 'go' | 'gql' | 'graphql' | 'groovy' | 'gts' | 'hack' | 'haml' | 'handlebars' | 'haskell' | 'haxe' | 'hbs' | 'hcl' | 'hjson' | 'hlsl' | 'hs' | 'html' | 'html-derivative' | 'http' | 'hxml' | 'hy' | 'imba' | 'ini' | 'jade' | 'java' | 'javascript' | 'jinja' | 'jison' | 'jl' | 'js' | 'json' | 'json5' | 'jsonc' | 'jsonl' | 'jsonnet' | 'jssm' | 'jsx' | 'julia' | 'kotlin' | 'kql' | 'kt' | 'kts' | 'kusto' | 'latex' | 'lean' | 'lean4' | 'less' | 'liquid' | 'lisp' | 'lit' | 'llvm' | 'log' | 'logo' | 'lua' | 'luau' | 'make' | 'makefile' | 'markdown' | 'marko' | 'matlab' | 'md' | 'mdc' | 'mdx' | 'mediawiki' | 'mermaid' | 'mips' | 'mipsasm' | 'mmd' | 'mojo' | 'move' | 'nar' | 'narrat' | 'nextflow' | 'nf' | 'nginx' | 'nim' | 'nix' | 'nu' | 'nushell' | 'objc' | 'objective-c' | 'objective-cpp' | 'ocaml' | 'pascal' | 'perl' | 'perl6' | 'php' | 'plsql' | 'po' | 'polar' | 'postcss' | 'pot' | 'potx' | 'powerquery' | 'powershell' | 'prisma' | 'prolog' | 'properties' | 'proto' | 'protobuf' | 'ps' | 'ps1' | 'pug' | 'puppet' | 'purescript' | 'py' | 'python' | 'ql' | 'qml' | 'qmldir' | 'qss' | 'r' | 'racket' | 'raku' | 'razor' | 'rb' | 'reg' | 'regex' | 'regexp' | 'rel' | 'riscv' | 'rs' | 'rst' | 'ruby' | 'rust' | 'sas' | 'sass' | 'scala' | 'scheme' | 'scss' | 'sdbl' | 'sh' | 'shader' | 'shaderlab' | 'shell' | 'shellscript' | 'shellsession' | 'smalltalk' | 'solidity' | 'soy' | 'sparql' | 'spl' | 'splunk' | 'sql' | 'ssh-config' | 'stata' | 'styl' | 'stylus' | 'svelte' | 'swift' | 'system-verilog' | 'systemd' | 'talon' | 'talonscript' | 'tasl' | 'tcl' | 'templ' | 'terraform' | 'tex' | 'tf' | 'tfvars' | 'toml' | 'ts' | 'ts-tags' | 'tsp' | 'tsv' | 'tsx' | 'turtle' | 'twig' | 'typ' | 'typescript' | 'typespec' | 'typst' | 'v' | 'vala' | 'vb' | 'verilog' | 'vhdl' | 'vim' | 'viml' | 'vimscript' | 'vue' | 'vue-html' | 'vy' | 'vyper' | 'wasm' | 'wenyan' | 'wgsl' | 'wiki' | 'wikitext' | 'wit' | 'wl' | 'wolfram' | 'xml' | 'xsl' | 'yaml' | 'yml' | 'zenscript' | 'zig' | 'zsh' | '文言';
|
|
11
11
|
declare const bundledLanguages: Record<BundledLanguage, DynamicImportLanguageRegistration>;
|
|
12
12
|
|
|
13
|
-
export {
|
|
13
|
+
export { bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo };
|
|
14
|
+
export type { BundledLanguage };
|
package/dist/textmate.d.mts
CHANGED
|
@@ -1,711 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type RuleId = {
|
|
3
|
-
__brand: typeof ruleIdSymbol;
|
|
4
|
-
};
|
|
5
|
-
declare const endRuleId = -1;
|
|
6
|
-
interface IRuleRegistry {
|
|
7
|
-
getRule(ruleId: RuleId): Rule;
|
|
8
|
-
registerRule<T extends Rule>(factory: (id: RuleId) => T): T;
|
|
9
|
-
}
|
|
10
|
-
interface IGrammarRegistry {
|
|
11
|
-
getExternalGrammar(scopeName: string, repository: IRawRepository): IRawGrammar | null | undefined;
|
|
12
|
-
}
|
|
13
|
-
interface IRuleFactoryHelper extends IRuleRegistry, IGrammarRegistry {
|
|
14
|
-
}
|
|
15
|
-
declare abstract class Rule {
|
|
16
|
-
readonly $location: ILocation | undefined;
|
|
17
|
-
readonly id: RuleId;
|
|
18
|
-
private readonly _nameIsCapturing;
|
|
19
|
-
private readonly _name;
|
|
20
|
-
private readonly _contentNameIsCapturing;
|
|
21
|
-
private readonly _contentName;
|
|
22
|
-
constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined);
|
|
23
|
-
abstract dispose(): void;
|
|
24
|
-
get debugName(): string;
|
|
25
|
-
getName(lineText: string | null, captureIndices: IOnigCaptureIndex[] | null): string | null;
|
|
26
|
-
getContentName(lineText: string, captureIndices: IOnigCaptureIndex[]): string | null;
|
|
27
|
-
abstract collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
|
|
28
|
-
abstract compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: RegExpString | null): CompiledRule;
|
|
29
|
-
abstract compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: RegExpString | null, allowA: boolean, allowG: boolean): CompiledRule;
|
|
30
|
-
}
|
|
31
|
-
declare class RegExpSource<TRuleId = RuleId | typeof endRuleId> {
|
|
32
|
-
source: RegExpString;
|
|
33
|
-
readonly ruleId: TRuleId;
|
|
34
|
-
hasAnchor: boolean;
|
|
35
|
-
readonly hasBackReferences: boolean;
|
|
36
|
-
private _anchorCache;
|
|
37
|
-
constructor(regExpSource: RegExpString, ruleId: TRuleId);
|
|
38
|
-
clone(): RegExpSource<TRuleId>;
|
|
39
|
-
setSource(newSource: RegExpString): void;
|
|
40
|
-
resolveBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string;
|
|
41
|
-
private _buildAnchorCache;
|
|
42
|
-
resolveAnchors(allowA: boolean, allowG: boolean): RegExpString;
|
|
43
|
-
}
|
|
44
|
-
declare class RegExpSourceList<TRuleId = RuleId | typeof endRuleId> {
|
|
45
|
-
private readonly _items;
|
|
46
|
-
private _hasAnchors;
|
|
47
|
-
private _cached;
|
|
48
|
-
private _anchorCache;
|
|
49
|
-
constructor();
|
|
50
|
-
dispose(): void;
|
|
51
|
-
private _disposeCaches;
|
|
52
|
-
push(item: RegExpSource<TRuleId>): void;
|
|
53
|
-
unshift(item: RegExpSource<TRuleId>): void;
|
|
54
|
-
length(): number;
|
|
55
|
-
setSource(index: number, newSource: RegExpString): void;
|
|
56
|
-
compile(onigLib: IOnigLib): CompiledRule<TRuleId>;
|
|
57
|
-
compileAG(onigLib: IOnigLib, allowA: boolean, allowG: boolean): CompiledRule<TRuleId>;
|
|
58
|
-
private _resolveAnchors;
|
|
59
|
-
}
|
|
60
|
-
declare class CompiledRule<TRuleId = RuleId | typeof endRuleId> {
|
|
61
|
-
private readonly regExps;
|
|
62
|
-
private readonly rules;
|
|
63
|
-
private readonly scanner;
|
|
64
|
-
constructor(onigLib: IOnigLib, regExps: RegExpString[], rules: TRuleId[]);
|
|
65
|
-
dispose(): void;
|
|
66
|
-
toString(): string;
|
|
67
|
-
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IFindNextMatchResult<TRuleId> | null;
|
|
68
|
-
}
|
|
69
|
-
interface IFindNextMatchResult<TRuleId = RuleId | typeof endRuleId> {
|
|
70
|
-
ruleId: TRuleId;
|
|
71
|
-
captureIndices: IOnigCaptureIndex[];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
interface IRawGrammar extends ILocatable {
|
|
75
|
-
repository: IRawRepository;
|
|
76
|
-
readonly scopeName: ScopeName;
|
|
77
|
-
readonly patterns: IRawRule[];
|
|
78
|
-
readonly injections?: {
|
|
79
|
-
[expression: string]: IRawRule;
|
|
80
|
-
};
|
|
81
|
-
readonly injectionSelector?: string;
|
|
82
|
-
readonly fileTypes?: string[];
|
|
83
|
-
readonly name?: string;
|
|
84
|
-
readonly firstLineMatch?: string;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Allowed values:
|
|
88
|
-
* * Scope Name, e.g. `source.ts`
|
|
89
|
-
* * Top level scope reference, e.g. `source.ts#entity.name.class`
|
|
90
|
-
* * Relative scope reference, e.g. `#entity.name.class`
|
|
91
|
-
* * self, e.g. `$self`
|
|
92
|
-
* * base, e.g. `$base`
|
|
93
|
-
*/
|
|
94
|
-
type IncludeString = string;
|
|
95
|
-
type RegExpString = string | RegExp;
|
|
96
|
-
interface IRawRepositoryMap {
|
|
97
|
-
[name: string]: IRawRule;
|
|
98
|
-
}
|
|
99
|
-
type IRawRepository = IRawRepositoryMap & ILocatable;
|
|
100
|
-
interface IRawRule extends ILocatable {
|
|
101
|
-
id?: RuleId;
|
|
102
|
-
readonly include?: IncludeString;
|
|
103
|
-
readonly name?: ScopeName;
|
|
104
|
-
readonly contentName?: ScopeName;
|
|
105
|
-
readonly match?: RegExpString;
|
|
106
|
-
readonly captures?: IRawCaptures;
|
|
107
|
-
readonly begin?: RegExpString;
|
|
108
|
-
readonly beginCaptures?: IRawCaptures;
|
|
109
|
-
readonly end?: RegExpString;
|
|
110
|
-
readonly endCaptures?: IRawCaptures;
|
|
111
|
-
readonly while?: RegExpString;
|
|
112
|
-
readonly whileCaptures?: IRawCaptures;
|
|
113
|
-
readonly patterns?: IRawRule[];
|
|
114
|
-
readonly repository?: IRawRepository;
|
|
115
|
-
readonly applyEndPatternLast?: boolean;
|
|
116
|
-
}
|
|
117
|
-
type IRawCaptures = IRawCapturesMap & ILocatable;
|
|
118
|
-
interface IRawCapturesMap {
|
|
119
|
-
[captureId: string]: IRawRule;
|
|
120
|
-
}
|
|
121
|
-
interface ILocation {
|
|
122
|
-
readonly filename: string;
|
|
123
|
-
readonly line: number;
|
|
124
|
-
readonly char: number;
|
|
125
|
-
}
|
|
126
|
-
interface ILocatable {
|
|
127
|
-
readonly $vscodeTextmateLocation?: ILocation;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
interface IOnigLib {
|
|
131
|
-
createOnigScanner(sources: RegExpString[]): OnigScanner;
|
|
132
|
-
createOnigString(str: string): OnigString;
|
|
133
|
-
}
|
|
134
|
-
interface IOnigCaptureIndex {
|
|
135
|
-
start: number;
|
|
136
|
-
end: number;
|
|
137
|
-
length: number;
|
|
138
|
-
}
|
|
139
|
-
interface IOnigMatch {
|
|
140
|
-
index: number;
|
|
141
|
-
captureIndices: IOnigCaptureIndex[];
|
|
142
|
-
}
|
|
143
|
-
declare const enum FindOption {
|
|
144
|
-
None = 0,
|
|
145
|
-
/**
|
|
146
|
-
* equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
|
|
147
|
-
*/
|
|
148
|
-
NotBeginString = 1,
|
|
149
|
-
/**
|
|
150
|
-
* equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
|
|
151
|
-
*/
|
|
152
|
-
NotEndString = 2,
|
|
153
|
-
/**
|
|
154
|
-
* equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
|
|
155
|
-
*/
|
|
156
|
-
NotBeginPosition = 4,
|
|
157
|
-
/**
|
|
158
|
-
* used for debugging purposes.
|
|
159
|
-
*/
|
|
160
|
-
DebugCall = 8
|
|
161
|
-
}
|
|
162
|
-
interface OnigScanner {
|
|
163
|
-
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
|
|
164
|
-
dispose?(): void;
|
|
165
|
-
}
|
|
166
|
-
interface OnigString {
|
|
167
|
-
readonly content: string;
|
|
168
|
-
dispose?(): void;
|
|
169
|
-
}
|
|
170
|
-
declare function disposeOnigString(str: OnigString): void;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* A union of given const enum values.
|
|
174
|
-
*/
|
|
175
|
-
type OrMask<T extends number> = number;
|
|
176
|
-
|
|
177
|
-
declare class Theme {
|
|
178
|
-
private readonly _colorMap;
|
|
179
|
-
private readonly _defaults;
|
|
180
|
-
private readonly _root;
|
|
181
|
-
static createFromRawTheme(source: IRawTheme | undefined, colorMap?: string[]): Theme;
|
|
182
|
-
static createFromParsedTheme(source: ParsedThemeRule[], colorMap?: string[]): Theme;
|
|
183
|
-
private readonly _cachedMatchRoot;
|
|
184
|
-
constructor(_colorMap: ColorMap, _defaults: StyleAttributes, _root: ThemeTrieElement);
|
|
185
|
-
getColorMap(): string[];
|
|
186
|
-
getDefaults(): StyleAttributes;
|
|
187
|
-
match(scopePath: ScopeStack | null): StyleAttributes | null;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Identifiers with a binary dot operator.
|
|
191
|
-
* Examples: `baz` or `foo.bar`
|
|
192
|
-
*/
|
|
193
|
-
type ScopeName = string;
|
|
194
|
-
/**
|
|
195
|
-
* An expression language of ScopeNames with a binary space (to indicate nesting) operator.
|
|
196
|
-
* Examples: `foo.bar boo.baz`
|
|
197
|
-
*/
|
|
198
|
-
type ScopePath = string;
|
|
199
|
-
/**
|
|
200
|
-
* An expression language of ScopePathStr with a binary comma (to indicate alternatives) operator.
|
|
201
|
-
* Examples: `foo.bar boo.baz,quick quack`
|
|
202
|
-
*/
|
|
203
|
-
type ScopePattern = string;
|
|
204
|
-
/**
|
|
205
|
-
* A TextMate theme.
|
|
206
|
-
*/
|
|
207
|
-
interface IRawTheme {
|
|
208
|
-
readonly name?: string;
|
|
209
|
-
readonly settings: IRawThemeSetting[];
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* A single theme setting.
|
|
213
|
-
*/
|
|
214
|
-
interface IRawThemeSetting {
|
|
215
|
-
readonly name?: string;
|
|
216
|
-
readonly scope?: ScopePattern | ScopePattern[];
|
|
217
|
-
readonly settings: {
|
|
218
|
-
readonly fontStyle?: string;
|
|
219
|
-
readonly foreground?: string;
|
|
220
|
-
readonly background?: string;
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
declare class ScopeStack {
|
|
224
|
-
readonly parent: ScopeStack | null;
|
|
225
|
-
readonly scopeName: ScopeName;
|
|
226
|
-
static push(path: ScopeStack | null, scopeNames: ScopeName[]): ScopeStack | null;
|
|
227
|
-
static from(first: ScopeName, ...segments: ScopeName[]): ScopeStack;
|
|
228
|
-
static from(...segments: ScopeName[]): ScopeStack | null;
|
|
229
|
-
constructor(parent: ScopeStack | null, scopeName: ScopeName);
|
|
230
|
-
push(scopeName: ScopeName): ScopeStack;
|
|
231
|
-
getSegments(): ScopeName[];
|
|
232
|
-
toString(): string;
|
|
233
|
-
extends(other: ScopeStack): boolean;
|
|
234
|
-
getExtensionIfDefined(base: ScopeStack | null): string[] | undefined;
|
|
235
|
-
}
|
|
236
|
-
declare class StyleAttributes {
|
|
237
|
-
readonly fontStyle: OrMask<FontStyle>;
|
|
238
|
-
readonly foregroundId: number;
|
|
239
|
-
readonly backgroundId: number;
|
|
240
|
-
constructor(fontStyle: OrMask<FontStyle>, foregroundId: number, backgroundId: number);
|
|
241
|
-
}
|
|
242
|
-
declare class ParsedThemeRule {
|
|
243
|
-
readonly scope: ScopeName;
|
|
244
|
-
readonly parentScopes: ScopeName[] | null;
|
|
245
|
-
readonly index: number;
|
|
246
|
-
readonly fontStyle: OrMask<FontStyle>;
|
|
247
|
-
readonly foreground: string | null;
|
|
248
|
-
readonly background: string | null;
|
|
249
|
-
constructor(scope: ScopeName, parentScopes: ScopeName[] | null, index: number, fontStyle: OrMask<FontStyle>, foreground: string | null, background: string | null);
|
|
250
|
-
}
|
|
251
|
-
declare const enum FontStyle {
|
|
252
|
-
NotSet = -1,
|
|
253
|
-
None = 0,
|
|
254
|
-
Italic = 1,
|
|
255
|
-
Bold = 2,
|
|
256
|
-
Underline = 4,
|
|
257
|
-
Strikethrough = 8
|
|
258
|
-
}
|
|
259
|
-
declare class ColorMap {
|
|
260
|
-
private readonly _isFrozen;
|
|
261
|
-
private _lastColorId;
|
|
262
|
-
private _id2color;
|
|
263
|
-
private _color2id;
|
|
264
|
-
constructor(_colorMap?: string[]);
|
|
265
|
-
getId(color: string | null): number;
|
|
266
|
-
getColorMap(): string[];
|
|
267
|
-
}
|
|
268
|
-
declare class ThemeTrieElementRule {
|
|
269
|
-
scopeDepth: number;
|
|
270
|
-
parentScopes: readonly ScopeName[];
|
|
271
|
-
fontStyle: number;
|
|
272
|
-
foreground: number;
|
|
273
|
-
background: number;
|
|
274
|
-
constructor(scopeDepth: number, parentScopes: readonly ScopeName[] | null, fontStyle: number, foreground: number, background: number);
|
|
275
|
-
clone(): ThemeTrieElementRule;
|
|
276
|
-
static cloneArr(arr: ThemeTrieElementRule[]): ThemeTrieElementRule[];
|
|
277
|
-
acceptOverwrite(scopeDepth: number, fontStyle: number, foreground: number, background: number): void;
|
|
278
|
-
}
|
|
279
|
-
interface ITrieChildrenMap {
|
|
280
|
-
[segment: string]: ThemeTrieElement;
|
|
281
|
-
}
|
|
282
|
-
declare class ThemeTrieElement {
|
|
283
|
-
private readonly _mainRule;
|
|
284
|
-
private readonly _children;
|
|
285
|
-
private readonly _rulesWithParentScopes;
|
|
286
|
-
constructor(_mainRule: ThemeTrieElementRule, rulesWithParentScopes?: ThemeTrieElementRule[], _children?: ITrieChildrenMap);
|
|
287
|
-
private static _cmpBySpecificity;
|
|
288
|
-
match(scope: ScopeName): ThemeTrieElementRule[];
|
|
289
|
-
insert(scopeDepth: number, scope: ScopeName, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number): void;
|
|
290
|
-
private _doInsertHere;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
type EncodedTokenAttributes = number;
|
|
294
|
-
declare class EncodedTokenMetadata {
|
|
295
|
-
static toBinaryStr(encodedTokenAttributes: EncodedTokenAttributes): string;
|
|
296
|
-
static print(encodedTokenAttributes: EncodedTokenAttributes): void;
|
|
297
|
-
static getLanguageId(encodedTokenAttributes: EncodedTokenAttributes): number;
|
|
298
|
-
static getTokenType(encodedTokenAttributes: EncodedTokenAttributes): StandardTokenType;
|
|
299
|
-
static containsBalancedBrackets(encodedTokenAttributes: EncodedTokenAttributes): boolean;
|
|
300
|
-
static getFontStyle(encodedTokenAttributes: EncodedTokenAttributes): number;
|
|
301
|
-
static getForeground(encodedTokenAttributes: EncodedTokenAttributes): number;
|
|
302
|
-
static getBackground(encodedTokenAttributes: EncodedTokenAttributes): number;
|
|
303
|
-
/**
|
|
304
|
-
* Updates the fields in `metadata`.
|
|
305
|
-
* A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is.
|
|
306
|
-
*/
|
|
307
|
-
static set(encodedTokenAttributes: EncodedTokenAttributes, languageId: number | 0, tokenType: OptionalStandardTokenType | OptionalStandardTokenType.NotSet, containsBalancedBrackets: boolean | null, fontStyle: FontStyle | FontStyle.NotSet, foreground: number | 0, background: number | 0): number;
|
|
308
|
-
}
|
|
309
|
-
declare const enum StandardTokenType {
|
|
310
|
-
Other = 0,
|
|
311
|
-
Comment = 1,
|
|
312
|
-
String = 2,
|
|
313
|
-
RegEx = 3
|
|
314
|
-
}
|
|
315
|
-
declare const enum OptionalStandardTokenType {
|
|
316
|
-
Other = 0,
|
|
317
|
-
Comment = 1,
|
|
318
|
-
String = 2,
|
|
319
|
-
RegEx = 3,
|
|
320
|
-
NotSet = 8
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
interface Matcher<T> {
|
|
324
|
-
(matcherInput: T): boolean;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
declare class BasicScopeAttributes {
|
|
328
|
-
readonly languageId: number;
|
|
329
|
-
readonly tokenType: OptionalStandardTokenType;
|
|
330
|
-
constructor(languageId: number, tokenType: OptionalStandardTokenType);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
interface IThemeProvider {
|
|
334
|
-
themeMatch(scopePath: ScopeStack): StyleAttributes | null;
|
|
335
|
-
getDefaults(): StyleAttributes;
|
|
336
|
-
}
|
|
337
|
-
interface IGrammarRepository {
|
|
338
|
-
lookup(scopeName: ScopeName): IRawGrammar | undefined;
|
|
339
|
-
injections(scopeName: ScopeName): ScopeName[];
|
|
340
|
-
}
|
|
341
|
-
interface Injection {
|
|
342
|
-
readonly debugSelector: string;
|
|
343
|
-
readonly matcher: Matcher<string[]>;
|
|
344
|
-
readonly priority: -1 | 0 | 1;
|
|
345
|
-
readonly ruleId: RuleId;
|
|
346
|
-
readonly grammar: IRawGrammar;
|
|
347
|
-
}
|
|
348
|
-
declare class Grammar implements IGrammar, IRuleFactoryHelper, IOnigLib {
|
|
349
|
-
private readonly _rootScopeName;
|
|
350
|
-
private readonly balancedBracketSelectors;
|
|
351
|
-
private readonly _onigLib;
|
|
352
|
-
private _rootId;
|
|
353
|
-
private _lastRuleId;
|
|
354
|
-
private readonly _ruleId2desc;
|
|
355
|
-
private readonly _includedGrammars;
|
|
356
|
-
private readonly _grammarRepository;
|
|
357
|
-
private readonly _grammar;
|
|
358
|
-
private _injections;
|
|
359
|
-
private readonly _basicScopeAttributesProvider;
|
|
360
|
-
private readonly _tokenTypeMatchers;
|
|
361
|
-
get themeProvider(): IThemeProvider;
|
|
362
|
-
constructor(_rootScopeName: ScopeName, grammar: IRawGrammar, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null, grammarRepository: IGrammarRepository & IThemeProvider, _onigLib: IOnigLib);
|
|
363
|
-
dispose(): void;
|
|
364
|
-
createOnigScanner(sources: RegExpString[]): OnigScanner;
|
|
365
|
-
createOnigString(sources: string): OnigString;
|
|
366
|
-
getMetadataForScope(scope: string): BasicScopeAttributes;
|
|
367
|
-
private _collectInjections;
|
|
368
|
-
getInjections(): Injection[];
|
|
369
|
-
registerRule<T extends Rule>(factory: (id: RuleId) => T): T;
|
|
370
|
-
getRule(ruleId: RuleId): Rule;
|
|
371
|
-
getExternalGrammar(scopeName: string, repository?: IRawRepository): IRawGrammar | undefined;
|
|
372
|
-
tokenizeLine(lineText: string, prevState: StateStackImpl | null, timeLimit?: number): ITokenizeLineResult;
|
|
373
|
-
tokenizeLine2(lineText: string, prevState: StateStackImpl | null, timeLimit?: number): ITokenizeLineResult2;
|
|
374
|
-
private _tokenize;
|
|
375
|
-
}
|
|
376
|
-
declare class AttributedScopeStack {
|
|
377
|
-
readonly parent: AttributedScopeStack | null;
|
|
378
|
-
readonly scopePath: ScopeStack;
|
|
379
|
-
readonly tokenAttributes: EncodedTokenAttributes;
|
|
380
|
-
static fromExtension(namesScopeList: AttributedScopeStack | null, contentNameScopesList: AttributedScopeStackFrame[]): AttributedScopeStack | null;
|
|
381
|
-
static createRoot(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes): AttributedScopeStack;
|
|
382
|
-
static createRootAndLookUpScopeName(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes, grammar: Grammar): AttributedScopeStack;
|
|
383
|
-
get scopeName(): ScopeName;
|
|
384
|
-
/**
|
|
385
|
-
* Invariant:
|
|
386
|
-
* ```
|
|
387
|
-
* if (parent && !scopePath.extends(parent.scopePath)) {
|
|
388
|
-
* throw new Error();
|
|
389
|
-
* }
|
|
390
|
-
* ```
|
|
391
|
-
*/
|
|
392
|
-
private constructor();
|
|
393
|
-
toString(): string;
|
|
394
|
-
equals(other: AttributedScopeStack): boolean;
|
|
395
|
-
static equals(a: AttributedScopeStack | null, b: AttributedScopeStack | null): boolean;
|
|
396
|
-
private static mergeAttributes;
|
|
397
|
-
pushAttributed(scopePath: ScopePath | null, grammar: Grammar): AttributedScopeStack;
|
|
398
|
-
private static _pushAttributed;
|
|
399
|
-
getScopeNames(): string[];
|
|
400
|
-
getExtensionIfDefined(base: AttributedScopeStack | null): AttributedScopeStackFrame[] | undefined;
|
|
401
|
-
}
|
|
402
|
-
interface AttributedScopeStackFrame {
|
|
403
|
-
encodedTokenAttributes: number;
|
|
404
|
-
scopeNames: string[];
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Represents a "pushed" state on the stack (as a linked list element).
|
|
408
|
-
*/
|
|
409
|
-
declare class StateStackImpl implements StateStack {
|
|
410
|
-
/**
|
|
411
|
-
* The previous state on the stack (or null for the root state).
|
|
412
|
-
*/
|
|
413
|
-
readonly parent: StateStackImpl | null;
|
|
414
|
-
/**
|
|
415
|
-
* The state (rule) that this element represents.
|
|
416
|
-
*/
|
|
417
|
-
private readonly ruleId;
|
|
418
|
-
/**
|
|
419
|
-
* The state has entered and captured \n. This means that the next line should have an anchorPosition of 0.
|
|
420
|
-
*/
|
|
421
|
-
readonly beginRuleCapturedEOL: boolean;
|
|
422
|
-
/**
|
|
423
|
-
* The "pop" (end) condition for this state in case that it was dynamically generated through captured text.
|
|
424
|
-
*/
|
|
425
|
-
readonly endRule: string | null;
|
|
426
|
-
/**
|
|
427
|
-
* The list of scopes containing the "name" for this state.
|
|
428
|
-
*/
|
|
429
|
-
readonly nameScopesList: AttributedScopeStack | null;
|
|
430
|
-
/**
|
|
431
|
-
* The list of scopes containing the "contentName" (besides "name") for this state.
|
|
432
|
-
* This list **must** contain as an element `scopeName`.
|
|
433
|
-
*/
|
|
434
|
-
readonly contentNameScopesList: AttributedScopeStack | null;
|
|
435
|
-
_stackElementBrand: void;
|
|
436
|
-
static NULL: StateStackImpl;
|
|
437
|
-
/**
|
|
438
|
-
* The position on the current line where this state was pushed.
|
|
439
|
-
* This is relevant only while tokenizing a line, to detect endless loops.
|
|
440
|
-
* Its value is meaningless across lines.
|
|
441
|
-
*/
|
|
442
|
-
private _enterPos;
|
|
443
|
-
/**
|
|
444
|
-
* The captured anchor position when this stack element was pushed.
|
|
445
|
-
* This is relevant only while tokenizing a line, to restore the anchor position when popping.
|
|
446
|
-
* Its value is meaningless across lines.
|
|
447
|
-
*/
|
|
448
|
-
private _anchorPos;
|
|
449
|
-
/**
|
|
450
|
-
* The depth of the stack.
|
|
451
|
-
*/
|
|
452
|
-
readonly depth: number;
|
|
453
|
-
/**
|
|
454
|
-
* Invariant:
|
|
455
|
-
* ```
|
|
456
|
-
* if (contentNameScopesList !== nameScopesList && contentNameScopesList?.parent !== nameScopesList) {
|
|
457
|
-
* throw new Error();
|
|
458
|
-
* }
|
|
459
|
-
* if (this.parent && !nameScopesList.extends(this.parent.contentNameScopesList)) {
|
|
460
|
-
* throw new Error();
|
|
461
|
-
* }
|
|
462
|
-
* ```
|
|
463
|
-
*/
|
|
464
|
-
constructor(
|
|
465
|
-
/**
|
|
466
|
-
* The previous state on the stack (or null for the root state).
|
|
467
|
-
*/
|
|
468
|
-
parent: StateStackImpl | null,
|
|
469
|
-
/**
|
|
470
|
-
* The state (rule) that this element represents.
|
|
471
|
-
*/
|
|
472
|
-
ruleId: RuleId, enterPos: number, anchorPos: number,
|
|
473
|
-
/**
|
|
474
|
-
* The state has entered and captured \n. This means that the next line should have an anchorPosition of 0.
|
|
475
|
-
*/
|
|
476
|
-
beginRuleCapturedEOL: boolean,
|
|
477
|
-
/**
|
|
478
|
-
* The "pop" (end) condition for this state in case that it was dynamically generated through captured text.
|
|
479
|
-
*/
|
|
480
|
-
endRule: string | null,
|
|
481
|
-
/**
|
|
482
|
-
* The list of scopes containing the "name" for this state.
|
|
483
|
-
*/
|
|
484
|
-
nameScopesList: AttributedScopeStack | null,
|
|
485
|
-
/**
|
|
486
|
-
* The list of scopes containing the "contentName" (besides "name") for this state.
|
|
487
|
-
* This list **must** contain as an element `scopeName`.
|
|
488
|
-
*/
|
|
489
|
-
contentNameScopesList: AttributedScopeStack | null);
|
|
490
|
-
equals(other: StateStackImpl): boolean;
|
|
491
|
-
private static _equals;
|
|
492
|
-
/**
|
|
493
|
-
* A structural equals check. Does not take into account `scopes`.
|
|
494
|
-
*/
|
|
495
|
-
private static _structuralEquals;
|
|
496
|
-
clone(): StateStackImpl;
|
|
497
|
-
private static _reset;
|
|
498
|
-
reset(): void;
|
|
499
|
-
pop(): StateStackImpl | null;
|
|
500
|
-
safePop(): StateStackImpl;
|
|
501
|
-
push(ruleId: RuleId, enterPos: number, anchorPos: number, beginRuleCapturedEOL: boolean, endRule: string | null, nameScopesList: AttributedScopeStack | null, contentNameScopesList: AttributedScopeStack | null): StateStackImpl;
|
|
502
|
-
getEnterPos(): number;
|
|
503
|
-
getAnchorPos(): number;
|
|
504
|
-
getRule(grammar: IRuleRegistry): Rule;
|
|
505
|
-
toString(): string;
|
|
506
|
-
private _writeString;
|
|
507
|
-
withContentNameScopesList(contentNameScopeStack: AttributedScopeStack): StateStackImpl;
|
|
508
|
-
withEndRule(endRule: string): StateStackImpl;
|
|
509
|
-
hasSameRuleAs(other: StateStackImpl): boolean;
|
|
510
|
-
toStateStackFrame(): StateStackFrame;
|
|
511
|
-
static pushFrame(self: StateStackImpl | null, frame: StateStackFrame): StateStackImpl;
|
|
512
|
-
}
|
|
513
|
-
interface StateStackFrame {
|
|
514
|
-
ruleId: number;
|
|
515
|
-
enterPos?: number;
|
|
516
|
-
anchorPos?: number;
|
|
517
|
-
beginRuleCapturedEOL: boolean;
|
|
518
|
-
endRule: string | null;
|
|
519
|
-
nameScopesList: AttributedScopeStackFrame[];
|
|
520
|
-
/**
|
|
521
|
-
* on top of nameScopesList
|
|
522
|
-
*/
|
|
523
|
-
contentNameScopesList: AttributedScopeStackFrame[];
|
|
524
|
-
}
|
|
525
|
-
declare class BalancedBracketSelectors {
|
|
526
|
-
private readonly balancedBracketScopes;
|
|
527
|
-
private readonly unbalancedBracketScopes;
|
|
528
|
-
private allowAny;
|
|
529
|
-
constructor(balancedBracketScopes: string[], unbalancedBracketScopes: string[]);
|
|
530
|
-
get matchesAlways(): boolean;
|
|
531
|
-
get matchesNever(): boolean;
|
|
532
|
-
match(scopes: string[]): boolean;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
declare class SyncRegistry implements IGrammarRepository, IThemeProvider {
|
|
536
|
-
private readonly _onigLib;
|
|
537
|
-
readonly _grammars: Map<string, Grammar>;
|
|
538
|
-
readonly _rawGrammars: Map<string, IRawGrammar>;
|
|
539
|
-
readonly _injectionGrammars: Map<string, string[]>;
|
|
540
|
-
_theme: Theme;
|
|
541
|
-
constructor(theme: Theme, _onigLib: IOnigLib);
|
|
542
|
-
dispose(): void;
|
|
543
|
-
setTheme(theme: Theme): void;
|
|
544
|
-
getColorMap(): string[];
|
|
545
|
-
/**
|
|
546
|
-
* Add `grammar` to registry and return a list of referenced scope names
|
|
547
|
-
*/
|
|
548
|
-
addGrammar(grammar: IRawGrammar, injectionScopeNames?: ScopeName[]): void;
|
|
549
|
-
/**
|
|
550
|
-
* Lookup a raw grammar.
|
|
551
|
-
*/
|
|
552
|
-
lookup(scopeName: ScopeName): IRawGrammar | undefined;
|
|
553
|
-
/**
|
|
554
|
-
* Returns the injections for the given grammar
|
|
555
|
-
*/
|
|
556
|
-
injections(targetScope: ScopeName): ScopeName[];
|
|
557
|
-
/**
|
|
558
|
-
* Get the default theme settings
|
|
559
|
-
*/
|
|
560
|
-
getDefaults(): StyleAttributes;
|
|
561
|
-
/**
|
|
562
|
-
* Match a scope in the theme.
|
|
563
|
-
*/
|
|
564
|
-
themeMatch(scopePath: ScopeStack): StyleAttributes | null;
|
|
565
|
-
/**
|
|
566
|
-
* Lookup a grammar.
|
|
567
|
-
*/
|
|
568
|
-
grammarForScopeName(scopeName: ScopeName, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null): IGrammar | null;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
interface StackDiff {
|
|
572
|
-
readonly pops: number;
|
|
573
|
-
readonly newFrames: StateStackFrame[];
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* A registry helper that can locate grammar file paths given scope names.
|
|
578
|
-
*/
|
|
579
|
-
interface RegistryOptions {
|
|
580
|
-
onigLib: IOnigLib;
|
|
581
|
-
theme?: IRawTheme;
|
|
582
|
-
colorMap?: string[];
|
|
583
|
-
loadGrammar(scopeName: ScopeName): IRawGrammar | undefined | null;
|
|
584
|
-
getInjections?(scopeName: ScopeName): ScopeName[] | undefined;
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* A map from scope name to a language id. Please do not use language id 0.
|
|
588
|
-
*/
|
|
589
|
-
interface IEmbeddedLanguagesMap {
|
|
590
|
-
[scopeName: string]: number;
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* A map from selectors to token types.
|
|
594
|
-
*/
|
|
595
|
-
interface ITokenTypeMap {
|
|
596
|
-
[selector: string]: StandardTokenType;
|
|
597
|
-
}
|
|
598
|
-
interface IGrammarConfiguration {
|
|
599
|
-
embeddedLanguages?: IEmbeddedLanguagesMap;
|
|
600
|
-
tokenTypes?: ITokenTypeMap;
|
|
601
|
-
balancedBracketSelectors?: string[];
|
|
602
|
-
unbalancedBracketSelectors?: string[];
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* The registry that will hold all grammars.
|
|
606
|
-
*/
|
|
607
|
-
declare class Registry {
|
|
608
|
-
readonly _options: RegistryOptions;
|
|
609
|
-
readonly _syncRegistry: SyncRegistry;
|
|
610
|
-
readonly _ensureGrammarCache: Map<string, boolean>;
|
|
611
|
-
constructor(options: RegistryOptions);
|
|
612
|
-
dispose(): void;
|
|
613
|
-
/**
|
|
614
|
-
* Change the theme. Once called, no previous `ruleStack` should be used anymore.
|
|
615
|
-
*/
|
|
616
|
-
setTheme(theme: IRawTheme, colorMap?: string[]): void;
|
|
617
|
-
/**
|
|
618
|
-
* Returns a lookup array for color ids.
|
|
619
|
-
*/
|
|
620
|
-
getColorMap(): string[];
|
|
621
|
-
/**
|
|
622
|
-
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
|
|
623
|
-
* Please do not use language id 0.
|
|
624
|
-
*/
|
|
625
|
-
loadGrammarWithEmbeddedLanguages(initialScopeName: ScopeName, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap): IGrammar | null;
|
|
626
|
-
/**
|
|
627
|
-
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
|
|
628
|
-
* Please do not use language id 0.
|
|
629
|
-
*/
|
|
630
|
-
loadGrammarWithConfiguration(initialScopeName: ScopeName, initialLanguage: number, configuration: IGrammarConfiguration): IGrammar | null;
|
|
631
|
-
/**
|
|
632
|
-
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
|
|
633
|
-
*/
|
|
634
|
-
loadGrammar(initialScopeName: ScopeName): IGrammar | null;
|
|
635
|
-
private _loadGrammar;
|
|
636
|
-
private _loadSingleGrammar;
|
|
637
|
-
private _doLoadSingleGrammar;
|
|
638
|
-
/**
|
|
639
|
-
* Adds a rawGrammar.
|
|
640
|
-
*/
|
|
641
|
-
addGrammar(rawGrammar: IRawGrammar, injections?: string[], initialLanguage?: number, embeddedLanguages?: IEmbeddedLanguagesMap | null): IGrammar;
|
|
642
|
-
/**
|
|
643
|
-
* Get the grammar for `scopeName`. The grammar must first be created via `loadGrammar` or `addGrammar`.
|
|
644
|
-
*/
|
|
645
|
-
private _grammarForScopeName;
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* A grammar
|
|
649
|
-
*/
|
|
650
|
-
interface IGrammar {
|
|
651
|
-
/**
|
|
652
|
-
* Tokenize `lineText` using previous line state `prevState`.
|
|
653
|
-
*/
|
|
654
|
-
tokenizeLine(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult;
|
|
655
|
-
/**
|
|
656
|
-
* Tokenize `lineText` using previous line state `prevState`.
|
|
657
|
-
* The result contains the tokens in binary format, resolved with the following information:
|
|
658
|
-
* - language
|
|
659
|
-
* - token type (regex, string, comment, other)
|
|
660
|
-
* - font style
|
|
661
|
-
* - foreground color
|
|
662
|
-
* - background color
|
|
663
|
-
* e.g. for getting the languageId: `(metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET`
|
|
664
|
-
*/
|
|
665
|
-
tokenizeLine2(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult2;
|
|
666
|
-
}
|
|
667
|
-
interface ITokenizeLineResult {
|
|
668
|
-
readonly tokens: IToken[];
|
|
669
|
-
/**
|
|
670
|
-
* The `prevState` to be passed on to the next line tokenization.
|
|
671
|
-
*/
|
|
672
|
-
readonly ruleStack: StateStack;
|
|
673
|
-
/**
|
|
674
|
-
* Did tokenization stop early due to reaching the time limit.
|
|
675
|
-
*/
|
|
676
|
-
readonly stoppedEarly: boolean;
|
|
677
|
-
}
|
|
678
|
-
interface ITokenizeLineResult2 {
|
|
679
|
-
/**
|
|
680
|
-
* The tokens in binary format. Each token occupies two array indices. For token i:
|
|
681
|
-
* - at offset 2*i => startIndex
|
|
682
|
-
* - at offset 2*i + 1 => metadata
|
|
683
|
-
*
|
|
684
|
-
*/
|
|
685
|
-
readonly tokens: Uint32Array;
|
|
686
|
-
/**
|
|
687
|
-
* The `prevState` to be passed on to the next line tokenization.
|
|
688
|
-
*/
|
|
689
|
-
readonly ruleStack: StateStack;
|
|
690
|
-
/**
|
|
691
|
-
* Did tokenization stop early due to reaching the time limit.
|
|
692
|
-
*/
|
|
693
|
-
readonly stoppedEarly: boolean;
|
|
694
|
-
}
|
|
695
|
-
interface IToken {
|
|
696
|
-
startIndex: number;
|
|
697
|
-
readonly endIndex: number;
|
|
698
|
-
readonly scopes: string[];
|
|
699
|
-
}
|
|
700
|
-
/**
|
|
701
|
-
* **IMPORTANT** - Immutable!
|
|
702
|
-
*/
|
|
703
|
-
interface StateStack {
|
|
704
|
-
_stackElementBrand: void;
|
|
705
|
-
readonly depth: number;
|
|
706
|
-
clone(): StateStack;
|
|
707
|
-
equals(other: StateStack): boolean;
|
|
708
|
-
}
|
|
709
|
-
declare const INITIAL: StateStack;
|
|
710
|
-
|
|
711
|
-
export { EncodedTokenMetadata, FindOption, FontStyle, type IEmbeddedLanguagesMap, type IGrammar, type IGrammarConfiguration, INITIAL, type IOnigCaptureIndex, type IOnigLib, type IOnigMatch, type IRawGrammar, type IRawTheme, type IRawThemeSetting, type IToken, type ITokenTypeMap, type ITokenizeLineResult, type ITokenizeLineResult2, type OnigScanner, type OnigString, Registry, type RegistryOptions, type StackDiff, type StateStack, StateStackImpl, Theme, disposeOnigString };
|
|
1
|
+
export * from '@shikijs/vscode-textmate';
|
package/dist/themes.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BundledThemeInfo, DynamicImportThemeRegistration } from '@shikijs/
|
|
1
|
+
import { BundledThemeInfo, DynamicImportThemeRegistration } from '@shikijs/core';
|
|
2
2
|
|
|
3
3
|
declare const bundledThemesInfo: BundledThemeInfo[];
|
|
4
4
|
type BundledTheme = 'andromeeda' | 'aurora-x' | 'ayu-dark' | 'catppuccin-frappe' | 'catppuccin-latte' | 'catppuccin-macchiato' | 'catppuccin-mocha' | 'dark-plus' | 'dracula' | 'dracula-soft' | 'everforest-dark' | 'everforest-light' | 'github-dark' | 'github-dark-default' | 'github-dark-dimmed' | 'github-dark-high-contrast' | 'github-light' | 'github-light-default' | 'github-light-high-contrast' | 'gruvbox-dark-hard' | 'gruvbox-dark-medium' | 'gruvbox-dark-soft' | 'gruvbox-light-hard' | 'gruvbox-light-medium' | 'gruvbox-light-soft' | 'houston' | 'kanagawa-dragon' | 'kanagawa-lotus' | 'kanagawa-wave' | 'laserwave' | 'light-plus' | 'material-theme' | 'material-theme-darker' | 'material-theme-lighter' | 'material-theme-ocean' | 'material-theme-palenight' | 'min-dark' | 'min-light' | 'monokai' | 'night-owl' | 'nord' | 'one-dark-pro' | 'one-light' | 'plastic' | 'poimandres' | 'red' | 'rose-pine' | 'rose-pine-dawn' | 'rose-pine-moon' | 'slack-dark' | 'slack-ochin' | 'snazzy-light' | 'solarized-dark' | 'solarized-light' | 'synthwave-84' | 'tokyo-night' | 'vesper' | 'vitesse-black' | 'vitesse-dark' | 'vitesse-light';
|
|
5
5
|
declare const bundledThemes: Record<BundledTheme, DynamicImportThemeRegistration>;
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { bundledThemes, bundledThemesInfo };
|
|
8
|
+
export type { BundledTheme };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { BundledLanguage } from './langs.mjs';
|
|
2
1
|
import { BundledTheme } from './themes.mjs';
|
|
3
2
|
export * from '@shikijs/core/types';
|
|
3
|
+
import { BundledLanguage } from './langs.mjs';
|
|
4
|
+
import '@shikijs/core';
|
|
4
5
|
import '@shikijs/types';
|
|
5
6
|
|
|
6
7
|
type BuiltinLanguage = BundledLanguage;
|
|
7
8
|
type BuiltinTheme = BundledTheme;
|
|
8
9
|
|
|
9
|
-
export {
|
|
10
|
+
export { BundledLanguage, BundledTheme };
|
|
11
|
+
export type { BuiltinLanguage, BuiltinTheme };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shiki",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.3.0",
|
|
5
5
|
"description": "A beautiful Syntax Highlighter.",
|
|
6
6
|
"author": "Pine Wu <octref@gmail.com>; Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@shikijs/vscode-textmate": "^10.0.2",
|
|
50
50
|
"@types/hast": "^3.0.4",
|
|
51
|
-
"@shikijs/core": "3.
|
|
52
|
-
"@shikijs/engine-javascript": "3.
|
|
53
|
-
"@shikijs/engine-oniguruma": "3.
|
|
54
|
-
"@shikijs/themes": "3.
|
|
55
|
-
"@shikijs/langs": "3.
|
|
56
|
-
"@shikijs/types": "3.
|
|
51
|
+
"@shikijs/core": "3.3.0",
|
|
52
|
+
"@shikijs/engine-javascript": "3.3.0",
|
|
53
|
+
"@shikijs/engine-oniguruma": "3.3.0",
|
|
54
|
+
"@shikijs/themes": "3.3.0",
|
|
55
|
+
"@shikijs/langs": "3.3.0",
|
|
56
|
+
"@shikijs/types": "3.3.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"rollup-plugin-copy": "^3.5.0",
|
|
60
|
-
"tm-grammars": "^1.23.
|
|
61
|
-
"tm-themes": "^1.10.
|
|
60
|
+
"tm-grammars": "^1.23.15",
|
|
61
|
+
"tm-themes": "^1.10.5",
|
|
62
62
|
"vscode-oniguruma": "1.7.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
|
-
"build": "
|
|
66
|
-
"dev": "
|
|
65
|
+
"build": "unbuild",
|
|
66
|
+
"dev": "unbuild --stub",
|
|
67
67
|
"test": "vitest",
|
|
68
68
|
"test:cf": "wrangler dev test/cf.ts --port 60001"
|
|
69
69
|
}
|
package/dist/types/index.d.d.mts
DELETED
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
// ## Interfaces
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Info associated with nodes by the ecosystem.
|
|
5
|
-
*
|
|
6
|
-
* This space is guaranteed to never be specified by unist or specifications
|
|
7
|
-
* implementing unist.
|
|
8
|
-
* But you can use it in utilities and plugins to store data.
|
|
9
|
-
*
|
|
10
|
-
* This type can be augmented to register custom data.
|
|
11
|
-
* For example:
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* declare module 'unist' {
|
|
15
|
-
* interface Data {
|
|
16
|
-
* // `someNode.data.myId` is typed as `number | undefined`
|
|
17
|
-
* myId?: number | undefined
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
interface Data$1 {}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* One place in a source file.
|
|
26
|
-
*/
|
|
27
|
-
interface Point {
|
|
28
|
-
/**
|
|
29
|
-
* Line in a source file (1-indexed integer).
|
|
30
|
-
*/
|
|
31
|
-
line: number;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Column in a source file (1-indexed integer).
|
|
35
|
-
*/
|
|
36
|
-
column: number;
|
|
37
|
-
/**
|
|
38
|
-
* Character in a source file (0-indexed integer).
|
|
39
|
-
*/
|
|
40
|
-
offset?: number | undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Position of a node in a source document.
|
|
45
|
-
*
|
|
46
|
-
* A position is a range between two points.
|
|
47
|
-
*/
|
|
48
|
-
interface Position {
|
|
49
|
-
/**
|
|
50
|
-
* Place of the first character of the parsed source region.
|
|
51
|
-
*/
|
|
52
|
-
start: Point;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Place of the first character after the parsed source region.
|
|
56
|
-
*/
|
|
57
|
-
end: Point;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Abstract unist node.
|
|
62
|
-
*
|
|
63
|
-
* The syntactic unit in unist syntax trees are called nodes.
|
|
64
|
-
*
|
|
65
|
-
* This interface is supposed to be extended.
|
|
66
|
-
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
67
|
-
* But for example in markdown, a `thematicBreak` (`***`), is neither literal
|
|
68
|
-
* nor parent, but still a node.
|
|
69
|
-
*/
|
|
70
|
-
interface Node$1 {
|
|
71
|
-
/**
|
|
72
|
-
* Node type.
|
|
73
|
-
*/
|
|
74
|
-
type: string;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Info from the ecosystem.
|
|
78
|
-
*/
|
|
79
|
-
data?: Data$1 | undefined;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Position of a node in a source document.
|
|
83
|
-
*
|
|
84
|
-
* Nodes that are generated (not in the original source document) must not
|
|
85
|
-
* have a position.
|
|
86
|
-
*/
|
|
87
|
-
position?: Position | undefined;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// ## Interfaces
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Info associated with hast nodes by the ecosystem.
|
|
94
|
-
*
|
|
95
|
-
* This space is guaranteed to never be specified by unist or hast.
|
|
96
|
-
* But you can use it in utilities and plugins to store data.
|
|
97
|
-
*
|
|
98
|
-
* This type can be augmented to register custom data.
|
|
99
|
-
* For example:
|
|
100
|
-
*
|
|
101
|
-
* ```ts
|
|
102
|
-
* declare module 'hast' {
|
|
103
|
-
* interface Data {
|
|
104
|
-
* // `someNode.data.myId` is typed as `number | undefined`
|
|
105
|
-
* myId?: number | undefined
|
|
106
|
-
* }
|
|
107
|
-
* }
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
interface Data extends Data$1 {}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Info associated with an element.
|
|
114
|
-
*/
|
|
115
|
-
interface Properties {
|
|
116
|
-
[PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ## Content maps
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Union of registered hast nodes that can occur in {@link Element}.
|
|
123
|
-
*
|
|
124
|
-
* To register mote custom hast nodes, add them to {@link ElementContentMap}.
|
|
125
|
-
* They will be automatically added here.
|
|
126
|
-
*/
|
|
127
|
-
type ElementContent = ElementContentMap[keyof ElementContentMap];
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Registry of all hast nodes that can occur as children of {@link Element}.
|
|
131
|
-
*
|
|
132
|
-
* For a union of all {@link Element} children, see {@link ElementContent}.
|
|
133
|
-
*/
|
|
134
|
-
interface ElementContentMap {
|
|
135
|
-
comment: Comment;
|
|
136
|
-
element: Element;
|
|
137
|
-
text: Text;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Union of registered hast nodes that can occur in {@link Root}.
|
|
142
|
-
*
|
|
143
|
-
* To register custom hast nodes, add them to {@link RootContentMap}.
|
|
144
|
-
* They will be automatically added here.
|
|
145
|
-
*/
|
|
146
|
-
type RootContent = RootContentMap[keyof RootContentMap];
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Registry of all hast nodes that can occur as children of {@link Root}.
|
|
150
|
-
*
|
|
151
|
-
* > 👉 **Note**: {@link Root} does not need to be an entire document.
|
|
152
|
-
* > it can also be a fragment.
|
|
153
|
-
*
|
|
154
|
-
* For a union of all {@link Root} children, see {@link RootContent}.
|
|
155
|
-
*/
|
|
156
|
-
interface RootContentMap {
|
|
157
|
-
comment: Comment;
|
|
158
|
-
doctype: Doctype;
|
|
159
|
-
element: Element;
|
|
160
|
-
text: Text;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// ## Abstract nodes
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Abstract hast node.
|
|
167
|
-
*
|
|
168
|
-
* This interface is supposed to be extended.
|
|
169
|
-
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
170
|
-
* But for example in HTML, a `Doctype` is neither literal nor parent, but
|
|
171
|
-
* still a node.
|
|
172
|
-
*
|
|
173
|
-
* To register custom hast nodes, add them to {@link RootContentMap} and other
|
|
174
|
-
* places where relevant (such as {@link ElementContentMap}).
|
|
175
|
-
*
|
|
176
|
-
* For a union of all registered hast nodes, see {@link Nodes}.
|
|
177
|
-
*/
|
|
178
|
-
interface Node extends Node$1 {
|
|
179
|
-
/**
|
|
180
|
-
* Info from the ecosystem.
|
|
181
|
-
*/
|
|
182
|
-
data?: Data | undefined;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Abstract hast node that contains the smallest possible value.
|
|
187
|
-
*
|
|
188
|
-
* This interface is supposed to be extended if you make custom hast nodes.
|
|
189
|
-
*
|
|
190
|
-
* For a union of all registered hast literals, see {@link Literals}.
|
|
191
|
-
*/
|
|
192
|
-
interface Literal extends Node {
|
|
193
|
-
/**
|
|
194
|
-
* Plain-text value.
|
|
195
|
-
*/
|
|
196
|
-
value: string;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Abstract hast node that contains other hast nodes (*children*).
|
|
201
|
-
*
|
|
202
|
-
* This interface is supposed to be extended if you make custom hast nodes.
|
|
203
|
-
*
|
|
204
|
-
* For a union of all registered hast parents, see {@link Parents}.
|
|
205
|
-
*/
|
|
206
|
-
interface Parent extends Node {
|
|
207
|
-
/**
|
|
208
|
-
* List of children.
|
|
209
|
-
*/
|
|
210
|
-
children: RootContent[];
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// ## Concrete nodes
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* HTML comment.
|
|
217
|
-
*/
|
|
218
|
-
interface Comment extends Literal {
|
|
219
|
-
/**
|
|
220
|
-
* Node type of HTML comments in hast.
|
|
221
|
-
*/
|
|
222
|
-
type: "comment";
|
|
223
|
-
/**
|
|
224
|
-
* Data associated with the comment.
|
|
225
|
-
*/
|
|
226
|
-
data?: CommentData | undefined;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Info associated with hast comments by the ecosystem.
|
|
231
|
-
*/
|
|
232
|
-
interface CommentData extends Data {}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* HTML document type.
|
|
236
|
-
*/
|
|
237
|
-
interface Doctype extends Node$1 {
|
|
238
|
-
/**
|
|
239
|
-
* Node type of HTML document types in hast.
|
|
240
|
-
*/
|
|
241
|
-
type: "doctype";
|
|
242
|
-
/**
|
|
243
|
-
* Data associated with the doctype.
|
|
244
|
-
*/
|
|
245
|
-
data?: DoctypeData | undefined;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Info associated with hast doctypes by the ecosystem.
|
|
250
|
-
*/
|
|
251
|
-
interface DoctypeData extends Data {}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* HTML element.
|
|
255
|
-
*/
|
|
256
|
-
interface Element extends Parent {
|
|
257
|
-
/**
|
|
258
|
-
* Node type of elements.
|
|
259
|
-
*/
|
|
260
|
-
type: "element";
|
|
261
|
-
/**
|
|
262
|
-
* Tag name (such as `'body'`) of the element.
|
|
263
|
-
*/
|
|
264
|
-
tagName: string;
|
|
265
|
-
/**
|
|
266
|
-
* Info associated with the element.
|
|
267
|
-
*/
|
|
268
|
-
properties: Properties;
|
|
269
|
-
/**
|
|
270
|
-
* Children of element.
|
|
271
|
-
*/
|
|
272
|
-
children: ElementContent[];
|
|
273
|
-
/**
|
|
274
|
-
* When the `tagName` field is `'template'`, a `content` field can be
|
|
275
|
-
* present.
|
|
276
|
-
*/
|
|
277
|
-
content?: Root | undefined;
|
|
278
|
-
/**
|
|
279
|
-
* Data associated with the element.
|
|
280
|
-
*/
|
|
281
|
-
data?: ElementData | undefined;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Info associated with hast elements by the ecosystem.
|
|
286
|
-
*/
|
|
287
|
-
interface ElementData extends Data {}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Document fragment or a whole document.
|
|
291
|
-
*
|
|
292
|
-
* Should be used as the root of a tree and must not be used as a child.
|
|
293
|
-
*
|
|
294
|
-
* Can also be used as the value for the content field on a `'template'` element.
|
|
295
|
-
*/
|
|
296
|
-
interface Root extends Parent {
|
|
297
|
-
/**
|
|
298
|
-
* Node type of hast root.
|
|
299
|
-
*/
|
|
300
|
-
type: "root";
|
|
301
|
-
/**
|
|
302
|
-
* Children of root.
|
|
303
|
-
*/
|
|
304
|
-
children: RootContent[];
|
|
305
|
-
/**
|
|
306
|
-
* Data associated with the hast root.
|
|
307
|
-
*/
|
|
308
|
-
data?: RootData | undefined;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Info associated with hast root nodes by the ecosystem.
|
|
313
|
-
*/
|
|
314
|
-
interface RootData extends Data {}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* HTML character data (plain text).
|
|
318
|
-
*/
|
|
319
|
-
interface Text extends Literal {
|
|
320
|
-
/**
|
|
321
|
-
* Node type of HTML character data (plain text) in hast.
|
|
322
|
-
*/
|
|
323
|
-
type: "text";
|
|
324
|
-
/**
|
|
325
|
-
* Data associated with the text.
|
|
326
|
-
*/
|
|
327
|
-
data?: TextData | undefined;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Info associated with hast texts by the ecosystem.
|
|
332
|
-
*/
|
|
333
|
-
interface TextData extends Data {}
|
|
334
|
-
|
|
335
|
-
export type { Root as R };
|