@fulate/core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ import { type Rect } from "@fulate/share";
2
+ export interface DirtyGridResult {
3
+ /** 合并后的脏矩形;`null` 表示应完整重绘 Layer。 */
4
+ rects: Rect[] | null;
5
+ }
6
+ /** 使用固定 3×3 网格合并零散 damage,并决定是否完整重绘。 */
7
+ export declare class DirtyGrid {
8
+ /** 每个网格单元当前合并得到的矩形。 */
9
+ private buckets;
10
+ /**
11
+ * 合并可见 damage;返回 `null` 表示合并面积已不值得局部重绘。
12
+ * @param dirtyRects 已裁剪到可见 world 区域的矩形。
13
+ * @param visibleArea 当前可见 world 区域面积。
14
+ * @param fullRepaintRatio 触发完整重绘的面积比例。
15
+ */
16
+ merge(dirtyRects: Rect[], visibleArea: number, fullRepaintRatio: number): DirtyGridResult;
17
+ }
@@ -0,0 +1,224 @@
1
+ import { Element, ElementProperties, type AnyElement } from "../node/element";
2
+ import { ElementTransform } from "../node/element-transform";
3
+ import { type PropertyChanges } from "../node/properties";
4
+ import type { BaseElementOption, ElementOptionPatch } from "../node/element";
5
+ import { Bound, type Rect, type RectWithCenter } from "@fulate/share";
6
+ import type { Root } from "../root";
7
+ /** 一轮 Layer 几何和绘制提交所消费的工作快照。
8
+ *
9
+ * @internal
10
+ */
11
+ export interface LayerFrameWork {
12
+ /** 需要提交布局、矩阵和几何的元素。 */
13
+ dirtyNodes: Set<Element>;
14
+ /** 仅需要重新绘制的元素。 */
15
+ paintDirtyNodes: Set<Element>;
16
+ /** 元素移除或移动前留下的 world damage 区域。 */
17
+ damageRects: Rect[];
18
+ /** 是否跳过脏矩形并完整重绘整层。 */
19
+ forceFullRepaint: boolean;
20
+ }
21
+ /** Layer 的构造选项。 */
22
+ export interface LayerOption extends Omit<BaseElementOption, "layer"> {
23
+ /** Root 中的图层顺序,默认 `1`,可通过 `setOptions()` 更新。 */
24
+ zIndex?: number;
25
+ /** 当前 Layer 中的元素是否可以参与层级排列,默认 `false`。 */
26
+ elementArrangementEnabled?: boolean;
27
+ /** 是否启用脏矩形绘制,默认 `true`,仅构造时设置。 */
28
+ enableDirtyRect?: boolean;
29
+ /** 是否允许 Viewport 使用 CSS 快速预览,默认 `true`,仅构造时设置。 */
30
+ cssTransformable?: boolean;
31
+ /** 是否显示脏矩形调试层,默认 `false`,仅构造时设置。 */
32
+ debugDirtyRect?: boolean;
33
+ }
34
+ /** `Layer.setOptions()` 接受的运行时补丁,不包含三个构造期绘制标志。 */
35
+ export type LayerOptionPatch<O extends LayerOption = LayerOption> = Omit<ElementOptionPatch<O>, "enableDirtyRect" | "cssTransformable" | "debugDirtyRect">;
36
+ /** Layer 选项规范化后的属性快照。 */
37
+ export declare class LayerProperties extends ElementProperties {
38
+ /** 当前图层顺序,默认 `1`。 */
39
+ zIndex: number;
40
+ /** 当前 Layer 中的元素是否可以参与层级排列,默认 `false`。 */
41
+ elementArrangementEnabled: boolean;
42
+ /** 是否启用脏矩形绘制,默认 `true`。 */
43
+ enableDirtyRect: boolean;
44
+ /** 是否允许 CSS 快速预览,默认 `true`。 */
45
+ cssTransformable: boolean;
46
+ /** 是否显示脏矩形调试层,默认 `false`。 */
47
+ debugDirtyRect: boolean;
48
+ /** 创建并规范化 Layer 属性。 */
49
+ constructor(options?: LayerOption);
50
+ /** 将 `zIndex` 变化映射为 Layer 排序和 hover 更新。 */
51
+ getImpact(changes: PropertyChanges): number;
52
+ }
53
+ /** Layer 以 Root 逻辑尺寸解析 fit,并作为 transform ancestry 终点。 */
54
+ export declare class LayerTransform<E extends Layer = Layer> extends ElementTransform<E> {
55
+ protected resolveFitSize(): void;
56
+ }
57
+ /** Root 直接拥有的 Canvas 图层及其帧提交状态。 */
58
+ export declare class Layer<P extends LayerProperties = LayerProperties, O extends LayerOption = LayerOption> extends Element<P, O, LayerOptionPatch<O>> {
59
+ /** 序列化使用的节点类型。 */
60
+ readonly type: string;
61
+ /** 由当前 Layer 拥有并挂载到 Root 容器的 Canvas。 */
62
+ canvasEl: HTMLCanvasElement;
63
+ /** `canvasEl` 的 2D 绘制上下文。 */
64
+ ctx: CanvasRenderingContext2D;
65
+ /** 当前 Root 图层顺序。 */
66
+ get zIndex(): number;
67
+ /** 当前 Layer 中的元素是否可以参与层级排列。 */
68
+ get elementArrangementEnabled(): boolean;
69
+ /** 是否使用脏矩形绘制。 */
70
+ get enableDirtyRect(): boolean;
71
+ /** 是否允许 Viewport 使用 CSS 快速预览。 */
72
+ get cssTransformable(): boolean;
73
+ /** 已提交 world visual AABB 的空间索引。 */
74
+ private spatialIndex;
75
+ /** Element 到可复用 RBush item 的映射。 */
76
+ private spatialItems;
77
+ /** 下一轮 frame runtime 要取走的 Layer 工作。 */
78
+ private pendingWork;
79
+ /** 已保存提交前 visual bounds、等待绘制后清理的节点。 */
80
+ private previousVisualBoundsNodes;
81
+ /** 当前局部绘制按 parent 选中的直接 children;只在一次 `paint()` 内有效。
82
+ *
83
+ * @internal
84
+ */
85
+ dirtyPaintChildren: ReadonlyMap<AnyElement, readonly AnyElement[]> | null;
86
+ /** 当前绘制所属的 Root;只在一次帧提交内有效。
87
+ *
88
+ * @internal
89
+ */
90
+ paintOwner: Root | null;
91
+ /** 声明当前节点具有 Layer 结构语义。 */
92
+ isLayerNode(): this is Layer;
93
+ /** 是否显示脏矩形调试层。 */
94
+ get debugDirtyRect(): boolean;
95
+ /** 脏矩形调试用的独立 Canvas。 */
96
+ private debugSurface;
97
+ /** 调试矩形自动清除定时器。 */
98
+ private debugTimer;
99
+ /** 本帧需要写入或移出 RBush 的元素。 */
100
+ private pendingSpatialNodes;
101
+ /** 合并 damage 超过可见面积此比例时完整重绘。 */
102
+ private static FULL_REPAINT_RATIO;
103
+ /** 候选命中达到空间项此比例时直接完整重绘。 */
104
+ private static CANDIDATE_FULL_REPAINT_RATIO;
105
+ /** 空间项变更超过现有项此比例时重建整个 RBush。 */
106
+ private static RBUSH_REBUILD_RATIO;
107
+ /** 将零散 damage 合并为有限数量矩形的网格。 */
108
+ private dirtyGrid;
109
+ /** 创建拥有独立 Canvas surface 的 Layer。 */
110
+ constructor(options?: NoInfer<O>, properties?: P);
111
+ /** 首次挂载时建立 Layer 上下文并初始化 Canvas 样式。 */
112
+ protected onMount(): void;
113
+ /** 激活时挂载 Canvas、注册 Layer 并安排首次完整提交。 */
114
+ protected onActivate(root: Root | null): void;
115
+ /** 停用时注销 Layer、移除 Canvas 并清理 Viewport 绘制记录。 */
116
+ protected onDeactivate(root: Root | null): void;
117
+ /** 卸载时释放 Canvas、空间索引、调试层和全部待提交状态。 */
118
+ protected onUnmount(): void;
119
+ /** 从 DOM 移除主 Canvas 和可选调试 Canvas。 */
120
+ private removeCanvases;
121
+ /** 属性提交后同步 Layer 自有的 Canvas 显示状态。 */
122
+ protected onPropertiesChanged(current: P, changes: PropertyChanges): void;
123
+ /**
124
+ * 按逻辑像素尺寸和 DPR 更新 Canvas backing store,并返回像素尺寸是否变化。
125
+ * @param width Canvas CSS/逻辑宽度。
126
+ * @param height Canvas CSS/逻辑高度。
127
+ * @param dpr 设备像素比,用于计算 backing store 尺寸。
128
+ */
129
+ resizeSurface(width: number, height: number, dpr: number): boolean;
130
+ /** 将需要写入空间索引的元素加入本帧队列。
131
+ *
132
+ * @internal
133
+ */
134
+ queueSpatialUpdate(node: Element): void;
135
+ /** 记录已捕获旧 visual bounds 的元素,以便绘制后清理缓存。
136
+ *
137
+ * @internal
138
+ */
139
+ registerPreviousVisualBounds(node: Element): void;
140
+ /** 绘制覆盖旧区域后清除节点的提交前 visual bounds。 */
141
+ private clearPreviousVisualBounds;
142
+ /** 从 pending 集合、item map 和 RBush 移除节点。 */
143
+ private removeSpatialItem;
144
+ /** 元素停用时移除其空间项和待处理状态,并保留需要重绘的旧区域。 */
145
+ detachNode(node: Element): void;
146
+ /**
147
+ * 查询 world visual AABB 相交的已提交元素,可按 Layer 内绘制顺序返回。
148
+ * @param area world 坐标查询矩形。
149
+ * @param order `paint` 按前到后排序,`none` 保留空间索引返回顺序。
150
+ */
151
+ queryCommittedElements(area: RectWithCenter, order?: "paint" | "none"): Element[];
152
+ /** @internal Copy the last visual bounds committed to this Layer index. */
153
+ getCommittedVisualBounds(node: Element): Bound | null;
154
+ /**
155
+ * Lazily yields visual-index candidates from the top of this Layer's paint
156
+ * order. The RBush broad-phase result is sorted in place; precise hit work
157
+ * stays with the consumer and stops when the iterator is closed.
158
+ *
159
+ * @internal
160
+ */
161
+ iterateCommittedElements(area: RectWithCenter): IterableIterator<Element>;
162
+ /** 直接查询 RBush 中与 world AABB 相交的已提交元素。 */
163
+ private searchCommittedElements;
164
+ /** 直接查询 RBush 中与 world AABB 相交的已提交空间项。 */
165
+ private searchCommittedItems;
166
+ /** 将本帧积累的 visual bounds 更新批量提交到 RBush。 */
167
+ flushRbush(): void;
168
+ /** 以节点当前 world visual bounds 创建或更新空间项。 */
169
+ private updateSpatialItem;
170
+ /** 标记元素需要重新提交布局、几何、空间索引和绘制。 */
171
+ invalidateLayout(node: Element): void;
172
+ /** 标记元素只需重绘而不重新提交几何。 */
173
+ invalidatePaint(node: Element): void;
174
+ /** 把当前 Layer 登记到所属 Root 的下一帧。 */
175
+ private scheduleCommit;
176
+ /** 请求整层完整重绘而不单独标脏全部元素几何。 */
177
+ invalidateAll(): void;
178
+ /** 判断 pendingWork 是否包含 geometry、paint、damage 或完整重绘。 */
179
+ private hasWork;
180
+ /** 取走下一轮几何提交要消费的工作快照;没有工作时返回 `null`。
181
+ *
182
+ * @internal
183
+ */
184
+ takeFrameWork(): LayerFrameWork | null;
185
+ /** @internal stabilization failure 诊断当前仍 pending 的 dirty owner keys。 */
186
+ pendingDirtyOwnerKeys(): readonly string[];
187
+ /** 提交工作快照中的布局和 world 几何,过程中可以产生下一轮工作。
188
+ *
189
+ * @internal
190
+ */
191
+ flushGeometry(work: LayerFrameWork): void;
192
+ /** 判断节点或其 ancestor 是否仍有下一帧 damage。 */
193
+ private hasPendingDamage;
194
+ /** 清理本次已覆盖且没有再次失效的提交前 visual bounds。 */
195
+ private clearPaintedDamage;
196
+ /** 清空并重新绘制整个 Layer Canvas。 */
197
+ private fullRepaint;
198
+ /** 树结构变化后提交 Layer 内用于命中排序的 preorder。
199
+ *
200
+ * @internal
201
+ */
202
+ commitStructureOrder(): void;
203
+ /** 从最终 damage 的 RBush hits 构建一次绘制期有序邻接表。 */
204
+ private buildDirtyPaintChildren;
205
+ /** 裁剪到 damage 矩形,并消费已经完成组织的候选绘制树。 */
206
+ private paintDirtyRects;
207
+ /** 按需创建并挂载脏矩形调试 Canvas。 */
208
+ private ensureDebugSurface;
209
+ /** 在调试 Canvas 上短暂显示脏矩形和命中轮廓。 */
210
+ private flashRects;
211
+ /** 绘制几何稳定后积累的工作,并返回是否产生了真实 Canvas 绘制。
212
+ *
213
+ * @internal
214
+ */
215
+ flushPaint(work: LayerFrameWork): boolean;
216
+ /** 将 world damage 转为覆盖完整像素的 backing-store 矩形。 */
217
+ private worldToScreenRects;
218
+ /** 在调试层标记本次完整重绘。 */
219
+ private flashFullRepaint;
220
+ /** 使用已提交顺序绘制 children。 */
221
+ paint(ctx?: CanvasRenderingContext2D): void;
222
+ /** 清空整个 Canvas backing store,不改变场景树或待提交状态。 */
223
+ clear(): void;
224
+ }
@@ -0,0 +1,29 @@
1
+ import type { Element } from "../node/element";
2
+ import type { Node } from "../node/node";
3
+ import type { Root } from "../root";
4
+ import { type StructureChange } from "./structure-change";
5
+ /** 领域 owner writer 产生的 typed configured patch effect。 */
6
+ export interface OwnerPropertyChange {
7
+ readonly owner: Element;
8
+ readonly patch: Readonly<Record<string, unknown>>;
9
+ }
10
+ /**
11
+ * 可选 semantic History owner 消费的 actual changed fields/placements。
12
+ * before 是 finalize 已有的 raw configured source;sink 在语义操作结束时读取 live final,
13
+ * 并决定是否持久化复制。
14
+ */
15
+ export interface ChangeHistorySink {
16
+ /** 记录一个 owner/key 首次触及批次提供的 raw configured before。 */
17
+ recordPropertyChange(owner: Element, key: string, before: unknown): void;
18
+ /** 记录一个节点首次触及批次提供的 before placement。 */
19
+ recordPlacementChange(node: Node, beforeOwner: Node | null, beforeIndex: number): void;
20
+ }
21
+ /**
22
+ * 同步应用一份 trusted change batch。
23
+ *
24
+ * owner effects 先按对象身份合并最终 patch;所有 fields/raw links 安装完成后才运行
25
+ * History、lifecycle、hooks、dirty 和一次 scene delivery。本函数不提供 rollback、
26
+ * retry、receipt 或 rejected 结果。
27
+ */
28
+ export declare function applyChangeBatch(root: Root, ownerEffects: readonly OwnerPropertyChange[], structureEffects?: readonly StructureChange[], history?: ChangeHistorySink): void;
29
+ export type { StructureChange } from "./structure-change";
@@ -0,0 +1,30 @@
1
+ import type { Node } from "../node/node";
2
+ /** 一个 trusted batch 中某个 affected parent 的最终 children。 */
3
+ export interface StructureChange {
4
+ readonly owner: Node;
5
+ readonly children: readonly Node[];
6
+ }
7
+ /** @internal affected-parent install 与 publication 共用的最终 delta。 */
8
+ export interface PreparedStructureChange extends StructureChange {
9
+ readonly before: readonly Node[];
10
+ readonly changed: readonly Node[];
11
+ }
12
+ /** @internal structure finalize 交给 install/publication 的局部记录。 */
13
+ export interface PreparedStructureBatch {
14
+ readonly changes: readonly PreparedStructureChange[];
15
+ readonly placementNodes: ReadonlySet<Node>;
16
+ }
17
+ /** @internal History-on 时才创建的一项实际 placement 变化。 */
18
+ export interface PreparedPlacementChange {
19
+ readonly node: Node;
20
+ readonly beforeOwner: Node | null;
21
+ readonly beforeIndex: number;
22
+ }
23
+ /** @internal 按 parent 对象身份合并,并只保留最终非空变化。 */
24
+ export declare function prepareStructureBatch(effects: readonly StructureChange[]): PreparedStructureBatch;
25
+ /** @internal History-on 才把 affected-parent delta 收敛为实际 node placements。 */
26
+ export declare function preparePlacementChanges(changes: readonly PreparedStructureChange[]): readonly PreparedPlacementChange[];
27
+ /** @internal 直接安装 affected raw links,并返回需要同步 lifecycle 的局部 roots。 */
28
+ export declare function installStructureLinks(batch: PreparedStructureBatch): readonly Node<import("..").NodeProperties, Node<any, any>>[];
29
+ /** @internal 所有 fields/raw links 安装及 History 记录后同步局部 lifecycle。 */
30
+ export declare function syncStructureLifecycles(nodes: readonly Node[]): void;
@@ -0,0 +1,252 @@
1
+ import { Bound, type BoundingBox, type PointView, type Rect } from "@fulate/share";
2
+ import { type GeometryPathPoint, type GeometryPathPosition, type GeometryQuery, type GeometrySnapshot } from "../geometry";
3
+ import type { Root } from "../root";
4
+ import type { Element } from "./element";
5
+ import { ChangeImpact } from "./properties";
6
+ /** 几何缓存内部借出的只读世界边界。 @internal */
7
+ export type GeometryBoundsView = Readonly<Rect & BoundingBox>;
8
+ /** 一次 Layer damage 收集共享的子树 visual bounds memo。 @internal */
9
+ export type DirtyBoundsMemo = Map<ElementTransform, Bound | null>;
10
+ /** Element 构造链传递的 companion Transform constructor。 */
11
+ export type ElementTransformConstructor<E extends Element = Element> = new (element: E) => ElementTransform<E>;
12
+ /** Element 继承构造链内部使用的 existential companion constructor。 */
13
+ export type ElementTransformClass = new (element: never) => ElementTransform;
14
+ /**
15
+ * 一个 Element 唯一的变换、几何、damage 与子树派生状态 owner。
16
+ *
17
+ * 具体 Element 类型通过 companion subclass 覆写 protected 几何、尺寸或矩阵方法。
18
+ */
19
+ export declare class ElementTransform<E extends Element = Element> {
20
+ protected readonly element: E;
21
+ /** 布局解析得到的 x 位移;只供采用 resolved frame 的元素读取。 @internal */
22
+ resolvedLeft: number | undefined;
23
+ /** 布局解析得到的 y 位移;只供采用 resolved frame 的元素读取。 @internal */
24
+ resolvedTop: number | undefined;
25
+ /** 布局解析得到的宽度;作者宽度优先。 @internal */
26
+ resolvedWidth: number | undefined;
27
+ /** 布局解析得到的高度;作者高度优先。 @internal */
28
+ resolvedHeight: number | undefined;
29
+ /** 当前 owner 是否需要提交尺寸、matrix 和空间索引。 @internal */
30
+ needsCommit: boolean;
31
+ /** descendant 是否仍有待提交变换。 @internal */
32
+ hasDirtyDescendant: boolean;
33
+ /** 当前 transform 提交是否正在解析 fitWidth/fitHeight。 */
34
+ private resolvingFitSize;
35
+ /** 本轮是否只失效 hit bounds、仍保留旧 visual 几何。 */
36
+ private hitOnlyInvalidation;
37
+ /** 自身 reference 或 child world space 是否要求 descendants 重算布局。 */
38
+ private childLayoutDirty;
39
+ /** 当前最后一次提交的 own world matrix。 */
40
+ private worldMatrix;
41
+ /** worldMatrix 的惰性逆矩阵。 */
42
+ private inverseWorldMatrix;
43
+ /** 提供给 children 的 world 坐标空间逆矩阵。 */
44
+ private inverseChildWorldMatrix;
45
+ /** local 命中 AABB;`undefined` 表示尚未计算。 */
46
+ private localHitBounds;
47
+ /** local 绘制 AABB;`undefined` 表示尚未计算。 */
48
+ private localVisualBounds;
49
+ /** 当前 canonical local geometry 快照。 */
50
+ private geometrySnapshot;
51
+ /** 下一份 snapshot 使用的 element-local revision。 */
52
+ private geometryRevision;
53
+ /** 复用 geometrySnapshot 的定位和包含查询。 */
54
+ private geometryQuery;
55
+ /** local 绘制轮廓点缓存。 */
56
+ private visualOutline;
57
+ /** visualOutline 变换后的 world 点缓存。 */
58
+ private worldVisualPoints;
59
+ /** localHitBounds 变换后的 world AABB。 */
60
+ private worldHitBounds;
61
+ /** localVisualBounds 变换后的 world AABB。 */
62
+ private worldVisualBounds;
63
+ /** 属性失效前最后一次提交的 world visual bounds。 */
64
+ private previousVisualBounds;
65
+ /** 稳定状态下缓存的当前子树 world render coverage。 */
66
+ private currentRenderCoverageBounds;
67
+ /** 当前 content subtree 在直接 parent child reference 中的只读 AABB。 */
68
+ private contentBoundsInParent;
69
+ /** 只在真实 dependent 存在时创建的内部 transform commit observers。 */
70
+ private transformCommitObservers?;
71
+ /**
72
+ * 创建指定 Element 的唯一 companion runtime。
73
+ * @param element 拥有此 transform 的 Element。
74
+ */
75
+ constructor(element: E);
76
+ /** Element 进入 active 上下文时要求重新提交自身和空间项。 @internal */
77
+ activate(): void;
78
+ /** raw parent link 改变后只标记本地 world commit;publication 在结构阶段统一执行。 @internal */
79
+ markParentChanged(): void;
80
+ /** children hook 的 companion Transform 扩展入口。 @internal */
81
+ runChildrenChanged(): void;
82
+ /** children raw links 已完整安装后的 dirty publication。 @internal */
83
+ publishChildrenDirty(): void;
84
+ /** 失效 visibility 影响的 content/render views 与 ancestor dirty path。 @internal */
85
+ markVisibilityDirty(): void;
86
+ /** children 变化时的 Transform 扩展点。 */
87
+ protected onChildrenChanged(): void;
88
+ /** descendant 变脏时的 Transform 扩展点。 */
89
+ protected onDescendantDirty(_child: ElementTransform, _affectsContentBounds: boolean): void;
90
+ /** 当前 branch 是否贡献到 parent/ancestor content bounds。 */
91
+ protected contributesToAncestorContentBounds(): boolean;
92
+ /** @internal dirty propagation 与 content query 共用的 branch role。 */
93
+ affectsAncestorContentBounds(): boolean;
94
+ /** 首次进入 dirty-descendant 状态并登记到唯一 RootFrameRuntime。 */
95
+ private enterDirtyDescendantState;
96
+ /** 清除当前 transform 的 dirty-descendant 标记。 @internal */
97
+ clearDirtyDescendantState(root: Root, includeDetached?: boolean): void;
98
+ /** 失效当前 owner 和 Layer 以内 ancestors 的 render coverage/dirty path。 */
99
+ private markDirtyAncestors;
100
+ /** @internal 失效当前 transform 及 Layer 以内 ancestors 的 render coverage。 */
101
+ invalidateRenderCoverageBounds(): void;
102
+ /** 构建 transform reference bounds;子类可覆盖。 */
103
+ protected buildLayoutReferenceBounds(): Readonly<Rect> | null;
104
+ /** 使用本次提交的 reference bounds 构建 canonical rectangle snapshot。 */
105
+ protected buildGeometrySnapshot(revision: number, layoutReferenceBounds?: Readonly<Rect>): GeometrySnapshot;
106
+ /** 构建命中候选使用的 local AABB;默认复用 reference bounds。 */
107
+ protected buildLocalHitBounds(snapshot: GeometrySnapshot): Readonly<Rect> | null;
108
+ /** 在 AABB 粗筛后执行精确 local 命中判断。 */
109
+ protected containsLocalHitPoint(point: PointView, query: GeometryQuery): boolean;
110
+ /** 构建用于精确世界投影的 local 绘制轮廓。 */
111
+ protected buildVisualOutline(snapshot: GeometrySnapshot): readonly PointView[];
112
+ /** 构建权威 local 绘制边界。 */
113
+ protected buildVisualBounds(snapshot: GeometrySnapshot): Readonly<Rect> | null;
114
+ /** 覆盖后可直接提供完整 world 矩阵;返回 `null` 使用标量变换。 */
115
+ protected buildWorldMatrix(): DOMMatrix | null;
116
+ /** 返回标量 world matrix 计算使用的 transform reference bounds。 */
117
+ protected getWorldMatrixReferenceBounds(): Readonly<Rect> | null;
118
+ /** world matrix 是否参与当前元素 local geometry 的解析。 */
119
+ protected worldMatrixAffectsLocalGeometry(): boolean;
120
+ /** 返回当前节点提供给 children 的 world 坐标空间。 */
121
+ protected getChildWorldMatrixView(): DOMMatrixReadOnly;
122
+ /** 按属性影响范围失效对应的几何缓存。 */
123
+ private invalidateCache;
124
+ /** 借用 canonical snapshot 的 transform reference bounds。 @internal */
125
+ getLayoutReferenceBoundsView(): Readonly<Rect>;
126
+ /** 当前 canonical snapshot 是否包含 resolved vertex。 @internal */
127
+ hasGeometry(): boolean;
128
+ /** 惰性构建 local 命中 AABB;没有专用 hook 时复用逻辑边界。 */
129
+ private getLocalHitBounds;
130
+ /** 返回当前 local 几何快照。 */
131
+ getGeometrySnapshot(): GeometrySnapshot;
132
+ /** @internal Current local-geometry identity for owner-local derived views. */
133
+ getLocalGeometryRevision(): number;
134
+ /** 返回复用当前快照的几何查询对象。 */
135
+ getGeometryQuery(): GeometryQuery;
136
+ /** 立即提交自身 world 矩阵并返回副本。 */
137
+ updateWorldMatrix(): DOMMatrix;
138
+ /** 清除 world 投影;world-dependent local geometry 只在矩阵实际变化时失效。 */
139
+ private finishWorldMatrixCommit;
140
+ /** 以给定 parent reference 组合当前 authored scalar matrix。 */
141
+ protected writeScalarMatrix(matrix: DOMMatrix, parentMatrix?: DOMMatrixReadOnly): DOMMatrix;
142
+ /** 提交作者 world matrix 并清除依赖它的投影。 */
143
+ private commitWorldMatrix;
144
+ /** 返回已提交的 world 矩阵副本,不包含 Viewport 和 DPR。 */
145
+ getWorldMatrix(): DOMMatrix;
146
+ /** 借用已提交矩阵;调用方不得修改或保留。 @internal */
147
+ getWorldMatrixView(): DOMMatrixReadOnly;
148
+ /** 借用已提交 child 坐标空间的逆矩阵。 @internal */
149
+ getChildWorldInverseMatrixView(): DOMMatrixReadOnly;
150
+ /** 返回已解析尺寸中心对应的 world 坐标。 */
151
+ getWorldCenter(): PointView;
152
+ /** 将 local 点转换为 world 点。 */
153
+ toWorld(point: PointView): PointView;
154
+ /** 将 world 点转换为 local 点;矩阵不可逆时返回 `undefined`。 */
155
+ toLocal(point: PointView): PointView | undefined;
156
+ /** 求值 snapshot-local path position,并转换 point/tangent/normal 到 world。 */
157
+ getWorldPathPoint(position: GeometryPathPosition): GeometryPathPoint | undefined;
158
+ /** 判断 world 点是否位于当前闭合几何内或边界上。 */
159
+ containsWorldPoint(point: PointView): boolean;
160
+ /** 借用已提交的 world 命中 AABB。 @internal */
161
+ getWorldHitBoundsView(): GeometryBoundsView;
162
+ /** 返回 world 绘制轮廓的独立点数组。 */
163
+ getWorldVisualPoints(): PointView[];
164
+ /** 返回 world 绘制 AABB 的独立副本。 */
165
+ getWorldVisualBounds(): Bound;
166
+ /** 借用当前 snapshot 的 local 绘制 AABB。 @internal */
167
+ getLocalVisualBoundsView(): Readonly<Rect> | null;
168
+ /** 返回自身贡献给 ancestor content query 的 local bounds。 */
169
+ protected getOwnContentBoundsView(): Readonly<Rect> | null;
170
+ /** 借用已提交的 world 绘制 AABB。 @internal */
171
+ getWorldVisualBoundsView(): GeometryBoundsView;
172
+ /** 构建当前 owner 的完整 world 绘制 AABB。 */
173
+ protected buildWorldVisualBounds(): Bound;
174
+ /** 将 local AABB 四角投影为当前 own world matrix 下的 world AABB。 */
175
+ private toWorldBounds;
176
+ /** 将 local AABB 四角投影到指定 reference matrix。 */
177
+ protected toBounds(matrix: DOMMatrixReadOnly, bounds: Readonly<Rect> | null): Bound;
178
+ /** 惰性构建当前快照对应的 local 绘制轮廓。 */
179
+ private getVisualOutline;
180
+ /** 借用已提交的 world 绘制轮廓。 @internal */
181
+ getWorldVisualPointsView(): readonly PointView[];
182
+ /** 在清理 visual 缓存前保存最后一次提交的 world 绘制范围。 */
183
+ private captureCurrentVisualBounds;
184
+ /** 将旧 visual bounds交给当前 transform 和所属 Layer 的 damage 跟踪。 */
185
+ private captureVisualBounds;
186
+ /** 返回累积旧 visual bounds 的独立副本。 @internal */
187
+ getPreviousVisualBounds(): Bound | null;
188
+ /** 是否保存了失效前的 visual bounds。 @internal */
189
+ hasPreviousVisualBounds(): boolean;
190
+ /** 清除失效前的 visual bounds。 @internal */
191
+ clearPreviousVisualBounds(): void;
192
+ /** @internal 按影响范围失效几何并安排 Layer 提交。 */
193
+ invalidate(impact: ChangeImpact, previousBounds?: Readonly<BoundingBox> | null): void;
194
+ /** 标记 local 几何需要重新构建。 */
195
+ markGeometryNeedsLayout(notifyScene?: boolean): void;
196
+ /** 安排当前元素所属 Layer 重绘。 @internal */
197
+ markPaintDirty(): void;
198
+ /** 标记 world 变换失效并安排 Layer 提交。 */
199
+ markNeedsLayout(notifyScene?: boolean): void;
200
+ /** @internal 订阅实际 world transform commit;返回同一 observer 的注销函数。 */
201
+ observeTransformCommit(observer: (transform: ElementTransform) => void): () => void;
202
+ /** 安装一次最终 resolved frame delta,并只发布一次合并后的几何影响。 */
203
+ private installResolvedFrame;
204
+ /** @internal 提交由布局解析得到的尺寸。 */
205
+ commitResolvedSize(width: number | undefined, height: number | undefined): boolean;
206
+ /** @internal 提交一个布局 owner 最终解析出的完整 frame。 */
207
+ commitResolvedFrame(frame: Readonly<Rect> | null): boolean;
208
+ /** 根据 parent 尺寸解析 fitWidth 和 fitHeight。 */
209
+ protected resolveFitSize(): void;
210
+ /** 立即提交当前节点所在的最高脏变换链。 */
211
+ bubbleUpdateTransform(): void;
212
+ /** @internal 仅在祖先变换脏时同步提交当前 world 变换链。 */
213
+ updateWorldTransformChain(): void;
214
+ /** 找到当前节点上方、Layer 以内最高的脏 Transform。 */
215
+ private findHighestDirtyAncestor;
216
+ /** 提交自身尺寸、world matrix 和空间索引更新,不递归 children。 */
217
+ private commitOwnTransform;
218
+ /** @internal 立即提交当前脏子树的变换和几何。 */
219
+ updateTransform(parentLayoutDirty?: boolean): void;
220
+ /** 返回本次失效前后覆盖到的 world 脏区域。 */
221
+ getDirtyRect(): Bound;
222
+ /** @internal 复用当前 Layer damage 收集已经解析的子树范围。 */
223
+ getDirtyRect(memo: DirtyBoundsMemo): Bound | null;
224
+ /** 返回自身与可见 descendants 的已提交 world render coverage。 */
225
+ getRenderCoverageBounds(): Bound;
226
+ /** 返回排除 decoration boundary 后的 world content subtree bounds。 */
227
+ getContentBounds(): Bound;
228
+ /** 在指定 reference 中沿 canonical local matrices 解析 content subtree。 */
229
+ protected collectContentBoundsInReference(parentMatrix: DOMMatrixReadOnly, referenceWorldInverse: DOMMatrixReadOnly): Bound | null;
230
+ /** 返回当前 content subtree 在直接 parent child reference 中的 AABB。 */
231
+ getContentBoundsInParentView(): GeometryBoundsView | null;
232
+ /** 借用排除 decoration boundary 后的已提交 world content bounds。 */
233
+ getWorldContentBoundsView(): GeometryBoundsView | null;
234
+ /** 借用自身与可见 descendants 的已提交 world render coverage。 @internal */
235
+ getRenderCoverageBoundsView(): Readonly<BoundingBox & Rect> | null;
236
+ /** 合并子树每个节点提交前后的 visual bounds,形成 damage 区域。 */
237
+ private collectDirtySubtreeBounds;
238
+ /** 将当前 owner local child clip 转换成保守的 world AABB。 */
239
+ private getWorldChildClipBounds;
240
+ /** 借用精确命中前使用的 world AABB。 @internal */
241
+ getHitTestBounds(): Readonly<BoundingBox>;
242
+ /** 返回命中边界变换到浏览器 client 坐标后的旋转 AABB。 */
243
+ getBoundingClientRect(): Bound;
244
+ /** 判断 world 点是否精确命中当前元素。 */
245
+ hasPointHint(point: PointView): boolean;
246
+ /** 判断自身或可见 descendants 是否与当前 Viewport 相交。 */
247
+ hasInView(): boolean;
248
+ /** 清除依赖 world matrix 的逆矩阵和 world 投影缓存。 */
249
+ private clearWorldProjection;
250
+ /** Element 卸载时释放全部 transform-owned 派生状态。 */
251
+ dispose(): void;
252
+ }