@kp-ui/lowcode-pc-v2 0.0.9 → 0.0.10
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/assets/styles/style.css +9 -7
- package/core/src/components/common/render/usePageContext.js +3 -6
- package/core/src/hooks/useWebMCP.js +107 -12
- package/package.json +2 -1
- package/src/widgets/containers/collapse/index-render.js +1 -1
- package/src/widgets/containers/form/index-render.js +1 -1
- package/src/widgets/containers/form/index-render.vue_vue_type_script_setup_true_lang.js +33 -1
- package/stats.html +1 -1
package/assets/styles/style.css
CHANGED
|
@@ -445,25 +445,27 @@
|
|
|
445
445
|
}
|
|
446
446
|
.vf-box-widget .vf-box-content[data-v-d52cfec5] {
|
|
447
447
|
min-height: 60px;
|
|
448
|
-
}.collapse-container[data-v-
|
|
448
|
+
}.collapse-container[data-v-72ccf79c] {
|
|
449
449
|
display: flex;
|
|
450
450
|
margin: 2px;
|
|
451
451
|
width: 100%;
|
|
452
452
|
}
|
|
453
|
-
.collapse-container .form-widget-list[data-v-
|
|
453
|
+
.collapse-container .form-widget-list[data-v-72ccf79c] {
|
|
454
454
|
min-height: 28px;
|
|
455
455
|
}
|
|
456
|
-
.collapse-container[data-v-
|
|
456
|
+
.collapse-container[data-v-72ccf79c] .header-right .form-widget-list {
|
|
457
457
|
min-width: 200px;
|
|
458
458
|
}
|
|
459
|
-
.tpf-collapse[data-v-
|
|
459
|
+
.tpf-collapse[data-v-72ccf79c] {
|
|
460
460
|
padding: 5px;
|
|
461
461
|
}
|
|
462
|
-
.tpf-collapse .collapse-right[data-v-
|
|
462
|
+
.tpf-collapse .collapse-right[data-v-72ccf79c] {
|
|
463
463
|
min-width: 200px;
|
|
464
464
|
min-height: 30px;
|
|
465
|
+
display: flex;
|
|
466
|
+
justify-content: end;
|
|
465
467
|
}
|
|
466
|
-
.tpf-collapse[data-v-
|
|
468
|
+
.tpf-collapse[data-v-72ccf79c] .tpf-collapse-content-wrapper {
|
|
467
469
|
overflow: hidden;
|
|
468
470
|
background-color: #fff;
|
|
469
471
|
padding: 16px;
|
|
@@ -476,7 +478,7 @@
|
|
|
476
478
|
}
|
|
477
479
|
.flex-container[data-v-4ac728a4] .ant-form-item {
|
|
478
480
|
margin-bottom: 0;
|
|
479
|
-
}.form-widget[data-v-
|
|
481
|
+
}.form-widget[data-v-4231072f] {
|
|
480
482
|
width: 100%;
|
|
481
483
|
min-height: 60px;
|
|
482
484
|
}.grid-cell[data-v-598209c1] {
|
|
@@ -4,7 +4,7 @@ import { generateId, insertCustomCssToHead, insertGlobalFunctionsToHtml, removeC
|
|
|
4
4
|
import { useAppRef } from "../../../hooks/useAppRef.js";
|
|
5
5
|
import { computed, nextTick, onMounted, ref, watch, watchEffect } from "vue";
|
|
6
6
|
import { useExecFunction, useRef } from "tmgc2-share";
|
|
7
|
-
import {
|
|
7
|
+
import { set } from "lodash-es";
|
|
8
8
|
//#region ../core/src/components/common/render/usePageContext.ts
|
|
9
9
|
/**
|
|
10
10
|
* 创建表单上下文
|
|
@@ -156,13 +156,10 @@ var usePageContext = ({ props }) => {
|
|
|
156
156
|
formDataModel.value[field] = value;
|
|
157
157
|
};
|
|
158
158
|
const setVfCtx = (vfCtx) => {
|
|
159
|
-
formContextData.value =
|
|
159
|
+
formContextData.value = vfCtx || {};
|
|
160
160
|
};
|
|
161
161
|
const addVfCtx = (vfCtx) => {
|
|
162
|
-
formContextData.value
|
|
163
|
-
...formContextData.value,
|
|
164
|
-
...vfCtx
|
|
165
|
-
});
|
|
162
|
+
Object.assign(formContextData.value, vfCtx);
|
|
166
163
|
};
|
|
167
164
|
const getVfCtx = () => {
|
|
168
165
|
return formContextData.value;
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
//#region ../core/src/hooks/useWebMCP.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var LOWCODE_PAGE_SCHEMA_AGENT = {
|
|
3
|
+
name: "lowcode-page-schema",
|
|
4
|
+
displayName: "低代码页面 Schema",
|
|
5
|
+
description: "生成、校验、调整或解释独立可交付的 PC 低代码 page schema,并与当前 PC widget 契约保持一致。",
|
|
6
|
+
defaultPrompt: "使用 lowcode-page-schema agent 生成、校验或调整独立可交付的 PC 低代码页面 schema。优先通过 WebMCP 读取当前设计器状态;需要导入时使用 setPageJson 回写并再次读取确认。输出必须补齐 widgetList、formConfig、serveList、cssCode/html/custom-render 等完整结构,并遵守当前 PC widget 契约。",
|
|
7
|
+
capabilities: [
|
|
8
|
+
"getPageData",
|
|
9
|
+
"setPageData",
|
|
10
|
+
"getWidgetsInfo",
|
|
11
|
+
"getPageJson",
|
|
12
|
+
"setPageJson",
|
|
13
|
+
"getRuntimeState"
|
|
14
|
+
],
|
|
15
|
+
skill: {
|
|
16
|
+
name: "lowcode-page-schema",
|
|
17
|
+
path: "packages/lowcode-page-schema-skill/SKILL.md",
|
|
18
|
+
references: [
|
|
19
|
+
"packages/lowcode-page-schema-skill/references/webMCP.md",
|
|
20
|
+
"packages/lowcode-page-schema-skill/references/widget/index.md",
|
|
21
|
+
"packages/lowcode-page-schema-skill/scripts/widget-schemas.json"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var getDesignerJson = (context) => {
|
|
26
|
+
var _context$designer;
|
|
27
|
+
const designer = context === null || context === void 0 || (_context$designer = context.designer) === null || _context$designer === void 0 ? void 0 : _context$designer.value;
|
|
28
|
+
if (!designer) return null;
|
|
29
|
+
return {
|
|
30
|
+
widgetList: designer.widgetList,
|
|
31
|
+
formConfig: designer.formConfig
|
|
32
|
+
};
|
|
33
|
+
};
|
|
6
34
|
var useWebMCP = (context) => {
|
|
7
35
|
const registerWebMCPTools = () => {
|
|
8
|
-
|
|
36
|
+
var _existingTools$contex, _context$designer4;
|
|
37
|
+
const tools = {
|
|
9
38
|
context,
|
|
39
|
+
agent: LOWCODE_PAGE_SCHEMA_AGENT,
|
|
40
|
+
getAgentManifest: () => LOWCODE_PAGE_SCHEMA_AGENT,
|
|
41
|
+
getSkillInfo: () => LOWCODE_PAGE_SCHEMA_AGENT.skill,
|
|
10
42
|
getPageData: () => {
|
|
11
43
|
var _context$formDataMode;
|
|
12
44
|
return ((_context$formDataMode = context.formDataModel) === null || _context$formDataMode === void 0 ? void 0 : _context$formDataMode.value) || {};
|
|
@@ -24,13 +56,7 @@ var useWebMCP = (context) => {
|
|
|
24
56
|
return Array.from(((_context$widgetRefLis = context.widgetRefList) === null || _context$widgetRefLis === void 0 || (_context$widgetRefLis = _context$widgetRefLis.value) === null || _context$widgetRefLis === void 0 ? void 0 : _context$widgetRefLis.keys()) || []);
|
|
25
57
|
},
|
|
26
58
|
getPageJson: () => {
|
|
27
|
-
|
|
28
|
-
const designer = (_context$designer = context.designer) === null || _context$designer === void 0 ? void 0 : _context$designer.value;
|
|
29
|
-
if (designer) return {
|
|
30
|
-
widgetList: designer.widgetList,
|
|
31
|
-
formConfig: designer.formConfig
|
|
32
|
-
};
|
|
33
|
-
return null;
|
|
59
|
+
return getDesignerJson(context);
|
|
34
60
|
},
|
|
35
61
|
setPageJson: (formJson) => {
|
|
36
62
|
var _context$designer2;
|
|
@@ -41,8 +67,77 @@ var useWebMCP = (context) => {
|
|
|
41
67
|
return "表单 JSON 已导入";
|
|
42
68
|
}
|
|
43
69
|
return "导入失败:设计器上下文不存在";
|
|
70
|
+
},
|
|
71
|
+
getRuntimeState: () => {
|
|
72
|
+
var _context$formDataMode3, _context$widgetRefLis2, _context$designer3;
|
|
73
|
+
return {
|
|
74
|
+
agent: LOWCODE_PAGE_SCHEMA_AGENT,
|
|
75
|
+
pageJson: getDesignerJson(context),
|
|
76
|
+
pageData: ((_context$formDataMode3 = context.formDataModel) === null || _context$formDataMode3 === void 0 ? void 0 : _context$formDataMode3.value) || {},
|
|
77
|
+
widgets: Array.from(((_context$widgetRefLis2 = context.widgetRefList) === null || _context$widgetRefLis2 === void 0 || (_context$widgetRefLis2 = _context$widgetRefLis2.value) === null || _context$widgetRefLis2 === void 0 ? void 0 : _context$widgetRefLis2.keys()) || []),
|
|
78
|
+
hasDesigner: Boolean(context === null || context === void 0 || (_context$designer3 = context.designer) === null || _context$designer3 === void 0 ? void 0 : _context$designer3.value)
|
|
79
|
+
};
|
|
44
80
|
}
|
|
45
81
|
};
|
|
82
|
+
const agent = {
|
|
83
|
+
...LOWCODE_PAGE_SCHEMA_AGENT,
|
|
84
|
+
listTools: () => LOWCODE_PAGE_SCHEMA_AGENT.capabilities,
|
|
85
|
+
callTool: (method, ...args) => {
|
|
86
|
+
const currentTools = window.__LOWCODE_MCP_TOOLS__;
|
|
87
|
+
const tool = currentTools === null || currentTools === void 0 ? void 0 : currentTools[method];
|
|
88
|
+
if (typeof tool !== "function") throw new Error(`Web Agent tool is not available: ${method}`);
|
|
89
|
+
return tool(...args);
|
|
90
|
+
},
|
|
91
|
+
getRuntimeState: tools.getRuntimeState
|
|
92
|
+
};
|
|
93
|
+
const existingTools = window.__LOWCODE_MCP_TOOLS__;
|
|
94
|
+
const existingHasDesigner = Boolean(existingTools === null || existingTools === void 0 || (_existingTools$contex = existingTools.context) === null || _existingTools$contex === void 0 || (_existingTools$contex = _existingTools$contex.designer) === null || _existingTools$contex === void 0 ? void 0 : _existingTools$contex.value);
|
|
95
|
+
const currentHasDesigner = Boolean(context === null || context === void 0 || (_context$designer4 = context.designer) === null || _context$designer4 === void 0 ? void 0 : _context$designer4.value);
|
|
96
|
+
if (!existingTools || currentHasDesigner || !existingHasDesigner) {
|
|
97
|
+
window.__LOWCODE_MCP_TOOLS__ = tools;
|
|
98
|
+
window.__LOWCODE_WEB_AGENT__ = agent;
|
|
99
|
+
}
|
|
100
|
+
if (typeof document !== "undefined" && !window.__LOWCODE_MCP_DOM_BRIDGE__) {
|
|
101
|
+
window.__LOWCODE_MCP_DOM_BRIDGE__ = true;
|
|
102
|
+
const ensureBridgeNode = (id, create) => {
|
|
103
|
+
const existed = document.getElementById(id);
|
|
104
|
+
if (existed) return existed;
|
|
105
|
+
const node = create();
|
|
106
|
+
node.id = id;
|
|
107
|
+
node.style.cssText = "position:fixed;left:0;bottom:0;width:1px;height:1px;opacity:0.01;z-index:2147483647;";
|
|
108
|
+
document.body.appendChild(node);
|
|
109
|
+
return node;
|
|
110
|
+
};
|
|
111
|
+
const runBridgeRequest = () => {
|
|
112
|
+
const requestNode = document.getElementById("__LOWCODE_MCP_REQUEST__");
|
|
113
|
+
const responseNode = document.getElementById("__LOWCODE_MCP_RESPONSE__") || document.body.appendChild(Object.assign(document.createElement("script"), {
|
|
114
|
+
id: "__LOWCODE_MCP_RESPONSE__",
|
|
115
|
+
type: "application/json"
|
|
116
|
+
}));
|
|
117
|
+
try {
|
|
118
|
+
const request = JSON.parse((requestNode === null || requestNode === void 0 ? void 0 : requestNode.value) || (requestNode === null || requestNode === void 0 ? void 0 : requestNode.textContent) || "{}");
|
|
119
|
+
const currentTools = window.__LOWCODE_MCP_TOOLS__;
|
|
120
|
+
const method = currentTools === null || currentTools === void 0 ? void 0 : currentTools[request.method || ""];
|
|
121
|
+
if (typeof method !== "function") throw new Error(`WebMCP method is not available: ${request.method}`);
|
|
122
|
+
responseNode.textContent = JSON.stringify({
|
|
123
|
+
id: request.id,
|
|
124
|
+
ok: true,
|
|
125
|
+
result: method(...request.args || [])
|
|
126
|
+
});
|
|
127
|
+
} catch (error) {
|
|
128
|
+
responseNode.textContent = JSON.stringify({
|
|
129
|
+
ok: false,
|
|
130
|
+
error: (error === null || error === void 0 ? void 0 : error.message) || String(error)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
ensureBridgeNode("__LOWCODE_MCP_REQUEST__", () => document.createElement("textarea"));
|
|
135
|
+
const button = ensureBridgeNode("__LOWCODE_MCP_TRIGGER__", () => document.createElement("button"));
|
|
136
|
+
button.setAttribute("type", "button");
|
|
137
|
+
button.setAttribute("aria-label", "WebMCP trigger");
|
|
138
|
+
button.onclick = runBridgeRequest;
|
|
139
|
+
document.addEventListener("__LOWCODE_MCP_REQUEST__", runBridgeRequest);
|
|
140
|
+
}
|
|
46
141
|
};
|
|
47
142
|
return { registerWebMCPTools };
|
|
48
143
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kp-ui/lowcode-pc-v2",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"ant-design-vue": "4.2.6",
|
|
16
16
|
"query-string": "^6.14.1",
|
|
17
17
|
"dayjs": "^1.11.7",
|
|
18
|
+
"@kp-ui/lowcode-page-schema-skill": "workspace:*",
|
|
18
19
|
"@kp-ui/tool": "2.14.1",
|
|
19
20
|
"tailwindcss": "3.4.9",
|
|
20
21
|
"vue": "3.5.17",
|
|
@@ -3,6 +3,6 @@ import index_render_vue_vue_type_script_setup_true_lang_default from "./index-re
|
|
|
3
3
|
/* empty css */
|
|
4
4
|
/* empty css */
|
|
5
5
|
//#region src/widgets/containers/collapse/index-render.vue
|
|
6
|
-
var index_render_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_render_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
6
|
+
var index_render_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_render_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-72ccf79c"]]);
|
|
7
7
|
//#endregion
|
|
8
8
|
export { index_render_default as default };
|
|
@@ -2,6 +2,6 @@ import _plugin_vue_export_helper_default from "../../../../_virtual/_plugin-vue_
|
|
|
2
2
|
import index_render_vue_vue_type_script_setup_true_lang_default from "./index-render.vue_vue_type_script_setup_true_lang.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/widgets/containers/form/index-render.vue
|
|
5
|
-
var index_render_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_render_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var index_render_default = /* @__PURE__ */ _plugin_vue_export_helper_default(index_render_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-4231072f"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { index_render_default as default };
|
|
@@ -12,7 +12,39 @@ var index_render_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ d
|
|
|
12
12
|
props: { widget: {} },
|
|
13
13
|
setup(__props, { expose: __expose }) {
|
|
14
14
|
const { fieldEditor, formModel, handleHidden, defineExposed } = useField(__props.widget);
|
|
15
|
-
|
|
15
|
+
const validate = (...args) => {
|
|
16
|
+
var _fieldEditor$value, _fieldEditor$value$va;
|
|
17
|
+
return (_fieldEditor$value = fieldEditor.value) === null || _fieldEditor$value === void 0 || (_fieldEditor$value$va = _fieldEditor$value.validate) === null || _fieldEditor$value$va === void 0 ? void 0 : _fieldEditor$value$va.call(_fieldEditor$value, ...args);
|
|
18
|
+
};
|
|
19
|
+
const validateFields = (...args) => {
|
|
20
|
+
var _fieldEditor$value2, _fieldEditor$value2$v;
|
|
21
|
+
return (_fieldEditor$value2 = fieldEditor.value) === null || _fieldEditor$value2 === void 0 || (_fieldEditor$value2$v = _fieldEditor$value2.validateFields) === null || _fieldEditor$value2$v === void 0 ? void 0 : _fieldEditor$value2$v.call(_fieldEditor$value2, ...args);
|
|
22
|
+
};
|
|
23
|
+
const resetFields = (...args) => {
|
|
24
|
+
var _fieldEditor$value3, _fieldEditor$value3$r;
|
|
25
|
+
return (_fieldEditor$value3 = fieldEditor.value) === null || _fieldEditor$value3 === void 0 || (_fieldEditor$value3$r = _fieldEditor$value3.resetFields) === null || _fieldEditor$value3$r === void 0 ? void 0 : _fieldEditor$value3$r.call(_fieldEditor$value3, ...args);
|
|
26
|
+
};
|
|
27
|
+
const clearValidate = (...args) => {
|
|
28
|
+
var _fieldEditor$value4, _fieldEditor$value4$c;
|
|
29
|
+
return (_fieldEditor$value4 = fieldEditor.value) === null || _fieldEditor$value4 === void 0 || (_fieldEditor$value4$c = _fieldEditor$value4.clearValidate) === null || _fieldEditor$value4$c === void 0 ? void 0 : _fieldEditor$value4$c.call(_fieldEditor$value4, ...args);
|
|
30
|
+
};
|
|
31
|
+
const scrollToField = (...args) => {
|
|
32
|
+
var _fieldEditor$value5, _fieldEditor$value5$s;
|
|
33
|
+
return (_fieldEditor$value5 = fieldEditor.value) === null || _fieldEditor$value5 === void 0 || (_fieldEditor$value5$s = _fieldEditor$value5.scrollToField) === null || _fieldEditor$value5$s === void 0 ? void 0 : _fieldEditor$value5$s.call(_fieldEditor$value5, ...args);
|
|
34
|
+
};
|
|
35
|
+
const getFieldsValue = (...args) => {
|
|
36
|
+
var _fieldEditor$value6, _fieldEditor$value6$g;
|
|
37
|
+
return (_fieldEditor$value6 = fieldEditor.value) === null || _fieldEditor$value6 === void 0 || (_fieldEditor$value6$g = _fieldEditor$value6.getFieldsValue) === null || _fieldEditor$value6$g === void 0 ? void 0 : _fieldEditor$value6$g.call(_fieldEditor$value6, ...args);
|
|
38
|
+
};
|
|
39
|
+
__expose({
|
|
40
|
+
...defineExposed,
|
|
41
|
+
validate,
|
|
42
|
+
validateFields,
|
|
43
|
+
resetFields,
|
|
44
|
+
clearValidate,
|
|
45
|
+
scrollToField,
|
|
46
|
+
getFieldsValue
|
|
47
|
+
});
|
|
16
48
|
return (_ctx, _cache) => {
|
|
17
49
|
const _component_a_form = resolveComponent("a-form");
|
|
18
50
|
return !unref(handleHidden) ? (openBlock(), createElementBlock("div", {
|