Skip to content

Commit

Permalink
fixes isMacroNodeDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
GabiGrin committed Feb 24, 2024
1 parent 4f626ac commit f795db3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
18 changes: 18 additions & 0 deletions core/src/node/macro-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,21 @@ export type ConfigurableInputDynamic = {
export type ConfigurableInput<T> =
| ConfigurableInputStatic<T>
| ConfigurableInputDynamic;

export const isMacroNode = (p: any): p is MacroNode<any> => {
return p && typeof (p as MacroNode<any>).runFnBuilder === "object";
};

export const isMacroNodeDefinition = (
p: any
): p is MacroNodeDefinition<any> => {
const { editorConfig } = (p ?? {}) as MacroNodeDefinition<any>;
if (editorConfig?.type === "custom") {
return (
typeof (editorConfig as MacroEditorConfigCustomDefinition)
.editorComponentBundleContent === "string"
);
} else {
return editorConfig?.type === "structured";
}
};
12 changes: 1 addition & 11 deletions core/src/node/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
nodeOutput,
} from "./node-pins";
import { ImportedNode } from "../flow-schema";
import { MacroNode, MacroNodeDefinition } from "./macro-node";
import { MacroNodeDefinition } from "./macro-node";

export type NodesCollection = OMap<Node>;

Expand Down Expand Up @@ -218,10 +218,6 @@ export const isCodeNode = (p: Node | NodeDefinition | any): p is CodeNode => {
return isBaseNode(p) && typeof (p as CodeNode).run === "function";
};

export const isMacroNode = (p: any): p is MacroNode<any> => {
return p && typeof (p as MacroNode<any>).runFnBuilder === "function";
};

export const extractMetadata: <N extends NodeMetadata>(
node: N
) => NodeMetadata = (node) => {
Expand All @@ -243,12 +239,6 @@ export const extractMetadata: <N extends NodeMetadata>(
};
};

export const isMacroNodeDefinition = (
p: any
): p is MacroNodeDefinition<any> => {
return p && typeof (p as MacroNode<any>).definitionBuilder === "undefined";
};

export const isVisualNode = (p: Node | NodeDefinition): p is VisualNode => {
return !!(p as VisualNode).instances;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
Dialog,
Classes,
} from "@blueprintjs/core";
import ReactDOM from "react-dom";

import { NodeStyleMenu } from "./NodeStyleMenu";
import { useDarkMode } from "../../flow-editor/DarkModeContext";

Expand Down

0 comments on commit f795db3

Please sign in to comment.