Skip to content

Commit 2335dda

Browse files
committed
feat: rename createWasmOnigEngine to createOnigurumaEngine
1 parent 73a9585 commit 2335dda

File tree

14 files changed

+42
-26
lines changed

14 files changed

+42
-26
lines changed

bench/engines.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import type { BundledLanguage } from 'shiki'
33
import type { ReportItem } from '../scripts/report-engine-js-compat'
44
import fs from 'node:fs/promises'
5-
import { createHighlighter, createJavaScriptRegexEngine, createWasmOnigEngine } from 'shiki'
5+
import { createHighlighter, createJavaScriptRegexEngine, createOnigurumaEngine } from 'shiki'
66
import { bench, describe } from 'vitest'
77

88
const js = createJavaScriptRegexEngine()
9-
const wasm = await createWasmOnigEngine(() => import('shiki/wasm'))
9+
const wasm = await createOnigurumaEngine(() => import('shiki/wasm'))
1010

1111
const RANGE = [0, 20]
1212

docs/guide/bundles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const highlighter = await createHighlighterCore({
6565
async () => JSON.parse(await fs.readFile('my-grammar.json', 'utf-8'))
6666
],
6767
// `shiki/wasm` contains the wasm binary inlined as base64 string.
68-
engine: createWasmOnigEngine(import('shiki/wasm'))
68+
engine: createOnigurumaEngine(import('shiki/wasm'))
6969
})
7070

7171
// optionally, load themes and languages after creation

docs/guide/future.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ import { loadWasm } from 'shiki/engine/oniguruma' // [!code ++]
4343
4444
```ts
4545
import { createHighlighter } from 'shiki'
46-
import { createWasmOnigEngine } from 'shiki/engine/oniguruma' // [!code ++]
46+
import { createOnigurumaEngine } from 'shiki/engine/oniguruma' // [!code ++]
4747
4848
const shiki = await createHighlighter({
4949
// ...
5050
loadWasm: () => import('shiki/wasm'), // [!code --]
51-
engine: createWasmOnigEngine(() => import('shiki/wasm')), // [!code ++]
51+
engine: createOnigurumaEngine(() => import('shiki/wasm')), // [!code ++]
5252
})
5353
```

docs/guide/regex-engines.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ This is the default engine that uses the compiled Oniguruma WebAssembly. The mos
2828

2929
```ts
3030
import { createHighlighter } from 'shiki'
31-
import { createWasmOnigEngine } from 'shiki/engine/oniguruma'
31+
import { createOnigurumaEngine } from 'shiki/engine/oniguruma'
3232

3333
const shiki = await createShiki({
3434
themes: ['nord'],
3535
langs: ['javascript'],
36-
engine: createWasmOnigEngine(import('shiki/wasm'))
36+
engine: createOnigurumaEngine(import('shiki/wasm'))
3737
})
3838
```
3939

docs/guide/sync-usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ The [Oniguruma Engine](/guide/regex-engines#oniguruma-engine) can only be create
2525

2626
```ts
2727
import { createHighlighterCoreSync } from 'shiki/core'
28-
import { createWasmOnigEngine } from 'shiki/engine/oniguruma'
28+
import { createOnigurumaEngine } from 'shiki/engine/oniguruma'
2929
import js from 'shiki/langs/javascript.mjs'
3030
import nord from 'shiki/themes/nord.mjs'
3131

3232
// Load this somewhere beforehand
33-
const engine = await createWasmOnigEngine(import('shiki/wasm'))
33+
const engine = await createOnigurumaEngine(import('shiki/wasm'))
3434

3535
const shiki = createHighlighterCoreSync({
3636
themes: [nord],

packages/core/src/constructors/bundle-factory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type {
2424
import type { Root } from 'hast'
2525
import { ShikiError } from '@shikijs/types'
2626

27-
import { createWasmOnigEngine } from '../engines/oniguruma'
27+
import { createOnigurumaEngine } from '../engines/oniguruma'
2828
import { isSpecialLang, isSpecialTheme } from '../utils'
2929
import { warnDeprecated } from '../warn'
3030
import { createHighlighterCore } from './highlighter'
@@ -43,7 +43,7 @@ import { createHighlighterCore } from './highlighter'
4343
* nord: () => import('shiki/themes/nord.mjs'),
4444
* // ...
4545
* },
46-
* engine: () => createWasmOnigEngine(), // or createJavaScriptRegexEngine()
46+
* engine: () => createOnigurumaEngine(), // or createJavaScriptRegexEngine()
4747
* })
4848
* ```
4949
*
@@ -78,7 +78,7 @@ export function createdBundledHighlighter<BundledLangs extends string, BundledTh
7878
warnDeprecated('`createdBundledHighlighter` signature with `bundledLanguages` and `bundledThemes` is deprecated. Use the options object signature instead.')
7979
bundledLanguages = arg1 as Record<BundledLangs, LanguageInput>
8080
bundledThemes = arg2
81-
engine = () => createWasmOnigEngine(arg3)
81+
engine = () => createOnigurumaEngine(arg3)
8282
}
8383
else {
8484
const options = arg1 as CreatedBundledHighlighterOptions<BundledLangs, BundledThemes>

packages/core/src/constructors/internal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {
22
HighlighterCoreOptions,
33
ShikiInternal,
44
} from '@shikijs/types'
5-
import { createWasmOnigEngine, getDefaultWasmLoader } from '@shikijs/engine-oniguruma'
5+
import { createOnigurumaEngine, getDefaultWasmLoader } from '@shikijs/engine-oniguruma'
66

77
import { resolveLangs, resolveThemes } from '../textmate/getters-resolve'
88
import { warnDeprecated } from '../warn'
@@ -13,7 +13,7 @@ import { createShikiInternalSync } from './internal-sync'
1313
*/
1414
export async function createShikiInternal(options: HighlighterCoreOptions = {}): Promise<ShikiInternal> {
1515
if (options.loadWasm) {
16-
warnDeprecated('`loadWasm` option is deprecated. Use `engine: createWasmOnigEngine(loadWasm)` instead.')
16+
warnDeprecated('`loadWasm` option is deprecated. Use `engine: createOnigurumaEngine(loadWasm)` instead.')
1717
}
1818

1919
const [
@@ -23,7 +23,7 @@ export async function createShikiInternal(options: HighlighterCoreOptions = {}):
2323
] = await Promise.all([
2424
resolveThemes(options.themes || []),
2525
resolveLangs(options.langs || []),
26-
(options.engine || createWasmOnigEngine(options.loadWasm || getDefaultWasmLoader())),
26+
(options.engine || createOnigurumaEngine(options.loadWasm || getDefaultWasmLoader())),
2727
] as const)
2828

2929
return createShikiInternalSync({

packages/core/src/engines/oniguruma.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import type { LoadWasmOptions, RegexEngine } from '@shikijs/types'
22
import {
3-
createWasmOnigEngine as _createWasmOnigEngine,
3+
createOnigurumaEngine as _createOnigurumaEngine,
44
loadWasm as _loadWasm,
55
} from '@shikijs/engine-oniguruma'
66
import { warnDeprecated } from '../warn'
77

8+
export function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine> {
9+
warnDeprecated('import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead')
10+
return _createOnigurumaEngine(options)
11+
}
12+
813
export function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine> {
9-
warnDeprecated('import `createWasmOnigEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead')
10-
return _createWasmOnigEngine(options)
14+
warnDeprecated('import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead')
15+
return createOnigurumaEngine(options)
1116
}
1217

1318
export function loadWasm(options: LoadWasmOptions): Promise<void> {

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export { createShikiInternalSync } from './constructors/internal-sync'
77

88
// Engines
99
export { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from './engines/javascript'
10-
export { createWasmOnigEngine, loadWasm } from './engines/oniguruma'
10+
export { createOnigurumaEngine, createWasmOnigEngine, loadWasm } from './engines/oniguruma'
1111

1212
// Low-level Highlighting
1313
export { codeToHast, tokensToHast } from './highlight/code-to-hast'

packages/engine-oniguruma/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function getDefaultWasmLoader(): LoadWasmOptions | undefined {
2121
return _defaultWasmLoader
2222
}
2323

24-
export async function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine> {
24+
export async function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine> {
2525
if (options)
2626
await loadWasm(options)
2727

@@ -34,3 +34,10 @@ export async function createWasmOnigEngine(options?: LoadWasmOptions | null): Pr
3434
},
3535
}
3636
}
37+
38+
/**
39+
* Deprecated. Use `createOnigurumaEngine` instead.
40+
*/
41+
export async function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine> {
42+
return createOnigurumaEngine(options)
43+
}

packages/shiki/src/bundle-full.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import type {} from 'hast'
33
import type { BundledLanguage } from './assets/langs-bundle-full'
44
import type { BundledTheme } from './themes'
55
import { bundledLanguages } from './assets/langs-bundle-full'
6-
import { createdBundledHighlighter, createSingletonShorthands, createWasmOnigEngine, warnDeprecated } from './core'
6+
import { createdBundledHighlighter, createSingletonShorthands, warnDeprecated } from './core'
7+
import { createOnigurumaEngine } from './engine-oniguruma'
78
import { bundledThemes } from './themes'
89
import { getWasmInlined } from './wasm-dynamic'
910

@@ -31,7 +32,7 @@ export const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<
3132
>({
3233
langs: bundledLanguages,
3334
themes: bundledThemes,
34-
engine: () => createWasmOnigEngine(getWasmInlined),
35+
engine: () => createOnigurumaEngine(getWasmInlined),
3536
})
3637

3738
export const {

packages/shiki/src/bundle-web.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type {} from 'hast'
44
import type { BundledLanguage } from './assets/langs-bundle-web'
55
import type { BundledTheme } from './themes'
66
import { bundledLanguages } from './assets/langs-bundle-web'
7-
8-
import { createdBundledHighlighter, createSingletonShorthands, createWasmOnigEngine, warnDeprecated } from './core'
7+
import { createdBundledHighlighter, createSingletonShorthands, warnDeprecated } from './core'
8+
import { createOnigurumaEngine } from './engine-oniguruma'
99
import { bundledThemes } from './themes'
1010
import { getWasmInlined } from './wasm-dynamic'
1111

@@ -33,7 +33,7 @@ export const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<
3333
>({
3434
langs: bundledLanguages,
3535
themes: bundledThemes,
36-
engine: () => createWasmOnigEngine(getWasmInlined),
36+
engine: () => createOnigurumaEngine(getWasmInlined),
3737
})
3838

3939
export const {

packages/shiki/src/core.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ export type { CssVariablesThemeOptions } from './theme-css-variables'
22

33
export { createCssVariablesTheme } from './theme-css-variables'
44
export * from '@shikijs/core'
5+
6+
export { createJavaScriptRegexEngine } from '@shikijs/engine-javascript'
7+
export { createOnigurumaEngine, loadWasm } from '@shikijs/engine-oniguruma'

packages/types/src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface HighlighterCoreOptions<Sync extends boolean = false> {
3333
/**
3434
* Load wasm file from a custom path or using a custom function.
3535
*
36-
* @deprecated Use `engine: createWasmOnigEngine(loadWasm)` instead.
36+
* @deprecated Use `engine: createOnigurumaEngine(loadWasm)` instead.
3737
*/
3838
loadWasm?: Sync extends true ? never : LoadWasmOptions
3939
}

0 commit comments

Comments
 (0)