Skip to content

Commit 3aaf77e

Browse files
committed
Add resoruces
1 parent 58b06d5 commit 3aaf77e

File tree

6 files changed

+96
-24
lines changed

6 files changed

+96
-24
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 DonJayamanne
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

icon.png

87.4 KB
Loading

package.json

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,45 @@
22
"name": "typescript-notebook",
33
"publisher": "donjayamanne",
44
"displayName": "TypeScript Notebook",
5-
"description": "TypeScript Notebook",
6-
"version": "0.0.1",
5+
"description": "Jupyter notebook support for TypeScript",
6+
"version": "1.0.0",
77
"engines": {
88
"vscode": "^1.53.0"
99
},
10-
"categories": [
11-
"Other"
10+
"author": {
11+
"name": "Don Jayamanne"
12+
},
13+
"license": "MIT",
14+
"homepage": "https://github.com/DonJayamanne/typescript-notebook",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/DonJayamanne/typescript-notebook"
18+
},
19+
"bugs": {
20+
"url": "https://github.com/DonJayamanne/typescript-notebook/issues"
21+
},
22+
"qna": "https://stackoverflow.com/questions/tagged/visual-studio-code+jupyter",
23+
"icon": "icon.png",
24+
"galleryBanner": {
25+
"color": "#ffffff",
26+
"theme": "light"
27+
},
28+
"keywords": [
29+
"jupyter",
30+
"notebook",
31+
"ipynb",
32+
"multi-root ready",
33+
"typescript"
34+
],
35+
"categories": [
36+
"Programming Languages",
37+
"Other",
38+
"Data Science",
39+
"Machine Learning",
40+
"Notebooks"
41+
],
42+
"extensionDependencies": [
43+
"ms-toolsai.jupyter"
1244
],
1345
"activationEvents": [
1446
"*",

resources/quickstart.gif

793 KB
Loading

src/extension.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
import {
22
commands,
33
ExtensionContext,
4-
extensions,
54
OutputChannel,
65
window,
76
} from "vscode";
87
import { installTslab } from "./installer";
8+
import { optIntoNativeNotebooks, registerWithJupyter } from "./jupyterExtension";
99
import { installKernelSpec } from "./kernel";
1010
import { logError, setOutputWindow, showLog } from "./logger";
11-
import { IJupyterExtensionApi } from "./types";
1211
import { noop } from "./utils";
1312

1413
export async function activate(context: ExtensionContext) {
1514
const outputChannel = window.createOutputChannel("TypeScript Notebook");
1615
setOutputWindow(outputChannel);
1716
// Install kernel (silently) as soon as extension activates.
18-
Promise.all([installTslab(outputChannel), installKernelSpec()]).catch(noop);
19-
registerWithJupyter().catch(noop);
17+
Promise.all([
18+
installTslab(outputChannel),
19+
installKernelSpec(),
20+
registerWithJupyter(),
21+
optIntoNativeNotebooks(),
22+
installKernelSpec()]).catch(noop);
2023
registerCommands(context, outputChannel);
2124
}
2225

@@ -49,21 +52,5 @@ async function installKernel(outputChannel: OutputChannel) {
4952
}
5053
}
5154

52-
async function registerWithJupyter() {
53-
const jupyter = extensions.getExtension<IJupyterExtensionApi>(
54-
"ms-toolsai.jupyter"
55-
);
56-
if (!jupyter) {
57-
return;
58-
}
59-
if (!jupyter.isActive) {
60-
await jupyter.activate();
61-
}
62-
if (jupyter.exports.registerNewNotebookContent) {
63-
jupyter.exports.registerNewNotebookContent({
64-
defaultCellLanguage: "typescript",
65-
});
66-
}
67-
}
6855
// this method is called when your extension is deactivated
6956
export function deactivate() {}

src/jupyterExtension.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { ConfigurationTarget, extensions, workspace } from "vscode";
2+
import { logMessage } from "./logger";
3+
import { IJupyterExtensionApi } from "./types";
4+
5+
export async function registerWithJupyter() {
6+
const jupyter = extensions.getExtension<IJupyterExtensionApi>(
7+
"ms-toolsai.jupyter"
8+
);
9+
if (!jupyter) {
10+
return;
11+
}
12+
if (!jupyter.isActive) {
13+
await jupyter.activate();
14+
}
15+
if (jupyter.exports.registerNewNotebookContent) {
16+
jupyter.exports.registerNewNotebookContent({
17+
defaultCellLanguage: "typescript",
18+
});
19+
}
20+
}
21+
22+
export async function optIntoNativeNotebooks(){
23+
const settings = workspace.getConfiguration('jupyter', undefined);
24+
const optInto = settings.get<string[]>('experiments.optInto');
25+
if (!Array.isArray(optInto) || optInto.includes('All') || optInto.includes('__NativeNotebookEditor__')){
26+
logMessage('Native Notebook already setup');
27+
return;
28+
}
29+
optInto.push('__NativeNotebookEditor__');
30+
logMessage('Setting up Native Notebooks');
31+
await settings.update('experiments.optInto', optInto, ConfigurationTarget.Global);
32+
}

0 commit comments

Comments
 (0)