shiki 2.5.0 → 3.0.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 +3 -9
- package/dist/bundle-full.mjs +2 -7
- package/dist/bundle-web.d.mts +3 -9
- package/dist/bundle-web.mjs +2 -7
- package/dist/core-unwasm.d.mts +3 -40
- package/dist/core-unwasm.mjs +3 -0
- package/dist/core.d.mts +1 -1
- package/dist/engine-oniguruma.d.mts +83 -1
- package/dist/index.d.mts +2 -76
- package/dist/index.mjs +1 -2
- package/dist/textmate.d.mts +1 -711
- package/package.json +16 -87
- package/dist/theme-css-variables.d.mts +0 -1
- package/dist/theme-css-variables.mjs +0 -4
- package/dist/types/wasm-dynamic.d.mts +0 -8
- package/dist/wasm-dynamic-K7LwWlz7.js +0 -8
package/dist/bundle-full.d.mts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { R as Root } from './types/index.d.mjs';
|
|
2
2
|
import * as _shikijs_types from '@shikijs/types';
|
|
3
|
-
import { HighlighterGeneric
|
|
3
|
+
import { HighlighterGeneric } from '@shikijs/types';
|
|
4
4
|
import { BundledLanguage } from './langs.mjs';
|
|
5
5
|
export { bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
|
|
6
6
|
import { BundledTheme } from './themes.mjs';
|
|
7
7
|
export { bundledThemes, bundledThemesInfo } from './themes.mjs';
|
|
8
8
|
export * from '@shikijs/core';
|
|
9
|
-
export { g as getWasmInlined } from './types/wasm-dynamic.mjs';
|
|
10
|
-
import '@shikijs/core/types';
|
|
11
9
|
|
|
12
10
|
type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>;
|
|
13
11
|
/**
|
|
@@ -20,7 +18,7 @@ type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>;
|
|
|
20
18
|
* For granular control over the bundle, check:
|
|
21
19
|
* @see https://shiki.style/guide/bundles#fine-grained-bundle
|
|
22
20
|
*/
|
|
23
|
-
declare const createHighlighter: CreateHighlighterFactory<BundledLanguage, BundledTheme>;
|
|
21
|
+
declare const createHighlighter: _shikijs_types.CreateHighlighterFactory<BundledLanguage, BundledTheme>;
|
|
24
22
|
declare const codeToHtml: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<string>;
|
|
25
23
|
declare const codeToHast: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<Root>;
|
|
26
24
|
declare const codeToTokens: (code: string, options: _shikijs_types.CodeToTokensOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.TokensResult>;
|
|
@@ -28,9 +26,5 @@ declare const codeToTokensBase: (code: string, options: _shikijs_types.RequireKe
|
|
|
28
26
|
declare const codeToTokensWithThemes: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensWithThemesOptions<BundledLanguage, BundledTheme>, "lang" | "themes">) => Promise<_shikijs_types.ThemedTokenWithVariants[][]>;
|
|
29
27
|
declare const getSingletonHighlighter: (options?: Partial<_shikijs_types.BundledHighlighterOptions<BundledLanguage, BundledTheme>> | undefined) => Promise<HighlighterGeneric<BundledLanguage, BundledTheme>>;
|
|
30
28
|
declare const getLastGrammarState: ((element: _shikijs_types.ThemedToken[][] | Root) => _shikijs_types.GrammarState) | ((code: string, options: _shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.GrammarState>);
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated Use `createHighlighter` or `getSingletonHighlighter` instead.
|
|
33
|
-
*/
|
|
34
|
-
declare const getHighlighter: CreateHighlighterFactory<BundledLanguage, BundledTheme>;
|
|
35
29
|
|
|
36
|
-
export { BundledLanguage, BundledTheme, type Highlighter, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter,
|
|
30
|
+
export { BundledLanguage, BundledTheme, type Highlighter, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
|
package/dist/bundle-full.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { createSingletonShorthands, createdBundledHighlighter, guessEmbeddedLanguages
|
|
1
|
+
import { createSingletonShorthands, createdBundledHighlighter, guessEmbeddedLanguages } from '@shikijs/core';
|
|
2
2
|
export * from '@shikijs/core';
|
|
3
3
|
import { bundledLanguages } from './langs.mjs';
|
|
4
4
|
export { bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
|
|
5
5
|
import { bundledThemes } from './themes.mjs';
|
|
6
6
|
export { bundledThemesInfo } from './themes.mjs';
|
|
7
|
-
export { g as getWasmInlined } from './wasm-dynamic-K7LwWlz7.js';
|
|
8
7
|
import { createOnigurumaEngine } from '@shikijs/engine-oniguruma';
|
|
9
8
|
|
|
10
9
|
const createHighlighter = /* @__PURE__ */ createdBundledHighlighter({
|
|
@@ -24,9 +23,5 @@ const {
|
|
|
24
23
|
createHighlighter,
|
|
25
24
|
{ guessEmbeddedLanguages }
|
|
26
25
|
);
|
|
27
|
-
const getHighlighter = (options) => {
|
|
28
|
-
warnDeprecated("`getHighlighter` is deprecated. Use `createHighlighter` or `getSingletonHighlighter` instead.");
|
|
29
|
-
return createHighlighter(options);
|
|
30
|
-
};
|
|
31
26
|
|
|
32
|
-
export { bundledLanguages, bundledThemes, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter,
|
|
27
|
+
export { bundledLanguages, bundledThemes, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
|
package/dist/bundle-web.d.mts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { R as Root } from './types/index.d.mjs';
|
|
2
2
|
import * as _shikijs_types from '@shikijs/types';
|
|
3
|
-
import { BundledLanguageInfo, DynamicImportLanguageRegistration, HighlighterGeneric
|
|
3
|
+
import { BundledLanguageInfo, DynamicImportLanguageRegistration, HighlighterGeneric } from '@shikijs/types';
|
|
4
4
|
import { BundledTheme } from './themes.mjs';
|
|
5
5
|
export { bundledThemes, bundledThemesInfo } from './themes.mjs';
|
|
6
6
|
export * from '@shikijs/core';
|
|
7
|
-
export { g as getWasmInlined } from './types/wasm-dynamic.mjs';
|
|
8
|
-
import '@shikijs/core/types';
|
|
9
7
|
|
|
10
8
|
declare const bundledLanguagesInfo: BundledLanguageInfo[];
|
|
11
9
|
declare const bundledLanguagesBase: {
|
|
@@ -28,7 +26,7 @@ type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>;
|
|
|
28
26
|
* For granular control over the bundle, check:
|
|
29
27
|
* @see https://shiki.style/guide/bundles#fine-grained-bundle
|
|
30
28
|
*/
|
|
31
|
-
declare const createHighlighter: CreateHighlighterFactory<BundledLanguage, BundledTheme>;
|
|
29
|
+
declare const createHighlighter: _shikijs_types.CreateHighlighterFactory<BundledLanguage, BundledTheme>;
|
|
32
30
|
declare const codeToHtml: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<string>;
|
|
33
31
|
declare const codeToHast: (code: string, options: _shikijs_types.CodeToHastOptions<BundledLanguage, BundledTheme>) => Promise<Root>;
|
|
34
32
|
declare const codeToTokensBase: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>, "lang" | "theme">) => Promise<_shikijs_types.ThemedToken[][]>;
|
|
@@ -36,9 +34,5 @@ declare const codeToTokens: (code: string, options: _shikijs_types.CodeToTokensO
|
|
|
36
34
|
declare const codeToTokensWithThemes: (code: string, options: _shikijs_types.RequireKeys<_shikijs_types.CodeToTokensWithThemesOptions<BundledLanguage, BundledTheme>, "lang" | "themes">) => Promise<_shikijs_types.ThemedTokenWithVariants[][]>;
|
|
37
35
|
declare const getSingletonHighlighter: (options?: Partial<_shikijs_types.BundledHighlighterOptions<BundledLanguage, BundledTheme>> | undefined) => Promise<HighlighterGeneric<BundledLanguage, BundledTheme>>;
|
|
38
36
|
declare const getLastGrammarState: ((element: _shikijs_types.ThemedToken[][] | Root) => _shikijs_types.GrammarState) | ((code: string, options: _shikijs_types.CodeToTokensBaseOptions<BundledLanguage, BundledTheme>) => Promise<_shikijs_types.GrammarState>);
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Use `createHighlighter` or `getSingletonHighlighter` instead.
|
|
41
|
-
*/
|
|
42
|
-
declare const getHighlighter: CreateHighlighterFactory<BundledLanguage, BundledTheme>;
|
|
43
37
|
|
|
44
|
-
export { type BundledLanguage, BundledTheme, type Highlighter, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter,
|
|
38
|
+
export { type BundledLanguage, BundledTheme, type Highlighter, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
|
package/dist/bundle-web.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { createSingletonShorthands, createdBundledHighlighter, guessEmbeddedLanguages
|
|
1
|
+
import { createSingletonShorthands, createdBundledHighlighter, guessEmbeddedLanguages } from '@shikijs/core';
|
|
2
2
|
export * from '@shikijs/core';
|
|
3
3
|
import { bundledThemes } from './themes.mjs';
|
|
4
4
|
export { bundledThemesInfo } from './themes.mjs';
|
|
5
|
-
export { g as getWasmInlined } from './wasm-dynamic-K7LwWlz7.js';
|
|
6
5
|
import { createOnigurumaEngine } from '@shikijs/engine-oniguruma';
|
|
7
6
|
|
|
8
7
|
const bundledLanguagesInfo = [
|
|
@@ -339,9 +338,5 @@ const {
|
|
|
339
338
|
createHighlighter,
|
|
340
339
|
{ guessEmbeddedLanguages }
|
|
341
340
|
);
|
|
342
|
-
const getHighlighter = (options) => {
|
|
343
|
-
warnDeprecated("`getHighlighter` is deprecated. Use `createHighlighter` or `getSingletonHighlighter` instead.");
|
|
344
|
-
return createHighlighter(options);
|
|
345
|
-
};
|
|
346
341
|
|
|
347
|
-
export { bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo, bundledThemes, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter,
|
|
342
|
+
export { bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo, bundledThemes, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
|
package/dist/core-unwasm.d.mts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { HighlighterGeneric, Awaitable, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, GrammarState, ShikiInternal, ShikiTransformerContextCommon, ThemeRegistration, HighlighterCoreOptions, HighlighterCore,
|
|
1
|
+
import { HighlighterGeneric, Awaitable, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, GrammarState, ShikiInternal, ShikiTransformerContextCommon, ThemeRegistration, HighlighterCoreOptions, HighlighterCore, Position, CreateHighlighterFactory, CreatedBundledHighlighterOptions, TokenStyles, ThemeInput, PlainTextLanguage, SpecialLanguage, SpecialTheme, MaybeGetter, ThemeRegistrationAny, ThemeRegistrationResolved, TokenizeWithThemeOptions, MaybeArray, Grammar, CodeToHastRenderOptions, ShikiTransformerContextSource, ShikiTransformer } from '@shikijs/types';
|
|
2
2
|
export * from '@shikijs/types';
|
|
3
3
|
import { a as RootContent, N as Nodes, R as Root, E as Element } from './types/index.d.mjs';
|
|
4
|
-
import { JavaScriptRegexEngineOptions } from '@shikijs/engine-javascript';
|
|
5
|
-
export { FontStyle, EncodedTokenMetadata as StackElementMetadata } from './textmate.mjs';
|
|
6
4
|
|
|
7
5
|
type FormatSmartOptions = {
|
|
8
6
|
/**
|
|
@@ -243,12 +241,6 @@ type Space = "html" | "svg";
|
|
|
243
241
|
* @param options
|
|
244
242
|
*/
|
|
245
243
|
declare function createdBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(options: CreatedBundledHighlighterOptions<BundledLangs, BundledThemes>): CreateHighlighterFactory<BundledLangs, BundledThemes>;
|
|
246
|
-
/**
|
|
247
|
-
* Create a `createHighlighter` function with bundled themes and languages.
|
|
248
|
-
*
|
|
249
|
-
* @deprecated Use `createdBundledHighlighter({ langs, themes, engine })` signature instead.
|
|
250
|
-
*/
|
|
251
|
-
declare function createdBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(bundledLanguages: Record<BundledLangs, LanguageInput>, bundledThemes: Record<BundledThemes, ThemeInput>, loadWasm: HighlighterCoreOptions['loadWasm']): CreateHighlighterFactory<BundledLangs, BundledThemes>;
|
|
252
244
|
interface ShorthandsBundle<L extends string, T extends string> {
|
|
253
245
|
/**
|
|
254
246
|
* Shorthand for `codeToHtml` with auto-loaded theme and language.
|
|
@@ -322,19 +314,11 @@ declare function createHighlighterCore(options: HighlighterCoreOptions<false>):
|
|
|
322
314
|
declare function createHighlighterCoreSync(options: HighlighterCoreOptions<true>): HighlighterCore;
|
|
323
315
|
declare function makeSingletonHighlighterCore(createHighlighter: typeof createHighlighterCore): (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
|
|
324
316
|
declare const getSingletonHighlighterCore: (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
|
|
325
|
-
/**
|
|
326
|
-
* @deprecated Use `createHighlighterCore` or `getSingletonHighlighterCore` instead.
|
|
327
|
-
*/
|
|
328
|
-
declare function getHighlighterCore(options: HighlighterCoreOptions): Promise<HighlighterCore>;
|
|
329
317
|
|
|
330
318
|
/**
|
|
331
319
|
* Get the minimal shiki context for rendering.
|
|
332
320
|
*/
|
|
333
321
|
declare function createShikiInternal(options: HighlighterCoreOptions): Promise<ShikiInternal>;
|
|
334
|
-
/**
|
|
335
|
-
* @deprecated Use `createShikiInternal` instead.
|
|
336
|
-
*/
|
|
337
|
-
declare function getShikiInternal(options: HighlighterCoreOptions): Promise<ShikiInternal>;
|
|
338
322
|
|
|
339
323
|
/**
|
|
340
324
|
* Get the minimal shiki context for rendering.
|
|
@@ -343,31 +327,10 @@ declare function getShikiInternal(options: HighlighterCoreOptions): Promise<Shik
|
|
|
343
327
|
*/
|
|
344
328
|
declare function createShikiInternalSync(options: HighlighterCoreOptions<true>): ShikiInternal;
|
|
345
329
|
|
|
346
|
-
/**
|
|
347
|
-
* @deprecated Import `createJavaScriptRegexEngine` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead.
|
|
348
|
-
*/
|
|
349
|
-
declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
|
|
350
|
-
/**
|
|
351
|
-
* @deprecated Import `defaultJavaScriptRegexConstructor` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead.
|
|
352
|
-
*/
|
|
353
|
-
declare function defaultJavaScriptRegexConstructor(pattern: string): RegExp;
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* @deprecated Import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
|
|
357
|
-
*/
|
|
358
|
-
declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
|
|
359
|
-
/**
|
|
360
|
-
* @deprecated Import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
|
|
361
|
-
*/
|
|
362
|
-
declare function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
|
|
363
|
-
/**
|
|
364
|
-
* @deprecated Import `loadWasm` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
|
|
365
|
-
*/
|
|
366
|
-
declare function loadWasm(options: LoadWasmOptions): Promise<void>;
|
|
367
|
-
|
|
368
330
|
declare function codeToHast(internal: ShikiInternal, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
|
|
369
331
|
declare function tokensToHast(tokens: ThemedToken[][], options: CodeToHastRenderOptions, transformerContext: ShikiTransformerContextSource, grammarState?: GrammarState | undefined): Root;
|
|
370
332
|
|
|
333
|
+
declare const hastToHtml: typeof toHtml;
|
|
371
334
|
/**
|
|
372
335
|
* Get highlighted code in HTML.
|
|
373
336
|
*/
|
|
@@ -526,4 +489,4 @@ declare function enableDeprecationWarnings(emitDeprecation?: DeprecationTarget |
|
|
|
526
489
|
*/
|
|
527
490
|
declare function warnDeprecated(message: string, version?: DeprecationTarget): void;
|
|
528
491
|
|
|
529
|
-
export { type CreateSingletonShorthandsOptions, type CssVariablesThemeOptions, type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync,
|
|
492
|
+
export { type CreateSingletonShorthandsOptions, type CssVariablesThemeOptions, type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createdBundledHighlighter, enableDeprecationWarnings, flatTokenVariants, getSingletonHighlighterCore, getTokenStyleObject, guessEmbeddedLanguages, hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
|
package/dist/core-unwasm.mjs
CHANGED
package/dist/core.d.mts
CHANGED
|
@@ -1 +1,83 @@
|
|
|
1
|
-
|
|
1
|
+
interface IOnigCaptureIndex {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
length: number;
|
|
5
|
+
}
|
|
6
|
+
interface IOnigMatch {
|
|
7
|
+
index: number;
|
|
8
|
+
captureIndices: IOnigCaptureIndex[];
|
|
9
|
+
}
|
|
10
|
+
declare const enum FindOption {
|
|
11
|
+
None = 0,
|
|
12
|
+
/**
|
|
13
|
+
* equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
|
|
14
|
+
*/
|
|
15
|
+
NotBeginString = 1,
|
|
16
|
+
/**
|
|
17
|
+
* equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
|
|
18
|
+
*/
|
|
19
|
+
NotEndString = 2,
|
|
20
|
+
/**
|
|
21
|
+
* equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
|
|
22
|
+
*/
|
|
23
|
+
NotBeginPosition = 4,
|
|
24
|
+
/**
|
|
25
|
+
* used for debugging purposes.
|
|
26
|
+
*/
|
|
27
|
+
DebugCall = 8
|
|
28
|
+
}
|
|
29
|
+
interface OnigScanner {
|
|
30
|
+
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
|
|
31
|
+
dispose?(): void;
|
|
32
|
+
}
|
|
33
|
+
interface OnigString {
|
|
34
|
+
readonly content: string;
|
|
35
|
+
dispose?(): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A union of given const enum values.
|
|
40
|
+
*/
|
|
41
|
+
type OrMask<T extends number> = number;
|
|
42
|
+
|
|
43
|
+
type Awaitable<T> = T | Promise<T>;
|
|
44
|
+
|
|
45
|
+
interface PatternScanner extends OnigScanner {
|
|
46
|
+
}
|
|
47
|
+
interface RegexEngineString extends OnigString {
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Engine for RegExp matching and scanning.
|
|
51
|
+
*/
|
|
52
|
+
interface RegexEngine {
|
|
53
|
+
createScanner: (patterns: (string | RegExp)[]) => PatternScanner;
|
|
54
|
+
createString: (s: string) => RegexEngineString;
|
|
55
|
+
}
|
|
56
|
+
interface WebAssemblyInstantiator {
|
|
57
|
+
(importObject: Record<string, Record<string, WebAssembly.ImportValue>> | undefined): Promise<WebAssemblyInstance>;
|
|
58
|
+
}
|
|
59
|
+
type WebAssemblyInstance = WebAssembly.WebAssemblyInstantiatedSource | WebAssembly.Instance | WebAssembly.Instance['exports'];
|
|
60
|
+
type OnigurumaLoadOptions = {
|
|
61
|
+
instantiator: WebAssemblyInstantiator;
|
|
62
|
+
} | {
|
|
63
|
+
default: WebAssemblyInstantiator;
|
|
64
|
+
} | {
|
|
65
|
+
data: ArrayBufferView | ArrayBuffer | Response;
|
|
66
|
+
};
|
|
67
|
+
type LoadWasmOptionsPlain = OnigurumaLoadOptions | WebAssemblyInstantiator | ArrayBufferView | ArrayBuffer | Response;
|
|
68
|
+
type LoadWasmOptions = Awaitable<LoadWasmOptionsPlain> | (() => Awaitable<LoadWasmOptionsPlain>);
|
|
69
|
+
|
|
70
|
+
declare function loadWasm(options: LoadWasmOptions): Promise<void>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Set the default wasm loader for `loadWasm`.
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
declare function setDefaultWasmLoader(_loader: LoadWasmOptions): void;
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
declare function getDefaultWasmLoader(): LoadWasmOptions | undefined;
|
|
81
|
+
declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
|
|
82
|
+
|
|
83
|
+
export { createOnigurumaEngine, getDefaultWasmLoader, loadWasm, setDefaultWasmLoader };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,84 +1,10 @@
|
|
|
1
|
-
export { Highlighter, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter,
|
|
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 {
|
|
4
|
+
export { createOnigurumaEngine, loadWasm } from './engine-oniguruma.mjs';
|
|
5
5
|
export * from '@shikijs/core';
|
|
6
6
|
export { BundledLanguage, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
|
|
7
7
|
export { BundledTheme, bundledThemes, bundledThemesInfo } from './themes.mjs';
|
|
8
8
|
import './types/index.d.mjs';
|
|
9
9
|
import '@shikijs/types';
|
|
10
10
|
import '@shikijs/core/types';
|
|
11
|
-
|
|
12
|
-
interface IOnigCaptureIndex {
|
|
13
|
-
start: number;
|
|
14
|
-
end: number;
|
|
15
|
-
length: number;
|
|
16
|
-
}
|
|
17
|
-
interface IOnigMatch {
|
|
18
|
-
index: number;
|
|
19
|
-
captureIndices: IOnigCaptureIndex[];
|
|
20
|
-
}
|
|
21
|
-
declare const enum FindOption {
|
|
22
|
-
None = 0,
|
|
23
|
-
/**
|
|
24
|
-
* equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
|
|
25
|
-
*/
|
|
26
|
-
NotBeginString = 1,
|
|
27
|
-
/**
|
|
28
|
-
* equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
|
|
29
|
-
*/
|
|
30
|
-
NotEndString = 2,
|
|
31
|
-
/**
|
|
32
|
-
* equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
|
|
33
|
-
*/
|
|
34
|
-
NotBeginPosition = 4,
|
|
35
|
-
/**
|
|
36
|
-
* used for debugging purposes.
|
|
37
|
-
*/
|
|
38
|
-
DebugCall = 8
|
|
39
|
-
}
|
|
40
|
-
interface OnigScanner {
|
|
41
|
-
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
|
|
42
|
-
dispose?(): void;
|
|
43
|
-
}
|
|
44
|
-
interface OnigString {
|
|
45
|
-
readonly content: string;
|
|
46
|
-
dispose?(): void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* A union of given const enum values.
|
|
51
|
-
*/
|
|
52
|
-
type OrMask<T extends number> = number;
|
|
53
|
-
|
|
54
|
-
type Awaitable<T> = T | Promise<T>;
|
|
55
|
-
|
|
56
|
-
interface PatternScanner extends OnigScanner {
|
|
57
|
-
}
|
|
58
|
-
interface RegexEngineString extends OnigString {
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Engine for RegExp matching and scanning.
|
|
62
|
-
*/
|
|
63
|
-
interface RegexEngine {
|
|
64
|
-
createScanner: (patterns: (string | RegExp)[]) => PatternScanner;
|
|
65
|
-
createString: (s: string) => RegexEngineString;
|
|
66
|
-
}
|
|
67
|
-
interface WebAssemblyInstantiator {
|
|
68
|
-
(importObject: Record<string, Record<string, WebAssembly.ImportValue>> | undefined): Promise<WebAssemblyInstance>;
|
|
69
|
-
}
|
|
70
|
-
type WebAssemblyInstance = WebAssembly.WebAssemblyInstantiatedSource | WebAssembly.Instance | WebAssembly.Instance['exports'];
|
|
71
|
-
type OnigurumaLoadOptions = {
|
|
72
|
-
instantiator: WebAssemblyInstantiator;
|
|
73
|
-
} | {
|
|
74
|
-
default: WebAssemblyInstantiator;
|
|
75
|
-
} | {
|
|
76
|
-
data: ArrayBufferView | ArrayBuffer | Response;
|
|
77
|
-
};
|
|
78
|
-
type LoadWasmOptionsPlain = OnigurumaLoadOptions | WebAssemblyInstantiator | ArrayBufferView | ArrayBuffer | Response;
|
|
79
|
-
type LoadWasmOptions = Awaitable<LoadWasmOptionsPlain> | (() => Awaitable<LoadWasmOptionsPlain>);
|
|
80
|
-
|
|
81
|
-
declare function loadWasm(options: LoadWasmOptions): Promise<void>;
|
|
82
|
-
declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
|
|
83
|
-
|
|
84
|
-
export { createOnigurumaEngine, loadWasm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter,
|
|
1
|
+
export { codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter } from './bundle-full.mjs';
|
|
2
2
|
export { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
|
|
3
3
|
export { createOnigurumaEngine, loadWasm } from '@shikijs/engine-oniguruma';
|
|
4
|
-
export { g as getWasmInlined } from './wasm-dynamic-K7LwWlz7.js';
|
|
5
4
|
export * from '@shikijs/core';
|
|
6
5
|
export { bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
|
|
7
6
|
export { bundledThemes, bundledThemesInfo } from './themes.mjs';
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shiki",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.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",
|
|
@@ -17,56 +17,23 @@
|
|
|
17
17
|
],
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
-
".":
|
|
21
|
-
"types": "./dist/index.d.mts",
|
|
22
|
-
"default": "./dist/index.mjs"
|
|
23
|
-
},
|
|
20
|
+
".": "./dist/index.mjs",
|
|
24
21
|
"./core": {
|
|
25
|
-
"types": "./dist/core.d.mts",
|
|
26
22
|
"unwasm": "./dist/core-unwasm.mjs",
|
|
27
23
|
"default": "./dist/core.mjs"
|
|
28
24
|
},
|
|
29
25
|
"./wasm": {
|
|
30
26
|
"unwasm": "./dist/onig.wasm",
|
|
31
|
-
"types": "./dist/wasm.d.mts",
|
|
32
27
|
"default": "./dist/wasm.mjs"
|
|
33
28
|
},
|
|
34
|
-
"./langs":
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"./
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"./types": {
|
|
43
|
-
"types": "./dist/types.d.mts",
|
|
44
|
-
"default": "./dist/types.mjs"
|
|
45
|
-
},
|
|
46
|
-
"./theme-css-variables": {
|
|
47
|
-
"types": "./dist/theme-css-variables.d.mts",
|
|
48
|
-
"default": "./dist/theme-css-variables.mjs"
|
|
49
|
-
},
|
|
50
|
-
"./engine/javascript": {
|
|
51
|
-
"types": "./dist/engine-javascript.d.mts",
|
|
52
|
-
"default": "./dist/engine-javascript.mjs"
|
|
53
|
-
},
|
|
54
|
-
"./engine/oniguruma": {
|
|
55
|
-
"types": "./dist/engine-oniguruma.d.mts",
|
|
56
|
-
"default": "./dist/engine-oniguruma.mjs"
|
|
57
|
-
},
|
|
58
|
-
"./textmate": {
|
|
59
|
-
"types": "./dist/textmate.d.mts",
|
|
60
|
-
"default": "./dist/textmate.mjs"
|
|
61
|
-
},
|
|
62
|
-
"./bundle/full": {
|
|
63
|
-
"types": "./dist/bundle-full.d.mts",
|
|
64
|
-
"default": "./dist/bundle-full.mjs"
|
|
65
|
-
},
|
|
66
|
-
"./bundle/web": {
|
|
67
|
-
"types": "./dist/bundle-web.d.mts",
|
|
68
|
-
"default": "./dist/bundle-web.mjs"
|
|
69
|
-
},
|
|
29
|
+
"./langs": "./dist/langs.mjs",
|
|
30
|
+
"./themes": "./dist/themes.mjs",
|
|
31
|
+
"./types": "./dist/types.mjs",
|
|
32
|
+
"./engine/javascript": "./dist/engine-javascript.mjs",
|
|
33
|
+
"./engine/oniguruma": "./dist/engine-oniguruma.mjs",
|
|
34
|
+
"./textmate": "./dist/textmate.mjs",
|
|
35
|
+
"./bundle/full": "./dist/bundle-full.mjs",
|
|
36
|
+
"./bundle/web": "./dist/bundle-web.mjs",
|
|
70
37
|
"./onig.wasm": "./dist/onig.wasm",
|
|
71
38
|
"./dist/*": "./dist/*",
|
|
72
39
|
"./package.json": "./package.json",
|
|
@@ -75,56 +42,18 @@
|
|
|
75
42
|
"main": "./dist/index.mjs",
|
|
76
43
|
"module": "./dist/index.mjs",
|
|
77
44
|
"types": "./dist/index.d.mts",
|
|
78
|
-
"typesVersions": {
|
|
79
|
-
"*": {
|
|
80
|
-
"core": [
|
|
81
|
-
"./dist/core.d.mts"
|
|
82
|
-
],
|
|
83
|
-
"wasm": [
|
|
84
|
-
"./dist/wasm.d.mts"
|
|
85
|
-
],
|
|
86
|
-
"langs": [
|
|
87
|
-
"./dist/langs.d.mts"
|
|
88
|
-
],
|
|
89
|
-
"themes": [
|
|
90
|
-
"./dist/themes.d.mts"
|
|
91
|
-
],
|
|
92
|
-
"bundle/full": [
|
|
93
|
-
"./dist/bundle-full.d.mts"
|
|
94
|
-
],
|
|
95
|
-
"bundle/web": [
|
|
96
|
-
"./dist/bundle-web.d.mts"
|
|
97
|
-
],
|
|
98
|
-
"engine/javascript": [
|
|
99
|
-
"./dist/engine-javascript.d.mts"
|
|
100
|
-
],
|
|
101
|
-
"engine/oniguruma": [
|
|
102
|
-
"./dist/engine-oniguruma.d.mts"
|
|
103
|
-
],
|
|
104
|
-
"textmate": [
|
|
105
|
-
"./dist/textmate.d.mts"
|
|
106
|
-
],
|
|
107
|
-
"theme-css-variables": [
|
|
108
|
-
"./dist/theme-css-variables.d.mts"
|
|
109
|
-
],
|
|
110
|
-
"*": [
|
|
111
|
-
"./dist/*",
|
|
112
|
-
"./*"
|
|
113
|
-
]
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
45
|
"files": [
|
|
117
46
|
"dist"
|
|
118
47
|
],
|
|
119
48
|
"dependencies": {
|
|
120
49
|
"@shikijs/vscode-textmate": "^10.0.2",
|
|
121
50
|
"@types/hast": "^3.0.4",
|
|
122
|
-
"@shikijs/core": "
|
|
123
|
-
"@shikijs/engine-
|
|
124
|
-
"@shikijs/engine-
|
|
125
|
-
"@shikijs/themes": "
|
|
126
|
-
"@shikijs/langs": "
|
|
127
|
-
"@shikijs/types": "
|
|
51
|
+
"@shikijs/core": "3.0.0",
|
|
52
|
+
"@shikijs/engine-javascript": "3.0.0",
|
|
53
|
+
"@shikijs/engine-oniguruma": "3.0.0",
|
|
54
|
+
"@shikijs/themes": "3.0.0",
|
|
55
|
+
"@shikijs/langs": "3.0.0",
|
|
56
|
+
"@shikijs/types": "3.0.0"
|
|
128
57
|
},
|
|
129
58
|
"devDependencies": {
|
|
130
59
|
"rollup-plugin-copy": "^3.5.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CssVariablesThemeOptions, createCssVariablesTheme } from '@shikijs/core';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { warnDeprecated } from '@shikijs/core';
|
|
2
|
-
|
|
3
|
-
const getWasmInlined = async (info) => {
|
|
4
|
-
warnDeprecated('`getWasmInlined` is deprecated. Use `import("shiki/wasm")` instead.');
|
|
5
|
-
return import('shiki/wasm').then((wasm) => wasm.default(info));
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export { getWasmInlined as g };
|