@fulate/ui 1.0.15 → 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
 
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.
@@ -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;
package/dist/group.d.ts CHANGED
@@ -59,7 +59,7 @@ export declare class Group extends Element {
59
59
  readonly rotate: true;
60
60
  readonly rotationPivot: "adjustable";
61
61
  };
62
- captureTransformBaseline(): ElementTransformBaseline<{
62
+ captureTransformBaseline(bakeGeometry: boolean): ElementTransformBaseline<{
63
63
  children: GroupTransformChildBaseline[];
64
64
  }>;
65
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
@@ -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";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { clearCache, layoutNextLineRange, layoutWithLines, materializeLineRange, measureLineStats, measureNaturalWidth, prepareWithSegments } from "@chenglou/pretext";
2
- import { ChangeImpact, CustomEvent, Element, ElementProperties, ElementTransform, SKIN_DEFAULTS, Shape, ShapeProperties, ShapeTransform, createAuthoredLineSubpath, createGeometrySnapshot, createLineSubpath, createPathLocalId, evaluatePathSegmentPoint, getElementConnectionPort, getElementConnectionPortPoint, isReparentTransformIntent, mergeOwnerPropertyChanges, resolveAuthoredGeometryFramePatch, resolveAuthoredSubpath, resolveReferenceBoundsTranslation, resolveReferenceTransform, resolveReferenceTransformTarget, splitPathSegment } from "@fulate/core";
1
+ import { clearCache, layout, layoutNextLine, layoutNextLineRange, layoutWithLines, materializeLineRange, measureLineStats, measureNaturalWidth, prepareWithSegments } from "@chenglou/pretext";
2
+ import { ChangeImpact, CustomEvent, Element, ElementProperties, ElementTransform, SKIN_DEFAULTS, Shape, ShapeProperties, ShapeTransform, createAuthoredLineSubpath, createGeometrySnapshot, createLineSubpath, createPathLocalId, evaluatePathSegmentPoint, getAuthoredPathLayoutBounds, getElementConnectionPort, getElementConnectionPortPoint, isReparentTransformIntent, mergeOwnerPropertyChanges, resolveAuthoredGeometryFramePatch, resolveAuthoredSubpath, resolveReferenceBoundsTranslation, resolveReferenceTransform, splitPathSegment } from "@fulate/core";
3
3
  import { clamp, has, isFunction, isNil, isNull, isString, isUndefined, last } from "lodash-es";
4
4
  import { Bound, Intersection, Matrix2D, createCanvasGradient, createPointView, isGradient, isPointWithinDistance, rectEdgePosition, transformPoint } from "@fulate/share";
5
5
  import { computePosition as computePosition$1, flip, offset, shift } from "@floating-ui/core";
@@ -287,24 +287,47 @@ var PreparedTextLayout = class {
287
287
  return new TextLayoutSnapshot(this.normalizedText, this.font, this.letterSpacing, options.lineHeight, this.naturalWidth, rawLineCount > 0 ? [this.normalizedText] : [], rawLineCount, truncated, lines, lines.length === 0 ? 0 : this.naturalWidth);
288
288
  }
289
289
  const prepared = this.getRichPrepared();
290
- const rawLines = layoutWithLines(prepared, getWrapWidth(options), options.lineHeight).lines;
291
- for (const line of rawLines) line.ellipsized = false;
292
- if (this.normalizedText.length > 0 && this.normalizedText.endsWith("\n")) {
293
- const end = {
294
- segmentIndex: prepared.segments.length,
290
+ const wrapWidth = getWrapWidth(options);
291
+ const visibleLineLimit = getVisibleLineLimit(options);
292
+ let rawLineCount;
293
+ let lines;
294
+ if (Number.isFinite(visibleLineLimit)) {
295
+ lines = [];
296
+ let cursor = {
297
+ segmentIndex: 0,
295
298
  graphemeIndex: 0
296
299
  };
297
- rawLines.push({
298
- text: "",
299
- width: 0,
300
- start: end,
301
- end,
302
- ellipsized: false
303
- });
300
+ while (lines.length < visibleLineLimit) {
301
+ const line = layoutNextLine(prepared, cursor, wrapWidth);
302
+ if (!line) break;
303
+ line.ellipsized = false;
304
+ lines.push(line);
305
+ cursor = line.end;
306
+ }
307
+ rawLineCount = cursor.segmentIndex === prepared.segments.length ? lines.length : layout(prepared, wrapWidth, options.lineHeight).lineCount;
308
+ } else {
309
+ const result = layoutWithLines(prepared, wrapWidth, options.lineHeight);
310
+ rawLineCount = result.lineCount;
311
+ lines = result.lines;
312
+ for (const line of lines) line.ellipsized = false;
304
313
  }
305
- const visibleLineLimit = getVisibleLineLimit(options);
306
- const truncated = rawLines.length > visibleLineLimit;
307
- const lines = Number.isFinite(visibleLineLimit) ? rawLines.slice(0, visibleLineLimit) : rawLines;
314
+ if (this.normalizedText.length > 0 && this.normalizedText.endsWith("\n")) {
315
+ rawLineCount += 1;
316
+ if (rawLineCount <= visibleLineLimit) {
317
+ const end = {
318
+ segmentIndex: prepared.segments.length,
319
+ graphemeIndex: 0
320
+ };
321
+ lines.push({
322
+ text: "",
323
+ width: 0,
324
+ start: end,
325
+ end,
326
+ ellipsized: false
327
+ });
328
+ }
329
+ }
330
+ const truncated = rawLineCount > visibleLineLimit;
308
331
  if (options.ellipsis && !truncated && lines.length === 1 && lines[0].width > options.width) {
309
332
  const line = lines[0];
310
333
  const fitted = ellipsizeText(line.text, options.width, this.font, this.letterSpacing, true);
@@ -328,7 +351,7 @@ var PreparedTextLayout = class {
328
351
  }
329
352
  let maxLineWidth = 0;
330
353
  for (const line of lines) maxLineWidth = Math.max(maxLineWidth, line.width);
331
- return new TextLayoutSnapshot(this.normalizedText, this.font, this.letterSpacing, options.lineHeight, this.naturalWidth, prepared.segments, rawLines.length, truncated, lines, maxLineWidth);
354
+ return new TextLayoutSnapshot(this.normalizedText, this.font, this.letterSpacing, options.lineHeight, this.naturalWidth, prepared.segments, rawLineCount, truncated, lines, maxLineWidth);
332
355
  }
333
356
  getRichPrepared() {
334
357
  if (this.prepared) return this.prepared;
@@ -400,8 +423,11 @@ var TextLayoutSnapshot = class TextLayoutSnapshot {
400
423
  }
401
424
  getLineX(index, width, textAlign) {
402
425
  const lineWidth = this.layoutLines[index]?.width ?? 0;
403
- if (textAlign === "center") return (width - lineWidth) / 2;
404
- if (textAlign === "right") return width - lineWidth;
426
+ return this.getBlockHorizontalOffset(width, textAlign, lineWidth);
427
+ }
428
+ getBlockHorizontalOffset(width, textAlign, contentWidth = this.maxLineWidth) {
429
+ if (textAlign === "center") return (width - contentWidth) / 2;
430
+ if (textAlign === "right") return width - contentWidth;
405
431
  return 0;
406
432
  }
407
433
  getBlockVerticalOffset(height, verticalAlign, contentHeight = this.textHeight) {
@@ -412,8 +438,8 @@ var TextLayoutSnapshot = class TextLayoutSnapshot {
412
438
  getCaretLocalXY(caretIndex, width, height, textAlign, verticalAlign, fontSize) {
413
439
  const intraLine = (this.lineHeight - fontSize) / 2;
414
440
  if (this.layoutLines.length === 0) return {
415
- x: textAlign === "center" ? width / 2 : textAlign === "right" ? width : 0,
416
- y: (verticalAlign === "middle" ? (height - this.lineHeight) / 2 : verticalAlign === "bottom" ? height - this.lineHeight : 0) + intraLine,
441
+ x: this.getBlockHorizontalOffset(width, textAlign, 0),
442
+ y: this.getBlockVerticalOffset(height, verticalAlign, this.lineHeight) + intraLine,
417
443
  h: fontSize
418
444
  };
419
445
  const lineIndex = this.getLineIndex(caretIndex);
@@ -566,7 +592,6 @@ function syncFromTextarea(self) {
566
592
  if (!self.textarea) return;
567
593
  if (self.editingConsumer) self.editingConsumer.submit(self.textarea.value);
568
594
  else self.setOptions({ text: self.textarea.value });
569
- self.transform.markNeedsLayout();
570
595
  ensureCaretVisible(self);
571
596
  updateTextareaPosition(self);
572
597
  self.dispatchEvent(new CustomEvent("input", {
@@ -575,7 +600,10 @@ function syncFromTextarea(self) {
575
600
  }));
576
601
  }
577
602
  function syncEditingText(self, value) {
578
- if (self.text !== value) self.setOptions({ text: value });
603
+ if (self.text !== value) {
604
+ self.setOptions({ text: value });
605
+ return;
606
+ }
579
607
  const textarea = self.textarea;
580
608
  if (textarea && textarea.value !== value) {
581
609
  const start = Math.min(textarea.selectionStart ?? value.length, value.length);
@@ -586,7 +614,6 @@ function syncEditingText(self, value) {
586
614
  ensureCaretVisible(self);
587
615
  updateTextareaPosition(self);
588
616
  }
589
- self.transform.markNeedsLayout();
590
617
  }
591
618
  function restartBlink(self) {
592
619
  stopBlink(self);
@@ -714,9 +741,11 @@ function enterEditing(self, initialClickLocal, consumer = null) {
714
741
  ensureCaretVisible(self);
715
742
  self.transform.markNeedsLayout();
716
743
  }, { signal });
717
- document.addEventListener("pointerup", () => {
744
+ const finishSelectionDrag = () => {
718
745
  self.selAnchor = -1;
719
- }, { signal });
746
+ };
747
+ document.addEventListener("pointerup", finishSelectionDrag, { signal });
748
+ document.addEventListener("pointercancel", finishSelectionDrag, { signal });
720
749
  document.addEventListener("pointerdown", (e) => {
721
750
  if (!root.container.contains(e.target)) textarea.blur();
722
751
  }, { signal });
@@ -728,20 +757,21 @@ function requestEditingFinish(self) {
728
757
  else closeEditing(self);
729
758
  }
730
759
  function closeEditing(self) {
731
- if (!self.isEditing) return;
760
+ const textarea = self.textarea;
761
+ if (!textarea) return;
762
+ const value = textarea.value;
763
+ const consumer = self.editingConsumer;
764
+ self.textarea = null;
765
+ self.editingConsumer = null;
732
766
  stopBlink(self);
733
767
  self.selAnchor = -1;
734
768
  self.scrollX = 0;
735
- if (self.textarea) {
736
- if (!self.editingConsumer) self.setOptions({ text: self.textarea.value });
737
- self.textarea.remove();
738
- self.textarea = null;
739
- }
740
769
  self.editSubscriptionRemove?.();
741
770
  self.editAbort?.abort();
742
771
  self.editAbort = null;
743
- self.editingConsumer = null;
744
772
  self.composing = false;
773
+ textarea.remove();
774
+ if (!consumer) self.setOptions({ text: value });
745
775
  self.transform.markNeedsLayout();
746
776
  self.dispatchEvent(new CustomEvent("change", {
747
777
  detail: self.text,
@@ -963,7 +993,7 @@ function paintTextContent(self, ctx, offsetY = 0) {
963
993
  const fillStyle = resolveColorFill(ctx, style.color, w, h);
964
994
  ctx.fillStyle = self.placeholderColor || fillStyle;
965
995
  const phWidth = measureTextWidth(self.placeholder, font, ls);
966
- const phX = style.textAlign === "center" ? (w - phWidth) / 2 : style.textAlign === "right" ? w - phWidth : 0;
996
+ const phX = layout.getBlockHorizontalOffset(w, style.textAlign, phWidth);
967
997
  const phBlockOffset = layout.getBlockVerticalOffset(h, style.verticalAlign, lineHeightPx);
968
998
  const lineMetrics = measureTextLinePlacement(font, style.textBaseline, lineHeightPx);
969
999
  drawTextLine(ctx, self.placeholder, phX, lineMetrics.drawY + phBlockOffset, font, ls, true, false);
@@ -1059,14 +1089,8 @@ var TextBlock = class {
1059
1089
  /** Return visual bounds for the same snapshot consumed by `paintTextBlock`. */
1060
1090
  function getTextBlockVisualBounds(layout, style, width, height) {
1061
1091
  if (layout.lines.length === 0) return null;
1062
- let left = Infinity;
1063
- let right = -Infinity;
1064
- for (let index = 0; index < layout.lines.length; index++) {
1065
- const line = layout.lines[index];
1066
- const lineX = layout.getLineX(index, width, style.textAlign);
1067
- left = Math.min(left, lineX);
1068
- right = Math.max(right, lineX + line.width);
1069
- }
1092
+ let left = layout.getBlockHorizontalOffset(width, style.textAlign);
1093
+ let right = left + layout.maxLineWidth;
1070
1094
  let top = layout.getBlockVerticalOffset(height, style.verticalAlign);
1071
1095
  let bottom = top + layout.textHeight;
1072
1096
  const strokeOutset = style.textStrokeColor && style.textStrokeWidth > 0 ? style.textStrokeWidth / 2 : 0;
@@ -1802,7 +1826,7 @@ var EditorShape = class EditorShape extends Shape {
1802
1826
  getTransformPolicy() {
1803
1827
  return FRAME_TRANSFORM_POLICY;
1804
1828
  }
1805
- captureTransformBaseline() {
1829
+ captureTransformBaseline(_bakeGeometry) {
1806
1830
  return captureElementTransformBaseline(this, "frame-authored", void 0);
1807
1831
  }
1808
1832
  resolveTransformChange(baseline, intent) {
@@ -2518,6 +2542,12 @@ var Polygon = class extends EditorShape {
2518
2542
  getPointScopeOutline(_scope) {
2519
2543
  return null;
2520
2544
  }
2545
+ resolvePointContourPatch(contour) {
2546
+ return {
2547
+ ...resolveReferenceBoundsPosePatch(this, () => [this.transform.getLayoutReferenceBoundsView(), getAuthoredSubpathBounds(contour)]),
2548
+ contour
2549
+ };
2550
+ }
2521
2551
  resolvePointEdit(request) {
2522
2552
  if (request.kind === "delete-scope") return null;
2523
2553
  if (request.kind === "move-handle") return null;
@@ -2527,7 +2557,7 @@ var Polygon = class extends EditorShape {
2527
2557
  kind: "owner-change",
2528
2558
  change: {
2529
2559
  owner: this,
2530
- patch: { contour: inserted.subpath }
2560
+ patch: this.resolvePointContourPatch(inserted.subpath)
2531
2561
  },
2532
2562
  nextTarget: {
2533
2563
  kind: "anchor",
@@ -2543,7 +2573,7 @@ var Polygon = class extends EditorShape {
2543
2573
  kind: "owner-change",
2544
2574
  change: {
2545
2575
  owner: this,
2546
- patch: { contour }
2576
+ patch: this.resolvePointContourPatch(contour)
2547
2577
  }
2548
2578
  };
2549
2579
  }
@@ -2554,11 +2584,11 @@ var Polygon = class extends EditorShape {
2554
2584
  kind: "owner-change",
2555
2585
  change: {
2556
2586
  owner: this,
2557
- patch: { contour }
2587
+ patch: this.resolvePointContourPatch(contour)
2558
2588
  }
2559
2589
  };
2560
2590
  }
2561
- captureTransformBaseline() {
2591
+ captureTransformBaseline(_bakeGeometry) {
2562
2592
  return captureElementTransformBaseline(this, "authored-geometry", this.contour);
2563
2593
  }
2564
2594
  resolveTransformChange(baseline, intent) {
@@ -2746,31 +2776,6 @@ function createVectorPathGeometry(commands) {
2746
2776
  finish();
2747
2777
  return { subpaths };
2748
2778
  }
2749
- function resolveVectorPath(path) {
2750
- return Array.isArray(path) ? createVectorPathGeometry(path) : path;
2751
- }
2752
- function createVectorPathSnapshot(elementKey, revision, path) {
2753
- return createGeometrySnapshot({
2754
- elementKey,
2755
- revision,
2756
- subpaths: path.subpaths.map(resolveAuthoredSubpath)
2757
- });
2758
- }
2759
- function withPathBounds(options) {
2760
- if (options.path === void 0) return options;
2761
- const path = resolveVectorPath(options.path);
2762
- if (path.subpaths.reduce((count, subpath) => count + subpath.anchors.length, 0) < 2) return {
2763
- ...options,
2764
- path
2765
- };
2766
- const { width, height } = createVectorPathSnapshot("", 0, path).layoutReferenceBounds;
2767
- return {
2768
- ...options,
2769
- path,
2770
- width: options.width ?? (width || 1),
2771
- height: options.height ?? (height || 1)
2772
- };
2773
- }
2774
2779
  function createEmptyVectorPath() {
2775
2780
  return { subpaths: [] };
2776
2781
  }
@@ -2788,7 +2793,11 @@ var VectorPathProperties = class extends ShapeProperties {
2788
2793
  };
2789
2794
  var VectorPathTransform = class extends EditorShapeTransform {
2790
2795
  buildGeometrySnapshot(revision) {
2791
- return createVectorPathSnapshot(this.element.key, revision, this.element.path);
2796
+ return createGeometrySnapshot({
2797
+ elementKey: this.element.key,
2798
+ revision,
2799
+ subpaths: this.element.path.subpaths.map(resolveAuthoredSubpath)
2800
+ });
2792
2801
  }
2793
2802
  };
2794
2803
  var VectorPath = class extends EditorShape {
@@ -2797,14 +2806,22 @@ var VectorPath = class extends EditorShape {
2797
2806
  return this.propertyState.path;
2798
2807
  }
2799
2808
  constructor(options = {}) {
2800
- const prepared = withPathBounds(options);
2809
+ const prepared = Array.isArray(options.path) ? {
2810
+ ...options,
2811
+ path: createVectorPathGeometry(options.path)
2812
+ } : options;
2801
2813
  super(prepared, new VectorPathProperties(prepared), VectorPathTransform);
2814
+ if (this.path.subpaths.reduce((count, subpath) => count + subpath.anchors.length, 0) >= 2 && (options.width === void 0 || options.height === void 0)) {
2815
+ const { width, height } = this.transform.getLayoutReferenceBoundsView();
2816
+ this.propertyState.width ??= width || 1;
2817
+ this.propertyState.height ??= height || 1;
2818
+ }
2802
2819
  }
2803
2820
  resolveOptions(options) {
2804
- if (!has(options, "path") || options.path === void 0 || options.path === this.path) return options;
2821
+ if (!Array.isArray(options.path)) return options;
2805
2822
  return {
2806
2823
  ...options,
2807
- path: resolveVectorPath(options.path)
2824
+ path: createVectorPathGeometry(options.path)
2808
2825
  };
2809
2826
  }
2810
2827
  getEditorCapability(token) {
@@ -2896,21 +2913,25 @@ var VectorPath = class extends EditorShape {
2896
2913
  return null;
2897
2914
  }
2898
2915
  ownerPathChange(previous, next) {
2916
+ const path = { subpaths: this.path.subpaths.map((subpath) => subpath === previous ? next : subpath) };
2899
2917
  return {
2900
2918
  kind: "owner-change",
2901
2919
  change: {
2902
2920
  owner: this,
2903
- patch: { path: { subpaths: this.path.subpaths.map((subpath) => subpath === previous ? next : subpath) } }
2921
+ patch: {
2922
+ ...resolveReferenceBoundsPosePatch(this, () => [this.transform.getLayoutReferenceBoundsView(), getAuthoredPathLayoutBounds(path.subpaths)]),
2923
+ path
2924
+ }
2904
2925
  }
2905
2926
  };
2906
2927
  }
2907
- captureTransformBaseline() {
2928
+ captureTransformBaseline(_bakeGeometry) {
2908
2929
  return captureElementTransformBaseline(this, "authored-geometry", this.path);
2909
2930
  }
2910
2931
  resolveTransformChange(baseline, intent) {
2911
2932
  const transform = resolveReferenceTransform(baseline.reference, intent);
2912
2933
  const path = transform.authoredLocalDelta.isIdentity ? baseline.ownedState : { subpaths: baseline.ownedState.subpaths.map((subpath) => transformAuthoredSubpath(subpath, transform.authoredLocalDelta)) };
2913
- const bounds = path === baseline.ownedState ? null : createVectorPathSnapshot("", 0, path).layoutReferenceBounds;
2934
+ const bounds = path === baseline.ownedState ? null : getAuthoredPathLayoutBounds(path.subpaths);
2914
2935
  const framePatch = bounds && intent.bakeGeometry && !isReparentTransformIntent(intent) ? resolveAuthoredGeometryFramePatch(baseline.reference, transform, bounds) : transform.framePatch;
2915
2936
  const restoredFrameSize = intent.bakeGeometry && !isReparentTransformIntent(intent) && path === baseline.ownedState ? {
2916
2937
  width: baseline.reference.frame.width,
@@ -3247,8 +3268,8 @@ var Text = class extends Rectangle {
3247
3268
  if (this.placeholder) {
3248
3269
  const placeholderWidth = measureTextWidth(this.placeholder, this.getFontString(style), style.letterSpacing);
3249
3270
  return {
3250
- left: style.textAlign === "center" ? (width - placeholderWidth) / 2 : style.textAlign === "right" ? width - placeholderWidth : 0,
3251
- top: style.verticalAlign === "middle" ? (height - lineHeight) / 2 : style.verticalAlign === "bottom" ? height - lineHeight : 0,
3271
+ left: layout.getBlockHorizontalOffset(width, style.textAlign, placeholderWidth),
3272
+ top: layout.getBlockVerticalOffset(height, style.verticalAlign, lineHeight),
3252
3273
  width: placeholderWidth,
3253
3274
  height: lineHeight
3254
3275
  };
@@ -3261,6 +3282,7 @@ var Text = class extends Rectangle {
3261
3282
  exitEditing() {
3262
3283
  exitEditing(this);
3263
3284
  }
3285
+ /** 更新文本属性,并同步当前正在使用的 textarea。 */
3264
3286
  setEditingText(value) {
3265
3287
  syncEditingText(this, value);
3266
3288
  }
@@ -3313,6 +3335,10 @@ var Text = class extends Rectangle {
3313
3335
  /** Owns one derived bitmap and connects replacements to normal Layer paint. */
3314
3336
  var Bitmap = class extends Rectangle {
3315
3337
  currentBitmap = null;
3338
+ sentFrameWidth = 0;
3339
+ sentFrameHeight = 0;
3340
+ sentFramePixelRatio = 0;
3341
+ framePending = false;
3316
3342
  constructor(options = {}, properties = new RectangleProperties(options), Transform = RectangleTransform) {
3317
3343
  super(options, properties, Transform);
3318
3344
  }
@@ -3325,8 +3351,35 @@ var Bitmap = class extends Rectangle {
3325
3351
  const viewport = this.activeRoot?.viewport;
3326
3352
  return viewport ? viewport.scale * viewport.dpr : 1;
3327
3353
  }
3354
+ /**
3355
+ * Records the size a new frame renderer is created with; size changes wait
3356
+ * for its first presented frame.
3357
+ */
3358
+ startFrameSurface(pixelRatio) {
3359
+ this.sentFrameWidth = this.width;
3360
+ this.sentFrameHeight = this.height;
3361
+ this.sentFramePixelRatio = pixelRatio;
3362
+ this.framePending = true;
3363
+ }
3364
+ /**
3365
+ * Returns `true` when the renderer should receive the current size: it
3366
+ * differs from the last sent size and no requested frame is still pending.
3367
+ * The accepted size is recorded and the next presented frame ends the wait.
3368
+ */
3369
+ claimFrameResize(pixelRatio) {
3370
+ if (this.framePending) return false;
3371
+ const width = this.width;
3372
+ const height = this.height;
3373
+ if (width === this.sentFrameWidth && height === this.sentFrameHeight && pixelRatio === this.sentFramePixelRatio) return false;
3374
+ this.sentFrameWidth = width;
3375
+ this.sentFrameHeight = height;
3376
+ this.sentFramePixelRatio = pixelRatio;
3377
+ this.framePending = true;
3378
+ return true;
3379
+ }
3328
3380
  /** Takes ownership of a derived frame and schedules one normal paint commit. */
3329
3381
  presentBitmap(bitmap) {
3382
+ this.framePending = false;
3330
3383
  this.clearBitmap();
3331
3384
  this.currentBitmap = bitmap;
3332
3385
  this.transform.markPaintDirty();
@@ -3373,7 +3426,13 @@ var ImageProperties = class extends RectangleProperties {
3373
3426
  return impact;
3374
3427
  }
3375
3428
  };
3376
- var ImageTransform = class extends RectangleTransform {};
3429
+ var ImageTransform = class extends RectangleTransform {
3430
+ resolveFitSize() {
3431
+ const image = this.element;
3432
+ const parent = image.parent;
3433
+ this.commitResolvedSize(isUndefined(image.properties.width) ? image.fitWidth ? parent?.width : image.naturalWidth : void 0, isUndefined(image.properties.height) ? image.fitHeight ? parent?.height : image.naturalHeight : void 0);
3434
+ }
3435
+ };
3377
3436
  var AUTO_DOWNSAMPLE_RATIO = 2;
3378
3437
  var UPGRADE_RATIO = 1.5;
3379
3438
  var Image = class extends Bitmap {
@@ -3389,13 +3448,25 @@ var Image = class extends Bitmap {
3389
3448
  w: 0,
3390
3449
  h: 0
3391
3450
  };
3392
- naturalWidth = 0;
3393
- naturalHeight = 0;
3451
+ sourceWidth = 0;
3452
+ sourceHeight = 0;
3453
+ externalImage;
3394
3454
  isProcessing = false;
3395
3455
  processGeneration = 0;
3396
3456
  constructor(options = {}, Transform = ImageTransform, properties = new ImageProperties(options)) {
3397
3457
  super(options, properties, Transform);
3398
- if (options.image) this.setExternalImage(options.image);
3458
+ if (options.image) {
3459
+ this.externalImage = options.image;
3460
+ this.loadAndProcess();
3461
+ }
3462
+ }
3463
+ /** Intrinsic width of the current image source, before authored or fit sizing. */
3464
+ get naturalWidth() {
3465
+ return this.sourceWidth;
3466
+ }
3467
+ /** Intrinsic height of the current image source, before authored or fit sizing. */
3468
+ get naturalHeight() {
3469
+ return this.sourceHeight;
3399
3470
  }
3400
3471
  get resizeMode() {
3401
3472
  return this.resize.mode ?? "auto";
@@ -3410,16 +3481,19 @@ var Image = class extends Bitmap {
3410
3481
  super.onPropertiesChanged(current, changes);
3411
3482
  if (changes.has("src")) {
3412
3483
  this.cancelProcessing();
3484
+ this.externalImage = void 0;
3485
+ this.sourceWidth = 0;
3486
+ this.sourceHeight = 0;
3413
3487
  this.clearBitmap();
3414
3488
  if (this.isActive && current.src) this.loadAndProcess();
3415
- } else if (changes.has("resize") && this.isActive && current.src) {
3489
+ } else if (changes.has("resize") && this.isActive && (current.src || this.externalImage)) {
3416
3490
  this.cancelProcessing();
3417
3491
  this.loadAndProcess();
3418
3492
  }
3419
3493
  }
3420
3494
  onActivate(root, layer) {
3421
3495
  super.onActivate(root, layer);
3422
- if (this.src && !this.renderBitmap) this.loadAndProcess();
3496
+ if ((this.src || this.externalImage) && !this.renderBitmap) this.loadAndProcess();
3423
3497
  }
3424
3498
  onDeactivate(root, layer) {
3425
3499
  this.cancelProcessing();
@@ -3428,15 +3502,16 @@ var Image = class extends Bitmap {
3428
3502
  paintContent(ctx) {
3429
3503
  if (!this.renderBitmap) return;
3430
3504
  if (this.resizeMode === "auto") this.checkResolution();
3431
- this.paintBitmap(ctx, this.width || this.naturalWidth, this.height || this.naturalHeight);
3505
+ this.paintBitmap(ctx, this.width ?? this.naturalWidth, this.height ?? this.naturalHeight);
3432
3506
  }
3433
3507
  async paintForExport(ctx) {
3434
3508
  if (!this.src) return;
3435
3509
  const img = await this.loadHTMLImage(this.src);
3436
- ctx.drawImage(img, 0, 0, this.width || img.naturalWidth, this.height || img.naturalHeight);
3510
+ ctx.drawImage(img, 0, 0, this.width ?? img.naturalWidth, this.height ?? img.naturalHeight);
3437
3511
  }
3438
3512
  onUnmount() {
3439
3513
  this.cancelProcessing();
3514
+ this.externalImage = void 0;
3440
3515
  super.onUnmount();
3441
3516
  }
3442
3517
  cancelProcessing() {
@@ -3451,33 +3526,20 @@ var Image = class extends Bitmap {
3451
3526
  h: 0
3452
3527
  };
3453
3528
  }
3454
- setExternalImage(image) {
3455
- this.naturalWidth = image instanceof HTMLImageElement ? image.naturalWidth : image.width;
3456
- this.naturalHeight = image instanceof HTMLImageElement ? image.naturalHeight : image.height;
3457
- createImageBitmap(image).then((bitmap) => {
3458
- if (this.isUnmounted) {
3459
- bitmap.close();
3460
- return;
3461
- }
3462
- this.presentBitmap(bitmap);
3463
- this.renderSize = {
3464
- w: this.naturalWidth,
3465
- h: this.naturalHeight
3466
- };
3467
- this.isLoaded = true;
3468
- this.transform.commitResolvedSize(isUndefined(this.propertyState.width) ? this.naturalWidth : void 0, isUndefined(this.propertyState.height) ? this.naturalHeight : void 0);
3469
- });
3470
- }
3471
3529
  async loadAndProcess() {
3472
- if (!this.src || this.isProcessing) return;
3530
+ if (!this.src && !this.externalImage || this.isProcessing) return;
3473
3531
  this.isProcessing = true;
3474
3532
  const generation = ++this.processGeneration;
3475
3533
  try {
3476
- const img = await this.loadHTMLImage(this.src);
3534
+ const img = this.externalImage ?? await this.loadHTMLImage(this.src);
3477
3535
  if (generation !== this.processGeneration || this.isUnmounted) return;
3478
- this.naturalWidth = img.naturalWidth;
3479
- this.naturalHeight = img.naturalHeight;
3480
- this.transform.commitResolvedSize(isUndefined(this.propertyState.width) ? img.naturalWidth : void 0, isUndefined(this.propertyState.height) ? img.naturalHeight : void 0);
3536
+ const width = img instanceof HTMLCanvasElement ? img.width : img.naturalWidth;
3537
+ const height = img instanceof HTMLCanvasElement ? img.height : img.naturalHeight;
3538
+ if (width !== this.sourceWidth || height !== this.sourceHeight) {
3539
+ this.sourceWidth = width;
3540
+ this.sourceHeight = height;
3541
+ this.transform.markGeometryNeedsLayout();
3542
+ }
3481
3543
  await this.processImage(img, generation);
3482
3544
  } finally {
3483
3545
  if (generation === this.processGeneration) this.isProcessing = false;
@@ -3492,10 +3554,10 @@ var Image = class extends Bitmap {
3492
3554
  bitmap.close();
3493
3555
  return;
3494
3556
  }
3495
- this.applyBitmap(bitmap, img.naturalWidth, img.naturalHeight);
3557
+ this.applyBitmap(bitmap, this.naturalWidth, this.naturalHeight);
3496
3558
  } else {
3497
- const { w, h } = this.calcAutoSize(img.naturalWidth, img.naturalHeight);
3498
- if (w >= img.naturalWidth && h >= img.naturalHeight) bitmap = await createImageBitmap(img);
3559
+ const { w, h } = this.calcAutoSize(this.naturalWidth, this.naturalHeight);
3560
+ if (w >= this.naturalWidth && h >= this.naturalHeight) bitmap = await createImageBitmap(img);
3499
3561
  else bitmap = await createImageBitmap(img, {
3500
3562
  resizeWidth: w,
3501
3563
  resizeHeight: h,
@@ -3515,12 +3577,11 @@ var Image = class extends Bitmap {
3515
3577
  h
3516
3578
  };
3517
3579
  this.isLoaded = true;
3518
- this.transform.markNeedsLayout();
3519
3580
  }
3520
3581
  calcAutoSize(naturalW, naturalH) {
3521
3582
  const pixelRatio = this.renderPixelRatio;
3522
- const targetW = Math.ceil((this.width || naturalW) * pixelRatio);
3523
- const targetH = Math.ceil((this.height || naturalH) * pixelRatio);
3583
+ const targetW = Math.ceil((this.properties.width ?? (this.fitWidth ? this.width : naturalW) ?? naturalW) * pixelRatio);
3584
+ const targetH = Math.ceil((this.properties.height ?? (this.fitHeight ? this.height : naturalH) ?? naturalH) * pixelRatio);
3524
3585
  if (!(naturalW > targetW * AUTO_DOWNSAMPLE_RATIO || naturalH > targetH * AUTO_DOWNSAMPLE_RATIO)) return {
3525
3586
  w: naturalW,
3526
3587
  h: naturalH
@@ -3536,10 +3597,10 @@ var Image = class extends Bitmap {
3536
3597
  }
3537
3598
  /** @internal 实际绘制前按当前 Viewport 检查分辨率升级。 */
3538
3599
  checkResolution() {
3539
- if (!this.isLoaded || !this.src || this.isProcessing) return;
3600
+ if (!this.isLoaded || !this.src && !this.externalImage || this.isProcessing) return;
3540
3601
  const pixelRatio = this.renderPixelRatio;
3541
- const needW = Math.ceil((this.width || this.naturalWidth) * pixelRatio);
3542
- const needH = Math.ceil((this.height || this.naturalHeight) * pixelRatio);
3602
+ const needW = Math.ceil((this.width ?? this.naturalWidth) * pixelRatio);
3603
+ const needH = Math.ceil((this.height ?? this.naturalHeight) * pixelRatio);
3543
3604
  if (needW > this.renderSize.w * UPGRADE_RATIO || needH > this.renderSize.h * UPGRADE_RATIO) {
3544
3605
  const nextSize = this.calcAutoSize(this.naturalWidth, this.naturalHeight);
3545
3606
  if (nextSize.w > this.renderSize.w || nextSize.h > this.renderSize.h) this.loadAndProcess();
@@ -3989,14 +4050,14 @@ var Group = class extends Element {
3989
4050
  rotationPivot: "adjustable"
3990
4051
  };
3991
4052
  }
3992
- captureTransformBaseline() {
4053
+ captureTransformBaseline(bakeGeometry) {
3993
4054
  const children = [];
3994
- for (const child of this.children) {
4055
+ if (bakeGeometry) for (const child of this.children) {
3995
4056
  const capability = getEditorCapability(child, TransformInteractionCapabilityToken);
3996
4057
  if (!capability) continue;
3997
4058
  children.push({
3998
4059
  capability,
3999
- baseline: capability.captureTransformBaseline()
4060
+ baseline: capability.captureTransformBaseline(true)
4000
4061
  });
4001
4062
  }
4002
4063
  return captureElementTransformBaseline(this, "pose-authored", { children });
@@ -4330,6 +4391,7 @@ var ScrollView = class extends Rectangle {
4330
4391
  root.container.addEventListener("pointerdown", (event) => {
4331
4392
  if (event.button !== 0 || !root.input.isInteractionTarget(this)) return;
4332
4393
  const logical = root.viewport.getLogicalPosition(event.clientX, event.clientY);
4394
+ this.transform.updateWorldTransformChain();
4333
4395
  const local = this.transform.toLocal(logical);
4334
4396
  const axis = local ? this.hitThumb(local) : null;
4335
4397
  if (!axis) return;
@@ -4337,7 +4399,7 @@ var ScrollView = class extends Rectangle {
4337
4399
  this.dragging = true;
4338
4400
  this.dragAxis = axis;
4339
4401
  this.dragStartScroll = axis === "y" ? this.scrollY : this.scrollX;
4340
- this.dragStartPointer = axis === "y" ? event.clientY : event.clientX;
4402
+ this.dragStartPointer = axis === "y" ? local.y : local.x;
4341
4403
  root.input.hasLockPoint = true;
4342
4404
  }, {
4343
4405
  capture: true,
@@ -4345,7 +4407,11 @@ var ScrollView = class extends Rectangle {
4345
4407
  });
4346
4408
  document.addEventListener("pointermove", (event) => {
4347
4409
  if (!this.dragging) return;
4348
- const delta = ((this.dragAxis === "y" ? event.clientY : event.clientX) - this.dragStartPointer) / root.viewport.scale;
4410
+ const logical = root.viewport.getLogicalPosition(event.clientX, event.clientY);
4411
+ this.transform.updateWorldTransformChain();
4412
+ const local = this.transform.toLocal(logical);
4413
+ if (!local) return;
4414
+ const delta = (this.dragAxis === "y" ? local.y : local.x) - this.dragStartPointer;
4349
4415
  const viewSize = this.dragAxis === "y" ? this.height ?? 0 : this.width ?? 0;
4350
4416
  const contentSize = this.dragAxis === "y" ? this.contentHeight : this.contentWidth;
4351
4417
  const thumb = this.dragAxis === "y" ? this.verticalThumb : this.horizontalThumb;
@@ -4357,11 +4423,13 @@ var ScrollView = class extends Rectangle {
4357
4423
  if (this.dragAxis === "y") this.scrollTo(this.scrollX, this.dragStartScroll + scrollDelta);
4358
4424
  else this.scrollTo(this.dragStartScroll + scrollDelta, this.scrollY);
4359
4425
  }, { signal });
4360
- document.addEventListener("pointerup", () => {
4426
+ const finishDrag = () => {
4361
4427
  if (!this.dragging) return;
4362
4428
  this.dragging = false;
4363
4429
  root.input.hasLockPoint = false;
4364
- }, { signal });
4430
+ };
4431
+ document.addEventListener("pointerup", finishDrag, { signal });
4432
+ document.addEventListener("pointercancel", finishDrag, { signal });
4365
4433
  }
4366
4434
  };
4367
4435
  //#endregion
@@ -4549,14 +4617,11 @@ function translateCreationPoints(points, left, top) {
4549
4617
  translatePoint(point, left, top);
4550
4618
  }
4551
4619
  }
4552
- function materializeEffectiveEndpointPoints(line) {
4553
- const path = line.path;
4554
- const vertices = line.getEffectiveLineVerticesView();
4620
+ function materializeEffectiveEndpointPoints(path, headPoint, tailPoint) {
4555
4621
  let anchors;
4556
- const replace = (index, relation) => {
4557
- if (!relation) return;
4622
+ const replace = (index, point) => {
4623
+ if (point === void 0) return;
4558
4624
  const current = path.anchors[index];
4559
- const point = vertices[index].point;
4560
4625
  if (Object.is(current.point, point)) return;
4561
4626
  anchors ??= [...path.anchors];
4562
4627
  anchors[index] = {
@@ -4564,8 +4629,8 @@ function materializeEffectiveEndpointPoints(line) {
4564
4629
  point
4565
4630
  };
4566
4631
  };
4567
- replace(0, line.headRelation);
4568
- replace(path.anchors.length - 1, line.tailRelation);
4632
+ replace(0, headPoint);
4633
+ if (path.anchors.length > 1) replace(path.anchors.length - 1, tailPoint);
4569
4634
  return anchors ? {
4570
4635
  ...path,
4571
4636
  anchors
@@ -4692,7 +4757,7 @@ var LineTransform = class extends ElementTransform {
4692
4757
  return this.buildLayoutReferenceBounds();
4693
4758
  }
4694
4759
  worldMatrixAffectsLocalGeometry() {
4695
- return true;
4760
+ return !!(this.element.headRelation || this.element.tailRelation);
4696
4761
  }
4697
4762
  resolveEndpointPoint(relation) {
4698
4763
  const endpoint = relation?.target;
@@ -4898,14 +4963,15 @@ var BaseLine = class extends Element {
4898
4963
  path
4899
4964
  } : { path };
4900
4965
  }
4901
- captureTransformBaseline() {
4966
+ captureTransformBaseline(_bakeGeometry) {
4902
4967
  const path = this.path;
4903
4968
  const baseline = captureElementTransformBaseline(this, "authored-geometry", path);
4904
4969
  if (!this.headRelation && !this.tailRelation) return {
4905
4970
  reference: baseline.reference,
4906
4971
  ownedState: { path }
4907
4972
  };
4908
- const effectivePath = materializeEffectiveEndpointPoints(this);
4973
+ const vertices = this.getEffectiveLineVerticesView();
4974
+ const effectivePath = materializeEffectiveEndpointPoints(path, this.headRelation ? vertices[0].point : void 0, this.tailRelation ? last(vertices).point : void 0);
4909
4975
  const referenceBounds = effectivePath === path ? baseline.reference.referenceBounds : getAuthoredSubpathBounds(effectivePath);
4910
4976
  return {
4911
4977
  reference: baseline.reference,
@@ -5014,9 +5080,7 @@ var BaseLine = class extends Element {
5014
5080
  patch: finalPatch
5015
5081
  } : null;
5016
5082
  const vertices = this.getEffectiveLineVerticesView();
5017
- let path = beforePath;
5018
- if (detachHead) path = replaceAuthoredAnchorPoint(path, head.anchorId, localPositions?.get(head.anchorId) ?? vertices[0].point);
5019
- if (detachTail && tail.anchorId !== head?.anchorId) path = replaceAuthoredAnchorPoint(path, tail.anchorId, localPositions?.get(tail.anchorId) ?? last(vertices).point);
5083
+ const path = materializeEffectiveEndpointPoints(beforePath, detachHead ? localPositions?.get(head.anchorId) ?? vertices[0].point : void 0, detachTail && tail.anchorId !== head?.anchorId ? localPositions?.get(tail.anchorId) ?? last(vertices).point : void 0);
5020
5084
  const geometryPatch = finalPatch ? {
5021
5085
  ...resolveReferenceBoundsPosePatch(this, () => [getAuthoredSubpathBounds(beforePath), getAuthoredSubpathBounds(path)], finalPatch),
5022
5086
  path
@@ -5092,13 +5156,14 @@ var BaseLine = class extends Element {
5092
5156
  if (!local) return;
5093
5157
  const appended = appendAuthoredLineAnchor(this.path, local);
5094
5158
  this.setOptions({
5095
- path: appended.subpath,
5159
+ ...this.resolvePointPathPatch(appended.subpath),
5096
5160
  relations: { tail: relation }
5097
5161
  });
5098
5162
  return appended.anchorId;
5099
5163
  }
5100
5164
  setLocalPoint(anchorId, point, endpointUpdate) {
5101
- const patch = { path: replaceAuthoredAnchorPoint(this.path, anchorId, point) };
5165
+ const path = replaceAuthoredAnchorPoint(this.path, anchorId, point);
5166
+ const patch = this.resolvePointPathPatch(path);
5102
5167
  if (endpointUpdate && has(endpointUpdate, "target")) {
5103
5168
  const head = this.headAnchor?.anchorId === anchorId;
5104
5169
  const tail = this.tailAnchor?.anchorId === anchorId;
@@ -5122,7 +5187,7 @@ var BaseLine = class extends Element {
5122
5187
  const local = this.worldToLocal(worldX, worldY);
5123
5188
  if (!local) return;
5124
5189
  const inserted = insertAuthoredLineAnchor(this.path, segmentId, local);
5125
- this.setOptions({ path: inserted.subpath });
5190
+ this.setOptions(this.resolvePointPathPatch(inserted.subpath));
5126
5191
  return inserted.anchorId;
5127
5192
  }
5128
5193
  removePoint(anchorId) {
@@ -5131,7 +5196,7 @@ var BaseLine = class extends Element {
5131
5196
  const path = removeAuthoredAnchor(this.path, anchorId);
5132
5197
  if (path === this.path) return;
5133
5198
  this.setOptions({
5134
- path,
5199
+ ...this.resolvePointPathPatch(path),
5135
5200
  ...head || tail ? { relations: {
5136
5201
  ...head ? { head: void 0 } : {},
5137
5202
  ...tail ? { tail: void 0 } : {}
@@ -5342,30 +5407,6 @@ function getLineTreePointDegrees(topology) {
5342
5407
  }
5343
5408
  return degrees;
5344
5409
  }
5345
- function getLineTreeEndpointRelationBindings(topology, elementKey) {
5346
- const rootAnchorId = (topology.rootSubpathId === void 0 ? void 0 : getLineTreeBranch(topology, topology.rootSubpathId))?.vertices[0]?.anchorId;
5347
- const degrees = getLineTreePointDegrees(topology);
5348
- const bindings = [];
5349
- for (const point of topology.points) {
5350
- if (!point.relation || degrees.get(point.anchorId) !== 1) continue;
5351
- bindings.push({
5352
- source: {
5353
- elementKey,
5354
- anchorId: point.anchorId
5355
- },
5356
- relation: point.relation,
5357
- role: point.anchorId === rootAnchorId ? "output" : "input"
5358
- });
5359
- }
5360
- return bindings;
5361
- }
5362
- function getLineTreeBindableEndpoints(topology, elementKey) {
5363
- const degrees = getLineTreePointDegrees(topology);
5364
- return topology.points.filter(({ anchorId }) => degrees.get(anchorId) === 1).map(({ anchorId }) => ({ ref: {
5365
- elementKey,
5366
- anchorId
5367
- } }));
5368
- }
5369
5410
  function moveLineTreePoint(topology, anchorId, point, relation) {
5370
5411
  const index = topology.points.findIndex((candidate) => candidate.anchorId === anchorId);
5371
5412
  const current = topology.points[index];
@@ -5558,6 +5599,7 @@ function remapLineTreeRelations(topology, keyMap) {
5558
5599
  var LineTreeTransform = class extends ElementTransform {
5559
5600
  topologySource = null;
5560
5601
  pointById = /* @__PURE__ */ new Map();
5602
+ hasEndpointRelations = false;
5561
5603
  branchById = /* @__PURE__ */ new Map();
5562
5604
  endpointRoleById;
5563
5605
  junctionAnchorIds = [];
@@ -5568,7 +5610,7 @@ var LineTreeTransform = class extends ElementTransform {
5568
5610
  worldBranchPoints = [];
5569
5611
  worldBranchPointsById = /* @__PURE__ */ new Map();
5570
5612
  worldPointById = /* @__PURE__ */ new Map();
5571
- worldSnapPoints = [];
5613
+ worldSnapPoints;
5572
5614
  worldMatrixA = NaN;
5573
5615
  worldMatrixB = NaN;
5574
5616
  worldMatrixC = NaN;
@@ -5577,14 +5619,32 @@ var LineTreeTransform = class extends ElementTransform {
5577
5619
  worldMatrixF = NaN;
5578
5620
  ensureTopologyViews() {
5579
5621
  const topology = this.element.topology;
5580
- if (this.topologySource === topology) return;
5622
+ const previous = this.topologySource;
5623
+ if (previous === topology) return;
5624
+ const previousRootAnchorId = previous?.rootSubpathId === void 0 ? void 0 : this.branchById.get(previous.rootSubpathId)?.vertices[0]?.anchorId;
5581
5625
  this.topologySource = topology;
5582
- this.pointById = new Map(topology.points.map((point) => [point.anchorId, point]));
5583
- this.branchById = new Map(topology.branches.map((branch) => [branch.subpathId, branch]));
5584
- this.endpointRoleById = void 0;
5585
- this.junctionAnchorIds = getLineTreeJunctionAnchorIds(topology);
5586
- this.junctionAnchorIdSet = new Set(this.junctionAnchorIds);
5587
- this.layoutBounds = getLineTreeTopologyBounds(topology);
5626
+ if (!previous || previous.points !== topology.points) {
5627
+ this.hasEndpointRelations = false;
5628
+ this.pointById.clear();
5629
+ for (const point of topology.points) {
5630
+ this.hasEndpointRelations ||= point.relation !== void 0;
5631
+ this.pointById.set(point.anchorId, point);
5632
+ }
5633
+ this.layoutBounds = getLineTreeTopologyBounds(topology);
5634
+ }
5635
+ let verticesChanged = !previous;
5636
+ if (!previous || previous.branches !== topology.branches) {
5637
+ verticesChanged = !previous || previous.branches.length !== topology.branches.length || topology.branches.some((branch, index) => branch.vertices !== previous.branches[index].vertices);
5638
+ this.branchById.clear();
5639
+ for (const branch of topology.branches) this.branchById.set(branch.subpathId, branch);
5640
+ if (verticesChanged) {
5641
+ this.junctionAnchorIds = getLineTreeJunctionAnchorIds(topology);
5642
+ this.junctionAnchorIdSet.clear();
5643
+ for (const anchorId of this.junctionAnchorIds) this.junctionAnchorIdSet.add(anchorId);
5644
+ }
5645
+ }
5646
+ const rootAnchorId = topology.rootSubpathId === void 0 ? void 0 : this.branchById.get(topology.rootSubpathId)?.vertices[0]?.anchorId;
5647
+ if (verticesChanged || rootAnchorId !== previousRootAnchorId) this.endpointRoleById = void 0;
5588
5648
  }
5589
5649
  buildEndpointRoles() {
5590
5650
  const topology = this.element.topology;
@@ -5630,7 +5690,8 @@ var LineTreeTransform = class extends ElementTransform {
5630
5690
  return this.buildLayoutReferenceBounds();
5631
5691
  }
5632
5692
  worldMatrixAffectsLocalGeometry() {
5633
- return true;
5693
+ this.ensureTopologyViews();
5694
+ return this.hasEndpointRelations;
5634
5695
  }
5635
5696
  resolveEndpointPoint(point) {
5636
5697
  const endpoint = point.relation?.target;
@@ -5731,9 +5792,7 @@ var LineTreeTransform = class extends ElementTransform {
5731
5792
  snapshot.subpaths.forEach((subpath, index) => {
5732
5793
  if (subpath.subpathId !== void 0) this.worldBranchPointsById.set(subpath.subpathId, this.worldBranchPoints[index]);
5733
5794
  });
5734
- this.worldSnapPoints = this.element.topology.points.map((point) => {
5735
- return this.worldPointById.get(point.anchorId);
5736
- });
5795
+ this.worldSnapPoints = void 0;
5737
5796
  }
5738
5797
  getWorldBranchPointsView(subpathId) {
5739
5798
  this.updateWorldPoints();
@@ -5745,7 +5804,7 @@ var LineTreeTransform = class extends ElementTransform {
5745
5804
  }
5746
5805
  getWorldSnapPointsView() {
5747
5806
  this.updateWorldPoints();
5748
- return this.worldSnapPoints;
5807
+ return this.worldSnapPoints ??= this.element.topology.points.map((point) => this.worldPointById.get(point.anchorId));
5749
5808
  }
5750
5809
  getBranchTailSource(subpathId) {
5751
5810
  const anchorId = last(this.getBranch(subpathId).vertices).anchorId;
@@ -5829,10 +5888,32 @@ var LineTree = class extends Element {
5829
5888
  return [];
5830
5889
  }
5831
5890
  getBindableEndpoints() {
5832
- return getLineTreeBindableEndpoints(this.topology, this.key);
5891
+ const endpoints = [];
5892
+ for (const point of this.topology.points) {
5893
+ if (this.transform.getEndpointRole(point.anchorId) === null) continue;
5894
+ endpoints.push({ ref: {
5895
+ elementKey: this.key,
5896
+ anchorId: point.anchorId
5897
+ } });
5898
+ }
5899
+ return endpoints;
5833
5900
  }
5834
5901
  getEndpointRelationBindings() {
5835
- return getLineTreeEndpointRelationBindings(this.topology, this.key);
5902
+ const bindings = [];
5903
+ for (const point of this.topology.points) {
5904
+ if (!point.relation) continue;
5905
+ const role = this.transform.getEndpointRole(point.anchorId);
5906
+ if (role === null) continue;
5907
+ bindings.push({
5908
+ source: {
5909
+ elementKey: this.key,
5910
+ anchorId: point.anchorId
5911
+ },
5912
+ relation: point.relation,
5913
+ role
5914
+ });
5915
+ }
5916
+ return bindings;
5836
5917
  }
5837
5918
  resolveOptions(options) {
5838
5919
  return prepareTopologyOption(options);
@@ -5875,28 +5956,14 @@ var LineTree = class extends Element {
5875
5956
  points
5876
5957
  };
5877
5958
  }
5878
- preservePoseForTopology(topology) {
5879
- if (this.angle === 0 && this.scaleX === 1 && this.scaleY === 1 && this.skewX === 0 && this.skewY === 0) return { topology };
5880
- const referenceBounds = getLineTreeTopologyBounds(topology);
5881
- const baseline = captureElementTransformBaseline(this, "pose-authored", void 0).reference;
5882
- const worldMatrix = baseline.startWorldMatrix;
5883
- const worldCenter = transformPoint(worldMatrix, {
5884
- x: referenceBounds.left + referenceBounds.width / 2,
5885
- y: referenceBounds.top + referenceBounds.height / 2
5886
- });
5959
+ /** @internal Point edits and branch extension retain the current world pose. */
5960
+ resolvePointTopologyPatch(topology) {
5887
5961
  return {
5888
- ...resolveReferenceTransformTarget({
5889
- ...baseline,
5890
- referenceBounds
5891
- }, {
5892
- worldMatrix,
5893
- worldCenter,
5894
- parentInverseMatrix: baseline.startParentWorldInverseMatrix
5895
- }).framePatch,
5962
+ ...resolveReferenceBoundsPosePatch(this, () => [this.transform.getLayoutReferenceBoundsView(), getLineTreeTopologyBounds(topology)]),
5896
5963
  topology
5897
5964
  };
5898
5965
  }
5899
- captureTransformBaseline() {
5966
+ captureTransformBaseline(_bakeGeometry) {
5900
5967
  const topology = this.topology;
5901
5968
  const baseline = captureElementTransformBaseline(this, "pose-authored", { topology });
5902
5969
  if (!topology.points.some((point) => point.relation)) return baseline;
@@ -6025,7 +6092,7 @@ var LineTree = class extends Element {
6025
6092
  kind: "owner-change",
6026
6093
  change: {
6027
6094
  owner: this,
6028
- patch: this.preservePoseForTopology(removal.topology)
6095
+ patch: this.resolvePointTopologyPatch(removal.topology)
6029
6096
  },
6030
6097
  ...removal.parentSubpathId === void 0 ? {} : { nextScope: {
6031
6098
  kind: "subpath",
@@ -6039,7 +6106,7 @@ var LineTree = class extends Element {
6039
6106
  kind: "owner-change",
6040
6107
  change: {
6041
6108
  owner: this,
6042
- patch: this.preservePoseForTopology(inserted.topology)
6109
+ patch: this.resolvePointTopologyPatch(inserted.topology)
6043
6110
  },
6044
6111
  nextTarget: {
6045
6112
  kind: "anchor",
@@ -6064,7 +6131,7 @@ var LineTree = class extends Element {
6064
6131
  kind: "owner-change",
6065
6132
  change: {
6066
6133
  owner: this,
6067
- patch: this.preservePoseForTopology(topology)
6134
+ patch: this.resolvePointTopologyPatch(topology)
6068
6135
  }
6069
6136
  };
6070
6137
  }
@@ -6135,6 +6202,7 @@ function samePoint(left, right) {
6135
6202
  return left === right || left.anchorId === right.anchorId && left.point.x === right.point.x && left.point.y === right.point.y && sameEndpointRelation(left.relation, right.relation);
6136
6203
  }
6137
6204
  function diffRecords(before, after, getId, sameValue) {
6205
+ if (before === after) return [];
6138
6206
  const beforeById = /* @__PURE__ */ new Map();
6139
6207
  const afterById = /* @__PURE__ */ new Map();
6140
6208
  before.forEach((value, index) => {
@@ -6203,4 +6271,4 @@ function applyLineTreeTopologyDelta(topology, delta, direction) {
6203
6271
  };
6204
6272
  }
6205
6273
  //#endregion
6206
- export { BaseLine, Bitmap, Circle, CircleTransform, ContentEditingCapabilityToken, DEFAULT_LINE_TREE_BRANCH_STYLE, EMPTY_LINE_TREE_TOPOLOGY, EditorFrameFlush, EndpointRelationIndex, Group, GroupTransform, Image, ImageProperties, ImageTransform, Line, LineTransform, LineTree, LineTreeProperties, LineTreeTransform, PointEditingCapabilityToken, Polygon, PolygonTransform, Rectangle, RectangleProperties, RectangleTransform, RippleOverlay, ScrollView, ScrollViewTransform, SelectionBehaviorCapabilityToken, SelectionBehaviorMode, SelectionDiveMode, SelectionSnapMode, SnapSourceCapabilityToken, Text, TextBlock, TextProperties, TextTransform, TransformInteractionCapabilityToken, Triangle, TriangleTransform, VectorPath, VectorPathProperties, VectorPathTransform, WorkerSurfacePool, Workspace, WorkspaceProperties, addLineTreeBranchAtTail, applyLineTreeTopologyDelta, computePosition, connectEndpoint, connectionPortAccepts, createLineTreeTopology, createLineTreeTopologyDelta, defineEditorCapability, disconnectEndpoint, fitWorkspace, flip, getEditorCapability, getEditorFrameFlush, getEndpointRelationIndex, getLineTreeBindableEndpoints, getLineTreeBranch, getLineTreeEndpointRelationBindings, getLineTreeJunctionAnchorIds, getLineTreePoint, getLineTreePointReferenceCounts, getTextBlockVisualBounds, hasConnectionPortCapacity, insertLineTreePoint, isEditorCapabilityHost, isEndpointRelationSource, measureTextRun, measureTextWidth, moveLineTreePoint, offset, paintTextBlock, remapLineTreeRelations, removeLineTreeBranch, removeLineTreePoint, resolveConnectEndpointChange, resolveConnectionPortChanges, resolveDisconnectEndpointChanges, resolveGroupMemberBounds, resolveSelectionFrameBounds, resolveTextStyle, shift, subscribeTextMeasurementChanges, transformLineTreeTopology, updateLineTreeBranchStyle, workspaceFocusInsetsKey };
6274
+ export { BaseLine, Bitmap, Circle, CircleTransform, ContentEditingCapabilityToken, DEFAULT_LINE_TREE_BRANCH_STYLE, EMPTY_LINE_TREE_TOPOLOGY, EditorFrameFlush, EndpointRelationIndex, Group, GroupTransform, Image, ImageProperties, ImageTransform, Line, LineTransform, LineTree, LineTreeProperties, LineTreeTransform, PointEditingCapabilityToken, Polygon, PolygonTransform, Rectangle, RectangleProperties, RectangleTransform, RippleOverlay, ScrollView, ScrollViewTransform, SelectionBehaviorCapabilityToken, SelectionBehaviorMode, SelectionDiveMode, SelectionSnapMode, SnapSourceCapabilityToken, Text, TextBlock, TextProperties, TextTransform, TransformInteractionCapabilityToken, Triangle, TriangleTransform, VectorPath, VectorPathProperties, VectorPathTransform, WorkerSurfacePool, Workspace, WorkspaceProperties, addLineTreeBranchAtTail, applyLineTreeTopologyDelta, computePosition, connectEndpoint, connectionPortAccepts, createLineTreeTopology, createLineTreeTopologyDelta, defineEditorCapability, disconnectEndpoint, fitWorkspace, flip, getEditorCapability, getEditorFrameFlush, getEndpointRelationIndex, getLineTreeBranch, getLineTreeJunctionAnchorIds, getLineTreePoint, getLineTreePointReferenceCounts, getTextBlockVisualBounds, hasConnectionPortCapacity, insertLineTreePoint, isEditorCapabilityHost, isEndpointRelationSource, measureTextRun, measureTextWidth, moveLineTreePoint, offset, paintTextBlock, remapLineTreeRelations, removeLineTreeBranch, removeLineTreePoint, resolveConnectEndpointChange, resolveConnectionPortChanges, resolveDisconnectEndpointChanges, resolveGroupMemberBounds, resolveSelectionFrameBounds, resolveTextStyle, shift, subscribeTextMeasurementChanges, transformLineTreeTopology, updateLineTreeBranchStyle, workspaceFocusInsetsKey };
@@ -109,7 +109,7 @@ export declare abstract class BaseLine extends Element<LineProperties, LineOptio
109
109
  readonly rotationPivot: "adjustable";
110
110
  };
111
111
  protected resolvePointPathPatch(path: AuthoredSubpath): LinePatch;
112
- captureTransformBaseline(): ElementTransformBaseline<LineTransformOwnedState>;
112
+ captureTransformBaseline(_bakeGeometry: boolean): ElementTransformBaseline<LineTransformOwnedState>;
113
113
  resolveTransformChange(baseline: Readonly<ElementTransformBaseline<LineTransformOwnedState>>, intent: Readonly<TransformIntent | ReparentTransformIntent>): readonly OwnerPropertyChange[];
114
114
  protected resolveOptions(options: LinePatch): LinePatch;
115
115
  get headAnchor(): AuthoredPathAnchor;
@@ -1,5 +1,5 @@
1
1
  import { ChangeImpact, Element, ElementProperties, type ElementTransformBaseline, type ConnectionPortRef, type Layer, type OwnerPropertyChange, type PropertyChanges, type ReparentTransformIntent, type Root, type AnchorId, type SubpathId, type TransformIntent } from "@fulate/core";
2
- import { type PointView } from "@fulate/share";
2
+ import type { PointView } from "@fulate/share";
3
3
  import { SelectionBehaviorMode, SelectionDiveMode, SelectionSnapMode, type EditorCapabilityToken, type PointEditRequest, type PointEditingScope, type PointOwnerEdit } from "../editor/capability";
4
4
  import { type BindableEndpoint, type EndpointRelation, type EndpointRelationBinding } from "../connection/types";
5
5
  import { LineTreeTransform } from "./transform";
@@ -43,8 +43,9 @@ export declare class LineTree extends Element<LineTreeProperties, LineTreeOption
43
43
  readonly rotationPivot: "adjustable";
44
44
  };
45
45
  private materializeEffectiveTopology;
46
- private preservePoseForTopology;
47
- captureTransformBaseline(): ElementTransformBaseline<LineTreeTransformOwnedState>;
46
+ /** @internal Point edits and branch extension retain the current world pose. */
47
+ resolvePointTopologyPatch(topology: LineTreeTopology): LineTreePatch;
48
+ captureTransformBaseline(_bakeGeometry: boolean): ElementTransformBaseline<LineTreeTransformOwnedState>;
48
49
  resolveTransformChange(baseline: Readonly<ElementTransformBaseline<LineTreeTransformOwnedState>>, intent: Readonly<TransformIntent | ReparentTransformIntent>): readonly OwnerPropertyChange[];
49
50
  getWorldSnapPointsView(): readonly PointView[];
50
51
  getEndpointRole(anchorId: AnchorId): "input" | "output";
@@ -70,5 +71,5 @@ export declare class LineTree extends Element<LineTreeProperties, LineTreeOption
70
71
  protected onDeactivate(root: Root | null, layer: Layer | null): void;
71
72
  }
72
73
  export { LineTreeTransform } from "./transform";
73
- export { EMPTY_LINE_TREE_TOPOLOGY, DEFAULT_LINE_TREE_BRANCH_STYLE, addLineTreeBranchAtTail, createLineTreeTopology, getLineTreeBranch, getLineTreeBindableEndpoints, getLineTreeEndpointRelationBindings, getLineTreeEndpointRole, getLineTreeJunctionAnchorIds, getLineTreePoint, getLineTreePointReferenceCounts, insertLineTreePoint, moveLineTreePoint, removeLineTreeBranch, removeLineTreePoint, remapLineTreeRelations, transformLineTreeTopology, updateLineTreeBranchStyle } from "./topology";
74
+ export { EMPTY_LINE_TREE_TOPOLOGY, DEFAULT_LINE_TREE_BRANCH_STYLE, addLineTreeBranchAtTail, createLineTreeTopology, getLineTreeBranch, getLineTreeJunctionAnchorIds, getLineTreePoint, getLineTreePointReferenceCounts, insertLineTreePoint, moveLineTreePoint, removeLineTreeBranch, removeLineTreePoint, remapLineTreeRelations, transformLineTreeTopology, updateLineTreeBranchStyle } from "./topology";
74
75
  export type { LineTreeBranch, LineTreeBranchRemoval, LineTreeBranchTailSource, LineTreeBranchStyle, LineTreeBranchVertex, LineTreeOption, LineTreePoint, LineTreeTopology } from "./types";
@@ -1,7 +1,7 @@
1
1
  import { type AnchorId, type SegmentId, type SubpathId } from "@fulate/core";
2
2
  import { type PointView, type ReadonlyMatrix2D, type Rect } from "@fulate/share";
3
3
  import type { LineEndpointRelationPatch } from "../line/base";
4
- import type { BindableEndpoint, EndpointRelation, EndpointRelationBinding } from "../connection/types";
4
+ import type { EndpointRelation } from "../connection/types";
5
5
  import type { LineTreeBranch, LineTreeBranchRemoval, LineTreeBranchStyle, LineTreePoint, LineTreeTopology } from "./types";
6
6
  export declare const EMPTY_LINE_TREE_TOPOLOGY: LineTreeTopology;
7
7
  export declare const DEFAULT_LINE_TREE_BRANCH_STYLE: LineTreeBranchStyle;
@@ -12,9 +12,6 @@ export declare function getLineTreeBranch(topology: LineTreeTopology, subpathId:
12
12
  export declare function getLineTreePointReferenceCounts(topology: LineTreeTopology): Map<AnchorId, number>;
13
13
  export declare function getLineTreeJunctionAnchorIds(topology: LineTreeTopology): AnchorId[];
14
14
  export declare function getLineTreePointDegrees(topology: LineTreeTopology): Map<AnchorId, number>;
15
- export declare function getLineTreeEndpointRelationBindings(topology: LineTreeTopology, elementKey: string): readonly EndpointRelationBinding[];
16
- export declare function getLineTreeBindableEndpoints(topology: LineTreeTopology, elementKey: string): readonly BindableEndpoint[];
17
- export declare function getLineTreeEndpointRole(topology: LineTreeTopology, anchorId: AnchorId): "input" | "output";
18
15
  export declare function moveLineTreePoint(topology: LineTreeTopology, anchorId: AnchorId, point: PointView, relation: EndpointRelation | undefined): LineTreeTopology;
19
16
  export declare function insertLineTreePoint(topology: LineTreeTopology, segmentId: SegmentId, point: PointView): {
20
17
  topology: {
@@ -5,6 +5,7 @@ import type { LineTreeBranch, LineTreeBranchTailSource, LineTreePoint } from "./
5
5
  export declare class LineTreeTransform<E extends LineTree = LineTree> extends ElementTransform<E> {
6
6
  private topologySource;
7
7
  private pointById;
8
+ private hasEndpointRelations;
8
9
  private branchById;
9
10
  private endpointRoleById;
10
11
  private junctionAnchorIds;
package/dist/polygon.d.ts CHANGED
@@ -35,8 +35,9 @@ export declare class Polygon extends EditorShape<PolygonProperties, PolygonOptio
35
35
  };
36
36
  getPointControls(_scope: PointEditingScope): import(".").PointControlDescriptor[];
37
37
  getPointScopeOutline(_scope: PointEditingScope): any;
38
+ private resolvePointContourPatch;
38
39
  resolvePointEdit(request: PointEditRequest): PointOwnerEdit | null;
39
- captureTransformBaseline(): ElementTransformBaseline<AuthoredSubpath<import("@fulate/core").AuthoredPathAnchor>>;
40
+ captureTransformBaseline(_bakeGeometry: boolean): ElementTransformBaseline<AuthoredSubpath<import("@fulate/core").AuthoredPathAnchor>>;
40
41
  resolveTransformChange(baseline: Readonly<ElementTransformBaseline<AuthoredSubpath>>, intent: Readonly<TransformIntent | ReparentTransformIntent>): readonly OwnerPropertyChange[];
41
42
  protected buildPath(ctx: CanvasRenderingContext2D): void;
42
43
  protected buildBorderPath(ctx: CanvasRenderingContext2D): void;
@@ -137,6 +137,7 @@ export declare class Text<P extends TextProperties = TextProperties, O extends T
137
137
  getVisibleTextBounds(): Rect | null;
138
138
  enterEditing(initialClickLocal?: PointView): void;
139
139
  exitEditing(): void;
140
+ /** 更新文本属性,并同步当前正在使用的 textarea。 */
140
141
  setEditingText(value: string): void;
141
142
  protected onPropertiesChanged(current: P, changes: PropertyChanges): void;
142
143
  protected onActivate(root: Root | null, layer: Layer | null): void;
@@ -111,6 +111,7 @@ export declare class TextLayoutSnapshot {
111
111
  getLineSourceRange(index: number): TextLineSourceRange;
112
112
  getLineIndex(offset: number): number;
113
113
  getLineX(index: number, width: number, textAlign: string): number;
114
+ getBlockHorizontalOffset(width: number, textAlign: string, contentWidth?: number): number;
114
115
  getBlockVerticalOffset(height: number, verticalAlign: string, contentHeight?: number): number;
115
116
  getCaretLocalXY(caretIndex: number, width: number, height: number, textAlign: string, verticalAlign: string, fontSize: number): {
116
117
  x: number;
@@ -51,7 +51,7 @@ export declare class VectorPath extends EditorShape<VectorPathProperties, Vector
51
51
  private findAnchor;
52
52
  private findSegment;
53
53
  private ownerPathChange;
54
- captureTransformBaseline(): ElementTransformBaseline<VectorPathGeometry>;
54
+ captureTransformBaseline(_bakeGeometry: boolean): ElementTransformBaseline<VectorPathGeometry>;
55
55
  resolveTransformChange(baseline: Readonly<ElementTransformBaseline<VectorPathGeometry>>, intent: Readonly<TransformIntent | ReparentTransformIntent>): readonly OwnerPropertyChange[];
56
56
  protected buildPath(ctx: CanvasRenderingContext2D): void;
57
57
  }
@@ -89,7 +89,7 @@ var BitmapFrameEmitter = class {
89
89
  const pending = createImageBitmap(this.getCanvas());
90
90
  this.pending = pending;
91
91
  pending.then((bitmap) => {
92
- if (!this.active || this.paused || this.pending !== pending || this.queued) {
92
+ if (!this.active || this.paused || this.queued) {
93
93
  bitmap.close();
94
94
  return;
95
95
  }
@@ -100,7 +100,7 @@ var BitmapFrameEmitter = class {
100
100
  throw error;
101
101
  }
102
102
  }).finally(() => {
103
- if (this.pending === pending) this.pending = null;
103
+ this.pending = null;
104
104
  if (this.active && !this.paused && this.queued) this.flush();
105
105
  });
106
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fulate/ui",
3
- "version": "1.0.15",
3
+ "version": "1.0.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",