Files
Cue-View/plugins/qlab/main.js
T
sparks-alec cf1874a29b Squashed commit of the following:
commit 38962ff052
Merge: d6cc11f 57324c8
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Sun Jun 11 20:54:13 2023 -0400

    Merge pull request #108 from stagehacks/qlab-refactor

    Qlab refactor

commit 57324c82e9
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Sun Jun 11 15:31:34 2023 -0400

    add .draw() to make sure troubleshooting info is displayed

commit bf06ec7f3a
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Sun Jun 11 15:20:32 2023 -0400

    remove debugging mark

commit 382dc8a0fe
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Sun Jun 11 15:18:55 2023 -0400

    make playhead a tad smaller

commit 0444d3976e
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Sun Jun 11 15:18:39 2023 -0400

    improved cueList data structure magic

commit c61b189634
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Tue May 30 17:38:44 2023 -0500

    update /chidren endpoint for qlab 4

commit 09ceb01963
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 16:27:46 2023 -0400

    failing to remove a full /cueLists update

    ideally when an /update message is received for a Group cue, we should just get the new list of children cues and stick that into the data.workspaces tree in the right spot.

commit af1094d3cd
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 16:24:54 2023 -0400

    remove full draws when Elapsed progress updates

commit c0d8c58e90
Merge: 6d69bac aec2eff
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 13:53:19 2023 -0400

    Merge branch 'qlab-refactor' of https://github.com/stagehacks/Cue-View into qlab-refactor

commit 6d69bac639
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 13:53:17 2023 -0400

    set version for all workspaces

commit dbb7064385
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 13:52:58 2023 -0400

    helpful text if no workspace is open

commit aec2effee1
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Mon May 29 08:33:15 2023 -0500

    update playback/display for QLab 4 compatibility

commit 454e794d4c
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 05:11:58 2023 -0400

    add playhead information overlay

commit 55ede73f22
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 04:07:17 2023 -0400

    remove bullet if tile doesn't have a cue number

commit 76d8f5e736
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 03:57:04 2023 -0400

    tidy up

commit bd9894c596
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 03:56:45 2023 -0400

    prevent error when many cues are made in QLab

commit 77549aff56
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 03:38:25 2023 -0400

    improve resiliency when passcode is incorrect

commit a237841a3a
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 01:14:44 2023 -0400

    update cart styles for QLab 5

commit 0364924f24
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 01:14:32 2023 -0400

    add carts!

commit d7508c1e22
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Mon May 29 01:13:43 2023 -0400

    add source img

commit 4cf68d3a07
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Sun May 28 07:14:44 2023 -0400

    bugfix error when no playbackPos

commit 03ad8f9682
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Sun May 28 07:06:57 2023 -0400

    refactor QLab

commit f273dab45d
Author: sparks-alec <sparks.alec@gmail.com>
Date:   Sun May 28 07:06:18 2023 -0400

    update styles for QLab 5

commit d6cc11f97d
Merge: d5cec87 5503ac9
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Mon May 22 11:31:37 2023 -0500

    Merge pull request #100 from stagehacks/dependabot/npm_and_yarn/eslint-8.41.0

    Bump eslint from 8.40.0 to 8.41.0

commit 5503ac9888
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon May 22 10:02:34 2023 +0000

    Bump eslint from 8.40.0 to 8.41.0

    Bumps [eslint](https://github.com/eslint/eslint) from 8.40.0 to 8.41.0.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/eslint/eslint/compare/v8.40.0...v8.41.0)

    ---
    updated-dependencies:
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit d5cec8799a
Author: Joel Wetzell <jwetzell@cait.org>
Date:   Wed May 10 16:30:05 2023 -0500

    fix for mac notarization

commit 39d95bb87f
Merge: dbadb6d 3e9b433
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Wed May 10 15:21:55 2023 -0500

    Merge pull request #97 from stagehacks/dependabot/npm_and_yarn/electron-builder-24.4.0

    Bump electron-builder from 24.2.0 to 24.4.0

commit 3e9b433056
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed May 10 20:13:01 2023 +0000

    Bump electron-builder from 24.2.0 to 24.4.0

    Bumps [electron-builder](https://github.com/electron-userland/electron-builder/tree/HEAD/packages/electron-builder) from 24.2.0 to 24.4.0.
    - [Release notes](https://github.com/electron-userland/electron-builder/releases)
    - [Changelog](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-builder/CHANGELOG.md)
    - [Commits](https://github.com/electron-userland/electron-builder/commits/v24.4.0/packages/electron-builder)

    ---
    updated-dependencies:
    - dependency-name: electron-builder
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit dbadb6d1ad
Merge: de7c267 5f2967a
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Wed May 10 15:11:26 2023 -0500

    Merge pull request #96 from stagehacks/dependabot/npm_and_yarn/eslint-8.40.0

    Bump eslint from 8.38.0 to 8.40.0

commit de7c2674bd
Merge: b617369 711eaaf
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Wed May 10 15:09:36 2023 -0500

    Merge pull request #92 from stagehacks/dependabot/npm_and_yarn/prettier-2.8.8

    Bump prettier from 2.8.7 to 2.8.8

commit 5f2967afae
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon May 8 10:03:22 2023 +0000

    Bump eslint from 8.38.0 to 8.40.0

    Bumps [eslint](https://github.com/eslint/eslint) from 8.38.0 to 8.40.0.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/eslint/eslint/compare/v8.38.0...v8.40.0)

    ---
    updated-dependencies:
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit 711eaaf69e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 24 10:03:33 2023 +0000

    Bump prettier from 2.8.7 to 2.8.8

    Bumps [prettier](https://github.com/prettier/prettier) from 2.8.7 to 2.8.8.
    - [Release notes](https://github.com/prettier/prettier/releases)
    - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/prettier/prettier/compare/2.8.7...2.8.8)

    ---
    updated-dependencies:
    - dependency-name: prettier
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit b6173695ce
Merge: 41384cb a91c67a
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Mon Apr 10 11:19:13 2023 -0500

    Merge pull request #88 from stagehacks/dependabot/npm_and_yarn/minimatch-and-electron-builder-3.1.2

    Bump minimatch and electron-builder

commit a91c67a323
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 10 16:10:51 2023 +0000

    Bump minimatch and electron-builder

    Bumps [minimatch](https://github.com/isaacs/minimatch) to 3.1.2 and updates ancestor dependency [electron-builder](https://github.com/electron-userland/electron-builder/tree/HEAD/packages/electron-builder). These dependencies need to be updated together.

    Updates `minimatch` from 3.0.4 to 3.1.2
    - [Release notes](https://github.com/isaacs/minimatch/releases)
    - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
    - [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

    Updates `electron-builder` from 23.6.0 to 24.2.0
    - [Release notes](https://github.com/electron-userland/electron-builder/releases)
    - [Changelog](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-builder/CHANGELOG.md)
    - [Commits](https://github.com/electron-userland/electron-builder/commits/v24.2.0/packages/electron-builder)

    ---
    updated-dependencies:
    - dependency-name: minimatch
      dependency-type: indirect
    - dependency-name: electron-builder
      dependency-type: direct:development
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit 41384cb66c
Merge: 7769ad9 7dc37a7
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Mon Apr 10 11:10:05 2023 -0500

    Merge pull request #87 from stagehacks/dependabot/npm_and_yarn/eslint-8.38.0

    Bump eslint from 8.37.0 to 8.38.0

commit 7dc37a7fcb
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 10 10:03:19 2023 +0000

    Bump eslint from 8.37.0 to 8.38.0

    Bumps [eslint](https://github.com/eslint/eslint) from 8.37.0 to 8.38.0.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/eslint/eslint/compare/v8.37.0...v8.38.0)

    ---
    updated-dependencies:
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit 7769ad9059
Merge: 159da19 a8d8092
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Tue Apr 4 11:46:35 2023 -0500

    Merge pull request #85 from stagehacks/dependabot/npm_and_yarn/eslint-8.37.0

    Bump eslint from 8.36.0 to 8.37.0

commit 159da195d3
Merge: 90e06ca 88ad920
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Tue Apr 4 10:51:36 2023 -0500

    Merge pull request #78 from stagehacks/plugin-atem

    This has passed tests and has been cleaned up, send it!

commit a8d8092e65
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Apr 3 10:04:27 2023 +0000

    Bump eslint from 8.36.0 to 8.37.0

    Bumps [eslint](https://github.com/eslint/eslint) from 8.36.0 to 8.37.0.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/eslint/eslint/compare/v8.36.0...v8.37.0)

    ---
    updated-dependencies:
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit 88ad9207e2
Merge: bd2b190 37a3fde
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Wed Mar 29 06:55:00 2023 -0500

    Merge branch 'plugin-atem' of github.com:stagehacks/Cue-View into plugin-atem

commit bd2b190fac
Merge: 50d8363 90e06ca
Author: Joel Wetzell <jwetzell@cait.org>
Date:   Tue Mar 28 13:50:13 2023 -0500

    Merge branch 'main' into plugin-atem

commit 50d8363a4a
Author: Joel Wetzell <jwetzell@cait.org>
Date:   Tue Mar 28 13:41:04 2023 -0500

    regenerate package-lock using node v18.13.0

commit 90e06cab99
Merge: 98a0c9c 3b24dcb
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Tue Mar 28 07:18:53 2023 -0500

    Merge pull request #79 from stagehacks/dependabot/npm_and_yarn/osc-2.4.4

    Bump osc from 2.4.3 to 2.4.4

commit 98a0c9c31b
Merge: 5c28a0c f5e8e72
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Tue Mar 28 07:18:41 2023 -0500

    Merge pull request #81 from stagehacks/dependabot/npm_and_yarn/eslint-config-prettier-8.8.0

    Bump eslint-config-prettier from 8.7.0 to 8.8.0

commit 5c28a0c6b3
Merge: b314735 095d7fb
Author: Joel Wetzell <jwetzell@yahoo.com>
Date:   Tue Mar 28 07:18:31 2023 -0500

    Merge pull request #83 from stagehacks/dependabot/npm_and_yarn/prettier-2.8.7

    Bump prettier from 2.8.4 to 2.8.7

commit 095d7fb89f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Mar 27 10:05:23 2023 +0000

    Bump prettier from 2.8.4 to 2.8.7

    Bumps [prettier](https://github.com/prettier/prettier) from 2.8.4 to 2.8.7.
    - [Release notes](https://github.com/prettier/prettier/releases)
    - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/prettier/prettier/compare/2.8.4...2.8.7)

    ---
    updated-dependencies:
    - dependency-name: prettier
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit f5e8e729e8
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Mar 27 10:04:15 2023 +0000

    Bump eslint-config-prettier from 8.7.0 to 8.8.0

    Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 8.7.0 to 8.8.0.
    - [Release notes](https://github.com/prettier/eslint-config-prettier/releases)
    - [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/prettier/eslint-config-prettier/compare/v8.7.0...v8.8.0)

    ---
    updated-dependencies:
    - dependency-name: eslint-config-prettier
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit 3b24dcb063
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Mar 20 10:08:41 2023 +0000

    Bump osc from 2.4.3 to 2.4.4

    Bumps [osc](https://github.com/colinbdclark/osc.js) from 2.4.3 to 2.4.4.
    - [Release notes](https://github.com/colinbdclark/osc.js/releases)
    - [Commits](https://github.com/colinbdclark/osc.js/compare/2.4.3...2.4.4)

    ---
    updated-dependencies:
    - dependency-name: osc
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
2023-06-11 21:16:38 -04:00

388 lines
13 KiB
JavaScript

const _ = require('lodash');
const fs = require('fs');
const path = require('path');
exports.config = {
defaultName: 'QLab',
connectionType: 'osc',
defaultPort: 53000,
mayChangePort: true,
heartbeatInterval: 100,
heartbeatTimeout: 5000,
searchOptions: {
type: 'Bonjour',
bonjourName: 'qlab',
},
fields: [
{
key: 'passcode',
label: 'Pass',
type: 'textinput',
value: '',
action(device) {
device.send('/workspaces');
},
},
],
};
const valuesForKeysString =
'["uniqueID","number","name","listName","isBroken","isRunning","isLoaded","isFlagged",' +
'"type","children","preWait","postWait","duration","colorName","continueMode",' +
'"mode","parent","cartRows","cartColumns","cartPosition","displayName","preWaitElapsed",' +
'"actionElapsed","postWaitElapsed","isPaused","currentCueTarget","isRunning","armed","notes"]';
exports.ready = function ready(_device) {
const device = _device;
device.send(`/version`);
device.send('/workspaces');
device.data.workspaces = {};
device.data.cueKeys = {};
device.data.version = '';
device.data.lastElapsedMessage = 0;
device.data.ticks = 0;
device.templates = {
cue: _.template(fs.readFileSync(path.join(__dirname, `cue.ejs`))),
tile: _.template(fs.readFileSync(path.join(__dirname, `tile.ejs`))),
cart: _.template(fs.readFileSync(path.join(__dirname, `cart.ejs`))),
cuelist: _.template(fs.readFileSync(path.join(__dirname, `cuelist.ejs`))),
};
};
exports.data = function data(_device, oscData) {
const device = _device;
const msgAddr = oscData.address.split('/');
msgAddr.shift();
let json = [];
try {
json = JSON.parse(oscData.args[0]);
} catch (err) {
// a handful of messages don't respond with JSON
}
if (Object.keys(json).length > 0) {
if (json.status === 'denied') {
if (device.data.workspaces[json.workspace_id]) {
device.data.workspaces[json.workspace_id].permission = 'denied';
}
return;
}
if (json.status === 'error') {
device.send('/workspaces');
return;
}
}
if (oscData.address === '/reply/workspaces') {
for (let i = 0; i < json.data.length; i++) {
device.data.workspaces[json.data[i].uniqueID] = {
version: json.data[i].version,
displayName: json.data[i].displayName,
port: json.data[i].port,
udpReplyPort: json.data[i].udpReplyPort,
cueLists: [],
selected: [],
};
device.data.version = json.data[i].version;
device.data.workspaces[json.data[i].uniqueID].permission = 'ok';
device.send(`/workspace/${json.data[i].uniqueID}/connect`, device.fields.passcode);
}
this.deviceInfoUpdate(device, 'status', 'ok');
device.draw();
} else if (/reply\/workspace\/.*\/connect/.test(oscData.address)) {
if (json.data === 'badpass') {
device.data.workspaces[json.workspace_id].permission = 'badpass';
} else {
device.data.workspaces[json.workspace_id].permission = 'ok';
device.send(`/workspace/${msgAddr[2]}/cueLists`);
device.send(`/workspace/${msgAddr[2]}/updates`, [{ type: 'i', value: 1 }]);
}
} else if (/reply\/workspace\/.*\/cueLists/.test(oscData.address)) {
insertChildCues(device, device.data.workspaces[msgAddr[2]].cueLists, json.data, '[root group of cue lists]');
} else if (/reply\/cue_id\/.*\/valuesForKeys/.test(oscData.address)) {
const keyValues = json.data;
let cue = device.data.cueKeys[msgAddr[2]];
if (cue === undefined) {
device.data.cueKeys[msgAddr[2]] = {};
cue = device.data.cueKeys[msgAddr[2]];
}
cue.uniqueID = keyValues.uniqueID;
cue.number = keyValues.number;
cue.listName = keyValues.listName;
cue.isBroken = keyValues.isBroken;
cue.isRunning = keyValues.isRunning;
cue.isLoaded = keyValues.isLoaded;
cue.isFlagged = keyValues.isFlagged;
cue.type = keyValues.type;
cue.cues = keyValues.children;
cue.preWait = keyValues.preWait;
cue.postWait = keyValues.postWait;
cue.duration = keyValues.duration;
cue.colorName = keyValues.colorName;
cue.continueMode = keyValues.continueMode;
cue.mode = keyValues.mode;
cue.parent = keyValues.parent;
cue.cartRows = keyValues.cartRows;
cue.cartColumns = keyValues.cartColumns;
cue.cartPosition = keyValues.cartPosition;
cue.displayName = keyValues.displayName;
cue.preWaitElapsed = keyValues.preWaitElapsed;
cue.actionElapsed = keyValues.actionElapsed;
cue.postWaitElapsed = keyValues.postWaitElapsed;
cue.isPaused = keyValues.isPaused;
cue.currentCueTarget = keyValues.currentCueTarget;
cue.armed = keyValues.armed;
cue.notes = keyValues.notes;
if (keyValues.isRunning) {
device.data.lastElapsedMessage = device.data.ticks;
}
if (cue.parent !== '[root group of cue lists]') {
cue.parent = device.data.cueKeys[cue.parent];
}
if (cue.type === 'Cue List' || cue.type === 'Group' || cue.type === 'Cart') {
if (device.data.cueKeys[msgAddr[2]].cueInWorkspace && cue.cues) {
insertChildCues(
device,
device.data.cueKeys[msgAddr[2]].cueInWorkspace.cues,
[...keyValues.children],
device.data.cueKeys[msgAddr[2]].cueInWorkspace
);
}
device.draw();
}
if (cue.type !== 'Cue List' && cue.type !== 'Cart') {
device.update('updateCueRow', { cue, workspace: device.data.workspaces[json.workspace_id] });
}
} else if (/reply\/cue_id\/(.*)\/(.*)Elapsed/.test(oscData.address)) {
const workspace = device.data.workspaces[json.workspace_id];
let cueID;
let keyName;
device.data.lastElapsedMessage = device.data.ticks;
if (workspace?.version.startsWith('5.')) {
const addrParts = json.address.split('/');
cueID = addrParts[4];
keyName = addrParts[5];
} else {
const addrParts = json.address.split('/');
cueID = addrParts[2];
keyName = addrParts[3];
}
device.data.cueKeys[cueID][keyName] = json.data;
device.update('updateCueRow', { cue: device.data.cueKeys[cueID], workspace });
} else if (/reply\/workspace\/.*\/selectedCues/.test(oscData.address)) {
const workspace = device.data.workspaces[msgAddr[2]];
if (!workspace) {
return;
}
workspace.selected = [];
for (let i = 0; i < json.data.length; i++) {
workspace.selected.push(json.data[i].uniqueID);
}
device.update('updatePlaybackAndSelected', { workspace: device.data.workspaces[json.workspace_id] });
} else if (/update\/workspace\/.*\/cue_id\/.*/.test(oscData.address)) {
device.send(`/cue_id/${msgAddr[4]}/valuesForKeys`, [{ type: 's', value: valuesForKeysString }]);
} else if (/update\/workspace\/.*\/cueList\/.*\/playbackPosition/.test(oscData.address)) {
const workspace = device.data.workspaces[msgAddr[2]];
if (workspace) {
workspace.playbackPosition = oscData.args[0];
device.update('updatePlaybackAndSelected', { workspace: device.data.workspaces[msgAddr[2]] });
}
} else if (/update\/workspace\/.*\/dashboard/.test(oscData.address)) {
device.send(`/workspace/${msgAddr[2]}/selectedCues`);
device.send(`/cue_id/active/preWaitElapsed`);
}
};
exports.update = function update(device, _doc, updateType, data) {
const doc = _doc;
if (updateType === 'updateCueRow') {
const $elem = doc.getElementById(data.cue.uniqueID);
if ($elem) {
if (data.cue.parent.type === 'Cart') {
$elem.outerHTML = device.templates.tile({
allCues: device.data.cueKeys,
cue: data.cue,
workspace: data.workspace,
});
} else {
$elem.outerHTML = device.templates.cue({
allCues: device.data.cueKeys,
cue: data.cue,
workspace: data.workspace,
});
}
}
} else if (updateType === 'updatePlaybackAndSelected') {
Array.from(doc.querySelectorAll('.selected')).forEach(($el) => {
$el.classList.remove('selected');
});
Array.from(doc.querySelectorAll('.playback-position')).forEach(($el) => {
$el.classList.remove('playback-position');
});
for (let i = 0; i < data.workspace.selected.length; i++) {
const $elem = doc.getElementById(data.workspace.selected[i]);
if ($elem) {
$elem.classList.add('selected');
}
}
const $playheadInfo = doc.getElementById('playhead-information');
const $playheadName = doc.getElementById('playhead-name');
const $playheadNotes = doc.getElementById('playhead-notes');
if (data.workspace.playbackPosition) {
const $cueRow = doc.getElementById(data.workspace.playbackPosition);
if ($cueRow) {
$cueRow.classList.add('playback-position');
$cueRow.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
const cue = device.data.cueKeys[data.workspace.playbackPosition];
if (cue && $playheadName) {
$playheadName.setAttribute('class', `playhead-name cartColor-${cue.colorName} playhead-disarmed`);
$playheadInfo.classList.add('playhead-active');
if (cue.number) {
$playheadName.innerHTML = `${cue.number} &bull; ${cue.displayName}`;
} else {
$playheadName.innerHTML = cue.displayName;
}
if (cue.notes) {
$playheadNotes.innerHTML = cue.notes;
} else {
$playheadNotes.innerHTML = '<span style="color:#5C5C5C">Notes</span>';
}
if (!cue.armed) {
$playheadName.classList.add('playhead-disarmed');
} else {
$playheadName.classList.remove('playhead-disarmed');
}
}
} else {
$playheadName.setAttribute('class', `playhead-name`);
$playheadName.innerHTML = '<span style="color:#747574">[no cue on standby]</span>';
$playheadNotes.innerHTML = '';
$playheadInfo.classList.remove('playhead-active');
}
}
};
exports.heartbeat = function heartbeat(_device) {
const device = _device;
device.data.ticks++;
if (device.data.ticks % 10 === 0) {
device.send(`/thump`);
}
if (device.data.ticks - device.data.lastElapsedMessage < 5) {
device.send(`/cue_id/active/preWaitElapsed`);
device.send(`/cue_id/active/postWaitElapsed`);
device.send(`/cue_id/active/actionElapsed`);
}
};
function insertChildCues(_device, _oldCues, newCues, _parent) {
const device = _device;
const newIDs = _.keyBy(newCues, 'uniqueID');
const oldCues = _oldCues;
const parent = _parent;
if (!oldCues) {
return;
}
for (let i = 0; i < oldCues.length; i++) {
const oldCue = oldCues[i];
if (!newIDs[oldCue.uniqueID]) {
oldCues.splice(i, 1);
i--;
}
const indexOfOldCueInNew = _.findIndex(newCues, (o) => o.uniqueID === oldCue.uniqueID);
if (indexOfOldCueInNew >= 0) {
const newCue = newCues[indexOfOldCueInNew];
oldCues[i].armed = newCue.armed;
oldCues[i].colorName = newCue.colorName;
oldCues[i].colorNameLive = newCue['colorName/live'];
oldCues[i].flagged = newCue.flagged;
oldCues[i].listName = newCue.listName;
oldCues[i].name = newCue.name;
oldCues[i].number = newCue.number;
oldCues[i].type = newCue.type;
oldCues[i].sortIndex = indexOfOldCueInNew;
oldCues[i].parent = parent;
newCue.used = true;
let keys = device.data.cueKeys[oldCues[i].uniqueID];
if (!keys) {
device.data.cueKeys[oldCues[i].uniqueID] = {};
keys = device.data.cueKeys[oldCues[i].uniqueID];
}
keys.cueInWorkspace = oldCues[i];
if (oldCues[i].type === 'Group' || oldCues[i].type === 'Cue List' || oldCues[i].type === 'Cart') {
insertChildCues(device, oldCues[i].cues, newCue.cues, oldCues[i]);
}
}
}
for (let i = 0; i < newCues.length; i++) {
const newCue = newCues[i];
if (newCue.used !== true) {
const newIndex = oldCues.push({
armed: newCue.armed,
colorName: newCue.colorName,
colorNameLive: newCue['colorName/live'],
flagged: newCue.flagged,
listName: newCue.listName,
name: newCue.name,
number: newCue.number,
type: newCue.type,
uniqueID: newCue.uniqueID,
sortIndex: i,
parent,
});
const freshCue = oldCues[newIndex - 1];
let keys = device.data.cueKeys[freshCue.uniqueID];
if (!keys) {
device.data.cueKeys[freshCue.uniqueID] = {};
keys = device.data.cueKeys[freshCue.uniqueID];
}
if (freshCue.parent === '[root group of cue lists]') {
keys.parentKeys = [];
} else {
keys.parentKeys = [...device.data.cueKeys[freshCue.parent.uniqueID].parentKeys];
keys.parentKeys.push(device.data.cueKeys[freshCue.parent.uniqueID]);
}
device.send(`/cue_id/${newCue.uniqueID}/valuesForKeys`, [{ type: 's', value: valuesForKeysString }]);
keys.cueInWorkspace = freshCue;
if (freshCue.type === 'Group' || freshCue.type === 'Cue List' || oldCues[i].type === 'Cart') {
freshCue.cues = [];
insertChildCues(device, freshCue.cues, newCue.cues, freshCue);
}
}
}
oldCues.sort((a, b) => a.sortIndex - b.sortIndex);
}