const COMPRESS can send brotli and zstd. Two cargo features of wisp turn them on: compress-br (the brotli crate, quality 4) and compress-zstd (the ruzstd crate, its Fastest level, about zstd level 1). Both are off by default. Neither is in the edge build. Gzip stays the base. The server picks the coding with the highest q of the request's accept-encoding. On a tie, zstd wins over br and br over gzip. A client must name br or zstd. * gets gzip. q=0 and identity give an answer as it is. If an encoder of brotli or zstd fails, the answer is gzip when the client takes gzip, else as it is. With panic = "abort", an encoder that panics stops the process. A streamed page ({#await}) with COMPRESS stays gzip. Embedded files and prerendered pages are as before: gzip, or brotli made at build time. A route without COMPRESS runs no new code. One reader of q now serves embedded files and COMPRESS answers. A q that is not digits with at most one . (1e-3, +1, inf) counts as 0 for both.
The server unpacks a request body with Content-Encoding: gzip (or x-gzip), over HTTP/1.1 and HTTP/2, before the handler reads it, so cx.body(), body: T and the form fields see plain bytes. WISP_BODY_LIMIT (or the route's BODY_LIMIT) limits the packed size and the unpacked size: a body that grows past it is a 413, and the unpacking stops at the limit. A body that is not one gzip file, or ends too soon, is a 400. So is a body with too many dynamic blocks. A body can hold one dynamic block for each 24 bytes of its deflate data (not the gzip header and trailer), and 64 more. Any other coding (br, zstd, deflate), a list of codings and a repeated header are a 415. identity leaves the body as sent. The unpacked request has no content-encoding and no content-length header. A request without the header is not unpacked. Its parse checks one flag more when it has a body. A route with an Upload holds a packed body in memory, within its limit, and does not stream it to disk. The early RATE_LIMIT and SIGNED_IN check of an upload does not run for a packed body, over HTTP/1.1 and HTTP/2: the server reads and unpacks it first. The edge build does not unpack: the handler reads the bytes as sent. See https://wispweb.dev/docs/design-runtime.
Four env vars set the connection times of the native server, in whole seconds, 1 or more. WISP_KEEP_ALIVE_TIMEOUT (default 60) is the idle time of a keep-alive connection, for HTTP/1 and HTTP/2. WISP_HEADER_TIMEOUT (10) is the time to receive a request head after its first byte. WISP_BODY_TIMEOUT (10) is the time for each part of a request body. WISP_WRITE_TIMEOUT (30) is the time a client may take none of a response. A value of 0 or a non-number stops the server at start. The defaults equal the old fixed times. The minimum rates of 1 KB/s stay fixed.
const CONCURRENCY: u32 = 8; in a page, mod server or +server.rs lets at most 8 requests of that file's handlers run at once. A request over the cap gets a 503 with retry-after: 1 and does not wait. 0 means no cap. A layout, a slot page or src/hooks.rs with it is a build error. A route without it pays nothing.
The server can speak HTTPS itself. Enable the tls feature of wisp and set WISP_TLS_CERT and WISP_TLS_KEY to the PEM files of the certificate chain and its private key. Set both or neither. The port then speaks TLS only (rustls, the ring provider that wisp::fetch already uses), and ALPN offers http/1.1 and, with the h2 feature, h2. WebSockets work over it. Cx counts the request as HTTPS, so cookies get Secure. A missing file, a file with no certificate or key, and a key that does not belong to the certificate stop the server at start with wisp: TLS: <reason>. The server never serves plain HTTP in its place. A build with no tls feature stops at start when either variable has a value. WISP_DEV_FRONT turns TLS off only for the front of wisp dev: a debug build with its WISP_DEV_PEER token. Once a minute, a separate thread checks the two files again, so a new connection never waits for that read. A changed pair that works serves new connections. The server logs a pair that does not work, and the old pair keeps serving. A check that panics writes wisp: TLS certificate reload failed, the old one is still served: <reason> once, and the next check runs as usual. With panic = "abort", a panic in the reload check stops the process. On Linux, HTTPS runs on tokio's sockets, because io_uring and epoll hand raw bytes to the connection with no layer for TLS. Plain HTTP stays on io_uring and epoll. WISP_TLS_CERT with WISP_LISTEN=unix: stops the server at start. The server says wisp: listening on https://<addr>. Without the tls feature the build has no TLS code. The tests are in tests/app/tests/tls.rs. See https://wispweb.dev/docs/deploy/#https-in-the-server.
Gate audit-mark --delta records a delta read. It fails when the last whole read of the file is over 15 days before the mark, or has no date. The ledger has a new whole column for this. The audit step fails on a delta mark that breaks the rule, and lists each line with no whole date as "whole read due". audit-mark with no flag is a whole read.
Gate step chunkcheck (also wisp-gate chunkcheck) checks the size of each chunk that Ask Wisp reads from the pages of the docs site and from llms/. A chunk over 2500 bytes fails the step and names its file and line. A chunk over 2300 bytes prints a warning. Before, the cap showed only in the test of Ask Wisp, after the build of the whole site. The step runs the test tests/chunk_cap.rs of the docs checkout (WISP_DOCS_DIR, default ../wisp-docs). With no docs checkout, the full gate prints chunkcheck: SKIPPED (no docs checkout) at the step and at the end of the run. In CI, and in chunkcheck mode, the step fails instead. fast does not run it.
wisp host [path|name] sets up an app on this machine and keeps it running. It reads the machine, asks for each choice that no option gives, and picks the lightest setup. On Linux and macOS, a user who is not root runs one command. wisp host asks and builds as that user. Then it runs itself under sudo with each answer as an option. That step runs sudo -- env WISP_HOST_ELEVATED=1 <wisp> host ..., so a sudoers rule for one wisp path does not match it. An administrator run never runs cargo build. A docker setup still builds its image with compose up -d --build. add refuses a Caddy block that exists and that no hosted app has. native (the default) runs the release binary as a system service, as wisp service does. docker runs it with docker compose or podman compose. --domain puts Caddy in front for HTTPS, and --install-deps installs Caddy. Wisp never installs Docker. A list (hosts.tsv in WISP_HOME, /var/lib/wisp or ~/.wisp) holds the hosted apps. A new app gets no port or domain of another hosted app. wisp host list, info, status, start, stop, restart, logs, update and delete use it. delete keeps the app folder. --purge also deletes the host folder (only with its .wisp-host file) and the data of the setup. The list has no lock, so run one wisp host at a time. See https://wispweb.dev/docs/hosting/#wisp-host.
Content collections: content::posts::filter(f), first(f), count(f), sorted(key), sorted_desc(key), page(skip, limit), page_of(f, skip, limit) and around(slug) query a collection. filter, page_of and the two sorts return a Vec of references, page returns a slice and copies nothing, and around returns the previous and next entry. f can be FnMut. They add no cost to an app that does not call them. No function skips drafts: draft is a field of your own.
Test tools for an app, on a new docs page /docs/testing and in examples/testing: - wisp::test::dom(html) and Reply::dom() read HTML with CSS selectors (get, find, all, count, has, text, attr, inner_html). Use them on a page, or on a component drawn alone with Card::html(..). A component also has Card::html_with(.., children) for its children. - wisp::test::request::<App>(method, target) makes a Cx by hand (query, headers, cookies, form or JSON body, session, peer) for a test that calls a handler or helper directly. block_on, reply_status and reply_headers run an async fn and read what it set. - wisp::test::net() mocks the outgoing calls of fetch, fetch_follow, fetch_public and fetch_stream* in a debug build. It queues replies, records each call and fails the test on an unused reply. A release build has no mock code. - wisp test --coverage runs cargo llvm-cov and moves the lines of generated code to the .wisp files. It prints a table and writes target/wisp-coverage.lcov. - wisp test --e2e builds the app, starts it on a free port and runs npx playwright test with WISP_URL. wisp test --e2e --init writes playwright.config.ts and e2e/home.spec.ts.
Content collections. #[collection("posts")] on a struct of src/content.rs (or any src/*.rs) makes the folder content/posts a typed collection. The build reads each .md file once, checks its front matter against the struct and keeps the entries in the binary. content::posts::all() returns &'static [Post] (newest date first) and content::posts::get("slug") returns one entry. An entry is a .md file (front matter and body), a .json object or a flat .yaml or .yml file, in nested folders too (the slug is the path). The build sets the fields slug and body (the Markdown as HTML). A missing field, an unknown field and a value of the wrong type fail the build with the file and line. A request parses nothing. wisp dev builds again when a file in content/ changes. The example examples/blog shows it. See Content collections.
swr(key, fetcher, options) is a cache of fetched data with revalidation, for browser code (/_app/c/swr.js). Calls of one key share one entry and one request. An entry is awake while a block or $effect reads it. An awake entry shows old data while it fetches new data. It fetches when its data is older than stale (30000 ms). It also fetches every interval, and when the tab shows again, the window gets focus or the network returns. When the last reader ends, the entry aborts its request. It keeps its data for gc (300000 ms). initial seeds an entry with a server value. swr.invalidate(key) marks the entries stale by key prefix. swr.set(key, v) writes the data of a key, also a key with no entry. A form that posted ok and invalidateAll() mark all entries stale. Only a module that names swr loads swr.js. Other pages load no byte more. The new page is Fetching data in the browser, and examples/api has a /notes page.
wisp fmt formats the body of a <script> and of a <style>. Before, it only re-indented a script and left a script with a template literal as it was. It gave a style one declaration a line only when the style had no string, comment or url(. A script now gets spacing, indentation by bracket and continuation line, and line breaks after ; and in long bracket pairs (past 100 columns). A style gets one selector and one declaration a line, with nested rules and at-rules. Template literals, strings, url() and custom property values keep their text. A comment between rules keeps its text. A block comment whose lines each start with * gets new indentation, line by line. The formatter adds and deletes no semicolon. It checks that the tokens stay equal and that a second format changes nothing. If a check fails, it only re-indents that body and warns once. It only re-indents a style in three cases, with no warning: a comment inside a selector or a declaration, a url( with no ), and an escaped space. It stops the layout of a script, with no warning, when a / after a } reads as a regex. A file that mixes \r\n and a bare \n stays as written.
The dev error page of a handler panic shows a code frame: the line that panicked and two lines above and below it, with line numbers and a ^ under the column. The dialog of the browser and the request line in the terminal of wisp dev show it too. A panic in generated code shows the frame of the .wisp file. Wisp reads only a file inside the app folder (a link out of it gives none), at most 1 MiB, and it escapes the text. Only a debug build with dev mode on shows the frame. A release build, and a server with WISP_DEV=off, answer with a plain 500. A new page, /docs/debugging, covers the dev error page, dbg!, RUST_BACKTRACE, logs and attaching a debugger to the app of wisp dev.
wisp lsp renames a form action: its fn and each ?/save of the route. The rename stops in three cases. The name is a word in the Rust code beyond the fn. The new name is already a word there. Another file of the app has ?/save. The clash check reads only the route files, so a name from a glob import or a parent module is not checked. There are three new quick fixes. A component name that is near one component changes in each tag of the file. The problem "needs a prop" adds the prop with an empty value of its type (${0.0} for a float) when the line has one tag of that name. The problem "has no prop" changes the name to the one prop that it is near. The new code action kind source.fixAll applies the first fix of each problem that has a sure fix. It skips a fix that adds a tag or a prop with an empty value. It drops a whole fix when one of its edits touches an earlier fix. A file shows the problem of the whole app (wisp check) with the problems of its buffer, not instead of them. After a change, the problem that was read from the disk is stale, so the file hides it until the next save. A closed file keeps the problem of the app in the Problems list.
wisp check lints more. There are 40 rules, each with a code: 24 accessibility rules (new: a11y-aria-role, a11y-role-redundant, a11y-role-props, a11y-interactive-focus, a11y-tabindex-static, a11y-aria-hidden-focusable, a11y-mouse-events, a11y-accesskey, a11y-iframe-title, a11y-media-captions, a11y-distracting, a11y-img-redundant-alt), 6 SEO rules, 5 CSS rules and 5 JavaScript rules. The CSS and JavaScript rules read <style> and <script> blocks and the .css, .js, .mjs and .ts files in src/.
Lint levels: the table [package.metadata.wisp.lint] in Cargo.toml sets "off", "warn" or "error" for a rule code or a group (a11y, seo, css, js). An unknown code is an error that names the nearest code. strict = true works as before. Wisp reads the levels only under the exact header [package.metadata.wisp.lint]. A lint key under [package.metadata.wisp], a header with a space or a quote, and a row without = are errors.
wisp check --fix makes the safe fixes (a redundant role, a debugger statement, an empty CSS rule, a repeated CSS declaration). It writes each file with a temporary file and a rename, and a second run changes nothing, unless the output says that fixes are left. wisp check --fix --dry-run writes nothing and fails if a fix is left. wisp check --rules lists the rules.
wisp check --rust runs cargo clippy. When clippy is not installed it runs cargo check and prints one note.
wisp build --analyze shows each file once as a module: the heaviest modules, the number of routes that load each one, and modules with equal bytes under two names. --analyze=json prints one JSON document for tools (total, routes with their share, modules, duplicates). --analyze=html [--out file] writes a treemap page (default target/wisp-analyze.html, and a relative --out also starts at the app folder) with a map of all modules and a map for each of the first 50 routes. The page has no script and loads no outside file. --analyze alone prints text, as before. --analyze=html takes --out, the other forms go alone.
PUBLIC_ variables are typed and checked. wisp check --types writes env in wisp.d.ts with one readonly member per PUBLIC_* variable that the build reads (process, .env and the mode files), so tsc rejects a name that nothing sets. Before, env accepted any PUBLIC_* name. A PUBLIC_ name with SECRET, PASSWORD, PASSWD, PRIVATE or CREDENTIAL in it is now an error: the build refuses it when browser code reads it or when public_env = true, and the server does not start with public_env = true while one is set. A name with TOKEN or KEY passes. A PUBLIC_ name must use only A-Z, a-z, 0-9 and _: a look-alike letter of another script is an error too. New example examples/pubenv.
Bench publish of 1.0.0-pre.3 (Latitude.sh box). bench/native-rank/report.mjs takes --summary FILE: it ranks the valid cells of the quiet summary only, shows a generator-limited cell as "at least X" with no rank and no sum, and shows a noisy cell with no rank. bench/rank/report.mjs gives two cells whose min-max ranges over the repeats overlap a tie and no place. bench/quiet/summarize.mjs lists only valid generator-limited cells. bench/tfb/aggregate.py reads its files as UTF-8 and counts the lower-bound levels of Wisp in the summary line. The stamps name tag commit 0d2d15a03. No framework behavior changes.
The VS Code extension gives more .wisp constructs their own color. Before, a theme showed them in the color of a plain attribute, tag or variable. These now have their own scope: - Wisp attributes (action, fields, confirm, data-wisp-*). - The name of use:, transition:, in:, out: and animate:, and the : of each directive. - The name in action="?/save". - The rules of #[validate(..)]. - <wisp:*> elements, fragments <>, and $store reads. - Browser blocks ({:#if}, {:expr}), which no longer look like Rust blocks. The value of <Card --gap="2"> was marked as an error. It is a string now. wisp lsp adds the token modifiers client (the keyword of a browser block) and action (the name of a form action). It marks <ui:Card> as a component, the modifiers of a directive (.prevent, |once) and loop.index. The extension maps them to the same scopes with semanticTokenScopes and turns on semantic highlighting for .wisp. The test editors/vscode/test/grammar.test.js checks that each Wisp construct and the plain thing beside it get different colors in Dark+, Light+ and Monokai. The TextMate grammar (VS Code, JetBrains) and the Sublime syntax also give each kind of block, tag and directive its own scope, as the tree-sitter grammar does: keyword.control.conditional.wisp ({#if}, {#match}), keyword.control.loop.wisp ({#each}), keyword.control.trycatch.wisp ({#await}), storage.type.function.snippet.wisp ({#snippet}), support.function.macro.wisp ({@html}, {@json}, {@render}), support.function.builtin.wisp ({@flash}, {@pager}, {@element}) and keyword.other.debug.wisp ({@debug}). The prefix of bind:, class:, style:, use: and the motion directives has a kind scope too, and a modifier such as .prevent is constant.language.builtin.wisp. The generic scope (keyword.control.block.wisp) stays beside the kind.