{"version":"v1.0","client_state":{"DocsNavigation.default":{"fields":{"query":""},"persist":"memory","send_to_server":true},"ColorScheme.default":{"fields":{"mode":"system"},"persist":"local","send_to_server":true}},"endpoints":{"action":"/_bretzel/action","sse":"/_bretzel/sse","refetch":"/_bretzel/refetch"},"csrf":"a3703b46e137da252608f9f81731e37e","page_id":"ee3533d7ae964f46b453a24979e25077","address":""}

The client runtime

The server stays the source of truth, but something runs in the browser: a home-made engine, with no npm and no third-party reactive framework. This page says what it guarantees, then enumerates its vocabulary.

You do not write this

In a Bretzel app, the `bz-*` directives are emitted by the components: passing `visible=binding` produces a `bz-show`, `value=binding` produces a `bz-model`. This page is the emergency exit — what one reads to understand what was emitted, or to write by hand the case the components do not cover.

The three guarantees

A client runtime is judged on what it promises when the server rewrites the page under its feet.
GuaranteeThe mechanism
A client state survives a server refreshEvery scope is keyed by bz-id. After a morph, the subtree is re-scanned: the bindings are thrown away then rewired, and the effects restore what the morph overwrote (text, display, value, classes).
No round trip just to display somethingA client binding compiles into a JS expression evaluated in the browser. Showing, hiding, computing a class: nothing goes over the network.
The transport boundary is the runtime'sA component never POSTs. It declares a handler; the bridge adds the HMAC signature, the CSRF token, the protocol headers and the client-state snapshot.

What the runtime weighs

The bundle is concatenated from `_src/` and the `.js` beside each component, with no bundler and no minifier — the file served is the one you debug. The load order is declared in `runtime/sources.py`.
31 modulescore: 8 files, 4815 linesbundle : 517 KB
core8
FileRoleLines
index.jsbootstrap + window.$bz wiring.558
signals.jsreactive primitives : signal / effect / computed.158
directives.jsthe 13 bz-* directives + the binding engine.991
scope.jsbz-data component-scoped state, keyed by bz-id.310
persistence.jskeeps a ClientState's fields in browser storage.71
bridge.jsHTMX glue : signal snapshot out, <bz-patch> in.1283
helpers.jsshared helpers for overlay-class components.983
locale.jsmonth and weekday names, derived from the language.461
component engine23
FileRoleLines
calendar.js<bz-calendar> custom element (stateful day grid).943
attachments.js$bz.attachments.makeScope, the engine of ui.attachments615
notification.jstoast stack manager (bz-data scope factory).131
charts.jsshared chart tooltip + legend scope factories.346
number_input.jsshared scope for the NumberInput component.141
slider.jsshared scope for the Slider component.122
select.jsshared scopes for the Select component.101
combobox.jsshared scopes for the Combobox component.278
tags_input.jsthe scope of ``ui.tags_input``.161
pagination.jsthe Pagination component's shared scope.135
accordion.jsthe shared scopes of Accordion, Tree, Tabs and280
carousel.jsthe Carousel component's shared scope.238
time_picker.jsthe TimePicker component's shared scope.214
dnd.jsthe node-DnD gesture shared by `dropzone` / `draggable`.765
resizable.jsthe shared scope of the Resizable component (split panes).436
signature_pad.jsthe SignaturePad component's shared scope.300
verbs.jsthe CLIENT half of `bretzel.runtime.verbs`.129
diagram.jsthe highlighting of neighbours, in `ui.diagram`.130
scheduler.jsdragging a `ui.scheduler` card to another time,511
tip.jsthe ONE tooltip panel of the page, and the service that shows it.286
message_input.jswhat ``ui.message_input`` does in the browser.228
editor.jsthe browser part of ``ui.editor``.665
message_list.js``ui.message_list`` follows its newest message.91

The directives

Grouped by what they guarantee. The vocabulary has two halves — a Python constant declares it, a JS module wires it — and the runtime cannot import Python. A gate already checks that at commit time (test_python_js_mirror.py); this table shows it, one notch stricter: comments stripped, and per source module.
DOM structure4
Written into the HTMLWhat it guaranteesDeclared by
bz-data="{ open: false }"Opens a local scope, keyed by bz-id — it SURVIVES the morph of a server refresh. Inside a scope method, write this.field.BZ_DATA_PREFIX — component-local scope declaration
bz-for="v in liste :key=v.id :flip"Keyed iteration over a single-root <template>. :key reuses the nodes; :flip animates the reflow of the rows that survive.BZ_FOR_PREFIX — keyed client-side iteration
bz-if="expr"Really mounts / unmounts the subtree. Every mount starts from a fresh tree.BZ_IF_PREFIX — mount/unmount conditional
bz-teleport="body"Projects the content elsewhere in the DOM; the scope stays resolved at the original place. Re-projects if the source changed.BZ_TELEPORT_PREFIX — render at another DOM location
reactive display4
Written into the HTMLWhat it guaranteesDeclared by
bz-attr:aria-expanded="open"A one-way reactive attribute. false/null/undefined remove the attribute; on a native form field, the property is updated too (otherwise a morph would empty the input).BZ_ATTR_PREFIX — generic one-way attribute bind
bz-class="{ actif: open }"Adds / removes classes by truthiness. The static class= rendered by the server is a baseline that is never removable.BZ_CLASS_PREFIX — class object/array bind
bz-show="expr"Toggles display. The element stays mounted (hence stays in the DOM for focus, measurement, tests).BZ_SHOW_PREFIX — display:none toggle (stays mounted)
bz-text="expr"textContent follows the value. Display only.BZ_TEXT_PREFIX — textContent (display-only)
two-way input1
Written into the HTMLWhat it guaranteesDeclared by
bz-model="$bz.state.Form.default.email"Two-way binding, form controls only.BZ_MODEL_PREFIX — two-way binding on form inputs
user gesture1
Written into the HTMLWhat it guaranteesDeclared by
bz-on:click="open = !open"Listens for an event. An element marked aria-disabled STARTS no interaction: activation events are ignored, the others pass (closing stays possible).BZ_ON_PREFIX — event handler (client-only)
the node's lifecycle3
Written into the HTMLWhat it guaranteesDeclared by
bz-effect="void geom"A continuous reactive effect: replayed on every mutation of a signal it reads.BZ_EFFECT_PREFIX — continuous reactive effect
bz-init="setup()"Once only, at the node's first mount — and not replayed by a re-bind after a morph.BZ_INIT_PREFIX — one-shot on-mount hook
bz-ref="track"Names the node in $refs. Registered across the whole tree BEFORE any binding, so a parent bz-init sees a child ref.BZ_REF_PREFIX — named DOM reference
Wiring order on a single elementref → model → attr → class → text → show → on → effect → initRead from the engine. It is not cosmetic: bz-ref is wired first (a neighbour can read it), bz-init last (the node is fully wired when it runs).

Inside an expression

A directive expression is compiled once then cached. The current scope is on the scope chain — a bare name reads the scope — and a few variables are injected.
scope1
VariableContents
$scopeThe current bz-data scope. It is on the scope chain too, so a bare name reads it.
the node2
VariableContents
$elThe element carrying the directive.
$refsThe nodes named by bz-ref in this scope.
the event2
VariableContents
$eventThe DOM event — inside a bz-on: only.
$valueThe value written — inside a bz-model only.
act2
VariableContents
$dispatch$dispatch(name, detail) — a CustomEvent bubbling up from $el.
$nextTick$nextTick(fn) — after the signal flush, hence after the DOM has been rewritten.
{ open: false, pick(v) { this.open = false; } }
The trap: the rebinding of bare names holds for inline expressions, not for a scope's methods. Inside a method it is `this.field` — without the `this`, you create a global.

The $bz surface

The global object, read module by module. The scope factories are what a component spreads into its `bz-data`; the rest is the engine. The “exposes” column is read from the JS literal, never copied by hand.
reactivity3
NameWhat it isExposesDefined in
$bz.computedcomputed(fn) → {get, peek, dispose}. A memoised derivation, recomputed when a dependency moves.—signals.js
$bz.effecteffect(fn) → {dispose}. Runs straight away, runs again when a signal it read changes. The writes of a single tick are merged into one re-execution.—signals.js
$bz.signalsignal(init) → {get, set, peek, subscribe}. get() subscribes the current effect, peek() reads without subscribing, set() triggers nothing if the value is identical.—signals.js
state & transport4
NameWhat it isExposesDefined in
$bz.notifyPushes a toast onto the notification stack.—index.js
$bz.pendingpending(element|action_id, delay_ms) → the “an action is in flight” signal. An element walks up to the carrier of its hx-post; a string addresses the action from elsewhere in the page. The delay is what avoids the flash on short round trips. On the Python side: ``ui.pending()``.—bridge.js
$bz.state$bz.state.<Class>.<key>.<field> — the signal of a client-state field, materialised at boot from the envelope.—index.js
$bz.versionThe bundle's protocol version.—index.js
shared helpers11
NameWhat it isExposesDefined in
$bz.datesThe one date reader of the pickers: ``typed(text)`` reads a typed date in the page language's order (22/11/2026 is November 22nd in French), ``typedWeek``, and local-time ``iso`` / ``addDays`` / ``addMonths`` / ``weekStartOf``.iso, fromIso, addDays, addMonths, weekStartOf, typed, typedMonth, shown, shownMonth, shownWeek, shownLong, axis, pattern, patternMonth, typedWeeklocale.js
$bz.foldThe one form a search compares: lowercase, no accents, ``ß`` as ``ss`` — twin of Python's ``bretzel.core.text.fold``, used by the combobox, ``filter_each`` and the datatable.—locale.js
$bz.helpersThe bricks shared by the overlays and by the pointer-drag family.escapeHtml, focusTrap, focusIn, blurIn, autofocusMounted, autofocusOpen, pageGivesFocus, escapeKey, onWindow, pushUrl, urlParam, scrollLock, clickOutside, floating, prefersReducedMotion, emitChange, capturePointer, releasePointerhelpers.js
$bz.localeThe month and day names, derived from ``<html lang>`` by ``Intl``. Python cannot produce them: its ``locale`` module is process-global state.tag, monthNames, monthName, weekdayNames, weekdayLongNames, iflocale.js
$bz.multiSelectThe membership algebra of a multiple selection, shared by Select and Combobox._picked, _isPicked, _hasPicked, _togglePick, _removeOne, _pick, _setValue, _clearAll, if, while, forhelpers.js
$bz.numPure numeric primitives: precision implied by a step.precisionFromStep, cachedPrecisionhelpers.js
$bz.partsThe parts a page carries once — a calendar picker's header, a colour picker's palette: ``fill(host)`` clones the ``<template data-bz-part>`` the host names into it.if, requestAnimationFramehelpers.js
$bz.reportErrorHow the runtime reports an error it contains — a directive or an effect that throws: ``console.error`` naming what failed, then ``window.reportError``, so whoever listens for uncaught errors still hears it. The rest of the page goes on.—signals.js
$bz.timesThe one clock: ``shown(hhmm)`` writes an "HH:MM" as the page language does (« 14h30 » in French, « 2:30 PM » in American English), ``typed(text)`` reads it back, ``pattern()`` is the empty field's hint, ``twelve()`` says whether the language counts its hours by twelve. Used by the time picker and the scheduler.—locale.js
$bz.tipThe page's one tooltip panel: ``open(anchor, opts)`` / ``close()``. Every ``tooltip=`` shows it, and so do the collapsed sidebar rail and the charts.—tip.js
$bz.verbsThe client half of the VERBS (``bretzel.copy`` …): a browser action triggered from an ``on_*=``. Only ``copy`` lives there — ``print`` and ``fullscreen`` fit in an expression Python writes out in full. It carries the fallback outside a secure context, without which an internal tool served over ``http://`` on a local IP would copy nothing, in silence.share, vibrate, copyverbs.js
gesture engine3
NameWhat it isExposesDefined in
$bz.dndThe Pointer Events drag-and-drop engine, shared by draggable and dropzone.MOUSE_THRESHOLD_PX, TOUCH_HOLD_MS, TOUCH_TOLERANCE_PX, _state, _axisOf, _accepts, _canEnter, _indexOfdnd.js
$bz.gestureThe pointer gesture rules shared by drag-and-drop and the scheduler: when a press becomes a drag, the end-of-drag click swallowed, a dropped item that waits while the server asks.MOUSE_THRESHOLD_PX, TOUCH_HOLD_MS, TOUCH_TOLERANCE_PX, SWALLOW_MS, distance, swallowClick, afterTwoFrames, whenAnswered, _inFlight, if, clearTimeouthelpers.js
$bz.schedulerDragging a scheduler card to another time and pulling its bottom edge; the card waits while a dialog asks.THRESHOLD_PX, SWALLOW_MS, _state, _isoscheduler.js
component scope19
NameWhat it isExposesDefined in
$bz.accordionA scope factory, spread into the component's bz-data.single, multiaccordion.js
$bz.attachmentsA scope factory, spread into the component's bz-data.makeScopeattachments.js
$bz.carouselA scope factory, spread into the component's bz-data.scopecarousel.js
$bz.chartsA scope factory, spread into the component's bz-data.tooltipScope, lineScope, scatterScope, barScope, hidecharts.js
$bz.comboboxA scope factory, spread into the component's bz-data.fitPills, observeFit, optionOf, paintOptions, common, single, multicombobox.js
$bz.diagramA scope factory, spread into the component's bz-data.scopediagram.js
$bz.editorA scope factory, spread into the component's bz-data.scopeeditor.js
$bz.notificationA scope factory, spread into the component's bz-data.—notification.js
$bz.numberInputA scope factory, spread into the component's bz-data.scopenumber_input.js
$bz.paginationA scope factory, spread into the component's bz-data.scopepagination.js
$bz.resizableA scope factory, spread into the component's bz-data.scoperesizable.js
$bz.selectA scope factory, spread into the component's bz-data.single, multiselect.js
$bz.signaturePadA scope factory, spread into the component's bz-data.scopesignature_pad.js
$bz.sliderA scope factory, spread into the component's bz-data.scopeslider.js
$bz.stepperA scope factory, spread into the component's bz-data.scopeaccordion.js
$bz.tabsA scope factory, spread into the component's bz-data.scopeaccordion.js
$bz.tagsInputA scope factory, spread into the component's bz-data.scopetags_input.js
$bz.timeA scope factory, spread into the component's bz-data.scope, filltime_picker.js
$bz.treeA scope factory, spread into the component's bz-data.scopeaccordion.js