Commit 9743bd7
refactor(gxt-backend): migrate __dcChangeListeners Set + counter via compilePipeline bridge (Cluster B slice 14)
Completes the half-migrated leftover from slice 12: the dynamic-component
change-listener Set (`__dcChangeListeners`) and its string-path counter
(`__dcStringListenerCount`) move from globalThis-shared state to
manager.ts module-local state, exposed as three new methods on
`compilePipeline`. Closes the last cross-file globalThis Set in the
slice-12 family.
Bridge interface evolution (slice 14 — ninth API change since the pilot):
- `GxtCompilePipelineCapabilities` extended with three required members:
* `addDynamicComponentListener(fn, options?: { stringPath?: boolean })`
-> `() => void` (off-fn). The `stringPath` option bumps the counter
consulted by `hasStringDynamicComponentListeners()`.
* `clearDynamicComponentListeners()` — clears both Set + counter in
lockstep.
* `hasStringDynamicComponentListeners(): boolean` — derived getter over
the manager.ts module-local counter.
- No new install API needed (manager.ts seeds all three via the initial
`setGxtRenderer` call; no host-hook is contributed from outside
manager.ts).
Site audit (per slice 12 + 13 deferred notes — all confirmed):
1. Three writer sites in `ember-gxt-wrappers.ts`:
- L1874-1877 (null path): `_nullListener` added via `add(_nullListener)`.
- L2034-2037 (curried path): `_dcChangeListener` added.
- L2302-2307 (string path): `_dcChangeListener` added + counter bumped.
2. Three cleanup sites in same file (L1881 / L2042 / L2312-2313): inline
`delete(...)` plus the string-path counter decrement at L2313.
3. One Set reader: the dispatch in manager.ts's `_gxtSyncAllWrappers`
after-body (L3712-3721, folded by slice 12).
4. Two counter readers:
- manager.ts:3857 — arg-cell update path triggers
`notifyPropertyChange` when string-path listeners are present.
- compile.ts:5202 — Phase 1 morph-skip when string-path listeners are
present.
5. One cross-test clear: compile.ts:5684-5685 plus the counter reset at
compile.ts:5692.
No external readers (the Set + counter were intra-gxt-backend only —
confirmed by exhaustive grep across packages and tests/HTML), so dual
exposure is NOT retained. The globalThis `__dcChangeListeners` /
`__dcStringListenerCount` keys are removed outright (no orphan reader risk).
Hooks migrated (1 Set + 1 counter -> 3 bridge methods):
1. `__dcChangeListeners` Set + `__dcStringListenerCount` counter ->
`compilePipeline.addDynamicComponentListener` /
`clearDynamicComponentListeners` /
`hasStringDynamicComponentListeners`.
- manager.ts module-local: `const _dcChangeListeners = new Set<_DcListener>()`
and `let _dcStringListenerCount = 0`. The three named functions
`_gxtAddDynamicComponentListener` / `_gxtClearDynamicComponentListeners` /
`_gxtHasStringDynamicComponentListeners` are seeded into the bridge
via `setGxtRenderer` at file EOF.
- The Set dispatch in `_gxtSyncAllWrappers` after-body now iterates the
module-local Set directly (no globalThis read).
- The counter check in manager.ts:3857 (notifyPropertyChange dispatch
after arg-cell updates) now calls `_gxtHasStringDynamicComponentListeners()`.
- compile.ts:5202's morph-skip check migrates to
`getGxtRenderer()?.compilePipeline.hasStringDynamicComponentListeners?.()`.
- compile.ts:5684-5692's cross-test clear block (Set `.clear()` +
counter reset) collapses into a single
`getGxtRenderer()?.compilePipeline.clearDynamicComponentListeners?.()`
call.
- The three ember-gxt-wrappers.ts writer sites are replaced with a
single `addDynamicComponentListener(fn, ...)` call returning an off-fn
used by the existing cleanup paths. The string-path site passes
`{ stringPath: true }` so the counter increments/decrements stay in
lockstep with the Set add/delete inside a single bridge surface.
Approach decision: (a) module-local + bridge methods, NOT (b) host-hook
or (c) relocation. The Set + counter are pure state; there is no wrap-by-
reassignment to break apart. The natural shape is "registry + register-fn
+ clear-fn + size-fn" — mechanically identical to slice 6's compile-side
state-bridging, but flipped (the state lives in manager.ts, not compile.ts,
because the dispatch already lives in manager.ts's `_gxtSyncAllWrappers`).
Verification (all 6 baseline gates green post-slice-14):
- smoke: 333/333 (16.8s)
- Errors thrown during render: 4/4
- Tracked Properties: 33/36 (3 pre-existing)
- computed: 147/148 (1 pre-existing)
- Lifecycle: 40/42 (2 pre-existing)
- render: 977/981 (4 pre-existing)
Net: 0 regressions, 0 new fixes. Cluster B progress: 14 slices migrated
covering 30 hooks (29 -> 30: the Set + counter count as a single logical
hook expressed as 3 bridge methods) across ~76 call sites + 9 orphan
cleanups + 9 wrap-by-reassignment installers eliminated (cumulative).
Bridge interface evolved NINE times total (slices 6/7/8/9/10/11/12/13/14).
All 8 capabilities namespaces remain stable.
Slice 14 validates a SIXTH migration shape on the bridge pattern: pure
state migration with a registry-style API (register-fn returning off-fn +
clear-fn + size-fn). Previous shapes: slice 3 = relocation, slice 6/7/9 =
install-API contribution, slice 8/10/11 = host-hook, slice 12/13 = wrap-
relocation. Slice 14's shape is the first to expose mutable state behind
typed methods without any host-hook or relocation pattern.
Suggested next slice (slice 15): `__gxtTriggerReRender` — multi-contributor
wrap (DEFERRED since slice 10 candidate ranking). The function is defined
in compile.ts; manager.ts wraps it at runtime to record dirtied nested
objects (`_dirtiedNestedObjectsForHooks` Set, an intra-manager.ts closure).
Audit needed: count of additional wrappers (beyond manager.ts's),
contributor location for each, and closure inventory. If manager.ts is the
only wrap contributor, this is a clean host-hook migration (slice 8/10/11
pattern: `__gxtTriggerReRender` becomes the canonical function in
`compilePipeline`, manager.ts contributes a `beforeTriggerReRender` host
hook via `installCompilePipelinePart`). If multiple files wrap it,
consider promoting to a chain pattern (extension of slice 8's host-hook
shape) or do a multi-slice migration. Alternative: `__gxtOriginalManagers`
(slice 7-deferred dual-writer) — `gxt-with-runtime-hbs.ts:219` AND
`compile.ts:6023` both write it. A dedicated slice can handle the dual-
write semantics via a chain or last-writer-wins discriminator.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 39cf0b0 commit 9743bd7
4 files changed
Lines changed: 210 additions & 50 deletions
File tree
- packages/@ember/-internals/gxt-backend
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5199 | 5199 | | |
5200 | 5200 | | |
5201 | 5201 | | |
5202 | | - | |
| 5202 | + | |
| 5203 | + | |
| 5204 | + | |
| 5205 | + | |
| 5206 | + | |
| 5207 | + | |
5203 | 5208 | | |
5204 | 5209 | | |
5205 | 5210 | | |
| |||
5679 | 5684 | | |
5680 | 5685 | | |
5681 | 5686 | | |
5682 | | - | |
| 5687 | + | |
| 5688 | + | |
| 5689 | + | |
| 5690 | + | |
| 5691 | + | |
| 5692 | + | |
| 5693 | + | |
| 5694 | + | |
| 5695 | + | |
5683 | 5696 | | |
5684 | | - | |
5685 | | - | |
5686 | | - | |
5687 | | - | |
5688 | | - | |
5689 | | - | |
5690 | | - | |
5691 | | - | |
5692 | | - | |
| 5697 | + | |
5693 | 5698 | | |
5694 | 5699 | | |
5695 | 5700 | | |
| |||
Lines changed: 43 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1868 | 1868 | | |
1869 | 1869 | | |
1870 | 1870 | | |
1871 | | - | |
1872 | | - | |
1873 | | - | |
1874 | | - | |
1875 | | - | |
1876 | | - | |
1877 | | - | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
1878 | 1882 | | |
1879 | 1883 | | |
1880 | 1884 | | |
1881 | | - | |
| 1885 | + | |
1882 | 1886 | | |
1883 | 1887 | | |
1884 | 1888 | | |
| |||
2027 | 2031 | | |
2028 | 2032 | | |
2029 | 2033 | | |
2030 | | - | |
2031 | | - | |
2032 | | - | |
2033 | | - | |
2034 | | - | |
2035 | | - | |
2036 | | - | |
2037 | | - | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
2038 | 2046 | | |
2039 | 2047 | | |
2040 | 2048 | | |
2041 | 2049 | | |
2042 | | - | |
| 2050 | + | |
2043 | 2051 | | |
2044 | 2052 | | |
2045 | 2053 | | |
| |||
2295 | 2303 | | |
2296 | 2304 | | |
2297 | 2305 | | |
2298 | | - | |
2299 | | - | |
2300 | | - | |
2301 | | - | |
2302 | | - | |
2303 | | - | |
2304 | | - | |
2305 | | - | |
2306 | | - | |
2307 | | - | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
2308 | 2323 | | |
2309 | 2324 | | |
2310 | 2325 | | |
2311 | 2326 | | |
2312 | | - | |
2313 | | - | |
| 2327 | + | |
2314 | 2328 | | |
2315 | 2329 | | |
2316 | 2330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
404 | 417 | | |
405 | 418 | | |
406 | 419 | | |
| |||
498 | 511 | | |
499 | 512 | | |
500 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
501 | 587 | | |
502 | 588 | | |
503 | 589 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3617 | 3617 | | |
3618 | 3618 | | |
3619 | 3619 | | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
| 3625 | + | |
| 3626 | + | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
3620 | 3662 | | |
3621 | 3663 | | |
3622 | 3664 | | |
| |||
3706 | 3748 | | |
3707 | 3749 | | |
3708 | 3750 | | |
3709 | | - | |
| 3751 | + | |
| 3752 | + | |
3710 | 3753 | | |
3711 | 3754 | | |
3712 | | - | |
3713 | | - | |
3714 | | - | |
3715 | | - | |
3716 | | - | |
3717 | | - | |
3718 | | - | |
3719 | | - | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
3720 | 3760 | | |
3721 | 3761 | | |
3722 | 3762 | | |
| |||
3854 | 3894 | | |
3855 | 3895 | | |
3856 | 3896 | | |
3857 | | - | |
| 3897 | + | |
3858 | 3898 | | |
3859 | 3899 | | |
3860 | 3900 | | |
| |||
12709 | 12749 | | |
12710 | 12750 | | |
12711 | 12751 | | |
| 12752 | + | |
| 12753 | + | |
| 12754 | + | |
| 12755 | + | |
| 12756 | + | |
| 12757 | + | |
| 12758 | + | |
| 12759 | + | |
| 12760 | + | |
| 12761 | + | |
| 12762 | + | |
| 12763 | + | |
| 12764 | + | |
| 12765 | + | |
| 12766 | + | |
12712 | 12767 | | |
12713 | 12768 | | |
12714 | 12769 | | |
| |||
0 commit comments