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