Skip to content

Fix Canvas renderer options, SVG loading, and pointer event semantics - #39

Merged
jonobr1 merged 2 commits into
mainfrom
codex/fix-open-bugs
Oct 10, 2026
Merged

jonobr1 merged 2 commits into
mainfrom
codex/fix-open-bugs

Conversation

@jonobr1

@jonobr1 jonobr1 commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Canvas aliases currently fail at construction, SVG loading ignores shallow and leaks lifecycle ownership, and pointer dispatch disagrees with Two.js coordinates and nested scene order. This change fixes all three open bug issues and documents the resulting behavior.

  • Normalize all six renderer spellings. Update width, height, and autostart in place; warn in development when type, fullscreen, ratio, overdraw, or smoothing changes without a key remount. Clean up fullscreen resize listeners and owned body styles. Apply SVG viewBox as an attribute.
  • Load URL SVGs with abortable fetch, validate inline documents, prevent stale results, implement shallow imports, and release owned imports without removing JSX children or borrowed effects. Preserve imported/JSX ordering across reorders and use current callbacks without reloading.
  • Use renderer world coordinates throughout, SVG screen transforms for viewport scaling, and upstream leaf traversal for complete scene order. Bubble through actual ancestry, exclude invisible/clipped/unpainted geometry, and respect masks. Add per-pointer capture that survives callback updates, deterministic hover transitions, and missed notifications only for complete empty primary presses.

Behavior changes: event.point now uses top-left renderer world coordinates; Group events target the actual leaf; onPointerMissed requires an empty primary down/up sequence. SVG shallow removes only the imported top-level group and its root transforms. Constructor options require a React key remount. Details and dragging examples are in the README.

Validation:

  • 242 tests passed across 21 files (45 more than baseline).
  • npm run lint: passed without warnings.
  • npx tsc -b, npm run build:lib, and npm run build:docs: passed. Docs build retains its large-chunk advisory.
  • Executed tests/browser/ in the in-app browser using real SVG, Canvas, and WebGL: all six renderer spellings passed CSS coordinate, masked-event, and shallow-import checks. Native dragging verified capture, movement, bubbling, and release outside each renderer.

Fixes #8
Fixes #32
Fixes #34

@jonobr1
jonobr1 requested a balanced review from Copilot October 10, 2026 00:34
@jonobr1
jonobr1 marked this pull request as ready for review October 10, 2026 00:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃煛 Changes recommended

Unpainted non-Path objects can intercept events, and imported SVG renderer resources are not fully released.

2 open findings
What changed in this PR

Fixes Canvas options, SVG loading lifecycle, and pointer-event semantics across renderers.

Changes:

  • Normalizes renderer aliases and manages mutable/immutable Canvas options.
  • Adds abortable SVG loading, shallow imports, ownership cleanup, and stable ordering.
  • Reworks coordinates, hit testing, bubbling, pointer capture, and regression coverage.
File Description
lib/鈥婸rovider.tsx Updates Canvas lifecycle and event dispatch.
lib/鈥婨vents.ts Implements coordinates, hit testing, and capture APIs.
lib/鈥婼VG.tsx Reworks SVG loading and ownership.
lib/鈥媢seTwoObject.ts Preserves registration across callback updates.
README.md Documents updated behavior.
tests/鈥媍anvasOptions.test.tsx Tests Canvas options.
tests/鈥媏ventSemantics.test.tsx Tests pointer semantics.
tests/鈥媏vents.test.tsx Updates event utility coverage.
tests/鈥媠vgLifecycle.test.tsx Tests SVG lifecycle behavior.
tests/鈥媌rowser/鈥媔ndex.html Adds browser harness UI.
tests/鈥媌rowser/鈥媟egressions.tsx Adds real-renderer regression checks.

馃 Review effort: Balanced


馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/Events.ts
Comment thread lib/SVG.tsx Outdated
@jonobr1
jonobr1 merged commit f07e185 into main Oct 10, 2026
2 checks passed
@jonobr1
jonobr1 deleted the codex/fix-open-bugs branch October 10, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants