shiki 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,16 @@
1
- import { R as Root } from './types/wasm-dynamic.mjs';
2
- export { g as getWasmInlined } from './types/wasm-dynamic.mjs';
1
+ import { R as Root } from './types/theme-css-variables.mjs';
2
+ export { C as CssVariablesThemeOptions, S as ShorthandsBundle, a as addClassToHast, b as applyColorReplacements, c as createCssVariablesTheme, d as createHighlighterCore, e as createHighlighterCoreSync, K as createJavaScriptRegexEngine, L as createOnigurumaEngine, f as createPositionConverter, g as createShikiInternal, h as createShikiInternalSync, i as createSingletonShorthands, j as createWasmOnigEngine, k as createdBundledHighlighter, M as defaultJavaScriptRegexConstructor, l as enableDeprecationWarnings, m as getHighlighterCore, n as getShikiInternal, o as getSingletonHighlighterCore, p as getTokenStyleObject, q as isNoneTheme, r as isPlainLang, s as isSpecialLang, t as isSpecialTheme, N as loadWasm, u as makeSingletonHighlighter, v as makeSingletonHighlighterCore, w as normalizeGetter, x as normalizeTheme, y as resolveColorReplacements, z as splitLines, A as splitToken, B as splitTokens, D as stringifyTokenStyle, E as toArray, F as tokenizeAnsiWithTheme, G as tokenizeWithTheme, H as tokensToHast, I as transformerDecorations, J as warnDeprecated } from './types/theme-css-variables.mjs';
3
3
  import * as _shikijs_types from '@shikijs/types';
4
4
  import { HighlighterGeneric, CreateHighlighterFactory } from '@shikijs/types';
5
+ export * from '@shikijs/types';
5
6
  import { BundledLanguage } from './langs.mjs';
6
7
  export { bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
7
8
  import { BundledTheme } from './themes.mjs';
8
9
  export { bundledThemes, bundledThemesInfo } from './themes.mjs';
9
- export * from '@shikijs/core';
10
+ export { g as getWasmInlined } from './types/wasm-dynamic.mjs';
11
+ export { FontStyle, StackElementMetadata, hastToHtml } from './core.mjs';
12
+ import '@shikijs/engine-javascript';
13
+ import '@shikijs/core';
10
14
  import '@shikijs/core/types';
11
15
 
12
16
  type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>;
@@ -3,7 +3,7 @@ export { bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } fro
3
3
  import { bundledThemes } from './themes.mjs';
4
4
  export { bundledThemesInfo } from './themes.mjs';
5
5
  export { g as getWasmInlined } from './wasm-dynamic-K7LwWlz7.js';
6
- import { createdBundledHighlighter, createSingletonShorthands, warnDeprecated } from '@shikijs/core';
6
+ import { createSingletonShorthands, createdBundledHighlighter, warnDeprecated } from '@shikijs/core';
7
7
  export * from '@shikijs/core';
8
8
  import { createOnigurumaEngine } from '@shikijs/engine-oniguruma';
9
9
 
@@ -1,10 +1,14 @@
1
- import { R as Root } from './types/wasm-dynamic.mjs';
2
- export { g as getWasmInlined } from './types/wasm-dynamic.mjs';
1
+ import { R as Root } from './types/theme-css-variables.mjs';
2
+ export { C as CssVariablesThemeOptions, S as ShorthandsBundle, a as addClassToHast, b as applyColorReplacements, c as createCssVariablesTheme, d as createHighlighterCore, e as createHighlighterCoreSync, K as createJavaScriptRegexEngine, L as createOnigurumaEngine, f as createPositionConverter, g as createShikiInternal, h as createShikiInternalSync, i as createSingletonShorthands, j as createWasmOnigEngine, k as createdBundledHighlighter, M as defaultJavaScriptRegexConstructor, l as enableDeprecationWarnings, m as getHighlighterCore, n as getShikiInternal, o as getSingletonHighlighterCore, p as getTokenStyleObject, q as isNoneTheme, r as isPlainLang, s as isSpecialLang, t as isSpecialTheme, N as loadWasm, u as makeSingletonHighlighter, v as makeSingletonHighlighterCore, w as normalizeGetter, x as normalizeTheme, y as resolveColorReplacements, z as splitLines, A as splitToken, B as splitTokens, D as stringifyTokenStyle, E as toArray, F as tokenizeAnsiWithTheme, G as tokenizeWithTheme, H as tokensToHast, I as transformerDecorations, J as warnDeprecated } from './types/theme-css-variables.mjs';
3
3
  import * as _shikijs_types from '@shikijs/types';
4
4
  import { BundledLanguageInfo, DynamicImportLanguageRegistration, HighlighterGeneric, CreateHighlighterFactory } from '@shikijs/types';
5
+ export * from '@shikijs/types';
5
6
  import { BundledTheme } from './themes.mjs';
6
7
  export { bundledThemes, bundledThemesInfo } from './themes.mjs';
7
- export * from '@shikijs/core';
8
+ export { g as getWasmInlined } from './types/wasm-dynamic.mjs';
9
+ export { FontStyle, StackElementMetadata, hastToHtml } from './core.mjs';
10
+ import '@shikijs/engine-javascript';
11
+ import '@shikijs/core';
8
12
  import '@shikijs/core/types';
9
13
 
10
14
  declare const bundledLanguagesInfo: BundledLanguageInfo[];
@@ -1,7 +1,7 @@
1
1
  import { bundledThemes } from './themes.mjs';
2
2
  export { bundledThemesInfo } from './themes.mjs';
3
3
  export { g as getWasmInlined } from './wasm-dynamic-K7LwWlz7.js';
4
- import { createdBundledHighlighter, createSingletonShorthands, warnDeprecated } from '@shikijs/core';
4
+ import { createSingletonShorthands, createdBundledHighlighter, warnDeprecated } from '@shikijs/core';
5
5
  export * from '@shikijs/core';
6
6
  import { createOnigurumaEngine } from '@shikijs/engine-oniguruma';
7
7
 
@@ -1 +1,4 @@
1
1
  export * from '@shikijs/core';
2
+ import '@shikijs/engine-oniguruma/wasm-inlined';
3
+ import '@shikijs/engine-javascript';
4
+ import '@shikijs/vscode-textmate';
@@ -1,4 +1 @@
1
- import { setDefaultWasmLoader } from '@shikijs/engine-oniguruma';
2
1
  export * from '@shikijs/core';
3
-
4
- setDefaultWasmLoader(() => import('shiki/wasm'));
package/dist/core.d.mts CHANGED
@@ -1,3 +1,263 @@
1
- export * from '@shikijs/core';
2
- import '@shikijs/engine-oniguruma/wasm-inlined';
1
+ import { O as RootContent, P as Nodes } from './types/theme-css-variables.mjs';
2
+ export { C as CssVariablesThemeOptions, S as ShorthandsBundle, a as addClassToHast, b as applyColorReplacements, Q as codeToHast, T as codeToHtml, U as codeToTokens, V as codeToTokensBase, W as codeToTokensWithThemes, c as createCssVariablesTheme, d as createHighlighterCore, e as createHighlighterCoreSync, K as createJavaScriptRegexEngine, L as createOnigurumaEngine, f as createPositionConverter, g as createShikiInternal, h as createShikiInternalSync, i as createSingletonShorthands, j as createWasmOnigEngine, k as createdBundledHighlighter, M as defaultJavaScriptRegexConstructor, l as enableDeprecationWarnings, m as getHighlighterCore, n as getShikiInternal, o as getSingletonHighlighterCore, p as getTokenStyleObject, q as isNoneTheme, r as isPlainLang, s as isSpecialLang, t as isSpecialTheme, N as loadWasm, u as makeSingletonHighlighter, v as makeSingletonHighlighterCore, w as normalizeGetter, x as normalizeTheme, y as resolveColorReplacements, z as splitLines, A as splitToken, B as splitTokens, D as stringifyTokenStyle, E as toArray, F as tokenizeAnsiWithTheme, G as tokenizeWithTheme, H as tokensToHast, I as transformerDecorations, J as warnDeprecated } from './types/theme-css-variables.mjs';
3
+ export * from '@shikijs/types';
3
4
  import '@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
+
45
+ type FormatSmartOptions = {
46
+ /**
47
+ * Prefer named character references (`&amp;`) where possible.
48
+ */
49
+ useNamedReferences?: boolean;
50
+ /**
51
+ * Prefer the shortest possible reference, if that results in less bytes.
52
+ * **Note**: `useNamedReferences` can be omitted when using `useShortestReferences`.
53
+ */
54
+ useShortestReferences?: boolean;
55
+ /**
56
+ * Whether to omit semicolons when possible.
57
+ * **Note**: This creates what HTML calls “parse errors” but is otherwise still valid HTML — don’t use this except when building a minifier.
58
+ * Omitting semicolons is possible for certain named and numeric references in some cases.
59
+ */
60
+ omitOptionalSemicolons?: boolean;
61
+ /**
62
+ * Create character references which don’t fail in attributes.
63
+ * **Note**: `attribute` only applies when operating dangerously with
64
+ * `omitOptionalSemicolons: true`.
65
+ */
66
+ attribute?: boolean;
67
+ };
68
+
69
+ type CoreOptions = {
70
+ /**
71
+ * Whether to only escape the given subset of characters.
72
+ */
73
+ subset?: ReadonlyArray<string>;
74
+ /**
75
+ * Whether to only escape possibly dangerous characters.
76
+ * Those characters are `"`, `&`, `'`, `<`, `>`, and `` ` ``.
77
+ */
78
+ escapeOnly?: boolean;
79
+ };
80
+
81
+ type Options$2 = CoreOptions & FormatSmartOptions;
82
+
83
+ type Options$1 = Options$2;
84
+
85
+ /**
86
+ * Serialize hast as HTML.
87
+ *
88
+ * @param {Array<RootContent> | Nodes} tree
89
+ * Tree to serialize.
90
+ * @param {Options | null | undefined} [options]
91
+ * Configuration (optional).
92
+ * @returns {string}
93
+ * Serialized HTML.
94
+ */
95
+ declare function toHtml(tree: Array<RootContent> | Nodes, options?: Options | null | undefined): string;
96
+ type CharacterReferences = Omit<Options$1, "attribute" | "escapeOnly" | "subset">;
97
+ /**
98
+ * Configuration.
99
+ */
100
+ type Options = {
101
+ /**
102
+ * Do not encode some characters which cause XSS vulnerabilities in older
103
+ * browsers (default: `false`).
104
+ *
105
+ * > ⚠️ **Danger**: only set this if you completely trust the content.
106
+ */
107
+ allowDangerousCharacters?: boolean | null | undefined;
108
+ /**
109
+ * Allow `raw` nodes and insert them as raw HTML (default: `false`).
110
+ *
111
+ * When `false`, `Raw` nodes are encoded.
112
+ *
113
+ * > ⚠️ **Danger**: only set this if you completely trust the content.
114
+ */
115
+ allowDangerousHtml?: boolean | null | undefined;
116
+ /**
117
+ * Do not encode characters which cause parse errors (even though they work),
118
+ * to save bytes (default: `false`).
119
+ *
120
+ * Not used in the SVG space.
121
+ *
122
+ * > 👉 **Note**: intentionally creates parse errors in markup (how parse
123
+ * > errors are handled is well defined, so this works but isn’t pretty).
124
+ */
125
+ allowParseErrors?: boolean | null | undefined;
126
+ /**
127
+ * Use “bogus comments” instead of comments to save byes: `<?charlie>`
128
+ * instead of `<!--charlie-->` (default: `false`).
129
+ *
130
+ * > 👉 **Note**: intentionally creates parse errors in markup (how parse
131
+ * > errors are handled is well defined, so this works but isn’t pretty).
132
+ */
133
+ bogusComments?: boolean | null | undefined;
134
+ /**
135
+ * Configure how to serialize character references (optional).
136
+ */
137
+ characterReferences?: CharacterReferences | null | undefined;
138
+ /**
139
+ * Close SVG elements without any content with slash (`/`) on the opening tag
140
+ * instead of an end tag: `<circle />` instead of `<circle></circle>`
141
+ * (default: `false`).
142
+ *
143
+ * See `tightSelfClosing` to control whether a space is used before the
144
+ * slash.
145
+ *
146
+ * Not used in the HTML space.
147
+ */
148
+ closeEmptyElements?: boolean | null | undefined;
149
+ /**
150
+ * Close self-closing nodes with an extra slash (`/`): `<img />` instead of
151
+ * `<img>` (default: `false`).
152
+ *
153
+ * See `tightSelfClosing` to control whether a space is used before the
154
+ * slash.
155
+ *
156
+ * Not used in the SVG space.
157
+ */
158
+ closeSelfClosing?: boolean | null | undefined;
159
+ /**
160
+ * Collapse empty attributes: get `class` instead of `class=""` (default:
161
+ * `false`).
162
+ *
163
+ * Not used in the SVG space.
164
+ *
165
+ * > 👉 **Note**: boolean attributes (such as `hidden`) are always collapsed.
166
+ */
167
+ collapseEmptyAttributes?: boolean | null | undefined;
168
+ /**
169
+ * Omit optional opening and closing tags (default: `false`).
170
+ *
171
+ * For example, in `<ol><li>one</li><li>two</li></ol>`, both `</li>` closing
172
+ * tags can be omitted.
173
+ * The first because it’s followed by another `li`, the last because it’s
174
+ * followed by nothing.
175
+ *
176
+ * Not used in the SVG space.
177
+ */
178
+ omitOptionalTags?: boolean | null | undefined;
179
+ /**
180
+ * Leave attributes unquoted if that results in less bytes (default: `false`).
181
+ *
182
+ * Not used in the SVG space.
183
+ */
184
+ preferUnquoted?: boolean | null | undefined;
185
+ /**
186
+ * Use the other quote if that results in less bytes (default: `false`).
187
+ */
188
+ quoteSmart?: boolean | null | undefined;
189
+ /**
190
+ * Preferred quote to use (default: `'"'`).
191
+ */
192
+ quote?: Quote | null | undefined;
193
+ /**
194
+ * When an `<svg>` element is found in the HTML space, this package already
195
+ * automatically switches to and from the SVG space when entering and exiting
196
+ * it (default: `'html'`).
197
+ *
198
+ * > 👉 **Note**: hast is not XML.
199
+ * > It supports SVG as embedded in HTML.
200
+ * > It does not support the features available in XML.
201
+ * > Passing SVG might break but fragments of modern SVG should be fine.
202
+ * > Use [`xast`][xast] if you need to support SVG as XML.
203
+ */
204
+ space?: Space | null | undefined;
205
+ /**
206
+ * Join attributes together, without whitespace, if possible: get
207
+ * `class="a b"title="c d"` instead of `class="a b" title="c d"` to save
208
+ * bytes (default: `false`).
209
+ *
210
+ * Not used in the SVG space.
211
+ *
212
+ * > 👉 **Note**: intentionally creates parse errors in markup (how parse
213
+ * > errors are handled is well defined, so this works but isn’t pretty).
214
+ */
215
+ tightAttributes?: boolean | null | undefined;
216
+ /**
217
+ * Join known comma-separated attribute values with just a comma (`,`),
218
+ * instead of padding them on the right as well (`,␠`, where `␠` represents a
219
+ * space) (default: `false`).
220
+ */
221
+ tightCommaSeparatedLists?: boolean | null | undefined;
222
+ /**
223
+ * Drop unneeded spaces in doctypes: `<!doctypehtml>` instead of
224
+ * `<!doctype html>` to save bytes (default: `false`).
225
+ *
226
+ * > 👉 **Note**: intentionally creates parse errors in markup (how parse
227
+ * > errors are handled is well defined, so this works but isn’t pretty).
228
+ */
229
+ tightDoctype?: boolean | null | undefined;
230
+ /**
231
+ * Do not use an extra space when closing self-closing elements: `<img/>`
232
+ * instead of `<img />` (default: `false`).
233
+ *
234
+ * > 👉 **Note**: only used if `closeSelfClosing: true` or
235
+ * > `closeEmptyElements: true`.
236
+ */
237
+ tightSelfClosing?: boolean | null | undefined;
238
+ /**
239
+ * Use a `<!DOCTYPE…` instead of `<!doctype…` (default: `false`).
240
+ *
241
+ * Useless except for XHTML.
242
+ */
243
+ upperDoctype?: boolean | null | undefined;
244
+ /**
245
+ * Tag names of elements to serialize without closing tag (default: `html-void-elements`).
246
+ *
247
+ * Not used in the SVG space.
248
+ *
249
+ * > 👉 **Note**: It’s highly unlikely that you want to pass this, because
250
+ * > hast is not for XML, and HTML will not add more void elements.
251
+ */
252
+ voids?: ReadonlyArray<string> | null | undefined;
253
+ };
254
+ /**
255
+ * HTML quotes for attribute values.
256
+ */
257
+ type Quote = "\"" | "'";
258
+ /**
259
+ * Namespace.
260
+ */
261
+ type Space = "html" | "svg";
262
+
263
+ export { FontStyle, EncodedTokenMetadata as StackElementMetadata, toHtml as hastToHtml };
package/dist/index.d.mts CHANGED
@@ -3,8 +3,10 @@ export { BuiltinLanguage, BuiltinTheme } from './types.mjs';
3
3
  export { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
4
4
  export { createOnigurumaEngine, loadWasm } from './engine-oniguruma.mjs';
5
5
  export { g as getWasmInlined } from './types/wasm-dynamic.mjs';
6
- export * from '@shikijs/core';
6
+ export { FontStyle, StackElementMetadata, hastToHtml } from './core.mjs';
7
+ export * from '@shikijs/types';
8
+ export { C as CssVariablesThemeOptions, S as ShorthandsBundle, a as addClassToHast, b as applyColorReplacements, c as createCssVariablesTheme, d as createHighlighterCore, e as createHighlighterCoreSync, f as createPositionConverter, g as createShikiInternal, h as createShikiInternalSync, i as createSingletonShorthands, j as createWasmOnigEngine, k as createdBundledHighlighter, l as enableDeprecationWarnings, m as getHighlighterCore, n as getShikiInternal, o as getSingletonHighlighterCore, p as getTokenStyleObject, q as isNoneTheme, r as isPlainLang, s as isSpecialLang, t as isSpecialTheme, u as makeSingletonHighlighter, v as makeSingletonHighlighterCore, w as normalizeGetter, x as normalizeTheme, y as resolveColorReplacements, z as splitLines, A as splitToken, B as splitTokens, D as stringifyTokenStyle, E as toArray, F as tokenizeAnsiWithTheme, G as tokenizeWithTheme, H as tokensToHast, I as transformerDecorations, J as warnDeprecated } from './types/theme-css-variables.mjs';
7
9
  export { BundledLanguage, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
8
10
  export { BundledTheme, bundledThemes, bundledThemesInfo } from './themes.mjs';
9
- import '@shikijs/types';
10
11
  import '@shikijs/core/types';
12
+ import '@shikijs/core';