diff --git a/src/application/index.js b/src/application/index.js index 08d27baf8..1a2c39688 100644 --- a/src/application/index.js +++ b/src/application/index.js @@ -9,7 +9,7 @@ import use from "./use"; import PromiseWorker from "promise-worker-transferable"; -import { ipcRenderer } from "electron"; +import { ipcRenderer, remote } from "electron"; let imageBitmap; const imageBitmapQueue = []; @@ -35,6 +35,11 @@ export default class ModV { this.$worker = new Worker(); this.$asyncWorker = new PromiseWorker(this.$worker); + this.$worker.postMessage({ + type: "__dirname", + payload: remote.app.getAppPath() + }); + this.$worker.addEventListener("message", e => { if (e.data.type === "tick" && this.ready) { this.tick(e.data.payload); diff --git a/src/application/worker/index.worker.js b/src/application/worker/index.worker.js index 004a06b7d..73d246e73 100644 --- a/src/application/worker/index.worker.js +++ b/src/application/worker/index.worker.js @@ -1,18 +1,15 @@ /* eslint-env worker node */ -import registerPromiseWorker from "promise-worker/register"; -import fs from "fs"; -import store from "./store"; -import loop from "./loop"; -import { tick as frameTick } from "./frame-counter"; -import { getFeatures, setFeatures } from "./audio-features"; -import featureAssignmentPlugin from "../plugins/feature-assignment"; let lastKick = false; -(async function() { - self.addEventListener("unhandledrejection", e => { - console.log(e); - }); +async function start() { + const registerPromiseWorker = require("promise-worker/register"); + const fs = require("fs"); + const store = require("./store").default; + const loop = require("./loop").default; + const { tick: frameTick } = require("./frame-counter"); + const { getFeatures, setFeatures } = require("./audio-features"); + // const featureAssignmentPlugin = require("../plugins/feature-assignment"); store.subscribe(mutation => { const { type, payload } = mutation; @@ -112,7 +109,7 @@ let lastKick = false; store.dispatch("modules/registerModule", module); } - store.dispatch("plugins/add", featureAssignmentPlugin); + // store.dispatch("plugins/add", featureAssignmentPlugin); const webcamOutput = await store.dispatch("outputs/getAuxillaryOutput", { name: "webcam", @@ -256,4 +253,18 @@ let lastKick = false; }); self.store = store; -})(); +} + +function handleDirname(e) { + const message = e.data; + const { type, payload } = message; + + if (type === "__dirname") { + self.__dirname = payload; + + self.removeEventListener("message", handleDirname); + start(); + } +} + +self.addEventListener("message", handleDirname); diff --git a/src/application/worker/store/modules/ndi.js b/src/application/worker/store/modules/ndi.js index 8c1e52ad2..6049a46f0 100644 --- a/src/application/worker/store/modules/ndi.js +++ b/src/application/worker/store/modules/ndi.js @@ -1,8 +1,17 @@ -import grandiose from "grandiose"; +/* globals __dirname */ + import uuidv4 from "uuid/v4"; import Vue from "vue"; import store from "../"; +// eslint-disable-next-line +__dirname = `${__dirname}/node_modules/grandiose`; + +const grandiose = require("grandiose"); + +// eslint-disable-next-line +__dirname = __dirname.replace("/node_modules/grandiose", ""); + const state = { discovering: false,