Skip to content

Commit

Permalink
Port Desktop to use @ystv/vmix
Browse files Browse the repository at this point in the history
  • Loading branch information
markspolakovs committed Aug 26, 2024
1 parent 1aee197 commit 7774c6e
Show file tree
Hide file tree
Showing 20 changed files with 240 additions and 864 deletions.
2 changes: 1 addition & 1 deletion desktop/e2e/complete/vmix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
server,
} from "./serverAPI";
import type { CompleteShowType } from "../../src/common/types";
import type VMixConnection from "../../src/main/vmix/vmix";
import type VMixConnection from "@ystv/vmix";
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";

let testShow: CompleteShowType;
Expand Down
110 changes: 61 additions & 49 deletions desktop/electron.vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ const visualizeBundle = process.argv.includes("--visualize-bundle");
* can import (and forbid importing @badger/prisma/client).
* However, zod-prisma-types still needs to import the actual Prisma client in one place,
* transformJsonNull.ts, so that it can access Prisma.JsonNull/Prisma.DbNull.
*
*
* To fix this, we stub out this one import, which thereby ensures the Prisma client runtime
* never gets bundled in. This is safe to do, because we will never need to interact with
* Prisma.{Db,Json}Null in Desktop.
*/
const jsonNullStub = "export const transformJsonNull = v => v; export default transformJsonNull;"
const jsonNullStubPlaceholder = "\0ignore_prisma_placeholder"
const jsonNullStub =
"export const transformJsonNull = v => v; export default transformJsonNull;";
const jsonNullStubPlaceholder = "\0ignore_prisma_placeholder";
/** @type {import("vite").Plugin} */
const IgnorePrismaJsonNullPlugin = {
name: "ignorePrismaJsonNull",
Expand All @@ -42,12 +43,14 @@ const IgnorePrismaJsonNullPlugin = {
return null;
},
load(name) {
return name === jsonNullStubPlaceholder ? {
code: jsonNullStub,
moduleSideEffects: false,
} : null;
return name === jsonNullStubPlaceholder
? {
code: jsonNullStub,
moduleSideEffects: false,
}
: null;
},
enforce: "pre"
enforce: "pre",
};

const base = defineConfig({
Expand Down Expand Up @@ -107,49 +110,58 @@ const base = defineConfig({
* @type {import('electron-vite').UserConfig}
*/
const config = {
main: mergeConfig(base, defineConfig({
plugins: [
IgnorePrismaJsonNullPlugin,
commonjs(),
visualizeBundle &&
visualizer({
filename: "bundle-main.html",
}),
].filter(Boolean),
resolve: {
conditions: ["node"],
browserField: false,
},
build: {
sourcemap: true,
}
})),
renderer: mergeConfig(base, defineConfig({
plugins: [
visualizeBundle &&
visualizer({
filename: "bundle-renderer.html",
}),
].filter(Boolean),
build: {
rollupOptions: {
input: "./src/renderer/index.html",
main: mergeConfig(
base,
defineConfig({
plugins: [
IgnorePrismaJsonNullPlugin,
commonjs(),
visualizeBundle &&
visualizer({
filename: "bundle-main.html",
}),
].filter(Boolean),
resolve: {
conditions: ["node", "badger-internal"],
browserField: false,
},
},
})),
preload: mergeConfig(base, defineConfig({
plugins: [
visualizeBundle &&
visualizer({
filename: "bundle-preload.html",
}),
].filter(Boolean),
build: {
lib: {
entry: "./src/common/preload.ts",
build: {
sourcemap: true,
},
},
})),
}),
),
renderer: mergeConfig(
base,
defineConfig({
plugins: [
visualizeBundle &&
visualizer({
filename: "bundle-renderer.html",
}),
].filter(Boolean),
build: {
rollupOptions: {
input: "./src/renderer/index.html",
},
},
}),
),
preload: mergeConfig(
base,
defineConfig({
plugins: [
visualizeBundle &&
visualizer({
filename: "bundle-preload.html",
}),
].filter(Boolean),
build: {
lib: {
entry: "./src/common/preload.ts",
},
},
}),
),
};

export default config;
1 change: 1 addition & 0 deletions desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@types/react-dom": "^18.2.14",
"@types/uuid": "^9.0.2",
"@types/which": "^3.0.0",
"@ystv/vmix": "workspace:*",
"badger-server": "workspace:*",
"bufferutil": "^4.0.7",
"classnames": "^2.3.2",
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/main/vmix/vMix.mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getLogger } from "loglevel";
import { mock, when, It, verify, reset } from "strong-mock";
import VMixConnection from "./vmix";
import VMixConnection from "@ystv/vmix";

const logger = getLogger("vMix.mock");

Expand Down
20 changes: 0 additions & 20 deletions desktop/src/main/vmix/vmix.test.integration.ts

This file was deleted.

124 changes: 0 additions & 124 deletions desktop/src/main/vmix/vmix.test.ts

This file was deleted.

Loading

0 comments on commit 7774c6e

Please sign in to comment.