…object (#16956)
Extension `configure()` hooks now receive a shallow copy of the
serialized node/graph object instead of the caller's live reference, so
a hook that reassigns or adds top-level fields (or the payload promotion
itself) no longer pollutes the caller's workflow JSON. No serialization
boundary is introduced inside `configure`: live `NodeInputSlot`
instances and other callback value shapes pass through untouched. Split
out of #16508 at the reviewer's request.
<details><summary>Full context for agent readers</summary>
## Summary
`extensionConfigureView` `Object.assign`'d the namespaced/legacy
extension payload directly onto the caller's live serialized object and
handed that object to `onConfigure`. Any hook mutation of its argument,
and the promotion of namespaced keys to top-level fields, leaked back
into the caller's data. Flagged in review of #15924
(#15924 (comment))
and tracked in #15973.
## Change
`extensionConfigureView` now builds the view as `Object.assign({
...canonical }, structuredClone(namespaced), structuredClone(legacy))`
and hands that to `onConfigure`. This is a shallow copy of the canonical
object: it isolates object identity and keeps promoted extension keys
off the caller's object (the two consequences raised in the #15924
review), without re-encoding anything. Nested values (`inputs`, `pos`,
`properties`, `widgets_values`, ...) stay shared with the caller by
design; in-place mutation of those still reaches the caller's data, and
the migration doc says so and points extensions at `node.properties` /
`graph.extra` for their own state.
An earlier revision of this PR used a JSON round trip for a deep copy.
That was dropped after review: `JSON.stringify` is a new failure and
representation boundary in the middle of `configure` (circular
references and BigInt throw; `undefined`, dates and class instances are
rewritten), and `configure` previously guaranteed the callback saw the
supported value shapes. The extension payloads themselves are still
validated as JSON and `structuredClone`d as before; the
`cloneSerialised` helper is gone.
## Tests
- `extensionPersistence.test.ts` (new): `onConfigure` receives a copy,
not the caller's object, and top-level adds/reassigns/deletes on the
view do not reach the caller (including `size` and `extensions`); a
serialized object holding live slot instances configures without
throwing and the hook sees the same `inputs` array and slot instance the
caller passed; serialize does not promote namespaced keys to top-level
fields; a missing-node placeholder stays free of promoted keys after
`onConfigure` mutates its view.
- `LGraph.serialise.test.ts`: the existing "passes the original
serialized object" test now asserts the hook gets a copy and that a
top-level field added by the hook is absent from the saved workflow.
No test asserts JSON-derived shapes. Verified green for
`src/lib/litegraph/src/extensionPersistence.test.ts
src/lib/litegraph/src/LGraph.serialise.test.ts
src/services/litegraphService.lateRegistration.test.ts` (28 tests), plus
typecheck, lint and format.
## Provenance
Extracted from #16508 (head f210e61) in response to the request to
split the configure-isolation fix from the coverage-only work. #16508
keeps the dynamic-widget fix and the `getNodeOnPos` coverage. Sibling
split: the `removeNode` `keep-values` fix.
Addresses #15973 (isolation for extension `configure()`).
</details>
<!-- authored-by:agent w3-w29 -->
---------
Co-authored-by: Amp <amp@ampcode.com>
Backport of #16956 to
core/1.53Automatically created by backport workflow.