diff --git a/CHANGELOG.md b/CHANGELOG.md index 1058cef..72c99ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [UNRELEASED] - +* Fixed a bug with receiving binary data on the frontend, which gets [quak](https://github.com/manzt/quak) and [mosaic-widget](https://idl.uw.edu/mosaic/jupyter/) working with `@render_widget`. (#152) ## [0.3.2] - 2024-04-16 diff --git a/js/src/comm.ts b/js/src/comm.ts index 948b773..3c1c7b0 100644 --- a/js/src/comm.ts +++ b/js/src/comm.ts @@ -32,6 +32,7 @@ export class ShinyComm { const msg = { content: {comm_id: this.comm_id, data: data}, metadata: metadata, + // TODO: need to _encode_ any buffers into base64 (JSON.stringify just drops them) buffers: buffers || [], // this doesn't seem relevant to the widget? header: {} diff --git a/js/src/utils.ts b/js/src/utils.ts index b69d55f..e02ebaf 100644 --- a/js/src/utils.ts +++ b/js/src/utils.ts @@ -5,7 +5,7 @@ import { decode } from 'base64-arraybuffer'; // along to the comm logic function jsonParse(x: string) { const msg = JSON.parse(x); - msg.buffers = msg.buffers.map((b: any) => decode(b)); + msg.buffers = msg.buffers.map((base64: string) => new DataView(decode(base64))); return msg; }