@xiongtao.xt/tau-plugins 0.6.0 → 0.8.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 (39) hide show
  1. package/AI.md +75 -0
  2. package/EDITOR.md +41 -42
  3. package/README.md +4 -4
  4. package/SERVICES.md +5 -5
  5. package/WHITEBOARD.md +115 -0
  6. package/package.json +8 -3
  7. package/tailwind.css +101 -0
  8. package/types/packages/plugins/src/ai.d.ts +40 -0
  9. package/types/packages/plugins/src/contract.d.ts +7 -0
  10. package/types/packages/plugins/src/index.d.ts +1 -0
  11. package/types/packages/plugins/src/whiteboard.d.ts +7 -0
  12. package/types/packages/shared/entity-ref.d.ts +19 -0
  13. package/types/packages/whiteboard/src/author.d.ts +14 -0
  14. package/types/packages/whiteboard/src/authorSketch.d.ts +6 -0
  15. package/types/packages/whiteboard/src/chrome/index.d.ts +189 -0
  16. package/types/packages/whiteboard/src/components/SketchPaths/index.d.ts +9 -0
  17. package/types/packages/whiteboard/src/components/SketchPopover.d.ts +43 -0
  18. package/types/packages/whiteboard/src/extensions/api.d.ts +352 -0
  19. package/types/packages/whiteboard/src/extensions/authorHooks.d.ts +4 -0
  20. package/types/packages/whiteboard/src/extensions/context.d.ts +4 -0
  21. package/types/packages/whiteboard/src/extensions/events.d.ts +50 -0
  22. package/types/packages/whiteboard/src/extensions/standard-schema.d.ts +32 -0
  23. package/types/packages/whiteboard/src/types/containment.d.ts +3 -0
  24. package/types/packages/whiteboard/src/types/element.d.ts +33 -0
  25. package/types/packages/whiteboard/src/types/operation.d.ts +51 -0
  26. package/types/packages/whiteboard/src/types/path.d.ts +1 -0
  27. package/types/packages/whiteboard/src/types/point.d.ts +4 -0
  28. package/types/packages/whiteboard/src/types/presentation.d.ts +11 -0
  29. package/types/packages/whiteboard/src/types/schematic.d.ts +44 -0
  30. package/types/packages/whiteboard/src/types/selection.d.ts +11 -0
  31. package/types/packages/whiteboard/src/types/sketch.d.ts +25 -0
  32. package/types/packages/whiteboard/src/types/viewport.d.ts +8 -0
  33. package/types/packages/whiteboard/src/utils/sketch/geometry.d.ts +22 -0
  34. package/types/packages/whiteboard/src/utils/sketch/handText.d.ts +3 -0
  35. package/types/packages/whiteboard/src/utils/sketch/ink.d.ts +13 -0
  36. package/types/packages/whiteboard/src/utils/sketch/levels.d.ts +5 -0
  37. package/types/packages/whiteboard/src/utils/sketch/random.d.ts +4 -0
  38. package/types/packages/whiteboard/src/utils/sketch/shape.d.ts +38 -0
  39. package/types/packages/whiteboard/src/utils/sketch/types.d.ts +24 -0
@@ -0,0 +1,32 @@
1
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
2
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
3
+ }
4
+ export declare namespace StandardSchemaV1 {
5
+ interface Props<Input = unknown, Output = Input> {
6
+ readonly version: 1;
7
+ readonly vendor: string;
8
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
9
+ readonly types?: Types<Input, Output> | undefined;
10
+ }
11
+ interface Types<Input = unknown, Output = Input> {
12
+ readonly input: Input;
13
+ readonly output: Output;
14
+ }
15
+ type Result<Output> = SuccessResult<Output> | FailureResult;
16
+ interface SuccessResult<Output> {
17
+ readonly value: Output;
18
+ readonly issues?: undefined;
19
+ }
20
+ interface FailureResult {
21
+ readonly issues: ReadonlyArray<Issue>;
22
+ }
23
+ interface Issue {
24
+ readonly message: string;
25
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
26
+ }
27
+ interface PathSegment {
28
+ readonly key: PropertyKey;
29
+ }
30
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
31
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
32
+ }
@@ -0,0 +1,3 @@
1
+ /** 受限容器类别;元素以 joins 声明愿意进入的容器组。 */
2
+ export declare const CONTAINER_KINDS: readonly ["layout"];
3
+ export type ContainerKind = (typeof CONTAINER_KINDS)[number];
@@ -0,0 +1,33 @@
1
+ import type { EntityRef } from "../../../shared/entity-ref";
2
+ import type { ElementSketch } from "./sketch";
3
+ import type { Point } from "./point";
4
+ /** 白板持久化元素;不依赖 Board 或内部插件实例。 */
5
+ export interface BoardElement {
6
+ id: string;
7
+ type: string;
8
+ name?: string;
9
+ groupId?: string;
10
+ children?: BoardElement[];
11
+ resizable?: boolean;
12
+ autoHeight?: boolean;
13
+ entityRef?: EntityRef;
14
+ sketch?: ElementSketch;
15
+ schemaVersion?: number;
16
+ [key: string]: any;
17
+ }
18
+ export interface ElementBounds {
19
+ minX: number;
20
+ minY: number;
21
+ maxX: number;
22
+ maxY: number;
23
+ }
24
+ export interface BoardContextMenuPayload {
25
+ clientX: number;
26
+ clientY: number;
27
+ viewPortPoint: Point;
28
+ selectedElements: BoardElement[];
29
+ hitElements: BoardElement[];
30
+ targetElements: BoardElement[];
31
+ hitElement?: BoardElement;
32
+ isHitSelected: boolean;
33
+ }
@@ -0,0 +1,51 @@
1
+ import { Selection } from "./selection";
2
+ import type { BoardElement } from "./element";
3
+ import { ViewPort } from "./viewport";
4
+ import { Path } from "./path";
5
+ import { PageSketch } from "./sketch";
6
+ export type SetNodePatch = Partial<Omit<BoardElement, "children">> & {
7
+ children?: never;
8
+ };
9
+ export type InsertNodeOperation = {
10
+ type: "insert_node";
11
+ path: Path;
12
+ node: BoardElement;
13
+ };
14
+ export type RemoveNodeOperation = {
15
+ type: "remove_node";
16
+ path: Path;
17
+ node: BoardElement;
18
+ };
19
+ export type MoveNodeOperation = {
20
+ type: "move_node";
21
+ path: Path;
22
+ newPath: Path;
23
+ };
24
+ export type SetNodeOperation = {
25
+ type: "set_node";
26
+ path: Path;
27
+ properties: SetNodePatch;
28
+ newProperties: SetNodePatch;
29
+ };
30
+ export type SetSelectionOperation = {
31
+ type: "set_selection";
32
+ properties: Partial<Selection>;
33
+ newProperties: Partial<Selection>;
34
+ };
35
+ export type SetViewportOperation = {
36
+ type: "set_viewport";
37
+ properties: Partial<ViewPort>;
38
+ newProperties: Partial<ViewPort>;
39
+ };
40
+ /** 页级画风(D-107),进撤销历史 */
41
+ export type SetSketchOperation = {
42
+ type: "set_sketch";
43
+ properties: Partial<PageSketch>;
44
+ newProperties: Partial<PageSketch>;
45
+ };
46
+ export type SetMovingOperation = {
47
+ type: "set_moving";
48
+ properties: BoardElement[];
49
+ newProperties: BoardElement[];
50
+ };
51
+ export type Operation = InsertNodeOperation | RemoveNodeOperation | MoveNodeOperation | SetNodeOperation | SetViewportOperation | SetSelectionOperation | SetMovingOperation | SetSketchOperation;
@@ -0,0 +1 @@
1
+ export type Path = number[];
@@ -0,0 +1,4 @@
1
+ export interface Point {
2
+ x: number;
3
+ y: number;
4
+ }
@@ -0,0 +1,11 @@
1
+ export interface PresentationFrame {
2
+ id: string;
3
+ elements: string[];
4
+ }
5
+ export interface PresentationSequence {
6
+ id: string;
7
+ name: string;
8
+ frames: PresentationFrame[];
9
+ createTime: number;
10
+ updateTime: number;
11
+ }
@@ -0,0 +1,44 @@
1
+ /** 纯色,或由 CSS linear-gradient 解析出的渐变(文本卡片常用渐变底) */
2
+ export type SchematicFill = string | {
3
+ angle: number;
4
+ stops: Array<{
5
+ color: string;
6
+ offset: number;
7
+ }>;
8
+ };
9
+ export type SchematicShape = {
10
+ kind: "rect";
11
+ x: number;
12
+ y: number;
13
+ w: number;
14
+ h: number;
15
+ r: number;
16
+ fill: SchematicFill;
17
+ fillOpacity?: number;
18
+ stroke?: string;
19
+ /** 输出像素 */
20
+ strokeWidth?: number;
21
+ } | {
22
+ kind: "path";
23
+ d: string;
24
+ fill?: string;
25
+ fillOpacity?: number;
26
+ stroke?: string;
27
+ strokeOpacity?: number;
28
+ /** 输出像素 */
29
+ strokeWidth?: number;
30
+ /** 归一化路径(0~1)放进元素框:translate(x y) scale(w h) */
31
+ box?: {
32
+ x: number;
33
+ y: number;
34
+ w: number;
35
+ h: number;
36
+ };
37
+ } | {
38
+ /** 箭头端点的三角:尺寸按输出像素,组件按缩放换算 */
39
+ kind: "arrowhead";
40
+ x: number;
41
+ y: number;
42
+ angle: number;
43
+ color: string;
44
+ };
@@ -0,0 +1,11 @@
1
+ import type { BoardElement } from "./element";
2
+ import { Point } from "./point";
3
+ export interface SelectArea {
4
+ anchor: Point;
5
+ focus: Point;
6
+ }
7
+ export interface Selection {
8
+ selectArea: SelectArea | null;
9
+ selectedElements: BoardElement[];
10
+ [key: string]: any;
11
+ }
@@ -0,0 +1,25 @@
1
+ /** 页面画风:手绘 / 普通(D-107) */
2
+ export type SketchMode = "sketch" | "normal";
3
+ /** 笔触档位:工整 / 自然 / 潦草 */
4
+ export type SketchLevel = "neat" | "natural" | "loose";
5
+ /** 形状填充样式;普通模式下一律按实色渲染 */
6
+ export type SketchFillStyle = "solid" | "hatch" | "cross" | "scribble";
7
+ /** 页级画风,存在 WhiteBoardContent.data.sketch,缺省为 DEFAULT_PAGE_SKETCH */
8
+ export interface PageSketch {
9
+ mode: SketchMode;
10
+ level: SketchLevel;
11
+ }
12
+ /** 元素级覆盖;未设置的字段跟随页面 */
13
+ export interface ElementSketch {
14
+ mode?: SketchMode;
15
+ level?: SketchLevel;
16
+ /** 「换一笔」写入;缺省时由元素 id 派生 */
17
+ seed?: number;
18
+ }
19
+ export declare const DEFAULT_PAGE_SKETCH: PageSketch;
20
+ /** 生效画风:页面默认值与元素覆盖合成后的结果 */
21
+ export interface ResolvedSketch {
22
+ enabled: boolean;
23
+ level: SketchLevel;
24
+ seed: number;
25
+ }
@@ -0,0 +1,8 @@
1
+ export interface ViewPort {
2
+ minX: number;
3
+ minY: number;
4
+ width: number;
5
+ height: number;
6
+ zoom: number;
7
+ [key: string]: any;
8
+ }
@@ -0,0 +1,22 @@
1
+ export type Vec = [number, number];
2
+ export interface Polyline {
3
+ points: Vec[];
4
+ closed: boolean;
5
+ }
6
+ export declare const distance: (a: Vec, b: Vec) => number;
7
+ export declare const clamp: (value: number, min: number, max: number) => number;
8
+ export declare function lengthOf(points: Vec[]): number;
9
+ export declare const polylineToD: (points: Vec[], closed?: boolean) => string;
10
+ /** 按弧长等距重采样,首尾点保留 */
11
+ export declare function resample(points: Vec[], step: number): Vec[];
12
+ /**
13
+ * 沿法线方向的低频摆动:两段正弦按弧长叠加,相位由 random 决定。
14
+ * 摆动是弧长的连续函数,端点移动时线形连续变化,不会整体跳变。
15
+ * waveScale 缩放波长:尺寸很小的图形(火柴人等)传 <1,否则一整笔都落在半个波长内、看不出手抖。
16
+ */
17
+ export declare function wobble(points: Vec[], amplitude: number, random: () => number, waveScale?: number): Vec[];
18
+ /**
19
+ * SVG path d → 折线(每个子路径一条),支持 M/L/H/V/C/S/Q/T/A/Z 的绝对与相对形式。
20
+ * 白板里的几何轮廓与连线路径(ArrowUtil.getArrowPath)都只用到这些命令。
21
+ */
22
+ export declare function flattenPath(d: string): Polyline[];
@@ -0,0 +1,3 @@
1
+ import type { ResolvedSketch } from "../../types/sketch";
2
+ /** 手绘文字容器的类名(D-107);未启用手绘时为空串 */
3
+ export declare const handTextClass: (sketch: ResolvedSketch) => string;
@@ -0,0 +1,13 @@
1
+ import { type Vec } from "./geometry";
2
+ export interface InkOptions {
3
+ /** 起笔 / 收笔渐细长度(px),0 为平头 */
4
+ taperStart?: number;
5
+ taperEnd?: number;
6
+ thinning?: number;
7
+ streamline?: number;
8
+ }
9
+ /**
10
+ * 一笔墨迹的轮廓(填充多边形):起笔略重、行笔饱满、收笔变细,压力带极小噪声。
11
+ * size 为墨迹最大宽度。
12
+ */
13
+ export declare function inkOutline(points: Vec[], size: number, random: () => number, options?: InkOptions): string;
@@ -0,0 +1,5 @@
1
+ import type { SketchLevel } from "../../types/sketch";
2
+ /** 各档位沿法线摆动的幅度(px) */
3
+ export declare const WOBBLE_AMPLITUDE: Record<SketchLevel, number>;
4
+ /** 墨迹宽度:比描边线宽略粗,补偿两端渐细后的视觉重量 */
5
+ export declare const inkSize: (strokeWidth: number) => number;
@@ -0,0 +1,4 @@
1
+ /** 可复现的伪随机数(mulberry32):同一 seed 永远得到同一序列 */
2
+ export declare function createRandom(seed: number): () => number;
3
+ /** 字符串 → 32 位种子(FNV-1a),用于由元素 id 派生默认笔迹 */
4
+ export declare function hashSeed(text: string): number;
@@ -0,0 +1,38 @@
1
+ import type { SketchFillStyle, SketchLevel } from "../../types/sketch";
2
+ import { type Polyline, type Vec } from "./geometry";
3
+ import type { SketchPath } from "./types";
4
+ export type SketchOutline = {
5
+ kind: "rect";
6
+ cornerRadius?: number;
7
+ } | {
8
+ kind: "ellipse";
9
+ }
10
+ /** 已缩放到元素尺寸的 path d(几何配置经 transformPath 的结果) */
11
+ | {
12
+ kind: "path";
13
+ paths: string[];
14
+ };
15
+ export interface SketchShapeInput {
16
+ outline: SketchOutline;
17
+ width: number;
18
+ height: number;
19
+ stroke?: string;
20
+ strokeWidth: number;
21
+ strokeOpacity?: number;
22
+ fill?: string;
23
+ fillOpacity?: number;
24
+ fillStyle?: SketchFillStyle;
25
+ /** 描边线型:只对圆角矩形生效;缺省实线 */
26
+ strokeDash?: "dashed" | "dotted";
27
+ /** 淡涂叠在纸上的不透明度系数,缺省 WASH_ALPHA;底色承载文字对比度时(导图节点)传 1 */
28
+ washAlpha?: number;
29
+ level: SketchLevel;
30
+ seed: number;
31
+ }
32
+ export declare function outlinePolylines(outline: SketchOutline, width: number, height: number): Polyline[];
33
+ /** 闭合轮廓一笔绕一圈:随机起点,末尾一小段向外搭接,形成手绘的收口 */
34
+ export declare function loopStroke(loop: Vec[], amplitude: number, random: () => number, overlapRatio?: number): Vec[];
35
+ /** 排线间距随线宽变粗、随形状尺寸微调:大形状不稀、小形状不糊 */
36
+ export declare const hatchGap: (strokeWidth: number, width: number, height: number) => number;
37
+ /** 形状的手绘渲染:填充在下、轮廓墨迹在上。坐标系为元素局部坐标(0,0 ~ width,height) */
38
+ export declare function sketchShape(input: SketchShapeInput): SketchPath[];
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 手绘渲染的输出单元:纯数据,由组件渲染为 <path>。
3
+ * - ink:墨迹(填充多边形)
4
+ * - wash:淡涂填充
5
+ * - lines:线类填充(斜线 / 交叉 / 涂鸦),深色主题下需要再退一步
6
+ */
7
+ export interface SketchPath {
8
+ role: "ink" | "wash" | "lines";
9
+ d: string;
10
+ color: string;
11
+ opacity?: number;
12
+ /** 限制在此轮廓内(线类填充) */
13
+ clip?: string;
14
+ /** 虚线遮罩:沿中心线描粗虚线,墨迹只露出虚线段;可多段(各自节奏) */
15
+ dashMask?: DashMask[];
16
+ }
17
+ export interface DashMask {
18
+ d: string;
19
+ width: number;
20
+ dash: number;
21
+ gap: number;
22
+ /** stroke-dashoffset,缺省 0 */
23
+ offset?: number;
24
+ }