Skip to content

Commit 972639e

Browse files
Merge pull request #19 from oslabs-beta/AL/js-to-ts
javascript to typescript
2 parents f6f2a5a + 5e5f8a0 commit 972639e

22 files changed

+362
-179
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
/build
2+
/build
3+
/package-lock.json

package-lock.json

Lines changed: 74 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,31 @@
33
"displayName": "React Labyrinth",
44
"description": "React Server Components visualization tool",
55
"version": "0.0.1",
6+
"publisher": "ReactLabyrinthDev",
67
"engines": {
78
"vscode": "^1.84.0"
89
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/oslabs-beta/React-Labyrinth"
13+
},
914
"categories": [
1015
"Other"
1116
],
17+
"keywords": [
18+
"react",
19+
"rsc",
20+
"hierarchy tree",
21+
"parent-child",
22+
"visualizer",
23+
"server component"
24+
],
25+
"license": "MIT",
1226
"pricing": "Free",
1327
"activationEvents": [],
14-
"main": "./extension.js",
28+
"main": "./build/extension.js",
1529
"contributes": {
1630
"commands": [
17-
{
18-
"command": "react-labyrinth.helloWorld",
19-
"title": "Hello World",
20-
"category": "React Labyrinth"
21-
},
2231
{
2332
"command": "myExtension.showPanel",
2433
"title": "Show Panel",
@@ -68,6 +77,8 @@
6877
"devDependencies": {
6978
"@types/mocha": "^10.0.3",
7079
"@types/node": "18.x",
80+
"@types/react": "^18.2.45",
81+
"@types/react-dom": "^18.2.18",
7182
"@types/vscode": "^1.84.0",
7283
"@vscode/test-electron": "^2.3.6",
7384
"eslint": "^8.54.0",
@@ -76,7 +87,7 @@
7687
"postcss-loader": "^7.3.3",
7788
"postcss-preset-env": "^9.3.0",
7889
"tailwindcss": "^3.3.6",
79-
"typescript": "^5.2.2",
90+
"typescript": "^5.3.3",
8091
"webpack-cli": "^5.1.4"
8192
},
8293
"dependencies": {
@@ -92,6 +103,7 @@
92103
"reactflow": "^11.10.1",
93104
"sass-loader": "^13.3.2",
94105
"style-loader": "^3.3.3",
106+
"ts-loader": "^9.5.1",
95107
"webpack": "^5.89.0"
96108
}
97109
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const tailwindcss = require('tailwindcss');
2+
23
module.exports = {
34
plugins: [
45
'postcss-preset-env',
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
const vscode = require('vscode');
2-
const { createPanel } = require('./src/panel');
3-
const { Parser } = require('./src/parser');
1+
import * as vscode from 'vscode';
2+
import {createPanel} from './panel';
3+
import { Parser } from './parser';
44

55
// This method is called when your extension is activated
66
// Your extension is activated the very first time the command is executed
77

8-
function activate(context) {
8+
function activate(context: vscode.ExtensionContext) {
99

1010
let disposable = vscode.commands.registerCommand('react-labyrinth.helloWorld', function () {
1111
vscode.window.showInformationMessage('Hello World from React Labyrinth!');
1212
});
1313

1414
// pass in the command we want to register (refer to package.json)
15-
let result = vscode.commands.registerCommand('myExtension.showPanel', () => {
16-
// call helper func
17-
createPanel(context);
18-
});
15+
// let result = vscode.commands.registerCommand('myExtension.showPanel', () => {
16+
// // call helper func
17+
// createPanel(context);
18+
// });
1919

2020
vscode.commands.registerCommand('myExtension.pickFile', async () => {
2121
const fileArray = await vscode.window.showOpenDialog({ canSelectFolders: false, canSelectFiles: true, canSelectMany: false });
22+
23+
if (!fileArray || fileArray.length === 0) {
24+
vscode.window.showErrorMessage('No file selected');
25+
return;
26+
}
27+
2228
const tree = new Parser(fileArray[0].path);
2329
tree.parse();
2430
const data = tree.getTree();
2531
console.log('Data sent back: \n', data);
2632
createPanel(context, data);
2733
});
28-
context.subscriptions.push(disposable, result);
34+
context.subscriptions.push(disposable);
2935
}
3036

3137
// This method is called when your extension is deactivated
32-
// function deactivate() {}
38+
function deactivate() {}
3339

3440
module.exports = {
3541
activate,
36-
// deactivate
42+
deactivate
3743
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
function getNonce() {
2-
let text = "";
3-
const possible =
1+
export function getNonce() {
2+
let text: string = "";
3+
const possible: string =
44
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
55
for (let i = 0; i < 32; i++) {
66
text += possible.charAt(Math.floor(Math.random() * possible.length));
77
}
88
return text;
99
}
1010

11-
module.exports = { getNonce }

0 commit comments

Comments
 (0)