Skip to content

Commit 8fe04aa

Browse files
committed
moved extension.ts to src folder, modified webpack to align with import/export, declared types for strict ts guidlines, installed some dev dependencies
1 parent 9d852c9 commit 8fe04aa

8 files changed

+121
-33
lines changed

Diff for: package-lock.json

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"license": "MIT",
2626
"pricing": "Free",
2727
"activationEvents": [],
28-
"main": "./extension.ts",
29-
"type": "module",
28+
"main": "./build/extension.js",
3029
"contributes": {
3130
"commands": [
3231
{
@@ -83,6 +82,8 @@
8382
"devDependencies": {
8483
"@types/mocha": "^10.0.3",
8584
"@types/node": "18.x",
85+
"@types/react": "^18.2.45",
86+
"@types/react-dom": "^18.2.18",
8687
"@types/vscode": "^1.84.0",
8788
"@vscode/test-electron": "^2.3.6",
8889
"eslint": "^8.54.0",

Diff for: extension.ts renamed to src/extension.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as vscode from 'vscode';
2-
import {createPanel} from './src/panel';
2+
import {createPanel} from './panel';
33
// const { createPanel } = require('./src/panel');
44
// const { Parser } = require('./src/parser');
5-
import { Parser } from './src/parser';
5+
import { Parser } from './parser';
66

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

Diff for: src/panel.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function createPanel(context, data) {
3434
switch (msg.type) {
3535
case 'onData':
3636
if (!msg.value) break;
37-
context.workspaceState = context.workspaceState || {};
37+
// context.workspaceState = context.workspaceState || {};
3838
context.workspaceState.update('reactLabyrinth', msg.value);
3939
// console.log('msg.value from panel.js: ', msg.value);
4040
panel.webview.postMessage(

Diff for: src/webview/Flow.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,27 @@ const OverviewFlow: React.FC = () => {
5454
attributionPosition="top-right"
5555
>
5656
<MiniMap
57-
nodeStrokeColor={(n) => {
58-
if (n.style?.background) return n.style.background;
57+
nodeStrokeColor={(n): string => {
58+
if (n.style?.background) return `${n.style.background}`;
5959
if (n.data.label.props.className.includes('orange')) return "#fdba74";
6060
if (n.data.label.props.className.includes('blue')) return "#93C5FD";
6161
if (n.type === "default") return "#1a192b";
6262

6363
return "#eee";
6464
}}
65-
nodeColor={(n) => {
66-
if (n.style?.background) return n.style.background;
65+
nodeColor={(n): string => {
66+
if (n.style?.background) return `${n.style.background}`;
6767
return "#fff";
6868
}}
6969
nodeBorderRadius={2}
7070
/>
7171
<Panel position="top-left">
7272
<div className="text-black">
7373
<div className="flex justify-end place-items-end shadow-lg bg-slate-50 w-20 h-15">
74-
<p className="pl-2 pr-2 py-2">Client: <span className="bg-orange-300 text-transparent rounded-full">00</span></p>
74+
<p className="pl-2 pr-2 py-2">Client: <span className="bg-orange text-transparent rounded-full">00</span></p>
7575
</div>
7676
<div className="flex justify-end place-items-end shadow-lg bg-slate-50 w-20 h-15">
77-
<p className="pl-2 pr-2 pb-2">Server: <span className="bg-blue-300 text-transparent rounded-full">00</span></p>
77+
<p className="pl-2 pr-2 pb-2">Server: <span className="bg-blue text-transparent rounded-full">00</span></p>
7878
</div>
7979
</div>
8080
</Panel >

Diff for: tailwind.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
module.exports = {
22
content: ['./build/bundle.js'],
33
theme: {
4-
extend: {},
4+
extend: {
5+
backgroundColor: {
6+
orange: '#fdba74',
7+
blue: '#93C5FD',
8+
},
9+
},
510
},
611
variants: {
712
extend: {},

Diff for: tsconfig.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
"compilerOptions": {
33
"target": "es6",
44
"module": "commonjs",
5-
"outDir": "build",
5+
"outDir": "./build",
66
"esModuleInterop": true,
77
"lib": ["es6", "dom"],
88
"jsx": "react",
99
"sourceMap": true,
10-
"rootDir": "src",
10+
"rootDir": "./src",
1111
"allowJs": true,
1212
"strict": false,
1313
},
14-
"include": ["src", "src/types/index.d.ts"],
14+
// "include": ["src", "src/types/index.d.ts"],
15+
"include": ["src/**/*.ts", "src/**/*.tsx"],
1516
"exclude": [
1617
"node_modules",
1718
".vscode-test",

Diff for: webpack.config.ts

+59-18
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,73 @@
1+
// import * as path from 'path';
2+
3+
// module.exports = {
4+
// entry: './src/webview/index.tsx',
5+
// output: {
6+
// filename: 'bundle.js',
7+
// path: path.resolve(__dirname, './build'),
8+
// },
9+
// resolve: {
10+
// extensions: ['.js', '.ts', '.tsx', '.css'],
11+
// },
12+
// module: {
13+
// rules: [
14+
// // {
15+
// // test: /\.jsx?/,
16+
// // exclude: /node_modules/,
17+
// // use: {
18+
// // loader: "babel-loader",
19+
// // options: {
20+
// // presets: ['@babel/preset-env', '@babel/preset-react']
21+
// // }
22+
// // }
23+
// // },
24+
// { test: /\.tsx?$/, use: ['babel-loader', 'ts-loader'] },
25+
// {
26+
// test: /\.(css)$/,
27+
// use: ["style-loader", "css-loader", "postcss-loader"],
28+
// },
29+
// ]
30+
// },
31+
// mode: "development"
32+
// }
33+
134
import * as path from 'path';
35+
import * as webpack from 'webpack';
36+
37+
const extConfig: webpack.Configuration = {
38+
target: 'node',
39+
entry: './src/extension.ts',
40+
output: {
41+
filename: 'extension.js',
42+
libraryTarget: 'commonjs2',
43+
path: path.resolve(__dirname, 'build'),
44+
},
45+
resolve: { extensions: ['.ts', '.js'] },
46+
module: { rules: [{ test: /\.ts$/, loader: 'ts-loader' }] },
47+
externals: { vscode: 'vscode' },
48+
mode: 'development'
49+
};
250

3-
module.exports = {
51+
const webviewConfig: webpack.Configuration = {
52+
target: 'web',
453
entry: './src/webview/index.tsx',
554
output: {
655
filename: 'bundle.js',
7-
path: path.resolve(__dirname, './build'),
56+
path: path.resolve(__dirname, 'build'),
857
},
958
resolve: {
10-
extensions: ['.js', '.ts', '.tsx', '.css'],
59+
extensions: ['.js', '.ts', '.tsx', 'scss'],
1160
},
1261
module: {
1362
rules: [
14-
// {
15-
// test: /\.jsx?/,
16-
// exclude: /node_modules/,
17-
// use: {
18-
// loader: "babel-loader",
19-
// options: {
20-
// presets: ['@babel/preset-env', '@babel/preset-react']
21-
// }
22-
// }
23-
// },
2463
{ test: /\.tsx?$/, use: ['babel-loader', 'ts-loader'] },
2564
{
26-
test: /\.(css)$/,
27-
use: ["style-loader", "css-loader", "postcss-loader"],
65+
test: /\.css$/,
66+
use: ['style-loader', 'css-loader'],
2867
},
29-
]
68+
],
3069
},
31-
mode: "development"
32-
}
70+
mode: 'development'
71+
};
72+
73+
export default [webviewConfig, extConfig];

0 commit comments

Comments
 (0)