(optPass: ICreateDefaultNodeOptions)
| 5841 | } |
| 5842 | |
| 5843 | createDefaultNodeForSlot(optPass: ICreateDefaultNodeOptions): boolean { |
| 5844 | type DefaultOptions = ICreateDefaultNodeOptions & { |
| 5845 | posAdd: Point |
| 5846 | posSizeFix: Point |
| 5847 | } |
| 5848 | |
| 5849 | const opts = Object.assign<DefaultOptions, ICreateDefaultNodeOptions>({ |
| 5850 | nodeFrom: null, |
| 5851 | slotFrom: null, |
| 5852 | nodeTo: null, |
| 5853 | slotTo: null, |
| 5854 | position: [0, 0], |
| 5855 | nodeType: undefined, |
| 5856 | posAdd: [0, 0], |
| 5857 | posSizeFix: [0, 0], |
| 5858 | }, optPass) |
| 5859 | const { afterRerouteId } = opts |
| 5860 | |
| 5861 | const isFrom = opts.nodeFrom && opts.slotFrom !== null |
| 5862 | const isTo = !isFrom && opts.nodeTo && opts.slotTo !== null |
| 5863 | |
| 5864 | if (!isFrom && !isTo) { |
| 5865 | console.warn(`No data passed to createDefaultNodeForSlot`, opts.nodeFrom, opts.slotFrom, opts.nodeTo, opts.slotTo) |
| 5866 | return false |
| 5867 | } |
| 5868 | if (!opts.nodeType) { |
| 5869 | console.warn("No type to createDefaultNodeForSlot") |
| 5870 | return false |
| 5871 | } |
| 5872 | |
| 5873 | const nodeX = isFrom ? opts.nodeFrom : opts.nodeTo |
| 5874 | if (!nodeX) throw new TypeError("nodeX was null when creating default node for slot.") |
| 5875 | |
| 5876 | let slotX = isFrom ? opts.slotFrom : opts.slotTo |
| 5877 | |
| 5878 | let iSlotConn: number | false = false |
| 5879 | if (nodeX instanceof SubgraphIONodeBase) { |
| 5880 | if (typeof slotX !== "object" || !slotX) { |
| 5881 | console.warn("Cant get slot information", slotX) |
| 5882 | return false |
| 5883 | } |
| 5884 | const { name } = slotX |
| 5885 | iSlotConn = nodeX.slots.findIndex(s => s.name === name) |
| 5886 | slotX = nodeX.slots[iSlotConn] |
| 5887 | if (!slotX) { |
| 5888 | console.warn("Cant get slot information", slotX) |
| 5889 | return false |
| 5890 | } |
| 5891 | } else { |
| 5892 | switch (typeof slotX) { |
| 5893 | case "string": |
| 5894 | iSlotConn = isFrom ? nodeX.findOutputSlot(slotX, false) : nodeX.findInputSlot(slotX, false) |
| 5895 | slotX = isFrom ? nodeX.outputs[slotX] : nodeX.inputs[slotX] |
| 5896 | break |
| 5897 | case "object": |
| 5898 | if (slotX === null) { |
| 5899 | console.warn("Cant get slot information", slotX) |
| 5900 | return false |
no test coverage detected