Skip to content

Commit

Permalink
refactor: remove unnecessary divs
Browse files Browse the repository at this point in the history
  • Loading branch information
7185 committed Nov 9, 2024
1 parent faf3f58 commit 59a26d6
Show file tree
Hide file tree
Showing 34 changed files with 916 additions and 986 deletions.
5 changes: 4 additions & 1 deletion action-parser/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
import type {Config} from '@jest/types'

const config: Config.InitialOptions = {
extensionsToTreatAsEsm: ['.ts', '.tsx'],
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest'
}
}
export default config
8 changes: 4 additions & 4 deletions action-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.10.0",
"@swc/core": "^1.7.40",
"@swc/jest": "^0.2.36",
"@swc/core": "^1.9.1",
"@swc/jest": "^0.2.37",
"@types/jest": "^29.5.14",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"eslint": "^9.13.0",
"globals": "^15.11.0",
"eslint": "^9.14.0",
"globals": "^15.12.0",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
Expand Down
10 changes: 5 additions & 5 deletions backend-py/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
aiofiles~=24.1.0
Flask-Caching~=2.3.0
httpx~=0.27.0
orjson~=3.10.6
prisma~=0.14.0
Quart~=0.19.6
httpx~=0.27.2
orjson~=3.10.10
prisma~=0.15.0
Quart~=0.19.8
Quart-JWT-Extended~=0.1.0
uvloop~=0.19.0
uvloop~=0.21.0
14 changes: 14 additions & 0 deletions backend/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type {Config} from '@jest/types'

const config: Config.InitialOptions = {
moduleFileExtensions: ['js', 'json', 'ts'],
rootDir: 'src',
testRegex: '.*\\.spec\\.ts$',
transform: {
'^.+\\.(t|j)s$': 'ts-jest'
},
collectCoverageFrom: ['**/*.{!(module),}.(t|j)s'],
coverageDirectory: '../coverage',
testEnvironment: 'node'
}
export default config
51 changes: 17 additions & 34 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,69 +24,52 @@
"dependencies": {
"@fastify/cookie": "^9.4.0",
"@fastify/static": "^8.0.1",
"@nestjs/axios": "^3.1.0",
"@nestjs/axios": "^3.1.2",
"@nestjs/cache-manager": "^2.3.0",
"@nestjs/common": "^10.4.6",
"@nestjs/core": "^10.4.6",
"@nestjs/common": "^10.4.7",
"@nestjs/core": "^10.4.7",
"@nestjs/jwt": "^10.2.0",
"@nestjs/platform-fastify": "^10.4.6",
"@nestjs/platform-ws": "^10.4.6",
"@nestjs/platform-fastify": "^10.4.7",
"@nestjs/platform-ws": "^10.4.7",
"@nestjs/serve-static": "^4.0.2",
"@nestjs/websockets": "^10.4.6",
"@prisma/client": "^5.21.1",
"@nestjs/websockets": "^10.4.7",
"@prisma/client": "^5.22.0",
"axios": "^1.7.7",
"cache-manager": "^5.7.6",
"class-validator": "^0.14.1",
"nestjs-pino": "^4.1.0",
"pino-pretty": "^11.3.0",
"pino-pretty": "^12.1.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"ws": "^8.18.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.2.2",
"@nestjs/testing": "^10.4.6",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.40",
"@nestjs/cli": "^10.4.7",
"@nestjs/schematics": "^10.2.3",
"@nestjs/testing": "^10.4.7",
"@swc/cli": "^0.5.0",
"@swc/core": "^1.9.1",
"@types/jest": "^29.5.14",
"@types/node": "^20.16.2",
"@types/supertest": "^6.0.2",
"@types/ws": "^8.5.12",
"@types/ws": "^8.5.13",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"eslint": "^9.13.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.11.0",
"globals": "^15.12.0",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"prisma": "^5.21.1",
"prisma": "^5.22.0",
"source-map-support": "^0.5.21",
"supertest": "^7.0.0",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "^5.6.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.{!(module),}.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
6 changes: 3 additions & 3 deletions bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.10.0",
"@types/node": "^20.16.2",
"@types/ws": "^8.5.12",
"@types/ws": "^8.5.13",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"eslint": "^9.13.0",
"globals": "^15.11.0",
"eslint": "^9.14.0",
"globals": "^15.12.0",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
"typescript": "^5.6.3"
Expand Down
18 changes: 9 additions & 9 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"@angular/common": "^18.2.2",
"@angular/compiler": "^18.2.2",
"@angular/core": "^18.2.2",
"@angular/forms": "^18.2.9",
"@angular/material": "^18.2.10",
"@angular/forms": "^18.2.11",
"@angular/material": "^18.2.12",
"@angular/platform-browser": "^18.2.2",
"@angular/platform-browser-dynamic": "^18.2.9",
"@angular/router": "^18.2.9",
"@angular/platform-browser-dynamic": "^18.2.11",
"@angular/router": "^18.2.11",
"@fontsource/arimo": "^5.1.0",
"@fortawesome/angular-fontawesome": "^0.15.0",
"@fortawesome/free-solid-svg-icons": "^6.6.0",
Expand All @@ -34,25 +34,25 @@
"fflate": "^0.8.2",
"linkify-string": "^4.1.3",
"rxjs": "~7.8.1",
"three": "^0.169.0",
"three": "^0.170.0",
"three-mesh-bvh": "^0.8.2",
"three-rwx-loader": "^0.12.4",
"tslib": "^2.8.0"
"tslib": "^2.8.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.8",
"@angular/cli": "^18.2.10",
"@angular/cli": "^18.2.11",
"@angular/compiler-cli": "^18.2.2",
"@types/node": "^20.16.2",
"@types/three": "^0.169.0",
"@types/webgl2": "^0.0.11",
"@typescript-eslint/types": "^8.10.0",
"angular-eslint": "^18.4.0",
"eslint": "^9.13.0",
"eslint": "^9.14.0",
"patch-package": "^8.0.0",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
"typescript": "~5.5.4",
"typescript-eslint": "^8.11.0"
"typescript-eslint": "^8.13.0"
}
}
4 changes: 2 additions & 2 deletions frontend/src/app/auth/auth.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container">
@defer (when !http.isLogged()) {
<form class="form-signin" (ngSubmit)="onLogin()" [formGroup]="loginForm">
<app-logo />
<mat-form-field appearance="outline">
Expand Down Expand Up @@ -78,4 +78,4 @@
</button>
}
</form>
</div>
}
3 changes: 2 additions & 1 deletion frontend/src/app/auth/auth.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.container {
:host {
display: block;
padding-top: 40px;
padding-bottom: 40px;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/auth/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class AuthComponent implements OnInit {
passwordCtl: FormControl<string | null>
private returnUrl: string

private readonly http = inject(HttpService)
protected readonly http = inject(HttpService)
private readonly fb = inject(FormBuilder)
private readonly router = inject(Router)
private readonly route = inject(ActivatedRoute)
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/app/engine/engine.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<div class="engine-wrapper">
<canvas #rendererCanvas id="render-canvas"></canvas>
<div #labelZone id="label-zone"></div>
<div #labelDesc id="label-desc"></div>
</div>
<canvas #rendererCanvas id="render-canvas"></canvas>
<div #labelZone id="label-zone"></div>
<div #labelDesc id="label-desc"></div>
3 changes: 2 additions & 1 deletion frontend/src/app/engine/engine.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.engine-wrapper {
:host {
display: block;
inset: 0;
z-index: 0;
pointer-events: all;
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/app/engine/engine.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
viewChild,
ViewEncapsulation
} from '@angular/core'
import type {AfterViewInit, ElementRef, OnDestroy, OnInit} from '@angular/core'
import type {ElementRef, OnDestroy, OnInit} from '@angular/core'
import {EngineService} from './engine.service'
import {WorldService} from '../world/world.service'

Expand All @@ -17,7 +17,7 @@ import {WorldService} from '../world/world.service'
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class EngineComponent implements OnInit, OnDestroy, AfterViewInit {
export class EngineComponent implements OnInit, OnDestroy {
rendererCanvas =
viewChild.required<ElementRef<HTMLCanvasElement>>('rendererCanvas')
labelZone = viewChild.required<ElementRef<HTMLDivElement>>('labelZone')
Expand All @@ -32,9 +32,6 @@ export class EngineComponent implements OnInit, OnDestroy, AfterViewInit {
this.labelZone(),
this.labelDesc()
)
}

ngAfterViewInit(): void {
this.world.initWorld()
this.engineSvc.animate()
}
Expand Down
29 changes: 8 additions & 21 deletions frontend/src/app/network/http.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {throwError} from 'rxjs'
import {inject, Injectable, signal} from '@angular/core'
import {computed, inject, Injectable, signal} from '@angular/core'
import type {WritableSignal} from '@angular/core'
import {HttpClient} from '@angular/common/http'
import type {HttpResponse} from '@angular/common/http'
Expand All @@ -19,16 +19,17 @@ export interface Avatar {
export class HttpService extends HttpClient {
private baseUrl = environment.url.server
private userLogged = signal<User>(new User())
#expiration = parseInt(localStorage.getItem('expiration') ?? '0', 10)
#expiration = signal(parseInt(localStorage.getItem('expiration') ?? '0', 10))
isLogged = computed(() => Math.floor(Date.now() / 1000) < this.#expiration())

private readonly router = inject(Router)

get expiration(): number {
return this.#expiration
return this.#expiration()
}

set expiration(value: number) {
this.#expiration = value
this.#expiration.set(value)
localStorage.setItem('expiration', value.toString())
}

Expand All @@ -39,14 +40,6 @@ export class HttpService extends HttpClient {
return c ? c.pop() : ''
}

isLogged(): boolean {
return !this.hasExpired()
}

setLogged(logged: User): void {
this.userLogged.set(logged)
}

getLogged(): WritableSignal<User> {
if (this.userLogged().id == null) {
this.session().subscribe()
Expand All @@ -58,7 +51,7 @@ export class HttpService extends HttpClient {
return this.post(`${this.baseUrl}/auth/`, {login, password}).pipe(
tap((data) => {
this.expiration = Math.floor(new Date().getTime() / 1000) + 36000
this.setLogged(new User(data))
this.userLogged.set(new User(data))
})
)
}
Expand All @@ -67,7 +60,7 @@ export class HttpService extends HttpClient {
this.expiration = 0
return this.delete(`${this.baseUrl}/auth/`).pipe(
tap(() => {
this.setLogged(new User())
this.userLogged.set(new User())
this.router.navigate(['login'])
})
)
Expand All @@ -79,7 +72,7 @@ export class HttpService extends HttpClient {
this.logout().subscribe()
return throwError(() => error)
}),
tap((data) => this.setLogged(new User(data)))
tap((data) => this.userLogged.set(new User(data)))
)
}

Expand Down Expand Up @@ -184,10 +177,4 @@ export class HttpService extends HttpClient {
params: {page_x: pageX, page_z: pageZ}
})
}

private hasExpired(): boolean {
return (
this.expiration === 0 || Math.floor(Date.now() / 1000) >= this.expiration
)
}
}
Loading

0 comments on commit 59a26d6

Please sign in to comment.