@cniot/mdd-editor 0.3.7 → 0.3.9
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/build/index.cjs.js +23 -23
- package/build/index.es.js +481 -29
- package/build/style.css +1 -1
- package/package.json +1 -1
- package/src/ai/LocalAIDrawer.jsx +511 -22
- package/src/ai/bridgeClient.js +1 -0
package/build/index.es.js
CHANGED
|
@@ -26193,6 +26193,9 @@ var styles$b = {
|
|
|
26193
26193
|
const DRAG_KEY$2 = "PanelTitle";
|
|
26194
26194
|
const { Panel: Panel$3 } = Collapse;
|
|
26195
26195
|
const { Tooltip } = Balloon;
|
|
26196
|
+
const stopHeaderInputKeyboardEvent = (event) => {
|
|
26197
|
+
event.stopPropagation();
|
|
26198
|
+
};
|
|
26196
26199
|
const TitleRender$2 = (props) => {
|
|
26197
26200
|
const ref = useRef(null);
|
|
26198
26201
|
const {
|
|
@@ -26270,7 +26273,8 @@ const TitleRender$2 = (props) => {
|
|
|
26270
26273
|
size: "small",
|
|
26271
26274
|
value: label,
|
|
26272
26275
|
onChange: (v2) => titleChange("label", v2),
|
|
26273
|
-
|
|
26276
|
+
onKeyDown: stopHeaderInputKeyboardEvent,
|
|
26277
|
+
placeholder: "\u8F93\u5165\u5C55\u793A\u540D\u79F0"
|
|
26274
26278
|
}), titleType.includes("type") && /* @__PURE__ */ React$1.createElement("div", {
|
|
26275
26279
|
className: styles$b.itemComponent
|
|
26276
26280
|
}, /* @__PURE__ */ React$1.createElement("label", {
|
|
@@ -30252,6 +30256,7 @@ function normalizeBridgeConfig(config2) {
|
|
|
30252
30256
|
};
|
|
30253
30257
|
}
|
|
30254
30258
|
return {
|
|
30259
|
+
...config2 || {},
|
|
30255
30260
|
enabled: (config2 == null ? void 0 : config2.enabled) !== false,
|
|
30256
30261
|
baseURL: (config2 == null ? void 0 : config2.baseURL) || DEFAULT_BRIDGE_URL
|
|
30257
30262
|
};
|
|
@@ -30632,10 +30637,372 @@ function PullDiffDetail({ diffSummary }) {
|
|
|
30632
30637
|
className: "mdd-local-ai-diff-pre"
|
|
30633
30638
|
}, diffText) : null));
|
|
30634
30639
|
}
|
|
30635
|
-
|
|
30640
|
+
const L4_CODE_PATTERN = /L4:([a-zA-Z0-9_-]+)/g;
|
|
30641
|
+
const DEFAULT_LINKED_PAGE_DETAIL_URL = "/l4/api/v1/console/get-by-code";
|
|
30642
|
+
const LINKED_PAGE_LOG_PREFIX = "[MDD AI Bridge][L4]";
|
|
30643
|
+
const LOCAL_CHANGE_SKIP_REASON = "\u672C\u5730\u5DF2\u6709\u672A\u540C\u6B65\u4FEE\u6539";
|
|
30644
|
+
const normalizeText = (value) => {
|
|
30645
|
+
if (typeof value === "string")
|
|
30646
|
+
return value;
|
|
30647
|
+
if (value == null)
|
|
30648
|
+
return "";
|
|
30649
|
+
return JSON.stringify(value, null, 2);
|
|
30650
|
+
};
|
|
30651
|
+
const logLinkedPageDebug = (...args) => {
|
|
30652
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
30653
|
+
console.info(LINKED_PAGE_LOG_PREFIX, ...args);
|
|
30654
|
+
}
|
|
30655
|
+
};
|
|
30656
|
+
const collectL4ReferencesFromText = (text = "", source = "script", path = "$") => {
|
|
30657
|
+
const references = [];
|
|
30658
|
+
const pattern = new RegExp(L4_CODE_PATTERN);
|
|
30659
|
+
let match = pattern.exec(String(text));
|
|
30660
|
+
while (match) {
|
|
30661
|
+
references.push({
|
|
30662
|
+
code: match[1],
|
|
30663
|
+
source,
|
|
30664
|
+
paths: [path]
|
|
30665
|
+
});
|
|
30666
|
+
match = pattern.exec(String(text));
|
|
30667
|
+
}
|
|
30668
|
+
return references;
|
|
30669
|
+
};
|
|
30670
|
+
const collectL4ReferencesFromJSON = (value, path = "$", references = []) => {
|
|
30671
|
+
if (typeof value === "string") {
|
|
30672
|
+
references.push(...collectL4ReferencesFromText(value, "schema", path));
|
|
30673
|
+
return references;
|
|
30674
|
+
}
|
|
30675
|
+
if (Array.isArray(value)) {
|
|
30676
|
+
value.forEach((item, index2) => collectL4ReferencesFromJSON(item, `${path}[${index2}]`, references));
|
|
30677
|
+
return references;
|
|
30678
|
+
}
|
|
30679
|
+
if (value && typeof value === "object") {
|
|
30680
|
+
Object.keys(value).forEach((key) => {
|
|
30681
|
+
references.push(...collectL4ReferencesFromText(key, "schema-key", `${path}.${key}`));
|
|
30682
|
+
collectL4ReferencesFromJSON(value[key], `${path}.${key}`, references);
|
|
30683
|
+
});
|
|
30684
|
+
}
|
|
30685
|
+
return references;
|
|
30686
|
+
};
|
|
30687
|
+
const mergeL4References = (references = [], rootCode) => {
|
|
30688
|
+
const referenceMap = /* @__PURE__ */ new Map();
|
|
30689
|
+
references.forEach((reference) => {
|
|
30690
|
+
if (!(reference == null ? void 0 : reference.code) || reference.code === rootCode)
|
|
30691
|
+
return;
|
|
30692
|
+
const existing = referenceMap.get(reference.code) || {
|
|
30693
|
+
code: reference.code,
|
|
30694
|
+
source: reference.source,
|
|
30695
|
+
paths: []
|
|
30696
|
+
};
|
|
30697
|
+
existing.source = existing.source === reference.source ? existing.source : "mixed";
|
|
30698
|
+
existing.paths = [.../* @__PURE__ */ new Set([...existing.paths, ...reference.paths || []])];
|
|
30699
|
+
referenceMap.set(reference.code, existing);
|
|
30700
|
+
});
|
|
30701
|
+
return [...referenceMap.values()];
|
|
30702
|
+
};
|
|
30703
|
+
const collectLinkedPageReferences = ({ schemaJson, scriptInfo, rootCode, extraSources = [] }) => {
|
|
30704
|
+
const schemaReferences = collectL4ReferencesFromJSON(schemaJson);
|
|
30705
|
+
const scriptReferences = collectL4ReferencesFromText(scriptInfo, "script", "mdd.script.jsx");
|
|
30706
|
+
const extraReferences = extraSources.flatMap(
|
|
30707
|
+
(source) => collectL4ReferencesFromText((source == null ? void 0 : source.text) || "", (source == null ? void 0 : source.source) || "extra", (source == null ? void 0 : source.path) || "$")
|
|
30708
|
+
);
|
|
30709
|
+
return mergeL4References([...schemaReferences, ...scriptReferences, ...extraReferences], rootCode);
|
|
30710
|
+
};
|
|
30711
|
+
const createLinkedPageExtraSources = (data = {}, prefix = "payload") => {
|
|
30712
|
+
const sourceFields = [
|
|
30713
|
+
"schemaInfo",
|
|
30714
|
+
"schemaJson",
|
|
30715
|
+
"schema",
|
|
30716
|
+
"scriptInfo",
|
|
30717
|
+
"script",
|
|
30718
|
+
"style",
|
|
30719
|
+
"compileFile",
|
|
30720
|
+
"translateInfo",
|
|
30721
|
+
"serverDataHandle",
|
|
30722
|
+
"metaData",
|
|
30723
|
+
"sqlData",
|
|
30724
|
+
"sqlDataCount",
|
|
30725
|
+
"swaggerInfo",
|
|
30726
|
+
"dataPermissions",
|
|
30727
|
+
"pageMeta",
|
|
30728
|
+
"pageIR"
|
|
30729
|
+
];
|
|
30730
|
+
return sourceFields.filter((fieldName) => data[fieldName] != null).map((fieldName) => ({
|
|
30731
|
+
source: fieldName,
|
|
30732
|
+
path: `${prefix}.${fieldName}`,
|
|
30733
|
+
text: normalizeText(data[fieldName])
|
|
30734
|
+
}));
|
|
30735
|
+
};
|
|
30736
|
+
const enqueueLinkedPageReferences = ({ queue, referenceMap, references, parentCode, depth, rootCode, visitedCodes }) => {
|
|
30737
|
+
references.forEach((reference) => {
|
|
30738
|
+
if (!(reference == null ? void 0 : reference.code) || reference.code === rootCode)
|
|
30739
|
+
return;
|
|
30740
|
+
const nextReference = {
|
|
30741
|
+
...reference,
|
|
30742
|
+
parentCode,
|
|
30743
|
+
depth
|
|
30744
|
+
};
|
|
30745
|
+
const existing = referenceMap.get(reference.code);
|
|
30746
|
+
if (existing) {
|
|
30747
|
+
existing.source = existing.source === nextReference.source ? existing.source : "mixed";
|
|
30748
|
+
existing.paths = [.../* @__PURE__ */ new Set([...existing.paths || [], ...nextReference.paths || []])];
|
|
30749
|
+
existing.parents = [.../* @__PURE__ */ new Set([...existing.parents || [], parentCode])];
|
|
30750
|
+
existing.depth = Math.min(existing.depth || depth, depth);
|
|
30751
|
+
return;
|
|
30752
|
+
}
|
|
30753
|
+
referenceMap.set(reference.code, {
|
|
30754
|
+
...nextReference,
|
|
30755
|
+
parents: [parentCode]
|
|
30756
|
+
});
|
|
30757
|
+
if (!visitedCodes.has(reference.code)) {
|
|
30758
|
+
queue.push(nextReference);
|
|
30759
|
+
}
|
|
30760
|
+
});
|
|
30761
|
+
};
|
|
30762
|
+
const fetchLinkedPageByCode = async (code, config2 = {}) => {
|
|
30636
30763
|
var _a2;
|
|
30764
|
+
const detailUrl = config2.linkedPageDetailUrl || DEFAULT_LINKED_PAGE_DETAIL_URL;
|
|
30765
|
+
const separator = detailUrl.includes("?") ? "&" : "?";
|
|
30766
|
+
const url = `${detailUrl}${separator}code=${encodeURIComponent(code)}`;
|
|
30767
|
+
logLinkedPageDebug("fetch page detail", { code, url });
|
|
30768
|
+
const response = await fetch(url, {
|
|
30769
|
+
credentials: "include"
|
|
30770
|
+
});
|
|
30771
|
+
const text = await response.text();
|
|
30772
|
+
let result = null;
|
|
30773
|
+
try {
|
|
30774
|
+
result = text ? JSON.parse(text) : null;
|
|
30775
|
+
} catch (error) {
|
|
30776
|
+
throw new Error(`\u5173\u8054 L4 \u9875\u9762\u8BE6\u60C5\u63A5\u53E3\u8FD4\u56DE\u975E JSON\uFF1A${text || response.status}`);
|
|
30777
|
+
}
|
|
30778
|
+
if (!response.ok) {
|
|
30779
|
+
throw new Error((result == null ? void 0 : result.errorMessage) || (result == null ? void 0 : result.message) || `\u5173\u8054 L4 \u9875\u9762\u8BE6\u60C5\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25\uFF1A${response.status}`);
|
|
30780
|
+
}
|
|
30781
|
+
if ((result == null ? void 0 : result.success) === false) {
|
|
30782
|
+
throw new Error((result == null ? void 0 : result.errorMessage) || (result == null ? void 0 : result.message) || (result == null ? void 0 : result.msg) || "\u5173\u8054 L4 \u9875\u9762\u8BE6\u60C5\u63A5\u53E3\u8FD4\u56DE\u5931\u8D25");
|
|
30783
|
+
}
|
|
30784
|
+
const pageData = (result == null ? void 0 : result.data) || result;
|
|
30785
|
+
logLinkedPageDebug("fetch page detail success", {
|
|
30786
|
+
code,
|
|
30787
|
+
name: (pageData == null ? void 0 : pageData.name) || ((_a2 = pageData == null ? void 0 : pageData.pageMeta) == null ? void 0 : _a2.name),
|
|
30788
|
+
hasSchemaInfo: Boolean(pageData == null ? void 0 : pageData.schemaInfo),
|
|
30789
|
+
hasScriptInfo: Boolean(pageData == null ? void 0 : pageData.scriptInfo),
|
|
30790
|
+
hasCompileFile: Boolean(pageData == null ? void 0 : pageData.compileFile)
|
|
30791
|
+
});
|
|
30792
|
+
return pageData;
|
|
30793
|
+
};
|
|
30794
|
+
const getLinkedPageResolver = (config2) => {
|
|
30795
|
+
if (typeof (config2 == null ? void 0 : config2.resolveLinkedPage) === "function")
|
|
30796
|
+
return config2.resolveLinkedPage;
|
|
30797
|
+
if (typeof window !== "undefined" && typeof window.__MDD_AI_BRIDGE_RESOLVE_L4_PAGE === "function") {
|
|
30798
|
+
return window.__MDD_AI_BRIDGE_RESOLVE_L4_PAGE;
|
|
30799
|
+
}
|
|
30800
|
+
return (code) => fetchLinkedPageByCode(code, config2);
|
|
30801
|
+
};
|
|
30802
|
+
const normalizeLinkedPagePayload = (reference, pageData) => {
|
|
30803
|
+
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
30804
|
+
if (!pageData)
|
|
30805
|
+
return null;
|
|
30806
|
+
const schemaJson = parseSchema(pageData.schemaInfo || pageData.schemaJson || pageData.schema || "{}") || {};
|
|
30807
|
+
const rawPageMeta = pageData.pageMeta || pageData.meta || {};
|
|
30808
|
+
const pageMeta = {
|
|
30809
|
+
...rawPageMeta,
|
|
30810
|
+
code: pageData.code || rawPageMeta.code || reference.code,
|
|
30811
|
+
name: (_a2 = pageData.name) != null ? _a2 : rawPageMeta.name,
|
|
30812
|
+
region: (_b2 = pageData.region) != null ? _b2 : rawPageMeta.region,
|
|
30813
|
+
module: (_c2 = pageData.module) != null ? _c2 : rawPageMeta.module,
|
|
30814
|
+
moduleName: (_d = pageData.moduleName) != null ? _d : rawPageMeta.moduleName,
|
|
30815
|
+
status: (_e = pageData.status) != null ? _e : rawPageMeta.status,
|
|
30816
|
+
grade: (_f = pageData.grade) != null ? _f : rawPageMeta.grade,
|
|
30817
|
+
mddTemplateType: (_g = pageData.mddTemplateType) != null ? _g : rawPageMeta.mddTemplateType,
|
|
30818
|
+
buildType: (_h = pageData.buildType) != null ? _h : rawPageMeta.buildType,
|
|
30819
|
+
operateType: (_i = pageData.operateType) != null ? _i : rawPageMeta.operateType,
|
|
30820
|
+
gmtModified: (_j = pageData.gmtModified) != null ? _j : rawPageMeta.gmtModified,
|
|
30821
|
+
modifierAccount: (_k = pageData.modifierAccount) != null ? _k : rawPageMeta.modifierAccount,
|
|
30822
|
+
modifierName: (_l = pageData.modifierName) != null ? _l : rawPageMeta.modifierName
|
|
30823
|
+
};
|
|
30824
|
+
const script = (_p = (_o = (_n = (_m = pageData.scriptInfo) == null ? void 0 : _m.script) != null ? _n : pageData.scriptInfo) != null ? _o : pageData.script) != null ? _p : "";
|
|
30825
|
+
const style2 = (_s = (_r = (_q = pageData.scriptInfo) == null ? void 0 : _q.style) != null ? _r : pageData.style) != null ? _s : "";
|
|
30826
|
+
const pageIR = pageData.pageIR || buildPageIR({
|
|
30827
|
+
schemaJson,
|
|
30828
|
+
script,
|
|
30829
|
+
style: style2,
|
|
30830
|
+
pageMeta
|
|
30831
|
+
});
|
|
30832
|
+
return {
|
|
30833
|
+
code: pageMeta.code,
|
|
30834
|
+
pageMeta,
|
|
30835
|
+
schemaInfo: normalizeText(pageData.schemaInfo || schemaJson),
|
|
30836
|
+
scriptInfo: script,
|
|
30837
|
+
style: style2,
|
|
30838
|
+
pageIR,
|
|
30839
|
+
extraSources: createLinkedPageExtraSources(
|
|
30840
|
+
{
|
|
30841
|
+
...pageData,
|
|
30842
|
+
pageMeta,
|
|
30843
|
+
pageIR,
|
|
30844
|
+
style: style2
|
|
30845
|
+
},
|
|
30846
|
+
`linkedPage.${pageMeta.code}`
|
|
30847
|
+
),
|
|
30848
|
+
linkedReference: reference
|
|
30849
|
+
};
|
|
30850
|
+
};
|
|
30851
|
+
const buildLinkedPagePayload = async (payload, config2) => {
|
|
30852
|
+
const rootSchemaJson = parseSchema(payload.schemaInfo) || {};
|
|
30853
|
+
const resolver = getLinkedPageResolver(config2);
|
|
30854
|
+
let rootPageData = null;
|
|
30855
|
+
try {
|
|
30856
|
+
logLinkedPageDebug("fetch root page detail for raw scan", { code: payload.code });
|
|
30857
|
+
rootPageData = await resolver(payload.code, {
|
|
30858
|
+
code: payload.code,
|
|
30859
|
+
source: "root",
|
|
30860
|
+
depth: 0,
|
|
30861
|
+
paths: ["root.get-by-code"]
|
|
30862
|
+
});
|
|
30863
|
+
} catch (error) {
|
|
30864
|
+
logLinkedPageDebug("fetch root page detail failed, fallback to editor payload only", {
|
|
30865
|
+
code: payload.code,
|
|
30866
|
+
reason: (error == null ? void 0 : error.message) || String(error)
|
|
30867
|
+
});
|
|
30868
|
+
}
|
|
30869
|
+
const directReferences = collectLinkedPageReferences({
|
|
30870
|
+
schemaJson: rootSchemaJson,
|
|
30871
|
+
scriptInfo: payload.scriptInfo,
|
|
30872
|
+
rootCode: payload.code,
|
|
30873
|
+
extraSources: [
|
|
30874
|
+
...payload.extraSources || [],
|
|
30875
|
+
...createLinkedPageExtraSources(rootPageData || {}, `rootApi.${payload.code}`)
|
|
30876
|
+
]
|
|
30877
|
+
});
|
|
30878
|
+
logLinkedPageDebug("scan root page", {
|
|
30879
|
+
code: payload.code,
|
|
30880
|
+
source: rootPageData ? "editor payload + root get-by-code raw data" : "editor payload only",
|
|
30881
|
+
directReferences: directReferences.map((reference) => ({
|
|
30882
|
+
code: reference.code,
|
|
30883
|
+
source: reference.source,
|
|
30884
|
+
paths: reference.paths
|
|
30885
|
+
}))
|
|
30886
|
+
});
|
|
30887
|
+
const queue = [];
|
|
30888
|
+
const referenceMap = /* @__PURE__ */ new Map();
|
|
30889
|
+
const visitedCodes = /* @__PURE__ */ new Set([payload.code]);
|
|
30890
|
+
const linkedPages = [];
|
|
30891
|
+
const failedLinkedPages = [];
|
|
30892
|
+
enqueueLinkedPageReferences({
|
|
30893
|
+
queue,
|
|
30894
|
+
referenceMap,
|
|
30895
|
+
references: directReferences,
|
|
30896
|
+
parentCode: payload.code,
|
|
30897
|
+
depth: 1,
|
|
30898
|
+
rootCode: payload.code,
|
|
30899
|
+
visitedCodes
|
|
30900
|
+
});
|
|
30901
|
+
while (queue.length > 0) {
|
|
30902
|
+
const currentReference = queue.shift();
|
|
30903
|
+
if (!(currentReference == null ? void 0 : currentReference.code) || visitedCodes.has(currentReference.code))
|
|
30904
|
+
continue;
|
|
30905
|
+
visitedCodes.add(currentReference.code);
|
|
30906
|
+
const latestReference = referenceMap.get(currentReference.code) || currentReference;
|
|
30907
|
+
try {
|
|
30908
|
+
logLinkedPageDebug("resolve linked page", {
|
|
30909
|
+
code: currentReference.code,
|
|
30910
|
+
parentCode: latestReference.parentCode,
|
|
30911
|
+
depth: latestReference.depth,
|
|
30912
|
+
paths: latestReference.paths
|
|
30913
|
+
});
|
|
30914
|
+
const pageData = await resolver(currentReference.code, latestReference);
|
|
30915
|
+
const linkedPage = normalizeLinkedPagePayload(latestReference, pageData);
|
|
30916
|
+
if (!linkedPage) {
|
|
30917
|
+
failedLinkedPages.push({
|
|
30918
|
+
...latestReference,
|
|
30919
|
+
reason: "\u5173\u8054 L4 \u9875\u9762\u8FD4\u56DE\u4E3A\u7A7A"
|
|
30920
|
+
});
|
|
30921
|
+
continue;
|
|
30922
|
+
}
|
|
30923
|
+
linkedPages.push(linkedPage);
|
|
30924
|
+
const linkedPageSchemaJson = parseSchema(linkedPage.schemaInfo) || {};
|
|
30925
|
+
const childReferences = collectLinkedPageReferences({
|
|
30926
|
+
schemaJson: linkedPageSchemaJson,
|
|
30927
|
+
scriptInfo: linkedPage.scriptInfo,
|
|
30928
|
+
rootCode: payload.code,
|
|
30929
|
+
extraSources: linkedPage.extraSources
|
|
30930
|
+
});
|
|
30931
|
+
logLinkedPageDebug("scan child page", {
|
|
30932
|
+
code: linkedPage.code,
|
|
30933
|
+
depth: latestReference.depth,
|
|
30934
|
+
childReferences: childReferences.map((reference) => ({
|
|
30935
|
+
code: reference.code,
|
|
30936
|
+
source: reference.source,
|
|
30937
|
+
paths: reference.paths
|
|
30938
|
+
}))
|
|
30939
|
+
});
|
|
30940
|
+
enqueueLinkedPageReferences({
|
|
30941
|
+
queue,
|
|
30942
|
+
referenceMap,
|
|
30943
|
+
references: childReferences,
|
|
30944
|
+
parentCode: linkedPage.code,
|
|
30945
|
+
depth: (latestReference.depth || 1) + 1,
|
|
30946
|
+
rootCode: payload.code,
|
|
30947
|
+
visitedCodes
|
|
30948
|
+
});
|
|
30949
|
+
} catch (error) {
|
|
30950
|
+
failedLinkedPages.push({
|
|
30951
|
+
...latestReference,
|
|
30952
|
+
reason: (error == null ? void 0 : error.message) || "\u5173\u8054 L4 \u9875\u9762\u52A0\u8F7D\u5931\u8D25"
|
|
30953
|
+
});
|
|
30954
|
+
}
|
|
30955
|
+
}
|
|
30956
|
+
const linkedPageReferences = [...referenceMap.values()];
|
|
30957
|
+
const maxDepth = linkedPageReferences.reduce((depth, reference) => Math.max(depth, reference.depth || 1), 0);
|
|
30958
|
+
const mergedLinkedPages = linkedPages.map((linkedPage) => ({
|
|
30959
|
+
...linkedPage,
|
|
30960
|
+
linkedReference: referenceMap.get(linkedPage.code) || linkedPage.linkedReference
|
|
30961
|
+
}));
|
|
30962
|
+
logLinkedPageDebug("scan complete", {
|
|
30963
|
+
code: payload.code,
|
|
30964
|
+
directCount: directReferences.length,
|
|
30965
|
+
totalCount: linkedPageReferences.length,
|
|
30966
|
+
syncedCount: mergedLinkedPages.length,
|
|
30967
|
+
failedCount: failedLinkedPages.length,
|
|
30968
|
+
references: linkedPageReferences.map((reference) => ({
|
|
30969
|
+
code: reference.code,
|
|
30970
|
+
source: reference.source,
|
|
30971
|
+
depth: reference.depth,
|
|
30972
|
+
paths: reference.paths,
|
|
30973
|
+
parents: reference.parents
|
|
30974
|
+
})),
|
|
30975
|
+
failed: failedLinkedPages
|
|
30976
|
+
});
|
|
30977
|
+
return {
|
|
30978
|
+
...payload,
|
|
30979
|
+
linkedPageReferences,
|
|
30980
|
+
linkedPageScan: {
|
|
30981
|
+
directCount: directReferences.length,
|
|
30982
|
+
totalCount: linkedPageReferences.length,
|
|
30983
|
+
maxDepth
|
|
30984
|
+
},
|
|
30985
|
+
linkedPages: mergedLinkedPages,
|
|
30986
|
+
failedLinkedPages
|
|
30987
|
+
};
|
|
30988
|
+
};
|
|
30989
|
+
const isLocalChangeSkippedPage = (page) => String((page == null ? void 0 : page.reason) || "").includes(LOCAL_CHANGE_SKIP_REASON);
|
|
30990
|
+
const createLinkedPushSummary = (res, fallbackDir) => ({
|
|
30991
|
+
type: "push",
|
|
30992
|
+
dir: (res == null ? void 0 : res.dir) || fallbackDir,
|
|
30993
|
+
linkedPages: (res == null ? void 0 : res.linkedPages) || {}
|
|
30994
|
+
});
|
|
30995
|
+
const createLinkedPullSummary = (res) => {
|
|
30996
|
+
const changedPages = ((res == null ? void 0 : res.linkedPageDiffs) || []).filter((item) => item.changed);
|
|
30997
|
+
if (!changedPages.length)
|
|
30998
|
+
return "";
|
|
30999
|
+
const codes = changedPages.map((item) => item.code).join("\u3001");
|
|
31000
|
+
return `\u68C0\u6D4B\u5230\u5173\u8054 L4 \u9875\u9762\u4E5F\u5B58\u5728\u672C\u5730\u4FEE\u6539\uFF1A${codes}\u3002\u5F53\u524D\u53EA\u540C\u6B65\u4E86\u5F53\u524D\u9875\u9762\uFF0C\u8BF7\u5206\u522B\u6253\u5F00\u8FD9\u4E9B L4 \u9875\u9762\u6267\u884C\u201C\u540C\u6B65\u672C\u5730\u4FEE\u6539\u201D\u5E76\u4FDD\u5B58\u3002`;
|
|
31001
|
+
};
|
|
31002
|
+
function LocalAIDrawer(props) {
|
|
31003
|
+
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i;
|
|
30637
31004
|
const { schema, scriptInfo, pageMeta = {}, bridgeConfig, onApply } = props;
|
|
30638
|
-
const config2 = normalizeBridgeConfig(bridgeConfig);
|
|
31005
|
+
const config2 = React$1.useMemo(() => normalizeBridgeConfig(bridgeConfig), [bridgeConfig]);
|
|
30639
31006
|
const [baseURL, setBaseURL] = React$1.useState(config2.baseURL || DEFAULT_BRIDGE_URL);
|
|
30640
31007
|
const [status, setStatus] = React$1.useState("\u672A\u8FDE\u63A5");
|
|
30641
31008
|
const [workspacePath, setWorkspacePath] = React$1.useState("");
|
|
@@ -30649,24 +31016,33 @@ function LocalAIDrawer(props) {
|
|
|
30649
31016
|
const getPayload = React$1.useCallback(() => {
|
|
30650
31017
|
var _a3;
|
|
30651
31018
|
const nextSchemaJson = ((_a3 = schema == null ? void 0 : schema.getAllJSON) == null ? void 0 : _a3.call(schema)) || {};
|
|
31019
|
+
const nextPageMeta = {
|
|
31020
|
+
...pageMeta,
|
|
31021
|
+
code: pageCode
|
|
31022
|
+
};
|
|
31023
|
+
const nextScriptInfo = (scriptInfo == null ? void 0 : scriptInfo.script) || "";
|
|
31024
|
+
const nextStyle = (scriptInfo == null ? void 0 : scriptInfo.style) || "";
|
|
31025
|
+
const nextPageIR = buildPageIR({
|
|
31026
|
+
schemaJson: nextSchemaJson,
|
|
31027
|
+
script: nextScriptInfo,
|
|
31028
|
+
style: nextStyle,
|
|
31029
|
+
pageMeta: nextPageMeta
|
|
31030
|
+
});
|
|
30652
31031
|
return {
|
|
30653
31032
|
code: pageCode,
|
|
30654
|
-
pageMeta:
|
|
30655
|
-
...pageMeta,
|
|
30656
|
-
code: pageCode
|
|
30657
|
-
},
|
|
31033
|
+
pageMeta: nextPageMeta,
|
|
30658
31034
|
schemaInfo: JSON.stringify(nextSchemaJson, null, 2),
|
|
30659
|
-
scriptInfo:
|
|
30660
|
-
style:
|
|
30661
|
-
pageIR:
|
|
30662
|
-
|
|
30663
|
-
|
|
30664
|
-
|
|
30665
|
-
|
|
30666
|
-
|
|
30667
|
-
|
|
30668
|
-
|
|
30669
|
-
|
|
31035
|
+
scriptInfo: nextScriptInfo,
|
|
31036
|
+
style: nextStyle,
|
|
31037
|
+
pageIR: nextPageIR,
|
|
31038
|
+
extraSources: createLinkedPageExtraSources(
|
|
31039
|
+
{
|
|
31040
|
+
pageMeta: nextPageMeta,
|
|
31041
|
+
pageIR: nextPageIR,
|
|
31042
|
+
style: nextStyle
|
|
31043
|
+
},
|
|
31044
|
+
"editorPayload"
|
|
31045
|
+
)
|
|
30670
31046
|
};
|
|
30671
31047
|
}, [pageCode, pageMeta, schema, scriptInfo]);
|
|
30672
31048
|
const expectedWorkspacePath = React$1.useMemo(() => {
|
|
@@ -30723,22 +31099,30 @@ function LocalAIDrawer(props) {
|
|
|
30723
31099
|
}
|
|
30724
31100
|
}, [baseURL]);
|
|
30725
31101
|
const handlePush = async () => {
|
|
31102
|
+
var _a3;
|
|
30726
31103
|
setLoadingAction("push");
|
|
30727
31104
|
setPullError(null);
|
|
30728
31105
|
setLastDiffSummary(null);
|
|
30729
31106
|
try {
|
|
30730
|
-
const
|
|
31107
|
+
const payload = await buildLinkedPagePayload(getPayload(), config2);
|
|
31108
|
+
const res = await pushPage(baseURL, pageCode, payload);
|
|
30731
31109
|
setWorkspacePath((res == null ? void 0 : res.dir) || "");
|
|
30732
31110
|
setBridgeInfo((prev) => {
|
|
30733
|
-
var
|
|
31111
|
+
var _a4;
|
|
30734
31112
|
return {
|
|
30735
31113
|
...prev || {},
|
|
30736
|
-
workspaceRoot: ((
|
|
31114
|
+
workspaceRoot: ((_a4 = res == null ? void 0 : res.context) == null ? void 0 : _a4.workspaceRoot) || (prev == null ? void 0 : prev.workspaceRoot)
|
|
30737
31115
|
};
|
|
30738
31116
|
});
|
|
30739
31117
|
setStatus("\u5DF2\u540C\u6B65\u5230\u672C\u5730");
|
|
30740
|
-
setLastSummary(
|
|
30741
|
-
|
|
31118
|
+
setLastSummary(createLinkedPushSummary(res, pageCode));
|
|
31119
|
+
if (((_a3 = res == null ? void 0 : res.linkedPages) == null ? void 0 : _a3.totalReferences) > 0) {
|
|
31120
|
+
CnMessage.success(
|
|
31121
|
+
`\u5DF2\u53D1\u9001\u5230\u672C\u5730 AI \u5DE5\u4F5C\u533A\uFF0C\u626B\u63CF\u5230\u76F4\u63A5\u5B50 L4 \u9875\u9762 ${res.linkedPages.directCount || 0} \u4E2A\uFF0C\u9012\u5F52\u5171 ${res.linkedPages.totalReferences} \u4E2A`
|
|
31122
|
+
);
|
|
31123
|
+
} else {
|
|
31124
|
+
CnMessage.success("\u5DF2\u53D1\u9001\u5230\u672C\u5730 AI \u5DE5\u4F5C\u533A");
|
|
31125
|
+
}
|
|
30742
31126
|
} catch (e) {
|
|
30743
31127
|
CnMessage.error(e.message || "\u53D1\u9001\u5230\u672C\u5730 AI \u5DE5\u4F5C\u533A\u5931\u8D25");
|
|
30744
31128
|
} finally {
|
|
@@ -30762,9 +31146,14 @@ function LocalAIDrawer(props) {
|
|
|
30762
31146
|
scriptInfo: nextScriptInfo,
|
|
30763
31147
|
raw: res
|
|
30764
31148
|
});
|
|
30765
|
-
|
|
31149
|
+
const linkedPullSummary = createLinkedPullSummary(res);
|
|
31150
|
+
setLastSummary([(res == null ? void 0 : res.summary) || "\u5DF2\u4ECE\u672C\u5730\u5DE5\u4F5C\u533A\u540C\u6B65\u4FEE\u6539", linkedPullSummary].filter(Boolean).join("\uFF1B"));
|
|
30766
31151
|
setLastDiffSummary((res == null ? void 0 : res.diffSummary) || null);
|
|
30767
|
-
|
|
31152
|
+
if (linkedPullSummary) {
|
|
31153
|
+
CnMessage.warning("\u5DF2\u540C\u6B65\u5F53\u524D\u9875\u9762\uFF1B\u5173\u8054\u5B50 L4 \u9875\u9762\u4E5F\u6709\u672C\u5730\u4FEE\u6539\uFF0C\u8BF7\u5206\u522B\u6253\u5F00\u5BF9\u5E94 L4 \u9875\u9762\u540C\u6B65\u5E76\u4FDD\u5B58");
|
|
31154
|
+
} else {
|
|
31155
|
+
CnMessage.success("\u5DF2\u540C\u6B65\u5F53\u524D\u9875\u9762\u7684\u672C\u5730\u4FEE\u6539\uFF0C\u8BF7\u9884\u89C8\u786E\u8BA4\u540E\u70B9\u51FB\u9875\u9762\u4FDD\u5B58");
|
|
31156
|
+
}
|
|
30768
31157
|
} catch (e) {
|
|
30769
31158
|
const detail = getJsonErrorDetail(e);
|
|
30770
31159
|
setPullError(detail);
|
|
@@ -30806,12 +31195,17 @@ function LocalAIDrawer(props) {
|
|
|
30806
31195
|
}
|
|
30807
31196
|
};
|
|
30808
31197
|
const handleStatus = async () => {
|
|
31198
|
+
var _a3, _b3;
|
|
30809
31199
|
setLoadingAction("status");
|
|
30810
31200
|
try {
|
|
30811
31201
|
const res = await getPageStatus(baseURL, pageCode);
|
|
30812
31202
|
setWorkspacePath((res == null ? void 0 : res.dir) || "");
|
|
30813
31203
|
setLastDiffSummary(null);
|
|
30814
|
-
|
|
31204
|
+
const linkedChangedCount = ((_a3 = res == null ? void 0 : res.linkedPages) == null ? void 0 : _a3.changedCount) || 0;
|
|
31205
|
+
const linkedStatusText = linkedChangedCount ? `\uFF1B\u5173\u8054 L4 \u9875\u9762\u4E2D\u6709 ${linkedChangedCount} \u4E2A\u5B58\u5728\u672C\u5730\u4FEE\u6539` : ((_b3 = res == null ? void 0 : res.linkedPages) == null ? void 0 : _b3.totalReferences) ? `\uFF1B\u5DF2\u8BB0\u5F55\u5173\u8054 L4 \u9875\u9762 ${res.linkedPages.totalReferences} \u4E2A` : "";
|
|
31206
|
+
setLastSummary(
|
|
31207
|
+
(res == null ? void 0 : res.exists) ? `\u672C\u5730\u5DE5\u4F5C\u533A\u5DF2\u5B58\u5728: ${res.dir}${linkedStatusText}` : "\u672C\u5730\u8FD8\u6CA1\u6709\u8FD9\u4E2A\u9875\u9762\u7684\u5DE5\u4F5C\u533A"
|
|
31208
|
+
);
|
|
30815
31209
|
CnMessage.success((res == null ? void 0 : res.exists) ? "\u672C\u5730\u5DE5\u4F5C\u533A\u5DF2\u5B58\u5728" : "\u672C\u5730\u5DE5\u4F5C\u533A\u4E0D\u5B58\u5728");
|
|
30816
31210
|
} catch (e) {
|
|
30817
31211
|
CnMessage.error(e.message || "\u67E5\u8BE2\u672C\u5730\u5DE5\u4F5C\u533A\u5931\u8D25");
|
|
@@ -30902,7 +31296,9 @@ function LocalAIDrawer(props) {
|
|
|
30902
31296
|
}, "\u6253\u5F00\u76EE\u5F55"), /* @__PURE__ */ React$1.createElement(CnButton, {
|
|
30903
31297
|
loading: loadingAction === "rollback",
|
|
30904
31298
|
onClick: handleRollback
|
|
30905
|
-
}, "\u56DE\u6EDA\u4E0A\u6B21\u66F4\u6539"))
|
|
31299
|
+
}, "\u56DE\u6EDA\u4E0A\u6B21\u66F4\u6539")), /* @__PURE__ */ React$1.createElement("div", {
|
|
31300
|
+
className: "mdd-local-ai-action-notice"
|
|
31301
|
+
}, "\u201C\u540C\u6B65\u672C\u5730\u4FEE\u6539\u201D\u53EA\u4F1A\u540C\u6B65\u5F53\u524D\u9875\u9762\u7684\u672C\u5730\u53D8\u66F4\uFF1B\u5982\u679C\u5173\u8054\u5B50 L4 \u9875\u9762\u4E5F\u5728\u672C\u5730\u6539\u8FC7\uFF0C\u8BF7\u6253\u5F00\u5BF9\u5E94\u5B50\u9875\u9762\u7684 L4 \u5730\u5740\uFF0C\u5206\u522B\u6267\u884C\u201C\u540C\u6B65\u672C\u5730\u4FEE\u6539\u201D\u5E76\u5728\u9875\u9762\u4E0A\u70B9\u51FB\u4FDD\u5B58\u3002")), /* @__PURE__ */ React$1.createElement("div", {
|
|
30906
31302
|
className: "mdd-local-ai-section"
|
|
30907
31303
|
}, /* @__PURE__ */ React$1.createElement("div", {
|
|
30908
31304
|
className: "mdd-local-ai-section-title"
|
|
@@ -30917,7 +31313,63 @@ function LocalAIDrawer(props) {
|
|
|
30917
31313
|
}, "\u590D\u5236\u5DE5\u4F5C\u533A\u8DEF\u5F84"), /* @__PURE__ */ React$1.createElement(CnButton, {
|
|
30918
31314
|
size: "small",
|
|
30919
31315
|
onClick: () => handleCopy(aiPrompt, "\u5DF2\u590D\u5236 AI \u63D0\u793A\u8BCD")
|
|
30920
|
-
}, "\u590D\u5236 AI \u63D0\u793A\u8BCD"))), lastSummary ? /* @__PURE__ */ React$1.createElement("div", {
|
|
31316
|
+
}, "\u590D\u5236 AI \u63D0\u793A\u8BCD"))), lastSummary ? lastSummary.type === "push" ? /* @__PURE__ */ React$1.createElement("div", {
|
|
31317
|
+
className: "mdd-local-ai-push-result"
|
|
31318
|
+
}, /* @__PURE__ */ React$1.createElement("div", {
|
|
31319
|
+
className: "mdd-local-ai-push-result-head"
|
|
31320
|
+
}, /* @__PURE__ */ React$1.createElement("div", null, /* @__PURE__ */ React$1.createElement("div", {
|
|
31321
|
+
className: "mdd-local-ai-push-result-title"
|
|
31322
|
+
}, "\u5DF2\u5199\u5165\u672C\u5730\u5DE5\u4F5C\u533A"), /* @__PURE__ */ React$1.createElement("div", {
|
|
31323
|
+
className: "mdd-local-ai-push-result-path"
|
|
31324
|
+
}, lastSummary.dir)), /* @__PURE__ */ React$1.createElement("span", {
|
|
31325
|
+
className: "mdd-local-ai-push-result-badge"
|
|
31326
|
+
}, "\u5B8C\u6210")), /* @__PURE__ */ React$1.createElement("div", {
|
|
31327
|
+
className: "mdd-local-ai-push-stats"
|
|
31328
|
+
}, /* @__PURE__ */ React$1.createElement("div", {
|
|
31329
|
+
className: "mdd-local-ai-push-stat"
|
|
31330
|
+
}, /* @__PURE__ */ React$1.createElement("span", null, "\u76F4\u63A5\u5B50 L4"), /* @__PURE__ */ React$1.createElement("strong", null, ((_b2 = lastSummary.linkedPages) == null ? void 0 : _b2.directCount) || 0)), /* @__PURE__ */ React$1.createElement("div", {
|
|
31331
|
+
className: "mdd-local-ai-push-stat"
|
|
31332
|
+
}, /* @__PURE__ */ React$1.createElement("span", null, "\u9012\u5F52\u5173\u8054"), /* @__PURE__ */ React$1.createElement("strong", null, ((_c2 = lastSummary.linkedPages) == null ? void 0 : _c2.totalReferences) || 0)), /* @__PURE__ */ React$1.createElement("div", {
|
|
31333
|
+
className: "mdd-local-ai-push-stat is-success"
|
|
31334
|
+
}, /* @__PURE__ */ React$1.createElement("span", null, "\u5DF2\u540C\u6B65"), /* @__PURE__ */ React$1.createElement("strong", null, ((_d = lastSummary.linkedPages) == null ? void 0 : _d.syncedCount) || 0)), /* @__PURE__ */ React$1.createElement("div", {
|
|
31335
|
+
className: "mdd-local-ai-push-stat is-warning"
|
|
31336
|
+
}, /* @__PURE__ */ React$1.createElement("span", null, "\u9700\u5904\u7406"), /* @__PURE__ */ React$1.createElement("strong", null, ((_e = lastSummary.linkedPages) == null ? void 0 : _e.failedCount) || 0))), ((_g = (_f = lastSummary.linkedPages) == null ? void 0 : _f.pages) == null ? void 0 : _g.length) ? /* @__PURE__ */ React$1.createElement("div", {
|
|
31337
|
+
className: "mdd-local-ai-linked-section"
|
|
31338
|
+
}, /* @__PURE__ */ React$1.createElement("div", {
|
|
31339
|
+
className: "mdd-local-ai-linked-section-title"
|
|
31340
|
+
}, "\u5DF2\u4E00\u8D77\u540C\u6B65\u7684\u5173\u8054\u9875\u9762"), /* @__PURE__ */ React$1.createElement("div", {
|
|
31341
|
+
className: "mdd-local-ai-linked-tags"
|
|
31342
|
+
}, lastSummary.linkedPages.pages.map((page) => /* @__PURE__ */ React$1.createElement("span", {
|
|
31343
|
+
key: page.code,
|
|
31344
|
+
className: "mdd-local-ai-linked-tag is-success has-name"
|
|
31345
|
+
}, /* @__PURE__ */ React$1.createElement("span", {
|
|
31346
|
+
className: "mdd-local-ai-linked-name"
|
|
31347
|
+
}, page.name || "\u672A\u547D\u540D\u9875\u9762"), /* @__PURE__ */ React$1.createElement("span", {
|
|
31348
|
+
className: "mdd-local-ai-linked-code"
|
|
31349
|
+
}, page.code))))) : null, ((_i = (_h = lastSummary.linkedPages) == null ? void 0 : _h.failed) == null ? void 0 : _i.length) ? /* @__PURE__ */ React$1.createElement("div", {
|
|
31350
|
+
className: "mdd-local-ai-linked-section"
|
|
31351
|
+
}, /* @__PURE__ */ React$1.createElement("div", {
|
|
31352
|
+
className: "mdd-local-ai-linked-section-title"
|
|
31353
|
+
}, "\u9700\u8981\u7528\u6237\u5904\u7406\u7684\u5173\u8054\u9875\u9762"), lastSummary.linkedPages.failed.map((page) => {
|
|
31354
|
+
const isLocalChangeSkipped = isLocalChangeSkippedPage(page);
|
|
31355
|
+
return /* @__PURE__ */ React$1.createElement("div", {
|
|
31356
|
+
key: page.code,
|
|
31357
|
+
className: "mdd-local-ai-linked-warning"
|
|
31358
|
+
}, /* @__PURE__ */ React$1.createElement("div", {
|
|
31359
|
+
className: "mdd-local-ai-linked-warning-main"
|
|
31360
|
+
}, /* @__PURE__ */ React$1.createElement("span", {
|
|
31361
|
+
className: "mdd-local-ai-linked-tag is-warning has-name"
|
|
31362
|
+
}, /* @__PURE__ */ React$1.createElement("span", {
|
|
31363
|
+
className: "mdd-local-ai-linked-name"
|
|
31364
|
+
}, page.name || "\u672A\u547D\u540D\u9875\u9762"), /* @__PURE__ */ React$1.createElement("span", {
|
|
31365
|
+
className: "mdd-local-ai-linked-code"
|
|
31366
|
+
}, page.code)), /* @__PURE__ */ React$1.createElement("span", null, page.reason || "\u672A\u80FD\u81EA\u52A8\u540C\u6B65")), isLocalChangeSkipped ? /* @__PURE__ */ React$1.createElement("div", {
|
|
31367
|
+
className: "mdd-local-ai-linked-actions-tip"
|
|
31368
|
+
}, /* @__PURE__ */ React$1.createElement("div", null, "\u8FD9\u4E2A\u9875\u9762\u672C\u5730\u5DF2\u6709\u672A\u540C\u6B65\u4FEE\u6539\uFF0C\u4E3A\u907F\u514D\u8986\u76D6\uFF0C\u672C\u6B21\u6CA1\u6709\u91CD\u65B0\u4E0B\u53D1\u3002"), /* @__PURE__ */ React$1.createElement("div", null, "\u4F60\u53EF\u4EE5\u9009\u62E9\uFF1A1\uFF09\u6253\u5F00\u8BE5 L4 \u9875\u9762\u5148\u201C\u540C\u6B65\u672C\u5730\u4FEE\u6539\u201D\u5E76\u4FDD\u5B58\uFF1B2\uFF09\u786E\u8BA4\u653E\u5F03\u672C\u5730\u6539\u52A8\u540E\u5220\u9664\u672C\u5730\u76EE\u5F55\uFF0C\u518D\u4ECE\u7236\u9875\u9762\u91CD\u65B0\u4E0B\u53D1\u3002"), page.dir ? /* @__PURE__ */ React$1.createElement(CnButton, {
|
|
31369
|
+
size: "small",
|
|
31370
|
+
onClick: () => handleCopy(page.dir, "\u5DF2\u590D\u5236\u5173\u8054\u9875\u9762\u672C\u5730\u76EE\u5F55")
|
|
31371
|
+
}, "\u590D\u5236\u672C\u5730\u76EE\u5F55") : null) : null);
|
|
31372
|
+
})) : null) : /* @__PURE__ */ React$1.createElement("div", {
|
|
30921
31373
|
className: "mdd-local-ai-summary"
|
|
30922
31374
|
}, lastSummary) : null, /* @__PURE__ */ React$1.createElement(PullDiffDetail, {
|
|
30923
31375
|
diffSummary: lastDiffSummary
|
|
@@ -31474,7 +31926,7 @@ function getDefaultIndexStyle() {
|
|
|
31474
31926
|
`;
|
|
31475
31927
|
}
|
|
31476
31928
|
const name = "@cniot/mdd-editor";
|
|
31477
|
-
const version = "0.3.
|
|
31929
|
+
const version = "0.3.9";
|
|
31478
31930
|
const description = "\u6A21\u578B\u9A71\u52A8\u7F16\u8F91\u5668";
|
|
31479
31931
|
const scripts = {
|
|
31480
31932
|
build: "vite build"
|