dashcam 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +16 -4
- package/lib.js +27 -2
- package/package.json +1 -1
- package/recorder.js +9 -4
package/index.js
CHANGED
|
@@ -6,7 +6,6 @@ const lib = require("./lib");
|
|
|
6
6
|
const Recorder = require("./recorder");
|
|
7
7
|
const packageMetadata = require("./package.json");
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
if (module.parent) {
|
|
11
10
|
module.exports = lib;
|
|
12
11
|
return;
|
|
@@ -51,7 +50,6 @@ program
|
|
|
51
50
|
md: this.opts().md,
|
|
52
51
|
png: this.opts().png,
|
|
53
52
|
});
|
|
54
|
-
console.log(result);
|
|
55
53
|
} catch (e) {
|
|
56
54
|
console.log("Error: ", e);
|
|
57
55
|
}
|
|
@@ -60,10 +58,11 @@ program
|
|
|
60
58
|
|
|
61
59
|
program
|
|
62
60
|
.command("record")
|
|
61
|
+
.option("-s, --silent", "Use silent mode when recording")
|
|
63
62
|
.description(
|
|
64
63
|
"Start a recording terminal to be included in your dashcam video recording"
|
|
65
64
|
)
|
|
66
|
-
.action(async function (
|
|
65
|
+
.action(async function ({ silent }) {
|
|
67
66
|
try {
|
|
68
67
|
const dashcam = new lib.PersistantDashcamIPC();
|
|
69
68
|
const id = crypto.randomUUID();
|
|
@@ -71,13 +70,26 @@ program
|
|
|
71
70
|
|
|
72
71
|
dashcam.onConnected = () => dashcam.emit("track-cli", logFile);
|
|
73
72
|
fs.appendFileSync(logFile, "");
|
|
74
|
-
const recorder = new Recorder(logFile);
|
|
73
|
+
const recorder = new Recorder(logFile, silent);
|
|
75
74
|
await recorder.start();
|
|
76
75
|
} catch (e) {
|
|
77
76
|
console.log("Error: ", e);
|
|
78
77
|
}
|
|
79
78
|
});
|
|
80
79
|
|
|
80
|
+
program
|
|
81
|
+
.command("start")
|
|
82
|
+
.description("Start instant replay recording on dashcam")
|
|
83
|
+
.action(async function (name, options) {
|
|
84
|
+
try {
|
|
85
|
+
await lib.startInstantReplay();
|
|
86
|
+
process.exit(0);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
console.log("startInstantReplay error: ", e);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
81
93
|
if (process.stdin.isTTY) {
|
|
82
94
|
program.parse(process.argv);
|
|
83
95
|
} else {
|
package/lib.js
CHANGED
|
@@ -60,9 +60,30 @@ const createReplay = async function (options = {}) {
|
|
|
60
60
|
);
|
|
61
61
|
}, 60000 * 5);
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
const replay = {
|
|
64
64
|
title: options.title,
|
|
65
65
|
description: options.description,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
ipc.of.dashcam.emit("create", replay);
|
|
69
|
+
|
|
70
|
+
resolve(replay);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const startInstantReplay = async function (options = {}) {
|
|
75
|
+
return new Promise(async (resolve, reject) => {
|
|
76
|
+
await connectToIpc();
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
reject(
|
|
79
|
+
"Dashcam Desktop App did not respond in time. Cancel startInstantReplay"
|
|
80
|
+
);
|
|
81
|
+
}, 60000 * 5);
|
|
82
|
+
|
|
83
|
+
ipc.of.dashcam.emit("start-instant-replay");
|
|
84
|
+
|
|
85
|
+
resolve({
|
|
86
|
+
started: true
|
|
66
87
|
});
|
|
67
88
|
});
|
|
68
89
|
};
|
|
@@ -92,7 +113,10 @@ class PersistantDashcamIPC {
|
|
|
92
113
|
}
|
|
93
114
|
|
|
94
115
|
emit(event, payload) {
|
|
95
|
-
if (!this.#isConnected)
|
|
116
|
+
if (!this.#isConnected) {
|
|
117
|
+
console.log(`Cannot emit event: ${event}. Disconnected!`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
96
120
|
persistantIPC.of.dashcam.emit(event, payload);
|
|
97
121
|
}
|
|
98
122
|
}
|
|
@@ -103,6 +127,7 @@ const getLogFilePath = (id) => {
|
|
|
103
127
|
|
|
104
128
|
module.exports = {
|
|
105
129
|
createReplay,
|
|
130
|
+
startInstantReplay,
|
|
106
131
|
getLogFilePath,
|
|
107
132
|
PersistantDashcamIPC,
|
|
108
133
|
};
|
package/package.json
CHANGED
package/recorder.js
CHANGED
|
@@ -6,12 +6,15 @@ const find = require("find-process");
|
|
|
6
6
|
class Recorder {
|
|
7
7
|
#ptyProcess = null;
|
|
8
8
|
#logFile = null;
|
|
9
|
+
#silent = false;
|
|
9
10
|
|
|
10
|
-
constructor(logFile) {
|
|
11
|
+
constructor(logFile, silent) {
|
|
11
12
|
// This way we don't run the recording script recursively, especially
|
|
12
13
|
// if it's inside bash/zsh configs
|
|
14
|
+
this.#silent = silent;
|
|
13
15
|
if (process.env.DASHCAM_TERMINAL_RECORDING) {
|
|
14
|
-
|
|
16
|
+
if (!this.#silent)
|
|
17
|
+
console.log("The current terminal is already being recorded");
|
|
15
18
|
process.exit(0);
|
|
16
19
|
}
|
|
17
20
|
this.#logFile = logFile;
|
|
@@ -27,8 +30,10 @@ class Recorder {
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
async start() {
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
if (!this.#silent) {
|
|
34
|
+
console.log("This session is being recorded by Dashcam");
|
|
35
|
+
console.log("Type `exit` to stop recording");
|
|
36
|
+
}
|
|
32
37
|
|
|
33
38
|
// TODO: Find a way to consistently get the current shell this is running from
|
|
34
39
|
// instead of using the default user shell (Maybe use parent processId to find
|