@slidev/types 0.42.5 → 0.42.6

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.
Files changed (2) hide show
  1. package/dist/index.d.mts +454 -0
  2. package/package.json +2 -2
@@ -0,0 +1,454 @@
1
+ import { TransitionGroupProps, App, Ref } from 'vue';
2
+ import { Awaitable } from '@antfu/utils';
3
+ import * as Shiki from 'shiki';
4
+ import { IThemeRegistration, ILanguageRegistration, Highlighter } from 'shiki';
5
+ import * as monaco from 'monaco-editor';
6
+ import { Router } from 'vue-router';
7
+ import mermaid from 'mermaid';
8
+ import { KatexOptions } from 'katex';
9
+ import { WindiCssOptions } from 'vite-plugin-windicss';
10
+ import { VitePluginConfig } from 'unocss/vite';
11
+
12
+ interface CommonArgs {
13
+ entry: string;
14
+ theme?: string;
15
+ }
16
+ interface ExportArgs extends CommonArgs {
17
+ output?: string;
18
+ format?: string;
19
+ timeout?: number;
20
+ range?: string;
21
+ dark?: boolean;
22
+ 'with-clicks'?: boolean;
23
+ 'executable-path'?: string;
24
+ 'with-toc'?: boolean;
25
+ 'per-slide'?: boolean;
26
+ }
27
+ interface BuildArgs extends ExportArgs {
28
+ watch: boolean;
29
+ out: string;
30
+ base?: string;
31
+ download?: boolean;
32
+ inspect: boolean;
33
+ }
34
+
35
+ interface SlidevConfig {
36
+ title: string;
37
+ /**
38
+ * String template to compose title
39
+ *
40
+ * @example "%s - Slidev" - to suffix " - Slidev" to all pages
41
+ * @default '%s - Slidev'
42
+ */
43
+ titleTemplate: string;
44
+ /**
45
+ * Theme to use for the slides
46
+ *
47
+ * @see https://sli.dev/themes/use.html
48
+ * @default 'default'
49
+ */
50
+ theme: string;
51
+ /**
52
+ * List of Slidev addons
53
+ *
54
+ * @default []
55
+ */
56
+ addons: string[];
57
+ /**
58
+ * Download remote assets in local using vite-plugin-remote-assets
59
+ *
60
+ * @default false
61
+ */
62
+ remoteAssets: boolean | 'dev' | 'build';
63
+ /**
64
+ * Enable Monaco
65
+ *
66
+ * @see https://sli.dev/custom/config-monaco.html
67
+ * @default 'dev'
68
+ */
69
+ monaco: boolean | 'dev' | 'build';
70
+ /**
71
+ * Show a download button in the SPA build,
72
+ * could also be a link to custom pdf
73
+ *
74
+ * @default false
75
+ */
76
+ download: boolean | string;
77
+ /**
78
+ * Options for export
79
+ *
80
+ * @default {}
81
+ */
82
+ export: ResolvedExportOptions;
83
+ /**
84
+ * Show a copy button in code blocks
85
+ *
86
+ * @default true
87
+ */
88
+ codeCopy: boolean;
89
+ /**
90
+ * Information shows on the built SPA
91
+ * Can be a markdown string
92
+ *
93
+ * @default false
94
+ */
95
+ info: string | boolean;
96
+ /**
97
+ * Prefer highlighter
98
+ *
99
+ * @see https://sli.dev/custom/highlighters.html
100
+ * @default prism
101
+ */
102
+ highlighter: 'prism' | 'shiki';
103
+ /**
104
+ * Show line numbers in code blocks
105
+ *
106
+ * @default false
107
+ */
108
+ lineNumbers: boolean;
109
+ /**
110
+ * Force slides color schema
111
+ *
112
+ * @default 'auto'
113
+ */
114
+ colorSchema: 'dark' | 'light' | 'all' | 'auto';
115
+ /**
116
+ * Router mode for vue-router
117
+ *
118
+ * @default 'history'
119
+ */
120
+ routerMode: 'hash' | 'history';
121
+ /**
122
+ * Aspect ratio for slides
123
+ * should be like `16/9` or `1:1`
124
+ *
125
+ * @default '16/9'
126
+ */
127
+ aspectRatio: number;
128
+ /**
129
+ * The actual width for slides canvas.
130
+ * unit in px.
131
+ *
132
+ * @default '980'
133
+ */
134
+ canvasWidth: number;
135
+ /**
136
+ * Force the filename used when exporting the presentation.
137
+ * The extension, e.g. .pdf, gets automatically added.
138
+ *
139
+ * @default ''
140
+ */
141
+ exportFilename: string | null;
142
+ /**
143
+ * Controls whether texts in slides are selectable
144
+ *
145
+ * @default true
146
+ */
147
+ selectable: boolean;
148
+ /**
149
+ * Configure for themes, will inject intro root styles as
150
+ * `--slidev-theme-x` for attribute `x`
151
+ *
152
+ * This allows themes to have customization options in frontmatter
153
+ * Refer to themes' document for options avaliable
154
+ *
155
+ * @default {}
156
+ */
157
+ themeConfig: SlidevThemeConfig;
158
+ /**
159
+ * Configure fonts for the slides and app
160
+ *
161
+ * @default {}
162
+ */
163
+ fonts: ResolvedFontOptions;
164
+ /**
165
+ * Configure the icon for app
166
+ *
167
+ * @default 'https://cdn.jsdelivr.net/gh/slidevjs/slidev/assets/favicon.png'
168
+ */
169
+ favicon: string;
170
+ /**
171
+ * Options for drawings
172
+ *
173
+ * @default {}
174
+ */
175
+ drawings: ResolvedDrawingsOptions;
176
+ /**
177
+ * URL of PlantUML server used to render diagrams
178
+ *
179
+ * @default https://www.plantuml.com/plantuml
180
+ */
181
+ plantUmlServer: string;
182
+ /**
183
+ * Enable slides recording
184
+ *
185
+ * @default 'dev'
186
+ */
187
+ record: boolean | 'dev' | 'build';
188
+ /**
189
+ * Expose the server to inbound requests (listen to `0.0.0.0`)
190
+ *
191
+ * Pass a string to set the password for accessing presenter mode.
192
+ *
193
+ * @default false
194
+ */
195
+ remote?: string | boolean;
196
+ /**
197
+ * Engine for Atomic CSS
198
+ *
199
+ * @see https://unocss.dev/
200
+ * @see https://windicss.org/
201
+ * @default 'unocss'
202
+ */
203
+ css: 'unocss' | 'windicss' | 'none';
204
+ /**
205
+ * Enable presenter mode
206
+ *
207
+ * @default true
208
+ */
209
+ presenter: boolean | 'dev' | 'build';
210
+ /**
211
+ * Attributes to apply to the HTML element
212
+ *
213
+ * @default {}
214
+ */
215
+ htmlAttrs: Record<string, string>;
216
+ /**
217
+ * Page transition, powered by Vue's <TransitionGroup/>
218
+ *
219
+ * Built-in transitions:
220
+ * - fade
221
+ * - fade-out
222
+ * - slide-left
223
+ * - slide-right
224
+ * - slide-up
225
+ * - slide-down
226
+ *
227
+ * @see https://sli.dev/guide/animations.html#pages-transitions
228
+ * @see https://vuejs.org/guide/built-ins/transition.html
229
+ */
230
+ transition?: BuiltinSlideTransition | string | TransitionGroupProps;
231
+ }
232
+ interface FontOptions {
233
+ /**
234
+ * Sans serif fonts (default fonts for most text)
235
+ */
236
+ sans?: string | string[];
237
+ /**
238
+ * Serif fonts
239
+ */
240
+ serif?: string | string[];
241
+ /**
242
+ * Monospace fonts, for code blocks and etc.
243
+ */
244
+ mono?: string | string[];
245
+ /**
246
+ * Load webfonts for custom CSS (does not apply anywhere by default)
247
+ */
248
+ custom?: string | string[];
249
+ /**
250
+ * Weights for fonts
251
+ *
252
+ * @default [200, 400, 600]
253
+ */
254
+ weights?: string | (string | number)[];
255
+ /**
256
+ * Import italic fonts
257
+ *
258
+ * @default false
259
+ */
260
+ italic?: boolean;
261
+ /**
262
+ * @default 'google'
263
+ */
264
+ provider?: 'none' | 'google';
265
+ /**
266
+ * Specify web fonts names, will detect from `sans`, `mono`, `serif` if not provided
267
+ */
268
+ webfonts?: string[];
269
+ /**
270
+ * Specify local fonts names, be excluded from webfonts
271
+ */
272
+ local?: string[];
273
+ /**
274
+ * Use fonts fallback
275
+ *
276
+ * @default true
277
+ */
278
+ fallbacks?: boolean;
279
+ }
280
+ interface DrawingsOptions {
281
+ /**
282
+ * Persist the drawings to disk
283
+ * Passing string to specify the directory (default to `.slidev/drawings`)
284
+ *
285
+ * @default false
286
+ */
287
+ persist?: boolean | string;
288
+ /**
289
+ * @default true
290
+ */
291
+ enabled?: boolean | 'dev' | 'build';
292
+ /**
293
+ * Only allow drawing from presenter mode
294
+ *
295
+ * @default false
296
+ */
297
+ presenterOnly?: boolean;
298
+ /**
299
+ * Sync drawing for all instances
300
+ *
301
+ * @default true
302
+ */
303
+ syncAll?: boolean;
304
+ }
305
+ interface ResolvedFontOptions {
306
+ sans: string[];
307
+ mono: string[];
308
+ serif: string[];
309
+ weights: string[];
310
+ italic: boolean;
311
+ provider: 'none' | 'google';
312
+ webfonts: string[];
313
+ local: string[];
314
+ }
315
+ interface ResolvedDrawingsOptions {
316
+ persist: string | false;
317
+ enabled: boolean | 'dev' | 'build';
318
+ presenterOnly: boolean;
319
+ syncAll: boolean;
320
+ }
321
+ interface ResolvedExportOptions extends Omit<ExportArgs, 'entry' | 'theme'> {
322
+ withClicks?: boolean;
323
+ executablePath?: string;
324
+ withToc?: boolean;
325
+ }
326
+ type BuiltinSlideTransition = 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'fade' | 'zoom' | 'none';
327
+
328
+ interface SlideInfoBase {
329
+ raw: string;
330
+ content: string;
331
+ note?: string;
332
+ frontmatter: Record<string, any>;
333
+ title?: string;
334
+ level?: number;
335
+ }
336
+ interface SlideInfo extends SlideInfoBase {
337
+ index: number;
338
+ start: number;
339
+ end: number;
340
+ inline?: SlideInfoBase;
341
+ source?: SlideInfoWithPath;
342
+ }
343
+ interface SlideInfoWithPath extends SlideInfoBase {
344
+ filepath: string;
345
+ }
346
+ interface SlideInfoExtended extends SlideInfo {
347
+ noteHTML: string;
348
+ }
349
+ /**
350
+ * Metadata for "slidev" field in themes' package.json
351
+ */
352
+ interface SlidevThemeMeta {
353
+ defaults?: Partial<SlidevConfig>;
354
+ colorSchema?: 'dark' | 'light' | 'both';
355
+ highlighter?: 'prism' | 'shiki' | 'both';
356
+ }
357
+ type SlidevThemeConfig = Record<string, string | number>;
358
+ interface SlidevFeatureFlags {
359
+ katex: boolean;
360
+ monaco: boolean;
361
+ tweet: boolean;
362
+ mermaid: boolean;
363
+ }
364
+ interface SlidevMarkdown {
365
+ slides: SlideInfo[];
366
+ raw: string;
367
+ config: SlidevConfig;
368
+ features: SlidevFeatureFlags;
369
+ headmatter: Record<string, unknown>;
370
+ filepath?: string;
371
+ entries?: string[];
372
+ themeMeta?: SlidevThemeMeta;
373
+ }
374
+ interface SlidevPreparserExtension {
375
+ name: string;
376
+ transformRawLines?(lines: string[]): Promise<void> | void;
377
+ transformSlide?(content: string, frontmatter: any): Promise<string | undefined>;
378
+ }
379
+ type PreparserExtensionLoader = (headmatter?: Record<string, unknown>, filepath?: string) => Promise<SlidevPreparserExtension[]>;
380
+ type PreparserExtensionFromHeadmatter = (headmatter: any, exts: SlidevPreparserExtension[], filepath?: string) => Promise<SlidevPreparserExtension[]>;
381
+ type RenderContext = 'slide' | 'overview' | 'presenter' | 'previewNext';
382
+
383
+ interface AppContext {
384
+ app: App;
385
+ router: Router;
386
+ }
387
+ interface ShikiDarkModeThemes {
388
+ dark: IThemeRegistration;
389
+ light: IThemeRegistration;
390
+ }
391
+ interface ShikiOptions {
392
+ theme?: IThemeRegistration | ShikiDarkModeThemes;
393
+ langs?: ILanguageRegistration[];
394
+ highlighter?: Highlighter;
395
+ }
396
+ interface MonacoSetupReturn {
397
+ theme?: {
398
+ light?: string;
399
+ dark?: string;
400
+ };
401
+ }
402
+ type MermaidOptions = (typeof mermaid.initialize) extends (a: infer A) => any ? A : never;
403
+ interface NavOperations {
404
+ next: () => void;
405
+ prev: () => Promise<void>;
406
+ nextSlide: () => void;
407
+ prevSlide: () => Promise<void>;
408
+ go: (index: number) => void;
409
+ goFirst: () => void;
410
+ goLast: () => void;
411
+ downloadPDF: () => Promise<void>;
412
+ toggleDark: () => void;
413
+ toggleOverview: () => void;
414
+ toggleDrawing: () => void;
415
+ escapeOverview: () => void;
416
+ showGotoDialog: () => void;
417
+ }
418
+ interface ShortcutOptions {
419
+ key: string | Ref<boolean>;
420
+ fn?: () => void;
421
+ autoRepeat?: boolean;
422
+ name?: string;
423
+ }
424
+ type ShikiSetup = (shiki: typeof Shiki) => Awaitable<ShikiOptions | undefined>;
425
+ type KatexSetup = () => Awaitable<Partial<KatexOptions> | undefined>;
426
+ type WindiSetup = () => Awaitable<Partial<WindiCssOptions> | undefined>;
427
+ type UnoSetup = () => Awaitable<Partial<VitePluginConfig> | undefined>;
428
+ type PreparserSetup = (filepath: string) => SlidevPreparserExtension;
429
+ type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn>;
430
+ type AppSetup = (context: AppContext) => Awaitable<void>;
431
+ type MermaidSetup = () => Partial<MermaidOptions> | undefined;
432
+ type ShortcutsSetup = (nav: NavOperations, defaultShortcuts: ShortcutOptions[]) => Array<ShortcutOptions>;
433
+ declare function defineShikiSetup(fn: ShikiSetup): ShikiSetup;
434
+ declare function defineWindiSetup(fn: WindiSetup): WindiSetup;
435
+ declare function defineUnoSetup(fn: UnoSetup): UnoSetup;
436
+ declare function defineMonacoSetup(fn: MonacoSetup): MonacoSetup;
437
+ declare function defineAppSetup(fn: AppSetup): AppSetup;
438
+ declare function defineMermaidSetup(fn: MermaidSetup): MermaidSetup;
439
+ declare function defineKatexSetup(fn: KatexSetup): KatexSetup;
440
+ declare function defineShortcutsSetup(fn: ShortcutsSetup): ShortcutsSetup;
441
+ declare function definePreparserSetup(fn: PreparserSetup): PreparserSetup;
442
+
443
+ interface TocItem {
444
+ active?: boolean;
445
+ activeParent?: boolean;
446
+ children: TocItem[];
447
+ hasActiveParent?: boolean;
448
+ level: number;
449
+ path: string;
450
+ hideInToc?: boolean;
451
+ title?: string;
452
+ }
453
+
454
+ export { AppContext, AppSetup, BuildArgs, BuiltinSlideTransition, CommonArgs, DrawingsOptions, ExportArgs, FontOptions, KatexSetup, MermaidOptions, MermaidSetup, MonacoSetup, MonacoSetupReturn, NavOperations, PreparserExtensionFromHeadmatter, PreparserExtensionLoader, PreparserSetup, RenderContext, ResolvedDrawingsOptions, ResolvedExportOptions, ResolvedFontOptions, ShikiDarkModeThemes, ShikiOptions, ShikiSetup, ShortcutOptions, ShortcutsSetup, SlideInfo, SlideInfoBase, SlideInfoExtended, SlideInfoWithPath, SlidevConfig, SlidevFeatureFlags, SlidevMarkdown, SlidevPreparserExtension, SlidevThemeConfig, SlidevThemeMeta, TocItem, UnoSetup, WindiSetup, defineAppSetup, defineKatexSetup, defineMermaidSetup, defineMonacoSetup, definePreparserSetup, defineShikiSetup, defineShortcutsSetup, defineUnoSetup, defineWindiSetup };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slidev/types",
3
- "version": "0.42.5",
4
- "description": "Shared types declerations for Slidev",
3
+ "version": "0.42.6",
4
+ "description": "Shared types declarations for Slidev",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/antfu",