@slidev/types 0.48.0-beta.2 → 0.48.0-beta.20

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/client.d.ts CHANGED
@@ -1,5 +1,64 @@
1
- declare module '/@slidev/configs' {
2
- import { SlidevConfig } from './types'
1
+ // Types for virtual modules
2
+ // `#slidev/*` is an alias for `/@slidev/*`, because TS will consider `/@slidev/*` as an absolute path that we can't override
3
3
 
4
- export default SlidevConfig
4
+ declare module '#slidev/configs' {
5
+ import type { SlidevConfig } from '@slidev/types'
6
+
7
+ const configs: SlidevConfig
8
+ export default configs
9
+ }
10
+
11
+ declare module '#slidev/global-components/top' {
12
+ import type { ComponentOptions } from 'vue'
13
+
14
+ const component: ComponentOptions
15
+ export default component
16
+ }
17
+
18
+ declare module '#slidev/global-components/bottom' {
19
+ import type { ComponentOptions } from 'vue'
20
+
21
+ const component: ComponentOptions
22
+ export default component
23
+ }
24
+
25
+ declare module '#slidev/routes' {
26
+ import type { RouteRecordRaw } from 'vue-router'
27
+
28
+ const rawRoutes: RouteRecordRaw[]
29
+ const redirects: RouteRecordRaw[]
30
+ export { rawRoutes, redirects }
31
+ }
32
+
33
+ declare module '@slidev/titles.md' {
34
+ import type { ComponentOptions } from 'vue'
35
+
36
+ const component: ComponentOptions
37
+ export default component
38
+ }
39
+
40
+ declare module '#slidev/custom-nav-controls' {
41
+ import type { ComponentOptions } from 'vue'
42
+
43
+ const component: ComponentOptions
44
+ export default component
45
+ }
46
+
47
+ declare module '#slidev/shiki' {
48
+ import type { ShikiHighlighterCore } from 'shiki/core'
49
+ import type { BundledLanguage, BundledTheme } from 'shiki'
50
+
51
+ export { shikiToMonaco } from '@shikijs/monaco'
52
+
53
+ export const langs: BundledLanguage[]
54
+ export const themes: BundledTheme | Record<string, BundledTheme>
55
+ export const shiki: Promise<ShikiHighlighterCore>
56
+ }
57
+
58
+ declare module '#slidev/styles' {
59
+ // side-effects only
60
+ }
61
+
62
+ declare module '#slidev/monaco-types' {
63
+ // side-effects only
5
64
  }
package/dist/index.d.mts CHANGED
@@ -67,6 +67,21 @@ interface SlidevConfig {
67
67
  * @default 'dev'
68
68
  */
69
69
  monaco: boolean | 'dev' | 'build';
70
+ /**
71
+ * Where to load monaco types from
72
+ *
73
+ * - `cdn` - load from CDN with `@typescript/ata`
74
+ * - `local` - load from local node_modules
75
+ *
76
+ * @default 'local'
77
+ */
78
+ monacoTypesSource: 'cdn' | 'local' | 'none';
79
+ /**
80
+ * Additional node packages to load as monaco types
81
+ *
82
+ * @default []
83
+ */
84
+ monacoTypesAdditionalPackages: string[];
70
85
  /**
71
86
  * Show a download button in the SPA build,
72
87
  * could also be a link to custom pdf
@@ -341,29 +356,43 @@ type BuiltinSlideTransition = 'slide-up' | 'slide-down' | 'slide-left' | 'slide-
341
356
 
342
357
  type FrontmatterStyle = 'frontmatter' | 'yaml';
343
358
  interface SlideInfoBase {
344
- raw: string;
359
+ frontmatter: Record<string, any>;
345
360
  content: string;
346
361
  note?: string;
347
- frontmatter: Record<string, any>;
348
- frontmatterRaw?: string;
349
- frontmatterStyle?: FrontmatterStyle;
350
362
  title?: string;
351
363
  level?: number;
352
364
  }
353
- interface SlideInfo extends SlideInfoBase {
365
+ interface SourceSlideInfo extends SlideInfoBase {
366
+ /**
367
+ * The filepath of the markdown file
368
+ */
369
+ filepath: string;
370
+ /**
371
+ * The index of the slide in the markdown file
372
+ */
354
373
  index: number;
374
+ /**
375
+ * The range of the slide in the markdown file
376
+ */
355
377
  start: number;
356
378
  end: number;
357
- inline?: SlideInfoBase;
358
- source?: SlideInfoWithPath;
359
- snippetsUsed?: LoadedSnippets;
360
- }
361
- interface SlideInfoWithPath extends SlideInfo {
362
- filepath: string;
379
+ raw: string;
380
+ frontmatterRaw?: string;
381
+ frontmatterStyle?: FrontmatterStyle;
363
382
  }
364
- interface SlideInfoExtended extends SlideInfo {
365
- noteHTML: string;
383
+ interface SlideInfo extends SlideInfoBase {
384
+ /**
385
+ * The index of the slide in the presentation
386
+ */
387
+ index: number;
388
+ source: SourceSlideInfo;
389
+ snippetsUsed?: LoadedSnippets;
390
+ noteHTML?: string;
366
391
  }
392
+ /**
393
+ * Editable fields for a slide
394
+ */
395
+ type SlidePatch = Partial<Pick<SlideInfoBase, 'content' | 'note'>>;
367
396
  /**
368
397
  * Metadata for "slidev" field in themes' package.json
369
398
  */
@@ -380,24 +409,33 @@ interface SlidevFeatureFlags {
380
409
  mermaid: boolean;
381
410
  }
382
411
  interface SlidevMarkdown {
383
- slides: SlideInfo[];
412
+ filepath: string;
384
413
  raw: string;
414
+ /**
415
+ * All slides in this markdown file
416
+ */
417
+ slides: SourceSlideInfo[];
418
+ }
419
+ interface SlidevData {
420
+ /**
421
+ * Slides that should be rendered (disabled slides excluded)
422
+ */
423
+ slides: SlideInfo[];
424
+ entry: SlidevMarkdown;
385
425
  config: SlidevConfig;
386
- features: SlidevFeatureFlags;
387
426
  headmatter: Record<string, unknown>;
388
- filepath?: string;
389
- entries?: string[];
427
+ features: SlidevFeatureFlags;
390
428
  themeMeta?: SlidevThemeMeta;
391
- subSlides?: Record<string, SlidevMarkdown>;
429
+ markdownFiles: Record<string, SlidevMarkdown>;
430
+ watchFiles: string[];
392
431
  }
393
432
  interface SlidevPreparserExtension {
394
433
  name: string;
395
434
  transformRawLines?: (lines: string[]) => Promise<void> | void;
396
435
  transformSlide?: (content: string, frontmatter: any) => Promise<string | undefined>;
397
436
  }
398
- type PreparserExtensionLoader = (headmatter?: Record<string, unknown>, filepath?: string) => Promise<SlidevPreparserExtension[]>;
399
- type PreparserExtensionFromHeadmatter = (headmatter: any, exts: SlidevPreparserExtension[], filepath?: string) => Promise<SlidevPreparserExtension[]>;
400
- type RenderContext = 'slide' | 'overview' | 'presenter' | 'previewNext';
437
+ type PreparserExtensionLoader = (headmatter?: Record<string, unknown>, filepath?: string, mode?: string) => Promise<SlidevPreparserExtension[]>;
438
+ type RenderContext = 'none' | 'slide' | 'overview' | 'presenter' | 'previewNext';
401
439
  type LoadedSnippets = Record<string, string>;
402
440
  type ClicksElement = Element | string;
403
441
  type ClicksRelativeEls = Map<ClicksElement, number>;
@@ -439,8 +477,8 @@ interface ClicksInfo {
439
477
  type ResolvedClicksInfo = Required<ClicksInfo>;
440
478
  type ClicksMap = Map<ClicksElement, ClicksInfo>;
441
479
  interface ClicksContext {
480
+ current: number;
442
481
  readonly disabled: boolean;
443
- readonly current: number;
444
482
  readonly relativeOffsets: ClicksRelativeEls;
445
483
  readonly map: ClicksMap;
446
484
  resolve: (at: string | number, size?: number) => {
@@ -459,10 +497,6 @@ interface AppContext {
459
497
  router: Router;
460
498
  }
461
499
  interface MonacoSetupReturn {
462
- theme?: {
463
- light?: string;
464
- dark?: string;
465
- };
466
500
  editorOptions?: monaco.editor.IEditorOptions;
467
501
  }
468
502
  type MermaidOptions = (typeof mermaid.initialize) extends (a: infer A) => any ? A : never;
@@ -501,7 +535,7 @@ type ShikiSetup = (shiki: ShikiContext) => Awaitable<ShikiSetupReturn | void>;
501
535
  type KatexSetup = () => Awaitable<Partial<KatexOptions> | void>;
502
536
  type UnoSetup = () => Awaitable<Partial<VitePluginConfig> | void>;
503
537
  type PreparserSetup = (filepath: string) => SlidevPreparserExtension;
504
- type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn>;
538
+ type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn | void>;
505
539
  type AppSetup = (context: AppContext) => Awaitable<void>;
506
540
  type MermaidSetup = () => Partial<MermaidOptions> | void;
507
541
  type ShortcutsSetup = (nav: NavOperations, defaultShortcuts: ShortcutOptions[]) => Array<ShortcutOptions>;
@@ -525,4 +559,4 @@ interface TocItem {
525
559
  title?: string;
526
560
  }
527
561
 
528
- export { type AppContext, type AppSetup, type BuildArgs, type BuiltinSlideTransition, type ClicksContext, type ClicksElement, type ClicksInfo, type ClicksMap, type ClicksRelativeEls, 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 ResolvedClicksInfo, 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 };
562
+ export { type AppContext, type AppSetup, type BuildArgs, type BuiltinSlideTransition, type ClicksContext, type ClicksElement, type ClicksInfo, type ClicksMap, type ClicksRelativeEls, 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 PreparserExtensionLoader, type PreparserSetup, type RenderContext, type ResolvedClicksInfo, type ResolvedDrawingsOptions, type ResolvedExportOptions, type ResolvedFontOptions, type ShikiContext, type ShikiSetup, type ShikiSetupReturn, type ShortcutOptions, type ShortcutsSetup, type SlideInfo, type SlideInfoBase, type SlidePatch, type SlidevConfig, type SlidevData, type SlidevFeatureFlags, type SlidevMarkdown, type SlidevPreparserExtension, type SlidevThemeConfig, type SlidevThemeMeta, type SourceSlideInfo, type TocItem, type UnoSetup, defineAppSetup, defineKatexSetup, defineMermaidSetup, defineMonacoSetup, definePreparserSetup, defineShikiSetup, defineShortcutsSetup, defineUnoSetup };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/types",
3
- "version": "0.48.0-beta.2",
3
+ "version": "0.48.0-beta.20",
4
4
  "description": "Shared types declarations for Slidev",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",