Skip to content

Commit

Permalink
Add system node to serach box db (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei committed Jul 13, 2024
1 parent 5fac7c9 commit 93a0c10
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { onMounted, onUnmounted, provide, ref } from "vue";
import NodeSearchboxPopover from "@/components/NodeSearchBoxPopover.vue";
import ProgressSpinner from "primevue/progressspinner";
import { api } from "@/scripts/api";
import { NodeSearchService } from "./services/nodeSearchService";
import {
NodeSearchService,
SYSTEM_NODE_DEFS,
} from "./services/nodeSearchService";
import { ColorPaletteLoadedEvent } from "./types/colorPalette";
import { LiteGraphNodeSearchSettingEvent } from "./scripts/ui";
Expand All @@ -35,7 +38,10 @@ const updateNodeSearchSetting = (e: LiteGraphNodeSearchSettingEvent) => {
const init = async () => {
const nodeDefs = Object.values(await api.getNodeDefs());
nodeSearchService.value = new NodeSearchService(nodeDefs);
nodeSearchService.value = new NodeSearchService([
...nodeDefs,
...SYSTEM_NODE_DEFS,
]);
document.addEventListener("comfy:setting:color-palette-loaded", updateTheme);
document.addEventListener(
Expand Down
36 changes: 36 additions & 0 deletions src/services/nodeSearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,42 @@ import { getNodeSource } from "@/types/nodeSource";
import Fuse, { IFuseOptions, FuseSearchOptions } from "fuse.js";
import _ from "lodash";

export const SYSTEM_NODE_DEFS: ComfyNodeDef[] = [
{
name: "PrimitiveNode",
display_name: "Primitive",
category: "utils",
input: { required: {}, optional: {} },
output: ["*"],
output_name: ["connect to widget input"],
output_is_list: [false],
python_module: "nodes",
description: "Primitive values like numbers, strings, and booleans.",
},
{
name: "Reroute",
display_name: "Reroute",
category: "utils",
input: { required: { "": ["*"] }, optional: {} },
output: ["*"],
output_name: [""],
output_is_list: [false],
python_module: "nodes",
description: "Reroute the connection to another node.",
},
{
name: "Note",
display_name: "Note",
category: "utils",
input: { required: {}, optional: {} },
output: [],
output_name: [],
output_is_list: [],
python_module: "nodes",
description: "Node that add notes to your project",
},
];

export class FuseSearch<T> {
private fuse: Fuse<T>;
public readonly data: T[];
Expand Down

0 comments on commit 93a0c10

Please sign in to comment.