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
|
||||
}
|
||||
@@ -21,7 +21,9 @@ import {
|
||||
import {
|
||||
checkR3Golden,
|
||||
treeOf,
|
||||
withDeclaredHitboxes,
|
||||
withIdsScopedPerView,
|
||||
withIsolatedLayer,
|
||||
withTriggerNamesPerLanguage,
|
||||
type TreeNode,
|
||||
} from '../helpers/svgTree'
|
||||
@@ -82,9 +84,10 @@ describe.each(VIEWS)('the %s canvas', (viewId) => {
|
||||
it('builds the frozen tree with no state', () => {
|
||||
const build = buildViewSvg(sheet, viewId)
|
||||
if (!build.ok) throw new Error(`canvas ${viewId}: ${build.failure}`)
|
||||
// and the owner's decision 2026-10-29: the drawing's ids scoped to the view
|
||||
// and the owner's decision 2026-10-29: the drawing's ids scoped to the view; the brief
|
||||
// 2026-10-30: the composition root is the engine's, the hitboxes declared
|
||||
checkR3Golden(`canvas.${viewId}.json`, treeOf(build.svg), (frozen) =>
|
||||
withIdsScopedPerView(declared(frozen), viewId),
|
||||
withIsolatedLayer(withIdsScopedPerView(declared(frozen), viewId)),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -94,6 +97,13 @@ describe.each(VIEWS)('the %s canvas', (viewId) => {
|
||||
layers[name] = await mountedLayer(viewId, states)
|
||||
}
|
||||
expect(Object.keys(layers).length).toBeGreaterThan(8)
|
||||
checkR3Golden(`canvas.${viewId}.layers.json`, layers, declared)
|
||||
checkR3Golden(`canvas.${viewId}.layers.json`, layers, (frozen) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(declared(frozen) as Record<string, unknown>).map(([name, layer]) => [
|
||||
name,
|
||||
withDeclaredHitboxes(layer),
|
||||
]),
|
||||
),
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user