@incremark/vue 0.2.2 → 0.2.4
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/ThemeProvider.vue.d.ts +25 -0
- package/dist/components/AutoScrollContainer.vue.d.ts +31 -0
- package/dist/components/Incremark.vue.d.ts +36 -0
- package/dist/components/IncremarkBlockquote.vue.d.ts +6 -0
- package/dist/components/IncremarkCode.vue.d.ts +23 -0
- package/dist/components/IncremarkContainer.vue.d.ts +18 -0
- package/dist/components/IncremarkDefault.vue.d.ts +6 -0
- package/dist/components/IncremarkFootnotes.vue.d.ts +2 -0
- package/dist/components/IncremarkHeading.vue.d.ts +6 -0
- package/dist/components/IncremarkHtmlElement.vue.d.ts +20 -0
- package/dist/components/IncremarkInline.vue.d.ts +6 -0
- package/dist/components/IncremarkList.vue.d.ts +6 -0
- package/dist/components/IncremarkMath.vue.d.ts +17 -0
- package/dist/components/IncremarkParagraph.vue.d.ts +6 -0
- package/dist/components/IncremarkRenderer.vue.d.ts +12 -0
- package/dist/components/IncremarkTable.vue.d.ts +6 -0
- package/dist/components/IncremarkThematicBreak.vue.d.ts +2 -0
- package/{src/components/index.ts → dist/components/index.d.ts} +16 -23
- package/dist/composables/index.d.ts +8 -0
- package/dist/composables/useBlockTransformer.d.ts +68 -0
- package/dist/composables/useDefinationsContext.d.ts +9 -0
- package/dist/composables/useDevTools.d.ts +18 -0
- package/dist/composables/useIncremark.d.ts +112 -0
- package/dist/composables/useProvideDefinations.d.ts +16 -0
- package/dist/composables/useStreamRenderer.d.ts +26 -0
- package/dist/composables/useTypewriter.d.ts +37 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +428 -222
- package/dist/index.js.map +1 -1
- package/dist/utils/cursor.d.ts +18 -0
- package/package.json +11 -13
- package/dist/index.css +0 -6
- package/dist/index.css.map +0 -1
- package/src/ThemeProvider.vue +0 -41
- package/src/components/AutoScrollContainer.vue +0 -164
- package/src/components/Incremark.vue +0 -131
- package/src/components/IncremarkBlockquote.vue +0 -18
- package/src/components/IncremarkCode.vue +0 -236
- package/src/components/IncremarkDefault.vue +0 -15
- package/src/components/IncremarkFootnotes.vue +0 -78
- package/src/components/IncremarkHeading.vue +0 -17
- package/src/components/IncremarkHtmlElement.vue +0 -127
- package/src/components/IncremarkInline.vue +0 -187
- package/src/components/IncremarkList.vue +0 -46
- package/src/components/IncremarkMath.vue +0 -105
- package/src/components/IncremarkParagraph.vue +0 -14
- package/src/components/IncremarkRenderer.vue +0 -50
- package/src/components/IncremarkTable.vue +0 -42
- package/src/components/IncremarkThematicBreak.vue +0 -8
- package/src/composables/index.ts +0 -11
- package/src/composables/useBlockTransformer.ts +0 -141
- package/src/composables/useDefinationsContext.ts +0 -16
- package/src/composables/useDevTools.ts +0 -54
- package/src/composables/useIncremark.ts +0 -238
- package/src/composables/useProvideDefinations.ts +0 -61
- package/src/composables/useStreamRenderer.ts +0 -55
- package/src/composables/useTypewriter.ts +0 -205
- package/src/index.ts +0 -78
- package/src/utils/cursor.ts +0 -46
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DesignTokens } from '@incremark/theme';
|
|
2
|
+
/**
|
|
3
|
+
* 主题配置,可以是:
|
|
4
|
+
* - 字符串:'default' | 'dark'
|
|
5
|
+
* - 完整主题对象:DesignTokens
|
|
6
|
+
* - 部分主题对象:Partial<DesignTokens>(会合并到默认主题)
|
|
7
|
+
*/
|
|
8
|
+
type __VLS_Props = {
|
|
9
|
+
theme: 'default' | 'dark' | DesignTokens | Partial<DesignTokens>;
|
|
10
|
+
class?: string;
|
|
11
|
+
};
|
|
12
|
+
declare var __VLS_1: {};
|
|
13
|
+
type __VLS_Slots = {} & {
|
|
14
|
+
default?: (props: typeof __VLS_1) => any;
|
|
15
|
+
};
|
|
16
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
17
|
+
class: string;
|
|
18
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
20
|
+
export default _default;
|
|
21
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
22
|
+
new (): {
|
|
23
|
+
$slots: S;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** 是否启用自动滚动 */
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
/** 触发自动滚动的底部阈值(像素) */
|
|
5
|
+
threshold?: number;
|
|
6
|
+
/** 滚动行为 */
|
|
7
|
+
behavior?: ScrollBehavior;
|
|
8
|
+
};
|
|
9
|
+
declare var __VLS_1: {};
|
|
10
|
+
type __VLS_Slots = {} & {
|
|
11
|
+
default?: (props: typeof __VLS_1) => any;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
|
|
14
|
+
/** 强制滚动到底部 */
|
|
15
|
+
scrollToBottom: () => void;
|
|
16
|
+
/** 是否用户手动向上滚动了 */
|
|
17
|
+
isUserScrolledUp: () => boolean;
|
|
18
|
+
/** 容器元素引用 */
|
|
19
|
+
container: import("vue").Ref<HTMLDivElement | null, HTMLDivElement | null>;
|
|
20
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
threshold: number;
|
|
23
|
+
behavior: ScrollBehavior;
|
|
24
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
26
|
+
export default _default;
|
|
27
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Component } from 'vue';
|
|
2
|
+
import type { ParsedBlock } from '@incremark/core';
|
|
3
|
+
import type { UseIncremarkReturn } from '../composables/useIncremark';
|
|
4
|
+
export type ComponentMap = Partial<Record<string, Component>>;
|
|
5
|
+
export interface BlockWithStableId extends ParsedBlock {
|
|
6
|
+
stableId: string;
|
|
7
|
+
isLastPending?: boolean;
|
|
8
|
+
}
|
|
9
|
+
type __VLS_Props = {
|
|
10
|
+
/** 要渲染的块列表(来自 useIncremark 的 blocks) */
|
|
11
|
+
blocks?: BlockWithStableId[];
|
|
12
|
+
/** 自定义组件映射,key 为节点类型 */
|
|
13
|
+
components?: ComponentMap;
|
|
14
|
+
/** 自定义容器组件映射,key 为容器名称(如 'warning', 'info') */
|
|
15
|
+
customContainers?: Record<string, Component>;
|
|
16
|
+
/** 自定义代码块组件映射,key 为代码语言名称(如 'echart', 'mermaid') */
|
|
17
|
+
customCodeBlocks?: Record<string, Component>;
|
|
18
|
+
/** 待处理块的样式类名 */
|
|
19
|
+
pendingClass?: string;
|
|
20
|
+
/** 已完成块的样式类名 */
|
|
21
|
+
completedClass?: string;
|
|
22
|
+
/** 是否显示块状态边框 */
|
|
23
|
+
showBlockStatus?: boolean;
|
|
24
|
+
/** 可选:useIncremark 返回的对象(用于自动注入数据) */
|
|
25
|
+
incremark?: UseIncremarkReturn;
|
|
26
|
+
};
|
|
27
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
28
|
+
blocks: BlockWithStableId[];
|
|
29
|
+
customCodeBlocks: Record<string, Component>;
|
|
30
|
+
customContainers: Record<string, Component>;
|
|
31
|
+
components: Partial<Record<string, Component>>;
|
|
32
|
+
pendingClass: string;
|
|
33
|
+
completedClass: string;
|
|
34
|
+
showBlockStatus: boolean;
|
|
35
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
36
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Blockquote } from 'mdast';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
node: Blockquote;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Code } from 'mdast';
|
|
2
|
+
import type { Component } from 'vue';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
node: Code;
|
|
5
|
+
/** Shiki 主题,默认 github-dark */
|
|
6
|
+
theme?: string;
|
|
7
|
+
/** 是否禁用代码高亮 */
|
|
8
|
+
disableHighlight?: boolean;
|
|
9
|
+
/** Mermaid 渲染延迟(毫秒),用于流式输入时防抖 */
|
|
10
|
+
mermaidDelay?: number;
|
|
11
|
+
/** 自定义代码块组件映射,key 为代码语言名称 */
|
|
12
|
+
customCodeBlocks?: Record<string, Component>;
|
|
13
|
+
/** 块状态,用于判断是否使用自定义组件 */
|
|
14
|
+
blockStatus?: 'pending' | 'stable' | 'completed';
|
|
15
|
+
};
|
|
16
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
17
|
+
theme: string;
|
|
18
|
+
disableHighlight: boolean;
|
|
19
|
+
mermaidDelay: number;
|
|
20
|
+
customCodeBlocks: Record<string, Component>;
|
|
21
|
+
blockStatus: "pending" | "stable" | "completed";
|
|
22
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RootContent } from 'mdast';
|
|
2
|
+
import type { Component } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* 容器节点类型定义
|
|
5
|
+
* 根据 directive 解析后的结构
|
|
6
|
+
*/
|
|
7
|
+
export interface ContainerNode {
|
|
8
|
+
type: 'containerDirective' | 'leafDirective' | 'textDirective';
|
|
9
|
+
name: string;
|
|
10
|
+
attributes?: Record<string, string>;
|
|
11
|
+
children?: RootContent[];
|
|
12
|
+
}
|
|
13
|
+
type __VLS_Props = {
|
|
14
|
+
node: ContainerNode;
|
|
15
|
+
customContainers?: Record<string, Component>;
|
|
16
|
+
};
|
|
17
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RootContent } from 'mdast';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
node: RootContent;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Heading } from 'mdast';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
node: Heading;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RootContent } from 'mdast';
|
|
2
|
+
/**
|
|
3
|
+
* HtmlElementNode 类型定义(与 @incremark/core 中的定义一致)
|
|
4
|
+
*/
|
|
5
|
+
interface HtmlElementNode {
|
|
6
|
+
type: 'htmlElement';
|
|
7
|
+
tagName: string;
|
|
8
|
+
attrs: Record<string, string>;
|
|
9
|
+
children: RootContent[];
|
|
10
|
+
data?: {
|
|
11
|
+
rawHtml?: string;
|
|
12
|
+
parsed?: boolean;
|
|
13
|
+
originalType?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
type __VLS_Props = {
|
|
17
|
+
node: HtmlElementNode;
|
|
18
|
+
};
|
|
19
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PhrasingContent } from 'mdast';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
nodes: PhrasingContent[];
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { List } from 'mdast';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
node: List;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface MathNode {
|
|
2
|
+
type: 'math' | 'inlineMath';
|
|
3
|
+
value: string;
|
|
4
|
+
data?: {
|
|
5
|
+
hName?: string;
|
|
6
|
+
hProperties?: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
type __VLS_Props = {
|
|
10
|
+
node: MathNode;
|
|
11
|
+
/** 渲染延迟(毫秒),用于流式输入时防抖 */
|
|
12
|
+
renderDelay?: number;
|
|
13
|
+
};
|
|
14
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
15
|
+
renderDelay: number;
|
|
16
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Paragraph } from 'mdast';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
node: Paragraph;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RootContent } from 'mdast';
|
|
2
|
+
import type { Component } from 'vue';
|
|
3
|
+
import type { ContainerNode } from './IncremarkContainer.vue';
|
|
4
|
+
type ExtendedRootContent = RootContent | ContainerNode;
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
node: ExtendedRootContent;
|
|
7
|
+
customContainers?: Record<string, Component>;
|
|
8
|
+
customCodeBlocks?: Record<string, Component>;
|
|
9
|
+
blockStatus?: 'pending' | 'stable' | 'completed';
|
|
10
|
+
};
|
|
11
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Table } from 'mdast';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
node: Table;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export default _default;
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { default as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export { default as
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as
|
|
12
|
-
export { default as
|
|
13
|
-
export { default as
|
|
14
|
-
export { default as
|
|
15
|
-
export { default as
|
|
16
|
-
export { default as
|
|
17
|
-
export { default as IncremarkMath } from './IncremarkMath.vue'
|
|
18
|
-
export { default as IncremarkHtmlElement } from './IncremarkHtmlElement.vue'
|
|
19
|
-
export { default as IncremarkDefault } from './IncremarkDefault.vue'
|
|
20
|
-
export { default as IncremarkFootnotes } from './IncremarkFootnotes.vue'
|
|
21
|
-
|
|
22
|
-
// 工具组件
|
|
23
|
-
export { default as AutoScrollContainer } from './AutoScrollContainer.vue'
|
|
1
|
+
export { default as Incremark } from './Incremark.vue';
|
|
2
|
+
export type { ComponentMap, BlockWithStableId } from './Incremark.vue';
|
|
3
|
+
export { default as IncremarkRenderer } from './IncremarkRenderer.vue';
|
|
4
|
+
export { default as IncremarkHeading } from './IncremarkHeading.vue';
|
|
5
|
+
export { default as IncremarkParagraph } from './IncremarkParagraph.vue';
|
|
6
|
+
export { default as IncremarkCode } from './IncremarkCode.vue';
|
|
7
|
+
export { default as IncremarkList } from './IncremarkList.vue';
|
|
8
|
+
export { default as IncremarkTable } from './IncremarkTable.vue';
|
|
9
|
+
export { default as IncremarkBlockquote } from './IncremarkBlockquote.vue';
|
|
10
|
+
export { default as IncremarkThematicBreak } from './IncremarkThematicBreak.vue';
|
|
11
|
+
export { default as IncremarkInline } from './IncremarkInline.vue';
|
|
12
|
+
export { default as IncremarkMath } from './IncremarkMath.vue';
|
|
13
|
+
export { default as IncremarkHtmlElement } from './IncremarkHtmlElement.vue';
|
|
14
|
+
export { default as IncremarkDefault } from './IncremarkDefault.vue';
|
|
15
|
+
export { default as IncremarkFootnotes } from './IncremarkFootnotes.vue';
|
|
16
|
+
export { default as AutoScrollContainer } from './AutoScrollContainer.vue';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { useIncremark } from './useIncremark';
|
|
2
|
+
export type { UseIncremarkOptions, TypewriterOptions, TypewriterControls } from './useIncremark';
|
|
3
|
+
export { useStreamRenderer } from './useStreamRenderer';
|
|
4
|
+
export type { UseStreamRendererOptions } from './useStreamRenderer';
|
|
5
|
+
export { useDevTools } from './useDevTools';
|
|
6
|
+
export type { UseDevToolsOptions } from './useDevTools';
|
|
7
|
+
export { useBlockTransformer } from './useBlockTransformer';
|
|
8
|
+
export type { UseBlockTransformerOptions, UseBlockTransformerReturn } from './useBlockTransformer';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type Ref, type ComputedRef } from 'vue';
|
|
2
|
+
import { BlockTransformer, type TransformerOptions, type DisplayBlock, type SourceBlock, type AnimationEffect } from '@incremark/core';
|
|
3
|
+
export interface UseBlockTransformerOptions extends Omit<TransformerOptions, 'onChange'> {
|
|
4
|
+
}
|
|
5
|
+
export interface UseBlockTransformerReturn<T = unknown> {
|
|
6
|
+
/** 用于渲染的 display blocks */
|
|
7
|
+
displayBlocks: ComputedRef<DisplayBlock<T>[]>;
|
|
8
|
+
/** 是否正在处理中 */
|
|
9
|
+
isProcessing: ComputedRef<boolean>;
|
|
10
|
+
/** 是否已暂停 */
|
|
11
|
+
isPaused: ComputedRef<boolean>;
|
|
12
|
+
/** 当前动画效果 */
|
|
13
|
+
effect: ComputedRef<AnimationEffect>;
|
|
14
|
+
/** 跳过所有动画 */
|
|
15
|
+
skip: () => void;
|
|
16
|
+
/** 重置状态 */
|
|
17
|
+
reset: () => void;
|
|
18
|
+
/** 暂停动画 */
|
|
19
|
+
pause: () => void;
|
|
20
|
+
/** 恢复动画 */
|
|
21
|
+
resume: () => void;
|
|
22
|
+
/** 动态更新配置 */
|
|
23
|
+
setOptions: (options: Partial<Pick<TransformerOptions, 'charsPerTick' | 'tickInterval' | 'effect' | 'pauseOnHidden'>>) => void;
|
|
24
|
+
/** transformer 实例(用于高级用法) */
|
|
25
|
+
transformer: BlockTransformer<T>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Vue 3 Composable: Block Transformer
|
|
29
|
+
*
|
|
30
|
+
* 用于控制 blocks 的逐步显示(打字机效果)
|
|
31
|
+
* 作为解析器和渲染器之间的中间层
|
|
32
|
+
*
|
|
33
|
+
* 特性:
|
|
34
|
+
* - 使用 requestAnimationFrame 实现流畅动画
|
|
35
|
+
* - 支持随机步长 `charsPerTick: [1, 3]`
|
|
36
|
+
* - 支持动画效果 `effect: 'typing'`
|
|
37
|
+
* - 页面不可见时自动暂停
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```vue
|
|
41
|
+
* <script setup>
|
|
42
|
+
* import { useIncremark, useBlockTransformer, defaultPlugins } from '@incremark/vue'
|
|
43
|
+
*
|
|
44
|
+
* const { blocks, completedBlocks, append, finalize } = useIncremark()
|
|
45
|
+
*
|
|
46
|
+
* // 使用 completedBlocks 作为输入(ID 稳定)
|
|
47
|
+
* const sourceBlocks = computed(() => completedBlocks.value.map(b => ({
|
|
48
|
+
* id: b.id,
|
|
49
|
+
* node: b.node,
|
|
50
|
+
* status: b.status
|
|
51
|
+
* })))
|
|
52
|
+
*
|
|
53
|
+
* // 添加打字机效果
|
|
54
|
+
* const { displayBlocks, isProcessing, skip, effect } = useBlockTransformer(sourceBlocks, {
|
|
55
|
+
* charsPerTick: [1, 3], // 随机步长
|
|
56
|
+
* tickInterval: 30,
|
|
57
|
+
* effect: 'typing', // 光标效果
|
|
58
|
+
* plugins: defaultPlugins
|
|
59
|
+
* })
|
|
60
|
+
* </script>
|
|
61
|
+
*
|
|
62
|
+
* <template>
|
|
63
|
+
* <Incremark :blocks="displayBlocks" :class="{ 'typing': effect === 'typing' }" />
|
|
64
|
+
* <button v-if="isProcessing" @click="skip">跳过</button>
|
|
65
|
+
* </template>
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function useBlockTransformer<T = unknown>(sourceBlocks: Ref<SourceBlock<T>[]> | ComputedRef<SourceBlock<T>[]>, options?: UseBlockTransformerOptions): UseBlockTransformerReturn<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* support definations and footnoteDefinitions
|
|
3
|
+
* @returns
|
|
4
|
+
*/
|
|
5
|
+
export declare function useDefinationsContext(): {
|
|
6
|
+
definations: import("vue").Ref<Record<string, import("mdast").Definition>>;
|
|
7
|
+
footnoteDefinitions: import("vue").Ref<Record<string, import("mdast").FootnoteDefinition>>;
|
|
8
|
+
footnoteReferenceOrder: import("vue").Ref<string[]>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type DevToolsOptions } from '@incremark/devtools';
|
|
2
|
+
import type { UseIncremarkReturn } from './useIncremark';
|
|
3
|
+
export interface UseDevToolsOptions extends DevToolsOptions {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Vue 3 DevTools 一行接入
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```vue
|
|
10
|
+
* <script setup>
|
|
11
|
+
* import { useIncremark, useDevTools } from '@incremark/vue'
|
|
12
|
+
*
|
|
13
|
+
* const incremark = useIncremark()
|
|
14
|
+
* useDevTools(incremark) // 就这一行!
|
|
15
|
+
* </script>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function useDevTools(incremark: UseIncremarkReturn, options?: UseDevToolsOptions): import("@incremark/devtools").IncremarkDevTools;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type ComputedRef } from 'vue';
|
|
2
|
+
import { type ParserOptions, type ParsedBlock, type IncrementalUpdate, type Root, type TransformerPlugin, type AnimationEffect } from '@incremark/core';
|
|
3
|
+
/** 打字机效果配置 */
|
|
4
|
+
export interface TypewriterOptions {
|
|
5
|
+
/** 是否启用打字机效果(可响应式切换) */
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
/** 每次显示的字符数,可以是固定值或范围 [min, max] */
|
|
8
|
+
charsPerTick?: number | [number, number];
|
|
9
|
+
/** 更新间隔 (ms) */
|
|
10
|
+
tickInterval?: number;
|
|
11
|
+
/** 动画效果: 'none' | 'fade-in' | 'typing' */
|
|
12
|
+
effect?: AnimationEffect;
|
|
13
|
+
/** 光标字符(仅 typing 效果使用) */
|
|
14
|
+
cursor?: string;
|
|
15
|
+
/** 页面不可见时暂停 */
|
|
16
|
+
pauseOnHidden?: boolean;
|
|
17
|
+
/** 自定义插件 */
|
|
18
|
+
plugins?: TransformerPlugin[];
|
|
19
|
+
}
|
|
20
|
+
export interface UseIncremarkOptions extends ParserOptions {
|
|
21
|
+
/** 打字机配置,传入即创建 transformer(可通过 enabled 控制是否启用) */
|
|
22
|
+
typewriter?: TypewriterOptions;
|
|
23
|
+
}
|
|
24
|
+
/** 打字机控制对象 */
|
|
25
|
+
export interface TypewriterControls {
|
|
26
|
+
/** 是否启用(只读) */
|
|
27
|
+
enabled: ComputedRef<boolean>;
|
|
28
|
+
/** 设置是否启用 */
|
|
29
|
+
setEnabled: (enabled: boolean) => void;
|
|
30
|
+
/** 是否正在处理中 */
|
|
31
|
+
isProcessing: ComputedRef<boolean>;
|
|
32
|
+
/** 是否已暂停 */
|
|
33
|
+
isPaused: ComputedRef<boolean>;
|
|
34
|
+
/** 当前动画效果 */
|
|
35
|
+
effect: ComputedRef<AnimationEffect>;
|
|
36
|
+
/** 跳过动画,直接显示全部 */
|
|
37
|
+
skip: () => void;
|
|
38
|
+
/** 暂停动画 */
|
|
39
|
+
pause: () => void;
|
|
40
|
+
/** 恢复动画 */
|
|
41
|
+
resume: () => void;
|
|
42
|
+
/** 动态更新配置 */
|
|
43
|
+
setOptions: (options: Partial<TypewriterOptions>) => void;
|
|
44
|
+
}
|
|
45
|
+
/** useIncremark 的返回类型 */
|
|
46
|
+
export type UseIncremarkReturn = ReturnType<typeof useIncremark>;
|
|
47
|
+
/**
|
|
48
|
+
* Vue 3 Composable: Incremark 流式 Markdown 解析器
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```vue
|
|
52
|
+
* <script setup>
|
|
53
|
+
* import { useIncremark, Incremark } from '@incremark/vue'
|
|
54
|
+
*
|
|
55
|
+
* // 基础用法
|
|
56
|
+
* const { blocks, append, finalize } = useIncremark()
|
|
57
|
+
*
|
|
58
|
+
* // 启用打字机效果
|
|
59
|
+
* const { blocks, append, finalize, typewriter } = useIncremark({
|
|
60
|
+
* typewriter: {
|
|
61
|
+
* enabled: true, // 可响应式切换
|
|
62
|
+
* charsPerTick: [1, 3],
|
|
63
|
+
* tickInterval: 30,
|
|
64
|
+
* effect: 'typing',
|
|
65
|
+
* cursor: '|'
|
|
66
|
+
* }
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* // 动态切换打字机效果
|
|
70
|
+
* typewriter.enabled.value = false
|
|
71
|
+
* </script>
|
|
72
|
+
*
|
|
73
|
+
* <template>
|
|
74
|
+
* <Incremark :blocks="blocks" />
|
|
75
|
+
* <button v-if="typewriter.isProcessing.value" @click="typewriter.skip">跳过</button>
|
|
76
|
+
* </template>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function useIncremark(options?: UseIncremarkOptions): {
|
|
80
|
+
/** 已收集的完整 Markdown 字符串 */
|
|
81
|
+
markdown: import("vue").Ref<string, string>;
|
|
82
|
+
/** 已完成的块列表 */
|
|
83
|
+
completedBlocks: import("vue").ShallowRef<ParsedBlock[], ParsedBlock[]>;
|
|
84
|
+
/** 待处理的块列表 */
|
|
85
|
+
pendingBlocks: import("vue").ShallowRef<ParsedBlock[], ParsedBlock[]>;
|
|
86
|
+
/** 当前完整的 AST */
|
|
87
|
+
ast: ComputedRef<Root>;
|
|
88
|
+
/** 用于渲染的 blocks(根据打字机设置自动处理) */
|
|
89
|
+
blocks: ComputedRef<(ParsedBlock & {
|
|
90
|
+
stableId: string;
|
|
91
|
+
})[]>;
|
|
92
|
+
/** 是否正在加载 */
|
|
93
|
+
isLoading: import("vue").Ref<boolean, boolean>;
|
|
94
|
+
/** 是否已完成(finalize) */
|
|
95
|
+
isFinalized: import("vue").Ref<boolean, boolean>;
|
|
96
|
+
/** 脚注引用的出现顺序 */
|
|
97
|
+
footnoteReferenceOrder: import("vue").Ref<string[], string[]>;
|
|
98
|
+
/** 追加内容 */
|
|
99
|
+
append: (chunk: string) => IncrementalUpdate;
|
|
100
|
+
/** 完成解析 */
|
|
101
|
+
finalize: () => IncrementalUpdate;
|
|
102
|
+
/** 强制中断 */
|
|
103
|
+
abort: () => IncrementalUpdate;
|
|
104
|
+
/** 重置解析器和打字机 */
|
|
105
|
+
reset: () => void;
|
|
106
|
+
/** 一次性渲染(reset + append + finalize) */
|
|
107
|
+
render: (content: string) => IncrementalUpdate;
|
|
108
|
+
/** 解析器实例 */
|
|
109
|
+
parser: import("@incremark/core").IncremarkParser;
|
|
110
|
+
/** 打字机控制 */
|
|
111
|
+
typewriter: TypewriterControls;
|
|
112
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type InjectionKey, type Ref } from 'vue';
|
|
2
|
+
import type { Definition, FootnoteDefinition } from 'mdast';
|
|
3
|
+
export declare const definationsInjectionKey: InjectionKey<{
|
|
4
|
+
definations: Ref<Record<string, Definition>>;
|
|
5
|
+
footnoteDefinitions: Ref<Record<string, FootnoteDefinition>>;
|
|
6
|
+
footnoteReferenceOrder: Ref<string[]>;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function useProvideDefinations(): {
|
|
9
|
+
setDefinations: (definitions: Record<string, Definition>) => void;
|
|
10
|
+
setFootnoteDefinitions: (definitions: Record<string, FootnoteDefinition>) => void;
|
|
11
|
+
setFootnoteReferenceOrder: (order: string[]) => void;
|
|
12
|
+
clearDefinations: () => void;
|
|
13
|
+
clearFootnoteDefinitions: () => void;
|
|
14
|
+
clearFootnoteReferenceOrder: () => void;
|
|
15
|
+
clearAllDefinations: () => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Ref, type ComputedRef } from 'vue';
|
|
2
|
+
import type { ParsedBlock } from '@incremark/core';
|
|
3
|
+
export interface BlockWithStableId extends ParsedBlock {
|
|
4
|
+
/** 稳定的渲染 ID(用于 Vue key) */
|
|
5
|
+
stableId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UseStreamRendererOptions {
|
|
8
|
+
/** 已完成的块 */
|
|
9
|
+
completedBlocks: Ref<ParsedBlock[]>;
|
|
10
|
+
/** 待处理的块 */
|
|
11
|
+
pendingBlocks: Ref<ParsedBlock[]>;
|
|
12
|
+
}
|
|
13
|
+
export interface UseStreamRendererReturn {
|
|
14
|
+
/** 带稳定 ID 的已完成块 */
|
|
15
|
+
stableCompletedBlocks: ComputedRef<BlockWithStableId[]>;
|
|
16
|
+
/** 带稳定 ID 的待处理块 */
|
|
17
|
+
stablePendingBlocks: ComputedRef<BlockWithStableId[]>;
|
|
18
|
+
/** 所有带稳定 ID 的块 */
|
|
19
|
+
allStableBlocks: ComputedRef<BlockWithStableId[]>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Vue 3 Composable: 流式渲染辅助
|
|
23
|
+
*
|
|
24
|
+
* 为块分配稳定的渲染 ID,确保 Vue 的虚拟 DOM 复用
|
|
25
|
+
*/
|
|
26
|
+
export declare function useStreamRenderer(options: UseStreamRendererOptions): UseStreamRendererReturn;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file useTypewriter Composable - 打字机效果管理
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* 管理打字机效果的状态和控制逻辑,从 useIncremark 中拆分出来以简化代码。
|
|
6
|
+
*
|
|
7
|
+
* @author Incremark Team
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/
|
|
10
|
+
import { type Ref, type ComputedRef } from 'vue';
|
|
11
|
+
import { type RootContent, type ParsedBlock, type BlockTransformer } from '@incremark/core';
|
|
12
|
+
import type { TypewriterOptions, TypewriterControls } from './useIncremark';
|
|
13
|
+
export interface UseTypewriterOptions {
|
|
14
|
+
typewriter?: TypewriterOptions;
|
|
15
|
+
completedBlocks: Ref<ParsedBlock[]>;
|
|
16
|
+
pendingBlocks: Ref<ParsedBlock[]>;
|
|
17
|
+
}
|
|
18
|
+
export interface UseTypewriterReturn {
|
|
19
|
+
/** 用于渲染的 blocks(经过打字机处理或原始blocks) */
|
|
20
|
+
blocks: ComputedRef<Array<ParsedBlock & {
|
|
21
|
+
stableId: string;
|
|
22
|
+
}>>;
|
|
23
|
+
/** 打字机控制对象 */
|
|
24
|
+
typewriter: TypewriterControls;
|
|
25
|
+
/** transformer 实例 */
|
|
26
|
+
transformer: BlockTransformer<RootContent> | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* useTypewriter Composable
|
|
30
|
+
*
|
|
31
|
+
* @description
|
|
32
|
+
* 管理打字机效果的所有状态和逻辑。
|
|
33
|
+
*
|
|
34
|
+
* @param options - 打字机配置和数据
|
|
35
|
+
* @returns 打字机状态和控制对象
|
|
36
|
+
*/
|
|
37
|
+
export declare function useTypewriter(options: UseTypewriterOptions): UseTypewriterReturn;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { useIncremark, useStreamRenderer, useDevTools, useBlockTransformer } from './composables';
|
|
2
|
+
export { useProvideDefinations } from './composables/useProvideDefinations';
|
|
3
|
+
export { useDefinationsContext } from './composables/useDefinationsContext';
|
|
4
|
+
export type { UseIncremarkOptions, TypewriterOptions, TypewriterControls, UseStreamRendererOptions, UseDevToolsOptions, UseBlockTransformerOptions, UseBlockTransformerReturn } from './composables';
|
|
5
|
+
export { Incremark, IncremarkRenderer, IncremarkHeading, IncremarkParagraph, IncremarkCode, IncremarkList, IncremarkTable, IncremarkBlockquote, IncremarkThematicBreak, IncremarkInline, IncremarkMath, IncremarkHtmlElement, IncremarkDefault, IncremarkFootnotes, AutoScrollContainer } from './components';
|
|
6
|
+
export type { ComponentMap, BlockWithStableId } from './components';
|
|
7
|
+
export { default as ThemeProvider } from './ThemeProvider.vue';
|
|
8
|
+
export type { ParsedBlock, IncrementalUpdate, ParserOptions, BlockStatus, Root, RootContent, SourceBlock, DisplayBlock, TransformerPlugin, TransformerOptions, TransformerState, AnimationEffect } from '@incremark/core';
|
|
9
|
+
export { BlockTransformer, createBlockTransformer, countChars, sliceAst, cloneNode, codeBlockPlugin, mermaidPlugin, imagePlugin, mathPlugin, thematicBreakPlugin, defaultPlugins, allPlugins, createPlugin } from '@incremark/core';
|
|
10
|
+
export { type DesignTokens, defaultTheme, darkTheme, generateCSSVars, mergeTheme, applyTheme } from '@incremark/theme';
|