fix(anatomy): V1-2.2 owner arbitrations on SVG references and bytes
Refuse local references to ids a drawing does not define, scope canvas ids per view, upload every drawing in one stored form checked by the verdict and the preview, keep strict numeric rgb() colours, and commit real Inkscape 1.4.3 exports with their generator.
This commit is contained in:
1 parent
17d919971e
commit
e823655f09
31 files changed
+1362
-110
No files matched your search
@@ -101,3 +101,28 @@ export function withTriggerNamesPerLanguage(tree: unknown, views: readonly ViewN
|
||||
visit(copy)
|
||||
return copy
|
||||
}
|
||||
|
||||
/**
|
||||
* Owner decision 2026-10-29 (V1-2.2): the canvas, inlined in the page, scopes the drawing's
|
||||
* ids and the references to them to its view (`fv.<view>.<id>`). Applied to a frozen tree (a
|
||||
* deep copy), written apart from the core's rewrite: every `id`, every `#id` href and every
|
||||
* plain `url(#` (the only spelling of the product drawing). Mirrors
|
||||
* `crates/core/tests/common/svg_tree.rs`.
|
||||
*/
|
||||
export function withIdsScopedPerView(tree: unknown, viewId: string): unknown {
|
||||
const copy = structuredClone(tree)
|
||||
const scope = `fv.${viewId}.`
|
||||
const visit = (node: unknown): void => {
|
||||
if (typeof node !== 'object' || node === null) return
|
||||
const n = node as { attrs?: Record<string, string>; children?: unknown[] }
|
||||
for (const [name, value] of Object.entries(n.attrs ?? {})) {
|
||||
if (name === 'id') n.attrs![name] = `${scope}${value}`
|
||||
else if ((name === 'href' || name === 'xlink:href') && value.startsWith('#')) {
|
||||
n.attrs![name] = `#${scope}${value.slice(1)}`
|
||||
} else n.attrs![name] = value.replaceAll('url(#', `url(#${scope}`)
|
||||
}
|
||||
n.children?.forEach(visit)
|
||||
}
|
||||
visit(copy)
|
||||
return copy
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
import {
|
||||
checkR3Golden,
|
||||
treeOf,
|
||||
withIdsScopedPerView,
|
||||
withTriggerNamesPerLanguage,
|
||||
type TreeNode,
|
||||
} from '../helpers/svgTree'
|
||||
@@ -81,7 +82,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}`)
|
||||
checkR3Golden(`canvas.${viewId}.json`, treeOf(build.svg), declared)
|
||||
// and the owner's decision 2026-10-29: the drawing's ids scoped to the view
|
||||
checkR3Golden(`canvas.${viewId}.json`, treeOf(build.svg), (frozen) =>
|
||||
withIdsScopedPerView(declared(frozen), viewId),
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the frozen layer for every state set of the reference reports', async () => {
|
||||
|
||||
Reference in new issue
Block a user