diff --git a/jupyter_ydoc/yblob.py b/jupyter_ydoc/yblob.py index 4f79e0c..894881e 100644 --- a/jupyter_ydoc/yblob.py +++ b/jupyter_ydoc/yblob.py @@ -1,7 +1,6 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. -import base64 from functools import partial from typing import Any, Callable, Optional, Union @@ -13,10 +12,7 @@ class YBlob(YBaseDoc): """ Extends :class:`YBaseDoc`, and represents a blob document. - It is currently encoded as base64 because of: - https://github.com/y-crdt/ypy/issues/108#issuecomment-1377055465 - The Y document can be set from bytes or from str, in which case it is assumed to be encoded as - base64. + The Y document is set from bytes. Schema: @@ -46,7 +42,7 @@ def version(self) -> str: :return: Document's version. :rtype: str """ - return "1.0.0" + return "2.0.0" def get(self) -> bytes: """ @@ -55,18 +51,16 @@ def get(self) -> bytes: :return: Document's content. :rtype: bytes """ - return base64.b64decode(self._ysource.get("base64", "").encode()) + return self._ysource.get("bytes", b"") - def set(self, value: Union[bytes, str]) -> None: + def set(self, value: bytes) -> None: """ Sets the content of the document. :param value: The content of the document. - :type value: Union[bytes, str] + :type value: bytes """ - if isinstance(value, bytes): - value = base64.b64encode(value).decode() - self._ysource["base64"] = value + self._ysource["bytes"] = value def observe(self, callback: Callable[[str, Any], None]) -> None: """ diff --git a/pyproject.toml b/pyproject.toml index ad36b8b..1a2b1b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ requires-python = ">=3.7" keywords = ["jupyter", "ypy"] dependencies = [ "importlib_metadata >=3.6; python_version<'3.10'", - "pycrdt >=0.8.1,<0.9.0", + "pycrdt >=0.8.3,<0.9.0", ] [[project.authors]]