156 Recursively instrument Dash component IDs.
158 Behavior is controlled by unified_debug:
160 - instrumentation_active():
161 False → return component unchanged
163 - instrumentation_verbose():
164 True → log detailed recursion info
165 False → log only high-level events
167 - instrumentation_allow_custom_components():
168 True → include custom (non-Dash-base-class) components
169 False → only standard Dash base-class components are instrumented
172 - Instrument ANY component that has an ID stored in `.id`,
173 or in Dash internals (`_props`, `_prop_ids`).
174 - Only rewrite string IDs (ignore dict IDs, None, etc.).
175 - Skip structural IDs.
176 - Recurse into children (list, tuple, or single child).
177 - Stop recursion if depth exceeds MAX_INSTRUMENT_DEPTH.
183 if not instrumentation_active():
189 if _depth > MAX_INSTRUMENT_DEPTH:
193 f
"MAX_INSTRUMENT_DEPTH ({MAX_INSTRUMENT_DEPTH}) exceeded — "
194 f
"instrumentation truncated at depth {_depth}",
202 if instrumentation_verbose():
206 f
"TYPE={type(component).__name__}, "
207 f
"CHILDREN_TYPE={type(getattr(component, 'children', None))}, "
208 f
"ID={getattr(component, 'id', None)}",
215 cid = getattr(component,
"id",
None)
218 if cid
is None and hasattr(component,
"_prop_ids"):
219 cid = component._prop_ids.get(
"id")
221 if cid
is None and hasattr(component,
"_props"):
222 cid = component._props.get(
"id")
233 if _ud.INSTRUMENTATION_ALL
or _is_dash_component(component)
or instrumentation_allow_custom_components():
235 new_id = {
"event": cid}
239 component.id = new_id
243 if hasattr(component,
"_prop_ids"):
244 component._prop_ids[
"id"] = new_id
246 if hasattr(component,
"_props"):
247 component._props[
"id"] = new_id
249 if instrumentation_verbose():
253 f
"Instrumented ID: {cid}",
257 elif instrumentation_verbose():
261 f
"Skipped custom component ID: {cid} (INSTRUMENTATION level < 5)",
268 children = getattr(component,
"children",
None)
270 if isinstance(children, (list, tuple)):
274 elif children
is not None: