diff --git a/app/net/client/local.js b/app/client/local.js similarity index 93% rename from app/net/client/local.js rename to app/client/local.js index 3209a4f..42417fb 100644 --- a/app/net/client/local.js +++ b/app/client/local.js @@ -1,4 +1,4 @@ -import Client from './client.js'; +import Client from '@/net/client.js'; export default class LocalClient extends Client { async connect() { diff --git a/app/net/client/prediction.js b/app/client/prediction.js similarity index 100% rename from app/net/client/prediction.js rename to app/client/prediction.js diff --git a/app/net/client/remote.js b/app/client/remote.js similarity index 94% rename from app/net/client/remote.js rename to app/client/remote.js index a678307..18b4535 100644 --- a/app/net/client/remote.js +++ b/app/client/remote.js @@ -1,8 +1,7 @@ +import Client from '@/net/client.js'; import {encode} from '@/net/packets/index.js'; import {CLIENT_PREDICTION} from '@/util/constants.js'; -import Client from './client.js'; - export default class RemoteClient extends Client { constructor() { super(); @@ -16,7 +15,7 @@ export default class RemoteClient extends Client { async connect(host) { if (CLIENT_PREDICTION) { this.worker = new Worker( - new URL('../client/prediction.js', import.meta.url), + new URL('./prediction.js', import.meta.url), {type: 'module'}, ); this.worker.postMessage({host}); diff --git a/app/entry.server.jsx b/app/entry.server.jsx index 2f82967..5c43a41 100644 --- a/app/entry.server.jsx +++ b/app/entry.server.jsx @@ -17,10 +17,10 @@ export async function websocket(server, viteDevServer) { if (viteDevServer) { const {createViteRuntime} = await import('vite'); const runtime = await createViteRuntime(viteDevServer); - (await runtime.executeEntrypoint('/app/websocket.js')).default(server); + (await runtime.executeEntrypoint('/app/server/websocket.js')).default(server); } else { - (await import('./websocket.js')).default(server); + (await import('./server/websocket.js')).default(server); } } diff --git a/app/net/client/client.js b/app/net/client.js similarity index 100% rename from app/net/client/client.js rename to app/net/client.js diff --git a/app/net/server/server.js b/app/net/server.js similarity index 100% rename from app/net/server/server.js rename to app/net/server.js diff --git a/app/routes/_main-menu.play.$.$/route.jsx b/app/routes/_main-menu.play.$.$/route.jsx index 714bedb..3bf682e 100644 --- a/app/routes/_main-menu.play.$.$/route.jsx +++ b/app/routes/_main-menu.play.$.$/route.jsx @@ -9,8 +9,8 @@ import DebugContext from '@/react/context/debug.js'; import EcsContext from '@/react/context/ecs.js'; import MainEntityContext from '@/react/context/main-entity.js'; import RadiansContext from '@/react/context/radians.js'; +import {juggleSession} from '@/server/session.server.js'; import {TAU} from '@/util/math.js'; -import {juggleSession} from '@/util/session.server'; export async function loader({request}) { await juggleSession(request); diff --git a/app/routes/_main-menu.play.$/route.jsx b/app/routes/_main-menu.play.$/route.jsx index 840b5e6..53ea8a4 100644 --- a/app/routes/_main-menu.play.$/route.jsx +++ b/app/routes/_main-menu.play.$/route.jsx @@ -14,10 +14,10 @@ export default function Play() { let Client; switch (type) { case 'local': - ({default: Client} = await import('@/net/client/local.js')); + ({default: Client} = await import('@/client/local.js')); break; case 'remote': - ({default: Client} = await import('@/net/client/remote.js')); + ({default: Client} = await import('@/client/remote.js')); break; } class SilphiusClient extends Client { diff --git a/app/create/ecs.js b/app/server/create/ecs.js similarity index 100% rename from app/create/ecs.js rename to app/server/create/ecs.js diff --git a/app/create/forest.js b/app/server/create/forest.js similarity index 100% rename from app/create/forest.js rename to app/server/create/forest.js diff --git a/app/create/homestead.js b/app/server/create/homestead.js similarity index 100% rename from app/create/homestead.js rename to app/server/create/homestead.js diff --git a/app/create/house.js b/app/server/create/house.js similarity index 100% rename from app/create/house.js rename to app/server/create/house.js diff --git a/app/create/player.js b/app/server/create/player.js similarity index 100% rename from app/create/player.js rename to app/server/create/player.js diff --git a/app/engine.js b/app/server/engine.js similarity index 100% rename from app/engine.js rename to app/server/engine.js diff --git a/app/util/session.server.js b/app/server/session.server.js similarity index 100% rename from app/util/session.server.js rename to app/server/session.server.js diff --git a/app/websocket.js b/app/server/websocket.js similarity index 93% rename from app/websocket.js rename to app/server/websocket.js index ebc9296..92077c2 100644 --- a/app/websocket.js +++ b/app/server/websocket.js @@ -3,8 +3,8 @@ import {dirname, join} from 'node:path'; import {WebSocketServer} from 'ws'; -import Server from '@/net/server/server.js'; -import {getSession} from '@/util/session.server.js'; +import Server from '@/net/server.js'; +import {getSession} from '@/server/session.server.js'; import Engine from './engine.js'; @@ -48,7 +48,7 @@ class SocketServer extends Server { await mkdir(path, {recursive: true}); } static qualify(path) { - return join(import.meta.dirname, '..', 'data', 'remote', 'UNIVERSE', path); + return join(import.meta.dirname, '..', '..', 'data', 'remote', 'UNIVERSE', path); } async readAsset(path) { const url = new URL(path, 'https://localhost:3000') diff --git a/app/net/server/worker.js b/app/server/worker.js similarity index 86% rename from app/net/server/worker.js rename to app/server/worker.js index 969c862..b04354a 100644 --- a/app/net/server/worker.js +++ b/app/server/worker.js @@ -1,14 +1,14 @@ import {del, get, set} from 'idb-keyval'; import {encode} from '@/net/packets/index.js'; +import Server from '@/net/server.js'; -import createEcs from '../../create/ecs.js'; -import '../../create/forest.js'; -import '../../create/homestead.js'; -import '../../create/player.js'; +import createEcs from './create/ecs.js'; +import './create/forest.js'; +import './create/homestead.js'; +import './create/player.js'; -import Engine from '../../engine.js'; -import Server from './server.js'; +import Engine from './engine.js'; class WorkerServer extends Server { constructor() { @@ -78,8 +78,8 @@ if (import.meta.hot) { await engine.saveEcses(); beforeResolver.resolve(); }); - import.meta.hot.accept('../../engine.js'); - import.meta.hot.accept('../../create-player.js', async ({default: createPlayer}) => { + import.meta.hot.accept('./engine.js'); + import.meta.hot.accept('./create/player.js', async ({default: createPlayer}) => { const resolver = createResolver(); resolvers.push(resolver); await beforeResolver; @@ -93,7 +93,7 @@ if (import.meta.hot) { await engine.server.writeData('players/0', (new TextEncoder()).encode(JSON.stringify(player))); resolver.resolve(); }); - import.meta.hot.accept('../../create-forest.js', async ({default: createForest}) => { + import.meta.hot.accept('./create/forest.js', async ({default: createForest}) => { const resolver = createResolver(); resolvers.push(resolver); await beforeResolver; @@ -106,7 +106,7 @@ if (import.meta.hot) { await engine.saveEcs('forests/0', forest); resolver.resolve(); }); - import.meta.hot.accept('../../create-homestead.js', async ({default: createHomestead}) => { + import.meta.hot.accept('./create/homestead.js', async ({default: createHomestead}) => { const resolver = createResolver(); resolvers.push(resolver); await beforeResolver;