Skip to content

JSON fold gutter and Generate types; Diff transforms in a worker - #25

Merged
fadeltd merged 6 commits into
mainfrom
feat/follow-ups
Oct 30, 2026
Merged

fadeltd merged 6 commits into
mainfrom
feat/follow-ups

Conversation

@fadeltd

@fadeltd fadeltd commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Added

  • JSON Formatter: foldable output with line numbers, Fold all and Unfold all
  • JSON Formatter: Generate types sends the output to JSON to Types

Changed

  • Diff Checker: sorted-lines and key-sorted JSON views are built in a worker, with Cancel
  • Base64, URL Encode / Decode and String Escaper stop soft-wrapping very long lines
  • The CI size budget covers all first-load JavaScript

Fixed

  • Diff Checker: a share link pasted into an open tab loads without a reload
  • Diff Checker: a lone \r counts as a line break in the size check

Moves the editor's base theme out of the Diff route into src/lib/codemirror so the JSON tool can use it, and pins @codemirror/lang-json 6.0.2 and @codemirror/language 6.12.4 (already in the lockfile) for the JSON output's fold gutter.
The old check gzipped only index-*.js, so the registry chunk index.html modulepreloads (~13.8 kB gzip) was never measured. The step now sums every script dist/index.html loads (entry, modulepreloads, registerSW.js): 98,355 B today against a 107,520 B (105 KiB) budget, the same headroom as before.
…nd String Escaper

YAML / JSON / TOML drops its private copy of the issue card for components/ui/IssueCard, whose column is now nullable to fit the YAML/TOML engine's messages.

Base64, URL and String Escaper turn soft-wrap off on input and output once a line passes 100k characters (hasLongLine from core /text), as JSON and Text to Binary / Hex already do, so a multi-MB single line stays editable.

Trims the JSON to Types SEO paragraph from 141 to 119 words.
…ine breaks

A #d= share link pasted into an already-open Diff tab now loads without a reload: the tool listens for hashchange, as List does, decodes the fragment, clears it with history.replaceState and ignores a fragment it is already decoding or that was replaced meanwhile.

The sorted-lines and key-sorted JSON views are built in a worker (transform.worker.ts) driven by useWorkerJob, so toggling them on a large input no longer freezes the page. The worker is spawned only while a transform is on (TransformRunner is mounted only then) and is killed by Show original. While a run is pending the panes keep the previous view of the same transform, or show a busy message, never the raw text; Copy patch is disabled until the view matches the text; after 2 s a Cancel button appears. The size verdict is computed on the transformed text in the worker, before it reaches CodeMirror. The JSON parser and the line sort leave the diff route chunk.

longestLineOf, and so assessSize, now ends a line at \r\n, \n or a lone \r, matching CodeMirror's /\r\n?|\n/ split, so a large classic-Mac file is no longer refused as one long line. It stays two indexOf cursors, linear. Unit and property tests in the package, and a parity test against CodeMirror's own line splitting.
Formatted output (format mode, text view, ok size tier, md and up) now renders in a read-only CodeMirror view with lang-json, line numbers and a chevron fold gutter. It is a lazily loaded component (FoldableOutput), so CodeMirror stays out of the entry and the JSON route chunk; the textarea output shows while it loads. Text changes are applied as one minimal replace transaction, so folds and scroll outside the edit survive typing. Fold all folds every object and array below the root; Unfold all uses unfoldAll. No syntax colours.

The large tier, escape/unescape, the tree view, errors, output over the 2 MB inline limit and viewports below md keep the plain textarea. Below md the Tree view, with 44px rows, is the way to fold.

Generate types hands the output (filtered, expanded and sorted as shown) to JSON to Types through handOff and navigates there, with a visible message if the write fails. NDJSON input gets the same button in its banner and sends the records as they are, since JSON to Types reads each line as a sample. Output past the inline limit is sent minified.

The private IssueCard is replaced by the shared one from components/ui. useNarrow moves out of TreeView into narrow.ts so both components share it.
@fadeltd fadeltd self-assigned this Oct 30, 2026
@fadeltd
fadeltd merged commit 1b8707f into main Oct 30, 2026
1 check passed
@fadeltd
fadeltd deleted the feat/follow-ups branch October 30, 2026 02:50
@fadeltd fadeltd changed the title Follow-ups: JSON fold gutter and Generate types, Diff transforms in a worker, first-load JS budget JSON fold gutter and Generate types; Diff transforms in a worker Oct 30, 2026
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