Skip to content

Add JSONHTML visual difference page - #97

Merged
ThorFuchs merged 1 commit into
mainfrom
feature/1.10-visual-diff
Nov 14, 2026
Merged

ThorFuchs merged 1 commit into
mainfrom
feature/1.10-visual-diff

Conversation

@ThorFuchs

Copy link
Copy Markdown
Owner

Stacked on #96 (base feature/1.10-patch-diff); merge #96 first, then retarget this PR to main.

Summary

JSONHTMLRenderer.renderDifference(from:to:) and renderDifferenceWithReport render two exact values as one static, script-free combined tree:

  • Markers: added (+, green), removed (−, red, struck through) and changed (old → new) values. Each marker carries visually hidden text, so the meaning does not depend on color.
  • Unchanged values: equal values (exact model equality) stay visible but collapsed in <details>; equal element runs collapse to "Elements #a–#b unchanged".
  • Navigation: a summary of counts, a change list linked by JSON Pointer, and a CSS-only "Show changes only" toggle.
  • Downloads: native downloads of the RFC 6902 patch (application/json-patch+json), the source and the target (exact lexemes).
  • Security: CSP script-src 'none'. The shared and difference stylesheets are authorized by SHA-256 hash, and all input is escaped.
  • Accounting: one cumulative JSONWorkMeter with the configured JSONHTMLLimits; outline entries count one per listed change. Cancellation is checked inside the walk.

Architecture

The comparison moves into a package JSONDifferenceWalker in JSON. JSONPatch.difference becomes a facade over it, so JSONPatch and JSONHTML share one comparison, and JSONHTML still depends on JSON only. Within an array the patch order is now: paired changes, then removals from the highest index down, then additions. One expectation in DifferenceTests changed for this; the semantics and round-trip behavior are unchanged.

Docs and tooling

  • New DocC article DifferenceRendering.md, linked from the JSONHTML landing page.
  • CHANGELOG entry under 1.10.0.
  • Scripts/verify_html_assets.py now also verifies Assets/Difference.css against its Swift mirror and hash (count 2 → 3, ci.py updated).
  • JSONHTMLTests discovery counts +6 (root/portable/WASI).
  • CLI identity regenerated.

Qualification (local)

Toolchain: Apple Swift 6.4.2 (swiftlang-6.4.2.1.9), macOS 27.3. Source: 7e323cf on 24f6ada.

  • python3 Scripts/ci.py --lane docs: exit 0, 4/4 commands passed
  • python3 Scripts/ci.py --lane native: exit 0, 62/62 commands passed, 0 failed

I also rendered a sample page and checked it in a browser, including the changes-only toggle.

No tag, release or publication follows from this PR.

🤖 Generated with Claude Code

Base automatically changed from feature/1.10-patch-diff to main November 14, 2026 15:16
renderDifference(from:to:) renders two exact values as one static,
script-free combined tree with added/removed/changed markers, a linked
change list, a CSS-only changes-only toggle and native downloads of the
RFC 6902 patch, source and target. The comparison moves into a package
walker in JSON so JSONPatch.difference and JSONHTML share it and JSONHTML
keeps depending on JSON only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ThorFuchs
ThorFuchs force-pushed the feature/1.10-visual-diff branch from 7e323cf to de2881a Compare November 14, 2026 15:17
@ThorFuchs
ThorFuchs merged commit 97bfd7d into main Nov 14, 2026
21 checks passed
@ThorFuchs
ThorFuchs deleted the feature/1.10-visual-diff branch November 14, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant