Changelog

@ogygia/image

Every release of @ogygia/image, newest first.

Latest
0.17.1
Versions
8
  1. 0.17.1 patch

    Dependency updates only @ogygia/image

  2. 0.17.0 minor

    Dependency updates only @ogygia/image

  3. 0.16.5 patch

    Dependency updates only @ogygia/image

  4. 0.16.4 patch

    Dependency updates only @ogygia/image

  5. 0.16.3 patch

    Patch Changes

    • A build, a dev server or Kit's prerender notes prerendered images in a file named by an inherited __OGYGIA_IMAGE_BUILD only when it is in a run folder right under a runs folder the image code owns; any other is refused with a warning (image_run_refused), nothing is written or made there, and the build notes in a run of its own (a prerender handed it names its images by the endpoint's URLs). A separate process a build or dev server starts in the app (a test runner's fork, a script) now uses the app's own image cache store it inherits, found where the working folder keeps its cache, instead of warning image_folder_refused and making its images again in a temporary store.

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

  6. 0.16.2 patch

    Patch Changes

    • On SvelteKit 3, a builder asked for an app build again after one that failed its prerender no longer tries to make the images the failed prerender named, so a page mended in between builds.
    • On SvelteKit 3, a watch rebuild after a first build that failed to compile no longer publishes pages whose image URLs hold the build's mark host: a page that names a file no build made stops the rebuild with image_watch_rebuild.
    • On SvelteKit 3, a watch rebuild after a first build that failed its prerender no longer hangs: it makes the images that prerender named, then goes on to the adapter. An image of them that cannot be made is warned about (image_owed_end) and stops the rebuild only if a page still names it, and the images that were made keep their names.
    • An SPA fallback page an adapter renders can no longer hold the build's mark host when another environment was built, a tool resolved the Vite config, or a watch rebuild started, after the build made its images.
    • A build deletes its notes folder at its end only when that folder is a real folder right under a runs folder the image code owns: the image cache's, or with no build cache this user's own owner-only folder in the system's temporary folder (ogygia-image-<uid>/runs); any other folder named by an inherited __OGYGIA_IMAGE_BUILD, or one reached through a link, is kept, and the build warns (image_run_kept) and goes on. A notes folder that cannot be deleted at a build's end no longer replaces the build's own image error: the build warns (image_run_kept) and goes on. With no build cache, a Kit 3 watch rebuild no longer leaves an empty temporary folder behind.
    • A build, a dev server or the image maker uses a store or remote images folder named by an inherited __OGYGIA_IMAGE_BUILD only when it is inside a folder the image code owns (the image cache, the build's own temporary folder, or this user's owner-only ogygia-image-<uid> folder); any other is refused with a warning (image_folder_refused), its own folder is used instead, and nothing in the refused one is deleted or written. With no build cache and a temporary folder that is not this user's alone, a build's end deletes a run in its own new temporary folder only while that folder is still this user's alone.
    • Under vite build --watch, the prerendered pages of a build that could not make an image are removed from the build output if they still hold that build's mark host, so no later rebuild publishes them. If one cannot be removed, the build warns (image_pages_left) beside its own error.

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

  7. 0.16.1 patch

    Patch Changes

    • On SvelteKit 3, a prerendered page's <Img> now points at the real image files, and the build writes them: before, every prerendered image URL kept the build's mark host (//<hex>.ogygia.invalid/...) and no file was written, so each image 404'd. Share cards and the remote image list in server chunks now also work on Kit 3. On SvelteKit 3, the build now runs the encoder and platform checks, which it skipped before: an app with sharp missing now fails the build with image_sharp_missing, an app on Cloudflare with no encoder chosen with image_option_invalid, and a platform encoder on another adapter with image_option_invalid (cloudflare()) or image_vercel_config (vercel()). On SvelteKit 3, a vite build --watch rebuild now names the image files a build has already made (the last build's, remote images and share cards included, and the warmed ones), instead of keeping the build's mark; a rebuilt prerendered page that names an image file no build made (a new image, a new remote URL or share card, or new options on one) now stops the rebuild before the adapter with image_watch_rebuild.

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

  8. 0.16.0 minor

    Minor Changes

    • sharp makes AVIF files at effort 2 (was 4): about twice as fast to encode, for files about 0.2% larger. Every file gets a new name once (the encoder's version moved).
    • cloudflare({ links?, binding? }) from @ogygia/image/vite is an encoder for Cloudflare Workers: a page the Worker renders on request names each file as an Image Transformations link (/cdn-cgi/image/<options>/<original>), or with links: false its image endpoint makes each file with the Worker's Images binding (default IMAGES) and keeps it in caches.default; a Worker without that binding answers 500 and says image_binding_missing. cloudflare() on any adapter but adapter-cloudflare (adapter-auto included) fails the server build with image_option_invalid. Prerendered pages still name the files the build makes. A page rendered on request, or in dev, that asks the encoder for a crop or operation it cannot make (Cloudflare: an entropy position, a turn other than a quarter, normalize, negate, gamma, tint, modulate hue or lightness, an AVIF source; a link also cannot make a PNG from another format) fails to render with image_encoder_cannot, naming the encoder and the need. A build for an adapter whose runtime cannot load sharp, with sharp() as the encoder, now says image_no_encoder once, naming cloudflare(), instead of image_adapter_no_encoder (removed) once per build pass. The image endpoint's reader checks an original with Web Crypto, so a Worker's image endpoint needs no Node crypto.
    • image({ encoder }) says who makes the image files: sharp() from @ogygia/image/vite (the default, as before: the app's own endpoint makes every live file and the build every prerendered one), or a list in order of priority (one platform, at most one encoder that makes files at the app's endpoint, sharp() only last); anything else fails the build with image_option_invalid. A Node server bundle now loads the files it reads and notes on disk only in dev and in the build. getImage()'s sources rows may carry media, sizes, width and height beside type and srcset, and <Img> writes them on each <source> when present (type is now optional); today's rows are unchanged.
    • With content({ markdown }) and image() listed, a local markdown image (![alt](./photo.jpg), relative to the post, spaces and accents included) renders through <Img> with the prose preset (or image({ markdown: { width } })), and a frontmatter value starting with ./ or ../ that names an image becomes a descriptor (accept it in a schema with v.custom<ImageDescriptor>(isImage)). A missing file, an HTML <img> naming a local file (image_markdown_html) and a local image in import.meta.og.md(text) (image_markdown_no_file) fail the build. image({ markdown: false }) leaves markdown images as plain <img>, and image({ markdown: { animated: 'motion' } }) shows a moving markdown image (an animated GIF or WebP) with that preset instead, so its width and sizes pick narrower files (a name image({ presets }) does not declare fails the build with image_option_invalid). import.meta.og.image() works in a markdown page's <script> too.
    • New package @ogygia/image: list image({ presets }) from @ogygia/image/vite beside ogygia(), read an image with import.meta.og.image('./hero.jpg') (or many with import.meta.og.image.glob('./gallery/*.jpg')), and render it with <Img of={hero} preset="cover" alt="…" />. The build reads each source once (its size and a blur placeholder of a few hundred bytes at most) and encodes nothing; <Img> picks the files from a preset or its own layout (constrained, fullWidth, fixed), width, aspect and position, and names each one by a signed URL that the image endpoint makes on first request, in dev and on a live server. A prerendered page's files (a getImage() CSS background too) are made by the build as static files under _app/immutable/og/, named by their recipe, so adapter-static sites need no server and keep the same image URLs across builds with no OGYGIA_SECRET. import.meta.og.image(src, { warm: 'cover' }) makes a preset's files there at build for pages rendered on a live server. Crops are real files (a 1/1 thumbnail downloads a square), a fixed 48-pixel avatar asks for 48 and 96 only, animated GIFs become animated WebP, SVGs are served as they are, and a changed or unsigned URL is refused. priority preloads the page's main image from the head, morph names an image for a view transition, and the HTML carries no client script and no inline event handler (the placeholder and a crop are inline styles, the placeholder a data: image). sharp is a peer the app installs (pnpm add @ogygia/image sharp): a build or dev server that cannot find it in the app, or a server build that lists it only in devDependencies (adapter-node would bundle it, and every image would answer 500), fails with image_sharp_missing. The server loads sharp on the first image request, never at start; it keeps its files on disk to a size, answers from memory when the disk cannot write, sends a URL with a query string to the bare URL, and answers 503 past a bounded line of encodes. Every file is named by a hash of its source's bytes and is never made from an original that no longer matches it, so an edited image gets new URLs and an old page's URL answers 404, never the new pixels. A URL made absolute with new URL(src, page.url) (an og:image, an RSS feed) names the file at kit.prerender.origin on a prerendered page. getImage() gives the same answer outside the component, and isImage checks a frontmatter image field (v.custom<ImageDescriptor>(isImage)). A missing file, a file outside src/, a non-literal argument, an unknown option, an unknown preset, a descriptor whose id or placeholder the build did not make, a size of 0 or less (fractions are rounded) or an image too large to encode fails with a code.
    • Remote images at build: image({ remote: { hosts } }) lets import.meta.og.image('https://…'), a markdown image and a frontmatter URL on a listed host be fetched into the build cache (asked again on each build, a 304 keeps the copy, an offline build uses it and warns image_remote_stale) and become a file source like any other; an unlisted URL fails the build with image_remote_host (which replaces image_remote_unsupported), and a fetch with no copy that fails is image_remote_failed.
    • Remote images at request: remoteImage(url, { width, height, alt?, version? }) makes a descriptor of an image a server load learns per request (a CMS entry's); the image endpoint fetches its URL (signed into the file's URL) under image({ remote: { hosts, maxBytes, timeout } }), one fetch per URL, and answers its files public, max-age=<rest of the maxAge window>, stale-while-revalidate=<maxAge>, never immutable; refusals are 404 (unlisted host, a redirect off the list, or a host listed only by *. that resolves to a private address, a rule the build's fetch now follows too), 413, 504 and 502, each no-store and said as image_remote_refused; a prerendered page's remoteImage() is fetched by the build and its files named by the bytes; cloudflare() links name the whole URL, and image_vercel_config now requires images.remotePatterns for each remote.hosts entry (type VercelRemotePattern).
    • Share cards: import.meta.og.image.card('./Card.svelte', { width, height, fonts }) returns (props) => ImageDescriptor, a Svelte component (and the components it imports, with their scoped CSS) drawn as a PNG by satori, satori-html and @resvg/resvg-js (optional peers the app installs; a build with a card and none of them fails image_card_engine_missing). Props are one JSON object of at most 2048 characters in the URL (image_card_props), signed into each file's .card/ tail; fonts are .woff, .ttf or .otf files whose family, weight and style the build reads (image_card_font); CSS satori cannot draw fails image_card_css, naming the property; an image a card names (<img src>, a style's url()) is read by ogygia and handed to satori as bytes, never fetched by it: an asset of the build, an http(s) URL on a remote.hosts host (under its size, time and private-address limits) or a data: URL, anything else image_card_source, and each is fitted to the card with sharp first (refused past 16383 × 16383 pixels from its header, drawn from a card-sized copy when larger), so a small file of huge dimensions cannot take the draw's memory; a link's href is no image. A prerendered page's card is drawn by the build into _app/immutable/og/, a live page's by the image endpoint on the first ask, kept forever and named by a digest of every module and font the card is made from (a card that shows a remote image follows remote.maxAge instead, never immutable, and the build names its file by the bytes it got); on an edge runtime a live page's card is the build's file when a prerendered page made it, else 404 with image_no_encoder (which gains what: 'card'). Descriptors gain from: 'card' and card. In dev, an og:image or twitter:image naming an AVIF or WebP file says image_share_format.
    • sharp({ effort: { avif } }) sets how hard sharp works on AVIF files, a whole number from 0 to 9 (default 2): a higher one makes smaller files and slower builds. Anything else fails the build with image_option_invalid.
    • A moving image (an animated GIF or WebP) offers its first frame as a still to visitors who ask for less motion (<source media="(prefers-reduced-motion: reduce)">, files named with -s; Cloudflare makes it with anim=false); with vercel() alone, which cannot keep one frame, no still is offered and the build warns image_still_left_out. import.meta.og.image(src, { dark: './x-dark.png' }) gives an image a dark file of the same shape (another shape fails with image_option_invalid), shown at (prefers-color-scheme: dark); image({ theme: { dark, light } }) makes it follow an app's own theme selectors instead, as two <picture>s a static stylesheet picks between, the hidden one never downloaded. Art direction: a preset's art: [{ media, aspect?, position?, width? }], <Img art> and getImage(of, { art }) (another crop, or another source with of), and the macro's art: { '<media>': './x.jpg' }; each twin row carries its own width and height, so nothing shifts when the media changes. warm warms twins too. getImage()'s result names one preload per candidate set, preloads (each with its media when the image has twins), in place of preload. @ogygia/image exports the types Twin (one entry of an art list) and LaidPreload (one of getImage()'s preloads), so an app can name them.
    • vercel({ sizes?, qualities? }) from @ogygia/image/vite is an encoder for adapter-vercel: a page rendered on request names each file as a Vercel Image Optimization link (/_vercel/image?url=…&w=…&q=…), its width snapped up to sizes, AVIF or WebP picked by Vercel from the browser's Accept; hand encoder.images to the adapter (adapter({ images })). Prerendered pages still name the files the build makes. image({ encoder: [vercel(), sharp()] }): a list is in order of priority, the first encoder that can make a file making it, so the crops, positions, operations, named PNG or JPEG, and GIF, TIFF or animated sources Vercel cannot make go to the app's own sharp endpoint; with vercel() alone they fail to render with image_encoder_cannot. A build that lists vercel() fails with image_vercel_config when adapter-vercel's .vercel/output/config.json images lacks a width, quality or format the app names, or the host of a full-URL paths.assets, or when it opens more than the app needs (no qualities, or localPatterns unset or wider than the app's originals), or when the adapter is not adapter-vercel. vercel()'s images lists qualities 60 and 80 by default and localPatterns for /_app/immutable/assets/ only, and a plugin or preset quality it does not list fails the build with image_option_invalid.

    Patch Changes

    • A responsive image no longer gets a ladder width within a tenth of a width its layout already names (its width, twice it, or the source's own): a 900 px constrained image makes 900 and no 960, so a build makes fewer files for the same srcset choices.
    • With vercel() alone, a share card for a page rendered on request is now drawn (every one answered 500 image_settle_failed, since no encoder made files there); one that names an image fails image_card_source, saying to list sharp().
    • A Vercel function now draws a share card for a page rendered on request (it answered 500 image_settle_failed): a server card's chunk names satori's harfbuzz WebAssembly file, so Vercel's file tracing keeps it in the function.

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