@slidev/types 0.48.9 → 0.49.0-beta.2
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 +7 -0
- package/dist/index.d.mts +93 -71
- package/dist/index.mjs +14 -27
- package/package.json +3 -3
package/client.d.ts
CHANGED
|
@@ -97,6 +97,13 @@ declare module '#slidev/setups/shortcuts' {
|
|
|
97
97
|
export default setups
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
declare module '#slidev/setups/context-menu' {
|
|
101
|
+
import type { ContextMenuSetup } from '@slidev/types'
|
|
102
|
+
|
|
103
|
+
const setups: ContextMenuSetup[]
|
|
104
|
+
export default setups
|
|
105
|
+
}
|
|
106
|
+
|
|
100
107
|
declare module '#slidev/styles' {
|
|
101
108
|
// side-effects only
|
|
102
109
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { TransitionGroupProps, ComputedRef, App, Ref } from 'vue';
|
|
2
1
|
import { RouteMeta, RouteComponent, Router } 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,7 +414,14 @@ 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'>> & {
|
|
418
|
+
skipHmr?: boolean;
|
|
419
|
+
/**
|
|
420
|
+
* The frontmatter patch (only the changed fields)
|
|
421
|
+
* `null` to remove a field
|
|
422
|
+
*/
|
|
423
|
+
frontmatter?: Record<string, any>;
|
|
424
|
+
};
|
|
410
425
|
/**
|
|
411
426
|
* Metadata for "slidev" field in themes' package.json
|
|
412
427
|
*/
|
|
@@ -456,61 +471,6 @@ interface SlideRoute {
|
|
|
456
471
|
component: () => Promise<RouteComponent>;
|
|
457
472
|
}
|
|
458
473
|
type LoadedSnippets = Record<string, string>;
|
|
459
|
-
type ClicksElement = Element | string;
|
|
460
|
-
type ClicksRelativeEls = Map<ClicksElement, number>;
|
|
461
|
-
interface ClicksInfo {
|
|
462
|
-
/**
|
|
463
|
-
* The maximum clicks, used to calculate the total clicks for current slide
|
|
464
|
-
*/
|
|
465
|
-
max?: number;
|
|
466
|
-
/**
|
|
467
|
-
* The offsets added to the subsequent clicks
|
|
468
|
-
* Delta is 0 when the click is absolute
|
|
469
|
-
*/
|
|
470
|
-
delta: number;
|
|
471
|
-
/**
|
|
472
|
-
* Resolved clicks
|
|
473
|
-
*/
|
|
474
|
-
clicks?: number | [number, number];
|
|
475
|
-
/**
|
|
476
|
-
* Computed ref of whether the click is exactly matched
|
|
477
|
-
*/
|
|
478
|
-
isCurrent?: ComputedRef<boolean>;
|
|
479
|
-
/**
|
|
480
|
-
* Computed ref of whether the click is active
|
|
481
|
-
*/
|
|
482
|
-
isActive?: ComputedRef<boolean>;
|
|
483
|
-
/**
|
|
484
|
-
* Computed ref of whether the click is shown, it take flagHide into account
|
|
485
|
-
*/
|
|
486
|
-
isShown?: ComputedRef<boolean>;
|
|
487
|
-
/**
|
|
488
|
-
* Having the hide flag
|
|
489
|
-
*/
|
|
490
|
-
flagHide?: boolean;
|
|
491
|
-
/**
|
|
492
|
-
* Having the fade flag
|
|
493
|
-
*/
|
|
494
|
-
flagFade?: boolean;
|
|
495
|
-
}
|
|
496
|
-
type ResolvedClicksInfo = Required<ClicksInfo>;
|
|
497
|
-
type ClicksMap = Map<ClicksElement, ClicksInfo>;
|
|
498
|
-
interface ClicksContext {
|
|
499
|
-
current: number;
|
|
500
|
-
readonly clicksStart: number;
|
|
501
|
-
readonly relativeOffsets: ClicksRelativeEls;
|
|
502
|
-
readonly map: ClicksMap;
|
|
503
|
-
resolve: (at: string | number, size?: number) => {
|
|
504
|
-
start: number;
|
|
505
|
-
end: number;
|
|
506
|
-
delta: number;
|
|
507
|
-
};
|
|
508
|
-
register: (el: ClicksElement, info: ClicksInfo) => void;
|
|
509
|
-
unregister: (el: ClicksElement) => void;
|
|
510
|
-
onMounted: () => void;
|
|
511
|
-
readonly currentOffset: number;
|
|
512
|
-
readonly total: number;
|
|
513
|
-
}
|
|
514
474
|
|
|
515
475
|
interface CodeRunnerContext {
|
|
516
476
|
/**
|
|
@@ -570,6 +530,20 @@ type CodeRunnerOutputs = Arrayable<CodeRunnerOutput>;
|
|
|
570
530
|
type CodeRunner = (code: string, ctx: CodeRunnerContext) => Awaitable<CodeRunnerOutputs>;
|
|
571
531
|
type CodeRunnerProviders = Record<string, CodeRunner>;
|
|
572
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
|
+
|
|
573
547
|
interface AppContext {
|
|
574
548
|
app: App;
|
|
575
549
|
router: Router;
|
|
@@ -606,10 +580,10 @@ interface ShikiContext {
|
|
|
606
580
|
*/
|
|
607
581
|
loadTheme: (path: string) => Promise<any>;
|
|
608
582
|
}
|
|
609
|
-
type ShikiSetupReturn = Partial<Omit<CodeToHastOptionsCommon<BuiltinLanguage>, 'lang'
|
|
610
|
-
setup
|
|
611
|
-
langs
|
|
612
|
-
}
|
|
583
|
+
type ShikiSetupReturn = Partial<Omit<CodeToHastOptionsCommon<BuiltinLanguage>, 'lang'> & CodeOptionsThemes<BuiltinTheme> & CodeOptionsMeta & {
|
|
584
|
+
setup: (highlighter: Highlighter) => Awaitable<void>;
|
|
585
|
+
langs: (LanguageInput | BuiltinLanguage)[];
|
|
586
|
+
}>;
|
|
613
587
|
type ShikiSetup = (shiki: ShikiContext) => Awaitable<ShikiSetupReturn | void>;
|
|
614
588
|
type KatexSetup = () => Awaitable<Partial<KatexOptions> | void>;
|
|
615
589
|
type UnoSetup = () => Awaitable<Partial<VitePluginConfig> | void>;
|
|
@@ -620,15 +594,17 @@ type RootSetup = () => Awaitable<void>;
|
|
|
620
594
|
type MermaidSetup = () => Partial<MermaidOptions> | void;
|
|
621
595
|
type ShortcutsSetup = (nav: NavOperations, defaultShortcuts: ShortcutOptions[]) => Array<ShortcutOptions>;
|
|
622
596
|
type CodeRunnersSetup = (runners: CodeRunnerProviders) => Awaitable<CodeRunnerProviders | void>;
|
|
623
|
-
|
|
624
|
-
declare
|
|
625
|
-
declare
|
|
626
|
-
declare
|
|
627
|
-
declare
|
|
628
|
-
declare
|
|
629
|
-
declare
|
|
630
|
-
declare
|
|
631
|
-
declare
|
|
597
|
+
type ContextMenuSetup = (items: ComputedRef<ContextMenuItem[]>) => ComputedRef<ContextMenuItem[]>;
|
|
598
|
+
declare const defineShikiSetup: (fn: ShikiSetup) => ShikiSetup;
|
|
599
|
+
declare const defineUnoSetup: (fn: UnoSetup) => UnoSetup;
|
|
600
|
+
declare const defineMonacoSetup: (fn: MonacoSetup) => MonacoSetup;
|
|
601
|
+
declare const defineAppSetup: (fn: AppSetup) => AppSetup;
|
|
602
|
+
declare const defineMermaidSetup: (fn: MermaidSetup) => MermaidSetup;
|
|
603
|
+
declare const defineKatexSetup: (fn: KatexSetup) => KatexSetup;
|
|
604
|
+
declare const defineShortcutsSetup: (fn: ShortcutsSetup) => ShortcutsSetup;
|
|
605
|
+
declare const definePreparserSetup: (fn: PreparserSetup) => PreparserSetup;
|
|
606
|
+
declare const defineCodeRunnersSetup: (fn: CodeRunnersSetup) => CodeRunnersSetup;
|
|
607
|
+
declare const defineContextMenuSetup: (fn: ContextMenuSetup) => ContextMenuSetup;
|
|
632
608
|
|
|
633
609
|
interface TocItem {
|
|
634
610
|
no: number;
|
|
@@ -730,4 +706,50 @@ interface MarkdownTransformContext {
|
|
|
730
706
|
isIgnored: (index: number) => boolean;
|
|
731
707
|
}
|
|
732
708
|
|
|
733
|
-
|
|
709
|
+
type RawAtValue = undefined | boolean | string | number | [string | number, string | number];
|
|
710
|
+
type NormalizedSinceClickValue = number | string;
|
|
711
|
+
type NormalizedRangeClickValue = [number, number] | [number, string] | [string, number] | [string, string];
|
|
712
|
+
type NormalizedAtValue = NormalizedSinceClickValue | NormalizedRangeClickValue | null;
|
|
713
|
+
type ClicksElement = Element | string;
|
|
714
|
+
interface ClicksInfo {
|
|
715
|
+
/**
|
|
716
|
+
* The absolute start click num
|
|
717
|
+
*/
|
|
718
|
+
start: number;
|
|
719
|
+
/**
|
|
720
|
+
* The absolute end click num
|
|
721
|
+
*/
|
|
722
|
+
end: number;
|
|
723
|
+
/**
|
|
724
|
+
* The required total click num
|
|
725
|
+
*/
|
|
726
|
+
max: number;
|
|
727
|
+
/**
|
|
728
|
+
* The delta for relative clicks
|
|
729
|
+
*/
|
|
730
|
+
delta: number;
|
|
731
|
+
/**
|
|
732
|
+
* Computed ref of whether the click is exactly matched
|
|
733
|
+
*/
|
|
734
|
+
isCurrent: ComputedRef<boolean>;
|
|
735
|
+
/**
|
|
736
|
+
* Computed ref of whether the click is active
|
|
737
|
+
*/
|
|
738
|
+
isActive: ComputedRef<boolean>;
|
|
739
|
+
}
|
|
740
|
+
interface ClicksContext {
|
|
741
|
+
current: number;
|
|
742
|
+
readonly clicksStart: number;
|
|
743
|
+
readonly relativeOffsets: Map<ClicksElement, number>;
|
|
744
|
+
readonly maxMap: Map<ClicksElement, number>;
|
|
745
|
+
calculateSince: (at: NormalizedSinceClickValue, size?: number) => ClicksInfo;
|
|
746
|
+
calculateRange: (at: NormalizedRangeClickValue) => ClicksInfo;
|
|
747
|
+
calculate: (at: NormalizedAtValue) => ClicksInfo | null;
|
|
748
|
+
register: (el: ClicksElement, info: Pick<ClicksInfo, 'delta' | 'max'>) => void;
|
|
749
|
+
unregister: (el: ClicksElement) => void;
|
|
750
|
+
onMounted: () => void;
|
|
751
|
+
readonly currentOffset: number;
|
|
752
|
+
readonly total: number;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
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 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, defineShikiSetup, defineShortcutsSetup, defineUnoSetup };
|
package/dist/index.mjs
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
// src/setups.ts
|
|
2
|
-
function
|
|
3
|
-
return fn;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return fn;
|
|
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 defineMermaidSetup = defineSetup;
|
|
10
|
+
var defineKatexSetup = defineSetup;
|
|
11
|
+
var defineShortcutsSetup = defineSetup;
|
|
12
|
+
var definePreparserSetup = defineSetup;
|
|
13
|
+
var defineCodeRunnersSetup = defineSetup;
|
|
14
|
+
var defineContextMenuSetup = defineSetup;
|
|
29
15
|
export {
|
|
30
16
|
defineAppSetup,
|
|
31
17
|
defineCodeRunnersSetup,
|
|
18
|
+
defineContextMenuSetup,
|
|
32
19
|
defineKatexSetup,
|
|
33
20
|
defineMermaidSetup,
|
|
34
21
|
defineMonacoSetup,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0-beta.2",
|
|
4
4
|
"description": "Shared types declarations for Slidev",
|
|
5
5
|
"author": "antfu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"katex": "^0.16.10",
|
|
30
30
|
"mermaid": "^10.9.0",
|
|
31
31
|
"monaco-editor": "^0.47.0",
|
|
32
|
-
"shiki": "^1.
|
|
33
|
-
"unocss": "^0.
|
|
32
|
+
"shiki": "^1.3.0",
|
|
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",
|