接口参考
扩展可用的全部接口:视图协议、界面套件的类、面板块与表单字段、组件,以及宿主接口、应用对后端的调用、清单和实例类型描述的键,以及管理工具。内容由应用导出的接口定义生成。
本页逐项列出扩展可以使用的接口,每一项都有可以直接链接的锚点和简短示例。内容在构建本站时从应用仓库中提交的接口导出 sdk/interfaces/ 读取(由 bun run export:backend-interfaces 和 bun run export:frontend-interfaces 生成,过期时检查会失败),因此始终与应用的代码一致。各项的用法和语义见后端、实例类型和界面。
导出中的说明为英文
方法摘要、参数、权限、类和字段的说明直接取自导出,与应用代码中的注释相同,因此为英文。本页自身的文字为中文。
版本
api | 2 |
documents | components.jsonexamples.jsonframe.jsonkit.jsonpanels.jsontokens.jsonutilities.json |
exportVersion | 1 |
kitVersion | 1 |
uiApiVersion | 1 |
typings | sdk/ui/ui.d.ts |
api是后端协议的版本,即清单engines.api声明的版本。同一版本内只会增加方法和可选字段;删除或重命名会提升版本。kitVersion是界面套件的类 API 版本,规则相同。uiApiVersion是视图可用组件(组件包,UI API)的版本。同一版本内只会增加组件和可选属性;删除或重命名会提升版本。exportVersion是导出文件本身的格式版本。
前端
视图消息
视图页面与应用之间通过 postMessage 交换的消息。页面通常不直接发送这些消息,而是使用视图客户端,它封装了下面的全部消息。
Every message is an object with v (the protocol) and type.
页面 → 应用
open-settings
Opens a registered settings section through the host navigation. Returns null; an unknown section is invalid.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
section | string | A currently registered settings section id; not a route. |
{"v":1,"type":"open-settings","id":1,"section":"<section>"}open-external
Opens the URL in the system browser. Returns null; invalid URLs or opener failures reject the request. The frame never navigates the top-level window.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
url | string | An HTTP or HTTPS URL, parsed once by Rust. |
{"v":1,"type":"open-external","id":1,"url":"<url>"}settings-get
Reads the frame owner's settings from the host, including for data-only extensions. Returns {values: Record<string, unknown>}; no extension id is accepted.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
{"v":1,"type":"settings-get","id":1}settings-patch
Patches the frame owner's settings through the host's Rust validation and persistence. Returns {values: Record<string, unknown>}; no backend or extension id is required.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
patch | Record<string, unknown> | Declared setting keys to change; null removes an override. |
{"v":1,"type":"settings-patch","id":1,"patch":{}}ready
The page is set up: the host sends theme and pings it from now on. Without it within 10 s the frame is unavailable.
成员: 无成员
{"v":1,"type":"ready"}call
Calls the extension's backend (ui.frame.call, within its 30 s bound); answered by result or error with the same id.
回答方: backend
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
method | string | The backend's method, non-empty. |
params? | unknown | Any JSON; an absent one is null. |
{"v":1,"type":"call","id":1,"method":"<method>"}subscribe
The host hands the page the backend's events of that name for this frame.
| 成员 | 类型 | |
|---|---|---|
event | string | The event's name, non-empty. |
{"v":1,"type":"subscribe","event":"<event>"}state
Reads the extension UI's state (ui.state, with the frame's context, within 10 s); answered by result (the state) or error. Without the hook ui it is unavailable.
回答方: backend
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
{"v":1,"type":"state","id":1}subscribe-state
The host hands the page each state the extension's UI pushes from now on.
成员: 无成员
{"v":1,"type":"subscribe-state"}resize
The frame's height; there is no width, the frame spans its section. A frame shown as a page of its own ignores it.
| 成员 | 类型 | |
|---|---|---|
height | number | The page's height in CSS pixels, kept within 96–4096 (240 until the page sends one). |
{"v":1,"type":"resize","height":1}focus-exit
Escape, unless the page prevented it: the host moves focus to what follows the frame, then takes the Escape as its own (in Settings, Settings closes).
成员: 无成员
{"v":1,"type":"focus-exit"}pick-directory
Opens the application's folder dialog; result is the native path chosen, or null when cancelled.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
title? | string | The dialog's title, cut at 200 characters; anything but text is no title. |
defaultPath? | string | The path at which the native dialog should start. |
{"v":1,"type":"pick-directory","id":1}pick-file
Opens the native single-file dialog. Returns the chosen path, or null when cancelled.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
title? | string | The dialog's title, cut at 200 characters; anything but text is no title. |
defaultPath? | string | The path at which the native dialog should start. |
filters? | { name: string; extensions: string[] }[] | Named native file filters, with at least one extension per filter and up to 64 extensions in total. |
{"v":1,"type":"pick-file","id":1}update-instance
In an instance's management section only, for the frame's own instance: the host asks the user to confirm the mode, then runs it with the recorded install values and values over them. result (null) once it has started; failed when the user declines, another update is waiting, or the application refuses it; invalid elsewhere.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
mode? | "update" | "reinstall" | Use update steps or reinstall in place. Defaults to update when available, otherwise reinstall. |
values | Record<string, unknown> | The install values to replace, at most 64. |
{"v":1,"type":"update-instance","id":1,"values":{}}navigate-instance
Takes the user to the instance's page (/instances/<instanceId>); result (null) once on its way, which may unmount the frame.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
instanceId | string | The instance, non-empty. |
{"v":1,"type":"navigate-instance","id":1,"instanceId":"<instanceId>"}open-management-section
Opens Instance Management at section, on instanceId or else on this frame's own instance, and returns null once it is on its way. Opening may unmount the frame.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
section | string | A currently registered management section id; not a route. An unknown section is invalid. |
instanceId | string | null | The instance whose management opens. Omitted: the instance this frame is in, which only a management.sections frame has. |
{"v":1,"type":"open-management-section","id":1,"section":"<section>","instanceId":"<instanceId>"}open-window
Open or focus the declared native window, inheriting the source instance for scoped views.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
frame | string | A frame declared with a window by this extension. |
{"v":1,"type":"open-window","id":1,"frame":"<frame>"}reset-overlay
Restores the calling overlay in this window or the named overlay of this extension across windows. An unnamed request from another frame returns invalid.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
frame? | string | Own overlay ID to reset in every window. Omit to reset the calling overlay in this window. |
{"v":1,"type":"reset-overlay","id":1}reload-extension
Reads this extension's package again — its manifest, the files it contributes, its settings form and its types — so what an entry declares reaches the running application without a restart. result (null); the frame may be unmounted as its contributions are rebuilt.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
{"v":1,"type":"reload-extension","id":1}open-dialog
Opens one of this extension's dialogs frames in a dialog over the window. result is what that page closed it with (close-dialog), or null when the user dismissed it; invalid for a frame that is not one of the extension's dialogs frames.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
frame | string | The id of one of this extension's dialogs frames, non-empty. |
title? | string | The dialog's title, cut at 200 characters; the frame's own when absent. |
{"v":1,"type":"open-dialog","id":1,"frame":"<frame>"}close-dialog
From a dialogs frame: closes its dialog and answers its opener with result. Ignored elsewhere.
| 成员 | 类型 | |
|---|---|---|
result | unknown | What the opener's open-dialog resolves with, at most 65536 bytes as JSON; larger is null. |
{"v":1,"type":"close-dialog","result":null}set-install-values
From a frame in the install wizard (install.frames): merges values into the install form's draft, as the user typed them, so the wizard's own validation and Rust's apply. result (null); invalid elsewhere.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
values | Record<string, unknown> | Install values to merge into the wizard's draft, at most 64; keys the type's install form does not declare are dropped. |
{"v":1,"type":"set-install-values","id":1,"values":{}}open-task-center-tab
Brings one of this extension's Task Center tabs forward, opening the Task Center if it is closed. result (null) once it is selected; invalid for a tab the application does not list for this extension.
回答方: host
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id, a finite number or non-empty text; its answer carries it. |
tab | string | The panel's or frame's own id in taskCenter.tabs; the application brings it forward. |
{"v":1,"type":"open-task-center-tab","id":1,"tab":"<tab>"}应用 → 页面
result
A request's answer.
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id. |
result | unknown | What the request answered. |
{"v":1,"type":"result","id":1,"result":null}error
A request failed.
| 成员 | 类型 | |
|---|---|---|
id | number | string | The request's id. |
error | { kind: FrameErrorKind; message: string } | unavailable (no backend, or it is down), timeout (it missed its bound), invalid, forbidden (only for state) or failed, and why. |
{"v":1,"type":"error","id":1,"error":null}event
A ui.frame.emit for this frame, of an event it subscribed to.
| 成员 | 类型 | |
|---|---|---|
event | string | The event's name. |
payload | unknown | What the backend sent with it. |
{"v":1,"type":"event","event":"<event>","payload":null}state
A push of the extension UI's state (ui.emit), after subscribe-state.
| 成员 | 类型 | |
|---|---|---|
state | unknown | The whole state. |
{"v":1,"type":"state","state":null}ping
Every 5 s once the frame is ready; answered by pong. A frame that answers none for 12 s is unavailable.
成员: 无成员
{"v":1,"type":"ping"}dialog-closed
How the dialog a frame opened ended; the same shape as a result.
| 成员 | 类型 | |
|---|---|---|
id | number | string | The open-dialog request's id. |
result | unknown | What the dialog's page closed it with. |
{"v":1,"type":"dialog-closed","id":1,"result":null}task-center-tab.shown
One of this extension's Task Center tabs became the selected one: its page may refresh what it shows without polling.
| 成员 | 类型 | |
|---|---|---|
tab | string | The panel's or frame's own id. |
{"v":1,"type":"task-center-tab.shown","tab":"<tab>"}theme
The application's theme and language, on ready and on every change of either.
| 成员 | 类型 | |
|---|---|---|
scheme | "light" | "dark" | The colour scheme. |
tokens | Record<string, string> | CSS variable name to value: the role tokens and every token the application sets on its root at run time. |
locale | string | The application's language, as its root's lang says. |
{"v":1,"type":"theme","scheme":"light","tokens":{},"locale":"<locale>"}layout
The box the host gave the page and how it is sized: from the frame's first load (before ready, so a page that measures itself on its first script already has it), on every ready again, and on every change of it.
| 成员 | 类型 | |
|---|---|---|
host | "toolbar" | "settings-section" | "management-section" | "page" | "dialog" | "task-center-tab" | "window" | The kind of place the frame is shown in, which is its sizing contract: a toolbar widget fills the bar's control height and never scrolls; a section's body is the height the page reports and the host scrolls it; a page, a dialog, a tab or a window fills what it is given. |
width | number | The box the host gave the page, in CSS pixels. |
height | number | null | The height the page is given and must fill, or null when the page reports its own with resize. |
scrolls | boolean | Whether the host scrolls the page's box, so the page must not. |
density | "compact" | "medium" | "wide" | Which of the design system's panel widths (480, 640, 1024) the box is at least as wide as. |
dpr | number | The device pixel ratio the box is drawn at. |
{"v":1,"type":"layout","host":"toolbar","width":1,"height":1,"scrolls":true,"density":"compact","dpr":1}backend
The extension's backend as its row says, on ready and on every change of it. A page whose backend is not up waits for it rather than failing its calls; one with no backend is told nothing.
| 成员 | 类型 | |
|---|---|---|
state | "starting" | "active" | "failed" | "stopped" | The extension's backend: coming up, up, failed (a crash loop included), or stopped (disabled, broken, incompatible). |
stage | "pythonRuntime" | "requirements" | "registration" | "dependency" | null | While starting, what it is doing; null otherwise. |
reason | string | null | Why it failed, while state is failed; null otherwise. |
{"v":1,"type":"backend","state":"starting","stage":"pythonRuntime","reason":"<reason>"}settings
The extension's settings changed — through its own form, another page of it, or its backend: every open page is told, so what it draws follows the setting without being reopened.
| 成员 | 类型 | |
|---|---|---|
values | Record<string, unknown> | The extension's stored settings after a write, as settings-get answers them. |
{"v":1,"type":"settings","values":{}}主题、语言与限制
应用随 theme 消息发送的颜色方案、CSS 变量和语言,以及视图高度和各项时限。
Beside these, theme carries every token the application sets on its root at run time.
lightdark
--text-primary--text-secondary--text-tertiary--text-disabled--text-on-accent--accent-fill--accent-fill-hover--accent-fill-pressed--accent-text--fill-card--fill-layer--fill-control--fill-control-hover--fill-control-pressed--fill-subtle-hover--fill-well--stroke-card--stroke-control--stroke-divider--focus-stroke-outer--danger--success--warning--info--radius-small--radius-control--radius-overlay--font-text--font-mono--font-size-caption--font-size-body--font-size-subtitle--font-size-title--line-height-caption--line-height-body--line-height-subtitle--line-height-title--weight-regular--weight-semibold--space-1--space-2--space-3--space-4--space-5--space-6--space-8--control-height-sm--control-height-md
The application's language, theme's locale; the client sets it as the page root's lang. en, zh
height.initial | 240 px |
height.min | 96 px |
height.max | 4096 px |
readyMs | 10 s |
pingIntervalMs | 5 s |
pongMs | 12 s |
dialogTitleMax | 200 |
updateValuesMax | 64 |
视图客户端
应用在每个扩展包根目录的保留路径提供的 ES 模块及其函数和类型。用法见界面。
__hanafubuki/frame.js · sdk/frame/frame.d.ts
ready
function ready(): voidTells the host the page is ready. Until it does, the host shows nothing; one that never does is unavailable after a few seconds. From then on the host sends the theme and the application's language, the box it gave the page (layout), and follows the page's height. The client applies the theme to the page's root (data-theme, color-scheme and the tokens as CSS variables, which the UI kit __hanafubuki/ui.css reads) and the language to its lang.
返回: void
locale
function locale(): string | nullThe application's language (en, zh; the root's lang too), or null until the host has sent the theme, which it does once the page is ready.
返回: string | null
onLocale
function onLocale(listener: (locale: string) => void): () => voidListens to the application's language: called when the host first sends it and on each change after; returns how to stop listening.
返回: () => void
layout
function layout(): FrameLayout | nullThe box the host last said it gave the page, or null until it has (from the frame's first load, which is before ready). The client also puts the host kind, scrolling and tier on the page's root as data-hf-host, data-hf-scrolls and data-hf-density, which the UI kit's body sizing rules read.
返回: FrameLayout | null
onLayout
function onLayout(listener: (layout: FrameLayout) => void): () => voidListens to each change of the page's box — on ready, when the window is resized, when the host's layout changes — the first included; returns how to stop listening.
返回: () => void
onLayoutReady
function onLayoutReady(listener: (layout: FrameLayout) => void): () => voidCalled once the host has said the page's box, which a host that sizes it does from the frame's first load — before the page's first script. A page that draws into its box waits for this rather than measuring a box not yet laid out. Returns how to stop listening; a page that already has its box hears it at once.
返回: () => void
backend
function backend(): FrameBackend | nullThe extension's backend as the host last said it is, or null until it has. The state is also on the page's root as data-hf-backend.
返回: FrameBackend | null
onBackend
function onBackend(listener: (backend: FrameBackend) => void): () => voidListens to the backend's state: the state as it is now (once the host has said it, which is on ready) and each change after. Returns how to stop listening. A page whose extension runs no backend hears nothing.
返回: () => void
onSettings
function onSettings(listener: (values: Record<string, unknown>) => void): () => voidListens to the extension's settings: called with the stored values each time they change — through its settings form, another of its pages, or its backend — so a page that draws from them keeps up without being reopened. Returns how to stop listening. Read getSettings once as well.
返回: () => void
call
function call<T = unknown>(method: string, params?: unknown): Promise<T>Calls method of the extension's backend (ui.frame.call, within its 30 s bound) and resolves with what it answered; rejects with a FrameError. A data-only extension's frame has no backend: every call fails unavailable.
返回: Promise<T>
on
function on<T = unknown>(event: string, listener: (payload: T) => void): () => voidListens to event, which the backend sends this frame (ui.frame.emit); returns how to stop listening.
返回: () => void
state
function state<T = unknown>(): Promise<T>Reads the state of the extension's UI (ui.state, with the frame's context; within 10 s) and resolves with it; rejects with a FrameError. Only a backend that announces the hook ui has one: otherwise it fails unavailable.
返回: Promise<T>
getSettings
function getSettings(): Promise<SettingsResult>Reads this frame owner's settings; works without an extension backend.
返回: Promise<SettingsResult>
patchSettings
function patchSettings(patch: Record<string, unknown>): Promise<SettingsResult>Patches this frame owner's declared settings through the host's validation and persistence. A null value removes that override. Returns all stored values after the write; works without an extension backend.
返回: Promise<SettingsResult>
onState
function onState<T = unknown>(listener: (state: T) => void): () => voidListens to each state the extension's UI pushes (ui.emit, the last of those within 100 ms); returns how to stop listening. A push is the whole state, the same for every frame and panel of the extension. Read state once as well: a state pushed before the page listened is not sent again.
返回: () => void
pickDirectory
function pickDirectory(options?: { title?: string; defaultPath?: string;}): Promise<string | null>Opens the application's folder dialog, titled title (cut at 200 characters), and resolves with the native path the user chose, or null when they cancelled. The page is given the path alone: it cannot read the folder, and only its backend acts on it.
返回: Promise<string | null>
pickFile
function pickFile(options?: { title?: string; defaultPath?: string; filters?: { name: string; extensions: string[] }[];}): Promise<string | null>Opens the native single-file dialog and resolves with the selected path or null on cancellation.
返回: Promise<string | null>
updateInstance
function updateInstance( values: Record<string, unknown>, mode?: "update" | "reinstall",): Promise<void>Updates or reinstalls the frame's instance after confirmation, with up to 64 install values replacing the recorded ones. When mode is omitted, a ready type with update steps is updated; other types reinstall in place. Rust validates the merged values. Resolves once it has started; its progress is the instance's install progress. Rejects with a FrameError of kind invalid outside an instance's management section, and failed when the user declines, another update is waiting for an answer, or the application refuses it.
返回: Promise<void>
navigateInstance
function navigateInstance(instanceId: string): Promise<void>Takes the user to an instance's page (/instances/<instanceId>), as a downloader does after registering one; resolves once the application is on its way there, which may close the frame.
返回: Promise<void>
openSettings
function openSettings(section: string): Promise<void>Opens a currently registered settings section. Unknown sections reject with FrameError.
返回: Promise<void>
openManagementSection
function openManagementSection(section: string, instanceId?: string): Promise<void>Opens Instance Management at section — a currently registered management section id, not a route — for instanceId, or for the instance this frame is in when it is omitted. Resolves once the window is on its way, which may close the frame. An unknown section rejects with FrameError invalid, and so does a page outside instance management that names no instance.
返回: Promise<void>
openExternal
function openExternal(url: string): Promise<void>Opens an HTTP(S) URL in the system browser. Rust validates it; invalid URLs or opener failures reject.
返回: Promise<void>
openWindow
function openWindow(frame: string): Promise<void>Open or focus a window declared by this extension.
返回: Promise<void>
resetOverlay
function resetOverlay(frame?: string): Promise<void>Reset this overlay in this window, or a named overlay of this extension in all windows.
返回: Promise<void>
reloadExtension
function reloadExtension(): Promise<void>Request a package reload. The host acknowledges before remounting its frames.
返回: Promise<void>
openDialog
function openDialog<T = unknown>( frame: string, options?: { title?: string },): Promise<T | null>Opens one of this extension's dialogs frames (kind = "frame", slot = "dialogs") in a dialog over the window, titled title or by the frame's own title. Resolves with what that page's closeDialog gave, or null when the user dismissed it. Rejects invalid for a frame that is not one of the extension's dialogs frames, and failed while another dialog is open.
返回: Promise<T | null>
closeDialog
function closeDialog(result?: unknown): voidFrom a dialogs frame: closes its dialog, resolving the opener's openDialog with result (any JSON under 64 KiB). Ignored in any other frame.
返回: void
setInstallValues
function setInstallValues(values: Record<string, unknown>): Promise<void>From a frame in the install wizard ([[install.frames]] of an instance type): merges values into the install form's draft as if the user typed them, so the wizard's own validation and Rust's apply; keys the type's install form does not declare are dropped, at most 64 kept. Resolves once merged; rejects invalid elsewhere.
返回: Promise<void>
openTaskCenterTab
function openTaskCenterTab(tab: string): Promise<void>Brings one of this extension's Task Center tabs (taskCenter.tabs) forward by the panel's or frame's own id, opening the Task Center if it is closed. Resolves once it is selected; rejects invalid for a tab the application does not list for this extension.
返回: Promise<void>
onTaskCenterTabShown
function onTaskCenterTabShown(listener: (tab: string) => void): () => voidFrom a Task Center tab's frame: called each time that tab becomes the shown one, tab its own id, so the page refreshes what it shows without polling; returns how to stop listening.
返回: () => void
FrameErrorKind
type FrameErrorKind = "unavailable" | "timeout" | "invalid" | "forbidden" | "failed"Why a call failed: the bridge's error type, or for state the extension UI's own (forbidden too). The host's own requests fail invalid (asked where they do not apply, or with members that do not read) or failed (the user declined, or the application refused).
FrameError
interface FrameError extends Error { name: "FrameError"; kind: FrameErrorKind;}A call's failure, as call rejects with it.
FrameHostKind
type FrameHostKind = | "toolbar" | "settings-section" | "management-section" | "page" | "dialog" | "task-center-tab" | "window"The kind of place the frame is shown in, which is its sizing contract: toolbar fills the bar's control height and never scrolls; settings-section and management-section sit in a body the host scrolls at the height the page reports; page, dialog, task-center-tab and window fill what they are given.
FrameDensity
type FrameDensity = "compact" | "medium" | "wide"Which of the design system's panel widths (480, 640, 1024) the box is at least as wide as.
FrameLayout
interface FrameLayout { host: FrameHostKind; width: number; /** The height the page must fill, or `null` when it reports its own height. */ height: number | null; /** Whether the host scrolls the page's box, so the page must not. */ scrolls: boolean; density: FrameDensity | null; /** The device pixel ratio the box is drawn at. */ dpr: number;}The box the host gave the page, in CSS pixels.
FrameBackendStage
type FrameBackendStage = "pythonRuntime" | "requirements" | "registration" | "dependency"What the backend is doing while it comes up.
FrameBackend
interface FrameBackend { /** `starting` (with `stage`), `active`, `failed` (with `reason`), or `stopped`. */ state: "starting" | "active" | "failed" | "stopped"; stage: FrameBackendStage | null; reason: string | null;}The extension's backend as its row says.
SettingsResult
interface SettingsResult { values: Record<string, unknown>;}The extension's current stored setting overrides, validated by the host.
界面套件
__hanafubuki/ui.css 提供的类,按组列出,并给出修饰类、属性和示例标记。
Vue 命名转场
将转场名传给 Vue 的 Transition 或 TransitionGroup 组件的 name 属性。
ambient-fadeaxis-backwardaxis-forwarddialog-popexpandfadefade-throughicon-swaplateral-backwardlateral-forwardpane-dockpopover-poptoast-poptoolbar-slotwindow-pop
CSS 关键帧
在 CSS 的 animation-name 属性中使用这些关键帧名称。
motion-blinkmotion-pulsemotion-revealmotion-ripplemotion-shimmermotion-shimmer-pulsemotion-spinmotion-sweep
Buttons
.btn
A button, 32px tall: a filled control with a slight raised edge, for every action that is not the primary one.
修饰类: .btn-primary, .btn-subtle, .btn-danger, .btn-icon, .btn-sm, .btn-lg
| 属性 | |
|---|---|
disabled | Unavailable. |
aria-disabled="true" | Unavailable but still focusable. |
<button class="btn">Save</button>.btn-primary
The accent fill: the single most important action in a view, at most one.
修饰: .btn
<button class="btn btn-primary">Save</button>.btn-subtle
No fill until hovered: toolbars, icon buttons, inline actions.
修饰: .btn
<button class="btn btn-subtle">Save</button>.btn-danger
Only the commit button of a destructive confirmation.
修饰: .btn
<button class="btn btn-danger">Save</button>.btn-icon
A fixed square holding an icon; a size resizes the square, not its padding.
修饰: .btn
<button class="btn btn-icon">Save</button>Fields
.form-grid
Fields at least 360px wide, as many to a row as the form's width allows, one when it is narrow.
修饰类: .span-all
<div class="form-grid"> <label>Name <input class="text-input" /></label> <label class="span-all">Notes <textarea class="text-input"></textarea></label></div>.text-input
A text field's box, on an <input>, a <textarea> or a box wrapping one: a filled control whose bottom edge becomes an accent underline while it has focus, its focus indicator.
| 属性 | |
|---|---|
disabled | Unavailable. |
aria-invalid="true" | Its value was refused. |
<input class="text-input" aria-invalid="true" />.field-error
An error in the danger colour, selectable, breaking anywhere.
<p class="field-error">The directory does not exist.</p>.panel-actions
The row of buttons that acts on a whole panel or form, at its foot.
<div class="panel-actions"> <button class="btn">Cancel</button> <button class="btn btn-primary">Apply</button></div>.checkbox
A 20px box on an <input type="checkbox">, for a choice among many; the words beside it name it through aria-labelledby.
| 属性 | |
|---|---|
checked | Checked. |
indeterminate | Mixed: the DOM property, not a class. |
disabled | Unavailable. |
<label class="check-row"> <input class="checkbox" type="checkbox" checked /> Keep the cache</label>Surfaces
.surface-card
A group of content inside a page or panel, raised by its fill and stroke; never a shadow.
<section class="surface-card">…</section>.surface-well
A sunken read-only region inside a card or panel: a list box, a readout, a log.
<pre class="surface-well mono">…</pre>.surface-floating
Anything laid over the content: a menu, a dropdown, a popover.
<div class="surface-floating" role="menu">…</div>Lists and navigation
.card-list
A run of related rows, each a card of its own, stacked 4px apart.
<ul class="card-list"> <li class="card-row"> <svg class="card-row__icon" aria-hidden="true"><!-- a glyph --></svg> <div class="card-row__text"> <span class="card-row__title">0.3.0</span> <span class="card-row__description">Released 2026-11-01</span> </div> <div class="card-row__control"><button class="btn btn-primary">Install</button></div> </li></ul>.card-row
A row of a card-list, at least 64px tall: an optional icon, its words and its control.
示例见: .card-list
.menu-item
The one row every menu, dropdown list, picker and palette draws, 32px tall.
修饰类: .is-active, .is-danger
| 属性 | |
|---|---|
disabled | Unavailable. |
aria-disabled="true" | Unavailable but still focusable. |
<button class="menu-item" role="menuitem">Rename</button>.is-active
The keyboard cursor on a menu-item, for a list whose focus stays in its field or trigger.
修饰: .menu-item
<button class="menu-item is-active" role="menuitem">Rename</button>.is-danger
A destructive menu-item, said by its colour alone.
修饰: .menu-item
<button class="menu-item is-danger" role="menuitem">Rename</button>.tabs
A tab list of tab buttons, with no track.
<div class="tabs" role="tablist" aria-label="Versions"> <button class="tab" role="tab" aria-selected="true">Installed</button> <button class="tab" role="tab" aria-selected="false">Available</button></div>Messages and progress
.info-bar
An inline message about a page, panel or form, tinted with its severity; information without one.
| 属性 | |
|---|---|
data-severity="error | warning | success" | Its severity. |
<div class="info-bar" data-severity="warning" role="alert"> <svg class="info-bar__icon" aria-hidden="true"><!-- a warning glyph --></svg> <p class="info-bar__text"> <strong class="info-bar__title">Not installed</strong> <span class="info-bar__message">Install a version to start.</span> </p> <div class="info-bar__action"><button class="btn btn-sm">Install</button></div> <button class="info-bar__dismiss btn btn-subtle btn-sm btn-icon" aria-label="Dismiss">×</button></div>.progress-bar
A 2px track holding progress-bar__fill; the element carries role="progressbar", a label, and aria-valuenow unless the amount is unknown.
修饰类: .indeterminate, .stepped
| 属性 | |
|---|---|
data-size="lg" | 4px: the one primary bar of a surface whose content is the progress. |
data-tone="success | warning | danger | muted" | The fill's colour: danger failed, muted held; the accent without it. |
<div class="progress-bar" role="progressbar" aria-label="Downloading" aria-valuenow="40"> <div class="progress-bar__fill" style="width: 40%"></div></div>.indeterminate
An unknown amount: a stripe travels the track.
修饰: .progress-bar
<div class="progress-bar indeterminate" role="progressbar" aria-label="Downloading" aria-valuenow="40"> <div class="progress-bar__fill" style="width: 40%"></div></div>.stepped
Each jump of the fill eases over a phase.
修饰: .progress-bar
<div class="progress-bar stepped" role="progressbar" aria-label="Downloading" aria-valuenow="40"> <div class="progress-bar__fill" style="width: 40%"></div></div>Shared transitions
.text-arrived
Fade in each newly rendered run of streamed text.
<span class="text-arrived">{{ chunk }}</span>.expand-region
A single-row grid for the expand transition.
<Transition name="expand" v-bind="expandGapHooks"> <div v-if="open" class="expand-region"><div class="expand-clip">…</div></div></Transition>.toolbar-slot
A toolbar control's animated grid slot.
<Transition name="toolbar-slot"> <div v-if="visible" class="toolbar-slot"><div class="toolbar-slot-body">…</div></div></Transition>.reveal-host
Reveal descendant hover-reveal controls on hover or focus within.
<div class="reveal-host">Report <button class="hover-reveal">Copy</button></div>.hover-reveal
A control that retains its space and keyboard focusability while hidden.
示例见: .reveal-host
.disclosure-chevron
Turn a glyph when its ancestor has aria-expanded="true" or the glyph has is-open.
修饰类: .is-open
| 属性 | |
|---|---|
data-turn="half" | Turn halfway instead of a quarter turn. |
<button :aria-expanded="open">Details <span class="disclosure-chevron">›</span></button>.is-open
Mark the disclosure chevron as expanded.
<button :aria-expanded="open">Details <span class="disclosure-chevron is-open">›</span></button>.lateral-host
A one-cell grid for lateral-forward/backward Vue transitions; outgoing lifted panels retain their measured box.
示例见: size-swap
.media-arrival
Fade decoded media into the space reserved by its placeholder.
修饰类: .is-loaded
<img class="media-arrival" src="cover.webp" alt="Cover" />示例见: surface-motion
.is-loaded
Reveal decoded media marked with media-arrival.
修饰: .media-arrival
<img class="media-arrival is-loaded" src="cover.webp" alt="Cover" />.pane-motion
Coordinate a docking pane's size and content with the --motion-pane-size and --motion-pane-content tokens.
| 属性 | |
|---|---|
data-pane-open | Present while the pane is open. |
<aside class="pane-motion" :data-pane-open="open ? '' : undefined">…</aside>示例见: surface-motion
.dialog-panel
The visible panel inside a dialog-pop overlay.
<Transition name="dialog-pop"> <div v-if="open"><section class="dialog-panel" role="dialog" aria-label="Settings">…</section></div></Transition>.window-panel
The visible panel inside a window-pop overlay.
<Transition name="window-pop"> <div v-if="open"><section class="window-panel">…</section></div></Transition>Helpers
.focus-inset
The focus rings drawn inside the box, for a row its container clips.
<button class="menu-item focus-inset">Open</button>.spin
The busy spinner: on the icon that should turn.
<svg class="spin" aria-hidden="true"><!-- a spinner glyph --></svg>.pulse
A dot breathing while something is live: on the dot.
<span class="pulse" aria-hidden="true"></span>.caret-blink
Blink the caret at the end of streaming text.
<span class="caret-blink" aria-hidden="true">▍</span>.text-secondary
Text in the secondary colour.
<span class="text-secondary">Last run 2 minutes ago</span>.mono
Monospaced, selectable text that breaks anywhere.
<code class="mono">C:\models\sd15.safetensors</code>面板块
面板(kind = "schema" 的 ui 项)中的块。每种块列出应用如何渲染它、块在面板文件中的写法,以及渲染时读取的数据。
The blocks' and fields' data shapes are the backend export's JSON Schema; this is how the application renders them.
渲染组件: src/settings/sections/extensions/ExtensionPanel.vue
ExtensionPanel
A schema panel, as its JSON file is written.
blocksPanelBlock[]必填未声明 Schema 默认PanelBlock
以下之一:
kind: "info"Key/value rows.
idstring必填未声明 Schema 默认kind"info"必填未声明 Schema 默认pathstring | null可选Schema 默认nullsourcePanelSource可选Schema 默认"query"titleSchemaText | null可选Schema 默认nullText a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
kind: "actions"Buttons, each pressing it calls the backend.
actionsPanelAction[]必填未声明 Schema 默认PanelAction
cardMenuboolean可选Schema 默认falseOffer this shortcut in the matching instance card's menu.
confirmSchemaText | null可选Schema 默认nullAsked before it runs.
SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
fieldsSchemaField[]可选Schema 默认[]Its form: form-schema fields as an extension's settings are. A list's actions have none.
SchemaField
advancedboolean可选未声明 Schema 默认It has a working default, so a creation form keeps it out of the way.
commitCommitMode | null可选未声明 Schema 默认Settings only: when its editor submits it.
CommitMode
以下之一:
"change"A discrete value; committing on change never sees a partial one.
"blur"Free text or a number; once the field is left or Enter is pressed.
"manual"Behind an explicit Save: persisting it has a side effect an intermediate value would make visible.
defaultSchemaValue | null可选未声明 Schema 默认A value a field holds.
disabledReasonSchemaText | null可选未声明 Schema 默认Shown while
disabledWhenholds.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
disabledWhenSchemaCondition | null可选未声明 Schema 默认When a condition holds, over the form's current values: a field equal to a value, or any or all of several conditions. Decoded where a form comes from outside the application (a descriptor), and checked there.
SchemaCondition
至少满足一项:
objectequalsSchemaValue必填未声明 Schema 默认A value a field holds.
keystring必填未声明 Schema 默认
objectanySchemaCondition[]必填未声明 Schema 默认(递归,结构同上)
objectallSchemaCondition[]必填未声明 Schema 默认(递归,结构同上)
helpSchemaText | null可选未声明 Schema 默认Text a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
keystring必填未声明 Schema 默认kindFieldKind必填未声明 Schema 默认What a field edits, and so which control shows it.
FieldKind
以下之一:
"text" | "boolean""number"Within
min/max, onstepfromminwhen given."select"One of
options."multiselect"Any of
options, as a list."path"A directory or a file (
pathKind)."secret"Text the control does not show.
"slider"A number between
minandmax, which a slider needs."textarea"Text of several lines.
labelSchemaText必填未声明 Schema 默认Text a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
maxnumber | null可选未声明 Schema 默认minnumber | null可选未声明 Schema 默认nullableboolean可选未声明 Schema 默认No value is a value the user can choose: a select or a boolean offers it as an entry (
unsetLabel), text as a blank.optionsSchemaOption[]可选未声明 Schema 默认SchemaOption
labelSchemaText必填未声明 Schema 默认Text a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
valuestring必填未声明 Schema 默认
optionsSourcestring | null可选未声明 Schema 默认The name of an option list the form's host fetches at run time (an install catalog's
branches), offered afteroptions. Rust checks the value against the same list when it uses it.patchGroupstring | null可选未声明 Schema 默认Settings only: the fields Rust validates together, which an editor submits together rather than restating the rule that binds them.
pathKindPathKind | null可选未声明 Schema 默认requiredboolean可选未声明 Schema 默认requiredWhenSchemaCondition | null可选未声明 Schema 默认When a condition holds, over the form's current values: a field equal to a value, or any or all of several conditions. Decoded where a form comes from outside the application (a descriptor), and checked there.
SchemaCondition
至少满足一项:
objectequalsSchemaValue必填未声明 Schema 默认A value a field holds.
keystring必填未声明 Schema 默认
objectanySchemaCondition[]必填未声明 Schema 默认(递归,结构同上)
objectallSchemaCondition[]必填未声明 Schema 默认(递归,结构同上)
stepnumber | null可选未声明 Schema 默认unsetLabelSchemaText | null可选未声明 Schema 默认Text a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
visibleWhenSchemaCondition | null可选未声明 Schema 默认While the condition does not hold the field is hidden and its value is not submitted.
SchemaCondition
至少满足一项:
objectequalsSchemaValue必填未声明 Schema 默认A value a field holds.
keystring必填未声明 Schema 默认
objectanySchemaCondition[]必填未声明 Schema 默认(递归,结构同上)
objectallSchemaCondition[]必填未声明 Schema 默认(递归,结构同上)
iconPanelIcon | null可选未声明 Schema 默认Its icon in the title bar, as the panel's.
PanelIcon
至少满足一项:
objectA Lucide icon by its kebab-case name (
rocket,external-link).lucidestring必填未声明 Schema 默认
objectAn image file of the package, by a path relative to its root.
filestring必填未声明 Schema 默认
idstring必填未声明 Schema 默认labelSchemaText必填未声明 Schema 默认Text a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
openUiDestination | null可选未声明 Schema 默认Opens this package's declared page, settings entry or dialog in the caller's window.
UiDestination
以下之一:
objectadditionalProperties:falsepagestring必填未声明 Schema 默认
objectadditionalProperties:falsesettingsstring必填未声明 Schema 默认
objectadditionalProperties:falsedialogstring必填未声明 Schema 默认
objectadditionalProperties:falsewindowstring必填未声明 Schema 默认
operationstring | null可选未声明 Schema 默认A management button may use the current type's exclusive operation and its form.
rowFieldstring | null可选未声明 Schema 默认A list operation binds the selected row id to this text field of its form.
toolbarToolbarPlacement | null可选未声明 Schema 默认Where an instance management panel or one of its actions is offered.
ToolbarPlacement
以下之一:
"button" | "externalBrowser""openUrl"In place of the ordinary shortcuts: opens an HTTP(S) address in the user's browser, the action's declared
urlor the one its answer names, without a management panel.urlstring | null可选未声明 Schema 默认A
toolbar = "openUrl"shortcut's address, opened when it is pressed; one its answer names takes precedence.
idstring必填未声明 Schema 默认kind"actions"必填未声明 Schema 默认titleSchemaText | null可选Schema 默认nullText a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
kind: "table"Where a block's data comes from: its backend's answer to
ui.panel.query(the default), orpathin the state its backend's UI pushes ("source": "state"), a dotted path of object keys (none: the whole state). What is there is written as the query's answer would be.columnsPanelColumn[]必填未声明 Schema 默认PanelColumn
keystring必填未声明 Schema 默认labelSchemaText必填未声明 Schema 默认Text a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.kind"literal"必填未声明 Schema 默认textRecord<string, string>必填未声明 Schema 默认
idstring必填未声明 Schema 默认kind"table"必填未声明 Schema 默认pathstring | null可选Schema 默认nullsourcePanelSource可选Schema 默认"query"titleSchemaText | null可选Schema 默认nullText a form shows: a message key of the frontend's locale tables, or text by locale. Decoded where a form comes from outside the application (an extension's settings), whose keys
SchemaText::scoped_toconfines.SchemaText
以下之一:
kind: "key"keystring必填未声明 Schema 默认kind"key"必填未声明 Schema 默认paramsRecord<string, string>可选未声明 Schema 默认Named interpolation values for the message.
kind: "literal"By locale (
en,zh, …). A locale it lacks shows the English, and text with no English shows the first locale it has.