@@ -23,20 +23,20 @@ import { IFileService } from 'vs/platform/files/common/files';
23
23
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
24
24
import { IStorageService , StorageScope , StorageTarget } from 'vs/platform/storage/common/storage' ;
25
25
import { Memento } from 'vs/workbench/common/memento' ;
26
- import { INotebookEditorContribution , notebookRendererExtensionPoint , notebooksExtensionPoint } from 'vs/workbench/contrib/notebook/browser/notebookExtensionPoint' ;
26
+ import { INotebookEditorContribution , notebookPreloadExtensionPoint , notebookRendererExtensionPoint , notebooksExtensionPoint } from 'vs/workbench/contrib/notebook/browser/notebookExtensionPoint' ;
27
27
import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
28
28
import { NotebookDiffEditorInput } from 'vs/workbench/contrib/notebook/common/notebookDiffEditorInput' ;
29
29
import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel' ;
30
30
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel' ;
31
- import { ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER , CellUri , NotebookSetting , INotebookContributionData , INotebookExclusiveDocumentFilter , INotebookRendererInfo , INotebookTextModel , IOrderedMimeType , IOutputDto , MimeTypeDisplayOrder , NotebookData , NotebookEditorPriority , NotebookRendererMatch , NOTEBOOK_DISPLAY_ORDER , RENDERER_EQUIVALENT_EXTENSIONS , RENDERER_NOT_AVAILABLE , TransientOptions , NotebookExtensionDescription } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
31
+ import { ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER , CellUri , NotebookSetting , INotebookContributionData , INotebookExclusiveDocumentFilter , INotebookRendererInfo , INotebookTextModel , IOrderedMimeType , IOutputDto , MimeTypeDisplayOrder , NotebookData , NotebookEditorPriority , NotebookRendererMatch , NOTEBOOK_DISPLAY_ORDER , RENDERER_EQUIVALENT_EXTENSIONS , RENDERER_NOT_AVAILABLE , TransientOptions , NotebookExtensionDescription , INotebookStaticPreloadInfo } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
32
32
import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput' ;
33
33
import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService' ;
34
34
import { updateEditorTopPadding } from 'vs/workbench/contrib/notebook/common/notebookOptions' ;
35
- import { NotebookOutputRendererInfo } from 'vs/workbench/contrib/notebook/common/notebookOutputRenderer' ;
35
+ import { NotebookOutputRendererInfo , NotebookStaticPreloadInfo as NotebookStaticPreloadInfo } from 'vs/workbench/contrib/notebook/common/notebookOutputRenderer' ;
36
36
import { NotebookEditorDescriptor , NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider' ;
37
37
import { ComplexNotebookProviderInfo , INotebookContentProvider , INotebookSerializer , INotebookService , SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService' ;
38
38
import { DiffEditorInputFactoryFunction , EditorInputFactoryFunction , EditorInputFactoryObject , IEditorResolverService , IEditorType , RegisteredEditorInfo , RegisteredEditorPriority , UntitledEditorInputFactoryFunction } from 'vs/workbench/services/editor/common/editorResolverService' ;
39
- import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
39
+ import { IExtensionService , isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions' ;
40
40
import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry' ;
41
41
42
42
export class NotebookProviderInfoStore extends Disposable {
@@ -422,6 +422,9 @@ export class NotebookService extends Disposable implements INotebookService {
422
422
private readonly _notebookRenderersInfoStore = this . _instantiationService . createInstance ( NotebookOutputRendererInfoStore ) ;
423
423
private readonly _onDidChangeOutputRenderers = this . _register ( new Emitter < void > ( ) ) ;
424
424
readonly onDidChangeOutputRenderers = this . _onDidChangeOutputRenderers . event ;
425
+
426
+ private readonly _notebookStaticPreloadInfoStore = new Set < NotebookStaticPreloadInfo > ( ) ;
427
+
425
428
private readonly _models = new ResourceMap < ModelData > ( ) ;
426
429
427
430
private readonly _onWillAddNotebookDocument = this . _register ( new Emitter < NotebookTextModel > ( ) ) ;
@@ -490,6 +493,35 @@ export class NotebookService extends Disposable implements INotebookService {
490
493
this . _onDidChangeOutputRenderers . fire ( ) ;
491
494
} ) ;
492
495
496
+ notebookPreloadExtensionPoint . setHandler ( extensions => {
497
+ this . _notebookStaticPreloadInfoStore . clear ( ) ;
498
+
499
+ for ( const extension of extensions ) {
500
+ if ( ! isProposedApiEnabled ( extension . description , 'contribNotebookStaticPreloads' ) ) {
501
+ continue ;
502
+ }
503
+
504
+ for ( const notebookContribution of extension . value ) {
505
+ if ( ! notebookContribution . entrypoint ) { // avoid crashing
506
+ extension . collector . error ( `Notebook preload does not specify entry point` ) ;
507
+ continue ;
508
+ }
509
+
510
+ const type = notebookContribution . type ;
511
+ if ( ! type ) {
512
+ extension . collector . error ( `Notebook preload does not specify type-property` ) ;
513
+ continue ;
514
+ }
515
+
516
+ this . _notebookStaticPreloadInfoStore . add ( new NotebookStaticPreloadInfo ( {
517
+ type,
518
+ extension : extension . description ,
519
+ entrypoint : notebookContribution . entrypoint ,
520
+ } ) ) ;
521
+ }
522
+ }
523
+ } ) ;
524
+
493
525
const updateOrder = ( ) => {
494
526
this . _displayOrder = new MimeTypeDisplayOrder (
495
527
this . _configurationService . getValue < string [ ] > ( NotebookSetting . displayOrder ) || [ ] ,
@@ -671,6 +703,14 @@ export class NotebookService extends Disposable implements INotebookService {
671
703
return this . _notebookRenderersInfoStore . getAll ( ) ;
672
704
}
673
705
706
+ * getStaticPreloads ( viewType : string ) : Iterable < INotebookStaticPreloadInfo > {
707
+ for ( const preload of this . _notebookStaticPreloadInfoStore ) {
708
+ if ( preload . type === viewType ) {
709
+ yield preload ;
710
+ }
711
+ }
712
+ }
713
+
674
714
// --- notebook documents: create, destory, retrieve, enumerate
675
715
676
716
createNotebookTextModel ( viewType : string , uri : URI , data : NotebookData , transientOptions : TransientOptions ) : NotebookTextModel {
0 commit comments