Skip to content

Commit 9a66c04

Browse files
merged new tests
2 parents f77adbf + ffeb6ff commit 9a66c04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+702
-362
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"rules": {
1717
"no-const-assign": "warn",
1818
"no-this-before-super": "warn",
19-
"no-undef": "warn",
19+
"no-undef": "off",
2020
"no-unreachable": "warn",
2121
"no-unused-vars": "off",
2222
"constructor-super": "warn",

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
node_modules
1+
/node_modules/
22
/package-lock.json
33
/.vscode-test/
4-
/build/
4+
/build/
5+
/.DS_Store

.vscodeignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
# FOLDERS
12
.vscode/**
23
.vscode-test/**
34
test/**
4-
.gitignore
5-
.yarnrc
6-
vsc-extension-quickstart.md
5+
node_modules
76
**/jsconfig.json
87
**/*.map
98
**/.eslintrc.json
9+
10+
# FILES
11+
.gitignore
12+
.yarnrc
13+
vsc-extension-quickstart.md
1014
**/*.js.map
15+

media/RL(Final).png

301 KB
Loading

package-lock.json

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

package.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
{
22
"name": "react-labyrinth",
33
"displayName": "React Labyrinth",
4-
"description": "React Server Components visualization tool",
4+
"description": "React Component Type hierarchy tree visualization tool",
55
"version": "0.0.1",
6+
"icon": "./media/reactLbayrinthFinal.png",
67
"publisher": "ReactLabyrinthDev",
8+
"preview": false,
79
"engines": {
810
"vscode": "^1.85.1"
911
},
1012
"repository": {
1113
"type": "git",
12-
"url": "https://github.com/oslabs-beta/React-Labyrinth"
14+
"url": "https://github.com/oslabs-beta/React-Labyrinth/tree/main"
1315
},
1416
"categories": [
1517
"Other"
1618
],
1719
"keywords": [
1820
"react",
1921
"rsc",
22+
"react components",
2023
"hierarchy tree",
2124
"parent-child",
2225
"visualizer",
23-
"server component"
26+
"server component",
27+
"client component"
2428
],
2529
"license": "MIT",
2630
"pricing": "Free",
27-
"activationEvents": [],
31+
"activationEvents": [
32+
"onStartupFinished"
33+
],
2834
"main": "./build/extension.js",
2935
"contributes": {
3036
"commands": [
@@ -44,30 +50,27 @@
4450
{
4551
"id": "react-labyrinth",
4652
"title": "React Labyrinth",
47-
"icon": "/media/test1.svg"
53+
"icon": "/media/RL(Final).png"
4854
}
4955
]
5056
},
5157
"views": {
5258
"react-labyrinth": [
5359
{
54-
"id": "metrics-file",
55-
"name": "Metrics"
56-
},
57-
{
58-
"id": "test",
59-
"name": "Test"
60+
"id": "tree-render",
61+
"name": "Tree"
6062
}
6163
]
6264
},
6365
"viewsWelcome": [
6466
{
65-
"view": "metrics-file",
66-
"contents": "View tree to see where improvements can be made!\n[View Tree](command:myExtension.pickFile)\n"
67+
"view": "tree-render",
68+
"contents": "View tree to see component types!\n[View Tree](command:myExtension.pickFile)\n"
6769
}
6870
]
6971
},
7072
"scripts": {
73+
"vscode:prepublish": "prod",
7174
"lint": "eslint .",
7275
"pretest": "npm run lint",
7376
"test": "npx tsc ; node ./build/src/test/runTest.js",
@@ -97,7 +100,7 @@
97100
},
98101
"dependencies": {
99102
"@babel/core": "^7.23.3",
100-
"@babel/parser": "^7.23.4",
103+
"@babel/parser": "^7.23.9",
101104
"@babel/preset-env": "^7.23.3",
102105
"@babel/preset-react": "^7.23.3",
103106
"babel": "^6.23.0",

src/extension.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import * as vscode from 'vscode';
22
import {createPanel} from './panel';
33
import { Parser } from './parser';
44
import { Tree } from './types/tree';
5+
import { showNotification } from './utils/modal';
56

67
let tree: Parser | undefined = undefined;
7-
let panel: vscode.WebviewPanel | undefined = undefined
8+
let panel: vscode.WebviewPanel | undefined = undefined;
89

910
// This method is called when your extension is activated
1011
// Your extension is activated the very first time the command is executed
@@ -14,37 +15,31 @@ function activate(context: vscode.ExtensionContext) {
1415
let columnToShowIn : vscode.ViewColumn | undefined = vscode.window.activeTextEditor
1516
? vscode.window.activeTextEditor.viewColumn
1617
: undefined;
17-
1818

1919
// Command that allows for User to select the root file of their React application.
2020
const pickFile: vscode.Disposable = vscode.commands.registerCommand('myExtension.pickFile', async () => {
21-
2221
// Check if there is an existing webview panel, if so display it.
23-
if(panel) {
24-
panel.reveal(columnToShowIn)
22+
if (panel) {
23+
panel.reveal(columnToShowIn);
2524
}
2625

27-
2826
// Opens window for the User to select the root file of React application
2927
const fileArray: vscode.Uri[] = await vscode.window.showOpenDialog({ canSelectFolders: false, canSelectFiles: true, canSelectMany: false });
30-
3128

3229
// Throw error message if no file was selected
3330
if (!fileArray || fileArray.length === 0) {
34-
vscode.window.showErrorMessage('No file selected');
31+
showNotification({message: 'No file selected'});
3532
return;
3633
}
37-
3834

3935
// Create Tree to be inserted into returned HTML
4036
tree = new Parser(fileArray[0].path);
4137
tree.parse();
4238
const data: Tree = tree.getTree();
4339

44-
4540
// Check if panel currently has a webview, if it does dispose of it and create another with updated root file selected.
4641
// Otherwise create a new webview to display root file selected.
47-
if(!panel) {
42+
if (!panel) {
4843
panel = createPanel(context, data, columnToShowIn);
4944
} else {
5045
panel.dispose()
@@ -54,23 +49,19 @@ function activate(context: vscode.ExtensionContext) {
5449
// Listens for when webview is closed and disposes of webview resources
5550
panel.onDidDispose(
5651
() => {
57-
console.log("Before: ", panel)
58-
panel.dispose()
52+
panel.dispose();
5953
panel = undefined;
6054
columnToShowIn = undefined;
61-
console.log("After: ", panel)
6255
},
6356
null,
6457
context.subscriptions
65-
);
58+
);
6659
});
6760

68-
6961
// Command to show panel if it is hidden
7062
const showPanel: vscode.Disposable = vscode.commands.registerCommand('myExtension.showPanel', () => {
71-
panel.reveal(columnToShowIn)
72-
});
73-
63+
panel.reveal(columnToShowIn);
64+
});
7465

7566
context.subscriptions.push(pickFile, showPanel);
7667
}

src/panel.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import * as vscode from 'vscode';
2-
import { getNonce } from './getNonce';
2+
import { getNonce } from './utils/getNonce';
33
import { Tree } from './types/tree';
44

5-
let panel: vscode.WebviewPanel | undefined = undefined
5+
let panel: vscode.WebviewPanel | undefined = undefined;
66

77
export function createPanel(context: vscode.ExtensionContext, data: Tree, columnToShowIn: vscode.ViewColumn) {
8-
9-
// utilize method on vscode.window object to create webview
8+
// Utilize method on vscode.window object to create webview
109
panel = vscode.window.createWebviewPanel(
1110
'reactLabyrinth',
1211
'React Labyrinth',
13-
// create one new tab
12+
// Create one tab
1413
vscode.ViewColumn.One,
1514
{
1615
enableScripts: true,
@@ -19,15 +18,15 @@ export function createPanel(context: vscode.ExtensionContext, data: Tree, column
1918
);
2019

2120
// Set the icon logo of extension webview
22-
panel.iconPath = vscode.Uri.joinPath(context.extensionUri, 'media', 'favicon.ico');
21+
panel.iconPath = vscode.Uri.joinPath(context.extensionUri, 'media', 'RL(Final).png');
2322

2423
// Set URI to be the path to bundle
2524
const bundlePath: vscode.Uri = vscode.Uri.joinPath(context.extensionUri, 'build', 'bundle.js');
2625

27-
// set webview URI to pass into html script
26+
// Set webview URI to pass into html script
2827
const bundleURI: vscode.Uri = panel.webview.asWebviewUri(bundlePath);
2928

30-
// render html of webview here
29+
// Render html of webview here
3130
panel.webview.html = createWebviewHTML(bundleURI, data);
3231

3332
// Sends data to Flow.tsx to be displayed after parsed data is received
@@ -37,7 +36,6 @@ export function createPanel(context: vscode.ExtensionContext, data: Tree, column
3736
case 'onData':
3837
if (!msg.value) break;
3938
context.workspaceState.update('reactLabyrinth', msg.value);
40-
4139
panel.webview.postMessage(
4240
{
4341
type: 'parsed-data',
@@ -54,10 +52,10 @@ export function createPanel(context: vscode.ExtensionContext, data: Tree, column
5452
return panel
5553
};
5654

57-
// getNonce generates a new random string each time ext is used to prevent external injection of foreign code into the html
55+
// getNonce generates a new random string to prevent external injection of foreign code into the HTML
5856
const nonce: string = getNonce();
5957

60-
// function to create the HTML page for webview
58+
// Creates the HTML page for webview
6159
function createWebviewHTML(URI: vscode.Uri, initialData: Tree) : string {
6260
return (
6361
`
@@ -83,5 +81,5 @@ function createWebviewHTML(URI: vscode.Uri, initialData: Tree) : string {
8381
</body>
8482
</html>
8583
`
86-
)
84+
);
8785
}

0 commit comments

Comments
 (0)