Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pycrdt-v0.8.30 #27

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ keywords = [
]
dependencies = [
"comm >=0.1.4,<1",
"pycrdt >=0.8.2,<0.9.0",
"pycrdt >=0.8.30,<0.9.0",
"declare >=1.0.1,<2.0.0",
]

Expand Down
18 changes: 12 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@

import comm
import pytest
from pycrdt import TransactionEvent
from pycrdt import (
YMessageType,
YSyncMessageType,
TransactionEvent,
create_sync_message,
create_update_message,
handle_sync_message,
)
from ypywidgets import Widget
from ypywidgets.comm import CommWidget
from ypywidgets.utils import YMessageType, YSyncMessageType, create_update_message, process_sync_message, sync


class MockComm(comm.base_comm.BaseComm):
Expand Down Expand Up @@ -73,13 +79,13 @@ async def receive(self):
msg_type, data, metadata, buffers, target_name, target_module = await self.comm.send_queue.get()
if msg_type == "comm_open":
self.widget = self.widget_factory()
msg = sync(self.widget.ydoc)
self.comm.handle_msg(msg)
msg = create_sync_message(self.widget.ydoc)
self.comm.handle_msg({"buffers": [msg]})
elif msg_type == "comm_msg":
message = buffers[0]
if message[0] == YMessageType.SYNC:
reply = process_sync_message(message[1:], self.widget.ydoc)
if reply:
reply = handle_sync_message(message[1:], self.widget.ydoc)
if reply is not None:
self.comm.handle_msg({"buffers": [reply]})
if message[1] == YSyncMessageType.SYNC_STEP2:
self.widget.ydoc.observe(self.send)
Expand Down
20 changes: 11 additions & 9 deletions ypywidgets/comm.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from __future__ import annotations

import comm
from pycrdt import Doc, Text, TransactionEvent

from .utils import (
from pycrdt import (
Doc,
Text,
TransactionEvent,
YMessageType,
YSyncMessageType,
create_sync_message,
create_update_message,
process_sync_message,
sync,
handle_sync_message,
)

from .widget import Widget


Expand All @@ -35,15 +37,15 @@ def __init__(
) -> None:
self._ydoc = ydoc
self._comm = comm
msg = sync(ydoc)
self._comm.send(**msg)
msg = create_sync_message(ydoc)
self._comm.send(buffers=[msg])
self._comm.on_msg(self._receive)

def _receive(self, msg):
message = bytes(msg["buffers"][0])
if message[0] == YMessageType.SYNC:
reply = process_sync_message(message[1:], self._ydoc)
if reply:
reply = handle_sync_message(message[1:], self._ydoc)
if reply is not None:
self._comm.send(buffers=[reply])
if message[1] == YSyncMessageType.SYNC_STEP2:
self._ydoc.observe(self._send)
Expand Down
121 changes: 0 additions & 121 deletions ypywidgets/utils.py

This file was deleted.

Loading