@@ -281,7 +281,7 @@ export class IpywidgetsState extends EventEmitter {
281
281
282
282
private set_model_buffers = (
283
283
model_id : string ,
284
- buffer_paths : string [ ] ,
284
+ buffer_paths : string [ ] [ ] ,
285
285
buffers : Buffer [ ] ,
286
286
fire_change_event : boolean = true ,
287
287
) : void => {
@@ -294,7 +294,7 @@ export class IpywidgetsState extends EventEmitter {
294
294
}
295
295
for ( let i = 0 ; i < buffer_paths . length ; i ++ ) {
296
296
const key = JSON . stringify ( buffer_paths [ i ] ) ;
297
- // we set to the sha1 of the buffer not to make getting
297
+ // we set to the sha1 of the buffer not just to make getting
298
298
// the buffer easy, but to make it easy to KNOW if we
299
299
// even need to get the buffer.
300
300
const hash = sha1 ( buffers [ i ] ) ;
@@ -388,14 +388,15 @@ export class IpywidgetsState extends EventEmitter {
388
388
this . set_state ( "closed" ) ;
389
389
} ;
390
390
391
- private dbg ( _f ) : Function {
391
+ private dbg = ( _f ) : Function => {
392
392
if ( this . client . is_project ( ) ) {
393
393
return this . client . dbg ( `IpywidgetsState.${ _f } ` ) ;
394
394
} else {
395
395
return ( ..._ ) => { } ;
396
396
}
397
- }
398
- public async clear ( ) : Promise < void > {
397
+ } ;
398
+
399
+ clear = async ( ) : Promise < void > => {
399
400
// This is used when we restart the kernel -- we reset
400
401
// things so no information about any models is known
401
402
// and delete all Buffers.
@@ -417,13 +418,13 @@ export class IpywidgetsState extends EventEmitter {
417
418
this . table . set ( { string_id, type, model_id, data : null } , "none" , false ) ;
418
419
}
419
420
await this . table . save ( ) ;
420
- }
421
+ } ;
421
422
422
423
// Clean up all data in the table about models that are not
423
424
// referenced (directly or indirectly) in any cell in the notebook.
424
425
// There is also a comm:close event/message somewhere, which
425
426
// could also be useful....?
426
- public async deleteUnused ( ) : Promise < void > {
427
+ deleteUnused = async ( ) : Promise < void > = > {
427
428
this . assert_state ( "ready" ) ;
428
429
const dbg = this . dbg ( "deleteUnused" ) ;
429
430
dbg ( ) ;
@@ -442,13 +443,13 @@ export class IpywidgetsState extends EventEmitter {
442
443
}
443
444
} ) ;
444
445
await this . table . save ( ) ;
445
- }
446
+ } ;
446
447
447
448
// For each model in init, we add in all the ids of models
448
449
// that it explicitly references, e.g., by IPY_MODEL_[model_id] fields
449
450
// and by output messages and other things we learn about (e.g., k3d
450
451
// has its own custom references).
451
- public getReferencedModelIds ( init : string | Set < string > ) : Set < string > {
452
+ getReferencedModelIds = ( init : string | Set < string > ) : Set < string > = > {
452
453
const modelIds =
453
454
typeof init == "string" ? new Set ( [ init ] ) : new Set < string > ( init ) ;
454
455
let before = 0 ;
@@ -470,14 +471,14 @@ export class IpywidgetsState extends EventEmitter {
470
471
this . includeThirdPartyReferences ( modelIds ) ;
471
472
472
473
return modelIds ;
473
- }
474
+ } ;
474
475
475
476
// We find the ids of all models that are explicitly referenced
476
477
// in the current version of the Jupyter notebook by iterating through
477
478
// the output of all cells, then expanding the result to everything
478
479
// that these models reference. This is used as a foundation for
479
480
// garbage collection.
480
- private getActiveModelIds ( ) : Set < string > {
481
+ private getActiveModelIds = ( ) : Set < string > = > {
481
482
const modelIds : Set < string > = new Set ( ) ;
482
483
this . syncdoc . get ( { type : "cell" } ) . forEach ( ( cell ) => {
483
484
const output = cell . get ( "output" ) ;
@@ -497,9 +498,9 @@ export class IpywidgetsState extends EventEmitter {
497
498
}
498
499
} ) ;
499
500
return this . getReferencedModelIds ( modelIds ) ;
500
- }
501
+ } ;
501
502
502
- private includeThirdPartyReferences ( modelIds : Set < string > ) {
503
+ private includeThirdPartyReferences = ( modelIds : Set < string > ) => {
503
504
/*
504
505
Motivation (RANT):
505
506
It seems to me that third party widgets can just invent their own
@@ -545,33 +546,33 @@ export class IpywidgetsState extends EventEmitter {
545
546
modelIds . add ( model_id ) ;
546
547
}
547
548
} ) ;
548
- }
549
+ } ;
549
550
550
551
// The finite state machine state, e.g., 'init' --> 'ready' --> 'close'
551
- private set_state ( state : State ) : void {
552
+ private set_state = ( state : State ) : void => {
552
553
this . state = state ;
553
554
this . emit ( state ) ;
554
- }
555
+ } ;
555
556
556
- public get_state ( ) : State {
557
+ get_state = ( ) : State => {
557
558
return this . state ;
558
- }
559
+ } ;
559
560
560
- private assert_state ( state : string ) : void {
561
+ private assert_state = ( state : string ) : void => {
561
562
if ( this . state != state ) {
562
563
throw Error ( `state must be "${ state } " but it is "${ this . state } "` ) ;
563
564
}
564
- }
565
+ } ;
565
566
566
567
/*
567
568
process_comm_message_from_kernel gets called whenever the
568
569
kernel emits a comm message related to widgets. This updates
569
570
the state of the table, which results in frontends creating widgets
570
571
or updating state of widgets.
571
572
*/
572
- public async process_comm_message_from_kernel (
573
+ process_comm_message_from_kernel = async (
573
574
msg : CommMessage ,
574
- ) : Promise < void > {
575
+ ) : Promise < void > => {
575
576
const dbg = this . dbg ( "process_comm_message_from_kernel" ) ;
576
577
// WARNING: serializing any msg could cause huge server load, e.g., it could contain
577
578
// a 20MB buffer in it.
@@ -697,7 +698,7 @@ export class IpywidgetsState extends EventEmitter {
697
698
}
698
699
699
700
await this . save ( ) ;
700
- }
701
+ } ;
701
702
702
703
/*
703
704
process_comm_message_from_browser gets called whenever a
@@ -707,20 +708,20 @@ export class IpywidgetsState extends EventEmitter {
707
708
kernel changing the value of variables (and possibly
708
709
updating other widgets).
709
710
*/
710
- public async process_comm_message_from_browser (
711
+ process_comm_message_from_browser = async (
711
712
msg : CommMessage ,
712
- ) : Promise < void > {
713
+ ) : Promise < void > => {
713
714
const dbg = this . dbg ( "process_comm_message_from_browser" ) ;
714
715
dbg ( msg ) ;
715
716
this . assert_state ( "ready" ) ;
716
717
// TODO: not implemented!
717
- }
718
+ } ;
718
719
719
720
// The mesg here is exactly what came over the IOPUB channel
720
721
// from the kernel.
721
722
722
723
// TODO: deal with buffers
723
- public capture_output_message ( mesg : any ) : boolean {
724
+ capture_output_message = ( mesg : any ) : boolean => {
724
725
const msg_id = mesg . parent_header . msg_id ;
725
726
if ( this . capture_output [ msg_id ] == null ) {
726
727
return false ;
@@ -759,13 +760,13 @@ export class IpywidgetsState extends EventEmitter {
759
760
outputs . push ( mesg . content ) ;
760
761
this . set_model_value ( model_id , { outputs } ) ;
761
762
return true ;
762
- }
763
+ } ;
763
764
764
- private async sendCustomMessage (
765
+ private sendCustomMessage = async (
765
766
model_id : string ,
766
767
message : object ,
767
768
fire_change_event : boolean = true ,
768
- ) : Promise < void > {
769
+ ) : Promise < void > => {
769
770
/*
770
771
Send a custom message.
771
772
@@ -782,11 +783,11 @@ export class IpywidgetsState extends EventEmitter {
782
783
// Actually, delete is not implemented for synctable, so for
783
784
// now we just set it to an empty message.
784
785
this . set ( model_id , "message" , { } , fire_change_event ) ;
785
- }
786
+ } ;
786
787
787
- public get_message ( model_id : string ) {
788
+ get_message = ( model_id : string ) => {
788
789
return this . get ( model_id , "message" ) ?. toJS ( ) ;
789
- }
790
+ } ;
790
791
}
791
792
792
793
// Get model id's that appear either as serialized references
0 commit comments