@lookit/record 4.1.0 → 6.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 +158 -15
- package/dist/index.browser.js +212 -43
- 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 +211 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +113 -9
- package/dist/index.js +211 -42
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/consentVideo.spec.ts +9 -0
- package/src/consentVideo.ts +24 -2
- 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": "6.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.1.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
|
@@ -12,7 +12,15 @@ const info = <const>{
|
|
|
12
12
|
name: "consent-video",
|
|
13
13
|
version,
|
|
14
14
|
parameters: {
|
|
15
|
-
template: {
|
|
15
|
+
template: {
|
|
16
|
+
type: ParameterType.SELECT,
|
|
17
|
+
options: [
|
|
18
|
+
"consent-template-5",
|
|
19
|
+
"consent-garden",
|
|
20
|
+
"consent-recording-only",
|
|
21
|
+
],
|
|
22
|
+
default: "consent-template-5",
|
|
23
|
+
},
|
|
16
24
|
locale: { type: ParameterType.STRING, default: "en-us" },
|
|
17
25
|
additional_video_privacy_statement: {
|
|
18
26
|
type: ParameterType.STRING,
|
|
@@ -58,6 +66,16 @@ const info = <const>{
|
|
|
58
66
|
prompt_only_adults: { type: ParameterType.BOOL, default: false },
|
|
59
67
|
consent_statement_text: { type: ParameterType.STRING, default: "" },
|
|
60
68
|
omit_injury_phrase: { type: ParameterType.BOOL, default: false },
|
|
69
|
+
/**
|
|
70
|
+
* This parameter is only relevant for the consent-recording-only template.
|
|
71
|
+
* If a different template is used, this parameter will be ignored. Whether
|
|
72
|
+
* or not the consent trial is the only data being collected on CHS (i.e.
|
|
73
|
+
* the study redirects to an external URL immediately after the consent
|
|
74
|
+
* trial). If false (the default), the consent template contains information
|
|
75
|
+
* about how CHS handles data/responses. If true, any statements about
|
|
76
|
+
* session data/responses are omitted.
|
|
77
|
+
*/
|
|
78
|
+
only_consent_on_chs: { type: ParameterType.BOOL, default: false },
|
|
61
79
|
},
|
|
62
80
|
data: {
|
|
63
81
|
chs_type: {
|
|
@@ -305,7 +323,11 @@ export class VideoConsentPlugin implements JsPsychPlugin<Info> {
|
|
|
305
323
|
stop.addEventListener("click", async () => {
|
|
306
324
|
stop.disabled = true;
|
|
307
325
|
this.addMessage(display, this.uploadingMsg!);
|
|
308
|
-
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
327
|
+
const { stopped, uploaded } = this.recorder.stop({
|
|
328
|
+
maintain_container_size: true,
|
|
329
|
+
});
|
|
330
|
+
await stopped;
|
|
309
331
|
this.recordFeed(display);
|
|
310
332
|
this.getImg(display, "record-icon").style.visibility = "hidden";
|
|
311
333
|
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
|
+
}
|