@sepveneto/dnde 0.8.0 → 0.8.2

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/App.vue.d.ts CHANGED
@@ -48,8 +48,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
48
48
  readonly name: string;
49
49
  readonly agent: boolean;
50
50
  readonly widgets: import("./store").LikeWidget[];
51
+ readonly extra: Record<string, any>;
51
52
  readonly capabilities: any[];
52
53
  readonly workflows: any[];
53
- readonly extra: Record<string, any>;
54
54
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
55
55
  export default _default;
@@ -170,8 +170,8 @@ declare const _default: Vue.DefineComponent<Vue.ExtractPropTypes<{
170
170
  readonly name: string;
171
171
  readonly agent: boolean;
172
172
  readonly widgets: import("./store").LikeWidget[];
173
+ readonly extra: Record<string, any>;
173
174
  readonly capabilities: any[];
174
175
  readonly workflows: any[];
175
- readonly extra: Record<string, any>;
176
176
  }, {}, {}, {}, string, Vue.ComponentProvideOptions, true, {}, any>;
177
177
  export default _default;
@@ -1,4 +1,4 @@
1
- import type { LayoutWidgetDescriptor } from '@agent/sdk';
1
+ import type { LayoutWidgetDescriptor } from './types';
2
2
  /**
3
3
  * 把编辑器组件列表拍平成 Layout Agent 需要的描述。
4
4
  *
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 可选 agent 能力的加载器。
3
+ *
4
+ * agent 被设计成独立的 web component(`<dnd-agent>`),编辑器自身**不**在构建期依赖
5
+ * `@sepveneto/dnde-agent`:业务侧不安装它也能正常打包、使用编辑器。
6
+ *
7
+ * 加载方式由宿主在 `register({ agent })` 时**显式注入**(通常是
8
+ * `() => import('@sepveneto/dnde-agent/element')`),这样业务侧的打包器才能正确解析依赖。
9
+ * 只开启 `agent` 却没注入、或依赖缺失时,会在控制台提示安装。
10
+ */
11
+ /** agent web component 注册的标签名。 */
12
+ export declare const AGENT_ELEMENT_TAG = "dnd-agent";
13
+ /** 可选的 agent 依赖包名。 */
14
+ export declare const AGENT_PACKAGE_NAME = "@sepveneto/dnde-agent";
15
+ /** agent 的 web component 入口(注册 `<dnd-agent>`,并 re-export 库方法)。 */
16
+ export declare const AGENT_ELEMENT_ENTRY = "@sepveneto/dnde-agent/element";
17
+ /** 按需加载 agent 包的方式,宿主可以注入自定义实现(如走 import map / CDN)。 */
18
+ export type AgentImporter = () => Promise<unknown>;
19
+ /**
20
+ * 注入 agent 的加载方式,由 `register({ agent })` 调用。
21
+ *
22
+ * 传入 `undefined` 可清除(一般不需要)。注入后未完成的加载会被丢弃,允许用新的
23
+ * importer 重新加载。
24
+ */
25
+ export declare function setAgentImporter(importer?: AgentImporter): void;
26
+ /** `<dnd-agent>` 是否已经注册(业务侧自行 import 过该包时即为 true)。 */
27
+ export declare function isAgentRegistered(tag?: string): boolean;
28
+ /**
29
+ * 确保 agent web component 可用。
30
+ *
31
+ * - 已注册:直接返回 `true`;
32
+ * - 未注册:调用宿主注入的加载器,成功后返回 `true`;
33
+ * - 未注入加载器 / 依赖缺失 / 加载失败:在控制台提示安装,并返回 `false`。失败不会缓存,
34
+ * 业务侧后续补上依赖或注入后可以重新触发。
35
+ */
36
+ export declare function loadAgent(tag?: string, importer?: AgentImporter | undefined): Promise<boolean>;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Agent 相关的轻量类型定义。
3
+ *
4
+ * 这些结构本来来自可选的 `@sepveneto/dnde-agent` 包,但编辑器不应当强依赖它
5
+ * (业务侧可以不安装)。因此这里保留编辑器真正用到的字段做本地声明,
6
+ * 运行时由 agent web component 通过事件/属性传回,结构保持一致即可。
7
+ */
8
+ /** 供 Layout Agent 选取组件的描述信息。 */
9
+ export interface LayoutWidgetDescriptor {
10
+ typeId: string;
11
+ description: string;
12
+ layout: Record<string, any>;
13
+ }
14
+ /** Layout Agent 生成的一个组件片段。 */
15
+ export interface LayoutWidgetItem {
16
+ widget: string;
17
+ items: Array<{
18
+ category: string;
19
+ id: any;
20
+ }>;
21
+ }
22
+ export type LayoutIR = LayoutWidgetItem[];
23
+ export interface AddComponentIR {
24
+ type: 'add-component';
25
+ widget: string;
26
+ items: Array<Record<string, any>>;
27
+ }
28
+ export interface DeleteComponentIR {
29
+ type: 'delete-component';
30
+ target: string;
31
+ }
32
+ export interface UpdateComponentIR {
33
+ type: 'update-component';
34
+ target: string;
35
+ changes: Record<string, any>;
36
+ }
37
+ export interface MoveComponentIR {
38
+ type: 'move-component';
39
+ target: string;
40
+ before?: string;
41
+ after?: string;
42
+ }
43
+ /** Edit Agent 生成的单条编辑指令。 */
44
+ export type EditIR = AddComponentIR | DeleteComponentIR | UpdateComponentIR | MoveComponentIR;