-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re #142429. Image renderer moved to extension.
- Loading branch information
Showing
14 changed files
with
162 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
renderer-out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Builtin Notebook Output Renderers for Visual Studio Code | ||
|
||
**Notice:** This extension is bundled with Visual Studio Code. It can be disabled but not uninstalled. | ||
|
||
## Features | ||
|
||
This extension provides the following notebook renderers for VS Code: | ||
|
||
- Image renderer for png, jpeg and gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
const path = require('path'); | ||
const esbuild = require('esbuild'); | ||
|
||
const args = process.argv.slice(2); | ||
|
||
const isWatch = args.indexOf('--watch') >= 0; | ||
|
||
let outputRoot = __dirname; | ||
const outputRootIndex = args.indexOf('--outputRoot'); | ||
if (outputRootIndex >= 0) { | ||
outputRoot = args[outputRootIndex + 1]; | ||
} | ||
|
||
const outDir = path.join(outputRoot, 'renderer-out'); | ||
|
||
esbuild.build({ | ||
entryPoints: [ | ||
path.join(__dirname, 'src', 'index.ts'), | ||
], | ||
bundle: true, | ||
minify: true, | ||
sourcemap: false, | ||
format: 'esm', | ||
outdir: outDir, | ||
platform: 'browser', | ||
target: ['es2020'], | ||
incremental: isWatch, | ||
}).catch(() => process.exit(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "builtin-notebook-renderers", | ||
"displayName": "%displayName%", | ||
"description": "%description%", | ||
"publisher": "vscode", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"engines": { | ||
"vscode": "^1.57.0" | ||
}, | ||
"capabilities": { | ||
"virtualWorkspaces": true, | ||
"untrustedWorkspaces": { | ||
"supported": true | ||
} | ||
}, | ||
"contributes": { | ||
"notebookRenderer": [ | ||
{ | ||
"id": "vscode-builtin-notebook-renderer", | ||
"entrypoint": "./renderer-out/index.js", | ||
"displayName": "VS Code Builtin Notebook Output Renderer", | ||
"requiresMessaging": "never", | ||
"mimeTypes": [ | ||
"image/gif", | ||
"image/png", | ||
"image/jpeg" | ||
] | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"compile": "npm run build-notebook", | ||
"watch": "node ./esbuild --watch", | ||
"build-notebook": "node ./esbuild" | ||
}, | ||
"dependencies": { | ||
}, | ||
"devDependencies": { | ||
"@types/vscode-notebook-renderer": "^1.60.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/microsoft/vscode.git" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"displayName": "Builtin Notebook Output Renderers", | ||
"description": "Provides basic output renderers for notebooks" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import type { ActivationFunction } from 'vscode-notebook-renderer'; | ||
|
||
interface IDisposable { | ||
dispose(): void; | ||
} | ||
|
||
export const activate: ActivationFunction<void> = (_ctx) => { | ||
const disposables = new Map<string, IDisposable>(); | ||
|
||
return { | ||
renderOutputItem: (outputInfo, element) => { | ||
const blob = new Blob([outputInfo.data()], { type: outputInfo.mime }); | ||
const src = URL.createObjectURL(blob); | ||
const disposable = { | ||
dispose: () => { | ||
URL.revokeObjectURL(src); | ||
} | ||
}; | ||
|
||
const image = document.createElement('img'); | ||
image.src = src; | ||
const display = document.createElement('div'); | ||
display.classList.add('display'); | ||
display.appendChild(image); | ||
element.appendChild(display); | ||
|
||
disposables.set(outputInfo.id, disposable); | ||
}, | ||
disposeOutputItem: (id: string | undefined) => { | ||
if (id) { | ||
disposables.get(id)?.dispose(); | ||
} else { | ||
disposables.forEach(d => d.dispose()); | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "./out", | ||
"lib": [ | ||
"dom" | ||
] | ||
}, | ||
"include": [ | ||
"src/**/*", | ||
"../../src/vscode-dts/vscode.d.ts", | ||
"../../src/vscode-dts/vscode.proposed.notebookEditor.d.ts", | ||
"../../src/vscode-dts/vscode.proposed.notebookEditorEdit.d.ts", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@types/vscode-notebook-renderer@^1.60.0": | ||
version "1.60.0" | ||
resolved "https://registry.yarnpkg.com/@types/vscode-notebook-renderer/-/vscode-notebook-renderer-1.60.0.tgz#8a67d561f48ddf46a95dfa9f712a79c72c7b8f7a" | ||
integrity sha512-u7TD2uuEZTVuitx0iijOJdKI0JLiQP6PsSBSRy2XmHXUOXcp5p1S56NrjOEDoF+PIHd3NL3eO6KTRSf5nukDqQ== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters