streamlit-nightly 1.38.1.dev20240914__py2.py3-none-any.whl → 1.38.1.dev20240916__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/commands/navigation.py +1 -1
- streamlit/config.py +87 -61
- streamlit/elements/arrow.py +1 -1
- streamlit/elements/vega_charts.py +1 -1
- streamlit/navigation/page.py +1 -1
- streamlit/runtime/fragment.py +1 -3
- streamlit/runtime/pages_manager.py +19 -50
- streamlit/runtime/scriptrunner/script_runner.py +0 -1
- streamlit/runtime/scriptrunner_utils/script_run_context.py +27 -3
- streamlit/static/asset-manifest.json +3 -3
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/7591.b3928443.chunk.js +2 -0
- streamlit/static/static/js/7591.b3928443.chunk.js.LICENSE.txt +1 -0
- streamlit/static/static/js/{main.8721af5a.js → main.50e02474.js} +2 -2
- {streamlit_nightly-1.38.1.dev20240914.dist-info → streamlit_nightly-1.38.1.dev20240916.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.38.1.dev20240914.dist-info → streamlit_nightly-1.38.1.dev20240916.dist-info}/RECORD +21 -21
- {streamlit_nightly-1.38.1.dev20240914.dist-info → streamlit_nightly-1.38.1.dev20240916.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/7591.116b650a.chunk.js +0 -2
- streamlit/static/static/js/7591.116b650a.chunk.js.LICENSE.txt +0 -1
- /streamlit/static/static/js/{main.8721af5a.js.LICENSE.txt → main.50e02474.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.38.1.dev20240914.data → streamlit_nightly-1.38.1.dev20240916.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.38.1.dev20240914.dist-info → streamlit_nightly-1.38.1.dev20240916.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.38.1.dev20240914.dist-info → streamlit_nightly-1.38.1.dev20240916.dist-info}/top_level.txt +0 -0
streamlit/commands/navigation.py
CHANGED
@@ -256,7 +256,7 @@ def navigation(
|
|
256
256
|
page_to_return._can_be_called = True
|
257
257
|
msg.navigation.page_script_hash = page_to_return._script_hash
|
258
258
|
# Set the current page script hash to the page that is going to be executed
|
259
|
-
ctx.
|
259
|
+
ctx.set_mpa_v2_page(page_to_return._script_hash)
|
260
260
|
|
261
261
|
# This will either navigation or yield if the page is not found
|
262
262
|
ctx.enqueue(msg)
|
streamlit/config.py
CHANGED
@@ -277,7 +277,7 @@ _create_option(
|
|
277
277
|
the widget's key in `st.session_state`.
|
278
278
|
|
279
279
|
If you'd like to turn off this warning, set this to True.
|
280
|
-
|
280
|
+
""",
|
281
281
|
default_val=False,
|
282
282
|
type_=bool,
|
283
283
|
)
|
@@ -288,7 +288,7 @@ _create_option(
|
|
288
288
|
description="""
|
289
289
|
If True, will show a warning when you run a Streamlit-enabled script
|
290
290
|
via "python my_script.py".
|
291
|
-
|
291
|
+
""",
|
292
292
|
default_val=True,
|
293
293
|
type_=bool,
|
294
294
|
)
|
@@ -343,8 +343,9 @@ _create_option(
|
|
343
343
|
|
344
344
|
_create_option(
|
345
345
|
"global.minCachedMessageSize",
|
346
|
-
description="""
|
347
|
-
this minimum.
|
346
|
+
description="""
|
347
|
+
Only cache ForwardMsgs that are greater than or equal to this minimum.
|
348
|
+
""",
|
348
349
|
visibility="hidden",
|
349
350
|
default_val=10 * 1e3,
|
350
351
|
type_=float,
|
@@ -352,9 +353,11 @@ _create_option(
|
|
352
353
|
|
353
354
|
_create_option(
|
354
355
|
"global.maxCachedMessageAge",
|
355
|
-
description="""
|
356
|
+
description="""
|
357
|
+
Expire cached ForwardMsgs whose age is greater than this
|
356
358
|
value. A message's age is defined by how many times its script has
|
357
|
-
finished running since the message has been accessed.
|
359
|
+
finished running since the message has been accessed.
|
360
|
+
""",
|
358
361
|
visibility="hidden",
|
359
362
|
default_val=2,
|
360
363
|
type_=int,
|
@@ -362,9 +365,11 @@ _create_option(
|
|
362
365
|
|
363
366
|
_create_option(
|
364
367
|
"global.storeCachedForwardMessagesInMemory",
|
365
|
-
description="""
|
366
|
-
|
367
|
-
|
368
|
+
description="""
|
369
|
+
If True, store cached ForwardMsgs in backend memory. This is an
|
370
|
+
internal flag to validate a potential removal of the in-memory
|
371
|
+
forward message cache.
|
372
|
+
""",
|
368
373
|
visibility="hidden",
|
369
374
|
default_val=True,
|
370
375
|
type_=bool,
|
@@ -377,9 +382,10 @@ _create_section("logger", "Settings to customize Streamlit log messages.")
|
|
377
382
|
|
378
383
|
@_create_option("logger.level", type_=str)
|
379
384
|
def _logger_log_level() -> str:
|
380
|
-
"""Level of logging:
|
385
|
+
"""Level of logging for Streamlit's internal logger: "error", "warning",
|
386
|
+
"info", or "debug".
|
381
387
|
|
382
|
-
Default:
|
388
|
+
Default: "info"
|
383
389
|
"""
|
384
390
|
if get_option("global.developmentMode"):
|
385
391
|
return "debug"
|
@@ -391,8 +397,8 @@ def _logger_log_level() -> str:
|
|
391
397
|
def _logger_message_format() -> str:
|
392
398
|
"""String format for logging messages. If logger.datetimeFormat is set,
|
393
399
|
logger messages will default to `%(asctime)s.%(msecs)03d %(message)s`. See
|
394
|
-
|
395
|
-
|
400
|
+
Python's documentation for available attributes:
|
401
|
+
https://docs.python.org/3/library/logging.html#formatter-objects
|
396
402
|
|
397
403
|
Default: "%(asctime)s %(message)s"
|
398
404
|
"""
|
@@ -412,7 +418,8 @@ _create_option(
|
|
412
418
|
If True and if rich is installed, exception tracebacks will be logged with syntax highlighting and formatting.
|
413
419
|
Rich tracebacks are easier to read and show more code than standard Python tracebacks.
|
414
420
|
|
415
|
-
If set to False, the default Python traceback formatting will be used.
|
421
|
+
If set to False, the default Python traceback formatting will be used.
|
422
|
+
""",
|
416
423
|
default_val=False,
|
417
424
|
visibility="hidden",
|
418
425
|
type_=bool,
|
@@ -436,7 +443,8 @@ _create_option(
|
|
436
443
|
will print to the console only. Exceptions will still display in the
|
437
444
|
browser with a generic error message. For now, the exception type and
|
438
445
|
traceback show in the browser also, but they will be removed in the
|
439
|
-
future.
|
446
|
+
future.
|
447
|
+
""",
|
440
448
|
default_val=True,
|
441
449
|
type_=bool,
|
442
450
|
scriptable=True,
|
@@ -531,8 +539,9 @@ _create_option(
|
|
531
539
|
"runner.enumCoercion",
|
532
540
|
description="""
|
533
541
|
Adjust how certain 'options' widgets like radio, selectbox, and
|
534
|
-
multiselect coerce Enum members when the Enum class gets
|
535
|
-
|
542
|
+
multiselect coerce Enum members when the Enum class gets re-defined
|
543
|
+
during a script re-run. For more information, check out the docs:
|
544
|
+
https://docs.streamlit.io/develop/concepts/design/custom-classes#enums
|
536
545
|
|
537
546
|
Allowed values:
|
538
547
|
* "off": Disables Enum coercion.
|
@@ -550,11 +559,12 @@ _create_section("server", "Settings for the Streamlit server")
|
|
550
559
|
|
551
560
|
_create_option(
|
552
561
|
"server.folderWatchBlacklist",
|
553
|
-
description="""
|
562
|
+
description="""
|
563
|
+
List of folders that should not be watched for changes.
|
554
564
|
|
555
|
-
|
565
|
+
Relative paths will be taken as relative to the current working directory.
|
556
566
|
|
557
|
-
|
567
|
+
Example: ['/home/user1/env', 'relative/path/to/folder']
|
558
568
|
""",
|
559
569
|
default_val=[],
|
560
570
|
)
|
@@ -580,8 +590,9 @@ _create_option(
|
|
580
590
|
@_create_option("server.cookieSecret", type_=str, sensitive=True)
|
581
591
|
@util.memoize
|
582
592
|
def _server_cookie_secret() -> str:
|
583
|
-
"""Symmetric key used to produce signed cookies. If deploying on multiple
|
584
|
-
be set to the same value across all replicas to ensure
|
593
|
+
"""Symmetric key used to produce signed cookies. If deploying on multiple
|
594
|
+
replicas, this should be set to the same value across all replicas to ensure
|
595
|
+
they all share the same secret.
|
585
596
|
|
586
597
|
Default: randomly generated secret key.
|
587
598
|
"""
|
@@ -610,7 +621,7 @@ _create_option(
|
|
610
621
|
"server.runOnSave",
|
611
622
|
description="""
|
612
623
|
Automatically rerun script when the file is modified on disk.
|
613
|
-
|
624
|
+
""",
|
614
625
|
default_val=False,
|
615
626
|
type_=bool,
|
616
627
|
)
|
@@ -619,7 +630,7 @@ _create_option(
|
|
619
630
|
"server.allowRunOnSave",
|
620
631
|
description="""
|
621
632
|
Allows users to automatically rerun when app is updated.
|
622
|
-
|
633
|
+
""",
|
623
634
|
visibility="hidden",
|
624
635
|
default_val=True,
|
625
636
|
type_=bool,
|
@@ -644,7 +655,7 @@ _create_option(
|
|
644
655
|
The port where the server will listen for browser connections.
|
645
656
|
|
646
657
|
Don't use port 3000 which is reserved for internal development.
|
647
|
-
|
658
|
+
""",
|
648
659
|
default_val=8501,
|
649
660
|
type_=int,
|
650
661
|
)
|
@@ -653,12 +664,12 @@ _create_option(
|
|
653
664
|
"server.scriptHealthCheckEnabled",
|
654
665
|
visibility="hidden",
|
655
666
|
description="""
|
656
|
-
|
657
|
-
|
658
|
-
|
667
|
+
Flag for enabling the script health check endpoint. It's used for checking if
|
668
|
+
a script loads successfully. On success, the endpoint will return a 200
|
669
|
+
HTTP status code. On failure, the endpoint will return a 503 HTTP status code.
|
659
670
|
|
660
|
-
|
661
|
-
|
671
|
+
Note: This is an experimental Streamlit internal API. The API is subject
|
672
|
+
to change anytime so this should be used at your own risk
|
662
673
|
""",
|
663
674
|
default_val=False,
|
664
675
|
type_=bool,
|
@@ -668,7 +679,7 @@ _create_option(
|
|
668
679
|
"server.baseUrlPath",
|
669
680
|
description="""
|
670
681
|
The base path for the URL where Streamlit should be served from.
|
671
|
-
|
682
|
+
""",
|
672
683
|
default_val="",
|
673
684
|
type_=str,
|
674
685
|
)
|
@@ -677,10 +688,12 @@ _create_option(
|
|
677
688
|
_create_option(
|
678
689
|
"server.enableCORS",
|
679
690
|
description="""
|
680
|
-
|
691
|
+
Enables support for Cross-Origin Resource Sharing (CORS) protection, for
|
692
|
+
added security.
|
681
693
|
|
682
|
-
|
683
|
-
|
694
|
+
Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is
|
695
|
+
on and `server.enableCORS` is off at the same time, we will prioritize
|
696
|
+
`server.enableXsrfProtection`.
|
684
697
|
""",
|
685
698
|
default_val=True,
|
686
699
|
type_=bool,
|
@@ -690,11 +703,13 @@ _create_option(
|
|
690
703
|
_create_option(
|
691
704
|
"server.enableXsrfProtection",
|
692
705
|
description="""
|
693
|
-
Enables support for Cross-Site Request Forgery (XSRF) protection, for
|
706
|
+
Enables support for Cross-Site Request Forgery (XSRF) protection, for
|
707
|
+
added security.
|
694
708
|
|
695
|
-
Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is
|
696
|
-
`server.enableCORS` is off at the same time, we will prioritize
|
697
|
-
|
709
|
+
Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is
|
710
|
+
on and `server.enableCORS` is off at the same time, we will prioritize
|
711
|
+
`server.enableXsrfProtection`.
|
712
|
+
""",
|
698
713
|
default_val=True,
|
699
714
|
type_=bool,
|
700
715
|
)
|
@@ -703,7 +718,7 @@ _create_option(
|
|
703
718
|
"server.maxUploadSize",
|
704
719
|
description="""
|
705
720
|
Max size, in megabytes, for files uploaded with the file_uploader.
|
706
|
-
|
721
|
+
""",
|
707
722
|
default_val=200, # If this default is changed, please also update the docstring for `DeltaGenerator.file_uploader`.
|
708
723
|
type_=int,
|
709
724
|
)
|
@@ -711,8 +726,9 @@ _create_option(
|
|
711
726
|
_create_option(
|
712
727
|
"server.maxMessageSize",
|
713
728
|
description="""
|
714
|
-
Max size, in megabytes, of messages that can be sent via the WebSocket
|
715
|
-
|
729
|
+
Max size, in megabytes, of messages that can be sent via the WebSocket
|
730
|
+
connection.
|
731
|
+
""",
|
716
732
|
default_val=200,
|
717
733
|
type_=int,
|
718
734
|
)
|
@@ -722,7 +738,7 @@ _create_option(
|
|
722
738
|
description="""
|
723
739
|
Enable automatically truncating all data structures that get serialized into Arrow (e.g. DataFrames)
|
724
740
|
to ensure that the size is under `server.maxMessageSize`.
|
725
|
-
|
741
|
+
""",
|
726
742
|
visibility="hidden",
|
727
743
|
default_val=False,
|
728
744
|
scriptable=True,
|
@@ -733,7 +749,7 @@ _create_option(
|
|
733
749
|
"server.enableWebsocketCompression",
|
734
750
|
description="""
|
735
751
|
Enables support for websocket compression.
|
736
|
-
|
752
|
+
""",
|
737
753
|
default_val=False,
|
738
754
|
type_=bool,
|
739
755
|
)
|
@@ -741,8 +757,9 @@ _create_option(
|
|
741
757
|
_create_option(
|
742
758
|
"server.enableStaticServing",
|
743
759
|
description="""
|
744
|
-
Enable serving files from a `static` directory in the running app's
|
745
|
-
|
760
|
+
Enable serving files from a `static` directory in the running app's
|
761
|
+
directory.
|
762
|
+
""",
|
746
763
|
default_val=False,
|
747
764
|
type_=bool,
|
748
765
|
)
|
@@ -753,7 +770,7 @@ _create_option(
|
|
753
770
|
TTL in seconds for sessions whose websockets have been disconnected. The server
|
754
771
|
may choose to clean up session state, uploaded files, etc for a given session
|
755
772
|
with no active websocket connection at any point after this time has passed.
|
756
|
-
|
773
|
+
""",
|
757
774
|
default_val=120,
|
758
775
|
type_=int,
|
759
776
|
)
|
@@ -773,7 +790,7 @@ _create_option(
|
|
773
790
|
- Set the correct URL for CORS and XSRF protection purposes.
|
774
791
|
- Show the URL on the terminal
|
775
792
|
- Open the browser
|
776
|
-
|
793
|
+
""",
|
777
794
|
default_val="localhost",
|
778
795
|
type_=str,
|
779
796
|
)
|
@@ -783,7 +800,7 @@ _create_option(
|
|
783
800
|
"browser.gatherUsageStats",
|
784
801
|
description="""
|
785
802
|
Whether to send usage statistics to Streamlit.
|
786
|
-
|
803
|
+
""",
|
787
804
|
default_val=True,
|
788
805
|
type_=bool,
|
789
806
|
)
|
@@ -845,9 +862,9 @@ _create_section("ui", "Configuration of UI elements displayed in the browser.")
|
|
845
862
|
_create_option(
|
846
863
|
"ui.hideTopBar",
|
847
864
|
description="""
|
848
|
-
|
865
|
+
Flag to hide most of the UI elements found at the top of a Streamlit app.
|
849
866
|
|
850
|
-
|
867
|
+
NOTE: This does *not* hide the main menu in the top-right of an app.
|
851
868
|
""",
|
852
869
|
default_val=False,
|
853
870
|
type_=bool,
|
@@ -861,10 +878,12 @@ _create_section("mapbox", "Mapbox configuration that is being used by DeckGL.")
|
|
861
878
|
|
862
879
|
_create_option(
|
863
880
|
"mapbox.token",
|
864
|
-
description="""
|
865
|
-
|
866
|
-
|
867
|
-
|
881
|
+
description="""
|
882
|
+
Configure Streamlit to use a custom Mapbox
|
883
|
+
token for elements like st.pydeck_chart and st.map.
|
884
|
+
To get a token for yourself, create an account at
|
885
|
+
https://mapbox.com. It's free (for moderate usage levels)!
|
886
|
+
""",
|
868
887
|
default_val="",
|
869
888
|
sensitive=True,
|
870
889
|
)
|
@@ -881,7 +900,7 @@ _create_option(
|
|
881
900
|
docstrings. When this flag is set to True, Streamlit will instead display
|
882
901
|
the root-level docstring in the app, just like any other magic string.
|
883
902
|
This is useful for things like notebooks.
|
884
|
-
|
903
|
+
""",
|
885
904
|
visibility="hidden",
|
886
905
|
default_val=False,
|
887
906
|
type_=bool,
|
@@ -893,7 +912,7 @@ _create_option(
|
|
893
912
|
Make Streamlit's "magic" parser always display the last expression in the
|
894
913
|
root file if it has no semicolon at the end. This matches the behavior of
|
895
914
|
Jupyter notebooks, for example.
|
896
|
-
|
915
|
+
""",
|
897
916
|
visibility="hidden",
|
898
917
|
default_val=False,
|
899
918
|
type_=bool,
|
@@ -906,8 +925,10 @@ _create_section("theme", "Settings to define a custom theme for your Streamlit a
|
|
906
925
|
|
907
926
|
_create_option(
|
908
927
|
"theme.base",
|
909
|
-
description="""
|
910
|
-
|
928
|
+
description="""
|
929
|
+
The preset Streamlit theme that your custom theme inherits from.
|
930
|
+
One of "light" or "dark".
|
931
|
+
""",
|
911
932
|
)
|
912
933
|
|
913
934
|
_create_option(
|
@@ -933,8 +954,8 @@ _create_option(
|
|
933
954
|
_create_option(
|
934
955
|
"theme.font",
|
935
956
|
description="""
|
936
|
-
|
937
|
-
|
957
|
+
Font family for all text in the app, except code blocks. One of "sans serif",
|
958
|
+
"serif", or "monospace".
|
938
959
|
""",
|
939
960
|
)
|
940
961
|
|
@@ -944,7 +965,12 @@ _create_section("secrets", "Secrets configuration.")
|
|
944
965
|
|
945
966
|
_create_option(
|
946
967
|
"secrets.files",
|
947
|
-
description="""
|
968
|
+
description="""
|
969
|
+
List of locations where secrets are searched. An entry can be a path to a
|
970
|
+
TOML file or directory path where Kubernetes style secrets are saved.
|
971
|
+
Order is important, import is first to last, so secrets in later files
|
972
|
+
will take precedence over earlier ones.
|
973
|
+
""",
|
948
974
|
default_val=[
|
949
975
|
# NOTE: The order here is important! Project-level secrets should overwrite global
|
950
976
|
# secrets.
|
streamlit/elements/arrow.py
CHANGED
@@ -578,7 +578,7 @@ class ArrowMixin:
|
|
578
578
|
selection_mode=selection_mode,
|
579
579
|
is_selection_activated=is_selection_activated,
|
580
580
|
form_id=proto.form_id,
|
581
|
-
page=ctx.
|
581
|
+
page=ctx.active_script_hash if ctx else None,
|
582
582
|
)
|
583
583
|
|
584
584
|
serde = DataframeSelectionSerde()
|
@@ -1906,7 +1906,7 @@ class VegaChartsMixin:
|
|
1906
1906
|
use_container_width=use_container_width,
|
1907
1907
|
selection_mode=parsed_selection_modes,
|
1908
1908
|
form_id=vega_lite_proto.form_id,
|
1909
|
-
page=ctx.
|
1909
|
+
page=ctx.active_script_hash if ctx else None,
|
1910
1910
|
)
|
1911
1911
|
|
1912
1912
|
serde = VegaLiteStateSerde(parsed_selection_modes)
|
streamlit/navigation/page.py
CHANGED
streamlit/runtime/fragment.py
CHANGED
@@ -222,9 +222,7 @@ def _fragment(
|
|
222
222
|
# This ensures that elements (especially widgets) are tied
|
223
223
|
# to a consistent active script hash
|
224
224
|
active_hash_context = (
|
225
|
-
ctx.
|
226
|
-
initialized_active_script_hash
|
227
|
-
)
|
225
|
+
ctx.run_with_active_hash(initialized_active_script_hash)
|
228
226
|
if initialized_active_script_hash != ctx.active_script_hash
|
229
227
|
else contextlib.nullcontext()
|
230
228
|
)
|
@@ -14,7 +14,6 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
import contextlib
|
18
17
|
import os
|
19
18
|
import threading
|
20
19
|
from pathlib import Path
|
@@ -74,15 +73,9 @@ class PagesStrategyV1:
|
|
74
73
|
if setup_watcher:
|
75
74
|
PagesStrategyV1.watch_pages_dir(pages_manager)
|
76
75
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
return self.pages_manager.current_page_hash
|
81
|
-
|
82
|
-
def set_active_script_hash(self, _page_hash: PageHash):
|
83
|
-
# Intentionally do nothing as MPA v1 active_script_hash does not
|
84
|
-
# differentiate the active_script_hash and the page_script_hash
|
85
|
-
pass
|
76
|
+
@property
|
77
|
+
def initial_active_script_hash(self) -> PageHash:
|
78
|
+
return self.pages_manager.current_page_script_hash
|
86
79
|
|
87
80
|
def get_initial_active_script(
|
88
81
|
self, page_script_hash: PageHash, page_name: PageName
|
@@ -147,15 +140,8 @@ class PagesStrategyV2:
|
|
147
140
|
|
148
141
|
def __init__(self, pages_manager: PagesManager, **kwargs):
|
149
142
|
self.pages_manager = pages_manager
|
150
|
-
self._active_script_hash: PageHash = self.pages_manager.main_script_hash
|
151
143
|
self._pages: dict[PageHash, PageInfo] | None = None
|
152
144
|
|
153
|
-
def get_active_script_hash(self) -> PageHash:
|
154
|
-
return self._active_script_hash
|
155
|
-
|
156
|
-
def set_active_script_hash(self, page_hash: PageHash):
|
157
|
-
self._active_script_hash = page_hash
|
158
|
-
|
159
145
|
def get_initial_active_script(
|
160
146
|
self, page_script_hash: PageHash, page_name: PageName
|
161
147
|
) -> PageInfo:
|
@@ -166,6 +152,10 @@ class PagesStrategyV2:
|
|
166
152
|
or self.pages_manager.main_script_hash, # Default Hash
|
167
153
|
}
|
168
154
|
|
155
|
+
@property
|
156
|
+
def initial_active_script_hash(self) -> PageHash:
|
157
|
+
return self.pages_manager.main_script_hash
|
158
|
+
|
169
159
|
def get_page_script(self, fallback_page_hash: PageHash) -> PageInfo | None:
|
170
160
|
if self._pages is None:
|
171
161
|
return None
|
@@ -243,15 +233,11 @@ class PagesManager:
|
|
243
233
|
):
|
244
234
|
self._main_script_path = main_script_path
|
245
235
|
self._main_script_hash: PageHash = calc_md5(main_script_path)
|
246
|
-
self._current_page_hash: PageHash = self._main_script_hash
|
247
236
|
self.pages_strategy = PagesManager.DefaultStrategy(self, **kwargs)
|
248
237
|
self._script_cache = script_cache
|
249
238
|
self._intended_page_script_hash: PageHash | None = None
|
250
239
|
self._intended_page_name: PageName | None = None
|
251
|
-
|
252
|
-
@property
|
253
|
-
def current_page_hash(self) -> PageHash:
|
254
|
-
return self._current_page_hash
|
240
|
+
self._current_page_script_hash: PageHash = ""
|
255
241
|
|
256
242
|
@property
|
257
243
|
def main_script_path(self) -> ScriptPath:
|
@@ -261,6 +247,10 @@ class PagesManager:
|
|
261
247
|
def main_script_hash(self) -> PageHash:
|
262
248
|
return self._main_script_hash
|
263
249
|
|
250
|
+
@property
|
251
|
+
def current_page_script_hash(self) -> PageHash:
|
252
|
+
return self._current_page_script_hash
|
253
|
+
|
264
254
|
@property
|
265
255
|
def intended_page_name(self) -> PageName | None:
|
266
256
|
return self._intended_page_name
|
@@ -269,34 +259,23 @@ class PagesManager:
|
|
269
259
|
def intended_page_script_hash(self) -> PageHash | None:
|
270
260
|
return self._intended_page_script_hash
|
271
261
|
|
262
|
+
@property
|
263
|
+
def initial_active_script_hash(self) -> PageHash:
|
264
|
+
return self.pages_strategy.initial_active_script_hash
|
265
|
+
|
272
266
|
@property
|
273
267
|
def mpa_version(self) -> int:
|
274
268
|
return 2 if isinstance(self.pages_strategy, PagesStrategyV2) else 1
|
275
269
|
|
270
|
+
def set_current_page_script_hash(self, page_script_hash: PageHash) -> None:
|
271
|
+
self._current_page_script_hash = page_script_hash
|
272
|
+
|
276
273
|
def get_main_page(self) -> PageInfo:
|
277
274
|
return {
|
278
275
|
"script_path": self._main_script_path,
|
279
276
|
"page_script_hash": self._main_script_hash,
|
280
277
|
}
|
281
278
|
|
282
|
-
def get_current_page_script_hash(self) -> PageHash:
|
283
|
-
"""Gets the script hash of the associated page of a script."""
|
284
|
-
return self._current_page_hash
|
285
|
-
|
286
|
-
def set_current_page_script_hash(self, page_hash: PageHash) -> None:
|
287
|
-
self._current_page_hash = page_hash
|
288
|
-
|
289
|
-
def get_active_script_hash(self) -> PageHash:
|
290
|
-
"""Gets the script hash of the currently executing script."""
|
291
|
-
return self.pages_strategy.get_active_script_hash()
|
292
|
-
|
293
|
-
def set_active_script_hash(self, page_hash: PageHash):
|
294
|
-
return self.pages_strategy.set_active_script_hash(page_hash)
|
295
|
-
|
296
|
-
def reset_active_script_hash(self):
|
297
|
-
# This will only apply to the V2 strategy as V1 ignores the concept
|
298
|
-
self.set_active_script_hash(self.main_script_hash)
|
299
|
-
|
300
279
|
def set_script_intent(
|
301
280
|
self, page_script_hash: PageHash, page_name: PageName
|
302
281
|
) -> None:
|
@@ -310,16 +289,6 @@ class PagesManager:
|
|
310
289
|
page_script_hash, page_name
|
311
290
|
)
|
312
291
|
|
313
|
-
@contextlib.contextmanager
|
314
|
-
def run_with_active_hash(self, page_hash: PageHash):
|
315
|
-
original_page_hash = self.get_active_script_hash()
|
316
|
-
self.set_active_script_hash(page_hash)
|
317
|
-
try:
|
318
|
-
yield
|
319
|
-
finally:
|
320
|
-
# in the event of any exception, ensure we set the active hash back
|
321
|
-
self.set_active_script_hash(original_page_hash)
|
322
|
-
|
323
292
|
def get_pages(self) -> dict[PageHash, PageInfo]:
|
324
293
|
return self.pages_strategy.get_pages()
|
325
294
|
|
@@ -15,10 +15,18 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
import collections
|
18
|
+
import contextlib
|
18
19
|
import contextvars
|
19
20
|
import threading
|
20
21
|
from dataclasses import dataclass, field
|
21
|
-
from typing import
|
22
|
+
from typing import (
|
23
|
+
TYPE_CHECKING,
|
24
|
+
Callable,
|
25
|
+
Counter,
|
26
|
+
Dict,
|
27
|
+
Final,
|
28
|
+
Union,
|
29
|
+
)
|
22
30
|
from urllib import parse
|
23
31
|
|
24
32
|
from typing_extensions import TypeAlias
|
@@ -90,6 +98,7 @@ class ScriptRunContext:
|
|
90
98
|
current_fragment_id: str | None = None
|
91
99
|
fragment_ids_this_run: list[str] | None = None
|
92
100
|
new_fragment_ids: set[str] = field(default_factory=set)
|
101
|
+
_active_script_hash: str = ""
|
93
102
|
# we allow only one dialog to be open at the same time
|
94
103
|
has_dialog_opened: bool = False
|
95
104
|
|
@@ -99,11 +108,25 @@ class ScriptRunContext:
|
|
99
108
|
|
100
109
|
@property
|
101
110
|
def page_script_hash(self):
|
102
|
-
return self.pages_manager.
|
111
|
+
return self.pages_manager.current_page_script_hash
|
103
112
|
|
104
113
|
@property
|
105
114
|
def active_script_hash(self):
|
106
|
-
return self.
|
115
|
+
return self._active_script_hash
|
116
|
+
|
117
|
+
@contextlib.contextmanager
|
118
|
+
def run_with_active_hash(self, page_hash: str):
|
119
|
+
original_page_hash = self._active_script_hash
|
120
|
+
self._active_script_hash = page_hash
|
121
|
+
try:
|
122
|
+
yield
|
123
|
+
finally:
|
124
|
+
# in the event of any exception, ensure we set the active hash back
|
125
|
+
self._active_script_hash = original_page_hash
|
126
|
+
|
127
|
+
def set_mpa_v2_page(self, page_script_hash: str):
|
128
|
+
self._active_script_hash = self.pages_manager.main_script_hash
|
129
|
+
self.pages_manager.set_current_page_script_hash(page_script_hash)
|
107
130
|
|
108
131
|
def reset(
|
109
132
|
self,
|
@@ -117,6 +140,7 @@ class ScriptRunContext:
|
|
117
140
|
self.form_ids_this_run = set()
|
118
141
|
self.query_string = query_string
|
119
142
|
self.pages_manager.set_current_page_script_hash(page_script_hash)
|
143
|
+
self._active_script_hash = self.pages_manager.initial_active_script_hash
|
120
144
|
# Permit set_page_config when the ScriptRunContext is reused on a rerun
|
121
145
|
self._set_page_config_allowed = True
|
122
146
|
self._has_script_started = False
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.5513bd04.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.50e02474.js",
|
5
5
|
"static/js/6679.265ca09c.chunk.js": "./static/js/6679.265ca09c.chunk.js",
|
6
6
|
"static/js/9464.7e9a3c0a.chunk.js": "./static/js/9464.7e9a3c0a.chunk.js",
|
7
7
|
"static/js/9077.e0a8db2a.chunk.js": "./static/js/9077.e0a8db2a.chunk.js",
|
@@ -62,7 +62,7 @@
|
|
62
62
|
"static/js/797.36f1bf7d.chunk.js": "./static/js/797.36f1bf7d.chunk.js",
|
63
63
|
"static/js/6198.956025ac.chunk.js": "./static/js/6198.956025ac.chunk.js",
|
64
64
|
"static/js/1674.86aea8e0.chunk.js": "./static/js/1674.86aea8e0.chunk.js",
|
65
|
-
"static/js/7591.
|
65
|
+
"static/js/7591.b3928443.chunk.js": "./static/js/7591.b3928443.chunk.js",
|
66
66
|
"static/media/MaterialSymbols-Rounded.woff2": "./static/media/MaterialSymbols-Rounded.ec07649f7a20048d5730.woff2",
|
67
67
|
"static/media/fireworks.gif": "./static/media/fireworks.0906f02ea43f1018a6d2.gif",
|
68
68
|
"static/media/flake-2.png": "./static/media/flake-2.e3f07d06933dd0e84c24.png",
|
@@ -153,6 +153,6 @@
|
|
153
153
|
},
|
154
154
|
"entrypoints": [
|
155
155
|
"static/css/main.5513bd04.css",
|
156
|
-
"static/js/main.
|
156
|
+
"static/js/main.50e02474.js"
|
157
157
|
]
|
158
158
|
}
|