@@ -23,20 +23,20 @@ import { IFileService } from 'vs/platform/files/common/files';
2323import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
2424import { IStorageService , StorageScope , StorageTarget } from 'vs/platform/storage/common/storage' ;
2525import { 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' ;
2727import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
2828import { NotebookDiffEditorInput } from 'vs/workbench/contrib/notebook/common/notebookDiffEditorInput' ;
2929import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel' ;
3030import { 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' ;
3232import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput' ;
3333import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService' ;
3434import { 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' ;
3636import { NotebookEditorDescriptor , NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookProvider' ;
3737import { ComplexNotebookProviderInfo , INotebookContentProvider , INotebookSerializer , INotebookService , SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService' ;
3838import { 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' ;
4040import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry' ;
4141
4242export class NotebookProviderInfoStore extends Disposable {
@@ -422,6 +422,9 @@ export class NotebookService extends Disposable implements INotebookService {
422422 private readonly _notebookRenderersInfoStore = this . _instantiationService . createInstance ( NotebookOutputRendererInfoStore ) ;
423423 private readonly _onDidChangeOutputRenderers = this . _register ( new Emitter < void > ( ) ) ;
424424 readonly onDidChangeOutputRenderers = this . _onDidChangeOutputRenderers . event ;
425+
426+ private readonly _notebookStaticPreloadInfoStore = new Set < NotebookStaticPreloadInfo > ( ) ;
427+
425428 private readonly _models = new ResourceMap < ModelData > ( ) ;
426429
427430 private readonly _onWillAddNotebookDocument = this . _register ( new Emitter < NotebookTextModel > ( ) ) ;
@@ -490,6 +493,35 @@ export class NotebookService extends Disposable implements INotebookService {
490493 this . _onDidChangeOutputRenderers . fire ( ) ;
491494 } ) ;
492495
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+
493525 const updateOrder = ( ) => {
494526 this . _displayOrder = new MimeTypeDisplayOrder (
495527 this . _configurationService . getValue < string [ ] > ( NotebookSetting . displayOrder ) || [ ] ,
@@ -671,6 +703,14 @@ export class NotebookService extends Disposable implements INotebookService {
671703 return this . _notebookRenderersInfoStore . getAll ( ) ;
672704 }
673705
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+
674714 // --- notebook documents: create, destory, retrieve, enumerate
675715
676716 createNotebookTextModel ( viewType : string , uri : URI , data : NotebookData , transientOptions : TransientOptions ) : NotebookTextModel {
0 commit comments