mirror of
https://github.com/Discreetly/frontend.git
synced 2026-05-04 03:00:34 -04:00
type cleanup
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { storable, sessionable } from './storeFactory';
|
||||
import { writable, derived } from 'svelte/store';
|
||||
import { derived } from 'svelte/store';
|
||||
import { configDefaults } from '$lib/defaults';
|
||||
import type {
|
||||
ConfigurationI,
|
||||
IdentityStoreI,
|
||||
messageStoreI,
|
||||
pixelStoreI,
|
||||
rateLimitStoreI,
|
||||
roomStoreI,
|
||||
selectedRoomStoreI,
|
||||
@@ -52,6 +53,8 @@ export const currentSelectedRoom = derived(
|
||||
*/
|
||||
export const messageStore = sessionable({} as messageStoreI, 'messages');
|
||||
|
||||
export const pixelStore = sessionable({} as pixelStoreI, 'pixelmaps');
|
||||
|
||||
/* ------------------ Misc State ------------------*/
|
||||
/**
|
||||
* @description Configuration and misc state
|
||||
|
||||
18
src/lib/types/enums.ts
Normal file
18
src/lib/types/enums.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export enum Experiences {
|
||||
'Chat',
|
||||
'Draw'
|
||||
}
|
||||
|
||||
export enum IdentityStoreE {
|
||||
'NO_IDENTITY',
|
||||
'localStorage',
|
||||
'cryptKeeper',
|
||||
'PCDPass'
|
||||
}
|
||||
|
||||
export enum ActionRepresentationE {
|
||||
'AP',
|
||||
'Hearts',
|
||||
'Shields',
|
||||
'Battery'
|
||||
}
|
||||
@@ -1,87 +1,3 @@
|
||||
import type { MessageI, RoomI as RI, ServerI } from 'discreetly-interfaces';
|
||||
|
||||
export interface ButtonI {
|
||||
link: string;
|
||||
cls: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface IdentityStoreI {
|
||||
_commitment: string;
|
||||
_trapdoor: string;
|
||||
_nullifier: string;
|
||||
_secret: string;
|
||||
}
|
||||
|
||||
export interface JoinResponseI {
|
||||
status: string;
|
||||
roomIds: string[];
|
||||
}
|
||||
|
||||
// Keyed by server URL
|
||||
export interface serverStoreI {
|
||||
[key: string]: ServerI;
|
||||
}
|
||||
|
||||
// Keyed by server URL
|
||||
export interface selectedRoomStoreI {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
// Keyed by roomId
|
||||
export interface roomStoreI {
|
||||
[key: string]: RoomI;
|
||||
}
|
||||
|
||||
// Keyed by roomId
|
||||
export interface messageStoreI {
|
||||
[key: string]: MessageI[];
|
||||
}
|
||||
|
||||
// Keyed by roomId
|
||||
export interface rateLimitStoreI {
|
||||
[key: string]: {
|
||||
lastEpoch: number;
|
||||
messagesSent: number;
|
||||
};
|
||||
}
|
||||
|
||||
export enum IdentityStoreE {
|
||||
'NO_IDENTITY',
|
||||
'localStorage',
|
||||
'cryptKeeper',
|
||||
'PCDPass'
|
||||
}
|
||||
|
||||
export interface SignUpStatusI {
|
||||
inviteAccepted: boolean;
|
||||
identityBackedUp: boolean;
|
||||
inviteCode?: string;
|
||||
}
|
||||
|
||||
export enum ActionRepresentationE {
|
||||
'AP',
|
||||
'Hearts',
|
||||
'Shields',
|
||||
'Battery'
|
||||
}
|
||||
|
||||
export interface ConfigurationI {
|
||||
signUpStatus: SignUpStatusI;
|
||||
identityStore: IdentityStoreE;
|
||||
apiUsername?: string;
|
||||
apiPassword?: string;
|
||||
actionRepresentation?: ActionRepresentationE;
|
||||
}
|
||||
|
||||
export interface RoomI extends RI {
|
||||
server?: string;
|
||||
}
|
||||
|
||||
export interface InviteCode {
|
||||
claimcode: string;
|
||||
}
|
||||
export interface Invites {
|
||||
message?: string;
|
||||
codes: InviteCode[];
|
||||
}
|
||||
export * from './stores';
|
||||
export * from './enums';
|
||||
export * from './interfaces';
|
||||
|
||||
42
src/lib/types/interfaces.ts
Normal file
42
src/lib/types/interfaces.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { IdentityStoreE, ActionRepresentationE, Experiences } from '.';
|
||||
import type { RoomI as RI } from 'discreetly-interfaces';
|
||||
|
||||
export interface ConfigurationI {
|
||||
signUpStatus: SignUpStatusI;
|
||||
identityStore: IdentityStoreE;
|
||||
apiUsername?: string;
|
||||
apiPassword?: string;
|
||||
actionRepresentation?: ActionRepresentationE;
|
||||
experience?: Experiences;
|
||||
}
|
||||
|
||||
export interface RoomI extends RI {
|
||||
server?: string;
|
||||
}
|
||||
|
||||
export interface InviteCode {
|
||||
claimcode: string;
|
||||
}
|
||||
export interface Invites {
|
||||
message?: string;
|
||||
codes: InviteCode[];
|
||||
}
|
||||
|
||||
export interface ButtonI {
|
||||
link: string;
|
||||
cls: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface JoinResponseI {
|
||||
status: string;
|
||||
roomIds: string[];
|
||||
}
|
||||
|
||||
// Keyed by roomId
|
||||
|
||||
export interface SignUpStatusI {
|
||||
inviteAccepted: boolean;
|
||||
identityBackedUp: boolean;
|
||||
inviteCode?: string;
|
||||
}
|
||||
41
src/lib/types/stores.ts
Normal file
41
src/lib/types/stores.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import type { ServerI, MessageI, HexColor } from 'discreetly-interfaces';
|
||||
import type { RoomI } from './interfaces';
|
||||
|
||||
// Keyed by server URL
|
||||
export interface serverStoreI {
|
||||
[key: string]: ServerI;
|
||||
}
|
||||
|
||||
// Keyed by server URL
|
||||
export interface selectedRoomStoreI {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
// Keyed by roomId
|
||||
export interface roomStoreI {
|
||||
[key: string]: RoomI;
|
||||
}
|
||||
|
||||
// Keyed by roomId
|
||||
export interface messageStoreI {
|
||||
[key: string]: MessageI[];
|
||||
}
|
||||
|
||||
// Keyed by roomId
|
||||
export interface pixelStoreI {
|
||||
[key: string]: HexColor[][];
|
||||
}
|
||||
|
||||
export interface IdentityStoreI {
|
||||
_commitment: string;
|
||||
_trapdoor: string;
|
||||
_nullifier: string;
|
||||
_secret: string;
|
||||
}
|
||||
|
||||
export interface rateLimitStoreI {
|
||||
[key: string]: {
|
||||
lastEpoch: number;
|
||||
messagesSent: number;
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '@skeletonlabs/skeleton';
|
||||
import { AppShell, Modal } from '@skeletonlabs/skeleton';
|
||||
import { Toast } from '@skeletonlabs/skeleton';
|
||||
import '../theme.postcss';
|
||||
import '@skeletonlabs/skeleton/styles/skeleton.css';
|
||||
@@ -34,38 +34,10 @@
|
||||
<SelectServer />
|
||||
<SelectRoom />
|
||||
</Drawer>
|
||||
<app id="app">
|
||||
<div id="header">
|
||||
<AppHeader />
|
||||
</div>
|
||||
<div id="main">
|
||||
<slot>
|
||||
<Loading />
|
||||
</slot>
|
||||
</div>
|
||||
<!-- <div id="footer">
|
||||
<AppFooter />
|
||||
</div> -->
|
||||
</app>
|
||||
|
||||
<style>
|
||||
#app {
|
||||
height: 100vh;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: auto 1fr auto;
|
||||
grid-template-areas: 'head' 'main' 'foot';
|
||||
}
|
||||
#app > #header {
|
||||
grid-area: head;
|
||||
}
|
||||
|
||||
#app > #main {
|
||||
grid-area: main;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#app > #footer {
|
||||
grid-area: foot;
|
||||
}
|
||||
</style>
|
||||
<AppShell>
|
||||
<svelte:fragment slot="header"><AppHeader /></svelte:fragment>
|
||||
<slot>
|
||||
<Loading />
|
||||
</slot>
|
||||
</AppShell>
|
||||
|
||||
@@ -10,9 +10,6 @@ export default defineConfig({
|
||||
rollupOptions: {
|
||||
plugins: [sizes()],
|
||||
output: {
|
||||
manualChunks: {
|
||||
'@sveltejs/kit': ['@sveltejs/kit']
|
||||
},
|
||||
compact: true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user