@njuptlzf/agent-chat-web 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentChat.d.ts +34 -0
- package/dist/AgentChat.js +373 -0
- package/dist/AgentChatApp.d.ts +34 -0
- package/dist/AgentChatApp.js +90 -0
- package/dist/DockPanel.d.ts +22 -0
- package/dist/DockPanel.js +22 -0
- package/dist/PersonasPage.d.ts +1 -0
- package/dist/PersonasPage.js +326 -0
- package/dist/adapter.d.ts +52 -0
- package/dist/adapter.js +242 -0
- package/dist/app-def-check.d.ts +50 -0
- package/dist/app-def-check.js +184 -0
- package/dist/app.d.ts +112 -0
- package/dist/app.js +174 -0
- package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
- package/dist/assets/exceljs.min-jlEt4kSc.js +29 -0
- package/dist/assets/index-B7uSE8SM.css +1 -0
- package/dist/assets/index-D57mU5H5.js +50 -0
- package/dist/assets/index-Dviy7gnB.js +44 -0
- package/dist/assets/pdf-CfhDiWmk.js +55 -0
- package/dist/assets/pdf.worker.min-CdXBBzB4.js +1 -0
- package/dist/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/dist/auth.d.ts +41 -0
- package/dist/auth.js +86 -0
- package/dist/dock.d.ts +52 -0
- package/dist/dock.js +132 -0
- package/dist/docs.d.ts +48 -0
- package/dist/docs.js +178 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.html +13 -0
- package/dist/index.js +8 -0
- package/dist/mount.d.ts +56 -0
- package/dist/mount.js +38 -0
- package/dist/qual.d.ts +21 -0
- package/dist/qual.js +53 -0
- package/dist/sse.d.ts +14 -0
- package/dist/sse.js +99 -0
- package/dist/styles.css +1492 -0
- package/dist/suggestions.d.ts +41 -0
- package/dist/suggestions.js +98 -0
- package/dist/theme.d.ts +10 -0
- package/dist/theme.js +14 -0
- package/dist/ui/CodeCopyHeader.d.ts +7 -0
- package/dist/ui/CodeCopyHeader.js +22 -0
- package/dist/ui/ConfirmCard.d.ts +15 -0
- package/dist/ui/ConfirmCard.js +9 -0
- package/dist/ui/FollowUpSuggestions.d.ts +9 -0
- package/dist/ui/FollowUpSuggestions.js +13 -0
- package/dist/ui/Icon.d.ts +8 -0
- package/dist/ui/Icon.js +26 -0
- package/dist/ui/Lightbox.d.ts +6 -0
- package/dist/ui/Lightbox.js +31 -0
- package/dist/ui/QueueBar.d.ts +44 -0
- package/dist/ui/QueueBar.js +17 -0
- package/dist/ui/Splitter.d.ts +27 -0
- package/dist/ui/Splitter.js +61 -0
- package/dist/ui/ThemeToggle.d.ts +2 -0
- package/dist/ui/ThemeToggle.js +16 -0
- package/dist/ui/TierPicker.d.ts +14 -0
- package/dist/ui/TierPicker.js +54 -0
- package/dist/ui/UIPromptCard.d.ts +17 -0
- package/dist/ui/UIPromptCard.js +18 -0
- package/dist/ui/icons.d.ts +19 -0
- package/dist/ui/icons.js +25 -0
- package/dist/ui/slots.d.ts +23 -0
- package/dist/ui/slots.js +13 -0
- package/dist/ui/timefmt.d.ts +35 -0
- package/dist/ui/timefmt.js +110 -0
- package/dist/ui/useNarrow.d.ts +7 -0
- package/dist/ui/useNarrow.js +15 -0
- package/package.json +14 -11
- package/src/App.tsx +13 -0
- package/src/agent-chat/AgentChat.tsx +39 -2
- package/src/agent-chat/AgentChatApp.tsx +5 -0
- package/src/agent-chat/{Dock.tsx → DockPanel.tsx} +73 -73
- package/src/agent-chat/PersonasPage.tsx +28 -1
- package/src/agent-chat/mount.tsx +130 -123
- package/src/agent-chat/suggestions.ts +127 -0
- package/src/agent-chat/ui/FollowUpSuggestions.tsx +28 -0
- package/src/agent-chat/ui/Icon.tsx +53 -0
- package/src/agent-chat/ui/icons.ts +31 -0
- package/src/agent-chat/ui/slots.tsx +35 -0
- package/src/fake-product/entry.tsx +63 -0
- package/src/main.tsx +8 -0
- package/src/styles.css +15 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 「下一步建议」的前端层:生效模式解析 + 自定义 `SuggestionAdapter`。
|
|
3
|
+
*
|
|
4
|
+
* 挂载走 `@assistant-ui` 原生 `adapters.suggestion`(run 结束自动生成、run 开始
|
|
5
|
+
* 自动清空),不自造状态机。数据来源由服务端决定:`llm` 调 `/api/suggestions`,
|
|
6
|
+
* `static` 直接用 `branding.ui.followUp.static`;任何失败静默返回空——建议区
|
|
7
|
+
* 消失而不是报错。
|
|
8
|
+
*/
|
|
9
|
+
import type { BrandingResponse } from "@njuptlzf/agent-chat-protocol";
|
|
10
|
+
import type { SuggestionAdapter } from "@assistant-ui/react";
|
|
11
|
+
export type FollowUpMode = "off" | "static" | "llm";
|
|
12
|
+
/**
|
|
13
|
+
* 与服务端 `SUGGESTIONS_DEFAULTS` 各持一份的缺省值(两个包不共享模块,
|
|
14
|
+
* 单测钉住两边一致)——改这里要同步那边。
|
|
15
|
+
*/
|
|
16
|
+
export declare const FOLLOW_UP_DEFAULTS: {
|
|
17
|
+
readonly count: 3;
|
|
18
|
+
readonly maxMessages: 10;
|
|
19
|
+
readonly messageChars: 500;
|
|
20
|
+
readonly totalChars: 4000;
|
|
21
|
+
};
|
|
22
|
+
/** 解析后的下一步建议配置(服务端已校验,这里再兜一道)。 */
|
|
23
|
+
export interface FollowUpConfig {
|
|
24
|
+
count: number;
|
|
25
|
+
maxMessages: number;
|
|
26
|
+
staticFallback: string[];
|
|
27
|
+
}
|
|
28
|
+
/** `branding.ui.followUp` 的声明形状(BrandingUi 未导出,用索引访问拿类型)。 */
|
|
29
|
+
type FollowUpDecl = NonNullable<BrandingResponse["ui"]>["followUp"];
|
|
30
|
+
/** `branding.ui.followUp` → 前端配置;缺字段走缺省,非法值回落。 */
|
|
31
|
+
export declare function followUpConfigOf(decl?: FollowUpDecl): FollowUpConfig;
|
|
32
|
+
/**
|
|
33
|
+
* 生效模式:**全局 `off` 是硬地板**——全局关掉后任何人格都不能重新打开;
|
|
34
|
+
* 否则人格 `followUpMode` > 全局 `mode` > 缺省 `llm`。默认助手(persona 为
|
|
35
|
+
* undefined)用 `branding.defaultPersona` 兜底;该人格不在 personas 表里时回落全局。
|
|
36
|
+
* 服务端 `/api/suggestions` 用同一套优先级复核,两边必须一致。
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveFollowUpMode(branding: BrandingResponse, persona?: string): FollowUpMode;
|
|
39
|
+
/** `off` 不产生 adapter(库不生成建议);`static` 本地返回、`llm` 请求服务端。 */
|
|
40
|
+
export declare function createFollowUpAdapter(cfg: FollowUpConfig, mode: Exclude<FollowUpMode, "off">, personaId?: string): SuggestionAdapter;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { apiHeaders, auth } from "./auth.js";
|
|
2
|
+
const MODES = ["off", "static", "llm"];
|
|
3
|
+
const isMode = (v) => typeof v === "string" && MODES.includes(v);
|
|
4
|
+
/**
|
|
5
|
+
* 与服务端 `SUGGESTIONS_DEFAULTS` 各持一份的缺省值(两个包不共享模块,
|
|
6
|
+
* 单测钉住两边一致)——改这里要同步那边。
|
|
7
|
+
*/
|
|
8
|
+
export const FOLLOW_UP_DEFAULTS = {
|
|
9
|
+
count: 3,
|
|
10
|
+
maxMessages: 10,
|
|
11
|
+
messageChars: 500,
|
|
12
|
+
totalChars: 4000,
|
|
13
|
+
};
|
|
14
|
+
/** `branding.ui.followUp` → 前端配置;缺字段走缺省,非法值回落。 */
|
|
15
|
+
export function followUpConfigOf(decl) {
|
|
16
|
+
const count = typeof decl?.count === "number" && Number.isInteger(decl.count) && decl.count >= 1 && decl.count <= 5
|
|
17
|
+
? decl.count
|
|
18
|
+
: FOLLOW_UP_DEFAULTS.count;
|
|
19
|
+
const maxMessages = typeof decl?.maxMessages === "number" && Number.isInteger(decl.maxMessages) && decl.maxMessages >= 1 && decl.maxMessages <= 20
|
|
20
|
+
? decl.maxMessages
|
|
21
|
+
: FOLLOW_UP_DEFAULTS.maxMessages;
|
|
22
|
+
const staticFallback = Array.isArray(decl?.static)
|
|
23
|
+
? decl.static.filter((s) => typeof s === "string" && s.trim() !== "").map((s) => s.trim())
|
|
24
|
+
: [];
|
|
25
|
+
return { count, maxMessages, staticFallback };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 生效模式:**全局 `off` 是硬地板**——全局关掉后任何人格都不能重新打开;
|
|
29
|
+
* 否则人格 `followUpMode` > 全局 `mode` > 缺省 `llm`。默认助手(persona 为
|
|
30
|
+
* undefined)用 `branding.defaultPersona` 兜底;该人格不在 personas 表里时回落全局。
|
|
31
|
+
* 服务端 `/api/suggestions` 用同一套优先级复核,两边必须一致。
|
|
32
|
+
*/
|
|
33
|
+
export function resolveFollowUpMode(branding, persona) {
|
|
34
|
+
const globalMode = isMode(branding.ui?.followUp?.mode) ? branding.ui.followUp.mode : "llm";
|
|
35
|
+
if (globalMode === "off")
|
|
36
|
+
return "off";
|
|
37
|
+
const id = persona ?? branding.defaultPersona;
|
|
38
|
+
const perPersona = id ? branding.personas?.[id]?.followUpMode : undefined;
|
|
39
|
+
return isMode(perPersona) ? perPersona : globalMode;
|
|
40
|
+
}
|
|
41
|
+
/** 只留文本 part(图片/附件/工具细节不出前端),再套单条与总量上限。 */
|
|
42
|
+
function clipForRequest(messages, maxMessages) {
|
|
43
|
+
const kept = [];
|
|
44
|
+
for (const message of messages) {
|
|
45
|
+
if (message.role !== "user" && message.role !== "assistant")
|
|
46
|
+
continue;
|
|
47
|
+
for (const part of message.content ?? []) {
|
|
48
|
+
if (part?.type !== "text" || typeof part.text !== "string")
|
|
49
|
+
continue;
|
|
50
|
+
const text = part.text.trim();
|
|
51
|
+
if (!text)
|
|
52
|
+
continue;
|
|
53
|
+
kept.push({ role: message.role, text: text.slice(0, FOLLOW_UP_DEFAULTS.messageChars) });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const window = kept.slice(-Math.max(1, maxMessages));
|
|
57
|
+
let total = 0;
|
|
58
|
+
const out = [];
|
|
59
|
+
for (let i = window.length - 1; i >= 0; i--) {
|
|
60
|
+
total += window[i].text.length;
|
|
61
|
+
if (total > FOLLOW_UP_DEFAULTS.totalChars)
|
|
62
|
+
break;
|
|
63
|
+
out.unshift(window[i]);
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/** `off` 不产生 adapter(库不生成建议);`static` 本地返回、`llm` 请求服务端。 */
|
|
68
|
+
export function createFollowUpAdapter(cfg, mode, personaId) {
|
|
69
|
+
if (mode === "static") {
|
|
70
|
+
const suggestions = cfg.staticFallback.slice(0, cfg.count).map((prompt) => ({ prompt }));
|
|
71
|
+
return { generate: () => Promise.resolve(suggestions) };
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
async generate({ messages, signal }) {
|
|
75
|
+
try {
|
|
76
|
+
// 不用 postJson(不带 signal):这里的 abort 由库的 suggestion controller 驱动。
|
|
77
|
+
const res = await fetch("/api/suggestions", {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "content-type": "application/json", ...apiHeaders(auth.token) },
|
|
80
|
+
body: JSON.stringify({ messages: clipForRequest(messages, cfg.maxMessages), persona: personaId }),
|
|
81
|
+
signal,
|
|
82
|
+
});
|
|
83
|
+
if (!res.ok)
|
|
84
|
+
return [];
|
|
85
|
+
const data = (await res.json());
|
|
86
|
+
if (!Array.isArray(data.suggestions))
|
|
87
|
+
return [];
|
|
88
|
+
return data.suggestions
|
|
89
|
+
.filter((s) => typeof s === "string" && s.trim() !== "")
|
|
90
|
+
.slice(0, cfg.count)
|
|
91
|
+
.map((prompt) => ({ prompt }));
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme mode (L2): "auto" follows the OS via `color-scheme: light dark` +
|
|
3
|
+
* light-dark() tokens; "light"/dark" pin it with a data-theme attribute on
|
|
4
|
+
* <html>. The choice persists per browser (localStorage) — it is a device
|
|
5
|
+
* preference, not product state, so it never travels through the protocol.
|
|
6
|
+
*/
|
|
7
|
+
export type ThemeMode = "auto" | "light" | "dark";
|
|
8
|
+
export declare function loadThemeMode(): ThemeMode;
|
|
9
|
+
export declare function applyThemeMode(mode: ThemeMode): void;
|
|
10
|
+
export declare function saveThemeMode(mode: ThemeMode): void;
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const KEY = "ac.theme";
|
|
2
|
+
export function loadThemeMode() {
|
|
3
|
+
const v = globalThis.localStorage?.getItem(KEY);
|
|
4
|
+
return v === "light" || v === "dark" ? v : "auto";
|
|
5
|
+
}
|
|
6
|
+
export function applyThemeMode(mode) {
|
|
7
|
+
if (mode === "auto")
|
|
8
|
+
document.documentElement.removeAttribute("data-theme");
|
|
9
|
+
else
|
|
10
|
+
document.documentElement.setAttribute("data-theme", mode);
|
|
11
|
+
}
|
|
12
|
+
export function saveThemeMode(mode) {
|
|
13
|
+
globalThis.localStorage?.setItem(KEY, mode);
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CodeHeaderProps } from "@assistant-ui/react-markdown";
|
|
2
|
+
/**
|
|
3
|
+
* Code-fence header with a copy button (assistant-ui's default CodeHeader
|
|
4
|
+
* renders nothing). It receives the raw `code` from the primitive, so there is
|
|
5
|
+
* no DOM scraping here — the string the model emitted is the string copied.
|
|
6
|
+
*/
|
|
7
|
+
export default function CodeCopyHeader({ language, code }: CodeHeaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Code-fence header with a copy button (assistant-ui's default CodeHeader
|
|
5
|
+
* renders nothing). It receives the raw `code` from the primitive, so there is
|
|
6
|
+
* no DOM scraping here — the string the model emitted is the string copied.
|
|
7
|
+
*/
|
|
8
|
+
export default function CodeCopyHeader({ language, code }) {
|
|
9
|
+
const [copied, setCopied] = useState(false);
|
|
10
|
+
const copy = async () => {
|
|
11
|
+
try {
|
|
12
|
+
await navigator.clipboard.writeText(code);
|
|
13
|
+
setCopied(true);
|
|
14
|
+
setTimeout(() => setCopied(false), 1500);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Clipboard can be refused (permissions/insecure context): stay silent,
|
|
18
|
+
// the code is still selectable by hand.
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return (_jsxs("div", { className: "code-head", children: [_jsx("span", { className: "code-lang", children: language || "text" }), _jsx("button", { type: "button", className: "copy-code", onClick: () => void copy(), children: copied ? "已复制" : "复制" })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ConfirmRequest {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
toolCallId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
args: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Tool-execution permission card (`tool_confirm` event, custom component UI-R3).
|
|
9
|
+
* assistant-ui has no server-parked approval primitive; answering POSTs
|
|
10
|
+
* /api/decision — the caller (ChatApp) keeps that plumbing, this is pure view.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ConfirmCard({ request, onAnswer, }: {
|
|
13
|
+
request: ConfirmRequest;
|
|
14
|
+
onAnswer: (allow: boolean) => void;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Tool-execution permission card (`tool_confirm` event, custom component UI-R3).
|
|
4
|
+
* assistant-ui has no server-parked approval primitive; answering POSTs
|
|
5
|
+
* /api/decision — the caller (ChatApp) keeps that plumbing, this is pure view.
|
|
6
|
+
*/
|
|
7
|
+
export function ConfirmCard({ request, onAnswer, }) {
|
|
8
|
+
return (_jsxs("div", { className: "confirm", children: [_jsxs("div", { className: "confirm-title", children: ["\u26A0\uFE0F \u52A9\u624B\u8BF7\u6C42\u6267\u884C ", _jsx("b", { children: request.name }), "\uFF0C\u662F\u5426\u5141\u8BB8\uFF1F"] }), _jsx("pre", { className: "confirm-args", children: JSON.stringify(request.args, null, 2) }), _jsxs("div", { className: "confirm-actions", children: [_jsx("button", { className: "allow", onClick: () => onAnswer(true), children: "\u5141\u8BB8" }), _jsx("button", { className: "deny", onClick: () => onAnswer(false), children: "\u62D2\u7EDD" })] })] }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 轮次结束后的「下一步建议」条。数据由库的 suggestion adapter 生成(run 结束自动
|
|
3
|
+
* 触发、run 开始自动清空),这里只负责渲染。必须渲染在 `ThreadPrimitive.Root` 内。
|
|
4
|
+
*
|
|
5
|
+
* `ThreadPrimitive.Suggestions` 本身不渲染包裹元素(空建议时返回 null),所以这里
|
|
6
|
+
* 提供一层 `.ac-followup` 容器;容器空时由 CSS `:empty` 收起,不留空白条。
|
|
7
|
+
* 点击即发送(`send`),与空态快捷问法 chips 的行为一致。
|
|
8
|
+
*/
|
|
9
|
+
export declare function FollowUpSuggestions(): import("react").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ThreadPrimitive } from "@assistant-ui/react";
|
|
3
|
+
/**
|
|
4
|
+
* 轮次结束后的「下一步建议」条。数据由库的 suggestion adapter 生成(run 结束自动
|
|
5
|
+
* 触发、run 开始自动清空),这里只负责渲染。必须渲染在 `ThreadPrimitive.Root` 内。
|
|
6
|
+
*
|
|
7
|
+
* `ThreadPrimitive.Suggestions` 本身不渲染包裹元素(空建议时返回 null),所以这里
|
|
8
|
+
* 提供一层 `.ac-followup` 容器;容器空时由 CSS `:empty` 收起,不留空白条。
|
|
9
|
+
* 点击即发送(`send`),与空态快捷问法 chips 的行为一致。
|
|
10
|
+
*/
|
|
11
|
+
export function FollowUpSuggestions() {
|
|
12
|
+
return (_jsx("div", { className: "ac-followup", children: _jsx(ThreadPrimitive.Suggestions, { children: ({ suggestion }) => (_jsx(ThreadPrimitive.Suggestion, { className: "ac-followup-chip", prompt: suggestion.prompt, send: true, title: suggestion.prompt, children: suggestion.title })) }) }));
|
|
13
|
+
}
|
package/dist/ui/Icon.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { parseIconSpec } from "./icons.js";
|
|
3
|
+
/**
|
|
4
|
+
* 内置 SVG(24×24 线框,stroke 走 currentColor 跟随主题,不引任何图标库)。
|
|
5
|
+
* 用惰性函数而不是模块级 JSX 常量:node 侧测试经 tsx 加载本模块时用的是
|
|
6
|
+
* classic JSX 运行时,模块级 JSX 会在 import 期执行 `React.createElement`
|
|
7
|
+
* 直接炸掉;渲染期执行就没有这个问题(浏览器走 react-jsx 自动运行时)。
|
|
8
|
+
*/
|
|
9
|
+
const PATHS = {
|
|
10
|
+
paperclip: () => (_jsx("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })),
|
|
11
|
+
plus: () => _jsx("path", { d: "M12 5v14M5 12h14" }),
|
|
12
|
+
image: () => (_jsxs(_Fragment, { children: [_jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), _jsx("circle", { cx: "8.5", cy: "8.5", r: "1.5" }), _jsx("polyline", { points: "21 15 16 10 5 21" })] })),
|
|
13
|
+
upload: () => (_jsxs(_Fragment, { children: [_jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), _jsx("polyline", { points: "17 8 12 3 7 8" }), _jsx("line", { x1: "12", y1: "3", x2: "12", y2: "15" })] })),
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 槽位用的图标渲染器。svg 走白名单 JSX(绝不用 dangerouslySetInnerHTML)、
|
|
17
|
+
* 文本走 React 文本节点、url 走 `<img>`(协议已在 parseIconSpec 校验)。
|
|
18
|
+
*/
|
|
19
|
+
export function Icon({ spec, className = "ac-icon" }) {
|
|
20
|
+
const icon = parseIconSpec(spec);
|
|
21
|
+
if (icon.kind === "url")
|
|
22
|
+
return _jsx("img", { className: className, src: icon.href, alt: "" });
|
|
23
|
+
if (icon.kind === "text")
|
|
24
|
+
return _jsx("span", { className: className, "aria-hidden": "true", children: icon.text });
|
|
25
|
+
return (_jsx("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: PATHS[icon.name]() }));
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* ⑥ 图片点击放大(lightbox)。全局委托监听,只认 `.thread` 内的 `<img>`
|
|
5
|
+
* (品牌 logo、头像等不在对话区,不会触发)。点击遮罩或放大图本身关闭,
|
|
6
|
+
* Esc 也关闭。纯前端,零协议改动。
|
|
7
|
+
*/
|
|
8
|
+
export function Lightbox() {
|
|
9
|
+
const [src, setSrc] = useState(null);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const onClick = (e) => {
|
|
12
|
+
const t = e.target;
|
|
13
|
+
if (!(t instanceof HTMLImageElement) || !t.closest(".thread"))
|
|
14
|
+
return;
|
|
15
|
+
setSrc(t.currentSrc || t.src);
|
|
16
|
+
};
|
|
17
|
+
const onKey = (e) => {
|
|
18
|
+
if (e.key === "Escape")
|
|
19
|
+
setSrc(null);
|
|
20
|
+
};
|
|
21
|
+
document.addEventListener("click", onClick, true);
|
|
22
|
+
document.addEventListener("keydown", onKey);
|
|
23
|
+
return () => {
|
|
24
|
+
document.removeEventListener("click", onClick, true);
|
|
25
|
+
document.removeEventListener("keydown", onKey);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
if (!src)
|
|
29
|
+
return null;
|
|
30
|
+
return (_jsx("div", { className: "lightbox", role: "dialog", "aria-label": "\u56FE\u7247\u9884\u89C8", onClick: () => setSrc(null), children: _jsx("img", { src: src, alt: "" }) }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Waiting-queue bar (custom component, UI-R3).
|
|
3
|
+
*
|
|
4
|
+
* Why not the official queue: `ComposerPrimitive.Queue` + `unstable_enableMessageQueue`
|
|
5
|
+
* cover enqueue/remove, but the local runtime wires the queue driver WITHOUT a
|
|
6
|
+
* `cancel` callback, so a steer-lane move degrades to "process next" instead of
|
|
7
|
+
* interrupting the running answer; and `notifyCancelled` pauses queue advance
|
|
8
|
+
* after a user-initiated stop, which kills our "stop then flush next" behavior.
|
|
9
|
+
* Forensics: @assistant-ui/core local-thread-runtime-core.js:356-366,
|
|
10
|
+
* message-queue.d.ts:13-30. Kept as a reusable custom component per the
|
|
11
|
+
* official-first rule (it does not match).
|
|
12
|
+
*/
|
|
13
|
+
/** A content part a queued send can carry: the composer only produces these three. */
|
|
14
|
+
export type QueuedPart = {
|
|
15
|
+
type: "text";
|
|
16
|
+
text: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "image";
|
|
19
|
+
image: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "file";
|
|
22
|
+
filename?: string;
|
|
23
|
+
mimeType: string;
|
|
24
|
+
data: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One queued send (E2, documents since B4-A). It holds content parts rather
|
|
28
|
+
* than a string because a message waiting behind the current answer may carry
|
|
29
|
+
* images and converted documents too — the queue is only a local staging
|
|
30
|
+
* area, and whatever sits here is appended to the thread verbatim once the run
|
|
31
|
+
* ends.
|
|
32
|
+
*/
|
|
33
|
+
export type QueuedMessage = readonly QueuedPart[];
|
|
34
|
+
/** What the bar shows for one queued message (the payload itself is a parts array). */
|
|
35
|
+
export declare function queuedPreview(message: QueuedMessage): {
|
|
36
|
+
text: string;
|
|
37
|
+
images: number;
|
|
38
|
+
docs: number;
|
|
39
|
+
};
|
|
40
|
+
export declare function QueueBar({ queue, onSteer, onDrop, }: {
|
|
41
|
+
queue: readonly QueuedMessage[];
|
|
42
|
+
onSteer: (i: number) => void;
|
|
43
|
+
onDrop: (i: number) => void;
|
|
44
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** What the bar shows for one queued message (the payload itself is a parts array). */
|
|
3
|
+
export function queuedPreview(message) {
|
|
4
|
+
const text = message
|
|
5
|
+
.filter((p) => p.type === "text")
|
|
6
|
+
.map((p) => p.text)
|
|
7
|
+
.join("");
|
|
8
|
+
const images = message.filter((p) => p.type === "image").length;
|
|
9
|
+
const docs = message.filter((p) => p.type === "file").length;
|
|
10
|
+
return { text: text.trim(), images, docs };
|
|
11
|
+
}
|
|
12
|
+
export function QueueBar({ queue, onSteer, onDrop, }) {
|
|
13
|
+
return (_jsxs("div", { className: "queuebar", children: [_jsxs("span", { className: "q-label", children: ["\u7B49\u5F85 ", queue.length, " \u6761"] }), queue.map((q, i) => {
|
|
14
|
+
const { text, images, docs } = queuedPreview(q);
|
|
15
|
+
return (_jsxs("span", { className: "q-item", title: text || `${images} 图片 / ${docs} 文档`, children: [images > 0 && _jsxs("span", { className: "q-img", "aria-label": `${images} 张图片`, children: ["\uD83D\uDDBC", images > 1 ? `×${images}` : ""] }), docs > 0 && _jsxs("span", { className: "q-img", "aria-label": `${docs} 个文档`, children: ["\uD83D\uDCC4", docs > 1 ? `×${docs}` : ""] }), _jsx("span", { className: "q-text", children: text }), _jsx("button", { onClick: () => onSteer(i), title: "\u4E2D\u6B62\u5F53\u524D\u56DE\u7B54\uFF0C\u4F18\u5148\u53D1\u9001\u8FD9\u6761", children: "\u63D2\u961F" }), _jsx("button", { onClick: () => onDrop(i), title: "\u4ECE\u961F\u5217\u79FB\u9664", children: "\u79FB\u9664" })] }, i));
|
|
16
|
+
})] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type PointerEvent as ReactPointerEvent } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* 解析左栏宽度:记忆值合法才用,否则回落默认。
|
|
4
|
+
* 损坏的 localStorage(NaN/越界/改参后旧值)一律回默认,不会把布局带坏。
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveWidth(stored: string | null, fallback: number, min: number, max: number): number;
|
|
7
|
+
/**
|
|
8
|
+
* 可拖拽竖向分隔条(agentChat 通用能力,零业务知识):拖动调整左栏宽度,
|
|
9
|
+
* 宽度记忆在 localStorage(每浏览器),双击恢复默认。参考 DSH 侧栏拖拽。
|
|
10
|
+
*/
|
|
11
|
+
export declare function usePaneWidth(storageKey: string, fallback: number, min: number, max: number): {
|
|
12
|
+
width: number;
|
|
13
|
+
handlers: {
|
|
14
|
+
onPointerDown: (e: ReactPointerEvent<HTMLDivElement>) => void;
|
|
15
|
+
onPointerMove: (e: ReactPointerEvent<HTMLDivElement>) => void;
|
|
16
|
+
onPointerUp: () => void;
|
|
17
|
+
onDoubleClick: () => void;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
interface SplitterProps {
|
|
21
|
+
onPointerDown?: (e: ReactPointerEvent<HTMLDivElement>) => void;
|
|
22
|
+
onPointerMove?: (e: ReactPointerEvent<HTMLDivElement>) => void;
|
|
23
|
+
onPointerUp?: (e: ReactPointerEvent<HTMLDivElement>) => void;
|
|
24
|
+
onDoubleClick?: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function Splitter(props: SplitterProps): import("react").JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
function clamp(v, min, max) {
|
|
4
|
+
return Math.min(max, Math.max(min, v));
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 解析左栏宽度:记忆值合法才用,否则回落默认。
|
|
8
|
+
* 损坏的 localStorage(NaN/越界/改参后旧值)一律回默认,不会把布局带坏。
|
|
9
|
+
*/
|
|
10
|
+
export function resolveWidth(stored, fallback, min, max) {
|
|
11
|
+
const v = Number(stored);
|
|
12
|
+
return stored !== null && stored !== "" && Number.isFinite(v) && v >= min && v <= max ? v : fallback;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 可拖拽竖向分隔条(agentChat 通用能力,零业务知识):拖动调整左栏宽度,
|
|
16
|
+
* 宽度记忆在 localStorage(每浏览器),双击恢复默认。参考 DSH 侧栏拖拽。
|
|
17
|
+
*/
|
|
18
|
+
export function usePaneWidth(storageKey, fallback, min, max) {
|
|
19
|
+
const [width, setWidth] = useState(() => {
|
|
20
|
+
let stored = null;
|
|
21
|
+
try {
|
|
22
|
+
stored = localStorage.getItem(storageKey);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* 隐私模式读不到就算了 */
|
|
26
|
+
}
|
|
27
|
+
return resolveWidth(stored, fallback, min, max);
|
|
28
|
+
});
|
|
29
|
+
const drag = useRef(null);
|
|
30
|
+
const commit = useCallback((v) => {
|
|
31
|
+
const w = clamp(v, min, max);
|
|
32
|
+
setWidth(w);
|
|
33
|
+
try {
|
|
34
|
+
localStorage.setItem(storageKey, String(w));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
/* 写不进去只影响"记忆",不影响本次拖拽 */
|
|
38
|
+
}
|
|
39
|
+
}, [storageKey, min, max]);
|
|
40
|
+
return {
|
|
41
|
+
width,
|
|
42
|
+
handlers: {
|
|
43
|
+
onPointerDown: (e) => {
|
|
44
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
45
|
+
drag.current = { startX: e.clientX, startW: width };
|
|
46
|
+
},
|
|
47
|
+
onPointerMove: (e) => {
|
|
48
|
+
const d = drag.current;
|
|
49
|
+
if (d)
|
|
50
|
+
commit(d.startW + e.clientX - d.startX);
|
|
51
|
+
},
|
|
52
|
+
onPointerUp: () => {
|
|
53
|
+
drag.current = null;
|
|
54
|
+
},
|
|
55
|
+
onDoubleClick: () => commit(fallback),
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function Splitter(props) {
|
|
60
|
+
return (_jsx("div", { className: "splitter", role: "separator", "aria-orientation": "vertical", title: "\u62D6\u52A8\u8C03\u6574\u5BBD\u5EA6\uFF0C\u53CC\u51FB\u6062\u590D\u9ED8\u8BA4", ...props }));
|
|
61
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { applyThemeMode, loadThemeMode, saveThemeMode } from "../theme.js";
|
|
4
|
+
const ICON = { auto: "🌗", light: "☀️", dark: "🌙" };
|
|
5
|
+
const LABEL = { auto: "跟随系统", light: "浅色", dark: "深色" };
|
|
6
|
+
const CYCLE = { auto: "light", light: "dark", dark: "auto" };
|
|
7
|
+
/** 三态循环:跟随系统 → 浅色 → 深色。自包含:状态、持久化、应用都在这里。 */
|
|
8
|
+
export default function ThemeToggle() {
|
|
9
|
+
const [mode, setMode] = useState(loadThemeMode);
|
|
10
|
+
return (_jsx("button", { className: "theme-toggle", title: `主题:${LABEL[mode]}(点击切换)`, onClick: () => {
|
|
11
|
+
const next = CYCLE[mode];
|
|
12
|
+
setMode(next);
|
|
13
|
+
applyThemeMode(next);
|
|
14
|
+
saveThemeMode(next);
|
|
15
|
+
}, children: ICON[mode] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ModelTier } from "@njuptlzf/agent-chat-protocol";
|
|
2
|
+
/**
|
|
3
|
+
* 档位下拉选择器(U1b)。assistant-ui 0.15.28 没有通用下拉/菜单原语
|
|
4
|
+
* (index.d.ts 只有 thread/composer 原语与 unstable trigger-popover 钩子),
|
|
5
|
+
* 按规范自定义。样式对齐宿主截图:触发钮只显示当前档位,弹出列表每行
|
|
6
|
+
* label + 右对齐消耗倍率,顶部结构化描述卡(名称/说明/倍率/单价)。
|
|
7
|
+
* ponytail: 只做点击+Esc+方向键,无焦点陷阱/滚动锁定;升级路径 = 换无头
|
|
8
|
+
* 菜单库(如 radix popover)。
|
|
9
|
+
*/
|
|
10
|
+
export declare function TierPicker({ tiers, value, onChange, }: {
|
|
11
|
+
tiers: ModelTier[];
|
|
12
|
+
value?: string;
|
|
13
|
+
onChange: (id: string) => void;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* 档位下拉选择器(U1b)。assistant-ui 0.15.28 没有通用下拉/菜单原语
|
|
5
|
+
* (index.d.ts 只有 thread/composer 原语与 unstable trigger-popover 钩子),
|
|
6
|
+
* 按规范自定义。样式对齐宿主截图:触发钮只显示当前档位,弹出列表每行
|
|
7
|
+
* label + 右对齐消耗倍率,顶部结构化描述卡(名称/说明/倍率/单价)。
|
|
8
|
+
* ponytail: 只做点击+Esc+方向键,无焦点陷阱/滚动锁定;升级路径 = 换无头
|
|
9
|
+
* 菜单库(如 radix popover)。
|
|
10
|
+
*/
|
|
11
|
+
export function TierPicker({ tiers, value, onChange, }) {
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
const [hover, setHover] = useState(null);
|
|
14
|
+
const rootRef = useRef(null);
|
|
15
|
+
const current = tiers.find((t) => t.id === value) ?? tiers[0];
|
|
16
|
+
const shown = tiers[hover ?? tiers.indexOf(current)] ?? current;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!open)
|
|
19
|
+
return;
|
|
20
|
+
const onDoc = (e) => {
|
|
21
|
+
if (!rootRef.current?.contains(e.target))
|
|
22
|
+
setOpen(false);
|
|
23
|
+
};
|
|
24
|
+
document.addEventListener("mousedown", onDoc);
|
|
25
|
+
return () => document.removeEventListener("mousedown", onDoc);
|
|
26
|
+
}, [open]);
|
|
27
|
+
const pick = (t) => {
|
|
28
|
+
onChange(t.id);
|
|
29
|
+
setOpen(false);
|
|
30
|
+
setHover(null);
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs("div", { className: "tierpick", ref: rootRef, onKeyDown: (e) => {
|
|
33
|
+
if (e.key === "Escape") {
|
|
34
|
+
setOpen(false);
|
|
35
|
+
setHover(null);
|
|
36
|
+
}
|
|
37
|
+
else if (open && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
const base = hover ?? tiers.indexOf(current);
|
|
40
|
+
setHover(e.key === "ArrowDown" ? Math.min(tiers.length - 1, base + 1) : Math.max(0, base - 1));
|
|
41
|
+
}
|
|
42
|
+
else if (open && e.key === "Enter" && hover !== null) {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
const t = tiers[hover];
|
|
45
|
+
if (t)
|
|
46
|
+
pick(t);
|
|
47
|
+
}
|
|
48
|
+
}, children: [open && (_jsxs("div", { className: "tier-pop", role: "listbox", "aria-label": "\u56DE\u7B54\u6863\u4F4D", children: [_jsxs("div", { className: "tier-desc", children: [_jsx("div", { className: "tier-desc-name", children: shown.label }), shown.description && _jsx("div", { className: "tier-desc-text", children: shown.description }), _jsxs("div", { className: "tier-desc-meta", children: [_jsx("span", { children: "\u6D88\u8017\u500D\u7387" }), _jsxs("span", { children: ["\u00D7", shown.multiplier] })] }), shown.pricePerThousandTokensCents !== undefined && (_jsxs("div", { className: "tier-desc-meta", children: [_jsx("span", { children: "\u5355\u4EF7" }), _jsxs("span", { children: [shown.pricePerThousandTokensCents, " \u5206/\u5343\u5B57"] })] }))] }), tiers.map((t, i) => (_jsxs("button", { type: "button", role: "option", "aria-selected": t.id === current.id, className: t.id === current.id ? "tier-row on" : "tier-row", onMouseEnter: () => setHover(i), onClick: () => pick(t), children: [_jsx("span", { children: t.label }), _jsxs("span", { className: "tier-mult", children: ["\u00D7", t.multiplier] })] }, t.id)))] })), _jsxs("button", { type: "button", className: "tier-btn", "aria-haspopup": "listbox", "aria-expanded": open, onKeyDown: (e) => {
|
|
49
|
+
if (!open && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
setOpen(true);
|
|
52
|
+
}
|
|
53
|
+
}, onClick: () => setOpen((o) => !o), children: [current.label, _jsx("span", { className: "tier-caret", children: "\u25BE" })] })] }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UiPromptEvent } from "../adapter.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Card for an extension dialog (`ctx.ui.select/confirm/input`, custom component
|
|
4
|
+
* UI-R3 — assistant-ui has no equivalent primitive for extension UI prompts).
|
|
5
|
+
* The server parks the run inside the extension's await until this answers
|
|
6
|
+
* POST /api/ui-response, so every kind offers an explicit way out: `cancelled`
|
|
7
|
+
* maps to the fail-closed default (false / undefined) if the user dismisses
|
|
8
|
+
* instead of choosing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function UIPromptCard({ prompt, onAnswer, }: {
|
|
11
|
+
prompt: UiPromptEvent;
|
|
12
|
+
onAnswer: (a: {
|
|
13
|
+
value?: string;
|
|
14
|
+
confirmed?: boolean;
|
|
15
|
+
cancelled?: true;
|
|
16
|
+
}) => void;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Card for an extension dialog (`ctx.ui.select/confirm/input`, custom component
|
|
5
|
+
* UI-R3 — assistant-ui has no equivalent primitive for extension UI prompts).
|
|
6
|
+
* The server parks the run inside the extension's await until this answers
|
|
7
|
+
* POST /api/ui-response, so every kind offers an explicit way out: `cancelled`
|
|
8
|
+
* maps to the fail-closed default (false / undefined) if the user dismisses
|
|
9
|
+
* instead of choosing.
|
|
10
|
+
*/
|
|
11
|
+
export function UIPromptCard({ prompt, onAnswer, }) {
|
|
12
|
+
const [text, setText] = useState("");
|
|
13
|
+
const submitInput = () => {
|
|
14
|
+
if (text.trim())
|
|
15
|
+
onAnswer({ value: text });
|
|
16
|
+
};
|
|
17
|
+
return (_jsxs("div", { className: "uidialog", role: prompt.kind === "confirm" ? "alertdialog" : "dialog", "aria-label": prompt.title, children: [_jsx("div", { className: "uidialog-title", children: prompt.title }), prompt.message && _jsx("div", { className: "uidialog-msg", children: prompt.message }), prompt.kind === "select" && (_jsxs("div", { className: "uidialog-options", children: [(prompt.options ?? []).map((o) => (_jsx("button", { onClick: () => onAnswer({ value: o }), children: o }, o))), _jsx("button", { className: "uidialog-dismiss", onClick: () => onAnswer({ cancelled: true }), children: "\u53D6\u6D88" })] })), prompt.kind === "confirm" && (_jsxs("div", { className: "uidialog-actions", children: [_jsx("button", { className: "allow", onClick: () => onAnswer({ confirmed: true }), children: "\u786E\u5B9A" }), _jsx("button", { className: "deny", onClick: () => onAnswer({ cancelled: true }), children: "\u53D6\u6D88" })] })), prompt.kind === "input" && (_jsxs("div", { className: "uidialog-input", children: [_jsx("input", { value: text, placeholder: prompt.placeholder ?? "", autoFocus: true, onChange: (e) => setText(e.target.value), onKeyDown: (e) => e.key === "Enter" && submitInput() }), _jsx("button", { onClick: submitInput, disabled: !text.trim(), children: "\u63D0\u4EA4" }), _jsx("button", { className: "uidialog-dismiss", onClick: () => onAnswer({ cancelled: true }), children: "\u53D6\u6D88" })] }))] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 图标值解析:`branding.ui.icons.<槽名>` 的一个字符串怎么画。
|
|
3
|
+
* 三种形态:`svg:<内置名>` / `url:https?://…`(图片地址)/ 其它非空字符串(emoji 或短文本)。
|
|
4
|
+
* 任何非法值都回落默认矢量——图标坏了不该让界面报错,也不该引入任何 HTML 注入面。
|
|
5
|
+
*/
|
|
6
|
+
declare const BUILTIN_SVGS: readonly ["paperclip", "plus", "image", "upload"];
|
|
7
|
+
export type BuiltinSvgName = (typeof BUILTIN_SVGS)[number];
|
|
8
|
+
export type IconDescriptor = {
|
|
9
|
+
kind: "svg";
|
|
10
|
+
name: BuiltinSvgName;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "url";
|
|
13
|
+
href: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "text";
|
|
16
|
+
text: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function parseIconSpec(spec: string | undefined | null): IconDescriptor;
|
|
19
|
+
export {};
|