Skip to content

Commit d6684ea

Browse files
manztcpsievert
andauthored
Ensure binary data is a DataView (#152)
Co-authored-by: Carson <[email protected]>
1 parent d86f74b commit d6684ea

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [UNRELEASED]
99

10-
10+
* 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)
1111

1212
## [0.3.2] - 2024-04-16
1313

js/src/comm.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class ShinyComm {
3232
const msg = {
3333
content: {comm_id: this.comm_id, data: data},
3434
metadata: metadata,
35+
// TODO: need to _encode_ any buffers into base64 (JSON.stringify just drops them)
3536
buffers: buffers || [],
3637
// this doesn't seem relevant to the widget?
3738
header: {}

js/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { decode } from 'base64-arraybuffer';
55
// along to the comm logic
66
function jsonParse(x: string) {
77
const msg = JSON.parse(x);
8-
msg.buffers = msg.buffers.map((b: any) => decode(b));
8+
msg.buffers = msg.buffers.map((base64: string) => new DataView(decode(base64)));
99
return msg;
1010
}
1111

0 commit comments

Comments
 (0)