monorepo part 2

This commit is contained in:
Spencer Pogorzelski 2023-08-12 12:23:45 -07:00
parent 2138e02613
commit 6dc4aa8c6b
17 changed files with 165 additions and 66 deletions

View file

@ -20,7 +20,11 @@
"typescript": "^5.1.6",
"vite": "^4.4.9",
"vite-plugin-singlefile": "^0.13.5",
"vite-plugin-svelte": "^3.0.1"
"vite-plugin-svelte": "^3.0.1",
"bare-client-custom": "file:../bare-client-custom",
"firebase-config": "workspace:*",
"client": "workspace:*",
"protocol": "workspace:*"
},
"devDependencies": {}
}

View file

@ -1,13 +1,14 @@
<script lang="ts">
import { AdriftBareClient } from "../client/AdriftClient";
import Connection from "../client/Connection";
import { DevWsTransport } from "../client/DevWsTransport";
import { RTCTransport } from "../client/RTCTransport";
// note: even though we import firebase, due to the tree shaking, it will only run if we use "auth" so if ADRIFT_DEV is set it won't import
import { auth } from "../firebase-config";
import type Transport from "../protocol/Transport";
import {
BareClient,
AdriftBareClient,
Connection,
DevWsTransport,
RTCTransport,
} from "client";
// note: even though we import firebase, due to the tree shaking, it will only run if we use "auth" so if ADRIFT_DEV is set it won't import
import { auth } from "firebase-config";
import type { Transport } from "protocol";
import {
registerRemoteListener,
setBareClientImplementation,
} from "bare-client-custom";
@ -16,14 +17,13 @@
let transport: Transport;
let wstransport: DevWsTransport | undefined;
let rtctransport: RTCTransport | undefined;
if (import.meta.env.VITE_ADRIFT_DEV) {
console.log(
"%cADRIFT RUNNING IN DEVELOPMENT MODE",
"background: blue; color: white; font-size: x-large"
);
wstransport = transport = new DevWsTransport(
transport = new DevWsTransport(
() => console.log("onopen"),
() => console.log("onclose")
);
@ -101,13 +101,12 @@
const { answer, candidates } = await r.json();
await rtctransport?.answer(answer, candidates);
}
// connectDevHttp();
</script>
<h1>
{#if !import.meta.env.VITE_ADRIFT_DEV}
<button on:click={connectFirebase}>Connect with firebase </button>
{:else}
connected to dev server
<button on:click={connectDevHttp}>Connect with dev HTTP</button>
{/if}
</h1>

View file

@ -1,7 +1,7 @@
import App from "./App.svelte";
const app = new App({
target: document.getElementById("app")
target: document.getElementById("app")!,
});
if (!import.meta.env.VITE_ADRIFT_SINGLEFILE) {

9
frontend/src/env.d.ts vendored Normal file
View file

@ -0,0 +1,9 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_ADRIFT_DEV: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}

View file

@ -10,4 +10,4 @@ const config = {
],
};
module.exports = config;
module.exports = config;

33
frontend/tsconfig.json Normal file
View file

@ -0,0 +1,33 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"baseUrl": ".",
"outDir": "build/dist",
"module": "esnext",
"target": "es2017",
"lib": ["es6", "dom", "esnext.asynciterable", "es2017"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "..",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"removeComments": true
},
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest",
"src/setupTests.ts"
]
}