retejs / vue-plugin

https://retejs.org
MIT License
38 stars 36 forks source link

Cannot apply preset. Provided signals are not compatible #63

Closed jangxx closed 1 year ago

jangxx commented 1 year ago

I built an application on a slightly older version of the v2 render plugin, which now broke after updating everything to the latest versions.

The offending lines are the following (excerpt):

class TextBlockNode extends ClassicPreset.Node<
    { textIn: ClassicPreset.Socket }, 
    { textOut: ClassicPreset.Socket }
> { ... }

class BranchNode extends ClassicPreset.Node<
    { textIn: ClassicPreset.Socket }, 
    Record<string, ClassicPreset.Socket>
> { ... }

class StartNode extends ClassicPreset.Node<
    {}, 
    { textOut: ClassicPreset.Socket }
> { ... }

class OutputNode extends ClassicPreset.Node<
    { textIn: ClassicPreset.Socket }, 
    {}
> { ... }

type Schemes = GetSchemes<
  TextBlockNode | StartNode | OutputNode | BranchNode,
  ClassicPreset.Connection<ClassicPreset.Node, ClassicPreset.Node>
>;
type AreaExtra = VueArea2D<Schemes>;

area = new AreaPlugin<Schemes, AreaExtra>(container);
const render = new VueRenderPlugin<Schemes>();

// error occurs in these lines:
render.addPreset(Presets.classic.setup<Schemes, AreaExtra>({
    area,
    customize: {
        node(context) {
            if (context.payload instanceof TextBlockNode) {
                return TextBlockNodeVue;
            }
            if (context.payload instanceof BranchNode) {
                return BranchNodeVue;
            }
            return CustomNode;
        },
        socket() {
            return CustomSocket;
        },
        connection() {
            return CustomConnection;
        },
    }
}));

All of the Custom* classes are imported from different Vue files. This code worked without issues before, but I think https://github.com/retejs/vue-render-plugin/commit/31711fa2678b33899031e0d61afc3a80cc9efca4 might have broken it. Unfortunately I can't figure out how to get it working again.

Used library versions:

"rete": "^2.0.0-beta.9",
"rete-area-plugin": "^2.0.0-beta.12",
"rete-connection-plugin": "^2.0.0-beta.17",
"rete-engine": "^2.0.0-beta.7",
"rete-minimap-plugin": "^2.0.0-beta.5",
"rete-render-utils": "^2.0.0-beta.13",
"rete-vue-render-plugin": "^2.0.0-beta.24",
Ni55aN commented 1 year ago

// error occurs in these lines:

what error?

Ni55aN commented 1 year ago

nevermind

const vueRender = new VueRenderPlugin<Schemes, AreaExtra>();

This is a part of breaking change (unfortunately it was not mentioned in the CHANGELOG.md). On the other hand, the code in the guide is correct

jangxx commented 1 year ago

Thanks for the quick reply, I'm gonna try to get it working with that change tomorrow.

jangxx commented 1 year ago

The fix worked perfectly, thanks again.