@elaraai/e3-ui-components

中文文档
1.0.107发布于 2026/11/13AGPL-3.0-or-laterTypeScriptESM + CJS构建来源已验证近 30 天下载 3486

React Query hooks and preview components for the e3 API

原始使用文档
文档目录20 节
  1. Features
  2. Installation
  3. Hooks
  4. Quick Start
  5. Query Overrides
  6. Polling
  7. Recovering a failed read
  8. Rendering a UI outside UITaskPreview
  9. Components
  10. TaskPreview
  11. DatasetPreview
  12. InputPreview
  13. VirtualizedLogViewer
  14. StatusDisplay
  15. Development
  16. Claude Code plugin
  17. License
  18. Ecosystem
  19. Links
  20. About Elara

E3 UI Components

React Query hooks and preview components for the e3 API

License Node Version

E3 UI Components provides React Query hooks for all e3-api-client functions and reusable preview components for tasks, inputs, and logs.

Features

  • React Query Hooks - useQuery and useMutation wrappers for all e3 API client functions
  • Task Preview - Component for viewing task execution output and logs
  • Input Preview - Component for viewing dataset input values
  • Virtualized Log Viewer - Performant log display with search and auto-scroll
  • Type-Safe - Full TypeScript support with proper return type inference

Installation

npm install @elaraai/e3-ui-components @elaraai/e3-api-client @tanstack/react-query

Hooks

React Query hooks are provided for every e3 API domain:

DomainHooks
ReposuseRepoList, useRepoStatus, useRepoGc, useRepoGcStart, useRepoGcStatus, useRepoCreate, useRepoRemove
PackagesusePackageList, usePackageGet, usePackageImport, usePackageExport, usePackageRemove
WorkspacesuseWorkspaceList, useWorkspaceCreate, useWorkspaceCopy, useWorkspaceGet, useWorkspaceStatus, useWorkspaceRemove, useWorkspaceDeploy, useWorkspaceExport
DatasetsuseDatasetList, useDatasetListAt, useDatasetListRecursive, useDatasetGet, useDatasetSet
TasksuseTaskList, useTaskGet, useTaskExecutionList
ExecutionsuseDataflowExecute, useDataflowStart, useDataflowGraph, useDataflowExecution, useDataflowCancel, useTaskLogs

Quick Start

import { useWorkspaceList, useTaskList } from '@elaraai/e3-ui-components';

function WorkspaceView({ apiUrl, repo }: { apiUrl: string; repo: string }) {
    const { data: workspaces, isLoading } = useWorkspaceList(apiUrl, repo);

    if (isLoading) return <div>Loading...</div>;

    return (
        <ul>
            {workspaces?.map(ws => <li key={ws.name}>{ws.name}</li>)}
        </ul>
    );
}

Query Overrides

All query hooks accept an optional QueryOverrides parameter for controlling query behavior:

const { data } = useTaskList(apiUrl, repo, workspace, requestOptions, {
    refetchInterval: 5000,
    staleTime: 10000,
    enabled: isReady,
});

Polling

A screen left open costs the server as little as it can:

  • A poll makes one request attempt. useWorkspaceStatus, useDataflowExecution, useTaskLogs, useDatasetStatus and the dataset cache's status poll send their requests with e3-api-client's pollRequestOptions, so a transient failure is left to the next poll rather than retried three times in between.
  • The dataset cache asks conditionally. <ReactiveDatasetProvider>'s cache polls a workspace's status at pollIntervalMs (1000 ms) while what it shows changes, backing off to pollBackoffMs (5000 ms) once nothing has; each poll sends the last answer's ETag back (workspaceStatusSince), and a server that still holds that status answers nothing. Every half minute it asks in full, so a runner that died shows as stale, and after a fetch that failed, a new watch or a refresh, so nothing a conditional answer would leave as it is stays so. While the page is hidden — its tab in the background — it polls nothing, and polls every workspace at once when the page is shown again. A UITaskPreview shortens the interval with pollInterval and the backoff with pollBackoff.
  • A dataset's status is polled every 30 s (DATASET_STATUS_POLL_MS): useDatasetStatus's pollInterval, and the previews' pollInterval (DatasetPreview, InputPreview) and statusPollInterval (TaskPreview, DataTaskPreview; UITaskPreview's outputPollInterval) shorten it.
  • A task's log is polled while it grows: every second while it changes, backing off to 5 s while it does not, and every half minute once the task's execution has ended and the log is read, for another execution of the task, which starts the polls again. A log the view left — the other stream, another task — is kept as far as it was read, so a view that comes back to it reads on from there. TaskPreview's logPollInterval and logPollBackoff set the intervals.
  • A task's details are read once. useTaskDetails and useTaskGet share one query key, so a preview and the host that opened it read the task once; a host that holds the details hands them over as TaskPreview's details, and the preview makes no request.

Recovering a failed read

A view on a screen no one touches, such as a kiosk's, has no one to reload it. useQueryRecovery tries a failed query again by itself while the view is mounted, as every stage of UITaskPreview does. It waits a random point in the second half of a backoff from 1 s to 30 s (recoveryDelay), and shows the latest failure through each try, never loading again.

import { StatusDisplay, useQueryRecovery, useTaskGet } from '@elaraai/e3-ui-components';

const details = useTaskGet(apiUrl, repo, workspace, task);
const failure = useQueryRecovery(details); // null once it reads
if (failure !== null) return <StatusDisplay variant="error" title="Error" message={failure.message} />;

Rendering a UI outside UITaskPreview

A host that renders UI functions itself decodes each with the platforms UITaskPreview lists. Every one is exported by name: east-ui-components' own, Decision.bind's (DecisionBindPlatform), and the bindings scoped to the UI's manifest. Preload the manifest's paths with usePreloadReactiveDatasets before the UI's first read.

import { decodeBeast2For } from '@elaraai/east';
import { UIComponentType } from '@elaraai/east-ui';
import {
    StateImpl, SliceImpl, SliceApplyImpl, OverlayImpl, ClipboardImpl, DownloadImpl, ShareImpl,
} from '@elaraai/east-ui-components';
import { RecordSliceImpl } from '@elaraai/east-ui-components/platform';
import {
    DecisionBindPlatform, createScopedBindPlatform, createScopedPagedPlatform,
    createScopedFuncPlatform, createScopedRecordPlatform,
} from '@elaraai/e3-ui-components';

const platforms = [
    ...StateImpl, ...SliceImpl, ...RecordSliceImpl, ...SliceApplyImpl, ...OverlayImpl,
    ...ClipboardImpl, ...DownloadImpl, ...ShareImpl, ...DecisionBindPlatform,
    ...createScopedBindPlatform(manifest),
    ...createScopedPagedPlatform(manifest.pages),
    ...createScopedFuncPlatform(manifest.functions),
    ...createScopedRecordPlatform(manifest.records),
];
const ui = decodeBeast2For(UIComponentType, { platform: platforms })(bytes);

Components

TaskPreview

Previews a task by its role: a ui() task renders its UI; a data task shows its output (Output) and its logs (Logs) under a band holding the Output/Logs switch. Above the output are its key search, size and Download, and above its tree Collapse all and Expand all; above the log, its stdout/stderr tabs, its search and Copy.

import { TaskPreview } from '@elaraai/e3-ui-components';

<TaskPreview apiUrl={url} repo="default" workspace={ws} task={taskName} />
PropMeaning
apiUrl, repo, workspace, taskrequired — the task to preview
requestOptionsthe token, and the fetch every request goes through
bareno task-name header, and a ui() task's output edge to edge — for a kiosk
toolbarfalse draws no band anywhere in a data task's preview — no switch, nothing above the output or its tree, nothing above the log, which fills the view edge to edge; the host draws the controls. Default true
view, onViewChangea data task's tab, 'output' or 'logs', controlled
search, onSearchChangethe output's key search, controlled: a given search is found and scrolled to ('' clears), and the preview draws no search box of its own; otherwise onSearchChange hears the preview's own box
logStream, onLogStreamChangethe log's stream, 'stdout' or 'stderr', controlled
logSearch, onLogSearchChangethe log's search, controlled: a given logSearch marks its matches, in any case, and scrolls to the first ('' clears), and the log draws no search box, count or chevrons of its own; otherwise onLogSearchChange hears the log's own box
onLogMatchesChangetold { current, count } — the log's match shown, from 0, and how many there are — whenever either changes
controlsthe handle the host's own buttons act through, made with usePreviewControls()
detailsthe task's details, when the host holds them: the preview reads them from the host, not the server
statusPollIntervalhow often the output's status is polled, in milliseconds. Default 30 000
logPollInterval, logPollBackoffhow often a data task's log is polled while it changes, and the longest it waits while nothing does, in milliseconds. Defaults 1000 and 5000

A host whose frame holds its controls in its header draws them itself and hides the bands:

import {
    TaskPreview, downloadDataset, formatSize, usePreviewControls, useDatasetStatus, useTaskDetails, type LogMatches,
} from '@elaraai/e3-ui-components';

const [view, setView] = useState<'output' | 'logs'>('output');
const [search, setSearch] = useState('');
const [stream, setStream] = useState<'stdout' | 'stderr'>('stdout');
const [logSearch, setLogSearch] = useState('');
const [matches, setMatches] = useState<LogMatches>({ current: 0, count: 0 });
const controls = usePreviewControls();
const details = useTaskDetails(url, 'default', ws, taskName);
const output = details.data?.output.path.map((step) => step.value).join('.') ?? null;
const status = useDatasetStatus(url, 'default', ws, output);

// In the header, at the header's size: the tab; on Output, the search, the size,
// Download, and Collapse all and Expand all; on Logs, the stream, the search,
// `${matches.current + 1}/${matches.count}`, the chevrons and Copy.
// In the body:
<TaskPreview apiUrl={url} repo="default" workspace={ws} task={taskName} bare
    toolbar={false} view={view} onViewChange={setView} search={search}
    logStream={stream} onLogStreamChange={setStream} logSearch={logSearch}
    onLogMatchesChange={setMatches} controls={controls} />
// Download: downloadDataset(url, 'default', ws, output); the size: formatSize(status.data.sizeBytes)
// Collapse all: controls.collapseAll(); Expand all: controls.expandAll()
// The chevrons: controls.previousMatch(), controls.nextMatch(); Copy: controls.copyLog()

search is read as the preview's own search box reads its text: a key's prefix, a struct key's leading fields (press, 2), a from..to range, or a whole key in .east syntax.

usePreviewControls() makes the handle. collapseAll() and expandAll() act on the output's tree; nextMatch() and previousMatch() step through the log's matches, from the last round to the first and back; and copyLog() copies the log shown, resolving true once it is on the clipboard and false when the clipboard refuses it. Each does nothing while its view is not shown — the Output tab shows no log, and a value too large to show has no tree. A handle serves one preview at a time, and holds no query, so a header outside <E3Provider> can make it.

DatasetPreview

Shows a dataset's value: a tree, inline while it is small, a page at a time for a read-only collection, and a Download for a value too large to show. editable writes a mutable input's edits back. toolbar, search, onSearchChange and controls are TaskPreview's, for the value alone.

import { DatasetPreview } from '@elaraai/e3-ui-components';

<DatasetPreview apiUrl={url} repo="default" workspace={ws} path="inputs.threshold" editable />

InputPreview

Shows an input's value, editable, under a band naming the input.

import { InputPreview } from '@elaraai/e3-ui-components';

<InputPreview apiUrl={url} repo="default" workspace={ws} path=".inputs.threshold" />

bare draws no band naming the input, for a host whose frame names it, and toolbar, search, onSearchChange, controls and pollInterval reach the value's DatasetPreview.

VirtualizedLogViewer

A log, its lines virtualized, under a band holding the stdout/stderr tabs, a search that marks its matches and steps through them, and Copy. It follows the log's end while it is there, and says when new lines arrive while it is not.

import { useTabs } from '@chakra-ui/react';
import { VirtualizedLogViewer } from '@elaraai/e3-ui-components';

const tabs = useTabs({ defaultValue: 'stdout' });

<VirtualizedLogViewer content={tabs.value === 'stderr' ? stderr : stdout} tabs={tabs} />
PropMeaning
content, tabsrequired — the log's text, and the tabs useTabs makes
toolbarfalse draws no band, and the log fills the view edge to edge, with no inset, corners or border. Default true
search, onSearchChangethe search, controlled, as TaskPreview's logSearch
onMatchesChangetold { current, count } whenever either changes
controlsRefgiven a LogViewerControls — nextMatch(), previousMatch() and copy() — while the view is mounted

StatusDisplay

Status feedback component with error, warning, info, and loading variants.

import { StatusDisplay } from '@elaraai/e3-ui-components';

<StatusDisplay variant="error" title="Failed" message={error.message} />

Development

npm run build     # Build library
npm run lint      # Check code quality

Claude Code plugin

The East ecosystem also ships a Claude Code plugin — East language skills, example search, and preemptive diagnostics for East code — installed separately from the elaraai marketplace:

# Inside Claude Code
/plugin marketplace add elaraai/east-workspace
/plugin install east@elaraai
# From a terminal
claude plugin marketplace add elaraai/east-workspace
claude plugin install east@elaraai

License

Dual-licensed:

Ecosystem

  • East: Statically typed, expression-based language with serializable IR. Run portable logic across TypeScript, Python, C, and other runtimes.

    • @elaraai/east: Core language SDK with type system, expressions, and reference JS compiler
  • East Node: Node.js platform functions for I/O, databases, and system operations.

  • East C: C11 native runtime for executing East IR. Tarballed for linux-x64 and linux-arm64, attached to each GitHub Release.

    • east-c: Core runtime — type system, IR interpreter, 200+ builtins, serialization (Beast2, JSON, CSV, East text)
    • east-c-std: Console, FileSystem, Fetch, Crypto, Time, Path, Random
    • east-c-cli: CLI for running East IR programs natively
  • East Python: Python runtime, standard platform, I/O, and data-science platform functions. Published to PyPI.

    • east-py: Core Python runtime — type system, IR compiler, 212+ builtins, Cython-accelerated hot paths
    • east-py-std: Console, FileSystem, Fetch, Crypto, Time, Path, Random
    • east-py-io: SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, compression
    • east-py-cli: CLI for running East IR programs in Python
    • east-py-datascience (PyPI) + @elaraai/east-py-datascience (npm): Optimization (MADS, Optuna, ALNS, GoogleOR), ML (XGBoost, LightGBM, NGBoost, PyTorch, Lightning, GP), Bayesian inference (PyMC), explainability (SHAP), conformal prediction (MAPIE)
  • East UI: Typed UI component definitions and React renderer, plus VS Code preview.

  • e3 — East Execution Engine: Durable execution engine for running East pipelines at scale. Git-like content-addressable storage, automatic memoization, reactive dataflow, real-time monitoring.

About Elara

East is developed by Elara AI Pty Ltd, an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across operations, purchasing, sales and customer engagement, and project and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.


Developed by Elara AI Pty Ltd.


Developed by Elara AI Pty Ltd - Powering the computational layer of AI-driven business optimization.

版本与发布记录

@elaraai/e3-ui-components 共发布 125 个版本,首次发布于 2026/02/15;过去 12 个月发布了 125 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.107latest2026/11/13今天
1.0.1062026/11/094 天前
1.0.1052026/11/085 天前
1.0.1042026/11/067 天前
1.0.1032026/11/049 天前
1.0.1022026/11/0310 天前

其他发布通道:beta → 0.0.1-beta.18。

关于 @elaraai/e3-ui-components 的常见问题

@elaraai/e3-ui-components 是什么?

React Query hooks and preview components for the e3 API

如何安装 @elaraai/e3-ui-components?

在项目目录运行 npm install @elaraai/e3-ui-components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)、@elaraai/east(1.0.107)、@elaraai/e3-ui(1.0.107)、@chakra-ui/react(^3.0.0)、@elaraai/east-ui(1.0.107)、@elaraai/e3-types(1.0.107)、@tanstack/react-query(^5.62.0)、@elaraai/e3-api-client(1.0.107)、@elaraai/east-ui-components(1.0.107)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@elaraai/e3-ui-components 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@elaraai/e3-ui-components 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@elaraai/e3-ui-components 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@elaraai/e3-ui-components 可以商用吗?

@elaraai/e3-ui-components 使用 AGPL-3.0-or-later 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@elaraai/e3-ui-components 的下载量有多少?

根据 npm 官方下载统计,@elaraai/e3-ui-components 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,486 次,日均约 116 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@elaraai/e3-ui-components 还在维护吗?

最新版本 1.0.107 发布于 2026/11/13(今天);至今共发布 125 个版本,其中过去 12 个月发布了 125 个;首次发布于 2026/02/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。