Skip to content

API ​

Language / 语言: English | 简体中文

本页说明 @ioai/lerobot-studio 的公开 API。这个包提供查看器、自定义欢迎页组件、归档与目录数据源工厂及其类型;不包含独立应用中的导出引擎。

文末自动生成的报告是完整 API 参考。修改源码后运行 npm run api:report,不要直接编辑生成的报告。


示例 ​

tsx
import { LeRobotViewer } from '@ioai/lerobot-studio';
import '@ioai/lerobot-studio/style.css';

<LeRobotViewer dataSource="https://example.com/dataset.zip" theme="system" />;

dataSource 可以是远程归档 URL,也可以是自定义 DataSource:

  • createArchiveDataSourceFromFile — 本地 ZIP / TAR / TAR.GZ
  • createArchiveDataSourceFromUrl — 要复用的远程归档
  • createRemoteManifestDataSource — 宿主已签名的逐文件 HTTP(S) URL 清单
  • createDirectoryDataSource — File System Access 目录句柄

自定义欢迎页时,使用 LeRobotStudioProvider,再搭配 LeRobotViewerContent、DatasetSourceSelector、SampleDatasetCard、Pagination 与 useDragAndDrop。见 嵌入。

数据集支持时,查看器可以在当前会话中修改 Episode。onExport 只是宿主 UI 的回调,不会自行导出数据。


自定义数据源 ​

如果应用需要按路径读取字节或文本,请实现 DataSource。路径和内容都应视为不可信输入,并在 clear() 中释放 object URL。

加载阶段包括 download、index、gunzip 和 read。致命错误包括无效数据源、远程 URL 不可用、不支持的归档和数据集加载失败。


生成的 API 报告 ​

API Report File for "@ioai/lerobot-studio" ​

Do not edit this file. It is a report generated by API Extractor.

ts

import { default as React_2 } from 'react';
import * as React_3 from 'react';

// @public
export function createArchiveDataSourceFromFile(file: File): DataSource;

// @public
export function createArchiveDataSourceFromUrl(url: string): DataSource;

// @public
export function createDirectoryDataSource(handle: FileSystemDirectoryHandle): DataSource;

// @public
export function createRemoteManifestDataSource(files: RemoteFileEntry[]): DataSource;

// @public
export const DatasetSourceSelector: React_2.FC<DatasetSourceSelectorProps>;

// @public
export interface DatasetSourceSelectorProps {
    // (undocumented)
    className?: string;
    // (undocumented)
    onOpenDirectory: () => void;
    // (undocumented)
    onOpenLocalArchive: () => void;
    // (undocumented)
    onOpenRemoteArchive: (url?: string) => void;
    // (undocumented)
    onRequestUrl?: (rawUrl: string | null, mode: 'push' | 'replace') => void;
    // (undocumented)
    onRestoreFromUrl?: (requested: ParsedSourceUrl) => void;
    // (undocumented)
    requested?: ParsedSourceUrl | null;
}

// @public
export interface DataSource {
    clear(): void | Promise<void>;
    exists(path: string): Promise<boolean>;
    getObjectUrl(path: string, mimeType?: string, onProgress?: ProgressHandler): Promise<string>;
    invalidateObjectUrl?(path: string): void | Promise<void>;
    listPaths?(): Promise<string[]>;
    readBytes(path: string, onProgress?: ProgressHandler): Promise<Uint8Array>;
    readText(path: string, onProgress?: ProgressHandler): Promise<string>;
}

// @public
export interface DirectoryFile {
    // (undocumented)
    file: File;
    // (undocumented)
    path: string;
}

// @public
export interface DragAndDropCallbacks {
    // (undocumented)
    onDirectoryFiles?: (files: DirectoryFile[]) => void;
    // (undocumented)
    onDirectoryHandle?: (handle: FileSystemDirectoryHandle) => void;
    // (undocumented)
    onFile: (file: File) => void;
    // (undocumented)
    onUnresolvedDirectory?: (name: string) => void;
}

// @public @deprecated (undocumented)
export const LeRobotProvider: React_2.FC<LeRobotStudioProviderProps>;

// @public
export const LeRobotStudioProvider: React_2.FC<LeRobotStudioProviderProps>;

// @public (undocumented)
export interface LeRobotStudioProviderProps {
    // (undocumented)
    children: React_2.ReactNode;
    // (undocumented)
    className?: string;
    // (undocumented)
    language?: string;
    showToaster?: boolean;
    // (undocumented)
    theme?: 'light' | 'dark' | 'system';
    wrapRoot?: boolean;
}

// @public (undocumented)
export const LeRobotViewer: React_2.FC<LeRobotViewerProps>;

// @public
export function LeRobotViewerContent(input: Omit<LeRobotViewerProps, 'theme' | 'language' | 'className'> & {
    showSidebar: boolean;
    showPlaybackBar: boolean;
}): React_2.JSX.Element | null;

// @public
export interface LeRobotViewerError {
    cause?: unknown;
    code: LeRobotViewerErrorCode;
    message: string;
    recoverable: boolean;
}

// @public
export type LeRobotViewerErrorCode = 'INVALID_DATA_SOURCE' | 'REMOTE_SOURCE_UNAVAILABLE' | 'UNSUPPORTED_ARCHIVE' | 'DATASET_LOAD_FAILED';

// @public
export interface LeRobotViewerProps {
    className?: string;
    dataSource: string | DataSource;
    enableKeyboardShortcuts?: boolean;
    language?: string;
    onBack?: () => void;
    onExport?: () => void;
    onFatalError?: (error: LeRobotViewerError) => void;
    showPlaybackBar?: boolean;
    showSidebar?: boolean;
    theme?: 'light' | 'dark' | 'system';
}

// @public
export type LoadingPhase = 'download' | 'index' | 'gunzip' | 'read';

// @public
export function Pagination(input: PaginationProps): React_3.JSX.Element;

// @public (undocumented)
export interface PaginationProps {
    // (undocumented)
    className?: string;
    // (undocumented)
    count: number;
    // (undocumented)
    onPageChange: (event: unknown, newPage: number) => void;
    // (undocumented)
    onRowsPerPageChange: (event: React_3.ChangeEvent<HTMLSelectElement>) => void;
    // (undocumented)
    page: number;
    // (undocumented)
    rowsPerPage: number;
    // (undocumented)
    rowsPerPageOptions?: number[];
}

// @public
export interface ParsedSourceUrl {
    hint?: string;
    // (undocumented)
    kind: SourceKind;
    raw: string;
    restorable?: boolean;
    sampleId?: string;
}

// @public
export type ProgressHandler = (info: ProgressInfo) => void;

// @public
export interface ProgressInfo {
    loaded?: number;
    message?: string;
    phase: LoadingPhase;
    total?: number;
}

// @public
export interface RemoteFileEntry {
    contentType?: string | null;
    logicalPath: string;
    presignedUrl: string;
    sizeBytes?: number | null;
}

// @public
export interface SampleDataset {
    // (undocumented)
    archiveUrl?: string;
    // (undocumented)
    coverImageUrl?: string;
    // (undocumented)
    description: string;
    // (undocumented)
    id: string;
    // (undocumented)
    name: string;
    // (undocumented)
    previewVideoUrl?: string;
    // (undocumented)
    title?: string;
    // (undocumented)
    url?: string;
    // (undocumented)
    version?: 'v2' | 'v3';
}

// @public
export const SampleDatasetCard: React_2.FC<SampleDatasetCardProps>;

// @public
export interface SampleDatasetCardProps {
    // (undocumented)
    fallbackImageUrl?: string;
    // (undocumented)
    onSelect: (sample: SampleDataset) => void | Promise<void>;
    // (undocumented)
    sample: SampleDataset;
}

// @public (undocumented)
export type SourceKind = 'remoteArchive' | 'localArchive' | 'directory' | 'sample' | 'unknown';

// @public
export function useDragAndDrop(callbacks: DragAndDropCallbacks): {
    isDragging: boolean;
};

基于 MIT 许可证发布。