@fulate/core 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/dist/geometry/common.d.ts +5 -2
- package/dist/geometry/index.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +321 -237
- package/dist/layer/index.d.ts +0 -2
- package/dist/mutation/change-batch.d.ts +3 -2
- package/dist/mutation/structure-change.d.ts +7 -2
- package/dist/node/element.d.ts +2 -2
- package/dist/node/node.d.ts +5 -5
- package/dist/node/shape.d.ts +1 -1
- package/dist/root/frame-runtime.d.ts +1 -2
- package/dist/root/index.d.ts +1 -1
- package/dist/root/input-controller.d.ts +2 -0
- package/package.json +1 -1
|
@@ -72,9 +72,10 @@ export interface GeometryQuery {
|
|
|
72
72
|
/**
|
|
73
73
|
* 返回所有 subpath line/cubic 的精确 local AABB;无顶点时为 `null`。
|
|
74
74
|
*
|
|
75
|
-
*
|
|
75
|
+
* 返回值是只读 borrowed view:同一 query 在其 snapshot
|
|
76
76
|
* 生命周期内重复返回同一引用,不会 clone 或 freeze。需要独立修改的
|
|
77
77
|
* 调用者必须在消费边界自行复制。
|
|
78
|
+
* snapshot 省略 reference bounds 时直接复用其精确结果,不建立 segment index。
|
|
78
79
|
*/
|
|
79
80
|
getBounds(): Readonly<Rect> | null;
|
|
80
81
|
/** 判断 local 点是否位于闭合 subpath 的指定填充内或边界上。 */
|
|
@@ -107,6 +108,8 @@ export interface PathSegmentSplit {
|
|
|
107
108
|
}
|
|
108
109
|
/** Split one canonical line/cubic segment at `t` without a second curve owner. */
|
|
109
110
|
export declare function splitPathSegment(start: PointView, shape: ResolvedSegmentShape, end: PointView, t: number): PathSegmentSplit;
|
|
111
|
+
/** 直接读取 authored anchors 的精确 line/cubic bounds,不创建 resolved 投影。 */
|
|
112
|
+
export declare function getAuthoredPathLayoutBounds(subpaths: readonly AuthoredSubpath[]): Readonly<Rect>;
|
|
110
113
|
/**
|
|
111
114
|
* 直接采用输入对象及其 subpath、point、control、标量 authored ID 和 bounds 引用。
|
|
112
115
|
* 省略 bounds 时在同一输入对象上安装一次派生结果;不创建 GeometryQuery index。
|
|
@@ -115,7 +118,7 @@ export declare function createGeometrySnapshot(input: GeometrySnapshotInput): Ge
|
|
|
115
118
|
/** @internal 通用 line/cubic canonical query。 */
|
|
116
119
|
export declare class SnapshotGeometryQuery implements GeometryQuery {
|
|
117
120
|
readonly snapshot: GeometrySnapshot;
|
|
118
|
-
/**
|
|
121
|
+
/** 第一次需要 segment 的 query 前保持 `null`。 */
|
|
119
122
|
private index;
|
|
120
123
|
private debugStats;
|
|
121
124
|
constructor(snapshot: GeometrySnapshot);
|
package/dist/geometry/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Rect } from "@fulate/share";
|
|
2
2
|
import { type GeometryQuery, type GeometrySnapshot } from "./common";
|
|
3
3
|
export { createAuthoredLineSubpath, createPathLocalId } from "./authored";
|
|
4
|
-
export { createGeometrySnapshot, createLineSubpath, evaluatePathSegmentPoint, resolveAuthoredSubpath, splitPathSegment } from "./common";
|
|
4
|
+
export { createGeometrySnapshot, createLineSubpath, evaluatePathSegmentPoint, getAuthoredPathLayoutBounds, resolveAuthoredSubpath, splitPathSegment } from "./common";
|
|
5
5
|
export type { GeometryNearestPoint, GeometryPathPoint, GeometryPathPosition, GeometryQuery, GeometrySnapshot, GeometrySnapshotInput, PathSegmentSplit, ResolvedSegmentShape, ResolvedSubpath, ResolvedVertex } from "./common";
|
|
6
6
|
export type { AnchorId, AuthoredCubicAnchor, AuthoredLineAnchor, AuthoredPathAnchor, AuthoredSubpath, AuthoredTerminalAnchor, SegmentId, StablePathTargetRef, SubpathId } from "./authored";
|
|
7
7
|
export { createRectangleGeometrySnapshot, rectangleSubpathsMaterializedForTest } from "./rectangle";
|
package/dist/index.d.ts
CHANGED
|
@@ -31,5 +31,5 @@ export { diffChildren } from "./mutation/structure-change";
|
|
|
31
31
|
export type { ChildPlacementChange, ChildrenDiff } from "./mutation/structure-change";
|
|
32
32
|
export { Layer, LayerProperties, LayerTransform } from "./layer/index";
|
|
33
33
|
export type { LayerFrameWork, LayerOption, LayerOptionPatch } from "./layer/index";
|
|
34
|
-
export { createAuthoredLineSubpath, createPathLocalId, createGeometryQuery, createGeometrySnapshot, createLineSubpath, evaluatePathSegmentPoint, resolveAuthoredSubpath, splitPathSegment } from "./geometry";
|
|
34
|
+
export { createAuthoredLineSubpath, createPathLocalId, createGeometryQuery, createGeometrySnapshot, createLineSubpath, evaluatePathSegmentPoint, getAuthoredPathLayoutBounds, resolveAuthoredSubpath, splitPathSegment } from "./geometry";
|
|
35
35
|
export type { AnchorId, AuthoredCubicAnchor, AuthoredLineAnchor, AuthoredPathAnchor, AuthoredSubpath, AuthoredTerminalAnchor, SegmentId, StablePathTargetRef, SubpathId, ResolvedVertex, ResolvedSegmentShape, ResolvedSubpath, GeometrySnapshot, GeometrySnapshotInput, GeometryPathPosition, GeometryPathPoint, GeometryNearestPoint, GeometryQuery, PathSegmentSplit } from "./geometry";
|
package/dist/index.js
CHANGED
|
@@ -527,7 +527,7 @@ var TransformProperties = class extends NodeProperties {
|
|
|
527
527
|
//#region packages/core/src/mutation/structure-change.ts
|
|
528
528
|
var NO_STRUCTURE_BATCH = {
|
|
529
529
|
changes: [],
|
|
530
|
-
placementNodes: /* @__PURE__ */ new
|
|
530
|
+
placementNodes: /* @__PURE__ */ new Map()
|
|
531
531
|
};
|
|
532
532
|
/** 标出一组互不相同数值中的一个最长递增子序列。 */
|
|
533
533
|
function markLongestIncreasingSubsequence(values) {
|
|
@@ -606,7 +606,7 @@ function prepareStructureBatch(effects) {
|
|
|
606
606
|
const finalChildren = /* @__PURE__ */ new Map();
|
|
607
607
|
for (const effect of effects) finalChildren.set(effect.owner, effect.children);
|
|
608
608
|
const changes = [];
|
|
609
|
-
const placementNodes = /* @__PURE__ */ new
|
|
609
|
+
const placementNodes = /* @__PURE__ */ new Map();
|
|
610
610
|
for (const [owner, children] of finalChildren) {
|
|
611
611
|
const before = owner.children;
|
|
612
612
|
const diff = diffChildren(before, children);
|
|
@@ -614,7 +614,14 @@ function prepareStructureBatch(effects) {
|
|
|
614
614
|
const changed = [];
|
|
615
615
|
for (const { node, beforeIndex, afterIndex } of diff.changes) {
|
|
616
616
|
changed.push(node);
|
|
617
|
-
if (beforeIndex < 0 || afterIndex < 0)
|
|
617
|
+
if (beforeIndex < 0 || afterIndex < 0) {
|
|
618
|
+
let placement = placementNodes.get(node);
|
|
619
|
+
if (!placement) {
|
|
620
|
+
placement = [node.parent, void 0];
|
|
621
|
+
placementNodes.set(node, placement);
|
|
622
|
+
}
|
|
623
|
+
if (beforeIndex < 0) placement[1] = owner;
|
|
624
|
+
}
|
|
618
625
|
}
|
|
619
626
|
changes.push({
|
|
620
627
|
owner,
|
|
@@ -633,7 +640,7 @@ function prepareStructureBatch(effects) {
|
|
|
633
640
|
}
|
|
634
641
|
/** @internal 直接安装 affected raw links。 */
|
|
635
642
|
function installStructureLinks(batch) {
|
|
636
|
-
for (const node of batch.placementNodes) node.detachBatchParent();
|
|
643
|
+
for (const node of batch.placementNodes.keys()) node.detachBatchParent();
|
|
637
644
|
for (const { owner, children, start, end } of batch.changes) owner.installBatchChildren(children, start, end);
|
|
638
645
|
}
|
|
639
646
|
/**
|
|
@@ -643,15 +650,97 @@ function installStructureLinks(batch) {
|
|
|
643
650
|
function syncStructureLifecycles(nodes) {
|
|
644
651
|
if (nodes.size === 0) return;
|
|
645
652
|
const depths = /* @__PURE__ */ new Map();
|
|
646
|
-
for (const node of nodes) {
|
|
653
|
+
for (const node of nodes.keys()) {
|
|
647
654
|
let depth = 0;
|
|
648
655
|
for (let parent = node.parent; parent; parent = parent.parent) depth++;
|
|
649
656
|
depths.set(node, depth);
|
|
650
657
|
}
|
|
651
|
-
const ordered = [...nodes].sort((left, right) => depths.get(left) - depths.get(right));
|
|
658
|
+
const ordered = [...nodes.keys()].sort((left, right) => depths.get(left) - depths.get(right));
|
|
652
659
|
for (const node of ordered) node.syncPlacementLifecycle();
|
|
653
660
|
}
|
|
654
661
|
//#endregion
|
|
662
|
+
//#region packages/core/src/mutation/change-batch.ts
|
|
663
|
+
/** @internal 合并 raw owner effects;单个 patch 直接借用,仅合并同 owner 字段时分配。 */
|
|
664
|
+
function mergeOwnerPropertyChanges(ownerEffects) {
|
|
665
|
+
const slots = /* @__PURE__ */ new Map();
|
|
666
|
+
let mergedOwners = null;
|
|
667
|
+
for (const { owner, patch } of ownerEffects) {
|
|
668
|
+
const current = slots.get(owner);
|
|
669
|
+
if (!current) {
|
|
670
|
+
slots.set(owner, patch);
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
let finalPatch;
|
|
674
|
+
if (mergedOwners?.has(owner)) finalPatch = current;
|
|
675
|
+
else {
|
|
676
|
+
finalPatch = {};
|
|
677
|
+
for (const key of Object.keys(current)) finalPatch[key] = current[key];
|
|
678
|
+
slots.set(owner, finalPatch);
|
|
679
|
+
(mergedOwners ??= /* @__PURE__ */ new Set()).add(owner);
|
|
680
|
+
}
|
|
681
|
+
for (const key of Object.keys(patch)) finalPatch[key] = patch[key];
|
|
682
|
+
}
|
|
683
|
+
return slots;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* 同步应用一份 trusted change batch。
|
|
687
|
+
*
|
|
688
|
+
* owner effects 先按对象身份合并最终 patch;所有 fields/raw links 安装完成后才运行
|
|
689
|
+
* History、lifecycle、hooks、dirty 和最多一次 scene delivery;纯 paint 变化不通知 scene。
|
|
690
|
+
* 本函数不提供 rollback、
|
|
691
|
+
* retry、receipt 或 rejected 结果。返回本批次是否实际安装属性或结构变化。
|
|
692
|
+
*/
|
|
693
|
+
function applyChangeBatch(root, ownerEffects, structureEffects = [], history) {
|
|
694
|
+
if (ownerEffects.length === 0 && structureEffects.length === 0) return false;
|
|
695
|
+
const slots = mergeOwnerPropertyChanges(ownerEffects);
|
|
696
|
+
const properties = [];
|
|
697
|
+
for (const [owner, patch] of slots) {
|
|
698
|
+
const commit = owner.preparePropertyCommit(patch);
|
|
699
|
+
if (commit) properties.push({
|
|
700
|
+
owner,
|
|
701
|
+
commit
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
const structureBatch = prepareStructureBatch(structureEffects);
|
|
705
|
+
const structure = structureBatch.changes;
|
|
706
|
+
if (properties.length === 0 && structure.length === 0) return false;
|
|
707
|
+
for (const { owner, commit } of properties) owner.installPropertyCommit(commit);
|
|
708
|
+
installStructureLinks(structureBatch);
|
|
709
|
+
if (history) {
|
|
710
|
+
for (const { owner, commit } of properties) for (const field of commit.update.fields) {
|
|
711
|
+
if (!field.sourceChanged) continue;
|
|
712
|
+
history.recordPropertyChange(owner, field.key, field.beforeSource);
|
|
713
|
+
}
|
|
714
|
+
for (const { owner, before } of structure) history.recordStructureChange(owner, before);
|
|
715
|
+
}
|
|
716
|
+
for (const [node, [previousParent, expectedParent]] of structureBatch.placementNodes) node.notifyBatchParentChanged(previousParent, expectedParent);
|
|
717
|
+
syncStructureLifecycles(structureBatch.placementNodes);
|
|
718
|
+
for (const { owner, commit } of properties) owner.syncPropertyCommitEvents(commit);
|
|
719
|
+
for (const { owner, commit } of properties) owner.runPropertyCommitHook(commit);
|
|
720
|
+
for (const { owner } of structure) owner.runBatchStructureHook();
|
|
721
|
+
for (const { owner, commit } of properties) owner.notifyPortsCommit(commit);
|
|
722
|
+
let layerOrderChanged = false;
|
|
723
|
+
let hoverChanged = false;
|
|
724
|
+
const observesScene = root?.sceneRegistry.hasSceneChangeObservers === true;
|
|
725
|
+
let sceneAffected;
|
|
726
|
+
for (const { owner, commit } of properties) {
|
|
727
|
+
if (owner.publishPropertyCommit(commit, false, false) && observesScene) (sceneAffected ??= /* @__PURE__ */ new Set()).add(owner);
|
|
728
|
+
if (commit.impact & ChangeImpact.LayerOrder) layerOrderChanged = true;
|
|
729
|
+
else if (commit.impact & ChangeImpact.Hover) hoverChanged = true;
|
|
730
|
+
}
|
|
731
|
+
for (const { owner } of structure) owner.publishBatchStructureDirty();
|
|
732
|
+
if (observesScene) for (const { owner, changed } of structure) {
|
|
733
|
+
(sceneAffected ??= /* @__PURE__ */ new Set()).add(owner);
|
|
734
|
+
for (const node of changed) sceneAffected.add(node);
|
|
735
|
+
}
|
|
736
|
+
if (structure.length) root?.commitBatchStructureChanges(structure, layerOrderChanged);
|
|
737
|
+
else if (layerOrderChanged) root?.commitLayerOrderChange();
|
|
738
|
+
else if (hoverChanged) root?.scheduleHoverRefresh();
|
|
739
|
+
if (sceneAffected) root?.sceneRegistry.notifySceneChange(void 0, [...sceneAffected]);
|
|
740
|
+
for (const { owner, commit } of properties) owner.dispatchPortsChange(commit);
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
//#endregion
|
|
655
744
|
//#region packages/core/src/node/node.ts
|
|
656
745
|
var nodeKeyPrefix = Date.now().toString(36);
|
|
657
746
|
var nodeKeySequence = 0;
|
|
@@ -822,13 +911,13 @@ var Node = class extends EventEmitter {
|
|
|
822
911
|
super();
|
|
823
912
|
this.#key = options.key ?? generateNodeKey();
|
|
824
913
|
this.propertyState = properties;
|
|
825
|
-
if (children) this.installChildren(this.adoptIncoming(children)
|
|
914
|
+
if (children) this.installChildren(this.adoptIncoming(children));
|
|
826
915
|
}
|
|
827
916
|
/**
|
|
828
917
|
* 安装最终 children 引用,只更新 `[start, end)` 窗口及其两侧邻居的 raw links;
|
|
829
918
|
* 窗口外的公共前后缀与旧 children 相同。
|
|
830
919
|
*/
|
|
831
|
-
installChildren(children,
|
|
920
|
+
installChildren(children, start = 0, end = children.length) {
|
|
832
921
|
this.childNodes = children;
|
|
833
922
|
assignSiblingOrders(children, start, end);
|
|
834
923
|
const last = Math.min(end, children.length - 1);
|
|
@@ -837,28 +926,22 @@ var Node = class extends EventEmitter {
|
|
|
837
926
|
child.previousSibling = children[index - 1] ?? null;
|
|
838
927
|
child.nextSibling = children[index + 1] ?? null;
|
|
839
928
|
}
|
|
840
|
-
for (let index = start; index < end; index++) this.linkChild(children[index]
|
|
929
|
+
for (let index = start; index < end; index++) this.linkChild(children[index]);
|
|
841
930
|
}
|
|
842
931
|
/** 建立结构所有权、上下文原型链和事件冒泡 parent。 */
|
|
843
|
-
linkChild(child
|
|
844
|
-
if (child.parent !== this)
|
|
845
|
-
child.parent = this;
|
|
846
|
-
if (notifyParentChange) child.onParentChanged();
|
|
847
|
-
}
|
|
932
|
+
linkChild(child) {
|
|
933
|
+
if (child.parent !== this) child.parent = this;
|
|
848
934
|
setProvidesParent(child, this.provides);
|
|
849
935
|
}
|
|
850
936
|
/** 解除结构所有权、sibling、上下文和事件冒泡关系。 */
|
|
851
937
|
unlinkFromParent() {
|
|
852
|
-
if (!isUndefined(this.parent))
|
|
853
|
-
this.parent = void 0;
|
|
854
|
-
this.onParentChanged();
|
|
855
|
-
}
|
|
938
|
+
if (!isUndefined(this.parent)) this.parent = void 0;
|
|
856
939
|
this.previousSibling = null;
|
|
857
940
|
this.nextSibling = null;
|
|
858
941
|
setProvidesParent(this, null);
|
|
859
942
|
}
|
|
860
943
|
/** raw parent link 改变后的派生 owner 接缝。 */
|
|
861
|
-
onParentChanged() {}
|
|
944
|
+
onParentChanged(_previousParent) {}
|
|
862
945
|
/** 直接 children 事务提交后的扩展点;构造期 children 不触发。 */
|
|
863
946
|
onChildrenChanged() {}
|
|
864
947
|
/** 全部 raw links 安装后的结构 dirty publication 扩展点。 */
|
|
@@ -879,14 +962,32 @@ var Node = class extends EventEmitter {
|
|
|
879
962
|
}
|
|
880
963
|
/** 安装一次最终 children,并在当前提交仍有效时发布结构变化。 */
|
|
881
964
|
commitChildren(next, entered = [], left = [], deactivateLeft = false) {
|
|
965
|
+
let previousParents;
|
|
966
|
+
for (const child of entered) if (child.parent && child.parent !== this) (previousParents ??= /* @__PURE__ */ new Set()).add(child.parent);
|
|
967
|
+
if (previousParents) {
|
|
968
|
+
const moving = new Set(entered);
|
|
969
|
+
const structure = [];
|
|
970
|
+
let root = this.activeRoot ?? void 0;
|
|
971
|
+
for (const owner of previousParents) {
|
|
972
|
+
root ??= owner.activeRoot ?? void 0;
|
|
973
|
+
structure.push({
|
|
974
|
+
owner,
|
|
975
|
+
children: owner.children.filter((child) => !moving.has(child))
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
structure.push({
|
|
979
|
+
owner: this,
|
|
980
|
+
children: next
|
|
981
|
+
});
|
|
982
|
+
return applyChangeBatch(root, [], structure);
|
|
983
|
+
}
|
|
882
984
|
const previous = this.childNodes;
|
|
883
985
|
const diff = diffChildren(previous, next);
|
|
884
986
|
if (diff.changes.length === 0) return false;
|
|
885
|
-
for (const child of left)
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
this.installChildren(next, true, diff.start, diff.end);
|
|
987
|
+
for (const child of left) child.unlinkFromParent();
|
|
988
|
+
this.installChildren(next, diff.start, diff.end);
|
|
989
|
+
for (const child of left) if (!child.parent) child.onParentChanged(this);
|
|
990
|
+
for (const child of entered) if (child.parent === this) child.onParentChanged(void 0);
|
|
890
991
|
this.syncCommittedLifecycles(entered, left, deactivateLeft);
|
|
891
992
|
const changed = diff.changes.map(({ node }) => node);
|
|
892
993
|
if (this.childNodes === next) this.markStructureDirty(changed);
|
|
@@ -899,16 +1000,9 @@ var Node = class extends EventEmitter {
|
|
|
899
1000
|
*/
|
|
900
1001
|
syncCommittedLifecycles(entered, left, deactivateLeft) {
|
|
901
1002
|
if (deactivateLeft) {
|
|
902
|
-
for (const child of left) if (!child.parent) child.transitionLifecycle(LifecycleState.Inactive);
|
|
903
|
-
}
|
|
904
|
-
for (const child of entered) {
|
|
905
|
-
if (child.parent !== this) continue;
|
|
906
|
-
if (this.isActive) {
|
|
907
|
-
const inheritedLayer = child.inject("layer") ?? null;
|
|
908
|
-
if (child.isActive && child.activeLayer !== inheritedLayer) child.transitionLifecycle(LifecycleState.Inactive);
|
|
909
|
-
child.transitionLifecycle(LifecycleState.Active);
|
|
910
|
-
} else if (child.isActive) child.transitionLifecycle(LifecycleState.Inactive);
|
|
1003
|
+
for (const child of left) if (!child.parent && child.isActive) child.transitionLifecycle(LifecycleState.Inactive);
|
|
911
1004
|
}
|
|
1005
|
+
for (const child of entered) if (child.parent === this) child.syncPlacementLifecycle();
|
|
912
1006
|
}
|
|
913
1007
|
/** @internal trusted batch 解除真实变化节点的旧 placement。 */
|
|
914
1008
|
detachBatchParent() {
|
|
@@ -916,7 +1010,11 @@ var Node = class extends EventEmitter {
|
|
|
916
1010
|
}
|
|
917
1011
|
/** @internal 接收 trusted batch 转移所有权的最终 children 与其变化窗口。 */
|
|
918
1012
|
installBatchChildren(children, start, end) {
|
|
919
|
-
this.installChildren(children,
|
|
1013
|
+
this.installChildren(children, start, end);
|
|
1014
|
+
}
|
|
1015
|
+
/** @internal 完整安装后的 parent hook;重入提交已改写归属时跳过旧结果。 */
|
|
1016
|
+
notifyBatchParentChanged(previousParent, expectedParent) {
|
|
1017
|
+
if (this.parent === expectedParent && this.parent !== previousParent) this.onParentChanged(previousParent);
|
|
920
1018
|
}
|
|
921
1019
|
/** @internal 按当前 parent 同步最终 lifecycle context。 */
|
|
922
1020
|
syncPlacementLifecycle() {
|
|
@@ -926,7 +1024,7 @@ var Node = class extends EventEmitter {
|
|
|
926
1024
|
const targetLayer = this.isLayerNode() ? this : parent?.inject("layer") ?? null;
|
|
927
1025
|
if (!shouldBeActive || this.activeLayer !== targetLayer) this.transitionLifecycle(LifecycleState.Inactive);
|
|
928
1026
|
}
|
|
929
|
-
if (
|
|
1027
|
+
if (this.parent?.isActive === true && !this.isActive) this.transitionLifecycle(LifecycleState.Active);
|
|
930
1028
|
}
|
|
931
1029
|
/** @internal tree 已完整安装后登记当前 owner 的 dirty path。 */
|
|
932
1030
|
publishBatchStructureDirty() {
|
|
@@ -945,27 +1043,27 @@ var Node = class extends EventEmitter {
|
|
|
945
1043
|
next.splice(index, 1);
|
|
946
1044
|
return this.commitChildren(next, [], [child], detach);
|
|
947
1045
|
}
|
|
948
|
-
/**
|
|
949
|
-
detachFromParent(child) {
|
|
950
|
-
const oldParent = child.parent;
|
|
951
|
-
if (!oldParent || oldParent === this) return true;
|
|
952
|
-
let keepsContext = false;
|
|
953
|
-
if (this.isActive) {
|
|
954
|
-
const inheritedLayer = this.inject("layer") ?? null;
|
|
955
|
-
keepsContext = child.isActive && child.activeLayer === inheritedLayer;
|
|
956
|
-
}
|
|
957
|
-
oldParent.removeOwnChild(child, false);
|
|
958
|
-
if (child.parent === oldParent) return false;
|
|
959
|
-
if (!keepsContext && isUndefined(child.parent)) child.transitionLifecycle(LifecycleState.Inactive);
|
|
960
|
-
return isUndefined(child.parent);
|
|
961
|
-
}
|
|
962
|
-
/** 分离 incoming nodes;只有同步回调改写归属时才创建过滤后的数组。 */
|
|
1046
|
+
/** 构造期采用 children,回调已建立的新归属不再由旧输入接管。 */
|
|
963
1047
|
adoptIncoming(nodes) {
|
|
1048
|
+
let hasPreviousParent = false;
|
|
1049
|
+
for (const child of nodes) if (child.parent && child.parent !== this) {
|
|
1050
|
+
hasPreviousParent = true;
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1053
|
+
if (!hasPreviousParent) return nodes;
|
|
1054
|
+
const expectedParents = nodes.map((child) => child.parent);
|
|
1055
|
+
for (let index = 0; index < nodes.length; index++) {
|
|
1056
|
+
const child = nodes[index];
|
|
1057
|
+
const previousParent = expectedParents[index];
|
|
1058
|
+
if (child.parent !== previousParent || !previousParent || previousParent === this) continue;
|
|
1059
|
+
previousParent.removeOwnChild(child, false);
|
|
1060
|
+
expectedParents[index] = void 0;
|
|
1061
|
+
if (!child.parent && child.isActive) child.transitionLifecycle(LifecycleState.Inactive);
|
|
1062
|
+
}
|
|
964
1063
|
let adopted = null;
|
|
965
1064
|
for (let index = 0; index < nodes.length; index++) {
|
|
966
1065
|
const child = nodes[index];
|
|
967
|
-
|
|
968
|
-
if (!oldParent || oldParent === this || this.detachFromParent(child)) adopted?.push(child);
|
|
1066
|
+
if (!child.isUnmounted && child.parent === expectedParents[index] && (!child.parent || child.parent === this)) adopted?.push(child);
|
|
969
1067
|
else if (!adopted) adopted = nodes.slice(0, index);
|
|
970
1068
|
}
|
|
971
1069
|
return adopted ?? nodes;
|
|
@@ -973,20 +1071,18 @@ var Node = class extends EventEmitter {
|
|
|
973
1071
|
/** 统一实现 append/prepend/before/after 的移动和插入事务。 */
|
|
974
1072
|
insertAt(nodes, getIndex) {
|
|
975
1073
|
if (nodes.length === 0) return this;
|
|
976
|
-
const adopted = this.adoptIncoming(nodes);
|
|
977
|
-
if (adopted.length === 0) return this;
|
|
978
1074
|
let next;
|
|
979
|
-
if (
|
|
1075
|
+
if (nodes.length === 1) {
|
|
980
1076
|
next = this.childNodes.slice();
|
|
981
|
-
const current = next.indexOf(
|
|
1077
|
+
const current = next.indexOf(nodes[0]);
|
|
982
1078
|
if (current !== -1) next.splice(current, 1);
|
|
983
1079
|
} else {
|
|
984
|
-
const moving = new Set(
|
|
1080
|
+
const moving = new Set(nodes);
|
|
985
1081
|
next = this.childNodes.filter((child) => !moving.has(child));
|
|
986
1082
|
}
|
|
987
1083
|
const index = clamp(getIndex(next), 0, next.length);
|
|
988
|
-
next.splice(index, 0, ...
|
|
989
|
-
const entered =
|
|
1084
|
+
next.splice(index, 0, ...nodes);
|
|
1085
|
+
const entered = nodes.filter((child) => child.parent !== this);
|
|
990
1086
|
this.commitChildren(next, entered);
|
|
991
1087
|
return this;
|
|
992
1088
|
}
|
|
@@ -1017,14 +1113,13 @@ var Node = class extends EventEmitter {
|
|
|
1017
1113
|
nextChildren.splice(oldIndex, 1, newChild);
|
|
1018
1114
|
return this.replaceChildren(...nextChildren);
|
|
1019
1115
|
}
|
|
1020
|
-
/**
|
|
1116
|
+
/** 替换完整 children 序列,完整安装后发布变化。 */
|
|
1021
1117
|
replaceChildren(...children) {
|
|
1022
1118
|
const previous = this.childNodes;
|
|
1023
|
-
const
|
|
1024
|
-
const
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1027
|
-
this.commitChildren(committed, entered, left, true);
|
|
1119
|
+
const childrenSet = new Set(children);
|
|
1120
|
+
const left = previous.filter((child) => !childrenSet.has(child));
|
|
1121
|
+
const entered = children.filter((child) => child.parent !== this);
|
|
1122
|
+
this.commitChildren(children, entered, left, true);
|
|
1028
1123
|
return this;
|
|
1029
1124
|
}
|
|
1030
1125
|
/** 将节点移动到当前节点之前。 */
|
|
@@ -1122,7 +1217,10 @@ var Node = class extends EventEmitter {
|
|
|
1122
1217
|
this.lifecycleState = LifecycleState.Inactive;
|
|
1123
1218
|
if (!rootIsUnmounting) root?.sceneRegistry.unregisterNodeKey(this);
|
|
1124
1219
|
if (!layer?.isUnmounted) layer?.detachNode(this);
|
|
1125
|
-
if (deactivateChildren) for (const child of this.children)
|
|
1220
|
+
if (deactivateChildren) for (const child of this.children) {
|
|
1221
|
+
if (child.parent !== this) continue;
|
|
1222
|
+
child.transitionLifecycle(LifecycleState.Inactive);
|
|
1223
|
+
}
|
|
1126
1224
|
if (!rootIsUnmounting) root?.clearHoverFor(this);
|
|
1127
1225
|
this.onDeactivate(root, layer);
|
|
1128
1226
|
}
|
|
@@ -1155,10 +1253,13 @@ var Node = class extends EventEmitter {
|
|
|
1155
1253
|
} catch (error) {
|
|
1156
1254
|
firstError = error;
|
|
1157
1255
|
}
|
|
1158
|
-
for (const child of terminalChildren)
|
|
1159
|
-
child.
|
|
1160
|
-
|
|
1161
|
-
|
|
1256
|
+
for (const child of terminalChildren) {
|
|
1257
|
+
if (child.parent !== this) continue;
|
|
1258
|
+
try {
|
|
1259
|
+
child.transitionLifecycle(LifecycleState.Unmounted);
|
|
1260
|
+
} catch (error) {
|
|
1261
|
+
if (firstError === NO_LIFECYCLE_ERROR) firstError = error;
|
|
1262
|
+
}
|
|
1162
1263
|
}
|
|
1163
1264
|
if (wasActive) try {
|
|
1164
1265
|
this.leaveActiveContext(this.activeRoot, this.activeLayer, false);
|
|
@@ -1228,14 +1329,16 @@ var EMPTY_LAYOUT_BOUNDS$1 = {
|
|
|
1228
1329
|
width: 0,
|
|
1229
1330
|
height: 0
|
|
1230
1331
|
};
|
|
1231
|
-
var
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
return
|
|
1235
|
-
}
|
|
1332
|
+
var SnapshotGeometryFlags = /* @__PURE__ */ function(SnapshotGeometryFlags) {
|
|
1333
|
+
SnapshotGeometryFlags[SnapshotGeometryFlags["HasGeometry"] = 1] = "HasGeometry";
|
|
1334
|
+
SnapshotGeometryFlags[SnapshotGeometryFlags["ExactReferenceBounds"] = 2] = "ExactReferenceBounds";
|
|
1335
|
+
return SnapshotGeometryFlags;
|
|
1336
|
+
}(SnapshotGeometryFlags || {});
|
|
1337
|
+
var snapshotGeometryFlags = /* @__PURE__ */ new WeakMap();
|
|
1236
1338
|
/** @internal 读取通用 snapshot 的非空元数据。 */
|
|
1237
1339
|
function genericSnapshotHasGeometry(snapshot) {
|
|
1238
|
-
|
|
1340
|
+
const flags = snapshotGeometryFlags.get(snapshot);
|
|
1341
|
+
return flags === void 0 ? snapshot.subpaths.some((subpath) => subpath.vertices.length > 0) : (flags & SnapshotGeometryFlags.HasGeometry) !== 0;
|
|
1239
1342
|
}
|
|
1240
1343
|
/** @internal 保持极大/极小坐标计算的共同缩放。 */
|
|
1241
1344
|
function nonzeroScale(...values) {
|
|
@@ -1490,34 +1593,23 @@ function scaledCubicPowerCoefficients(start, control1, control2, end, scale, off
|
|
|
1490
1593
|
coefficients[0] -= offset / scale;
|
|
1491
1594
|
return coefficients;
|
|
1492
1595
|
}
|
|
1493
|
-
function
|
|
1494
|
-
let minX = Infinity;
|
|
1495
|
-
let minY = Infinity;
|
|
1496
|
-
let maxX = -Infinity;
|
|
1497
|
-
let maxY = -Infinity;
|
|
1596
|
+
function includeSegmentBounds(bounds, start, shape, end) {
|
|
1498
1597
|
const include = (point) => {
|
|
1499
|
-
minX = Math.min(minX, point.x);
|
|
1500
|
-
minY = Math.min(minY, point.y);
|
|
1501
|
-
maxX = Math.max(maxX, point.x);
|
|
1502
|
-
maxY = Math.max(maxY, point.y);
|
|
1598
|
+
bounds.minX = Math.min(bounds.minX, point.x);
|
|
1599
|
+
bounds.minY = Math.min(bounds.minY, point.y);
|
|
1600
|
+
bounds.maxX = Math.max(bounds.maxX, point.x);
|
|
1601
|
+
bounds.maxY = Math.max(bounds.maxY, point.y);
|
|
1503
1602
|
};
|
|
1504
|
-
include(
|
|
1505
|
-
include(
|
|
1506
|
-
if (
|
|
1507
|
-
const xScale = nonzeroScale(
|
|
1508
|
-
const yScale = nonzeroScale(
|
|
1509
|
-
const x = scaledCubicPowerCoefficients(
|
|
1510
|
-
const y = scaledCubicPowerCoefficients(
|
|
1603
|
+
include(start);
|
|
1604
|
+
include(end);
|
|
1605
|
+
if (shape.kind === "cubic") {
|
|
1606
|
+
const xScale = nonzeroScale(start.x, shape.control1.x, shape.control2.x, end.x);
|
|
1607
|
+
const yScale = nonzeroScale(start.y, shape.control1.y, shape.control2.y, end.y);
|
|
1608
|
+
const x = scaledCubicPowerCoefficients(start.x, shape.control1.x, shape.control2.x, end.x, xScale);
|
|
1609
|
+
const y = scaledCubicPowerCoefficients(start.y, shape.control1.y, shape.control2.y, end.y, yScale);
|
|
1511
1610
|
const extrema = [...rootsInUnitInterval(derivativePolynomial(x)), ...rootsInUnitInterval(derivativePolynomial(y))];
|
|
1512
|
-
for (const t of extrema) if (t > 0 && t < 1) include(
|
|
1611
|
+
for (const t of extrema) if (t > 0 && t < 1) include(evaluatePathSegmentPoint(start, shape, end, t));
|
|
1513
1612
|
}
|
|
1514
|
-
return {
|
|
1515
|
-
record,
|
|
1516
|
-
minX,
|
|
1517
|
-
minY,
|
|
1518
|
-
maxX,
|
|
1519
|
-
maxY
|
|
1520
|
-
};
|
|
1521
1613
|
}
|
|
1522
1614
|
function buildGeometryBounds(subpaths, recordsBySubpath) {
|
|
1523
1615
|
const boundedSegments = [];
|
|
@@ -1545,7 +1637,14 @@ function buildGeometryBounds(subpaths, recordsBySubpath) {
|
|
|
1545
1637
|
maxY = Math.max(maxY, vertex.point.y);
|
|
1546
1638
|
}
|
|
1547
1639
|
for (const record of recordsBySubpath[subpathIndex]) {
|
|
1548
|
-
const bounded =
|
|
1640
|
+
const bounded = {
|
|
1641
|
+
record,
|
|
1642
|
+
minX: Infinity,
|
|
1643
|
+
minY: Infinity,
|
|
1644
|
+
maxX: -Infinity,
|
|
1645
|
+
maxY: -Infinity
|
|
1646
|
+
};
|
|
1647
|
+
includeSegmentBounds(bounded, record.start, record.shape, record.end);
|
|
1549
1648
|
boundedSegments.push(bounded);
|
|
1550
1649
|
includeBounds(bounded);
|
|
1551
1650
|
}
|
|
@@ -1577,16 +1676,63 @@ function buildGeometryBounds(subpaths, recordsBySubpath) {
|
|
|
1577
1676
|
bounds
|
|
1578
1677
|
};
|
|
1579
1678
|
}
|
|
1679
|
+
function includeSubpathBounds(bounds, vertices, shapes, segmentCount) {
|
|
1680
|
+
for (const { point } of vertices) {
|
|
1681
|
+
bounds.minX = Math.min(bounds.minX, point.x);
|
|
1682
|
+
bounds.minY = Math.min(bounds.minY, point.y);
|
|
1683
|
+
bounds.maxX = Math.max(bounds.maxX, point.x);
|
|
1684
|
+
bounds.maxY = Math.max(bounds.maxY, point.y);
|
|
1685
|
+
}
|
|
1686
|
+
for (let index = 0; index < segmentCount; index++) {
|
|
1687
|
+
const shape = shapes[index];
|
|
1688
|
+
if (shape.kind === "cubic") includeSegmentBounds(bounds, vertices[index].point, shape, vertices[(index + 1) % vertices.length].point);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
function layoutBoundsFromBBox(bounds) {
|
|
1692
|
+
return bounds.minX === Infinity ? EMPTY_LAYOUT_BOUNDS$1 : {
|
|
1693
|
+
left: bounds.minX,
|
|
1694
|
+
top: bounds.minY,
|
|
1695
|
+
width: bounds.maxX - bounds.minX,
|
|
1696
|
+
height: bounds.maxY - bounds.minY
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1580
1699
|
function exactBounds(subpaths) {
|
|
1581
|
-
|
|
1700
|
+
const bounds = {
|
|
1701
|
+
minX: Infinity,
|
|
1702
|
+
minY: Infinity,
|
|
1703
|
+
maxX: -Infinity,
|
|
1704
|
+
maxY: -Infinity
|
|
1705
|
+
};
|
|
1706
|
+
for (const subpath of subpaths) includeSubpathBounds(bounds, subpath.vertices, subpath.segmentShapes, subpath.segmentShapes.length);
|
|
1707
|
+
return layoutBoundsFromBBox(bounds);
|
|
1708
|
+
}
|
|
1709
|
+
/** 直接读取 authored anchors 的精确 line/cubic bounds,不创建 resolved 投影。 */
|
|
1710
|
+
function getAuthoredPathLayoutBounds(subpaths) {
|
|
1711
|
+
const bounds = {
|
|
1712
|
+
minX: Infinity,
|
|
1713
|
+
minY: Infinity,
|
|
1714
|
+
maxX: -Infinity,
|
|
1715
|
+
maxY: -Infinity
|
|
1716
|
+
};
|
|
1717
|
+
for (const subpath of subpaths) {
|
|
1718
|
+
const { anchors, closed } = subpath;
|
|
1719
|
+
includeSubpathBounds(bounds, anchors, anchors, anchors.length < 2 ? 0 : closed ? anchors.length : anchors.length - 1);
|
|
1720
|
+
}
|
|
1721
|
+
return layoutBoundsFromBBox(bounds);
|
|
1582
1722
|
}
|
|
1583
1723
|
/**
|
|
1584
1724
|
* 直接采用输入对象及其 subpath、point、control、标量 authored ID 和 bounds 引用。
|
|
1585
1725
|
* 省略 bounds 时在同一输入对象上安装一次派生结果;不创建 GeometryQuery index。
|
|
1586
1726
|
*/
|
|
1587
1727
|
function createGeometrySnapshot(input) {
|
|
1588
|
-
|
|
1589
|
-
|
|
1728
|
+
let flags = input.subpaths.some((subpath) => subpath.vertices.length > 0) ? SnapshotGeometryFlags.HasGeometry : 0;
|
|
1729
|
+
if (input.layoutReferenceBounds === void 0) {
|
|
1730
|
+
input.layoutReferenceBounds = exactBounds(input.subpaths);
|
|
1731
|
+
flags |= SnapshotGeometryFlags.ExactReferenceBounds;
|
|
1732
|
+
}
|
|
1733
|
+
const snapshot = input;
|
|
1734
|
+
snapshotGeometryFlags.set(snapshot, flags);
|
|
1735
|
+
return snapshot;
|
|
1590
1736
|
}
|
|
1591
1737
|
function pointDistance(left, right) {
|
|
1592
1738
|
const scale = nonzeroScale(left.x, left.y, right.x, right.y);
|
|
@@ -1704,7 +1850,7 @@ function rayWinding(record, previous, point) {
|
|
|
1704
1850
|
/** @internal 通用 line/cubic canonical query。 */
|
|
1705
1851
|
var SnapshotGeometryQuery = class {
|
|
1706
1852
|
snapshot;
|
|
1707
|
-
/**
|
|
1853
|
+
/** 第一次需要 segment 的 query 前保持 `null`。 */
|
|
1708
1854
|
index = null;
|
|
1709
1855
|
debugStats = null;
|
|
1710
1856
|
constructor(snapshot) {
|
|
@@ -1748,6 +1894,8 @@ var SnapshotGeometryQuery = class {
|
|
|
1748
1894
|
return { ...this.debugStats };
|
|
1749
1895
|
}
|
|
1750
1896
|
getBounds() {
|
|
1897
|
+
const flags = snapshotGeometryFlags.get(this.snapshot) ?? 0;
|
|
1898
|
+
if (flags & SnapshotGeometryFlags.ExactReferenceBounds) return flags & SnapshotGeometryFlags.HasGeometry ? this.snapshot.layoutReferenceBounds : null;
|
|
1751
1899
|
return this.getBoundsData().bounds;
|
|
1752
1900
|
}
|
|
1753
1901
|
getPathPoint(position) {
|
|
@@ -2570,6 +2718,7 @@ var ElementTransform = class {
|
|
|
2570
2718
|
}
|
|
2571
2719
|
this.invalidateCache(impact);
|
|
2572
2720
|
} else this.invalidate(impact);
|
|
2721
|
+
this.element.activeRoot?.scheduleHoverRefresh();
|
|
2573
2722
|
return true;
|
|
2574
2723
|
}
|
|
2575
2724
|
/** @internal 提交由布局解析得到的尺寸。 */
|
|
@@ -2740,8 +2889,8 @@ var ElementTransform = class {
|
|
|
2740
2889
|
collectDirtySubtreeBounds(memo) {
|
|
2741
2890
|
let bounds = this.getPreviousVisualBounds();
|
|
2742
2891
|
if (this.hasGeometry()) {
|
|
2743
|
-
const current = this.
|
|
2744
|
-
bounds = bounds ? bounds.merge(current) : current;
|
|
2892
|
+
const current = this.getWorldVisualBoundsView();
|
|
2893
|
+
bounds = bounds ? bounds.merge(current) : new Bound(current.minX, current.minY, current.maxX, current.maxY);
|
|
2745
2894
|
}
|
|
2746
2895
|
for (const child of this.element.children) {
|
|
2747
2896
|
const childBounds = memo ? child.transform.getDirtyRect(memo) : child.transform.getDirtyRect();
|
|
@@ -3405,7 +3554,7 @@ var Element = class Element extends Node {
|
|
|
3405
3554
|
this.syncOptionEvents(properties, Object.keys(options));
|
|
3406
3555
|
}
|
|
3407
3556
|
/** raw parent link 变化只标记 transform local commit。 */
|
|
3408
|
-
onParentChanged() {
|
|
3557
|
+
onParentChanged(_previousParent) {
|
|
3409
3558
|
this.transform.markParentChanged();
|
|
3410
3559
|
}
|
|
3411
3560
|
/** raw children 完整安装后的 transform hook。 */
|
|
@@ -3510,13 +3659,15 @@ var Element = class Element extends Node {
|
|
|
3510
3659
|
publishPropertyCommit(commit, notifyScene, publishRootImpact = true) {
|
|
3511
3660
|
const { changes } = commit.update;
|
|
3512
3661
|
const { impact, previousVisualBounds } = commit;
|
|
3513
|
-
if (!changes.size) return;
|
|
3662
|
+
if (!changes.size) return false;
|
|
3514
3663
|
const visibilityChanged = changes.has("visible");
|
|
3515
3664
|
if (visibilityChanged) this.transform.invalidateRenderCoverageBounds();
|
|
3516
3665
|
if ((impact & GEOMETRY_IMPACT) !== 0) this.transform.invalidate(impact, previousVisualBounds);
|
|
3517
3666
|
else if (visibilityChanged) this.transform.markVisibilityDirty();
|
|
3518
3667
|
if (impact) this.invalidate(impact, publishRootImpact);
|
|
3519
|
-
|
|
3668
|
+
const affectsScene = (impact & (GEOMETRY_IMPACT | ChangeImpact.LayerOrder)) !== 0 || changes.has("visible") || changes.has("selectable") || changes.has("silent") || changes.has("pickable");
|
|
3669
|
+
if (notifyScene && affectsScene) this.activeRoot?.sceneRegistry.notifySceneChange(this);
|
|
3670
|
+
return affectsScene;
|
|
3520
3671
|
}
|
|
3521
3672
|
/** 应用一份 direct configured/runtime update 并完成一次成功路径 publication。 */
|
|
3522
3673
|
commitPreparedProperty(commit) {
|
|
@@ -4389,10 +4540,15 @@ var Shape = class extends Element {
|
|
|
4389
4540
|
getConnectionPortPosition(edge, ratio, edgePosition) {
|
|
4390
4541
|
return (edgePosition ?? this.getEdgePosition(edge, ratio)).pos;
|
|
4391
4542
|
}
|
|
4392
|
-
/** Replay
|
|
4543
|
+
/** Replay committed geometry without expanding ordinary rectangle subpaths. */
|
|
4393
4544
|
buildResolvedPath(ctx) {
|
|
4394
4545
|
const snapshot = this.transform.getGeometrySnapshot();
|
|
4395
4546
|
ctx.beginPath();
|
|
4547
|
+
const rectangle = geometrySnapshotRectangle(snapshot);
|
|
4548
|
+
if (rectangle) {
|
|
4549
|
+
ctx.rect(rectangle.left, rectangle.top, rectangle.width, rectangle.height);
|
|
4550
|
+
return;
|
|
4551
|
+
}
|
|
4396
4552
|
for (const subpath of snapshot.subpaths) {
|
|
4397
4553
|
const first = subpath.vertices[0];
|
|
4398
4554
|
if (!first) continue;
|
|
@@ -4744,7 +4900,7 @@ function queryAreaElements(root, area, options = {}) {
|
|
|
4744
4900
|
}
|
|
4745
4901
|
//#endregion
|
|
4746
4902
|
//#region packages/core/src/root/input-controller.ts
|
|
4747
|
-
/** 同一 Document
|
|
4903
|
+
/** 同一 Document 最近接收焦点或指针的 Root。 */
|
|
4748
4904
|
var activeInputByDocument = /* @__PURE__ */ new WeakMap();
|
|
4749
4905
|
/** 判断键盘事件目标是否应保留浏览器原生空格输入。 */
|
|
4750
4906
|
function isFormControlTarget(target) {
|
|
@@ -4788,6 +4944,13 @@ var RootInputController = class {
|
|
|
4788
4944
|
get isPointerInside() {
|
|
4789
4945
|
return this.pointerInside;
|
|
4790
4946
|
}
|
|
4947
|
+
/** 当前 DOM 焦点决定键盘归属;无元素焦点时采用最近的 Root 指针归属。 */
|
|
4948
|
+
get isKeyboardOwner() {
|
|
4949
|
+
const document = this.ownerDocument;
|
|
4950
|
+
const focused = this.root.container.getRootNode().activeElement ?? document.activeElement;
|
|
4951
|
+
if (focused && focused !== document.body && focused !== document.documentElement) return this.root.container.contains(focused);
|
|
4952
|
+
return activeInputByDocument.get(document) === this;
|
|
4953
|
+
}
|
|
4791
4954
|
/** @internal 安装当前 Root 的键盘、指针、滚轮和焦点监听。 */
|
|
4792
4955
|
activate() {
|
|
4793
4956
|
if (this.abortController) return;
|
|
@@ -4944,7 +5107,7 @@ var RootInputController = class {
|
|
|
4944
5107
|
}
|
|
4945
5108
|
/** 进入空格平移模式,并清除普通 hover。 */
|
|
4946
5109
|
onKeyDown = (event) => {
|
|
4947
|
-
if (
|
|
5110
|
+
if (!this.isKeyboardOwner || event.code !== "Space" || event.repeat || isFormControlTarget(event.target)) return;
|
|
4948
5111
|
event.preventDefault();
|
|
4949
5112
|
if (!isNull(this.activePointerId)) return;
|
|
4950
5113
|
this.isSpacePressed = true;
|
|
@@ -5647,8 +5810,8 @@ var RootFrameRuntime = class {
|
|
|
5647
5810
|
const scheduleAfterCompletionError = this.completionFollowUpFrameRequested;
|
|
5648
5811
|
this.completionFollowUpFrameRequested = false;
|
|
5649
5812
|
if (frameError) this.rejectNextTick(frameError);
|
|
5813
|
+
else if (!this.hasPendingSynchronousWork()) this.resolveNextTick();
|
|
5650
5814
|
if ((!frameError || scheduleAfterCompletionError) && this.needsAnotherFrame()) this.requestFrame();
|
|
5651
|
-
else if (!frameError) this.resolveNextTick();
|
|
5652
5815
|
}
|
|
5653
5816
|
});
|
|
5654
5817
|
if (this.animationFrameScheduled) this.animationFrameId = id;
|
|
@@ -5742,11 +5905,13 @@ var RootFrameRuntime = class {
|
|
|
5742
5905
|
return this.participant?.resolveCursor?.(point, contentCursor) ?? contentCursor;
|
|
5743
5906
|
}
|
|
5744
5907
|
consumeDirtyTransforms() {
|
|
5908
|
+
if (this.pendingDirtyTransforms.size === 0) return;
|
|
5745
5909
|
const current = this.pendingDirtyTransforms;
|
|
5746
5910
|
this.pendingDirtyTransforms = /* @__PURE__ */ new Set();
|
|
5747
5911
|
for (const transform of current) transform.clearDirtyDescendantState(this.root);
|
|
5748
5912
|
}
|
|
5749
5913
|
flushLayouts() {
|
|
5914
|
+
if (this.pendingLayouts.size === 0) return;
|
|
5750
5915
|
const current = this.pendingLayouts;
|
|
5751
5916
|
this.pendingLayouts = /* @__PURE__ */ new Set();
|
|
5752
5917
|
const affected = this.root.sceneRegistry.hasSceneChangeObservers ? [] : void 0;
|
|
@@ -5756,12 +5921,6 @@ var RootFrameRuntime = class {
|
|
|
5756
5921
|
}
|
|
5757
5922
|
if (affected && affected.length > 0) this.root.sceneRegistry.notifySceneChange(void 0, affected);
|
|
5758
5923
|
}
|
|
5759
|
-
takePendingLayers() {
|
|
5760
|
-
const pending = /* @__PURE__ */ new Set();
|
|
5761
|
-
for (const layer of this.pendingLayers) if (this.ownsLayer(layer)) pending.add(layer);
|
|
5762
|
-
this.pendingLayers.clear();
|
|
5763
|
-
return pending;
|
|
5764
|
-
}
|
|
5765
5924
|
dirtyOwnerKeys(lastRound) {
|
|
5766
5925
|
const keys = new Set(this.participant?.getDirtyOwnerKeys?.() ?? []);
|
|
5767
5926
|
for (const owner of this.pendingLayouts) keys.add(owner.key);
|
|
@@ -5774,13 +5933,15 @@ var RootFrameRuntime = class {
|
|
|
5774
5933
|
try {
|
|
5775
5934
|
const frameWorkByLayer = /* @__PURE__ */ new Map();
|
|
5776
5935
|
let rounds = 0;
|
|
5777
|
-
let lastRound =
|
|
5936
|
+
let lastRound = frameWorkByLayer;
|
|
5778
5937
|
while (this.pendingLayers.size > 0 || this.pendingLayouts.size > 0 || this.participant?.hasPendingWork() === true) {
|
|
5779
|
-
if (++rounds > MAX_STABILIZATION_ROUNDS) throw new FrameStabilizationError(this.dirtyOwnerKeys(lastRound));
|
|
5938
|
+
if (++rounds > MAX_STABILIZATION_ROUNDS) throw new FrameStabilizationError(this.dirtyOwnerKeys(lastRound.values()));
|
|
5780
5939
|
this.participant?.flushMutationPhase();
|
|
5781
5940
|
this.flushLayouts();
|
|
5782
5941
|
const roundWorkByLayer = /* @__PURE__ */ new Map();
|
|
5783
|
-
|
|
5942
|
+
const pendingLayers = this.pendingLayers;
|
|
5943
|
+
this.pendingLayers = /* @__PURE__ */ new Set();
|
|
5944
|
+
for (const layer of pendingLayers) {
|
|
5784
5945
|
if (!this.ownsLayer(layer)) continue;
|
|
5785
5946
|
const work = layer.takeFrameWork();
|
|
5786
5947
|
if (!work) continue;
|
|
@@ -5789,7 +5950,7 @@ var RootFrameRuntime = class {
|
|
|
5789
5950
|
if (accumulated) mergeFrameWork(accumulated, work);
|
|
5790
5951
|
else frameWorkByLayer.set(layer, work);
|
|
5791
5952
|
}
|
|
5792
|
-
lastRound =
|
|
5953
|
+
lastRound = roundWorkByLayer;
|
|
5793
5954
|
this.consumeDirtyTransforms();
|
|
5794
5955
|
for (const [layer, work] of roundWorkByLayer) if (this.ownsLayer(layer)) layer.flushGeometry(work);
|
|
5795
5956
|
}
|
|
@@ -5831,7 +5992,7 @@ var RootFrameRuntime = class {
|
|
|
5831
5992
|
this.nextTickReject = null;
|
|
5832
5993
|
reject?.(error);
|
|
5833
5994
|
}
|
|
5834
|
-
/**
|
|
5995
|
+
/** 返回在当前帧及其同步新增工作稳定后结算的共享 Promise;持续动画不阻塞。 */
|
|
5835
5996
|
nextTick() {
|
|
5836
5997
|
if (!this.root.isActive || !this.animationFrameScheduled && this.pendingLayers.size === 0 && this.pendingLayouts.size === 0 && this.pendingTransformCompletions.size === 0 && this.completionWork.size === 0 && !this.hoverRefreshPending && this.participant?.hasPendingWork() !== true && this.participant?.hasPendingSpatialWork?.() !== true && this.participant?.hasPendingOverlayWork?.() !== true && this.participant?.hasPendingCompletionWork?.() !== true) return Promise.resolve();
|
|
5837
5998
|
if (!this.nextTickPromise) this.nextTickPromise = new Promise((resolve, reject) => {
|
|
@@ -5952,80 +6113,6 @@ var SceneRegistry = class {
|
|
|
5952
6113
|
}
|
|
5953
6114
|
};
|
|
5954
6115
|
//#endregion
|
|
5955
|
-
//#region packages/core/src/mutation/change-batch.ts
|
|
5956
|
-
/** @internal 合并 raw owner effects;单个 patch 直接借用,仅合并同 owner 字段时分配。 */
|
|
5957
|
-
function mergeOwnerPropertyChanges(ownerEffects) {
|
|
5958
|
-
const slots = /* @__PURE__ */ new Map();
|
|
5959
|
-
let mergedOwners = null;
|
|
5960
|
-
for (const { owner, patch } of ownerEffects) {
|
|
5961
|
-
const current = slots.get(owner);
|
|
5962
|
-
if (!current) {
|
|
5963
|
-
slots.set(owner, patch);
|
|
5964
|
-
continue;
|
|
5965
|
-
}
|
|
5966
|
-
let finalPatch;
|
|
5967
|
-
if (mergedOwners?.has(owner)) finalPatch = current;
|
|
5968
|
-
else {
|
|
5969
|
-
finalPatch = {};
|
|
5970
|
-
for (const key of Object.keys(current)) finalPatch[key] = current[key];
|
|
5971
|
-
slots.set(owner, finalPatch);
|
|
5972
|
-
(mergedOwners ??= /* @__PURE__ */ new Set()).add(owner);
|
|
5973
|
-
}
|
|
5974
|
-
for (const key of Object.keys(patch)) finalPatch[key] = patch[key];
|
|
5975
|
-
}
|
|
5976
|
-
return slots;
|
|
5977
|
-
}
|
|
5978
|
-
/**
|
|
5979
|
-
* 同步应用一份 trusted change batch。
|
|
5980
|
-
*
|
|
5981
|
-
* owner effects 先按对象身份合并最终 patch;所有 fields/raw links 安装完成后才运行
|
|
5982
|
-
* History、lifecycle、hooks、dirty 和一次 scene delivery。本函数不提供 rollback、
|
|
5983
|
-
* retry、receipt 或 rejected 结果。返回本批次是否实际安装属性或结构变化。
|
|
5984
|
-
*/
|
|
5985
|
-
function applyChangeBatch(root, ownerEffects, structureEffects = [], history) {
|
|
5986
|
-
if (ownerEffects.length === 0 && structureEffects.length === 0) return false;
|
|
5987
|
-
const slots = mergeOwnerPropertyChanges(ownerEffects);
|
|
5988
|
-
const properties = [];
|
|
5989
|
-
for (const [owner, patch] of slots) {
|
|
5990
|
-
const commit = owner.preparePropertyCommit(patch);
|
|
5991
|
-
if (commit) properties.push({
|
|
5992
|
-
owner,
|
|
5993
|
-
commit
|
|
5994
|
-
});
|
|
5995
|
-
}
|
|
5996
|
-
const structureBatch = prepareStructureBatch(structureEffects);
|
|
5997
|
-
const structure = structureBatch.changes;
|
|
5998
|
-
if (properties.length === 0 && structure.length === 0) return false;
|
|
5999
|
-
for (const { owner, commit } of properties) owner.installPropertyCommit(commit);
|
|
6000
|
-
installStructureLinks(structureBatch);
|
|
6001
|
-
if (history) {
|
|
6002
|
-
for (const { owner, commit } of properties) for (const field of commit.update.fields) {
|
|
6003
|
-
if (!field.sourceChanged) continue;
|
|
6004
|
-
history.recordPropertyChange(owner, field.key, field.beforeSource);
|
|
6005
|
-
}
|
|
6006
|
-
for (const { owner, before } of structure) history.recordStructureChange(owner, before);
|
|
6007
|
-
}
|
|
6008
|
-
syncStructureLifecycles(structureBatch.placementNodes);
|
|
6009
|
-
for (const { owner, commit } of properties) owner.syncPropertyCommitEvents(commit);
|
|
6010
|
-
for (const { owner, commit } of properties) owner.runPropertyCommitHook(commit);
|
|
6011
|
-
for (const { owner } of structure) owner.runBatchStructureHook();
|
|
6012
|
-
for (const { owner, commit } of properties) owner.notifyPortsCommit(commit);
|
|
6013
|
-
let layerOrderChanged = false;
|
|
6014
|
-
let hoverChanged = false;
|
|
6015
|
-
for (const { owner, commit } of properties) {
|
|
6016
|
-
owner.publishPropertyCommit(commit, false, false);
|
|
6017
|
-
if (commit.impact & ChangeImpact.LayerOrder) layerOrderChanged = true;
|
|
6018
|
-
else if (commit.impact & ChangeImpact.Hover) hoverChanged = true;
|
|
6019
|
-
}
|
|
6020
|
-
for (const { owner } of structure) owner.publishBatchStructureDirty();
|
|
6021
|
-
if (structure.length) root.commitBatchStructureChanges(structure, layerOrderChanged);
|
|
6022
|
-
else if (layerOrderChanged) root.commitLayerOrderChange();
|
|
6023
|
-
else if (hoverChanged) root.scheduleHoverRefresh();
|
|
6024
|
-
if (root.sceneRegistry.hasSceneChangeObservers) root.sceneRegistry.notifySceneChange(void 0, [...properties.map(({ owner }) => owner), ...structure.flatMap(({ owner, changed }) => [owner, ...changed])]);
|
|
6025
|
-
for (const { owner, commit } of properties) owner.dispatchPortsChange(commit);
|
|
6026
|
-
return true;
|
|
6027
|
-
}
|
|
6028
|
-
//#endregion
|
|
6029
6116
|
//#region packages/core/src/root/index.ts
|
|
6030
6117
|
/** 场景树根节点,统一管理 Layer、Viewport、输入、查询和帧提交。 */
|
|
6031
6118
|
var Root = class extends Node {
|
|
@@ -6242,7 +6329,7 @@ var Root = class extends Node {
|
|
|
6242
6329
|
}
|
|
6243
6330
|
/**
|
|
6244
6331
|
* 等待当前 frame-final completion 及其监听器同步新增的帧工作。
|
|
6245
|
-
*
|
|
6332
|
+
* 持续动画不延迟本次完成。监听器抛错时以同一个 error reject;没有待处理帧时立即完成。
|
|
6246
6333
|
*/
|
|
6247
6334
|
nextTick() {
|
|
6248
6335
|
return this.frameRuntime.nextTick();
|
|
@@ -6702,7 +6789,7 @@ var Layer = class Layer extends Element {
|
|
|
6702
6789
|
* @param order `paint` 按前到后排序,`none` 保留空间索引返回顺序。
|
|
6703
6790
|
*/
|
|
6704
6791
|
queryCommittedElements(area, order = "paint") {
|
|
6705
|
-
const elements = this.
|
|
6792
|
+
const elements = this.searchCommittedItems(area).map(({ element }) => element);
|
|
6706
6793
|
if (order === "none") return elements;
|
|
6707
6794
|
return elements.sort((a, b) => compareTreeOrder(b, a));
|
|
6708
6795
|
}
|
|
@@ -6723,10 +6810,6 @@ var Layer = class Layer extends Element {
|
|
|
6723
6810
|
items.sort((a, b) => compareTreeOrder(b.element, a.element));
|
|
6724
6811
|
for (const item of items) yield item.element;
|
|
6725
6812
|
}
|
|
6726
|
-
/** 直接查询 RBush 中与 world AABB 相交的已提交元素。 */
|
|
6727
|
-
searchCommittedElements(area) {
|
|
6728
|
-
return this.searchCommittedItems(area).map(({ element }) => element);
|
|
6729
|
-
}
|
|
6730
6813
|
/** 直接查询 RBush 中与 world AABB 相交的已提交空间项。 */
|
|
6731
6814
|
searchCommittedItems(area) {
|
|
6732
6815
|
const x = area.left;
|
|
@@ -6869,9 +6952,9 @@ var Layer = class Layer extends Element {
|
|
|
6869
6952
|
* 清空并重新绘制整个 Layer Canvas。dirty-rect Layer 的元素只绘制在 visual bounds 内,
|
|
6870
6953
|
* 因此直接用 viewport 的 RBush 候选组织绘制树;候选密度达到阈值时逐 child 判断可见性。
|
|
6871
6954
|
*/
|
|
6872
|
-
fullRepaint() {
|
|
6955
|
+
fullRepaint(dirtyPaintChildren = this.enableDirtyRect ? this.buildDirtyPaintChildren([this.root.viewport.getWorldRectView()], Layer.VIEWPORT_CANDIDATE_RATIO) : null) {
|
|
6873
6956
|
const previousDirtyPaintChildren = this.dirtyPaintChildren;
|
|
6874
|
-
this.dirtyPaintChildren =
|
|
6957
|
+
this.dirtyPaintChildren = dirtyPaintChildren;
|
|
6875
6958
|
try {
|
|
6876
6959
|
this.clear();
|
|
6877
6960
|
this.paint(this.ctx);
|
|
@@ -6884,28 +6967,32 @@ var Layer = class Layer extends Element {
|
|
|
6884
6967
|
const spatialCount = this.spatialItems.size;
|
|
6885
6968
|
const limit = spatialCount > 0 ? spatialCount * fullRepaintRatio : Infinity;
|
|
6886
6969
|
const queryPad = 1 / (this.root.viewport.scale * this.root.viewport.dpr);
|
|
6887
|
-
const search = (rect) => this.
|
|
6970
|
+
const search = (rect) => this.searchCommittedItems({
|
|
6888
6971
|
left: rect.left - queryPad,
|
|
6889
6972
|
top: rect.top - queryPad,
|
|
6890
6973
|
width: rect.width + queryPad * 2,
|
|
6891
6974
|
height: rect.height + queryPad * 2
|
|
6892
6975
|
});
|
|
6893
6976
|
let hits;
|
|
6977
|
+
let hitCount;
|
|
6894
6978
|
if (worldRects.length === 1) {
|
|
6895
|
-
|
|
6896
|
-
|
|
6979
|
+
const items = search(worldRects[0]);
|
|
6980
|
+
hitCount = items.length;
|
|
6981
|
+
if (hitCount >= limit) return null;
|
|
6982
|
+
hits = items;
|
|
6897
6983
|
} else {
|
|
6898
6984
|
const unique = /* @__PURE__ */ new Set();
|
|
6899
6985
|
for (const rect of worldRects) {
|
|
6900
6986
|
for (const hit of search(rect)) unique.add(hit);
|
|
6901
6987
|
if (unique.size >= limit) return null;
|
|
6902
6988
|
}
|
|
6903
|
-
|
|
6989
|
+
hitCount = unique.size;
|
|
6990
|
+
hits = unique;
|
|
6904
6991
|
}
|
|
6905
6992
|
const childrenByParent = /* @__PURE__ */ new Map();
|
|
6906
|
-
if (
|
|
6993
|
+
if (hitCount === 0) return childrenByParent;
|
|
6907
6994
|
const included = /* @__PURE__ */ new Set();
|
|
6908
|
-
for (const hit of hits) {
|
|
6995
|
+
for (const { element: hit } of hits) {
|
|
6909
6996
|
let child = hit;
|
|
6910
6997
|
while (child !== this) {
|
|
6911
6998
|
if (included.has(child)) break;
|
|
@@ -7022,40 +7109,37 @@ var Layer = class Layer extends Element {
|
|
|
7022
7109
|
if (this.enableDirtyRect && hasDirty) {
|
|
7023
7110
|
const { scale, x, y } = this.root.viewport;
|
|
7024
7111
|
const worldPad = 2 / scale;
|
|
7025
|
-
const worldRects = [...damageRects];
|
|
7026
|
-
if (dirtyNodes.size > 0 || paintDirtyNodes.size > 0) {
|
|
7027
|
-
const dirtyBoundsMemo = dirtyNodes.size + paintDirtyNodes.size > 1 ? /* @__PURE__ */ new Map() : void 0;
|
|
7028
|
-
const addPadded = (node) => {
|
|
7029
|
-
if (!node.isActive || node.layer !== this) return;
|
|
7030
|
-
const r = dirtyBoundsMemo ? node.transform.getDirtyRect(dirtyBoundsMemo) : node.transform.getDirtyRect();
|
|
7031
|
-
if (!r || r.width <= 0 || r.height <= 0) return;
|
|
7032
|
-
worldRects.push({
|
|
7033
|
-
left: r.left - worldPad,
|
|
7034
|
-
top: r.top - worldPad,
|
|
7035
|
-
width: r.width + worldPad * 2,
|
|
7036
|
-
height: r.height + worldPad * 2
|
|
7037
|
-
});
|
|
7038
|
-
};
|
|
7039
|
-
for (const node of dirtyNodes) addPadded(node);
|
|
7040
|
-
for (const node of paintDirtyNodes) addPadded(node);
|
|
7041
|
-
}
|
|
7042
7112
|
const visibleWorldW = paintOwner.width / scale;
|
|
7043
7113
|
const visibleWorldH = paintOwner.height / scale;
|
|
7044
7114
|
const visibleArea = visibleWorldW * visibleWorldH;
|
|
7045
7115
|
const viewLeft = -x / scale;
|
|
7046
7116
|
const viewTop = -y / scale;
|
|
7047
7117
|
const visibleWorldRects = [];
|
|
7048
|
-
|
|
7049
|
-
const
|
|
7050
|
-
const
|
|
7051
|
-
const
|
|
7052
|
-
const
|
|
7118
|
+
const addVisible = (rect, pad = 0) => {
|
|
7119
|
+
const rectLeft = rect.left - pad;
|
|
7120
|
+
const rectTop = rect.top - pad;
|
|
7121
|
+
const left = Math.max(rectLeft, viewLeft);
|
|
7122
|
+
const top = Math.max(rectTop, viewTop);
|
|
7123
|
+
const right = Math.min(rectLeft + (rect.width + pad * 2), viewLeft + visibleWorldW);
|
|
7124
|
+
const bottom = Math.min(rectTop + (rect.height + pad * 2), viewTop + visibleWorldH);
|
|
7053
7125
|
if (right > left && bottom > top) visibleWorldRects.push({
|
|
7054
7126
|
left,
|
|
7055
7127
|
top,
|
|
7056
7128
|
width: right - left,
|
|
7057
7129
|
height: bottom - top
|
|
7058
7130
|
});
|
|
7131
|
+
};
|
|
7132
|
+
for (const rect of damageRects) addVisible(rect);
|
|
7133
|
+
if (dirtyNodes.size > 0 || paintDirtyNodes.size > 0) {
|
|
7134
|
+
const dirtyBoundsMemo = dirtyNodes.size + paintDirtyNodes.size > 1 ? /* @__PURE__ */ new Map() : void 0;
|
|
7135
|
+
const addPadded = (node) => {
|
|
7136
|
+
if (!node.isActive || node.layer !== this) return;
|
|
7137
|
+
const r = dirtyBoundsMemo ? node.transform.getDirtyRect(dirtyBoundsMemo) : node.transform.getDirtyRect();
|
|
7138
|
+
if (!r || r.width <= 0 || r.height <= 0) return;
|
|
7139
|
+
addVisible(r, worldPad);
|
|
7140
|
+
};
|
|
7141
|
+
for (const node of dirtyNodes) addPadded(node);
|
|
7142
|
+
for (const node of paintDirtyNodes) addPadded(node);
|
|
7059
7143
|
}
|
|
7060
7144
|
const { rects: mergedWorldRects } = this.dirtyGrid.merge(visibleWorldRects, visibleArea, Layer.FULL_REPAINT_RATIO);
|
|
7061
7145
|
if (!mergedWorldRects) {
|
|
@@ -7068,7 +7152,7 @@ var Layer = class Layer extends Element {
|
|
|
7068
7152
|
} else {
|
|
7069
7153
|
const dirtyPaintChildren = this.buildDirtyPaintChildren(mergedWorldRects);
|
|
7070
7154
|
if (!dirtyPaintChildren) {
|
|
7071
|
-
this.fullRepaint();
|
|
7155
|
+
this.fullRepaint(null);
|
|
7072
7156
|
didFullRepaint = true;
|
|
7073
7157
|
this.flashFullRepaint();
|
|
7074
7158
|
} else {
|
|
@@ -7133,4 +7217,4 @@ var Layer = class Layer extends Element {
|
|
|
7133
7217
|
}
|
|
7134
7218
|
};
|
|
7135
7219
|
//#endregion
|
|
7136
|
-
export { ChangeImpact, CustomEvent, DEFAULT_CONNECTION_PORT_SCHEMA, EVENT_NAMES, Element, ElementProperties, ElementTransform, EventEmitter, FrameStabilizationError, Layer, LayerProperties, LayerTransform, Node, NodeLifecycleEvent, NodeProperties, Root, RootFrameRuntime, RootInputController, SKIN_DEFAULTS, SceneRegistry, Shape, ShapeProperties, ShapeTransform, Skin, TransformProperties, Viewport, createAuthoredLineSubpath, createGeometryQuery, createGeometrySnapshot, createLineSubpath, createPathLocalId, diffChildren, evaluatePathSegmentPoint, getElementConnectionPort, getElementConnectionPortPoint, getElementConnectionPortPoints, isFormControlTarget, isReparentTransformIntent, mergeOwnerPropertyChanges, projectConnectionPortPoint, resolveAuthoredGeometryFramePatch, resolveAuthoredSubpath, resolveOrigin, resolveReferenceBoundsTranslation, resolveReferenceTransform, resolveReferenceTransformTarget, splitPathSegment };
|
|
7220
|
+
export { ChangeImpact, CustomEvent, DEFAULT_CONNECTION_PORT_SCHEMA, EVENT_NAMES, Element, ElementProperties, ElementTransform, EventEmitter, FrameStabilizationError, Layer, LayerProperties, LayerTransform, Node, NodeLifecycleEvent, NodeProperties, Root, RootFrameRuntime, RootInputController, SKIN_DEFAULTS, SceneRegistry, Shape, ShapeProperties, ShapeTransform, Skin, TransformProperties, Viewport, createAuthoredLineSubpath, createGeometryQuery, createGeometrySnapshot, createLineSubpath, createPathLocalId, diffChildren, evaluatePathSegmentPoint, getAuthoredPathLayoutBounds, getElementConnectionPort, getElementConnectionPortPoint, getElementConnectionPortPoints, isFormControlTarget, isReparentTransformIntent, mergeOwnerPropertyChanges, projectConnectionPortPoint, resolveAuthoredGeometryFramePatch, resolveAuthoredSubpath, resolveOrigin, resolveReferenceBoundsTranslation, resolveReferenceTransform, resolveReferenceTransformTarget, splitPathSegment };
|
package/dist/layer/index.d.ts
CHANGED
|
@@ -161,8 +161,6 @@ export declare class Layer<P extends LayerProperties = LayerProperties, O extend
|
|
|
161
161
|
* @internal
|
|
162
162
|
*/
|
|
163
163
|
iterateCommittedElements(area: RectWithCenter): IterableIterator<Element>;
|
|
164
|
-
/** 直接查询 RBush 中与 world AABB 相交的已提交元素。 */
|
|
165
|
-
private searchCommittedElements;
|
|
166
164
|
/** 直接查询 RBush 中与 world AABB 相交的已提交空间项。 */
|
|
167
165
|
private searchCommittedItems;
|
|
168
166
|
/** 将本帧积累的 visual bounds 更新批量提交到 RBush。 */
|
|
@@ -24,8 +24,9 @@ export declare function mergeOwnerPropertyChanges(ownerEffects: readonly OwnerPr
|
|
|
24
24
|
* 同步应用一份 trusted change batch。
|
|
25
25
|
*
|
|
26
26
|
* owner effects 先按对象身份合并最终 patch;所有 fields/raw links 安装完成后才运行
|
|
27
|
-
* History、lifecycle、hooks、dirty
|
|
27
|
+
* History、lifecycle、hooks、dirty 和最多一次 scene delivery;纯 paint 变化不通知 scene。
|
|
28
|
+
* 本函数不提供 rollback、
|
|
28
29
|
* retry、receipt 或 rejected 结果。返回本批次是否实际安装属性或结构变化。
|
|
29
30
|
*/
|
|
30
|
-
export declare function applyChangeBatch(root: Root, ownerEffects: readonly OwnerPropertyChange[], structureEffects?: readonly StructureChange[], history?: ChangeHistorySink): boolean;
|
|
31
|
+
export declare function applyChangeBatch(root: Root | undefined, ownerEffects: readonly OwnerPropertyChange[], structureEffects?: readonly StructureChange[], history?: ChangeHistorySink): boolean;
|
|
31
32
|
export type { StructureChange } from "./structure-change";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { Node } from "../node/node";
|
|
2
|
+
type ParentPlacement = [
|
|
3
|
+
previousParent: Node | undefined,
|
|
4
|
+
expectedParent: Node | undefined
|
|
5
|
+
];
|
|
2
6
|
/** 一个 trusted batch 中某个 affected parent 的最终 children。 */
|
|
3
7
|
export interface StructureChange {
|
|
4
8
|
readonly owner: Node;
|
|
@@ -34,7 +38,7 @@ export interface PreparedStructureChange extends StructureChange {
|
|
|
34
38
|
/** @internal structure finalize 交给 install/publication 的局部记录。 */
|
|
35
39
|
export interface PreparedStructureBatch {
|
|
36
40
|
readonly changes: readonly PreparedStructureChange[];
|
|
37
|
-
readonly placementNodes:
|
|
41
|
+
readonly placementNodes: ReadonlyMap<Node, ParentPlacement>;
|
|
38
42
|
}
|
|
39
43
|
/** @internal 计算同一 owner 两份 children 的最小 placement 差异。 */
|
|
40
44
|
export declare function diffChildren(before: readonly Node[], after: readonly Node[]): ChildrenDiff;
|
|
@@ -46,4 +50,5 @@ export declare function installStructureLinks(batch: PreparedStructureBatch): vo
|
|
|
46
50
|
* @internal 所有 fields/raw links 安装及 History 记录后,自上而下同步每个 placement 节点;
|
|
47
51
|
* parent 先完成自身迁移,同批进入它的 children 再按 parent 的最终 context 同步。
|
|
48
52
|
*/
|
|
49
|
-
export declare function syncStructureLifecycles(nodes:
|
|
53
|
+
export declare function syncStructureLifecycles(nodes: ReadonlyMap<Node, ParentPlacement>): void;
|
|
54
|
+
export {};
|
package/dist/node/element.d.ts
CHANGED
|
@@ -175,7 +175,7 @@ export declare class Element<P extends ElementProperties = ElementProperties, O
|
|
|
175
175
|
/** 创建带显示、输入、锚点和可选 children 的元素。 */
|
|
176
176
|
constructor(options?: NoInfer<O>, properties?: P, Transform?: ElementTransformClass);
|
|
177
177
|
/** raw parent link 变化只标记 transform local commit。 */
|
|
178
|
-
protected onParentChanged(): void;
|
|
178
|
+
protected onParentChanged(_previousParent?: Node): void;
|
|
179
179
|
/** raw children 完整安装后的 transform hook。 */
|
|
180
180
|
protected onChildrenChanged(): void;
|
|
181
181
|
/** raw children、lifecycle 和 hook 完成后的 transform dirty publication。 */
|
|
@@ -207,7 +207,7 @@ export declare class Element<P extends ElementProperties = ElementProperties, O
|
|
|
207
207
|
/** @internal 在内部 publication 完成后派发 authored `portschange`。 */
|
|
208
208
|
dispatchPortsChange(commit: PreparedElementPropertyCommit): void;
|
|
209
209
|
/** @internal 使用 finalize 已有 impact 登记 dirty,并按 direct 语义通知场景。 */
|
|
210
|
-
publishPropertyCommit(commit: PreparedElementPropertyCommit, notifyScene: boolean, publishRootImpact?: boolean):
|
|
210
|
+
publishPropertyCommit(commit: PreparedElementPropertyCommit, notifyScene: boolean, publishRootImpact?: boolean): boolean;
|
|
211
211
|
/** 应用一份 direct configured/runtime update 并完成一次成功路径 publication。 */
|
|
212
212
|
private commitPreparedProperty;
|
|
213
213
|
private commitConfiguredOptions;
|
package/dist/node/node.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export declare class Node<P extends NodeProperties = NodeProperties, Child exten
|
|
|
84
84
|
/** 解除结构所有权、sibling、上下文和事件冒泡关系。 */
|
|
85
85
|
private unlinkFromParent;
|
|
86
86
|
/** raw parent link 改变后的派生 owner 接缝。 */
|
|
87
|
-
protected onParentChanged(): void;
|
|
87
|
+
protected onParentChanged(_previousParent?: Node): void;
|
|
88
88
|
/** 直接 children 事务提交后的扩展点;构造期 children 不触发。 */
|
|
89
89
|
protected onChildrenChanged(): void;
|
|
90
90
|
/** 全部 raw links 安装后的结构 dirty publication 扩展点。 */
|
|
@@ -107,6 +107,8 @@ export declare class Node<P extends NodeProperties = NodeProperties, Child exten
|
|
|
107
107
|
detachBatchParent(): void;
|
|
108
108
|
/** @internal 接收 trusted batch 转移所有权的最终 children 与其变化窗口。 */
|
|
109
109
|
installBatchChildren(children: readonly Node[], start: number, end: number): void;
|
|
110
|
+
/** @internal 完整安装后的 parent hook;重入提交已改写归属时跳过旧结果。 */
|
|
111
|
+
notifyBatchParentChanged(previousParent: Node | undefined, expectedParent: Node | undefined): void;
|
|
110
112
|
/** @internal 按当前 parent 同步最终 lifecycle context。 */
|
|
111
113
|
syncPlacementLifecycle(): void;
|
|
112
114
|
/** @internal tree 已完整安装后登记当前 owner 的 dirty path。 */
|
|
@@ -115,9 +117,7 @@ export declare class Node<P extends NodeProperties = NodeProperties, Child exten
|
|
|
115
117
|
runBatchStructureHook(): void;
|
|
116
118
|
/** 从当前 owner 移除一个直接 child,可选择同时停用它。 */
|
|
117
119
|
private removeOwnChild;
|
|
118
|
-
/**
|
|
119
|
-
private detachFromParent;
|
|
120
|
-
/** 分离 incoming nodes;只有同步回调改写归属时才创建过滤后的数组。 */
|
|
120
|
+
/** 构造期采用 children,回调已建立的新归属不再由旧输入接管。 */
|
|
121
121
|
private adoptIncoming;
|
|
122
122
|
/** 统一实现 append/prepend/before/after 的移动和插入事务。 */
|
|
123
123
|
private insertAt;
|
|
@@ -131,7 +131,7 @@ export declare class Node<P extends NodeProperties = NodeProperties, Child exten
|
|
|
131
131
|
insertAfter(newChild: Child, refChild: Child): this;
|
|
132
132
|
/** 用一个可复用节点替换指定 child。 */
|
|
133
133
|
replaceChild(newChild: Child, oldChild: Child): this;
|
|
134
|
-
/**
|
|
134
|
+
/** 替换完整 children 序列,完整安装后发布变化。 */
|
|
135
135
|
replaceChildren(...children: Child[]): this;
|
|
136
136
|
/** 将节点移动到当前节点之前。 */
|
|
137
137
|
before(...nodes: Node[]): this;
|
package/dist/node/shape.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ export declare class Shape<P extends ShapeProperties = ShapeProperties, O extend
|
|
|
138
138
|
readonly nx: number;
|
|
139
139
|
readonly ny: number;
|
|
140
140
|
}): PointView;
|
|
141
|
-
/** Replay
|
|
141
|
+
/** Replay committed geometry without expanding ordinary rectangle subpaths. */
|
|
142
142
|
protected buildResolvedPath(ctx: CanvasRenderingContext2D): void;
|
|
143
143
|
paint(ctx?: CanvasRenderingContext2D): void;
|
|
144
144
|
/** 定义形状路径(width × height),hover 复用此路径 */
|
|
@@ -110,13 +110,12 @@ export declare class RootFrameRuntime {
|
|
|
110
110
|
resolveCursor(point: PointView | undefined, contentCursor: string): string;
|
|
111
111
|
private consumeDirtyTransforms;
|
|
112
112
|
private flushLayouts;
|
|
113
|
-
private takePendingLayers;
|
|
114
113
|
private dirtyOwnerKeys;
|
|
115
114
|
private stabilize;
|
|
116
115
|
/** 停止 RAF、Tween 和待处理工作,并结清当前 `nextTick()`。 */
|
|
117
116
|
stop(): void;
|
|
118
117
|
private resolveNextTick;
|
|
119
118
|
private rejectNextTick;
|
|
120
|
-
/**
|
|
119
|
+
/** 返回在当前帧及其同步新增工作稳定后结算的共享 Promise;持续动画不阻塞。 */
|
|
121
120
|
nextTick(): Promise<void>;
|
|
122
121
|
}
|
package/dist/root/index.d.ts
CHANGED
|
@@ -124,7 +124,7 @@ export declare class Root extends Node<NodeProperties, Layer> {
|
|
|
124
124
|
scheduleAnimation(): void;
|
|
125
125
|
/**
|
|
126
126
|
* 等待当前 frame-final completion 及其监听器同步新增的帧工作。
|
|
127
|
-
*
|
|
127
|
+
* 持续动画不延迟本次完成。监听器抛错时以同一个 error reject;没有待处理帧时立即完成。
|
|
128
128
|
*/
|
|
129
129
|
nextTick(): Promise<void>;
|
|
130
130
|
/**
|
|
@@ -33,6 +33,8 @@ export declare class RootInputController {
|
|
|
33
33
|
get lastPointerPos(): PointView;
|
|
34
34
|
/** Root 当前是否认为指针位于容器内。 */
|
|
35
35
|
get isPointerInside(): boolean;
|
|
36
|
+
/** 当前 DOM 焦点决定键盘归属;无元素焦点时采用最近的 Root 指针归属。 */
|
|
37
|
+
get isKeyboardOwner(): boolean;
|
|
36
38
|
/** @internal 安装当前 Root 的键盘、指针、滚轮和焦点监听。 */
|
|
37
39
|
activate(): void;
|
|
38
40
|
/** @internal 移除监听并清理当前输入和 hover 会话。 */
|