check group and var on build
This commit is contained in:
1 parent
4fb851c8cc
commit
b8817fd2c9
10 files changed
+164
-61
No files matched your search
+34
-14
@@ -21,7 +21,15 @@ import {
|
||||
EditTree,
|
||||
useWorkspace,
|
||||
} from "../contexts/workspace-context";
|
||||
import { ImportDef, isExprType, NodeModel, TreeGraphData, TreeModel, VarDef } from "../misc/b3type";
|
||||
import {
|
||||
ImportDef,
|
||||
isExprType,
|
||||
NodeModel,
|
||||
TreeGraphData,
|
||||
TreeModel,
|
||||
VarDef,
|
||||
VERSION,
|
||||
} from "../misc/b3type";
|
||||
import * as b3util from "../misc/b3util";
|
||||
import { message } from "../misc/hooks";
|
||||
import i18n from "../misc/i18n";
|
||||
@@ -777,20 +785,32 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
};
|
||||
|
||||
const save = () => {
|
||||
if (editor.unsave || !fs.existsSync(editor.path)) {
|
||||
const path = editor.path;
|
||||
editor.autoId = b3util.refreshTreeDataId(editor.root, editor.data.firstid);
|
||||
editor.data.root = b3util.createFileData(editor.root);
|
||||
editor.modifiedTime = Date.now();
|
||||
fs.writeFileSync(path, JSON.stringify(editor.data, null, 2));
|
||||
workspace.updateFileMeta(editor);
|
||||
editor.unsave = false;
|
||||
editor.graph.changeData(editor.root);
|
||||
editor.graph.layout();
|
||||
restoreViewport();
|
||||
updateSearchState();
|
||||
updateState();
|
||||
if (b3util.isNewVersion(editor.data.version)) {
|
||||
message.error(t("alertNewVersion", { version: editor.data.version }), 6);
|
||||
return;
|
||||
}
|
||||
const path = editor.path;
|
||||
editor.autoId = b3util.refreshTreeDataId(editor.root, editor.data.firstid);
|
||||
editor.data.root = b3util.createFileData(editor.root);
|
||||
editor.modifiedTime = Date.now();
|
||||
fs.writeFileSync(
|
||||
path,
|
||||
JSON.stringify(
|
||||
{
|
||||
...editor.data,
|
||||
version: VERSION,
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
workspace.updateFileMeta(editor);
|
||||
editor.unsave = false;
|
||||
editor.graph.changeData(editor.root);
|
||||
editor.graph.layout();
|
||||
restoreViewport();
|
||||
updateSearchState();
|
||||
updateState();
|
||||
};
|
||||
|
||||
const editSubtree = () => {
|
||||
|
||||
@@ -152,12 +152,14 @@ G6.registerNode(
|
||||
!checkTreeData(data) ||
|
||||
(nodeDef.group && !usingGroups[nodeDef.group]) ||
|
||||
(usingVars &&
|
||||
(data.input?.some((v) => usingVars?.[v] === undefined) ||
|
||||
data.output?.some((v) => usingVars?.[v] === undefined) ||
|
||||
(data.input?.some((v) => v && usingVars?.[v] === undefined) ||
|
||||
data.output?.some((v) => v && usingVars?.[v] === undefined) ||
|
||||
nodeDef.args?.some(
|
||||
(v) =>
|
||||
isExprType(v.type) &&
|
||||
parseExpr(data.args?.[v.name] ?? "").some((vv) => usingVars?.[vv] === undefined)
|
||||
parseExpr(data.args?.[v.name] ?? "").some(
|
||||
(vv) => vv && usingVars?.[vv] === undefined
|
||||
)
|
||||
)))
|
||||
) {
|
||||
classify = "Error";
|
||||
|
||||
Reference in new issue
Block a user