@farris/x-ui 0.0.2 → 0.0.4
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/app-preview/src/types.d.ts +13 -0
- package/bubble/src/components/text-content/composition/block-type.d.ts +41 -0
- package/bubble/src/components/text-content/renderers/a2ui-renderer.d.ts +3 -0
- package/bubble/src/components/text-content/renderers/assistant-widget-renderer.d.ts +3 -0
- package/bubble/src/components/text-content/renderers/dynamic-component-renderer.d.ts +3 -0
- package/bubble/src/components/text-content/renderers/text-renderer.d.ts +3 -0
- package/bubble/src/components/text-content/utils/block-parser.d.ts +3 -0
- package/bubble/src/components/text-content/utils/block-renderer.d.ts +13 -0
- package/chat-preview/index.d.ts +4 -2
- package/chat-preview/src/invoke-agent-workbench-sdk.d.ts +5 -0
- package/chat-preview/src/preview-bridge-host.d.ts +15 -0
- package/chat-preview/src/preview-iframe-sdk.d.ts +5 -4
- package/dynamic-component/index.d.ts +1 -1
- package/dynamic-component/src/composition/dynamic-component-registry.d.ts +2 -1
- package/dynamic-component/src/composition/types.d.ts +12 -0
- package/dynamic-component/src/dynamic-component.component.d.ts +1 -1
- package/farris.x-ui.esm.js +2991 -2969
- package/farris.x-ui.umd.cjs +49 -49
- package/index.css +1 -1
- package/package.json +1 -1
- package/chat-preview/src/agent-workbench-sdk.d.ts +0 -61
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DynamicComponentConfig } from '../../../../../dynamic-component/src/composition/types';
|
|
2
|
+
|
|
1
3
|
/** 预览配置 */
|
|
2
4
|
export type PreviewMode = 'splitScreen' | 'fullScreen';
|
|
3
5
|
export interface PreviewConfig {
|
|
@@ -22,6 +24,17 @@ export interface PreviewConfig {
|
|
|
22
24
|
postMessageTargetOrigin?: string;
|
|
23
25
|
/** 预览面板初始宽度占比 (0.3 ~ 0.7),默认 0.5 */
|
|
24
26
|
initialRatio?: number;
|
|
27
|
+
/**
|
|
28
|
+
* 是否替换模式(默认 false)。
|
|
29
|
+
* 为 true 时始终替换 preview-1,不进入三面板双预览布局。
|
|
30
|
+
* 适用于从对话区域点击预览的场景。
|
|
31
|
+
*/
|
|
32
|
+
replace?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 动态组件配置(与 url/content 互斥)。
|
|
35
|
+
* 非空时走动态组件预览流程,复用三面板布局的 preview-1 槽位。
|
|
36
|
+
*/
|
|
37
|
+
dynamicComponent?: DynamicComponentConfig;
|
|
25
38
|
}
|
|
26
39
|
export interface AppConfig {
|
|
27
40
|
appPath: string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DynamicComponentConfig } from '../../../../../../../../../../../dynamic-component/src/composition/types';
|
|
2
|
+
|
|
3
|
+
export declare enum BlockType {
|
|
4
|
+
Text = "text",
|
|
5
|
+
A2UIComplete = "a2ui-complete",
|
|
6
|
+
AssistantWidgetComplete = "assistant-widget-complete",
|
|
7
|
+
AssistantWidgetPending = "assistant-widget-pending",
|
|
8
|
+
DynamicComponentComplete = "dynamic-component-complete",
|
|
9
|
+
DynamicComponentPending = "dynamic-component-pending"
|
|
10
|
+
}
|
|
11
|
+
export interface TextBlock {
|
|
12
|
+
type: BlockType.Text;
|
|
13
|
+
raw: string;
|
|
14
|
+
}
|
|
15
|
+
export interface A2UICompleteBlock {
|
|
16
|
+
type: BlockType.A2UIComplete;
|
|
17
|
+
raw: string;
|
|
18
|
+
a2uiData: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface AssistantWidgetCompleteBlock {
|
|
21
|
+
type: BlockType.AssistantWidgetComplete;
|
|
22
|
+
raw: string;
|
|
23
|
+
widgetData: Record<string, unknown> | null;
|
|
24
|
+
widgetUrl: string | undefined;
|
|
25
|
+
widgetImplOptions: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface AssistantWidgetPendingBlock {
|
|
28
|
+
type: BlockType.AssistantWidgetPending;
|
|
29
|
+
raw: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DynamicComponentCompleteBlock {
|
|
32
|
+
type: BlockType.DynamicComponentComplete;
|
|
33
|
+
raw: string;
|
|
34
|
+
config: DynamicComponentConfig | null;
|
|
35
|
+
}
|
|
36
|
+
export interface DynamicComponentPendingBlock {
|
|
37
|
+
type: BlockType.DynamicComponentPending;
|
|
38
|
+
raw: string;
|
|
39
|
+
position: 'inline' | 'right' | null;
|
|
40
|
+
}
|
|
41
|
+
export type ParsedBlock = TextBlock | A2UICompleteBlock | AssistantWidgetCompleteBlock | AssistantWidgetPendingBlock | DynamicComponentCompleteBlock | DynamicComponentPendingBlock;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VNode, SetupContext, ComputedRef } from '../../../../../../vue';
|
|
2
|
+
import { ParsedBlock, BlockType } from '../../../../../../../composition/block-type';
|
|
3
|
+
import { EmbeddedContentRenderContext } from '../../../../../../../../../composition/use-embedded-content';
|
|
4
|
+
import { EmbeddedContent } from '../../../../../../../../../composition/types';
|
|
5
|
+
|
|
6
|
+
export interface RenderContext {
|
|
7
|
+
shouldShowMarkdown: ComputedRef<boolean>;
|
|
8
|
+
emit: SetupContext['emit'];
|
|
9
|
+
renderFileEmbeddedContent: (content: EmbeddedContent, ctx: EmbeddedContentRenderContext) => VNode;
|
|
10
|
+
}
|
|
11
|
+
export type BlockRenderer = (block: ParsedBlock, index: number, ctx: RenderContext) => VNode | VNode[] | null;
|
|
12
|
+
export type RendererRegistry = Record<BlockType, BlockRenderer>;
|
|
13
|
+
export declare function createRendererRegistry(): RendererRegistry;
|
package/chat-preview/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { default as FXChatPreview } from '../../src/chat-preview.component';
|
|
|
3
3
|
|
|
4
4
|
export * from '../../src/chat-preview.props';
|
|
5
5
|
export * from '../../src/preview-bridge-protocol';
|
|
6
|
-
export {
|
|
7
|
-
/**
|
|
6
|
+
export { postAssistantToPreviewIframe, subscribeAssistantInPreviewIframe, type PreviewAssistantBridgeSubscribeOptions, } from '../../src/preview-bridge-host';
|
|
7
|
+
/** 按方法名调用宿主 `window.AgentWorkbenchSDK`(由 `@farris/x-workbench` 注入) */
|
|
8
|
+
export { invokeAgentWorkbenchSdkApi } from '../../src/invoke-agent-workbench-sdk';
|
|
9
|
+
/** @deprecated 请使用 {@link subscribeAssistantInPreviewIframe};宿主侧见 `@farris/x-workbench` */
|
|
8
10
|
export { createPreviewIframeSdk } from '../../src/preview-iframe-sdk';
|
|
9
11
|
/** @deprecated */
|
|
10
12
|
export type { CreatePreviewIframeSdkOptions } from '../../src/preview-iframe-sdk';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按方法名调用宿主挂载的 {@link AgentWorkbenchSDK}(由 `@farris/x-workbench` 在 `window.AgentWorkbenchSDK` 注入)。
|
|
3
|
+
* 供网关 `InputRecommend` 等配置 `api` + `params`;无宿主 SDK 时会告警并返回 `undefined`。
|
|
4
|
+
*/
|
|
5
|
+
export declare function invokeAgentWorkbenchSdkApi(api: string, params?: unknown[]): unknown;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PreviewBridgeAssistantPayload } from '../../../preview-bridge-protocol';
|
|
2
|
+
|
|
3
|
+
export interface PreviewAssistantBridgeSubscribeOptions {
|
|
4
|
+
/** 允许的父页面 origin;不传则只做结构校验,不校验 origin */
|
|
5
|
+
allowedParentOrigins?: string[];
|
|
6
|
+
/**
|
|
7
|
+
* 为 true(默认)时接受 `window.parent` 或 `window.top` 作为发送方。
|
|
8
|
+
*/
|
|
9
|
+
allowTopAsSource?: boolean;
|
|
10
|
+
onAssistantMessage?: (payload: PreviewBridgeAssistantPayload) => void;
|
|
11
|
+
}
|
|
12
|
+
/** 向预览 iframe 的 `contentWindow` 投递助手消息(与 {@link subscribeAssistantInPreviewIframe} 协议一致) */
|
|
13
|
+
export declare function postAssistantToPreviewIframe(targetWindow: Window, targetOrigin: string, payload: PreviewBridgeAssistantPayload): boolean;
|
|
14
|
+
/** 预览页内:订阅父页 / top 推送的助手消息 */
|
|
15
|
+
export declare function subscribeAssistantInPreviewIframe(options: PreviewAssistantBridgeSubscribeOptions): () => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PreviewAssistantBridgeSubscribeOptions } from '../../../preview-bridge-host';
|
|
2
2
|
|
|
3
|
-
export type CreatePreviewIframeSdkOptions =
|
|
4
|
-
/** @deprecated 请使用 {@link
|
|
3
|
+
export type CreatePreviewIframeSdkOptions = PreviewAssistantBridgeSubscribeOptions;
|
|
4
|
+
/** @deprecated 请使用 {@link subscribeAssistantInPreviewIframe} */
|
|
5
5
|
export declare function createPreviewIframeSdk(options: CreatePreviewIframeSdkOptions): () => void;
|
|
6
|
-
|
|
6
|
+
/** @deprecated 请使用 {@link postAssistantToPreviewIframe} */
|
|
7
|
+
export { postAssistantToPreviewIframe as postAssistantViaAgentWorkbenchSDK } from '../../../preview-bridge-host';
|
|
@@ -2,6 +2,6 @@ import { Plugin } from '../../vue';
|
|
|
2
2
|
import { default as FXDynamicComponent } from '../../src/dynamic-component.component';
|
|
3
3
|
export { default as FXDynamicComponent } from '../../src/dynamic-component.component';
|
|
4
4
|
export * from '../../src/composition/types';
|
|
5
|
-
export { loadDynamicComponent, unloadDynamicComponent } from '../../src/composition/dynamic-component-registry';
|
|
5
|
+
export { loadDynamicComponent, unloadDynamicComponent, postDynamicComponentAssistantMessage } from '../../src/composition/dynamic-component-registry';
|
|
6
6
|
declare const _default: typeof FXDynamicComponent & Plugin;
|
|
7
7
|
export default _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DynamicComponentConfig, DynamicComponentAPI } from '../../../../types';
|
|
1
|
+
import { DynamicComponentConfig, DynamicComponentAPI, DynamicComponentAssistantMessagePayload } from '../../../../types';
|
|
2
2
|
|
|
3
3
|
export declare function loadDynamicComponent(config: DynamicComponentConfig): Promise<DynamicComponentAPI>;
|
|
4
4
|
export declare function unloadDynamicComponent(id: string): void;
|
|
5
|
+
export declare function postDynamicComponentAssistantMessage(id: string, payload: DynamicComponentAssistantMessagePayload): boolean;
|
|
5
6
|
declare global {
|
|
6
7
|
interface Window {
|
|
7
8
|
__fluens_dynamic_component_register: (id: string, api: DynamicComponentAPI) => void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export interface DynamicComponentConfig {
|
|
2
|
+
/** 允许网关透传自定义字段给动态组件 mount(config) 与右侧预览气泡 */
|
|
3
|
+
[key: string]: unknown;
|
|
2
4
|
instanceId: string;
|
|
3
5
|
name?: string;
|
|
4
6
|
componentId?: string;
|
|
@@ -11,9 +13,19 @@ export interface DynamicComponentConfig {
|
|
|
11
13
|
autoOpen?: boolean;
|
|
12
14
|
fileRe?: string;
|
|
13
15
|
}
|
|
16
|
+
export interface DynamicComponentAssistantMessagePayload {
|
|
17
|
+
messageId: string;
|
|
18
|
+
role: 'assistant';
|
|
19
|
+
/** 会话内 assistant 消息的完整 content;包含 dynamic-component 围栏、markdown、复合块等结构。 */
|
|
20
|
+
content: unknown;
|
|
21
|
+
}
|
|
14
22
|
export interface DynamicComponentAPI {
|
|
15
23
|
mount(container: HTMLElement, config: DynamicComponentConfig): void;
|
|
16
24
|
unmount(): void;
|
|
25
|
+
/**
|
|
26
|
+
* 可选:接收唤起当前 dynamic-component 的 assistant 消息,以及之后同会话继续产生的 assistant 消息。
|
|
27
|
+
*/
|
|
28
|
+
onAssistantMessage?: (payload: DynamicComponentAssistantMessagePayload) => void;
|
|
17
29
|
}
|
|
18
30
|
export interface DynamicComponentInstance {
|
|
19
31
|
config: DynamicComponentConfig;
|
|
@@ -6,7 +6,7 @@ declare const _default: import('../../../vue').DefineComponent<import('../../../
|
|
|
6
6
|
type: PropType<DynamicComponentConfig>;
|
|
7
7
|
required: true;
|
|
8
8
|
};
|
|
9
|
-
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('../../../vue').ComponentOptionsMixin, import('../../../vue').ComponentOptionsMixin, {}, string, import('../../../vue').PublicProps, Readonly<import('../../../vue').ExtractPropTypes<{
|
|
9
|
+
}>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import('../../../vue').ComponentOptionsMixin, import('../../../vue').ComponentOptionsMixin, {}, string, import('../../../vue').PublicProps, Readonly<import('../../../vue').ExtractPropTypes<{
|
|
10
10
|
config: {
|
|
11
11
|
type: PropType<DynamicComponentConfig>;
|
|
12
12
|
required: true;
|