src/vs/workbench/api/browser/mainThreadNotebookDocuments.ts/MainThreadNotebookDocuments/$tryCreateNotebook
class MainThreadNotebookDocuments:	async $tryCreateNotebook(options: { viewType: string, content?: NotebookDataDto }): Promise<UriComponents> {

		const info = this._notebookService.getContributedNotebookType(options.viewType);
		if (!info) {
			throw new Error('UNKNOWN view type: ' + options.viewType);
		}

		// find a free URI for the untitled case
		const suffix = NotebookProviderInfo.possibleFileEnding(info.selectors) ?? '';
		let uri: URI;
		for (let counter = 1; ; counter++) {
			let candidate = URI.from({ scheme: Schemas.untitled, path: `Untitled-${counter}${suffix}`, query: options.viewType });
			if (!this._notebookService.getNotebookTextModel(candidate)) {
				uri = candidate;
				break;
			}
		}

		const ref = await this._notebookEditorModelResolverService.resolve(uri, options.viewType);

		// untitled notebooks are disposed when they get saved. we should not hold a reference
		// to such a disposed notebook and therefore dispose the reference as well
		ref.object.notebook.onWillDispose(() => {
			ref.dispose();
		});

		// untitled notebooks are dirty by default
		this._proxy.$acceptDirtyStateChanged(uri, true);

		// apply content changes... slightly HACKY -> this triggers a change event
		if (options.content) {
			const data = NotebookDto.fromNotebookDataDto(options.content);
			ref.object.notebook.reset(data.cells, data.metadata, ref.object.notebook.transientOptions);
		}
		return uri;
	}