Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.

Commit 4b2d23c

Browse files
committed
feat: add website extension metadata
1 parent 94c88ef commit 4b2d23c

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/views/OAuth2.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function handleRoute() {
2828
const params = new URLSearchParams(route.hash.slice(1));
2929
const token = params.get("token");
3030
31-
let is7TV;
31+
let is7TV: boolean;
3232
try {
3333
is7TV = opener.location.origin === window.origin;
3434
} catch (e) {

src/worker/worker.events.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ export class EventAPI {
2828
connect(transport: EventAPITransport): void {
2929
if (this.eventSource || this.socket || !this.url) return;
3030

31+
const url = new URL(this.url);
32+
33+
// Add query param giving the version of the website / src
34+
url.searchParams.append("app", "7tv-website-old");
35+
url.searchParams.append("version", import.meta.env.VITE_APP_VERSION);
36+
3137
this.transport = transport;
3238

3339
if (this.transport === "WebSocket") {
34-
this.socket = new WebSocket(this.url);
40+
this.socket = new WebSocket(url);
3541
this.socket.onopen = () => this.onOpen();
3642
this.socket.onclose = () => this.onClose();
3743
this.socket.onmessage = (ev) => {
@@ -44,7 +50,7 @@ export class EventAPI {
4450
};
4551
}
4652

47-
log.debug("<EventAPI>", "Connecting...", `url=${this.url}`);
53+
log.debug("<EventAPI>", "Connecting...", `url=${url}`);
4854
}
4955

5056
getSocket(): WebSocket | null {

src/worker/worker.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export function handleMessage<N extends WorkerMessageName>(evt: WorkerMessage<N>
1111
switch (evt.name) {
1212
case "EventCommandSubscribe": {
1313
const d = evt.data as WorkerMessageData<"EventCommandSubscribe">;
14-
1514
eventAPI.subscribe(d.type, d.condition);
1615
break;
1716
}

tsconfig.node.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"compilerOptions": {
33
"composite": true,
44
"module": "esnext",
5-
"moduleResolution": "node"
5+
"moduleResolution": "node",
6+
"resolveJsonModule": true
67
},
78
"include": ["vite.config.ts"]
89
}

vite.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import { version } from "./package.json";
12
import vue from "@vitejs/plugin-vue";
23
import { resolve } from "path";
34
import { visualizer } from "rollup-plugin-visualizer";
45
import { defineConfig, loadEnv } from "vite";
56

67
// https://vitejs.dev/config/
78
export default ({ mode }) => {
8-
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
9+
process.env = {
10+
...process.env,
11+
...loadEnv(mode, process.cwd()),
12+
VITE_APP_VERSION: version,
13+
};
914

1015
return defineConfig({
1116
build: {

0 commit comments

Comments
 (0)