File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -203,12 +203,20 @@ export class WidgetManager extends JupyterLabManager {
203
203
{ widgets : null }
204
204
) ;
205
205
206
- const [ widgetsInfo , buffers ] : any = await new Promise ( resolve => {
206
+ let [ widgetsInfo , buffers ] : any = await new Promise ( resolve => {
207
207
initComm . on_msg ( msg => {
208
208
const info = JSON . parse (
209
209
Buffer . from ( new Int8Array ( msg . buffers [ 0 ] . buffer ) ) . toString ( 'utf-8' )
210
210
) ;
211
- resolve ( [ info , msg . buffers . slice ( 1 ) ] ) ;
211
+
212
+ const buffers = ( msg . buffers . slice ( 1 ) || [ ] ) . map ( ( b : any ) => {
213
+ if ( b instanceof DataView ) {
214
+ return b ;
215
+ } else {
216
+ return new DataView ( b instanceof ArrayBuffer ? b : b . buffer ) ;
217
+ }
218
+ } ) ;
219
+ resolve ( [ info , buffers ] ) ;
212
220
} ) ;
213
221
} ) ;
214
222
@@ -234,9 +242,11 @@ export class WidgetManager extends JupyterLabManager {
234
242
try {
235
243
const comm = await this . _create_comm ( 'jupyter.widget' , widget_id ) ;
236
244
237
- // If we have binary buffers
245
+ // Put binary buffers
238
246
if ( widget_id in bufferPaths ) {
239
- base . put_buffers ( state , bufferPaths [ widget_id ] , buffers ) ;
247
+ const nBuffers = bufferPaths [ widget_id ] . length ;
248
+ base . put_buffers ( state , bufferPaths [ widget_id ] , buffers . slice ( 0 , nBuffers ) ) ;
249
+ buffers = buffers . slice ( nBuffers ) ;
240
250
}
241
251
242
252
const modelPromise = this . new_model (
You can’t perform that action at this time.
0 commit comments