streamlit-nightly 1.42.3.dev20250225__py2.py3-none-any.whl → 1.42.3.dev20250226__py2.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.
- streamlit/config.py +11 -4
- streamlit/elements/widgets/chat.py +99 -17
- streamlit/elements/widgets/file_uploader.py +20 -10
- streamlit/proto/ClientState_pb2.py +5 -3
- streamlit/proto/ClientState_pb2.pyi +29 -2
- streamlit/proto/NewSession_pb2.py +16 -16
- streamlit/proto/NewSession_pb2.pyi +9 -9
- streamlit/runtime/app_session.py +5 -0
- streamlit/runtime/context.py +19 -0
- streamlit/runtime/scriptrunner/script_runner.py +2 -0
- streamlit/runtime/scriptrunner_utils/script_requests.py +7 -1
- streamlit/runtime/scriptrunner_utils/script_run_context.py +4 -0
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{FileDownload.esm.BlYgQAwd.js → FileDownload.esm.CWn5B5ZN.js} +1 -1
- streamlit/static/static/js/{FileHelper.Da-FUCX4.js → FileHelper.Bii_mi1A.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.B4WYSqDL.js → FormClearHelper.BlCIuWCo.js} +1 -1
- streamlit/static/static/js/{Hooks.BoeFlDaA.js → Hooks.DURid8_V.js} +1 -1
- streamlit/static/static/js/{InputInstructions.DiPa6u6x.js → InputInstructions.gFFpIc6i.js} +1 -1
- streamlit/static/static/js/{ProgressBar.B-iCNc1a.js → ProgressBar.CtXtbXhv.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.DPgp77ia.js → RenderInPortalIfExists.DKWNQmbm.js} +1 -1
- streamlit/static/static/js/{Toolbar.9G2Er6_r.js → Toolbar.CKKwksQV.js} +1 -1
- streamlit/static/static/js/{base-input.z22leTiB.js → base-input.BUY9TLqO.js} +1 -1
- streamlit/static/static/js/{checkbox.DT5JbCKx.js → checkbox.C4L_5Z9H.js} +1 -1
- streamlit/static/static/js/{createSuper.9dngDO4F.js → createSuper.DprEKsA6.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.DnBgrJEy.js → data-grid-overlay-editor.BArvtwSg.js} +1 -1
- streamlit/static/static/js/{downloader.BgiOz4Dy.js → downloader.C5pxkE2v.js} +1 -1
- streamlit/static/static/js/{es6.C2nbxS8x.js → es6.DmKjMqyQ.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.XvWZp7Dg.js → iframeResizer.contentWindow.DhqbXIl1.js} +1 -1
- streamlit/static/static/js/{index.Bgn4z-Mp.js → index.B-S4HX7x.js} +1 -1
- streamlit/static/static/js/{index.CMvo7Iwl.js → index.B-vrwvgD.js} +1 -1
- streamlit/static/static/js/{index.qC8qMz0q.js → index.BAfr2RC0.js} +1 -1
- streamlit/static/static/js/index.BCErGZwr.js +1 -0
- streamlit/static/static/js/{index.DkwDCuk1.js → index.BEnZZwfW.js} +1 -1
- streamlit/static/static/js/{index.JgS0whqe.js → index.BSczaRDm.js} +1 -1
- streamlit/static/static/js/{index.B5-iXfzx.js → index.BUnWa5Cg.js} +1 -1
- streamlit/static/static/js/{index.DTP3exjF.js → index.BVHfAEko.js} +1 -1
- streamlit/static/static/js/{index.rECpAXqX.js → index.Bds7Anva.js} +1 -1
- streamlit/static/static/js/{index.DjTdTgti.js → index.Bk3A478D.js} +11 -11
- streamlit/static/static/js/{index.BkyYp5Em.js → index.BmnSGdtS.js} +1 -1
- streamlit/static/static/js/{index.T5vKsEVA.js → index.BoBCblDb.js} +1 -1
- streamlit/static/static/js/{index.Hnms5TSS.js → index.C3l2zbST.js} +1 -1
- streamlit/static/static/js/{index.exPoJHIW.js → index.CTqvpoOz.js} +1 -1
- streamlit/static/static/js/{index.D5wciRNz.js → index.CXpOPWFV.js} +1 -1
- streamlit/static/static/js/{index.DZ_FHOJd.js → index.Cd03IYkG.js} +1 -1
- streamlit/static/static/js/{index.BdtKHTgl.js → index.ChEJa75P.js} +1 -1
- streamlit/static/static/js/{index.D9bqDCB_.js → index.CoQjULdH.js} +1 -1
- streamlit/static/static/js/{index.BFYGskaf.js → index.CvNhwseQ.js} +1 -1
- streamlit/static/static/js/{index.BTK3gx3H.js → index.D2-IYCcZ.js} +1 -1
- streamlit/static/static/js/{index.UrE-Phqy.js → index.D2G24Udm.js} +1 -1
- streamlit/static/static/js/{index.D-9nQW74.js → index.DNr2W0gq.js} +1 -1
- streamlit/static/static/js/{index.BiPYzGZi.js → index.DhcYAj3f.js} +1 -1
- streamlit/static/static/js/{index.CBoIJv6M.js → index.DtIKjlNZ.js} +1 -1
- streamlit/static/static/js/{index.C5bx6jEW.js → index.EIkP6R_d.js} +1 -1
- streamlit/static/static/js/{index.BDSGWkr0.js → index.KPwXWqBk.js} +7 -7
- streamlit/static/static/js/{index.CAC6FyHh.js → index.NKOzzX__.js} +1 -1
- streamlit/static/static/js/{index.CBYIbEuv.js → index.O5-Wn4Yr.js} +1 -1
- streamlit/static/static/js/{index.bDDanN90.js → index.RFfgDsnM.js} +1 -1
- streamlit/static/static/js/{index.DcXXaGYK.js → index.RrEbViHi.js} +1 -1
- streamlit/static/static/js/{index.CrNuA-BG.js → index.UE_L1IEZ.js} +1 -1
- streamlit/static/static/js/{index.DC6PJYZU.js → index.WAlW9lgW.js} +1 -1
- streamlit/static/static/js/{index.DMreumKF.js → index.c_V1HXTs.js} +1 -1
- streamlit/static/static/js/{index.BNc20KTN.js → index.doRPQ8od.js} +1 -1
- streamlit/static/static/js/{index.pWHQEj0Q.js → index.oPGa5nFU.js} +1 -1
- streamlit/static/static/js/{index.DV46EgCO.js → index.u1gL_Cm_.js} +1 -1
- streamlit/static/static/js/{index.BxYliQ9c.js → index.xTncca7J.js} +1 -1
- streamlit/static/static/js/{input.mCBQrtCY.js → input.EkJ_AsTP.js} +1 -1
- streamlit/static/static/js/{memory.Te_zHgq3.js → memory.BFs17dZE.js} +1 -1
- streamlit/static/static/js/{mergeWith.Di9Yv3PE.js → mergeWith.B4u0whL-.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.Du6B2U8c.js → number-overlay-editor.DwazN43x.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.DqqPe-iu.js → possibleConstructorReturn.CZfYLVBb.js} +1 -1
- streamlit/static/static/js/{sandbox.iqWXuowq.js → sandbox.PjijA1v1.js} +1 -1
- streamlit/static/static/js/{textarea.DUN7d2zN.js → textarea.BGGnQXtw.js} +1 -1
- streamlit/static/static/js/{timepicker.BkmEJ-b8.js → timepicker.eLEnk1tw.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.D4OFzlWy.js → toConsumableArray.CgKj9NUY.js} +1 -1
- streamlit/static/static/js/{uniqueId.6OlKTkzK.js → uniqueId.CPmOGhdZ.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.Btr3rzhN.js → useBasicWidgetState.Bw_fxTtX.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.BM7LVpC-.js → useOnInputChange.D8qi7pm4.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.BCTIo1o2.js → withFullScreenWrapper.BjVufR9b.js} +1 -1
- {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/RECORD +84 -84
- {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/index.DyyHt_xV.js +0 -1
- {streamlit_nightly-1.42.3.dev20250225.data → streamlit_nightly-1.42.3.dev20250226.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.42.3.dev20250225.dist-info → streamlit_nightly-1.42.3.dev20250226.dist-info}/top_level.txt +0 -0
streamlit/config.py
CHANGED
@@ -1021,6 +1021,7 @@ _create_option(
|
|
1021
1021
|
_create_option(
|
1022
1022
|
"theme.linkColor",
|
1023
1023
|
description="Color used for all links.",
|
1024
|
+
visibility="hidden",
|
1024
1025
|
)
|
1025
1026
|
|
1026
1027
|
_create_option(
|
@@ -1038,6 +1039,7 @@ _create_option(
|
|
1038
1039
|
The font family to use for code (monospace) in the app.
|
1039
1040
|
To use a custom font, it needs to be added via [theme.fontFaces].
|
1040
1041
|
""",
|
1042
|
+
visibility="hidden",
|
1041
1043
|
)
|
1042
1044
|
|
1043
1045
|
_create_option(
|
@@ -1045,16 +1047,18 @@ _create_option(
|
|
1045
1047
|
description="""
|
1046
1048
|
Configure a list of font faces that you can use for the app & code fonts.
|
1047
1049
|
""",
|
1050
|
+
visibility="hidden",
|
1048
1051
|
)
|
1049
1052
|
|
1050
1053
|
|
1051
1054
|
_create_option(
|
1052
|
-
"theme.
|
1055
|
+
"theme.baseRadius",
|
1053
1056
|
description="""
|
1054
|
-
The
|
1055
|
-
|
1057
|
+
The radius used as basis for the corners of most UI elements. Can be:
|
1058
|
+
"none", "small", "medium", "large", "full", or the number in pixel or rem.
|
1059
|
+
For example: "10px", "0.5rem", "1.2rem", "2rem".
|
1056
1060
|
""",
|
1057
|
-
|
1061
|
+
visibility="hidden",
|
1058
1062
|
)
|
1059
1063
|
|
1060
1064
|
_create_option(
|
@@ -1062,6 +1066,7 @@ _create_option(
|
|
1062
1066
|
description="""
|
1063
1067
|
The color of the border around elements.
|
1064
1068
|
""",
|
1069
|
+
visibility="hidden",
|
1065
1070
|
)
|
1066
1071
|
|
1067
1072
|
_create_option(
|
@@ -1071,6 +1076,7 @@ _create_option(
|
|
1071
1076
|
file_uploader, etc).
|
1072
1077
|
""",
|
1073
1078
|
type_=bool,
|
1079
|
+
visibility="hidden",
|
1074
1080
|
)
|
1075
1081
|
|
1076
1082
|
_create_option(
|
@@ -1080,6 +1086,7 @@ _create_option(
|
|
1080
1086
|
scale of text and UI elements. The default base font size is 16.
|
1081
1087
|
""",
|
1082
1088
|
type_=int,
|
1089
|
+
visibility="hidden",
|
1083
1090
|
)
|
1084
1091
|
|
1085
1092
|
# Config Section: Secrets #
|
@@ -374,9 +374,9 @@ class ChatMixin:
|
|
374
374
|
Parameters
|
375
375
|
----------
|
376
376
|
placeholder : str
|
377
|
-
A placeholder text shown when the chat input is empty.
|
378
|
-
"Your message"
|
379
|
-
empty string.
|
377
|
+
A placeholder text shown when the chat input is empty. This
|
378
|
+
defaults to ``"Your message"``. For accessibility reasons, you
|
379
|
+
should not use an empty string.
|
380
380
|
|
381
381
|
key : str or int
|
382
382
|
An optional string or integer to use as the unique key for the widget.
|
@@ -384,19 +384,44 @@ class ChatMixin:
|
|
384
384
|
its content. No two widgets may have the same key.
|
385
385
|
|
386
386
|
max_chars : int or None
|
387
|
-
The maximum number of characters that can be entered. If
|
388
|
-
(default), there will be no maximum.
|
387
|
+
The maximum number of characters that can be entered. If this is
|
388
|
+
``None`` (default), there will be no maximum.
|
389
389
|
|
390
|
-
accept_file : bool
|
391
|
-
Whether the chat input should accept files.
|
392
|
-
|
390
|
+
accept_file : bool or str
|
391
|
+
Whether the chat input should accept files. This can be one of the
|
392
|
+
following values:
|
393
393
|
|
394
|
-
|
395
|
-
|
394
|
+
- ``False`` (default): No files are accepted and the user can only
|
395
|
+
submit a message.
|
396
|
+
- ``True``: The user can add a single file to their submission.
|
397
|
+
- ``"multiple"``: The user can add multiple files to their
|
398
|
+
submission.
|
399
|
+
|
400
|
+
When the widget is configured to accept files, the accepted file
|
401
|
+
types can be configured with the ``file_type`` parameter.
|
402
|
+
|
403
|
+
By default, uploaded files are limited to 200 MB each. You can
|
404
|
+
configure this using the ``server.maxUploadSize`` config option.
|
405
|
+
For more information on how to set config options, see
|
406
|
+
|config.toml|_.
|
407
|
+
|
408
|
+
.. |config.toml| replace:: ``config.toml``
|
409
|
+
.. _config.toml: https://docs.streamlit.io/develop/api-reference/configuration/config.toml
|
410
|
+
|
411
|
+
file_type : str, Sequence[str], or None
|
412
|
+
The allowed file extension(s) for uploaded files. This can be one
|
413
|
+
of the following types:
|
396
414
|
|
397
|
-
|
398
|
-
|
399
|
-
|
415
|
+
- ``None`` (default): All file extensions are allowed.
|
416
|
+
- A string: A single file extension is allowed. For example, to
|
417
|
+
only accept CSV files, use ``"csv"``.
|
418
|
+
- A sequence of strings: Multiple file extensions are allowed. For
|
419
|
+
example, to only accept JPG/JPEG and PNG files, use
|
420
|
+
``["jpg", "jpeg", "png"]``.
|
421
|
+
|
422
|
+
disabled : bool
|
423
|
+
Whether the chat input should be disabled. This defaults to
|
424
|
+
``False``.
|
400
425
|
|
401
426
|
on_submit : callable
|
402
427
|
An optional callback invoked when the chat input's value is submitted.
|
@@ -409,12 +434,41 @@ class ChatMixin:
|
|
409
434
|
|
410
435
|
Returns
|
411
436
|
-------
|
412
|
-
str or
|
413
|
-
The
|
414
|
-
|
437
|
+
None, str, or dict-like
|
438
|
+
The user's submission. This is one of the following types:
|
439
|
+
|
440
|
+
- ``None``: If the user didn't submit a message or file in the last
|
441
|
+
rerun, the widget returns ``None``.
|
442
|
+
- A string: When the widget is not configured to accept files and
|
443
|
+
the user submitted a message in the last rerun, the widget
|
444
|
+
returns the user's message as a string.
|
445
|
+
- A dict-like object: When the widget is configured to accept files
|
446
|
+
and the user submitted a message and/or file(s) in the last
|
447
|
+
rerun, the widget returns a dict-like object with two attributes,
|
448
|
+
``text`` and ``files``.
|
449
|
+
|
450
|
+
When the widget is configured to accept files and the user submits
|
451
|
+
something in the last rerun, you can access the user's submission
|
452
|
+
with key or attribute notation from the dict-like object. This is
|
453
|
+
shown in Example 3 below.
|
454
|
+
|
455
|
+
The ``text`` attribute holds a string, which is the user's message.
|
456
|
+
This is an empty string if the user only submitted one or more
|
457
|
+
files.
|
458
|
+
|
459
|
+
The ``files`` attribute holds a list of UploadedFile objects.
|
460
|
+
The list is empty if the user only submitted a message. Unlike
|
461
|
+
``st.file_uploader``, this attribute always returns a list, even
|
462
|
+
when the widget is configured to accept only one file at a time.
|
463
|
+
|
464
|
+
The UploadedFile class is a subclass of BytesIO, and therefore is
|
465
|
+
"file-like". This means you can pass an instance of it anywhere a
|
466
|
+
file is expected.
|
415
467
|
|
416
468
|
Examples
|
417
469
|
--------
|
470
|
+
**Example 1: Pin the the chat input widget to the bottom of your app**
|
471
|
+
|
418
472
|
When ``st.chat_input`` is used in the main body of an app, it will be
|
419
473
|
pinned to the bottom of the page.
|
420
474
|
|
@@ -428,9 +482,11 @@ class ChatMixin:
|
|
428
482
|
https://doc-chat-input.streamlit.app/
|
429
483
|
height: 350px
|
430
484
|
|
485
|
+
**Example 2: Use the chat input widget inline**
|
486
|
+
|
431
487
|
The chat input can also be used inline by nesting it inside any layout
|
432
488
|
container (container, columns, tabs, sidebar, etc) or fragment. Create
|
433
|
-
chat interfaces embedded next to other content or have multiple
|
489
|
+
chat interfaces embedded next to other content, or have multiple
|
434
490
|
chatbots!
|
435
491
|
|
436
492
|
>>> import streamlit as st
|
@@ -444,6 +500,32 @@ class ChatMixin:
|
|
444
500
|
.. output ::
|
445
501
|
https://doc-chat-input-inline.streamlit.app/
|
446
502
|
height: 350px
|
503
|
+
|
504
|
+
**Example 3: Let users upload files**
|
505
|
+
|
506
|
+
When you configure your chat input widget to allow file attachments, it
|
507
|
+
will return a dict-like object when the user sends a submission. You
|
508
|
+
can access the user's message through the ``text`` attribute of this
|
509
|
+
dictionary. You can access a list of the user's submitted file(s)
|
510
|
+
through the ``files`` attribute. Similar to ``st.session_state``, you
|
511
|
+
can use key or attribute notation.
|
512
|
+
|
513
|
+
>>> import streamlit as st
|
514
|
+
>>>
|
515
|
+
>>> prompt = st.chat_input(
|
516
|
+
>>> "Say something and/or attach an image",
|
517
|
+
>>> accept_file=True,
|
518
|
+
>>> file_type=["jpg", "jpeg", "png"],
|
519
|
+
>>> )
|
520
|
+
>>> if prompt and prompt.text:
|
521
|
+
>>> st.markdown(prompt.text)
|
522
|
+
>>> if prompt and prompt["files"]:
|
523
|
+
>>> st.image(prompt["files"][0])
|
524
|
+
|
525
|
+
.. output ::
|
526
|
+
https://doc-chat-input-file-uploader.streamlit.app/
|
527
|
+
height: 350px
|
528
|
+
|
447
529
|
"""
|
448
530
|
# We default to an empty string here and disallow user choice intentionally
|
449
531
|
default = ""
|
@@ -235,10 +235,12 @@ class FileUploaderMixin:
|
|
235
235
|
label_visibility: LabelVisibility = "visible",
|
236
236
|
) -> UploadedFile | list[UploadedFile] | None:
|
237
237
|
r"""Display a file uploader widget.
|
238
|
-
By default, uploaded files are limited to
|
239
|
-
this using the ``server.maxUploadSize`` config option. For
|
240
|
-
on how to set config options, see
|
241
|
-
|
238
|
+
By default, uploaded files are limited to 200 MB each. You can
|
239
|
+
configure this using the ``server.maxUploadSize`` config option. For
|
240
|
+
more information on how to set config options, see |config.toml|_.
|
241
|
+
|
242
|
+
.. |config.toml| replace:: ``config.toml``
|
243
|
+
.. _config.toml: https://docs.streamlit.io/develop/api-reference/configuration/config.toml
|
242
244
|
|
243
245
|
Parameters
|
244
246
|
----------
|
@@ -265,13 +267,21 @@ class FileUploaderMixin:
|
|
265
267
|
.. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown
|
266
268
|
|
267
269
|
type : str or list of str or None
|
268
|
-
|
269
|
-
|
270
|
+
The allowed file extension(s) for uploaded files. This can be one
|
271
|
+
of the following types:
|
272
|
+
|
273
|
+
- ``None`` (default): All file extensions are allowed.
|
274
|
+
- A string: A single file extension is allowed. For example, to
|
275
|
+
only accept CSV files, use ``"csv"``.
|
276
|
+
- A sequence of strings: Multiple file extensions are allowed. For
|
277
|
+
example, to only accept JPG/JPEG and PNG files, use
|
278
|
+
``["jpg", "jpeg", "png"]``.
|
270
279
|
|
271
280
|
accept_multiple_files : bool
|
272
|
-
|
273
|
-
|
274
|
-
|
281
|
+
Whether to accept more than one file in a submission. If this is
|
282
|
+
``False`` (default), the user can only submit one file at a time.
|
283
|
+
If this is ``True``, the user can upload multiple files at the same
|
284
|
+
time, in which case the return value will be a list of files.
|
275
285
|
|
276
286
|
key : str or int
|
277
287
|
An optional string or integer to use as the unique key for the widget.
|
@@ -309,7 +319,7 @@ class FileUploaderMixin:
|
|
309
319
|
|
310
320
|
Returns
|
311
321
|
-------
|
312
|
-
None
|
322
|
+
None, UploadedFile, or list of UploadedFile
|
313
323
|
- If accept_multiple_files is False, returns either None or
|
314
324
|
an UploadedFile object.
|
315
325
|
- If accept_multiple_files is True, returns a list with the
|
@@ -15,7 +15,7 @@ _sym_db = _symbol_database.Default()
|
|
15
15
|
from streamlit.proto import WidgetStates_pb2 as streamlit_dot_proto_dot_WidgetStates__pb2
|
16
16
|
|
17
17
|
|
18
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!streamlit/proto/ClientState.proto\x1a\"streamlit/proto/WidgetStates.proto\"\
|
18
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!streamlit/proto/ClientState.proto\x1a\"streamlit/proto/WidgetStates.proto\"c\n\x0b\x43ontextInfo\x12\x15\n\x08timezone\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x1c\n\x0ftimezone_offset\x18\x02 \x01(\x05H\x01\x88\x01\x01\x42\x0b\n\t_timezoneB\x12\n\x10_timezone_offset\"\xc6\x01\n\x0b\x43lientState\x12\x14\n\x0cquery_string\x18\x01 \x01(\t\x12$\n\rwidget_states\x18\x02 \x01(\x0b\x32\r.WidgetStates\x12\x18\n\x10page_script_hash\x18\x03 \x01(\t\x12\x11\n\tpage_name\x18\x04 \x01(\t\x12\x13\n\x0b\x66ragment_id\x18\x05 \x01(\t\x12\x15\n\ris_auto_rerun\x18\x06 \x01(\x08\x12\"\n\x0c\x63ontext_info\x18\x08 \x01(\x0b\x32\x0c.ContextInfoB0\n\x1c\x63om.snowflake.apps.streamlitB\x10\x43lientStateProtob\x06proto3')
|
19
19
|
|
20
20
|
_globals = globals()
|
21
21
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
@@ -23,6 +23,8 @@ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'streamlit.proto.ClientState
|
|
23
23
|
if not _descriptor._USE_C_DESCRIPTORS:
|
24
24
|
_globals['DESCRIPTOR']._loaded_options = None
|
25
25
|
_globals['DESCRIPTOR']._serialized_options = b'\n\034com.snowflake.apps.streamlitB\020ClientStateProto'
|
26
|
-
_globals['
|
27
|
-
_globals['
|
26
|
+
_globals['_CONTEXTINFO']._serialized_start=73
|
27
|
+
_globals['_CONTEXTINFO']._serialized_end=172
|
28
|
+
_globals['_CLIENTSTATE']._serialized_start=175
|
29
|
+
_globals['_CLIENTSTATE']._serialized_end=373
|
28
30
|
# @@protoc_insertion_point(module_scope)
|
@@ -25,6 +25,29 @@ import typing
|
|
25
25
|
|
26
26
|
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
|
27
27
|
|
28
|
+
@typing.final
|
29
|
+
class ContextInfo(google.protobuf.message.Message):
|
30
|
+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
31
|
+
|
32
|
+
TIMEZONE_FIELD_NUMBER: builtins.int
|
33
|
+
TIMEZONE_OFFSET_FIELD_NUMBER: builtins.int
|
34
|
+
timezone: builtins.str
|
35
|
+
timezone_offset: builtins.int
|
36
|
+
def __init__(
|
37
|
+
self,
|
38
|
+
*,
|
39
|
+
timezone: builtins.str | None = ...,
|
40
|
+
timezone_offset: builtins.int | None = ...,
|
41
|
+
) -> None: ...
|
42
|
+
def HasField(self, field_name: typing.Literal["_timezone", b"_timezone", "_timezone_offset", b"_timezone_offset", "timezone", b"timezone", "timezone_offset", b"timezone_offset"]) -> builtins.bool: ...
|
43
|
+
def ClearField(self, field_name: typing.Literal["_timezone", b"_timezone", "_timezone_offset", b"_timezone_offset", "timezone", b"timezone", "timezone_offset", b"timezone_offset"]) -> None: ...
|
44
|
+
@typing.overload
|
45
|
+
def WhichOneof(self, oneof_group: typing.Literal["_timezone", b"_timezone"]) -> typing.Literal["timezone"] | None: ...
|
46
|
+
@typing.overload
|
47
|
+
def WhichOneof(self, oneof_group: typing.Literal["_timezone_offset", b"_timezone_offset"]) -> typing.Literal["timezone_offset"] | None: ...
|
48
|
+
|
49
|
+
global___ContextInfo = ContextInfo
|
50
|
+
|
28
51
|
@typing.final
|
29
52
|
class ClientState(google.protobuf.message.Message):
|
30
53
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
@@ -35,6 +58,7 @@ class ClientState(google.protobuf.message.Message):
|
|
35
58
|
PAGE_NAME_FIELD_NUMBER: builtins.int
|
36
59
|
FRAGMENT_ID_FIELD_NUMBER: builtins.int
|
37
60
|
IS_AUTO_RERUN_FIELD_NUMBER: builtins.int
|
61
|
+
CONTEXT_INFO_FIELD_NUMBER: builtins.int
|
38
62
|
query_string: builtins.str
|
39
63
|
page_script_hash: builtins.str
|
40
64
|
page_name: builtins.str
|
@@ -42,6 +66,8 @@ class ClientState(google.protobuf.message.Message):
|
|
42
66
|
is_auto_rerun: builtins.bool
|
43
67
|
@property
|
44
68
|
def widget_states(self) -> streamlit.proto.WidgetStates_pb2.WidgetStates: ...
|
69
|
+
@property
|
70
|
+
def context_info(self) -> global___ContextInfo: ...
|
45
71
|
def __init__(
|
46
72
|
self,
|
47
73
|
*,
|
@@ -51,8 +77,9 @@ class ClientState(google.protobuf.message.Message):
|
|
51
77
|
page_name: builtins.str = ...,
|
52
78
|
fragment_id: builtins.str = ...,
|
53
79
|
is_auto_rerun: builtins.bool = ...,
|
80
|
+
context_info: global___ContextInfo | None = ...,
|
54
81
|
) -> None: ...
|
55
|
-
def HasField(self, field_name: typing.Literal["widget_states", b"widget_states"]) -> builtins.bool: ...
|
56
|
-
def ClearField(self, field_name: typing.Literal["fragment_id", b"fragment_id", "is_auto_rerun", b"is_auto_rerun", "page_name", b"page_name", "page_script_hash", b"page_script_hash", "query_string", b"query_string", "widget_states", b"widget_states"]) -> None: ...
|
82
|
+
def HasField(self, field_name: typing.Literal["context_info", b"context_info", "widget_states", b"widget_states"]) -> builtins.bool: ...
|
83
|
+
def ClearField(self, field_name: typing.Literal["context_info", b"context_info", "fragment_id", b"fragment_id", "is_auto_rerun", b"is_auto_rerun", "page_name", b"page_name", "page_script_hash", b"page_script_hash", "query_string", b"query_string", "widget_states", b"widget_states"]) -> None: ...
|
57
84
|
|
58
85
|
global___ClientState = ClientState
|
@@ -16,7 +16,7 @@ from streamlit.proto import AppPage_pb2 as streamlit_dot_proto_dot_AppPage__pb2
|
|
16
16
|
from streamlit.proto import SessionStatus_pb2 as streamlit_dot_proto_dot_SessionStatus__pb2
|
17
17
|
|
18
18
|
|
19
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n streamlit/proto/NewSession.proto\x1a\x1dstreamlit/proto/AppPage.proto\x1a#streamlit/proto/SessionStatus.proto\"\xa5\x02\n\nNewSession\x12\x1f\n\ninitialize\x18\x01 \x01(\x0b\x32\x0b.Initialize\x12\x15\n\rscript_run_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x18\n\x10main_script_path\x18\x04 \x01(\t\x12\x17\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x07.Config\x12(\n\x0c\x63ustom_theme\x18\x07 \x01(\x0b\x32\x12.CustomThemeConfig\x12\x1b\n\tapp_pages\x18\x08 \x03(\x0b\x32\x08.AppPage\x12\x18\n\x10page_script_hash\x18\t \x01(\t\x12\x1d\n\x15\x66ragment_ids_this_run\x18\n \x03(\t\x12\x18\n\x10main_script_hash\x18\x0b \x01(\tJ\x04\x08\x05\x10\x06\"\xba\x01\n\nInitialize\x12\x1c\n\tuser_info\x18\x01 \x01(\x0b\x32\t.UserInfo\x12*\n\x10\x65nvironment_info\x18\x03 \x01(\x0b\x32\x10.EnvironmentInfo\x12&\n\x0esession_status\x18\x04 \x01(\x0b\x32\x0e.SessionStatus\x12\x14\n\x0c\x63ommand_line\x18\x05 \x01(\t\x12\x12\n\nsession_id\x18\x06 \x01(\t\x12\x10\n\x08is_hello\x18\x07 \x01(\x08\"\x97\x02\n\x06\x43onfig\x12\x1a\n\x12gather_usage_stats\x18\x02 \x01(\x08\x12\x1e\n\x16max_cached_message_age\x18\x03 \x01(\x05\x12\x14\n\x0cmapbox_token\x18\x04 \x01(\t\x12\x19\n\x11\x61llow_run_on_save\x18\x05 \x01(\x08\x12\x14\n\x0chide_top_bar\x18\x06 \x01(\x08\x12\x18\n\x10hide_sidebar_nav\x18\x07 \x01(\x08\x12)\n\x0ctoolbar_mode\x18\x08 \x01(\x0e\x32\x13.Config.ToolbarMode\"?\n\x0bToolbarMode\x12\x08\n\x04\x41UTO\x10\x00\x12\r\n\tDEVELOPER\x10\x01\x12\n\n\x06VIEWER\x10\x02\x12\x0b\n\x07MINIMAL\x10\x03J\x04\x08\x01\x10\x02\"\
|
19
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n streamlit/proto/NewSession.proto\x1a\x1dstreamlit/proto/AppPage.proto\x1a#streamlit/proto/SessionStatus.proto\"\xa5\x02\n\nNewSession\x12\x1f\n\ninitialize\x18\x01 \x01(\x0b\x32\x0b.Initialize\x12\x15\n\rscript_run_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x18\n\x10main_script_path\x18\x04 \x01(\t\x12\x17\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x07.Config\x12(\n\x0c\x63ustom_theme\x18\x07 \x01(\x0b\x32\x12.CustomThemeConfig\x12\x1b\n\tapp_pages\x18\x08 \x03(\x0b\x32\x08.AppPage\x12\x18\n\x10page_script_hash\x18\t \x01(\t\x12\x1d\n\x15\x66ragment_ids_this_run\x18\n \x03(\t\x12\x18\n\x10main_script_hash\x18\x0b \x01(\tJ\x04\x08\x05\x10\x06\"\xba\x01\n\nInitialize\x12\x1c\n\tuser_info\x18\x01 \x01(\x0b\x32\t.UserInfo\x12*\n\x10\x65nvironment_info\x18\x03 \x01(\x0b\x32\x10.EnvironmentInfo\x12&\n\x0esession_status\x18\x04 \x01(\x0b\x32\x0e.SessionStatus\x12\x14\n\x0c\x63ommand_line\x18\x05 \x01(\t\x12\x12\n\nsession_id\x18\x06 \x01(\t\x12\x10\n\x08is_hello\x18\x07 \x01(\x08\"\x97\x02\n\x06\x43onfig\x12\x1a\n\x12gather_usage_stats\x18\x02 \x01(\x08\x12\x1e\n\x16max_cached_message_age\x18\x03 \x01(\x05\x12\x14\n\x0cmapbox_token\x18\x04 \x01(\t\x12\x19\n\x11\x61llow_run_on_save\x18\x05 \x01(\x08\x12\x14\n\x0chide_top_bar\x18\x06 \x01(\x08\x12\x18\n\x10hide_sidebar_nav\x18\x07 \x01(\x08\x12)\n\x0ctoolbar_mode\x18\x08 \x01(\x0e\x32\x13.Config.ToolbarMode\"?\n\x0bToolbarMode\x12\x08\n\x04\x41UTO\x10\x00\x12\r\n\tDEVELOPER\x10\x01\x12\n\n\x06VIEWER\x10\x02\x12\x0b\n\x07MINIMAL\x10\x03J\x04\x08\x01\x10\x02\"\x80\x06\n\x11\x43ustomThemeConfig\x12\x15\n\rprimary_color\x18\x01 \x01(\t\x12\"\n\x1asecondary_background_color\x18\x02 \x01(\t\x12\x18\n\x10\x62\x61\x63kground_color\x18\x03 \x01(\t\x12\x12\n\ntext_color\x18\x04 \x01(\t\x12+\n\x04\x66ont\x18\x05 \x01(\x0e\x32\x1d.CustomThemeConfig.FontFamily\x12*\n\x04\x62\x61se\x18\x06 \x01(\x0e\x32\x1c.CustomThemeConfig.BaseTheme\x12\x1f\n\x17widget_background_color\x18\x07 \x01(\t\x12\x1b\n\x13widget_border_color\x18\x08 \x01(\t\x12\x15\n\x05radii\x18\t \x01(\x0b\x32\x06.Radii\x12\x11\n\tbody_font\x18\r \x01(\t\x12\x11\n\tcode_font\x18\x0e \x01(\t\x12\x1d\n\nfont_faces\x18\x0f \x03(\x0b\x32\t.FontFace\x12\x1e\n\nfont_sizes\x18\x10 \x01(\x0b\x32\n.FontSizes\x12!\n\x19skeleton_background_color\x18\x11 \x01(\t\x12\x18\n\x0b\x62\x61se_radius\x18\x12 \x01(\tH\x00\x88\x01\x01\x12\x19\n\x0c\x62order_color\x18\x13 \x01(\tH\x01\x88\x01\x01\x12&\n\x19show_border_around_inputs\x18\x14 \x01(\x08H\x02\x88\x01\x01\x12\x17\n\nlink_color\x18\x15 \x01(\tH\x03\x88\x01\x01\x12\x1b\n\x0e\x62\x61se_font_size\x18\x16 \x01(\x05H\x04\x88\x01\x01\" \n\tBaseTheme\x12\t\n\x05LIGHT\x10\x00\x12\x08\n\x04\x44\x41RK\x10\x01\"6\n\nFontFamily\x12\x0e\n\nSANS_SERIF\x10\x00\x12\t\n\x05SERIF\x10\x01\x12\r\n\tMONOSPACE\x10\x02\x42\x0e\n\x0c_base_radiusB\x0f\n\r_border_colorB\x1c\n\x1a_show_border_around_inputsB\r\n\x0b_link_colorB\x11\n\x0f_base_font_size\"F\n\x08\x46ontFace\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x0e\n\x06\x66\x61mily\x18\x02 \x01(\t\x12\x0e\n\x06weight\x18\x03 \x01(\x05\x12\r\n\x05style\x18\x04 \x01(\t\"<\n\x05Radii\x12\x1a\n\x12\x62\x61se_widget_radius\x18\x01 \x01(\x05\x12\x17\n\x0f\x63heckbox_radius\x18\x02 \x01(\x05\"T\n\tFontSizes\x12\x16\n\x0etiny_font_size\x18\x01 \x01(\x05\x12\x17\n\x0fsmall_font_size\x18\x02 \x01(\x05\x12\x16\n\x0e\x62\x61se_font_size\x18\x03 \x01(\x05\"E\n\x08UserInfo\x12\x17\n\x0finstallation_id\x18\x01 \x01(\t\x12\x1a\n\x12installation_id_v3\x18\x05 \x01(\tJ\x04\x08\x02\x10\x03\"D\n\x0f\x45nvironmentInfo\x12\x19\n\x11streamlit_version\x18\x01 \x01(\t\x12\x16\n\x0epython_version\x18\x02 \x01(\tB/\n\x1c\x63om.snowflake.apps.streamlitB\x0fNewSessionProtob\x06proto3')
|
20
20
|
|
21
21
|
_globals = globals()
|
22
22
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
@@ -33,19 +33,19 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
33
|
_globals['_CONFIG_TOOLBARMODE']._serialized_start=800
|
34
34
|
_globals['_CONFIG_TOOLBARMODE']._serialized_end=863
|
35
35
|
_globals['_CUSTOMTHEMECONFIG']._serialized_start=872
|
36
|
-
_globals['_CUSTOMTHEMECONFIG']._serialized_end=
|
37
|
-
_globals['_CUSTOMTHEMECONFIG_BASETHEME']._serialized_start=
|
38
|
-
_globals['_CUSTOMTHEMECONFIG_BASETHEME']._serialized_end=
|
39
|
-
_globals['_CUSTOMTHEMECONFIG_FONTFAMILY']._serialized_start=
|
40
|
-
_globals['_CUSTOMTHEMECONFIG_FONTFAMILY']._serialized_end=
|
41
|
-
_globals['_FONTFACE']._serialized_start=
|
42
|
-
_globals['_FONTFACE']._serialized_end=
|
43
|
-
_globals['_RADII']._serialized_start=
|
44
|
-
_globals['_RADII']._serialized_end=
|
45
|
-
_globals['_FONTSIZES']._serialized_start=
|
46
|
-
_globals['_FONTSIZES']._serialized_end=
|
47
|
-
_globals['_USERINFO']._serialized_start=
|
48
|
-
_globals['_USERINFO']._serialized_end=
|
49
|
-
_globals['_ENVIRONMENTINFO']._serialized_start=
|
50
|
-
_globals['_ENVIRONMENTINFO']._serialized_end=
|
36
|
+
_globals['_CUSTOMTHEMECONFIG']._serialized_end=1640
|
37
|
+
_globals['_CUSTOMTHEMECONFIG_BASETHEME']._serialized_start=1455
|
38
|
+
_globals['_CUSTOMTHEMECONFIG_BASETHEME']._serialized_end=1487
|
39
|
+
_globals['_CUSTOMTHEMECONFIG_FONTFAMILY']._serialized_start=1489
|
40
|
+
_globals['_CUSTOMTHEMECONFIG_FONTFAMILY']._serialized_end=1543
|
41
|
+
_globals['_FONTFACE']._serialized_start=1642
|
42
|
+
_globals['_FONTFACE']._serialized_end=1712
|
43
|
+
_globals['_RADII']._serialized_start=1714
|
44
|
+
_globals['_RADII']._serialized_end=1774
|
45
|
+
_globals['_FONTSIZES']._serialized_start=1776
|
46
|
+
_globals['_FONTSIZES']._serialized_end=1860
|
47
|
+
_globals['_USERINFO']._serialized_start=1862
|
48
|
+
_globals['_USERINFO']._serialized_end=1931
|
49
|
+
_globals['_ENVIRONMENTINFO']._serialized_start=1933
|
50
|
+
_globals['_ENVIRONMENTINFO']._serialized_end=2001
|
51
51
|
# @@protoc_insertion_point(module_scope)
|
@@ -283,7 +283,7 @@ class CustomThemeConfig(google.protobuf.message.Message):
|
|
283
283
|
FONT_FACES_FIELD_NUMBER: builtins.int
|
284
284
|
FONT_SIZES_FIELD_NUMBER: builtins.int
|
285
285
|
SKELETON_BACKGROUND_COLOR_FIELD_NUMBER: builtins.int
|
286
|
-
|
286
|
+
BASE_RADIUS_FIELD_NUMBER: builtins.int
|
287
287
|
BORDER_COLOR_FIELD_NUMBER: builtins.int
|
288
288
|
SHOW_BORDER_AROUND_INPUTS_FIELD_NUMBER: builtins.int
|
289
289
|
LINK_COLOR_FIELD_NUMBER: builtins.int
|
@@ -303,14 +303,14 @@ class CustomThemeConfig(google.protobuf.message.Message):
|
|
303
303
|
code_font: builtins.str
|
304
304
|
skeleton_background_color: builtins.str
|
305
305
|
"""DEPRECATED: This color is not applied anymore:"""
|
306
|
-
|
306
|
+
base_radius: builtins.str
|
307
307
|
border_color: builtins.str
|
308
308
|
show_border_around_inputs: builtins.bool
|
309
309
|
link_color: builtins.str
|
310
310
|
base_font_size: builtins.int
|
311
311
|
@property
|
312
312
|
def radii(self) -> global___Radii:
|
313
|
-
"""DEPRECATED: Please use the
|
313
|
+
"""DEPRECATED: Please use the base_radius theme config instead:"""
|
314
314
|
|
315
315
|
@property
|
316
316
|
def font_faces(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___FontFace]: ...
|
@@ -335,23 +335,23 @@ class CustomThemeConfig(google.protobuf.message.Message):
|
|
335
335
|
font_faces: collections.abc.Iterable[global___FontFace] | None = ...,
|
336
336
|
font_sizes: global___FontSizes | None = ...,
|
337
337
|
skeleton_background_color: builtins.str = ...,
|
338
|
-
|
338
|
+
base_radius: builtins.str | None = ...,
|
339
339
|
border_color: builtins.str | None = ...,
|
340
340
|
show_border_around_inputs: builtins.bool | None = ...,
|
341
341
|
link_color: builtins.str | None = ...,
|
342
342
|
base_font_size: builtins.int | None = ...,
|
343
343
|
) -> None: ...
|
344
|
-
def HasField(self, field_name: typing.Literal["_base_font_size", b"_base_font_size", "
|
345
|
-
def ClearField(self, field_name: typing.Literal["_base_font_size", b"_base_font_size", "
|
344
|
+
def HasField(self, field_name: typing.Literal["_base_font_size", b"_base_font_size", "_base_radius", b"_base_radius", "_border_color", b"_border_color", "_link_color", b"_link_color", "_show_border_around_inputs", b"_show_border_around_inputs", "base_font_size", b"base_font_size", "base_radius", b"base_radius", "border_color", b"border_color", "font_sizes", b"font_sizes", "link_color", b"link_color", "radii", b"radii", "show_border_around_inputs", b"show_border_around_inputs"]) -> builtins.bool: ...
|
345
|
+
def ClearField(self, field_name: typing.Literal["_base_font_size", b"_base_font_size", "_base_radius", b"_base_radius", "_border_color", b"_border_color", "_link_color", b"_link_color", "_show_border_around_inputs", b"_show_border_around_inputs", "background_color", b"background_color", "base", b"base", "base_font_size", b"base_font_size", "base_radius", b"base_radius", "body_font", b"body_font", "border_color", b"border_color", "code_font", b"code_font", "font", b"font", "font_faces", b"font_faces", "font_sizes", b"font_sizes", "link_color", b"link_color", "primary_color", b"primary_color", "radii", b"radii", "secondary_background_color", b"secondary_background_color", "show_border_around_inputs", b"show_border_around_inputs", "skeleton_background_color", b"skeleton_background_color", "text_color", b"text_color", "widget_background_color", b"widget_background_color", "widget_border_color", b"widget_border_color"]) -> None: ...
|
346
346
|
@typing.overload
|
347
347
|
def WhichOneof(self, oneof_group: typing.Literal["_base_font_size", b"_base_font_size"]) -> typing.Literal["base_font_size"] | None: ...
|
348
348
|
@typing.overload
|
349
|
+
def WhichOneof(self, oneof_group: typing.Literal["_base_radius", b"_base_radius"]) -> typing.Literal["base_radius"] | None: ...
|
350
|
+
@typing.overload
|
349
351
|
def WhichOneof(self, oneof_group: typing.Literal["_border_color", b"_border_color"]) -> typing.Literal["border_color"] | None: ...
|
350
352
|
@typing.overload
|
351
353
|
def WhichOneof(self, oneof_group: typing.Literal["_link_color", b"_link_color"]) -> typing.Literal["link_color"] | None: ...
|
352
354
|
@typing.overload
|
353
|
-
def WhichOneof(self, oneof_group: typing.Literal["_roundness", b"_roundness"]) -> typing.Literal["roundness"] | None: ...
|
354
|
-
@typing.overload
|
355
355
|
def WhichOneof(self, oneof_group: typing.Literal["_show_border_around_inputs", b"_show_border_around_inputs"]) -> typing.Literal["show_border_around_inputs"] | None: ...
|
356
356
|
|
357
357
|
global___CustomThemeConfig = CustomThemeConfig
|
@@ -382,7 +382,7 @@ global___FontFace = FontFace
|
|
382
382
|
|
383
383
|
@typing.final
|
384
384
|
class Radii(google.protobuf.message.Message):
|
385
|
-
"""DEPRECATED: Please use the
|
385
|
+
"""DEPRECATED: Please use the base_radius theme config instead."""
|
386
386
|
|
387
387
|
DESCRIPTOR: google.protobuf.descriptor.Descriptor
|
388
388
|
|
streamlit/runtime/app_session.py
CHANGED
@@ -353,6 +353,7 @@ class AppSession:
|
|
353
353
|
to use previous client state.
|
354
354
|
|
355
355
|
"""
|
356
|
+
|
356
357
|
if self._state == AppSessionState.SHUTDOWN_REQUESTED:
|
357
358
|
_LOGGER.warning("Discarding rerun request after shutdown")
|
358
359
|
return
|
@@ -382,6 +383,9 @@ class AppSession:
|
|
382
383
|
)
|
383
384
|
return
|
384
385
|
|
386
|
+
if client_state.HasField("context_info"):
|
387
|
+
self._client_state.context_info.CopyFrom(client_state.context_info)
|
388
|
+
|
385
389
|
rerun_data = RerunData(
|
386
390
|
client_state.query_string,
|
387
391
|
client_state.widget_states,
|
@@ -389,6 +393,7 @@ class AppSession:
|
|
389
393
|
client_state.page_name,
|
390
394
|
fragment_id=fragment_id if fragment_id else None,
|
391
395
|
is_auto_rerun=client_state.is_auto_rerun,
|
396
|
+
context_info=client_state.context_info,
|
392
397
|
)
|
393
398
|
else:
|
394
399
|
rerun_data = RerunData()
|
streamlit/runtime/context.py
CHANGED
@@ -205,3 +205,22 @@ class ContextProxy:
|
|
205
205
|
|
206
206
|
cookies = session_client_request.cookies
|
207
207
|
return StreamlitCookies.from_tornado_cookies(cookies)
|
208
|
+
|
209
|
+
@property
|
210
|
+
@gather_metrics("context.timezone")
|
211
|
+
def timezone(self) -> str | None:
|
212
|
+
"""The timezone of the user's browser, read-only."""
|
213
|
+
ctx = get_script_run_ctx()
|
214
|
+
|
215
|
+
if ctx is None or ctx.context_info is None:
|
216
|
+
return None
|
217
|
+
return ctx.context_info.timezone
|
218
|
+
|
219
|
+
@property
|
220
|
+
@gather_metrics("context.timezone_offset")
|
221
|
+
def timezone_offset(self) -> int | None:
|
222
|
+
"""The timezone offset of the user's browser, read-only."""
|
223
|
+
ctx = get_script_run_ctx()
|
224
|
+
if ctx is None or ctx.context_info is None:
|
225
|
+
return None
|
226
|
+
return ctx.context_info.timezone_offset
|
@@ -310,6 +310,7 @@ class ScriptRunner:
|
|
310
310
|
gather_usage_stats=bool(config.get_option("browser.gatherUsageStats")),
|
311
311
|
fragment_storage=self._fragment_storage,
|
312
312
|
pages_manager=self._pages_manager,
|
313
|
+
context_info=None,
|
313
314
|
)
|
314
315
|
add_script_run_ctx(threading.current_thread(), ctx)
|
315
316
|
|
@@ -468,6 +469,7 @@ class ScriptRunner:
|
|
468
469
|
query_string=rerun_data.query_string,
|
469
470
|
page_script_hash=page_script_hash,
|
470
471
|
fragment_ids_this_run=fragment_ids_this_run,
|
472
|
+
context_info=rerun_data.context_info,
|
471
473
|
)
|
472
474
|
|
473
475
|
self.on_event.send(
|
@@ -17,13 +17,16 @@ from __future__ import annotations
|
|
17
17
|
import threading
|
18
18
|
from dataclasses import dataclass, field, replace
|
19
19
|
from enum import Enum
|
20
|
-
from typing import cast
|
20
|
+
from typing import TYPE_CHECKING, cast
|
21
21
|
|
22
22
|
from streamlit import util
|
23
23
|
from streamlit.proto.Common_pb2 import ChatInputValue as ChatInputValueProto
|
24
24
|
from streamlit.proto.Common_pb2 import StringTriggerValue as StringTriggerValueProto
|
25
25
|
from streamlit.proto.WidgetStates_pb2 import WidgetState, WidgetStates
|
26
26
|
|
27
|
+
if TYPE_CHECKING:
|
28
|
+
from streamlit.proto.ClientState_pb2 import ContextInfo
|
29
|
+
|
27
30
|
|
28
31
|
class ScriptRequestType(Enum):
|
29
32
|
# The ScriptRunner should continue running its script.
|
@@ -55,6 +58,8 @@ class RerunData:
|
|
55
58
|
is_fragment_scoped_rerun: bool = False
|
56
59
|
# set to true when a script is rerun by the fragment auto-rerun mechanism
|
57
60
|
is_auto_rerun: bool = False
|
61
|
+
# context_info is used to store information from the user browser (e.g. timezone)
|
62
|
+
context_info: ContextInfo | None = None
|
58
63
|
|
59
64
|
def __repr__(self) -> str:
|
60
65
|
return util.repr_(self)
|
@@ -233,6 +238,7 @@ class ScriptRequests:
|
|
233
238
|
fragment_id_queue=fragment_id_queue,
|
234
239
|
is_fragment_scoped_rerun=new_data.is_fragment_scoped_rerun,
|
235
240
|
is_auto_rerun=new_data.is_auto_rerun,
|
241
|
+
context_info=new_data.context_info,
|
236
242
|
)
|
237
243
|
|
238
244
|
return True
|
@@ -41,6 +41,7 @@ if TYPE_CHECKING:
|
|
41
41
|
from pathlib import Path
|
42
42
|
|
43
43
|
from streamlit.cursor import RunningCursor
|
44
|
+
from streamlit.proto.ClientState_pb2 import ContextInfo
|
44
45
|
from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
|
45
46
|
from streamlit.proto.PageProfile_pb2 import Command
|
46
47
|
from streamlit.runtime.fragment import FragmentStorage
|
@@ -85,6 +86,7 @@ class ScriptRunContext:
|
|
85
86
|
fragment_storage: FragmentStorage
|
86
87
|
pages_manager: PagesManager
|
87
88
|
|
89
|
+
context_info: ContextInfo | None = None
|
88
90
|
gather_usage_stats: bool = False
|
89
91
|
command_tracking_deactivated: bool = False
|
90
92
|
tracked_commands: list[Command] = field(default_factory=list)
|
@@ -138,12 +140,14 @@ class ScriptRunContext:
|
|
138
140
|
query_string: str = "",
|
139
141
|
page_script_hash: str = "",
|
140
142
|
fragment_ids_this_run: list[str] | None = None,
|
143
|
+
context_info: ContextInfo | None = None,
|
141
144
|
) -> None:
|
142
145
|
self.cursors = {}
|
143
146
|
self.widget_ids_this_run = set()
|
144
147
|
self.widget_user_keys_this_run = set()
|
145
148
|
self.form_ids_this_run = set()
|
146
149
|
self.query_string = query_string
|
150
|
+
self.context_info = context_info
|
147
151
|
self.pages_manager.set_current_page_script_hash(page_script_hash)
|
148
152
|
self._active_script_hash = self.pages_manager.initial_active_script_hash
|
149
153
|
# Permit set_page_config when the ScriptRunContext is reused on a rerun
|
streamlit/static/index.html
CHANGED
@@ -51,7 +51,7 @@
|
|
51
51
|
<script>
|
52
52
|
window.prerenderReady = false
|
53
53
|
</script>
|
54
|
-
<script type="module" crossorigin src="./static/js/index.
|
54
|
+
<script type="module" crossorigin src="./static/js/index.KPwXWqBk.js"></script>
|
55
55
|
<link rel="stylesheet" crossorigin href="./static/css/index.DpJG_94W.css">
|
56
56
|
</head>
|
57
57
|
<body>
|
@@ -1 +1 @@
|
|
1
|
-
import{r as e,E as n,_ as a}from"./index.
|
1
|
+
import{r as e,E as n,_ as a}from"./index.KPwXWqBk.js";var o=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),e.createElement("path",{d:"M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"}))});o.displayName="Delete";var i=e.forwardRef(function(t,r){var l={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return e.createElement(n,a({iconAttrs:l,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},t,{ref:r}),e.createElement("rect",{width:24,height:24,fill:"none"}),e.createElement("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4l-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z"}))});i.displayName="FileDownload";export{o as D,i as F};
|