[sandbox] Clean up

This commit is contained in:
orosmatthew 2023-10-15 18:35:49 -04:00
parent 384bf03688
commit 74b9b50d8e
13 changed files with 547 additions and 486 deletions

View File

@ -0,0 +1,2 @@
node_modules
compiled

View File

@ -1,8 +1,8 @@
{ {
"tabWidth": 2, "useTabs": true,
"useTabs": true, "singleQuote": true,
"singleQuote": true, "trailingComma": "none",
"trailingComma": "none", "printWidth": 100,
"printWidth": 100, "plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."] "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
} }

View File

@ -1,5 +1,3 @@
{ {
"recommendations": [ "recommendations": ["dbaeumer.vscode-eslint"]
"dbaeumer.vscode-eslint"
]
} }

View File

@ -5,12 +5,8 @@
"name": "Run Extension", "name": "Run Extension",
"type": "extensionHost", "type": "extensionHost",
"request": "launch", "request": "launch",
"args": [ "args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"--extensionDevelopmentPath=${workspaceFolder}" "outFiles": ["${workspaceFolder}/out/**/*.js"]
], }
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
},
] ]
} }

View File

@ -1,9 +1,9 @@
{ {
"files.exclude": { "files.exclude": {
"out": false "out": false
}, },
"search.exclude": { "search.exclude": {
"out": true "out": true
}, },
"typescript.tsc.autoDetect": "off" "typescript.tsc.autoDetect": "off"
} }

View File

@ -11,28 +11,31 @@
"@vscode/vsce": "^2.21.1", "@vscode/vsce": "^2.21.1",
"axios": "^1.5.1", "axios": "^1.5.1",
"fs-extra": "^11.1.1", "fs-extra": "^11.1.1",
"tree-kill": "^1.2.2" "tree-kill": "^1.2.2",
"url-join": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^25.0.4", "@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.1", "@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.3", "@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.4", "@rollup/plugin-typescript": "^11.1.5",
"@tsconfig/svelte": "^5.0.2", "@tsconfig/svelte": "^5.0.2",
"@types/fs-extra": "^11.0.2", "@types/fs-extra": "^11.0.2",
"@types/glob": "^8.1.0", "@types/glob": "^8.1.0",
"@types/mocha": "^10.0.2", "@types/mocha": "^10.0.2",
"@types/node": "20.x", "@types/node": "20.x",
"@types/vscode": "^1.82.0", "@types/vscode": "^1.83.0",
"@typescript-eslint/eslint-plugin": "^6.7.4", "@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.4", "@typescript-eslint/parser": "^6.7.5",
"@vscode/test-electron": "^2.3.4", "@vscode/test-electron": "^2.3.5",
"concurrently": "^8.2.1", "concurrently": "^8.2.1",
"esbuild": "^0.19.4", "esbuild": "^0.19.4",
"eslint": "^8.50.0", "eslint": "^8.51.0",
"glob": "^10.3.10", "glob": "^10.3.10",
"mocha": "^10.2.0", "mocha": "^10.2.0",
"postcss": "^8.4.31", "postcss": "^8.4.31",
"prettier": "^3.0.3",
"prettier-plugin-svelte": "^3.0.3",
"rollup-plugin-css-only": "^4.3.0", "rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-postcss": "^4.0.2", "rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-svelte": "^7.1.6", "rollup-plugin-svelte": "^7.1.6",
@ -42,7 +45,7 @@
"typescript": "^5.2.2" "typescript": "^5.2.2"
}, },
"engines": { "engines": {
"vscode": "^1.81.0" "vscode": "^1.83.0"
} }
}, },
"node_modules/@aashutoshrathi/word-wrap": { "node_modules/@aashutoshrathi/word-wrap": {
@ -479,9 +482,9 @@
} }
}, },
"node_modules/@eslint/js": { "node_modules/@eslint/js": {
"version": "8.50.0", "version": "8.51.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.50.0.tgz", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.51.0.tgz",
"integrity": "sha512-NCC3zz2+nvYd+Ckfh87rA47zfu2QsQpvc6k1yzTk+b9KzRj0wkGa8LSoGOXN6Zv4lRf/EIoZ80biDh9HOI+RNQ==", "integrity": "sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0" "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -726,9 +729,9 @@
} }
}, },
"node_modules/@rollup/plugin-commonjs": { "node_modules/@rollup/plugin-commonjs": {
"version": "25.0.4", "version": "25.0.7",
"resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.4.tgz", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.7.tgz",
"integrity": "sha512-L92Vz9WUZXDnlQQl3EwbypJR4+DM2EbsO+/KOcEkP4Mc6Ct453EeDB2uH9lgRwj4w5yflgNpq9pHOiY8aoUXBQ==", "integrity": "sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@rollup/pluginutils": "^5.0.1", "@rollup/pluginutils": "^5.0.1",
@ -736,13 +739,13 @@
"estree-walker": "^2.0.2", "estree-walker": "^2.0.2",
"glob": "^8.0.3", "glob": "^8.0.3",
"is-reference": "1.2.1", "is-reference": "1.2.1",
"magic-string": "^0.27.0" "magic-string": "^0.30.3"
}, },
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"rollup": "^2.68.0||^3.0.0" "rollup": "^2.68.0||^3.0.0||^4.0.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"rollup": { "rollup": {
@ -778,6 +781,18 @@
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/@rollup/plugin-commonjs/node_modules/magic-string": {
"version": "0.30.5",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.5.tgz",
"integrity": "sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==",
"dev": true,
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@rollup/plugin-commonjs/node_modules/minimatch": { "node_modules/@rollup/plugin-commonjs/node_modules/minimatch": {
"version": "5.1.6", "version": "5.1.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
@ -791,9 +806,9 @@
} }
}, },
"node_modules/@rollup/plugin-node-resolve": { "node_modules/@rollup/plugin-node-resolve": {
"version": "15.2.1", "version": "15.2.3",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.1.tgz", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz",
"integrity": "sha512-nsbUg588+GDSu8/NS8T4UAshO6xeaOfINNuXeVHcKV02LJtoRaM1SiOacClw4kws1SFiNhdLGxlbMY9ga/zs/w==", "integrity": "sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@rollup/pluginutils": "^5.0.1", "@rollup/pluginutils": "^5.0.1",
@ -807,7 +822,7 @@
"node": ">=14.0.0" "node": ">=14.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"rollup": "^2.78.0||^3.0.0" "rollup": "^2.78.0||^3.0.0||^4.0.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"rollup": { "rollup": {
@ -816,9 +831,9 @@
} }
}, },
"node_modules/@rollup/plugin-terser": { "node_modules/@rollup/plugin-terser": {
"version": "0.4.3", "version": "0.4.4",
"resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.3.tgz", "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz",
"integrity": "sha512-EF0oejTMtkyhrkwCdg0HJ0IpkcaVg1MMSf2olHb2Jp+1mnLM04OhjpJWGma4HobiDTF0WCyViWuvadyE9ch2XA==", "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"serialize-javascript": "^6.0.1", "serialize-javascript": "^6.0.1",
@ -829,7 +844,7 @@
"node": ">=14.0.0" "node": ">=14.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"rollup": "^2.x || ^3.x" "rollup": "^2.0.0||^3.0.0||^4.0.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"rollup": { "rollup": {
@ -847,9 +862,9 @@
} }
}, },
"node_modules/@rollup/plugin-typescript": { "node_modules/@rollup/plugin-typescript": {
"version": "11.1.4", "version": "11.1.5",
"resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.4.tgz", "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.1.5.tgz",
"integrity": "sha512-WZRh5LBVLQXdKFICUId5J3eIpmjGURaBqntfg3GSZACgeOAFS+lOSMGTwfzDkELTaZVp/lWdMVNU3UkwCUBg/Q==", "integrity": "sha512-rnMHrGBB0IUEv69Q8/JGRD/n4/n6b3nfpufUu26axhUcboUzv/twfZU8fIBbTOphRAe0v8EyxzeDpKXqGHfyDA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@rollup/pluginutils": "^5.0.1", "@rollup/pluginutils": "^5.0.1",
@ -859,7 +874,7 @@
"node": ">=14.0.0" "node": ">=14.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"rollup": "^2.14.0||^3.0.0", "rollup": "^2.14.0||^3.0.0||^4.0.0",
"tslib": "*", "tslib": "*",
"typescript": ">=3.7.0" "typescript": ">=3.7.0"
}, },
@ -996,22 +1011,22 @@
"dev": true "dev": true
}, },
"node_modules/@types/vscode": { "node_modules/@types/vscode": {
"version": "1.82.0", "version": "1.83.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.82.0.tgz", "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.83.0.tgz",
"integrity": "sha512-VSHV+VnpF8DEm8LNrn8OJ8VuUNcBzN3tMvKrNpbhhfuVjFm82+6v44AbDhLvVFgCzn6vs94EJNTp7w8S6+Q1Rw==", "integrity": "sha512-3mUtHqLAVz9hegut9au4xehuBrzRE3UJiQMpoEHkNl6XHliihO7eATx2BMHs0odsmmrwjJrlixx/Pte6M3ygDQ==",
"dev": true "dev": true
}, },
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "6.7.4", "version": "6.7.5",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.5.tgz",
"integrity": "sha512-DAbgDXwtX+pDkAHwiGhqP3zWUGpW49B7eqmgpPtg+BKJXwdct79ut9+ifqOFPJGClGKSHXn2PTBatCnldJRUoA==", "integrity": "sha512-JhtAwTRhOUcP96D0Y6KYnwig/MRQbOoLGXTON2+LlyB/N35SP9j1boai2zzwXb7ypKELXMx3DVk9UTaEq1vHEw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/regexpp": "^4.5.1", "@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "6.7.4", "@typescript-eslint/scope-manager": "6.7.5",
"@typescript-eslint/type-utils": "6.7.4", "@typescript-eslint/type-utils": "6.7.5",
"@typescript-eslint/utils": "6.7.4", "@typescript-eslint/utils": "6.7.5",
"@typescript-eslint/visitor-keys": "6.7.4", "@typescript-eslint/visitor-keys": "6.7.5",
"debug": "^4.3.4", "debug": "^4.3.4",
"graphemer": "^1.4.0", "graphemer": "^1.4.0",
"ignore": "^5.2.4", "ignore": "^5.2.4",
@ -1037,15 +1052,15 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "6.7.4", "version": "6.7.5",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.7.5.tgz",
"integrity": "sha512-I5zVZFY+cw4IMZUeNCU7Sh2PO5O57F7Lr0uyhgCJmhN/BuTlnc55KxPonR4+EM3GBdfiCyGZye6DgMjtubQkmA==", "integrity": "sha512-bIZVSGx2UME/lmhLcjdVc7ePBwn7CLqKarUBL4me1C5feOd663liTGjMBGVcGr+BhnSLeP4SgwdvNnnkbIdkCw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "6.7.4", "@typescript-eslint/scope-manager": "6.7.5",
"@typescript-eslint/types": "6.7.4", "@typescript-eslint/types": "6.7.5",
"@typescript-eslint/typescript-estree": "6.7.4", "@typescript-eslint/typescript-estree": "6.7.5",
"@typescript-eslint/visitor-keys": "6.7.4", "@typescript-eslint/visitor-keys": "6.7.5",
"debug": "^4.3.4" "debug": "^4.3.4"
}, },
"engines": { "engines": {
@ -1065,13 +1080,13 @@
} }
}, },
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "6.7.4", "version": "6.7.5",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.7.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.7.5.tgz",
"integrity": "sha512-SdGqSLUPTXAXi7c3Ob7peAGVnmMoGzZ361VswK2Mqf8UOYcODiYvs8rs5ILqEdfvX1lE7wEZbLyELCW+Yrql1A==", "integrity": "sha512-GAlk3eQIwWOJeb9F7MKQ6Jbah/vx1zETSDw8likab/eFcqkjSD7BI75SDAeC5N2L0MmConMoPvTsmkrg71+B1A==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.7.4", "@typescript-eslint/types": "6.7.5",
"@typescript-eslint/visitor-keys": "6.7.4" "@typescript-eslint/visitor-keys": "6.7.5"
}, },
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"
@ -1082,13 +1097,13 @@
} }
}, },
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "6.7.4", "version": "6.7.5",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.7.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.7.5.tgz",
"integrity": "sha512-n+g3zi1QzpcAdHFP9KQF+rEFxMb2KxtnJGID3teA/nxKHOVi3ylKovaqEzGBbVY2pBttU6z85gp0D00ufLzViQ==", "integrity": "sha512-Gs0qos5wqxnQrvpYv+pf3XfcRXW6jiAn9zE/K+DlmYf6FcpxeNYN0AIETaPR7rHO4K2UY+D0CIbDP9Ut0U4m1g==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/typescript-estree": "6.7.4", "@typescript-eslint/typescript-estree": "6.7.5",
"@typescript-eslint/utils": "6.7.4", "@typescript-eslint/utils": "6.7.5",
"debug": "^4.3.4", "debug": "^4.3.4",
"ts-api-utils": "^1.0.1" "ts-api-utils": "^1.0.1"
}, },
@ -1109,9 +1124,9 @@
} }
}, },
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "6.7.4", "version": "6.7.5",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.7.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.7.5.tgz",
"integrity": "sha512-o9XWK2FLW6eSS/0r/tgjAGsYasLAnOWg7hvZ/dGYSSNjCh+49k5ocPN8OmG5aZcSJ8pclSOyVKP2x03Sj+RrCA==", "integrity": "sha512-WboQBlOXtdj1tDFPyIthpKrUb+kZf2VroLZhxKa/VlwLlLyqv/PwUNgL30BlTVZV1Wu4Asu2mMYPqarSO4L5ZQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "^16.0.0 || >=18.0.0" "node": "^16.0.0 || >=18.0.0"
@ -1122,13 +1137,13 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree": { "node_modules/@typescript-eslint/typescript-estree": {
"version": "6.7.4", "version": "6.7.5",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.5.tgz",
"integrity": "sha512-ty8b5qHKatlNYd9vmpHooQz3Vki3gG+3PchmtsA4TgrZBKWHNjWfkQid7K7xQogBqqc7/BhGazxMD5vr6Ha+iQ==", "integrity": "sha512-NhJiJ4KdtwBIxrKl0BqG1Ur+uw7FiOnOThcYx9DpOGJ/Abc9z2xNzLeirCG02Ig3vkvrc2qFLmYSSsaITbKjlg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.7.4", "@typescript-eslint/types": "6.7.5",
"@typescript-eslint/visitor-keys": "6.7.4", "@typescript-eslint/visitor-keys": "6.7.5",
"debug": "^4.3.4", "debug": "^4.3.4",
"globby": "^11.1.0", "globby": "^11.1.0",
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
@ -1149,17 +1164,17 @@
} }
}, },
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "6.7.4", "version": "6.7.5",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.7.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.7.5.tgz",
"integrity": "sha512-PRQAs+HUn85Qdk+khAxsVV+oULy3VkbH3hQ8hxLRJXWBEd7iI+GbQxH5SEUSH7kbEoTp6oT1bOwyga24ELALTA==", "integrity": "sha512-pfRRrH20thJbzPPlPc4j0UNGvH1PjPlhlCMq4Yx7EGjV7lvEeGX0U6MJYe8+SyFutWgSHsdbJ3BXzZccYggezA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.4.0", "@eslint-community/eslint-utils": "^4.4.0",
"@types/json-schema": "^7.0.12", "@types/json-schema": "^7.0.12",
"@types/semver": "^7.5.0", "@types/semver": "^7.5.0",
"@typescript-eslint/scope-manager": "6.7.4", "@typescript-eslint/scope-manager": "6.7.5",
"@typescript-eslint/types": "6.7.4", "@typescript-eslint/types": "6.7.5",
"@typescript-eslint/typescript-estree": "6.7.4", "@typescript-eslint/typescript-estree": "6.7.5",
"semver": "^7.5.4" "semver": "^7.5.4"
}, },
"engines": { "engines": {
@ -1174,12 +1189,12 @@
} }
}, },
"node_modules/@typescript-eslint/visitor-keys": { "node_modules/@typescript-eslint/visitor-keys": {
"version": "6.7.4", "version": "6.7.5",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.4.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.5.tgz",
"integrity": "sha512-pOW37DUhlTZbvph50x5zZCkFn3xzwkGtNoJHzIM3svpiSkJzwOYr/kVBaXmf+RAQiUDs1AHEZVNPg6UJCJpwRA==", "integrity": "sha512-3MaWdDZtLlsexZzDSdQWsFQ9l9nL8B80Z4fImSpyllFC/KLqWQRdEcB+gGGO+N3Q2uL40EsG66wZLsohPxNXvg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/types": "6.7.4", "@typescript-eslint/types": "6.7.5",
"eslint-visitor-keys": "^3.4.1" "eslint-visitor-keys": "^3.4.1"
}, },
"engines": { "engines": {
@ -1191,9 +1206,9 @@
} }
}, },
"node_modules/@vscode/test-electron": { "node_modules/@vscode/test-electron": {
"version": "2.3.4", "version": "2.3.5",
"resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.4.tgz", "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.3.5.tgz",
"integrity": "sha512-eWzIqXMhvlcoXfEFNWrVu/yYT5w6De+WZXR/bafUQhAp8+8GkQo95Oe14phwiRUPv8L+geAKl/QM2+PoT3YW3g==", "integrity": "sha512-lAW7nQ0HuPqJnGJrtCzEKZCICtRizeP6qNanyCrjmdCOAAWjX3ixiG8RVPwqsYPQBWLPgYuE12qQlwXsOR/2fQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"http-proxy-agent": "^4.0.1", "http-proxy-agent": "^4.0.1",
@ -1332,6 +1347,11 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/@vscode/vsce/node_modules/url-join": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz",
"integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA=="
},
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.10.0", "version": "8.10.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz",
@ -2587,15 +2607,15 @@
} }
}, },
"node_modules/eslint": { "node_modules/eslint": {
"version": "8.50.0", "version": "8.51.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.50.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz",
"integrity": "sha512-FOnOGSuFuFLv/Sa+FDVRZl4GGVAAFFi8LecRsI5a1tMO5HIE8nCm4ivAlzt4dT3ol/PaaGC0rJEEXQmHJBGoOg==", "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1", "@eslint-community/regexpp": "^4.6.1",
"@eslint/eslintrc": "^2.1.2", "@eslint/eslintrc": "^2.1.2",
"@eslint/js": "8.50.0", "@eslint/js": "8.51.0",
"@humanwhocodes/config-array": "^0.11.11", "@humanwhocodes/config-array": "^0.11.11",
"@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/module-importer": "^1.0.1",
"@nodelib/fs.walk": "^1.2.8", "@nodelib/fs.walk": "^1.2.8",
@ -5073,6 +5093,31 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/prettier": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz",
"integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==",
"dev": true,
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/prettier-plugin-svelte": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-3.0.3.tgz",
"integrity": "sha512-dLhieh4obJEK1hnZ6koxF+tMUrZbV5YGvRpf2+OADyanjya5j0z1Llo8iGwiHmFWZVG/hLEw/AJD5chXd9r3XA==",
"dev": true,
"peerDependencies": {
"prettier": "^3.0.0",
"svelte": "^3.2.0 || ^4.0.0-next.0"
}
},
"node_modules/process-nextick-args": { "node_modules/process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@ -6292,9 +6337,12 @@
} }
}, },
"node_modules/url-join": { "node_modules/url-join": {
"version": "4.0.1", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", "resolved": "https://registry.npmjs.org/url-join/-/url-join-5.0.0.tgz",
"integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==" "integrity": "sha512-n2huDr9h9yzd6exQVnH/jU5mr+Pfx08LRXXZhkLLetAMESRj+anQsTAh940iMrIetKAmry9coFuZQ2jY8/p3WA==",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
}, },
"node_modules/util-deprecate": { "node_modules/util-deprecate": {
"version": "1.0.2", "version": "1.0.2",

View File

@ -4,7 +4,7 @@
"description": "The student extension for BW's HSPC", "description": "The student extension for BW's HSPC",
"version": "0.0.1", "version": "0.0.1",
"engines": { "engines": {
"vscode": "^1.81.0" "vscode": "^1.83.0"
}, },
"categories": [ "categories": [
"Other" "Other"
@ -57,46 +57,38 @@
} }
] ]
}, },
"commands": [ "commands": []
{
"command": "bwcontest.helloWorld",
"category": "BWContest",
"title": "Hello World"
},
{
"command": "bwcontest.askQuestion",
"category": "BWContest",
"title": "Ask Question"
}
]
}, },
"scripts": { "scripts": {
"vscode:prepublish": "npm run compile", "vscode:prepublish": "npm run compile",
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node", "esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
"esbuild": "npm run esbuild-base -- --sourcemap", "esbuild": "npm run esbuild-base -- --sourcemap",
"compile": "rollup -c && npm run esbuild-base -- --minify", "compile": "rollup -c && npm run esbuild-base -- --minify",
"format": "prettier --plugin prettier-plugin-svelte --write .",
"watch": "concurrently \"rollup -c -w\" \"npm run esbuild-base -- --sourcemap --watch\"" "watch": "concurrently \"rollup -c -w\" \"npm run esbuild-base -- --sourcemap --watch\""
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^25.0.4", "@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.1", "@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.3", "@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.4", "@rollup/plugin-typescript": "^11.1.5",
"@tsconfig/svelte": "^5.0.2", "@tsconfig/svelte": "^5.0.2",
"@types/fs-extra": "^11.0.2", "@types/fs-extra": "^11.0.2",
"@types/glob": "^8.1.0", "@types/glob": "^8.1.0",
"@types/mocha": "^10.0.2", "@types/mocha": "^10.0.2",
"@types/node": "20.x", "@types/node": "20.x",
"@types/vscode": "^1.82.0", "@types/vscode": "^1.83.0",
"@typescript-eslint/eslint-plugin": "^6.7.4", "@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.4", "@typescript-eslint/parser": "^6.7.5",
"@vscode/test-electron": "^2.3.4", "@vscode/test-electron": "^2.3.5",
"concurrently": "^8.2.1", "concurrently": "^8.2.1",
"esbuild": "^0.19.4", "esbuild": "^0.19.4",
"eslint": "^8.50.0", "eslint": "^8.51.0",
"glob": "^10.3.10", "glob": "^10.3.10",
"mocha": "^10.2.0", "mocha": "^10.2.0",
"postcss": "^8.4.31", "postcss": "^8.4.31",
"prettier": "^3.0.3",
"prettier-plugin-svelte": "^3.0.3",
"rollup-plugin-css-only": "^4.3.0", "rollup-plugin-css-only": "^4.3.0",
"rollup-plugin-postcss": "^4.0.2", "rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-svelte": "^7.1.6", "rollup-plugin-svelte": "^7.1.6",
@ -109,6 +101,7 @@
"@vscode/vsce": "^2.21.1", "@vscode/vsce": "^2.21.1",
"axios": "^1.5.1", "axios": "^1.5.1",
"fs-extra": "^11.1.1", "fs-extra": "^11.1.1",
"tree-kill": "^1.2.2" "tree-kill": "^1.2.2",
"url-join": "^5.0.0"
} }
} }

View File

@ -1,49 +1,47 @@
import svelte from "rollup-plugin-svelte"; import svelte from 'rollup-plugin-svelte';
import resolve from "@rollup/plugin-node-resolve"; import resolve from '@rollup/plugin-node-resolve';
import commonjs from "@rollup/plugin-commonjs"; import commonjs from '@rollup/plugin-commonjs';
import terser from "@rollup/plugin-terser"; import terser from '@rollup/plugin-terser';
import sveltePreprocess from "svelte-preprocess"; import sveltePreprocess from 'svelte-preprocess';
import typescript from "@rollup/plugin-typescript"; import typescript from '@rollup/plugin-typescript';
import path from "path"; import path from 'path';
import fs from "fs"; import fs from 'fs';
import css from "rollup-plugin-css-only"; import css from 'rollup-plugin-css-only';
const production = !process.env.ROLLUP_WATCH; const production = !process.env.ROLLUP_WATCH;
export default fs export default fs.readdirSync(path.join(__dirname, 'webviews', 'pages')).map((input) => {
.readdirSync(path.join(__dirname, "webviews", "pages")) const name = input.split('.')[0];
.map((input) => { return {
const name = input.split(".")[0]; input: 'webviews/pages/' + input,
return { output: {
input: "webviews/pages/" + input, format: 'iife',
output: { name: 'app',
format: "iife", file: 'out/compiled/' + name + '.js'
name: "app", },
file: "out/compiled/" + name + ".js", plugins: [
}, svelte({
plugins: [ // enable run-time checks when not in production
svelte({ compilerOptions: {
// enable run-time checks when not in production dev: !production
compilerOptions: { },
dev: !production preprocess: sveltePreprocess(),
}, emitCss: true
preprocess: sveltePreprocess(), }),
emitCss: true css({ output: name + '.css' }),
}), resolve({
css({ output: name + ".css" }), browser: true,
resolve({ dedupe: ['svelte']
browser: true, }),
dedupe: ["svelte"], commonjs(),
}), typescript({
commonjs(), tsconfig: 'webviews/tsconfig.json',
typescript({ inlineSources: !production
tsconfig: "webviews/tsconfig.json", }),
inlineSources: !production, production && terser()
}), ],
production && terser(), watch: {
], clearScreen: false
watch: { }
clearScreen: false, };
}, });
};
});

View File

@ -2,43 +2,44 @@ import * as vscode from 'vscode';
import { getNonce } from './getNonce'; import { getNonce } from './getNonce';
import { cloneAndOpenRepo } from './extension'; import { cloneAndOpenRepo } from './extension';
import { BWPanel } from './problemPanel'; import { BWPanel } from './problemPanel';
import urlJoin from 'url-join';
export class SidebarProvider implements vscode.WebviewViewProvider { export class SidebarProvider implements vscode.WebviewViewProvider {
_view?: vscode.WebviewView; constructor(
_context?: vscode.ExtensionContext; private readonly extensionUri: vscode.Uri,
private readonly context: vscode.ExtensionContext,
constructor(private readonly _extensionUri: vscode.Uri, context: vscode.ExtensionContext) { private readonly webUrl: string
this._context = context; ) {}
}
public resolveWebviewView(webviewView: vscode.WebviewView) { public resolveWebviewView(webviewView: vscode.WebviewView) {
this._view = webviewView; const webview = webviewView.webview;
webview.options = {
webviewView.webview.options = {
// Allow scripts in the webview
enableScripts: true, enableScripts: true,
localResourceRoots: [this.extensionUri]
localResourceRoots: [this._extensionUri]
}; };
webview.html = this.getHtmlForWebview(webview);
webviewView.webview.html = this._getHtmlForWebview(webviewView.webview); webview.onDidReceiveMessage(async (data: { type: string; value: any }) => {
webviewView.webview.onDidReceiveMessage(async (data) => {
switch (data.type) { switch (data.type) {
case 'onTestAndSubmit': { case 'onTestAndSubmit': {
if (this._context) { if (this.context) {
BWPanel.createOrShow(this._context); BWPanel.createOrShow(this.context, this.webUrl);
} }
break; break;
} }
case 'onStartup': { case 'onStartup': {
const token: string | undefined = this._context?.globalState.get('token'); const token: string | undefined = this.context.globalState.get('token');
if (token) { const teamData = this.context.globalState.get('teamData');
this._view?.webview.postMessage({ if (token && teamData !== undefined) {
type: 'onSession', webview.postMessage({
value: token type: 'onLogin',
value: teamData
}); });
} }
webview.postMessage({
type: 'onWebUrl',
value: this.webUrl
});
break; break;
} }
case 'onClone': { case 'onClone': {
@ -48,15 +49,56 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
await cloneAndOpenRepo(parseInt(data.value.contestId), parseInt(data.value.teamId)); await cloneAndOpenRepo(parseInt(data.value.contestId), parseInt(data.value.teamId));
break; break;
} }
case 'onLogin': { case 'requestLogin': {
if (!data.value) { const res = await fetch(urlJoin(this.webUrl, '/api/team/login'), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
teamname: data.value.teamname,
password: data.value.password
})
});
const thing = await res.json();
if (thing.success !== true) {
return; return;
} }
this._context?.globalState.update('token', data.value); const sessionToken = thing.token;
this.context.globalState.update('token', sessionToken);
const res1 = await fetch(urlJoin(this.webUrl, `api/team/${sessionToken}`), {
method: 'GET'
});
const data2 = await res1.json();
if (!data2.success) {
return;
}
this.context.globalState.update('teamData', data2.data);
webview.postMessage({ type: 'onLogin', value: data2.data });
break;
}
case 'requestLogout': {
const sessionToken = this.context.globalState.get<string>('token');
if (sessionToken === undefined) {
webview.postMessage({ type: 'onLogout' });
}
const res = await fetch(urlJoin(this.webUrl, '/api/team/logout'), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
token: sessionToken
})
});
if (res.status !== 200) {
return;
}
const data2 = await res.json();
if (data2.success === true) {
webview.postMessage({ type: 'onLogout' });
this.context.globalState.update('token', undefined);
}
break; break;
} }
case 'onLogout': { case 'onLogout': {
this._context?.globalState.update('token', null); this.context.globalState.update('token', null);
break; break;
} }
case 'onInfo': { case 'onInfo': {
@ -77,19 +119,19 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
}); });
} }
private _getHtmlForWebview(webview: vscode.Webview) { private getHtmlForWebview(webview: vscode.Webview) {
const styleResetUri = webview.asWebviewUri( const styleResetUri = webview.asWebviewUri(
vscode.Uri.joinPath(this._extensionUri, 'media', 'reset.css') vscode.Uri.joinPath(this.extensionUri, 'media', 'reset.css')
); );
const styleVSCodeUri = webview.asWebviewUri( const styleVSCodeUri = webview.asWebviewUri(
vscode.Uri.joinPath(this._extensionUri, 'media', 'vscode.css') vscode.Uri.joinPath(this.extensionUri, 'media', 'vscode.css')
); );
const scriptUri = webview.asWebviewUri( const scriptUri = webview.asWebviewUri(
vscode.Uri.joinPath(this._extensionUri, 'out', 'compiled/sidebar.js') vscode.Uri.joinPath(this.extensionUri, 'out', 'compiled/sidebar.js')
); );
const styleMainUri = webview.asWebviewUri( const styleMainUri = webview.asWebviewUri(
vscode.Uri.joinPath(this._extensionUri, 'out', 'compiled/sidebar.css') vscode.Uri.joinPath(this.extensionUri, 'out', 'compiled/sidebar.css')
); );
// Use a nonce to only allow a specific script to be run. // Use a nonce to only allow a specific script to be run.

View File

@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import { SidebarProvider } from './SidebarProvider'; import { SidebarProvider } from './SidebarProvider';
import * as child_process from 'child_process'; import * as child_process from 'child_process';
import * as fs from 'fs-extra'; import * as fs from 'fs-extra';
import { BWPanel } from './problemPanel'; import urlJoin from 'url-join';
export interface BWContestSettings { export interface BWContestSettings {
repoBaseUrl: string; repoBaseUrl: string;
@ -41,8 +41,12 @@ export async function cloneAndOpenRepo(contestId: number, teamId: number) {
vscode.window.showErrorMessage('BWContest: BWContest.webUrl not set'); vscode.window.showErrorMessage('BWContest: BWContest.webUrl not set');
return; return;
} }
const repoUrl = `${currentSettings.repoBaseUrl}/${contestId.toString()}/${teamId.toString()}.git`; const repoUrl = urlJoin(
currentSettings.repoBaseUrl,
contestId.toString(),
`${teamId.toString()}.git`
);
const repoName = repoUrl.split('/').pop()?.replace('.git', '')!; const repoName = repoUrl.split('/').pop()?.replace('.git', '')!;
@ -96,27 +100,14 @@ export async function cloneAndOpenRepo(contestId: number, teamId: number) {
} }
export function activate(context: vscode.ExtensionContext) { export function activate(context: vscode.ExtensionContext) {
const sidebarProvider = new SidebarProvider(context.extensionUri, context); const sidebarProvider = new SidebarProvider(
context.extensionUri,
context,
extensionSettings().webUrl
);
context.subscriptions.push( context.subscriptions.push(
vscode.window.registerWebviewViewProvider('bwcontest-sidebar', sidebarProvider) vscode.window.registerWebviewViewProvider('bwcontest-sidebar', sidebarProvider)
); );
context.subscriptions.push(
vscode.commands.registerCommand('bwcontest.helloWorld', () => {
BWPanel.createOrShow(context);
})
);
context.subscriptions.push(
vscode.commands.registerCommand('bwcontest.askQuestion', async () => {
const answer = await vscode.window.showInformationMessage('How was your day?', 'good', 'bad');
if (answer === 'bad') {
vscode.window.showInformationMessage('Sorry to hear that');
} else {
console.log(answer);
}
})
);
} }
export function deactivate() {} export function deactivate() {}

View File

@ -20,7 +20,7 @@ export class BWPanel {
private static _running: boolean; private static _running: boolean;
private static _kill: Function | null; private static _kill: Function | null;
public static createOrShow(context: vscode.ExtensionContext) { public static createOrShow(context: vscode.ExtensionContext, webUrl: string) {
this._context = context; this._context = context;
const column = vscode.window.activeTextEditor const column = vscode.window.activeTextEditor
? vscode.window.activeTextEditor.viewColumn ? vscode.window.activeTextEditor.viewColumn
@ -51,7 +51,7 @@ export class BWPanel {
} }
); );
BWPanel.currentPanel = new BWPanel(panel, context.extensionUri); BWPanel.currentPanel = new BWPanel(panel, context.extensionUri, webUrl);
} }
public static kill() { public static kill() {
@ -59,11 +59,11 @@ export class BWPanel {
BWPanel.currentPanel = undefined; BWPanel.currentPanel = undefined;
} }
public static revive(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) { public static revive(panel: vscode.WebviewPanel, extensionUri: vscode.Uri, webUrl: string) {
BWPanel.currentPanel = new BWPanel(panel, extensionUri); BWPanel.currentPanel = new BWPanel(panel, extensionUri, webUrl);
} }
private constructor(panel: vscode.WebviewPanel, extensionUri: vscode.Uri) { private constructor(panel: vscode.WebviewPanel, extensionUri: vscode.Uri, webUrl: string) {
this._panel = panel; this._panel = panel;
this._extensionUri = extensionUri; this._extensionUri = extensionUri;
this._update(); this._update();

View File

@ -1,187 +1,216 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte"; import { onMount } from 'svelte';
import urlJoin from 'url-join';
function postMessage(message: any) { function postMessage(message: any) {
vscode.postMessage(message); vscode.postMessage(message);
} }
type ProblemData = { type ProblemData = {
id: number, id: number;
name: string, name: string;
pascalName: string, pascalName: string;
sampleInput: string, sampleInput: string;
sampleOutput: string sampleOutput: string;
}[]; }[];
let savedInputs: Map<number, {input: string, output: string}> = new Map(); let savedInputs: Map<number, { input: string; output: string }> = new Map();
let activeProblem: ProblemData[0]; let activeProblem: ProblemData[0];
let sessionToken: string | undefined; let sessionToken: string | undefined;
let problemData: ProblemData | undefined; let problemData: ProblemData | undefined;
let sampleInputText: HTMLTextAreaElement; let sampleInputText: HTMLTextAreaElement;
let outputText: HTMLTextAreaElement; let outputText: HTMLTextAreaElement;
let running = false; let running = false;
$: if (problemData && problemData.length !== 0) { let webUrl: string | undefined;
let first = problemData.at(0);
if (first) {
activeProblem = first;
}
};
function resetInput() { $: if (problemData && problemData.length !== 0) {
sampleInputText.value = activeProblem.sampleInput; let first = problemData.at(0);
} if (first) {
activeProblem = first;
}
}
let contestId: number | undefined; function resetInput() {
let teamId: number | undefined; sampleInputText.value = activeProblem.sampleInput;
}
function onRun() { let contestId: number | undefined;
if (!running && contestId && teamId) { let teamId: number | undefined;
postMessage({type: 'onRun', value: {problemPascalName: activeProblem.pascalName, contestId: contestId, teamId: teamId, input: sampleInputText.value}});
running = true;
}
}
function updateTextBoxes() { function onRun() {
if (savedInputs.has(activeProblem.id)) { if (!running && contestId && teamId) {
sampleInputText.value = savedInputs.get(activeProblem.id)!.input; postMessage({
outputText.value = savedInputs.get(activeProblem.id)!.output; type: 'onRun',
} else { value: {
sampleInputText.value = activeProblem.sampleInput; problemPascalName: activeProblem.pascalName,
outputText.value = "[Run to get output]"; contestId: contestId,
} teamId: teamId,
} input: sampleInputText.value
}
});
running = true;
}
}
function onSubmit() { function updateTextBoxes() {
if (teamId && contestId && sessionToken) { if (savedInputs.has(activeProblem.id)) {
postMessage({type: 'onSubmit', value: {sessionToken: sessionToken, contestId: contestId, teamId: teamId, problemId: activeProblem.id, problemName: activeProblem.pascalName}}) sampleInputText.value = savedInputs.get(activeProblem.id)!.input;
} outputText.value = savedInputs.get(activeProblem.id)!.output;
} } else {
sampleInputText.value = activeProblem.sampleInput;
outputText.value = '[Run to get output]';
}
}
function onKill() { function onSubmit() {
postMessage({type: 'onKill'}); if (teamId && contestId && sessionToken) {
} postMessage({
type: 'onSubmit',
value: {
sessionToken: sessionToken,
contestId: contestId,
teamId: teamId,
problemId: activeProblem.id,
problemName: activeProblem.pascalName
}
});
}
}
async function fetchProblemData() { function onKill() {
if (sessionToken) { postMessage({ type: 'onKill' });
const res = await fetch(`http://localhost:5173/api/contest/${sessionToken}`); }
const data = await res.json();
if (data.success === true) {
problemData = data.problems as ProblemData;
contestId = data.contestId;
teamId = data.teamId;
}
}
}
window.addEventListener("message", async (event) => { async function fetchProblemData() {
const message = (event as MessageEvent).data; if (sessionToken && webUrl) {
if (message.type === "onSession") { const res = await fetch(urlJoin(webUrl, `/api/contest/${sessionToken}`));
if (message.value !== "") { const data = await res.json();
sessionToken = message.value; if (data.success === true) {
await fetchProblemData(); problemData = data.problems as ProblemData;
updateTextBoxes(); contestId = data.contestId;
} teamId = data.teamId;
} else if (message.type === 'onOutput') { }
outputText.value = message.value; }
running = false; }
}
})
onMount(() => { window.addEventListener('message', async (event) => {
postMessage({type: "onStartup"}); const message = (event as MessageEvent).data;
}) if (message.type === 'onSession') {
if (message.value !== '') {
sessionToken = message.value;
await fetchProblemData();
updateTextBoxes();
}
} else if (message.type === 'onOutput') {
outputText.value = message.value;
running = false;
} else if (message.type === 'onWebUrl') {
webUrl = message.value;
}
});
onMount(() => {
postMessage({ type: 'onStartup' });
});
</script> </script>
<h1>Test & Submit Problems</h1> <h1>Test & Submit Problems</h1>
{#if problemData} {#if problemData}
<div class="tab-container"> <div class="tab-container">
{#each problemData as problem} {#each problemData as problem}
<button on:click={() => { <button
if (!running) { on:click={() => {
savedInputs.set(activeProblem.id, {input: sampleInputText.value, output: outputText.value}); if (!running) {
activeProblem = problem; savedInputs.set(activeProblem.id, {
updateTextBoxes(); input: sampleInputText.value,
} output: outputText.value
}} id={`problem_${problem.id}`} type="button" class={"tab " + (activeProblem.id == problem.id ? "active" : "")}>{problem.name}</button> });
{/each} activeProblem = problem;
</div> updateTextBoxes();
}
}}
id={`problem_${problem.id}`}
type="button"
class={'tab ' + (activeProblem.id == problem.id ? 'active' : '')}>{problem.name}</button
>
{/each}
</div>
{/if} {/if}
{#if activeProblem} {#if activeProblem}
<h2>{activeProblem.name}</h2> <h2>{activeProblem.name}</h2>
<div style="display:flex"> <div style="display:flex">
<div style="flex:1; margin-right:20px"> <div style="flex:1; margin-right:20px">
<h3>Sample Input (You can edit this!)</h3> <h3>Sample Input (You can edit this!)</h3>
<textarea bind:this={sampleInputText} /> <textarea bind:this={sampleInputText} />
<button style="margin-top:5px" on:click={resetInput} type="button">Reset Input</button> <button style="margin-top:5px" on:click={resetInput} type="button">Reset Input</button>
</div> </div>
<div style="flex:1"> <div style="flex:1">
<div style="display:flex"> <div style="display:flex">
<h3 style="margin-right:5px">Output</h3> <h3 style="margin-right:5px">Output</h3>
{#if running} {#if running}
<span class="loader"></span> <span class="loader"></span>
{/if} {/if}
</div> </div>
<textarea bind:this={outputText} disabled /> <textarea bind:this={outputText} disabled />
{#if !running} {#if !running}
<button style="margin-top:5px" on:click={onRun} type="button">Run</button> <button style="margin-top:5px" on:click={onRun} type="button">Run</button>
{:else} {:else}
<button style="margin-top:5px" on:click={onKill} type="button">Stop</button> <button style="margin-top:5px" on:click={onKill} type="button">Stop</button>
{/if} {/if}
</div> </div>
</div> </div>
<button on:click={onSubmit} type="button">Submit</button> <button on:click={onSubmit} type="button">Submit</button>
{/if} {/if}
<style> <style>
textarea { textarea {
resize: vertical; resize: vertical;
height: 250px; height: 250px;
} }
.tab-container { .tab-container {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
height: 30px; height: 30px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.tab { .tab {
flex: 1; flex: 1;
border: none; border: none;
cursor: pointer; cursor: pointer;
text-align: center; text-align: center;
} }
.tab.active { .tab.active {
background-color: rgb(95, 103, 118); background-color: rgb(95, 103, 118);
} }
.loader { .loader {
width: 16px; width: 16px;
height: 16px; height: 16px;
border: 3px solid #FFF; border: 3px solid #fff;
border-bottom-color: transparent; border-bottom-color: transparent;
border-radius: 50%; border-radius: 50%;
display: inline-block; display: inline-block;
box-sizing: border-box; box-sizing: border-box;
animation: rotation 1s linear infinite; animation: rotation 1s linear infinite;
} }
@keyframes rotation { @keyframes rotation {
0% { 0% {
transform: rotate(0deg); transform: rotate(0deg);
} }
100% { 100% {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
</style> </style>

View File

@ -1,116 +1,80 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte"; import { onMount } from 'svelte';
function postMessage(message: any) { function postMessage(message: any) {
vscode.postMessage(message); vscode.postMessage(message);
} }
let teamname: HTMLInputElement; let teamname: string;
let password: HTMLInputElement; let password: string;
let sessionToken: string | undefined; let loggedIn = false;
interface TeamData { interface TeamData {
teamId: number, teamId: number;
contestId: number contestId: number;
} }
let teamData: TeamData | undefined;
async function fetchTeamData() { let teamData: TeamData | undefined;
if (sessionToken) {
const res = await fetch(`http://localhost:5173/api/team/${sessionToken}`, {method: "GET"});
const data = await res.json();
if (!data.success) {
postMessage({type: 'onError', value: "BWContest: Failed to fetch team data"});
return;
}
teamData = data.data as TeamData;
}
}
async function onClone() { function onClone() {
if (teamData) { if (teamData) {
postMessage({type: 'onClone', value: {contestId: teamData.contestId, teamId: teamData.teamId}}); postMessage({
} type: 'onClone',
} value: { contestId: teamData.contestId, teamId: teamData.teamId }
});
}
}
async function onLogin() { function onLogin() {
try { postMessage({
const res = await fetch("http://localhost:5173/api/team/login", {method: "POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ type: 'requestLogin',
teamname: teamname.value, password: password.value value: { teamname: teamname, password: password }
})}); });
if (res.status !== 200) { }
postMessage({type: 'onError', value: 'Error logging in'});
return;
}
const data = await res.json();
if (data.success === false) {
postMessage({type: 'onError', value: data.message ?? "Unknown error logging in"});
return;
}
sessionToken = data.token;
postMessage({type: 'onLogin', value: sessionToken});
} catch (err) {
console.error('Failed to fetch:', err);
}
fetchTeamData();
}
async function onLogout() { function onLogout() {
const res = await fetch("http://localhost:5173/api/team/logout", {method: "POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ postMessage({
token: sessionToken, type: 'requestLogout'
})}) });
if (res.status !== 200) { }
postMessage({type: 'onError', value: 'Error logging out'});
sessionToken = undefined;
return;
}
const data = await res.json();
if (data.success === true) {
postMessage({type: 'onInfo', value: 'BWContest: Logged out'});
sessionToken = undefined;
postMessage({type: 'onLogout'});
} else {
postMessage({type: 'onError', value: 'Log out unsuccessful'});
}
}
window.addEventListener("message", event => { function onTestAndSubmit() {
const message = (event as MessageEvent).data; postMessage({ type: 'onTestAndSubmit' });
if (message.type === "onSession") { }
if (message.value !== "") {
sessionToken = message.value;
fetchTeamData();
}
}
})
function onTestAndSubmit() { onMount(() => {
postMessage({type: 'onTestAndSubmit'}); postMessage({ type: 'onStartup' });
} });
onMount(() => { window.addEventListener('message', (event) => {
postMessage({type: "onStartup"}); const message = (event as MessageEvent).data;
}) if (message.type === 'onLogin') {
loggedIn = true;
teamData = message.value;
} else if (message.type === 'onLogout') {
loggedIn = false;
teamData = undefined;
}
});
</script> </script>
<h1>Contest</h1> <h1>Contest</h1>
{#if sessionToken === undefined} {#if !loggedIn}
<label for="teamname">Team Name</label> <label for="teamname">Team Name</label>
<input bind:this={teamname} id="teamname" type="text"/> <input bind:value={teamname} id="teamname" type="text" />
<label for="password">Password</label> <label for="password">Password</label>
<input bind:this={password} id="password" type="password"/> <input bind:value={password} id="password" type="password" />
<button on:click={onLogin}>Login</button> <button on:click={onLogin}>Login</button>
{:else} {:else}
<button on:click={onLogout}>Logout</button> <button on:click={onLogout}>Logout</button>
{#if teamData} {#if teamData}
<p>TeamID: {teamData.teamId}</p> <p>TeamID: {teamData.teamId}</p>
<p>ContestID: {teamData.contestId}</p> <p>ContestID: {teamData.contestId}</p>
<button on:click={onClone}>Clone and Open Repo</button> <button on:click={onClone}>Clone and Open Repo</button>
<button on:click={onTestAndSubmit}>Test & Submit</button> <button on:click={onTestAndSubmit}>Test & Submit</button>
{/if} {/if}
{/if} {/if}