Skip to content

Commit c428037

Browse files
authored
fix: some shiki deprecation warnings (#204)
Signed-off-by: flakey5 <[email protected]>
1 parent adefb11 commit c428037

File tree

4 files changed

+52
-21
lines changed

4 files changed

+52
-21
lines changed

shiki.config.mjs

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
import { getWasmInstance } from '@shikijs/core/wasm-inlined';
4-
53
import cLanguage from 'shiki/langs/c.mjs';
64
import coffeeScriptLanguage from 'shiki/langs/coffeescript.mjs';
75
import cPlusPlusLanguage from 'shiki/langs/cpp.mjs';
@@ -24,7 +22,6 @@ import darkTheme from 'shiki/themes/catppuccin-mocha.mjs';
2422
* @type {import('@shikijs/core').HighlighterCoreOptions}
2523
*/
2624
export default {
27-
loadWasm: getWasmInstance,
2825
// Only register the themes we need, to support light/dark theme
2926
themes: [lightTheme, darkTheme],
3027
// Only register the languages that the API docs use

src/constants.mjs

+39-11
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,45 @@ export const DOC_SLUG_ENVIRONMENT = 'environment-variables-1';
125125
// JavaScript globals types within the MDN JavaScript docs
126126
// @see DOC_MDN_BASE_URL_JS_GLOBALS
127127
export const DOC_TYPES_MAPPING_GLOBALS = {
128-
...Object.fromEntries([
129-
'AggregateError', 'Array', 'ArrayBuffer', 'DataView', 'Date', 'Error',
130-
'EvalError', 'Function', 'Map', 'NaN', 'Object', 'Promise', 'Proxy', 'RangeError',
131-
'ReferenceError', 'RegExp', 'Set', 'SharedArrayBuffer', 'SyntaxError', 'Symbol',
132-
'TypeError', 'URIError', 'WeakMap', 'WeakSet',
133-
134-
'TypedArray',
135-
'Float32Array', 'Float64Array',
136-
'Int8Array', 'Int16Array', 'Int32Array',
137-
'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array',
138-
].map(e => [e, e])),
128+
...Object.fromEntries(
129+
[
130+
'AggregateError',
131+
'Array',
132+
'ArrayBuffer',
133+
'DataView',
134+
'Date',
135+
'Error',
136+
'EvalError',
137+
'Function',
138+
'Map',
139+
'NaN',
140+
'Object',
141+
'Promise',
142+
'Proxy',
143+
'RangeError',
144+
'ReferenceError',
145+
'RegExp',
146+
'Set',
147+
'SharedArrayBuffer',
148+
'SyntaxError',
149+
'Symbol',
150+
'TypeError',
151+
'URIError',
152+
'WeakMap',
153+
'WeakSet',
154+
155+
'TypedArray',
156+
'Float32Array',
157+
'Float64Array',
158+
'Int8Array',
159+
'Int16Array',
160+
'Int32Array',
161+
'Uint8Array',
162+
'Uint8ClampedArray',
163+
'Uint16Array',
164+
'Uint32Array',
165+
].map(e => [e, e])
166+
),
139167
bigint: 'BigInt',
140168
'WebAssembly.Instance': 'WebAssembly/Instance',
141169
};

src/generators/legacy-html/assets/style.css

+7-5
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ html {
7575
}
7676

7777
body {
78-
font-family: Lato, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans',
79-
Verdana, Tahoma, sans-serif;
78+
font-family:
79+
Lato, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Verdana,
80+
Tahoma, sans-serif;
8081
margin: 0;
8182
padding: 0;
8283
color: var(--color-text-primary);
@@ -137,8 +138,8 @@ code,
137138
.pre,
138139
span.type,
139140
a.type {
140-
font-family: SFMono-Regular, Menlo, Consolas, 'Liberation Mono',
141-
'Courier New', monospace;
141+
font-family:
142+
SFMono-Regular, Menlo, Consolas, 'Liberation Mono', 'Courier New', monospace;
142143
font-size: 0.9em;
143144
}
144145

@@ -1031,7 +1032,8 @@ kbd {
10311032
margin-right: 10px;
10321033
margin-top: -2px;
10331034
height: 1.5rem;
1034-
transition-property: background-color, border-color, color, box-shadow, filter;
1035+
transition-property:
1036+
background-color, border-color, color, box-shadow, filter;
10351037
transition-duration: 0.3s;
10361038
cursor: pointer;
10371039
}

src/utils/highlighter.mjs

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { h as createElement } from 'hastscript';
55
import { toString } from 'hast-util-to-string';
66
import { SKIP, visit } from 'unist-util-visit';
77

8-
import { getSingletonHighlighterCore } from '@shikijs/core';
8+
import { createHighlighterCoreSync } from '@shikijs/core';
9+
import { createJavaScriptRegexEngine } from '@shikijs/engine-javascript';
910

1011
import shikiConfig from '../../shiki.config.mjs';
1112

@@ -14,7 +15,10 @@ import shikiConfig from '../../shiki.config.mjs';
1415
const languagePrefix = 'language-';
1516

1617
// Creates a Singleton instance for Shiki's syntax highlighter using WASM
17-
const shikiHighlighter = await getSingletonHighlighterCore(shikiConfig);
18+
const shikiHighlighter = createHighlighterCoreSync({
19+
...shikiConfig,
20+
engine: createJavaScriptRegexEngine(),
21+
});
1822

1923
// Creates a static button element which is used for the "copy" button
2024
// within codeboxes for copying the code to the clipboard

0 commit comments

Comments
 (0)