fix(anatomy): V1-2.2 marker layer and halo outside the drawing's group
Owner-approved lot B (brief 2026-11-01). The composition root is the engine's (namespaces and frame); the drawing's root becomes a group and the marker layer and halo are its siblings, so no root property reaches a marker. Point hitboxes declare stroke none and visibleFill. Census over the reader's whole allowlist; R3 references compared under the declared transform; click proofs in three engines.
This commit is contained in:
1 parent
f1bb19b30b
commit
4f52f5e1c4
23 files changed
+933
-112
No files matched your search
@@ -126,3 +126,49 @@ export function withIdsScopedPerView(tree: unknown, viewId: string): unknown {
|
||||
visit(copy)
|
||||
return copy
|
||||
}
|
||||
|
||||
const HITBOX_DECLARED = { stroke: 'none', 'pointer-events': 'visibleFill' }
|
||||
|
||||
/** A point hitbox of the R3 layer: a circle capturing on `all` with no stroke of its own. */
|
||||
function isR3Hitbox(node: unknown): node is { name: string; attrs: Record<string, string> } {
|
||||
const n = node as { name?: string; attrs?: Record<string, string> }
|
||||
return n.name === 'circle' && n.attrs?.['pointer-events'] === 'all' && !('stroke' in n.attrs)
|
||||
}
|
||||
|
||||
/**
|
||||
* Owner brief 2026-10-30 (V1-2.2, three MEDIUM): each point hitbox the composers draw declares
|
||||
* `stroke="none"` and `pointer-events="visibleFill"`. Applied to a frozen layer (a deep copy).
|
||||
* Mirrors `crates/core/tests/common/svg_tree.rs`.
|
||||
*/
|
||||
export function withDeclaredHitboxes(layer: unknown): unknown {
|
||||
const copy = structuredClone(layer) as { children?: unknown[] }
|
||||
for (const child of copy.children ?? []) {
|
||||
if (isR3Hitbox(child)) Object.assign(child.attrs, HITBOX_DECLARED)
|
||||
}
|
||||
return copy
|
||||
}
|
||||
|
||||
/**
|
||||
* Owner brief 2026-10-30 (V1-2.2, three MEDIUM): the composition root is the engine's. Applied
|
||||
* to a frozen canvas tree (a deep copy): the root keeps its namespaces and `viewBox`; its other
|
||||
* attributes and every child before the layer go into a `<g>` of the drawing; the layer's
|
||||
* hitboxes are declared (`withDeclaredHitboxes`). Mirrors `crates/core/tests/common/svg_tree.rs`.
|
||||
*/
|
||||
export function withIsolatedLayer(tree: unknown): unknown {
|
||||
const root = structuredClone(tree) as {
|
||||
ns: string
|
||||
attrs: Record<string, string>
|
||||
children: unknown[]
|
||||
}
|
||||
const layer = root.children.pop()
|
||||
const kept: Record<string, string> = {}
|
||||
const moved: Record<string, string> = {}
|
||||
for (const [name, value] of Object.entries(root.attrs)) {
|
||||
if (name === 'xmlns' || name === 'xmlns:xlink' || name === 'viewBox') kept[name] = value
|
||||
else moved[name] = value
|
||||
}
|
||||
const group = { ns: root.ns, name: 'g', attrs: moved, children: root.children }
|
||||
root.attrs = kept
|
||||
root.children = [group, withDeclaredHitboxes(layer)]
|
||||
return root
|
||||
}
|
||||
Reference in new issue
Block a user