@@ -806,7 +806,10 @@ def serve_reload_hash(self):
806806 )
807807
808808 def serve_dist (self ):
809- libraries = flask .request .get_json ()
809+ libraries = [
810+ ComponentRegistry .namespace_to_package .get (lib , lib )
811+ for lib in flask .request .get_json ()
812+ ]
810813 dists = []
811814 for dist_type in ("_js_dist" , "_css_dist" ):
812815 resources = ComponentRegistry .get_resources (dist_type , libraries )
@@ -1282,6 +1285,8 @@ def long_callback(
12821285 def dispatch (self ):
12831286 body = flask .request .get_json ()
12841287
1288+ nlibs = len (ComponentRegistry .registry )
1289+
12851290 g = AttributeDict ({})
12861291
12871292 g .inputs_list = inputs = body .get ( # pylint: disable=assigning-non-slot
@@ -1311,6 +1316,7 @@ def dispatch(self):
13111316
13121317 try :
13131318 cb = self .callback_map [output ]
1319+ _allow_dynamic = cb .get ("allow_dynamic_callbacks" , False )
13141320 func = cb ["callback" ]
13151321 g .background_callback_manager = (
13161322 cb .get ("manager" ) or self ._background_manager
@@ -1362,6 +1368,7 @@ def dispatch(self):
13621368 except KeyError as missing_callback_function :
13631369 msg = f"Callback function not found for output '{ output } ', perhaps you forgot to prepend the '@'?"
13641370 raise KeyError (msg ) from missing_callback_function
1371+
13651372 ctx = copy_context ()
13661373 # noinspection PyArgumentList
13671374 response .set_data (
@@ -1375,6 +1382,12 @@ def dispatch(self):
13751382 )
13761383 )
13771384 )
1385+
1386+ if not _allow_dynamic and nlibs != len (ComponentRegistry .registry ):
1387+ print (
1388+ "Warning: component library imported during callback, move to top-level for full support." ,
1389+ file = sys .stderr ,
1390+ )
13781391 return response
13791392
13801393 def _setup_server (self ):
0 commit comments