Repository navigation
Releases
6.0.4
Security
Found by security audit 6, on 6.0.3.
redirect()keeps a same-site path that begins//on the site.@zubra/routerread a location as a browser does and refused another origin, but wrote a location on this site as its path, and a path can begin//:redirect(next)withnextset tohttps://this.site//evil.example/,.//evil.exampleor..//evil.exampleansweredLocation: //evil.example/, which the browser reads as another site. It's written with one slash now, as a location that starts//already was.- A value can't set the page's
<base>, and a spread can't go on<base>or<link>.<base href={…}>and<base {...attrs}>took a visitor'shttps://evil.example/, which passes the URL check, and the base then decided where every relative URL went: the page loaded the runtime and the components' modules from the visitor's site, and its forms posted there. A spread on<link>could be{ rel: 'stylesheet', href }. Both are compile errors now; a<base>the template writes still compiles. - @zubra/sync's live stream is paced by the page reading it. A page that opened
/live?since=0and read nothing made the server load the whole log into that stream, and keep every change after it: ten such pages held 400 MB for a 200,000-change log, and any page that may read a collection could open them. The log is now read a page at a time as the page takes the last, a stream more than 64 events behind is closed (its page reconnects from its cursor, as with thezubra-syncbinary), and Node'shandle()writes only as fast as the connection takes it. - A visitor's
style:value is left off, not a failed render.style:color={tone}with a prop that isn't a single CSS value (red;}) failed the whole server render, so one profile's colour took down every page that showed it. It's left off the element with a warning, as in the browser and as a spread'sstylealready was; a literal one is still a compile error. - Signals mode takes
globalThis.Signalonly when it is the API. On a page, an element withid="Signal"(or<img name="Signal">) isglobalThis.Signal, and in signals mode a visitor's id stopped every component on the page. A nativeSignalis used only when it hasState,Computedandsubtle.untrack.
6.0.3
Fixed
- A window listener, the light-DOM slot observer, and an in-flight fetch go when the element leaves the page. They lived in effect cleanups, and disconnect only pauses the effect graph so a moved element can resume it. The listener stayed on
windowordocument, the observer stayed on the host, and aresource()request kept running and could write into a detached element. Each is now tied to the element being connected: disconnect removes it, and connecting again starts it once. Azb-awaitwhose promise settles while the element is detached still shows its result when the element comes back. Pause still does not run every effect cleanup, so a move re-runs only the effects whose inputs changed. .selfis the click's original target. A listener on a shadow host seesevent.targetretargeted to the host, so a click inside the shadow looked like a click on the host..selfnow uses the first entry ofcomposedPath().formDisabledCallback(false)before connect is kept, andsetValiditydoes not throw when its anchor is not focusable. Safari and Firefox can call the callback before the element connects, including withfalse, and thatfalsewas dropped, so the control stayed disabled. The last value is replayed once the script has registered. Safari throwsNotFoundErrorif the validity anchor is the host and the host is not a focusable descendant; the call is retried without an anchor.- A hot update that cannot swap the element reloads the page. Defining the same tag twice throws
NotSupportedErrorin Firefox and WebKit. A build with no swap method now setshotReloadedto false, which is what the plugin already reloads on, and the first class stays registered. --emit elementdrops a window listener when itszb-if,zb-each, or slot fallback goes. The listener was pushed onto the element for as long as the element lived, so hiding the branch left it onwindow. A listener nested inside another condition or row stayed too, and connecting the element again put it back. The branch, row, or fallback removes it, including one nested inside, and connecting again adds it only while that branch is showing.
6.0.2
Fixed
- Framework server rendering drops hostile host attributes.
renderToString(what an Astro page's attributes go through) wrote every extra host attribute into the HTML, name and all, so a visitor's"><script>oronmouseoverran when the page was parsed. A name that isn't an attribute name, a string event handler,innerHTMLand its kin, an object, and an unsafe URL (javascript:,data:,vbscript:, including one hidden by a character reference) are left off, as a spread already left them off. - A dynamic
style:value can't inject CSS.style:background-image={user}appliedurl(...)in the browser, and a custom property took</style>, even though a value the server can see is rejected. The runtime now leaves a value that isn't a single CSS value off the element. - A sync log can't apply
__proto__,constructororprototype. A push of those names was already refused. A log that already held them (written before the check, or past the handler) was still applied when documents were rebuilt:__proto__set that document's prototype, andconstructor/prototypeshowed up as fields. They're skipped, on the server and when a client merges a change.prototypeis refused on a push too. The Worker standup example servesfields.jsbesideconnect.js, which imports it. - A single-quoted attribute can't grow a second attribute. The HTML output always uses double quotes. A literal
"inside the value, including one around{name}written with single quotes, was copied through, so a visitor's prop closed the attribute and the rest (ontoggle,open) was parsed as its own."and<in that literal are escaped. An&the author already wrote (&) stays as written. - A spread can't set
<meta http-equiv>'scontent.http-equivitself was already refused.contenton a meta that has it (or a spread that tries to set both) was still written, which is a refresh to whatever URL the visitor supplied. It's left off, on the server and in the browser. - Hydration doesn't bind a component's listeners to a visitor's lookalike markup. An early
<!--]-->or<?zb ]?>in a slot, or a child whose tags match the template but whose text doesn't, is not adopted: the component renders its own template. A child component is left to its own template. A matching element loses a URL, an event handler,srcdocorpingthe template doesn't have and no part binds (formactionoronmouseoveron the template's button). Anidthe page wrote stays. Whitespace left where a marker was stripped still matches; a different word does not. - The local playground and gallery servers stay inside their directory. A request whose path decodes to
..(/..%2fsecret.txt,/zubra/..%2fsecret.txt) is a 404.index.htmlin the directory is still served. - An action result cookie with no
pageis ignored. The cookie is shown only on the path it names. One withoutpagematched every path.
6.0.1
Fixed
- A starter script run before
npm installsays to install.npm create zubrainstalls nothing, and its last lines say to runnpm installand thennpm run dev. Runningdev,build,previewortestfirst (andstartin the server app, andcheckwith--typescript) asked the shell forviteorastro, or started the server, which then could not import its packages. Git Bash reportedvite: command not found, which reads as if the app never included Vite. Those scripts now runscripts/ensure-installed.jsfirst (predevand the rest), and it stops withDependencies are not installed. Run npm install, then npm run dev.Oncenode_modulesis there, the check is quiet. New apps only: an app already created can copyscripts/ensure-installed.jsand thepre*lines from the template.
6.0.0
Zubra 6.0 makes its own reactive engine the default, with TC39 Signals as an experimental mode. It also makes production mode and closed Sync reads the defaults, and starts the 6.x long-term-support line. Migrating to 6.0 covers the changes for 5.x users. These notes include the release candidate and the changes made since it.
Added
-
A compact SQLite Sync log is opt-in.
sqliteLog(path, { keep: 'latest' })andzubra-sync --keep-latestretain only each field's latest value in a shared table. On first use they copy the latest values from an existing full log after its old cursors; the old table remains, and later starts must use the same mode. The default still keeps the full history. See Sync for the trade-offs. -
zubra.errorPage(error): a development error page for any@zubra/serverapp. The server starter wrote its own: the error's message in the open page, which went away once the fix was saved; an app without that code got whatever it wrote itself (often plain text, or the stack).errorPage(error)gives{ status: 500, type, body }to send from the app'scatch. In development: an HTML page with the message, escaped (a component's comes with its file, line, a caret and often a fix), and the stack's frames, carrying thereloadscript when that's on. In production: "Something went wrong" as plain text, never the message, which can hold a query, a path or a host.errorPage(error, { nonce })for a Content-Security-Policy nonce. Node and the edge (a Worker is production unlessproduction: false). The server starter and the help desk example use it. -
The Zubra DevTools pane shows more of the reactive engine. A binding that re-ran says why: the signals it reads that the update wrote, followed through computeds (
re-ran because doubled ← count changed). A Signals section lists the component's props, state and computeds with their values, how many times each has changed, what reads it (bindings by their DOM operation, computeds by name) and what a computed reads. Live counts the effects in the component, the components on the page, and the effects made since the pane connected that are still alive, with how that count moved over the last updates (counting starts when the pane connects, so a page that never opens it pays nothing; removed elements' effects leave the count when they're garbage-collected). Updates lists the page's last 50: what each wrote (from and to), what it re-ran, in which component, and how long it took. The header names the engine. Read-only, as before; development builds only (the production runtime is byte for byte the same); the pane's DevTools version stays 1, so an older extension and a newer runtime, or the reverse, still work together. Signals mode shows everything but the change counts. The Signals Inspector is unchanged. -
A warning for
classNameandhtmlForin a.zbtemplate. They are React's names forclassandfor. HTML has neither, so<button className="more">was sent as written, the browser read an attribute nothing uses, and the styling was gone with no message;zubra checksaid "no errors". The compiler now warns at the attribute, withwrite \class`as the help, inzubra check, the editors and the server's log. Not for a child component that declares a prop of that name, and not in a JSX component, where those names are the right ones. (onClickneeds none: attribute names aren't case-sensitive, so it isonclick`.) -
createZubra({ reload: true }): saved components update the open page in place, and the server starter uses it.npm create zubra -- --framework serverrestarts its server on a saved file (node --watch), but the open page stayed as it was until someone reloaded it, where every bundler starter updates on save. Withreload,page.finish()andpage.scripts()add a small script (<prefix>/reload.js, a file, so no policy has to allow it inline) that keeps an event stream to the server open; when the stream is lost and then opens again, the server is back. The script then asks what each of the page's components is now (<prefix>/reload/versions/…), imports the ones that changed, and the runtime swaps each into its live elements, keeping their state, as the bundler starters' hot updates do; a change to anything else (the server's own code, a component's props or events, one that doesn't compile) reloads the page. In the starter a saved template edit shows in about 0.6 s with the counter's count kept. Nothing watches files: the restart is the signal, so a server that doesn't restart doesn't update. Off by default; Node only.- The starter turns it on in development, its error page in development is a page with the same script (so it goes away when the fix is saved), and the counter's comment and the welcome line ("updates in place, keeping its count") are now true of it too.
-
Compared on one app (
docs/compared-on-one-app.md): one slice of an ordering app (live menu, bag, pickup time, checkout, live order page) built twelve ways, in Zubra twice, Lit, Enhance, Stencil, FAST, WebUI, SvelteKit, Next.js and Nuxt, on one backend and one set of browser tests, measured on 5.23.0. Where Zubra is ahead (a tap on a slow phone, pages served, lines of code) and where it is behind (download size, menu load, start-up, memory). Each build's code, the spec, the tests, the measuring script and the raw results are indocs/compared/slice/; the backend they share is not published, so they can be read but not rerun. -
@zubra/unplugin:autoImport, tags without imports. A page can only use a component's tag once something has imported it, so an app with many pages kept a side-effect import in every file or one file listing them all (open.parlor has seven such files, 154 lines).zubra({ autoImport: ['./src/components', '@acme/ui/components'] })names folders of components, the app's or a package's, and a.svelte,.vue,.jsxor.tsxfile that opens one of their tags getsimport '…/tool-bar.zb?element'written for it. A component is known by its host tag, not its file's name; only the tags a file uses are imported, so an unused component stays out of the build; the import goes on a line that is already there, so line numbers don't move. In Vite, Rollup, webpack, esbuild and Rspack. Off by default. Not for Astro pages or Angular. -
createZubra({ compress: true }): the server's files in Brotli or gzip.zubra.handle()andzubra.fetch()sent every file as it is, so the sizes these notes give held only behind a CDN or proxy that compresses: on a plain Node host the browser was sent the runtime's base as 30.5 KB, not 12. Withcompress: truethey answer in Brotli when the request'saccept-encodingtakes it, in gzip when it takes that, and as before otherwise, withvary: accept-encodingeither way. Off by default, so no existing app's responses change;npm create zubra's server app turns it on.- Each file is compressed once and kept: what stays the same until a restart gets the smallest encoding (the base is 11.0 KB in Brotli, 12.0 KB in gzip; Brotli takes about 36 ms for it, once), and what an edit may change in development a quick one. Files under 1 KB go as they are.
- Measured on the comparison's menu page, on a slowed phone over slow 4G: 570 ms to 481 ms to the load event, and 39.4 KB to 21.2 KB sent (20.0 KB in Brotli). On fast 4G, 240 ms to 225 ms.
- Leave it off where something in front compresses already, and at the edge, where the platform does. It covers what Zubra serves under its prefix;
zubra.send(req, res, html)also compresses the page. The app handles its own CSS.
-
buildApp()from@zubra/server/build: the whole app as one module (experimental). A page loaded the runtime, a module per component and each script of its own: four requests on the comparison's menu page, and on a slowed phone the requests, not the work in them, were most of the time between Zubra and the single-file libraries.buildApp({ components, scripts })builds whatbuildRuntime()does and puts every component, the plain modules they import and the page scripts you name into the same module; passed ascreateZubra({ runtime }), it is a page's only script and only preload. On that menu page, CPU slowed six times, thirty interleaved loads: 301 ms to 242 ms to the load event, level with Lit (244), and 12.7 KB in four files to 12.1 KB in one.@zubra/syncis in the module too, where a component or a script of the app's uses it, and the package's own address (/_zubra/sync/index.js) then answers from the module, so a script outside it shares the one store;connect()'s peer-to-peer module stays a file loaded when asked for. On the comparison's build with Sync, thirty interleaved loads, sent in Brotli: 522 ms with the package beside the module (three files, 14.7 KB) to 452 ms with it inside (one file, 13.5 KB); the same page on 5.23.0 was five files and 567 ms in that run.- Every page loads the same module, so it is cached once; it defines every component of the app, whether the page uses it or not.
- A script you name runs on the components' copy of the runtime:
import { effect } from '@zubra/runtime'in it is theirs. - A component added since the build is refused when its page is made, with a message that says to build again. A component's own address (
/_zubra/components/<name>.js) answers with an import of the module, so nothing defines an element twice. - As
buildRuntime(): needs esbuild installed by the app, production only, not at the edge.
Changed
- Sync replay and live queues use bounded memory. The
zubra-syncbinary sends backlog pages as it reads them and closes a live connection that falls more than 16 events behind; clients reconnect from their cursors to recover changes. Presence and signaling are transient.memoryLog({ keep: 'latest' })also indexes the latest values for faster ...
6.0.0-rc.0
A release candidate for 6.0.0, on npm's next tag: npm install @zubra/runtime@next @zubra/compiler@next (and the same for the other packages) tries it, and a plain npm install keeps 5.23. The VS Code extension stays on 5.23.0 until 6.0.0.
6.0.0: Zubra's own reactive engine is the default, and the TC39 Signals API is an experimental mode. Components, templates and the script API don't change, and neither does compiled output: code compiled by 5.18 and later runs on either engine. What changes is only for code that relied on a state being the proposal's object; signals: true keeps 5.x's behaviour for that code. Migrating to 6.0 lists what to look for.
Changed
- The repository is github.com/zubra-js/zubra, and the site zubra-js.github.io/zubra. The old repository address redirects; the old site address doesn't. Update git remotes (
git remote set-url origin https://github.com/zubra-js/zubra) and bookmarks. npm package names, the VS Code extension and the crate's name are unchanged. - Releases can be prereleases.
scripts/bump-version.sh 6.0.0-rc.0sets a prerelease;release.ymlpublishes it to npm undernext, marks its GitHub release as a prerelease, and leaves the VS Code extension and the browser extension on the last release. - The server renders with less than half the allocations, and a large list in about half the time. The lowered tree borrows tag names, attribute names and literal text from the parsed component instead of copying them for every element of every render; a branch's or a list's rows go straight into the list they're part of, not through a list of their own; a text of one part needs no list;
{row.name}in a list of a prop is read where it is (one copy, not two); a comparison with a string literal (type === "money") copies neither side; a request's props are moved into the render, not copied; a list's rows share one scope, their names borrowed, and their keys are checked for duplicates without being written out as text; a script binding that is a prop (const sorted = sortKey ? … : rowswhile there's no sort key) is that prop, not a copy of it; azb-switchcase ((column.type || "text") === "money") compares the side||,??,&&or?:picks where it is; a string method on an ASCII string reads it where it is instead of copying it to UTF-16 first, and+and template literals add to the string they're building instead of copying it; each component a page renders borrows its props' and script's names from the parsed component instead of copying them, and makes an attribute's camelCase name, a prop's kebab-case one, and its spread bookkeeping only when they differ or are used; an element's children are reserved from its template's shape instead of growing; a list inside a list's rows reuses the scope and key set the last one emptied, and reads its items without collecting them first; a call's one or two arguments are kept inline;toFixedrounds in the one string it answers with; names are lowercased only when they have an uppercase letter; andtoFixedrounds from 20 digits more than asked instead of a number's whole 1,100-digit expansion, which it now writes only for a value that rounds to exactly half. The comparison table with 100 orders, per render (native, callgrind and DHAT): 19.5M → 11.0M instructions, 28,406 → 6,328 allocations, 4.4 MB → 1.9 MB allocated; wall-clock 1,653 → about 680 µs (3 orders 99 → about 54 µs; the field and quantity controls, one component each, 158 → 119 and 202 → 158 allocations and about 15% faster). Every.zbfile in the repository renders to the same bytes as before. - The README is an introduction, and the reference is a page of its own (
docs/reference.md). The README was 840 lines and served as both; it is now under 200: what Zubra is, a link to try it in the browser, the command to start an app, one component, who it is for, the packages and where the documentation is. Every section from "Writing a component" to "Standards" moved to the reference unchanged, with the same headings, so on the documentation site its address and anchors are as before. A link to a section of the old README (github.com/…/zubra#the-cli) now lands on the README's top, which links the reference; the skills' links point at the new page. - Hydration reads each marker once. Finding a component's parts in server markup steps over regions (
<?zb [?>to<?zb ]?>), and it read each node's marker two or three times on the way, parsing a comment's text each time. Ten 100-row tables hydrating: 494,710 marker reads to 265,350, and about 9% less script time (CPU slowed 2×). 28 B gzip. - Effects keep half the memory and are made and disposed twice as fast. Each effect kept three arrays of what it read (each with room for about 20 entries on its first push), each signal two of what read it, a closure around the effect's function, and a
Setof its children: for a scope with three effects, 49 objects and 3.8 KB alive. Dependencies and subscribers are now one array each, at their exact size while short; every effect runs through one shared method; an owner's children are a list through the children themselves. The same scope is 27 objects and 1.9 KB, and 1,000 of them are made in 0.65 ms instead of 1.4 and disposed in 0.37 instead of 0.8 (Node,perfmicrobenchmark). On the js-framework-benchmark's script-time profile, replacing 1,000 rows is about 9% faster (35.8 to 32.2 ms, and 34.6 to 31.6 in a second run); the other operations move by a few percent either way, within the noise. About 0.17 KB gzip on the runtime's base. Signals mode is unchanged. - Removing items from a long list is about a quarter faster.
items.splice(i, 1)on a reactive array went through the proxy's traps for every element it shifted, a thousandsets with their bookkeeping for one row of a thousand, and the list then ran its whole keyed pass (every key, three maps, the longest run in order). Nowpush,pop,shift,unshiftandsplicerun on the array itself and re-run only the readers of indexes from the first one they change (and oflengthwhen it moves); they no longer make the effect that calls them depend on the list. A keyedzb-eachsettles the rows that kept their key at either end first, and a removal from one place is done without the general pass. In the js-framework-benchmark's script-time profile, removing 10 rows of 1,000: 39.0 ms to 29.4 ms per cycle; the other operations are unchanged. About 0.3 KB gzip on the runtime's base. @zubra/serverminifies the component modules it sends in production, the CSS in them too. A module went as the compiler writes it, comments, indentation and authors' names included: across the registry's 26 components, 39.5 KB compressed (102.9 KB raw) is now 33.1 KB (75.5 KB raw), 16.4% fewer compressed bytes on every page. The compiler does it, with oxc's mangler and code generator (a new request command,minify; not oxc's whole minifier, which would bring JavaScript imports into the compiler's WebAssembly build), after everything the server changes in a module, and once per module; withbundle, the joined module is minified once, after joining. The CSS loses its comments and the whitespace next to{,},;and,, and nothing else (a space before:, around+or before(can mean something). Development and the DevTools get modules as the compiler writes them, and so doescreateZubra({ minify: false }); with a compiler from before the command, they go as they are. The compiler is larger for it (the native binary 8.1 MB to 8.6 MB).ZUBRA_MINIFY=1runs the runtime's and the registry's browser suites on minified modules, and CI does.- Zubra's own reactive engine is the default; the TC39 Signals API is signals mode, experimental. The model doesn't change: state, computeds and effects, dependencies tracked as they're read, lazy, cached and glitch-free computeds with the equality cut-off, no virtual DOM, setup run once, each binding its own effect. The engine (
runtime/src/signal.js) is one the runtime owns, so how an app updates no longer depends on a Stage 1 API, or on a browser shipping a nativeSignalthat behaves differently. An effect is one node the graph marks directly, where on the API it was a Computed and a Watcher's links to it. In Node, creating and disposing 2,000 effects went from 6.6 ms to 1.5 ms, selecting one row of 1,000 from 0.54 ms to 0.47 ms. What every page of@zubra/serverloads, file by file, went from 16.1 KB to 15.1 KB compressed, and the whole script API from 20.5 KB to 19.5 KB.- What changes for code (none of it for components, templates or the script API):
- A native
globalThis.Signalis no longer used, andisNativeis alwaysfalse. - The runtime's
Signalexport isState,Computedandsubtle.untrack/subtle.currentComputed.new Signal.State(0)andSignal.subtle.untrack(fn)work as before;Signal.subtle.Watcher, the introspection functions and thewatched/unwatchedoptions don't exist. The typings say so. - What
state()andcomputed()return is not an instance of another library'sSignal.State, so it can't be handed to another Signals library as one. Zubra's own bridges (subscribe,toStore, React and VueuseSignal,@zubra/sync) work as before. - The Signals Inspector shows Zubra apps in signals mode only. Zubra DevTools work on both engines.
- A native
- Signals mode:
signals: truein@zubra/unplugin, increateZubra()of@zubra/serverand@zubra/server/edge, and inbuildRuntime()andbuildApp(). Each putssignal-tc39.jswhere the runtime's engine is: the API, native where a browser has it, Zubra's implementation (signal-impl.js) otherwise, as in 5.x.@zubra/serverthen serves the runtime file by file in production too, since its one-file builds hold Zubra's engine. A built runtime must be built with the same option as the server tha...
- What changes for code (none of it for components, templates or the script API):
5.23.0
Added
-
buildRuntime()from@zubra/server/build: an app's own build of the runtime (experimental).@zubra/serverhas no bundler, so the runtime file a page loads holds everything any component might use of it. An app that installs esbuild can now have one built for it: every name its components, the plain modules beside them and@zubra/syncimport from the runtime is collected, and the result is one module with those names and only what they reach.createZubra({ runtime })serves it in production in place of the base and the files beside it; development ignores it. It takes a fraction of a second, soconst runtime = await buildRuntime({ components })when the server starts is enough.- On the comparison's menu app the runtime file goes from 12.0 KB to 10.5 KB compressed (the app has a list on another page, so
zb-eachstays in). On an app that uses context, form controls, event modifiers, shadow roots andresource(): one file of 12.1 KB where a page loaded seven, 18.4 KB. - A component that names something the build doesn't have (added since it was built) is refused when it is compiled, with a message that says to build again; it never reaches the browser half-working.
keep: ['watch']adds names for a<script type="module">of your own. - While a built runtime is served, the runtime's own files answer with a module that throws and says why: loaded beside it they would be a second copy, with signals the first can't see.
- Not at the edge, not with
imports['@zubra/runtime'], and not for components compiled by Zubra 5.19 or older. esbuild is an optional peer: nothing changes for an app that doesn't install it.
- On the comparison's menu app the runtime file goes from 12.0 KB to 10.5 KB compressed (the app has a list on another page, so
-
--emit elementprovidesonFormReset,onFormRestoreandonFormDisabled(#367). A plain element hadformValueandvalidity, half of the form-associated API, and refused the other half, so a control that wanted to hear a disabled<fieldset>couldn't be a plain element (zubra-ui'stoggle-switchworked around it with adisabledprop). The three hooks are now the class'sformResetCallback,formStateRestoreCallback(state, mode)andformDisabledCallback(disabled), written only for a component whose script asks for them. As with the runtime, a script's ownonFormResetis the reset, in place of a single two-way prop going back to what it started as, and a control disabled before its script ran hears it once it has.zubra convertreads the hooks back. One difference from--emit js: in a component withoutform-associated, where the browser would never call them, the compiler says so ("onFormDisabled()needs form-associated on the component's host tag") where the runtime throws when the element starts.
Changed
- The Preact example (
examples/frameworks/preact-habits) is on Preact 11.2.0, from 10.29.8, so the framework tests run against the Preact people install today. The example passes unchanged. It has no keyed list inside a component's slot, so what guardsmoveBefore()on a host (below) is the runtime's own browser test, not this example. The Preact starter (npm create zubra -- --framework preact) still asks for^10.29.8.
Fixed
@zubra/server's types havepackagesandimports(#375).createZubratook both, the guide documentspackages("Components from a package") and the tests use both, andZubraOptionshad neither, so a TypeScript server that followed the guide didn't compile: "'packages' does not exist in type 'ZubraOptions'". A test now compares the options the function reads with the ones the type declares.- A
.zbimport in a.sveltefile is the element, in any project (#377). In a Vite app whose framework is React or Vue, a Svelte file's import fell through to the project's wrapper: a React component Svelte can't render, or, for a bareimport './x.zb', the wrapper and its adapter loaded for nothing. Svelte renders custom elements directly, so its files now get the element class whatever the project around them, as a.vuefile gets the Vue component in a React app.?reactor?vueon the import still picks a wrapper. Found in open.parlor's Svelte editors inside its React app, which had to import with?element. - A light-DOM host routes
moveBefore()to its slots, so Preact 11 can reorder slotted children (#370). Frameworks manage an element's children through the host, and the host passedinsertBefore,appendChild,removeChildand the rest on to its slots, but notmoveBefore. Preact 11 reorders keyed children withmoveBefore()where the browser has it (Chromium and Firefox), so reversing a keyed list inside a component threw "The node before which the new node is to be inserted is not a child of this node" and the list kept its old order.host.moveBefore(node, before)now places the node asinsertBeforedoes, and a node already in its slot is moved there with its state kept. It is defined only where the browser has the method, since frameworks ask for it by name. The same in--emit elementoutput, whose own helper for moving a row now calls the platform'smoveBeforeand not one a host overrides. Found by open.parlor's conformance suite on Preact 11.2;examples/frameworkspinned Preact 10, which only usesinsertBefore.
5.22.0
Changed
- A page of
@zubra/serverloads less of the runtime: its base, and only the rest its components name. The file every page loaded in production (runtime/zubra.js) carried the whole script API, used or not: 14.3 KB compressed. It is now the base, 11.7 KB, and what only some components use is in files beside it, each sent to the pages whose components name it: context (provide.js, 0.85 KB), form controls and their helpers (form.js, 1.2), event modifiers and helpers (modifiers.js, 1.1), shadow roots (shadow.js, 0.6) andresource()(resource.js, 0.65). A page that uses none loads 2.6 KB less; one that uses event modifiers about 1.5 KB less, in one more request (preloaded, so not another round). The server sends each module the names it imports from the file that has them, by address, as it already did forzb-awaitand slots; that covers components, the plain modules they import and@zubra/sync's.- Nothing to change in an app. The script API is the same, from the same import (
@zubra/runtime);@zubra/runtime/coreexports what it did; bundlers and@zubra/unpluginare untouched. - A
<script type="module">of your own that imports@zubra/runtimegets the whole API as before, from the same modules the components use, now as the base and five small files where it was one. - With
imports: { '@zubra/runtime': … }(a CDN) nothing changes: every name comes from the address you gave. - A server from before this release with this runtime is unaffected:
dist/bundledis still whole, and the split build is a folder of its own (dist/split). - At the edge, serve
dist/splitwhere you serveddist/bundled(which still works, without the saving). Pages using@zubra/syncfrom static assets load the whole API there, since the Worker can't rewrite files it doesn't serve. - In the runtime, the helpers moved out of
element.jsintoprovide.js,form.jsandmodifiers.js, andbase.jsis the new smaller entry;@zubra/runtime/modulesgainedsplit.
- Nothing to change in an app. The script API is the same, from the same import (
5.21.1
Changed
@zubra/actionsserves its browser scripts minified in production.actions.script()'s module and the form script (/_zb/enhance-forms.js) were sent as written, comments included: 1.34 KB and 1.85 KB compressed. In production (NODE_ENV=production, orcreateActions({ production: true })) they now come from the package'sdist/production: 0.78 KB and 1.04 KB. Development serves the source as before. Found by Potomac's comparison, where the form script added more to the menu page thanfollow()took off. At the edge, servedist/production/client.jsanddist/production/enhance-forms.jsfrom your static assets, or pass their text asclientandforms.
5.21.0
Added
- Plain form posts without the reload:
data-zb-updatesand@zubra/actions/enhance-forms(experimental). A form that posts to an app's own route and is redirected back loaded the whole page again. A form that names the parts of the page its post changes,<form method="post" action="/add" data-zb-updates="site said">, is now sent withfetch, and those parts' children come from the page the server redirects to; the rest of the page, components and typed input included, stays. The server is unchanged, and so is every form without the attribute.actions.formsScript()writes the script tag andcreateActionsserves it at/_zb/enhance-forms.js(0.9 KB compressed). On the comparison's menu page on a slow phone, adding an item took 264 ms, from 525. follow()from@zubra/sync/follow: a connection for a page that only reads (experimental). A page whose server writes its documents and never lets a page write loadedconnect()'s outbox, pushes, presence and peer code for nothing.follow()pulls and listens exactly asconnect()does (the same cursor, scope, merge by clock and reconnecting, tested against the same cases) and has none of the rest: 3.5 KB compressed against 4.9 on a read-only menu page. An edit on such a page stays on that device and is reported once in the console.connect()and every existing page are unchanged.@zubra/servermaps and serves it besideconnect.js.
Fixed
- The server starter (
npm create zubra -- --framework server): an edited'use server'function now applies without restarting by hand, and errors are 500s that say why.npm run devrestarted only forserver.js, and@zubra/actionsloads server functions once at start, so an edit to one did nothing until the server was stopped and started; a component broken at start left the server down after the fix was saved. The script now restarts for anything insrc/as well (data kept in memory starts over with it). An error while rendering the page was sent with status 200 and the words "Something went wrong"; it is now a 500, and in development the page shows the compiler's message (file, line, suggested fix) that the terminal shows. New apps only: an existing app can copy thedevscript and thetryblock from the template.