shiki 2.3.1 → 2.4.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.mjs +4 -2
- package/dist/bundle-web.mjs +4 -2
- package/dist/core-unwasm.d.mts +9 -3
- package/dist/index.mjs +1 -1
- package/dist/wasm-dynamic-DgcGSsZr.js +23 -0
- package/package.json +10 -10
- package/dist/wasm-dynamic-K7LwWlz7.js +0 -8
package/dist/bundle-full.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { a as guessEmbeddedLanguages } from './wasm-dynamic-DgcGSsZr.js';
|
|
2
|
+
export { g as getWasmInlined } from './wasm-dynamic-DgcGSsZr.js';
|
|
1
3
|
import { bundledLanguages } from './langs.mjs';
|
|
2
4
|
export { bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
|
|
3
5
|
import { bundledThemes } from './themes.mjs';
|
|
4
6
|
export { bundledThemesInfo } from './themes.mjs';
|
|
5
|
-
export { g as getWasmInlined } from './wasm-dynamic-K7LwWlz7.js';
|
|
6
7
|
import { createSingletonShorthands, createdBundledHighlighter, warnDeprecated } from '@shikijs/core';
|
|
7
8
|
export * from '@shikijs/core';
|
|
8
9
|
import { createOnigurumaEngine } from '@shikijs/engine-oniguruma';
|
|
@@ -21,7 +22,8 @@ const {
|
|
|
21
22
|
getSingletonHighlighter,
|
|
22
23
|
getLastGrammarState
|
|
23
24
|
} = /* @__PURE__ */ createSingletonShorthands(
|
|
24
|
-
createHighlighter
|
|
25
|
+
createHighlighter,
|
|
26
|
+
{ guessEmbeddedLanguages }
|
|
25
27
|
);
|
|
26
28
|
const getHighlighter = (options) => {
|
|
27
29
|
warnDeprecated("`getHighlighter` is deprecated. Use `createHighlighter` or `getSingletonHighlighter` instead.");
|
package/dist/bundle-web.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { a as guessEmbeddedLanguages } from './wasm-dynamic-DgcGSsZr.js';
|
|
2
|
+
export { g as getWasmInlined } from './wasm-dynamic-DgcGSsZr.js';
|
|
1
3
|
import { bundledThemes } from './themes.mjs';
|
|
2
4
|
export { bundledThemesInfo } from './themes.mjs';
|
|
3
|
-
export { g as getWasmInlined } from './wasm-dynamic-K7LwWlz7.js';
|
|
4
5
|
import { createSingletonShorthands, createdBundledHighlighter, warnDeprecated } from '@shikijs/core';
|
|
5
6
|
export * from '@shikijs/core';
|
|
6
7
|
import { createOnigurumaEngine } from '@shikijs/engine-oniguruma';
|
|
@@ -336,7 +337,8 @@ const {
|
|
|
336
337
|
getSingletonHighlighter,
|
|
337
338
|
getLastGrammarState
|
|
338
339
|
} = /* @__PURE__ */ createSingletonShorthands(
|
|
339
|
-
createHighlighter
|
|
340
|
+
createHighlighter,
|
|
341
|
+
{ guessEmbeddedLanguages }
|
|
340
342
|
);
|
|
341
343
|
const getHighlighter = (options) => {
|
|
342
344
|
warnDeprecated("`getHighlighter` is deprecated. Use `createHighlighter` or `getSingletonHighlighter` instead.");
|
package/dist/core-unwasm.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions,
|
|
1
|
+
import { HighlighterGeneric, Awaitable, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, GrammarState, ShikiInternal, ShikiTransformerContextCommon, ThemeRegistration, HighlighterCoreOptions, HighlighterCore, RegexEngine, LoadWasmOptions, Position, CreateHighlighterFactory, CreatedBundledHighlighterOptions, LanguageInput, ThemeInput, TokenStyles, 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
4
|
import { JavaScriptRegexEngineOptions } from '@shikijs/engine-javascript';
|
|
@@ -334,7 +334,13 @@ interface ShorthandsBundle<L extends string, T extends string> {
|
|
|
334
334
|
getLastGrammarState: ((element: ThemedToken[][] | Root) => GrammarState) | ((code: string, options: CodeToTokensBaseOptions<L, T>) => Promise<GrammarState>);
|
|
335
335
|
}
|
|
336
336
|
declare function makeSingletonHighlighter<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>): (options?: Partial<BundledHighlighterOptions<L, T>>) => Promise<HighlighterGeneric<L, T>>;
|
|
337
|
-
|
|
337
|
+
interface CreateSingletonShorthandsOptions<L extends string, T extends string> {
|
|
338
|
+
/**
|
|
339
|
+
* A custom function to guess embedded languages to be loaded.
|
|
340
|
+
*/
|
|
341
|
+
guessEmbeddedLanguages?: (code: string, lang: string | undefined, highlighter: HighlighterGeneric<L, T>) => Awaitable<string[] | undefined>;
|
|
342
|
+
}
|
|
343
|
+
declare function createSingletonShorthands<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>, config?: CreateSingletonShorthandsOptions<L, T>): ShorthandsBundle<L, T>;
|
|
338
344
|
|
|
339
345
|
/**
|
|
340
346
|
* Create a Shiki core highlighter instance, with no languages or themes bundled.
|
|
@@ -547,4 +553,4 @@ declare function enableDeprecationWarnings(emitDeprecation?: DeprecationTarget |
|
|
|
547
553
|
*/
|
|
548
554
|
declare function warnDeprecated(message: string, version?: DeprecationTarget): void;
|
|
549
555
|
|
|
550
|
-
export { type CssVariablesThemeOptions, FontStyle, type ShorthandsBundle, EncodedTokenMetadata as StackElementMetadata, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createOnigurumaEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, enableDeprecationWarnings, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, toHtml as hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
|
|
556
|
+
export { type CreateSingletonShorthandsOptions, type CssVariablesThemeOptions, FontStyle, type ShorthandsBundle, EncodedTokenMetadata as StackElementMetadata, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createOnigurumaEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, enableDeprecationWarnings, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, toHtml as hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getHighlighter, 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-
|
|
4
|
+
export { g as getWasmInlined } from './wasm-dynamic-DgcGSsZr.js';
|
|
5
5
|
export * from '@shikijs/core';
|
|
6
6
|
export { bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
|
|
7
7
|
export { bundledThemes, bundledThemesInfo } from './themes.mjs';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { warnDeprecated } from '@shikijs/core';
|
|
2
|
+
|
|
3
|
+
function guessEmbeddedLanguages(code, _lang, shiki) {
|
|
4
|
+
const langs = /* @__PURE__ */ new Set();
|
|
5
|
+
for (const match of code.matchAll(/lang=["']([\w-]+)["']/g)) {
|
|
6
|
+
langs.add(match[1]);
|
|
7
|
+
}
|
|
8
|
+
for (const match of code.matchAll(/(?:```|~~~)([\w-]+)/g)) {
|
|
9
|
+
langs.add(match[1]);
|
|
10
|
+
}
|
|
11
|
+
for (const match of code.matchAll(/\\begin\{([\w-]+)\}/g)) {
|
|
12
|
+
langs.add(match[1]);
|
|
13
|
+
}
|
|
14
|
+
const bundle = shiki.getBundledLanguages();
|
|
15
|
+
return Array.from(langs).filter((l) => l && bundle[l]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const getWasmInlined = async (info) => {
|
|
19
|
+
warnDeprecated('`getWasmInlined` is deprecated. Use `import("shiki/wasm")` instead.');
|
|
20
|
+
return import('shiki/wasm').then((wasm) => wasm.default(info));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { guessEmbeddedLanguages as a, getWasmInlined as g };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shiki",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.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",
|
|
@@ -117,19 +117,19 @@
|
|
|
117
117
|
"dist"
|
|
118
118
|
],
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@shikijs/vscode-textmate": "^10.0.
|
|
120
|
+
"@shikijs/vscode-textmate": "^10.0.2",
|
|
121
121
|
"@types/hast": "^3.0.4",
|
|
122
|
-
"@shikijs/core": "2.
|
|
123
|
-
"@shikijs/engine-
|
|
124
|
-
"@shikijs/engine-
|
|
125
|
-
"@shikijs/
|
|
126
|
-
"@shikijs/
|
|
127
|
-
"@shikijs/
|
|
122
|
+
"@shikijs/core": "2.4.0",
|
|
123
|
+
"@shikijs/engine-oniguruma": "2.4.0",
|
|
124
|
+
"@shikijs/engine-javascript": "2.4.0",
|
|
125
|
+
"@shikijs/themes": "2.4.0",
|
|
126
|
+
"@shikijs/types": "2.4.0",
|
|
127
|
+
"@shikijs/langs": "2.4.0"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
130
|
"rollup-plugin-copy": "^3.5.0",
|
|
131
|
-
"tm-grammars": "^1.22.
|
|
132
|
-
"tm-themes": "^1.9.
|
|
131
|
+
"tm-grammars": "^1.22.14",
|
|
132
|
+
"tm-themes": "^1.9.12",
|
|
133
133
|
"vscode-oniguruma": "1.7.0"
|
|
134
134
|
},
|
|
135
135
|
"scripts": {
|
|
@@ -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 };
|