Skip to content

v0.28.0

Choose a tag to compare

@github-actions github-actions released this 21 Oct 12:07
· 3573 commits to main since this release

Images and icons. foldkit-media 0.1.0 is its first release: an image's facts, a provider and a
layout give every attribute of its markup, a server (/server, /cloudflare, /sharp) or a
build (/vite) makes and keeps each variant, and icons are data a build reads from an Iconify set
or an SVG file. foldkit-mixins-ui 0.17.0 draws them (Image, Figure, Icon.view, an
Avatar picture), and foldkit-mixins 0.17.0 adds the theme's icon tokens and keeps a
reader's theme and knobs before the first paint. foldkit-richtext 0.5.0 lets an Image carry its
facts, foldkit-primitives 0.15.0 adds decodeImage, foldkit-ssr 0.8.0 adds emit,
foldkit-mixins-richtext 0.5.0 draws its icons from Lucide's data, and foldkit-plus is 0.10.0.
Packages that pin one of them republish with a patch so their ranges cover the new versions
(foldkit-builder, foldkit-cms, foldkit-cms-drizzle, foldkit-composition,
foldkit-mixins-builder, foldkit-mixins-crud, foldkit-mixins-data-grid,
foldkit-mixins-form, foldkit-mixins-surface, foldkit-richtext-code,
foldkit-richtext-code-shiki, foldkit-richtext-dom, foldkit-richtext-markdown,
foldkit-site). One change needs code: ColorPicker.popover now draws the whole Popover and takes
its Model and Messages (see Changed).

Added

  • foldkit-richtext: a standard Image may carry its asset, foldkit-media's ImageAsset of
    what its src names, as stored; with it, the standard rendering writes the img's width and
    height (at the drawn width when set), so a page holds the image's box before the file
    arrives, and imageBox(props) gives a rendering of its own the same. Optional: a document
    without it is as valid as before. foldkit-media is a new dependency.
  • examples/cms: the site's Image block may carry its asset, the facts of the file its src
    names, hidden from the inspector; with them the image's box is its own shape before the file
    arrives, while the facts' key is still the src (an edited address falls back to 4:3).
  • foldkit-primitives: decodeImage(source) fetches and decodes a picture before it is shown,
    yielding Decoded or DecodeFailed; given candidates, the one the browser would draw.
  • foldkit-ssr: a static site's emit(pages) adds files made from the generated pages, written
    beside them; a path outside the output, or on a file the build or the client build writes, is
    refused. writeEmitted writes them without the plugin.
  • foldkit-mixins: Theme.knobScript({ key?, selector? }) and Theme.chooseKnobs(theme, { base, key?, selector? }) keep a reader's knob values and apply them before the first paint, as
    schemeScript and chooseScheme do for the scheme: the head script applies the kept knob
    variables to one unlayered rule, and the Command rewrites that rule and keeps those that differ
    from base. See docs/design/theme-robustness-DESIGN.md.
  • foldkit-mixins: Themes.choose(themes, name, key?) shows a named theme and keeps it, and
    Themes.script(themes, key?) is a head script that shows the kept one before the first paint,
    on the attribute Themes.apply writes; a name no theme has is ignored.
  • foldkit-media 0.1.0, its first release: responsive images as URLs to write. Picture.derive turns
    an ImageAsset's facts, a Provider and a Layout (Fixed, Constrained, FullWidth) into
    every attribute of an image's markup: srcset and a source per format from one Widths
    ladder, sizes, the reserved box, loading priority, and a placeholder background (a color, a
    ThumbHash, or the smallest width; none behind a transparent image). Providers: cdnCgi
    (Cloudflare's /cdn-cgi/image/), fromFiles (a build's variants) and hosted (its own server,
    whose route, /_image/<hash>/w640.avif, foldkit-media/server's MediaApi declares with the same
    Schema). Variant.space({ widths, formats, qualities, revision }) bounds every variant a server makes; a
    changed output is a new revision, written into the URL (w640.r1.avif; none at 0), and a
    server answers an earlier revision while it keeps the variant, else with a 302 to the current
    URL, kept briefly, since a rollback answers the old URL again. Picture.preload writes
    the page's largest image's <link rel="preload"> for an SSR head. Picture.ogImage gives an absolute
    og:image URL at least 1200 wide, never AVIF.
    foldkit-media/server serves Provider.hosted's route over three services, Originals,
    Transformer and Variants: a variant is made once and kept, served immutable, and a failure is
    its own status (400, 404, 413, 502, 503), never the original (only a variant is kept long; every
    refusal is kept a minute at the edge and not by a browser, since a later release in a rollout, or
    the same one configured otherwise, may answer it), with headers decided in one place
    (headersFor): an ETag and 304, a cache lifetime for each answer, CORS, nosniff, Server-Timing. serveFetch hosts it in a Worker,
    layer in an Effect HttpRouter. foldkit-media/cloudflare gives its services from a Worker's bindings:
    originalsR2, transformerImages (the Images binding) and variantsR2 (R2 behind the Cache API).
    examples/cloudflare serves /_image/ with them, and takes an upload only with its UPLOAD_TOKEN secret. Originals and Variants are kept in
    any Effect KeyValueStore (originalsKeyValueStore, variantsKeyValueStore), and
    keyValueStoreR2 is an R2 bucket as one. foldkit-media/sharp's transformerSharp serves a Node server: it
    refuses an original above its pixel limit with a 413 before decoding it, and runs at most
    concurrency transforms (limitTransforms); layer coalesces concurrent misses for a variant (serveFetch does not: a Worker request cannot wait on another's work), and sharp reads an original as its EXIF orientation shows it. Rate limits apply to misses only:
    admissionRateLimiter (Effect's RateLimiter) or admissionRateLimit (a Workers rate-limit
    binding) answers a 429 with Retry-After. materialize writes the hosted variants a static site's pages
    name, as foldkit-ssr's emit, and headersRule() is the _headers rule they need.
    describe (in the core) derives an original's facts through an Inspector (foldkit-media/browser's
    inspectorBrowser, the browser's own decoder, so an editor describes a file where it is chosen;
    inspectorSharp,
    inspectorImages), and factsOf(url) describes an image named only by URL, from allowed hosts at their default port,
    kept and revalidated with its ETag. Icon holds an icon as data (IconData: its viewBox,
    what its root paints, its drawing): Icon.serialize writes it as one SVG document and
    Icon.maskUrl as a CSS url() for a mask. foldkit-media/icons, for builds, reads an SVG file
    (parse) or an Iconify set's icon (fromIconify, through its aliases) into it, and refuses,
    naming the icon, any element or attribute outside a presentational allowlist, a link or
    url() outside the icon or to an id it does not define, a CSS function other than a colour, a
    transform or url(), an Iconify icon or alias that rotates or flips, and a CSS escape. Icon.key(icon) names an icon by its content, and
    Icon.prefixIds(icon, prefix) renames the ids it defines and every reference to them.
    Icon.withStroke(icon, { width?, corners? }) redraws an icon's strokes, for a mask CSS cannot
    reach, and Icon.maskUrl escapes only what a quoted CSS url() cannot hold, a fifth shorter.
    foldkit-media/vite's icons({ iconify, folders, dts }) makes icons imports:
    import { arrowLeft } from 'virtual:foldkit-icons/lucide' reads an installed Iconify set or a
    folder of the application's SVGs, the bundle holds only what is imported, and a written
    declaration names every icon, so a misspelt one is a type error. A refused SVG in a folder fails
    the build; a refused Iconify icon is left out, and the declaration says why.
    foldkit-media/vite's images({ widths?, sources?, fallback?, quality? }) makes an image in the
    repository an import: import hero from './hero.jpg?image' is { asset, provider }, its facts
    read once through sharp and a file written for each ladder width up to its own in each format,
    named by content and kept whole in Vite's cache by the original's hash, at most one original read
    per core at once; the development server makes
    the same variants on request. foldkit-media/client types the import.
    foldkit-media/unpic's detect(url, options?) is the provider of an image on a host that resizes
    it (Shopify, Cloudinary, imgix and the rest unpic knows, an optional peer), or none: the img
    asks for auto, a format the host ignores is never offered as a source, and an asset on another
    host gets no URL.
    foldkit-media/server's upload route (uploadLayer, serveUploadFetch): POST /_media/upload
    takes an image/* body under a byte cap, keeps it by its SHA-256 in Uploads
    (uploadsKeyValueStore, foldkit-media/cloudflare's uploadsR2), and answers its facts as an
    ImageAsset; who may upload is a required UploadPolicy, asked before the body is read. GET /_media/facts?url=, behind the same policy, answers the facts of an image named by URL through
    factsOf, from the hosts facts: { allow } names (none by default), or a 422.
  • foldkit-media: Icon.draw(icon, h, { key?, size? }) draws an IconData as inline SVG through
    any view builder of its shape (SvgBuilder; Foldkit's h is one), every attribute in the
    server's markup, 1em square unless size is given and kept so in a squeezed flex row,
    aria-hidden, its ids prefixed by the
    icon's content so two icons sharing an id each paint their own; key sets two copies of one icon
    apart. foldkit-mixins-ui's Icon.view fills its glyph with the drawing.
  • foldkit-mixins-richtext: the chrome's icons are generated from @iconify-json/lucide (pnpm icons, from the package's icons.json) and drawn with foldkit-media's Icon.draw and
    Icon.maskUrl, in place of hand-copied paths, so they are today's Lucide drawings. A drawn
    icon's size is now written in pixels (width="16px"), and its stroke sits on each path.
    foldkit-media is a new dependency.
  • foldkit-mixins: the theme's icon tokens are the masks of the icons the components draw
    themselves (search, eye, eye-off, pipette, rotate-ccw, rotate-cw, success, warning,
    error, info, lock, close; their names are ChromeIcon), Lucide's by default, written by
    pnpm icons. Command, PasswordInput, ColorPicker, ImageCropper, Toast and the data grid draw from
    them in place of their hand-written masks, so the toast's marks are Lucide's stroked drawings now.
    foldkit-mixins-ui's Icons.tokens(pack, { width?, corners? }) is an application's own pack as
    its own tokens, a pack missing a name being a type error. Two knobs: icon.size multiplies every
    icon box (the icon rung of ladder), and icon.stroke is border.glyph, the stroke of the
    checks, chevrons and guides recipes draw in CSS, until now a fixed 2px.
  • foldkit-mixins-ui: Image, a picture drawn from foldkit-media: a source per format, the
    img's candidates and sizes, its box held before the file arrives, lazy unless priority,
    and the placeholder painted behind it. alt is Image.described(text) or Image.decorative,
    never omitted. Recipes.Image has fit (cover, contain), edge (none, line), ratio
    (auto, square, video, portrait, cropped at the focal point) and radius.
    Image.watchLoad, beside the style, marks its load state and hides a failed image. Image.preloadsIn
    is a foldkit-ssr Head that preloads each image the rendered page drew with priority. Image.audit
    warns, in a development build, of a blurry or wasteful image and of two drawn with priority. An image with no
    variant keeps its box and its alt text. An asset's focus places a crop (--fk-image-focus), and a
    ThumbHash paints its picture for the priority image and its average color for the rest.
  • foldkit-mixins-ui: Figure, a figure holding its content and a figcaption in the caption
    role; Recipes.Figure has align (start, center).
  • foldkit-mixins-ui: an Avatar's src may be an AvatarPicture ({ asset, provider, width }),
    drawn with the candidates foldkit-media derives for that width, so a small avatar fetches a
    small variant. Avatar.widthOf(size) gives that width from the recipe's own sizes.
    foldkit-media is a new peer dependency. See docs/design/media-DESIGN.md.

Changed

  • foldkit-mixins-ui: ColorPicker.popover draws the whole Popover, not a toView for one:
    it takes the Popover's Model and Messages (popover, onPopover, and anchor;
    popoverMixins is the old popover option) and requires the Popover made with
    contentFocus: true, throwing for one without. The panel opens on the area's thumb, and
    focus leaving it closes one the keys or a finger opened. A popover opened by touch, a pen or the keys closed at the
    first press inside it, so the area and the tracks could not be dragged.
  • foldkit-mixins-ui: a CardGroup's highlight is a film over the card the pointer is on, the
    card's size, whatever its surface. Under cards with a surface it showed only as a rim in the
    gap around them, beside the card's own hover; a card in a group with a highlight now draws no
    hover of its own.

Fixed

  • foldkit-mixins-ui: a Card's media is an accent tile only around a bare icon (svg,
    img); an Avatar or anything else leads at its own size, at the card's start. The docs site's
    profile card passed its Avatar as image, which bleeds to the edges in a 16:9 band, and the
    avatar sat in the band's corner with the band empty beside it.
  • foldkit-mixins-ui: a ColorPicker's hue and alpha tracks stay in their channel: a Slider is
    at least 12rem wide, which ran the tracks under the swatch in a narrow picker, as in a
    popover; a holder lays one narrower with --fk-slider-min-length. The popover's trigger keeps
    the width of its format's widest text, so it no longer resizes, and moves its panel, as the
    color's text changes length.
  • foldkit-mixins-ui: a Sidebar's icon is centred in its slot, and its content on the column
    with its edge, so a rail's icons sit in its middle; an icon smaller than its slot sat at the
    slot's start, and the default variant's edge took a pixel from the content's side.
  • foldkit-mixins-ui: a Checkbox's check is centered in its box at every size; it stood low and a
    little left, by about 8% of the box.
  • foldkit-mixins-ui: a mixed Checkbox's dash is the check's stroke, 2px, on whole pixel rows
    across the box's middle; it was a tenth of the box, 1.4px at 16px, blurred off its rows.
  • foldkit-mixins-ui: the AngleSlider's dial, thumb and markers stay round in a theme whose
    radius-factor is 0; they read the radius scale before, which squared them off.