shiki 2.5.0 → 3.1.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.
@@ -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, CreateHighlighterFactory } from '@shikijs/types';
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, getHighlighter, getLastGrammarState, getSingletonHighlighter };
30
+ export { BundledLanguage, BundledTheme, type Highlighter, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
@@ -1,10 +1,9 @@
1
- import { createSingletonShorthands, createdBundledHighlighter, guessEmbeddedLanguages, warnDeprecated } from '@shikijs/core';
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, getHighlighter, getLastGrammarState, getSingletonHighlighter };
27
+ export { bundledLanguages, bundledThemes, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
@@ -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, CreateHighlighterFactory } from '@shikijs/types';
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, getHighlighter, getLastGrammarState, getSingletonHighlighter };
38
+ export { type BundledLanguage, BundledTheme, type Highlighter, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
@@ -1,8 +1,7 @@
1
- import { createSingletonShorthands, createdBundledHighlighter, guessEmbeddedLanguages, warnDeprecated } from '@shikijs/core';
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, getHighlighter, getLastGrammarState, getSingletonHighlighter };
342
+ export { bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo, bundledThemes, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getLastGrammarState, getSingletonHighlighter };
@@ -1,529 +1 @@
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
- export * from '@shikijs/types';
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
-
7
- type FormatSmartOptions = {
8
- /**
9
- * Prefer named character references (`&amp;`) where possible.
10
- */
11
- useNamedReferences?: boolean;
12
- /**
13
- * Prefer the shortest possible reference, if that results in less bytes.
14
- * **Note**: `useNamedReferences` can be omitted when using `useShortestReferences`.
15
- */
16
- useShortestReferences?: boolean;
17
- /**
18
- * Whether to omit semicolons when possible.
19
- * **Note**: This creates what HTML calls “parse errors” but is otherwise still valid HTML — don’t use this except when building a minifier.
20
- * Omitting semicolons is possible for certain named and numeric references in some cases.
21
- */
22
- omitOptionalSemicolons?: boolean;
23
- /**
24
- * Create character references which don’t fail in attributes.
25
- * **Note**: `attribute` only applies when operating dangerously with
26
- * `omitOptionalSemicolons: true`.
27
- */
28
- attribute?: boolean;
29
- };
30
-
31
- type CoreOptions = {
32
- /**
33
- * Whether to only escape the given subset of characters.
34
- */
35
- subset?: ReadonlyArray<string>;
36
- /**
37
- * Whether to only escape possibly dangerous characters.
38
- * Those characters are `"`, `&`, `'`, `<`, `>`, and `` ` ``.
39
- */
40
- escapeOnly?: boolean;
41
- };
42
-
43
- type Options$2 = CoreOptions & FormatSmartOptions;
44
-
45
- type Options$1 = Options$2;
46
-
47
- /**
48
- * Serialize hast as HTML.
49
- *
50
- * @param {Array<RootContent> | Nodes} tree
51
- * Tree to serialize.
52
- * @param {Options | null | undefined} [options]
53
- * Configuration (optional).
54
- * @returns {string}
55
- * Serialized HTML.
56
- */
57
- declare function toHtml(tree: Array<RootContent> | Nodes, options?: Options | null | undefined): string;
58
- type CharacterReferences = Omit<Options$1, "attribute" | "escapeOnly" | "subset">;
59
- /**
60
- * Configuration.
61
- */
62
- type Options = {
63
- /**
64
- * Do not encode some characters which cause XSS vulnerabilities in older
65
- * browsers (default: `false`).
66
- *
67
- * > ⚠️ **Danger**: only set this if you completely trust the content.
68
- */
69
- allowDangerousCharacters?: boolean | null | undefined;
70
- /**
71
- * Allow `raw` nodes and insert them as raw HTML (default: `false`).
72
- *
73
- * When `false`, `Raw` nodes are encoded.
74
- *
75
- * > ⚠️ **Danger**: only set this if you completely trust the content.
76
- */
77
- allowDangerousHtml?: boolean | null | undefined;
78
- /**
79
- * Do not encode characters which cause parse errors (even though they work),
80
- * to save bytes (default: `false`).
81
- *
82
- * Not used in the SVG space.
83
- *
84
- * > 👉 **Note**: intentionally creates parse errors in markup (how parse
85
- * > errors are handled is well defined, so this works but isn’t pretty).
86
- */
87
- allowParseErrors?: boolean | null | undefined;
88
- /**
89
- * Use “bogus comments” instead of comments to save byes: `<?charlie>`
90
- * instead of `<!--charlie-->` (default: `false`).
91
- *
92
- * > 👉 **Note**: intentionally creates parse errors in markup (how parse
93
- * > errors are handled is well defined, so this works but isn’t pretty).
94
- */
95
- bogusComments?: boolean | null | undefined;
96
- /**
97
- * Configure how to serialize character references (optional).
98
- */
99
- characterReferences?: CharacterReferences | null | undefined;
100
- /**
101
- * Close SVG elements without any content with slash (`/`) on the opening tag
102
- * instead of an end tag: `<circle />` instead of `<circle></circle>`
103
- * (default: `false`).
104
- *
105
- * See `tightSelfClosing` to control whether a space is used before the
106
- * slash.
107
- *
108
- * Not used in the HTML space.
109
- */
110
- closeEmptyElements?: boolean | null | undefined;
111
- /**
112
- * Close self-closing nodes with an extra slash (`/`): `<img />` instead of
113
- * `<img>` (default: `false`).
114
- *
115
- * See `tightSelfClosing` to control whether a space is used before the
116
- * slash.
117
- *
118
- * Not used in the SVG space.
119
- */
120
- closeSelfClosing?: boolean | null | undefined;
121
- /**
122
- * Collapse empty attributes: get `class` instead of `class=""` (default:
123
- * `false`).
124
- *
125
- * Not used in the SVG space.
126
- *
127
- * > 👉 **Note**: boolean attributes (such as `hidden`) are always collapsed.
128
- */
129
- collapseEmptyAttributes?: boolean | null | undefined;
130
- /**
131
- * Omit optional opening and closing tags (default: `false`).
132
- *
133
- * For example, in `<ol><li>one</li><li>two</li></ol>`, both `</li>` closing
134
- * tags can be omitted.
135
- * The first because it’s followed by another `li`, the last because it’s
136
- * followed by nothing.
137
- *
138
- * Not used in the SVG space.
139
- */
140
- omitOptionalTags?: boolean | null | undefined;
141
- /**
142
- * Leave attributes unquoted if that results in less bytes (default: `false`).
143
- *
144
- * Not used in the SVG space.
145
- */
146
- preferUnquoted?: boolean | null | undefined;
147
- /**
148
- * Use the other quote if that results in less bytes (default: `false`).
149
- */
150
- quoteSmart?: boolean | null | undefined;
151
- /**
152
- * Preferred quote to use (default: `'"'`).
153
- */
154
- quote?: Quote | null | undefined;
155
- /**
156
- * When an `<svg>` element is found in the HTML space, this package already
157
- * automatically switches to and from the SVG space when entering and exiting
158
- * it (default: `'html'`).
159
- *
160
- * > 👉 **Note**: hast is not XML.
161
- * > It supports SVG as embedded in HTML.
162
- * > It does not support the features available in XML.
163
- * > Passing SVG might break but fragments of modern SVG should be fine.
164
- * > Use [`xast`][xast] if you need to support SVG as XML.
165
- */
166
- space?: Space | null | undefined;
167
- /**
168
- * Join attributes together, without whitespace, if possible: get
169
- * `class="a b"title="c d"` instead of `class="a b" title="c d"` to save
170
- * bytes (default: `false`).
171
- *
172
- * Not used in the SVG space.
173
- *
174
- * > 👉 **Note**: intentionally creates parse errors in markup (how parse
175
- * > errors are handled is well defined, so this works but isn’t pretty).
176
- */
177
- tightAttributes?: boolean | null | undefined;
178
- /**
179
- * Join known comma-separated attribute values with just a comma (`,`),
180
- * instead of padding them on the right as well (`,␠`, where `␠` represents a
181
- * space) (default: `false`).
182
- */
183
- tightCommaSeparatedLists?: boolean | null | undefined;
184
- /**
185
- * Drop unneeded spaces in doctypes: `<!doctypehtml>` instead of
186
- * `<!doctype html>` to save bytes (default: `false`).
187
- *
188
- * > 👉 **Note**: intentionally creates parse errors in markup (how parse
189
- * > errors are handled is well defined, so this works but isn’t pretty).
190
- */
191
- tightDoctype?: boolean | null | undefined;
192
- /**
193
- * Do not use an extra space when closing self-closing elements: `<img/>`
194
- * instead of `<img />` (default: `false`).
195
- *
196
- * > 👉 **Note**: only used if `closeSelfClosing: true` or
197
- * > `closeEmptyElements: true`.
198
- */
199
- tightSelfClosing?: boolean | null | undefined;
200
- /**
201
- * Use a `<!DOCTYPE…` instead of `<!doctype…` (default: `false`).
202
- *
203
- * Useless except for XHTML.
204
- */
205
- upperDoctype?: boolean | null | undefined;
206
- /**
207
- * Tag names of elements to serialize without closing tag (default: `html-void-elements`).
208
- *
209
- * Not used in the SVG space.
210
- *
211
- * > 👉 **Note**: It’s highly unlikely that you want to pass this, because
212
- * > hast is not for XML, and HTML will not add more void elements.
213
- */
214
- voids?: ReadonlyArray<string> | null | undefined;
215
- };
216
- /**
217
- * HTML quotes for attribute values.
218
- */
219
- type Quote = "\"" | "'";
220
- /**
221
- * Namespace.
222
- */
223
- type Space = "html" | "svg";
224
-
225
- /**
226
- * Create a `createHighlighter` function with bundled themes, languages, and engine.
227
- *
228
- * @example
229
- * ```ts
230
- * const createHighlighter = createdBundledHighlighter({
231
- * langs: {
232
- * typescript: () => import('@shikijs/langs/typescript'),
233
- * // ...
234
- * },
235
- * themes: {
236
- * nord: () => import('@shikijs/themes/nord'),
237
- * // ...
238
- * },
239
- * engine: () => createOnigurumaEngine(), // or createJavaScriptRegexEngine()
240
- * })
241
- * ```
242
- *
243
- * @param options
244
- */
245
- 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
- interface ShorthandsBundle<L extends string, T extends string> {
253
- /**
254
- * Shorthand for `codeToHtml` with auto-loaded theme and language.
255
- * A singleton highlighter it maintained internally.
256
- *
257
- * Differences from `highlighter.codeToHtml()`, this function is async.
258
- */
259
- codeToHtml: (code: string, options: CodeToHastOptions<L, T>) => Promise<string>;
260
- /**
261
- * Shorthand for `codeToHtml` with auto-loaded theme and language.
262
- * A singleton highlighter it maintained internally.
263
- *
264
- * Differences from `highlighter.codeToHtml()`, this function is async.
265
- */
266
- codeToHast: (code: string, options: CodeToHastOptions<L, T>) => Promise<Root>;
267
- /**
268
- * Shorthand for `codeToTokens` with auto-loaded theme and language.
269
- * A singleton highlighter it maintained internally.
270
- *
271
- * Differences from `highlighter.codeToTokens()`, this function is async.
272
- */
273
- codeToTokens: (code: string, options: CodeToTokensOptions<L, T>) => Promise<TokensResult>;
274
- /**
275
- * Shorthand for `codeToTokensBase` with auto-loaded theme and language.
276
- * A singleton highlighter it maintained internally.
277
- *
278
- * Differences from `highlighter.codeToTokensBase()`, this function is async.
279
- */
280
- codeToTokensBase: (code: string, options: RequireKeys<CodeToTokensBaseOptions<L, T>, 'theme' | 'lang'>) => Promise<ThemedToken[][]>;
281
- /**
282
- * Shorthand for `codeToTokensWithThemes` with auto-loaded theme and language.
283
- * A singleton highlighter it maintained internally.
284
- *
285
- * Differences from `highlighter.codeToTokensWithThemes()`, this function is async.
286
- */
287
- codeToTokensWithThemes: (code: string, options: RequireKeys<CodeToTokensWithThemesOptions<L, T>, 'themes' | 'lang'>) => Promise<ThemedTokenWithVariants[][]>;
288
- /**
289
- * Get the singleton highlighter.
290
- */
291
- getSingletonHighlighter: (options?: Partial<BundledHighlighterOptions<L, T>>) => Promise<HighlighterGeneric<L, T>>;
292
- /**
293
- * Shorthand for `getLastGrammarState` with auto-loaded theme and language.
294
- * A singleton highlighter it maintained internally.
295
- */
296
- getLastGrammarState: ((element: ThemedToken[][] | Root) => GrammarState) | ((code: string, options: CodeToTokensBaseOptions<L, T>) => Promise<GrammarState>);
297
- }
298
- declare function makeSingletonHighlighter<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>): (options?: Partial<BundledHighlighterOptions<L, T>>) => Promise<HighlighterGeneric<L, T>>;
299
- interface CreateSingletonShorthandsOptions<L extends string, T extends string> {
300
- /**
301
- * A custom function to guess embedded languages to be loaded.
302
- */
303
- guessEmbeddedLanguages?: (code: string, lang: string | undefined, highlighter: HighlighterGeneric<L, T>) => Awaitable<string[] | undefined>;
304
- }
305
- declare function createSingletonShorthands<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>, config?: CreateSingletonShorthandsOptions<L, T>): ShorthandsBundle<L, T>;
306
-
307
- /**
308
- * Create a Shiki core highlighter instance, with no languages or themes bundled.
309
- * Wasm and each language and theme must be loaded manually.
310
- *
311
- * @see http://shiki.style/guide/bundles#fine-grained-bundle
312
- */
313
- declare function createHighlighterCore(options: HighlighterCoreOptions<false>): Promise<HighlighterCore>;
314
- /**
315
- * Create a Shiki core highlighter instance, with no languages or themes bundled.
316
- * Wasm and each language and theme must be loaded manually.
317
- *
318
- * Synchronous version of `createHighlighterCore`, which requires to provide the engine and all themes and languages upfront.
319
- *
320
- * @see http://shiki.style/guide/bundles#fine-grained-bundle
321
- */
322
- declare function createHighlighterCoreSync(options: HighlighterCoreOptions<true>): HighlighterCore;
323
- declare function makeSingletonHighlighterCore(createHighlighter: typeof createHighlighterCore): (options: HighlighterCoreOptions) => Promise<HighlighterCore>;
324
- 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
-
330
- /**
331
- * Get the minimal shiki context for rendering.
332
- */
333
- declare function createShikiInternal(options: HighlighterCoreOptions): Promise<ShikiInternal>;
334
- /**
335
- * @deprecated Use `createShikiInternal` instead.
336
- */
337
- declare function getShikiInternal(options: HighlighterCoreOptions): Promise<ShikiInternal>;
338
-
339
- /**
340
- * Get the minimal shiki context for rendering.
341
- *
342
- * Synchronous version of `createShikiInternal`, which requires to provide the engine and all themes and languages upfront.
343
- */
344
- declare function createShikiInternalSync(options: HighlighterCoreOptions<true>): ShikiInternal;
345
-
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
- declare function codeToHast(internal: ShikiInternal, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
369
- declare function tokensToHast(tokens: ThemedToken[][], options: CodeToHastRenderOptions, transformerContext: ShikiTransformerContextSource, grammarState?: GrammarState | undefined): Root;
370
-
371
- /**
372
- * Get highlighted code in HTML.
373
- */
374
- declare function codeToHtml(internal: ShikiInternal, code: string, options: CodeToHastOptions): string;
375
-
376
- /**
377
- * High-level code-to-tokens API.
378
- *
379
- * It will use `codeToTokensWithThemes` or `codeToTokensBase` based on the options.
380
- */
381
- declare function codeToTokens(internal: ShikiInternal, code: string, options: CodeToTokensOptions): TokensResult;
382
-
383
- declare function tokenizeAnsiWithTheme(theme: ThemeRegistrationResolved, fileContents: string, options?: TokenizeWithThemeOptions): ThemedToken[][];
384
-
385
- /**
386
- * Code to tokens, with a simple theme.
387
- */
388
- declare function codeToTokensBase(internal: ShikiInternal, code: string, options?: CodeToTokensBaseOptions): ThemedToken[][];
389
- declare function tokenizeWithTheme(code: string, grammar: Grammar, theme: ThemeRegistrationResolved, colorMap: string[], options: TokenizeWithThemeOptions): ThemedToken[][];
390
-
391
- /**
392
- * Get tokens with multiple themes
393
- */
394
- declare function codeToTokensWithThemes(internal: ShikiInternal, code: string, options: CodeToTokensWithThemesOptions): ThemedTokenWithVariants[][];
395
-
396
- /**
397
- * Normalize a textmate theme to shiki theme
398
- */
399
- declare function normalizeTheme(rawTheme: ThemeRegistrationAny): ThemeRegistrationResolved;
400
-
401
- interface CssVariablesThemeOptions {
402
- /**
403
- * Theme name. Need to unique if multiple css variables themes are created
404
- *
405
- * @default 'css-variables'
406
- */
407
- name?: string;
408
- /**
409
- * Prefix for css variables
410
- *
411
- * @default '--shiki-'
412
- */
413
- variablePrefix?: string;
414
- /**
415
- * Default value for css variables, the key is without the prefix
416
- *
417
- * @example `{ 'token-comment': '#888' }` will generate `var(--shiki-token-comment, #888)` for comments
418
- */
419
- variableDefaults?: Record<string, string>;
420
- /**
421
- * Enable font style
422
- *
423
- * @default true
424
- */
425
- fontStyle?: boolean;
426
- }
427
- /**
428
- * A factory function to create a css-variable-based theme
429
- *
430
- * @see https://shiki.style/guide/theme-colors#css-variables-theme
431
- */
432
- declare function createCssVariablesTheme(options?: CssVariablesThemeOptions): ThemeRegistration;
433
-
434
- /**
435
- * A built-in transformer to add decorations to the highlighted code.
436
- */
437
- declare function transformerDecorations(): ShikiTransformer;
438
-
439
- declare function resolveColorReplacements(theme: ThemeRegistrationAny | string, options?: TokenizeWithThemeOptions): Record<string, string | undefined>;
440
- declare function applyColorReplacements(color: string, replacements?: Record<string, string | undefined>): string;
441
- declare function applyColorReplacements(color?: string | undefined, replacements?: Record<string, string | undefined>): string | undefined;
442
-
443
- declare function toArray<T>(x: MaybeArray<T>): T[];
444
- /**
445
- * Normalize a getter to a promise.
446
- */
447
- declare function normalizeGetter<T>(p: MaybeGetter<T>): Promise<T>;
448
- /**
449
- * Check if the language is plaintext that is ignored by Shiki.
450
- *
451
- * Hard-coded plain text languages: `plaintext`, `txt`, `text`, `plain`.
452
- */
453
- declare function isPlainLang(lang: string | null | undefined): lang is PlainTextLanguage;
454
- /**
455
- * Check if the language is specially handled or bypassed by Shiki.
456
- *
457
- * Hard-coded languages: `ansi` and plaintexts like `plaintext`, `txt`, `text`, `plain`.
458
- */
459
- declare function isSpecialLang(lang: any): lang is SpecialLanguage;
460
- /**
461
- * Check if the theme is specially handled or bypassed by Shiki.
462
- *
463
- * Hard-coded themes: `none`.
464
- */
465
- declare function isNoneTheme(theme: string | ThemeInput | null | undefined): theme is 'none';
466
- /**
467
- * Check if the theme is specially handled or bypassed by Shiki.
468
- *
469
- * Hard-coded themes: `none`.
470
- */
471
- declare function isSpecialTheme(theme: string | ThemeInput | null | undefined): theme is SpecialTheme;
472
-
473
- /**
474
- * Utility to append class to a hast node
475
- *
476
- * If the `property.class` is a string, it will be splitted by space and converted to an array.
477
- */
478
- declare function addClassToHast(node: Element, className: string | string[]): Element;
479
-
480
- /**
481
- * Split a string into lines, each line preserves the line ending.
482
- */
483
- declare function splitLines(code: string, preserveEnding?: boolean): [string, number][];
484
- /**
485
- * Creates a converter between index and position in a code block.
486
- *
487
- * Overflow/underflow are unchecked.
488
- */
489
- declare function createPositionConverter(code: string): {
490
- lines: string[];
491
- indexToPos: (index: number) => Position;
492
- posToIndex: (line: number, character: number) => number;
493
- };
494
- /**
495
- * Guess embedded languages from given code and highlighter.
496
- *
497
- * When highlighter is provided, only bundled languages will be included.
498
- */
499
- declare function guessEmbeddedLanguages(code: string, _lang: string | undefined, highlighter?: HighlighterGeneric<any, any>): string[];
500
-
501
- /**
502
- * Split a token into multiple tokens by given offsets.
503
- *
504
- * The offsets are relative to the token, and should be sorted.
505
- */
506
- declare function splitToken<T extends Pick<ThemedToken, 'content' | 'offset'>>(token: T, offsets: number[]): T[];
507
- /**
508
- * Split 2D tokens array by given breakpoints.
509
- */
510
- declare function splitTokens<T extends Pick<ThemedToken, 'content' | 'offset'>>(tokens: T[][], breakpoints: number[] | Set<number>): T[][];
511
- declare function flatTokenVariants(merged: ThemedTokenWithVariants, variantsOrder: string[], cssVariablePrefix: string, defaultColor: string | boolean): ThemedToken;
512
- declare function getTokenStyleObject(token: TokenStyles): Record<string, string>;
513
- declare function stringifyTokenStyle(token: string | Record<string, string>): string;
514
-
515
- type DeprecationTarget = 3;
516
- /**
517
- * Enable runtime warning for deprecated APIs, for the future versions of Shiki.
518
- *
519
- * You can pass a major version to only warn for deprecations that will be removed in that version.
520
- *
521
- * By default, deprecation warning is set to 3 since Shiki v2.0.0
522
- */
523
- declare function enableDeprecationWarnings(emitDeprecation?: DeprecationTarget | boolean, emitError?: boolean): void;
524
- /**
525
- * @internal
526
- */
527
- declare function warnDeprecated(message: string, version?: DeprecationTarget): void;
528
-
529
- export { type CreateSingletonShorthandsOptions, type CssVariablesThemeOptions, type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createOnigurumaEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, enableDeprecationWarnings, flatTokenVariants, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, guessEmbeddedLanguages, toHtml as hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
1
+ export * from '@shikijs/core';
@@ -1 +1,4 @@
1
+ import { setDefaultWasmLoader } from '@shikijs/engine-oniguruma';
1
2
  export * from '@shikijs/core';
3
+
4
+ setDefaultWasmLoader(() => import('shiki/wasm'));
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- export { Highlighter, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getHighlighter, getLastGrammarState, getSingletonHighlighter } from './bundle-full.mjs';
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 { g as getWasmInlined } from './types/wasm-dynamic.mjs';
5
4
  export * from '@shikijs/core';
6
5
  export { BundledLanguage, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
7
6
  export { BundledTheme, bundledThemes, bundledThemesInfo } from './themes.mjs';
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
- export { codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getHighlighter, getLastGrammarState, getSingletonHighlighter } from './bundle-full.mjs';
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/themes.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { BundledThemeInfo, DynamicImportThemeRegistration } from '@shikijs/core';
1
+ import { BundledThemeInfo, DynamicImportThemeRegistration } from '@shikijs/types';
2
2
 
3
3
  declare const bundledThemesInfo: BundledThemeInfo[];
4
4
  type BundledTheme = 'andromeeda' | 'aurora-x' | 'ayu-dark' | 'catppuccin-frappe' | 'catppuccin-latte' | 'catppuccin-macchiato' | 'catppuccin-mocha' | 'dark-plus' | 'dracula' | 'dracula-soft' | 'everforest-dark' | 'everforest-light' | 'github-dark' | 'github-dark-default' | 'github-dark-dimmed' | 'github-dark-high-contrast' | 'github-light' | 'github-light-default' | 'github-light-high-contrast' | 'houston' | 'kanagawa-dragon' | 'kanagawa-lotus' | 'kanagawa-wave' | 'laserwave' | 'light-plus' | 'material-theme' | 'material-theme-darker' | 'material-theme-lighter' | 'material-theme-ocean' | 'material-theme-palenight' | 'min-dark' | 'min-light' | 'monokai' | 'night-owl' | 'nord' | 'one-dark-pro' | 'one-light' | 'plastic' | 'poimandres' | 'red' | 'rose-pine' | 'rose-pine-dawn' | 'rose-pine-moon' | 'slack-dark' | 'slack-ochin' | 'snazzy-light' | 'solarized-dark' | 'solarized-light' | 'synthwave-84' | 'tokyo-night' | 'vesper' | 'vitesse-black' | 'vitesse-dark' | 'vitesse-light';
@@ -160,15 +160,6 @@ interface RootContentMap {
160
160
  text: Text;
161
161
  }
162
162
 
163
- /**
164
- * Union of registered hast nodes.
165
- *
166
- * To register custom hast nodes, add them to {@link RootContentMap} and other
167
- * places where relevant.
168
- * They will be automatically added here.
169
- */
170
- type Nodes = Root | RootContent;
171
-
172
163
  // ## Abstract nodes
173
164
 
174
165
  /**
@@ -341,4 +332,4 @@ interface Text extends Literal {
341
332
  */
342
333
  interface TextData extends Data {}
343
334
 
344
- export type { Element as E, Nodes as N, Root as R, RootContent as a };
335
+ export type { Root as R };
package/dist/types.d.mts CHANGED
@@ -2,7 +2,6 @@ import { BundledLanguage } from './langs.mjs';
2
2
  import { BundledTheme } from './themes.mjs';
3
3
  export * from '@shikijs/core/types';
4
4
  import '@shikijs/types';
5
- import '@shikijs/core';
6
5
 
7
6
  type BuiltinLanguage = BundledLanguage;
8
7
  type BuiltinTheme = BundledTheme;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shiki",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "3.1.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
- "types": "./dist/langs.d.mts",
36
- "default": "./dist/langs.mjs"
37
- },
38
- "./themes": {
39
- "types": "./dist/themes.d.mts",
40
- "default": "./dist/themes.mjs"
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,61 +42,23 @@
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": "2.5.0",
123
- "@shikijs/engine-oniguruma": "2.5.0",
124
- "@shikijs/engine-javascript": "2.5.0",
125
- "@shikijs/themes": "2.5.0",
126
- "@shikijs/langs": "2.5.0",
127
- "@shikijs/types": "2.5.0"
51
+ "@shikijs/engine-javascript": "3.1.0",
52
+ "@shikijs/core": "3.1.0",
53
+ "@shikijs/langs": "3.1.0",
54
+ "@shikijs/engine-oniguruma": "3.1.0",
55
+ "@shikijs/themes": "3.1.0",
56
+ "@shikijs/types": "3.1.0"
128
57
  },
129
58
  "devDependencies": {
130
59
  "rollup-plugin-copy": "^3.5.0",
131
- "tm-grammars": "^1.22.14",
132
- "tm-themes": "^1.9.12",
60
+ "tm-grammars": "^1.22.18",
61
+ "tm-themes": "^1.9.13",
133
62
  "vscode-oniguruma": "1.7.0"
134
63
  },
135
64
  "scripts": {
@@ -1 +0,0 @@
1
- export { CssVariablesThemeOptions, createCssVariablesTheme } from '@shikijs/core';
@@ -1,4 +0,0 @@
1
- import { warnDeprecated } from '@shikijs/core';
2
- export { createCssVariablesTheme } from '@shikijs/core';
3
-
4
- warnDeprecated("`shiki/theme-css-variables` entry point is deprecated. Use `shiki/core` instead.");
@@ -1,8 +0,0 @@
1
- import { WebAssemblyInstantiator } from '@shikijs/core/types';
2
-
3
- /**
4
- * @deprecated Use `import('shiki/wasm')` instead.
5
- */
6
- declare const getWasmInlined: WebAssemblyInstantiator;
7
-
8
- export { getWasmInlined as g };
@@ -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 };