@fluxdown/uni-app 0.0.0-stage → 0.2.0
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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +16 -2
- package/dist/components/block-reconciler/consts.d.ts +3 -0
- package/dist/components/block-reconciler/consts.js +15 -0
- package/dist/components/block-reconciler/index.d.ts +1 -0
- package/dist/components/block-reconciler/index.js +2 -0
- package/dist/components/block-reconciler/main.uvue +49 -0
- package/dist/components/block-reconciler/main.uvue.d.ts +12 -0
- package/dist/components/block-reconciler/spacing.d.ts +4 -0
- package/dist/components/block-reconciler/spacing.js +47 -0
- package/dist/components/block-reconciler/type.d.ts +24 -0
- package/dist/components/block-reconciler/type.js +0 -0
- package/dist/components/block-reconciler/utils.d.ts +6 -0
- package/dist/components/block-reconciler/utils.js +68 -0
- package/dist/components/root-reconciler/index.d.ts +1 -0
- package/dist/components/root-reconciler/index.js +2 -0
- package/dist/components/root-reconciler/main.uvue +13 -0
- package/dist/components/root-reconciler/main.uvue.d.ts +12 -0
- package/dist/components/root-reconciler/type.d.ts +5 -0
- package/dist/components/root-reconciler/type.js +0 -0
- package/dist/consts/config.d.ts +2 -0
- package/dist/consts/config.js +11 -0
- package/dist/consts/defaults.d.ts +2 -0
- package/dist/consts/defaults.js +5 -0
- package/dist/consts/index.d.ts +3 -0
- package/dist/consts/index.js +4 -0
- package/dist/consts/smooth.d.ts +3 -0
- package/dist/consts/smooth.js +6 -0
- package/dist/context/render/index.d.ts +6 -0
- package/dist/context/render/index.js +13 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/plugins.d.ts +5 -0
- package/dist/hooks/plugins.js +23 -0
- package/dist/modules/uni-renderer/index.d.ts +7 -0
- package/dist/modules/uni-renderer/index.js +20 -0
- package/dist/packs/full/index.d.ts +3 -0
- package/dist/packs/full/index.js +3 -0
- package/dist/packs/full/main.uvue +32 -0
- package/dist/packs/full/main.uvue.d.ts +32 -0
- package/dist/packs/full/type.d.ts +3 -0
- package/dist/packs/full/type.js +0 -0
- package/dist/packs/lite/index.d.ts +3 -0
- package/dist/packs/lite/index.js +3 -0
- package/dist/packs/lite/main.uvue +32 -0
- package/dist/packs/lite/main.uvue.d.ts +32 -0
- package/dist/packs/lite/type.d.ts +3 -0
- package/dist/packs/lite/type.js +0 -0
- package/dist/packs/raw/consts.d.ts +30 -0
- package/dist/packs/raw/consts.js +28 -0
- package/dist/packs/raw/index.d.ts +2 -0
- package/dist/packs/raw/index.js +3 -0
- package/dist/packs/raw/main.uvue +137 -0
- package/dist/packs/raw/main.uvue.d.ts +30 -0
- package/dist/packs/raw/type.d.ts +70 -0
- package/dist/packs/raw/type.js +0 -0
- package/dist/packs/utils/config.d.ts +13 -0
- package/dist/packs/utils/config.js +53 -0
- package/dist/packs/utils/effect.d.ts +4 -0
- package/dist/packs/utils/effect.js +22 -0
- package/dist/packs/utils/index.d.ts +3 -0
- package/dist/packs/utils/index.js +4 -0
- package/dist/packs/utils/patches.d.ts +2 -0
- package/dist/packs/utils/patches.js +13 -0
- package/package.json +95 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @fluxdown/uni-app
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 65f128e: Add uni-app x Vapor components with full, lite, and raw presets, native render slots, theme customization, and streaming effects. Keep RAF smoothing on one clock origin in native hosts.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 65f128e: Require a current-clock reader for custom smooth tickers and provide the shared implementation on BaseSmoothTicker. Keep deterministic ticker fixtures on the same arrival and frame clock.
|
|
12
|
+
- Updated dependencies [a6380c3]
|
|
13
|
+
- Updated dependencies [65f128e]
|
|
14
|
+
- Updated dependencies [65f128e]
|
|
15
|
+
- Updated dependencies [65f128e]
|
|
16
|
+
- @fluxdown/core@0.12.8
|
|
17
|
+
- @fluxdown/core-plugins@0.13.0
|
|
18
|
+
- @fluxdown/types@0.10.2
|
|
19
|
+
- @fluxdown/utils@0.7.3
|
|
20
|
+
- stative@2.1.1
|
|
21
|
+
- @fluxdown/uni-app-plugins@0.2.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fluxdown contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @fluxdown/uni-app
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
uni-app x Vapor components for streaming Markdown. Requires HBuilderX 5.33 or later.
|
|
4
|
+
|
|
5
|
+
[Quick start](https://fluxdown.dev/guide/uni-app/quick-start.html) covers the project configuration.
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { Fluxdown } from "@fluxdown/uni-app";
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<Fluxdown text="# Hello, Fluxdown" />
|
|
14
|
+
</template>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Use `@fluxdown/uni-app/lite` for the lite preset, or `@fluxdown/uni-app/raw` with your own plugins.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { toState } from "stative";
|
|
2
|
+
//#region src/components/block-reconciler/consts.ts
|
|
3
|
+
var EMPTY_ROOT = /*#__PURE__*/ toState(null);
|
|
4
|
+
var BLOCK_CONTAINERS = [
|
|
5
|
+
"blockquote",
|
|
6
|
+
"ol",
|
|
7
|
+
"ul",
|
|
8
|
+
"table",
|
|
9
|
+
"thead",
|
|
10
|
+
"tbody",
|
|
11
|
+
"tfoot",
|
|
12
|
+
"tr"
|
|
13
|
+
];
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BLOCK_CONTAINERS, EMPTY_ROOT };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BlockReconciler } from './main.uvue';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { RenderNodes, useStateValue, useTheme } from '@fluxdown/uni-app-plugins/base';
|
|
3
|
+
import { toState } from 'stative';
|
|
4
|
+
import { computed } from 'vue';
|
|
5
|
+
|
|
6
|
+
import type { BlockReconcilerProps } from './type';
|
|
7
|
+
|
|
8
|
+
import { useRender } from '../../context/render';
|
|
9
|
+
import { EMPTY_ROOT } from './consts';
|
|
10
|
+
import { normalizeBlockSpacing } from './spacing';
|
|
11
|
+
import { renderParentChildren } from './utils';
|
|
12
|
+
|
|
13
|
+
const props = defineProps<BlockReconcilerProps>();
|
|
14
|
+
|
|
15
|
+
const { getProps } = useRender();
|
|
16
|
+
|
|
17
|
+
const root = useStateValue(() => props.block.value);
|
|
18
|
+
|
|
19
|
+
const meta = useStateValue(() => props.block.meta);
|
|
20
|
+
|
|
21
|
+
const first = computed(() => meta.value.currentIndex === 0);
|
|
22
|
+
|
|
23
|
+
const last = computed(() => meta.value.currentIndex === meta.value.blockCount - 1);
|
|
24
|
+
|
|
25
|
+
const blocks = useStateValue(() => toState(props.blocks));
|
|
26
|
+
|
|
27
|
+
const previous = useStateValue(
|
|
28
|
+
() => blocks.value[meta.value.currentIndex - 1]?.value ?? EMPTY_ROOT,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const theme = useTheme();
|
|
32
|
+
|
|
33
|
+
const patches = computed(() => toState(props.patches));
|
|
34
|
+
|
|
35
|
+
const plugins = useStateValue(() => toState(props.plugins));
|
|
36
|
+
|
|
37
|
+
const nodes = computed(() =>
|
|
38
|
+
normalizeBlockSpacing(
|
|
39
|
+
renderParentChildren(root.value, [root.value], patches.value, plugins.value, getProps),
|
|
40
|
+
{ first: first.value, last: last.value },
|
|
41
|
+
previous.value,
|
|
42
|
+
theme.value.tokens,
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<RenderNodes :nodes="nodes" :tail="last" />
|
|
49
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BlockReconcilerProps } from './type';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_TypePropsToOption<BlockReconcilerProps>, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<BlockReconcilerProps>>>, {}, {}>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
5
|
+
type __VLS_TypePropsToOption<T> = {
|
|
6
|
+
[K in keyof T & string]-?: {} extends Pick<T, K> ? {
|
|
7
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
8
|
+
} : {
|
|
9
|
+
type: import('vue').PropType<T[K]>;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ThemeTokens, UniRenderNode } from '@fluxdown/uni-app-plugins/typings';
|
|
2
|
+
import type { Root } from 'hast';
|
|
3
|
+
import type { BlockEdges } from './type';
|
|
4
|
+
export declare const normalizeBlockSpacing: (nodes: UniRenderNode[], edges: BlockEdges, previous: Root | null, tokens: ThemeTokens) => UniRenderNode[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getBlockSpacing } from "@fluxdown/uni-app-plugins/base";
|
|
2
|
+
import { findLast } from "lodash-es";
|
|
3
|
+
//#region src/components/block-reconciler/spacing.ts
|
|
4
|
+
var getSlotTag = (node) => {
|
|
5
|
+
switch (node.type) {
|
|
6
|
+
case "Heading": return `h${node.props.level}`;
|
|
7
|
+
case "Paragraph": return "p";
|
|
8
|
+
case "Blockquote": return "blockquote";
|
|
9
|
+
case "CodeBlock": return "pre";
|
|
10
|
+
case "Table": return "table";
|
|
11
|
+
case "List": return "ul";
|
|
12
|
+
default: return "";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var applySpacing = (nodes, tokens, previousBottom, first, last) => {
|
|
16
|
+
const entries = nodes.filter((node) => node !== null);
|
|
17
|
+
return entries.map((node, index) => {
|
|
18
|
+
if (node === null || typeof node !== "object" || !("type" in node)) {
|
|
19
|
+
previousBottom = 0;
|
|
20
|
+
return node;
|
|
21
|
+
}
|
|
22
|
+
const spacing = getBlockSpacing(getSlotTag(node), tokens);
|
|
23
|
+
if (!spacing) {
|
|
24
|
+
previousBottom = 0;
|
|
25
|
+
return node;
|
|
26
|
+
}
|
|
27
|
+
const marginTop = first && index === 0 ? 0 : Math.max(0, spacing.marginTop - previousBottom);
|
|
28
|
+
previousBottom = spacing.marginBottom;
|
|
29
|
+
return {
|
|
30
|
+
...node,
|
|
31
|
+
children: node.type === "Blockquote" && node.children ? applySpacing(node.children, tokens, 0, true, true) : node.children,
|
|
32
|
+
props: {
|
|
33
|
+
...node.props,
|
|
34
|
+
style: [node.props.style, {
|
|
35
|
+
marginTop: `${marginTop}px`,
|
|
36
|
+
marginBottom: `${last && index === entries.length - 1 ? 0 : spacing.marginBottom}px`
|
|
37
|
+
}]
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var normalizeBlockSpacing = (nodes, edges, previous, tokens) => {
|
|
43
|
+
const previousElement = findLast(previous?.children, (node) => node.type === "element");
|
|
44
|
+
return applySpacing(nodes, tokens, previousElement?.type === "element" ? getBlockSpacing(previousElement.tagName, tokens)?.marginBottom ?? 0 : 0, edges.first, edges.last);
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { normalizeBlockSpacing };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IRenderPatchItem } from '@fluxdown/core';
|
|
2
|
+
import type { IBlockState } from '@fluxdown/types';
|
|
3
|
+
import type { IUniRenderPlugin } from '@fluxdown/uni-app-plugins/base';
|
|
4
|
+
import type { UniRenderNode } from '@fluxdown/uni-app-plugins/base';
|
|
5
|
+
import type { GetPropsFunction } from '@fluxdown/uni-app-plugins/typings';
|
|
6
|
+
import type { ElementContent, Parent, Root } from 'hast';
|
|
7
|
+
import type { IReactiveState, StateSource } from 'stative';
|
|
8
|
+
export interface BlockReconcilerProps {
|
|
9
|
+
block: IBlockState<Root>;
|
|
10
|
+
blocks: StateSource<IBlockState<Root>[]>;
|
|
11
|
+
patches: StateSource<IRenderPatchItem<UniRenderNode>[]>;
|
|
12
|
+
plugins: StateSource<IUniRenderPlugin[]>;
|
|
13
|
+
}
|
|
14
|
+
export interface RenderNodeParams {
|
|
15
|
+
node: ElementContent;
|
|
16
|
+
parents: Parent[];
|
|
17
|
+
patches: IReactiveState<IRenderPatchItem<UniRenderNode>[]>;
|
|
18
|
+
plugins: IUniRenderPlugin[];
|
|
19
|
+
getProps: GetPropsFunction | undefined | null;
|
|
20
|
+
}
|
|
21
|
+
export interface BlockEdges {
|
|
22
|
+
first: boolean;
|
|
23
|
+
last: boolean;
|
|
24
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IRenderPatchItem } from '@fluxdown/core';
|
|
2
|
+
import type { IUniRenderPlugin, UniRenderNode } from '@fluxdown/uni-app-plugins/base';
|
|
3
|
+
import type { GetPropsFunction } from '@fluxdown/uni-app-plugins/typings';
|
|
4
|
+
import type { Parent } from 'hast';
|
|
5
|
+
import type { IReactiveState } from 'stative';
|
|
6
|
+
export declare const renderParentChildren: (parent: Parent, parents: Parent[], patches: IReactiveState<IRenderPatchItem<UniRenderNode>[]>, plugins: IUniRenderPlugin[], getProps: GetPropsFunction | undefined | null) => UniRenderNode[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BLOCK_CONTAINERS } from "./consts.js";
|
|
2
|
+
import { isHastElement, isHastParent } from "@fluxdown/uni-app-plugins/base";
|
|
3
|
+
import { isArray, isObject, isString } from "lodash-es";
|
|
4
|
+
import { PluginPriority } from "@fluxdown/types";
|
|
5
|
+
//#region src/components/block-reconciler/utils.ts
|
|
6
|
+
var isElementContent = (node) => node.type === "comment" || node.type === "element" || node.type === "text";
|
|
7
|
+
var getChildKey = (node, fallbackIndex) => {
|
|
8
|
+
if (node.type === "element" && node.properties?.dataParserPatch === "1" && isString(node.properties.dataPatchKey)) return `patch:${node.properties.dataPatchKey}`;
|
|
9
|
+
if (isString(node.data?.renderKey)) return `render:${node.data.renderKey}`;
|
|
10
|
+
const tagName = node.type === "element" ? `:${node.tagName}` : "";
|
|
11
|
+
return `${fallbackIndex}:${node.type}${tagName}`;
|
|
12
|
+
};
|
|
13
|
+
var renderParentChildren = (parent, parents, patches, plugins, getProps) => parent.children.map((child, index) => {
|
|
14
|
+
if (!isElementContent(child) || child.type === "text" && !child.value.trim() && (parent.type === "root" || isHastElement(parent) && BLOCK_CONTAINERS.includes(parent.tagName))) return null;
|
|
15
|
+
const node = renderNode({
|
|
16
|
+
node: child,
|
|
17
|
+
parents,
|
|
18
|
+
patches,
|
|
19
|
+
plugins,
|
|
20
|
+
getProps
|
|
21
|
+
});
|
|
22
|
+
if (isObject(node) && !isArray(node)) return {
|
|
23
|
+
...node,
|
|
24
|
+
key: getChildKey(child, index)
|
|
25
|
+
};
|
|
26
|
+
return node;
|
|
27
|
+
});
|
|
28
|
+
var renderNode = ({ node, parents, patches, plugins, getProps: getNodeProps }) => {
|
|
29
|
+
const childParents = isHastParent(node) ? [...parents, node] : parents;
|
|
30
|
+
const render = (child) => renderNode({
|
|
31
|
+
node: child,
|
|
32
|
+
parents: childParents,
|
|
33
|
+
patches,
|
|
34
|
+
plugins,
|
|
35
|
+
getProps: getNodeProps
|
|
36
|
+
});
|
|
37
|
+
const renderChildren = (target) => {
|
|
38
|
+
const parent = target ?? (isHastParent(node) ? node : null);
|
|
39
|
+
if (!parent) return [];
|
|
40
|
+
return renderParentChildren(parent, parent === node ? childParents : [...childParents, parent], patches, plugins, getNodeProps);
|
|
41
|
+
};
|
|
42
|
+
const getProps = (target) => {
|
|
43
|
+
if (getNodeProps === null) return {};
|
|
44
|
+
const current = target ?? (isHastElement(node) ? node : void 0);
|
|
45
|
+
return getNodeProps ? getNodeProps(current) : { ...current?.properties };
|
|
46
|
+
};
|
|
47
|
+
let matched;
|
|
48
|
+
let priority = Infinity;
|
|
49
|
+
for (const plugin of plugins) {
|
|
50
|
+
const nextPriority = plugin.config.priority ?? PluginPriority.Default;
|
|
51
|
+
if (nextPriority > priority || !plugin.match({
|
|
52
|
+
node,
|
|
53
|
+
parents
|
|
54
|
+
})) continue;
|
|
55
|
+
matched = plugin;
|
|
56
|
+
priority = nextPriority;
|
|
57
|
+
}
|
|
58
|
+
return matched?.render({
|
|
59
|
+
getProps,
|
|
60
|
+
node,
|
|
61
|
+
parents,
|
|
62
|
+
patches,
|
|
63
|
+
render,
|
|
64
|
+
renderChildren
|
|
65
|
+
}) ?? null;
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
export { renderParentChildren };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as RootReconciler } from './main.uvue';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { RootReconcilerProps } from './type';
|
|
3
|
+
|
|
4
|
+
import { RenderNodes, useStateValue } from '@fluxdown/uni-app-plugins/base';
|
|
5
|
+
|
|
6
|
+
const props = defineProps<RootReconcilerProps>();
|
|
7
|
+
|
|
8
|
+
const nodes = useStateValue(() => props.value);
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<RenderNodes :nodes="nodes" />
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RootReconcilerProps } from './type';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_TypePropsToOption<RootReconcilerProps>, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<RootReconcilerProps>>>, {}, {}>;
|
|
3
|
+
declare const _default: typeof __VLS_export;
|
|
4
|
+
export default _default;
|
|
5
|
+
type __VLS_TypePropsToOption<T> = {
|
|
6
|
+
[K in keyof T & string]-?: {} extends Pick<T, K> ? {
|
|
7
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
8
|
+
} : {
|
|
9
|
+
type: import('vue').PropType<T[K]>;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IntervalSmoothTicker, RafSmoothTicker, SpringSmoothScheduler } from "@fluxdown/core-plugins/plugins/mapper/smooth";
|
|
2
|
+
//#region src/consts/smooth.ts
|
|
3
|
+
var ALL_TICKERS = [RafSmoothTicker, IntervalSmoothTicker];
|
|
4
|
+
var ALL_SCHEDULERS = [SpringSmoothScheduler];
|
|
5
|
+
//#endregion
|
|
6
|
+
export { ALL_SCHEDULERS, ALL_TICKERS };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GetPropsFunction } from '@fluxdown/uni-app-plugins/typings';
|
|
2
|
+
export interface RenderConfig {
|
|
3
|
+
getProps?: GetPropsFunction | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const provideRender: (config: RenderConfig) => void;
|
|
6
|
+
export declare const useRender: () => RenderConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { inject, provide } from "vue";
|
|
2
|
+
//#region src/context/render/index.ts
|
|
3
|
+
var RenderContext = /*#__PURE__*/ Symbol("FluxdownRender");
|
|
4
|
+
var provideRender = (config) => {
|
|
5
|
+
provide(RenderContext, config);
|
|
6
|
+
};
|
|
7
|
+
var useRender = () => {
|
|
8
|
+
const config = inject(RenderContext, null);
|
|
9
|
+
if (config === null) throw new Error("[Fluxdown] A render context is required.");
|
|
10
|
+
return config;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { provideRender, useRender };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './plugins';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IPluginItem } from '@fluxdown/uni-app-plugins/typings';
|
|
2
|
+
type PluginChannel = Exclude<keyof IPluginItem, 'config'>;
|
|
3
|
+
export declare const usePlugins: <K extends PluginChannel>(items: () => IPluginItem[], type: K) => import("vue").ComputedRef<NonNullable<IPluginItem[K]>>;
|
|
4
|
+
export declare const useMergePlugins: (presets: IPluginItem[], plugins: () => IPluginItem | IPluginItem[] | undefined) => import("vue").ComputedRef<IPluginItem>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EL } from "../consts/defaults.js";
|
|
2
|
+
import { filterDisabledBy, toPluginList } from "@fluxdown/uni-app-plugins/base";
|
|
3
|
+
import { castArray } from "lodash-es";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
//#region src/hooks/plugins.ts
|
|
6
|
+
var usePlugins = (items, type) => computed(() => toPluginList(items(), type));
|
|
7
|
+
var useMergePlugins = (presets, plugins) => computed(() => {
|
|
8
|
+
const items = castArray(plugins() ?? EL);
|
|
9
|
+
const merge = (type) => {
|
|
10
|
+
const overrides = toPluginList(items, type);
|
|
11
|
+
return [...filterDisabledBy(toPluginList(presets, type), overrides), ...overrides];
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
remarks: merge("remarks"),
|
|
15
|
+
rehypes: merge("rehypes"),
|
|
16
|
+
repairs: merge("repairs"),
|
|
17
|
+
mappers: merge("mappers"),
|
|
18
|
+
renders: merge("renders"),
|
|
19
|
+
slots: merge("slots")
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useMergePlugins, usePlugins };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IBlockState } from '@fluxdown/types';
|
|
2
|
+
import type { UniRenderExtraParams, UniRenderNode } from '@fluxdown/uni-app-plugins/base';
|
|
3
|
+
import type { ElementContent, Parent, Root } from 'hast';
|
|
4
|
+
import { BaseRenderer } from '@fluxdown/core';
|
|
5
|
+
export declare class UniRenderer extends BaseRenderer<Root, ElementContent, Parent, UniRenderNode, UniRenderExtraParams> {
|
|
6
|
+
protected renderItem(block: IBlockState<Root>): UniRenderNode;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BlockReconciler } from "../../components/block-reconciler/index.js";
|
|
2
|
+
import { BaseRenderer } from "@fluxdown/core";
|
|
3
|
+
//#region src/modules/uni-renderer/index.ts
|
|
4
|
+
var UniRenderer = class extends BaseRenderer {
|
|
5
|
+
renderItem(block) {
|
|
6
|
+
const { patches, plugins, source } = this.inputs;
|
|
7
|
+
return {
|
|
8
|
+
component: BlockReconciler,
|
|
9
|
+
key: block.meta.value.key,
|
|
10
|
+
props: {
|
|
11
|
+
block,
|
|
12
|
+
patches,
|
|
13
|
+
plugins,
|
|
14
|
+
blocks: source
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { UniRenderer };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { PRESET_FULL_PLUGINS } from '@fluxdown/uni-app-plugins/full';
|
|
3
|
+
import { shallowRef } from 'vue';
|
|
4
|
+
|
|
5
|
+
import type { FluxdownRef } from '../raw';
|
|
6
|
+
|
|
7
|
+
import { useMergePlugins } from '../../hooks';
|
|
8
|
+
import { PRESET_PROPS } from '../raw/consts';
|
|
9
|
+
import { FluxdownRaw } from '../raw';
|
|
10
|
+
|
|
11
|
+
defineOptions({ name: 'Fluxdown' });
|
|
12
|
+
|
|
13
|
+
const props = defineProps(PRESET_PROPS);
|
|
14
|
+
|
|
15
|
+
const raw = shallowRef<FluxdownRef>();
|
|
16
|
+
|
|
17
|
+
const plugins = useMergePlugins(PRESET_FULL_PLUGINS, () => props.plugins);
|
|
18
|
+
|
|
19
|
+
defineExpose({
|
|
20
|
+
get value() {
|
|
21
|
+
return raw.value?.value;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
destroy() {
|
|
25
|
+
raw.value?.destroy();
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<FluxdownRaw v-bind="props" :plugins="plugins" ref="raw" />
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{
|
|
2
|
+
readonly plugins: {
|
|
3
|
+
readonly required: false;
|
|
4
|
+
readonly type: import("vue").PropType<import(".").FluxdownRawProps["plugins"]>;
|
|
5
|
+
};
|
|
6
|
+
readonly text: {
|
|
7
|
+
readonly type: StringConstructor;
|
|
8
|
+
readonly required: true;
|
|
9
|
+
};
|
|
10
|
+
readonly build: import("vue").PropType<import(".").FluxdownRawProps["build"]>;
|
|
11
|
+
readonly streaming: import("vue").PropType<import(".").FluxdownRawProps["streaming"]>;
|
|
12
|
+
readonly patches: import("vue").PropType<import(".").FluxdownRawProps["patches"]>;
|
|
13
|
+
readonly theme: import("vue").PropType<import(".").FluxdownRawProps["theme"]>;
|
|
14
|
+
}, {
|
|
15
|
+
readonly value: import("stative").IReactiveState<import("@fluxdown/uni-app-plugins/typings").UniRenderNode[]> | undefined;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
18
|
+
readonly plugins: {
|
|
19
|
+
readonly required: false;
|
|
20
|
+
readonly type: import("vue").PropType<import(".").FluxdownRawProps["plugins"]>;
|
|
21
|
+
};
|
|
22
|
+
readonly text: {
|
|
23
|
+
readonly type: StringConstructor;
|
|
24
|
+
readonly required: true;
|
|
25
|
+
};
|
|
26
|
+
readonly build: import("vue").PropType<import(".").FluxdownRawProps["build"]>;
|
|
27
|
+
readonly streaming: import("vue").PropType<import(".").FluxdownRawProps["streaming"]>;
|
|
28
|
+
readonly patches: import("vue").PropType<import(".").FluxdownRawProps["patches"]>;
|
|
29
|
+
readonly theme: import("vue").PropType<import(".").FluxdownRawProps["theme"]>;
|
|
30
|
+
}>>, {}, {}>;
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { PRESET_LITE_PLUGINS } from '@fluxdown/uni-app-plugins/lite';
|
|
3
|
+
import { shallowRef } from 'vue';
|
|
4
|
+
|
|
5
|
+
import type { FluxdownRef } from '../raw';
|
|
6
|
+
|
|
7
|
+
import { useMergePlugins } from '../../hooks';
|
|
8
|
+
import { PRESET_PROPS } from '../raw/consts';
|
|
9
|
+
import { FluxdownRaw } from '../raw';
|
|
10
|
+
|
|
11
|
+
defineOptions({ name: 'FluxdownLite' });
|
|
12
|
+
|
|
13
|
+
const props = defineProps(PRESET_PROPS);
|
|
14
|
+
|
|
15
|
+
const raw = shallowRef<FluxdownRef>();
|
|
16
|
+
|
|
17
|
+
const plugins = useMergePlugins(PRESET_LITE_PLUGINS, () => props.plugins);
|
|
18
|
+
|
|
19
|
+
defineExpose({
|
|
20
|
+
get value() {
|
|
21
|
+
return raw.value?.value;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
destroy() {
|
|
25
|
+
raw.value?.destroy();
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<FluxdownRaw v-bind="props" :plugins="plugins" ref="raw" />
|
|
32
|
+
</template>
|