shiki 2.4.2 → 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 -78
- package/dist/core.d.mts +1 -1
- package/dist/engine-javascript.d.mts +1 -88
- package/dist/engine-oniguruma.d.mts +83 -1
- package/dist/index.d.mts +2 -76
- package/dist/index.mjs +1 -2
- 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,46 +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
|
-
|
|
6
|
-
declare const enum FontStyle {
|
|
7
|
-
NotSet = -1,
|
|
8
|
-
None = 0,
|
|
9
|
-
Italic = 1,
|
|
10
|
-
Bold = 2,
|
|
11
|
-
Underline = 4,
|
|
12
|
-
Strikethrough = 8
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type EncodedTokenAttributes = number;
|
|
16
|
-
declare class EncodedTokenMetadata {
|
|
17
|
-
static toBinaryStr(encodedTokenAttributes: EncodedTokenAttributes): string;
|
|
18
|
-
static print(encodedTokenAttributes: EncodedTokenAttributes): void;
|
|
19
|
-
static getLanguageId(encodedTokenAttributes: EncodedTokenAttributes): number;
|
|
20
|
-
static getTokenType(encodedTokenAttributes: EncodedTokenAttributes): StandardTokenType;
|
|
21
|
-
static containsBalancedBrackets(encodedTokenAttributes: EncodedTokenAttributes): boolean;
|
|
22
|
-
static getFontStyle(encodedTokenAttributes: EncodedTokenAttributes): number;
|
|
23
|
-
static getForeground(encodedTokenAttributes: EncodedTokenAttributes): number;
|
|
24
|
-
static getBackground(encodedTokenAttributes: EncodedTokenAttributes): number;
|
|
25
|
-
/**
|
|
26
|
-
* Updates the fields in `metadata`.
|
|
27
|
-
* A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is.
|
|
28
|
-
*/
|
|
29
|
-
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;
|
|
30
|
-
}
|
|
31
|
-
declare const enum StandardTokenType {
|
|
32
|
-
Other = 0,
|
|
33
|
-
Comment = 1,
|
|
34
|
-
String = 2,
|
|
35
|
-
RegEx = 3
|
|
36
|
-
}
|
|
37
|
-
declare const enum OptionalStandardTokenType {
|
|
38
|
-
Other = 0,
|
|
39
|
-
Comment = 1,
|
|
40
|
-
String = 2,
|
|
41
|
-
RegEx = 3,
|
|
42
|
-
NotSet = 8
|
|
43
|
-
}
|
|
44
4
|
|
|
45
5
|
type FormatSmartOptions = {
|
|
46
6
|
/**
|
|
@@ -281,12 +241,6 @@ type Space = "html" | "svg";
|
|
|
281
241
|
* @param options
|
|
282
242
|
*/
|
|
283
243
|
declare function createdBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(options: CreatedBundledHighlighterOptions<BundledLangs, BundledThemes>): CreateHighlighterFactory<BundledLangs, BundledThemes>;
|
|
284
|
-
/**
|
|
285
|
-
* Create a `createHighlighter` function with bundled themes and languages.
|
|
286
|
-
*
|
|
287
|
-
* @deprecated Use `createdBundledHighlighter({ langs, themes, engine })` signature instead.
|
|
288
|
-
*/
|
|
289
|
-
declare function createdBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(bundledLanguages: Record<BundledLangs, LanguageInput>, bundledThemes: Record<BundledThemes, ThemeInput>, loadWasm: HighlighterCoreOptions['loadWasm']): CreateHighlighterFactory<BundledLangs, BundledThemes>;
|
|
290
244
|
interface ShorthandsBundle<L extends string, T extends string> {
|
|
291
245
|
/**
|
|
292
246
|
* Shorthand for `codeToHtml` with auto-loaded theme and language.
|
|
@@ -360,19 +314,11 @@ declare function createHighlighterCore(options: HighlighterCoreOptions<false>):
|
|
|
360
314
|
declare function createHighlighterCoreSync(options: HighlighterCoreOptions<true>): HighlighterCore;
|
|
361
315
|
declare function makeSingletonHighlighterCore(createHighlighter: typeof createHighlighterCore): (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
|
|
362
316
|
declare const getSingletonHighlighterCore: (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
|
|
363
|
-
/**
|
|
364
|
-
* @deprecated Use `createHighlighterCore` or `getSingletonHighlighterCore` instead.
|
|
365
|
-
*/
|
|
366
|
-
declare function getHighlighterCore(options: HighlighterCoreOptions): Promise<HighlighterCore>;
|
|
367
317
|
|
|
368
318
|
/**
|
|
369
319
|
* Get the minimal shiki context for rendering.
|
|
370
320
|
*/
|
|
371
321
|
declare function createShikiInternal(options: HighlighterCoreOptions): Promise<ShikiInternal>;
|
|
372
|
-
/**
|
|
373
|
-
* @deprecated Use `createShikiInternal` instead.
|
|
374
|
-
*/
|
|
375
|
-
declare function getShikiInternal(options: HighlighterCoreOptions): Promise<ShikiInternal>;
|
|
376
322
|
|
|
377
323
|
/**
|
|
378
324
|
* Get the minimal shiki context for rendering.
|
|
@@ -381,31 +327,10 @@ declare function getShikiInternal(options: HighlighterCoreOptions): Promise<Shik
|
|
|
381
327
|
*/
|
|
382
328
|
declare function createShikiInternalSync(options: HighlighterCoreOptions<true>): ShikiInternal;
|
|
383
329
|
|
|
384
|
-
/**
|
|
385
|
-
* @deprecated Import `createJavaScriptRegexEngine` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead.
|
|
386
|
-
*/
|
|
387
|
-
declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
|
|
388
|
-
/**
|
|
389
|
-
* @deprecated Import `defaultJavaScriptRegexConstructor` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead.
|
|
390
|
-
*/
|
|
391
|
-
declare function defaultJavaScriptRegexConstructor(pattern: string): RegExp;
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* @deprecated Import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
|
|
395
|
-
*/
|
|
396
|
-
declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
|
|
397
|
-
/**
|
|
398
|
-
* @deprecated Import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
|
|
399
|
-
*/
|
|
400
|
-
declare function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
|
|
401
|
-
/**
|
|
402
|
-
* @deprecated Import `loadWasm` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
|
|
403
|
-
*/
|
|
404
|
-
declare function loadWasm(options: LoadWasmOptions): Promise<void>;
|
|
405
|
-
|
|
406
330
|
declare function codeToHast(internal: ShikiInternal, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
|
|
407
331
|
declare function tokensToHast(tokens: ThemedToken[][], options: CodeToHastRenderOptions, transformerContext: ShikiTransformerContextSource, grammarState?: GrammarState | undefined): Root;
|
|
408
332
|
|
|
333
|
+
declare const hastToHtml: typeof toHtml;
|
|
409
334
|
/**
|
|
410
335
|
* Get highlighted code in HTML.
|
|
411
336
|
*/
|
|
@@ -564,4 +489,4 @@ declare function enableDeprecationWarnings(emitDeprecation?: DeprecationTarget |
|
|
|
564
489
|
*/
|
|
565
490
|
declare function warnDeprecated(message: string, version?: DeprecationTarget): void;
|
|
566
491
|
|
|
567
|
-
export { type CreateSingletonShorthandsOptions, type CssVariablesThemeOptions,
|
|
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.d.mts
CHANGED
|
@@ -1,88 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { IOnigMatch } from '@shikijs/vscode-textmate';
|
|
3
|
-
|
|
4
|
-
type ToRegExpOptions = {
|
|
5
|
-
accuracy?: "default" | "strict";
|
|
6
|
-
avoidSubclass?: boolean;
|
|
7
|
-
flags?: string;
|
|
8
|
-
global?: boolean;
|
|
9
|
-
hasIndices?: boolean;
|
|
10
|
-
lazyCompileLength?: number;
|
|
11
|
-
rules?: {
|
|
12
|
-
allowOrphanBackrefs?: boolean;
|
|
13
|
-
asciiWordBoundaries?: boolean;
|
|
14
|
-
captureGroup?: boolean;
|
|
15
|
-
recursionLimit?: number;
|
|
16
|
-
singleline?: boolean;
|
|
17
|
-
};
|
|
18
|
-
target?: "auto" | "ES2025" | "ES2024" | "ES2018";
|
|
19
|
-
verbose?: boolean;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
interface JavaScriptRegexScannerOptions {
|
|
23
|
-
/**
|
|
24
|
-
* Whether to allow invalid regex patterns.
|
|
25
|
-
*
|
|
26
|
-
* @default false
|
|
27
|
-
*/
|
|
28
|
-
forgiving?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Cache for regex patterns.
|
|
31
|
-
*/
|
|
32
|
-
cache?: Map<string, RegExp | Error> | null;
|
|
33
|
-
/**
|
|
34
|
-
* Custom pattern to RegExp constructor.
|
|
35
|
-
*
|
|
36
|
-
* By default `oniguruma-to-es` is used.
|
|
37
|
-
*/
|
|
38
|
-
regexConstructor?: (pattern: string) => RegExp;
|
|
39
|
-
}
|
|
40
|
-
declare class JavaScriptScanner implements PatternScanner {
|
|
41
|
-
patterns: (string | RegExp)[];
|
|
42
|
-
options: JavaScriptRegexScannerOptions;
|
|
43
|
-
regexps: (RegExp | null)[];
|
|
44
|
-
constructor(patterns: (string | RegExp)[], options?: JavaScriptRegexScannerOptions);
|
|
45
|
-
findNextMatchSync(string: string | RegexEngineString, startPosition: number, _options: number): IOnigMatch | null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface JavaScriptRegexEngineOptions extends JavaScriptRegexScannerOptions {
|
|
49
|
-
/**
|
|
50
|
-
* The target ECMAScript version.
|
|
51
|
-
*
|
|
52
|
-
* Oniguruma-To-ES uses RegExp features from later versions of ECMAScript to add support for a
|
|
53
|
-
* few more grammars. If using target `ES2024` or later, the RegExp `v` flag is used which
|
|
54
|
-
* requires Node.js 20+ or Chrome 112+.
|
|
55
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets
|
|
56
|
-
*
|
|
57
|
-
* For maximum compatibility, you can set it to `ES2018` which uses the RegExp `u` flag.
|
|
58
|
-
*
|
|
59
|
-
* Set to `auto` to automatically detect the latest version supported by the environment.
|
|
60
|
-
*
|
|
61
|
-
* @default 'auto'
|
|
62
|
-
*/
|
|
63
|
-
target?: 'auto' | 'ES2025' | 'ES2024' | 'ES2018';
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The default regex constructor for the JavaScript RegExp engine.
|
|
67
|
-
*/
|
|
68
|
-
declare function defaultJavaScriptRegexConstructor(pattern: string, options?: ToRegExpOptions): RegExp;
|
|
69
|
-
/**
|
|
70
|
-
* Use the modern JavaScript RegExp engine to implement the OnigScanner.
|
|
71
|
-
*
|
|
72
|
-
* As Oniguruma supports some features that can't be emulated using native JavaScript regexes, some
|
|
73
|
-
* patterns are not supported. Errors will be thrown when parsing TextMate grammars with
|
|
74
|
-
* unsupported patterns, and when the grammar includes patterns that use invalid Oniguruma syntax.
|
|
75
|
-
* Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
|
|
76
|
-
*/
|
|
77
|
-
declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Raw JavaScript regex engine that only supports precompiled grammars.
|
|
81
|
-
*
|
|
82
|
-
* This further simplifies the engine by excluding the regex compilation step.
|
|
83
|
-
*
|
|
84
|
-
* Zero dependencies.
|
|
85
|
-
*/
|
|
86
|
-
declare function createJavaScriptRawEngine(): RegexEngine;
|
|
87
|
-
|
|
88
|
-
export { type JavaScriptRegexEngineOptions, type JavaScriptRegexScannerOptions, JavaScriptScanner, createJavaScriptRawEngine, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };
|
|
1
|
+
export * from '@shikijs/engine-javascript';
|
|
@@ -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/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/
|
|
123
|
-
"@shikijs/
|
|
124
|
-
"@shikijs/engine-oniguruma": "
|
|
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 };
|