Changelog

@ogygia/rewrite

Every release of @ogygia/rewrite, newest first.

Latest
0.17.1
Versions
11
  1. 0.17.1 patch

    Dependency updates only @ogygia/rewrite

  2. 0.17.0 minor

    Minor Changes

    • A restored element's plan can say og-handoff="replace": the server's tree in its shadow root goes the first time the upgraded component writes into the root (for a library that renders into the root it finds, next to what is there, which showed it twice), in a region answer or an incoming page too. What is added to the root while its own ogygia:restored event is dispatched is the listener's, never the component's write, even when the listener defines the element or makes it render: a listener renders after the event (queueMicrotask) to hand off. og-handoff="adopt", the default, keeps today's behavior; another value, an empty one too, is adopt, said once per element name and value as restore_handoff_unknown.
    • Each restored element hears ogygia:restored (bubbles, composed, detail: { host, root }) once the whole restore is done: its root holds the server's tree and sheets, its light DOM and attributes are Svelte's again. A region answer's or an incoming page's elements hear it once they are in the page.
    • og-shadow can name a 'page' sheet as well as a 'shadow' one, so one sheet serves the document and shadow roots alike.
    • A result's sheet can carry attributes on its tag (attrs: { media, … }, values escaped; a handler, an ogygia mark, is, a name that starts with xmlns or shadowroot fails the element), and a shadow root that adopts the sheet keeps its media.

    Patch Changes

    • A page with an element whose id (or a form's, img's, embed's or object's name) is one of the data ogygia keeps on the window, such as <div id="__og_sheets"> or <div id="__og_rendered">, no longer stops the restorer, an answer's restore, the morph or the devtools' read of the restore log with a TypeError, in browsers and in DOMs that make such an element the window's own property (happy-dom): that data is read only as the window's own property, and only when it has its expected shape.
    • A page with an element whose id (or a form's, img's, embed's or object's name) is one of ogygia's page hooks, such as <div id="__og_carry">, no longer breaks the morph, a navigation, an answer's parse or the restorer with TypeError: … is not a function: a hook is called only when it is a function.
    • .check() restores into a document of its own and leaves nothing in the page running the test: no sheets moved into its head, no restore warnings logged for it to print later.
    • .check() no longer rejects under jsdom 27 to 30 when the markup has a restored host (Cannot read properties of null (reading 'customElements')), for a region and for a document; the restorer on a page restores in those test environments too.
    • A restored element in a region answer or an incoming page gets a declarative shadow root on the copy the runtime inserts, so a component that always calls attachShadow() gets the root back emptied instead of throwing NotSupportedError.
    • The README's samples use rewrite() from @ogygia/rewrite/vite and rewrite({ match, render }) / rewrite({ page }) from @ogygia/rewrite, the names the package exports, in place of reshape and ReshapeTransform, which it never did.
    • The README shows the real API (rewrite() from @ogygia/rewrite and @ogygia/rewrite/vite, .check(), a rewrite for some requests only) instead of the removed reshape() and helpers.
    • An incoming page's restored elements get their sheets, in restore order, even when a region answer goes into the page while the navigation is still in flight.

    Dependencies: @ogygia/compiler@0.17.0, @ogygia/core@0.17.0, @ogygia/machine@0.17.0

  3. 0.16.5 patch

    Dependency updates only @ogygia/rewrite

  4. 0.16.4 patch

    Dependency updates only @ogygia/rewrite

  5. 0.16.3 patch

    Dependency updates only @ogygia/rewrite

  6. 0.16.2 patch

    Dependency updates only @ogygia/rewrite

  7. 0.16.1 patch

    Dependency updates only @ogygia/rewrite

  8. 0.16.0 minor

    Dependency updates only @ogygia/rewrite

  9. 0.15.1 patch

    Dependency updates only @ogygia/rewrite

  10. 0.15.0 minor

    Dependency updates only @ogygia/rewrite

  11. 0.14.0 minor

    Minor Changes

    • - 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

    • - @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.
    • @ogygia/rewrite: the restorer's attribute reset (og-r) never sets an on* or srcdoc attribute, or a javascript: / vbscript: URL (#851).
    • 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.
    • 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.
    • 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).
    • 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.
    • @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.
    • 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).
    • 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.
    • 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.
    • 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.
    • 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.

    Dependencies: @ogygia/core@0.14.0, @ogygia/compiler@0.14.0, @ogygia/machine@0.14.0