Skip to content

Commit

Permalink
Merge pull request #209 from LordTocs/dev
Browse files Browse the repository at this point in the history
Viewer Variables
  • Loading branch information
LordTocs authored Sep 9, 2024
2 parents f2e56ac + e179629 commit 89041bb
Show file tree
Hide file tree
Showing 68 changed files with 2,678 additions and 237 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
run: "yarn install"
- name: "Setup Vite Extensions"
run: "yarn setup-vite"
- name: "Recompile Native Deps for Electron"
run: "yarn workspace castmate-core run rebuild"
- name: "Build"
run: "yarn run buildpublish"
env:
Expand Down
8 changes: 7 additions & 1 deletion libs/castmate-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
"main": "src/index.ts",
"devMain": "src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"rebuild": "electron-rebuild -f -w better-sqlite3",
"postinstall": "electron-rebuild -f -w better-sqlite3"
},
"author": "",
"license": "ISC",
"type": "module",
"devDependencies": {
"@electron/rebuild": "^3.6.0",
"@types/better-sqlite3": "^7.6.11",
"@types/express": "^4.17.21",
"@types/http-proxy": "^1.17.14",
"@types/lodash": "^4.14.192",
Expand All @@ -25,6 +29,7 @@
"@colors/colors": "^1.6.0",
"@joshyour/ffprobe-client": "^1.1.7",
"@types/fluent-ffmpeg": "^2.1.21",
"better-sqlite3": "^11.1.2",
"castmate-schema": "workspace:^",
"chokidar": "^3.5.3",
"electron": "29.4.5",
Expand All @@ -36,6 +41,7 @@
"nanoid": "^5.0.7",
"recursive-readdir-async": "^1.3.0",
"semver": "^7.6.2",
"sqlite3": "^5.1.7",
"winston": "^3.11.0",
"ws": "^8.16.0",
"yaml": "^2.2.1"
Expand Down
2 changes: 2 additions & 0 deletions libs/castmate-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ export * from "./analytics/analytics-manager"
export * from "./info/info-manager"

export * from "./util/time-utils"

export * from "./viewer-data/viewer-data"
37 changes: 1 addition & 36 deletions libs/castmate-core/src/media/media-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,41 +42,6 @@ export interface MediaFolder {
path: string
watcher: chokidar.FSWatcher
}
/*
function downloadFile(url: string, dest: string) {
return new Promise<void>((resolve, reject) => {
const writeStream = fsSync.createWriteStream(dest)
const request = http.get(url, (resp) => {
if (resp.statusCode !== 200) {
reject(`Failed to download ${url} with ${resp.statusCode}`)
}
resp.pipe(writeStream)
})
writeStream.on("finish", () => {
writeStream.close((err) => {
if (err) return reject(err)
resolve()
})
})
request.on("error", (err) => {
fsSync.unlink(dest, (unlinkErr) => {
if (unlinkErr) return reject(unlinkErr)
reject(err)
})
})
writeStream.on("error", (err) => {
fsSync.unlink(dest, (unlinkErr) => {
if (unlinkErr) return reject(unlinkErr)
reject(err)
})
})
})
}*/

async function downloadFile(url: string, dest: string) {
const writeStream = fsSync.createWriteStream(dest)
Expand Down Expand Up @@ -146,7 +111,7 @@ export const MediaManager = Service(
getLocalPath(mediaPath: string) {
const baseMediaPath = resolveProjectPath("./media")

if (!mediaPath.startsWith("/default")) throw new Error("not a media path")
if (!mediaPath.startsWith("/default")) throw new Error(`"${mediaPath}" not a media path`)

const defaultPath = path.relative("/default", mediaPath)

Expand Down
3 changes: 3 additions & 0 deletions libs/castmate-core/src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { app } from "electron"
import path from "path"
import { InfoService } from "./info/info-manager"
import { AnalyticsService } from "./analytics/analytics-manager"
import { ViewerData } from "./viewer-data/viewer-data"

/*
//This shit is dynamic and vite hates it.
Expand Down Expand Up @@ -90,6 +91,8 @@ export async function initializeCastMate() {
SequenceResolvers.initialize()
EmoteCache.initialize()
setupStreamPlans()
ViewerData.initialize()
await ViewerData.getInstance().initialize()

//How do we load plugins???
//await loadPlugin("twitch")
Expand Down
12 changes: 10 additions & 2 deletions libs/castmate-core/src/util/boolean-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ function baseCompare(left: any, right: any, operator: ValueCompareOperator) {

async function evaluateValueExpression(expression: BooleanValueExpression) {
const left = await getExpressionValueAndSchema(expression.lhs)
const right = await getExpressionValueAndSchema(expression.rhs)
return await evaluateHalfBooleanExpression(left, expression.rhs, expression.operator)
}

export async function evaluateHalfBooleanExpression(
left: { value: any; schema: Schema } | undefined,
rhs: ExpressionValue,
operator: ValueCompareOperator
) {
const right = await getExpressionValueAndSchema(rhs)

let compareFunc = baseCompare

Expand All @@ -113,7 +121,7 @@ async function evaluateValueExpression(expression: BooleanValueExpression) {
}
}

return compareFunc(leftValue, rightValue, expression.operator)
return compareFunc(leftValue, rightValue, operator)
}

function inRangeCompare(
Expand Down
Loading

0 comments on commit 89041bb

Please sign in to comment.