jupyter-server-ydoc 2.0.2__py3-none-any.whl → 2.1.0a0__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.
- jupyter_server_ydoc/_version.py +1 -1
- jupyter_server_ydoc/handlers.py +15 -0
- jupyter_server_ydoc/pytest_plugin.py +1 -1
- jupyter_server_ydoc/rooms.py +27 -1
- jupyter_server_ydoc/utils.py +1 -0
- {jupyter_server_ydoc-2.0.2.dist-info → jupyter_server_ydoc-2.1.0a0.dist-info}/METADATA +1 -1
- jupyter_server_ydoc-2.1.0a0.dist-info/RECORD +19 -0
- jupyter_server_ydoc-2.0.2.dist-info/RECORD +0 -19
- {jupyter_server_ydoc-2.0.2.data → jupyter_server_ydoc-2.1.0a0.data}/data/etc/jupyter/jupyter_server_config.d/jupyter_collaboration.json +0 -0
- {jupyter_server_ydoc-2.0.2.dist-info → jupyter_server_ydoc-2.1.0a0.dist-info}/WHEEL +0 -0
- {jupyter_server_ydoc-2.0.2.dist-info → jupyter_server_ydoc-2.1.0a0.dist-info}/licenses/LICENSE +0 -0
jupyter_server_ydoc/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.0.
|
|
1
|
+
__version__ = "2.1.0.a0"
|
jupyter_server_ydoc/handlers.py
CHANGED
|
@@ -9,6 +9,7 @@ import uuid
|
|
|
9
9
|
from logging import Logger
|
|
10
10
|
from typing import Any
|
|
11
11
|
from uuid import uuid4
|
|
12
|
+
from typing import cast
|
|
12
13
|
|
|
13
14
|
from jupyter_server.auth import authorized
|
|
14
15
|
from jupyter_server.base.handlers import APIHandler, JupyterHandler
|
|
@@ -32,6 +33,8 @@ from .utils import (
|
|
|
32
33
|
room_id_from_encoded_path,
|
|
33
34
|
)
|
|
34
35
|
from .websocketserver import JupyterWebsocketServer, RoomNotFound
|
|
36
|
+
from .utils import MessageType
|
|
37
|
+
from pycrdt import Decoder
|
|
35
38
|
|
|
36
39
|
YFILE = YDOCS["file"]
|
|
37
40
|
|
|
@@ -291,6 +294,18 @@ class YDocWebSocketHandler(WebSocketHandler, JupyterHandler):
|
|
|
291
294
|
"""
|
|
292
295
|
On message receive.
|
|
293
296
|
"""
|
|
297
|
+
decoder = Decoder(message)
|
|
298
|
+
header = decoder.read_var_uint()
|
|
299
|
+
if header == MessageType.RAW:
|
|
300
|
+
msg = decoder.read_var_string()
|
|
301
|
+
if msg == "save":
|
|
302
|
+
try:
|
|
303
|
+
room = cast(DocumentRoom, self.room)
|
|
304
|
+
room._save_to_disc()
|
|
305
|
+
except Exception:
|
|
306
|
+
self.log.error("Couldn't save content from room: %s", self._room_id)
|
|
307
|
+
return
|
|
308
|
+
|
|
294
309
|
self._message_queue.put_nowait(message)
|
|
295
310
|
self._websocket_server.ypatch_nb += 1
|
|
296
311
|
|
|
@@ -276,7 +276,7 @@ def rtc_create_mock_document_room():
|
|
|
276
276
|
last_modified: datetime | None = None,
|
|
277
277
|
save_delay: float | None = None,
|
|
278
278
|
store: SQLiteYStore | None = None,
|
|
279
|
-
writable: bool =
|
|
279
|
+
writable: bool = True,
|
|
280
280
|
) -> tuple[FakeContentsManager, FileLoader, DocumentRoom]:
|
|
281
281
|
paths = {id: path}
|
|
282
282
|
|
jupyter_server_ydoc/rooms.py
CHANGED
|
@@ -247,6 +247,33 @@ class DocumentRoom(YRoom):
|
|
|
247
247
|
document. This tasks are debounced (60 seconds by default) so we
|
|
248
248
|
need to cancel previous tasks before creating a new one.
|
|
249
249
|
"""
|
|
250
|
+
# Collect autosave values from all clients
|
|
251
|
+
autosave_states = [
|
|
252
|
+
state.get("autosave", True)
|
|
253
|
+
for state in self.awareness.states.values()
|
|
254
|
+
if state # skip empty states
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
# If no states exist (e.g., during tests), force autosave to be True
|
|
258
|
+
if not autosave_states:
|
|
259
|
+
autosave_states = [True]
|
|
260
|
+
|
|
261
|
+
# Enable autosave if at least one client has it turned on
|
|
262
|
+
autosave = any(autosave_states)
|
|
263
|
+
|
|
264
|
+
if not autosave:
|
|
265
|
+
return
|
|
266
|
+
if self._update_lock.locked():
|
|
267
|
+
return
|
|
268
|
+
|
|
269
|
+
self._saving_document = asyncio.create_task(
|
|
270
|
+
self._maybe_save_document(self._saving_document)
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
def _save_to_disc(self):
|
|
274
|
+
"""
|
|
275
|
+
Called when manual save is triggered. Helpful when autosave is turned off.
|
|
276
|
+
"""
|
|
250
277
|
if self._update_lock.locked():
|
|
251
278
|
return
|
|
252
279
|
|
|
@@ -265,7 +292,6 @@ class DocumentRoom(YRoom):
|
|
|
265
292
|
"""
|
|
266
293
|
if self._save_delay is None:
|
|
267
294
|
return
|
|
268
|
-
|
|
269
295
|
if saving_document is not None and not saving_document.done():
|
|
270
296
|
# the document is being saved, cancel that
|
|
271
297
|
saving_document.cancel()
|
jupyter_server_ydoc/utils.py
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
jupyter_server_ydoc/__init__.py,sha256=B8H7XLhzgrTCQD8304Lx91FYXslwabsnV9OuYu4M4Hw,346
|
|
2
|
+
jupyter_server_ydoc/_version.py,sha256=eZzF8e5HVFytAjd60EQKykaCgPXnPcL_rr7wws5yI1o,25
|
|
3
|
+
jupyter_server_ydoc/app.py,sha256=6Zca0acaEFCKyUbXdmcPmVk1Dgu91Y-DFjYR16WKFlg,8161
|
|
4
|
+
jupyter_server_ydoc/handlers.py,sha256=WbQLlExk84GsZ0JNA5cmNCbWucruQi0FhQaKG_ZQGiY,27808
|
|
5
|
+
jupyter_server_ydoc/loaders.py,sha256=XUQqg2EbfQUYlQVjHY183gYKeVZ6x92VHy4EsOQz4fA,11303
|
|
6
|
+
jupyter_server_ydoc/pytest_plugin.py,sha256=yMVlk7fvHXiM7g6ua0Ophc96cFwC0bmTWVDbbUeu2DE,8741
|
|
7
|
+
jupyter_server_ydoc/rooms.py,sha256=isX4vHhhvi5WgHtUJBsj29aXw99qoyrO4UOvCij0VbU,13066
|
|
8
|
+
jupyter_server_ydoc/stores.py,sha256=_5J6eNs3R5Tv88PCc-GGuszxQstfvNoBCYABqzBzJXA,1004
|
|
9
|
+
jupyter_server_ydoc/test_utils.py,sha256=utUwB5FThc_SCQshhUbLNih9GUa5qBcmMgU6-jx0ZnA,2275
|
|
10
|
+
jupyter_server_ydoc/utils.py,sha256=_wI4CFOEZK4MSMYCZe2moSbggUTRdGxY4qTzSDEFzdE,2183
|
|
11
|
+
jupyter_server_ydoc/websocketserver.py,sha256=h1yTgJcsCK17_97Ne5x-lbgIFsxylwnltxagcuAlTJY,5185
|
|
12
|
+
jupyter_server_ydoc/events/awareness.yaml,sha256=2FrCci5rZIaU4rn8pIPZJkd132YAZdzKjSNSwjOY7Dk,755
|
|
13
|
+
jupyter_server_ydoc/events/fork.yaml,sha256=3OrhQjhVyLjlBJWMiffbnZodL3GzFafLwEmSBFrK33o,1303
|
|
14
|
+
jupyter_server_ydoc/events/session.yaml,sha256=PS0MxowpRwY5QFYm-LJvHUxKHnsictV8_6VEwfhYxcQ,1596
|
|
15
|
+
jupyter_server_ydoc-2.1.0a0.data/data/etc/jupyter/jupyter_server_config.d/jupyter_collaboration.json,sha256=0thh2hJUxAKkZSmneJMG0U6QJRjdM6zGlwrTedEt-Jk,94
|
|
16
|
+
jupyter_server_ydoc-2.1.0a0.dist-info/METADATA,sha256=Z0ZJ1wFBxpe2nTL4_f_9DaaUsRuQDgXLLbLzh3HsVf4,5117
|
|
17
|
+
jupyter_server_ydoc-2.1.0a0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
jupyter_server_ydoc-2.1.0a0.dist-info/licenses/LICENSE,sha256=mhO0ZW9EiWOPg0dUgB-lNbJ0CGwRmTdbeAg_se1SOnY,2833
|
|
19
|
+
jupyter_server_ydoc-2.1.0a0.dist-info/RECORD,,
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
jupyter_server_ydoc/__init__.py,sha256=B8H7XLhzgrTCQD8304Lx91FYXslwabsnV9OuYu4M4Hw,346
|
|
2
|
-
jupyter_server_ydoc/_version.py,sha256=tATvJM5shAzfspHYjdVwpV2w3-gDA119NlEYi5X2lFY,22
|
|
3
|
-
jupyter_server_ydoc/app.py,sha256=6Zca0acaEFCKyUbXdmcPmVk1Dgu91Y-DFjYR16WKFlg,8161
|
|
4
|
-
jupyter_server_ydoc/handlers.py,sha256=Prsi_IlJa9wl9VszRr-2qKZ8z224u-o7lRYI5SNJBaE,27276
|
|
5
|
-
jupyter_server_ydoc/loaders.py,sha256=XUQqg2EbfQUYlQVjHY183gYKeVZ6x92VHy4EsOQz4fA,11303
|
|
6
|
-
jupyter_server_ydoc/pytest_plugin.py,sha256=MfFqL5xJLGeIuLG8GF1kr2TumRjIIQfxoeNLGjvQjY8,8742
|
|
7
|
-
jupyter_server_ydoc/rooms.py,sha256=u4umGLsudteR6oJvw4pcszzrZTDgzOZkVXZEOfBPk8M,12221
|
|
8
|
-
jupyter_server_ydoc/stores.py,sha256=_5J6eNs3R5Tv88PCc-GGuszxQstfvNoBCYABqzBzJXA,1004
|
|
9
|
-
jupyter_server_ydoc/test_utils.py,sha256=utUwB5FThc_SCQshhUbLNih9GUa5qBcmMgU6-jx0ZnA,2275
|
|
10
|
-
jupyter_server_ydoc/utils.py,sha256=EgKC15js8VOS8-5jGMs4pfHQfV9drnNT2Gew5UlyXZc,2171
|
|
11
|
-
jupyter_server_ydoc/websocketserver.py,sha256=h1yTgJcsCK17_97Ne5x-lbgIFsxylwnltxagcuAlTJY,5185
|
|
12
|
-
jupyter_server_ydoc/events/awareness.yaml,sha256=2FrCci5rZIaU4rn8pIPZJkd132YAZdzKjSNSwjOY7Dk,755
|
|
13
|
-
jupyter_server_ydoc/events/fork.yaml,sha256=3OrhQjhVyLjlBJWMiffbnZodL3GzFafLwEmSBFrK33o,1303
|
|
14
|
-
jupyter_server_ydoc/events/session.yaml,sha256=PS0MxowpRwY5QFYm-LJvHUxKHnsictV8_6VEwfhYxcQ,1596
|
|
15
|
-
jupyter_server_ydoc-2.0.2.data/data/etc/jupyter/jupyter_server_config.d/jupyter_collaboration.json,sha256=0thh2hJUxAKkZSmneJMG0U6QJRjdM6zGlwrTedEt-Jk,94
|
|
16
|
-
jupyter_server_ydoc-2.0.2.dist-info/METADATA,sha256=Wcc5iSM2ZdOp74R__1pRnFDoPYvNK0lm-y9WkQJjBX0,5115
|
|
17
|
-
jupyter_server_ydoc-2.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
-
jupyter_server_ydoc-2.0.2.dist-info/licenses/LICENSE,sha256=mhO0ZW9EiWOPg0dUgB-lNbJ0CGwRmTdbeAg_se1SOnY,2833
|
|
19
|
-
jupyter_server_ydoc-2.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{jupyter_server_ydoc-2.0.2.dist-info → jupyter_server_ydoc-2.1.0a0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|