weifuwu 0.65.1 → 0.67.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.
Files changed (32) hide show
  1. package/README.md +12 -12
  2. package/dist/client/browser.d.ts +10 -0
  3. package/dist/client/index.js +4 -4
  4. package/dist/client/types.d.ts +51 -0
  5. package/dist/client/ui.d.ts +8 -0
  6. package/dist/components/Anchor/Anchor.d.ts +27 -0
  7. package/dist/components/DiffView/DiffView.d.ts +24 -0
  8. package/dist/components/DiffView/diff-utils.d.ts +19 -0
  9. package/dist/components/Editor/Editor.d.ts +1 -1
  10. package/dist/components/Editor/tools/format.d.ts +1 -1
  11. package/dist/components/FileUpload/FileUpload.d.ts +4 -0
  12. package/dist/components/JSONViewer/JSONViewer.d.ts +21 -0
  13. package/dist/components/Kanban/Kanban.d.ts +28 -0
  14. package/dist/components/LogViewer/LogViewer.d.ts +29 -0
  15. package/dist/components/Menu/Menu.d.ts +11 -2
  16. package/dist/components/Pipeline/Pipeline.d.ts +27 -0
  17. package/dist/components/Pipeline/dag-utils.d.ts +36 -0
  18. package/dist/components/Sparkline/Sparkline.d.ts +21 -0
  19. package/dist/components/Sparkline/sparkline-utils.d.ts +16 -0
  20. package/dist/components/Tour/Tour.d.ts +34 -0
  21. package/dist/components/Tree/Tree.d.ts +2 -0
  22. package/dist/components/TreeSelect/TreeSelect.d.ts +24 -0
  23. package/dist/components/VirtualTable/VirtualTable.d.ts +32 -0
  24. package/dist/components/index.d.ts +16 -0
  25. package/dist/components/index.js +15 -11
  26. package/dist/components/style.css +1048 -101
  27. package/dist/index.js +28 -1
  28. package/dist/layout/weifuwu-layout.css +7 -0
  29. package/docs/components-map.md +28 -7
  30. package/docs/custom-components.md +29 -0
  31. package/docs/frontend.md +28 -0
  32. package/package.json +1 -1
@@ -0,0 +1,29 @@
1
+ /**
2
+ * weifuwu/components — LogViewer
3
+ *
4
+ * 日志流查看器(Agent 执行日志 / CI 输出):ANSI 着色 + 虚拟滚动 + 自动跟随。
5
+ * 复用 VirtualList 滚动基座(useScrollPosition + rAF 节流)。
6
+ * 裁剪:正则高亮、多日志源合并、搜索定位。
7
+ */
8
+ import type { Component } from '../../client/vnode.ts';
9
+ export interface LogViewerProps {
10
+ lines: string[];
11
+ /** 视口高度(px),默认 400 */
12
+ height?: number;
13
+ /** 行高(px),默认 24 */
14
+ lineHeight?: number;
15
+ /** 可见区外额外渲染行数 */
16
+ overscan?: number;
17
+ /** 自动跟随:新行到达时若已在底部则滚到底(默认 true) */
18
+ follow?: boolean;
19
+ /** 只显示尾部 N 行(内存保护,默认不限) */
20
+ maxLines?: number;
21
+ /** 显示复制按钮(默认 true) */
22
+ showCopy?: boolean;
23
+ /** 显示行号(默认 true) */
24
+ showLineNumbers?: boolean;
25
+ className?: string;
26
+ }
27
+ /** ANSI 转义解析(16 色 + 粗体 + 背景 8 色):累积样式到 reset 为止,零依赖 */
28
+ export declare function parseAnsi(text: string): any[];
29
+ export declare const LogViewer: Component<LogViewerProps>;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * weifuwu/components — Menu
3
3
  *
4
- * 导航菜单(侧栏导航):分组项 + 图标 + 选中态 + 方向键导航 + Enter 激活。
4
+ * 导航菜单(侧栏导航):分组项 + 图标 + 选中态 + 方向键导航 + Enter 激活 + 子菜单 + 折叠。
5
5
  * 用于 SaaS 应用侧边导航(替代手写 nav-item 循环)。
6
- * 裁剪:不做子菜单展开/水平菜单栏(见 roadmap)。
6
+ * 裁剪:水平菜单栏(Menubar)、折叠时子菜单浮层(popup,见 roadmap)、子菜单自动互斥。
7
7
  */
8
8
  import type { Component } from '../../client/vnode.ts';
9
9
  export interface MenuItem {
@@ -15,11 +15,20 @@ export interface MenuItem {
15
15
  active?: boolean;
16
16
  danger?: boolean;
17
17
  onClick?: () => void;
18
+ /** 子菜单项(有 children 即渲染为可展开子菜单) */
19
+ children?: MenuItem[];
18
20
  }
19
21
  export interface MenuProps {
20
22
  items: MenuItem[];
21
23
  onSelect?: (key: string) => void;
22
24
  activeKey?: string;
23
25
  className?: string;
26
+ /** 受控展开 key 列表(子菜单) */
27
+ openKeys?: string[];
28
+ onOpenChange?: (keys: string[]) => void;
29
+ /** 可折叠侧栏(宽度收窄 + label 隐藏) */
30
+ collapsible?: boolean;
31
+ collapsed?: boolean;
32
+ onCollapseChange?: (collapsed: boolean) => void;
24
33
  }
25
34
  export declare const Menu: Component<MenuProps>;
@@ -0,0 +1,27 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export type NodeStatus = 'default' | 'success' | 'running' | 'error' | 'pending';
3
+ export interface PipelineNode {
4
+ id: string;
5
+ label: string;
6
+ /** 状态着色(默认 default) */
7
+ status?: NodeStatus;
8
+ }
9
+ export interface PipelineEdge {
10
+ from: string;
11
+ to: string;
12
+ }
13
+ export interface PipelineProps {
14
+ nodes: PipelineNode[];
15
+ edges: PipelineEdge[];
16
+ /** 布局方向(默认 vertical:输入在左→输出在右) */
17
+ orientation?: 'vertical' | 'horizontal';
18
+ width?: number;
19
+ height?: number;
20
+ className?: string;
21
+ }
22
+ /**
23
+ * Pipeline/DAG — Agent 多步工作流可视化。
24
+ * 分层布局(Kahn 拓扑最长路径)+ SVG 贝塞尔连线 + 状态语义色。
25
+ * 纯函数布局(dag-utils)可 SSR/单测;环检测 → 渲染警告不崩溃。
26
+ */
27
+ export declare const Pipeline: Component<PipelineProps>;
@@ -0,0 +1,36 @@
1
+ export interface DagNodeInput {
2
+ id: string;
3
+ }
4
+ export interface DagEdgeInput {
5
+ from: string;
6
+ to: string;
7
+ }
8
+ export interface LayoutNode {
9
+ id: string;
10
+ x: number;
11
+ y: number;
12
+ }
13
+ export interface LayoutEdge {
14
+ from: string;
15
+ to: string;
16
+ d: string;
17
+ }
18
+ /**
19
+ * 分层:每个节点层 = 最长入链深度(BFS/DP)。
20
+ * 无入边节点 → 0;菱形依赖取最长路径。
21
+ */
22
+ export declare function computeLayers(nodes: DagNodeInput[], edges: DagEdgeInput[]): Map<string, number>;
23
+ /** 环检测:Kahn 拓扑——有环时访问节点数 < 总节点数 */
24
+ export declare function detectCycle(nodes: DagNodeInput[], edges: DagEdgeInput[]): boolean;
25
+ export interface GraphLayoutOptions {
26
+ orientation: 'vertical' | 'horizontal';
27
+ width: number;
28
+ height: number;
29
+ nodeW?: number;
30
+ nodeH?: number;
31
+ }
32
+ /** 布局:分层 → 层列分布 + 层内均匀;边 = 贝塞尔 path */
33
+ export declare function layoutGraph(nodes: DagNodeInput[], edges: DagEdgeInput[], opts: GraphLayoutOptions): {
34
+ nodes: LayoutNode[];
35
+ edges: LayoutEdge[];
36
+ };
@@ -0,0 +1,21 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface SparklineProps {
3
+ /** 数据序列 */
4
+ data: number[];
5
+ /** SVG 宽(默认 120) */
6
+ width?: number;
7
+ /** SVG 高(默认 32) */
8
+ height?: number;
9
+ /** 描边色(默认语义 primary,随 currentColor 可继承) */
10
+ stroke?: string;
11
+ /** 面积填充(默认关) */
12
+ fill?: boolean;
13
+ /** 平滑曲线(Catmull-Rom)——默认折线 */
14
+ smooth?: boolean;
15
+ className?: string;
16
+ }
17
+ /**
18
+ * Sparkline — 迷你趋势线(SVG 自绘,零依赖)。
19
+ * 归一化到 viewBox,等值/单点/空数据安全。
20
+ */
21
+ export declare const Sparkline: Component<SparklineProps>;
@@ -0,0 +1,16 @@
1
+ export interface SparklinePoint {
2
+ x: number;
3
+ y: number;
4
+ }
5
+ /**
6
+ * 将数据点归一化到 [padding, width-padding] × [padding, height-padding]。
7
+ * - min → 底部(y=height-padding),max → 顶部(y=padding)
8
+ * - 单点:居中(x 中点,y 垂直居中)
9
+ * - 等值:全部垂直居中(除零防护)
10
+ * - 空:空数组
11
+ */
12
+ export declare function computeSparklinePoints(data: number[], width: number, height: number, padding?: number): SparklinePoint[];
13
+ /** 折线 points 字符串 */
14
+ export declare function polylinePoints(pts: SparklinePoint[]): string;
15
+ /** 平滑 path(Catmull-Rom → cubic Bézier)——描边 + 可选面积 */
16
+ export declare function smoothPath(pts: SparklinePoint[]): string;
@@ -0,0 +1,34 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export type TourPlacement = 'top' | 'bottom' | 'left' | 'right';
3
+ export interface TourStep {
4
+ /** 目标元素选择器(ctx.browser.query) */
5
+ target: string;
6
+ title: string;
7
+ content: string;
8
+ /** 气泡相对目标的位置(默认 bottom) */
9
+ placement?: TourPlacement;
10
+ }
11
+ export interface TourProps {
12
+ steps: TourStep[];
13
+ /** 受控:是否打开 */
14
+ open?: boolean;
15
+ /** 受控回调(关闭时 onChange(false)) */
16
+ onChange?: (open: boolean) => void;
17
+ /** 受控:当前步骤索引 */
18
+ current?: number;
19
+ /** 步骤变化回调 */
20
+ onStepChange?: (step: number) => void;
21
+ /** 完成/跳过回调 */
22
+ onFinish?: () => void;
23
+ /** 遮罩(默认 true) */
24
+ mask?: boolean;
25
+ }
26
+ /**
27
+ * Tour — 新手引导(步骤式)。
28
+ * 目标 rect 定位(usePopupPosition 跟随 scroll/resize)+ Portal 遮罩 + 步骤气泡。
29
+ *
30
+ * 状态纪律:
31
+ * - 步骤索引闭包 let + render()(手动模式——避免 $ 内置类型问题)
32
+ * - open 受控(props.open + onChange)
33
+ */
34
+ export declare const Tour: Component<TourProps>;
@@ -16,6 +16,8 @@ export interface TreeProps {
16
16
  onExpand?: (keys: string[]) => void;
17
17
  /** 勾选模式(父子联动,antd 非 strict 语义) */
18
18
  checkable?: boolean;
19
+ /** 点击有子节点的行 = 展开/折叠(不触发选中)——TreeSelect 场景(点行展开比点箭头直观) */
20
+ expandOnClick?: boolean;
19
21
  checkedKeys?: string[];
20
22
  onCheck?: (keys: string[]) => void;
21
23
  className?: string;
@@ -0,0 +1,24 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ import type { TreeNode } from '../Tree/Tree.ts';
3
+ export interface TreeSelectProps {
4
+ /** 树选项(复用 TreeNode 结构) */
5
+ options: TreeNode[];
6
+ /** 受控:单选 string / 多选 string[] */
7
+ value?: string | string[];
8
+ /** 受控回调:单选 key / 多选 keys[] */
9
+ onChange?: (value: any) => void;
10
+ /** 多选(checkable 父子联动语义) */
11
+ multiple?: boolean;
12
+ placeholder?: string;
13
+ className?: string;
14
+ }
15
+ /** 在树中按 key 找 label(选中显示用) */
16
+ export declare function findLabel(nodes: TreeNode[], key: string): string | undefined;
17
+ /**
18
+ * TreeSelect — 树形选择(Tree + 下拉组合)。
19
+ * 下拉经 createPortal + position:fixed(usePopupPosition 定位/跟随/夹紧)——
20
+ * 与 DatePicker 同模式:父容器 overflow/transform 不影响弹出层。
21
+ * 单选 selectedKeys / 多选 checkable checkedKeys(父子联动)。
22
+ * 受控纪律:value 受控无 onChange → warn。
23
+ */
24
+ export declare const TreeSelect: Component<TreeSelectProps>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * weifuwu/components — VirtualTable
3
+ *
4
+ * 虚拟表格(数据密集场景):固定表头 + 虚拟滚动表体,10k+ 行只渲染可见窗口。
5
+ * 复用 VirtualList 滚动基座(useScrollPosition 像素级 scrollTop + rAF 节流)。
6
+ * 排序:受控 sortKey/sortOrder + onSort(与 Table 同款模式)。
7
+ * 裁剪:行选择(rowSelection)、列虚拟化(横向)、行编辑、单元格合并、树形表格。
8
+ */
9
+ import type { Component } from '../../client/vnode.ts';
10
+ import type { TableColumn } from '../Table/Table.ts';
11
+ export interface VirtualTableProps {
12
+ columns: TableColumn[];
13
+ data?: any[];
14
+ /** 视口高度(px),默认 400 */
15
+ height?: number;
16
+ /** 行高(px),默认 40 */
17
+ rowHeight?: number;
18
+ /** 可见区外额外渲染行数 */
19
+ overscan?: number;
20
+ /** 当前排序列 key */
21
+ sortKey?: string;
22
+ /** 当前排序方向 */
23
+ sortOrder?: 'asc' | 'desc';
24
+ /** 排序变化回调 */
25
+ onSort?: (key: string, order: 'asc' | 'desc') => void;
26
+ /** 数据为空时显示的文本 */
27
+ emptyText?: string;
28
+ /** 行点击 */
29
+ onRowClick?: (row: any, index: number) => void;
30
+ className?: string;
31
+ }
32
+ export declare const VirtualTable: Component<VirtualTableProps>;
@@ -183,7 +183,23 @@ export { InfiniteScroll } from './InfiniteScroll/InfiniteScroll.ts';
183
183
  export type { InfiniteScrollProps } from './InfiniteScroll/InfiniteScroll.ts';
184
184
  export { VirtualList } from './VirtualList/VirtualList.ts';
185
185
  export type { VirtualListProps } from './VirtualList/VirtualList.ts';
186
+ export { VirtualTable } from './VirtualTable/VirtualTable.ts';
187
+ export type { VirtualTableProps } from './VirtualTable/VirtualTable.ts';
188
+ export { Anchor } from './Anchor/Anchor.ts';
189
+ export type { AnchorProps, AnchorItem } from './Anchor/Anchor.ts';
190
+ export { LogViewer, parseAnsi } from './LogViewer/LogViewer.ts';
191
+ export type { LogViewerProps } from './LogViewer/LogViewer.ts';
192
+ export { JSONViewer } from './JSONViewer/JSONViewer.ts';
193
+ export type { JSONViewerProps } from './JSONViewer/JSONViewer.ts';
186
194
  export { QRCode } from './QRCode/QRCode.ts';
187
195
  export type { QRCodeProps } from './QRCode/QRCode.ts';
188
196
  export { generateQr } from './QRCode/qr.ts';
189
197
  export type { QrMatrix, QrEcLevel } from './QRCode/qr.ts';
198
+ export { DiffView } from './DiffView/DiffView.ts';
199
+ export { Sparkline } from './Sparkline/Sparkline.ts';
200
+ export { Tour } from './Tour/Tour.ts';
201
+ export { Kanban } from './Kanban/Kanban.ts';
202
+ export { Pipeline } from './Pipeline/Pipeline.ts';
203
+ export { layoutGraph, computeLayers, detectCycle } from './Pipeline/dag-utils.ts';
204
+ export { TreeSelect } from './TreeSelect/TreeSelect.ts';
205
+ export { findLabel } from './TreeSelect/TreeSelect.ts';