@fulate/ui 1.0.19 → 3.0.2
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/README.md +130 -177
- package/dist/circle.d.ts +2 -1
- package/dist/connection/commands.d.ts +3 -3
- package/dist/connection/types.d.ts +5 -1
- package/dist/connection-port-decoration.d.ts +18 -2
- package/dist/editor/capability.d.ts +37 -6
- package/dist/editor/frame-flush.d.ts +3 -4
- package/dist/editor/properties.d.ts +31 -0
- package/dist/editor/shape-capability.d.ts +13 -0
- package/dist/editor/shape.d.ts +16 -19
- package/dist/editor/transform.d.ts +1 -3
- package/dist/editor-vector-path.d.ts +70 -0
- package/dist/floating.d.ts +12 -2
- package/dist/group.d.ts +17 -8
- package/dist/image.d.ts +16 -19
- package/dist/index.d.ts +15 -6
- package/dist/index.js +2757 -1555
- package/dist/line/base.d.ts +64 -27
- package/dist/line/geometry.d.ts +28 -0
- package/dist/line/index.d.ts +2 -0
- package/dist/line/label.d.ts +58 -0
- package/dist/line/orthogonal.d.ts +23 -0
- package/dist/line/serialization.d.ts +11 -0
- package/dist/line/straight.d.ts +7 -3
- package/dist/line-tree/history-delta.d.ts +2 -0
- package/dist/line-tree/index.d.ts +15 -8
- package/dist/line-tree/serialization.d.ts +2 -0
- package/dist/line-tree/transform.d.ts +1 -0
- package/dist/line-tree/types.d.ts +3 -2
- package/dist/polygon.d.ts +19 -38
- package/dist/rectangle.d.ts +5 -4
- package/dist/ripple.d.ts +18 -4
- package/dist/scrollbars.d.ts +36 -0
- package/dist/scrollview.d.ts +27 -21
- package/dist/serialization.d.ts +4 -0
- package/dist/text/block.d.ts +5 -1
- package/dist/text/editing.d.ts +54 -12
- package/dist/text/index.d.ts +22 -20
- package/dist/text/layout.d.ts +8 -2
- package/dist/text/paint.d.ts +3 -2
- package/dist/text/style.d.ts +4 -0
- package/dist/triangle.d.ts +10 -5
- package/dist/worker-surface-worker.d.ts +4 -1
- package/dist/worker-surface-worker.js +11 -8
- package/dist/worker-surface.d.ts +1 -0
- package/dist/workspace.d.ts +3 -3
- package/package.json +33 -33
- package/dist/authored-path.d.ts +0 -28
- package/dist/vector-path.d.ts +0 -58
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PointView, Rect } from "@fulate/share";
|
|
2
|
+
/** 滚动条样式。 */
|
|
3
|
+
export interface ScrollbarOptions {
|
|
4
|
+
/** 条宽,单位为所属容器坐标,默认 6。 */
|
|
5
|
+
scrollbarSize?: number;
|
|
6
|
+
/** 滑块颜色,默认 rgba(0,0,0,0.35)。 */
|
|
7
|
+
scrollbarColor?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const SCROLLBAR_DEFAULTS: {
|
|
10
|
+
readonly scrollbarSize: 6;
|
|
11
|
+
readonly scrollbarColor: "rgba(0,0,0,0.35)";
|
|
12
|
+
};
|
|
13
|
+
interface ScrollMetrics extends ScrollbarOptions {
|
|
14
|
+
readonly width: number | undefined;
|
|
15
|
+
readonly height: number | undefined;
|
|
16
|
+
readonly contentWidth: number;
|
|
17
|
+
readonly contentHeight: number;
|
|
18
|
+
readonly scrollX: number;
|
|
19
|
+
readonly scrollY: number;
|
|
20
|
+
}
|
|
21
|
+
/** 滚动条的派生投影与临时拖拽;不持有滚动位置或监听 DOM。 */
|
|
22
|
+
export declare class Scrollbars {
|
|
23
|
+
private x;
|
|
24
|
+
private y;
|
|
25
|
+
private drag?;
|
|
26
|
+
project(metrics: ScrollMetrics): void;
|
|
27
|
+
paint(ctx: CanvasRenderingContext2D, style: ScrollbarOptions): void;
|
|
28
|
+
/** 当前轨道的只读几何;未溢出的方向没有轨道。 */
|
|
29
|
+
getTrack(axis: "x" | "y"): Readonly<Rect> | undefined;
|
|
30
|
+
hitThumb(point: PointView): "x" | "y" | undefined;
|
|
31
|
+
startDrag(point: PointView): boolean;
|
|
32
|
+
moveDrag(point: PointView, metrics: ScrollMetrics): PointView | undefined;
|
|
33
|
+
get dragging(): boolean;
|
|
34
|
+
endDrag(): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
package/dist/scrollview.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { PaintContext } from "@fulate/core";
|
|
2
|
+
import { CustomEvent, type Layer, type PropertyChanges, type Root, type RootFrameLayoutOwner } from "@fulate/core";
|
|
2
3
|
import { Rectangle, RectangleProperties, RectangleTransform, type RectangleOption } from "./rectangle";
|
|
3
4
|
import { type PointView, type ReadonlyMatrix2D } from "@fulate/share";
|
|
4
|
-
|
|
5
|
+
import { type ScrollbarOptions } from "./scrollbars";
|
|
6
|
+
export interface ScrollViewOption extends RectangleOption<ScrollView>, ScrollbarOptions {
|
|
5
7
|
scrollX?: number;
|
|
6
8
|
scrollY?: number;
|
|
9
|
+
/** Initial range before the first layout; layout replaces it with child extent. */
|
|
7
10
|
contentWidth?: number;
|
|
11
|
+
/** Initial range before the first layout; layout replaces it with child extent. */
|
|
8
12
|
contentHeight?: number;
|
|
9
13
|
maxWidth?: number;
|
|
10
14
|
maxHeight?: number;
|
|
11
|
-
scrollbarSize?: number;
|
|
12
|
-
scrollbarColor?: string;
|
|
13
|
-
scrollbarTrackColor?: string;
|
|
14
15
|
scrollEndThreshold?: number;
|
|
15
16
|
}
|
|
16
17
|
declare class ScrollViewProperties extends RectangleProperties {
|
|
@@ -20,49 +21,54 @@ declare class ScrollViewProperties extends RectangleProperties {
|
|
|
20
21
|
maxHeight?: number;
|
|
21
22
|
scrollbarSize: number;
|
|
22
23
|
scrollbarColor: string;
|
|
23
|
-
scrollbarTrackColor: string;
|
|
24
24
|
scrollEndThreshold: number;
|
|
25
25
|
constructor(options?: ScrollViewOption);
|
|
26
|
-
getImpact(changes: PropertyChanges):
|
|
26
|
+
getImpact(changes: PropertyChanges): number;
|
|
27
27
|
}
|
|
28
|
-
export declare class ScrollViewTransform<E extends ScrollView = ScrollView> extends RectangleTransform<E> {
|
|
28
|
+
export declare class ScrollViewTransform<E extends ScrollView = ScrollView> extends RectangleTransform<E> implements RootFrameLayoutOwner {
|
|
29
29
|
private readonly childWorldMatrix;
|
|
30
|
+
private contentExtentDirty;
|
|
31
|
+
get key(): string;
|
|
32
|
+
activate(): void;
|
|
30
33
|
protected onChildrenChanged(): void;
|
|
31
34
|
protected onDescendantDirty(): void;
|
|
32
35
|
protected getChildWorldMatrixView(): ReadonlyMatrix2D;
|
|
33
|
-
|
|
36
|
+
flushLayout(): void;
|
|
37
|
+
updateTransform(parentLayoutDirty?: boolean): void;
|
|
34
38
|
}
|
|
35
39
|
export declare class ScrollView extends Rectangle<ScrollViewProperties, ScrollViewOption> {
|
|
36
40
|
readonly type = "scrollview";
|
|
41
|
+
readonly transform: ScrollViewTransform<this>;
|
|
37
42
|
get scrollX(): number;
|
|
38
43
|
get scrollY(): number;
|
|
39
44
|
get maxWidth(): number;
|
|
40
45
|
get maxHeight(): number;
|
|
41
46
|
get scrollbarSize(): number;
|
|
42
47
|
get scrollbarColor(): string;
|
|
43
|
-
get scrollbarTrackColor(): string;
|
|
44
48
|
get scrollEndThreshold(): number;
|
|
49
|
+
/** Current direct-child extent after layout; constructor seeds are valid before it. */
|
|
45
50
|
contentWidth: number;
|
|
51
|
+
/** Current direct-child extent after layout; constructor seeds are valid before it. */
|
|
46
52
|
contentHeight: number;
|
|
47
|
-
private
|
|
48
|
-
private
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
private readonly scrollbars;
|
|
54
|
+
private readonly clampScroll;
|
|
55
|
+
/** 几何 owner 发现滚动范围变化后,把归位意图交给下一 RAF 的 R0。 @internal */
|
|
56
|
+
updateScrollClamp(): void;
|
|
57
|
+
/** @internal 统一在 R2 更新 scrollbar 绘制与命中使用的投影。 */
|
|
58
|
+
scheduleScrollbarProjection(): void;
|
|
59
|
+
protected onPropertiesInstalled(current: ScrollViewProperties, changes: PropertyChanges): void;
|
|
54
60
|
constructor(options?: ScrollViewOption);
|
|
55
|
-
protected fireCallbacks(event: CustomEvent): void;
|
|
56
|
-
protected onActivate(root: Root | null, layer: Layer | null): void;
|
|
61
|
+
protected fireCallbacks(event: CustomEvent, capture: boolean): void;
|
|
57
62
|
protected onDeactivate(root: Root | null, layer: Layer | null): void;
|
|
58
63
|
getChildClipRect(): Readonly<import("@fulate/share").Rect>;
|
|
59
64
|
/** ScrollView paints a rectangular viewport even when its border is rounded. */
|
|
60
65
|
containsChildClipPoint(point: PointView): boolean;
|
|
66
|
+
protected applyChildClip(ctx: CanvasRenderingContext2D): void;
|
|
61
67
|
scrollTo(x: number, y: number): void;
|
|
62
68
|
scrollBy(dx: number, dy: number): void;
|
|
63
|
-
protected paintHost(
|
|
69
|
+
protected paintHost(paint: PaintContext): void;
|
|
70
|
+
private readonly projectScrollbars;
|
|
64
71
|
protected paintScrollbars(ctx: CanvasRenderingContext2D): void;
|
|
65
|
-
private hitThumb;
|
|
66
72
|
private initDragInteraction;
|
|
67
73
|
}
|
|
68
74
|
export {};
|
package/dist/text/block.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ export declare class TextBlock {
|
|
|
27
27
|
private snapshot;
|
|
28
28
|
private snapshotKey;
|
|
29
29
|
get layout(): TextLayoutSnapshot;
|
|
30
|
+
/** Borrow the final snapshot while its owner's layout inputs are unchanged. */
|
|
31
|
+
get cachedLayout(): TextLayoutSnapshot;
|
|
32
|
+
/** Preserve prepared text and metrics when only final layout inputs change. */
|
|
33
|
+
invalidateLayout(): void;
|
|
30
34
|
/** Yoga 只需要这个紧凑结果;这里不生成 PaintLine/source range。 */
|
|
31
35
|
measure(input: TextBlockLayoutInput): TextLayoutMetrics;
|
|
32
36
|
/** Final width 已确定后生成一次 PaintLine snapshot,后续直接复用。 */
|
|
@@ -36,4 +40,4 @@ export declare class TextBlock {
|
|
|
36
40
|
private getLayoutKey;
|
|
37
41
|
}
|
|
38
42
|
/** Return visual bounds for the same snapshot consumed by `paintTextBlock`. */
|
|
39
|
-
export declare function getTextBlockVisualBounds(layout: TextLayoutSnapshot, style: Readonly<ResolvedTextStyle>, width: number, height: number): Rect | null;
|
|
43
|
+
export declare function getTextBlockVisualBounds(layout: TextLayoutSnapshot, style: Readonly<ResolvedTextStyle>, width: number, height: number, includeShadow?: boolean): Rect | null;
|
package/dist/text/editing.d.ts
CHANGED
|
@@ -1,16 +1,58 @@
|
|
|
1
|
+
import { type Element, type ElementTransform } from "@fulate/core";
|
|
1
2
|
import type { PointView } from "@fulate/share";
|
|
2
3
|
import type { Text } from "./index";
|
|
4
|
+
import type { TextLayoutSnapshot } from "./layout";
|
|
5
|
+
import type { ResolvedTextStyle } from "./style";
|
|
3
6
|
import type { ContentEditingConsumer } from "../editor/capability";
|
|
4
|
-
declare const SELECTION_COLOR = "rgba(66, 133, 244, 0.3)";
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
export declare const SELECTION_COLOR = "rgba(66, 133, 244, 0.3)";
|
|
8
|
+
/** Shared content read by the canvas text painter and the DOM input owner. */
|
|
9
|
+
export interface EditableTextContent {
|
|
10
|
+
readonly text: string;
|
|
11
|
+
readonly editable: boolean;
|
|
12
|
+
readonly width: number | undefined;
|
|
13
|
+
readonly height: number | undefined;
|
|
14
|
+
readonly overflow: "hidden" | "visible";
|
|
15
|
+
readonly textLayout: TextLayoutSnapshot;
|
|
16
|
+
readonly placeholder: string;
|
|
17
|
+
readonly placeholderColor: string;
|
|
18
|
+
getResolvedTextStyle(): ResolvedTextStyle;
|
|
19
|
+
getPlaceholderMetrics(): TextMetrics;
|
|
20
|
+
setEditingText(value: string): void;
|
|
21
|
+
}
|
|
22
|
+
/** The current text frame, shared with painting and hit testing. */
|
|
23
|
+
export type TextEditingGeometry = Pick<ElementTransform, "getWorldMatrixView" | "toLocal" | "hasPointHint">;
|
|
24
|
+
/** Owns only the current DOM/IME/caret interaction; authored text stays with owner. */
|
|
25
|
+
export declare class TextEditor {
|
|
26
|
+
private readonly owner;
|
|
27
|
+
private readonly content;
|
|
28
|
+
private readonly geometry;
|
|
29
|
+
textarea: HTMLTextAreaElement | null;
|
|
30
|
+
private editingConsumer;
|
|
31
|
+
private editAbort;
|
|
32
|
+
private editSubscriptionRemove;
|
|
33
|
+
private editProjection;
|
|
34
|
+
caretVisible: boolean;
|
|
35
|
+
private blinkTimer;
|
|
36
|
+
private composing;
|
|
37
|
+
scrollX: number;
|
|
38
|
+
private selAnchor;
|
|
39
|
+
constructor(owner: Element, content: EditableTextContent, geometry?: TextEditingGeometry);
|
|
40
|
+
get isEditing(): boolean;
|
|
41
|
+
getCaretLocalXY(caretIndex: number): {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
h: number;
|
|
45
|
+
};
|
|
46
|
+
private hitTestCaret;
|
|
47
|
+
private ensureCaretVisible;
|
|
48
|
+
private updateTextareaPosition;
|
|
49
|
+
private scheduleEditingProjection;
|
|
50
|
+
private syncFromTextarea;
|
|
51
|
+
syncValue(value: string): void;
|
|
52
|
+
private restartBlink;
|
|
53
|
+
private stopBlink;
|
|
54
|
+
enter(initialClickLocal?: PointView, consumer?: ContentEditingConsumer | null): HTMLTextAreaElement;
|
|
55
|
+
finish(): void;
|
|
56
|
+
close(): void;
|
|
57
|
+
}
|
|
16
58
|
export declare function setupClickToEdit(self: Text): (() => void) | null;
|
package/dist/text/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { PaintContext } from "@fulate/core";
|
|
2
|
+
import { type ElementTransformClass, type GeometrySnapshot, type Layer, type PropertyChanges, type Root, type ShadowOption } from "@fulate/core";
|
|
2
3
|
import { Rectangle, RectangleProperties, RectangleTransform, type RectangleOption } from "../rectangle";
|
|
3
4
|
import { type BackgroundColor, type PointView, type Rect } from "@fulate/share";
|
|
4
5
|
import { type TextLineBoxMetrics } from "./paint";
|
|
@@ -62,22 +63,23 @@ export declare class TextProperties extends RectangleProperties {
|
|
|
62
63
|
textStrokeWidth?: number;
|
|
63
64
|
textShadow?: Readonly<ShadowOption> | null;
|
|
64
65
|
constructor(options?: TextOption);
|
|
65
|
-
getImpact(changes: PropertyChanges):
|
|
66
|
+
getImpact(changes: PropertyChanges): number;
|
|
66
67
|
}
|
|
67
68
|
export declare class TextTransform<E extends Text = Text> extends RectangleTransform<E> {
|
|
68
|
-
protected
|
|
69
|
-
protected buildVisualBounds(snapshot: GeometrySnapshot): Readonly<Rect> | null;
|
|
69
|
+
protected buildVisualBounds(snapshot: GeometrySnapshot, includeShadow?: boolean): Readonly<Rect> | null;
|
|
70
70
|
protected buildVisualOutline(snapshot: GeometrySnapshot): PointView[];
|
|
71
71
|
}
|
|
72
72
|
export declare class Text<P extends TextProperties = TextProperties, O extends TextOption<any> = TextOption<any>> extends Rectangle<P, O> {
|
|
73
73
|
readonly type = "text";
|
|
74
|
+
get width(): number;
|
|
75
|
+
get height(): number;
|
|
74
76
|
get text(): string;
|
|
75
77
|
get fontSize(): number;
|
|
76
78
|
get fontFamily(): string;
|
|
77
79
|
get fontWeight(): string | number;
|
|
78
80
|
get fontStyle(): string;
|
|
79
81
|
get color(): BackgroundColor;
|
|
80
|
-
get textAlign(): "
|
|
82
|
+
get textAlign(): "center" | "left" | "right";
|
|
81
83
|
get textBaseline(): CanvasTextBaseline;
|
|
82
84
|
get verticalAlign(): "top" | "bottom" | "middle";
|
|
83
85
|
get underline(): boolean;
|
|
@@ -93,16 +95,9 @@ export declare class Text<P extends TextProperties = TextProperties, O extends T
|
|
|
93
95
|
get textStrokeColor(): BackgroundColor;
|
|
94
96
|
get textStrokeWidth(): number;
|
|
95
97
|
get textShadow(): Readonly<ShadowOption>;
|
|
98
|
+
private textEditor;
|
|
96
99
|
get isEditing(): boolean;
|
|
97
|
-
textarea: HTMLTextAreaElement
|
|
98
|
-
editingConsumer: ContentEditingConsumer | null;
|
|
99
|
-
editAbort: AbortController | null;
|
|
100
|
-
editSubscriptionRemove: (() => void) | null;
|
|
101
|
-
caretVisible: boolean;
|
|
102
|
-
blinkTimer: ReturnType<typeof setInterval> | null;
|
|
103
|
-
composing: boolean;
|
|
104
|
-
scrollX: number;
|
|
105
|
-
selAnchor: number;
|
|
100
|
+
get textarea(): HTMLTextAreaElement;
|
|
106
101
|
private clickToEditRemove;
|
|
107
102
|
private skinTextCommitRemove;
|
|
108
103
|
private textMeasurementRemove;
|
|
@@ -110,12 +105,14 @@ export declare class Text<P extends TextProperties = TextProperties, O extends T
|
|
|
110
105
|
private resolvedTextStyleCache;
|
|
111
106
|
private textLineBoxMetricsCache;
|
|
112
107
|
private readonly textBlock;
|
|
108
|
+
private placeholderMetrics;
|
|
113
109
|
constructor(options?: NoInfer<O>, properties?: P, Transform?: ElementTransformClass);
|
|
114
110
|
getEditorCapability<T>(token: EditorCapabilityToken<T>): T | undefined;
|
|
115
111
|
beginContentEditing(consumer: ContentEditingConsumer): ContentEditingSession | undefined;
|
|
116
112
|
get fontString(): string;
|
|
117
113
|
getResolvedTextStyle(): ResolvedTextStyle;
|
|
118
114
|
getFontString(style?: Required<TextStyleConfig>): string;
|
|
115
|
+
/** Pure cached layout shared by dimensions, geometry, paint and editing. */
|
|
119
116
|
get textLayout(): import("./layout").TextLayoutSnapshot;
|
|
120
117
|
/** @internal Shared by TextRow layout and the final Text painter. */
|
|
121
118
|
getTextLineBoxMetrics(): TextLineBoxMetrics;
|
|
@@ -128,23 +125,28 @@ export declare class Text<P extends TextProperties = TextProperties, O extends T
|
|
|
128
125
|
get textHeight(): number;
|
|
129
126
|
protected getLayoutWidth(): number;
|
|
130
127
|
protected getResolvedHeight(): number;
|
|
131
|
-
syncTextLayout(): void;
|
|
132
|
-
/** 布局 owner 提交 Text 自身的 intrinsic size;派生布局可覆写为只采用其 resolved frame。 */
|
|
133
|
-
protected commitTextLayoutSize(width: number | undefined, height: number | undefined): void;
|
|
134
128
|
/** @internal Shared by Yoga Span and the canvas Text owner. */
|
|
135
129
|
measureTextLayout(width: number, height?: number): import("./layout").TextLayoutMetrics;
|
|
136
130
|
/** @internal TextTransform 消费现有 Text layout owner 的 visual bounds。 */
|
|
137
|
-
getVisibleTextBounds(): Rect | null;
|
|
131
|
+
getVisibleTextBounds(includeShadow?: boolean): Rect | null;
|
|
132
|
+
/** @internal Native placeholder metrics shared by bounds and paint until its input changes. */
|
|
133
|
+
getPlaceholderMetrics(): TextMetrics;
|
|
134
|
+
/** Enters editing synchronously using prepared Text layout and world geometry. */
|
|
138
135
|
enterEditing(initialClickLocal?: PointView): void;
|
|
139
136
|
exitEditing(): void;
|
|
140
137
|
/** 更新文本属性,并同步当前正在使用的 textarea。 */
|
|
141
138
|
setEditingText(value: string): void;
|
|
139
|
+
protected onPropertiesInstalled(current: P, changes: PropertyChanges): void;
|
|
142
140
|
protected onPropertiesChanged(current: P, changes: PropertyChanges): void;
|
|
143
141
|
protected onActivate(root: Root | null, layer: Layer | null): void;
|
|
144
142
|
protected onDeactivate(root: Root | null, layer: Layer | null): void;
|
|
143
|
+
/** Final frame owners invalidate the shared snapshot after installing new dimensions. */
|
|
144
|
+
protected invalidateTextLayout(): void;
|
|
145
|
+
private readonly handleSkinTextChanged;
|
|
146
|
+
private readonly invalidateTextMeasurement;
|
|
145
147
|
private readonly handleTextMeasurementChanged;
|
|
146
148
|
/** @internal Layout owners such as Span use this to invalidate Yoga. */
|
|
147
149
|
protected onTextLayoutInvalidated(): void;
|
|
148
|
-
protected paintTextContent(
|
|
149
|
-
protected paintContent(
|
|
150
|
+
protected paintTextContent(paint: PaintContext, offsetY?: number): void;
|
|
151
|
+
protected paintContent(paint: PaintContext): void;
|
|
150
152
|
}
|
package/dist/text/layout.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export interface TextLayoutMetrics {
|
|
|
43
43
|
readonly maxLineWidth: number;
|
|
44
44
|
readonly truncated: boolean;
|
|
45
45
|
}
|
|
46
|
+
/** @internal Native width and alphabetic glyph ink from the same measurement. */
|
|
47
|
+
export declare function measureTextMetrics(text: string, font: string, letterSpacing?: number): TextMetrics;
|
|
46
48
|
/**
|
|
47
49
|
* Resolve one line box from a native Canvas measurement. The font bounding
|
|
48
50
|
* box is stable for the font state, while `alphabeticBaseline` translates the
|
|
@@ -72,7 +74,7 @@ declare class PreparedTextLayout {
|
|
|
72
74
|
readonly letterSpacing: number;
|
|
73
75
|
readonly normalizedText: string;
|
|
74
76
|
readonly naturalWidth: number;
|
|
75
|
-
private readonly
|
|
77
|
+
private readonly plainMetrics;
|
|
76
78
|
private prepared;
|
|
77
79
|
constructor(text: string, font: string, letterSpacing: number);
|
|
78
80
|
measure(options: TextLayoutOptions): TextLayoutMetrics;
|
|
@@ -96,7 +98,9 @@ export declare class TextLayoutSnapshot {
|
|
|
96
98
|
readonly rawLineCount: number;
|
|
97
99
|
readonly truncated: boolean;
|
|
98
100
|
readonly maxLineWidth: number;
|
|
101
|
+
private readonly plainMetrics?;
|
|
99
102
|
readonly textHeight: number;
|
|
103
|
+
private lineInkMetrics;
|
|
100
104
|
private readonly lineCaretMetrics;
|
|
101
105
|
private readonly lineSourceRanges;
|
|
102
106
|
private readonly preparedSegments;
|
|
@@ -104,8 +108,10 @@ export declare class TextLayoutSnapshot {
|
|
|
104
108
|
private segmentStarts;
|
|
105
109
|
private segmentBoundaries;
|
|
106
110
|
private lineCharOffsetsCache;
|
|
107
|
-
constructor(normalizedText: string, font: string, letterSpacing: number, lineHeight: number, naturalWidth: number, preparedSegments: readonly string[], rawLineCount: number, truncated: boolean, lines: readonly SnapshotLine[], maxLineWidth: number);
|
|
111
|
+
constructor(normalizedText: string, font: string, letterSpacing: number, lineHeight: number, naturalWidth: number, preparedSegments: readonly string[], rawLineCount: number, truncated: boolean, lines: readonly SnapshotLine[], maxLineWidth: number, plainMetrics?: TextMetrics);
|
|
108
112
|
get lines(): readonly TextLayoutLine[];
|
|
113
|
+
/** Alphabetic glyph ink; plain lines reuse their prepared native measurement. */
|
|
114
|
+
getLineInkMetrics(): readonly TextMetrics[];
|
|
109
115
|
get lineCharOffsets(): readonly number[];
|
|
110
116
|
static empty(): TextLayoutSnapshot;
|
|
111
117
|
getLineSourceRange(index: number): TextLineSourceRange;
|
package/dist/text/paint.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { PaintContext } from "@fulate/core";
|
|
1
2
|
import { type TextLayoutSnapshot, type TextLineBoxMetrics } from "./layout";
|
|
2
|
-
import type
|
|
3
|
+
import { type EditableTextContent, type TextEditor } from "./editing";
|
|
3
4
|
import { type ResolvedTextStyle } from "./style";
|
|
4
5
|
import type { ShadowOption, TextStyleConfig } from "@fulate/core";
|
|
5
6
|
export type { TextLineBoxMetrics } from "./layout";
|
|
@@ -55,4 +56,4 @@ export declare function measureTextLineBoxMetrics(style: ResolvedTextStyle): Tex
|
|
|
55
56
|
* same snapshot for `getTextBlockVisualBounds`.
|
|
56
57
|
*/
|
|
57
58
|
export declare function paintTextBlock(ctx: CanvasRenderingContext2D, layout: TextLayoutSnapshot, style: Readonly<ResolvedTextStyle>, width: number, height: number): void;
|
|
58
|
-
export declare function paintTextContent(self:
|
|
59
|
+
export declare function paintTextContent(self: EditableTextContent, paint: PaintContext, offsetY?: number, editor?: TextEditor): void;
|
package/dist/text/style.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { ChangeImpact } from "@fulate/core";
|
|
1
2
|
import type { TextStyleConfig } from "@fulate/core";
|
|
2
3
|
export type { TextStyleConfig };
|
|
3
4
|
export type ResolvedTextStyle = Required<TextStyleConfig>;
|
|
4
5
|
export declare const TEXT_STYLE_DEFAULTS: Required<TextStyleConfig>;
|
|
5
6
|
export declare const TEXT_STYLE_KEYS: readonly TextStyleKey[];
|
|
6
7
|
export type TextStyleKey = keyof TextStyleConfig;
|
|
8
|
+
export declare const TEXT_LAYOUT_STYLE_KEYS: Set<string>;
|
|
9
|
+
/** Shared by authored text properties and Skin-dependent text owners. */
|
|
10
|
+
export declare function getTextStyleImpact(key: string): ChangeImpact;
|
|
7
11
|
export declare function buildFontString(style: {
|
|
8
12
|
fontStyle?: string;
|
|
9
13
|
fontWeight?: string | number;
|
package/dist/triangle.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type EditorShapeOption } from "./editor/properties";
|
|
1
2
|
import { type Edge, type PointView } from "@fulate/share";
|
|
2
3
|
import { type GeometrySnapshot } from "@fulate/core";
|
|
3
4
|
import { EditorShape, EditorShapeTransform } from "./editor/shape";
|
|
@@ -7,14 +8,18 @@ export declare class TriangleTransform<E extends Triangle = Triangle> extends Ed
|
|
|
7
8
|
}
|
|
8
9
|
export declare class Triangle extends EditorShape {
|
|
9
10
|
readonly type = "triangle";
|
|
10
|
-
constructor(options?:
|
|
11
|
+
constructor(options?: EditorShapeOption);
|
|
11
12
|
protected buildPath(ctx: CanvasRenderingContext2D): void;
|
|
12
13
|
getEdgeSegment(edge: Edge): {
|
|
13
14
|
start: PointView;
|
|
14
15
|
end: PointView;
|
|
15
16
|
};
|
|
16
|
-
protected
|
|
17
|
-
|
|
18
|
-
localPosition:
|
|
19
|
-
|
|
17
|
+
protected getDefaultConnectionPortIds(): readonly string[];
|
|
18
|
+
protected getDefaultConnectionPortGeometry(portId: string): {
|
|
19
|
+
localPosition: PointView;
|
|
20
|
+
localNormal: {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
20
25
|
}
|
|
@@ -8,7 +8,10 @@ export interface WorkerSurfaceFactory<Initialize, Create, Message, Runtime, Outp
|
|
|
8
8
|
}
|
|
9
9
|
/** Installs the shared typed lifecycle in one Worker realm. */
|
|
10
10
|
export declare function runWorkerSurfaceHost<Initialize, Create, Message, Runtime, Output = never>(factory: WorkerSurfaceFactory<Initialize, Create, Message, Runtime, Output>): void;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Coalesces renderer callbacks to one current transferable bitmap frame.
|
|
13
|
+
* Calling emit transfers bitmap ownership to the receiver, including on failure.
|
|
14
|
+
*/
|
|
12
15
|
export declare class BitmapFrameEmitter {
|
|
13
16
|
private readonly getCanvas;
|
|
14
17
|
private readonly emit;
|
|
@@ -26,7 +26,12 @@ function runWorkerSurfaceHost(factory) {
|
|
|
26
26
|
surfaceId,
|
|
27
27
|
bitmap
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
try {
|
|
30
|
+
scope.postMessage(response, [bitmap]);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
bitmap.close();
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
30
35
|
}, (output) => {
|
|
31
36
|
if (surfaces.get(surfaceId) !== entry) return;
|
|
32
37
|
const response = {
|
|
@@ -54,7 +59,10 @@ function runWorkerSurfaceHost(factory) {
|
|
|
54
59
|
}
|
|
55
60
|
};
|
|
56
61
|
}
|
|
57
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Coalesces renderer callbacks to one current transferable bitmap frame.
|
|
64
|
+
* Calling emit transfers bitmap ownership to the receiver, including on failure.
|
|
65
|
+
*/
|
|
58
66
|
var BitmapFrameEmitter = class {
|
|
59
67
|
pending = null;
|
|
60
68
|
queued = false;
|
|
@@ -93,12 +101,7 @@ var BitmapFrameEmitter = class {
|
|
|
93
101
|
bitmap.close();
|
|
94
102
|
return;
|
|
95
103
|
}
|
|
96
|
-
|
|
97
|
-
this.emit(bitmap);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
bitmap.close();
|
|
100
|
-
throw error;
|
|
101
|
-
}
|
|
104
|
+
this.emit(bitmap);
|
|
102
105
|
}).finally(() => {
|
|
103
106
|
this.pending = null;
|
|
104
107
|
if (this.active && !this.paused && this.queued) this.flush();
|
package/dist/worker-surface.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface WorkerSurfaceHandle<Message> {
|
|
|
7
7
|
post(message: Message): void;
|
|
8
8
|
dispose(): void;
|
|
9
9
|
}
|
|
10
|
+
/** Takes ownership on invocation, including when the receiver later throws. */
|
|
10
11
|
type FrameReceiver = (bitmap: ImageBitmap) => void;
|
|
11
12
|
type OutputReceiver<Output> = (output: Output) => void;
|
|
12
13
|
/** Pins long-lived bitmap surfaces to a fixed set of homogeneous Workers. */
|
package/dist/workspace.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ElementPayload, type Layer, type Root, type Viewport, type ViewportInsets } from "@fulate/core";
|
|
2
2
|
import { Image, ImageProperties, type ImageOption } from "./image";
|
|
3
3
|
/** @internal 当前 Root 中为 Workspace 自动聚焦提供屏幕边距的唯一 owner。 */
|
|
4
4
|
export type WorkspaceFocusInsetsSource = () => number | ViewportInsets;
|
|
@@ -11,7 +11,6 @@ export interface WorkspaceOption extends Omit<ImageOption<Workspace>, "children"
|
|
|
11
11
|
/** Root 尺寸变化后是否无动画重新聚焦工作区,默认 `true`。 */
|
|
12
12
|
fitOnResize?: boolean;
|
|
13
13
|
}
|
|
14
|
-
export type WorkspaceJSON = Omit<ElementJSON<WorkspaceOption>, "children">;
|
|
15
14
|
/** Workspace 的自有 authored 属性。 */
|
|
16
15
|
export declare class WorkspaceProperties extends ImageProperties {
|
|
17
16
|
/** 首次进入 Root 时是否在首个 Canvas paint 前执行一次无动画聚焦。 */
|
|
@@ -36,7 +35,8 @@ export declare class Workspace extends Image<WorkspaceProperties, WorkspaceOptio
|
|
|
36
35
|
get fit(): boolean;
|
|
37
36
|
get fitOnResize(): boolean;
|
|
38
37
|
/** Workspace 只导出自己的配置,不导出任何子节点。 */
|
|
39
|
-
|
|
38
|
+
getPersistentChildren(): any[];
|
|
39
|
+
toJSON(): ElementPayload;
|
|
40
40
|
protected onDeactivate(root: Root | null, layer: Layer | null): void;
|
|
41
41
|
protected onActivate(root: Root | null, layer: Layer | null): void;
|
|
42
42
|
private focusInsets;
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fulate/ui",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"import": "./dist/index.js"
|
|
11
|
-
},
|
|
12
|
-
"./worker-surface-worker": {
|
|
13
|
-
"types": "./dist/worker-surface-worker.d.ts",
|
|
14
|
-
"import": "./dist/worker-surface-worker.js"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"scripts": {
|
|
22
|
-
"test": "vitest run",
|
|
23
|
-
"test:watch": "vitest"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@chenglou/pretext": "0.0.8",
|
|
27
|
-
"@floating-ui/core": "^1.8.0",
|
|
28
|
-
"@fulate/core": "
|
|
29
|
-
"@fulate/share": "
|
|
30
|
-
"@tweenjs/tween.js": "^25.0.0",
|
|
31
|
-
"lodash-es": "^4.17.22"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@fulate/ui",
|
|
3
|
+
"version": "3.0.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./worker-surface-worker": {
|
|
13
|
+
"types": "./dist/worker-surface-worker.d.ts",
|
|
14
|
+
"import": "./dist/worker-surface-worker.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@chenglou/pretext": "0.0.8",
|
|
27
|
+
"@floating-ui/core": "^1.8.0",
|
|
28
|
+
"@fulate/core": "3.0.2",
|
|
29
|
+
"@fulate/share": "3.0.2",
|
|
30
|
+
"@tweenjs/tween.js": "^25.0.0",
|
|
31
|
+
"lodash-es": "^4.17.22"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/dist/authored-path.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createAuthoredLineSubpath, type AnchorId, type AuthoredSubpath, type SegmentId } from "@fulate/core";
|
|
2
|
-
import { type PointView, type ReadonlyMatrix2D, type Rect } from "@fulate/share";
|
|
3
|
-
export { createAuthoredLineSubpath };
|
|
4
|
-
/** Replace one authored anchor point while retaining its record and all IDs. */
|
|
5
|
-
export declare function replaceAuthoredAnchorPoint(subpath: AuthoredSubpath, anchorId: AnchorId, point: PointView): AuthoredSubpath;
|
|
6
|
-
/** Append one anchor to an open line subpath. */
|
|
7
|
-
export declare function appendAuthoredLineAnchor(subpath: AuthoredSubpath, point: PointView): {
|
|
8
|
-
readonly subpath: AuthoredSubpath;
|
|
9
|
-
readonly anchorId: AnchorId;
|
|
10
|
-
};
|
|
11
|
-
/** Split one authored line/cubic segment, retaining the leading segment ID. */
|
|
12
|
-
export declare function insertAuthoredPathAnchor(subpath: AuthoredSubpath, segmentId: SegmentId, t: number, point: PointView): {
|
|
13
|
-
readonly subpath: AuthoredSubpath;
|
|
14
|
-
readonly anchorId: AnchorId;
|
|
15
|
-
};
|
|
16
|
-
/** Split a line segment at its midpoint for Line and Polygon. */
|
|
17
|
-
export declare function insertAuthoredLineAnchor(subpath: AuthoredSubpath, segmentId: SegmentId, point: PointView): {
|
|
18
|
-
readonly subpath: AuthoredSubpath;
|
|
19
|
-
readonly anchorId: AnchorId;
|
|
20
|
-
};
|
|
21
|
-
/** Replace one cubic segment handle without changing other authored records. */
|
|
22
|
-
export declare function replaceAuthoredCubicHandle(subpath: AuthoredSubpath, segmentId: SegmentId, role: "cubic-control-1" | "cubic-control-2", point: PointView): AuthoredSubpath;
|
|
23
|
-
/** Delete one anchor and merge its predecessor directly to its successor. */
|
|
24
|
-
export declare function removeAuthoredAnchor(subpath: AuthoredSubpath, anchorId: AnchorId, minimumAnchorCount?: number): AuthoredSubpath;
|
|
25
|
-
/** Transform coordinates while retaining every subpath, anchor, segment, and record ID. */
|
|
26
|
-
export declare function transformAuthoredSubpath(subpath: AuthoredSubpath, matrix: ReadonlyMatrix2D): AuthoredSubpath;
|
|
27
|
-
/** Read bounds directly from authored anchor coordinates. */
|
|
28
|
-
export declare function getAuthoredSubpathBounds(subpath: AuthoredSubpath): Readonly<Rect> | null;
|