@slidev/types 0.49.0-beta.1 → 0.49.0-beta.3
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 +14 -0
- package/dist/index.d.mts +95 -72
- package/dist/index.mjs +18 -27
- package/package.json +2 -2
package/client.d.ts
CHANGED
|
@@ -97,6 +97,20 @@ declare module '#slidev/setups/shortcuts' {
|
|
|
97
97
|
export default setups
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
declare module '#slidev/setups/routes' {
|
|
101
|
+
import type { RoutesSetup } from '@slidev/types'
|
|
102
|
+
|
|
103
|
+
const setups: RoutesSetup[]
|
|
104
|
+
export default setups
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare module '#slidev/setups/context-menu' {
|
|
108
|
+
import type { ContextMenuSetup } from '@slidev/types'
|
|
109
|
+
|
|
110
|
+
const setups: ContextMenuSetup[]
|
|
111
|
+
export default setups
|
|
112
|
+
}
|
|
113
|
+
|
|
100
114
|
declare module '#slidev/styles' {
|
|
101
115
|
// side-effects only
|
|
102
116
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { RouteMeta, RouteComponent, Router, RouteRecordRaw } from 'vue-router';
|
|
2
|
+
import YAML from 'yaml';
|
|
3
|
+
import { TransitionGroupProps, Component, App, Ref, ComputedRef } from 'vue';
|
|
3
4
|
import { Arrayable, Awaitable, ArgumentsType } from '@antfu/utils';
|
|
4
5
|
import * as monaco from 'monaco-editor';
|
|
5
6
|
import mermaid from 'mermaid';
|
|
@@ -271,6 +272,12 @@ interface SlidevConfig {
|
|
|
271
272
|
* @default true
|
|
272
273
|
*/
|
|
273
274
|
editor: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Enable context menu
|
|
277
|
+
*
|
|
278
|
+
* @default true
|
|
279
|
+
*/
|
|
280
|
+
contextMenu: boolean | 'dev' | 'build' | undefined;
|
|
274
281
|
}
|
|
275
282
|
interface FontOptions {
|
|
276
283
|
/**
|
|
@@ -392,6 +399,7 @@ interface SourceSlideInfo extends SlideInfoBase {
|
|
|
392
399
|
end: number;
|
|
393
400
|
raw: string;
|
|
394
401
|
frontmatterRaw?: string;
|
|
402
|
+
frontmatterDoc?: YAML.Document;
|
|
395
403
|
frontmatterStyle?: FrontmatterStyle;
|
|
396
404
|
}
|
|
397
405
|
interface SlideInfo extends SlideInfoBase {
|
|
@@ -406,8 +414,13 @@ interface SlideInfo extends SlideInfoBase {
|
|
|
406
414
|
/**
|
|
407
415
|
* Editable fields for a slide
|
|
408
416
|
*/
|
|
409
|
-
type SlidePatch = Partial<Pick<SlideInfoBase, 'content' | 'note'
|
|
417
|
+
type SlidePatch = Partial<Pick<SlideInfoBase, 'content' | 'note'>> & {
|
|
410
418
|
skipHmr?: boolean;
|
|
419
|
+
/**
|
|
420
|
+
* The frontmatter patch (only the changed fields)
|
|
421
|
+
* `null` to remove a field
|
|
422
|
+
*/
|
|
423
|
+
frontmatter?: Record<string, any>;
|
|
411
424
|
};
|
|
412
425
|
/**
|
|
413
426
|
* Metadata for "slidev" field in themes' package.json
|
|
@@ -458,61 +471,6 @@ interface SlideRoute {
|
|
|
458
471
|
component: () => Promise<RouteComponent>;
|
|
459
472
|
}
|
|
460
473
|
type LoadedSnippets = Record<string, string>;
|
|
461
|
-
type ClicksElement = Element | string;
|
|
462
|
-
type ClicksRelativeEls = Map<ClicksElement, number>;
|
|
463
|
-
interface ClicksInfo {
|
|
464
|
-
/**
|
|
465
|
-
* The maximum clicks, used to calculate the total clicks for current slide
|
|
466
|
-
*/
|
|
467
|
-
max?: number;
|
|
468
|
-
/**
|
|
469
|
-
* The offsets added to the subsequent clicks
|
|
470
|
-
* Delta is 0 when the click is absolute
|
|
471
|
-
*/
|
|
472
|
-
delta: number;
|
|
473
|
-
/**
|
|
474
|
-
* Resolved clicks
|
|
475
|
-
*/
|
|
476
|
-
clicks?: number | [number, number];
|
|
477
|
-
/**
|
|
478
|
-
* Computed ref of whether the click is exactly matched
|
|
479
|
-
*/
|
|
480
|
-
isCurrent?: ComputedRef<boolean>;
|
|
481
|
-
/**
|
|
482
|
-
* Computed ref of whether the click is active
|
|
483
|
-
*/
|
|
484
|
-
isActive?: ComputedRef<boolean>;
|
|
485
|
-
/**
|
|
486
|
-
* Computed ref of whether the click is shown, it take flagHide into account
|
|
487
|
-
*/
|
|
488
|
-
isShown?: ComputedRef<boolean>;
|
|
489
|
-
/**
|
|
490
|
-
* Having the hide flag
|
|
491
|
-
*/
|
|
492
|
-
flagHide?: boolean;
|
|
493
|
-
/**
|
|
494
|
-
* Having the fade flag
|
|
495
|
-
*/
|
|
496
|
-
flagFade?: boolean;
|
|
497
|
-
}
|
|
498
|
-
type ResolvedClicksInfo = Required<ClicksInfo>;
|
|
499
|
-
type ClicksMap = Map<ClicksElement, ClicksInfo>;
|
|
500
|
-
interface ClicksContext {
|
|
501
|
-
current: number;
|
|
502
|
-
readonly clicksStart: number;
|
|
503
|
-
readonly relativeOffsets: ClicksRelativeEls;
|
|
504
|
-
readonly map: ClicksMap;
|
|
505
|
-
resolve: (at: string | number, size?: number) => {
|
|
506
|
-
start: number;
|
|
507
|
-
end: number;
|
|
508
|
-
delta: number;
|
|
509
|
-
};
|
|
510
|
-
register: (el: ClicksElement, info: ClicksInfo) => void;
|
|
511
|
-
unregister: (el: ClicksElement) => void;
|
|
512
|
-
onMounted: () => void;
|
|
513
|
-
readonly currentOffset: number;
|
|
514
|
-
readonly total: number;
|
|
515
|
-
}
|
|
516
474
|
|
|
517
475
|
interface CodeRunnerContext {
|
|
518
476
|
/**
|
|
@@ -572,6 +530,20 @@ type CodeRunnerOutputs = Arrayable<CodeRunnerOutput>;
|
|
|
572
530
|
type CodeRunner = (code: string, ctx: CodeRunnerContext) => Awaitable<CodeRunnerOutputs>;
|
|
573
531
|
type CodeRunnerProviders = Record<string, CodeRunner>;
|
|
574
532
|
|
|
533
|
+
type ContextMenuOption = {
|
|
534
|
+
action: () => void;
|
|
535
|
+
disabled?: boolean;
|
|
536
|
+
} & ({
|
|
537
|
+
small?: false;
|
|
538
|
+
icon?: Component;
|
|
539
|
+
label: string | Component;
|
|
540
|
+
} | {
|
|
541
|
+
small: true;
|
|
542
|
+
icon: Component;
|
|
543
|
+
label: string;
|
|
544
|
+
});
|
|
545
|
+
type ContextMenuItem = ContextMenuOption | 'separator';
|
|
546
|
+
|
|
575
547
|
interface AppContext {
|
|
576
548
|
app: App;
|
|
577
549
|
router: Router;
|
|
@@ -608,10 +580,10 @@ interface ShikiContext {
|
|
|
608
580
|
*/
|
|
609
581
|
loadTheme: (path: string) => Promise<any>;
|
|
610
582
|
}
|
|
611
|
-
type ShikiSetupReturn = Partial<Omit<CodeToHastOptionsCommon<BuiltinLanguage>, 'lang'
|
|
612
|
-
setup
|
|
613
|
-
langs
|
|
614
|
-
}
|
|
583
|
+
type ShikiSetupReturn = Partial<Omit<CodeToHastOptionsCommon<BuiltinLanguage>, 'lang'> & CodeOptionsThemes<BuiltinTheme> & CodeOptionsMeta & {
|
|
584
|
+
setup: (highlighter: Highlighter) => Awaitable<void>;
|
|
585
|
+
langs: (LanguageInput | BuiltinLanguage)[];
|
|
586
|
+
}>;
|
|
615
587
|
type ShikiSetup = (shiki: ShikiContext) => Awaitable<ShikiSetupReturn | void>;
|
|
616
588
|
type KatexSetup = () => Awaitable<Partial<KatexOptions> | void>;
|
|
617
589
|
type UnoSetup = () => Awaitable<Partial<VitePluginConfig> | void>;
|
|
@@ -619,18 +591,23 @@ type PreparserSetup = (filepath: string) => SlidevPreparserExtension;
|
|
|
619
591
|
type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn | void>;
|
|
620
592
|
type AppSetup = (context: AppContext) => Awaitable<void>;
|
|
621
593
|
type RootSetup = () => Awaitable<void>;
|
|
594
|
+
type RoutesSetup = (routes: RouteRecordRaw[]) => RouteRecordRaw[];
|
|
622
595
|
type MermaidSetup = () => Partial<MermaidOptions> | void;
|
|
623
596
|
type ShortcutsSetup = (nav: NavOperations, defaultShortcuts: ShortcutOptions[]) => Array<ShortcutOptions>;
|
|
624
597
|
type CodeRunnersSetup = (runners: CodeRunnerProviders) => Awaitable<CodeRunnerProviders | void>;
|
|
625
|
-
|
|
626
|
-
declare
|
|
627
|
-
declare
|
|
628
|
-
declare
|
|
629
|
-
declare
|
|
630
|
-
declare
|
|
631
|
-
declare
|
|
632
|
-
declare
|
|
633
|
-
declare
|
|
598
|
+
type ContextMenuSetup = (items: ComputedRef<ContextMenuItem[]>) => ComputedRef<ContextMenuItem[]>;
|
|
599
|
+
declare const defineShikiSetup: (fn: ShikiSetup) => ShikiSetup;
|
|
600
|
+
declare const defineUnoSetup: (fn: UnoSetup) => UnoSetup;
|
|
601
|
+
declare const defineMonacoSetup: (fn: MonacoSetup) => MonacoSetup;
|
|
602
|
+
declare const defineAppSetup: (fn: AppSetup) => AppSetup;
|
|
603
|
+
declare const defineRootSetup: (fn: RootSetup) => RootSetup;
|
|
604
|
+
declare const defineRoutesSetup: (fn: RoutesSetup) => RoutesSetup;
|
|
605
|
+
declare const defineMermaidSetup: (fn: MermaidSetup) => MermaidSetup;
|
|
606
|
+
declare const defineKatexSetup: (fn: KatexSetup) => KatexSetup;
|
|
607
|
+
declare const defineShortcutsSetup: (fn: ShortcutsSetup) => ShortcutsSetup;
|
|
608
|
+
declare const definePreparserSetup: (fn: PreparserSetup) => PreparserSetup;
|
|
609
|
+
declare const defineCodeRunnersSetup: (fn: CodeRunnersSetup) => CodeRunnersSetup;
|
|
610
|
+
declare const defineContextMenuSetup: (fn: ContextMenuSetup) => ContextMenuSetup;
|
|
634
611
|
|
|
635
612
|
interface TocItem {
|
|
636
613
|
no: number;
|
|
@@ -732,4 +709,50 @@ interface MarkdownTransformContext {
|
|
|
732
709
|
isIgnored: (index: number) => boolean;
|
|
733
710
|
}
|
|
734
711
|
|
|
735
|
-
|
|
712
|
+
type RawAtValue = undefined | boolean | string | number | [string | number, string | number];
|
|
713
|
+
type NormalizedSinceClickValue = number | string;
|
|
714
|
+
type NormalizedRangeClickValue = [number, number] | [number, string] | [string, number] | [string, string];
|
|
715
|
+
type NormalizedAtValue = NormalizedSinceClickValue | NormalizedRangeClickValue | null;
|
|
716
|
+
type ClicksElement = Element | string;
|
|
717
|
+
interface ClicksInfo {
|
|
718
|
+
/**
|
|
719
|
+
* The absolute start click num
|
|
720
|
+
*/
|
|
721
|
+
start: number;
|
|
722
|
+
/**
|
|
723
|
+
* The absolute end click num
|
|
724
|
+
*/
|
|
725
|
+
end: number;
|
|
726
|
+
/**
|
|
727
|
+
* The required total click num
|
|
728
|
+
*/
|
|
729
|
+
max: number;
|
|
730
|
+
/**
|
|
731
|
+
* The delta for relative clicks
|
|
732
|
+
*/
|
|
733
|
+
delta: number;
|
|
734
|
+
/**
|
|
735
|
+
* Computed ref of whether the click is exactly matched
|
|
736
|
+
*/
|
|
737
|
+
isCurrent: ComputedRef<boolean>;
|
|
738
|
+
/**
|
|
739
|
+
* Computed ref of whether the click is active
|
|
740
|
+
*/
|
|
741
|
+
isActive: ComputedRef<boolean>;
|
|
742
|
+
}
|
|
743
|
+
interface ClicksContext {
|
|
744
|
+
current: number;
|
|
745
|
+
readonly clicksStart: number;
|
|
746
|
+
readonly relativeOffsets: Map<ClicksElement, number>;
|
|
747
|
+
readonly maxMap: Map<ClicksElement, number>;
|
|
748
|
+
calculateSince: (at: NormalizedSinceClickValue, size?: number) => ClicksInfo;
|
|
749
|
+
calculateRange: (at: NormalizedRangeClickValue) => ClicksInfo;
|
|
750
|
+
calculate: (at: NormalizedAtValue) => ClicksInfo | null;
|
|
751
|
+
register: (el: ClicksElement, info: Pick<ClicksInfo, 'delta' | 'max'>) => void;
|
|
752
|
+
unregister: (el: ClicksElement) => void;
|
|
753
|
+
onMounted: () => void;
|
|
754
|
+
readonly currentOffset: number;
|
|
755
|
+
readonly total: number;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
export { type AppContext, type AppSetup, type BuildArgs, type BuiltinSlideTransition, type ClicksContext, type ClicksElement, type ClicksInfo, type CodeRunner, type CodeRunnerContext, type CodeRunnerOutput, type CodeRunnerOutputDom, type CodeRunnerOutputError, type CodeRunnerOutputHtml, type CodeRunnerOutputText, type CodeRunnerOutputTextArray, type CodeRunnerOutputs, type CodeRunnerProviders, type CodeRunnersSetup, type CommonArgs, type ContextMenuItem, type ContextMenuSetup, type DrawingsOptions, type ExportArgs, type FontOptions, type FrontmatterStyle, type KatexSetup, type LoadedSnippets, type MarkdownTransformContext, type MermaidOptions, type MermaidSetup, type MonacoSetup, type MonacoSetupReturn, type NavOperations, type NormalizedAtValue, type NormalizedRangeClickValue, type NormalizedSinceClickValue, type PreparserExtensionLoader, type PreparserSetup, type RawAtValue, type RenderContext, type ResolvedDrawingsOptions, type ResolvedExportOptions, type ResolvedFontOptions, type ResolvedSlidevOptions, type RootSetup, type RootsInfo, type RoutesSetup, type ShikiContext, type ShikiSetup, type ShikiSetupReturn, type ShortcutOptions, type ShortcutsSetup, type SlideInfo, type SlideInfoBase, type SlidePatch, type SlideRoute, type SlidevConfig, type SlidevData, type SlidevEntryOptions, type SlidevFeatureFlags, type SlidevMarkdown, type SlidevPluginOptions, type SlidevPreparserExtension, type SlidevServerOptions, type SlidevThemeConfig, type SlidevThemeMeta, type SourceSlideInfo, type TocItem, type UnoSetup, defineAppSetup, defineCodeRunnersSetup, defineContextMenuSetup, defineKatexSetup, defineMermaidSetup, defineMonacoSetup, definePreparserSetup, defineRootSetup, defineRoutesSetup, defineShikiSetup, defineShortcutsSetup, defineUnoSetup };
|
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
// src/setups.ts
|
|
2
|
-
function
|
|
3
|
-
return fn;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function defineKatexSetup(fn) {
|
|
18
|
-
return fn;
|
|
19
|
-
}
|
|
20
|
-
function defineShortcutsSetup(fn) {
|
|
21
|
-
return fn;
|
|
22
|
-
}
|
|
23
|
-
function definePreparserSetup(fn) {
|
|
24
|
-
return fn;
|
|
25
|
-
}
|
|
26
|
-
function defineCodeRunnersSetup(fn) {
|
|
27
|
-
return fn;
|
|
28
|
-
}
|
|
2
|
+
function defineSetup(fn) {
|
|
3
|
+
return fn;
|
|
4
|
+
}
|
|
5
|
+
var defineShikiSetup = defineSetup;
|
|
6
|
+
var defineUnoSetup = defineSetup;
|
|
7
|
+
var defineMonacoSetup = defineSetup;
|
|
8
|
+
var defineAppSetup = defineSetup;
|
|
9
|
+
var defineRootSetup = defineSetup;
|
|
10
|
+
var defineRoutesSetup = defineSetup;
|
|
11
|
+
var defineMermaidSetup = defineSetup;
|
|
12
|
+
var defineKatexSetup = defineSetup;
|
|
13
|
+
var defineShortcutsSetup = defineSetup;
|
|
14
|
+
var definePreparserSetup = defineSetup;
|
|
15
|
+
var defineCodeRunnersSetup = defineSetup;
|
|
16
|
+
var defineContextMenuSetup = defineSetup;
|
|
29
17
|
export {
|
|
30
18
|
defineAppSetup,
|
|
31
19
|
defineCodeRunnersSetup,
|
|
20
|
+
defineContextMenuSetup,
|
|
32
21
|
defineKatexSetup,
|
|
33
22
|
defineMermaidSetup,
|
|
34
23
|
defineMonacoSetup,
|
|
35
24
|
definePreparserSetup,
|
|
25
|
+
defineRootSetup,
|
|
26
|
+
defineRoutesSetup,
|
|
36
27
|
defineShikiSetup,
|
|
37
28
|
defineShortcutsSetup,
|
|
38
29
|
defineUnoSetup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/types",
|
|
3
|
-
"version": "0.49.0-beta.
|
|
3
|
+
"version": "0.49.0-beta.3",
|
|
4
4
|
"description": "Shared types declarations for Slidev",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"mermaid": "^10.9.0",
|
|
31
31
|
"monaco-editor": "^0.47.0",
|
|
32
32
|
"shiki": "^1.3.0",
|
|
33
|
-
"unocss": "^0.59.
|
|
33
|
+
"unocss": "^0.59.2",
|
|
34
34
|
"unplugin-icons": "^0.18.5",
|
|
35
35
|
"unplugin-vue-markdown": "^0.26.0",
|
|
36
36
|
"vite-plugin-remote-assets": "^0.4.1",
|