Lango Client
A browser runtime for applications built with Lango UI. Application handlers run
on the server. The client renders control definitions, collects form values, sends
requests, and applies responses. Runtime, build tools, and tests are written in
Lango. dist/ contains compiled application modules and separately licensed
third-party browser modules under vendor/.
This is the first implementation of the new client contract. It is not yet a
complete renderer for the Lango UI control catalog.
Build and test
Node.js 24 or newer is required.
npm install
npm test
npm run browser:install
npm run test:browser
Browser installation uses .test-output/browsers inside this project. Browser
tests start a temporary local HTTP server and launch headless Chromium. They do
not use any other Lango Client checkout.
npm run build writes a static application to dist/, including the module
runtime, Bootstrap 5 CSS, Markdown/date-picker dependencies and their licenses, the HTML shell,
and the entry module.
Configure the application's static server to serve this directory at /, or
copy its entire contents, including .lango/ and vendor/, into the public
directory. The static shell includes an import map for marked, dompurify and flatpickr;
keep it when embedding this build in a custom HTML shell. Bundlers may instead
resolve these npm dependencies directly. No CDN is used.
Keep POST / available for Lango UI startup and provide a UI endpoint at
/index. Build output must be served over HTTP rather than opened as a file.
GET / serves the unchanged HTML shell. Its entry module sends POST /, saves
the opaque response token, and requests POST /index. On a deep link, the client
requests the initial pathname instead. A host must explicitly serve the HTML
shell for those deep-link GETs. Lango Server 0.2.0 supports the explicit
fallback="index.html" runtime="true" static settings used by the generated
application. Without fallback configuration, missing paths still return 404.
Create an application
To create a server-side Lango UI application with this browser runtime, use the
UI package's generator after the delivery releases are published:
npm exec --package=@lango-project/lango-ui@0.4.0 -- create-lango-ui my-app
cd my-app
npm install
npm test
npm run dev
Open http://127.0.0.1:3000/ or /profile. Application handlers live in
src/handlers.lango, with routes.xml and deploy.xml selecting the npm exports
and hosting settings. The browser remains a consumer of server control
instructions. Rebuild/restart after changing the application source.
For an existing application that only needs the static browser assets:
npm exec --package=@lango-project/lango-client@0.4.0 -- lango-client ./public
The first phase supports same-origin Web/Bootstrap. The destination must be
empty. --update explicitly refreshes generated assets in an existing directory;
use a dedicated output directory when maintaining a custom HTML shell. The
command preserves the complete runtime and vendor trees; it does not generate
business handlers or install dependencies. Keep private keys outside this output.
npm run test:starter in this checkout tests delivery using sibling lango-ui,
lango-server and lango-js checkouts (or LANGO_STARTER_UI,
LANGO_STARTER_SERVER, LANGO_STARTER_COMPILER paths). It builds and packs them,
installs the packed generator without a compiler, generates an app, installs and
tests/builds it, verifies a stable local key, removes development dependencies,
and exercises the actual server/UI/browser pipeline in Chromium. Offline installs
use the dependency cache populated by installing the source repositories. No
registry publish or existing user application is involved.
Implemented behavior
- Startup restores the most recently saved token and sends it unchanged.
- Every form owns its current token. New child forms inherit the creating
form's token; later responses update only the receiving form. Tokens are never
decoded in the client. Storage errors do not prevent in-memory operation.
- Named controls contribute values, including
null for buttons and other
controls without values. Named child forms contribute nested maps.
inheritedNames reads and writes through to the parent form.
- A form and its ancestors/descendants serialize sends. Unrelated forms may send
concurrently. Queued sends collect values and read the current token when
they actually start. Failed requests are not automatically repeated.
- Responses update the token first, then replace the view, then execute ordered
commands. Partial value updates preserve unspecified controls and do not emit
DOM change events.
- Ordinary same-origin links use client navigation. Modified clicks, downloads,
external links, and links targeting another browsing context keep browser
behavior. Back and forward request the page again.
values, invalid, set, disable, enable, changeCaption, redirect, and setUrl
commands are implemented. setUrl changes history without fetching a view;
redirect requests the target after the current response finishes.
- A sending form has a waiting indicator, blur, and
aria-busy state.
- Forms dispose child controls and registered resources when removed. Failed
control construction preserves the previous view and its control registry.
The Bootstrap renderer supports form, container, row, col, text,
button, value, input, checkbox, switch, select, radio, range,
alert, progress, toast, and toastStack. Dialog definitions are opened
through showDialog.
Fields use separate Lango classes and have visible associated labels and
descriptions. Supported value semantics:
| Control |
Value |
| Input, text-like variants |
String; empty input returns an empty string |
Input String |
Alias for the text variant; lines > 1 creates a textarea |
Input Number |
JavaScript number, or null when empty/invalid |
Input Decimal / Money |
Exact text, with a decimal input hint; no float conversion |
| Checkbox |
Boolean, or null while indeterminate |
| Switch |
Boolean; an unset/null value becomes false |
| Range |
Native numeric slider value, with min/max/steps |
| Select / Radio |
The option's original JSON value, or null when unselected |
Select and Radio support structured JSON option values, compared by structure
and primitive type. Radio also supports selectedIndex when no value is
supplied, and respects each option's enabled flag. Readonly controls that have
no native readonly mode stay disabled even after an enable command.
Input url sends its owning form after 500 ms without another input event.
Programmatic values updates emit no events and create no request. Disposing
the input cancels its pending debounce and removes its listeners.
Date ranges, single-file JSON uploads, OTP and explicit numeric format settings
are implemented as described below. Advanced decorative options remain open.
Unsupported control types and input variants fail explicitly. Decimal/Money
without a format map retain their existing plain-text behavior.
Validation and form content replacement
invalid(name, message) resolves slash-separated names and presents plain-text
feedback. Fields receive an invalid style, aria-invalid, and an additional
aria-describedby reference while retaining their description. Before a queued
send actually starts, the sending form clears errors on the named controls
included in its value tree, child forms and inherited value sources. Unrelated errors remain visible.
set(name, control) replaces the contents of a named Form, preserving that
Form's identity and token. A Form definition replaces its content directly; any
other control becomes its new content. Remaining commands, including the final
values command, address the new controls. Successful replacement disposes old
controls and form resources. Failed construction preserves the previous DOM,
registry, inherited names and resources, and disposes the failed candidate.
App-wide navigation listeners survive form content changes and are released
only when the application is disposed.
Alerts, Toasts, Dialogs and Progress
showAlert({ name?, message, theme?, place?, closeButton? }) accepts literal
text, a control definition or an array of text/control definitions.
The default is a dismissible alert at the start of the sending form. A placement
map uses { name: "email", position: "before" }; position may also be after
or inside. Paths resolve against the sending form. A named alert replaces the
existing alert with that name; malformed replacements preserve the old alert.
dismissAlert(name) is idempotent for an absent alert. Closing unregisters the
control and all controls owned by its message. Named message controls belong
to the sending Form, while explicit nested Forms keep their own value/token
scopes. Replacing an alert may reuse its previous content names; collisions
with unrelated controls are rejected. A replacement cannot be anchored inside
the content it will remove. Alerts positioned in another form's subtree also close when that
subtree is replaced, without leaving a stale name in the originating form.
showToast(toast, stack = null) displays a Toast definition. A named ToastStack
is resolved by path; otherwise a form-owned corner region is created. Toast
header/body accept text or control definitions, including explicit Forms. A
named Toast can be addressed through its stack and content names, for example
notifications/saved/editor/value. Toasts themselves contribute null rather
than their internal Form values to the owner's payload. Explicit Forms inside
Toast content send their own values and may use inherited names from the owning
application form; internal presentation scopes are skipped for inheritance.
instant: true closes the Toast after five seconds. False or omitted leaves it
open until dismissal or owner replacement. Default position is bottom-right;
positions combine top/middle/bottom with left/center/right. Header/body
text is never treated as HTML. Close listeners, nested Forms and the auto-close
timer are disposed together. Button.dismiss closes its containing Toast or
Dialog; with a URL it dismisses only after that form send succeeds.
showDialog(dialog, keepPrev = false) uses a native HTML dialog with Bootstrap
content styling. Each Dialog has its own Form/token scope inherited from the
request that creates it. A root body Form supplies its controls and inherited
names; footer controls share that scope. The namespace is the Dialog's name,
or the root body Form's name when omitted, allowing a following values command
such as editor/name. Titles accept text or a Text definition; body/footer may
contain controls. Supported sizes are sm, lg, xl and fullscreen, with
optional dark, scrollable and backdrop-blur flags.
With keepPrev: true, the previous Dialog remains alive with its values,
validation, focus, resources and token. Only the active Dialog appears in the
owner's named value tree. At most the current and one previous Dialog are kept;
a subsequent retained Dialog disposes the older saved one. swapDialog()
exchanges those two without reconstruction. Native modality handles focus
trapping and Escape; a saved focus is restored when possible.
showDialog(null) closes the addressed/current Dialog and restores the saved
one when present. Programmatic closure and owner replacement do not invoke
closeUrl. User dismissal invokes that optional URL once using the Dialog's
values and current token, then closes after success. Repeated dismissal while
the request is pending is ignored. Failure keeps the Dialog open for an explicit
retry. New Dialog construction failures leave the active Dialog intact. Parent
view replacement or disposal closes both active and saved windows and resources.
setProgress(name, min, max, value = null) requires a numeric range with max
greater than min. Values are visually clamped; null is indeterminate and omits
aria-valuenow. updateProgress(name, value, label = null) preserves the range
and changes an optional application-supplied text label. The label stays visible
at zero and is exposed through aria-valuetext. Min/max/now ARIA values,
bar width, theme and stripe flags are updated without adding a form value. An
invalid range fails before changing the existing bar.
Per-token keepalive
The client tracks successful response times per opaque token string. An active
form cannot postpone another form's renewal. One app timer follows the earliest
60-second deadline; equal token strings are sent once and their replacements
update every live form still holding that string. Disposed forms do not
participate, and stale results cannot overwrite a subsequently changed token.
Before Ping, current sends finish and new sends remain queued. Due tokens are
recomputed after those sends finish. Batches contain at most 64 tokens and use
the most recently refreshed live token as the Bearer credential. A batch returns
individual replacement tokens and statuses; JWT contents are never decoded.
Failed entries retain their tokens and wait until the next scheduled minute.
Business requests are never automatically replayed. Application disposal
cancels the timer.
Timers and longpoll subscriptions
setTimer(url, interval) schedules one form send; setInterval(url, interval)
schedules repeated form sends. Delays are positive milliseconds within the
native timer range. A new command replaces the timer of the same kind and URL
in that form. Timer and interval registries are separate. clearTimer and
clearInterval are idempotent. Intervals schedule their next tick after the
previous request settles, avoiding overlapping sends and queued tick backlogs.
Each tick collects current form values and uses the current token.
Form replacement/disposal cancels timers, queued resource sends and pending
longpoll HTTP requests. Replies from stopped resources cannot modify the form.
An ordinary resource request that already reached the server may finish there;
the client cannot undo application side effects and never automatically retries
that business operation.
startLongPoll(url, key, cursor = null) starts one subscription per URL/key pair
in the form. Repeating a start without a cursor keeps a live subscription; an
explicit cursor replaces it. stopLongPoll(url, key) is idempotent. Poll requests
send only { key, cursor }, not form values, with the form's Bearer token.
Held HTTP polls run outside the form send queue. Before a related ordinary send
or report, the client aborts the pending poll; Ping aborts all held polls. Polls
resume after those operations with the latest token and successfully applied
cursor. Responses from an aborted generation are discarded. Successful poll
responses enter the normal form queue, so message application cannot race form
sends or Ping. Each message's data is a UI response map (view and/or cmds).
Messages apply in order. The cursor advances only after successful application;
the last 256 applied message IDs also suppress recent duplicate deliveries.
A bad message stops the subscription and reports a technical failure.
Empty successful responses immediately start the next poll. Network/503/429
failures reconnect with 1–30 second exponential backoff; a numeric Retry-After
can extend the delay up to 60 seconds. Authentication and other terminal HTTP
failures stop the subscription. These reconnects repeat transport reads, not
application form operations.