Repository navigation
Diagrams under a strict content policy, onLayout for exports, and multi-line sink reasons - #142
Merged
Merged
Conversation
…le-src refuses nothing The ink wrote each label's left, top and width as a style attribute in its HTML, which a policy without 'unsafe-inline' refuses: every label landed in the drawing's corner, on the page and in the viewer, with a console error each. inkHtml now writes no place, and placeLabels sets it through the CSSOM after the ink is written and after every measure (a label can move while the ink's string stays the same), in React and in the skill. The audit found the same fault in a text sequence's transcript, whose lines' indents are styles: React drew it as HTML, and the skill read it back and wrote it again as HTML. React now draws the transcript as the tree's elements (keyed apart from the art's HTML), the skill keeps its nodes and puts them back, and syncAttributes walks into the transcript, so indents a page's own markup carried (server HTML, a composed page) are set again through the CSSOM. A test in content-policy.test.mjs serves two figures under style-src 'self' and under 'unsafe-inline' and compares each label's box on the page and in the viewer, and the transcript's indents, with nothing refused. Written, not run (DECISIONS 359). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…herwise fails with an error that says so The PNG was drawn through a data: image, which `img-src 'self'` refuses, so under CIMIP's policy the image never decoded. diagramToPng now tries createImageBitmap from the SVG as a Blob first (no URL, so no img-src, where the browser decodes SVG that way), then an image from a blob: URL, then from a data: URL. Where the policy allows none, it rejects with an error naming `img-src 'self' blob:` (or data:) and makes no file. The JSDoc, the skill's usage text and foundations' export line say the app must allow blob: or data:. A test in content-policy.test.mjs exports under img-src 'self', 'self' blob: and 'self' data:. Written, not run (DECISIONS 359). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… for its draw.io, Visio and Lucid files
exportMeasuredDiagram takes a figure's measured geometry, but only diagram-core's internals could read it, so an app's files used the headless
approximation. Each diagram component now takes `onLayout(laid)`, called each time the figure is laid out anew and not again for the same
layout: `laid.spec` (under layout="auto", with the placement it is drawn on), `laid.geo`, `laid.layout` ("drawn" or "stacked") and
`laid.figure`, so `exportMeasuredDiagram(laid.spec, laid.geo, "drawio", { extras: readMeasuredExtras(laid.figure) })` writes what the reader
sees. Our own types only (DiagramLayoutInfo, exported); the callback is held in a ref, so a new one each render, or one that sets state, never
lays the figure out again. It changes no pixel. The viewer's figure does not call it.
A test in diagram-interop-browser.test.mjs exports two figures (one automatic) from onLayout, checks it is not called in a loop, and that a
resize calls it again. Written, not run (DECISIONS 359).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check-sinks read only the one `//` comment that starts `sink:`, so a reason continued on a second `//` line failed as one with no test. A `sink:` line comment now takes each `//` comment on the lines straight after it, each on a line of its own, until a line that is not one or another `sink:` (as CIMIP's port does). Block comments were always read whole. Planted cases in tools/html-skill/test/sinks.test.mjs: a reason over three lines and an indented one pass; a line of code or a second reason ends it. Written, not run as a test (DECISIONS 359); the lint's sink step passes on the repo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ble regenerated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four diagram faults CIMIP's lead found while adopting main, relayed by the Basalt gaps thread. All four are engineering inside decided designs: they restore documented behaviour, or add a prop that changes no pixel.
style-src: line labels (d058e618). Labels were positioned with astyleattribute inside HTML Basalt writes; understyle-src 'self'each was refused and fell into the figure's corner, on the page and in the viewer.placeLabels) after the ink is written and after every measure, in React and the skill.data:card mark is refused underimg-src 'self'.img-src: PNG export (d4b17322).diagramToPngtriescreateImageBitmapon the SVG as a Blob, then ablob:image, then adata:image. When all three are refused, it rejects with an error naming theimg-srcit needs, and makes no file. The JSDoc, the skill's usage and foundations' export line say so. An app underimg-src 'self'most likely needs to allowblob:.onLayout(6e3f31d0). Every diagram component takesonLayout(laid)with the layout on screen (DiagramLayoutInfo, our own type), so an app's draw.io, Visio and Lucid files use the real geometry:exportMeasuredDiagram(laid.spec, laid.geo, format, { extras: readMeasuredExtras(laid.figure) }). It fires only when the layout changes. No pixel changes; about +0.3% a diagram component.check-sinks.mjs(b839fd31). A// sink:reason now continues onto the//lines straight after it, stopping at code or anothersink:.Not here:
Checks: lint (5 of 5 steps), both typechecks,
npm run buildandnpm run sizespass on the tree merged with main. No tests were run (DECISIONS 330, 359). New cases are written, not run, incontent-policy.test.mjs,diagram-interop-browser.test.mjsandsinks.test.mjs. No reviewer seat looked at this PR.🤖 Generated with Claude Code