|
4 | 4 |
|
5 | 5 | from htmltools import TagChild |
6 | 6 |
|
| 7 | +from shiny.bookmark._bookmark import ShinySaveState |
| 8 | + |
7 | 9 | from .._namespaces import Id, ResolvedId, Root |
8 | 10 | from ..session import Inputs, Outputs, Session |
9 | | -from ..session._session import SessionProxy |
| 11 | +from ..session._session import Bookmark, SessionProxy |
10 | 12 |
|
11 | 13 | if TYPE_CHECKING: |
12 | 14 | from ..session._session import DownloadHandler, DynamicRouteHandler, RenderedDeps |
@@ -44,21 +46,17 @@ def __init__(self, ns: ResolvedId = Root): |
44 | 46 | # Application-level (not session-level) options that may be set via app_opts(). |
45 | 47 | self.app_opts: AppOpts = {} |
46 | 48 |
|
47 | | - self.bookmark_exclude = [] |
48 | | - self.bookmark_store = "disable" # TODO: Is this correct? |
| 49 | + self.bookmark = BookmarkExpressStub(self) |
| 50 | + |
| 51 | + self.exclude = [] |
| 52 | + self.store = "disable" # TODO: Is this correct? |
49 | 53 |
|
50 | 54 | def is_stub_session(self) -> Literal[True]: |
51 | 55 | return True |
52 | 56 |
|
53 | 57 | async def close(self, code: int = 1001) -> None: |
54 | 58 | return |
55 | 59 |
|
56 | | - def _get_bookmark_exclude(self) -> list[str]: |
57 | | - raise NotImplementedError("Please call this only from a real session object") |
58 | | - |
59 | | - def do_bookmark(self) -> None: |
60 | | - raise NotImplementedError("Please call this only from a real session object") |
61 | | - |
62 | 60 | # This is needed so that Outputs don't throw an error. |
63 | 61 | def _is_hidden(self, name: str) -> bool: |
64 | 62 | return False |
@@ -147,3 +145,32 @@ def download( |
147 | 145 | encoding: str = "utf-8", |
148 | 146 | ) -> Callable[[DownloadHandler], None]: |
149 | 147 | return lambda x: None |
| 148 | + |
| 149 | + |
| 150 | +class BookmarkExpressStub(Bookmark): |
| 151 | + |
| 152 | + def _get_bookmark_exclude(self) -> list[str]: |
| 153 | + raise NotImplementedError("Please call this only from a real session object") |
| 154 | + |
| 155 | + def on_bookmark( |
| 156 | + self, |
| 157 | + callback: ( |
| 158 | + Callable[[ShinySaveState], None] |
| 159 | + | Callable[[ShinySaveState], Awaitable[None]] |
| 160 | + ), |
| 161 | + ) -> None: |
| 162 | + raise NotImplementedError("Please call this only from a real session object") |
| 163 | + |
| 164 | + def on_bookmarked( |
| 165 | + self, |
| 166 | + callback: Callable[[str], None] | Callable[[str], Awaitable[None]], |
| 167 | + ) -> None: |
| 168 | + raise NotImplementedError("Please call this only from a real session object") |
| 169 | + |
| 170 | + async def update_query_string( |
| 171 | + self, query_string: str, mode: Literal["replace", "push"] = "replace" |
| 172 | + ) -> None: |
| 173 | + raise NotImplementedError("Please call this only from a real session object") |
| 174 | + |
| 175 | + async def do_bookmark(self) -> None: |
| 176 | + raise NotImplementedError("Please call this only from a real session object") |
0 commit comments