Feat/62 logger (#79)

* feat/62-logger request log data in app
* feat/62-logger refact osc integration
* feat/62-logger feedback on osc
* feat/62-logger refact broadcast on triggers
* feat/62-logger log triggers
* feat/62-logger add link to studio
* feat/62-logger replace toasts with logger context
* feat/62-logger style improvements
* feat/62-logger refactor code duplications
* feat/62-logger cleanup and version bump
This commit is contained in:
Carlos Valente
2021-12-25 19:39:40 +01:00
committed by GitHub
parent 160ccabebc
commit 9fc154955a
46 changed files with 3830 additions and 598 deletions
+18 -30
View File
@@ -7,22 +7,11 @@
import { stringFromMillis } from '../utils/time.js';
export class Timer {
clock = null;
duration = null;
current = null;
timeTag = null;
secondaryTimer = null;
_secondaryTarget = null;
_finishAt = null;
_finishedAt = null;
_finishedFlag = false;
_startedAt = null;
_pausedAt = null;
_pausedInterval = null;
_pausedTotal = null;
state = 'stop';
constructor() {}
constructor() {
this.clock = null;
this._resetTimers(true);
this.state = 'stop';
}
// call setup separately
setupWithSeconds(seconds, autoStart = false) {
@@ -74,11 +63,11 @@ export class Timer {
if (this._startedAt != null) {
// update current timer
this.current =
this._startedAt
+ this.duration
+ this._pausedTotal
+ this._pausedInterval
- now;
this._startedAt +
this.duration +
this._pausedTotal +
this._pausedInterval -
now;
}
// enable flag
@@ -92,13 +81,14 @@ export class Timer {
if (checkFinish) {
// is event finished?
const isTimeOver = this.current <= 0;
const isUpdating = (this.state !== 'pause');
const isUpdating = this.state !== 'pause';
if (isTimeOver && isUpdating && this._finishedAt == null) {
if (this._finishedAt === null) this._finishedAt = now;
this._finishedFlag = true;
}
}
this.timeTag = stringFromMillis(this.current);
}
// helpers
@@ -136,6 +126,7 @@ export class Timer {
_resetTimers(total = false) {
if (total) this.duration = null;
this.current = this.duration;
this.timeTag = null;
this.running = null;
this.secondaryTimer = null;
this._secondaryTarget = null;
@@ -153,14 +144,11 @@ export class Timer {
return this.duration - this.current;
}
// get time object
getTimes(update = true) {
// update timer
if (update) this.update();
// update timetag
this.timeTag = stringFromMillis(this.current);
/**
* Builds time object
* @returns {{running: number, secondary: number, expectedFinish: number, durationSeconds: number, startedAt: null, clock: null}}
*/
getTimeObject() {
return {
clock: this.clock,
running: Timer.toSeconds(this.current),