streamlit-webrtc 0.47.9__py3-none-any.whl → 0.48.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,14 @@ to abstract and improve the session behavior.
40
40
  Ref: https://github.com/streamlit/streamlit/pull/5856
41
41
  """
42
42
 
43
+ VER_GTE_1_36_0 = ST_VERSION >= version.parse("1.36.0")
44
+ """ Since 1.36.0, the `on_change` handler on a custom component is supported.
45
+ Ref: https://github.com/streamlit/streamlit/issues/3977
46
+ Also, the `.components_callbacks.register_callback` hack no longer works since 1.39.0
47
+ where the registered callback via this hack is not called,
48
+ so we must use the new `on_change` handler.
49
+ """
50
+
43
51
  try:
44
52
  from streamlit.runtime.app_session import AppSession, AppSessionState
45
53
  except ModuleNotFoundError:
@@ -28,7 +28,7 @@ from streamlit_webrtc.models import (
28
28
  VideoFrameCallback,
29
29
  )
30
30
 
31
- from ._compat import rerun
31
+ from ._compat import VER_GTE_1_36_0, rerun
32
32
  from .components_callbacks import register_callback
33
33
  from .config import (
34
34
  DEFAULT_AUDIO_HTML_ATTRS,
@@ -481,8 +481,13 @@ def webrtc_streamer(
481
481
  if on_change and old_state != new_state:
482
482
  on_change()
483
483
 
484
- register_callback(element_key=frontend_key, callback=callback)
485
-
484
+ if not VER_GTE_1_36_0:
485
+ register_callback(element_key=frontend_key, callback=callback)
486
+ kwargs = {}
487
+ else:
488
+ kwargs = {
489
+ "on_change": callback,
490
+ }
486
491
  component_value_raw: Union[Dict, str, None] = _component_func(
487
492
  key=frontend_key,
488
493
  sdp_answer_json=sdp_answer_json,
@@ -494,6 +499,7 @@ def webrtc_streamer(
494
499
  audio_html_attrs=audio_html_attrs,
495
500
  translations=translations,
496
501
  desired_playing_state=desired_playing_state,
502
+ **kwargs,
497
503
  )
498
504
  # HOTFIX: The return value from _component_func()
499
505
  # is of type str with streamlit==0.84.0.
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "files": {
3
- "main.js": "./static/js/main.ff279b83.js",
3
+ "main.js": "./static/js/main.39438811.js",
4
4
  "index.html": "./index.html",
5
- "main.ff279b83.js.map": "./static/js/main.ff279b83.js.map"
5
+ "main.39438811.js.map": "./static/js/main.39438811.js.map"
6
6
  },
7
7
  "entrypoints": [
8
- "static/js/main.ff279b83.js"
8
+ "static/js/main.39438811.js"
9
9
  ]
10
10
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><title>Streamlit WebRTC Component</title><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Streamlit WebRTC Component"/><script defer="defer" src="./static/js/main.ff279b83.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><title>Streamlit WebRTC Component</title><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Streamlit WebRTC Component"/><script defer="defer" src="./static/js/main.39438811.js"></script></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>