LuxelEspañol

Luxel v0.1 · Guide

Tooling

Luxel has four command-line tools: luxel (build, check, dev), luxel-host (the server), create-luxel (new apps), and the repository script npm run pack:local.

All of them exit with 0 on success, 1 on errors, and 2 on a usage error.

luxel build

luxel build [--json] [--root ‹dir>]

Compiles the project described by luxel.config.ts (in --root, default the current directory). For each view in src/views/*.view.tsx it writes the template, the slot map and the manifest, and it writes the server-only outputs: the event contract, the generated handler types (.luxel/server.ts) and the bundled handlers (.luxel/events.mjs). Outputs go to outDir.

Diagnostics are printed as text:

src/views/e001-onclick.view.tsx:8:7 - error LUXEL-E001 (no-function-handler): "onClick" on ‹Action> is a function. … 8 | ‹Action id="pay" event="transfer.submit" onClick={pay}>Pagar‹/Action> | ^ suggestion: Logic runs on the server: use ‹Action event="..."> and handle the event with defineEvent. …

With --json, for tools and AI agents:

{ "ok": false, "errors": 1, "warnings": 0, "diagnostics": [ { "code": "LUXEL-E001", "severity": "error", "file": "src/views/e001-onclick.view.tsx", "line": 8, "column": 7, "rule": "no-function-handler", "message": "…", "suggestion": "…" } ], "outputs": {} }

file is relative to the project, line and column are 1-based, and codes are stable: a code is never renumbered or reused. The full list is in the diagnostic catalog.

luxel check

luxel check [--json] [--root ‹dir>] [--out ‹dir>] [--surface ‹file.json>]

Runs the policies of luxel.config.ts (policies) over the built output: the JavaScript budget, ASEF = 0, collection and page limits, payload size, allowed events and components, exposure of secrets and server names, and the data class of public views. It finds the build where luxel.config.json is (the project or dist/), or in --out. Run luxel build first.

  • Text output lists each policy with its verdict and a final luxel check: ok or failed.
  • --json prints { ok, diagnostics, policies, pages }.
  • --surface ‹file.json> also checks a dynamic surface (UI proposed at run time) before projection.

Policies that need a measurement (initialTransferKiB, scalability) are reported as NOT VERIFIABLE STATICALLY (LUXEL-W002), with a static lower bound where one exists.

The same checks are a library: checkProject and checkSurface from @luxel-framework/check.

The template's npm run build is luxel build && luxel check.

luxel test (preview)

luxel test [files…] [--mutate-bindings [--jobs ‹n>] [--mutant-timeout ‹ms>]] [--json] [--root ‹dir>]

Runs the app's screen tests (tests/**/*.test.mjs) against the built app, without a browser: the real host on loopback, the runtime's own core, and a page model in place of the DOM. It does not compile; it refuses a missing build and a build older than a source file. --mutate-bindings removes each bound zone of each compiled view in turn (from the served page and the manifest the page is built from; nothing is rebuilt) and reports the zones no test would miss, and the zones whose run could not be evaluated. The runs are one at a time unless --jobs says otherwise, and the unchanged suite has to pass before and after them. It does not run with LUXEL_ENV=production. See Testing screens; this command is Sprint 12.3 work and not frozen.

luxel dev

luxel dev [--port ‹n>] [--root ‹dir>]

Builds, serves on http://localhost:4321 (or --port, or PORT), rebuilds on save and reloads the page.

  • Recompiles only what changed. A view whose inputs, config and contract are unchanged is reused. The handlers are bundled again only when their directory changed.
  • Reloads the page on save of a view, a handler or a CSS file, through one dev-only script that listens for a reload signal. There is no hot module replacement.
  • A view or CSS change reloads the host in place: in-memory sessions survive, you stay signed in.
  • A screen file (src/screens/*.screen.tsx) holds its handlers, so saving one is a server change whenever the server bundle comes out different (it does for a change to the view as well).
  • A server change (bindings, handlers, contract, config) starts a new host process, the only way Node loads new code. With the memory session store you stay signed in: under luxel dev its sessions are also kept in files (below). Other in-memory data of your app (the template's contacts) is lost.
  • A failed build is shown on the page: every diagnostic, HTML-escaped, under its own CSP, until the next good build. It is printed in the terminal too.
  • Without LUXEL_VIEW_KEYS, it uses an ephemeral key for the session (and says so).
  • It refuses to start with LUXEL_ENV=production: it generates a key, injects a script and shows source code, none of which belongs in production. Use luxel build and luxel-host there.

The development session files

Under luxel dev, and only there, the memory session store also keeps each session in a file under node_modules/.cache/luxel/dev-sessions-‹project>/, and a new host process starts from those files. A file is named by a hash of the session id and holds the user, the roles and the two times: never the id, never the CSRF token. It is written once, when the session is opened (mode 0600), and removed when the session is signed out, revoked or expires; every operation of the store looks at the directory first, so a sign-out holds across the old host process and the new one for every request that starts after it. One limit: a request already being answered when another host signs the session out may still be answered once. The same holds for a sign-in that one host had started before another host revoked the user's sessions: it completes, as a session opened after the revocation. The files are trusted like your source code: whoever can write there can sign in to your development server as any user. Do not copy them to another machine and do not commit them. Deleting the directory signs everyone out. The store's limits (maxSessions) are counted by each host process: while luxel dev replaces one host with another, the two together can briefly hold more sessions than the limit.

luxel-host never reads or writes these files: with LUXEL_DEV_SESSION_FILE set it does not start, and outside LUXEL_ENV=development the memory store refuses to be created with it. An app with several memory session stores names them (createMemorySessionStore({ name: 'admin' })): each keeps its own files, and under luxel dev a second store without a name is refused. An app with its own session store (PostgreSQL) is not affected.

Under the hood, luxel dev runs the real luxel-host in a child process, behind a small proxy that adds the reload script (and its hash to the page's CSP).

luxel-host

luxel-host ‹config.json> [--check]

The server. It reads the build's luxel.config.json, loads your bindings and handlers, and serves the views, the runtime modules and the two gateway routes.

  • --check validates the config, manifests, assets and runtime, renders every boot page, then exits without serving. No key is needed.
  • Without --check, it listens on PORT (default 8080) and needs LUXEL_VIEW_KEYS.
  • SIGTERM and SIGINT stop it gracefully.

Routes it serves:

RouteWhat
GET /‹variant>/‹view>A filled page (or the static page of a static view); a redirect to the view's path when it declares one
GET ‹path>The page of the view that declares that path (Routes)
GET /The view whose path is /, or a redirect to home from luxel.config.ts
any other page address404: pages are answered from the route table only
GET /_luxel/view/‹view>The view's state for the session (no-store); a form token for a static view
POST /_luxel/eventThe single endpoint for business events
POST /_luxel/logoutEnds the session and clears the cookie: 204 to a script (CSRF header), 303 to the form of ‹Logout>
GET /healthzHealth check; 503 while draining

Environment variables are listed in Production. Outside production, a start failure prints its message so a setup mistake names itself.

npm run pack:local

In the Luxel repository:

npm run build npm run pack:local [-- --out ‹dir>]

Packs every framework package, and create-luxel, into tarballs in .packs/ (or --out), without publishing anything. Each package's file: dependencies on its siblings are rewritten to their exact version. Run npm run build first: the tarballs carry the built dist/. (npm run build also builds the lab in examples/; npx tsc -b && npm run bundle -w @luxel-framework/runtime builds only the framework.)

This is how you install Luxel until it is published on npm.

create-luxel

node ‹path-to-luxel>/packages/create-luxel/bin.mjs ‹directory> --packages ‹dir> [--name ‹package name>] npx --yes --package=‹path-to-luxel>/.packs/create-luxel-‹version>.tgz create-luxel ‹directory> --packages ‹dir> [--name ‹package name>]

OptionMeaning
‹directory>Where to create the app; it must not exist or must be empty
--packages ‹dir>The directory with the tarballs of npm run pack:local (or the LUXEL_PACKAGES environment variable). Required while Luxel is not on npm
--name ‹name>The package name (default: from the directory name)

It copies the template, writes package.json with file: dependencies on the tarballs of @luxel-framework/check, cli, compiler, gateway, protocol, runtime, server and ui, and overrides so every @luxel-framework/* package resolves to the same tarball. @luxel-framework/postgres is not added; install it from its tarball when you need it (Sessions).

The generated app's scripts:

ScriptWhat it does
npm run devluxel dev
npm run buildluxel build && luxel check
npm startluxel-host luxel.config.json
npm run test:e2ePlaywright, against luxel-host on the build with a fresh key (port E2E_PORT, default 4410)
npm run typechecktsc -p tsconfig.json
Edit this page on GitHub

This page: 7.9 KB of JavaScript (Luxel's shared runtime), 0 KB from your app.

Measured when the site is built: the runtime files this page loads, compressed as they are sent.

Made by IntiOps. Luxel 0.1.0-beta.1 is a beta: no external security review yet.