Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu committed Jun 17, 2024
1 parent c04afac commit 5bf3270
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
rules: {
"vue/no-unused-vars": "error",
"vue/no-reserved-component-names": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "error",
"no-unreachable": "error",
"vue/multi-word-component-names": "off",
Expand Down
26 changes: 11 additions & 15 deletions src/views/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { LGraphNode } from "litegraph.js";

type Methods = {
[key: string]: (...args: any[]) => any;
};

type AgentData = {
cname: string;
name: string;
inputs?: [string, string][];
outputs?: [string, string][];
inputs?: string[][];
outputs?: string[][];
};
function createAgentNode(agentData: AgentData, baseClass: { new (...args: any[]): any }) {
function createAgentNode(agentData: AgentData) {
class DynamicSubclass extends LGraphNode {
constructor(...args: any[]) {
constructor() {
super(agentData.name);
(this as any).className = agentData.cname;
if (agentData.inputs) {
Expand All @@ -31,11 +27,10 @@ function createAgentNode(agentData: AgentData, baseClass: { new (...args: any[])

Object.defineProperty(DynamicSubclass, "name", { value: agentData.cname });

return DynamicSubclass as new (...args: any[]) => { className: string } & LGraphNode;
return DynamicSubclass;
}

const ret = {};
[
const ret = [
{
cname: "BasicSumAgent",
name: "Sum",
Expand Down Expand Up @@ -71,7 +66,8 @@ const ret = {};
},
{ cname: "StringTemplateAgentNode", name: "StringTemplate", inputs: [["${0}", "string"]], outputs: [["Output", "string"]] },
{ cname: "PropertyFilterAgentNode", name: "PropertyFilter", inputs: [["In", "string"]], outputs: [["Output", "string"]] },
].map((agent: AgentData) => {
ret[agent.cname] = createAgentNode(agent, LGraphNode);
});
export default ret;
].reduce((tmp: Record<string, new () => LGraphNode>, agent: AgentData) => {
tmp[agent.cname] = createAgentNode(agent);
return tmp;
}, {});
export default ret;

0 comments on commit 5bf3270

Please sign in to comment.