Skip to content

Commit

Permalink
Merge branch 'fix-electron-video' into fix-electron-photodiode
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGemmaJr committed Nov 21, 2023
2 parents 9c5f350 + ed450f2 commit 30c5920
Show file tree
Hide file tree
Showing 6 changed files with 1,252 additions and 507 deletions.
1,723 changes: 1,240 additions & 483 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"url": "https://ccv.brown.edu"
},
"version": "3.2.4",
"honeycombVersion": "",
"license": "MIT",
"private": true,
"main": "public/electron/main.js",
Expand Down Expand Up @@ -42,12 +43,12 @@
"devDependencies": {
"@babel/core": "^7.22.20",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@electron-forge/cli": "^6.4.2",
"@electron-forge/maker-deb": "^6.2.1",
"@electron-forge/maker-dmg": "^6.2.1",
"@electron-forge/maker-squirrel": "^6.2.1",
"@electron-forge/maker-zip": "^6.2.1",
"@electron-forge/plugin-auto-unpack-natives": "^6.2.1",
"@electron-forge/cli": "^7.1.0",
"@electron-forge/maker-deb": "^7.1.0",
"@electron-forge/maker-dmg": "^7.1.0",
"@electron-forge/maker-squirrel": "^7.1.0",
"@electron-forge/maker-zip": "^7.1.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.1.0",
"@inquirer/prompts": "^3.0.3",
"chai": "^4.2.0",
"concurrently": "^8.2.1",
Expand Down
13 changes: 0 additions & 13 deletions public/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,6 @@ app.on("before-quit", () => {
}
});

/** Prevents navigation outside of known pages */
// TODO: This is super useful but end user will have to enter their live website?
// const allowedNavigationDestinations = "https://my-electron-app.com";
// app.on("web-contents-created", (event, contents) => {
// contents.on("will-navigate", (event, navigationUrl) => {
// const parsedUrl = new URL(navigationUrl);

// if (!allowedNavigationDestinations.includes(parsedUrl.origin)) {
// event.preventDefault();
// }
// });
// });

/** Log any uncaught exceptions before quitting */
process.on("uncaughtException", (error) => {
log.error(error);
Expand Down
1 change: 0 additions & 1 deletion public/electron/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { contextBridge, ipcRenderer } = require("electron");
/** Load bridges between the main and renderer processes when the preload process is first loaded */
process.once("loaded", () => {
contextBridge.exposeInMainWorld("electronAPI", {
USE_ELECTRON: true,
setConfig: (config) => ipcRenderer.send("setConfig", config),
setTrigger: (triggerCodes) => ipcRenderer.send("setTrigger", triggerCodes),
getCredentials: () => ipcRenderer.invoke("getCredentials"),
Expand Down
8 changes: 5 additions & 3 deletions src/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function App() {
"Task Settings": taskSettings,
});

// If on desktop
// If running in a native application
if (config.USE_ELECTRON) {
await window.electronAPI.setConfig(config); // Pass config to Electron ipcMain
await window.electronAPI.setTrigger(trigger); // Pass trigger to Electron ipcMain
Expand All @@ -73,7 +73,8 @@ export default function App() {

setMethod("desktop");
} else {
// If MTURK
// If using Mechanical Turk and PsiTurk
// TODO: Change config variable to psiturk? That's what user's are really using
if (config.USE_MTURK) {
/* eslint-disable */
window.lodash = _.noConflict();
Expand All @@ -82,6 +83,7 @@ export default function App() {
handleLogin("mturk", turkUniqueId);
/* eslint-enable */
} else if (config.USE_PROLIFIC) {
// TODO: Remove prolific check - we should always check process.env AND UrlSearchParams
const pID = getProlificId();
if (config.USE_FIREBASE && pID) {
setMethod("firebase");
Expand All @@ -91,6 +93,7 @@ export default function App() {
setIsError(true);
}
} else if (config.USE_FIREBASE) {
// TODO: There's a difference between PROLIFIC_ID in URL and PID/SID
// Fill in login fields based on query parameters (may still be blank)
const query = new URLSearchParams(window.location.search);
const studyId = query.get("studyID");
Expand All @@ -105,7 +108,6 @@ export default function App() {
}
}
setUpHoneycomb();
// eslint-disable-next-line
}, []);

/** VALIDATION FUNCTIONS */
Expand Down
1 change: 0 additions & 1 deletion src/config/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const USE_MTURK = !turkInfo.outsideTurk;
const turkUniqueId = `${turkInfo.workerId}:${turkInfo.assignmentId}`; // ID of the user in mechanical turk

// Whether or not the experiment is running in Electron (local app)
// TODO: Fix .electronAPi?.USE_ELECTRON - need ? support
const USE_ELECTRON = window.electronAPI !== undefined;
const USE_PROLIFIC = (getProlificId() && !USE_MTURK) || false; // Whether or not the experiment is running with Prolific
const USE_FIREBASE = process.env.REACT_APP_FIREBASE === "true"; // Whether or not the experiment is running in Firebase (web app)
Expand Down

0 comments on commit 30c5920

Please sign in to comment.