Skip to content

[feat]: Scope vueNodesMap per LogicFlow instance to support nested scenarios#2378

Merged
DymoneLewis merged 4 commits intodidi:masterfrom
EralChen:feat/vue_nodes_scoped
Mar 4, 2026
Merged

[feat]: Scope vueNodesMap per LogicFlow instance to support nested scenarios#2378
DymoneLewis merged 4 commits intodidi:masterfrom
EralChen:feat/vue_nodes_scoped

Conversation

@EralChen
Copy link
Contributor

Store Vue node registrations in a WeakMap<GraphModel, ...> and add getVueNodeConfig(type, graphModel) so node configs are resolved per LogicFlow instance instead of from a shared global map.

Updated VueNodeView to read configs through the new scoped getter, which prevents cross-instance registration collisions in multi-instance usage. Kept populating the legacy vueNodesMap (marked deprecated) for backward compatibility.fix(vue-node-registry): isolate node config per LF instance

Store Vue node registrations in a WeakMap<GraphModel, ...> and add getVueNodeConfig(type, graphModel) so node configs are resolved per LogicFlow instance instead of from a shared global map.

Updated VueNodeView to read configs through the new scoped getter, which prevents cross-instance registration collisions in multi-instance usage. Kept populating the legacy vueNodesMap (marked deprecated) for backward compatibility.

@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2026

⚠️ No Changeset found

Latest commit: 50f528b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@EralChen
Copy link
Contributor Author

About #2377

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR scopes Vue node registrations to a specific LogicFlow instance to avoid cross-instance collisions (notably in nested / multi-instance scenarios), by introducing a WeakMap<GraphModel, ...> registry and updating VueNodeView to resolve configs through a scoped getter.

Changes:

  • Added per-GraphModel Vue node registry stored in a module-level WeakMap plus getVueNodeConfig(type, graphModel).
  • Deprecated (but still populated) the legacy global vueNodesMap for backward compatibility.
  • Updated VueNodeView to load the node component via getVueNodeConfig(...) instead of the global map.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/vue-node-registry/src/view.ts Switches runtime config lookup to the new per-instance getter.
packages/vue-node-registry/src/registry.ts Introduces WeakMap-scoped registry, adds getter, keeps legacy global map populated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +54 to +59
let map = vueNodesMaps.get(lf.graphModel)
if (!map) {
map = {}
vueNodesMaps.set(lf.graphModel, map)
}
map[type] = entry
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the per-instance registry (map) and the deprecated global vueNodesMap use plain objects indexed by type. If type is not strictly controlled, keys like __proto__/constructor can lead to prototype pollution. Prefer Map<string, VueNodeEntry> (and store it in the WeakMap), or initialize with Object.create(null) and reject dangerous keys.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s strange
it doesn’t seem to be running. Could you please manually add a commit?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

EralChen and others added 3 commits March 3, 2026 17:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@DymoneLewis DymoneLewis merged commit 66cada5 into didi:master Mar 4, 2026
@DymoneLewis
Copy link
Collaborator

Thank you for your contribution. I will release a version later, and the version number will be synchronized here after the release is complete.ღ( ´・ᴗ・` )

@DymoneLewis
Copy link
Collaborator

@EralChen Good afternoon, friend. I just released version @logicflow/vue-node-registry@1.1.13, which includes the changes you submitted in your recent PR. You can upgrade and try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants