@texuli/player
v0.18.0
Published
Svelte paint runtime for validated Texuli catalog blueprints.
Maintainers
Readme
@texuli/player
The Svelte 5 paint runtime for agent-built interfaces in
Texuli, an MIT-licensed Svelte 5 component library by
Dailybot, Inc. (Small pieces. Infinite possibilities.). Hand
<Player> a blueprint (catalog JSON, usually written by an agent) and it
validates the blueprint, then paints it with real Texuli layouts, content
blocks, charts and media. HTML sinks never touch the blueprint. Agent
output stays inside a labelled frame with a visible trust badge, and the
player never navigates, fetches or persists anything on its own.
In the stack: layer L7: paints what the agent catalog (L6) validates against the @texuli/spec blueprint contract, with the texuli components and the domain packages. @texuli/pages and @texuli/slides embed it.
Status: 0.x release. Texuli is in development. The packages are published to npm as
0.18.0, a pre-1.0 release (1.0.0 will be the first stable release). Under 0.x, a new minor (0.18.0) may contain breaking changes, so pin the exact version or use^0.18.0, which accepts only 0.18.x.
New in
0.4.0. Spec 0.3.0 and 0.4.0 envelopes (state,flow,bind,onand the closed actions), the data view, chat display, sortable list and workflow graph painters, the shared drag scope, thedeckHostseam andchrome={false}ship in0.4.0; the0.3.0release predates them (RELEASE).
Install
npm install @texuli/player svelteSvelte 5 (^5.57.2) is a peer dependency. The validation core
(@texuli/catalog) and the blocks, charts and media painters are installed
as dependencies. Import the stylesheet once if your bundler does not keep
package CSS side effects:
import '@texuli/player/styles.css';Quick start
<script lang="ts">
import { Player } from '@texuli/player';
import '@texuli/player/styles.css';
// A blueprint is catalog JSON: text or data, usually from an agent.
const blueprint = {
id: 'layout-page',
props: { title: 'Weekly summary' },
children: [
{
id: 'blocks-text',
props: { block: { type: 'text', markdown: 'Fictional: **38 of 44** items closed.' } },
},
],
};
</script>
<Player {blueprint} label="Report preview" />The root must be layout-page, layout-doc or layout-deck. The player
validates at the untrusted tier by default, shows the frame chrome (your
label, the lifecycle status and an Untrusted content badge), and loads
only the painters the blueprint uses.
Without Svelte, mount it from plain JavaScript:
import { mountPlayer } from '@texuli/player';
const player = mountPlayer(document.querySelector('#preview')!, {
blueprint,
label: 'Report preview',
});
player.update({ blueprint: nextBlueprint }); // re-validates in place
player.dispose();What's inside
Everything is exported from the root entry, @texuli/player.
| Area | Headline exports |
| --- | --- |
| Svelte component | Player, with host-owned props for tier, status, labels, density, motion, selection and callbacks |
| Plain JavaScript | mountPlayer (update, setState, getState, dispatchFlow, getView, dispose) |
| Catalog and loaders | createPlayerCatalog, PLAYER_LOADERS, withLoadTimeout, skeletonFamily |
| Error placeholders | PLAYER_NODE_ERROR_CODES, placeholderMessage |
| Labels and localization | DEFAULT_PLAYER_LABELS, resolvePlayerLabels |
| Local state and flows | parseStateDeclarations, parseFlowDeclaration, resolveStateBindings |
| Action forms | runAction, actionValues, AUTOCOMPLETE_ALLOWLIST |
| Host data and regions | sanitizeDataSources, hostRegionManifest, HOST_CHROME_IDS |
| Iframe embedding | PlayerFrame, createPlayerFrameHost, mountPlayerFrame, createPlayerFrameClient |
| Media policy | applyMediaPolicy, TRUST_PINNED_IDS |
| Streaming (new in 0.6.0) | <Player stream>, BlueprintStreamSource, PlayerStreamProgress, STREAM_PENDING_ID; the push handle is createBlueprintStream from @texuli/spec/stream (streaming.md) |
| Data sources (new in 0.8.0) | <Player sourceRegistry> or sourceLoader: blueprint props {"$source": name, "query": {...}} read host-registered sources from @texuli/core/data-source, with loading, empty and error states, paging and optimistic edits (data-sources.md) |
| Design systems (from 0.10.0) | <Player designSystems={{ resolve, mode }}> and onDesignSystem: a blueprint's designSystem (spec 0.10.0) is resolved by the host (never fetched), compiled lazily and applied to the player root; a refused one keeps the default theme with a notice, and its component defaults reach the painted components (props still win); PlayerDesignSystems, PlayerDesignSystemEvent. The step is also the @texuli/player/design-system subpath (resolvePlayerDesignSystem, applyPlayerDesignSystem, playerDesignDefaults, loadPlayerLibraryBase); @texuli/player/design-system-core (from 0.11.0, G127) is the same step without the theme library (resolvePlayerDesignSystemCore, applyPlayerDesignSystemCore: texuli:<theme> loads only through the caller's loadLibraryBase), which the @texuli/slides stage loads lazily for a deck's own designSystem (reference.md) |
| Stylesheet | @texuli/player/styles.css |
The TypeScript declarations list the full surface.
Key guarantees
- Validated before it paints. Every blueprint value that paints has
passed
validateDraftfrom@texuli/catalogand the untrusted URL policy, on every entry path: the prop,mountPlayerupdates, local state, host data and iframe messages. Choosingtier="developer"widens validation but never the paint-time URL policy. - No HTML sinks. The player paints through components and never uses
{@html}orinnerHTML. Layout props are closed enums, clamped numbers or bounded lengths. - Visible trust boundary. At the
untrustedtier the frame always shows the trust badge. A host can reword it but not remove it. - Fails per node. Invalid drafts are refused with a notice by default. A node that cannot load or paint becomes its own labelled placeholder and never blanks the page or throws into it.
- No side effects. Controls write local state only. An action form
proposes an intent to your
onActionhandler, and the player sends nothing itself. - Every emittable id paints from JSON (new in
0.4.0). All 66 agent-emittable ids of the 158-id catalog have a painter (the other ids are app tier, refused at the untrusted tier), including data views (grid, tree, board, calendar, timeline, map, files), chat display,sortable-listandworkflow-graph(the@texuli/workflowsviewer or editor). Nodeonruns only the closed actions (setState,toggleState,moveItem,flowGo,emit,submit), andbindwrites back only to declared variables. The chat composer stays host chrome. New in0.5.0, three more data views paint from JSON:data-cohort-table,data-notification-inbox(read changes stay in view,filteris bindable, links always pass the untrusted URL policy) anddata-filter-builder(a starting filter is parsed against its fields; one that does not fit starts empty; from0.10.0, a field'soptionLabelsgive enum values their menu text andissuesshow under their conditions). - One drag scope (new in
0.4.0).sortable-listnodes share one drag scope, so an item moves between lists anywhere in the layout under the same group,accepts,locked,pullandmaxItemsrules thatmoveItemapplies; the drag offers exactly what the data move does. - A blueprint that validates paints. The spec and catalog validators
refuse the same state surface errors the player refuses (form nodes
outside an
action-form, unbound controls, unmatched flow nodes, writes to host-bound variables). - Streams add speed, not trust (new in
0.6.0). Withstream, a node paints only once its shell (everything butchildren) has arrived and passed every node-level check, under anaria-busy,inertsurface with polite progress at most every few seconds. Nothing is armed until the complete draft passesvalidateDraft; a refused draft replaces the painted prefix with the notice, and an interrupted stream keeps its painted nodes with a recoverable error (streaming). - Motion as data (spec 0.6.0, new in
0.6.0). A node's closedmotion(enter and exit presets, layout, stagger and duration in token steps) plays through@texuli/core/motion, loaded only when a node declares it: never on the server or for what the first paint shows, instant under reduced motion, and capped by the host'smotionLevel(reference). - Accessible frame. A skip link, F6 between frames, Escape walking
outward,
inertfor inactive frames, one polite live region, and reduced motion honored. - Strict CSP friendly. No
unsafe-inlineorunsafe-evalis needed, and the player makes no network requests of its own. - Sandboxed iframes.
PlayerFramerenders only an HTTPSsrcon your allowlist, sandboxed withoutallow-same-origin. Every message is re-parsed and size-clamped on both sides.
Not built yet: painting the catalog core's closed intents (such as
navigate or copy), retrying a failed node, and a hosted player-frame
page. Decks paint as a document flow; the slide-by-slide presenter stage
lives in @texuli/slides. New in 0.4.0: a
host that has both packages passes a deckHost to present a deck blueprint
on that stage instead, and chrome={false} paints a component with no frame
chrome, as the slides stage does for every component on a slide
(embedding).
New in 0.14.0
Ships in 0.14.0 (spec 0.12.0); the 0.13.x releases predate it. The data-timeline
painter passes groups (header labels and bands), markers, collapsed
and selectedRow to TimelineView. Bands with dates that do not parse,
markers whose at does not parse and unknown tones are dropped. Rows
become selectable once selectedRow is set or bound (an empty string
selects none). Toggling a group writes collapsed back as { id } items
and runs on.collapse with the group id; selecting a row writes
selectedRow and runs on.select with the task id.
New in 0.8.0
Ships in 0.8.0; the 0.7.0 release predates it: schema-form nodes (spec 0.8.0) paint
through the formHost seam (createFormPlayerHost() from
@texuli/forms/host, which also supplies the form check and the host
validators by name); submitting proposes the node's action intent, and
without a host a form blueprint is refused
(embedding).
Also new in 0.8.0: the canvasHost seam paints agent
canvas blueprints (spec 0.8.0) through createCanvasPlayerHost() from
@texuli/canvas/host, which also supplies the canvas check validation
runs; without one a canvas is refused
(embedding).
Also new in 0.8.0: the sheetHost seam paints
spreadsheet nodes (spec 0.8.0) in place through
createSheetPlayerHost() from @texuli/sheets/host, which also supplies the
sheet check validation runs (every formula is parsed at draft time) and
mounts a read-only SheetView; without one a spreadsheet is refused
(sheet-unchecked), and a preview shows its title and sheetNeedsHost
(embedding).
data-dashboard and data-dashboard-widget nodes paint a dashboard grid,
and data-dashboard.layout may read a host source
(data sources).
New in 0.7.0
Ships in 0.7.0; the 0.6.0 release predates it: the documentHost seam paints agent
document blueprints (spec 0.7.0) through a host such as
createDocumentPlayerHost() from @texuli/pages/host, which also supplies
the document check validation runs; without one a document is refused
(embedding).
Node keys ride on the render tree, and a streamed node that repeats a key
already painted is held (duplicate-key).
New in 0.6.0
Ships in 0.6.0; the 0.5.0 release predates it: streaming mode
(<Player stream>), spec 0.6.0 node motion (motionLevel), and reduced
motion at 0s durations and delays (G78)
(streaming,
reference).
Documentation
- Website: texuli.com, the blueprint builder and the agents overview
- Embedding guide (start here): embedding.md
- Validate, edit and activate around the player: blueprint-flow.md
- Full reference (loaders, layouts, keyboard, state, flows, actions, iframe protocol): reference.md
- Streaming mode (paint a blueprint while an agent writes it; new in
0.6.0): streaming.md - Data sources (blueprint spec 0.8.0; new in
0.8.0): data-sources.md - Security property: paint-proof.md
- Security model: SECURITY.md
Related packages
@texuli/catalog: the catalog, draft validation and the sink-free renderer the player is built on.@texuli/slides: presentation decks with a presenter stage.@texuli/tools: custom elements for hosts that do not use Svelte.
Contributing
Source, issues and contribution guidelines live at github.com/DailybotHQ/texuli. Report bugs at github.com/DailybotHQ/texuli/issues.
License
MIT © Dailybot, Inc. Powered by Dailybot.
