Skip empty native selection listener scans

This commit is contained in:
2026-11-11 03:37:03 +08:00
parent 0ce73a6854
commit 57dab91a9c
5 changed files with 80 additions and 4 deletions
+12 -2
View File
@@ -1018,13 +1018,23 @@ layer and its endpoints, while unrelated nodes remain culled. This can still
retain many endpoints/edges; it is not a constant-cost or complete geometry proof.
React Flow 12.12.1 does not expose a retained-ID selector. The app-only
`scripts/loaders/xyflow-retained.cjs` extends its two ESM visibility selectors at
compile time, under both webpack and Turbopack in `next.config.ts`. It requires
`scripts/loaders/xyflow-retained.cjs` extends its two ESM visibility selectors and
fixes the empty selection-listener guard at compile time, under both webpack
and Turbopack in `next.config.ts`. It requires
the pinned version and exact source anchors, rejecting mismatches before silently
losing editor retention. Dependency upgrades require reviewing this extension.
Shared node_modules are not edited. This is an app renderer build requirement;
the portable headless SDK/optional bindings do not include the Next loader.
The pinned dependency treats an empty `onSelectionChangeHandlers` array as
truthy. The app guard checks its length, so an unused SelectionListenerInner no
longer scans both native lookups on every store update. A callback prop or a real
`useOnSelectionChange` subscriber still mounts the original listener. This does
not add a second selection cache. The isolated page fixture checks notification,
unsubscribe/re-subscribe and scan counts; counters and the fixture observer are
excluded from performance builds and the production app. The VM regression also
checks callback-prop delivery against both installed ESM entry files.
The actual-page performance probe double-clicks a visible text card with native
Chrome input, checks mounted-node growth, inserts text and checks DOM identity,
focus and content before measuring deep copy. It then clears selection with a