Skip to content

Commit e6d21b0

Browse files
tushar73-jetTusharantfu
authored
fix(shiki): rename createdBundledHighlighter to createBundledHighlighter (#1135)
Co-authored-by: Tushar <tushar@Tushar-ka-MacBook-Pro.local> Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 156c5f0 commit e6d21b0

File tree

12 files changed

+39
-22
lines changed

12 files changed

+39
-22
lines changed

docs/guide/shorthands.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ console.log(html) // highlighted html string
2020
You can create your own shorthands with fine-grained bundles. Here is an example of creating shorthands with fine-grained bundles:
2121

2222
```ts
23-
import { createdBundledHighlighter, createSingletonShorthands } from 'shiki/core'
23+
import { createBundledHighlighter, createSingletonShorthands } from 'shiki/core'
2424
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'
2525

2626
const BundledLanguage = {
@@ -35,7 +35,7 @@ const BundledTheme = {
3535
}
3636

3737
// This creates your custom 'createHighlighter' function with fine-grained bundles
38-
export const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<
38+
export const createHighlighter = /* @__PURE__ */ createBundledHighlighter<
3939
BundledLanguage,
4040
BundledTheme
4141
>({

packages/codegen/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export async function codegen(options: ShikiCodegenOptions): Promise<ShikiCodege
9898
'@shikijs/types': ['HighlighterGeneric', 'DynamicImportThemeRegistration', 'DynamicImportLanguageRegistration'],
9999
}
100100
const imports: Record<string, string[]> = {
101-
'@shikijs/core': ['createdBundledHighlighter'],
101+
'@shikijs/core': ['createBundledHighlighter'],
102102
}
103103
const lines: string[] = [
104104
'',
@@ -143,7 +143,7 @@ export async function codegen(options: ShikiCodegenOptions): Promise<ShikiCodege
143143

144144
lines.push(
145145
'',
146-
`const createHighlighter = /* @__PURE__ */ createdBundledHighlighter${ts('<BundledLanguage, BundledTheme>')}({`,
146+
`const createHighlighter = /* @__PURE__ */ createBundledHighlighter${ts('<BundledLanguage, BundledTheme>')}({`,
147147
` langs: bundledLanguages,`,
148148
` themes: bundledThemes,`,
149149
` engine: () => ${engine}`,

packages/codegen/test/__snapshots__/basic-oniguruma-js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* Generate by @shikijs/codegen */
22
import {
3+
createBundledHighlighter,
34
createSingletonShorthands,
4-
createdBundledHighlighter,
55
} from '@shikijs/core'
66
import { createOnigurumaEngine } from '@shikijs/engine-oniguruma'
77

@@ -22,7 +22,7 @@ const bundledThemes = {
2222
'vitesse-dark': () => import('@shikijs/themes/vitesse-dark'),
2323
}
2424

25-
const createHighlighter = /* @__PURE__ */ createdBundledHighlighter({
25+
const createHighlighter = /* @__PURE__ */ createBundledHighlighter({
2626
langs: bundledLanguages,
2727
themes: bundledThemes,
2828
engine: () => createOnigurumaEngine(import('shiki/wasm')),

packages/codegen/test/__snapshots__/basic-oniguruma.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type {
55
HighlighterGeneric,
66
} from '@shikijs/types'
77
import {
8+
createBundledHighlighter,
89
createSingletonShorthands,
9-
createdBundledHighlighter,
1010
} from '@shikijs/core'
1111
import { createOnigurumaEngine } from '@shikijs/engine-oniguruma'
1212

@@ -40,7 +40,7 @@ const bundledThemes = {
4040
'vitesse-dark': () => import('@shikijs/themes/vitesse-dark'),
4141
} as Record<BundledTheme, DynamicImportThemeRegistration>
4242

43-
const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<
43+
const createHighlighter = /* @__PURE__ */ createBundledHighlighter<
4444
BundledLanguage,
4545
BundledTheme
4646
>({

packages/codegen/test/__snapshots__/basic-precompiled.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
DynamicImportThemeRegistration,
55
HighlighterGeneric,
66
} from '@shikijs/types'
7-
import { createdBundledHighlighter } from '@shikijs/core'
7+
import { createBundledHighlighter } from '@shikijs/core'
88
import { createJavaScriptRawEngine } from '@shikijs/engine-javascript/raw'
99

1010
type BundledLanguage =
@@ -37,7 +37,7 @@ const bundledThemes = {
3737
'vitesse-dark': () => import('@shikijs/themes/vitesse-dark'),
3838
} as Record<BundledTheme, DynamicImportThemeRegistration>
3939

40-
const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<
40+
const createHighlighter = /* @__PURE__ */ createBundledHighlighter<
4141
BundledLanguage,
4242
BundledTheme
4343
>({

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
CodeToTokensBaseOptions,
66
CodeToTokensOptions,
77
CodeToTokensWithThemesOptions,
8-
CreatedBundledHighlighterOptions,
8+
CreateBundledHighlighterOptions,
99
CreateHighlighterFactory,
1010
GrammarState,
1111
HighlighterGeneric,
@@ -30,7 +30,7 @@ import { createHighlighterCore } from './highlighter'
3030
*
3131
* @example
3232
* ```ts
33-
* const createHighlighter = createdBundledHighlighter({
33+
* const createHighlighter = createBundledHighlighter({
3434
* langs: {
3535
* typescript: () => import('@shikijs/langs/typescript'),
3636
* // ...
@@ -45,13 +45,13 @@ import { createHighlighterCore } from './highlighter'
4545
*
4646
* @param options
4747
*/
48-
export function createdBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(
49-
options: CreatedBundledHighlighterOptions<BundledLangs, BundledThemes>,
48+
export function createBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(
49+
options: CreateBundledHighlighterOptions<BundledLangs, BundledThemes>,
5050
): CreateHighlighterFactory<BundledLangs, BundledThemes>
5151

5252
// Implementation
53-
export function createdBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(
54-
options: CreatedBundledHighlighterOptions<BundledLangs, BundledThemes>,
53+
export function createBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(
54+
options: CreateBundledHighlighterOptions<BundledLangs, BundledThemes>,
5555
): CreateHighlighterFactory<BundledLangs, BundledThemes> {
5656
const bundledLanguages = options.langs
5757
const bundledThemes = options.themes
@@ -270,3 +270,8 @@ export function createSingletonShorthands<L extends string, T extends string>(
270270
},
271271
}
272272
}
273+
274+
/**
275+
* @deprecated Use `createBundledHighlighter` instead.
276+
*/
277+
export const createdBundledHighlighter = createBundledHighlighter

packages/shiki/src/bundle-full.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { HighlighterGeneric } from '@shikijs/types'
22
import type {} from 'hast'
33
import type { BundledLanguage } from './langs-bundle-full'
44
import type { BundledTheme } from './themes'
5-
import { createdBundledHighlighter, createSingletonShorthands, guessEmbeddedLanguages } from '@shikijs/core'
5+
import { createBundledHighlighter, createSingletonShorthands, guessEmbeddedLanguages } from '@shikijs/core'
66
import { createOnigurumaEngine } from './engine-oniguruma'
77
import { bundledLanguages } from './langs-bundle-full'
88
import { bundledThemes } from './themes'
@@ -23,7 +23,7 @@ export type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>
2323
* For granular control over the bundle, check:
2424
* @see https://shiki.style/guide/bundles#fine-grained-bundle
2525
*/
26-
export const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<
26+
export const createHighlighter = /* @__PURE__ */ createBundledHighlighter<
2727
BundledLanguage,
2828
BundledTheme
2929
>({

packages/shiki/src/bundle-web.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { HighlighterGeneric } from '@shikijs/types'
22
import type {} from 'hast'
33
import type { BundledLanguage } from './langs-bundle-web'
44
import type { BundledTheme } from './themes'
5-
import { createdBundledHighlighter, createSingletonShorthands, guessEmbeddedLanguages } from '@shikijs/core'
5+
import { createBundledHighlighter, createSingletonShorthands, guessEmbeddedLanguages } from '@shikijs/core'
66
import { createOnigurumaEngine } from './engine-oniguruma'
77
import { bundledLanguages } from './langs-bundle-web'
88
import { bundledThemes } from './themes'
@@ -23,7 +23,7 @@ export type Highlighter = HighlighterGeneric<BundledLanguage, BundledTheme>
2323
* For granular control over the bundle, check:
2424
* @see https://shiki.style/guide/bundles#fine-grained-bundle
2525
*/
26-
export const createHighlighter = /* @__PURE__ */ createdBundledHighlighter<
26+
export const createHighlighter = /* @__PURE__ */ createBundledHighlighter<
2727
BundledLanguage,
2828
BundledTheme
2929
>({

packages/shiki/test/bundle.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ it('bundle-full', async () => {
77
}))
88

99
expect(highlighter.getLoadedLanguages().length)
10-
.toMatchInlineSnapshot(`331`)
10+
.toMatchInlineSnapshot(`334`)
1111
})
1212

1313
it('bundle-web', async () => {

packages/types/src/highlighter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,15 @@ export type HighlighterCore = HighlighterGeneric<never, never>
161161
/**
162162
* Options for creating a bundled highlighter.
163163
*/
164-
export interface CreatedBundledHighlighterOptions<BundledLangs extends string, BundledThemes extends string> {
164+
export interface CreateBundledHighlighterOptions<BundledLangs extends string, BundledThemes extends string> {
165165
langs: Record<BundledLangs, LanguageInput>
166166
themes: Record<BundledThemes, ThemeInput>
167167
engine: () => Awaitable<RegexEngine>
168168
}
169+
170+
/**
171+
* @deprecated Use `CreateBundledHighlighterOptions` instead.
172+
*/
173+
export interface CreatedBundledHighlighterOptions<BundledLangs extends string, BundledThemes extends string>
174+
extends CreateBundledHighlighterOptions<BundledLangs, BundledThemes> {
175+
}

0 commit comments

Comments
 (0)