Skip to content

Commit 61a8cce

Browse files
author
marcus-sa
committed
feat: initial client integrations
1 parent b4d8026 commit 61a8cce

34 files changed

+209
-69
lines changed

apps/client/project.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"format-util"
2525
],
2626
"styles": ["apps/client/src/styles.css"],
27-
"scripts": [],
28-
"buildLibsFromSource": false
27+
"scripts": []
2928
},
3029
"configurations": {
3130
"production": {

apps/client/src/app/app.component.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { RouterModule } from '@angular/router';
1010
import { Dialog, DialogModule } from '@angular/cdk/dialog';
1111
import { NgIf } from '@angular/common';
1212

13-
import { Scuti } from '@apex/scuti-renderer';
13+
// import { Scuti } from '@apex/scuti-renderer';
1414

1515
@Component({
1616
selector: 'apex-root',
@@ -25,7 +25,8 @@ export class AppComponent implements OnInit {
2525
@ViewChild('init', { static: true })
2626
readonly initTemplateRef: TemplateRef<unknown>;
2727

28-
renderer: Scuti;
28+
// renderer: Scuti;
29+
2930
assetsLoaded = signal(false);
3031

3132
constructor(private readonly dialog: Dialog) {}
@@ -34,15 +35,15 @@ export class AppComponent implements OnInit {
3435
const dialogRef = this.dialog.open(this.initTemplateRef, {
3536
hasBackdrop: true,
3637
});
37-
this.renderer = new Scuti({
38-
width: window.innerWidth,
39-
height: window.innerHeight,
40-
canvas: this.canvasElementRef.nativeElement,
41-
resources: 'http://localhost:8083',
42-
backgroundColor: 0x212225,
43-
resizeTo: window,
44-
});
45-
await this.renderer.load();
38+
// this.renderer = new Scuti({
39+
// width: window.innerWidth,
40+
// height: window.innerHeight,
41+
// canvas: this.canvasElementRef.nativeElement,
42+
// resources: 'http://localhost:8083',
43+
// backgroundColor: 0x212225,
44+
// resizeTo: window,
45+
// });
46+
// await this.renderer.load();
4647
this.assetsLoaded.set(true);
4748
dialogRef.close();
4849
}

apps/client/src/app/app.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { ApplicationConfig } from '@angular/core';
22
import { provideRouter } from '@angular/router';
33
import { deserialize } from '@deepkit/type';
44

5-
import { ApexClientConfig } from '@apex/client';
5+
import { ApexClientConfig, importProvidersDynamicallyFrom } from '@apex/client';
66

77
import { routes } from './routes';
88
import { provideRpcClient } from './utils';
99
import { GameController } from './game';
1010
import { MessengerController } from './messenger';
1111
import { RoomController } from './room';
12+
import { IntegrationsModule } from './integrations';
1213

1314
export const clientConfig = deserialize<ApexClientConfig>(
1415
(window as any)['APEX_CLIENT_CONFIG'],
@@ -26,5 +27,8 @@ export const appConfig: ApplicationConfig = {
2627
provide: ApexClientConfig,
2728
useValue: clientConfig,
2829
},
30+
importProvidersDynamicallyFrom(
31+
new IntegrationsModule(clientConfig.integrations),
32+
),
2933
],
3034
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './integrations.module';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { DynamicNgModule, IntegrationsConfig } from '@apex/client';
2+
import { SupabaseModule } from '@apex/integrations/supabase/client';
3+
4+
export class IntegrationsModule extends DynamicNgModule<IntegrationsModule> {
5+
constructor(private readonly config: IntegrationsConfig) {
6+
super();
7+
}
8+
9+
process() {
10+
if (this.config.supabase) {
11+
this.addImport(SupabaseModule);
12+
}
13+
}
14+
}

apps/client/src/app/room/room.component.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import { Component, DestroyRef, Inject, OnInit, signal } from '@angular/core';
1+
import { Component, DestroyRef, OnInit } from '@angular/core';
22
import { Dialog } from '@angular/cdk/dialog';
3-
import { ActivatedRoute, Router } from '@angular/router';
3+
import { ActivatedRoute } from '@angular/router';
44
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5-
import { Observable } from 'rxjs';
65

76
import { Room, RoomState } from '@apex/api/shared';
8-
import {
9-
FloorMaterial as ScutiFloorMaterial,
10-
Room as ScutiRoom,
11-
WallMaterial as ScutiWallMaterial,
12-
} from '@apex/scuti-renderer';
13-
147
import { JoinRoomOptions } from '@apex/api/server';
158
import { RoomChatMessageEvent } from '@apex/api/client';
9+
// import {
10+
// FloorMaterial as ScutiFloorMaterial,
11+
// Room as ScutiRoom,
12+
// WallMaterial as ScutiWallMaterial,
13+
// } from '@apex/scuti-renderer';
1614

1715
import { AppComponent } from '../app.component';
1816
import { RoomService } from './room.service';
@@ -26,7 +24,7 @@ import { RoomController } from './room.controller';
2624
templateUrl: './room.component.html',
2725
})
2826
export class RoomComponent implements OnInit {
29-
scutiRoom?: ScutiRoom;
27+
// scutiRoom?: ScutiRoom;
3028

3129
constructor(
3230
private readonly app: AppComponent,
@@ -39,18 +37,18 @@ export class RoomComponent implements OnInit {
3937
) {}
4038

4139
private render(room: Room) {
42-
this.scutiRoom = new ScutiRoom({
43-
heightMap: room.map,
44-
dragging: true,
45-
centerCamera: true,
46-
floorMaterial: new ScutiFloorMaterial(101),
47-
floorThickness: 8,
48-
wallMaterial: new ScutiWallMaterial(108),
49-
wallThickness: 8,
50-
wallHeight: -1,
51-
});
52-
53-
this.app.renderer.add(this.scutiRoom);
40+
// this.scutiRoom = new ScutiRoom({
41+
// heightMap: room.map,
42+
// dragging: true,
43+
// centerCamera: true,
44+
// floorMaterial: new ScutiFloorMaterial(101),
45+
// floorThickness: 8,
46+
// wallMaterial: new ScutiWallMaterial(108),
47+
// wallThickness: 8,
48+
// wallHeight: -1,
49+
// });
50+
//
51+
// this.app.renderer.add(this.scutiRoom);
5452
}
5553

5654
private async join(id: Room['id'], options?: JoinRoomOptions): Promise<Room> {
@@ -67,7 +65,9 @@ export class RoomComponent implements OnInit {
6765
if (!this.service.isOwner(this.user.me, room)) {
6866
// room.users.length === room.capacity
6967
if (room.state === RoomState.FULL) {
68+
/* eslint-disable no-empty */
7069
} else if (room.state === RoomState.LOCKED) {
70+
/* eslint-disable no-empty */
7171
} else if (room.state === RoomState.PASSWORD_PROTECTED) {
7272
const dialogRef = this.dialog.open(
7373
PasswordProtectedRoomDialogComponent,

apps/client/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<base href="/" />
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
88
<link rel="icon" type="image/x-icon" href="favicon.ico" />
9-
<script src=http://localhost:8080/config.js"></script>
9+
<script src="http://localhost:8080/config.js"></script>
1010
<!--<link
1111
rel="stylesheet"
1212
rel="preload"

apps/client/tsconfig.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"extends": "../../tsconfig.base.json",
23
"compilerOptions": {
34
"target": "es2022",
45
"useDefineForClassFields": false,
@@ -28,15 +29,10 @@
2829
"path": "./tsconfig.worker.json"
2930
}
3031
],
31-
"extends": "../../tsconfig.base.json",
3232
"angularCompilerOptions": {
3333
"enableI18nLegacyMessageIdFormat": false,
3434
"strictInjectionParameters": true,
3535
"strictInputAccessModifiers": true,
3636
"strictTemplates": true
37-
},
38-
"reflection": [
39-
"src/**/*.controller.ts",
40-
"src/**/*-dialog.component.ts"
41-
]
37+
}
4238
}

apps/client/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join } from 'node:path';
1+
import { join } from 'path';
22
import { defineConfig } from 'vite';
33
import { deepkitType } from '@deepkit/vite';
44
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

libs/api/client/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"name": "@apex/api/client",
33
"version": "0.0.1",
44
"dependencies": {},
5-
"type": "commonjs",
6-
"main": "./index.cjs",
5+
"type": "module",
76
"module": "./index.js",
87
"reflection": true
98
}

0 commit comments

Comments
 (0)