@lookit/record 4.1.0 → 5.0.0
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/README.md +82 -10
- package/dist/index.browser.js +201 -41
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +16 -16
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +200 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +83 -7
- package/dist/index.js +200 -40
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/consentVideo.spec.ts +9 -0
- package/src/consentVideo.ts +5 -1
- package/src/errors.ts +28 -0
- package/src/index.spec.ts +497 -54
- package/src/recorder.spec.ts +669 -109
- package/src/recorder.ts +184 -36
- package/src/start.ts +45 -5
- package/src/stop.ts +29 -12
- package/src/trial.ts +42 -16
- package/src/types.ts +21 -0
- package/src/utils.spec.ts +129 -0
- package/src/utils.ts +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookit/record",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Recording extensions and plugins for CHS studies.",
|
|
5
5
|
"homepage": "https://github.com/lookit/lookit-jspsych#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"typescript": "^5.6.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@lookit/data": "^0.
|
|
45
|
-
"@lookit/templates": "^
|
|
44
|
+
"@lookit/data": "^0.3.0",
|
|
45
|
+
"@lookit/templates": "^3.0.0",
|
|
46
46
|
"jspsych": "^8.0.3"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/consentVideo.spec.ts
CHANGED
|
@@ -8,6 +8,7 @@ import recordFeed from "../hbs/record-feed.hbs";
|
|
|
8
8
|
import { VideoConsentPlugin } from "./consentVideo";
|
|
9
9
|
import { ElementNotFoundError } from "./errors";
|
|
10
10
|
import Recorder from "./recorder";
|
|
11
|
+
import type { StopOptions, StopResult } from "./types";
|
|
11
12
|
|
|
12
13
|
declare const window: LookitWindow;
|
|
13
14
|
|
|
@@ -288,6 +289,14 @@ test("playButton", () => {
|
|
|
288
289
|
});
|
|
289
290
|
|
|
290
291
|
test("stopButton", async () => {
|
|
292
|
+
// We need to mock the return values for Recorder.stop because it is called in the stop button's callback function
|
|
293
|
+
(
|
|
294
|
+
Recorder.prototype.stop as jest.Mock<StopResult, [StopOptions?]>
|
|
295
|
+
).mockImplementation(() => ({
|
|
296
|
+
stopped: Promise.resolve("mock-url"),
|
|
297
|
+
uploaded: Promise.resolve(),
|
|
298
|
+
}));
|
|
299
|
+
|
|
291
300
|
const jsPsych = initJsPsych();
|
|
292
301
|
const plugin = new VideoConsentPlugin(jsPsych);
|
|
293
302
|
const display = document.createElement("div");
|
package/src/consentVideo.ts
CHANGED
|
@@ -305,7 +305,11 @@ export class VideoConsentPlugin implements JsPsychPlugin<Info> {
|
|
|
305
305
|
stop.addEventListener("click", async () => {
|
|
306
306
|
stop.disabled = true;
|
|
307
307
|
this.addMessage(display, this.uploadingMsg!);
|
|
308
|
-
|
|
308
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
309
|
+
const { stopped, uploaded } = this.recorder.stop({
|
|
310
|
+
maintain_container_size: true,
|
|
311
|
+
});
|
|
312
|
+
await stopped;
|
|
309
313
|
this.recordFeed(display);
|
|
310
314
|
this.getImg(display, "record-icon").style.visibility = "hidden";
|
|
311
315
|
this.addMessage(display, this.notRecordingMsg!);
|
package/src/errors.ts
CHANGED
|
@@ -154,6 +154,21 @@ export class S3UndefinedError extends Error {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Error thrown when a filename does not exist but is needed for upload or local
|
|
159
|
+
* download.
|
|
160
|
+
*/
|
|
161
|
+
export class NoFileNameError extends Error {
|
|
162
|
+
/**
|
|
163
|
+
* Provide information when the recorder attempts to upload/download the
|
|
164
|
+
* recording but there is no file name.
|
|
165
|
+
*/
|
|
166
|
+
public constructor() {
|
|
167
|
+
super("No filename found for recording.");
|
|
168
|
+
this.name = "NoFileNameError";
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
157
172
|
/**
|
|
158
173
|
* Error thrown when attempting to reset recorder, but its stream is still
|
|
159
174
|
* active.
|
|
@@ -209,3 +224,16 @@ export class ElementNotFoundError extends Error {
|
|
|
209
224
|
this.name = "ElementNotFoundError";
|
|
210
225
|
}
|
|
211
226
|
}
|
|
227
|
+
|
|
228
|
+
/** Thrown when the timeout duration is reached. */
|
|
229
|
+
export class TimeoutError extends Error {
|
|
230
|
+
/**
|
|
231
|
+
* String passed in with more info about the event that timed out.
|
|
232
|
+
*
|
|
233
|
+
* @param msg - Timeout error message string.
|
|
234
|
+
*/
|
|
235
|
+
public constructor(msg: string) {
|
|
236
|
+
super(`${msg}`);
|
|
237
|
+
this.name = "TimeoutError";
|
|
238
|
+
}
|
|
239
|
+
}
|