@ogygia/rewrite

AllMajorMinorPatch Show pre-releases
0.14.0 minor

@ogygia/rewrite

Minor Changes

  • #1707 b20ae04 Thanks @PuruVJ! - - breaking: an app's own pass over the HTML ogygia sends is the new @ogygia/rewrite package. ogygia.handle({ transform }) now throws handle_transform_moved; list rewrite() (from @ogygia/rewrite/vite, no options) beside ogygia(), and put a rewrite() handle before ogygia.handle() in sequence(). ogygia/markup is removed, and scanRegions / liftRegions / restoreRegions leave ogygia/server. - @ogygia/rewrite: rewrite({ match, render }) renders only the outermost custom elements match picks (a tag prefix, a list of tags, or a test), in one render(elements, ctx) call per chunk of the page and per region answer, so a streamed page keeps streaming and its later chunks are rendered too. - @ogygia/rewrite: each element render gets has ogygia's marks numbered from 0, so a cache can key on its bytes; equal elements in one call are rendered once. - @ogygia/rewrite: ctx carries kind, csr, url, event and signal, an AbortSignal that fires when the request is cancelled. - @ogygia/rewrite: a render's sheets go out once per key per response, into the head while it is open and inline before the first element that needs them after. - @ogygia/rewrite: a failed batch is retried one element at a time; an element that still fails, drops ogygia's marks, or returns HTML that does not close what it opens goes out as ogygia rendered it, with a warning in every build (rewrite_element_failed, rewrite_marks_lost), never thrown. - @ogygia/rewrite: an element split across streamed chunks goes out unrendered, said in dev (rewrite_element_split). - @ogygia/rewrite: several rewrites in sequence() run in order on one marking of the HTML; one listed after ogygia.handle() throws rewrite_after_ogygia, and a rewrite without the plugin throws rewrite_plugin_missing. - @ogygia/rewrite: rewrite({ page }) rewrites the whole document (held until its last chunk) or region answer, says rewrite_page_failed when it throws (thrown in dev), and has .html(str) for a plain string. - @ogygia/rewrite: .check(html, { kind, csr }) runs the whole round trip on one piece of markup for a test, listing failures and, with a DOM, every restored element that differs from Svelte's. - @ogygia/rewrite: a page where nothing was restored ships no restorer, and each streamed chunk that restored something ends with one short restore call. - @ogygia/devtools: the profiler reads a page's regions itself and no longer depends on @ogygia/rewrite.

Patch Changes

  • #608 67127a4 Thanks @PuruVJ! - - @ogygia/core: the runtime no longer carries the restore support for an app's own HTML pass (the restore report, a web component's class tokens through hydration, the answer restore hooks); apps without @ogygia/rewrite boot about 0.15 to 0.2 kB (brotli) smaller. - @ogygia/rewrite: rewrite() ships that support to the browser itself; restore_markup_broken and restore_late are its message codes.
  • #855 db021f1 Thanks @PuruVJ! - @ogygia/rewrite: the restorer's attribute reset (og-r) never sets an on* or srcdoc attribute, or a javascript: / vbscript: URL (#851).
  • #1681 3398571 Thanks @PuruVJ! - A restored host's shadow root is now declarative, as a server-rendered <template shadowrootmode> root would be: a component whose constructor attaches its own root no longer throws on upgrade, and gets that root back emptied. A host not yet upgraded is replaced by an equal element during the restore, before anything hydrates.
  • #1693 29ac140 Thanks @PuruVJ! - A marked host that cannot have a shadow root no longer stops the restore: it is left as served with ogygia's marks taken off, said once per page and element name (restore_host_invalid), and every other host is still restored.
  • #1886 1b756bf Thanks @PuruVJ! - The restorer refuses a data: URL in an attribute reset (og-r), as it refuses javascript: and vbscript:, and reads each value's scheme the way a browser's URL parser does (the same check as core's html).
  • #1679 aa32050 Thanks @PuruVJ! - A restored host whose og-shadow names a sheet the page does not carry is no longer skipped silently: the page says restore_sheet_missing once per key, and the other sheets it names still apply.
  • #710 28f8504 Thanks @PuruVJ! - @ogygia/rewrite: the restorer for an app's server transform turns an <og-as> stand-in back only into a tag the server pass writes as one (a block, a list or table part, a link, a button, a form, an option), and never copies an on* attribute onto it. Any other <og-as> is left as it is.
  • #720 47d4d47 Thanks @PuruVJ! - The restorer reshape inlines into a document the app's transform reshaped is now written the same safe way as every other inline script (no text in it can end the script element early).
  • #1393 9872ace Thanks @PuruVJ! - The reversible transform's marking reads the page as the browser does: a quote inside an unquoted value or an attribute name no longer hides every custom element after it, a comment ends at --!> and <!--> too, and a custom element inside a <noscript> is left as the text it is.
  • #1832 b9edaf3 Thanks @PuruVJ! - A matched element whose start tag a chunk boundary cuts, after a chunk with no match, is now said as split (rewrite_element_split, in dev) like any element its chunk ends inside, instead of going out unrendered with nothing said.
  • #1830 abdfed1 Thanks @PuruVJ! - A matched element inside a declarative shadow root the page opened, in a later chunk of a streamed page, is now restored: that chunk's restore call enters every shadow root.
  • #1779 fa587dc Thanks @PuruVJ! - A stand-in tag whose attributes include a name only the HTML parser accepts (like =eq) is restored to its real tag, and the restore goes on to every stand-in and host after it instead of stopping with an error.

Updated dependencies: @ogygia/[email protected], @ogygia/[email protected], @ogygia/[email protected]