@slidev/types 0.48.0-beta.22 → 0.48.0-beta.24

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,7 +1,7 @@
1
1
  import { ComputedRef } from '@vue/reactivity';
2
2
  import { RouteMeta, RouteComponent, Router } from 'vue-router';
3
3
  import { TransitionGroupProps, App, Ref } from 'vue';
4
- import { Awaitable } from '@antfu/utils';
4
+ import { Arrayable, Awaitable } from '@antfu/utils';
5
5
  import * as monaco from 'monaco-editor';
6
6
  import mermaid from 'mermaid';
7
7
  import { KatexOptions } from 'katex';
@@ -64,7 +64,7 @@ interface SlidevConfig {
64
64
  * Enable Monaco
65
65
  *
66
66
  * @see https://sli.dev/custom/config-monaco.html
67
- * @default 'dev'
67
+ * @default true
68
68
  */
69
69
  monaco: boolean | 'dev' | 'build';
70
70
  /**
@@ -493,10 +493,56 @@ interface ClicksContext {
493
493
  };
494
494
  register: (el: ClicksElement, info: ClicksInfo) => void;
495
495
  unregister: (el: ClicksElement) => void;
496
+ onMounted: () => void;
496
497
  readonly currentOffset: number;
497
498
  readonly total: number;
498
499
  }
499
500
 
501
+ interface CodeRunnerContext {
502
+ options: Record<string, unknown>;
503
+ highlight: (code: string, lang: string, options?: Partial<CodeToHastOptions>) => Promise<string>;
504
+ run: (code: string, lang: string) => Promise<CodeRunnerOutputs>;
505
+ }
506
+ interface CodeRunnerOutputHtml {
507
+ /**
508
+ * The HTML to be rendered.
509
+ *
510
+ * Slidev does NOT sanitize the HTML for you - make sure it's from trusted sources or sanitize it before passing it in
511
+ */
512
+ html: string;
513
+ }
514
+ interface CodeRunnerOutputDom {
515
+ /**
516
+ * The DOM element to be rendered.
517
+ */
518
+ element: HTMLElement;
519
+ }
520
+ interface CodeRunnerOutputError {
521
+ /**
522
+ * The error message to be displayed.
523
+ */
524
+ error: string;
525
+ }
526
+ interface CodeRunnerOutputText {
527
+ /**
528
+ * The text to be displayed.
529
+ */
530
+ text: string;
531
+ /**
532
+ * The class to be applied to the text.
533
+ */
534
+ class?: string;
535
+ /**
536
+ * The language to be highlighted.
537
+ */
538
+ highlightLang?: string;
539
+ }
540
+ type CodeRunnerOutputTextArray = CodeRunnerOutputText[];
541
+ type CodeRunnerOutput = CodeRunnerOutputHtml | CodeRunnerOutputError | CodeRunnerOutputText | CodeRunnerOutputTextArray | CodeRunnerOutputDom;
542
+ type CodeRunnerOutputs = Arrayable<CodeRunnerOutput>;
543
+ type CodeRunner = (code: string, ctx: CodeRunnerContext) => Awaitable<CodeRunnerOutputs>;
544
+ type CodeRunnerProviders = Record<string, CodeRunner>;
545
+
500
546
  interface AppContext {
501
547
  app: App;
502
548
  router: Router;
@@ -544,6 +590,7 @@ type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn | void>;
544
590
  type AppSetup = (context: AppContext) => Awaitable<void>;
545
591
  type MermaidSetup = () => Partial<MermaidOptions> | void;
546
592
  type ShortcutsSetup = (nav: NavOperations, defaultShortcuts: ShortcutOptions[]) => Array<ShortcutOptions>;
593
+ type CodeRunnersSetup = (runners: CodeRunnerProviders) => Awaitable<CodeRunnerProviders | void>;
547
594
  declare function defineShikiSetup(fn: ShikiSetup): ShikiSetup;
548
595
  declare function defineUnoSetup(fn: UnoSetup): UnoSetup;
549
596
  declare function defineMonacoSetup(fn: MonacoSetup): MonacoSetup;
@@ -552,6 +599,7 @@ declare function defineMermaidSetup(fn: MermaidSetup): MermaidSetup;
552
599
  declare function defineKatexSetup(fn: KatexSetup): KatexSetup;
553
600
  declare function defineShortcutsSetup(fn: ShortcutsSetup): ShortcutsSetup;
554
601
  declare function definePreparserSetup(fn: PreparserSetup): PreparserSetup;
602
+ declare function defineCodeRunnersSetup(fn: CodeRunnersSetup): CodeRunnersSetup;
555
603
 
556
604
  interface TocItem {
557
605
  no: number;
@@ -568,15 +616,15 @@ interface TocItem {
568
616
  declare module 'vite' {
569
617
  interface CustomEventMap {
570
618
  'slidev:update-slide': {
571
- id: number;
619
+ no: number;
572
620
  data: SlideInfo;
573
621
  };
574
622
  'slidev:update-note': {
575
- id: number;
623
+ no: number;
576
624
  note: string;
577
625
  noteHTML: string;
578
626
  };
579
627
  }
580
628
  }
581
629
 
582
- 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 SlideRoute, 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 };
630
+ export { type AppContext, type AppSetup, type BuildArgs, type BuiltinSlideTransition, type ClicksContext, type ClicksElement, type ClicksInfo, type ClicksMap, type ClicksRelativeEls, 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 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 SlideRoute, type SlidevConfig, type SlidevData, type SlidevFeatureFlags, type SlidevMarkdown, type SlidevPreparserExtension, type SlidevThemeConfig, type SlidevThemeMeta, type SourceSlideInfo, type TocItem, type UnoSetup, defineAppSetup, defineCodeRunnersSetup, defineKatexSetup, defineMermaidSetup, defineMonacoSetup, definePreparserSetup, defineShikiSetup, defineShortcutsSetup, defineUnoSetup };
package/dist/index.mjs CHANGED
@@ -23,8 +23,12 @@ function defineShortcutsSetup(fn) {
23
23
  function definePreparserSetup(fn) {
24
24
  return fn;
25
25
  }
26
+ function defineCodeRunnersSetup(fn) {
27
+ return fn;
28
+ }
26
29
  export {
27
30
  defineAppSetup,
31
+ defineCodeRunnersSetup,
28
32
  defineKatexSetup,
29
33
  defineMermaidSetup,
30
34
  defineMonacoSetup,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidev/types",
3
- "version": "0.48.0-beta.22",
3
+ "version": "0.48.0-beta.24",
4
4
  "description": "Shared types declarations for Slidev",
5
5
  "author": "antfu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",