Skip to content

Commit b4a8a21

Browse files
authored
Merge pull request #6 from DandrewsDev/cleanup-improvements-to-visibility-dep-update
Cleanup, improvements to visibility, dependency updates
2 parents 29326f4 + c9a0bd7 commit b4a8a21

16 files changed

+1655
-2784
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ extension/manifest.json
1414
node_modules
1515
src/auto-imports.d.ts
1616
src/components.d.ts
17+
.env

package-lock.json

+1,204-2,623
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "faceit-elo-calc",
33
"displayName": "Faceit Elo Calculator",
4-
"version": "0.2.5",
4+
"version": "0.2.7",
55
"description": "Show Elo Gain/Loss for Faceit Matches",
66
"private": true,
77
"scripts": {
@@ -21,39 +21,36 @@
2121
"lint": "eslint '{src,scripts}/**/*.{json,ts,js,vue}'"
2222
},
2323
"devDependencies": {
24-
"@antfu/eslint-config": "^0.25.2",
24+
"@antfu/eslint-config": "^0.26.1",
2525
"@ffflorian/jszip-cli": "^3.1.6",
26-
"@iconify/json": "^2.1.28",
27-
"@quasar/vite-plugin": "^1.0.9",
2826
"@types/fs-extra": "^9.0.13",
29-
"@types/node": "^18.0.1",
27+
"@types/node": "^18.7.6",
3028
"@types/webextension-polyfill": "^0.9.0",
3129
"@typescript-eslint/eslint-plugin": "^5.19.0",
32-
"@vitejs/plugin-vue": "^2.3.1",
30+
"@vitejs/plugin-vue": "^3.0.3",
3331
"@vue/compiler-sfc": "^3.2.33",
34-
"@vueuse/core": "^8.2.6",
35-
"chokidar": "^3.5.3",
32+
"@vueuse/core": "^9.1.0",
3633
"cross-env": "^7.0.3",
37-
"crx": "^5.0.1",
38-
"eslint": "^8.13.0",
34+
"dotenv": "^16.0.1",
35+
"eslint": "^8.22.0",
3936
"esno": "^0.16.3",
4037
"fs-extra": "^10.0.1",
4138
"kolorist": "^1.5.1",
4239
"npm-run-all": "^4.1.5",
4340
"rimraf": "^3.0.2",
44-
"sass": "1.32.12",
41+
"sass": "1.54.4",
4542
"typescript": "^4.6.3",
46-
"unplugin-auto-import": "^0.9.2",
47-
"unplugin-icons": "^0.14.1",
48-
"unplugin-vue-components": "^0.21.0",
49-
"vite": "^2.9.5",
43+
"unplugin-auto-import": "^0.11.2",
44+
"unplugin-vue-components": "^0.22.4",
45+
"vite": "^3.0.9",
5046
"vue": "^3.2.33",
51-
"vue-demi": "^0.13.1",
52-
"webext-bridge": "^5.0.4",
53-
"webextension-polyfill": "^0.9.0"
47+
"vue-demi": "^0.13.8",
48+
"webextension-polyfill": "^0.10.0"
5449
},
5550
"dependencies": {
56-
"@quasar/extras": "^1.13.5",
57-
"quasar": "^2.6.6"
51+
"echarts": "^5.3.3",
52+
"vite-plugin-package-version": "^1.0.2",
53+
"vue-echarts": "^6.2.3",
54+
"vue-material-design-icons": "^5.1.2"
5855
}
5956
}

scripts/prepare.ts

-35
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,8 @@
11
// generate stub index.html files for dev entry
22
import { execSync } from 'child_process'
3-
import fs from 'fs-extra'
4-
import chokidar from 'chokidar'
5-
import { isDev, log, port, r } from './utils'
6-
7-
/**
8-
* Stub index.html to use Vite in development
9-
*/
10-
async function stubIndexHtml() {
11-
const views = [
12-
'popup',
13-
'background',
14-
]
15-
16-
for (const view of views) {
17-
await fs.ensureDir(r(`extension/dist/${view}`))
18-
let data = await fs.readFile(r(`src/${view}/index.html`), 'utf-8')
19-
data = data
20-
.replace('"./main.ts"', `"http://localhost:${port}/${view}/main.ts"`)
21-
.replace('<div id="app"></div>', '<div id="app">Vite server did not start</div>')
22-
await fs.writeFile(r(`extension/dist/${view}/index.html`), data, 'utf-8')
23-
log('PRE', `stub ${view}`)
24-
}
25-
}
263

274
function writeManifest() {
285
execSync('npx esno ./scripts/manifest.ts', { stdio: 'inherit' })
296
}
307

318
writeManifest()
32-
33-
if (isDev) {
34-
stubIndexHtml()
35-
chokidar.watch(r('src/**/*.html'))
36-
.on('change', () => {
37-
stubIndexHtml()
38-
})
39-
chokidar.watch([r('src/manifest.ts'), r('package.json')])
40-
.on('change', () => {
41-
writeManifest()
42-
})
43-
}

shim.d.ts

-10
This file was deleted.

src/components/LeetifyStatsGauge.vue

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<script>
2+
import { use } from 'echarts/core'
3+
import { CanvasRenderer } from 'echarts/renderers'
4+
import { GaugeChart } from 'echarts/charts'
5+
import {
6+
TooltipComponent,
7+
} from 'echarts/components'
8+
import VChart, { THEME_KEY } from 'vue-echarts'
9+
import { defineComponent, ref } from 'vue'
10+
11+
use([
12+
TooltipComponent, GaugeChart, CanvasRenderer,
13+
])
14+
15+
export default defineComponent({
16+
name: 'LeetifyStatsGauge',
17+
components: {
18+
VChart,
19+
},
20+
provide: {
21+
[THEME_KEY]: 'dark',
22+
},
23+
props: ['playerStats'],
24+
setup(props) {
25+
const showChart = ref(false)
26+
const option = ref({
27+
tooltip: {
28+
formatter: '{b}: {c}%',
29+
},
30+
backgroundColor: '#181818',
31+
series: [
32+
{
33+
radius: '90%',
34+
type: 'gauge',
35+
startAngle: 90,
36+
endAngle: -270,
37+
pointer: {
38+
show: false,
39+
},
40+
progress: {
41+
show: true,
42+
overlap: false,
43+
roundCap: true,
44+
clip: false,
45+
itemStyle: {
46+
borderWidth: 1,
47+
borderColor: '#464646',
48+
},
49+
},
50+
axisLine: {
51+
lineStyle: {
52+
width: 80,
53+
},
54+
},
55+
splitLine: {
56+
show: false,
57+
distance: 0,
58+
length: 10,
59+
},
60+
axisTick: {
61+
show: false,
62+
},
63+
axisLabel: {
64+
show: false,
65+
distance: 50,
66+
},
67+
data: [
68+
{
69+
value: props.playerStats.leetify_rating,
70+
name: 'Leetify Rating',
71+
title: {
72+
offsetCenter: ['-22%', '-40%'],
73+
},
74+
itemStyle: {
75+
color: props.playerStats.leetify_rating_color,
76+
},
77+
detail: {
78+
valueAnimation: true,
79+
offsetCenter: ['-22%', '-30%'],
80+
},
81+
},
82+
{
83+
value: props.playerStats.aim_rating,
84+
name: 'Aim',
85+
title: {
86+
offsetCenter: ['22%', '-40%'],
87+
},
88+
detail: {
89+
valueAnimation: true,
90+
offsetCenter: ['22%', '-30%'],
91+
},
92+
},
93+
{
94+
value: props.playerStats.utility_rating,
95+
name: 'Utility',
96+
title: {
97+
offsetCenter: ['-22%', '-10%'],
98+
},
99+
detail: {
100+
valueAnimation: true,
101+
offsetCenter: ['-22%', '0%'],
102+
},
103+
},
104+
{
105+
value: props.playerStats.positioning_rating,
106+
name: 'Positioning',
107+
title: {
108+
offsetCenter: ['22%', '-10%'],
109+
},
110+
detail: {
111+
valueAnimation: true,
112+
offsetCenter: ['22%', '0%'],
113+
},
114+
},
115+
{
116+
value: props.playerStats.clutch_rating,
117+
name: 'Clutching',
118+
title: {
119+
offsetCenter: ['-22%', '26%'],
120+
},
121+
detail: {
122+
valueAnimation: true,
123+
offsetCenter: ['-22%', '36%'],
124+
},
125+
},
126+
{
127+
value: props.playerStats.opening_duels_rating,
128+
name: 'Opening Duels',
129+
title: {
130+
offsetCenter: ['22%', '26%'],
131+
},
132+
detail: {
133+
valueAnimation: true,
134+
offsetCenter: ['22%', '36%'],
135+
},
136+
},
137+
],
138+
title: {
139+
fontSize: 14,
140+
},
141+
detail: {
142+
width: 50,
143+
height: 12,
144+
fontSize: 14,
145+
color: 'auto',
146+
borderColor: 'auto',
147+
borderRadius: 20,
148+
borderWidth: 1,
149+
formatter: '{value}%',
150+
},
151+
},
152+
],
153+
})
154+
return { option, showChart }
155+
},
156+
})
157+
</script>
158+
159+
<template>
160+
<VChart class="chart" :option="option" />
161+
</template>
162+
163+
<style scoped>
164+
.chart {
165+
height: 410px;
166+
width: 410px;
167+
}
168+
</style>

src/components/PlayerLeetifyStats.vue

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<script setup>
2+
import { ref } from 'vue'
3+
import LeetifyStatsGauge from '~/components/LeetifyStatsGauge.vue'
4+
5+
const props = defineProps({
6+
playerData: Object,
7+
})
8+
9+
const playerStats = ref({})
10+
const showStats = ref(false)
11+
12+
async function getPlayerStats(playerGameId) {
13+
showStats.value = false
14+
try {
15+
let json = await fetch(`https://api.leetify.com/api/mini-profiles/${playerGameId}`, {
16+
method: 'GET',
17+
})
18+
19+
json = await json.json()
20+
const leetStatsPlayer = json
21+
const baseRating = leetStatsPlayer.ratings.leetify * 100
22+
let leetifyRatingColor = 'white'
23+
if (baseRating <= -8.1)
24+
leetifyRatingColor = 'red'
25+
else if (baseRating <= -3.31)
26+
leetifyRatingColor = 'orange'
27+
else if (baseRating <= 3.31)
28+
leetifyRatingColor = 'white'
29+
else if (baseRating <= 8.10)
30+
leetifyRatingColor = 'lightgreen'
31+
else if (baseRating > 8.10)
32+
leetifyRatingColor = 'green'
33+
34+
playerStats.value.leetify_rating = (((baseRating - -8.5) * 100) / (8.5 - -8.5)).toFixed(2)
35+
playerStats.value.leetify_rating_color = leetifyRatingColor
36+
playerStats.value.aim_rating = leetStatsPlayer.ratings.aim.toFixed(2)
37+
playerStats.value.clutch_rating = (((leetStatsPlayer.ratings.clutch * 100) / 16) * 100).toFixed(2)
38+
playerStats.value.utility_rating = leetStatsPlayer.ratings.utility.toFixed(2)
39+
playerStats.value.positioning_rating = leetStatsPlayer.ratings.positioning.toFixed(2)
40+
playerStats.value.opening_duels_rating = (((leetStatsPlayer.ratings.opening - -10) * 100) / (10 - -10)).toFixed(2)
41+
showStats.value = true
42+
}
43+
catch (e) {
44+
// eslint-disable-next-line no-console
45+
console.log(e)
46+
}
47+
}
48+
watch(() => props.playerData, newValue => getPlayerStats(newValue.gameId))
49+
onMounted(() => {
50+
getPlayerStats(props.playerData.gameId)
51+
})
52+
</script>
53+
54+
<template>
55+
<div v-if="playerData.hasOwnProperty('gameId')" id="fec_player_leet_stats">
56+
{{ playerStats.nickname }}
57+
<LeetifyStatsGauge v-if="showStats" :player-stats="playerStats" />
58+
</div>
59+
</template>
60+
61+
<style scoped>
62+
</style>

src/components/README.md

-6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,3 @@
33
Components in this dir will be auto-registered and on-demand, powered by [`vite-plugin-components`](https://github.com/antfu/vite-plugin-components).
44

55
Components can be shared in all views.
6-
7-
### Icons
8-
9-
You can use icons from almost any icon sets by the power of [Iconify](https://iconify.design/).
10-
11-
It will only bundle the icons you use. Check out [vite-plugin-icons](https://github.com/antfu/vite-plugin-icons) for more details.

src/contentScripts/index.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { createApp } from 'vue'
2-
import { Quasar } from 'quasar'
32
import App from './views/App.vue'
4-
import 'quasar/src/css/index.sass'
5-
// eslint-disable-next-line import/order
6-
import quasarIconSet from 'quasar/icon-set/svg-material-icons'
73

84
// Firefox `browser.tabs.executeScript()` requires scripts return a primitive value
95
(() => {
@@ -59,10 +55,6 @@ import quasarIconSet from 'quasar/icon-set/svg-material-icons'
5955
shadowDOM.appendChild(styleEl)
6056
shadowDOM.appendChild(root)
6157
match_overview.prepend(container)
62-
app.use(Quasar, {
63-
plugins: {}, // import Quasar plugins and add here
64-
iconSet: quasarIconSet,
65-
})
6658
app.mount(root)
6759
}
6860
})()

src/contentScripts/views/App.vue

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<script setup lang="ts">
2-
import { Dark } from 'quasar'
32
import DisplayElo from '~/contentScripts/views/DisplayElo.vue'
4-
5-
Dark.set(true)
63
</script>
74

85
<template>

0 commit comments

Comments
 (0)