@@ -144,22 +144,21 @@ export function registerWidgetManager(
144
144
/**
145
145
* The widget manager provider.
146
146
*/
147
- const plugin : JupyterFrontEndPlugin < base . IJupyterWidgetRegistry > = {
148
- id : '@jupyter-widgets/jupyterlab-manager:plugin' ,
149
- requires : [ IRenderMimeRegistry ] ,
150
- optional : [
151
- INotebookTracker ,
152
- ISettingRegistry ,
153
- IMainMenu ,
154
- ILoggerRegistry ,
155
- ITranslator ,
156
- ] ,
157
- provides : base . IJupyterWidgetRegistry ,
158
- activate : activateWidgetExtension ,
159
- autoStart : true ,
160
- } ;
161
-
162
- export default plugin ;
147
+ export const managerPlugin : JupyterFrontEndPlugin < base . IJupyterWidgetRegistry > =
148
+ {
149
+ id : '@jupyter-widgets/jupyterlab-manager:plugin' ,
150
+ requires : [ IRenderMimeRegistry ] ,
151
+ optional : [
152
+ INotebookTracker ,
153
+ ISettingRegistry ,
154
+ IMainMenu ,
155
+ ILoggerRegistry ,
156
+ ITranslator ,
157
+ ] ,
158
+ provides : base . IJupyterWidgetRegistry ,
159
+ activate : activateWidgetExtension ,
160
+ autoStart : true ,
161
+ } ;
163
162
164
163
function updateSettings ( settings : ISettingRegistry . ISettings ) : void {
165
164
SETTINGS . saveState = settings . get ( 'saveState' ) . composite as boolean ;
@@ -209,7 +208,7 @@ function activateWidgetExtension(
209
208
} ;
210
209
if ( settingRegistry !== null ) {
211
210
settingRegistry
212
- . load ( plugin . id )
211
+ . load ( managerPlugin . id )
213
212
. then ( ( settings : ISettingRegistry . ISettings ) => {
214
213
settings . changed . connect ( updateSettings ) ;
215
214
updateSettings ( settings ) ;
@@ -262,9 +261,11 @@ function activateWidgetExtension(
262
261
label : trans . __ ( 'Save Widget State Automatically' ) ,
263
262
execute : ( args ) => {
264
263
return settingRegistry
265
- . set ( plugin . id , 'saveState' , ! SETTINGS . saveState )
264
+ . set ( managerPlugin . id , 'saveState' , ! SETTINGS . saveState )
266
265
. catch ( ( reason : Error ) => {
267
- console . error ( `Failed to set ${ plugin . id } : ${ reason . message } ` ) ;
266
+ console . error (
267
+ `Failed to set ${ managerPlugin . id } : ${ reason . message } `
268
+ ) ;
268
269
} ) ;
269
270
} ,
270
271
isToggled : ( ) => SETTINGS . saveState ,
@@ -277,55 +278,100 @@ function activateWidgetExtension(
277
278
] ) ;
278
279
}
279
280
280
- WIDGET_REGISTRY . push ( {
281
- name : '@jupyter-widgets/base' ,
282
- version : base . JUPYTER_WIDGETS_VERSION ,
283
- exports : {
284
- WidgetModel : base . WidgetModel ,
285
- WidgetView : base . WidgetView ,
286
- DOMWidgetView : base . DOMWidgetView ,
287
- DOMWidgetModel : base . DOMWidgetModel ,
288
- LayoutModel : base . LayoutModel ,
289
- LayoutView : base . LayoutView ,
290
- StyleModel : base . StyleModel ,
291
- StyleView : base . StyleView ,
292
- ErrorWidgetView : base . ErrorWidgetView ,
293
- } ,
294
- } ) ;
295
-
296
- WIDGET_REGISTRY . push ( {
297
- name : '@jupyter-widgets/controls' ,
298
- version : JUPYTER_CONTROLS_VERSION ,
299
- exports : ( ) => {
300
- return new Promise ( ( resolve , reject ) => {
301
- ( require as any ) . ensure (
302
- [ '@jupyter-widgets/controls' ] ,
303
- ( require : NodeRequire ) => {
304
- // eslint-disable-next-line @typescript-eslint/no-var-requires
305
- resolve ( require ( '@jupyter-widgets/controls' ) ) ;
306
- } ,
307
- ( err : any ) => {
308
- reject ( err ) ;
309
- } ,
310
- '@jupyter-widgets/controls'
311
- ) ;
312
- } ) ;
313
- } ,
314
- } ) ;
315
-
316
- WIDGET_REGISTRY . push ( {
317
- name : '@jupyter-widgets/output' ,
318
- version : OUTPUT_WIDGET_VERSION ,
319
- exports : { OutputModel, OutputView } ,
320
- } ) ;
321
-
322
281
return {
323
282
registerWidget ( data : base . IWidgetRegistryData ) : void {
324
283
WIDGET_REGISTRY . push ( data ) ;
325
284
} ,
326
285
} ;
327
286
}
328
287
288
+ /**
289
+ * The base widgets.
290
+ */
291
+ export const baseWidgetsPlugin : JupyterFrontEndPlugin < void > = {
292
+ id : `@jupyter-widgets/jupyterlab-manager:base-${ base . JUPYTER_WIDGETS_VERSION } ` ,
293
+ requires : [ base . IJupyterWidgetRegistry ] ,
294
+ autoStart : true ,
295
+ activate : (
296
+ app : JupyterFrontEnd ,
297
+ registry : base . IJupyterWidgetRegistry
298
+ ) : void => {
299
+ registry . registerWidget ( {
300
+ name : '@jupyter-widgets/base' ,
301
+ version : base . JUPYTER_WIDGETS_VERSION ,
302
+ exports : {
303
+ WidgetModel : base . WidgetModel ,
304
+ WidgetView : base . WidgetView ,
305
+ DOMWidgetView : base . DOMWidgetView ,
306
+ DOMWidgetModel : base . DOMWidgetModel ,
307
+ LayoutModel : base . LayoutModel ,
308
+ LayoutView : base . LayoutView ,
309
+ StyleModel : base . StyleModel ,
310
+ StyleView : base . StyleView ,
311
+ ErrorWidgetView : base . ErrorWidgetView ,
312
+ } ,
313
+ } ) ;
314
+ } ,
315
+ } ;
316
+
317
+ /**
318
+ * The control widgets.
319
+ */
320
+ export const controlWidgetsPlugin : JupyterFrontEndPlugin < void > = {
321
+ id : `@jupyter-widgets/jupyterlab-manager:controls-${ JUPYTER_CONTROLS_VERSION } ` ,
322
+ requires : [ base . IJupyterWidgetRegistry ] ,
323
+ autoStart : true ,
324
+ activate : (
325
+ app : JupyterFrontEnd ,
326
+ registry : base . IJupyterWidgetRegistry
327
+ ) : void => {
328
+ registry . registerWidget ( {
329
+ name : '@jupyter-widgets/controls' ,
330
+ version : JUPYTER_CONTROLS_VERSION ,
331
+ exports : ( ) => {
332
+ return new Promise ( ( resolve , reject ) => {
333
+ ( require as any ) . ensure (
334
+ [ '@jupyter-widgets/controls' ] ,
335
+ ( require : NodeRequire ) => {
336
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
337
+ resolve ( require ( '@jupyter-widgets/controls' ) ) ;
338
+ } ,
339
+ ( err : any ) => {
340
+ reject ( err ) ;
341
+ } ,
342
+ '@jupyter-widgets/controls'
343
+ ) ;
344
+ } ) ;
345
+ } ,
346
+ } ) ;
347
+ } ,
348
+ } ;
349
+
350
+ /**
351
+ * The output widget.
352
+ */
353
+ export const outputWidgetPlugin : JupyterFrontEndPlugin < void > = {
354
+ id : `@jupyter-widgets/jupyterlab-manager:output-${ OUTPUT_WIDGET_VERSION } ` ,
355
+ requires : [ base . IJupyterWidgetRegistry ] ,
356
+ autoStart : true ,
357
+ activate : (
358
+ app : JupyterFrontEnd ,
359
+ registry : base . IJupyterWidgetRegistry
360
+ ) : void => {
361
+ registry . registerWidget ( {
362
+ name : '@jupyter-widgets/output' ,
363
+ version : OUTPUT_WIDGET_VERSION ,
364
+ exports : { OutputModel, OutputView } ,
365
+ } ) ;
366
+ } ,
367
+ } ;
368
+
369
+ export default [
370
+ managerPlugin ,
371
+ baseWidgetsPlugin ,
372
+ controlWidgetsPlugin ,
373
+ outputWidgetPlugin ,
374
+ ] ;
329
375
namespace Private {
330
376
/**
331
377
* A private attached property for a widget manager.
0 commit comments