fix check variadic input/output
This commit is contained in:
1 parent
82379131df
commit
90d2e30ff7
6 files changed
+20
-11
No files matched your search
@@ -79,7 +79,7 @@
|
|||||||
"tree.desc": "Tree desc",
|
"tree.desc": "Tree desc",
|
||||||
"tree.export": "Export",
|
"tree.export": "Export",
|
||||||
"tree.firstid": "First id",
|
"tree.firstid": "First id",
|
||||||
"tree.group": "Available groups",
|
"tree.group": "Enable Node Grouping",
|
||||||
"tree.vars": "Define Variables",
|
"tree.vars": "Define Variables",
|
||||||
"tree.vars.name": "name",
|
"tree.vars.name": "name",
|
||||||
"tree.vars.invalidName": "Invalid variable name",
|
"tree.vars.invalidName": "Invalid variable name",
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
"tree.desc": "说明",
|
"tree.desc": "说明",
|
||||||
"tree.export": "导出",
|
"tree.export": "导出",
|
||||||
"tree.firstid": "起始标识",
|
"tree.firstid": "起始标识",
|
||||||
"tree.group": "可用分组",
|
"tree.group": "启用节点分组",
|
||||||
"tree.vars": "定义变量",
|
"tree.vars": "定义变量",
|
||||||
"tree.vars.name": "变量名",
|
"tree.vars.name": "变量名",
|
||||||
"tree.vars.invalidName": "变量名不合法",
|
"tree.vars.invalidName": "变量名不合法",
|
||||||
|
|||||||
@@ -239,10 +239,6 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const parseExpr = (expr: string) => {
|
|
||||||
return expr.split(/[^a-zA-Z0-9_]/);
|
|
||||||
};
|
|
||||||
|
|
||||||
const findHightlight = (node: TreeGraphData, highlight: string[], changed?: TreeGraphData[]) => {
|
const findHightlight = (node: TreeGraphData, highlight: string[], changed?: TreeGraphData[]) => {
|
||||||
changed ||= [];
|
changed ||= [];
|
||||||
if (node.highlightInput || node.highlightOutput || node.highlightArgs) {
|
if (node.highlightInput || node.highlightOutput || node.highlightArgs) {
|
||||||
@@ -276,7 +272,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
|||||||
if (isExprType(arg.type)) {
|
if (isExprType(arg.type)) {
|
||||||
const expr: string | string[] = node.args?.[arg.name];
|
const expr: string | string[] = node.args?.[arg.name];
|
||||||
if (typeof expr === "string") {
|
if (typeof expr === "string") {
|
||||||
for (const v of parseExpr(expr)) {
|
for (const v of b3util.parseExpr(expr)) {
|
||||||
if (highlight.includes(v)) {
|
if (highlight.includes(v)) {
|
||||||
node.highlightArgs = true;
|
node.highlightArgs = true;
|
||||||
changed.push(node);
|
changed.push(node);
|
||||||
@@ -285,7 +281,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
|||||||
}
|
}
|
||||||
} else if (expr instanceof Array) {
|
} else if (expr instanceof Array) {
|
||||||
loop: for (const str of expr) {
|
loop: for (const str of expr) {
|
||||||
for (const v of parseExpr(str)) {
|
for (const v of b3util.parseExpr(str)) {
|
||||||
if (highlight.includes(v)) {
|
if (highlight.includes(v)) {
|
||||||
node.highlightArgs = true;
|
node.highlightArgs = true;
|
||||||
changed.push(node);
|
changed.push(node);
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ const TreeInspector: FC = () => {
|
|||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
gap: 8,
|
gap: 8,
|
||||||
rowGap: 0,
|
rowGap: 0,
|
||||||
|
marginLeft: 16,
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,11 @@
|
|||||||
import type { TreeGraphData as G6TreeGraphData } from "@antv/g6";
|
import type { TreeGraphData as G6TreeGraphData } from "@antv/g6";
|
||||||
import type { NodeDef } from "../behavior3/src/behavior3";
|
import { NodeDef } from "../behavior3/src/behavior3";
|
||||||
|
|
||||||
|
declare module "../behavior3/src/behavior3" {
|
||||||
|
interface NodeDef {
|
||||||
|
group?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type NodeType = NodeDef["type"] | "Other" | "Error";
|
export type NodeType = NodeDef["type"] | "Other" | "Error";
|
||||||
export type NodeArg = Exclude<NodeDef["args"], undefined>[number];
|
export type NodeArg = Exclude<NodeDef["args"], undefined>[number];
|
||||||
|
|||||||
+8
-2
@@ -1,5 +1,5 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { type NodeDef } from "../behavior3/src/behavior3";
|
import { NodeDef } from "../behavior3/src/behavior3";
|
||||||
import {
|
import {
|
||||||
ImportDef,
|
ImportDef,
|
||||||
isBoolType,
|
isBoolType,
|
||||||
@@ -54,6 +54,7 @@ export const initWorkdir = (path: string, handler: typeof alertError) => {
|
|||||||
|
|
||||||
const group = v.type.match(/\((\w+)\)/)?.[1];
|
const group = v.type.match(/\((\w+)\)/)?.[1];
|
||||||
if (group) {
|
if (group) {
|
||||||
|
v.group = group;
|
||||||
groups.add(group);
|
groups.add(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -534,7 +535,7 @@ export const isVariadic = (def: string[], i: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isValidInputOrOutput = (def: string[], data: string[] | undefined, index: number) => {
|
const isValidInputOrOutput = (def: string[], data: string[] | undefined, index: number) => {
|
||||||
return def[index].includes("?") || data?.[index] || (isVariadic(def, index) && data?.[index]);
|
return def[index].includes("?") || data?.[index] || isVariadic(def, index);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const checkTreeData = (data: TreeGraphData) => {
|
export const checkTreeData = (data: TreeGraphData) => {
|
||||||
@@ -759,3 +760,8 @@ export const loadSubtreeVarDef = (data: TreeGraphData) => {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const parseExpr = (expr: string) => {
|
||||||
|
const result = expr.split(/[^a-zA-Z0-9_.]/);
|
||||||
|
return result.map((v) => v.split(".")[0]).filter((v) => v);
|
||||||
|
};
|
||||||
Reference in new issue
Block a user