@slidev/types 0.46.3 → 0.47.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.
package/dist/index.d.mts CHANGED
@@ -1,13 +1,10 @@
1
1
  import { TransitionGroupProps, App, Ref } from 'vue';
2
2
  import { Awaitable } from '@antfu/utils';
3
- import * as Shiki from 'shiki';
4
- import { IThemeRegistration, Theme, ILanguageRegistration, Lang, Highlighter } from 'shiki';
5
- import { CodeToHastOptions } from 'shikiji';
6
3
  import * as monaco from 'monaco-editor';
7
4
  import { Router } from 'vue-router';
8
5
  import mermaid from 'mermaid';
9
6
  import { KatexOptions } from 'katex';
10
- import { WindiCssOptions } from 'vite-plugin-windicss';
7
+ import { CodeToHastOptions, Highlighter } from 'shiki';
11
8
  import { VitePluginConfig } from 'unocss/vite';
12
9
 
13
10
  interface CommonArgs {
@@ -98,9 +95,9 @@ interface SlidevConfig {
98
95
  * Prefer highlighter
99
96
  *
100
97
  * @see https://sli.dev/custom/highlighters.html
101
- * @default prism
98
+ * @default shiki
102
99
  */
103
- highlighter: 'prism' | 'shiki' | 'shikiji';
100
+ highlighter: 'prism' | 'shiki';
104
101
  /**
105
102
  * Show line numbers in code blocks
106
103
  *
@@ -198,10 +195,9 @@ interface SlidevConfig {
198
195
  * Engine for Atomic CSS
199
196
  *
200
197
  * @see https://unocss.dev/
201
- * @see https://windicss.org/
202
198
  * @default 'unocss'
203
199
  */
204
- css: 'unocss' | 'windicss' | 'none';
200
+ css: 'unocss' | 'none';
205
201
  /**
206
202
  * Enable presenter mode
207
203
  *
@@ -357,6 +353,7 @@ interface SlideInfo extends SlideInfoBase {
357
353
  end: number;
358
354
  inline?: SlideInfoBase;
359
355
  source?: SlideInfoWithPath;
356
+ snippetsUsed?: LoadedSnippets;
360
357
  }
361
358
  interface SlideInfoWithPath extends SlideInfoBase {
362
359
  filepath: string;
@@ -397,27 +394,12 @@ interface SlidevPreparserExtension {
397
394
  type PreparserExtensionLoader = (headmatter?: Record<string, unknown>, filepath?: string) => Promise<SlidevPreparserExtension[]>;
398
395
  type PreparserExtensionFromHeadmatter = (headmatter: any, exts: SlidevPreparserExtension[], filepath?: string) => Promise<SlidevPreparserExtension[]>;
399
396
  type RenderContext = 'slide' | 'overview' | 'presenter' | 'previewNext';
397
+ type LoadedSnippets = Record<string, string>;
400
398
 
401
399
  interface AppContext {
402
400
  app: App;
403
401
  router: Router;
404
402
  }
405
- interface ShikiDarkModeThemes {
406
- dark: IThemeRegistration | Theme;
407
- light: IThemeRegistration | Theme;
408
- }
409
- interface ShikiOptions {
410
- theme?: IThemeRegistration | ShikiDarkModeThemes | Theme;
411
- langs?: (ILanguageRegistration | Lang)[];
412
- highlighter?: Highlighter;
413
- }
414
- interface ResolvedShikiOptions extends ShikiOptions {
415
- themes: (IThemeRegistration | Theme)[];
416
- darkModeThemes?: {
417
- dark: Theme;
418
- light: Theme;
419
- };
420
- }
421
403
  interface MonacoSetupReturn {
422
404
  theme?: {
423
405
  light?: string;
@@ -447,19 +429,25 @@ interface ShortcutOptions {
447
429
  autoRepeat?: boolean;
448
430
  name?: string;
449
431
  }
450
- type ShikiSetup = (shiki: typeof Shiki) => Awaitable<ShikiOptions | undefined>;
451
- type ShikijiSetup = () => Awaitable<Partial<CodeToHastOptions> | undefined>;
452
- type KatexSetup = () => Awaitable<Partial<KatexOptions> | undefined>;
453
- type WindiSetup = () => Awaitable<Partial<WindiCssOptions> | undefined>;
454
- type UnoSetup = () => Awaitable<Partial<VitePluginConfig> | undefined>;
432
+ interface ShikiContext {
433
+ /**
434
+ * @deprecated Pass directly the theme name it's supported by Shiki.
435
+ * For custom themes, load it manually via `JSON.parse(fs.readFileSync(path, 'utf-8'))` and pass the raw JSON object instead.
436
+ */
437
+ loadTheme(path: string): Promise<any>;
438
+ }
439
+ type ShikiSetupReturn = Partial<CodeToHastOptions> & {
440
+ setup?(highlighter: Highlighter): Awaitable<void>;
441
+ };
442
+ type ShikiSetup = (shiki: ShikiContext) => Awaitable<ShikiSetupReturn | void>;
443
+ type KatexSetup = () => Awaitable<Partial<KatexOptions> | void>;
444
+ type UnoSetup = () => Awaitable<Partial<VitePluginConfig> | void>;
455
445
  type PreparserSetup = (filepath: string) => SlidevPreparserExtension;
456
446
  type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn>;
457
447
  type AppSetup = (context: AppContext) => Awaitable<void>;
458
- type MermaidSetup = () => Partial<MermaidOptions> | undefined;
448
+ type MermaidSetup = () => Partial<MermaidOptions> | void;
459
449
  type ShortcutsSetup = (nav: NavOperations, defaultShortcuts: ShortcutOptions[]) => Array<ShortcutOptions>;
460
450
  declare function defineShikiSetup(fn: ShikiSetup): ShikiSetup;
461
- declare function defineShikijiSetup(fn: ShikijiSetup): ShikijiSetup;
462
- declare function defineWindiSetup(fn: WindiSetup): WindiSetup;
463
451
  declare function defineUnoSetup(fn: UnoSetup): UnoSetup;
464
452
  declare function defineMonacoSetup(fn: MonacoSetup): MonacoSetup;
465
453
  declare function defineAppSetup(fn: AppSetup): AppSetup;
@@ -479,4 +467,4 @@ interface TocItem {
479
467
  title?: string;
480
468
  }
481
469
 
482
- export { type AppContext, type AppSetup, type BuildArgs, type BuiltinSlideTransition, type CommonArgs, type DrawingsOptions, type ExportArgs, type FontOptions, type FrontmatterStyle, type KatexSetup, type MermaidOptions, type MermaidSetup, type MonacoSetup, type MonacoSetupReturn, type NavOperations, type PreparserExtensionFromHeadmatter, type PreparserExtensionLoader, type PreparserSetup, type RenderContext, type ResolvedDrawingsOptions, type ResolvedExportOptions, type ResolvedFontOptions, type ResolvedShikiOptions, type ShikiDarkModeThemes, type ShikiOptions, type ShikiSetup, type ShikijiSetup, type ShortcutOptions, type ShortcutsSetup, type SlideInfo, type SlideInfoBase, type SlideInfoExtended, type SlideInfoWithPath, type SlidevConfig, type SlidevFeatureFlags, type SlidevMarkdown, type SlidevPreparserExtension, type SlidevThemeConfig, type SlidevThemeMeta, type TocItem, type UnoSetup, type WindiSetup, defineAppSetup, defineKatexSetup, defineMermaidSetup, defineMonacoSetup, definePreparserSetup, defineShikiSetup, defineShikijiSetup, defineShortcutsSetup, defineUnoSetup, defineWindiSetup };
470
+ export { type AppContext, type AppSetup, type BuildArgs, type BuiltinSlideTransition, type CommonArgs, type DrawingsOptions, type ExportArgs, type FontOptions, type FrontmatterStyle, type KatexSetup, type LoadedSnippets, type MermaidOptions, type MermaidSetup, type MonacoSetup, type MonacoSetupReturn, type NavOperations, type PreparserExtensionFromHeadmatter, type PreparserExtensionLoader, type PreparserSetup, type RenderContext, type ResolvedDrawingsOptions, type ResolvedExportOptions, type ResolvedFontOptions, type ShikiContext, type ShikiSetup, type ShikiSetupReturn, type ShortcutOptions, type ShortcutsSetup, type SlideInfo, type SlideInfoBase, type SlideInfoExtended, type SlideInfoWithPath, type SlidevConfig, type SlidevFeatureFlags, type SlidevMarkdown, type SlidevPreparserExtension, type SlidevThemeConfig, type SlidevThemeMeta, type TocItem, type UnoSetup, defineAppSetup, defineKatexSetup, defineMermaidSetup, defineMonacoSetup, definePreparserSetup, defineShikiSetup, defineShortcutsSetup, defineUnoSetup };
package/dist/index.mjs CHANGED
@@ -2,12 +2,6 @@
2
2
  function defineShikiSetup(fn) {
3
3
  return fn;
4
4
  }
5
- function defineShikijiSetup(fn) {
6
- return fn;
7
- }
8
- function defineWindiSetup(fn) {
9
- return fn;
10
- }
11
5
  function defineUnoSetup(fn) {
12
6
  return fn;
13
7
  }
@@ -36,8 +30,6 @@ export {
36
30
  defineMonacoSetup,
37
31
  definePreparserSetup,
38
32
  defineShikiSetup,
39
- defineShikijiSetup,
40
33
  defineShortcutsSetup,
41
- defineUnoSetup,
42
- defineWindiSetup
34
+ defineUnoSetup
43
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/types",
3
- "version": "0.46.3",
3
+ "version": "0.47.0",
4
4
  "description": "Shared types declarations for Slidev",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",