1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use crate::*;
/// Retrieves a mutable pointer to `SignalInner<T>` directly from the signal's
/// stored address.
///
/// SAFETY: The address stored in `Signal::inner` is always a valid pointer
/// to a `SignalInner<T>` that is kept alive by the global registry. Since
/// WASM is single-threaded, the pointer is always valid as long as the signal
/// has not been explicitly freed.
///
/// # Arguments
///
/// - `usize` - The pointer address of the signal's inner state.
///
/// # Returns
///
/// - `&'static mut SignalInner<T>` - A mutable reference to the signal's inner state.
pub
/// Clears DOM-binding listeners on a signal identified by its inner pointer
/// address, without deactivating the signal itself.
///
/// This function is used during DOM cleanup (`cleanup_dom_subtree`) to
/// release signal listeners that reference DOM elements being removed.
/// Only `Signal<String>` instances are bound to the DOM, so this function
/// only handles that type. If the address does not correspond to a
/// `Signal<String>`, this is a no-op.
///
/// Importantly, this does NOT set `alive = false` or clear `dependents`.
/// A signal may be shared across multiple DOM bindings and DynamicNodes
/// (e.g., a user-created signal used as both a `value:` attribute on a
/// conditionally-rendered element AND as a dependency of another
/// DynamicNode's render function). Deactivating the signal here would
/// permanently break all other dependents — subsequent `set()` calls
/// would be no-ops and `get()` would skip dependency tracking.
///
/// The listeners are cleared to prevent stale callbacks from referencing
/// removed DOM elements. The signal remains fully functional for future
/// `set()` / `get()` calls and dependent DynamicNodes continue to receive
/// updates.
///
/// # Arguments
///
/// - `usize` - The inner pointer address of the signal.
pub
/// Returns whether the signal allocation at `addr` is still present in the
/// global registry (i.e. has not been freed signal inner).
///
/// Used by `update_and_notify` to avoid re-borrowing a `SignalInner` pointer
/// after running listeners, since a listener may have freed the allocation
/// during its execution. Probing the registry is the only safe way to detect
/// this, because the raw address itself carries no liveness information.
///
/// # Arguments
///
/// - `usize` - The inner pointer address of the signal.
///
/// # Returns
///
/// - `bool` - `true` if the allocation is still registered (safe to deref).
pub
/// Ensures the signal inner registry is initialized and returns a mutable reference.
///
/// SAFETY: Must only be called from the main thread (WASM single-threaded context).
///
/// # Returns
///
/// - `&'static mut HashSet<usize>`: A mutable reference to the signal inner registry.
pub