@fulate/ui 1.0.14 → 1.0.19

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 CHANGED
@@ -6,9 +6,23 @@
6
6
  producer保持authored-local布局;需要超采样时,在自己的backend中基于该倍率增加质量倍率和资源预算。
7
7
  `paintBitmap()`仍把最终位图绘制到图元authored宽高,再由Layer应用Viewport与DPR。
8
8
 
9
+ `Bitmap`也唯一记录renderer最近收到的authored宽高与像素倍率。producer创建renderer时调用
10
+ `startFrameSurface(pixelRatio)`;需要同步尺寸时调用`claimFrameResize(pixelRatio)`,只有尺寸或倍率变化
11
+ 且上一次请求的frame已经`presentBitmap()`时才返回`true`,producer据此发送一次自己的resize消息。
12
+ 等待期间的变化在该frame绘制后按最新值发送,renderer同时最多处理一次待完成的尺寸请求。
13
+
9
14
  位图、DPR和超采样质量都不改变逻辑坐标。鼠标与Worker返回的坐标保持authored-local,不经过
10
15
  `Bitmap`的scale换算。
11
16
 
17
+ ## Image 尺寸与加载
18
+
19
+ `Image` 未提供尺寸时使用当前源的 `naturalWidth`/`naturalHeight`;`fitWidth`/`fitHeight` 使用父元素布局尺寸,显式
20
+ `width`/`height` 优先且保留 `0`。源的 intrinsic 尺寸变化进入同一 geometry/layout 提交,位图分辨率
21
+ 升级只重绘,不改变逻辑尺寸。
22
+
23
+ `src` 与构造时提供的 `image` 使用同一加载路径;切换源、detach、重新进入和 unmount 都使旧处理
24
+ 结果失效。晚到的旧 bitmap 会被释放,不覆盖当前源。
25
+
12
26
  ## Workspace fit
13
27
 
14
28
  `WorkspaceOption.fit`控制首次进入Root时的自动聚焦,`WorkspaceOption.fitOnResize`控制Root尺寸
@@ -133,9 +147,8 @@ Rectangle、Triangle及其他Shape省略`backgroundColor`/`borderColor`时读取
133
147
  `skin.lineStroke`。显式值始终优先,Shape的显式`null`关闭绘制,显式字段清回`undefined`后立即重新
134
148
  继承Skin。Skin改变只触发现有Root/Layer重绘,不改写element、branch topology或History。
135
149
 
136
- LineTree整体resize把全部拓扑点按完整仿射写回 authored topology。随后Point移动或插入anchor时在
137
- 同一owner change内保留当前world pose;包括反向scale在内,只有目标anchor改变world位置,其他points
138
- 保持不动。
150
+ LineTree整体resize把全部拓扑点按完整仿射写回 authored topology。随后Point编辑和L分支扩展在
151
+ 同一owner change内保留当前world pose;包括反向scale在内,未编辑points保持world位置不变。
139
152
 
140
153
  ## Text 尺寸与显示
141
154
 
@@ -159,13 +172,13 @@ import { measureTextRun } from "@fulate/ui";
159
172
  const metrics = measureTextRun(ctx, text, root.skin.text, 14, 500);
160
173
  ```
161
174
 
162
- 每次调用只执行一次 `ctx.measureText()`,返回 `font`、`width`、`lineHeight`、`drawY`、
163
- `alphabeticBaseline`、`textBaseline` 和 `letterSpacing`。`drawY` 根据原生 Canvas 的
164
- `fontBoundingBoxAscent`/`fontBoundingBoxDescent` 把字体行框放到行框中心;`alphabeticBaseline`
165
- 是同一行框内的规范 alphabetic baseline,因此不同字号的 run 可以直接对齐。空文本的 `width`
166
- 为 `0`,但仍测量一个空格以取得稳定字体度量。函数会把本次测量所需的文字状态写入 `ctx`,不会
167
- 调用 `save()` 或 `restore()`;Canvas 生命周期以及业务特有的文字顺序、对齐和绘制仍由 Shape
168
- 自己拥有。
175
+ 每次调用只执行一次 `ctx.measureText()`,返回 `font`、`width`、`lineHeight`、`drawY`、
176
+ `alphabeticBaseline`、`textBaseline` 和 `letterSpacing`。`drawY` 根据原生 Canvas 的
177
+ `fontBoundingBoxAscent`/`fontBoundingBoxDescent` 把字体行框放到行框中心;`alphabeticBaseline`
178
+ 是同一行框内的规范 alphabetic baseline,因此不同字号的 run 可以直接对齐。空文本的 `width`
179
+ 为 `0`,但仍测量一个空格以取得稳定字体度量。函数会把本次测量所需的文字状态写入 `ctx`,不会
180
+ 调用 `save()` 或 `restore()`;Canvas 生命周期以及业务特有的文字顺序、对齐和绘制仍由 Shape
181
+ 自己拥有。
169
182
 
170
183
  ### 组合型多行文本
171
184
 
@@ -238,15 +251,15 @@ const behavior = {
238
251
  };
239
252
  ```
240
253
 
241
- `OwnerDirect` 用于不绘制单选 frame、首次位移可直接提升 owner drag 的自定义对象;Group 使用
242
- `DirectChild` dive,普通 Shape/Line 使用 `Standard`。Transform provider 在 gesture start 捕获 frozen
243
- reference 与领域 owned state,每帧只纯解析最终 owner change;frame-authored Shape、pose-authored
244
- Group 与 authored-geometry Line/Polygon/VectorPath 共用 Core reference-transform primitive,结构化
245
- authored value 不为 caller isolation clone。Group 的稳定 reference 由创建时的 width/height/origin 与
246
- pose 拥有;当前 content bounds 是只读 local derived view。Line/LineTree 的
247
- 固定world paint padding不贡献ancestor content bounds,但仍进入各自render coverage。普通Group
248
- move/rotate只写自身pose;Group或多选resize/flip递归写入子元素的frame或矢量geometry。group/ungroup
249
- 只转换 local pose,保留 width/path/contour/topology、effect 与 relation 的值和引用。
254
+ `OwnerDirect` 用于不绘制单选 frame、首次位移可直接提升 owner drag 的自定义对象;Group 使用
255
+ `DirectChild` dive,普通 Shape/Line 使用 `Standard`。Transform provider 在 gesture start 捕获 frozen
256
+ reference 与领域 owned state,每帧只纯解析最终 owner change;frame-authored Shape、pose-authored
257
+ Group 与 authored-geometry Line/Polygon/VectorPath 共用 Core reference-transform primitive,结构化
258
+ authored value 不为 caller isolation clone。Group 的稳定 reference 由创建时的 width/height/origin 与
259
+ pose 拥有;当前 content bounds 是只读 local derived view。Line/LineTree 的
260
+ 固定world paint padding不贡献ancestor content bounds,但仍进入各自render coverage。普通Group
261
+ move/rotate只写自身pose;Group或多选resize/flip递归写入子元素的frame或矢量geometry。group/ungroup
262
+ 只转换 local pose,保留 width/path/contour/topology、effect 与 relation 的值和引用。
250
263
 
251
264
  `selectable:false`只限制Editor交互选择,并对该owner分支生效:普通点击、marquee、Select All与
252
265
  Group DirectChild下钻都不能进入该分支。公开`Select.select(elements)`和History selection replay由
@@ -1,5 +1,5 @@
1
1
  import { createAuthoredLineSubpath, type AnchorId, type AuthoredSubpath, type SegmentId } from "@fulate/core";
2
- import { type PointView, type Rect } from "@fulate/share";
2
+ import { type PointView, type ReadonlyMatrix2D, type Rect } from "@fulate/share";
3
3
  export { createAuthoredLineSubpath };
4
4
  /** Replace one authored anchor point while retaining its record and all IDs. */
5
5
  export declare function replaceAuthoredAnchorPoint(subpath: AuthoredSubpath, anchorId: AnchorId, point: PointView): AuthoredSubpath;
@@ -23,6 +23,6 @@ export declare function replaceAuthoredCubicHandle(subpath: AuthoredSubpath, seg
23
23
  /** Delete one anchor and merge its predecessor directly to its successor. */
24
24
  export declare function removeAuthoredAnchor(subpath: AuthoredSubpath, anchorId: AnchorId, minimumAnchorCount?: number): AuthoredSubpath;
25
25
  /** Transform coordinates while retaining every subpath, anchor, segment, and record ID. */
26
- export declare function transformAuthoredSubpath(subpath: AuthoredSubpath, matrix: DOMMatrixReadOnly): AuthoredSubpath;
26
+ export declare function transformAuthoredSubpath(subpath: AuthoredSubpath, matrix: ReadonlyMatrix2D): AuthoredSubpath;
27
27
  /** Read bounds directly from authored anchor coordinates. */
28
28
  export declare function getAuthoredSubpathBounds(subpath: AuthoredSubpath): Readonly<Rect> | null;
package/dist/bitmap.d.ts CHANGED
@@ -3,11 +3,26 @@ import { Rectangle, RectangleProperties, type RectangleOption } from "./rectangl
3
3
  /** Owns one derived bitmap and connects replacements to normal Layer paint. */
4
4
  export declare abstract class Bitmap<P extends RectangleProperties = RectangleProperties, O extends RectangleOption<any> = RectangleOption<any>> extends Rectangle<P, O> {
5
5
  private currentBitmap;
6
+ private sentFrameWidth;
7
+ private sentFrameHeight;
8
+ private sentFramePixelRatio;
9
+ private framePending;
6
10
  constructor(options?: NoInfer<O>, properties?: P, Transform?: ElementTransformClass);
7
11
  /** Current borrowed bitmap view for specialized paint and resolution logic. */
8
12
  protected get renderBitmap(): ImageBitmap;
9
13
  /** Physical screen pixels occupied by one authored bitmap-local unit. */
10
14
  protected get renderPixelRatio(): number;
15
+ /**
16
+ * Records the size a new frame renderer is created with; size changes wait
17
+ * for its first presented frame.
18
+ */
19
+ protected startFrameSurface(pixelRatio: number): void;
20
+ /**
21
+ * Returns `true` when the renderer should receive the current size: it
22
+ * differs from the last sent size and no requested frame is still pending.
23
+ * The accepted size is recorded and the next presented frame ends the wait.
24
+ */
25
+ protected claimFrameResize(pixelRatio: number): boolean;
11
26
  /** Takes ownership of a derived frame and schedules one normal paint commit. */
12
27
  protected presentBitmap(bitmap: ImageBitmap): void;
13
28
  /** Releases the currently owned frame. */
@@ -51,7 +51,8 @@ export interface TransformInteractionCapability<Owned = unknown> {
51
51
  getTransformPolicy(): TransformInteractionPolicy;
52
52
  /** Optional authored/layout bounds used by the editor transform frame. */
53
53
  getSelectionFrameBounds?(): Readonly<Rect> | null;
54
- captureTransformBaseline(): ElementTransformBaseline<Owned>;
54
+ /** Capture start state using the same bakeGeometry policy as the ensuing intent. */
55
+ captureTransformBaseline(bakeGeometry: boolean): ElementTransformBaseline<Owned>;
55
56
  /**
56
57
  * Resolves every owner change for this transform. Composite owners may return
57
58
  * multiple child changes; the editor commits the complete result in one batch.
@@ -1,5 +1,5 @@
1
1
  import { type Layer, type PropertyChanges, type Root, Shape, ShapeProperties, ShapeTransform, type ConnectionPortConfiguration, type ElementOptionPatch, type ElementTransformBaseline, type ReparentTransformIntent, type ShapeOption, type TransformIntent } from "@fulate/core";
2
- import { Bound, type PointView, type Rect } from "@fulate/share";
2
+ import { Bound, type PointView, type ReadonlyMatrix2D, type Rect } from "@fulate/share";
3
3
  import { SelectionBehaviorMode, SelectionDiveMode, SelectionSnapMode, type EditorCapabilityToken, type SelectionBehaviorCapability, type SnapSourceCapability, type TransformInteractionCapability } from "./capability";
4
4
  export interface WorldRectPointsViewCache {
5
5
  source: Readonly<Rect> | null;
@@ -13,7 +13,7 @@ export interface WorldRectPointsViewCache {
13
13
  }
14
14
  export declare function createWorldRectPointsViewCache(): WorldRectPointsViewCache;
15
15
  /** Project one stable local frame to a borrowed world-point view. */
16
- export declare function getWorldRectPointsView(cache: WorldRectPointsViewCache, frame: Readonly<Rect>, matrix: DOMMatrixReadOnly): readonly PointView[];
16
+ export declare function getWorldRectPointsView(cache: WorldRectPointsViewCache, frame: Readonly<Rect>, matrix: ReadonlyMatrix2D): readonly PointView[];
17
17
  /** UI frame-authored Shape 系列共享的 direct Editor provider。 */
18
18
  export declare abstract class EditorShape<P extends ShapeProperties = ShapeProperties, O extends ShapeOption<any> = ShapeOption<any>> extends Shape<P, O> implements SelectionBehaviorCapability, TransformInteractionCapability, SnapSourceCapability {
19
19
  private connectionPortDecoration;
@@ -30,7 +30,7 @@ export declare abstract class EditorShape<P extends ShapeProperties = ShapePrope
30
30
  readonly rotate: true;
31
31
  readonly rotationPivot: "adjustable";
32
32
  };
33
- captureTransformBaseline(): ElementTransformBaseline;
33
+ captureTransformBaseline(_bakeGeometry: boolean): ElementTransformBaseline;
34
34
  resolveTransformChange(baseline: Readonly<ElementTransformBaseline>, intent: Readonly<TransformIntent | ReparentTransformIntent>): readonly import("@fulate/core").OwnerPropertyChange[];
35
35
  getSelectionFrameBounds(): Readonly<Rect> | null;
36
36
  setOptions(options?: ElementOptionPatch<O>): this;
@@ -1,5 +1,5 @@
1
1
  import { Element, type ElementOptionPatch, type ElementTransformBaseline, type OwnerPropertyChange, type ReparentTransformIntent, type TransformIntent } from "@fulate/core";
2
- import type { Rect } from "@fulate/share";
2
+ import { type Rect } from "@fulate/share";
3
3
  /** @internal frame-authored provider 共用的纯 resolver。 */
4
4
  export declare function resolveFrameTransformChange(owner: Element, baseline: Readonly<ElementTransformBaseline>, intent: Readonly<TransformIntent | ReparentTransformIntent>): readonly OwnerPropertyChange[];
5
5
  /** @internal 捕获一次 owner reference;structured ownedState 直接保留原引用。 */
package/dist/group.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { ChangeImpact, Element, ElementTransform, type BaseElementOption, type ElementTransformBaseline, type ReparentTransformIntent, type TransformIntent } from "@fulate/core";
2
- import { Bound, type BoundingBox, type PointView } from "@fulate/share";
2
+ import { Bound, type BoundingBox, type PointView, type ReadonlyMatrix2D } from "@fulate/share";
3
3
  import { SelectionBehaviorMode, SelectionDiveMode, SelectionSnapMode, type EditorCapabilityToken, type TransformInteractionCapability } from "./editor/capability";
4
+ /**
5
+ * Group 成员的逻辑范围:frame capability 优先(Text 等排除绘制溢出),否则为成员 content
6
+ * bounds(Line 取几何,不含描边外扩)。`space` 为 `parent` 时返回成员 parent 的 child 坐标。
7
+ * 编组命令与 Group 选区框共用这一口径。
8
+ */
9
+ export declare function resolveGroupMemberBounds(element: Element, capability: TransformInteractionCapability | undefined, space: "world" | "parent"): Bound | null;
4
10
  interface GroupTransformChildBaseline {
5
11
  readonly capability: TransformInteractionCapability;
6
12
  readonly baseline: ReturnType<TransformInteractionCapability["captureTransformBaseline"]>;
@@ -22,14 +28,10 @@ export declare class GroupTransform<E extends Group = Group> extends ElementTran
22
28
  /** @internal Group-local selection frame derived from child owner frames. */
23
29
  getLocalSelectionFrameBoundsView(): Readonly<Bound> | null;
24
30
  /** Group 是 content bounds owner;ancestor 只投影这份 local view。 */
25
- protected collectContentBoundsInReference(parentMatrix: DOMMatrixReadOnly, _referenceWorldInverse: DOMMatrixReadOnly): Bound;
31
+ protected collectContentBoundsInReference(parentMatrix: ReadonlyMatrix2D, _referenceWorldInverse: ReadonlyMatrix2D): Bound;
26
32
  /** 只合并真实 content members;不贡献 content bounds 的 branch 返回 null。 */
27
33
  protected buildLocalContentBounds(): Bound | null;
28
- /**
29
- * Build the frame used by selection/transform/snap. Text-like owners expose
30
- * authored frame bounds that intentionally exclude paint overflow; owners
31
- * without that capability retain an explicit content/visual fallback.
32
- */
34
+ /** Build the frame used by selection/transform/snap from each visible member's logical bounds. */
33
35
  protected buildLocalSelectionFrameBounds(): Bound | null;
34
36
  protected buildLocalHitBounds(): Readonly<Bound>;
35
37
  protected containsLocalHitPoint(point: PointView): boolean;
@@ -57,7 +59,7 @@ export declare class Group extends Element {
57
59
  readonly rotate: true;
58
60
  readonly rotationPivot: "adjustable";
59
61
  };
60
- captureTransformBaseline(): ElementTransformBaseline<{
62
+ captureTransformBaseline(bakeGeometry: boolean): ElementTransformBaseline<{
61
63
  children: GroupTransformChildBaseline[];
62
64
  }>;
63
65
  resolveTransformChange(baseline: Readonly<ElementTransformBaseline<GroupTransformOwnedState>>, intent: Readonly<TransformIntent | ReparentTransformIntent>): readonly import("@fulate/core").OwnerPropertyChange[];
package/dist/image.d.ts CHANGED
@@ -18,6 +18,7 @@ export declare class ImageProperties extends RectangleProperties {
18
18
  getImpact(changes: PropertyChanges): ChangeImpact;
19
19
  }
20
20
  export declare class ImageTransform<E extends Image = Image> extends RectangleTransform<E> {
21
+ protected resolveFitSize(): void;
21
22
  }
22
23
  export declare class Image<P extends ImageProperties = ImageProperties, O extends ImageOption<any> = ImageOption<any>> extends Bitmap<P, O> {
23
24
  readonly type: string;
@@ -25,11 +26,16 @@ export declare class Image<P extends ImageProperties = ImageProperties, O extend
25
26
  get resize(): Readonly<ImageResizeOption>;
26
27
  protected isLoaded: boolean;
27
28
  private renderSize;
28
- private naturalWidth;
29
- private naturalHeight;
29
+ private sourceWidth;
30
+ private sourceHeight;
31
+ private externalImage;
30
32
  private isProcessing;
31
33
  private processGeneration;
32
34
  constructor(options?: NoInfer<O>, Transform?: ElementTransformClass, properties?: P);
35
+ /** Intrinsic width of the current image source, before authored or fit sizing. */
36
+ get naturalWidth(): number;
37
+ /** Intrinsic height of the current image source, before authored or fit sizing. */
38
+ get naturalHeight(): number;
33
39
  get resizeMode(): ImageResizeMode;
34
40
  get resizeQuality(): ImageBitmapOptions["resizeQuality"];
35
41
  setResize(resize: ImageResizeOption): void;
@@ -41,7 +47,6 @@ export declare class Image<P extends ImageProperties = ImageProperties, O extend
41
47
  protected onUnmount(): void;
42
48
  private cancelProcessing;
43
49
  protected clearBitmap(): void;
44
- private setExternalImage;
45
50
  protected loadAndProcess(): Promise<void>;
46
51
  private processImage;
47
52
  private applyBitmap;
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export { fitWorkspace, workspaceFocusInsetsKey, Workspace, WorkspaceProperties }
24
24
  export type { WorkspaceFocusInsetsSource, WorkspaceFitOptions, WorkspaceJSON, WorkspaceOption } from "./workspace";
25
25
  export { computePosition, flip, offset, shift } from "./floating";
26
26
  export type { ComputePositionOptions, Placement } from "./floating";
27
- export { Group, GroupTransform } from "./group";
27
+ export { Group, GroupTransform, resolveGroupMemberBounds } from "./group";
28
28
  export type { GroupOption } from "./group";
29
29
  export { ContentEditingCapabilityToken, PointEditingCapabilityToken, SelectionBehaviorMode, SelectionBehaviorCapabilityToken, SelectionDiveMode, SelectionSnapMode, SnapSourceCapabilityToken, TransformInteractionCapabilityToken, defineEditorCapability, getEditorCapability, isEditorCapabilityHost, resolveSelectionFrameBounds } from "./editor/capability";
30
30
  export type { ContentEditingCapability, ContentEditingConsumer, ContentEditingSession, EditorCapabilityHost, EditorCapabilityToken, PointControlDescriptor, PointEditRequest, PointEditTarget, PointEditingCapability, PointEditingScope, PointOwnerEdit, SelectionBehavior, SelectionBehaviorCapability, SnapSourceCapability, TransformInteractionCapability, TransformInteractionPolicy } from "./editor/capability";
@@ -37,7 +37,7 @@ export type { RippleOption } from "./ripple";
37
37
  export { BaseLine, LineTransform, Line } from "./line/index";
38
38
  export { connectionPortAccepts, connectEndpoint, disconnectEndpoint, getEndpointRelationIndex, hasConnectionPortCapacity, isEndpointRelationSource, resolveConnectionPortChanges, resolveConnectEndpointChange, resolveDisconnectEndpointChanges, EndpointRelationIndex } from "./connection";
39
39
  export type { BindableEndpoint, EndpointConnectionRole, EndpointRef, EndpointRelation, EndpointRelationBinding, EndpointRelationSource } from "./connection";
40
- export { LineTree, LineTreeProperties, LineTreeTransform, EMPTY_LINE_TREE_TOPOLOGY, DEFAULT_LINE_TREE_BRANCH_STYLE, addLineTreeBranchAtTail, createLineTreeTopology, getLineTreeBranch, getLineTreeBindableEndpoints, getLineTreeEndpointRelationBindings, getLineTreeJunctionAnchorIds, getLineTreePoint, getLineTreePointReferenceCounts, insertLineTreePoint, moveLineTreePoint, removeLineTreeBranch, removeLineTreePoint, remapLineTreeRelations, transformLineTreeTopology, updateLineTreeBranchStyle } from "./line-tree";
40
+ export { LineTree, LineTreeProperties, LineTreeTransform, EMPTY_LINE_TREE_TOPOLOGY, DEFAULT_LINE_TREE_BRANCH_STYLE, addLineTreeBranchAtTail, createLineTreeTopology, getLineTreeBranch, getLineTreeJunctionAnchorIds, getLineTreePoint, getLineTreePointReferenceCounts, insertLineTreePoint, moveLineTreePoint, removeLineTreeBranch, removeLineTreePoint, remapLineTreeRelations, transformLineTreeTopology, updateLineTreeBranchStyle } from "./line-tree";
41
41
  export type { LineTreeBranch, LineTreeBranchRemoval, LineTreeBranchTailSource, LineTreeBranchStyle, LineTreeBranchVertex, LineTreeOption, LineTreePoint, LineTreeTopology } from "./line-tree";
42
42
  export { applyLineTreeTopologyDelta, createLineTreeTopologyDelta } from "./line-tree/history-delta";
43
43
  export type { LineTreeTopologyDelta } from "./line-tree/history-delta";